fixed a coding mistake that lead to

a missbehavior in the time evolution of the
reservoir
This commit is contained in:
Georg ´Brantegger
2022-07-28 16:26:04 +02:00
parent e90406d90b
commit dc5bcfe7f8
5 changed files with 135 additions and 2087 deletions

View File

@@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": null,
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
@@ -17,7 +17,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
@@ -26,7 +26,7 @@
"#Turbine\n",
"Q_nenn = 0.85 # m³/s\n",
"p_nenn = pressure_conversion(10.6,'bar','Pa')\n",
"closing_time = 30 #s\n",
"closing_time = 5 #s\n",
"\n",
"# physics\n",
"g = 9.81 # gravitational acceleration [m/s²]\n",
@@ -38,14 +38,14 @@
"A_pipe = D**2/4*np.pi # pipeline area\n",
"h_pipe = 105 # hydraulic head without reservoir [m] \n",
"alpha = np.arcsin(h_pipe/L) # Höhenwinkel der Druckrohrleitung \n",
"n = 200 # number of pipe segments in discretization\n",
"n = 50 # number of pipe segments in discretization\n",
"# consider replacing Q0 with a vector be be more flexible in initial conditions\n",
"# Q0 = Q_nenn # initial flow in whole pipe [m³/s]\n",
"# v0 = Q0/A_pipe # initial flow velocity [m/s]\n",
"f_D = 0.014 # Darcy friction factor\n",
"c = 500. # 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 = 20000 # number of time steps after initial conditions\n",
"nt = 2500 # number of time steps after initial conditions\n",
"\n",
"# derivatives of the pipeline constants\n",
"dx = L/n # length of each pipe segment\n",
@@ -69,7 +69,7 @@
"critical_level_high = np.inf # for yet-to-be-implemented warnings[m]\n",
"\n",
"# make sure e-RK4 method of reservoir has a small enough timestep to avoid runaway numerical error\n",
"nt_eRK4 = 1000 # number of simulation steps of reservoir in between timesteps of pipeline \n",
"nt_eRK4 = 100 # number of simulation steps of reservoir in between timesteps of pipeline \n",
"simulation_timestep = dt/nt_eRK4\n",
"\n",
"\n"
@@ -77,7 +77,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
@@ -90,7 +90,7 @@
"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_flux,initial_level,pl_vec,h_vec)\n",
"pipe.set_steady_state(initial_flux,initial_level,area_base,pl_vec,h_vec)\n",
"\n",
"initial_pressure_turbine = pipe.get_current_pressure_distribution()[-1]\n",
"\n",
@@ -105,7 +105,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
@@ -142,7 +142,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
@@ -170,21 +170,20 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
"# loop through time steps of the pipeline\n",
"for it_pipe in range(1,pipe.nt+1):\n",
"\n",
" if t_vec[it_pipe]>20:\n",
" if V.get_current_influx() > 0:\n",
" V.set_influx(np.max([V.get_current_influx()-initial_flux*5*1e-3,0.]))\n",
" if it_pipe == 250:\n",
" V.set_influx(0.)\n",
"\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.set_pressure = p_old[0]\n",
" V.set_outflux = v_old[0]*area_outflux\n",
" V.set_pressure(p_old[0])\n",
" V.set_outflux(v_old[0]*area_outflux)\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.timestep_reservoir_evolution() \n",
@@ -233,7 +232,24 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 7,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"0.0\n"
]
}
],
"source": [
"print(V.get_current_influx())"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [],
"source": [
@@ -274,11 +290,57 @@
"fig2.tight_layout()\n",
"plt.show()"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"The cuboid reservoir has the following attributes: \n",
"----------------------------- \n",
"Base area = 74.0 m² \n",
"Outflux area = 0.636 m² \n",
"Current level = 7.875725956447418 m\n",
"Critical level low = 0.0 m \n",
"Critical level high = inf m \n",
"Volume in reservoir = -- m³ \n",
"Current influx = 0.0 m³/s \n",
"Current outflux = -0.1415386124341686 m³/s \n",
"Current outflux vel = -0.222 m/s \n",
"Current pipe pressure = 0.772 bar \n",
"Simulation timestep = 0.0004052 s \n",
"Density of liquid = 1000 kg/m³ \n",
"----------------------------- \n",
"\n",
"9.22707730779877\n",
"10.57842865915012\n",
"11.92978001050147\n",
"13.281131361852822\n",
"14.632482713204173\n",
"15.983834064555523\n",
"17.335185415906874\n",
"18.686536767258225\n",
"20.037888118609576\n",
"21.389239469960927\n"
]
}
],
"source": [
"V.get_info(full=True)\n",
"V.set_outflux(-10.)\n",
"for i in range(10):\n",
" V.level = V.update_level(10.)\n",
" print(V.get_current_level())"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3.8.13 ('Georg_DT_Slot3')",
"display_name": "Python 3.8.13 ('DT_Slot_3')",
"language": "python",
"name": "python3"
},
@@ -297,7 +359,7 @@
"orig_nbformat": 4,
"vscode": {
"interpreter": {
"hash": "84fb123bdc47ab647d3782661abcbe80fbb79236dd2f8adf4cef30e8755eb2cd"
"hash": "4a28055eb8a3160fa4c7e4fca69770c4e0a1add985300856aa3fcf4ce32a2c48"
}
}
},