Skip to content
This repository has been archived by the owner on Apr 6, 2023. It is now read-only.

Commit

Permalink
Fix remaining uses of legacy default-kwarg ProcessBlock API after IDA…
Browse files Browse the repository at this point in the history
…ES/idaes-pse#959 (#139)

* Apply fix to .ipynb files

* Apply fix to .py files
  • Loading branch information
lbianchi-lbl authored Sep 16, 2022
1 parent 4dff3f9 commit 6b8d461
Show file tree
Hide file tree
Showing 10 changed files with 1,273 additions and 7,782 deletions.
44 changes: 6 additions & 38 deletions src/Examples/DAE/pid.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,47 +94,15 @@ def create_model(
time_set = [0, 3]

m = pyo.ConcreteModel(name=model_name)
m.fs = FlowsheetBlock(default=fs_cfg)
m.fs = FlowsheetBlock(**fs_cfg)
# Create a property parameter block
m.fs.prop_water = iapws95.Iapws95ParameterBlock(
default={"phase_presentation": iapws95.PhaseType.LG}
)
m.fs.prop_water = iapws95.Iapws95ParameterBlock(phase_presentation=iapws95.PhaseType.LG)
# Create the valve and tank models
m.fs.valve_1 = Valve(
default={
"dynamic": False,
"has_holdup": False,
"pressure_flow_callback": _valve_pressure_flow_cb,
"material_balance_type": MaterialBalanceType.componentTotal,
"property_package": m.fs.prop_water,
}
)
m.fs.tank = Heater(
default={
"has_holdup": True,
"material_balance_type": MaterialBalanceType.componentTotal,
"property_package": m.fs.prop_water,
}
)
m.fs.valve_2 = Valve(
default={
"dynamic": False,
"has_holdup": False,
"pressure_flow_callback": _valve_pressure_flow_cb,
"material_balance_type": MaterialBalanceType.componentTotal,
"property_package": m.fs.prop_water,
}
)
m.fs.valve_1 = Valve(dynamic=False, has_holdup=False, pressure_flow_callback=_valve_pressure_flow_cb, material_balance_type=MaterialBalanceType.componentTotal, property_package=m.fs.prop_water)
m.fs.tank = Heater(has_holdup=True, material_balance_type=MaterialBalanceType.componentTotal, property_package=m.fs.prop_water)
m.fs.valve_2 = Valve(dynamic=False, has_holdup=False, pressure_flow_callback=_valve_pressure_flow_cb, material_balance_type=MaterialBalanceType.componentTotal, property_package=m.fs.prop_water)
# Add a controller
m.fs.ctrl = PIDController(
default={
"process_var": m.fs.tank.control_volume.properties_out[:].pressure,
"manipulated_var": m.fs.valve_1.valve_opening,
"calculate_initial_integral": calc_integ,
"mv_bound_type": ControllerMVBoundType.SMOOTH_BOUND,
"type": ControllerType.PI, # rather use PI, but testing all terms
}
)
m.fs.ctrl = PIDController(process_var=m.fs.tank.control_volume.properties_out[:].pressure, manipulated_var=m.fs.valve_1.valve_opening, calculate_initial_integral=calc_integ, mv_bound_type=ControllerMVBoundType.SMOOTH_BOUND, type=ControllerType.PI)
# The control volume block doesn't assume the two phases are in equilibrium
# by default, so I'll make that assumption here, I don't actually expect
# liquid to form but who knows. The phase_fraction in the control volume is
Expand Down
6,464 changes: 9 additions & 6,455 deletions src/Examples/Flowsheets/ngcc/ngcc_soec.ipynb

Large diffs are not rendered by default.

16 changes: 2 additions & 14 deletions src/Examples/Flowsheets/ngcc/ngcc_soec.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,20 +44,8 @@ def build(self):
self._add_tags()

def _add_flowsheets(self):
self.ngcc = ngcc.NgccFlowsheet(
default={
"dynamic": self.config.dynamic,
"time": self.time,
"time_units": self.config.time_units,
}
)
self.soec = soec.SoecFlowsheet(
default={
"dynamic": self.config.dynamic,
"time": self.time,
"time_units": self.config.time_units,
}
)
self.ngcc = ngcc.NgccFlowsheet(dynamic=self.config.dynamic, time=self.time, time_units=self.config.time_units)
self.soec = soec.SoecFlowsheet(dynamic=self.config.dynamic, time=self.time, time_units=self.config.time_units)

def _add_arcs(self):
self.c01 = Arc(
Expand Down
2 changes: 1 addition & 1 deletion src/Examples/Flowsheets/ngcc/ngcc_soec_costing.py
Original file line number Diff line number Diff line change
Expand Up @@ -782,7 +782,7 @@ def heat_exchanger_costs(b):

# # create the ngcc model
# m = pyo.ConcreteModel()
# m.fs = ngcc_soec.NgccSoecFlowsheet(default={"dynamic": False})
# m.fs = ngcc_soec.NgccSoecFlowsheet(dynamic=False)
# iscale.calculate_scaling_factors(m)
# m.fs.initialize(
# load_from="ngcc_soec_init.json.gz",
Expand Down
Loading

0 comments on commit 6b8d461

Please sign in to comment.