Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion docs/whats_new/v0-9-14.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ Bug Fixes
silent error because if not used, it did not do any trouble. Only when
importing a :code:`Network` and reconstructing the component parameters the
:code:`CharMap` could not be constructed successfully because it was missing
dimensions (`PR #934 <https://github.com/oemof/tespy/pull/934>`__).
dimensions (`PR #933 <https://github.com/oemof/tespy/pull/933>`__).
- The reactor classes :code:`FuelCell` and :code:`WaterElectrolyzer` were
missing the implementation for a :code:`PowerConnection`
(`PR #934 <https://github.com/oemof/tespy/pull/934>`__).

Other Changes
#############
Expand Down
38 changes: 36 additions & 2 deletions src/tespy/components/reactors/fuel_cell.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ def get_parameters(self):
}

def get_mandatory_constraints(self):
return {
constraints = {
'mass_flow_constraints': dc_cmc(**{
'func': self.reactor_mass_flow_func,
'deriv': self.reactor_mass_flow_deriv,
Expand Down Expand Up @@ -247,6 +247,14 @@ def get_mandatory_constraints(self):
"description": "reactor pressure equality equations"
})
}
if len(self.power_outl) > 0:
constraints["energy_connector_balance"] = dc_cmc(**{
"func": self.energy_connector_balance_func,
"dependents": self.energy_connector_dependents,
"num_eq_sets": 1
})

return constraints

@staticmethod
def get_bypass_constraints():
Expand All @@ -260,6 +268,10 @@ def inlets():
def outlets():
return ['out1', 'out2']

@staticmethod
def poweroutlets():
return ["power"]

def _add_missing_fluids(self, connections):
if self.inl[1] in connections:
return ["O2"]
Expand Down Expand Up @@ -325,6 +337,28 @@ def calc_e0(self):

return e0

def energy_connector_balance_func(self):
r"""
(optional) energy balance equation connecting the power connector to
the component's power. Since the power of the FuelCell is negative by
definition of the system, the two quantities are added in the residual
so the power on the PowerConnection is positive again.

Returns
-------
residual : float
Residual value of equation

.. math::

0=\dot E + P
"""
return self.power_outl[0].E.val_SI + self.P.val_SI

def energy_connector_dependents(self):
return [self.power_outl[0].E, self.P]


def eta_func(self):
r"""
Equation for efficiency.
Expand Down Expand Up @@ -454,7 +488,7 @@ def energy_balance_deriv(self, increment_filter, k, dependents=None):

# derivatives for variable P
if self.P.is_var:
self.jacobian[k, self.p.J_col] = 1
self.jacobian[k, self.P.J_col] = 1

def energy_balance_dependents(self):
return [
Expand Down
33 changes: 32 additions & 1 deletion src/tespy/components/reactors/water_electrolyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ def get_parameters(self):
}

def get_mandatory_constraints(self):
return {
constraints = {
'mass_flow_constraints': dc_cmc(**{
'func': self.reactor_mass_flow_func,
'deriv': self.reactor_mass_flow_deriv,
Expand Down Expand Up @@ -291,6 +291,14 @@ def get_mandatory_constraints(self):
"description": "equation for same temperature of product gases"
})
}
if len(self.power_inl) > 0:
constraints["energy_connector_balance"] = dc_cmc(**{
"func": self.energy_connector_balance_func,
"dependents": self.energy_connector_dependents,
"num_eq_sets": 1
})

return constraints

@staticmethod
def get_bypass_constraints():
Expand All @@ -304,6 +312,10 @@ def inlets():
def outlets():
return ['out1', 'out2', 'out3']

@staticmethod
def powerinlets():
return ["power"]

def _add_missing_fluids(self, connections):
if self.inl[1] in connections:
return ["H2O"]
Expand Down Expand Up @@ -369,6 +381,25 @@ def calc_e0(self):

return e0

def energy_connector_balance_func(self):
r"""
(optional) energy balance equation connecting the power connector to
the component's power

Returns
-------
residual : float
Residual value of equation

.. math::

0=\dot E - P
"""
return self.power_inl[0].E.val_SI - self.P.val_SI

def energy_connector_dependents(self):
return [self.power_inl[0].E, self.P]

def gas_temperature_func(self):
r"""
Equation for temperature equality of product gases.
Expand Down
Loading
Loading