Skip to content

Commit dd01226

Browse files
authored
Merge pull request #25 from andr1976/Valve-equations
Valve equations
2 parents 8c9790e + d8db693 commit dd01226

File tree

5 files changed

+89
-0
lines changed

5 files changed

+89
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,4 @@ hyddown/__pycache__/hdclass.cpython-38.pyc
2424
hyddown/__pycache__/transport.cpython-38.pyc
2525
hyddown/__pycache__/tests.cpython-38.pyc
2626
hyddown/__pycache__/validator.cpython-38.pyc
27+
hyddown/__pycache__/hdclass.cpython-38.pyc
-55 Bytes
Binary file not shown.

main.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
with open(input_filename) as infile:
1616
input = yaml.load(infile, Loader=yaml.FullLoader)
1717

18+
1819
hdown=HydDown(input)
1920
hdown.run()
2021
hdown.plot()

requirements.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
streamlit==0.80.0
2+
pandas==1.1.4
3+
matplotlib==3.3.3
4+
numpy==1.19.5
5+
pytest==6.2.3
6+
Cerberus==1.3.3
7+
CoolProp==6.4.1
8+
PyYAML==5.4.1

streamlit_app.py

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# HydDown hydrogen/other gas depressurisation
2+
# Copyright (c) 2021 Anders Andreasen
3+
# Published under an MIT license
4+
5+
import streamlit as st
6+
import matplotlib
7+
import matplotlib.pyplot as plt
8+
import numpy as np
9+
import pandas as pd
10+
from hyddown import HydDown
11+
12+
if __name__ == "__main__":
13+
#matplotlib.use('TkAgg')
14+
15+
sideb = st.sidebar
16+
length = sideb.text_input('Vessel length (m):',10)
17+
diam = sideb.text_input('Vessel diam (m):',3)
18+
orifice_diam = sideb.text_input('Orifice diam (mm):',100)
19+
orifice_diam = float(orifice_diam)/1000
20+
pres = sideb.text_input('Initial pressure (bar):',100)
21+
pres = float(pres)*1e5
22+
temp = sideb.text_input('Initial temperature (C):',25)
23+
temp = float(temp)+273.15
24+
fluid = sideb.selectbox(
25+
'Select fluid',
26+
('N2', 'He', 'H2', 'air', 'CH4'))
27+
option = sideb.selectbox(
28+
'Select calculation type',
29+
('isothermal', 'isenthalpic', 'isentropic'))
30+
31+
tstep = sideb.text_input('Calculation time step (s):',0.5)
32+
end_time = sideb.text_input('Calculation end time (s):',100)
33+
34+
input={}
35+
input['calculation'] = {}
36+
input['vessel'] = {}
37+
input['initial'] = {}
38+
input['valve'] = {}
39+
40+
input['calculation']['type'] = option
41+
input['calculation']['time_step'] = float(tstep)
42+
input['calculation']['end_time'] = float(end_time)
43+
input['vessel']['length'] = float(length)
44+
input['vessel']['diameter'] = float(diam)
45+
input['initial']['pressure'] = pres
46+
input['initial']['temperature'] = temp
47+
input['initial']['fluid'] = fluid
48+
input['valve']['flow'] = 'discharge'
49+
input['valve']['type'] = 'orifice'
50+
input['valve']['diameter'] = float(orifice_diam)
51+
input['valve']['discharge_coef'] = 0.84
52+
input['valve']['back_pressure'] = 1e5
53+
54+
col = st.beta_columns(1)
55+
st.title('HydDown adiabatic demo')
56+
st.subheader(r'https://github.com/andr1976/HydDown')
57+
my_expander = st.beta_expander("Description")
58+
my_expander.write('Real gas vessel depressurisation for pure and pseudo-pure components. No heat transfer is enabled in this demo version.')
59+
60+
col1, col2= st.beta_columns(2)
61+
hdown=HydDown(input)
62+
hdown.run()
63+
64+
temp_data = pd.DataFrame({'Time (s)': hdown.time_array, 'Temperature (C)': hdown.T_fluid-273.15})
65+
pres_data = pd.DataFrame({'Time (s)': hdown.time_array, 'Pressure (bar)': hdown.P/1e5})
66+
67+
col1.line_chart(pres_data.rename(columns={'Time (s)':'index'}).set_index('index'))
68+
col1.text('Time (s)')
69+
col2.line_chart(temp_data.rename(columns={'Time (s)':'index'}).set_index('index'))
70+
col2.text('Time (s)')
71+
72+
73+
mdot_data = pd.DataFrame({'Time (s)': hdown.time_array, 'Mass rate (kg/s)': hdown.mass_rate})
74+
mass_data = pd.DataFrame({'Time (s)': hdown.time_array, 'Fluid inventory (kg)': hdown.mass_fluid})
75+
col1.line_chart(mdot_data.rename(columns={'Time (s)':'index'}).set_index('index'))
76+
col1.text('Time (s)')
77+
col2.line_chart(mass_data.rename(columns={'Time (s)':'index'}).set_index('index'))
78+
col2.text('Time (s)')
79+

0 commit comments

Comments
 (0)