further code cleanup
This commit is contained in:
@@ -25,7 +25,7 @@
|
||||
"\n",
|
||||
"#Turbine\n",
|
||||
"Q_nenn = 0.85\n",
|
||||
"p_nenn,_ = pressure_conversion(10.6,'bar','Pa')\n",
|
||||
"p_nenn = pressure_conversion(10.6,'bar','Pa')\n",
|
||||
"\n",
|
||||
"# physics\n",
|
||||
"g = 9.81 # gravitational acceleration [m/s²]\n",
|
||||
@@ -104,12 +104,12 @@
|
||||
"# create objects\n",
|
||||
"\n",
|
||||
"V = Ausgleichsbecken_class(area_base,area_outflux,critical_level_low,critical_level_high,simulation_timestep)\n",
|
||||
"V.set_steady_state(initial_influx,initial_level,initial_pressure_unit,conversion_pressure_unit)\n",
|
||||
"V.set_steady_state(initial_influx,initial_level,conversion_pressure_unit)\n",
|
||||
"\n",
|
||||
"pipe = Druckrohrleitung_class(L,D,n,alpha,f_D)\n",
|
||||
"pipe.set_pressure_propagation_velocity(c)\n",
|
||||
"pipe.set_number_of_timesteps(nt)\n",
|
||||
"pipe.set_steady_state(initial_influx,V.level,pl_vec,h_vec,initial_pressure_unit,conversion_pressure_unit)\n",
|
||||
"pipe.set_steady_state(initial_influx,V.level,pl_vec,h_vec)\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"T1 = Francis_Turbine(Q_nenn,p_nenn)\n",
|
||||
@@ -137,14 +137,14 @@
|
||||
" # keep in mind, that the velocity at the turbine and the pressure at the reservoir are set manually and\n",
|
||||
" # through the time evolution of the reservoir respectively \n",
|
||||
" # the pressure at the turbine and the velocity at the reservoir are calculated from the method of characteristics\n",
|
||||
"v_boundary_res = np.empty_like(t_vec)\n",
|
||||
"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",
|
||||
"v_boundary_res = np.zeros_like(t_vec)\n",
|
||||
"v_boundary_tur = np.zeros_like(t_vec)\n",
|
||||
"p_boundary_res = np.zeros_like(t_vec)\n",
|
||||
"p_boundary_tur = np.zeros_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,V.level) # level at the end of each pipeline timestep\n",
|
||||
"level_vec_2 = np.empty([nt_eRK4]) # level throughout each reservoir timestep-used for plotting and overwritten afterwards\n",
|
||||
"level_vec_2 = np.zeros([nt_eRK4]) # level throughout each reservoir timestep-used for plotting and overwritten afterwards\n",
|
||||
"\n",
|
||||
"# set the boundary conditions for the first timestep\n",
|
||||
"v_boundary_res[0] = v_old[0]\n",
|
||||
@@ -176,7 +176,7 @@
|
||||
"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,initial_pressure_unit, conversion_pressure_unit)[0],marker='.')\n",
|
||||
"lo_00, = axs1[0].plot(pl_vec,pressure_conversion(pipe.p_old,initial_pressure_unit, conversion_pressure_unit),marker='.')\n",
|
||||
"lo_01, = axs1[1].plot(pl_vec,pipe.v_old,marker='.')\n",
|
||||
"axs1[0].autoscale()\n",
|
||||
"axs1[1].autoscale()\n",
|
||||
@@ -193,7 +193,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 6,
|
||||
"execution_count": 7,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
@@ -208,7 +208,7 @@
|
||||
" for it_res in range(nt_eRK4):\n",
|
||||
" V.e_RK_4() # call e-RK4 to update outflux\n",
|
||||
" V.level = V.update_level(V.timestep) # \n",
|
||||
" V.set_volume() # update volume in reservoir\n",
|
||||
" V.update_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",
|
||||
@@ -217,15 +217,14 @@
|
||||
"\n",
|
||||
" # set boundary conditions for the next timestep of the characteristic method\n",
|
||||
" p_boundary_res[it_pipe] = rho*g*V.level-V.outflux_vel**2*rho/2\n",
|
||||
" v_boundary_res[it_pipe] = v_old[1]+1/(rho*c)*(p_boundary_res[it_pipe]-p_old[1])-f_D*dt/(2*D)*abs(v_old[1])*v_old[1] \\\n",
|
||||
" +dt*g*np.sin(alpha)\n",
|
||||
"\n",
|
||||
" T1.change_LA(LA_soll_vec[it_pipe],dt)\n",
|
||||
" v_boundary_tur[it_pipe] = 1/A_pipe*T1.get_Q(p_old[-1])\n",
|
||||
"\n",
|
||||
" # the the boundary conditions in the pipe.object and thereby calculate boundary pressure at turbine\n",
|
||||
" pipe.set_boundary_conditions_next_timestep(v_boundary_res[it_pipe],p_boundary_res[it_pipe],v_boundary_tur[it_pipe])\n",
|
||||
" pipe.set_boundary_conditions_next_timestep(p_boundary_res[it_pipe],v_boundary_tur[it_pipe])\n",
|
||||
" p_boundary_tur[it_pipe] = pipe.p_boundary_tur\n",
|
||||
" v_boundary_res[it_pipe] = pipe.v_boundary_res\n",
|
||||
"\n",
|
||||
" # perform the next timestep via the characteristic method\n",
|
||||
" pipe.timestep_characteristic_method()\n",
|
||||
@@ -236,7 +235,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,initial_pressure_unit, conversion_pressure_unit)[0],marker='.',c='blue')\n",
|
||||
" lo_00, = axs1[0].plot(pl_vec,pressure_conversion(pipe.p_old,initial_pressure_unit, conversion_pressure_unit),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(round(t_vec[it_pipe],2))+ ' s / '+str(round(t_vec[-1],2)) + ' s' )\n",
|
||||
@@ -255,16 +254,17 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 7,
|
||||
"execution_count": 9,
|
||||
"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,initial_pressure_unit, conversion_pressure_unit)[0])\n",
|
||||
"axs2[0,0].plot(t_vec,pressure_conversion(p_boundary_res,initial_pressure_unit, conversion_pressure_unit))\n",
|
||||
"axs2[0,1].plot(t_vec,v_boundary_res)\n",
|
||||
"axs2[1,0].plot(t_vec,pressure_conversion(p_boundary_tur,initial_pressure_unit, conversion_pressure_unit)[0])\n",
|
||||
"axs2[0,1].set_ylim(-2*Q_nenn,+2*Q_nenn)\n",
|
||||
"axs2[1,0].plot(t_vec,pressure_conversion(p_boundary_tur,initial_pressure_unit, conversion_pressure_unit))\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",
|
||||
@@ -290,7 +290,7 @@
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3.8.13 ('DT_Slot_3')",
|
||||
"display_name": "Python 3.8.13 ('Georg_DT_Slot3')",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
@@ -309,7 +309,7 @@
|
||||
"orig_nbformat": 4,
|
||||
"vscode": {
|
||||
"interpreter": {
|
||||
"hash": "4a28055eb8a3160fa4c7e4fca69770c4e0a1add985300856aa3fcf4ce32a2c48"
|
||||
"hash": "84fb123bdc47ab647d3782661abcbe80fbb79236dd2f8adf4cef30e8755eb2cd"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user