diff --git a/Turbinen/Turbinen_class_file.py b/Turbinen/Turbinen_class_file.py index e1b3d5a..30e37a0 100644 --- a/Turbinen/Turbinen_class_file.py +++ b/Turbinen/Turbinen_class_file.py @@ -71,7 +71,10 @@ class Francis_Turbine: def get_current_Q(self): # return the flux through the turbine, based on the current pressure in front # of the turbine and the Leitapparatöffnung - self.Q = self.Q_n*(self.LA/self.LA_n)*np.sqrt(self.p/self.p_n) + if self.p < 0: + self.Q = 0 + else: + self.Q = self.Q_n*(self.LA/self.LA_n)*np.sqrt(self.p/self.p_n) return self.Q def get_current_LA(self): @@ -114,7 +117,13 @@ class Francis_Turbine: LA_diff = self.LA-LA_soll # calculate the difference to the target LA LA_diff_max = self.d_LA_max_dt*self.dt # calculate the maximum change in LA based on the given timestep LA_diff = np.sign(LA_diff)*np.min(np.abs([LA_diff,LA_diff_max])) # calulate the correct change in LA - self.set_LA(self.LA-LA_diff,display_warning=False) # set new LA + + LA_new = self.LA-LA_diff + if LA_new < 0.: + LA_new = 0. + elif LA_new > 1.: + LA_new = 1. + self.set_LA(LA_new,display_warning=False) def set_steady_state(self,ss_flux,ss_pressure): # calculate and set steady state LA, that allows the flow of ss_flux at ss_pressure through the diff --git a/Untertweng.ipynb b/Untertweng.ipynb index bc92115..bbd030a 100644 --- a/Untertweng.ipynb +++ b/Untertweng.ipynb @@ -38,10 +38,7 @@ "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 = 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", + "n = 50 # number of pipe segments in discretization # 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", @@ -94,13 +91,8 @@ "\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.set_steady_state(initial_flux,initial_pressure_turbine)\n", - "\n", - "\n", - "# display the attributes of the created reservoir and pipeline object\n", - "# V.get_info(full=True)\n", - "# pipe.get_info()" + "T1 = Francis_Turbine(Q_nenn,p_nenn,closing_time,timestep=dt)\n", + "T1.set_steady_state(initial_flux,initial_pressure_turbine)\n" ] }, {