first attempt at involving a Pegelregler in the system
This commit is contained in:
169
Ausgleichsbecken/Ausgleichsbecken_test.ipynb
Normal file
169
Ausgleichsbecken/Ausgleichsbecken_test.ipynb
Normal file
@@ -0,0 +1,169 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 12,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import numpy as np\n",
|
||||
"from Ausgleichsbecken_class_file import Ausgleichsbecken_class\n",
|
||||
"import matplotlib.pyplot as plt\n",
|
||||
"\n",
|
||||
"#importing pressure conversion function\n",
|
||||
"import sys\n",
|
||||
"import os\n",
|
||||
"current = os.path.dirname(os.path.realpath('Main_Programm.ipynb'))\n",
|
||||
"parent = os.path.dirname(current)\n",
|
||||
"sys.path.append(parent)\n",
|
||||
"from functions.pressure_conversion import pressure_conversion"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 13,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# define constants\n",
|
||||
"initial_level = 10. # m\n",
|
||||
"initial_influx = 5. # m³/s\n",
|
||||
"initial_outflux = 1. # m³/s\n",
|
||||
"initial_pipeline_pressure = 10.\n",
|
||||
"initial_pressure_unit = 'mWS'\n",
|
||||
"conversion_pressure_unit = 'mWS'\n",
|
||||
"\n",
|
||||
"area_base = 1. # m²\n",
|
||||
"area_outflux = 0.5 # m²\n",
|
||||
"critical_level_low = 0. # m\n",
|
||||
"critical_level_high = 10. # m\n",
|
||||
"simulation_timestep = 0.001 # s\n",
|
||||
"\n",
|
||||
"# for while loop\n",
|
||||
"total_min_level = 0.01 # m\n",
|
||||
"total_max_time = 1000 # s"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 14,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"%matplotlib qt\n",
|
||||
"\n",
|
||||
"V = Ausgleichsbecken_class(area_base, area_outflux, critical_level_low, critical_level_high,simulation_timestep)\n",
|
||||
"# V.set_initial_level(initial_level) \n",
|
||||
"# V.set_influx(initial_influx)\n",
|
||||
"# V.set_outflux(initial_outflux)\n",
|
||||
"# converted_pressure,_ = pressure_conversion(initial_pipeline_pressure,input_unit = initial_pressure_unit, target_unit = 'Pa')\n",
|
||||
"# V.pressure = converted_pressure\n",
|
||||
"V.set_steady_state(initial_influx,initial_level,initial_pressure_unit,conversion_pressure_unit)\n",
|
||||
"\n",
|
||||
"time_vec = np.arange(0,total_max_time,simulation_timestep)\n",
|
||||
"outflux_vec = np.empty_like(time_vec)\n",
|
||||
"outflux_vec[0] = V.outflux\n",
|
||||
"level_vec = np.empty_like(time_vec)\n",
|
||||
"level_vec[0] = V.level\n",
|
||||
"\n",
|
||||
"# pressure_vec = np.full_like(time_vec,converted_pressure)*((np.sin(time_vec)+1)*np.exp(-time_vec/50))\n",
|
||||
"pressure_vec = np.full_like(time_vec,V.pressure)\n",
|
||||
" \n",
|
||||
"i_max = -1\n",
|
||||
"\n",
|
||||
"for i in range(np.size(time_vec)-1):\n",
|
||||
" # update to include p_halfstep\n",
|
||||
" V.pressure = pressure_vec[i]\n",
|
||||
" V.e_RK_4()\n",
|
||||
" V.level = V.update_level(V.timestep)\n",
|
||||
" V.set_volume()\n",
|
||||
" outflux_vec[i+1] = V.outflux\n",
|
||||
" level_vec[i+1] = V.level\n",
|
||||
" if V.level < total_min_level:\n",
|
||||
" i_max = i\n",
|
||||
" break\n",
|
||||
"\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 15,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"\n",
|
||||
"fig1, (ax1, ax2, ax3, ax4) = plt.subplots(4, 1)\n",
|
||||
"fig1.set_figheight(10)\n",
|
||||
"fig1.suptitle('Ausgleichsbecken')\n",
|
||||
"\n",
|
||||
"ax1.plot(time_vec[:i_max],level_vec[:i_max], label='Water level')\n",
|
||||
"ax1.set_ylabel(r'$h$ ['+V.level_unit+']')\n",
|
||||
"ax1.set_xlabel(r'$t$ ['+V.time_unit+']')\n",
|
||||
"ax1.legend()\n",
|
||||
"\n",
|
||||
"ax2.plot(time_vec[:i_max],outflux_vec[:i_max], label='Outflux')\n",
|
||||
"ax2.set_ylabel(r'$Q_{out}$ ['+V.flux_unit+']')\n",
|
||||
"ax2.set_xlabel(r'$t$ ['+V.time_unit+']')\n",
|
||||
"ax2.legend()\n",
|
||||
"\n",
|
||||
"ax3.plot(time_vec[:i_max],pressure_conversion(pressure_vec[:i_max],'Pa',conversion_pressure_unit)[0], label='Pipeline pressure at reservoir')\n",
|
||||
"ax3.set_ylabel(r'$p_{pipeline}$ ['+conversion_pressure_unit+']')\n",
|
||||
"ax3.set_xlabel(r'$t$ ['+V.time_unit+']')\n",
|
||||
"ax3.legend()\n",
|
||||
"\n",
|
||||
"# plt.subplots_adjust(left=0.2, bottom=0.2)\n",
|
||||
"ax4.set_axis_off()\n",
|
||||
"cell_text = np.array([[level_vec[0], V.level_unit], \\\n",
|
||||
" [initial_influx, V.flux_unit], \\\n",
|
||||
" [outflux_vec[0], V.flux_unit], \\\n",
|
||||
" [simulation_timestep, V.time_unit], \\\n",
|
||||
" [area_base, V.area_unit], \\\n",
|
||||
" [area_outflux, V.area_unit]])\n",
|
||||
"\n",
|
||||
"row_labels =['initial_level', \\\n",
|
||||
" 'initial_influx', \\\n",
|
||||
" 'initial_outflux', \\\n",
|
||||
" 'simulation_timestep', \\\n",
|
||||
" 'area_base', \\\n",
|
||||
" 'area_outflux']\n",
|
||||
"\n",
|
||||
"plt.table(cellText=cell_text, \\\n",
|
||||
" cellLoc='center', \\\n",
|
||||
" colWidths=[0.3,0.1,0.3], \\\n",
|
||||
" rowLabels=row_labels, \\\n",
|
||||
" loc = 1, \\\n",
|
||||
" rowLoc='left', \\\n",
|
||||
" fontsize = 15.)\n",
|
||||
"\n",
|
||||
"fig1.tight_layout() "
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3.8.13 ('DT_Slot_3')",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
"codemirror_mode": {
|
||||
"name": "ipython",
|
||||
"version": 3
|
||||
},
|
||||
"file_extension": ".py",
|
||||
"mimetype": "text/x-python",
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.8.13"
|
||||
},
|
||||
"orig_nbformat": 4,
|
||||
"vscode": {
|
||||
"interpreter": {
|
||||
"hash": "4a28055eb8a3160fa4c7e4fca69770c4e0a1add985300856aa3fcf4ce32a2c48"
|
||||
}
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 2
|
||||
}
|
||||
Reference in New Issue
Block a user