{ "cells": [ { "cell_type": "code", "execution_count": 1, "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": 2, "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": 3, "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", "# V.set_initial_pressure(pressure_conversion(initial_pipeline_pressure,input_unit = initial_pressure_unit, target_unit = 'Pa'),conversion_pressure_unit)\n", "# V.pressure = converted_pressure\n", "V.set_steady_state(initial_influx,initial_level,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.get_current_outflux()\n", "level_vec = np.empty_like(time_vec)\n", "level_vec[0] = V.get_current_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.get_current_pressure())\n", " \n", "i_max = -1\n", "\n", "for i in range(np.size(time_vec)-1):\n", " V.set_pressure(pressure_vec[i])\n", " V.timestep_reservoir_evolution()\n", " outflux_vec[i+1] = V.get_current_outflux()\n", " level_vec[i+1] = V.get_current_level()\n", " if V.level < total_min_level:\n", " i_max = i\n", " break\n", "\n" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [], "source": [ "\n", "fig1, (ax1, ax2, ax3) = plt.subplots(3, 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), 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", "\n", "fig1.tight_layout() " ] } ], "metadata": { "kernelspec": { "display_name": "Python 3.8.13 ('Georg_DT_Slot3')", "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": "84fb123bdc47ab647d3782661abcbe80fbb79236dd2f8adf4cef30e8755eb2cd" } } }, "nbformat": 4, "nbformat_minor": 2 }