restructured folders
This commit is contained in:
3
Messing Around/.gitignore
vendored
Normal file
3
Messing Around/.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
2bignored.txt
|
||||
functions/__pycache__/
|
||||
.vscode/settings.json
|
||||
47
Messing Around/Messy_NB.ipynb
Normal file
47
Messing Around/Messy_NB.ipynb
Normal file
@@ -0,0 +1,47 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"11\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import numpy as np\n",
|
||||
"import plotly\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"interpreter": {
|
||||
"hash": "84fb123bdc47ab647d3782661abcbe80fbb79236dd2f8adf4cef30e8755eb2cd"
|
||||
},
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3.8.13 ('Georg_DT_Slot3')",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
"codemirror_mode": {
|
||||
"name": "ipython",
|
||||
"version": 3
|
||||
},
|
||||
"file_extension": ".py",
|
||||
"mimetype": "text/x-python",
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.8.13"
|
||||
},
|
||||
"orig_nbformat": 4
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 2
|
||||
}
|
||||
4
Messing Around/Messy_py.py
Normal file
4
Messing Around/Messy_py.py
Normal file
@@ -0,0 +1,4 @@
|
||||
import numpy as np
|
||||
print(np.__version__)
|
||||
|
||||
print("Test for Github commit")
|
||||
89
Messing Around/Zeitreihenvisualisierung.ipynb
Normal file
89
Messing Around/Zeitreihenvisualisierung.ipynb
Normal file
@@ -0,0 +1,89 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 8,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"%matplotlib qt\n",
|
||||
"import numpy as np\n",
|
||||
"import matplotlib.pyplot as plt\n",
|
||||
"\n",
|
||||
"n = 10000\n",
|
||||
"\n",
|
||||
"t = np.linspace(0,200*np.pi,n)\n",
|
||||
"omega = 2\n",
|
||||
"f_t = np.sin(omega*t)*np.cos(50/n*t)\n",
|
||||
"\n",
|
||||
"dt_max = 100\n",
|
||||
"x_s = np.full([dt_max,],np.NaN)\n",
|
||||
"y_s = np.full([dt_max,],np.NaN)\n",
|
||||
"\n",
|
||||
"# fig_ref = plt.figure()\n",
|
||||
"# ax_ref = fig_ref.add_subplot(111)\n",
|
||||
"# line_obj_ref = ax_ref.plot(t,f_t, marker='.')\n",
|
||||
"# plt.show(block=False)\n",
|
||||
"# plt.pause(3)\n",
|
||||
"# plt.close(fig_ref)\n",
|
||||
"\n",
|
||||
"fig = plt.figure()\n",
|
||||
"ax1 = fig.add_subplot(211)\n",
|
||||
"ax2 = fig.add_subplot(212)\n",
|
||||
"ax1.set_xlim([0,t[100+50]])\n",
|
||||
"ax1.set_ylim([-1.05,1.05])\n",
|
||||
"ax2.set_xlim([t[0],t[100+50]])\n",
|
||||
"ax2.set_ylim([-1.05,1.05])\n",
|
||||
"line_obj1, = ax1.plot(0,0, marker='.')\n",
|
||||
"line_obj2, = ax2.plot(0,0, marker='.')\n",
|
||||
"plt.show(block=False)\n",
|
||||
"plt.pause(0.01)\n",
|
||||
"\n",
|
||||
"for i in range(n):\n",
|
||||
" if i <= dt_max:\n",
|
||||
" x_s[:i] = t[:i]\n",
|
||||
" y_s[:i] = f_t[:i]\n",
|
||||
" else:\n",
|
||||
" x_s = t[i-dt_max:i]\n",
|
||||
" y_s = f_t[i-dt_max:i]\n",
|
||||
" ax1.set_xlim([t[i-dt_max],t[i]+t[50]])\n",
|
||||
" ax2.set_xlim([t[0],t[i]+(t[i]-t[0])/2])\n",
|
||||
" \n",
|
||||
" line_obj1.set_xdata(x_s)\n",
|
||||
" line_obj1.set_ydata(y_s)\n",
|
||||
" line_obj2.set_xdata(t[:i])\n",
|
||||
" line_obj2.set_ydata(f_t[:i])\n",
|
||||
" ax1.set_title(str(i))\n",
|
||||
" fig.canvas.draw()\n",
|
||||
" plt.pause(0.001)\n",
|
||||
"\n",
|
||||
" \n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"interpreter": {
|
||||
"hash": "84fb123bdc47ab647d3782661abcbe80fbb79236dd2f8adf4cef30e8755eb2cd"
|
||||
},
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3.8.13 ('Georg_DT_Slot3')",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
"codemirror_mode": {
|
||||
"name": "ipython",
|
||||
"version": 3
|
||||
},
|
||||
"file_extension": ".py",
|
||||
"mimetype": "text/x-python",
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.8.13"
|
||||
},
|
||||
"orig_nbformat": 4
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 2
|
||||
}
|
||||
138
Messing Around/flow_patterns.ipynb
Normal file
138
Messing Around/flow_patterns.ipynb
Normal file
@@ -0,0 +1,138 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import numpy as np\n",
|
||||
"import pandas as pd\n",
|
||||
"import plotly.express as px\n",
|
||||
"from plotly.subplots import make_subplots\n",
|
||||
"import plotly.graph_objects as go\n",
|
||||
"from flow_patterns import return_flux_profiles,make_flux_df\n",
|
||||
"from volume_change import V_h_test_2,h_V_test_2"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# #constant flows\n",
|
||||
"# #number of steps\n",
|
||||
"# n = 100\n",
|
||||
"# #input identifiers\n",
|
||||
"# i_i_1 = 0\n",
|
||||
"# #output identifiers\n",
|
||||
"# o_i_1 = 0\n",
|
||||
"# # influx and outflux offset\n",
|
||||
"# i_o = 10\n",
|
||||
"# o_o = 10\n",
|
||||
"# #outflux delay\n",
|
||||
"# o_d = 10\n",
|
||||
"\n",
|
||||
"# influx_profile,outflux_profile = return_flux_profiles(n,i_i_1,o_i_1,i_o,o_o,o_d)\n",
|
||||
"# flux_df = make_flux_df(influx_profile,outflux_profile)\n",
|
||||
"\n",
|
||||
"# fig = make_subplots(2,1)\n",
|
||||
"\n",
|
||||
"# fig.add_trace(go.Scatter(x=flux_df['time'],y=flux_df['influx']),row=1,col=1)\n",
|
||||
"# fig.add_trace(go.Scatter(x=flux_df['time'],y=flux_df['outflux']),row=2,col=1)\n",
|
||||
"# fig.show()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# #linear increasing flows\n",
|
||||
"# #number of steps\n",
|
||||
"# n = 100\n",
|
||||
"# #input identifiers\n",
|
||||
"# i_i_2 = 'lin_0010'\n",
|
||||
"# #output identifiers\n",
|
||||
"# o_i_2 = 'lin_0010'\n",
|
||||
"# # influx and outflux offset\n",
|
||||
"# i_o = 10\n",
|
||||
"# o_o = 10\n",
|
||||
"# #outflux delay\n",
|
||||
"# o_d = 10\n",
|
||||
"\n",
|
||||
"# influx_profile,outflux_profile = return_flux_profiles(n,i_i_2,o_i_2,i_o,o_o,o_d)\n",
|
||||
"# flux_df = make_flux_df(influx_profile,outflux_profile)\n",
|
||||
"\n",
|
||||
"# fig = make_subplots(2,1)\n",
|
||||
"\n",
|
||||
"# fig.add_trace(go.Scatter(x=flux_df['time'],y=flux_df['influx']),row=1,col=1)\n",
|
||||
"# fig.add_trace(go.Scatter(x=flux_df['time'],y=flux_df['outflux']),row=2,col=1)\n",
|
||||
"# fig.show()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# #sawtooth flows\n",
|
||||
"# #number of steps\n",
|
||||
"# n = 100\n",
|
||||
"# #input identifiers\n",
|
||||
"# i_i_3 = 'st_0010_0010'\n",
|
||||
"# #output identifiers\n",
|
||||
"# o_i_3 = 'st_0010_0010'\n",
|
||||
"# # influx and outflux offset\n",
|
||||
"# i_o = 10\n",
|
||||
"# o_o = 10\n",
|
||||
"# #outflux delay\n",
|
||||
"# o_d = 10\n",
|
||||
"\n",
|
||||
"# influx_profile,outflux_profile = return_flux_profiles(n,i_i_3,o_i_3,i_o,o_o,o_d)\n",
|
||||
"# flux_df = make_flux_df(influx_profile,outflux_profile)\n",
|
||||
"\n",
|
||||
"# fig = make_subplots(2,1)\n",
|
||||
"\n",
|
||||
"# fig.add_trace(go.Scatter(x=flux_df['time'],y=flux_df['influx']),row=1,col=1)\n",
|
||||
"# fig.add_trace(go.Scatter(x=flux_df['time'],y=flux_df['outflux']),row=2,col=1)\n",
|
||||
"# fig.show()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"interpreter": {
|
||||
"hash": "84fb123bdc47ab647d3782661abcbe80fbb79236dd2f8adf4cef30e8755eb2cd"
|
||||
},
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3.8.13 ('Georg_DT_Slot3')",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
"codemirror_mode": {
|
||||
"name": "ipython",
|
||||
"version": 3
|
||||
},
|
||||
"file_extension": ".py",
|
||||
"mimetype": "text/x-python",
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.8.13"
|
||||
},
|
||||
"orig_nbformat": 4
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 2
|
||||
}
|
||||
67
Messing Around/flow_patterns.py
Normal file
67
Messing Around/flow_patterns.py
Normal file
@@ -0,0 +1,67 @@
|
||||
import numpy as np
|
||||
import pandas as pd
|
||||
import plotly.express as px
|
||||
from plotly.subplots import make_subplots
|
||||
import plotly.graph_objects as go
|
||||
|
||||
|
||||
def return_flux_profiles(number_of_steps = 1,influx_identifier = 0, outflux_identifier = 0,influx_offset=0,outflux_offset=0, outflux_delay = 0):
|
||||
''' Identifier patterns:
|
||||
0 ... constant
|
||||
'lin_SSSS' ... linear increase with slope int(SSSS)
|
||||
'st_SSSS_PPPP' ... sawtooth pattern with slope int(SSSS) and period int(PPPP) steps
|
||||
'''
|
||||
|
||||
# case identifiers for if statment
|
||||
i = influx_identifier
|
||||
o = outflux_identifier
|
||||
|
||||
n = number_of_steps
|
||||
#starting value for the influx and outflux
|
||||
i_o = influx_offset
|
||||
o_o = outflux_offset
|
||||
# number of steps, the outflux is held at 0 at the beginning
|
||||
o_d = outflux_delay
|
||||
|
||||
|
||||
# get base profile for the influx (offset will get applied later)
|
||||
if i == 0:
|
||||
influx_profile = np.zeros(n)
|
||||
elif 'lin' in influx_identifier:
|
||||
k = int(influx_identifier[-4:])
|
||||
influx_profile = np.linspace(0,k*(n-1),n)
|
||||
elif 'st' in influx_identifier:
|
||||
k = int(influx_identifier[3:7])
|
||||
p = int(influx_identifier[-4:])
|
||||
influx_profile = np.tile(np.linspace(0,k*(p-1),p),int(np.ceil(n/p)))
|
||||
|
||||
|
||||
# apply influx offset
|
||||
influx_profile = influx_offset + influx_profile
|
||||
|
||||
if o == 0:
|
||||
outflux_profile = np.zeros(n)
|
||||
elif 'lin' in outflux_identifier:
|
||||
k = int(outflux_identifier[-4:])
|
||||
outflux_profile = np.linspace(0,k*(n-1),n)
|
||||
elif 'st' in outflux_identifier:
|
||||
k = int(outflux_identifier[3:7])
|
||||
p = int(outflux_identifier[-4:])
|
||||
outflux_profile = np.tile(np.linspace(0,k*(p-1),p),int(np.ceil(n/p)))
|
||||
|
||||
#apply outflux offset and delay (delay means, that the first o_d steps, the outflux will be 0)
|
||||
outflux_profile = np.concatenate((np.zeros(o_d),outflux_profile[:-o_d]+o_o))
|
||||
|
||||
return influx_profile,outflux_profile
|
||||
|
||||
def make_flux_df(influx_profile,outflux_profile, time = 0):
|
||||
if time == 0:
|
||||
time = np.arange(0,len(influx_profile))
|
||||
flux_df = pd.DataFrame(np.transpose([time, influx_profile, outflux_profile]), \
|
||||
columns=['time', 'influx', 'outflux'])
|
||||
return flux_df
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
influx_profile,outflux_profile = return_flux_profiles(100,influx_identifier='st_0010_0010',influx_offset=10)
|
||||
print(influx_profile)
|
||||
92
Messing Around/pressure_propagation.ipynb
Normal file
92
Messing Around/pressure_propagation.ipynb
Normal file
@@ -0,0 +1,92 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 12,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import numpy as np \n",
|
||||
"from pressure_propagation import pressure_update"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 13,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# Ausbreitungsgeschwindigkeit\n",
|
||||
"u = 1 # m/s\n",
|
||||
"# Rohrlänge\n",
|
||||
"l = 100 # m\n",
|
||||
"# maximal simulierte Zeitspanne\n",
|
||||
"t_max = 60 # s\n",
|
||||
"\n",
|
||||
"# Zeitschritt\n",
|
||||
"delta_t = 0.1 # s\n",
|
||||
"# Diskretisierungslänge = Ausbreitungsgeschwindigkeit*Zeitschritt\n",
|
||||
"delta_x = u*delta_t\n",
|
||||
"\n",
|
||||
"# Anzahl der örtlichen Diskretisierungsintervalle\n",
|
||||
"n_x = int(np.floor(l/delta_x))\n",
|
||||
"# Anzahl der zeitlichen Diskretisierungsintervalle\n",
|
||||
"n_t = int(np.floor(t_max/delta_t))\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"#initiale Druckverteilung (excl hydrostatischer Drucks)\n",
|
||||
"p_0 = np.ones([n_x,1])\n",
|
||||
"# np.array das den Verlauf der Druckverteilungen speichert\n",
|
||||
"pressure_profiles = np.tile(p_0,[1,n_t])\n",
|
||||
"\n",
|
||||
"pressure_profiles[-1,0] = 2 # for testing\n",
|
||||
"# loop\n",
|
||||
"for i in range(1,n_t): # start at 1 because i reference i-1 in the loop over the control-volumina\n",
|
||||
" #get boundary pressure from outflux-change and hydrostatic pressure in the pool\n",
|
||||
" pressure_profiles[-1,i] = 2 # for testing\n",
|
||||
" \n",
|
||||
" for j in range(n_x-2,1,-1): # leave out the first and last control-volume because their pressure\n",
|
||||
" # is set by the boundary conditions\n",
|
||||
" p = pressure_profiles[j,i-1]\n",
|
||||
" p1 = pressure_profiles[j+1,i-1]\n",
|
||||
" p2 = pressure_profiles[j-1,i-1]\n",
|
||||
" pressure_profiles[j,i] = pressure_update(p,p1,p2)\n",
|
||||
" \n",
|
||||
"\n",
|
||||
"\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"interpreter": {
|
||||
"hash": "84fb123bdc47ab647d3782661abcbe80fbb79236dd2f8adf4cef30e8755eb2cd"
|
||||
},
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3.8.13 ('Georg_DT_Slot3')",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
"codemirror_mode": {
|
||||
"name": "ipython",
|
||||
"version": 3
|
||||
},
|
||||
"file_extension": ".py",
|
||||
"mimetype": "text/x-python",
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.8.13"
|
||||
},
|
||||
"orig_nbformat": 4
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 2
|
||||
}
|
||||
2
Messing Around/pressure_propagation.py
Normal file
2
Messing Around/pressure_propagation.py
Normal file
@@ -0,0 +1,2 @@
|
||||
def pressure_update(p,p1=-1,p2=-1):
|
||||
return 1/4*(2*p+p1+p2)
|
||||
1
Messing Around/visualize_parameters.py
Normal file
1
Messing Around/visualize_parameters.py
Normal file
@@ -0,0 +1 @@
|
||||
import plotly
|
||||
6977
Messing Around/visualize_parameters_nb.ipynb
Normal file
6977
Messing Around/visualize_parameters_nb.ipynb
Normal file
File diff suppressed because it is too large
Load Diff
140
Messing Around/volume_change.py
Normal file
140
Messing Around/volume_change.py
Normal file
@@ -0,0 +1,140 @@
|
||||
|
||||
# Testvolume
|
||||
# Depth of the whole structure is constant and given by the variable d
|
||||
#
|
||||
#
|
||||
# { x_1*d*h for h <= h_1
|
||||
# V(h) = { x_1*d*(h-h_1)+(x_2-x_1)*d*(h-h_1)**2/(2*(h_2-h_1) + V(h_1)) for h_1 < h <= h_2
|
||||
# { x_2*d*(h-h_2)+(x_3-x_2)*d*(h-h_2)**2/(2*(h_3-h_2) + V(h_2)) for h_2 < h <= h_3
|
||||
# { x_3*d*(h-h_3) + V(h_3) for h_3 < h
|
||||
#
|
||||
#
|
||||
# { V/(x_1*d) for V <= V_1
|
||||
#h(V) = { (-b_2+sqrt(b_2**2-4*a_2*c_2)/(2*a_2)) for V_1 < V <= V_2
|
||||
# { (-b_3+sqrt(b_3**2-4*a_3*c_3)/(2*a_3)) for V_2 < V <= V_3
|
||||
# { (V-V_3)/(x_1*d) for V_3 < V
|
||||
#
|
||||
# with
|
||||
# a_2 = 0.5*((x_2-x_1)*d)/(h_2-h_1)
|
||||
# a_3 = 0.5*((x_3-x_2)*d)/(h_3-h_2)
|
||||
#
|
||||
# b_2 = x_1*d-((x_2-x_1)*d*h_1)/(h_2-h_1)
|
||||
# b_3 = x_2*d-((x_3-x_2)*d*h_2)/(h_3-h_2)
|
||||
#
|
||||
# c_2 = ((x_2-x_1)*d*h_1**2)/(h_2-h_1)-h_1*x_1*d-(V-V_1)
|
||||
# c_3 = ((x_3-x_2)*d*h_2**2)/(h_3-h_2)-h_2*x_2*d-(V-V_2)
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
# _____
|
||||
# | | |
|
||||
# | | |
|
||||
# | | | h_4 - h_3
|
||||
# | | _|_
|
||||
# __| _ _ |__ |
|
||||
# / x_3 \ |
|
||||
# / \ |
|
||||
# / \ |
|
||||
# / \ | h_3 - h_2
|
||||
# / \ |
|
||||
# / \ |
|
||||
# / \ |
|
||||
# / \ |
|
||||
# / \ _|_
|
||||
# <-----------------------------> |
|
||||
# \ x_2 / | h_2 - h_1
|
||||
# \ / |
|
||||
# \ _ _ _ _ _ _ _ _ _ _ _ / _|_
|
||||
# | x_1 | |
|
||||
# | | | h_1
|
||||
# | | |
|
||||
# |_____________________| _|_
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def test_1_parameters():
|
||||
h_1 = 10
|
||||
h_2 = 5 + h_1
|
||||
h_3 = 5 + h_2
|
||||
|
||||
x_1 = 100
|
||||
x_2 = 101
|
||||
x_3 = 30
|
||||
|
||||
d = 5
|
||||
|
||||
vol_1 = x_1*d*h_1
|
||||
vol_2 = x_1*d*(h_2-h_1)+(x_2-x_1)*d*(h_2-h_1)**2/(2*(h_2-h_1)) + vol_1
|
||||
vol_3 = x_2*d*(h_3-h_2)+(x_3-x_2)*d*(h_3-h_2)**2/(2*(h_3-h_2)) + vol_2
|
||||
|
||||
a_2 = 0.5*((x_2-x_1)*d)/(h_2-h_1)
|
||||
a_3 = 0.5*((x_3-x_2)*d)/(h_3-h_2)
|
||||
|
||||
b_2 = x_1*d-((x_2-x_1)*d*h_1)/(h_2-h_1)
|
||||
b_3 = x_2*d-((x_3-x_2)*d*h_2)/(h_3-h_2)
|
||||
|
||||
c_2 = ((x_2-x_1)*d*h_1**2)/(2*(h_2-h_1))-h_1*x_1*d
|
||||
c_3 = ((x_3-x_2)*d*h_2**2)/(2*(h_3-h_2))-h_2*x_2*d
|
||||
|
||||
return h_1,h_2,h_3,x_1,x_2,x_3,d,vol_1,vol_2,vol_3,a_2,a_3,b_2,b_3,c_2,c_3
|
||||
|
||||
def V_h_test_1(h):
|
||||
h_1,h_2,h_3,x_1,x_2,x_3,d,vol_1,vol_2,vol_3,a_2,a_3,b_2,b_3,c_2,c_3 = test_1_parameters()
|
||||
if h <= h_1:
|
||||
V = x_1*d*h
|
||||
elif (h_1 < h) and (h <= h_2):
|
||||
V = x_1*d*(h-h_1)+(x_2-x_1)*d*(h-h_1)**2/(2*(h_2-h_1)) + vol_1
|
||||
elif (h_2 < h) and (h <= h_3):
|
||||
V = x_2*d*(h-h_2)+(x_3-x_2)*d*(h-h_2)**2/(2*(h_3-h_2)) + vol_2
|
||||
elif (h_3 < h):
|
||||
V = x_3*d*(h-h_3) + vol_3
|
||||
|
||||
return V
|
||||
|
||||
def h_V_test_1(V):
|
||||
h_1,h_2,h_3,x_1,x_2,x_3,d,vol_1,vol_2,vol_3,a_2,a_3,b_2,b_3,c_2,c_3 =test_1_parameters()
|
||||
if V <= vol_1:
|
||||
h = V/(x_1*d)
|
||||
elif (vol_1 < V) and (V <= vol_2):
|
||||
h = (-b_2+(b_2**2-4*a_2*(c_2-(V-vol_1)))**0.5)/(2*a_2)
|
||||
elif (vol_2 < V) and (V <= vol_3):
|
||||
h = (-b_3+(b_3**2-4*a_3*(c_3-(V-vol_2)))**0.5)/(2*a_3)
|
||||
elif (vol_3 < V):
|
||||
h = (V-vol_3)/(x_3*d)+h_3
|
||||
return h
|
||||
|
||||
|
||||
def test_2_parameters():
|
||||
x = 10.
|
||||
d = 10.
|
||||
return x,d
|
||||
|
||||
def V_h_test_2(h):
|
||||
x,d = test_2_parameters()
|
||||
return x*d*h
|
||||
|
||||
def h_V_test_2(V):
|
||||
x,d = test_2_parameters()
|
||||
return V/(x*d)
|
||||
|
||||
def show_parameters(test_version):
|
||||
h_1,h_2,h_3,x_1,x_2,x_3,d,vol_1,vol_2,vol_3,a_2,a_3,b_2,b_3,c_2,c_3 = test_1_parameters()
|
||||
x,d = test_2_parameters()
|
||||
|
||||
if test_version == 1:
|
||||
print('h_1: ', h_1)
|
||||
print('h_2: ', h_2)
|
||||
print('h_3: ', h_3)
|
||||
print('x_1: ', x_1)
|
||||
print('x_2: ', x_2)
|
||||
print('x_3: ', x_3)
|
||||
elif test_version == 2:
|
||||
print('x: ', x)
|
||||
print('d: ', d)
|
||||
|
||||
|
||||
|
||||
237
Messing Around/volume_change_nb.ipynb
Normal file
237
Messing Around/volume_change_nb.ipynb
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user