def test_config(): m = ConcreteModel() m.fs = FlowsheetBlock(default={"dynamic": True, "time_set": [0, 3600], "time_units": pyunits.s}) # Set up thermo props and reaction props m.fs.gas_props = GasPhaseParameterBlock() m.fs.solid_props = SolidPhaseParameterBlock() m.fs.solid_rxns = HeteroReactionParameterBlock( default={"solid_property_package": m.fs.solid_props, "gas_property_package": m.fs.gas_props}) m.fs.unit = FixedBed0D( default={"gas_property_package": m.fs.gas_props, "solid_property_package": m.fs.solid_props, "reaction_package": m.fs.solid_rxns}) # Check unit config arguments assert len(m.fs.unit.config) == 9 assert m.fs.unit.config.dynamic is True assert m.fs.unit.config.has_holdup is True assert m.fs.unit.config.energy_balance_type == \ EnergyBalanceType.enthalpyTotal assert m.fs.unit.config.gas_property_package is m.fs.gas_props assert m.fs.unit.config.gas_property_package_args is None assert m.fs.unit.config.solid_property_package is m.fs.solid_props assert m.fs.unit.config.solid_property_package_args is None assert m.fs.unit.config.reaction_package is m.fs.solid_rxns
def iron_oc(self): m = ConcreteModel() m.fs = FlowsheetBlock(default={"dynamic": False}) # Set up thermo props and reaction props m.fs.gas_properties = GasPhaseThermoParameterBlock() m.fs.solid_properties = SolidPhaseThermoParameterBlock() m.fs.hetero_reactions = HeteroReactionParameterBlock( default={ "solid_property_package": m.fs.solid_properties, "gas_property_package": m.fs.gas_properties }) m.fs.unit = MBR( default={ "energy_balance_type": EnergyBalanceType.none, "gas_phase_config": { "property_package": m.fs.gas_properties }, "solid_phase_config": { "property_package": m.fs.solid_properties, "reaction_package": m.fs.hetero_reactions } }) return m
def test_config(): m = ConcreteModel() m.fs = FlowsheetBlock(default={"dynamic": False}) # Set up thermo props and reaction props m.fs.gas_properties = GasPhaseThermoParameterBlock() m.fs.solid_properties = SolidPhaseThermoParameterBlock() m.fs.hetero_reactions = HeteroReactionParameterBlock( default={ "solid_property_package": m.fs.solid_properties, "gas_property_package": m.fs.gas_properties }) m.fs.unit = BubblingFluidizedBed( default={ "gas_phase_config": { "property_package": m.fs.gas_properties }, "solid_phase_config": { "property_package": m.fs.solid_properties, "reaction_package": m.fs.hetero_reactions } }) # Check unit config arguments assert len(m.fs.unit.config) == 14 assert isinstance(m.fs.unit.config.gas_phase_config, ConfigBlock) assert isinstance(m.fs.unit.config.solid_phase_config, ConfigBlock) assert m.fs.unit.config.finite_elements == 10 assert m.fs.unit.config.length_domain_set == [0.0, 1.0] assert m.fs.unit.config.transformation_method == "dae.finite_difference" assert m.fs.unit.config.transformation_scheme == 'BACKWARD' assert m.fs.unit.config.collocation_points == 3 assert m.fs.unit.config.flow_type == "co_current" assert m.fs.unit.config.material_balance_type == \ MaterialBalanceType.componentTotal assert m.fs.unit.config.energy_balance_type == \ EnergyBalanceType.enthalpyTotal assert m.fs.unit.config.momentum_balance_type == \ MomentumBalanceType.pressureTotal assert m.fs.unit.config.has_pressure_change is True # Check gas phase config arguments assert len(m.fs.unit.config.gas_phase_config) == 7 assert m.fs.unit.config.gas_phase_config.has_equilibrium_reactions is False assert m.fs.unit.config.gas_phase_config.property_package is \ m.fs.gas_properties assert m.fs.unit.config.gas_phase_config.reaction_package is None # Check solid phase config arguments assert len(m.fs.unit.config.solid_phase_config) == 7 assert m.fs.unit.config.solid_phase_config.has_equilibrium_reactions is \ False assert m.fs.unit.config.solid_phase_config.property_package is \ m.fs.solid_properties assert m.fs.unit.config.solid_phase_config.reaction_package is \ m.fs.hetero_reactions
def iron_oc(self): m = ConcreteModel() m.fs = FlowsheetBlock(default={ "dynamic": True, "time_set": [0, 3600], "time_units": pyunits.s }) m.fs.gas_props = GasPhaseParameterBlock() m.fs.solid_props = SolidPhaseParameterBlock() m.fs.solid_rxns = HeteroReactionParameterBlock( default={ "solid_property_package": m.fs.solid_props, "gas_property_package": m.fs.gas_props }) m.fs.unit = FixedBed0D( default={ "energy_balance_type": EnergyBalanceType.none, "gas_property_package": m.fs.gas_props, "solid_property_package": m.fs.solid_props, "reaction_package": m.fs.solid_rxns }) # Discretize time domain m.discretizer = TransformationFactory('dae.finite_difference') m.discretizer.apply_to(m, nfe=100, wrt=m.fs.time, scheme="BACKWARD") # Set reactor design conditions m.fs.unit.bed_diameter.fix(1) # diameter of the TGA reactor [m] m.fs.unit.bed_height.fix(1) # height of solids in the TGA reactor [m] # Set initial conditions of the solid phase m.fs.unit.solids[0].temperature.fix(1273.15) m.fs.unit.solids[0].particle_porosity.fix(0.20) m.fs.unit.solids[0].mass_frac_comp['Fe2O3'].fix(0.45) m.fs.unit.solids[0].mass_frac_comp['Fe3O4'].fix(0) m.fs.unit.solids[0].mass_frac_comp['Al2O3'].fix(0.55) # Set conditions of the gas phase (this is all fixed as gas side # assumption is excess gas flowrate which means all state variables # remain unchanged) for t in m.fs.time: m.fs.unit.gas[t].temperature.fix(1273.15) m.fs.unit.gas[t].pressure.fix(1.01325E5) # 1atm m.fs.unit.gas[t].mole_frac_comp['CO2'].fix(0.4) m.fs.unit.gas[t].mole_frac_comp['H2O'].fix(0.5) m.fs.unit.gas[t].mole_frac_comp['CH4'].fix(0.1) return m
def iron_oc(self): m = ConcreteModel() m.fs = FlowsheetBlock(default={"dynamic": False}) # Set up thermo props and reaction props m.fs.gas_properties = GasPhaseThermoParameterBlock() m.fs.solid_properties = SolidPhaseThermoParameterBlock() m.fs.hetero_reactions = HeteroReactionParameterBlock( default={ "solid_property_package": m.fs.solid_properties, "gas_property_package": m.fs.gas_properties }) m.fs.unit = BubblingFluidizedBed( default={ "energy_balance_type": EnergyBalanceType.none, "gas_phase_config": { "property_package": m.fs.gas_properties }, "solid_phase_config": { "property_package": m.fs.solid_properties, "reaction_package": m.fs.hetero_reactions } }) # # Fix geometry variables m.fs.unit.number_orifice.fix(2500) # [-] m.fs.unit.bed_diameter.fix(6.5) # m m.fs.unit.bed_height.fix(5) # m # # Fix inlet port variables for gas and solid m.fs.unit.gas_inlet.flow_mol[0].fix(272.81) # mol/s m.fs.unit.gas_inlet.temperature[0].fix(1186) # K m.fs.unit.gas_inlet.pressure[0].fix(1.86) # bar m.fs.unit.gas_inlet.mole_frac_comp[0, "CO2"].fix(0.4772) m.fs.unit.gas_inlet.mole_frac_comp[0, "H2O"].fix(0.0646) m.fs.unit.gas_inlet.mole_frac_comp[0, "CH4"].fix(0.4582) m.fs.unit.solid_inlet.flow_mass[0].fix(1422) # kg/ m.fs.unit.solid_inlet.particle_porosity.fix(0.27) # (-) m.fs.unit.solid_inlet.temperature[0].fix(1186) # K m.fs.unit.solid_inlet.mass_frac_comp[0, "Fe2O3"].fix(0.45) m.fs.unit.solid_inlet.mass_frac_comp[0, "Fe3O4"].fix(1e-9) m.fs.unit.solid_inlet.mass_frac_comp[0, "Al2O3"].fix(0.55) return m
def iron_oc(self): m = ConcreteModel() m.fs = FlowsheetBlock(default={"dynamic": False}) # Set up thermo props and reaction props m.fs.gas_properties = GasPhaseParameterBlock() m.fs.solid_properties = SolidPhaseParameterBlock() m.fs.hetero_reactions = HeteroReactionParameterBlock( default={ "solid_property_package": m.fs.solid_properties, "gas_property_package": m.fs.gas_properties }) m.fs.unit = MBR( default={ "energy_balance_type": EnergyBalanceType.none, "gas_phase_config": { "property_package": m.fs.gas_properties }, "solid_phase_config": { "property_package": m.fs.solid_properties, "reaction_package": m.fs.hetero_reactions } }) # Fix geometry variables m.fs.unit.bed_diameter.fix(6.5) # m m.fs.unit.bed_height.fix(5) # m # Fix inlet port variables for gas and solid m.fs.unit.gas_inlet.flow_mol[0].fix(128.20513) # mol/s m.fs.unit.gas_inlet.temperature[0].fix(1183.15) # K m.fs.unit.gas_inlet.pressure[0].fix(2.00) # bar m.fs.unit.gas_inlet.mole_frac_comp[0, "CO2"].fix(0.02499) m.fs.unit.gas_inlet.mole_frac_comp[0, "H2O"].fix(0.00001) m.fs.unit.gas_inlet.mole_frac_comp[0, "CH4"].fix(0.975) m.fs.unit.solid_inlet.flow_mass[0].fix(591.4) # kg/s m.fs.unit.solid_inlet.temperature[0].fix(1183.15) # K m.fs.unit.solid_inlet.particle_porosity[0].fix(0.27) # (-) m.fs.unit.solid_inlet.mass_frac_comp[0, "Fe2O3"].fix(0.45) m.fs.unit.solid_inlet.mass_frac_comp[0, "Fe3O4"].fix(1e-9) m.fs.unit.solid_inlet.mass_frac_comp[0, "Al2O3"].fix(0.55) return m
def rxn_prop(): m = ConcreteModel() m.fs = FlowsheetBlock(default={"dynamic": False}) # Set up thermo props and reaction props m.fs.solid_properties = SolidPhaseParameterBlock() m.fs.solid_state_block = m.fs.solid_properties.build_state_block( default={ "parameters": m.fs.solid_properties, "defined_state": True }) m.fs.gas_properties = GasPhaseParameterBlock() m.fs.gas_state_block = m.fs.gas_properties.build_state_block( default={ "parameters": m.fs.gas_properties, "defined_state": True }) m.fs.reactions = HeteroReactionParameterBlock( default={ "solid_property_package": m.fs.solid_properties, "gas_property_package": m.fs.gas_properties }) m.fs.unit = m.fs.reactions.reaction_block_class( default={ "parameters": m.fs.reactions, "solid_state_block": m.fs.solid_state_block, "gas_state_block": m.fs.gas_state_block, "has_equilibrium": False }) # Fix required variables to make reaction model square # (gas mixture and component densities, # solid particle porosity, density and component fractions) m.fs.gas_state_block.dens_mol.fix(10) m.fs.gas_state_block.dens_mol_comp.fix(10) m.fs.solid_state_block.particle_porosity.fix(0.27) m.fs.solid_state_block.mass_frac_comp["Fe2O3"].fix(0.45) m.fs.solid_state_block.mass_frac_comp["Fe3O4"].fix(1e-9) m.fs.solid_state_block.mass_frac_comp["Al2O3"].fix(0.55) m.fs.solid_state_block.dens_mass_skeletal.fix(1) m.fs.solid_state_block.temperature.fix(1183.15) # K return m
def main(): # --------------------------------------------------------------------- # Build model # Create a concrete model m = ConcreteModel() # Create a steady-state flowsheet m.fs = FlowsheetBlock(default={"dynamic": False}) # Set up thermo-physical and reaction properties m.fs.gas_properties = GasPhaseThermoParameterBlock() m.fs.solid_properties = SolidPhaseThermoParameterBlock() m.fs.hetero_reactions = HeteroReactionParameterBlock( default={ "solid_property_package": m.fs.solid_properties, "gas_property_package": m.fs.gas_properties }) # Build the BFB in the flowsheet m.fs.BFB = BubblingFluidizedBed( default={ "flow_type": "co_current", "finite_elements": 5, "transformation_method": "dae.collocation", "gas_phase_config": { "property_package": m.fs.gas_properties }, "solid_phase_config": { "property_package": m.fs.solid_properties, "reaction_package": m.fs.hetero_reactions } }) # --------------------------------------------------------------------- # Set design and operating variables of the BFB model # Fix design variables m.fs.BFB.number_orifice.fix(2500) # [-] m.fs.BFB.bed_diameter.fix(6.5) # m m.fs.BFB.bed_height.fix(5) # m # Fix inlet port variables for gas and solid m.fs.BFB.gas_inlet.flow_mol[0].fix(272.81) # mol/s m.fs.BFB.gas_inlet.temperature[0].fix(373) # K m.fs.BFB.gas_inlet.pressure[0].fix(1.86) # bar m.fs.BFB.gas_inlet.mole_frac_comp[0, "CO2"].fix(0.4772) m.fs.BFB.gas_inlet.mole_frac_comp[0, "H2O"].fix(0.0646) m.fs.BFB.gas_inlet.mole_frac_comp[0, "CH4"].fix(0.4582) m.fs.BFB.solid_inlet.flow_mass[0].fix(1230) # kg/s # Particle porosity: # The porosity of the OC particle at the inlet is calculated from the # known bulk density of the fresh OC particle (3251.75 kg/m3), and the # skeletal density of the fresh OC particle (calculated from the known # composition of the fresh particle, and the skeletal density of its # components [see the solids property package]) m.fs.BFB.solid_inlet.particle_porosity[0].fix(0.27) m.fs.BFB.solid_inlet.temperature[0].fix(1186) # K m.fs.BFB.solid_inlet.mass_frac_comp[0, "Fe2O3"].fix(0.45) m.fs.BFB.solid_inlet.mass_frac_comp[0, "Fe3O4"].fix(1e-9) m.fs.BFB.solid_inlet.mass_frac_comp[0, "Al2O3"].fix(0.55) # --------------------------------------------------------------------- # Initialize reactor t_start = time.time() # Run start time # State arguments for initializing property state blocks # Bubble and gas_emulsion temperatures are initialized at solid # temperature because thermal mass of solid >> thermal mass of gas blk = m.fs.BFB gas_phase_state_args = { 'flow_mol': blk.gas_inlet.flow_mol[0].value, 'temperature': blk.solid_inlet.temperature[0].value, 'pressure': blk.gas_inlet.pressure[0].value, 'mole_frac': { 'CH4': blk.gas_inlet.mole_frac_comp[0, 'CH4'].value, 'CO2': blk.gas_inlet.mole_frac_comp[0, 'CO2'].value, 'H2O': blk.gas_inlet.mole_frac_comp[0, 'H2O'].value } } solid_phase_state_args = { 'flow_mass': blk.solid_inlet.flow_mass[0].value, 'particle_porosity': blk.solid_inlet.particle_porosity[0].value, 'temperature': blk.solid_inlet.temperature[0].value, 'mass_frac': { 'Fe2O3': blk.solid_inlet.mass_frac_comp[0, 'Fe2O3'].value, 'Fe3O4': blk.solid_inlet.mass_frac_comp[0, 'Fe3O4'].value, 'Al2O3': blk.solid_inlet.mass_frac_comp[0, 'Al2O3'].value } } m.fs.BFB.initialize(outlvl=idaeslog.INFO, gas_phase_state_args=gas_phase_state_args, solid_phase_state_args=solid_phase_state_args) t_initialize = time.time() # Initialization time # --------------------------------------------------------------------- # Final solve # Create a solver solver = SolverFactory('ipopt') solver.solve(m.fs.BFB, tee=True) t_simulation = time.time() # Simulation time print("\n") print("----------------------------------------------------------") print('Total initialization time: ', value(t_initialize - t_start), " s") print("----------------------------------------------------------") print("\n") print("----------------------------------------------------------") print('Total simulation time: ', value(t_simulation - t_start), " s") print("----------------------------------------------------------") return m
def main(m): m.fs = FlowsheetBlock(default={"dynamic": True, "time_set": [0, 3600], "time_units": pyunits.s}) m.fs.gas_props = GasPhaseParameterBlock() m.fs.solid_props = SolidPhaseParameterBlock() m.fs.solid_rxns = HeteroReactionParameterBlock( default={"solid_property_package": m.fs.solid_props, "gas_property_package": m.fs.gas_props}) m.fs.TGA = FixedBed0D(default={ "energy_balance_type": EnergyBalanceType.none, "gas_property_package": m.fs.gas_props, "solid_property_package": m.fs.solid_props, "reaction_package": m.fs.solid_rxns}) # Discretize time domain m.discretizer = TransformationFactory('dae.finite_difference') m.discretizer.apply_to(m, nfe=100, wrt=m.fs.time, scheme="BACKWARD") # Set reactor design conditions m.fs.TGA.bed_diameter.fix(1) # diameter of the TGA reactor [m] m.fs.TGA.bed_height.fix(1) # height of solids in the TGA reactor [m] # Set initial conditions of the solid phase m.fs.TGA.solids[0].particle_porosity.fix(0.20) m.fs.TGA.solids[0].mass_frac_comp['Fe2O3'].fix(0.45) m.fs.TGA.solids[0].mass_frac_comp['Fe3O4'].fix(0) m.fs.TGA.solids[0].mass_frac_comp['Al2O3'].fix(0.55) m.fs.TGA.solids[0].temperature.fix(1273.15) # Set conditions of the gas phase (this is all fixed as gas side assumption # is excess gas flowrate which means all state variables remain unchanged) for t in m.fs.time: m.fs.TGA.gas[t].temperature.fix(1273.15) m.fs.TGA.gas[t].pressure.fix(1.01325E5) # 1atm m.fs.TGA.gas[t].mole_frac_comp['CO2'].fix(0.4) m.fs.TGA.gas[t].mole_frac_comp['H2O'].fix(0.5) m.fs.TGA.gas[t].mole_frac_comp['CH4'].fix(0.1) # Solver options optarg = { "bound_push": 1e-8, 'halt_on_ampl_error': 'yes', 'linear_solver': 'ma27' } t_start = time.time() # Run start time m.fs.TGA.initialize() t_initialize = time.time() # Initialization time solver = get_solver('ipopt', optarg) # create solver initialize_by_time_element(m.fs, m.fs.time, solver=solver) solver.solve(m, tee=True) t_simulation = time.time() # Simulation time print("\n") print("----------------------------------------------------------") print('Total initialization time: ', value(t_initialize - t_start), " s") print("----------------------------------------------------------") print("\n") print("----------------------------------------------------------") print('Total simulation time: ', value(t_simulation - t_start), " s") print("----------------------------------------------------------") return m
def main(): m = ConcreteModel() m.fs = FlowsheetBlock(default={"dynamic": False}) # Set up thermo props and reaction props m.fs.gas_properties = GasPhaseThermoParameterBlock() m.fs.solid_properties = SolidPhaseThermoParameterBlock() m.fs.hetero_reactions = HeteroReactionParameterBlock( default={ "solid_property_package": m.fs.solid_properties, "gas_property_package": m.fs.gas_properties }) m.fs.MB = MBR( default={ "transformation_method": "dae.collocation", "gas_phase_config": { "property_package": m.fs.gas_properties }, "solid_phase_config": { "property_package": m.fs.solid_properties, "reaction_package": m.fs.hetero_reactions } }) # Fix bed geometry variables m.fs.MB.bed_diameter.fix(6.5) # m m.fs.MB.bed_height.fix(5) # m # Fix inlet port variables for gas and solid m.fs.MB.gas_inlet.flow_mol[0].fix(128.20513) # mol/s m.fs.MB.gas_inlet.temperature[0].fix(298.15) # K m.fs.MB.gas_inlet.pressure[0].fix(2.00) # bar m.fs.MB.gas_inlet.mole_frac_comp[0, "CO2"].fix(0.02499) m.fs.MB.gas_inlet.mole_frac_comp[0, "H2O"].fix(0.00001) m.fs.MB.gas_inlet.mole_frac_comp[0, "CH4"].fix(0.975) m.fs.MB.solid_inlet.flow_mass[0].fix(591.4) # kg/s # Particle porosity: # The porosity of the OC particle at the inlet is calculated from the # known bulk density of the fresh OC particle (3251.75 kg/m3), and the # skeletal density of the fresh OC particle (calculated from the known # composition of the fresh particle, and the skeletal density of its # components [see the solids property package]) m.fs.MB.solid_inlet.particle_porosity[0].fix(0.27) m.fs.MB.solid_inlet.temperature[0].fix(1183.15) # K m.fs.MB.solid_inlet.mass_frac_comp[0, "Fe2O3"].fix(0.45) m.fs.MB.solid_inlet.mass_frac_comp[0, "Fe3O4"].fix(1e-9) m.fs.MB.solid_inlet.mass_frac_comp[0, "Al2O3"].fix(0.55) # Initialize fuel reactor t_start = time.time() # Run start time # State arguments for initializing property state blocks # Gas phase temperature is initialized at solid # temperature because thermal mass of solid >> thermal mass of gas # Particularly useful for initialization if reaction takes place blk = m.fs.MB gas_phase_state_args = { 'flow_mol': blk.gas_inlet.flow_mol[0].value, 'temperature': blk.solid_inlet.temperature[0].value, 'pressure': blk.gas_inlet.pressure[0].value, 'mole_frac': { 'CH4': blk.gas_inlet.mole_frac_comp[0, 'CH4'].value, 'CO2': blk.gas_inlet.mole_frac_comp[0, 'CO2'].value, 'H2O': blk.gas_inlet.mole_frac_comp[0, 'H2O'].value } } solid_phase_state_args = { 'flow_mass': blk.solid_inlet.flow_mass[0].value, 'particle_porosity': blk.solid_inlet.particle_porosity[0].value, 'temperature': blk.solid_inlet.temperature[0].value, 'mass_frac': { 'Fe2O3': blk.solid_inlet.mass_frac_comp[0, 'Fe2O3'].value, 'Fe3O4': blk.solid_inlet.mass_frac_comp[0, 'Fe3O4'].value, 'Al2O3': blk.solid_inlet.mass_frac_comp[0, 'Al2O3'].value } } m.fs.MB.initialize(outlvl=idaeslog.INFO, gas_phase_state_args=gas_phase_state_args, solid_phase_state_args=solid_phase_state_args) t_initialize = time.time() # Initialization time # Create a solver solver = get_solver() solver.solve(m.fs.MB, tee=True) t_simulation = time.time() # Simulation time print("\n") print("----------------------------------------------------------") print('Total initialization time: ', value(t_initialize - t_start), " s") print("----------------------------------------------------------") print("\n") print("----------------------------------------------------------") print('Total simulation time: ', value(t_simulation - t_start), " s") print("----------------------------------------------------------") return m