added safety condition on turbine flux and turbine LA

This commit is contained in:
Georg ´Brantegger
2022-07-29 08:25:23 +02:00
parent dc5bcfe7f8
commit b4bfd017de

View File

@@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": 18,
"execution_count": 9,
"metadata": {},
"outputs": [],
"source": [
@@ -18,7 +18,7 @@
},
{
"cell_type": "code",
"execution_count": 19,
"execution_count": 10,
"metadata": {},
"outputs": [],
"source": [
@@ -27,7 +27,7 @@
"#Turbine\n",
"Q_nenn = 0.85 # m³/s\n",
"p_nenn = pressure_conversion(10.6,'bar','Pa')\n",
"closing_time = 70 #s\n",
"closing_time = 30 #s\n",
"\n",
"# physics\n",
"g = 9.81 # gravitational acceleration [m/s²]\n",
@@ -51,7 +51,7 @@
"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 = 1000 # number of time steps after initial conditions\n",
"nt = 4500 # number of time steps after initial conditions\n",
"\n",
"# derivatives of the pipeline constants\n",
"dx = L/n # length of each pipe segment\n",
@@ -75,7 +75,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"
@@ -83,7 +83,7 @@
},
{
"cell_type": "code",
"execution_count": 20,
"execution_count": 11,
"metadata": {},
"outputs": [],
"source": [
@@ -96,20 +96,46 @@
"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",
"T1 = Francis_Turbine(Q_nenn,p_nenn,closing_time,timestep = dt)\n",
"T1 = Francis_Turbine(Q_nenn,p_nenn,closing_time,timestep=dt)\n",
"T1.set_steady_state(initial_flux,initial_pressure_turbine)\n",
"\n",
"T_in = Francis_Turbine(Q_nenn,p_nenn,closing_time/2,timestep=dt)\n",
"T_in.set_steady_state(initial_flux,p_nenn)\n",
"\n",
"Pegelregler = PI_controller_class(target_level,deadband_range,Kp,Ti,dt)\n",
"Pegelregler.control_variable = T1.get_current_LA()\n"
]
},
{
"cell_type": "code",
"execution_count": 22,
"execution_count": 12,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"The current attributes are: \n",
"----------------------------- \n",
"Current flux = -1.0 m³/s \n",
"Current pipe pressure = -1.0 mWS \n",
"Current LA = 90.90909090909089 % \n",
"----------------------------- \n",
"\n"
]
}
],
"source": [
"T_in.get_info()"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"outputs": [],
"source": [
@@ -137,15 +163,17 @@
"p_boundary_res[0] = p_old[0]\n",
"p_boundary_tur[0] = p_old[-1]\n",
"\n",
"LA_soll_vec = np.full_like(t_vec,T1.LA)\n",
"LA_ist_vec = np.full_like(t_vec,T1.LA)\n",
"LA_soll_vec = np.full_like(t_vec,T1.get_current_LA())\n",
"LA_ist_vec = np.full_like(t_vec,T1.get_current_LA())\n",
"\n",
"\n"
"LA_soll_vec2 = np.full_like(t_vec,T_in.get_current_LA())\n",
"LA_soll_vec2[200:1500] = 0.\n",
"LA_soll_vec2[1500:2500] = 1. \n"
]
},
{
"cell_type": "code",
"execution_count": 23,
"execution_count": 14,
"metadata": {},
"outputs": [],
"source": [
@@ -173,38 +201,21 @@
},
{
"cell_type": "code",
"execution_count": 24,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"1.2146505196687856\n"
]
}
],
"source": [
"print(initial_flux/area_outflux)"
]
},
{
"cell_type": "code",
"execution_count": 25,
"execution_count": 15,
"metadata": {},
"outputs": [],
"source": [
"# loop through time steps of the pipeline\n",
"for it_pipe in range(1,pipe.nt+1):\n",
"\n",
" T_in.update_LA(LA_soll_vec2[it_pipe])\n",
" T_in.set_pressure(p_nenn)\n",
" V.set_influx(T_in.get_current_Q())\n",
"\n",
" if it_pipe > 0.015*(nt+1):\n",
" if V.get_current_influx() > 0:\n",
" V.set_influx(np.max([V.get_current_influx()-initial_flux*5*1e-3,0.]))\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]\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",
@@ -216,10 +227,9 @@
" \n",
" # change the Leitapparatöffnung based on the target value\n",
" T1.update_LA(LA_soll_vec[it_pipe])\n",
" LA_ist_vec[it_pipe] = T1.get_current_LA()\n",
"\n",
" T1.set_pressure(p_old[-1])\n",
"\n",
" LA_ist_vec[it_pipe] = T1.LA\n",
"\n",
" # set boundary conditions for the next timestep of the characteristic method\n",
" p_boundary_res[it_pipe] = V.get_current_pressure()\n",
" v_boundary_tur[it_pipe] = 1/A_pipe*T1.get_current_Q()\n",
@@ -229,6 +239,7 @@
" p_boundary_tur[it_pipe] = pipe.get_current_pressure_distribution()[-1]\n",
" v_boundary_res[it_pipe] = pipe.get_current_velocity_distribution()[0]\n",
"\n",
"\n",
" # perform the next timestep via the characteristic method\n",
" pipe.timestep_characteristic_method()\n",
"\n",
@@ -257,7 +268,7 @@
},
{
"cell_type": "code",
"execution_count": 26,
"execution_count": 16,
"metadata": {},
"outputs": [],
"source": [
@@ -298,28 +309,11 @@
"fig2.tight_layout()\n",
"plt.show()"
]
},
{
"cell_type": "code",
"execution_count": 27,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"0.0\n"
]
}
],
"source": [
"print(np.sum(v_boundary_res[2500:])*area_outflux)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3.8.13 ('Georg_DT_Slot3')",
"display_name": "Python 3.8.13 ('DT_Slot_3')",
"language": "python",
"name": "python3"
},
@@ -338,7 +332,7 @@
"orig_nbformat": 4,
"vscode": {
"interpreter": {
"hash": "84fb123bdc47ab647d3782661abcbe80fbb79236dd2f8adf4cef30e8755eb2cd"
"hash": "4a28055eb8a3160fa4c7e4fca69770c4e0a1add985300856aa3fcf4ce32a2c48"
}
}
},