folder restructuring on Dev branch
This commit is contained in:
6
.gitignore
vendored
6
.gitignore
vendored
@@ -1,6 +1,4 @@
|
||||
2bignored.txt
|
||||
functions/__pycache__/
|
||||
*__pycache__/
|
||||
.vscode/settings.json
|
||||
__pycache__/Ausgleichsbecken_class_file.cpython-38.pyc
|
||||
__pycache__/Ausgleichsbecken.cpython-38.pyc
|
||||
__pycache__/functions.cpython-38.pyc
|
||||
*.pyc
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from Ausgleichsbecken import FODE_function, get_h_halfstep, get_p_halfstep
|
||||
from functions.pressure_conversion import pressure_conversion
|
||||
from pressure_conversion import pressure_conversion
|
||||
class Ausgleichsbecken_class:
|
||||
# units
|
||||
area_unit = r'$\mathrm{m}^2$'
|
||||
@@ -2,19 +2,19 @@
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 10,
|
||||
"execution_count": 2,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import numpy as np\n",
|
||||
"from Ausgleichsbecken_class_file import Ausgleichsbecken_class\n",
|
||||
"import matplotlib.pyplot as plt\n",
|
||||
"from functions.pressure_conversion import pressure_conversion"
|
||||
"from pressure_conversion import pressure_conversion"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 11,
|
||||
"execution_count": 3,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
@@ -39,13 +39,13 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 12,
|
||||
"execution_count": 4,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"application/vnd.jupyter.widget-view+json": {
|
||||
"model_id": "c7ff9cd7c3ae4d21a32d833650fa73a3",
|
||||
"model_id": "6a4020b97d834285b3b362c8b1f27e47",
|
||||
"version_major": 2,
|
||||
"version_minor": 0
|
||||
},
|
||||
@@ -0,0 +1,77 @@
|
||||
# convert to Pa
|
||||
def bar_to_pa(p):
|
||||
return p*1e5
|
||||
|
||||
def mWS_to_pa(p):
|
||||
return p*9.80665*1e3
|
||||
|
||||
def torr_to_pa(p):
|
||||
return p*133.322
|
||||
|
||||
def atm_to_pa(p):
|
||||
return p*101.325*1e3
|
||||
|
||||
def psi_to_pa(p):
|
||||
return p*6894.8
|
||||
|
||||
# convert from Pa
|
||||
def pa_to_bar(p):
|
||||
return p*1e-5
|
||||
|
||||
def pa_to_mWS(p):
|
||||
return p*1/(9.80665*1e3)
|
||||
|
||||
def pa_to_torr(p):
|
||||
return p/133.322
|
||||
|
||||
def pa_to_atm(p):
|
||||
return p*1/(101.325*1e3)
|
||||
|
||||
# converstion function
|
||||
|
||||
def pa_to_psi(p):
|
||||
return p/6894.8
|
||||
|
||||
def pressure_conversion(pressure, input_unit = 'bar', target_unit = 'Pa'):
|
||||
p = pressure
|
||||
if input_unit.lower() == 'bar':
|
||||
p_pa = bar_to_pa(p)
|
||||
elif input_unit.lower() == 'mws':
|
||||
p_pa = mWS_to_pa(p)
|
||||
elif input_unit.lower() == 'torr':
|
||||
p_pa = torr_to_pa(p)
|
||||
elif input_unit.lower() == 'atm':
|
||||
p_pa = atm_to_pa(p)
|
||||
elif input_unit.lower() == 'psi':
|
||||
p_pa = psi_to_pa(p)
|
||||
elif input_unit.lower() == 'pa':
|
||||
p_pa = p
|
||||
else:
|
||||
raise Exception('Given input unit not recognised. \n Known units are: Pa, bar, mWs, Torr, atm, psi')
|
||||
|
||||
if target_unit.lower() == 'bar':
|
||||
return pa_to_bar(p_pa), target_unit
|
||||
elif target_unit.lower() == 'mws':
|
||||
return pa_to_mWS(p_pa), target_unit
|
||||
elif target_unit.lower() == 'torr':
|
||||
return pa_to_torr(p_pa), target_unit
|
||||
elif target_unit.lower() == 'atm':
|
||||
return pa_to_atm(p_pa), target_unit
|
||||
elif target_unit.lower() =='psi':
|
||||
return pa_to_psi(p_pa), target_unit
|
||||
elif target_unit.lower() == 'pa':
|
||||
return p_pa, target_unit
|
||||
else:
|
||||
raise Exception('Given target unit not recognised. \n Known units are: Pa, bar, mWs, Torr, atm, psi')
|
||||
|
||||
# testing_pressure_conversion
|
||||
if __name__ == '__main__':
|
||||
p = 1
|
||||
|
||||
unit_dict = ['Pa','Bar','Torr','Atm','MWS','psi']
|
||||
|
||||
for input_unit in unit_dict:
|
||||
for target_unit in unit_dict:
|
||||
converted_p = pressure_conversion(p,input_unit,target_unit)
|
||||
print(input_unit,target_unit)
|
||||
print(converted_p)
|
||||
@@ -1,5 +1,5 @@
|
||||
from Ausgleichsbecken import FODE_function, get_h_halfstep, get_p_halfstep
|
||||
from functions.pressure_conversion import pressure_conversion
|
||||
from pressure_conversion import pressure_conversion
|
||||
class Ausgleichsbecken_class:
|
||||
# units
|
||||
area_unit = r'$\mathrm{m}^2$'
|
||||
171
Ausgleichsbecken/static_pipeline_pressure/Main_Program.ipynb
Normal file
171
Ausgleichsbecken/static_pipeline_pressure/Main_Program.ipynb
Normal file
File diff suppressed because one or more lines are too long
@@ -0,0 +1,77 @@
|
||||
# convert to Pa
|
||||
def bar_to_pa(p):
|
||||
return p*1e5
|
||||
|
||||
def mWS_to_pa(p):
|
||||
return p*9.80665*1e3
|
||||
|
||||
def torr_to_pa(p):
|
||||
return p*133.322
|
||||
|
||||
def atm_to_pa(p):
|
||||
return p*101.325*1e3
|
||||
|
||||
def psi_to_pa(p):
|
||||
return p*6894.8
|
||||
|
||||
# convert from Pa
|
||||
def pa_to_bar(p):
|
||||
return p*1e-5
|
||||
|
||||
def pa_to_mWS(p):
|
||||
return p*1/(9.80665*1e3)
|
||||
|
||||
def pa_to_torr(p):
|
||||
return p/133.322
|
||||
|
||||
def pa_to_atm(p):
|
||||
return p*1/(101.325*1e3)
|
||||
|
||||
# converstion function
|
||||
|
||||
def pa_to_psi(p):
|
||||
return p/6894.8
|
||||
|
||||
def pressure_conversion(pressure, input_unit = 'bar', target_unit = 'Pa'):
|
||||
p = pressure
|
||||
if input_unit.lower() == 'bar':
|
||||
p_pa = bar_to_pa(p)
|
||||
elif input_unit.lower() == 'mws':
|
||||
p_pa = mWS_to_pa(p)
|
||||
elif input_unit.lower() == 'torr':
|
||||
p_pa = torr_to_pa(p)
|
||||
elif input_unit.lower() == 'atm':
|
||||
p_pa = atm_to_pa(p)
|
||||
elif input_unit.lower() == 'psi':
|
||||
p_pa = psi_to_pa(p)
|
||||
elif input_unit.lower() == 'pa':
|
||||
p_pa = p
|
||||
else:
|
||||
raise Exception('Given input unit not recognised. \n Known units are: Pa, bar, mWs, Torr, atm, psi')
|
||||
|
||||
if target_unit.lower() == 'bar':
|
||||
return pa_to_bar(p_pa), target_unit
|
||||
elif target_unit.lower() == 'mws':
|
||||
return pa_to_mWS(p_pa), target_unit
|
||||
elif target_unit.lower() == 'torr':
|
||||
return pa_to_torr(p_pa), target_unit
|
||||
elif target_unit.lower() == 'atm':
|
||||
return pa_to_atm(p_pa), target_unit
|
||||
elif target_unit.lower() =='psi':
|
||||
return pa_to_psi(p_pa), target_unit
|
||||
elif target_unit.lower() == 'pa':
|
||||
return p_pa, target_unit
|
||||
else:
|
||||
raise Exception('Given target unit not recognised. \n Known units are: Pa, bar, mWs, Torr, atm, psi')
|
||||
|
||||
# testing_pressure_conversion
|
||||
if __name__ == '__main__':
|
||||
p = 1
|
||||
|
||||
unit_dict = ['Pa','Bar','Torr','Atm','MWS','psi']
|
||||
|
||||
for input_unit in unit_dict:
|
||||
for target_unit in unit_dict:
|
||||
converted_p = pressure_conversion(p,input_unit,target_unit)
|
||||
print(input_unit,target_unit)
|
||||
print(converted_p)
|
||||
Reference in New Issue
Block a user