end of day commit 12.07.

This commit is contained in:
Georg ´Brantegger
2022-07-12 14:07:53 +02:00
parent 824034699e
commit 84ccadc66d
3 changed files with 35 additions and 10376 deletions

View File

@@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 11,
"metadata": {},
"outputs": [],
"source": [
@@ -16,7 +16,7 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 12,
"metadata": {},
"outputs": [],
"source": [
@@ -32,14 +32,14 @@
"A_pipe = D**2/4*np.pi # pipeline area\n",
"h_pipe = 200 # hydraulic head without reservoir [m] \n",
"alpha = np.arcsin(h_pipe/L) # Höhenwinkel der Druckrohrleitung \n",
"n = 10 # number of pipe segments in discretization\n",
"n = 100 # number of pipe segments in discretization\n",
"# consider replacing Q0 with a vector be be more flexible in initial conditions\n",
"Q0 = 2. # initial flow in whole pipe [m³/s]\n",
"v0 = Q0/A_pipe # initial flow velocity [m/s]\n",
"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 = 100 # number of time steps after initial conditions\n",
"nt = 1000 # number of time steps after initial conditions\n",
"\n",
"# derivatives of the pipeline constants\n",
"dx = L/n # length of each pipe segment\n",
@@ -50,13 +50,13 @@
"pl_vec = np.arange(0,nn*dx,dx) # pl = pipe-length. position of the nodes on the pipeline\n",
"t_vec = np.arange(0,nt+1)*dt # time vector\n",
"h_vec = np.arange(0,n+1)*h_pipe/n # hydraulic head of pipeline at each node \n",
"v_init = np.full(nn,Q0/(D**2/4*np.pi)) # initial velocity distribution in pipeline\n",
"v_init = np.full(nn,Q0/(A_pipe)) # initial velocity distribution in pipeline\n",
"p_init = (rho*g*(initial_level+h_vec)-v_init**2*rho/2)-(f_D*pl_vec/D*rho/2*v_init**2) # ref Wikipedia: Darcy Weisbach\n",
"\n",
"\n",
"# reservoir\n",
"# replace influx by vector\n",
"initial_influx = 0. # initial influx of volume to the reservoir [m³/s]\n",
"# replace influx by time variable vector\n",
"initial_influx = Q0 # 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' # DO NOT CHANGE! for pressure conversion in print statements and plot labels \n",
@@ -91,7 +91,7 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 13,
"metadata": {},
"outputs": [],
"source": [
@@ -116,7 +116,7 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": 14,
"metadata": {},
"outputs": [],
"source": [
@@ -134,6 +134,7 @@
"v_boundary_tur = np.empty_like(t_vec)\n",
"p_boundary_res = np.empty_like(t_vec)\n",
"p_boundary_tur = np.empty_like(t_vec)\n",
"influx_vec = np.empty_like(t_vec)\n",
"\n",
"# prepare the vectors that store the temporal evolution of the level in the reservoir\n",
"level_vec = np.full(nt+1,initial_level) # level at the end of each pipeline timestep\n",
@@ -141,19 +142,28 @@
"\n",
"# set the boudary conditions for the first timestep\n",
"v_boundary_res[0] = v_old[0]\n",
"v_boundary_tur[0] = v_old[-1] \n",
"v_boundary_tur[1:] = 0 # instantaneous closing\n",
"# v_boundary_tur[0:20] = np.linspace(v_old[-1],0,20) # overwrite for finite closing time - linear case\n",
"const = int(np.min([100,round(nt/1.1)]))\n",
"v_boundary_tur[0:const] = v_old[1]*np.cos(t_vec[0:const]*2*np.pi/5)**2\n",
"p_boundary_res[0] = p_old[0]\n",
"p_boundary_tur[0] = p_old[-1]\n",
"p_boundary_res[0] = p_old[0]\n",
"p_boundary_tur[0] = p_old[-1]\n",
"\n",
"v_boundary_tur[:] = v_old[0] \n",
"v_boundary_tur[1:] = 0 # instantaneous closing\n",
"\n",
"const = int(np.min([1000,round(nt/1.25)])) \n",
"# # v_boundary_tur[0:const] = np.linspace(v_old[-1],0,const) # linear closing\n",
"v_boundary_tur[0:const] = v_old[1]*np.cos(t_vec[0:const]*2*np.pi)**2 # oscillating\n",
"\n",
"influx_vec[0] = initial_influx # instantaneous closing\n",
"influx_vec[1:] = initial_influx # instantaneous closing\n",
"\n",
"const2 = int(np.min([1000,round(nt/1.25)])) \n",
"# influx_vec[0:const2] = np.linspace(v_old[-1],0,const2) # linear closing\n",
"# influx_vec[0:const2] = initial_influx*np.cos(t_vec[0:const2]*2*np.pi)**2 # oscillating\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": 15,
"metadata": {},
"outputs": [],
"source": [
@@ -188,8 +198,9 @@
"\n",
"# for each pipeline timestep, execute nt_eRK4 timesteps of the reservoir code\n",
" # set initial conditions for the reservoir time evolution calculted with e-RK4\n",
" V.pressure = p_old[0]\n",
" V.outflux = v_old[0]\n",
" V.pressure = p_old[0]\n",
" V.outflux_vel = v_old[0]\n",
" V.influx = influx_vec[it_pipe]\n",
" # calculate the time evolution of the reservoir level within each pipeline timestep to avoid runaway numerical error\n",
" for it_res in range(nt_eRK4):\n",
" V.e_RK_4() # call e-RK4 to update outflux\n",
@@ -197,7 +208,6 @@
" V.set_volume() # update volume in reservoir\n",
" level_vec_2[it_res] = V.level # save for plotting\n",
" if (V.level < critical_level_low) or (V.level > critical_level_high): # make sure to never exceed critical levels\n",
" i_max = it_pipe # for plotting only calculated values\n",
" break \n",
" level_vec[it_pipe] = V.level \n",
"\n",
@@ -238,7 +248,7 @@
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": 16,
"metadata": {},
"outputs": [],
"source": [
@@ -273,7 +283,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3.8.13 ('Georg_DT_Slot3')",
"display_name": "Python 3.8.13 ('DT_Slot_3')",
"language": "python",
"name": "python3"
},
@@ -292,7 +302,7 @@
"orig_nbformat": 4,
"vscode": {
"interpreter": {
"hash": "84fb123bdc47ab647d3782661abcbe80fbb79236dd2f8adf4cef30e8755eb2cd"
"hash": "4a28055eb8a3160fa4c7e4fca69770c4e0a1add985300856aa3fcf4ce32a2c48"
}
}
},