made sure pressures are consistent in Pa in all
classes
This commit is contained in:
@@ -22,7 +22,6 @@ class Ausgleichsbecken_class:
|
|||||||
area_outflux_unit = r'$\mathrm{m}^2$'
|
area_outflux_unit = r'$\mathrm{m}^2$'
|
||||||
flux_unit = r'$\mathrm{m}^3/\mathrm{s}$'
|
flux_unit = r'$\mathrm{m}^3/\mathrm{s}$'
|
||||||
level_unit = 'm'
|
level_unit = 'm'
|
||||||
pressure_unit = 'Pa'
|
|
||||||
time_unit = 's'
|
time_unit = 's'
|
||||||
volume_unit = r'$\mathrm{m}^3$'
|
volume_unit = r'$\mathrm{m}^3$'
|
||||||
|
|
||||||
@@ -30,7 +29,6 @@ class Ausgleichsbecken_class:
|
|||||||
area_outflux_unit_print = 'm²'
|
area_outflux_unit_print = 'm²'
|
||||||
flux_unit_print = 'm³/s'
|
flux_unit_print = 'm³/s'
|
||||||
level_unit_print = 'm'
|
level_unit_print = 'm'
|
||||||
pressure_unit_print = 'Pa'
|
|
||||||
time_unit_print = 's'
|
time_unit_print = 's'
|
||||||
volume_unit_print = 'm³'
|
volume_unit_print = 'm³'
|
||||||
|
|
||||||
@@ -63,9 +61,14 @@ class Ausgleichsbecken_class:
|
|||||||
def set_outflux(self,outflux):
|
def set_outflux(self,outflux):
|
||||||
self.outflux = outflux
|
self.outflux = outflux
|
||||||
|
|
||||||
|
def set_pressure(self,pressure,pressure_unit,display_pressure_unit):
|
||||||
|
self.pressure = pressure
|
||||||
|
self.pressure_unit = pressure_unit
|
||||||
|
self.pressure_unit_print = display_pressure_unit
|
||||||
# getter
|
# getter
|
||||||
def get_info(self, full = False):
|
def get_info(self, full = False):
|
||||||
new_line = '\n'
|
new_line = '\n'
|
||||||
|
p,_ = pressure_conversion(self.pressure,self.pressure_unit,self.pressure_unit_print)
|
||||||
|
|
||||||
|
|
||||||
if full == True:
|
if full == True:
|
||||||
@@ -80,6 +83,7 @@ class Ausgleichsbecken_class:
|
|||||||
f"Volume in reservoir = {self.volume:<10} {self.volume_unit_print} {new_line}"
|
f"Volume in reservoir = {self.volume:<10} {self.volume_unit_print} {new_line}"
|
||||||
f"Current influx = {self.influx:<10} {self.flux_unit_print} {new_line}"
|
f"Current influx = {self.influx:<10} {self.flux_unit_print} {new_line}"
|
||||||
f"Current outflux = {self.outflux:<10} {self.flux_unit_print} {new_line}"
|
f"Current outflux = {self.outflux:<10} {self.flux_unit_print} {new_line}"
|
||||||
|
f"Current pipe pressure = {round(p,3):<10} {self.pressure_unit_print} {new_line}"
|
||||||
f"Simulation timestep = {self.timestep:<10} {self.time_unit_print} {new_line}"
|
f"Simulation timestep = {self.timestep:<10} {self.time_unit_print} {new_line}"
|
||||||
f"----------------------------- {new_line}")
|
f"----------------------------- {new_line}")
|
||||||
else:
|
else:
|
||||||
@@ -90,6 +94,7 @@ class Ausgleichsbecken_class:
|
|||||||
f"Volume in reservoir = {self.volume:<10} {self.volume_unit_print} {new_line}"
|
f"Volume in reservoir = {self.volume:<10} {self.volume_unit_print} {new_line}"
|
||||||
f"Current influx = {self.influx:<10} {self.flux_unit_print} {new_line}"
|
f"Current influx = {self.influx:<10} {self.flux_unit_print} {new_line}"
|
||||||
f"Current outflux = {self.outflux:<10} {self.flux_unit_print} {new_line}"
|
f"Current outflux = {self.outflux:<10} {self.flux_unit_print} {new_line}"
|
||||||
|
f"Current pipe pressure = {round(p,3):<10} {self.pressure_unit_print} {new_line}"
|
||||||
f"----------------------------- {new_line}")
|
f"----------------------------- {new_line}")
|
||||||
|
|
||||||
print(print_str)
|
print(print_str)
|
||||||
@@ -104,19 +109,20 @@ class Ausgleichsbecken_class:
|
|||||||
|
|
||||||
|
|
||||||
def e_RK_4(self):
|
def e_RK_4(self):
|
||||||
yn = self.outflux/self.area_outflux
|
yn = self.outflux/self.area_outflux
|
||||||
h = self.level
|
h = self.level
|
||||||
dt = self.timestep
|
dt = self.timestep
|
||||||
p,_ = pressure_conversion(self.pressure,self.pressure_unit,'Pa')
|
p = self.pressure
|
||||||
# update to include p_halfstep
|
# assume constant pipeline pressure during timestep (see comments in main_programm)
|
||||||
p_hs,_ = pressure_conversion(self.pressure,self.pressure_unit,'Pa')
|
p_hs = self.pressure
|
||||||
alpha = (self.area_outflux/self.area-1)
|
alpha = (self.area_outflux/self.area-1)
|
||||||
h_hs = self.update_level(dt/2)
|
h_hs = self.update_level(dt/2)
|
||||||
Y1 = yn
|
# explicit 4 step Runge Kutta
|
||||||
Y2 = yn + dt/2*FODE_function(Y1, h, alpha, self.pressure)
|
Y1 = yn
|
||||||
Y3 = yn + dt/2*FODE_function(Y2, h_hs, alpha, p_hs)
|
Y2 = yn + dt/2*FODE_function(Y1, h, alpha, self.pressure)
|
||||||
Y4 = yn + dt*FODE_function(Y3, h_hs, alpha, p_hs)
|
Y3 = yn + dt/2*FODE_function(Y2, h_hs, alpha, p_hs)
|
||||||
ynp1 = yn + dt/6*(FODE_function(Y1, h, alpha, p)+2*FODE_function(Y2, h_hs, alpha, p_hs)+ \
|
Y4 = yn + dt*FODE_function(Y3, h_hs, alpha, p_hs)
|
||||||
|
ynp1 = yn + dt/6*(FODE_function(Y1, h, alpha, p)+2*FODE_function(Y2, h_hs, alpha, p_hs)+ \
|
||||||
2*FODE_function(Y3, h_hs, alpha, p_hs)+ FODE_function(Y4, h, alpha, p))
|
2*FODE_function(Y3, h_hs, alpha, p_hs)+ FODE_function(Y4, h, alpha, p))
|
||||||
|
|
||||||
self.outflux = ynp1*self.area_outflux
|
self.outflux = ynp1*self.area_outflux
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
"cells": [
|
"cells": [
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 6,
|
"execution_count": 26,
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
@@ -11,12 +11,12 @@
|
|||||||
"\n",
|
"\n",
|
||||||
"from functions.pressure_conversion import pressure_conversion\n",
|
"from functions.pressure_conversion import pressure_conversion\n",
|
||||||
"from Ausgleichsbecken.Ausgleichsbecken_class_file import Ausgleichsbecken_class\n",
|
"from Ausgleichsbecken.Ausgleichsbecken_class_file import Ausgleichsbecken_class\n",
|
||||||
"from Druckrohrleitung.Druckrohrleitung_class_file import Druckrohrleitung_class\n"
|
"from Druckrohrleitung.Druckrohrleitung_class_file import Druckrohrleitung_class"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 7,
|
"execution_count": 27,
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
@@ -39,7 +39,7 @@
|
|||||||
"f_D = 0.1 # Darcy friction factor\n",
|
"f_D = 0.1 # Darcy friction factor\n",
|
||||||
"c = 400. # propagation velocity of the pressure wave [m/s]\n",
|
"c = 400. # propagation velocity of the pressure wave [m/s]\n",
|
||||||
"#consider prescribing a total simulation time and deducting the number of timesteps from that\n",
|
"#consider prescribing a total simulation time and deducting the number of timesteps from that\n",
|
||||||
"nt = 500 # number of time steps after initial conditions\n",
|
"nt = 100 # number of time steps after initial conditions\n",
|
||||||
"\n",
|
"\n",
|
||||||
"# derivatives of the pipeline constants\n",
|
"# derivatives of the pipeline constants\n",
|
||||||
"dx = L/n # length of each pipe segment\n",
|
"dx = L/n # length of each pipe segment\n",
|
||||||
@@ -60,8 +60,8 @@
|
|||||||
"initial_influx = 0. # initial influx of volume to the reservoir [m³/s]\n",
|
"initial_influx = 0. # initial influx of volume to the reservoir [m³/s]\n",
|
||||||
"initial_outflux = Q0 # initial outflux of volume from the reservoir to the pipeline [m³/s]\n",
|
"initial_outflux = Q0 # initial outflux of volume from the reservoir to the pipeline [m³/s]\n",
|
||||||
"initial_pipeline_pressure = p0 # Initial condition for the static pipeline pressure at the reservoir (= hydrostatic pressure - dynamic pressure) \n",
|
"initial_pipeline_pressure = p0 # Initial condition for the static pipeline pressure at the reservoir (= hydrostatic pressure - dynamic pressure) \n",
|
||||||
"initial_pressure_unit = 'Pa' # for pressure conversion in print statements and plot labels\n",
|
"initial_pressure_unit = 'Pa' # DO NOT CHANGE! for pressure conversion in print statements and plot labels \n",
|
||||||
"conversion_pressure_unit = 'Pa' # for pressure conversion in print statements and plot labels\n",
|
"conversion_pressure_unit = 'Torr' # for pressure conversion in print statements and plot labels\n",
|
||||||
"area_base = 20. # total base are of the cuboid reservoir [m²] \n",
|
"area_base = 20. # total base are of the cuboid reservoir [m²] \n",
|
||||||
"area_outflux = A_pipe # outlfux area of the reservoir, given by pipeline area [m²]\n",
|
"area_outflux = A_pipe # outlfux area of the reservoir, given by pipeline area [m²]\n",
|
||||||
"critical_level_low = 0. # for yet-to-be-implemented warnings[m]\n",
|
"critical_level_low = 0. # for yet-to-be-implemented warnings[m]\n",
|
||||||
@@ -83,7 +83,7 @@
|
|||||||
" - may happen, if there is too little hydraulic head to create the initial flow conditions with the given friction\n",
|
" - may happen, if there is too little hydraulic head to create the initial flow conditions with the given friction\n",
|
||||||
"<br>\n",
|
"<br>\n",
|
||||||
"<br>\n",
|
"<br>\n",
|
||||||
"- stupidity checks?\n",
|
"- plausbility checks?\n",
|
||||||
" - area > area_outflux ?\n",
|
" - area > area_outflux ?\n",
|
||||||
" - propable ranges for parameters?\n",
|
" - propable ranges for parameters?\n",
|
||||||
" - angle and height/length fit together?\n",
|
" - angle and height/length fit together?\n",
|
||||||
@@ -92,7 +92,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 8,
|
"execution_count": 28,
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [
|
"outputs": [
|
||||||
{
|
{
|
||||||
@@ -109,9 +109,19 @@
|
|||||||
"Volume in reservoir = 400.0 m³ \n",
|
"Volume in reservoir = 400.0 m³ \n",
|
||||||
"Current influx = 0.0 m³/s \n",
|
"Current influx = 0.0 m³/s \n",
|
||||||
"Current outflux = 2.0 m³/s \n",
|
"Current outflux = 2.0 m³/s \n",
|
||||||
|
"Current pipe pressure = 1447.306 Torr \n",
|
||||||
"Simulation timestep = 0.00025 s \n",
|
"Simulation timestep = 0.00025 s \n",
|
||||||
"----------------------------- \n",
|
"----------------------------- \n",
|
||||||
"\n",
|
"\n",
|
||||||
|
"The current attributes are: \n",
|
||||||
|
"----------------------------- \n",
|
||||||
|
"Current level = 20.0 m\n",
|
||||||
|
"Volume in reservoir = 400.0 m³ \n",
|
||||||
|
"Current influx = 0.0 m³/s \n",
|
||||||
|
"Current outflux = 2.0 m³/s \n",
|
||||||
|
"Current pipe pressure = 1447.306 Torr \n",
|
||||||
|
"----------------------------- \n",
|
||||||
|
"\n",
|
||||||
"The pipeline has the following attributes: \n",
|
"The pipeline has the following attributes: \n",
|
||||||
"----------------------------- \n",
|
"----------------------------- \n",
|
||||||
"Length = 1000.0 m \n",
|
"Length = 1000.0 m \n",
|
||||||
@@ -125,8 +135,8 @@
|
|||||||
"Density of liquid = 1000 kg/m³ \n",
|
"Density of liquid = 1000 kg/m³ \n",
|
||||||
"Pressure wave vel. = 400.0 m/s \n",
|
"Pressure wave vel. = 400.0 m/s \n",
|
||||||
"Simulation timestep = 0.25 s \n",
|
"Simulation timestep = 0.25 s \n",
|
||||||
"Number of timesteps = 500 \n",
|
"Number of timesteps = 100 \n",
|
||||||
"Total simulation time = 125.0 s \n",
|
"Total simulation time = 25.0 s \n",
|
||||||
"----------------------------- \n",
|
"----------------------------- \n",
|
||||||
"Velocity and pressure distribution are vectors and are accessible by the .v and .p attribute of the pipeline object\n"
|
"Velocity and pressure distribution are vectors and are accessible by the .v and .p attribute of the pipeline object\n"
|
||||||
]
|
]
|
||||||
@@ -139,8 +149,7 @@
|
|||||||
"V.set_initial_level(initial_level) \n",
|
"V.set_initial_level(initial_level) \n",
|
||||||
"V.set_influx(initial_influx)\n",
|
"V.set_influx(initial_influx)\n",
|
||||||
"V.set_outflux(initial_outflux)\n",
|
"V.set_outflux(initial_outflux)\n",
|
||||||
"V.pressure, V.pressure_unit = pressure_conversion(initial_pipeline_pressure,input_unit = initial_pressure_unit, target_unit = conversion_pressure_unit)\n",
|
"V.set_pressure(initial_pipeline_pressure,initial_pressure_unit,conversion_pressure_unit)\n",
|
||||||
"\n",
|
|
||||||
"\n",
|
"\n",
|
||||||
"pipe = Druckrohrleitung_class(L,D,n,alpha,f_D)\n",
|
"pipe = Druckrohrleitung_class(L,D,n,alpha,f_D)\n",
|
||||||
"pipe.set_pressure_propagation_velocity(c)\n",
|
"pipe.set_pressure_propagation_velocity(c)\n",
|
||||||
@@ -155,7 +164,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 9,
|
"execution_count": 29,
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
@@ -192,7 +201,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 10,
|
"execution_count": 30,
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
@@ -204,10 +213,10 @@
|
|||||||
"axs1[0].set_title('Pressure distribution in pipeline')\n",
|
"axs1[0].set_title('Pressure distribution in pipeline')\n",
|
||||||
"axs1[1].set_title('Velocity distribution in pipeline')\n",
|
"axs1[1].set_title('Velocity distribution in pipeline')\n",
|
||||||
"axs1[0].set_xlabel(r'$x$ [$\\mathrm{m}$]')\n",
|
"axs1[0].set_xlabel(r'$x$ [$\\mathrm{m}$]')\n",
|
||||||
"axs1[0].set_ylabel(r'$p$ [mWS]')\n",
|
"axs1[0].set_ylabel(r'$p$ ['+conversion_pressure_unit+']')\n",
|
||||||
"axs1[1].set_xlabel(r'$x$ [$\\mathrm{m}$]')\n",
|
"axs1[1].set_xlabel(r'$x$ [$\\mathrm{m}$]')\n",
|
||||||
"axs1[1].set_ylabel(r'$v$ [$\\mathrm{m} / \\mathrm{s}$]')\n",
|
"axs1[1].set_ylabel(r'$v$ [$\\mathrm{m} / \\mathrm{s}$]')\n",
|
||||||
"lo_00, = axs1[0].plot(pl_vec,pressure_conversion(pipe.p_old,'Pa','mWS')[0],marker='.')\n",
|
"lo_00, = axs1[0].plot(pl_vec,pressure_conversion(pipe.p_old,initial_pressure_unit, conversion_pressure_unit)[0],marker='.')\n",
|
||||||
"lo_01, = axs1[1].plot(pl_vec,pipe.v_old,marker='.')\n",
|
"lo_01, = axs1[1].plot(pl_vec,pipe.v_old,marker='.')\n",
|
||||||
"axs1[0].autoscale()\n",
|
"axs1[0].autoscale()\n",
|
||||||
"axs1[1].autoscale()\n",
|
"axs1[1].autoscale()\n",
|
||||||
@@ -257,7 +266,7 @@
|
|||||||
" lo_01.remove()\n",
|
" lo_01.remove()\n",
|
||||||
" # lo_02.remove()\n",
|
" # lo_02.remove()\n",
|
||||||
" # plot new pressure and velocity distribution in the pipeline\n",
|
" # plot new pressure and velocity distribution in the pipeline\n",
|
||||||
" lo_00, = axs1[0].plot(pl_vec,pressure_conversion(pipe.p_old,'Pa','mWS')[0],marker='.',c='blue')\n",
|
" lo_00, = axs1[0].plot(pl_vec,pressure_conversion(pipe.p_old,initial_pressure_unit, conversion_pressure_unit)[0],marker='.',c='blue')\n",
|
||||||
" lo_01, = axs1[1].plot(pl_vec,pipe.v_old,marker='.',c='blue')\n",
|
" lo_01, = axs1[1].plot(pl_vec,pipe.v_old,marker='.',c='blue')\n",
|
||||||
" # lo_02, = axs1[2].plot(level_vec_2,c='blue')\n",
|
" # lo_02, = axs1[2].plot(level_vec_2,c='blue')\n",
|
||||||
" fig1.suptitle(str(it_pipe))\n",
|
" fig1.suptitle(str(it_pipe))\n",
|
||||||
@@ -275,16 +284,16 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 11,
|
"execution_count": 31,
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"# plot time evolution of boundary pressure and velocity as well as the reservoir level\n",
|
"# plot time evolution of boundary pressure and velocity as well as the reservoir level\n",
|
||||||
"\n",
|
"\n",
|
||||||
"fig2,axs2 = plt.subplots(3,2)\n",
|
"fig2,axs2 = plt.subplots(3,2)\n",
|
||||||
"axs2[0,0].plot(t_vec,pressure_conversion(p_boundary_res,'Pa','mWS')[0])\n",
|
"axs2[0,0].plot(t_vec,pressure_conversion(p_boundary_res,initial_pressure_unit, conversion_pressure_unit)[0])\n",
|
||||||
"axs2[0,1].plot(t_vec,v_boundary_res)\n",
|
"axs2[0,1].plot(t_vec,v_boundary_res)\n",
|
||||||
"axs2[1,0].plot(t_vec,pressure_conversion(p_boundary_tur,'Pa','mWS')[0])\n",
|
"axs2[1,0].plot(t_vec,pressure_conversion(p_boundary_tur,initial_pressure_unit, conversion_pressure_unit)[0])\n",
|
||||||
"axs2[1,1].plot(t_vec,v_boundary_tur)\n",
|
"axs2[1,1].plot(t_vec,v_boundary_tur)\n",
|
||||||
"axs2[2,0].plot(t_vec,level_vec)\n",
|
"axs2[2,0].plot(t_vec,level_vec)\n",
|
||||||
"axs2[0,0].set_title('Pressure reservoir')\n",
|
"axs2[0,0].set_title('Pressure reservoir')\n",
|
||||||
@@ -293,11 +302,11 @@
|
|||||||
"axs2[1,1].set_title('Velocity turbine')\n",
|
"axs2[1,1].set_title('Velocity turbine')\n",
|
||||||
"axs2[2,0].set_title('Level reservoir')\n",
|
"axs2[2,0].set_title('Level reservoir')\n",
|
||||||
"axs2[0,0].set_xlabel(r'$t$ [$\\mathrm{s}$]')\n",
|
"axs2[0,0].set_xlabel(r'$t$ [$\\mathrm{s}$]')\n",
|
||||||
"axs2[0,0].set_ylabel(r'$p$ [mWS]')\n",
|
"axs2[0,0].set_ylabel(r'$p$ ['+conversion_pressure_unit+']')\n",
|
||||||
"axs2[0,1].set_xlabel(r'$t$ [$\\mathrm{s}$]')\n",
|
"axs2[0,1].set_xlabel(r'$t$ [$\\mathrm{s}$]')\n",
|
||||||
"axs2[0,1].set_ylabel(r'$v$ [$\\mathrm{m}/\\mathrm{s}$]')\n",
|
"axs2[0,1].set_ylabel(r'$v$ [$\\mathrm{m}/\\mathrm{s}$]')\n",
|
||||||
"axs2[1,0].set_xlabel(r'$t$ [$\\mathrm{s}$]')\n",
|
"axs2[1,0].set_xlabel(r'$t$ [$\\mathrm{s}$]')\n",
|
||||||
"axs2[1,0].set_ylabel(r'$p$ [mWS]')\n",
|
"axs2[1,0].set_ylabel(r'$p$ ['+conversion_pressure_unit+']')\n",
|
||||||
"axs2[1,1].set_xlabel(r'$t$ [$\\mathrm{s}$]')\n",
|
"axs2[1,1].set_xlabel(r'$t$ [$\\mathrm{s}$]')\n",
|
||||||
"axs2[1,1].set_ylabel(r'$v$ [$\\mathrm{m}/\\mathrm{s}$]')\n",
|
"axs2[1,1].set_ylabel(r'$v$ [$\\mathrm{m}/\\mathrm{s}$]')\n",
|
||||||
"axs2[2,0].set_xlabel(r'$t$ [$\\mathrm{s}$]')\n",
|
"axs2[2,0].set_xlabel(r'$t$ [$\\mathrm{s}$]')\n",
|
||||||
Reference in New Issue
Block a user