oemof / tespy

Thermal Engineering Systems in Python (TESPy). This package provides a powerful simulation toolkit for thermal engineering plants such as power plants, district heating systems or heat pumps.
https://tespy.readthedocs.io
MIT License
272 stars 85 forks source link

Add tutorial with deleting and adding connections #288

Closed OskarRaftegard closed 2 years ago

OskarRaftegard commented 2 years ago

I'm following the heat pump tutorial. When solving the second part of the model, "Valve and evaporator system", I get an error message:

"ERROR:root:All Components must have unique labels, duplicate labels are: "valve".

These are the "dummy-sink" and the real valve component.

1) Somehow I do not think this is expected? Setting up the dummy-sink valve as va = Sink('valve') when modeling the consumer system was supposed to make it easy to replace it when modelling the valve and evaporator.

2) How du you drop / remove / change a component? The obvious solution above is of course to remove the dummy valve from the code, as soon as the consumer system is verified. But is there a way to delete a component? I could only find a way to delete connectors ( del_conns).

(Btw, I discovered a Pandas DataFrame, nw.comps. But dropping the row with the dummy did not help. What is this DataFrame?

fwitte commented 2 years ago

Hi Oskar,

thank you for reaching out! The network is generated from the connection information, therefore you do not add or delete components but connections instead:

  1. Delete the connection with the Sink nw.del_conns(cd_va).
  2. Create the Valve component va = Valve('valve')
  3. Create a new connection with the actual valve cd_va = Connection(cd, 'out1', va, 'in1')
  4. Add the newly created connection to the network nw.add_conns(cd_va)

I will clarify this in the tutorial section once I find the time. When we created the tutorial, I was going with the solution you suggested in 2., but using this solution might be favorable in many cases, especially with larger networks.

To your second question: The DataFrames (nw.comps and nw.conns) are only used internally to handle equation and derivative calculation as well as some pre- and postprocessing steps. If you want to export the results of a simulation, you can use the nw.results dictionary, which contains pandas DataFrames for each class of component (e.g. nw.results['HeatExchanger']) as well as the connections nw.results['Connection'] and busses nw.results['Bus']. The key is the respective class name.

If there are any other questions or improvements you'd like to suggest, I'd be glad if you let me know.

Best regards and have a nice day Francesco

OskarRaftegard commented 2 years ago

Thanks! Problem solved. Do not know if you want to close issue or keep it open it until tutorial updated?

Best regards, Oskar


Other minor heat pump tutorial improvements:

The tutorial is however very well written as it is!

I'm looking onto making better char_maps for refrigeration compressors. Something that is closer to commercially available compressors. As example have a look at Figure 3 and 4 in below paper: https://www.researchgate.net/publication/281476915_Reciprocating_and_Screw_Compressor_semi-empirical_models_for_establishing_minimum_energy_performance_standards

fwitte commented 2 years ago

Thanks! Problem solved. Do not know if you want to close issue or keep it open it until tutorial updated?

Will keep this open as reminder, thank you for your feedback!

I'm looking onto making better char_maps for refrigeration compressors. Something that is closer to commercially available compressors. As example have a look at Figure 3 and 4 in below paper: https://www.researchgate.net/publication/281476915_Reciprocating_and_Screw_Compressor_semi-empirical_models_for_establishing_minimum_energy_performance_standards

That sounds nice, let me know if you need any assistance or guidance in integrating the data in the models or the codebase. We can also easily create a new parameter/equation in the Compressor class, if required. Also, as far as I know @maltefritz and @jfreissmann are working in a project where characteristic curves for different types of compressors are required as well. At least regarding the implementation of new methods there might be common tasks.

fwitte commented 2 years ago

All issues have been fixed here, closing this.

In case you still have questions/ideas please reach out at any time :)