Skip to content

Commit

Permalink
Merge pull request #70 from andr1976/revise-andr1976
Browse files Browse the repository at this point in the history
Revise andr1976
  • Loading branch information
andr1976 authored Oct 4, 2021
2 parents c52ac6d + 2d599f9 commit 3f43cf3
Show file tree
Hide file tree
Showing 18 changed files with 124 additions and 42 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,4 @@ src/hyddown/__pycache__/validator.cpython-38.pyc
src/hyddown/__pycache__/hdclass.cpython-38.pyc
.gitignore
src/hyddown/__pycache__/validator.cpython-38.pyc
src/hyddown/__pycache__/hdclass.cpython-38.pyc
1 change: 1 addition & 0 deletions Manual.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ where python3 is the symlink or full path to the python3 executable installed on
- [PyYaml](https://pypi.org/project/PyYAML/)
- [pandas](https://pandas.pydata.org/)
- [Scipy](https://www.scipy.org/)
- [tqdm](https://tqdm.github.io/)

The script is running on Windows 10 x64, with stock python installation from python.org and packages installed using pip.
It should also run on Linux (it does on an Ubuntu image on GitHub) or in any conda environment as well, but I haven't checked.
Expand Down
Binary file removed dist/HydDown-0.16.1-py3-none-any.whl
Binary file not shown.
Binary file removed dist/HydDown-0.16.1.tar.gz
Binary file not shown.
Binary file added dist/HydDown-0.16.2-py3-none-any.whl
Binary file not shown.
Binary file added dist/HydDown-0.16.2.tar.gz
Binary file not shown.
45 changes: 43 additions & 2 deletions docs/references.bib
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ @article{Bjerre2017
year = {2017}
}

@Article{safety4010011,
@article{safety4010011,
AUTHOR = {Andreasen, Anders and Borroni, Filippo and Zan Nieto, Marcos and Stegelmann, Carsten and P. Nielsen, Rudi},
TITLE = {On the Adequacy of API 521 Relief-Valve Sizing Method for Gas-Filled Pressure Vessels Exposed to Fire},
JOURNAL = {Safety},
Expand Down Expand Up @@ -199,4 +199,45 @@ @misc{firstlaw
url = "https://commons.wikimedia.org/wiki/File:First_law_open_system.svg",
note = "Adapted from DOE-HDBK-1012/1-92, Thermodynamics, Heat Transfer, and Fluid Flow, Volume 1 of 3, 2014. U.S. Department of Energy",
year = " 2008,",
}
}

@software{tqdmref,
author = {Casper da Costa-Luis and
Stephen Karl Larroque and
Kyle Altendorf and
Hadrien Mary and
richardsheridan and
Mikhail Korobov and
Noam Yorav-Raphael and
Ivan Ivanov and
Marcel Bargull and
Nishant Rodrigues and
Guangshuo CHEN and
Antony Lee and
Charles Newey and
James and
Joshua Coales and
Martin Zugnoni and
Matthew D. Pagel and
mjstevens777 and
Mikhail Dektyarev and
Alex Rothberg and
Alexander and
Daniel Panteleit and
Fabian Dill and
FichteFoll and
Gregor Sturm and
HeoHeo and
Hugo van Kemenade and
Jack McCracken and
MapleCCC and
Max Nordlund},
title = {{tqdm: A fast, Extensible Progress Bar for Python
and CLI}},
month = sep,
year = 2021,
publisher = {Zenodo},
version = {v4.62.3},
doi = {10.5281/zenodo.5517697},
url = {https://doi.org/10.5281/zenodo.5517697}
}
41 changes: 41 additions & 0 deletions joss/paper.bib
Original file line number Diff line number Diff line change
Expand Up @@ -298,3 +298,44 @@ @article{SHAFIQ2020104
doi = {10.1016/j.psep.2019.10.035},
author = {Umar Shafiq and Azmi M. Shariff and Muhammad Babar and Babar Azeem and Abulhassan Ali and Mohamad Azmi Bustam},
}

@software{tqdmref,
author = {Casper da Costa-Luis and
Stephen Karl Larroque and
Kyle Altendorf and
Hadrien Mary and
richardsheridan and
Mikhail Korobov and
Noam Yorav-Raphael and
Ivan Ivanov and
Marcel Bargull and
Nishant Rodrigues and
Guangshuo CHEN and
Antony Lee and
Charles Newey and
James and
Joshua Coales and
Martin Zugnoni and
Matthew D. Pagel and
mjstevens777 and
Mikhail Dektyarev and
Alex Rothberg and
Alexander and
Daniel Panteleit and
Fabian Dill and
FichteFoll and
Gregor Sturm and
HeoHeo and
Hugo van Kemenade and
Jack McCracken and
MapleCCC and
Max Nordlund},
title = {{tqdm: A fast, Extensible Progress Bar for Python
and CLI}},
month = sep,
year = 2021,
publisher = {Zenodo},
version = {v4.62.3},
doi = {10.5281/zenodo.5517697},
url = {https://doi.org/10.5281/zenodo.5517697}
}
28 changes: 14 additions & 14 deletions joss/paper.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,25 @@ bibliography: paper.bib
---

# Summary
HydDown [@anders_andreasen_2021_5154096] is a Python package for calculation of pressure vessel behaviour during filling (pressurisation) or discharge (depressurisation/blow-down). More specifically the software allows calculation of vessel pressure, fluid inventory temperature as well as vessel wall temperature as a function of time during either filling or discharge operations. The applications are manifold and some examples are:
HydDown [@anders_andreasen_2021_5154096] is a Python package for calculation of pressure vessel behaviour during filling (pressurisation) or discharge (depressurisation/blow-down). More specifically, the software allows calculation of vessel pressure, fluid inventory temperature as well as vessel wall temperature as a function of time during either filling or discharge operations. The applications are manifold and some examples are:

* Rapid filling of vehicle high-pressure hydrogen cylinders
* Rapid emergency discharge from high pressure gas cylinders
* Dynamic pressure safety valve behaviour for gas filled pressure vessels subject to fire heat load
* Rapid emergency discharge from high-pressure gas cylinders
* Dynamic pressure safety valve behaviour for gas-filled pressure vessels subject to fire heat load

A typical system modelled is shown in \autoref{fig:sketch} and it visualizes the key parameters and transport phenomena during gas vessel filling or discharging. The thermodynamic state inside the vessel changes over time as seen from immediately observable variables temperature (T) and pressure (P). This is caused by change in fluid inventory (density) due to flow of gas either in- or out of the vessel. Further, heat is transfered from or to the surroundings via convective heat transfer on the in- and outside of the vessel - with heat being conducted thorugh the vessel wall. The easiest way to explore the basic capabilities fo the code is via the [HydDown Streamlit app](https://share.streamlit.io/andr1976/hyddown/main/scripts/streamlit_app.py).
A typical system modelled is shown in \autoref{fig:sketch} and it visualizes the key parameters and transport phenomena during gas vessel filling or discharging. The thermodynamic state inside the vessel changes over time as seen from immediately observable variables temperature (T) and pressure (P). This is caused by a change in fluid inventory (density) due to flow of gas either in or out of the vessel. Furthermore, heat is transfered from or to the surroundings via convective heat transfer on the in- and outside of the vessel - with heat being conducted through the vessel wall. The easiest way to explore the basic capabilities fo the code is via the [HydDown Streamlit app](https://share.streamlit.io/andr1976/hyddown/main/scripts/streamlit_app.py).

![Gas filled pressure vessel subject to gas discharge and heat transfer between vessel and gas inventory. \label{fig:sketch}](../docs/img/Sketch.png){ width=80% }
![Gas-filled pressure vessel subject to gas discharge and heat transfer between vessel and gas inventory. \label{fig:sketch}](../docs/img/Sketch.png){ width=70% }

In its essence the code solves the mass and energy balances, with gas thermodynamics calculated using the [CoolProp](http://www.coolprop.org/) library [@doi:10.1021/ie4033999] including both real gas equation of state and gas transport properties. The energy balance is the first law of thermodynamics for an open system exchanging both heat and mass with the surroundings [@sva]. Heat transfer between gas inventory and vessel wall is accounted for using either natural convection or mixed forced convection/natural convection [@woodfield][@geankoplis]. The mass balance is closed using an applicable flow equation e.g. orifice [@yellowbook], relief valve [@API520], control valve [@borden][@ISA][@IEC60534], a fixed mass rate or a predefined mass rate in or out of the pressure vessel.
The code also allows an external heat load to be applied using the Stefan-Boltzmann equation for fire heat load minimcking background heat load from both pool and jet fire [@scandpower][@API521].
In its essence, the code solves the mass and energy balances with gas thermodynamics calculated using the [CoolProp](http://www.coolprop.org/) library [@doi:10.1021/ie4033999] including both real gas equation of state and gas transport properties. The energy balance is the first law of thermodynamics for an open system exchanging both heat and mass with the surroundings [@sva]. Heat transfer between gas inventory and vessel wall is accounted for using either natural convection or mixed forced convection/natural convection [@woodfield][@geankoplis]. The mass balance is closed using an applicable flow equation e.g. orifice [@yellowbook], relief valve [@API520], control valve [@borden][@ISA][@IEC60534], a fixed mass rate or a predefined mass rate in or out of the pressure vessel.
The code also allows an external heat load to be applied using the Stefan-Boltzmann equation for fire heat load mimicking background heat load from both pool and jet fire [@scandpower][@API521].

A few choices has been made to keep things simple:
A few choices have been made to keep things simple:

- [Coolprop](http://www.coolprop.org/) is used as thermodynamic backend
- Gas phase only
- No temperature stratification in vessel inventory
- No temperature gradient through vessel wall (applicable for high heat conductivity / thin walled vessels)
- No temperature gradient through vessel wall (applicable for high heat conductivity / thin-walled vessels)

Still, the code allows a variety of mass flow devices and heat transfer both with ambient air and also considering fire heat loads, with the vessel fluid inventory being rigorously described by a Helmholtz energy formulation of a real gas equation of state. Typical calculation output is shown in \autoref{fig:N2discharge} and \autoref{fig:H2filling} with experimental data included for comparison.

Expand All @@ -48,9 +48,9 @@ Still, the code allows a variety of mass flow devices and heat transfer both wit
![Simulation of hydrogen cylinder pressurisation using a pressurisation rate of 10 MPa/min. Comparison between calculated (full line) and measured gas temperature [@STRIEDNIG] (stipulated line) is shown in the upper left graph. \label{fig:H2filling}](../docs/img/Striednig_fillingH2_10MPa_min.png)

# Statement of need
With an increasing demand of clean(er) energy and associated storage such as e.g. on-board hydrogen storage for hydrogen powered vehicles, compressed air energy storage (CAES), compressed biogas, compressed natural gas (CNG) etc., the need for tools which can simulate the filling and emptying of the pressure containers holding the fluid is indeed present both for operational reasons, but even more important for safety reasons.
With an increasing demand of clean(er) energy and associated storage such as e.g. on-board hydrogen storage for hydrogen powered vehicles, compressed air energy storage (CAES), compressed biogas, compressed natural gas (CNG) etc., the need for tools, which can simulate the filling and emptying of the pressure containers holding the fluid is indeed present both for operational reasons, but even more importantly for safety reasons.

Apparently, no free (as in speach, as in beer) tool exists today which accomplishes the same tasks as HydDown. It has been one of the main goals in producing this software to provide a free tool which can calculate the pressure vessel response during filling and discharge of gas. There are however many tools in the market which can do a subset of HydDown capabilities, the same as HydDown, or even more. Most of these tools are commercial/proprietary (and closed source) and comes with a significant license cost. A single tool has been identified which is free (as in beer), but still closed source [@h2fills]. Below is a partial list of tools which has comparable capabilities as HydDown - for review of more codes, please refer to [@SHAFIQ2020104].
Apparently, no free (as in speach, as in beer) tool exists today which accomplishes the same tasks as HydDown. It has been one of the main goals in producing this software to provide a free tool, which can calculate the pressure vessel response during filling and discharge of gas. There are, however, many tools available which can do a subset of HydDown capabilities, the same as HydDown, or even more. Most of these tools are commercial/proprietary (and closed source) and comes with a significant license cost. A single tool has been identified, which is free (as in beer), but still closed source [@h2fills]. Below is a partial list of tools, which have comparable capabilities as HydDown - for review of more codes, please refer to [@SHAFIQ2020104].

| Software | Cost | Filling/discharge | Fire heat laod |
|-------------------------------|-----------------------|-----------------------|-------------------|
Expand All @@ -60,16 +60,16 @@ Apparently, no free (as in speach, as in beer) tool exists today which accomplis
| BLOWSIM [@blowsim] | N/A | Discharge | Yes |
| H2FillS [@h2fills] | Free | Filling | No |

Compared to other software codes HydDown has a number of advantages: It is open source, computations are fast - especially for single component gas, the code is simple to install, the code is easy to run using a simple input file format, both filling and discharge can be handled and fire heat load can be handled for calculations of emergency response. In this way the code has advantages over existing codes on one or more parameters. However, the code is still limited to gas phase bahaviour and heat transfer through the vessel wall is not rigorously modelled. Hence composite cylinders with different layers of material may give inaccurate results, especially for low heat conductivity materials. Some of the above codes can handle this.
Compared to other software codes, HydDown has a number of advantages: It is open source, computations are fast - especially for single component gas, the code is simple to install, the code is easy to run using a simple input file format, both filling and discharge can be handled and fire heat load can be handled for calculations of emergency response. In this way, the code has advantages over existing codes on one or more parameters. However, the code is still limited to gas phase behaviour and heat transfer through the vessel wall is not rigorously modelled. Hence composite cylinders with different layers of material may give inaccurate results, especially for low heat conductivity materials. Some of the above codes can handle this.

It is the intent that the present software can be of use for a number of tasks including (but not limited to):

* Design aid for experimental facilities for e.g. mass flow device sizing e.g. orifice, control valve etc.
* Benchmarking of other software codes.
* Safety device sizing and review (blow-down valve, pressure safety valve), for instance how fast shall blow-down be? How large should an installed pressure safety valve be?
* Thermal response of vessel during filling/discharge. Is the design (lower/upper) temperatures exceeded? Shall the rate be lower? Is any pre-cooling/heating required?
* Thermal response of vessel during filling/discharge. Is the design (lower/upper) temperatures exceeded? Should the rate be lower? Is any pre-cooling/heating required?

# Acknowledgements
The making of this project would not have possible without the great [CoolProp](http://www.coolprop.org/) library [@doi:10.1021/ie4033999]. The author is also thankful for enlightning discussions with colleague Jacob Gram Iskov Eriksen (Ramboll Energy, Denmark) and former Ramboll Energy colleague Carsten Stegelmann (ORS Consulting) in relation to vessel depressurisation, nozzle flow and heat transfer considerations. This work has also befitted significantly from the understanding of thermo mechanical pressure vessel behaviour obtained in previous works [@Bjerre2017],[@safety4010011],[@iskov]. Furthermore, this project relies on high quality open source Python packages: NumPy [@Walt:2011:NAS:1957373.1957466][@harris2020array], SciPy [@virtanen2020scipy], matplotlib [@Hunter:2007], pandas [@mckinney-proc-scipy-2010], [PyYaml](https://pyyaml.org/wiki/PyYAMLDocumentation), [cerberus](https://docs.python-cerberus.org/en/stable/), [Streamlit](https://streamlit.io/) and pytest [@pytest].
The making of this project would not have been possible without the great [CoolProp](http://www.coolprop.org/) library [@doi:10.1021/ie4033999]. The author is also thankful for enlightning discussions with colleague Jacob Gram Iskov Eriksen (Ramboll Energy, Denmark) and former Ramboll Energy colleague Carsten Stegelmann (ORS Consulting) in relation to vessel depressurisation, nozzle flow and heat transfer considerations. This work has also benefitted significantly from the understanding of thermo-mechanical pressure vessel behaviour obtained in previous works [@Bjerre2017],[@safety4010011],[@iskov]. Furthermore, this project relies on high quality open source Python packages: NumPy [@Walt:2011:NAS:1957373.1957466][@harris2020array], SciPy [@virtanen2020scipy], matplotlib [@Hunter:2007], pandas [@mckinney-proc-scipy-2010], [PyYaml](https://pyyaml.org/wiki/PyYAMLDocumentation), [cerberus](https://docs.python-cerberus.org/en/stable/), [Streamlit](https://streamlit.io/), tqdm [@tqdmref] and pytest [@pytest]. Sussanne Tolstrup, language secretary at Ramboll Energy, Field Development, is acknowledged for proofreading this manuscript.

# References
5 changes: 3 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
streamlit>=0.81.1
tqdm
streamlit>=0.89
pandas>=1.1.4
matplotlib>=3.3.3
numpy>=1.19.5
pytest>=6.2.3
Cerberus>=1.3.3
CoolProp>=6.4.1
PyYAML>=5.4.1
scipy>=1.6.0
scipy>=1.6.0
9 changes: 3 additions & 6 deletions scripts/hyddown_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import yaml
import sys
import time

try:
from hyddown import HydDown
Expand All @@ -13,7 +12,7 @@
import os
hyddown_path = os.path.join(os.path.abspath(os.path.dirname(__file__)),"..","src")
sys.path.append(os.path.abspath(hyddown_path))

from hyddown import HydDown


Expand All @@ -28,8 +27,6 @@


hdown=HydDown(input)
start = time.time()
hdown.run()
end = time.time()
print('Elapsed time: ',end-start,' sec.')

hdown.run(disable_pbar=False)
hdown.plot()
4 changes: 3 additions & 1 deletion scripts/streamlit_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,9 @@ def read_input():

input = read_input()
hdown=HydDown(input)
hdown.run()

with st.spinner('Calculating, please wait....'):
hdown.run(disable_pbar=True)

st.title('HydDown rigorous demo')
st.subheader(r'https://github.com/andr1976/HydDown')
Expand Down
5 changes: 3 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = HydDown
version = 0.16.1
version = 0.16.2
author = Anders Andreasen
author_email = andr1976@gmail.com
description = Hydrogen (or other pure gas phase species) pressure vessel filling and discharge calculations
Expand All @@ -23,7 +23,8 @@ scripts =
python_requires = >=3.6
include_package_data = True
install_requires =
streamlit>=0.81.1
tqdm
streamlit>=0.89
pandas>=1.1.4
matplotlib>=3.3.3
numpy>=1.19.5
Expand Down
2 changes: 1 addition & 1 deletion src/HydDown.egg-info/PKG-INFO
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Metadata-Version: 2.1
Name: HydDown
Version: 0.16.1
Version: 0.16.2
Summary: Hydrogen (or other pure gas phase species) pressure vessel filling and discharge calculations
Home-page: https://github.com/andr1976/HydDown/
Author: Anders Andreasen
Expand Down
3 changes: 2 additions & 1 deletion src/HydDown.egg-info/requires.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
streamlit>=0.81.1
tqdm
streamlit>=0.89
pandas>=1.1.4
matplotlib>=3.3.3
numpy>=1.19.5
Expand Down
Binary file modified src/hyddown/__pycache__/hdclass.cpython-38.pyc
Binary file not shown.
Loading

0 comments on commit 3f43cf3

Please sign in to comment.