diff --git a/.gitignore b/.gitignore index 3a7ba42..83a5626 100644 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/Manual.md b/Manual.md index 358f155..33a9372 100644 --- a/Manual.md +++ b/Manual.md @@ -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. diff --git a/dist/HydDown-0.16.1-py3-none-any.whl b/dist/HydDown-0.16.1-py3-none-any.whl deleted file mode 100644 index 0d4f8e2..0000000 Binary files a/dist/HydDown-0.16.1-py3-none-any.whl and /dev/null differ diff --git a/dist/HydDown-0.16.1.tar.gz b/dist/HydDown-0.16.1.tar.gz deleted file mode 100644 index 8a21bc8..0000000 Binary files a/dist/HydDown-0.16.1.tar.gz and /dev/null differ diff --git a/dist/HydDown-0.16.2-py3-none-any.whl b/dist/HydDown-0.16.2-py3-none-any.whl new file mode 100644 index 0000000..68c706f Binary files /dev/null and b/dist/HydDown-0.16.2-py3-none-any.whl differ diff --git a/dist/HydDown-0.16.2.tar.gz b/dist/HydDown-0.16.2.tar.gz new file mode 100644 index 0000000..4617bd0 Binary files /dev/null and b/dist/HydDown-0.16.2.tar.gz differ diff --git a/docs/references.bib b/docs/references.bib index 1edb50d..92e925c 100644 --- a/docs/references.bib +++ b/docs/references.bib @@ -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}, @@ -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,", - } \ No newline at end of file + } + + @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} +} \ No newline at end of file diff --git a/joss/paper.bib b/joss/paper.bib index 396d168..a7470e1 100644 --- a/joss/paper.bib +++ b/joss/paper.bib @@ -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} +} \ No newline at end of file diff --git a/joss/paper.md b/joss/paper.md index a4b57ae..e04cb92 100644 --- a/joss/paper.md +++ b/joss/paper.md @@ -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. @@ -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 | |-------------------------------|-----------------------|-----------------------|-------------------| @@ -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 diff --git a/requirements.txt b/requirements.txt index 2379756..6d1d31d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,5 @@ -streamlit>=0.81.1 +tqdm +streamlit>=0.89 pandas>=1.1.4 matplotlib>=3.3.3 numpy>=1.19.5 @@ -6,4 +7,4 @@ pytest>=6.2.3 Cerberus>=1.3.3 CoolProp>=6.4.1 PyYAML>=5.4.1 -scipy>=1.6.0 \ No newline at end of file +scipy>=1.6.0 diff --git a/scripts/hyddown_main.py b/scripts/hyddown_main.py index a36b33f..96cc250 100644 --- a/scripts/hyddown_main.py +++ b/scripts/hyddown_main.py @@ -4,7 +4,6 @@ import yaml import sys -import time try: from hyddown import HydDown @@ -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 @@ -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() \ No newline at end of file diff --git a/scripts/streamlit_app.py b/scripts/streamlit_app.py index da0481d..b9d2691 100644 --- a/scripts/streamlit_app.py +++ b/scripts/streamlit_app.py @@ -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') diff --git a/setup.cfg b/setup.cfg index dca98d2..ce6be98 100644 --- a/setup.cfg +++ b/setup.cfg @@ -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 @@ -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 diff --git a/src/HydDown.egg-info/PKG-INFO b/src/HydDown.egg-info/PKG-INFO index 48a42b4..8b75e25 100644 --- a/src/HydDown.egg-info/PKG-INFO +++ b/src/HydDown.egg-info/PKG-INFO @@ -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 diff --git a/src/HydDown.egg-info/requires.txt b/src/HydDown.egg-info/requires.txt index 6e61160..6d1d31d 100644 --- a/src/HydDown.egg-info/requires.txt +++ b/src/HydDown.egg-info/requires.txt @@ -1,4 +1,5 @@ -streamlit>=0.81.1 +tqdm +streamlit>=0.89 pandas>=1.1.4 matplotlib>=3.3.3 numpy>=1.19.5 diff --git a/src/hyddown/__pycache__/hdclass.cpython-38.pyc b/src/hyddown/__pycache__/hdclass.cpython-38.pyc index ef1cd73..a56007f 100644 Binary files a/src/hyddown/__pycache__/hdclass.cpython-38.pyc and b/src/hyddown/__pycache__/hdclass.cpython-38.pyc differ diff --git a/src/hyddown/hdclass.py b/src/hyddown/hdclass.py index 08f7adf..2debbcc 100644 --- a/src/hyddown/hdclass.py +++ b/src/hyddown/hdclass.py @@ -5,6 +5,7 @@ import math import numpy as np import pandas as pd +from tqdm import tqdm from scipy.optimize import fmin from scipy.optimize import minimize from CoolProp.CoolProp import PropsSI @@ -308,11 +309,12 @@ def UDproblem(self, U, rho, Pguess, Tguess): return P1, T1, Ures - def run(self): + def run(self,disable_pbar=True): """ Routine for running the actual problem defined i.e. integrating the mass and energy balances """ # Inititialise / setting initial values for t=0 + if self.isrun == True: self.initialize() input = self.input self.rho[0] = self.rho0 self.T_fluid[0] = self.T0 @@ -325,7 +327,6 @@ def run(self): self.P[0] = self.p0 self.mass_fluid[0] = self.m0 cpcv = self.fluid.cp0molar() / self.fluid.cvmolar() - massflow_stop_switch = 0 # Calculating initial mass rate for t=0 depending on mass flow device @@ -411,7 +412,7 @@ def run(self): # Run actual integration by updating values by numerical integration/time stepping # Mass of fluid is calculated from previous time step mass and mass flow rate - for i in range(1, len(self.time_array)): + for i in tqdm(range(1, len(self.time_array)),desc='hyddown',disable=disable_pbar,total=len(self.time_array)): self.time_array[i] = self.time_array[i - 1] + self.tstep self.mass_fluid[i] = ( self.mass_fluid[i - 1] - self.mass_rate[i - 1] * self.tstep @@ -561,7 +562,7 @@ def run(self): self.S_mass[i] = self.fluid.smass() self.U_mass[i] = self.fluid.umass() - print("Progress", int(i/(self.time_tot / self.tstep)*100),"%",end="\r") + #print("Progress", int(i/(self.time_tot / self.tstep)*100),"%",end="\r") # Calculating vent temperature (adiabatic) only for discharge problem if self.input["valve"]["flow"] == "discharge": @@ -626,6 +627,7 @@ def run(self): self.mass_rate[i]=0 self.isrun = True + def get_dataframe(self): """ Storing relevant results in pandas dataframe for e.g. export diff --git a/src/main.py b/src/main.py index 254009a..96a7f68 100644 --- a/src/main.py +++ b/src/main.py @@ -5,7 +5,6 @@ import yaml import sys from hyddown import HydDown -import time if __name__ == "__main__": @@ -19,11 +18,6 @@ hdown=HydDown(input) - start = time.time() - hdown.run() - end = time.time() - print('Elapsed time: ',end-start,' sec.') - hdown.plot() - - hdown.fluid.build_phase_envelope("None") - PE=hdown.fluid.get_phase_envelope_data() \ No newline at end of file + hdown.run(disable_pbar=False) + + hdown.plot() \ No newline at end of file