diff --git a/Ausgleichsbecken.py b/Ausgleichsbecken.py index e69de29..f56b829 100644 --- a/Ausgleichsbecken.py +++ b/Ausgleichsbecken.py @@ -0,0 +1,35 @@ +import numpy as np + +def Volume_trend(influx,outflux,timestep=1,V_0=0): + ''' + Returns the trend and the volume and the final volume, defined + by influx and outflux patterns. The optional parameter timestep + defines the time increment over which the fluxes are changing. + ''' + net_flux = influx-outflux + delta_V = net_flux*timestep + V_trend = V_0+np.cumsum(delta_V) + V_end = V_trend[-1] + return V_end, V_trend + +def Height_trend(V_trend,area=1,h_crit_low=-np.inf,h_crit_high=np.inf): + ''' + Returns the trend and the height and the final height, defined + by influx and outflux patterns as well as the crosssection area. + The optional parameters h_crit_low/high indicate limits that the height + should never exceed. If this occures, TRUE is returned in the corresponding + h_crit_flag. + ''' + h_trend = V_trend/area + h_crit_flag_low = np.any(h_trend <= h_crit_low) + h_crit_flag_high = np.any(h_trend >= h_crit_high) + h_end = h_trend[-1] + return h_trend,h_end,h_crit_flag_low,h_crit_flag_high + +## testing +if __name__ == "__main__": + influx = np.full([1,100], 6) + outflux = np.full_like(influx, 4) + V_end, V_trend = Volume_trend(influx, outflux,timestep=0.5,V_0 = 100) + print(V_end) + print(V_trend) diff --git a/Druckrohrleitung.py b/Druckrohrleitung.py index e69de29..2aeb9d9 100644 --- a/Druckrohrleitung.py +++ b/Druckrohrleitung.py @@ -0,0 +1,17 @@ +import numpy as np + +def simple_time_delay(delta_p_profile,delay,timestep): + rounded_delay = timestep * np.round(delay/timestep) + print('Delay was rounded to ', rounded_delay) + n_pad = int(rounded_delay/timestep) + output_delta_p_profile = np.pad(delta_p_profile[0:-n_pad],[n_pad,0],constant_values=0) + return output_delta_p_profile + +## testing +if __name__ == "__main__": + delta_p_profile = np.ones([100]) + delay = 4 + timestep = 0.2 + + print(simple_time_delay(delta_p_profile, delay, timestep)) + diff --git a/__pycache__/Druckrohrleitung.cpython-38.pyc b/__pycache__/Druckrohrleitung.cpython-38.pyc new file mode 100644 index 0000000..82b5992 Binary files /dev/null and b/__pycache__/Druckrohrleitung.cpython-38.pyc differ