How to use a property model

The example below shows how to use a property model and display outputs for a state block. Property models allow users to model the chemical and physical properties of simple systems without the use of unit models.

# Import concrete model from Pyomo
from pyomo.environ import ConcreteModel
# Import flowsheet block from IDAES core
from idaes.core import FlowsheetBlock
# Import solver from IDAES core
from idaes.core.solvers import get_solver
# Import NaCl property model
import watertap.property_models.NaCl_prop_pack as props
# Import utility tool for calculating scaling factors
import idaes.core.util.scaling as iscale

# Create a concrete model, flowsheet, and NaCl property parameter block.
m = ConcreteModel()
m.fs = FlowsheetBlock(default={"dynamic": False}) = props.NaClParameterBlock()

# Build the state block and specify a time (0 = steady state).
m.fs.state_block =[0], default={})

# Fully specify the system.
feed_flow_mass = 1
feed_mass_frac_NaCl = 0.035
feed_mass_frac_H2O = 1 - feed_mass_frac_NaCl
feed_pressure = 50e5
feed_temperature = 298.15

m.fs.state_block[0].flow_mass_phase_comp['Liq', 'NaCl'].fix(feed_flow_mass * feed_mass_frac_NaCl)
m.fs.state_block[0].flow_mass_phase_comp['Liq', 'H2O'].fix(feed_flow_mass * feed_mass_frac_H2O)

# Set scaling factors for component mass flowrates (variable * scaling factor should be between 0.01 and 100).'flow_mass_phase_comp', 1, index=('Liq', 'H2O'))'flow_mass_phase_comp', 1e2, index=('Liq', 'NaCl'))

# "Touch" build-on-demand variables so that they are created. If these are not touched before running the solver, the output would only display their initial values, not their actual values.
m.fs.state_block[0].conc_mass_phase_comp['Liq', 'NaCl']

# Create the solver object.
solver = get_solver()

# Solve the model and display the output.
results = solver.solve(m, tee=False)