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$'
|
||||
flux_unit = r'$\mathrm{m}^3/\mathrm{s}$'
|
||||
level_unit = 'm'
|
||||
pressure_unit = 'Pa'
|
||||
time_unit = 's'
|
||||
volume_unit = r'$\mathrm{m}^3$'
|
||||
|
||||
@@ -30,7 +29,6 @@ class Ausgleichsbecken_class:
|
||||
area_outflux_unit_print = 'm²'
|
||||
flux_unit_print = 'm³/s'
|
||||
level_unit_print = 'm'
|
||||
pressure_unit_print = 'Pa'
|
||||
time_unit_print = 's'
|
||||
volume_unit_print = 'm³'
|
||||
|
||||
@@ -63,9 +61,14 @@ class Ausgleichsbecken_class:
|
||||
def set_outflux(self,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
|
||||
def get_info(self, full = False):
|
||||
new_line = '\n'
|
||||
p,_ = pressure_conversion(self.pressure,self.pressure_unit,self.pressure_unit_print)
|
||||
|
||||
|
||||
if full == True:
|
||||
@@ -80,6 +83,7 @@ class Ausgleichsbecken_class:
|
||||
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 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"----------------------------- {new_line}")
|
||||
else:
|
||||
@@ -90,6 +94,7 @@ class Ausgleichsbecken_class:
|
||||
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 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}")
|
||||
|
||||
print(print_str)
|
||||
@@ -107,11 +112,12 @@ class Ausgleichsbecken_class:
|
||||
yn = self.outflux/self.area_outflux
|
||||
h = self.level
|
||||
dt = self.timestep
|
||||
p,_ = pressure_conversion(self.pressure,self.pressure_unit,'Pa')
|
||||
# update to include p_halfstep
|
||||
p_hs,_ = pressure_conversion(self.pressure,self.pressure_unit,'Pa')
|
||||
p = self.pressure
|
||||
# assume constant pipeline pressure during timestep (see comments in main_programm)
|
||||
p_hs = self.pressure
|
||||
alpha = (self.area_outflux/self.area-1)
|
||||
h_hs = self.update_level(dt/2)
|
||||
# explicit 4 step Runge Kutta
|
||||
Y1 = yn
|
||||
Y2 = yn + dt/2*FODE_function(Y1, h, alpha, self.pressure)
|
||||
Y3 = yn + dt/2*FODE_function(Y2, h_hs, alpha, p_hs)
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 6,
|
||||
"execution_count": 26,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
@@ -11,12 +11,12 @@
|
||||
"\n",
|
||||
"from functions.pressure_conversion import pressure_conversion\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",
|
||||
"execution_count": 7,
|
||||
"execution_count": 27,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
@@ -39,7 +39,7 @@
|
||||
"f_D = 0.1 # Darcy friction factor\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",
|
||||
"nt = 500 # number of time steps after initial conditions\n",
|
||||
"nt = 100 # number of time steps after initial conditions\n",
|
||||
"\n",
|
||||
"# derivatives of the pipeline constants\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_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_pressure_unit = 'Pa' # for pressure conversion in print statements and plot labels\n",
|
||||
"conversion_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 = 'Torr' # for pressure conversion in print statements and plot labels\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",
|
||||
"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",
|
||||
"<br>\n",
|
||||
"<br>\n",
|
||||
"- stupidity checks?\n",
|
||||
"- plausbility checks?\n",
|
||||
" - area > area_outflux ?\n",
|
||||
" - propable ranges for parameters?\n",
|
||||
" - angle and height/length fit together?\n",
|
||||
@@ -92,7 +92,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 8,
|
||||
"execution_count": 28,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
@@ -109,9 +109,19 @@
|
||||
"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",
|
||||
"Simulation timestep = 0.00025 s \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",
|
||||
"----------------------------- \n",
|
||||
"Length = 1000.0 m \n",
|
||||
@@ -125,8 +135,8 @@
|
||||
"Density of liquid = 1000 kg/m³ \n",
|
||||
"Pressure wave vel. = 400.0 m/s \n",
|
||||
"Simulation timestep = 0.25 s \n",
|
||||
"Number of timesteps = 500 \n",
|
||||
"Total simulation time = 125.0 s \n",
|
||||
"Number of timesteps = 100 \n",
|
||||
"Total simulation time = 25.0 s \n",
|
||||
"----------------------------- \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_influx(initial_influx)\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",
|
||||
"\n",
|
||||
"V.set_pressure(initial_pipeline_pressure,initial_pressure_unit,conversion_pressure_unit)\n",
|
||||
"\n",
|
||||
"pipe = Druckrohrleitung_class(L,D,n,alpha,f_D)\n",
|
||||
"pipe.set_pressure_propagation_velocity(c)\n",
|
||||
@@ -155,7 +164,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 9,
|
||||
"execution_count": 29,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
@@ -192,7 +201,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 10,
|
||||
"execution_count": 30,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
@@ -204,10 +213,10 @@
|
||||
"axs1[0].set_title('Pressure 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_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_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",
|
||||
"axs1[0].autoscale()\n",
|
||||
"axs1[1].autoscale()\n",
|
||||
@@ -257,7 +266,7 @@
|
||||
" lo_01.remove()\n",
|
||||
" # lo_02.remove()\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_02, = axs1[2].plot(level_vec_2,c='blue')\n",
|
||||
" fig1.suptitle(str(it_pipe))\n",
|
||||
@@ -275,16 +284,16 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 11,
|
||||
"execution_count": 31,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# plot time evolution of boundary pressure and velocity as well as the reservoir level\n",
|
||||
"\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[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[2,0].plot(t_vec,level_vec)\n",
|
||||
"axs2[0,0].set_title('Pressure reservoir')\n",
|
||||
@@ -293,11 +302,11 @@
|
||||
"axs2[1,1].set_title('Velocity turbine')\n",
|
||||
"axs2[2,0].set_title('Level reservoir')\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_ylabel(r'$v$ [$\\mathrm{m}/\\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_ylabel(r'$v$ [$\\mathrm{m}/\\mathrm{s}$]')\n",
|
||||
"axs2[2,0].set_xlabel(r'$t$ [$\\mathrm{s}$]')\n",
|
||||
Reference in New Issue
Block a user