started implementing turbine and controller code
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
import numpy as np
|
||||
# from Ausgleichsbecken_functions import FODE_function, get_h_halfstep, get_p_halfstep
|
||||
|
||||
#importing pressure conversion function
|
||||
import sys
|
||||
@@ -86,7 +85,7 @@ class Ausgleichsbecken_class:
|
||||
f"Volume in reservoir = {self.volume:<10} {self.volume_unit_print} {new_line}"
|
||||
f"Current influx = {self.influx:<10} {self.flux_unit_print} {new_line}"
|
||||
f"Current outflux = {self.outflux:<10} {self.flux_unit_print} {new_line}"
|
||||
f"Current outflux vel = {self.outflux_vel:<10} {self.velocity_unit_print} {new_line}"
|
||||
f"Current outflux vel = {round(self.outflux_vel,3):<10} {self.velocity_unit_print} {new_line}"
|
||||
f"Current pipe pressure = {round(p,3):<10} {self.pressure_unit_print} {new_line}"
|
||||
f"Simulation timestep = {self.timestep:<10} {self.time_unit_print} {new_line}"
|
||||
f"----------------------------- {new_line}")
|
||||
@@ -98,7 +97,7 @@ class Ausgleichsbecken_class:
|
||||
f"Volume in reservoir = {self.volume:<10} {self.volume_unit_print} {new_line}"
|
||||
f"Current influx = {self.influx:<10} {self.flux_unit_print} {new_line}"
|
||||
f"Current outflux = {self.outflux:<10} {self.flux_unit_print} {new_line}"
|
||||
f"Current outflux vel = {self.outflux_vel:<10} {self.velocity_unit_print} {new_line}"
|
||||
f"Current outflux vel = {round(self.outflux_vel,3):<10} {self.velocity_unit_print} {new_line}"
|
||||
f"Current pipe pressure = {round(p,3):<10} {self.pressure_unit_print} {new_line}"
|
||||
f"----------------------------- {new_line}")
|
||||
|
||||
|
||||
@@ -133,7 +133,7 @@
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3.8.13 ('Georg_DT_Slot3')",
|
||||
"display_name": "Python 3.8.13 ('DT_Slot_3')",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
@@ -152,7 +152,7 @@
|
||||
"orig_nbformat": 4,
|
||||
"vscode": {
|
||||
"interpreter": {
|
||||
"hash": "84fb123bdc47ab647d3782661abcbe80fbb79236dd2f8adf4cef30e8755eb2cd"
|
||||
"hash": "4a28055eb8a3160fa4c7e4fca69770c4e0a1add985300856aa3fcf4ce32a2c48"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -153,7 +153,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 12,
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
@@ -181,8 +181,15 @@
|
||||
"# axs1[2].autoscale()\n",
|
||||
"fig1.tight_layout()\n",
|
||||
"fig1.show()\n",
|
||||
"plt.pause(1)\n",
|
||||
"\n",
|
||||
"plt.pause(1)\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 12,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# loop through time steps of the pipeline\n",
|
||||
"for it_pipe in range(1,pipe.nt+1):\n",
|
||||
"\n",
|
||||
@@ -273,7 +280,7 @@
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3.8.13 ('Georg_DT_Slot3')",
|
||||
"display_name": "Python 3.8.13 ('DT_Slot_3')",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
@@ -292,7 +299,7 @@
|
||||
"orig_nbformat": 4,
|
||||
"vscode": {
|
||||
"interpreter": {
|
||||
"hash": "84fb123bdc47ab647d3782661abcbe80fbb79236dd2f8adf4cef30e8755eb2cd"
|
||||
"hash": "4a28055eb8a3160fa4c7e4fca69770c4e0a1add985300856aa3fcf4ce32a2c48"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
10351
Main_Programm_demo.ipynb
10351
Main_Programm_demo.ipynb
File diff suppressed because it is too large
Load Diff
35
Regler/Regler_class_file.py
Normal file
35
Regler/Regler_class_file.py
Normal file
@@ -0,0 +1,35 @@
|
||||
import numpy as np
|
||||
#based on https://en.wikipedia.org/wiki/PID_controller#Discrete_implementation
|
||||
|
||||
|
||||
class P_controller_class:
|
||||
def __init__(self,setpoint,proportionality_constant):
|
||||
self.SP = setpoint
|
||||
self.Kp = proportionality_constant
|
||||
self.error_history = []
|
||||
self.control_variable = 0.1
|
||||
self.lower_limit = -0.1 # default
|
||||
self.upper_limit = +0.1 # default
|
||||
|
||||
def set_control_variable_limits(self,lower_limit,upper_limit):
|
||||
self.lower_limit = lower_limit
|
||||
self.upper_limit = upper_limit
|
||||
|
||||
def calculate_error(self,process_variable):
|
||||
self.error = self.SP-process_variable
|
||||
self.error_history.append(self.error)
|
||||
|
||||
def get_control_variable(self):
|
||||
new_control = self.control_variable+self.Kp*(self.error_history[-1]-self.error_history[-2])
|
||||
if new_control < self.lower_limit:
|
||||
new_control = self.lower_limit
|
||||
|
||||
if new_control > self.upper_limit:
|
||||
new_control = self.upper_limit
|
||||
|
||||
self.control_variable = new_control
|
||||
# print(new_control)
|
||||
return new_control
|
||||
|
||||
|
||||
|
||||
148
Regler/regler_test.ipynb
Normal file
148
Regler/regler_test.ipynb
Normal file
File diff suppressed because one or more lines are too long
19
Turbinen/Turbinen_class_file.py
Normal file
19
Turbinen/Turbinen_class_file.py
Normal file
@@ -0,0 +1,19 @@
|
||||
def turbine_flux(p,LA,p_exp,cubic_coeff,quadratic_coeff,linear_coeff,const_coeff):
|
||||
return (p*1e-5)**p_exp*(cubic_coeff*LA**3+quadratic_coeff*LA**2+linear_coeff*LA+const_coeff)
|
||||
|
||||
|
||||
class Francis_turbine_class:
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
def set_turbine_flux_parameters(self,p_exp,cubic_coeff,quadratic_coeff,linear_coeff,const_coeff):
|
||||
# extracted from the Muschelkurve of the Turbine and used to calculate the turbine flux for a given pressure
|
||||
self.p_exp = p_exp
|
||||
self.cubic_coeff = cubic_coeff
|
||||
self.quadratic_coeff = quadratic_coeff
|
||||
self.linear_coeff = linear_coeff
|
||||
self.const_coeff = const_coeff
|
||||
|
||||
def get_turbine_flux(self,pressure,Leitapparatöffnung):
|
||||
self.flux = turbine_flux(pressure,Leitapparatöffnung,self.p_exp,self.cubic_coeff,self.quadratic_coeff,self.linear_coeff,self.const_coeff)
|
||||
return self.flux
|
||||
174
Turbinen/messy.ipynb
Normal file
174
Turbinen/messy.ipynb
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user