diff --git a/src/View/Results/CustomPlot/Plot.py b/src/View/Results/CustomPlot/Plot.py index f9ebdfcfd850739aa8bdf15ae5aacf40397c863a..cb45863cae05640fe98ce2a83644f3983aeb3506 100644 --- a/src/View/Results/CustomPlot/Plot.py +++ b/src/View/Results/CustomPlot/Plot.py @@ -20,6 +20,7 @@ import logging from functools import reduce from datetime import datetime +from numpy import sqrt from tools import timer from View.Tools.PamhyrPlot import PamhyrPlot @@ -35,6 +36,7 @@ unit = { "velocity": "2-ms", "depth": "3-meter", "mean_depth": "3-meter", + "froude": "4-dimensionless", } @@ -185,7 +187,31 @@ class CustomPlot(PamhyrPlot): rk, d, 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 lns = reduce( @@ -343,6 +369,23 @@ class CustomPlot(PamhyrPlot): ) 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) # Legend diff --git a/src/View/Results/CustomPlot/Translate.py b/src/View/Results/CustomPlot/Translate.py index df4ad75be875341dfaabee117c784509b2ebae8e..6d96bf276553f99e1399e6abea3b7a4bc730d002 100644 --- a/src/View/Results/CustomPlot/Translate.py +++ b/src/View/Results/CustomPlot/Translate.py @@ -47,6 +47,7 @@ class CustomPlotTranslate(ResultsTranslate): self._dict['wet_area'] = self._dict["unit_wet_area"] self._dict['wet_perimeter'] = self._dict["unit_wet_perimeter"] self._dict['hydraulic_radius'] = self._dict["unit_hydraulic_radius"] + self._dict['froude'] = self._dict["unit_froude"] # Unit corresponding long name (plot axes display) @@ -56,6 +57,7 @@ class CustomPlotTranslate(ResultsTranslate): self._dict['1-m3s'] = self._dict["unit_discharge"] self._dict['2-ms'] = self._dict["unit_speed"] self._dict['3-meter'] = self._dict["unit_height"] + self._dict['4-dimensionless'] = self._dict["unit_froude"] # SubDict @@ -70,4 +72,5 @@ class CustomPlotTranslate(ResultsTranslate): "velocity": self._dict["velocity"], "depth": self._dict["max_depth"], "mean_depth": self._dict["mean_depth"], + "froude": self._dict["froude"], } diff --git a/src/View/Results/Table.py b/src/View/Results/Table.py index 1088ac26877757794911cb39acc2a206f83c97a6..fead357e1af820e1f498befe08cb1d3a4731f8b5 100644 --- a/src/View/Results/Table.py +++ b/src/View/Results/Table.py @@ -19,6 +19,8 @@ import logging import traceback +from numpy import sqrt + from tools import timer, trace from PyQt5.QtGui import ( @@ -89,7 +91,6 @@ class TableModel(PamhyrTableModel): elif self._headers[column] == "velocity": 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) return f"{v:.4f}" elif self._headers[column] == "width": @@ -116,6 +117,14 @@ class TableModel(PamhyrTableModel): z = self._lst[row].get_ts_key(self._timestamp, "Z") v = self._lst[row].geometry.wet_radius(z) 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: v = 0.0 return f"{v:.4f}" diff --git a/src/View/Results/translate.py b/src/View/Results/translate.py index bf96ba13600a189f5d31b59b59384e8a20a505d7..faab6ecb0e550f6e27fe7abc5f7aaf803eadc3d7 100644 --- a/src/View/Results/translate.py +++ b/src/View/Results/translate.py @@ -64,4 +64,5 @@ class ResultsTranslate(MainTranslate): "wet_area": self._dict["unit_wet_area"], "wet_perimeter": self._dict["unit_wet_perimeter"], "hydraulic_radius": self._dict["unit_hydraulic_radius"], + "froude": self._dict["unit_froude"], } diff --git a/src/View/Translate.py b/src/View/Translate.py index 1a47f238514a8355f71cb75af1ccab15bf0b97eb..30a8a564baa50b89142282b5d77592e7d29effb6 100644 --- a/src/View/Translate.py +++ b/src/View/Translate.py @@ -80,6 +80,7 @@ class UnitTranslate(CommonWordTranslate): self._dict["unit_hydraulic_radius"] = _translate( "Unit", "Hydraulic Radius (m)" ) + self._dict["unit_froude"] = _translate("Unit", "Froude number") class MainTranslate(UnitTranslate):