probably working combined code :D
This commit is contained in:
@@ -2,12 +2,11 @@
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 52,
|
||||
"execution_count": 13,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import numpy as np\n",
|
||||
"from numpy import sin, arcsin\n",
|
||||
"from Druckrohrleitung_class_file import Druckrohrleitung_class\n",
|
||||
"import matplotlib.pyplot as plt\n",
|
||||
"\n",
|
||||
@@ -22,7 +21,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 53,
|
||||
"execution_count": 14,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
@@ -40,8 +39,8 @@
|
||||
"nt = 100 # number of time steps after initial conditions\n",
|
||||
"f_D = 0.01 # Darcy friction factor\n",
|
||||
"c = 400 # propagation velocity of the pressure wave [m/s]\n",
|
||||
"h_pipe = 1e-5 # hydraulic head without reservoir [m] \n",
|
||||
"alpha = arcsin(h_pipe/L) # Höhenwinkel der Druckrohrleitung \n",
|
||||
"h_pipe = 200 # hydraulic head without reservoir [m] \n",
|
||||
"alpha = np.arcsin(h_pipe/L) # Höhenwinkel der Druckrohrleitung \n",
|
||||
"\n",
|
||||
"\n",
|
||||
"# preparing the discretization and initial conditions\n",
|
||||
@@ -79,7 +78,7 @@
|
||||
" p_new[0] = p_init[0] # hydrostatic pressure from the reservoir\n",
|
||||
"\n",
|
||||
" # calculate the new parameters at first and last node\n",
|
||||
" v_new[0] = v_old[1]+1/(rho*c)*(p_init[0]-p_old[1])+dt*g*sin(alpha)-f_D*dt/(2*D)*abs(v_old[1])*v_old[1]\n",
|
||||
" v_new[0] = v_old[1]+1/(rho*c)*(p_init[0]-p_old[1])+dt*g*np.sin(alpha)-f_D*dt/(2*D)*abs(v_old[1])*v_old[1]\n",
|
||||
" p_new[-1] = p_old[-2]+rho*c*v_old[-2]-rho*c*f_D*dt/(2*D) *abs(v_old[-2])*v_old[-2]\n",
|
||||
"\n",
|
||||
" # calculate parameters at second to second-to-last nodes \n",
|
||||
@@ -87,7 +86,7 @@
|
||||
"\n",
|
||||
" for i in range(1,nn-1):\n",
|
||||
" v_new[i] = 0.5*(v_old[i-1]+v_old[i+1])+0.5/(rho*c)*(p_old[i-1]-p_old[i+1]) \\\n",
|
||||
" +dt*g*sin(alpha)-f_D*dt/(4*D)*(abs(v_old[i-1])*v_old[i-1]+abs(v_old[i+1])*v_old[i+1])\n",
|
||||
" +dt*g*np.sin(alpha)-f_D*dt/(4*D)*(abs(v_old[i-1])*v_old[i-1]+abs(v_old[i+1])*v_old[i+1])\n",
|
||||
"\n",
|
||||
" p_new[i] = 0.5*rho*c*(v_old[i-1]-v_old[i+1])+0.5*(p_old[i-1]+p_old[i+1]) \\\n",
|
||||
" -rho*c*f_D*dt/(4*D)*(abs(v_old[i-1])*v_old[i-1]-abs(v_old[i+1])*v_old[i+1])\n",
|
||||
@@ -109,11 +108,11 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 54,
|
||||
"execution_count": 15,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"pipe = Druckrohrleitung_class(L,D,n,0,f_D)\n",
|
||||
"pipe = Druckrohrleitung_class(L,D,n,alpha,f_D)\n",
|
||||
"\n",
|
||||
"pipe.set_pressure_propagation_velocity(c)\n",
|
||||
"pipe.set_number_of_timesteps(nt)\n",
|
||||
@@ -134,12 +133,12 @@
|
||||
"axs2[0].set_title('Pressure distribution in pipeline')\n",
|
||||
"axs2[1].set_title('Velocity distribution in pipeline')\n",
|
||||
"axs2[0].set_xlabel(r'$x$ [$\\mathrm{m}$]')\n",
|
||||
"axs2[0].set_ylabel(r'$p$ [Pa]')\n",
|
||||
"axs2[0].set_ylabel(r'$p$ [mWS]')\n",
|
||||
"axs2[1].set_xlabel(r'$x$ [$\\mathrm{m}$]')\n",
|
||||
"axs2[1].set_ylabel(r'$p$ [Pa]')\n",
|
||||
"lo_00, = axs2[0].plot(pl_vec,pressure_conversion(pipe.p_old,'Pa','mWs')[0],marker='.')\n",
|
||||
"axs2[1].set_ylabel(r'$p$ [mWS]')\n",
|
||||
"lo_00, = axs2[0].plot(pl_vec,pressure_conversion(pipe.p_old,'Pa','mWS')[0],marker='.')\n",
|
||||
"lo_01, = axs2[1].plot(pl_vec,pipe.v_old,marker='.')\n",
|
||||
"axs2[0].set_ylim([-5*np.max(pressure_conversion(pipe.p_old,'Pa','mWs')[0]),5*np.max(pressure_conversion(pipe.p_old,'Pa','mWs')[0])])\n",
|
||||
"axs2[0].set_ylim([-2*np.max(pressure_conversion(p_init,'Pa','mWS')[0]),2*np.max(pressure_conversion(p_init,'Pa','mWS')[0])])\n",
|
||||
"axs2[1].set_ylim([-2*np.max(v_init),2*np.max(v_init)])\n",
|
||||
"fig2.tight_layout()\n",
|
||||
"\n",
|
||||
@@ -147,7 +146,7 @@
|
||||
"for it in range(1,pipe.nt):\n",
|
||||
" pipe.set_boundary_conditions_next_timestep(v_0[it],p_0[it],v_np1[it])\n",
|
||||
" pipe.timestep_characteristic_method()\n",
|
||||
" lo_00.set_ydata(pipe.p)\n",
|
||||
" lo_00.set_ydata(pressure_conversion(pipe.p,'Pa','mWS')[0])\n",
|
||||
" lo_01.set_ydata(pipe.v)\n",
|
||||
"\n",
|
||||
" # store parameters of node 0 (at reservoir)\n",
|
||||
@@ -165,35 +164,52 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 55,
|
||||
"execution_count": 16,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"fig3,axs3 = plt.subplots(2,2)\n",
|
||||
"axs3[0,0].plot(t_vec,pipe.p_0)\n",
|
||||
"axs3[0,0].plot(t_vec,pressure_conversion(pipe.p_0,'Pa','mWS')[0])\n",
|
||||
"axs3[0,1].plot(t_vec,pipe.v_0)\n",
|
||||
"axs3[1,0].plot(t_vec,pipe.p_np1)\n",
|
||||
"axs3[1,0].plot(t_vec,pressure_conversion(pipe.p_np1,'Pa','mWS')[0])\n",
|
||||
"axs3[1,1].plot(t_vec,pipe.v_np1)\n",
|
||||
"axs3[0,0].set_title('Pressure Reservoir')\n",
|
||||
"axs3[0,1].set_title('Velocity Reservoir')\n",
|
||||
"axs3[1,0].set_title('Pressure Turbine')\n",
|
||||
"axs3[1,1].set_title('Velocity Turbine')\n",
|
||||
"axs3[0,0].set_xlabel(r'$t$ [$\\mathrm{s}$]')\n",
|
||||
"axs3[0,0].set_ylabel(r'$p$ [Pa]')\n",
|
||||
"axs3[0,0].set_ylabel(r'$p$ [mWS]')\n",
|
||||
"axs3[0,1].set_xlabel(r'$t$ [$\\mathrm{s}$]')\n",
|
||||
"axs3[0,1].set_ylabel(r'$v$ [$\\mathrm{m}/\\mathrm{s}$]')\n",
|
||||
"axs3[1,0].set_xlabel(r'$t$ [$\\mathrm{s}$]')\n",
|
||||
"axs3[1,0].set_ylabel(r'$p$ [Pa]')\n",
|
||||
"axs3[1,0].set_ylabel(r'$p$ [mWS]')\n",
|
||||
"axs3[1,1].set_xlabel(r'$t$ [$\\mathrm{s}$]')\n",
|
||||
"axs3[1,1].set_ylabel(r'$v$ [$\\mathrm{m}/\\mathrm{s}$]')\n",
|
||||
"fig3.tight_layout()\n",
|
||||
"plt.show()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 17,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"0.29590621205048523\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"print(np.mean(v_0))"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3.8.13 ('DT_Slot_3')",
|
||||
"display_name": "Python 3.8.13 ('Georg_DT_Slot3')",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
@@ -212,7 +228,7 @@
|
||||
"orig_nbformat": 4,
|
||||
"vscode": {
|
||||
"interpreter": {
|
||||
"hash": "4a28055eb8a3160fa4c7e4fca69770c4e0a1add985300856aa3fcf4ce32a2c48"
|
||||
"hash": "84fb123bdc47ab647d3782661abcbe80fbb79236dd2f8adf4cef30e8755eb2cd"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user