def test_dataframe(): from hyddown import HydDown input = get_example_input("controlvalve.yml") hdown = HydDown(input) hdown.run() df = hdown.get_dataframe()
def test_sim_orifice_full(): from hyddown import HydDown input = get_example_input("input.yml") hdown = HydDown(input) hdown.run() hdown.plot(verbose=False) hdown.generate_report() assert hdown.report['final_mass'] == pytest.approx(0.14, rel=0.02) assert hdown.report['min_wall_temp'] == pytest.approx(284.9, rel=0.01) assert hdown.report['min_fluid_temp'] == pytest.approx(193.7, rel=0.01) assert hdown.report['time_min_fluid_temp'] == pytest.approx(37., rel=0.01) assert hdown.report['max_mass_rate'] == pytest.approx(0.88, rel=0.01)
input['heat_transfer']['temp_ambient'] = temp_amb input['heat_transfer']['h_outer'] = 5 if heattran == True: input['heat_transfer']['h_inner'] = 'calc' else: input['heat_transfer']['h_inner'] = 0.0 input['heat_transfer']['D_throat'] = float(diam) return input if __name__ == "__main__": #matplotlib.use('TkAgg') st.set_page_config(layout='wide') input = read_input() hdown = HydDown(input) with st.spinner('Calculating, please wait....'): hdown.run(disable_pbar=True) st.title('HydDown rigorous demo') st.subheader(r'https://github.com/andr1976/HydDown') my_expander = st.expander("Description") my_expander.write( 'Real gas vessel depressurisation with heat transfer from gas to vessel and ambient and vice versa. Flow is controlled via an ANSI/ISA control valve.' ) my_expander.write( 'For more information about the calculations and validation of the code please refer to the [manual](https://github.com/andr1976/HydDown/raw/main/docs/MANUAL.pdf)' )
def test_sim_stefan_boltzmann(): from hyddown import HydDown input = get_example_input("psv_sb.yml") hdown = HydDown(input) hdown.run()
def test_multicomponent(): from hyddown import HydDown input = get_example_input("ng.yml") hdown = HydDown(input) hdown.run()
def test_sim_filling(): from hyddown import HydDown input = get_example_input("filling.yml") hdown = HydDown(input) hdown.run()
def test_isenthalpic(): from hyddown import HydDown input = get_example_input("isenthalpic.yml") hdown = HydDown(input) hdown.run()
def test_sim_psv(): from hyddown import HydDown input = get_example_input("psv.yml") hdown = HydDown(input) hdown.run()
def test_sim_controlvalve(): from hyddown import HydDown input = get_example_input("controlvalve.yml") hdown = HydDown(input) hdown.run()
input['valve']['discharge_coef'] = 0.975 input['valve']['set_pressure'] = set_pressure input['valve']['back_pressure'] = back_pressure input['valve']['blowdown'] = blowdown #input['valve']['end_pressure']=end_pressure input['heat_transfer']['type']='s-b' input['heat_transfer']['fire']=fire_type return input if __name__ == "__main__": st.set_page_config(layout='wide') input = read_input() hdown=HydDown(input) hdown.run() st.title('HydDown rigorous gas vessel fire PSV discharge calculation') st.subheader(r'https://github.com/andr1976/HydDown') my_expander = st.expander("Description") my_expander.write('Real gas vessel fire PSV relief with fire modelled via Stefan-Boltzmann equation. Orifice size (Cd = 0.975) is specified.') my_expander.write('For more information about the calculations and validation of the code please refer to the [manual](https://github.com/andr1976/HydDown/raw/main/docs/MANUAL.pdf)') df=hdown.get_dataframe() file_name=st.text_input('Filename for saving data:','saved_data') st.markdown(get_table_download_link(df,file_name), unsafe_allow_html=True) col1, col2= st.columns(2)
input['valve']['flow'] = 'discharge' input['valve']['type'] = 'orifice' input['valve']['diameter'] = float(orifice_diam) input['valve']['discharge_coef'] = 0.84 input['valve']['back_pressure'] = 1e5 col = st.columns(1) st.title('HydDown adiabatic demo') st.subheader(r'https://github.com/andr1976/HydDown') my_expander = st.expander("Description") my_expander.write( 'Real gas vessel depressurisation for pure and pseudo-pure ' + 'components. No heat transfer is enabled in this demo version.') col1, col2 = st.columns(2) hdown = HydDown(input) hdown.run() temp_data = pd.DataFrame({ 'Time (s)': hdown.time_array, 'Temperature (C)': hdown.T_fluid - 273.15 }) pres_data = pd.DataFrame({ 'Time (s)': hdown.time_array, 'Pressure (bar)': hdown.P / 1e5 }) col1.line_chart( pres_data.rename(columns={ 'Time (s)': 'index' }).set_index('index'))
# HydDown hydrogen/other gas depressurisation # Copyright (c) 2021 Anders Andreasen # Published under an MIT license import yaml import sys try: from hyddown import HydDown except: import sys 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 if __name__ == "__main__": if len(sys.argv) > 1: input_filename = sys.argv[1] else: input_filename = "input.yml" with open(input_filename) as infile: input = yaml.load(infile, Loader=yaml.FullLoader) hdown = HydDown(input) hdown.run(disable_pbar=False) hdown.plot()
# HydDown hydrogen/other gas depressurisation # Copyright (c) 2021 Anders Andreasen # Published under an MIT license import yaml import sys try: from hyddown import HydDown except: import sys import os sys.path.append(os.path.abspath("../src")) from hyddown import HydDown if __name__ == "__main__": if len(sys.argv) > 1: input_filename = sys.argv[1] else: input_filename = "input.yml" with open(input_filename) as infile: input = yaml.load(infile, Loader=yaml.FullLoader) hdown = HydDown(input) hdown.run() hdown.plot('docs/img/' + input_filename.split('\\')[1].split('.')[0] + '.png')