mirror of
https://gitlab.com/pamhyr/pamhyr2.git
synced 2026-10-30 03:20:41 +01:00
Compare commits
7
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1db1a543c7 | ||
|
|
3e92a0c40d | ||
|
|
f3c461cbd9 | ||
|
|
012408d19e | ||
|
|
f7e563e71a | ||
|
|
81c6d39c1a | ||
|
|
d682443e1d |
No files matched your search
+2
-13
@@ -139,17 +139,9 @@ class InternalMeshing(AMeshingTool):
|
||||
# len1 and 2: number of intervals
|
||||
# len1: target len
|
||||
|
||||
if tag1 == '': # left end point
|
||||
start1 = 0
|
||||
start2 = 0
|
||||
else:
|
||||
start1 = sect1.named_point_index(tag1)
|
||||
start2 = sect2.named_point_index(tag1)
|
||||
|
||||
if tag2 == '': # right end point
|
||||
end1 = sect1.nb_points-1
|
||||
end2 = sect2.nb_points-1
|
||||
else:
|
||||
end1 = sect1.named_point_index(tag2)
|
||||
end2 = sect2.named_point_index(tag2)
|
||||
|
||||
@@ -183,11 +175,6 @@ class InternalMeshing(AMeshingTool):
|
||||
p = sect2.point(start2).copy()
|
||||
sect2.insert_point(start2, p)
|
||||
len2 += 1
|
||||
if tag1 == '': # left end point
|
||||
sect2.point(start2).name = ''
|
||||
if tag2 == '': # left end point
|
||||
sect2.point(start2+1).name = ''
|
||||
len2 += 1
|
||||
elif ltot1 < 0.0001:
|
||||
sect2.add_npoints(len1-len2)
|
||||
len2 = len1
|
||||
@@ -254,7 +241,9 @@ class InternalMeshing(AMeshingTool):
|
||||
p = sect2.point(start2+len2).copy()
|
||||
sect2.insert_point(start2+len2, p)
|
||||
sect2.point(start2+len2).name = ''
|
||||
if tag1 != "un":
|
||||
sect2.point(start2).name = tag1
|
||||
if tag1 != "np":
|
||||
sect2.point(start2+len2).name = tag2
|
||||
sect2.modified()
|
||||
|
||||
|
||||
@@ -537,7 +537,10 @@ class InitialConditions(SQLSubModel):
|
||||
strickler = 25.0
|
||||
|
||||
if not compute_discharge:
|
||||
if profile.rk in data_discharge:
|
||||
discharge = data_discharge[profile.rk]
|
||||
else:
|
||||
discharge = 0.0
|
||||
else:
|
||||
discharge = (
|
||||
# ((width * 0.8)
|
||||
@@ -605,7 +608,10 @@ class InitialConditions(SQLSubModel):
|
||||
strickler = 25.0
|
||||
|
||||
if not compute_height:
|
||||
if profile.rk in data_height:
|
||||
height = data_height[profile.rk]
|
||||
else:
|
||||
height = 0.0
|
||||
else:
|
||||
if abs(incline) <= 0:
|
||||
height = 0.0
|
||||
@@ -656,7 +662,10 @@ class InitialConditions(SQLSubModel):
|
||||
for profile in profiles:
|
||||
|
||||
if not compute_discharge:
|
||||
if profile.rk in data_discharge:
|
||||
d = data_discharge[profile.rk]
|
||||
else:
|
||||
d = 0.0
|
||||
else:
|
||||
d = discharge
|
||||
elevation = interp(profile.rk,
|
||||
|
||||
@@ -307,6 +307,21 @@ class Pollutants(SQLSubModel):
|
||||
def data(self):
|
||||
return self._data
|
||||
|
||||
@data.setter
|
||||
def data(self, data):
|
||||
self._data = [PollutantCharacteristics(type=int(data[0]),
|
||||
diametre=float(data[1]),
|
||||
rho=float(data[2]),
|
||||
porosity=float(data[3]),
|
||||
cdc_riv=float(data[4]),
|
||||
cdc_cas=float(data[5]),
|
||||
apd=float(data[6]),
|
||||
ac=float(data[7]),
|
||||
bc=float(data[8]),
|
||||
pollutant=self,
|
||||
status=self._status
|
||||
)]
|
||||
|
||||
@classmethod
|
||||
def _db_create(cls, execute, ext=""):
|
||||
execute(f"""
|
||||
@@ -397,7 +412,7 @@ class Pollutants(SQLSubModel):
|
||||
|
||||
data["pollutant"] = new_pollutant
|
||||
new_pollutant._data = PollutantCharacteristics._db_load(
|
||||
execute, data.copy()
|
||||
execute, data=data
|
||||
)
|
||||
|
||||
loaded.add(pid)
|
||||
@@ -421,7 +436,7 @@ class Pollutants(SQLSubModel):
|
||||
f"AND scenario = {self._status.scenario_id}"
|
||||
)
|
||||
execute(
|
||||
f"DELETE FROM pollutants_characteristics " +
|
||||
"DELETE FROM pollutants_characteristics " +
|
||||
f"WHERE pollutant = {self.id} " +
|
||||
f"AND scenario = {self._status.scenario_id}"
|
||||
)
|
||||
|
||||
@@ -31,7 +31,7 @@ class Scenario(SQLSubModel):
|
||||
id: int = -1,
|
||||
name: str = "",
|
||||
description: str = "",
|
||||
x: int = 0.0, y: int = 0.0,
|
||||
x: int = 1000.0, y: int = 1000.0,
|
||||
revision: int = 0,
|
||||
parent=None):
|
||||
super(Scenario, self).__init__()
|
||||
|
||||
@@ -260,7 +260,7 @@ class AdisTS(CommandLineSolver):
|
||||
_nodes_views = set()
|
||||
|
||||
def get_reach_name(self, reach):
|
||||
return f"Reach_{reach.id:>3}".replace(" ", "0")
|
||||
return f"Reach_{reach.pamhyr_id:>3}".replace(" ", "0")
|
||||
|
||||
def get_node_name(self, node):
|
||||
"""Generate a 3 char name for node
|
||||
@@ -271,7 +271,7 @@ class AdisTS(CommandLineSolver):
|
||||
Returns:
|
||||
A 3 char name string
|
||||
"""
|
||||
n = node.id
|
||||
n = node.pamhyr_id
|
||||
|
||||
# print("node name id: ", n)
|
||||
|
||||
@@ -401,9 +401,9 @@ class AdisTSwc(AdisTS):
|
||||
) as f:
|
||||
for LC in POL_LC:
|
||||
reach = next(filter(
|
||||
lambda edge: edge.id == LC.edge, study.river.edges()
|
||||
lambda edge: edge.id == LC.edge, study.river.enable_edges()
|
||||
)) # .name
|
||||
reach_name = self.get_reach_name(self, reach)
|
||||
reach_name = self.get_reach_name(reach)
|
||||
f.write(f"${reach_name} {LC.begin_rk} {LC.end_rk}\n")
|
||||
f.write(f"*temps |débit massique (kg/s)\n")
|
||||
f.write(f"*---------++++++++++\n")
|
||||
|
||||
@@ -169,9 +169,8 @@ class Rubar3(CommandLineSolver):
|
||||
|
||||
it = iter(params)
|
||||
|
||||
line = 0
|
||||
while line < 27:
|
||||
param = next(it)
|
||||
param = next(it, None)
|
||||
while param != None:
|
||||
name = param.name
|
||||
value = param.value
|
||||
|
||||
@@ -204,7 +203,7 @@ class Rubar3(CommandLineSolver):
|
||||
# New line
|
||||
f.write(f"\n")
|
||||
|
||||
line += 1
|
||||
param = next(it, None)
|
||||
|
||||
def _export_ts(self, study, repertory, qlog, name="0"):
|
||||
if qlog is not None:
|
||||
|
||||
@@ -1206,6 +1206,31 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
|
||||
Returns:
|
||||
Nothing
|
||||
"""
|
||||
if self._study is None:
|
||||
return
|
||||
if self._study.filename is None or self._study.filename == "":
|
||||
self.message_box(
|
||||
window_title=self._trad["Warning"],
|
||||
text=self._trad["mb_unsaved_study_title"],
|
||||
informative_text=self._trad["mb_unsaved_studyh_msg"]
|
||||
)
|
||||
|
||||
options = QFileDialog.Options()
|
||||
options |= QFileDialog.DontUseNativeDialog
|
||||
|
||||
file_name, _ = QFileDialog.getSaveFileName(
|
||||
self, "Save File",
|
||||
"", "Pamhyr(*.pamhyr)",
|
||||
options=options,
|
||||
)
|
||||
if file_name is None or file_name == "":
|
||||
return
|
||||
|
||||
if file_name.rsplit(".", 1)[-1] == "pamhyr":
|
||||
self._study.filename = file_name
|
||||
else:
|
||||
self._study.filename = file_name + ".pamhyr"
|
||||
|
||||
if self._study is not None:
|
||||
if self.sub_window_exists(
|
||||
ScenariosWindow,
|
||||
|
||||
@@ -80,7 +80,7 @@ class AddCommand(QUndoCommand):
|
||||
self._new = self._pollutants_lst.new(
|
||||
self._pollutants_lst, self._index
|
||||
)
|
||||
self._new._data = [[0, 0., 0., 0., 0., 0., 0., 0., 0.]]
|
||||
self._new.data = [0, 0., 0., 0., 0., 0., 0., 0., 0.]
|
||||
self._new_ic_adists = self._data.new(self._index, self._new.id)
|
||||
else:
|
||||
self._pollutants_lst.insert(self._index, self._new)
|
||||
|
||||
@@ -149,8 +149,17 @@ class PlotAC(PamhyrPlot):
|
||||
self.annotation = []
|
||||
self.cgl, self.igl = reach.geometry.compute_guidelines()
|
||||
|
||||
lcomplete = list(self.cgl)
|
||||
lincomplete = list(self.igl)
|
||||
# we make sure that the lines are in the left-to-right order
|
||||
lcomplete = [
|
||||
x.name
|
||||
for x in profile.geometry.named_points()
|
||||
if x.name in self.cgl
|
||||
]
|
||||
lincomplete = [
|
||||
x.name
|
||||
for x in profile.geometry.named_points()
|
||||
if x.name in self.igl
|
||||
]
|
||||
|
||||
self.color_complete_gl = self.colors
|
||||
self.color_incomplete_gl = 2 * ["grey"]
|
||||
@@ -170,7 +179,7 @@ class PlotAC(PamhyrPlot):
|
||||
]
|
||||
else:
|
||||
color = self.color_incomplete_gl[
|
||||
lincomplete.index(txt)
|
||||
lincomplete.index(txt) % len(self.color_incomplete_gl)
|
||||
]
|
||||
|
||||
annotation = self.canvas.axes.annotate(
|
||||
|
||||
@@ -266,6 +266,16 @@ class MainTranslate(UnitTranslate):
|
||||
"incompatible study version"
|
||||
)
|
||||
|
||||
|
||||
self._dict["mb_unsaved_study_title"] = _translate(
|
||||
"MainWindow", "Open scenarios window"
|
||||
)
|
||||
self._dict["mb_unsaved_studyh_msg"] = _translate(
|
||||
"MainWindow",
|
||||
"You must save your study to open "
|
||||
"the scenario windows"
|
||||
)
|
||||
|
||||
self._dict["x"] = _translate("MainWindow", "X (m)")
|
||||
self._dict["y"] = _translate("MainWindow", "Y (m)")
|
||||
self._dict["Yes"] = _translate("MainWindow", "Yes")
|
||||
|
||||
+31
-1
@@ -37,7 +37,7 @@ logger = logging.getLogger()
|
||||
|
||||
class Config(SQL):
|
||||
def __init__(self):
|
||||
self._version = '0.0.6'
|
||||
self._version = '0.0.7'
|
||||
self.filename = Config.filename()
|
||||
self.set_default_value()
|
||||
|
||||
@@ -165,6 +165,29 @@ class Config(SQL):
|
||||
"WHERE name='default-AdisTS'"
|
||||
)
|
||||
|
||||
if int(release) < 7:
|
||||
posix = os.name == 'posix'
|
||||
ext = "" if posix else ".exe"
|
||||
|
||||
self.execute(f"""
|
||||
INSERT INTO solver VALUES (
|
||||
'rubar3',
|
||||
'default-Rubar3',
|
||||
'Default Pamhyr2 Rubar 3 version',
|
||||
|
||||
'', '', '',
|
||||
|
||||
'',
|
||||
'@install_dir/rubar/rubar3{ext} @args @input',
|
||||
''
|
||||
)
|
||||
""")
|
||||
self.execute(
|
||||
"UPDATE solver SET cmd_solver=" +
|
||||
f"'@install_dir/rubar/rubar3{ext} @args @input' "
|
||||
"WHERE name='default-Rubar3'"
|
||||
)
|
||||
|
||||
self.execute(
|
||||
f"UPDATE info SET value='{self._version}' " +
|
||||
"WHERE key='version'"
|
||||
@@ -337,6 +360,13 @@ class Config(SQL):
|
||||
new._cmd_solver = f""""@install_dir/adists/adists{ext}" @args @input"""
|
||||
self._solvers.append(new)
|
||||
|
||||
# Rubar3
|
||||
ctor = solver_type_list["rubar3"]
|
||||
new = ctor("default-Rubar3")
|
||||
new._description = "Default Pamhyr2 Rubar 3 version"
|
||||
new._cmd_solver = f""""@install_dir/rubar/rubar3{ext}" @args @input"""
|
||||
self._solvers.append(new)
|
||||
|
||||
# Mage fake 7
|
||||
# ctor = solver_type_list["mage_fake7"]
|
||||
# new = ctor("default-mage-fake-7")
|
||||
|
||||
+511
-218
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user