add froude in results

This commit is contained in:
Theophile Terraz committed 2024-08-09 10:03:55 +02:00
1 parent 16916f44b9
commit 0ee47e95da
5 files changed
+59 -2

No files matched your search

+44 -1
View File
@@ -20,6 +20,7 @@ import logging
from functools import reduce from functools import reduce
from datetime import datetime from datetime import datetime
from numpy import sqrt
from tools import timer from tools import timer
from View.Tools.PamhyrPlot import PamhyrPlot from View.Tools.PamhyrPlot import PamhyrPlot
@@ -35,6 +36,7 @@ unit = {
"velocity": "2-ms", "velocity": "2-ms",
"depth": "3-meter", "depth": "3-meter",
"mean_depth": "3-meter", "mean_depth": "3-meter",
"froude": "4-dimensionless",
} }
@@ -185,7 +187,31 @@ class CustomPlot(PamhyrPlot):
rk, d, rk, d,
color='orange', lw=1., color='orange', lw=1.,
) )
lines["depth"] = line lines["mean_depth"] = line
if "froude" in self._y:
ax = self._axes[unit["froude"]]
fr = list(
map(
lambda p:
p.geometry.speed(
p.get_ts_key(self._timestamp, "Q"),
p.get_ts_key(self._timestamp, "Z")) /
sqrt(9.81 * (
p.geometry.wet_width(
p.get_ts_key(self._timestamp, "Z")) /
p.geometry.wet_area(
p.get_ts_key(self._timestamp, "Z"))
)),
reach.profiles
)
)
line = ax.plot(
rk, fr, color='black', linestyle='--', lw=1.,
)
lines["froude"] = line
# Legend # Legend
lns = reduce( lns = reduce(
@@ -343,6 +369,23 @@ class CustomPlot(PamhyrPlot):
) )
lines["depth"] = line lines["depth"] = line
if "froude" in self._y:
ax = self._axes[unit["froude"]]
d = list(
map(lambda z, q:
profile.geometry.speed(q, z) /
sqrt(9.81 * (
profile.geometry.wet_width(z) /
profile.geometry.wet_area(z))
), z, q)
)
line = ax.plot(
ts, d, color='black', linestyle='--', lw=1.,
)
lines["froude"] = line
self._customize_x_axes_time(ts) self._customize_x_axes_time(ts)
# Legend # Legend
+3
View File
@@ -47,6 +47,7 @@ class CustomPlotTranslate(ResultsTranslate):
self._dict['wet_area'] = self._dict["unit_wet_area"] self._dict['wet_area'] = self._dict["unit_wet_area"]
self._dict['wet_perimeter'] = self._dict["unit_wet_perimeter"] self._dict['wet_perimeter'] = self._dict["unit_wet_perimeter"]
self._dict['hydraulic_radius'] = self._dict["unit_hydraulic_radius"] self._dict['hydraulic_radius'] = self._dict["unit_hydraulic_radius"]
self._dict['froude'] = self._dict["unit_froude"]
# Unit corresponding long name (plot axes display) # Unit corresponding long name (plot axes display)
@@ -56,6 +57,7 @@ class CustomPlotTranslate(ResultsTranslate):
self._dict['1-m3s'] = self._dict["unit_discharge"] self._dict['1-m3s'] = self._dict["unit_discharge"]
self._dict['2-ms'] = self._dict["unit_speed"] self._dict['2-ms'] = self._dict["unit_speed"]
self._dict['3-meter'] = self._dict["unit_height"] self._dict['3-meter'] = self._dict["unit_height"]
self._dict['4-dimensionless'] = self._dict["unit_froude"]
# SubDict # SubDict
@@ -70,4 +72,5 @@ class CustomPlotTranslate(ResultsTranslate):
"velocity": self._dict["velocity"], "velocity": self._dict["velocity"],
"depth": self._dict["max_depth"], "depth": self._dict["max_depth"],
"mean_depth": self._dict["mean_depth"], "mean_depth": self._dict["mean_depth"],
"froude": self._dict["froude"],
} }
+10 -1
View File
@@ -19,6 +19,8 @@
import logging import logging
import traceback import traceback
from numpy import sqrt
from tools import timer, trace from tools import timer, trace
from PyQt5.QtGui import ( from PyQt5.QtGui import (
@@ -89,7 +91,6 @@ class TableModel(PamhyrTableModel):
elif self._headers[column] == "velocity": elif self._headers[column] == "velocity":
q = self._lst[row].get_ts_key(self._timestamp, "Q") q = self._lst[row].get_ts_key(self._timestamp, "Q")
z = self._lst[row].get_ts_key(self._timestamp, "Z") z = self._lst[row].get_ts_key(self._timestamp, "Z")
v = self._lst[row].geometry.speed(q, z) v = self._lst[row].geometry.speed(q, z)
return f"{v:.4f}" return f"{v:.4f}"
elif self._headers[column] == "width": elif self._headers[column] == "width":
@@ -116,6 +117,14 @@ class TableModel(PamhyrTableModel):
z = self._lst[row].get_ts_key(self._timestamp, "Z") z = self._lst[row].get_ts_key(self._timestamp, "Z")
v = self._lst[row].geometry.wet_radius(z) v = self._lst[row].geometry.wet_radius(z)
return f"{v:.4f}" return f"{v:.4f}"
elif self._headers[column] == "froude":
q = self._lst[row].get_ts_key(self._timestamp, "Q")
z = self._lst[row].get_ts_key(self._timestamp, "Z")
v = self._lst[row].geometry.speed(q, z)
b = self._lst[row].geometry.wet_area(z)
a = self._lst[row].geometry.wet_width(z)
froude = v / sqrt(9.81 * (a / b))
return f"{froude:.4f}"
else: else:
v = 0.0 v = 0.0
return f"{v:.4f}" return f"{v:.4f}"
+1
View File
@@ -64,4 +64,5 @@ class ResultsTranslate(MainTranslate):
"wet_area": self._dict["unit_wet_area"], "wet_area": self._dict["unit_wet_area"],
"wet_perimeter": self._dict["unit_wet_perimeter"], "wet_perimeter": self._dict["unit_wet_perimeter"],
"hydraulic_radius": self._dict["unit_hydraulic_radius"], "hydraulic_radius": self._dict["unit_hydraulic_radius"],
"froude": self._dict["unit_froude"],
} }
+1
View File
@@ -80,6 +80,7 @@ class UnitTranslate(CommonWordTranslate):
self._dict["unit_hydraulic_radius"] = _translate( self._dict["unit_hydraulic_radius"] = _translate(
"Unit", "Hydraulic Radius (m)" "Unit", "Hydraulic Radius (m)"
) )
self._dict["unit_froude"] = _translate("Unit", "Froude number")
class MainTranslate(UnitTranslate): class MainTranslate(UnitTranslate):