def frame(self): m = ConcreteModel() # Create a dummy parameter block m.params = Block() # Add necessary parameters to parameter block m.params.config = ConfigBlock() m.params.config.declare("state_bounds", ConfigValue(default={})) m.params.phase_list = Set(initialize=["a", "b"], ordered=True) m.params.component_list = Set(initialize=[1, 2, 3], ordered=True) # Create a dummy state block m.props = Block([1]) m.props[1].config = ConfigBlock() m.props[1].config.declare("defined_state", ConfigValue(default=False)) add_object_reference(m.props[1], "_params", m.params) # Add necessary variables that would be built by other methods m.props[1].dens_mol_phase = Var(m.params.phase_list, initialize=1) m.props[1].enth_mol_phase = Var(m.params.phase_list, initialize=1) define_state(m.props[1]) return m
def frame2(self): m = Block(concrete=True) m.params = Block() m.params.config = ConfigBlock() m.params.config.declare("inherent_reactions", ConfigBlock( implicit=True, implicit_domain=rxn_config)) add_object_reference(m, "state_ref", m) m.conc_mol_phase_comp = Var() m.act_phase_comp = Var() m.molality_phase_comp = Var() m.mole_frac_phase_comp = Var() m.mass_frac_phase_comp = Var() m.pressure_phase_comp = Var() m.log_conc_mol_phase_comp = Var() m.log_act_phase_comp = Var() m.log_molality_phase_comp = Var() m.log_mole_frac_phase_comp = Var() m.log_mass_frac_phase_comp = Var() m.log_pressure_phase_comp = Var() return m
def frame(): m = ConcreteModel() # Create a dummy parameter block m.params = Block() m.params.config = ConfigBlock(implicit=True) m.params.config.parameter_data = {"relative_permittivity_liq_comp": 101} m.meta_object = PropertyClassMetadata() m.meta_object.default_units["temperature"] = pyunits.K m.meta_object.default_units["mass"] = pyunits.kg m.meta_object.default_units["length"] = pyunits.m m.meta_object.default_units["time"] = pyunits.s m.meta_object.default_units["amount"] = pyunits.mol def get_metadata(self): return m.meta_object m.get_metadata = types.MethodType(get_metadata, m) m.params.get_metadata = types.MethodType(get_metadata, m.params) # Add necessary parameters to parameter block m.params.temperature_ref = Var(initialize=298.15, units=pyunits.K) m.params.pressure_ref = Var(initialize=1e5, units=pyunits.Pa) # Create a dummy state block m.props = Block([1]) add_object_reference(m.props[1], "params", m.params) m.props[1].temperature = Var(initialize=500, units=pyunits.K) m.props[1].pressure = Var(initialize=101325, units=pyunits.Pa) return m
def frame(): m = ConcreteModel() # Create a dummy parameter block m.params = Block() # Add necessary parameters to parameter block m.params.temperature_ref = Var(initialize=298.15) m.params.pressure_ref = Var(initialize=1e5) m.params.pressure_sat_comp_coeff = Var(["H2O"], ["A", "B", "C"]) m.params.cp_mol_ig_comp_coeff = Var( ["H2O"], ["A", "B", "C", "D", "E", "F", "G", "H"]) m.params.pressure_sat_comp_coeff["H2O", "A"].value = 8.55959 # +5 for unit conversion m.params.pressure_sat_comp_coeff["H2O", "B"].value = 643.748 m.params.pressure_sat_comp_coeff["H2O", "C"].value = -198.043 m.params.cp_mol_ig_comp_coeff["H2O", "A"].value = 30.09200 m.params.cp_mol_ig_comp_coeff["H2O", "B"].value = 6.832514 m.params.cp_mol_ig_comp_coeff["H2O", "C"].value = 6.793435 m.params.cp_mol_ig_comp_coeff["H2O", "D"].value = -2.534480 m.params.cp_mol_ig_comp_coeff["H2O", "E"].value = 0.082139 m.params.cp_mol_ig_comp_coeff["H2O", "F"].value = -250.8810 m.params.cp_mol_ig_comp_coeff["H2O", "G"].value = 223.3967 m.params.cp_mol_ig_comp_coeff["H2O", "H"].value = -241.8264 # Create a dummy state block m.props = Block([1]) add_object_reference(m.props[1], "_params", m.params) m.props[1].temperature = Var(initialize=500) m.props[1].pressure = Var(initialize=101325) return m
def frame(self): m = ConcreteModel() # Create a dummy parameter block m.params = DummyParameterBlock(default={ "components": {"c1": {}, "c2": {}, "c3": {}}, "phases": { "p1": {"equation_of_state": dummy_eos}, "p2": {"equation_of_state": dummy_eos}, "p3": {"equation_of_state": dummy_eos}}, "state_definition": modules[__name__], "pressure_ref": 1e5, "temperature_ref": 300, "state_bounds": {"flow_mol": (0, 100, 200), "temperature": (290, 345, 400), "pressure": (1e5, 3e5, 5e5), "enth_mol": (0, 500, 1000)}, "base_units": {"time": pyunits.s, "length": pyunits.m, "mass": pyunits.kg, "amount": pyunits.mol, "temperature": pyunits.K}}) # Create a dummy state block m.props = Block([1]) m.props[1].config = ConfigBlock() m.props[1].config.declare("defined_state", ConfigValue(default=True)) add_object_reference(m.props[1], "params", m.params) # Add necessary variables that would be built by other methods m.props[1].enth_mol_phase = Var(m.params.phase_list, initialize=1, units=pyunits.J/pyunits.mol) return m
def build(self): """ Callable method for Block construction """ super(GasPhaseThermoStateBlockData, self).build() # Object reference for molecular weight if needed by CV1D # Molecular weights add_object_reference(self, "mw_comp", self.config.parameters.mw_comp) """List the necessary state variable objects.""" self.flow_mol = Var(initialize=1.0, domain=Reals, doc='Component molar flowrate [mol/s]') self.mole_frac_comp = Var(self._params.component_list, domain=Reals, initialize=1 / len(self._params.component_list), doc='State component mole fractions [-]') self.pressure = Var(initialize=1.01325, domain=Reals, doc='State pressure [bar]') self.temperature = Var(initialize=298.15, domain=Reals, doc='State temperature [K]') # Create standard constraints # Sum mole fractions if not inlet block if self.config.defined_state is False: def sum_component_eqn(b): return 1e2 == 1e2 * sum(b.mole_frac_comp[j] for j in b._params.component_list) self.sum_component_eqn = Constraint(rule=sum_component_eqn)
def frame(): m = ConcreteModel() # Create a dummy parameter block m.params = Block() m.params.config = ConfigBlock() m.params.config.declare( "equation_of_state", ConfigValue(default={ "Liq": DummyEoS, "Vap": DummyEoS })) m.params.component_list = Set(initialize=["H2O"]) m.params.phase_list = Set(initialize=["Liq", "Vap"]) m.params.temperature_crit_comp = Var(["H2O"], initialize=647.3) # Create a dummy state block m.props = Block([1]) add_object_reference(m.props[1], "_params", m.params) m.props[1].temperature = Var(initialize=300) m.props[1].temperature_bubble = Var(initialize=300) m.props[1].temperature_dew = Var(initialize=300) m.props[1].fug_phase_comp = Var(m.params.phase_list, m.params.component_list, initialize=10) smooth_VLE.phase_equil(m.props[1]) return m
def frame(self): m = ConcreteModel() m.params = DummyParameterBlock(default={ "components": {"c1": {}, "c2": {}, "c3": {}}, "phases": { "a": {"equation_of_state": dummy_eos}, "b": {"equation_of_state": dummy_eos}}, "state_definition": modules[__name__], "pressure_ref": 1e5, "temperature_ref": 300, "state_bounds": { "flow_mol": (0, 0.1, 0.2, pyunits.kmol/pyunits.s), "temperature": (522, 621, 720, pyunits.degR), "pressure": (1, 3, 5, pyunits.bar), "enth_mol": (0, 0.5, 1, pyunits.kJ/pyunits.mol)}, "base_units": {"time": pyunits.s, "length": pyunits.m, "mass": pyunits.kg, "amount": pyunits.mol, "temperature": pyunits.K}}) # Create a dummy state block m.props = Block([1]) m.props[1].config = ConfigBlock() m.props[1].config.declare("defined_state", ConfigValue(default=False)) add_object_reference(m.props[1], "params", m.params) # Add necessary variables that would be built by other methods m.props[1].dens_mol_phase = Var(m.params.phase_list, initialize=1) m.props[1].enth_mol_phase = Var(m.params.phase_list, initialize=1) define_state(m.props[1]) return m
def test_mole_frac(self, caplog): m = ConcreteModel() caplog.set_level( idaeslog.WARNING, logger=("idaes.generic_models.properties.core.")) m.params = DummyParameterBlock(default={ "components": {"c1": {}, "c2": {}, "c3": {}}, "phases": { "p1": {"equation_of_state": dummy_eos}}, "state_definition": modules[__name__], "pressure_ref": 1e5, "temperature_ref": 300, "base_units": {"time": pyunits.s, "length": pyunits.m, "mass": pyunits.kg, "amount": pyunits.mol, "temperature": pyunits.K}, "state_bounds": {"mole_frac_comp": (None, None, None)}}) # Create a dummy state block m.props = Block([1]) m.props[1].config = ConfigBlock() m.props[1].config.declare("defined_state", ConfigValue(default=False)) add_object_reference(m.props[1], "params", m.params) with pytest.raises( ConfigurationError, match="props\[1\] - found unexpected state_bounds key " "mole_frac_comp. Please ensure bounds are provided only for " "expected state variables and that you have typed the " "variable names correctly."): define_state(m.props[1])
def test_power_law_rate_no_order(): m = ConcreteModel() # # Add a test thermo package for validation m.pparams = PhysicalParameterTestBlock() m.thermo = m.pparams.build_state_block([1]) m.rparams = GenericReactionParameterBlock( default={ "property_package": m.pparams, "base_units": { "time": pyunits.s, "mass": pyunits.kg, "amount": pyunits.mol, "length": pyunits.m, "temperature": pyunits.K }, "rate_reactions": { "r1": { "stoichiometry": { ("p1", "c1"): -1, ("p1", "c2"): 2 }, "rate_form": power_law_rate, "concentration_form": ConcentrationForm.moleFraction } } }) # Create a dummy state block m.rxn = Block([1]) add_object_reference(m.rxn[1], "params", m.rparams) add_object_reference(m.rxn[1], "state_ref", m.thermo[1]) m.rxn[1].k_rxn = Var(["r1"], initialize=1) power_law_rate.build_parameters(m.rparams.reaction_r1, m.rparams.config.rate_reactions["r1"]) # Check parameter construction assert isinstance(m.rparams.reaction_r1.reaction_order, Var) assert len(m.rparams.reaction_r1.reaction_order) == 4 for i, v in m.rparams.reaction_r1.reaction_order.items(): try: stoic = m.rparams.config.rate_reactions.r1.stoichiometry[i] except KeyError: stoic = 0 if stoic < 1: assert v.value == -stoic else: assert v.value == 0 # Check reaction form rform = power_law_rate.return_expression(m.rxn[1], m.rparams.reaction_r1, "r1", 300) assert str(rform) == str(m.rxn[1].k_rxn["r1"] * m.thermo[1].mole_frac_phase_comp["p1", "c1"]** m.rparams.reaction_r1.reaction_order["p1", "c1"])
def build(self): """ Callable method for Block construction """ super(HDAReactionBlockData, self).build() # Heat of reaction - no _ref as this is the actual property add_object_reference(self, "dh_rxn", self.config.parameters.dh_rxn)
def test_add_object_reference(): m = ConcreteModel() m.s = Set(initialize=[1, 2, 3]) add_object_reference(m, "test_ref", m.s) assert hasattr(m, "test_ref") assert m.test_ref == m.s
def frame(): m = ConcreteModel() # Create a dummy parameter block m.params = Block() m.params.config = ConfigBlock(implicit=True) m.params.config.parameter_data = { "cp_mol_ig_comp_coeff": { 'A': 3.224e1, 'B': 1.924e-3, 'C': 1.055e-5, 'D': -3.596e-9 }, "enth_mol_form_vap_comp_ref": -241.83e3, "entr_mol_form_vap_comp_ref": 188.84, "pressure_sat_comp_coeff": { 'A': -7.76451, 'B': 1.45838, 'C': -2.77580, 'D': -1.23303 } } m.params.config.include_enthalpy_of_formation = True # Also need to dummy configblock on the model for the test m.config = ConfigBlock(implicit=True) m.config.include_enthalpy_of_formation = True m.meta_object = PropertyClassMetadata() m.meta_object.default_units["temperature"] = pyunits.K m.meta_object.default_units["mass"] = pyunits.kg m.meta_object.default_units["length"] = pyunits.m m.meta_object.default_units["time"] = pyunits.s m.meta_object.default_units["amount"] = pyunits.mol def get_metadata(self): return m.meta_object m.get_metadata = types.MethodType(get_metadata, m) m.params.get_metadata = types.MethodType(get_metadata, m.params) # Add necessary parameters to parameter block m.params.temperature_ref = Var(initialize=273.15, units=pyunits.K) m.params.pressure_ref = Var(initialize=1e5, units=pyunits.Pa) m.params.temperature_crit = Var(initialize=647.3, units=pyunits.K) m.params.pressure_crit = Var(initialize=221.2e5, units=pyunits.Pa) # Create a dummy state block m.props = Block([1]) add_object_reference(m.props[1], "params", m.params) m.props[1].temperature = Var(initialize=298.15, units=pyunits.K) m.props[1].pressure = Var(initialize=101325, units=pyunits.Pa) return m
def frame(): m = ConcreteModel() # Create a dummy parameter block m.params = Block() m.params.config = ConfigBlock(implicit=True) m.params.config.parameter_data = { "cp_mol_ig_comp_coeff": { 'a0': 4.395, 'a1': -4.186e-3, 'a2': 1.405e-5, 'a3': -1.564e-8, 'a4': 0.632e-11 }, "enth_mol_form_vap_comp_ref": -241.81e3, "entr_mol_form_vap_comp_ref": 188.84, "pressure_sat_comp_coeff": { 'A': 5.11564, 'B': 1687.537, 'C': 230.14 } } m.params.config.include_enthalpy_of_formation = True # Also need to dummy configblock on the model for the test m.config = ConfigBlock(implicit=True) m.config.include_enthalpy_of_formation = True m.meta_object = PropertyClassMetadata() m.meta_object.default_units["temperature"] = pyunits.K m.meta_object.default_units["mass"] = pyunits.kg m.meta_object.default_units["length"] = pyunits.m m.meta_object.default_units["time"] = pyunits.s m.meta_object.default_units["amount"] = pyunits.mol def get_metadata(self): return m.meta_object m.get_metadata = types.MethodType(get_metadata, m) m.params.get_metadata = types.MethodType(get_metadata, m.params) # Add necessary parameters to parameter block m.params.temperature_ref = Var(initialize=273.15, units=pyunits.K) m.params.pressure_ref = Var(initialize=1e5, units=pyunits.Pa) m.params.temperature_crit = Var(initialize=647.15, units=pyunits.K) m.params.pressure_crit = Var(initialize=220.64e5, units=pyunits.Pa) # Create a dummy state block m.props = Block([1]) add_object_reference(m.props[1], "params", m.params) m.props[1].temperature = Var(initialize=298.15, units=pyunits.K) m.props[1].pressure = Var(initialize=101325, units=pyunits.Pa) return m
def frame(): m = ConcreteModel() # Create a dummy parameter block m.params = Block() m.params.config = ConfigBlock(implicit=True) m.params.config.parameter_data = { "cp_mol_ig_comp_coeff": { 'A': 7.701, 'B': 4.595e-4, 'C': 2.521e-6, 'D': -0.859e-9 }, "enth_mol_form_vap_comp_ref": (-57.797e3, pyunits.cal / pyunits.mol), "entr_mol_form_vap_comp_ref": (45.13, pyunits.cal / pyunits.mol / pyunits.K), "pressure_sat_comp_coeff": { 'A': 18.3036, 'B': 3816.44, 'C': -46.13 } } m.params.config.include_enthalpy_of_formation = True # Also need to dummy configblock on the model for the test m.config = ConfigBlock(implicit=True) m.config.include_enthalpy_of_formation = True m.meta_object = PropertyClassMetadata() m.meta_object.default_units["temperature"] = pyunits.K m.meta_object.default_units["mass"] = pyunits.kg m.meta_object.default_units["length"] = pyunits.m m.meta_object.default_units["time"] = pyunits.s m.meta_object.default_units["amount"] = pyunits.mol def get_metadata(self): return m.meta_object m.get_metadata = types.MethodType(get_metadata, m) m.params.get_metadata = types.MethodType(get_metadata, m.params) # Add necessary parameters to parameter block m.params.temperature_ref = Var(initialize=273.15, units=pyunits.K) m.params.pressure_ref = Var(initialize=1e5, units=pyunits.Pa) m.params.temperature_crit = Var(initialize=647.3, units=pyunits.K) m.params.pressure_crit = Var(initialize=217.6e5, units=pyunits.Pa) # Create a dummy state block m.props = Block([1]) add_object_reference(m.props[1], "params", m.params) m.props[1].temperature = Var(initialize=298.15, units=pyunits.K) m.props[1].pressure = Var(initialize=101325, units=pyunits.Pa) return m
def build(self): """ Callable method for Block construction """ super().build() # Create references to state vars # Concentration add_object_reference(self, "conc_mass_comp_ref", self.state_ref.conc_mass_comp)
def frame(): m = ConcreteModel() # Create a dummy parameter block m.params = Block() m.params.config = ConfigBlock(implicit=True) m.params.config.parameter_data = { "dens_mol_liq_comp_coeff": (55.2046332734557, pyunits.kmol / pyunits.m**3), "cp_mol_liq_comp_coeff": (75704.2953333398, pyunits.J / pyunits.kmol / pyunits.K), "enth_mol_form_liq_comp_ref": (-285.83, pyunits.kJ / pyunits.mol), "entr_mol_form_liq_comp_ref": (69.95, pyunits.J / pyunits.K / pyunits.mol), "cp_mol_ig_comp_coeff": (29114.850, pyunits.J / pyunits.kmol / pyunits.K), "enth_mol_form_ig_comp_ref": (0.0, pyunits.kJ / pyunits.mol), "entr_mol_form_ig_comp_ref": (0.0, pyunits.J / pyunits.K / pyunits.mol), "dens_mol_sol_comp_coeff": (100, pyunits.kmol / pyunits.m**3), "cp_mol_sol_comp_coeff": (100000, pyunits.J / pyunits.kmol / pyunits.K), "enth_mol_form_sol_comp_ref": (-300, pyunits.kJ / pyunits.mol), "entr_mol_form_sol_comp_ref": (50, pyunits.J / pyunits.K / pyunits.mol) } m.params.config.include_enthalpy_of_formation = True # Also need to dummy configblock on the model for the test m.config = ConfigBlock(implicit=True) m.config.include_enthalpy_of_formation = True m.meta_object = PropertyClassMetadata() m.meta_object.default_units["temperature"] = pyunits.K m.meta_object.default_units["mass"] = pyunits.kg m.meta_object.default_units["length"] = pyunits.m m.meta_object.default_units["time"] = pyunits.s m.meta_object.default_units["amount"] = pyunits.mol def get_metadata(self): return m.meta_object m.get_metadata = types.MethodType(get_metadata, m) m.params.get_metadata = types.MethodType(get_metadata, m.params) # Add necessary parameters to parameter block m.params.temperature_ref = Var(initialize=300, units=pyunits.K) # Create a dummy state block m.props = Block([1]) add_object_reference(m.props[1], "params", m.params) m.props[1].temperature = Var(initialize=300, units=pyunits.K) return m
def model(): m = ConcreteModel() # # Add a test thermo package for validation m.pparams = PhysicalParameterTestBlock() m.thermo = m.pparams.build_state_block([1]) # Create a dummy reaction parameter block m.rparams = Block() m.rparams.config = ConfigBlock(implicit=True) m.rparams.config.property_package = m.pparams m.rparams.config.reaction_basis = MaterialFlowBasis.molar m.rparams.config.rate_reactions = ConfigBlock(implicit=True) m.rparams.config.rate_reactions.r1 = ConfigBlock(implicit=True) m.rparams.config.rate_reactions.r1 = { "stoichiometry": { ("p1", "c1"): -1, ("p1", "c2"): 2 }, "parameter_data": {} } m.rparams.config.equilibrium_reactions = ConfigBlock(implicit=True) m.rparams.config.equilibrium_reactions.e1 = ConfigBlock(implicit=True) m.rparams.config.equilibrium_reactions.e1 = { "stoichiometry": { ("p1", "c1"): -1, ("p1", "c2"): 2 }, "parameter_data": {} } m.rparams.reaction_r1 = Block() m.rparams.reaction_e1 = Block() m.meta_object = PropertyClassMetadata() m.meta_object.default_units["temperature"] = pyunits.K m.meta_object.default_units["mass"] = pyunits.kg m.meta_object.default_units["length"] = pyunits.m m.meta_object.default_units["time"] = pyunits.s m.meta_object.default_units["amount"] = pyunits.mol def get_metadata(self): return m.meta_object m.rparams.get_metadata = types.MethodType(get_metadata, m.rparams) # Create a dummy state block m.rxn = Block([1]) add_object_reference(m.rxn[1], "params", m.rparams) add_object_reference(m.rxn[1], "state_ref", m.thermo[1]) return m
def frame(): m = ConcreteModel() # Create a dummy parameter block m.params = Block() m.params.config = ConfigBlock(implicit=True) m.params.config.parameter_data = { "dens_mol_liq_comp_coeff": { 'eqn_type': 1, '1': 5.459, '2': 0.30542, '3': 647.13, '4': 0.081 }, "cp_mol_liq_comp_coeff": { '1': 2.7637e+05, '2': -2.0901e+03, '3': 8.1250e+00, '4': -1.4116e-2, '5': 9.3701e-06 }, "enth_mol_form_liq_comp_ref": -285.83e3, "entr_mol_form_liq_comp_ref": 69.95 } m.params.config.include_enthalpy_of_formation = True # Also need to dummy configblock on the model for the test m.config = ConfigBlock(implicit=True) m.config.include_enthalpy_of_formation = True m.meta_object = PropertyClassMetadata() m.meta_object.default_units["temperature"] = pyunits.K m.meta_object.default_units["mass"] = pyunits.kg m.meta_object.default_units["length"] = pyunits.m m.meta_object.default_units["time"] = pyunits.s m.meta_object.default_units["amount"] = pyunits.mol def get_metadata(self): return m.meta_object m.get_metadata = types.MethodType(get_metadata, m) m.params.get_metadata = types.MethodType(get_metadata, m.params) # Add necessary parameters to parameter block m.params.temperature_ref = Var(initialize=273.16, units=pyunits.K) # Create a dummy state block m.props = Block([1]) add_object_reference(m.props[1], "params", m.params) m.props[1].temperature = Var(initialize=273.16, units=pyunits.K) return m
def build(self): """ Callable method for Block construction """ super(SolidPhaseThermoStateBlockData, self).build() # Object reference for molecular weight if needed by CV1D # Molecular weights add_object_reference(self, "mw_comp", self.config.parameters.mw_comp) self._make_state_vars()
def build(self): """ General build method for StateBlockDatas. Args: None Returns: None """ super(StateBlockData, self).build() add_object_reference(self, "_params", self.config.parameters)
def frame(): m = ConcreteModel() # Create a dummy parameter block m.params = Block() m.params.config = ConfigBlock(implicit=True) m.params.config.parameter_data = { "cp_mol_ig_comp_coeff": { 'A': 30.09200, # parameters for water 'B': 6.832514, 'C': 6.793435, 'D': -2.534480, 'E': 0.082139, 'F': -250.8810, 'G': 223.3967, 'H': -241.8264 }, "pressure_sat_comp_coeff": { 'A': 3.55959, # units bar, K 'B': 643.748, 'C': -198.043 } } m.params.config.include_enthalpy_of_formation = True m.meta_object = PropertyClassMetadata() m.meta_object.default_units["temperature"] = pyunits.K m.meta_object.default_units["mass"] = pyunits.kg m.meta_object.default_units["length"] = pyunits.m m.meta_object.default_units["time"] = pyunits.s m.meta_object.default_units["amount"] = pyunits.mol def get_metadata(self): return m.meta_object m.get_metadata = types.MethodType(get_metadata, m) m.params.get_metadata = types.MethodType(get_metadata, m.params) # Add necessary parameters to parameter block m.params.temperature_ref = Var(initialize=298.15, units=pyunits.K) m.params.pressure_ref = Var(initialize=1e5, units=pyunits.Pa) # Create a dummy state block m.props = Block([1]) add_object_reference(m.props[1], "params", m.params) m.props[1].temperature = Var(initialize=500, units=pyunits.K) m.props[1].pressure = Var(initialize=101325, units=pyunits.Pa) return m
def set_geometry(self): """ Define the geometry of the unit as necessary, and link to control volume Args: None Returns: None """ # For this case, just create a reference to control volume if self.config.has_holdup is True: add_object_reference(self, "volume", self.control_volume.volume)
def model(self): m = ConcreteModel() m.frame = ZeroOrderCosting() # Dummy a unit model to use with _get_tech_parameters m.dummy_unit = Block(concrete=True) m.dummy_unit.config = ConfigBlock() m.dummy_unit.config.declare("flowsheet_costing_block", ConfigValue()) m.dummy_unit.config.flowsheet_costing_block = m.frame add_object_reference(m.dummy_unit, "unit_model", m.dummy_unit) m.dummy_unit._tech_type = "test_tech" return m
def build(self): """ General build method for PropertyBlockDatas. Inheriting models should call super().build. Args: None Returns: None """ super(ReactionBlockDataBase, self).build() add_object_reference(self, "_params", self.config.parameters) self._validate_state_block()
def build(self): """ General build method for StateBlockDatas. Args: None Returns: None """ super(StateBlockData, self).build() add_object_reference(self, "_params", self.config.parameters) # TODO: Deprecate this at some point # Backwards compatability check for old-style property packages self._params._validate_parameter_block()
def build(self): """ Building model Args: None Returns: None """ # Call UnitModel.build to setup dynamics super(HeaterData, self).build() # Add Control Volume _make_heater_control_volume(self, "control_volume", self.config) # Add Ports self.add_inlet_port() self.add_outlet_port() # Add a convienient reference to heat duty. add_object_reference(self, "heat_duty", self.control_volume.heat)
def test_mole_frac(self, caplog): m = ConcreteModel() caplog.set_level(idaeslog.WARNING, logger=("idaes.generic_models.properties.core.")) m.params = DummyParameterBlock( default={ "components": { "c1": {}, "c2": {}, "c3": {} }, "phases": { "p1": { "equation_of_state": dummy_eos } }, "state_definition": modules[__name__], "pressure_ref": 1e5, "temperature_ref": 300, "base_units": { "time": pyunits.s, "length": pyunits.m, "mass": pyunits.kg, "amount": pyunits.mol, "temperature": pyunits.K }, "state_bounds": { "mole_frac_comp": (None, None, None) } }) # Create a dummy state block m.props = Block([1]) m.props[1].config = ConfigBlock() m.props[1].config.declare("defined_state", ConfigValue(default=False)) add_object_reference(m.props[1], "params", m.params) m.props[1].enth_mol_phase = {"p1": 1} define_state(m.props[1]) assert ("props[1] - found state_bounds argument for mole_frac_comp." " Mole fraction bounds are set automatically and " "this argument will be ignored." in caplog.text)
def build(self): """ Begin building model (pre-DAE transformation). Args: None Returns: None """ # Call UnitModel.build to setup dynamics super(StoichiometricReactorData, self).build() # Build Control Volume self.control_volume = ControlVolume0DBlock( default={ "dynamic": self.config.dynamic, "property_package": self.config.property_package, "property_package_args": self.config.property_package_args, "reaction_package": self.config.reaction_package, "reaction_package_args": self.config.reaction_package_args }) self.control_volume.add_state_blocks(has_phase_equilibrium=False) self.control_volume.add_reaction_blocks(has_equilibrium=False) self.control_volume.add_material_balances( balance_type=self.config.material_balance_type, has_rate_reactions=True) self.control_volume.add_energy_balances( balance_type=self.config.energy_balance_type, has_heat_transfer=self.config.has_heat_transfer, has_heat_of_reaction=self.config.has_heat_of_reaction) self.control_volume.add_momentum_balances( balance_type=self.config.momentum_balance_type, has_pressure_change=self.config.has_pressure_change) # Add Ports self.add_inlet_port() self.add_outlet_port() # Add performance equations add_object_reference(self, "rate_reaction_idx_ref", self.config.reaction_package.rate_reaction_idx) add_object_reference(self, "rate_reaction_extent", self.control_volume.rate_reaction_extent) # Set references to balance terms at unit level if (self.config.has_heat_transfer is True and self.config.energy_balance_type != 'none'): add_object_reference(self, "heat_duty", self.control_volume.heat) if (self.config.has_pressure_change is True and self.config.momentum_balance_type != 'none'): add_object_reference(self, "deltaP", self.control_volume.deltaP)
def frame(self): m = ConcreteModel() # Create a dummy parameter block m.params = Block() # Add necessary parameters to parameter block m.params.config = ConfigBlock() m.params.config.declare("dummy_option", ConfigValue(default=None)) # Create a dummy state block m.props = Block([1]) m.props[1].config = ConfigBlock() add_object_reference(m.props[1], "_params", m.params) m.props[1].dummy_response = "foo" return m