SOEC Simple Design Model
========================

.. index::
    pair: idaes.models_extra.power_generation.unit_models.soec_design;SoecDesign

.. module:: idaes.models_extra.power_generation.unit_models.soec_design
  :noindex:

The simple SOEC design model can be used as a design point model during initial
development of a flowsheet concept.  The model does basic mass and energy
balances to calculate cell voltage and current.  Users specify the outlet
temperature and water utilization, for which typical representative values can
be readily obtained.  Based on typical current densities the size of the SOEC
module can be estimated, if rough capital costs are needed.

Performance of the SOEC away from the design point can be handled in two way. Either
the more detailed spatially discretized models can be used, or surrogate models
can be coupled with this model.


Example
-------

The example below shows how to setup a feedwater heater with all three sections.
The feedwater flow rate, steam conditions, heat transfer coefficients and areas
are not necessarily realistic.

.. testcode::

  import pyomo.environ as pyo
  import idaes
  from idaes.core import FlowsheetBlock
  from idaes.models.properties.modular_properties.base.generic_property import (
      GenericParameterBlock)
  import idaes.core.util.scaling as iscale
  from idaes.models_extra.power_generation.properties.natural_gas_PR import get_prop
  from idaes.models_extra.power_generation.unit_models.soec_design import SoecDesign, EosType
  import pytest

  def soec_example_flowsheet(eos=EosType.PR):
      m = pyo.ConcreteModel()
      m.fs = FlowsheetBlock(dynamic=False)

      sweep_comp = {
          "O2":0.2074,
          "H2O":0.0099,
          "CO2":0.0003,
          "N2":0.7732,
          "Ar":0.0092,
      }

      feed_comp = {
          "H2": 0.01,
          "H2O": 0.99,
      }

      m.fs.o2_side_prop_params = GenericParameterBlock(
          **get_prop(sweep_comp, {"Vap"}, eos=eos),
          doc="Air property parameters",
      )
      m.fs.h2_side_prop_params = GenericParameterBlock(
          **get_prop(feed_comp, {"Vap"}, eos=eos),
          doc="Flue gas property parameters",
      )
      m.fs.soec = SoecDesign(
          oxygen_side_property_package=m.fs.o2_side_prop_params,
          hydrogen_side_property_package=m.fs.h2_side_prop_params,
          reaction_eos=eos
      )

      m.fs.soec.hydrogen_side_inlet.temperature.fix(1023)
      m.fs.soec.hydrogen_side_inlet.pressure.fix(20e5)
      m.fs.soec.hydrogen_side_inlet.flow_mol.fix(2)
      for (t, i), c in m.fs.soec.hydrogen_side_inlet.mole_frac_comp.items():
          c.fix(feed_comp[i])
      m.fs.soec.oxygen_side_inlet.temperature.fix(1023)
      m.fs.soec.oxygen_side_inlet.pressure.fix(20e5)
      m.fs.soec.oxygen_side_inlet.flow_mol.fix(2)
      for (t, i), c in m.fs.soec.oxygen_side_inlet.mole_frac_comp.items():
          c.fix(sweep_comp[i])
      m.fs.soec.hydrogen_side_outlet_temperature.fix(1023)
      m.fs.soec.oxygen_side_outlet_temperature.fix(1023)
      m.fs.soec.water_utilization.fix(0.7)
      iscale.calculate_scaling_factors(m)
      m.fs.soec.initialize(optarg={"max_iter":30})
      return m

  # create a flowsheet with the SOEC model
  model = soec_example_flowsheet()

Model Structure
---------------

Internally the model consist of several subunits.  The internal structure is not
important.  The SOEC consist two sides separated by a solid oxide electrolyte.
The oxygen side carries the oxygen generated by electrolysis and a sweep gas.
The hydrogen side contains water and hydrogen. The water is broken into hydrogen
and oxygen.  Hydrogen stays on the hydrogen side and oxygen leaves in the water
side.

The hydrogen side properties are specified by providing a physical property parameter
block to the ``hydrogen_side_property_package`` config option, and must contain only
hydrogen and water. The oxygen side properties are specified by providing a physical
property parameter block to the ``oxygen_side_property_package`` config option, and must
contain at least oxygen and other sweep gas components.  Typical sweep gas choices
are air or steam. It is recommended that the ``idaes.models_extra.power_generation.properties.natural_gas_PR``
property parameters be used with the generic IDAES property package.  See the example
above.

There four ports, an inlet and outlet on the hydrogen side and an inlet and outlet
on the oxygen side.  The ports are named ``hydrogen_side_inlet``, ``hydrogen_side_outlet``,
``oxygen_side_inlet``, and ``oxygen_side_outlet``.


Degrees of Freedom
------------------

The typical variables that should be specified are:
* inlet ports,
* water utilization ``water_utilization``,
* hydrogen side outlet temperature ``hydrogen_side_outlet_temperature``, and
* oxygen side outlet temperature ``oxygen_side_outlet_temperature``.

If the ``has_heat_transfer`` configuration option is set to true the ``heat``
variable should also be specified.

Output
------

The main outputs of interest in the model are the outlet ports, ``cell_voltage``
and ``current``.

SoecDesign Class
----------------

.. autoclass:: SoecDesign
  :members:

SoecDesignData Class
--------------------

.. autoclass:: SoecDesignData
  :members:
