build a programm to test e-RK4-function - NOT WORKING YET
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1,3 +1,5 @@
|
|||||||
2bignored.txt
|
2bignored.txt
|
||||||
functions/__pycache__/
|
functions/__pycache__/
|
||||||
.vscode/settings.json
|
.vscode/settings.json
|
||||||
|
__pycache__/Ausgleichsbecken_class_file.cpython-38.pyc
|
||||||
|
__pycache__/Ausgleichsbecken.cpython-38.pyc
|
||||||
|
|||||||
@@ -38,8 +38,8 @@ def get_h_halfstep(initial_height, influx, outflux, timestep, area):
|
|||||||
def get_p_halfstep(p0, p1):
|
def get_p_halfstep(p0, p1):
|
||||||
p_halfstep = (p0+p1)/2
|
p_halfstep = (p0+p1)/2
|
||||||
|
|
||||||
def FODE_function(x, h, alpha, p, rho=1000, g=9.81):
|
def FODE_function(x, h, alpha, p, rho=1000., g=9.81):
|
||||||
f = x**2/h*alpha+g+p/(rho*h)
|
f = x**2/h*alpha+g-p/(rho*h)
|
||||||
return f
|
return f
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
84
Ausgleichsbecken_class_file.py
Normal file
84
Ausgleichsbecken_class_file.py
Normal file
@@ -0,0 +1,84 @@
|
|||||||
|
from Ausgleichsbecken import FODE_function, get_h_halfstep, get_p_halfstep
|
||||||
|
class Ausgleichsbecken_class:
|
||||||
|
# units
|
||||||
|
area_unit = 'm^2'
|
||||||
|
area_outflux_unit = 'm^2'
|
||||||
|
level_unit = 'm'
|
||||||
|
volume_unit = 'm^3'
|
||||||
|
flux_unit = 'm^3/s'
|
||||||
|
time_unit = 's'
|
||||||
|
|
||||||
|
# init
|
||||||
|
def __init__(self,area,outflux_area,level_min,level_max,timestep = 1):
|
||||||
|
self.area = area # base area of the rectangular structure
|
||||||
|
self.area_outflux = outflux_area # area of the outlet towards the pipeline
|
||||||
|
self.level_min = level_min # lowest allowed water level
|
||||||
|
self.level_max = level_max # highest allowed water level
|
||||||
|
self.timestep = timestep # timestep of the simulation
|
||||||
|
|
||||||
|
# setter
|
||||||
|
def set_volume(self):
|
||||||
|
self.volume = self.level*self.area
|
||||||
|
|
||||||
|
def set_initial_level(self,initial_level):
|
||||||
|
self.level = initial_level
|
||||||
|
self.set_volume()
|
||||||
|
|
||||||
|
def set_influx(self,influx):
|
||||||
|
self.influx = influx
|
||||||
|
|
||||||
|
def set_outflux(self,outflux):
|
||||||
|
self.outflux = outflux
|
||||||
|
|
||||||
|
# getter
|
||||||
|
def get_area(self):
|
||||||
|
print('The base area of the cuboid reservoir is', self.area, self.area_unit)
|
||||||
|
|
||||||
|
def get_outflux_area(self):
|
||||||
|
print('The outflux area from the cuboid reservoir to the pipeline is', \
|
||||||
|
self.area_outflux, self.area_outflux_unit)
|
||||||
|
|
||||||
|
def get_level(self):
|
||||||
|
print('The current level in the reservoir is', self.level , self.level_unit)
|
||||||
|
|
||||||
|
def get_crit_levels(self):
|
||||||
|
print('The critical water levels in the reservoir are: \n',\
|
||||||
|
' Minimum:', self.level_min , self.level_unit , '\n',\
|
||||||
|
' Maximum:', self.level_max , self.level_unit )
|
||||||
|
|
||||||
|
def get_volume(self):
|
||||||
|
print('The current water volume in the reservoir is', self.volume, self.volume_unit)
|
||||||
|
|
||||||
|
def get_timestep(self):
|
||||||
|
print('The timestep for the simulation is' , self.timestep, self.time_unit)
|
||||||
|
|
||||||
|
def get_influx(self):
|
||||||
|
print('The current influx is', self.influx, self.flux_unit)
|
||||||
|
|
||||||
|
def get_outflux(self):
|
||||||
|
print('The current outflux is', self.outflux, self.flux_unit)
|
||||||
|
|
||||||
|
# methods
|
||||||
|
def update_level(self,timestep):
|
||||||
|
net_flux = self.influx-self.outflux
|
||||||
|
delta_V = net_flux*timestep
|
||||||
|
new_level = (self.volume+delta_V)/self.area
|
||||||
|
return new_level
|
||||||
|
|
||||||
|
|
||||||
|
def e_RK_4(self):
|
||||||
|
yn = self.outflux/self.area_outflux
|
||||||
|
h = self.level
|
||||||
|
dt = self.timestep
|
||||||
|
p = self.p0
|
||||||
|
p_hs = self.p0
|
||||||
|
alpha = (self.area/self.area_outflux-1)
|
||||||
|
h_hs = self.update_level(dt/2)
|
||||||
|
Y1 = yn
|
||||||
|
Y2 = yn + dt/2*FODE_function(Y1, h, alpha, self.p0)
|
||||||
|
Y3 = yn + dt/2*FODE_function(Y2, h_hs, alpha, p_hs)
|
||||||
|
Y4 = yn + dt*FODE_function(Y3, h_hs, alpha, p_hs)
|
||||||
|
ynp1 = yn + dt/6*(FODE_function(Y1, h, alpha, p)+2*FODE_function(Y2, h_hs, alpha, p_hs)+ \
|
||||||
|
2*FODE_function(Y3, h_hs, alpha, p_hs)+ FODE_function(Y4, h, alpha, p))
|
||||||
|
|
||||||
|
self.outflux = ynp1*self.area_outflux
|
||||||
@@ -1,4 +1,9 @@
|
|||||||
import numpy as np
|
class Person:
|
||||||
print(np.__version__)
|
def __init__(self, name, age):
|
||||||
|
self.name = name
|
||||||
|
self.age = age
|
||||||
|
|
||||||
print("Test for Github commit")
|
p1 = Person("John", 36)
|
||||||
|
|
||||||
|
print(p1.name)
|
||||||
|
print(p1.age)
|
||||||
|
|||||||
93
e-RK4-Test.ipynb
Normal file
93
e-RK4-Test.ipynb
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user