Skip to content

Commit

Permalink
Merge branch 'fix/#608-postprocessing-only-for-converged-solutions' i…
Browse files Browse the repository at this point in the history
…nto dev
  • Loading branch information
fwitte committed Feb 12, 2025
2 parents 959bca4 + 568a107 commit dd0059c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
7 changes: 7 additions & 0 deletions docs/whats_new/v0-7-9.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ New Features
use the feature check the documentation of the component class
(`PR #602 <https://github.com/oemof/tespy/pull/602>`__).

Bug Fixes
#########
- Run the postprocessing only for a converged solution. Otherwise specified
values on buses, components or connections may change to nonsense, because
the calculation is based on not-converged results of the variables
(`PR #609 <https://github.com/oemof/tespy/pull/609>`__).

Contributors
############
- `@tlmerbecks <https://github.com/tlmerbecks>`__
Expand Down
4 changes: 2 additions & 2 deletions src/tespy/components/reactors/water_electrolyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,10 +176,10 @@ class WaterElectrolyzer(Component):
>>> round(el.eta.val, 1)
0.8
>>> el_cmp.set_attr(v=None)
>>> el.set_attr(P=P_design * 0.66)
>>> el.set_attr(P=P_design * 1e6 * 0.2)
>>> nw.solve('offdesign', design_path='tmp')
>>> round(el.eta.val, 2)
0.88
0.84
>>> shutil.rmtree('./tmp', ignore_errors=True)
"""

Expand Down
12 changes: 7 additions & 5 deletions src/tespy/networks/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -1109,9 +1109,11 @@ def presolve_fluid_topology(self):
main_conn.fluid.val.update(fixed_fractions)
main_conn.fluid.is_set = {f for f in fixed_fractions}
main_conn.fluid.is_var = variable
num_var = len(variable)
for f in variable:
main_conn.fluid.val[f]: (1 - mass_fraction_sum) / num_var
# this seems to be a problem in some cases, e.g. the basic
# gas turbine tutorial
# num_var = len(variable)
# for f in variable:
# main_conn.fluid.val[f] = (1 - mass_fraction_sum) / num_var

[c.build_fluid_data() for c in all_connections]
for fluid in main_conn.fluid.is_var:
Expand Down Expand Up @@ -1992,8 +1994,6 @@ def solve(self, mode, init_path=None, design_path=None,
logger.error(msg)
return

self.postprocessing()

if not self.progress:
msg = (
'The solver does not seem to make any progress, aborting '
Expand All @@ -2005,6 +2005,8 @@ def solve(self, mode, init_path=None, design_path=None,
logger.warning(msg)
return

self.postprocessing()

msg = 'Calculation complete.'
logger.info(msg)
return
Expand Down

0 comments on commit dd0059c

Please sign in to comment.