diff --git a/Druckrohrleitung/Druckrohrleitung_class_file.py b/Druckrohrleitung/Druckrohrleitung_class_file.py index 5458873..c6dd4bf 100644 --- a/Druckrohrleitung/Druckrohrleitung_class_file.py +++ b/Druckrohrleitung/Druckrohrleitung_class_file.py @@ -19,7 +19,6 @@ class Druckrohrleitung_class: density_unit = r'$\mathrm{kg}/\mathrm{m}^3$' flux_unit = r'$\mathrm{m}^3/\mathrm{s}$' length_unit = 'm' - pressure_unit = 'Pa' time_unit = 's' velocity_unit = r'$\mathrm{m}/\mathrm{s}$' # for flux and pressure propagation volume_unit = r'$\mathrm{m}^3$' @@ -30,7 +29,6 @@ class Druckrohrleitung_class: density_unit_print = 'kg/m³' flux_unit_print = 'm³/s' length_unit_print = 'm' - pressure_unit_print = 'Pa' time_unit_print = 's' velocity_unit_print = 'm/s' # for flux and pressure propagation volume_unit_print = 'm³' @@ -65,14 +63,15 @@ class Druckrohrleitung_class: else: self.t_vec = np.arange(0,self.nt*self.dt,self.dt) - def set_initial_pressure(self,pressure,input_unit = 'Pa'): - p,_ = pressure_conversion(pressure,input_unit,target_unit=self.pressure_unit) - if np.size(p) == 1: - self.p0 = np.full_like(self.l_vec,p) - elif np.size(p) == np.size(self.l_vec): - self.p0 = p + def set_initial_pressure(self,pressure,pressure_unit,display_pressure_unit): + if np.size(pressure) == 1: + self.p0 = np.full_like(self.l_vec,pressure) + elif np.size(pressure) == np.size(self.l_vec): + self.p0 = pressure else: raise Exception('Unable to assign initial pressure. Input has to be of size 1 or' + np.size(self.l_vec)) + self.pressure_unit = pressure_unit + self.pressure_unit_print = display_pressure_unit #initialize the vectors in which the old and new pressures are stored for the method of characteristics self.p_old = self.p0.copy() @@ -102,7 +101,7 @@ class Druckrohrleitung_class: v_old = self.v_old[-2] # @ second to last node (the one before the turbine) self.v_boundary_res = v_reservoir # at new timestep self.v_boundary_tur = v_turbine # at new timestep - self.p_boundary_res,_ = pressure_conversion(p_reservoir,input_unit_pressure,target_unit=self.pressure_unit) + self.p_boundary_res = p_reservoir self.p_boundary_tur = p_old-rho*c*(v_turbine-v_old)+rho*c*dt*g*np.sin(alpha)-f_D*rho*c*dt/(2*D)*abs(v_old)*v_old self.v[0] = self.v_boundary_res.copy() self.v[-1] = self.v_boundary_tur.copy() @@ -137,15 +136,15 @@ class Druckrohrleitung_class: print(print_str) - def get_boundary_conditions_next_timestep(self,target_unit_pressure ='bar'): + def get_boundary_conditions_next_timestep(self): print('The pressure at the reservoir for the next timestep is', '\n', \ - pressure_conversion(self.p_boundary_res,self.pressure_unit_print,target_unit_pressure), '\n', \ + pressure_conversion(self.p_boundary_res,self.pressure_unit,self.pressure_unit_print), '\n', \ 'The velocity at the reservoir for the next timestep is', '\n', \ - self.v_boundary_res, self.velocity_unit, '\n', \ + self.v_boundary_res, self.velocity_unit_print, '\n', \ 'The pressure at the turbine for the next timestep is', '\n', \ - pressure_conversion(self.p_boundary_tur,self.pressure_unit_print,target_unit_pressure), '\n', \ + pressure_conversion(self.p_boundary_tur,self.pressure_unit,self.pressure_unit_print), '\n', \ 'The velocity at the turbine for the next timestep is', '\n', \ - self.v_boundary_tur, self.velocity_unit) + self.v_boundary_tur, self.velocity_unit_print) def timestep_characteristic_method(self): diff --git a/Main_Programm.ipynb b/Main_Programm.ipynb index a0d1a35..a7505b6 100644 --- a/Main_Programm.ipynb +++ b/Main_Programm.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "code", - "execution_count": 26, + "execution_count": 1, "metadata": {}, "outputs": [], "source": [ @@ -16,7 +16,7 @@ }, { "cell_type": "code", - "execution_count": 27, + "execution_count": 2, "metadata": {}, "outputs": [], "source": [ @@ -61,7 +61,7 @@ "initial_outflux = Q0 # initial outflux of volume from the reservoir to the pipeline [m³/s]\n", "initial_pipeline_pressure = p0 # Initial condition for the static pipeline pressure at the reservoir (= hydrostatic pressure - dynamic pressure) \n", "initial_pressure_unit = 'Pa' # DO NOT CHANGE! for pressure conversion in print statements and plot labels \n", - "conversion_pressure_unit = 'Torr' # for pressure conversion in print statements and plot labels\n", + "conversion_pressure_unit = 'mWS' # for pressure conversion in print statements and plot labels\n", "area_base = 20. # total base are of the cuboid reservoir [m²] \n", "area_outflux = A_pipe # outlfux area of the reservoir, given by pipeline area [m²]\n", "critical_level_low = 0. # for yet-to-be-implemented warnings[m]\n", @@ -92,7 +92,7 @@ }, { "cell_type": "code", - "execution_count": 28, + "execution_count": 3, "metadata": {}, "outputs": [ { @@ -113,15 +113,6 @@ "Simulation timestep = 0.00025 s \n", "----------------------------- \n", "\n", - "The current attributes are: \n", - "----------------------------- \n", - "Current level = 20.0 m\n", - "Volume in reservoir = 400.0 m³ \n", - "Current influx = 0.0 m³/s \n", - "Current outflux = 2.0 m³/s \n", - "Current pipe pressure = 1447.306 Torr \n", - "----------------------------- \n", - "\n", "The pipeline has the following attributes: \n", "----------------------------- \n", "Length = 1000.0 m \n", @@ -154,17 +145,17 @@ "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_initial_pressure(p_init)\n", + "pipe.set_initial_pressure(p_init,initial_pressure_unit,conversion_pressure_unit)\n", "pipe.set_initial_flow_velocity(v_init)\n", "\n", "# display the attributes of the created reservoir and pipeline object\n", - "V.get_info(full=True)\n", - "pipe.get_info()" + "# V.get_info(full=True)\n", + "# pipe.get_info()" ] }, { "cell_type": "code", - "execution_count": 29, + "execution_count": 4, "metadata": {}, "outputs": [], "source": [ @@ -201,7 +192,7 @@ }, { "cell_type": "code", - "execution_count": 30, + "execution_count": 5, "metadata": {}, "outputs": [], "source": [ @@ -284,7 +275,7 @@ }, { "cell_type": "code", - "execution_count": 31, + "execution_count": 6, "metadata": {}, "outputs": [], "source": [