From 43483dc9598e49f296692e9cb8d12aa003929f9d Mon Sep 17 00:00:00 2001 From: Brantegger Georg Date: Tue, 9 Aug 2022 13:53:09 +0200 Subject: [PATCH] small change to the convergence and set steady state method --- Turbinen/Turbinen_class_file.py | 16 +++++++++++----- Turbinen/Turbinen_test_steady_state.ipynb | 19 ++++++++++--------- 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/Turbinen/Turbinen_class_file.py b/Turbinen/Turbinen_class_file.py index d8fbf41..628e9a6 100644 --- a/Turbinen/Turbinen_class_file.py +++ b/Turbinen/Turbinen_class_file.py @@ -78,6 +78,8 @@ class Francis_Turbine: if ss_LA < 0 or ss_LA > 1: raise Exception('LA out of range [0;1]') self.set_LA(ss_LA,display_warning=False) + self.set_pressure(ss_pressure) + self.get_current_Q() #getter - get attributes def get_current_Q(self): @@ -113,22 +115,26 @@ class Francis_Turbine: f"Nominal pressure = {round(p_n,3):<10} {self.pressure_unit_disp}{new_line}" f"Nominal LA = {self.LA_n*100:<10} {self.LA_unit_disp} {new_line}" f"Closing time = {self.t_c:<10} {self.time_unit_disp} {new_line}" - f"Current flux = {self.Q:<10} {self.flux_unit_disp} {new_line}" + f"Current flux = {round(self.Q,3):<10} {self.flux_unit_disp} {new_line}" f"Current pipe pressure = {round(p,3):<10} {self.pressure_unit_disp} {new_line}" - f"Current LA = {self.LA*100:<10} {self.LA_unit_disp} {new_line}" + f"Current LA = {round(self.LA,4)*100:<10} {self.LA_unit_disp} {new_line}" f"Simulation timestep = {self.dt:<10} {self.time_unit_disp} {new_line}" f"----------------------------- {new_line}") else: # :<10 pads the self.value to be 10 characters wide print_str = (f"The current attributes are: {new_line}" f"----------------------------- {new_line}" - f"Current flux = {self.Q:<10} {self.flux_unit_disp} {new_line}" + f"Current flux = {round(self.Q,3):<10} {self.flux_unit_disp} {new_line}" f"Current pipe pressure = {round(p,3):<10} {self.pressure_unit_disp} {new_line}" - f"Current LA = {self.LA*100:<10} {self.LA_unit_disp} {new_line}" + f"Current LA = {round(self.LA,4)*100:<10} {self.LA_unit_disp} {new_line}" f"----------------------------- {new_line}") print(print_str) + def get_Q_n(self): + # needed for Kraftwerk_class + return self.Q_n + # update methods def update_LA(self,LA_soll): # update the Leitappartöffnung and consider the restrictions of the closing time of the turbine @@ -182,4 +188,4 @@ class Francis_Turbine: print('did not converge') break # print(i) - self.Q = Q_new \ No newline at end of file + # self.get_current_Q() \ No newline at end of file diff --git a/Turbinen/Turbinen_test_steady_state.ipynb b/Turbinen/Turbinen_test_steady_state.ipynb index 2891587..acc9658 100644 --- a/Turbinen/Turbinen_test_steady_state.ipynb +++ b/Turbinen/Turbinen_test_steady_state.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "code", - "execution_count": null, + "execution_count": 1, "metadata": {}, "outputs": [], "source": [ @@ -23,7 +23,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 2, "metadata": {}, "outputs": [], "source": [ @@ -74,14 +74,14 @@ " # for general simulation\n", "flux_init = Tur_Q_nenn/1.1 # [m³/s] initial flux through whole system for steady state initialization \n", "level_init = Con_targetLevel # [m] initial water level in upstream reservoir for steady state initialization\n", - "simTime_target = 100. # [s] target for total simulation time (will vary slightly to fit with Pip_dt)\n", + "simTime_target = 600. # [s] target for total simulation time (will vary slightly to fit with Pip_dt)\n", "nt = int(simTime_target//Pip_dt) # [1] Number of timesteps of the whole system\n", "t_vec = np.arange(0,nt+1,1)*Pip_dt # [s] time vector. At each step of t_vec the system parameters are stored\n" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 3, "metadata": {}, "outputs": [], "source": [ @@ -110,7 +110,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 4, "metadata": {}, "outputs": [], "source": [ @@ -149,12 +149,13 @@ "LA_soll_vec = np.full_like(t_vec,turbine.get_current_LA())\n", "LA_ist_vec = np.full_like(t_vec,turbine.get_current_LA())\n", "\n", - "LA_soll_vec2 = np.full_like(t_vec,turbine_in.get_current_LA())\n" + "LA_soll_vec2 = np.full_like(t_vec,turbine_in.get_current_LA())\n", + "# LA_soll_vec2[100:] = 0\n" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 5, "metadata": {}, "outputs": [], "source": [ @@ -187,7 +188,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 6, "metadata": {}, "outputs": [], "source": [ @@ -267,7 +268,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 7, "metadata": {}, "outputs": [], "source": [