Skip to content

Commit

Permalink
Merge pull request #559 from oemof/features/make-topology-simplificat…
Browse files Browse the repository at this point in the history
…ion-reset-public

Make the topology simplification reset a public method
  • Loading branch information
fwitte authored Oct 21, 2024
2 parents 9002ab4 + a4aec69 commit 43d1137
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 13 deletions.
25 changes: 17 additions & 8 deletions docs/modules/networks.rst
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ in .csv-files rather than your python script.
The :code:`init_previous` parameter can be used in design and offdesign
calculations and works very similar to specifying an :code:`init_path`.
In contrast, starting values are taken from the previous calculation. Specifying
the :code:`ìnit_path` overwrites :code:`init_previous`.
the :code:`init_path` overwrites :code:`init_previous`.

Design mode
+++++++++++
Expand Down Expand Up @@ -234,8 +234,8 @@ consequently the solution is obtained with numerical methods. TESPy uses the
n-dimensional Newton-Raphson method to find the system's solution, which may
only be found, if the network is parameterized correctly. **The number of**
**variables n changes depending on your system's topology and your**
**specifications**. Generally, masA presolving step reduces the amount of variables, see below
for more information.
**specifications**. On top of that, the presolver reduces the number of
variables based on your model structure and your specifications.

**General preprocessing**

Expand Down Expand Up @@ -311,7 +311,7 @@ result. The following steps are performed in finding starting values:

* fluid composition guessing.
* fluid property initialisation.
* initialisation from previous simulation run (:code:`ìnit_previous`).
* initialisation from previous simulation run (:code:`init_previous`).
* initialisation from .csv (setting starting values from :code:`init_path`
argument).

Expand Down Expand Up @@ -499,14 +499,14 @@ over-determined.
determine, which parameters are still to be specified.

If you are modeling a cycle, e.g. the Clausius Rankine cylce, you need to make
a cut in the cycle using the cycle_closer or a sink and a source not to
over-determine the system. Have a look in the
a cut in the cycle using the :code:`CycleCloser` or a :code:`Sink` and a
:code:`Source` not to over-determine the system. Have a look in the
:ref:`tutorial section <tespy_basics_label>` to understand why this is
important and how it can be implemented.

If you have provided the correct number of parameters in your system and the
calculations stops after or even before the first iteration, there might be a
couple reasons for that:
couple of reasons for that:

- Sometimes, the fluid property database does not find a specific fluid
property in the initialisation process, have you specified the values in the
Expand Down Expand Up @@ -543,6 +543,15 @@ in this case.
variables. Maybe it is only one variable causing the instability, its
increment is much larger than the increment of the other variables?

If you run multiple simulations and a simulation crashed due to an internal
error (e.g. fluid property related), and you still want the next simulations to
perform correctly, you have to call the
:py:meth:`tespy.networks.network.Network.reset_topology_reduction_specifications`
method after the failed simulation and before you run the next simulation.
Usually, this happens automatically as part of the post-processing, but in case
the simulation crashed before that, this step cannot be executed. Then,
restarting the simulation is not possible.

Did you experience other errors frequently and have a workaround/tips for
resolving them? You are very welcome to contact us and share your experience
for other users!
Expand Down Expand Up @@ -732,7 +741,7 @@ save the network first.
This generates a folder structure containing all relevant files defining your
network (general network information, components, connections, busses,
characteristics) holding the parametrization of that network. You can re-import
characteristics) holding the parametrisation of that network. You can re-import
the network using following code with the path to the saved documents. The
generated network object contains the same information as a TESPy network
created by a python script. Thus, it is possible to set your parameters in the
Expand Down
7 changes: 7 additions & 0 deletions docs/whats_new/v0-7-7.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ Bug Fixes
available in the namespace via the :code:`@component_registry` decorator
(`PR #536 <https://github.com/oemof/tespy/pull/536>`__).


Other Changes
#############
- Make the :code:`reset_topology_reduction_specifications` method of the
`Network` class a public method
(`PR #559 <https://github.com/oemof/tespy/pull/559>`__).

Documentation
#############
- Update deprecated information on the indices of variables in the Jacobian of
Expand Down
8 changes: 4 additions & 4 deletions src/tespy/networks/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -1121,7 +1121,7 @@ def presolve_fluid_topology(self):
}
self.num_conn_vars += 1

def _reset_topology_reduction_specifications(self):
def reset_topology_reduction_specifications(self):
for c in self.conns["object"]:
if hasattr(c, "_m_tmp"):
value = c.m.val_SI
Expand Down Expand Up @@ -1661,7 +1661,7 @@ def init_properties(self):
Initialise the fluid properties on every connection of the network.
- Set generic starting values for mass flow, enthalpy and pressure if
not user specified, read from :code:`ìnit_path` or available from
not user specified, read from :code:`init_path` or available from
previous calculation.
- For generic starting values precalculate enthalpy value at points of
given temperature, vapor mass fraction, temperature difference to
Expand Down Expand Up @@ -1963,7 +1963,7 @@ def solve(self, mode, init_path=None, design_path=None,
self.initialise()

if init_only:
self._reset_topology_reduction_specifications()
self.reset_topology_reduction_specifications()
return

msg = 'Starting solver.'
Expand All @@ -1974,7 +1974,7 @@ def solve(self, mode, init_path=None, design_path=None,
self.solve_loop(print_results=print_results)

if not prepare_fast_lane:
self._reset_topology_reduction_specifications()
self.reset_topology_reduction_specifications()

if self.lin_dep:
msg = (
Expand Down
3 changes: 2 additions & 1 deletion tutorial/advanced/starting_values.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@
nw.solve("design")
except ValueError as e:
print(e)
nw._reset_topology_reduction_specifications()
nw.reset_topology_reduction_specifications()

# %%[sec_4]
import CoolProp.CoolProp as CP

Expand Down

0 comments on commit 43d1137

Please sign in to comment.