def test_elec_splitter_outlet_list(): m = ConcreteModel() m.fs = FlowsheetBlock( default={"dynamic": False}) # dynamic or ss flowsheet needs to be specified here m.fs.unit = ElectricalSplitter(default={"outlet_list": ["o1", "o2"]}) assert hasattr(m.fs.unit, "electricity") assert hasattr(m.fs.unit, "electricity_in") assert hasattr(m.fs.unit, "split_fraction") assert hasattr(m.fs.unit, "outlet_list") assert isinstance(m.fs.unit.electricity, Var) assert isinstance(m.fs.unit.split_fraction, Var) assert isinstance(m.fs.unit.o1_elec, Var) assert isinstance(m.fs.unit.o2_elec, Var) m.fs.unit.o1_elec.fix(0.5) m.fs.unit.o2_elec.fix(0.5) solver = SolverFactory('ipopt') results = solver.solve(m.fs) assert results.solver.termination_condition == TerminationCondition.optimal assert results.solver.status == SolverStatus.ok assert m.fs.unit.electricity[0].value == approx(1, 1e-4) assert m.fs.unit.split_fraction['o1', 0].value == approx(0.5, 1e-4) assert m.fs.unit.split_fraction['o2', 0].value == approx(0.5, 1e-4)
def test_elec_splitter_num_outlets_init_1(): m = ConcreteModel() m.fs = FlowsheetBlock(default={"dynamic": False}) m.fs.unit = ElectricalSplitter(default={"num_outlets": 3}) # fix 1 outlets, dof=1 m.fs.unit.electricity_in.electricity.fix(1) m.fs.unit.outlet_1_elec.fix(0.25) initialization_tester(m, dof=1)
def test_elec_splitter_num_outlets_build(): m = ConcreteModel() m.fs = FlowsheetBlock( default={"dynamic": False}) # dynamic or ss flowsheet needs to be specified here m.fs.unit = ElectricalSplitter(default={"num_outlets": 3}) assert hasattr(m.fs.unit, "electricity") assert hasattr(m.fs.unit, "electricity_in") assert hasattr(m.fs.unit, "split_fraction") assert hasattr(m.fs.unit, "outlet_list") assert isinstance(m.fs.unit.electricity, Var) assert isinstance(m.fs.unit.split_fraction, Var) assert isinstance(m.fs.unit.outlet_1_elec, Var) assert isinstance(m.fs.unit.outlet_2_elec, Var) assert isinstance(m.fs.unit.outlet_3_elec, Var)
def test_elec_splitter_num_outlets_solve_1(): m = ConcreteModel() m.fs = FlowsheetBlock(default={"dynamic": False}) m.fs.unit = ElectricalSplitter(default={"num_outlets": 3}) m.fs.unit.outlet_1_elec.fix(25) m.fs.unit.outlet_2_elec.fix(25) m.fs.unit.outlet_3_elec.fix(50) solver = SolverFactory('ipopt') results = solver.solve(m.fs) assert results.solver.termination_condition == TerminationCondition.optimal assert results.solver.status == SolverStatus.ok assert m.fs.unit.electricity[0].value == 100 assert m.fs.unit.split_fraction['outlet_1', 0].value == approx(0.25, 1e-4) assert m.fs.unit.split_fraction['outlet_2', 0].value == approx(0.25, 1e-4) assert m.fs.unit.split_fraction['outlet_3', 0].value == approx(0.5, 1e-4)
def build_ne_flowsheet(m, **kwargs): """ This function builds the entire nuclear flowsheet by adding the required models and arcs connecting the models. """ m.fs = FlowsheetBlock(default={"dynamic": False}) # Load thermodynamic and reaction packages m.fs.h2ideal_props = GenericParameterBlock(default=h2_ideal_config) m.fs.h2turbine_props = GenericParameterBlock(default=hturbine_config) m.fs.reaction_params = h2_reaction_props.H2ReactionParameterBlock( default={"property_package": m.fs.h2turbine_props}) # Add electrical splitter m.fs.np_power_split = ElectricalSplitter(default={ "num_outlets": 2, "outlet_list": ["np_to_grid", "np_to_pem"]}) # Add PEM electrolyzer m.fs.pem = PEM_Electrolyzer(default={ "property_package": m.fs.h2ideal_props}) # Add hydrogen tank m.fs.h2_tank = SimpleHydrogenTank(default={ "property_package": m.fs.h2ideal_props}) # Add translator block m.fs.translator = Translator(default={ "inlet_property_package": m.fs.h2ideal_props, "outlet_property_package": m.fs.h2turbine_props}) # Add translator block constraints m.fs.translator.eq_flow_hydrogen = Constraint( expr=m.fs.translator.inlet.flow_mol[0] == m.fs.translator.outlet.flow_mol[0]) m.fs.translator.eq_temperature = Constraint( expr=m.fs.translator.inlet.temperature[0] == m.fs.translator.outlet.temperature[0]) m.fs.translator.eq_pressure = Constraint( expr=m.fs.translator.inlet.pressure[0] == m.fs.translator.outlet.pressure[0]) # Add mixer block # using minimize pressure for all inlets and outlet of the mixer # because pressure of inlets is already fixed in flowsheet, # using equality will over-constrain m.fs.mixer = Mixer(default={ "momentum_mixing_type": MomentumMixingType.minimize, "property_package": m.fs.h2turbine_props, "inlet_list": ["air_feed", "hydrogen_feed"]}) # Add hydrogen turbine m.fs.h2_turbine = HydrogenTurbine( default={"property_package": m.fs.h2turbine_props, "reaction_package": m.fs.reaction_params}) """ Connect the individual blocks via Arcs """ # Connect the electrical splitter and PEM m.fs.arc_np_to_pem = Arc( source=m.fs.np_power_split.np_to_pem_port, destination=m.fs.pem.electricity_in ) # Connect the pem electrolyzer and h2 tank m.fs.arc_pem_to_h2_tank = Arc( source=m.fs.pem.outlet, destination=m.fs.h2_tank.inlet ) # Connect h2 tank and translator m.fs.arc_h2_tank_to_translator = Arc( source=m.fs.h2_tank.outlet_to_turbine, destination=m.fs.translator.inlet ) # Connect translator and mixer m.fs.arc_translator_to_mixer = Arc( source=m.fs.translator.outlet, destination=m.fs.mixer.hydrogen_feed ) # Connect mixer and h2 turbine m.fs.arc_mixer_to_h2_turbine = Arc( source=m.fs.mixer.outlet, destination=m.fs.h2_turbine.compressor.inlet ) TransformationFactory("network.expand_arcs").apply_to(m) return m