def model(self): m = ConcreteModel() m.fs = FlowsheetBlock(default={"dynamic": False}) m.fs.water_props = WaterParameterBlock( default={"solute_list": ["A", "B", "C"]}) m.fs.unit = DerivedDISO(default={"property_package": m.fs.water_props}) m.fs.unit.inlet1.flow_mass_comp[0, "H2O"].fix(1000) m.fs.unit.inlet1.flow_mass_comp[0, "A"].fix(10) m.fs.unit.inlet1.flow_mass_comp[0, "B"].fix(20) m.fs.unit.inlet1.flow_mass_comp[0, "C"].fix(30) m.fs.unit.inlet2.flow_mass_comp[0, "H2O"].fix(1000) m.fs.unit.inlet2.flow_mass_comp[0, "A"].fix(10) m.fs.unit.inlet2.flow_mass_comp[0, "B"].fix(20) m.fs.unit.inlet2.flow_mass_comp[0, "C"].fix(30) m.fs.unit.recovery_frac_mass_H2O.fix(0) m.fs.unit.removal_frac_mass_solute[0, "A"].fix(0.1) m.fs.unit.removal_frac_mass_solute[0, "B"].fix(0.2) m.fs.unit.removal_frac_mass_solute[0, "C"].fix(0.3) return m
def test_all_sources(source): m = ConcreteModel() m.db = Database() m.fs = FlowsheetBlock(default={"dynamic": False}) m.fs.params = WaterParameterBlock(default={ "database": m.db, "water_source": source }) m.fs.unit = FeedZO(default={"property_package": m.fs.params}) for j in m.fs.params.solute_set: assert j in source_data[source]["solutes"] m.fs.unit.load_feed_data_from_database() assert pytest.approx(source_data[source]["default_flow"]["value"], rel=1e-12) == value(m.fs.unit.flow_vol[0]) assert m.fs.unit.flow_vol[0].fixed for j, v in source_data[source]["solutes"].items(): assert pytest.approx(v["value"], rel=1e-12) == value(m.fs.unit.conc_mass_comp[0, j]) assert m.fs.unit.conc_mass_comp[0, j].fixed assert j in m.db.component_list.keys()
def test_missing_key_reactant(self): m = ConcreteModel() m.db = Database(dbpath=local_path) # Load data from YAML so that we can modify it m.db._get_technology("test_sidor_data") m.db._cached_files["test_sidor_data"]["default"]["reactions"][ "Rxn3"] = {} R3 = m.db._cached_files["test_sidor_data"]["default"]["reactions"][ "Rxn3"] R3["conversion"] = 0.5 m.fs = FlowsheetBlock(default={"dynamic": False}) m.fs.water_props = WaterParameterBlock( default={"solute_list": ["A", "B", "C"]}) with pytest.raises( KeyError, match="fs.unit - database provided does not " "contain an entry for key_reactant for reaction Rxn3."): m.fs.unit = DerivedSIDOR(default={ "property_package": m.fs.water_props, "database": m.db })
def test_invlaid_key_reactant(self): m = ConcreteModel() m.db = Database(dbpath=local_path) # Load data from YAML so that we can modify it m.db._get_technology("test_sidor_data") m.db._cached_files["test_sidor_data"]["default"]["reactions"][ "Rxn3"] = {} R3 = m.db._cached_files["test_sidor_data"]["default"]["reactions"][ "Rxn3"] R3["conversion"] = 0.5 R3["key_reactant"] = "foo" m.fs = FlowsheetBlock(default={"dynamic": False}) m.fs.water_props = WaterParameterBlock( default={"solute_list": ["A", "B", "C"]}) with pytest.raises( ValueError, match="fs.unit - key_reactant foo for reaction Rxn3 " "is not in the component list used by the assigned property " "package."): m.fs.unit = DerivedSIDOR(default={ "property_package": m.fs.water_props, "database": m.db })
def test_ratio_and_order(self): m = ConcreteModel() m.db = Database(dbpath=local_path) # Load data from YAML so that we can modify it m.db._get_technology("test_sidor_data") m.db._cached_files["test_sidor_data"]["default"]["reactions"][ "Rxn3"] = {} R3 = m.db._cached_files["test_sidor_data"]["default"]["reactions"][ "Rxn3"] R3["conversion"] = 0.5 R3["key_reactant"] = "A" R3["stoichiometry"] = {"A": {"order": 1, "conversion_ratio": 1}} m.fs = FlowsheetBlock(default={"dynamic": False}) m.fs.water_props = WaterParameterBlock( default={"solute_list": ["A", "B", "C"]}) with pytest.raises( RuntimeError, match="fs.unit - database provides entries for both " "conversion_ratio and reaction order in reaction Rxn3. " "Please provide only one or the other."): m.fs.unit = DerivedSIDOR(default={ "property_package": m.fs.water_props, "database": m.db })
def test_order_no_key_order(self): m = ConcreteModel() m.db = Database(dbpath=local_path) # Load data from YAML so that we can modify it m.db._get_technology("test_sidor_data") m.db._cached_files["test_sidor_data"]["default"]["reactions"][ "Rxn3"] = {} R3 = m.db._cached_files["test_sidor_data"]["default"]["reactions"][ "Rxn3"] R3["conversion"] = 0.5 R3["key_reactant"] = "B" R3["stoichiometry"] = {"A": {"order": 1, "molecular_weight": 1}} m.fs = FlowsheetBlock(default={"dynamic": False}) m.fs.water_props = WaterParameterBlock( default={"solute_list": ["A", "B", "C"]}) with pytest.raises(KeyError, match="fs.unit - database provided does not " "contain an entry for order w.r.t. species " "B in reaction Rxn3."): m.fs.unit = DerivedSIDOR(default={ "property_package": m.fs.water_props, "database": m.db })
def model(): m = ConcreteModel() m.fs = FlowsheetBlock(default={"dynamic": False}) m.fs.water_props = WaterParameterBlock( default={"solute_list": ["A", "B", "C"]}) return m
def test_no_solute_list_defined(): m = ConcreteModel() m.fs = FlowsheetBlock(default={"dynamic": False}) with pytest.raises(ConfigurationError, match="water_props no solute_list or database was " "defined. Users must provide at least one of these " "arguments."): m.fs.water_props = WaterParameterBlock()
def test_solute_list_from_database(): m = ConcreteModel() db = Database() m.fs = FlowsheetBlock(default={"dynamic": False}) m.fs.water_props = WaterParameterBlock(default={"database": db}) assert m.fs.water_props.solute_set == db.get_solute_set()
def model(self): m = ConcreteModel() m.fs = FlowsheetBlock(default={"dynamic": False}) m.fs.params = WaterParameterBlock(default={"solute_list": ["A", "B", "C"]}) m.fs.params.del_component(m.fs.params.phase_list) m.fs.params.del_component(m.fs.params.solvent_set) m.fs.params.del_component(m.fs.params.solute_set) m.fs.params.del_component(m.fs.params.component_list) return m
def model(self): m = ConcreteModel() m.fs = FlowsheetBlock(default={"dynamic": False}) m.fs.water_props = WaterParameterBlock(default={"solute_list": ["A", "B", "C"]}) m.fs.unit = DerivedZO(default={"property_package": m.fs.water_props}) constant_intensity(m.fs.unit) m.fs.unit.energy_electric_flow_vol_inlet.fix(10) return m
def test_private_attributes(): m = ConcreteModel() m.fs = FlowsheetBlock(default={"dynamic": False}) m.fs.params = WaterParameterBlock(default={"solute_list": ["A", "B", "C"]}) m.fs.unit = DerivedZOBase(default={"property_package": m.fs.params}) assert m.fs.unit._tech_type is None assert m.fs.unit._has_recovery_removal is False assert m.fs.unit._fixed_perf_vars == [] assert m.fs.unit._initialize is None assert m.fs.unit._scaling is None assert m.fs.unit._get_Q is None assert m.fs.unit._stream_table_dict == {} assert m.fs.unit._perf_var_dict == {}
def model(self): m = ConcreteModel() m.db = Database() m.fs = FlowsheetBlock(default={"dynamic": False}) m.fs.water_props = WaterParameterBlock(default={"solute_list": ["cod"]}) m.fs.unit = GasSpargedMembraneZO( default={"property_package": m.fs.water_props, "database": m.db} ) m.fs.unit.inlet.flow_mass_comp[0, "H2O"].fix(1000) m.fs.unit.inlet.flow_mass_comp[0, "cod"].fix(1) return m
def model(self): m = ConcreteModel() m.fs = FlowsheetBlock(default={"dynamic": False}) m.fs.water_props = WaterParameterBlock(default={"solute_list": ["A", "B", "C"]}) m.fs.unit = DerivedZO(default={"property_package": m.fs.water_props}) m.fs.unit.flow = Param( m.fs.time, initialize=1, units=pyunits.gallon / pyunits.minute ) pump_electricity(m.fs.unit, m.fs.unit.flow) return m
def model(self): m = ConcreteModel() m.fs = FlowsheetBlock(default={"dynamic": False}) m.fs.water_props = WaterParameterBlock( default={"solute_list": ["A", "B", "C"]}) m.fs.unit = DerivedPT(default={"property_package": m.fs.water_props}) m.fs.unit.inlet.flow_mass_comp[0, "H2O"].fix(1000) m.fs.unit.inlet.flow_mass_comp[0, "A"].fix(10) m.fs.unit.inlet.flow_mass_comp[0, "B"].fix(20) m.fs.unit.inlet.flow_mass_comp[0, "C"].fix(30) return m
def test_reaction_list(self): m = ConcreteModel() m.db = Database(dbpath=local_path) # Load data from YAML so that we can modify it m.db._get_technology("test_sidor_data") m.db._cached_files["test_sidor_data"]["default"] = {} m.fs = FlowsheetBlock(default={"dynamic": False}) m.fs.water_props = WaterParameterBlock(default={"solute_list": ["A", "B", "C"]}) with pytest.raises( KeyError, match="fs.unit - database provided does not contain a list of " "reactions for this technology.", ): m.fs.unit = DerivedSIDOR( default={"property_package": m.fs.water_props, "database": m.db} )
def model(self): m = ConcreteModel() m.db = Database(dbpath=local_path) m.fs = FlowsheetBlock(default={"dynamic": False}) m.fs.water_props = WaterParameterBlock(default={"solute_list": ["A", "B", "C"]}) m.fs.unit = DerivedSIDOR( default={"property_package": m.fs.water_props, "database": m.db} ) m.fs.unit.inlet.flow_mass_comp[0, "H2O"].fix(1000) m.fs.unit.inlet.flow_mass_comp[0, "A"].fix(10) m.fs.unit.inlet.flow_mass_comp[0, "B"].fix(20) m.fs.unit.inlet.flow_mass_comp[0, "C"].fix(30) m.fs.unit.load_parameters_from_database(use_default_removal=True) return m
def test_solute_list_with_database(caplog): caplog.set_level(idaeslog.DEBUG, logger="watertap") log = idaeslog.getLogger("idaes.watertap.core.zero_order_properties") log.setLevel(idaeslog.DEBUG) m = ConcreteModel() db = Database() m.fs = FlowsheetBlock(default={"dynamic": False}) m.fs.water_props = WaterParameterBlock(default={ "solute_list": ["A", "B", "tds"], "database": db }) assert ("fs.water_props component A is not defined in the water_sources " "database file.") in caplog.text assert ("fs.water_props component B is not defined in the water_sources " "database file.") in caplog.text assert ("fs.water_props component tds is not defined in the water_sources " "database file.") not in caplog.text