mirror of https://gitlab.com/pamhyr/pamhyr2
Compare commits
3 Commits
bdaa38ea5c
...
18a3d51d75
| Author | SHA1 | Date |
|---|---|---|
|
|
18a3d51d75 | |
|
|
118a39bd5c | |
|
|
2009e8223b |
|
|
@ -31,6 +31,7 @@ stages:
|
||||||
variables:
|
variables:
|
||||||
MAGE_8_VERSION: "permalink/latest"
|
MAGE_8_VERSION: "permalink/latest"
|
||||||
ADISTS_VERSION: "permalink/latest"
|
ADISTS_VERSION: "permalink/latest"
|
||||||
|
RUBAR_VERSION: "permalink/latest"
|
||||||
|
|
||||||
dl-mage8-doc:
|
dl-mage8-doc:
|
||||||
stage: downloads
|
stage: downloads
|
||||||
|
|
@ -104,6 +105,37 @@ dl-adists-windows:
|
||||||
paths:
|
paths:
|
||||||
- adists-windows/adists.exe
|
- adists-windows/adists.exe
|
||||||
|
|
||||||
|
dl-rubar-linux:
|
||||||
|
stage: downloads
|
||||||
|
tags:
|
||||||
|
- linux
|
||||||
|
rules:
|
||||||
|
- if: $CI_COMMIT_BRANCH == 'ci-test' || $CI_COMMIT_BRANCH == 'master' || $CI_COMMIT_TAG
|
||||||
|
script:
|
||||||
|
- mkdir -p rubar-linux
|
||||||
|
- cd rubar-linux
|
||||||
|
- curl -L -o rubar.tgz https://forge.inrae.fr/river-hydraulics/rubarbe/-/releases/$RUBAR_VERSION/downloads/packages/rubar_linux.tgz
|
||||||
|
- tar xf rubar.tgz
|
||||||
|
artifacts:
|
||||||
|
paths:
|
||||||
|
- rubar-linux/rubarbe
|
||||||
|
|
||||||
|
dl-rubar-windows:
|
||||||
|
stage: downloads
|
||||||
|
tags:
|
||||||
|
- linux
|
||||||
|
rules:
|
||||||
|
- if: $CI_COMMIT_BRANCH == 'ci-test' || $CI_COMMIT_BRANCH == 'master' || $CI_COMMIT_TAG
|
||||||
|
script:
|
||||||
|
- mkdir -p rubar-windows
|
||||||
|
- cd rubar-windows
|
||||||
|
- curl -L -o rubar.tgz https://forge.inrae.fr/river-hydraulics/rubarbe/-/releases/$RUBAR_VERSION/downloads/packages/rubar_windows.tgz
|
||||||
|
- tar xf rubar.tgz
|
||||||
|
|
||||||
|
artifacts:
|
||||||
|
paths:
|
||||||
|
- rubar-windows/rubarbe.exe
|
||||||
|
|
||||||
#############
|
#############
|
||||||
# CONFIGURE #
|
# CONFIGURE #
|
||||||
#############
|
#############
|
||||||
|
|
@ -266,6 +298,8 @@ build-linux:
|
||||||
needs:
|
needs:
|
||||||
- job: dl-adists-linux
|
- job: dl-adists-linux
|
||||||
artifacts: true
|
artifacts: true
|
||||||
|
- job: dl-rubar-linux
|
||||||
|
artifacts: true
|
||||||
- job: dl-mage8-linux
|
- job: dl-mage8-linux
|
||||||
artifacts: true
|
artifacts: true
|
||||||
- job: dl-mage8-doc
|
- job: dl-mage8-doc
|
||||||
|
|
@ -307,6 +341,9 @@ build-linux:
|
||||||
# Copy adists
|
# Copy adists
|
||||||
- mkdir -p pamhyr/adists
|
- mkdir -p pamhyr/adists
|
||||||
- cp -v ../adists-linux/* pamhyr/adists/
|
- cp -v ../adists-linux/* pamhyr/adists/
|
||||||
|
# Copy rubar
|
||||||
|
- mkdir -p pamhyr/rubar
|
||||||
|
- cp -v ../rubar-linux/* pamhyr/rubar/
|
||||||
# Copy Pamhyr
|
# Copy Pamhyr
|
||||||
- cp -r dist/pamhyr/* pamhyr/
|
- cp -r dist/pamhyr/* pamhyr/
|
||||||
# Pamhyr script to force x11
|
# Pamhyr script to force x11
|
||||||
|
|
@ -372,6 +409,8 @@ build-windows:
|
||||||
artifacts: true
|
artifacts: true
|
||||||
- job: dl-adists-windows
|
- job: dl-adists-windows
|
||||||
artifacts: true
|
artifacts: true
|
||||||
|
- job: dl-rubar-windows
|
||||||
|
artifacts: true
|
||||||
- job: dl-mage8-doc
|
- job: dl-mage8-doc
|
||||||
artifacts: true
|
artifacts: true
|
||||||
- job: set-version
|
- job: set-version
|
||||||
|
|
|
||||||
Binary file not shown.
|
|
@ -46,6 +46,10 @@ copy /y ..\mage8-windows\mage_extraire.exe pamhyr\mage8\
|
||||||
copy /y ..\mage8-windows\mailleurTT.exe pamhyr\mage8\
|
copy /y ..\mage8-windows\mailleurTT.exe pamhyr\mage8\
|
||||||
copy /y ..\mage8-windows\libbief.dll pamhyr\mage8\
|
copy /y ..\mage8-windows\libbief.dll pamhyr\mage8\
|
||||||
|
|
||||||
|
rem rubar
|
||||||
|
mkdir pamhyr\rubar
|
||||||
|
copy /y ..\rubar-windows\rubarbe.exe pamhyr\rubar\
|
||||||
|
|
||||||
rem adists
|
rem adists
|
||||||
mkdir pamhyr\adists
|
mkdir pamhyr\adists
|
||||||
copy /y ..\adists-windows\adists.exe pamhyr\adists\
|
copy /y ..\adists-windows\adists.exe pamhyr\adists\
|
||||||
|
|
|
||||||
|
|
@ -108,6 +108,187 @@ class AdisTS(CommandLineSolver):
|
||||||
name = self._study.name
|
name = self._study.name
|
||||||
return f"{name}.TRA"
|
return f"{name}.TRA"
|
||||||
|
|
||||||
|
def _export_ST(self, study, repertory, qlog, name="0"):
|
||||||
|
files = []
|
||||||
|
|
||||||
|
if qlog is not None:
|
||||||
|
qlog.put("Export ST file")
|
||||||
|
|
||||||
|
os.makedirs(os.path.join(repertory, "net"), exist_ok=True)
|
||||||
|
|
||||||
|
# Write header
|
||||||
|
edges = study.river.enable_edges()
|
||||||
|
for edge in edges:
|
||||||
|
name = f"Reach_{edge.id + 1:>3}".replace(" ", "0")
|
||||||
|
|
||||||
|
with adists_file_open(
|
||||||
|
os.path.join(repertory, "net", f"{name}.ST"),
|
||||||
|
"w+"
|
||||||
|
) as f:
|
||||||
|
files.append(str(os.path.join("net", f"{name}.ST")))
|
||||||
|
|
||||||
|
cnt_num = 1
|
||||||
|
for profile in edge.reach.profiles:
|
||||||
|
self._export_ST_profile_header(
|
||||||
|
f, files, profile, cnt_num
|
||||||
|
)
|
||||||
|
cnt_num += 1
|
||||||
|
|
||||||
|
# Points
|
||||||
|
for point in profile.points:
|
||||||
|
self._export_ST_point_line(
|
||||||
|
f, files, point
|
||||||
|
)
|
||||||
|
|
||||||
|
# Profile last line
|
||||||
|
f.write(f" 999.9990 999.9990 999.9990\n")
|
||||||
|
|
||||||
|
def _export_ST_profile_header(self, wfile, files,
|
||||||
|
profile, cnt):
|
||||||
|
num = f"{cnt:>6}"
|
||||||
|
c1 = f"{profile.code1:>6}"
|
||||||
|
c2 = f"{profile.code2:>6}"
|
||||||
|
t = f"{len(profile.points):>6}"
|
||||||
|
rk = f"{profile.rk:>12f}"[0:12]
|
||||||
|
pname = profile.name
|
||||||
|
if profile.name == "":
|
||||||
|
# Generate name from profile id prefixed with
|
||||||
|
# 'p' (and replace space char with '0' char)
|
||||||
|
pname = f"p{profile.id:>3}".replace(" ", "0")
|
||||||
|
name = f"{pname:<19}"
|
||||||
|
|
||||||
|
# Generate sediment additional data if available
|
||||||
|
sediment = ""
|
||||||
|
if profile.sl is not None:
|
||||||
|
if not any(filter(lambda f: ".GRA" in f, files)):
|
||||||
|
files.append(self._gra_file)
|
||||||
|
|
||||||
|
# Number of layers
|
||||||
|
nl = len(profile.sl)
|
||||||
|
sediment = f" {nl:>3}"
|
||||||
|
|
||||||
|
# Layers data
|
||||||
|
for layer in profile.sl.layers:
|
||||||
|
sediment += (
|
||||||
|
f" {layer.height:>10} {layer.d50:>10} " +
|
||||||
|
f"{layer.sigma:>10} " +
|
||||||
|
f"{layer.critical_constraint:>10}"
|
||||||
|
)
|
||||||
|
|
||||||
|
# Profile header line
|
||||||
|
wfile.write(f"{num}{c1}{c2}{t} {rk} {pname} {sediment}\n")
|
||||||
|
|
||||||
|
def _export_ST_point_line(self, wfile, files, point):
|
||||||
|
x = f"{point.x:<12.4f}"[0:12]
|
||||||
|
y = f"{point.y:<12.4f}"[0:12]
|
||||||
|
z = f"{point.z:<12.4f}"[0:12]
|
||||||
|
n = f"{point.name:<3}"
|
||||||
|
|
||||||
|
# Generate sediment additional data if available
|
||||||
|
sediment = ""
|
||||||
|
prev = point.z
|
||||||
|
if point.sl is not None:
|
||||||
|
# Number of layers
|
||||||
|
nl = len(point.sl)
|
||||||
|
sediment = f"{nl:>3}"
|
||||||
|
|
||||||
|
# Layers data
|
||||||
|
for layer in point.sl.layers:
|
||||||
|
prev = round(prev - layer.height, 5)
|
||||||
|
sediment += (
|
||||||
|
f" {prev:>10} {layer.d50:>10} " +
|
||||||
|
f"{layer.sigma:>10} " +
|
||||||
|
f"{layer.critical_constraint:>10}"
|
||||||
|
)
|
||||||
|
|
||||||
|
# Point line
|
||||||
|
wfile.write(f"{x} {y} {z} {n} {sediment}\n")
|
||||||
|
|
||||||
|
def _export_NET(self, study, repertory, qlog=None, name="0"):
|
||||||
|
|
||||||
|
if qlog is not None:
|
||||||
|
qlog.put("Export NET file")
|
||||||
|
|
||||||
|
with adists_file_open(
|
||||||
|
os.path.join(repertory, f"{name}.NET"), "w+") as f:
|
||||||
|
edges = study.river.enable_edges()
|
||||||
|
|
||||||
|
for e in edges:
|
||||||
|
name = f"Reach_{e.id + 1:>3}".replace(" ", "0")
|
||||||
|
id = name
|
||||||
|
|
||||||
|
n1 = f"{e.node1.id:3}".replace(" ", "x")
|
||||||
|
n2 = f"{e.node2.id:3}".replace(" ", "x")
|
||||||
|
file = os.path.join("net", name + ".ST")
|
||||||
|
|
||||||
|
f.write(f"{id} {n1} {n2} {file}\n")
|
||||||
|
|
||||||
|
def _export_fake_INI(self, study, repertory, qlog=None, name="0"):
|
||||||
|
if qlog is not None:
|
||||||
|
qlog.put("Export fake INI file")
|
||||||
|
|
||||||
|
with adists_file_open(
|
||||||
|
os.path.join(
|
||||||
|
repertory, "Mage_fin.ini"
|
||||||
|
), "w+"
|
||||||
|
) as f:
|
||||||
|
edges = study.river.enable_edges()
|
||||||
|
for i, edge in enumerate(edges):
|
||||||
|
lst = list(filter(
|
||||||
|
lambda f: f.is_full_defined(),
|
||||||
|
edge.frictions.frictions
|
||||||
|
))
|
||||||
|
rk_min = 9999999.9
|
||||||
|
rk_max = -9999999.9
|
||||||
|
coeff_min = -1.0
|
||||||
|
coeff_max = -1.0
|
||||||
|
for s in lst: # TODO optimise ?
|
||||||
|
if s.begin_rk > rk_max:
|
||||||
|
rk_max = s.begin_rk
|
||||||
|
coeff_max = s.begin_strickler
|
||||||
|
if s.begin_rk < rk_min:
|
||||||
|
rk_min = s.begin_rk
|
||||||
|
coeff_min = s.begin_strickler
|
||||||
|
if s.end_rk > rk_max:
|
||||||
|
rk_max = s.end_rk
|
||||||
|
coeff_max = s.end_strickler
|
||||||
|
if s.end_rk < rk_min:
|
||||||
|
rk_min = s.end_rk
|
||||||
|
coeff_min = s.end_strickler
|
||||||
|
|
||||||
|
print("min max", rk_min, rk_max)
|
||||||
|
|
||||||
|
def get_stricklers_from_rk(rk, lst):
|
||||||
|
print("rk", rk)
|
||||||
|
|
||||||
|
coeff = None
|
||||||
|
if rk > rk_max:
|
||||||
|
coeff = coeff_max
|
||||||
|
elif rk < rk_min:
|
||||||
|
coeff = coeff_min
|
||||||
|
else:
|
||||||
|
for s in lst:
|
||||||
|
if (rk >= s.begin_rk and rk <= s.end_rk or
|
||||||
|
rk <= s.begin_rk and rk >= s.end_rk):
|
||||||
|
coeff = s.begin_strickler # TODO: inerpolate
|
||||||
|
break
|
||||||
|
|
||||||
|
# TODO interpolation if rk is not in frictons
|
||||||
|
|
||||||
|
if coeff is None:
|
||||||
|
logger.error(
|
||||||
|
"Study frictions are not fully defined"
|
||||||
|
)
|
||||||
|
return None
|
||||||
|
|
||||||
|
return coeff.minor, coeff.medium
|
||||||
|
|
||||||
|
for j, profile in enumerate(edge.reach.profiles):
|
||||||
|
coef_min, coef_moy = get_stricklers_from_rk(profile.rk,
|
||||||
|
lst)
|
||||||
|
f.write(
|
||||||
|
f" {i+1:3}{j+1:4}{' '*116}{coef_min:9}{coef_moy:9}\n")
|
||||||
|
|
||||||
def _export_REP_additional_lines(self, study, rep_file):
|
def _export_REP_additional_lines(self, study, rep_file):
|
||||||
lines = filter(
|
lines = filter(
|
||||||
lambda line: line.is_enabled(),
|
lambda line: line.is_enabled(),
|
||||||
|
|
@ -129,7 +310,7 @@ class AdisTS(CommandLineSolver):
|
||||||
), "w+"
|
), "w+"
|
||||||
) as f:
|
) as f:
|
||||||
path = os.path.join("..", mage_rep, name)
|
path = os.path.join("..", mage_rep, name)
|
||||||
f.write(f"NET {path}.NET\n")
|
f.write(f"NET {name}.NET\n")
|
||||||
f.write(f"REP {path}.REP\n")
|
f.write(f"REP {path}.REP\n")
|
||||||
|
|
||||||
for file in files:
|
for file in files:
|
||||||
|
|
@ -138,13 +319,25 @@ class AdisTS(CommandLineSolver):
|
||||||
|
|
||||||
self._export_REP_additional_lines(study, f)
|
self._export_REP_additional_lines(study, f)
|
||||||
|
|
||||||
path_mage_net = os.path.join(os.path.abspath(
|
self._export_ST(study, repertory, qlog, name=name)
|
||||||
os.path.join(repertory, os.pardir)
|
self._export_NET(study, repertory, qlog, name=name)
|
||||||
), os.path.join(mage_rep, "net"))
|
|
||||||
path_adists_net = os.path.join(repertory, "net")
|
|
||||||
|
|
||||||
if os.path.exists(path_mage_net):
|
# fake mage_fin.ini:
|
||||||
shutil.copytree(path_mage_net, path_adists_net, dirs_exist_ok=True)
|
|
||||||
|
path_mage = os.path.join(os.path.abspath(
|
||||||
|
os.path.join(repertory, os.pardir)), mage_rep)
|
||||||
|
self._export_fake_INI(study, path_mage,
|
||||||
|
qlog, name=name)
|
||||||
|
|
||||||
|
# path_mage_net = os.path.join(os.path.abspath(
|
||||||
|
# os.path.join(repertory, os.pardir)
|
||||||
|
# ), os.path.join(mage_rep, "net"))
|
||||||
|
# path_adists_net = os.path.join(repertory, "net")
|
||||||
|
|
||||||
|
# if os.path.exists(path_mage_net):
|
||||||
|
# shutil.copytree(path_mage_net,
|
||||||
|
# path_adists_net,
|
||||||
|
# dirs_exist_ok=True)
|
||||||
|
|
||||||
@timer
|
@timer
|
||||||
def export(self, study, repertory, qlog=None):
|
def export(self, study, repertory, qlog=None):
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
# RubarBE.py -- Pamhyr
|
# RubarBE.py -- Pamhyr
|
||||||
# Copyright (C) 2024 INRAE
|
# Copyright (C) 2024-2025 INRAE
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# This program is free software: you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
|
@ -20,7 +20,7 @@ import os
|
||||||
import logging
|
import logging
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
|
||||||
from tools import timer, trace, old_pamhyr_date_to_timestamp
|
from tools import timer, trace, old_pamhyr_date_to_timestamp, logger_exception
|
||||||
|
|
||||||
from Solver.CommandLine import CommandLineSolver
|
from Solver.CommandLine import CommandLineSolver
|
||||||
|
|
||||||
|
|
@ -39,7 +39,7 @@ class Rubar3(CommandLineSolver):
|
||||||
self._type = "rubar3"
|
self._type = "rubar3"
|
||||||
|
|
||||||
self._cmd_input = ""
|
self._cmd_input = ""
|
||||||
self._cmd_solver = "@path @input -o @output"
|
self._cmd_solver = "@path @args @input"
|
||||||
self._cmd_output = ""
|
self._cmd_output = ""
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
|
@ -73,11 +73,12 @@ class Rubar3(CommandLineSolver):
|
||||||
("rubarbe_tf_4", "y"),
|
("rubarbe_tf_4", "y"),
|
||||||
("rubarbe_tf_5", "y"),
|
("rubarbe_tf_5", "y"),
|
||||||
("rubarbe_tf_6", "n"),
|
("rubarbe_tf_6", "n"),
|
||||||
("rubarbe_trased", "y"),
|
("rubarbe_trased", "n"),
|
||||||
# ("rubarbe_optfpc", "0"),
|
("rubarbe_optfpc", "0"),
|
||||||
# ("rubarbe_ros", "2650.0"),
|
# trased parameters
|
||||||
# ("rubarbe_dm", "0.1"),
|
("rubarbe_ros", "2650.0"),
|
||||||
# ("rubarbe_segma", "1.0"),
|
("rubarbe_dm", "0.1"),
|
||||||
|
("rubarbe_segma", "1.0"),
|
||||||
# Sediment parameters
|
# Sediment parameters
|
||||||
("rubarbe_sediment_ros", "2650.0"),
|
("rubarbe_sediment_ros", "2650.0"),
|
||||||
("rubarbe_sediment_por", "0.4"),
|
("rubarbe_sediment_por", "0.4"),
|
||||||
|
|
@ -129,11 +130,11 @@ class Rubar3(CommandLineSolver):
|
||||||
|
|
||||||
def output_param(self):
|
def output_param(self):
|
||||||
name = self._study.name
|
name = self._study.name
|
||||||
return f"{name}"
|
return f"profil.{name}"
|
||||||
|
|
||||||
def log_file(self):
|
def log_file(self):
|
||||||
name = self._study.name
|
name = self._study.name
|
||||||
return f"{name}"
|
return f"geomac-i.{name}"
|
||||||
|
|
||||||
def export(self, study, repertory, qlog=None):
|
def export(self, study, repertory, qlog=None):
|
||||||
self._study = study
|
self._study = study
|
||||||
|
|
@ -143,10 +144,12 @@ class Rubar3(CommandLineSolver):
|
||||||
self._export_ts(study, repertory, qlog, name=name)
|
self._export_ts(study, repertory, qlog, name=name)
|
||||||
self._export_geomac_i(study, repertory, qlog, name=name)
|
self._export_geomac_i(study, repertory, qlog, name=name)
|
||||||
self._export_mail(study, repertory, qlog, name=name)
|
self._export_mail(study, repertory, qlog, name=name)
|
||||||
|
self._export_devers(study, repertory, qlog, name=name)
|
||||||
self._export_condin(study, repertory, qlog, name=name)
|
self._export_condin(study, repertory, qlog, name=name)
|
||||||
self._export_stricklers(study, repertory, qlog, name=name)
|
self._export_stricklers(study, repertory, qlog, name=name)
|
||||||
self._export_hydro(study, repertory, qlog, name=name)
|
self._export_hydro(study, repertory, qlog, name=name)
|
||||||
self._export_condav(study, repertory, qlog, name=name)
|
self._export_condav(study, repertory, qlog, name=name)
|
||||||
|
# self._export_abshyd(study, repertory, qlog, name=name)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
@ -166,9 +169,8 @@ class Rubar3(CommandLineSolver):
|
||||||
|
|
||||||
it = iter(params)
|
it = iter(params)
|
||||||
|
|
||||||
line = 0
|
param = next(it, None)
|
||||||
while line < 25:
|
while param is not None:
|
||||||
param = next(it)
|
|
||||||
name = param.name
|
name = param.name
|
||||||
value = param.value
|
value = param.value
|
||||||
|
|
||||||
|
|
@ -196,12 +198,12 @@ class Rubar3(CommandLineSolver):
|
||||||
v2 = next(it).value
|
v2 = next(it).value
|
||||||
v3 = next(it).value
|
v3 = next(it).value
|
||||||
|
|
||||||
f.write(f"{v2}{v3}")
|
# f.write(f"{v2}{v3}")
|
||||||
|
|
||||||
# New line
|
# New line
|
||||||
f.write(f"\n")
|
f.write(f"\n")
|
||||||
|
|
||||||
line += 1
|
param = next(it, None)
|
||||||
|
|
||||||
def _export_ts(self, study, repertory, qlog, name="0"):
|
def _export_ts(self, study, repertory, qlog, name="0"):
|
||||||
if qlog is not None:
|
if qlog is not None:
|
||||||
|
|
@ -330,6 +332,50 @@ class Rubar3(CommandLineSolver):
|
||||||
if ind % 3 != 0:
|
if ind % 3 != 0:
|
||||||
f.write("\n")
|
f.write("\n")
|
||||||
|
|
||||||
|
def _export_abshyd(self, study, repertory, qlog, name="0"):
|
||||||
|
if qlog is not None:
|
||||||
|
qlog.put("Export ABSHYD file")
|
||||||
|
|
||||||
|
with open(
|
||||||
|
os.path.join(
|
||||||
|
repertory, f"abshyd.{name}"
|
||||||
|
), "w+"
|
||||||
|
) as f:
|
||||||
|
reach_ind = 1
|
||||||
|
for edge in study.river.enable_edges():
|
||||||
|
reach = edge.reach
|
||||||
|
lm = len(reach) + 1
|
||||||
|
f.write(f"{lm:>13}\n")
|
||||||
|
|
||||||
|
ind = 1
|
||||||
|
for mail in reach.inter_profiles_rk():
|
||||||
|
f.write(f"{ind:>4} {mail:15.3f} {reach_ind:>4}\n")
|
||||||
|
ind += 1
|
||||||
|
|
||||||
|
reach_ind += 1
|
||||||
|
|
||||||
|
def _export_devers(self, study, repertory, qlog, name="0"):
|
||||||
|
if qlog is not None:
|
||||||
|
qlog.put("Export DEVERS file")
|
||||||
|
|
||||||
|
with open(
|
||||||
|
os.path.join(
|
||||||
|
repertory, f"devers.{name}"
|
||||||
|
), "w+"
|
||||||
|
) as f:
|
||||||
|
reach_ind = 1
|
||||||
|
for edge in study.river.enable_edges():
|
||||||
|
reach = edge.reach
|
||||||
|
lm = len(reach) + 1
|
||||||
|
f.write(f"{lm:>13}\n")
|
||||||
|
|
||||||
|
ind = 1
|
||||||
|
for mail in reach.inter_profiles_rk():
|
||||||
|
f.write(f"{ind:>4} {0.0:15.3f} {0.0:15.3f} {1.0:>15.3f}\n")
|
||||||
|
ind += 1
|
||||||
|
|
||||||
|
reach_ind += 1
|
||||||
|
|
||||||
def _export_stricklers(self, study, repertory, qlog, name="0"):
|
def _export_stricklers(self, study, repertory, qlog, name="0"):
|
||||||
self._export_frot(study, repertory, qlog, name=name, version="")
|
self._export_frot(study, repertory, qlog, name=name, version="")
|
||||||
self._export_frot(study, repertory, qlog, name=name, version="2")
|
self._export_frot(study, repertory, qlog, name=name, version="2")
|
||||||
|
|
@ -348,24 +394,57 @@ class Rubar3(CommandLineSolver):
|
||||||
lm = len(reach) + 1
|
lm = len(reach) + 1
|
||||||
f.write(f"{lm:>6}\n")
|
f.write(f"{lm:>6}\n")
|
||||||
|
|
||||||
def get_stricklers_from_rk(rk):
|
lst = list(filter(
|
||||||
return next(
|
lambda f: f.is_full_defined(),
|
||||||
map(
|
edge.frictions.frictions
|
||||||
lambda s: (
|
))
|
||||||
s.begin_strickler.medium if version == "2"
|
|
||||||
else s.begin_strickler.minor
|
rk_min = 9999999.9
|
||||||
),
|
rk_max = -9999999.9
|
||||||
filter(
|
coeff_min = -1.0
|
||||||
lambda f: rk in f,
|
coeff_max = -1.0
|
||||||
edge.frictions.lst
|
for s in lst: # TODO optimise ?
|
||||||
)
|
if s.begin_rk > rk_max:
|
||||||
)
|
rk_max = s.begin_rk
|
||||||
|
coeff_max = s.begin_strickler
|
||||||
|
if s.begin_rk < rk_min:
|
||||||
|
rk_min = s.begin_rk
|
||||||
|
coeff_min = s.begin_strickler
|
||||||
|
if s.end_rk > rk_max:
|
||||||
|
rk_max = s.end_rk
|
||||||
|
coeff_max = s.end_strickler
|
||||||
|
if s.end_rk < rk_min:
|
||||||
|
rk_min = s.end_rk
|
||||||
|
coeff_min = s.end_strickler
|
||||||
|
|
||||||
|
def get_stricklers_from_rk(rk, lst):
|
||||||
|
|
||||||
|
coeff = None
|
||||||
|
if rk > rk_max:
|
||||||
|
coeff = coeff_max
|
||||||
|
elif rk < rk_min:
|
||||||
|
coeff = coeff_min
|
||||||
|
else:
|
||||||
|
for s in lst:
|
||||||
|
if (rk >= s.begin_rk and rk <= s.end_rk or
|
||||||
|
rk <= s.begin_rk and rk >= s.end_rk):
|
||||||
|
coeff = s.begin_strickler # TODO: inerpolate
|
||||||
|
break
|
||||||
|
|
||||||
|
# TODO interpolation if rk is not in frictons
|
||||||
|
|
||||||
|
if coeff is None:
|
||||||
|
logger.error(
|
||||||
|
"Study frictions are not fully defined"
|
||||||
)
|
)
|
||||||
|
return None
|
||||||
|
|
||||||
|
return coeff.medium if version == "2" else coeff.minor
|
||||||
|
|
||||||
ind = 1
|
ind = 1
|
||||||
for mail in edge.reach.inter_profiles_rk():
|
for mail in edge.reach.inter_profiles_rk():
|
||||||
coef = get_stricklers_from_rk(mail)
|
coef = get_stricklers_from_rk(mail, lst)
|
||||||
|
if coef is not None:
|
||||||
f.write(f"{ind:>6} {coef:>12.5f}")
|
f.write(f"{ind:>6} {coef:>12.5f}")
|
||||||
|
|
||||||
ind += 1
|
ind += 1
|
||||||
|
|
@ -383,7 +462,7 @@ class Rubar3(CommandLineSolver):
|
||||||
for edge in study.river.enable_edges():
|
for edge in study.river.enable_edges():
|
||||||
reach = edge.reach
|
reach = edge.reach
|
||||||
|
|
||||||
f.write(f"0.0\n")
|
f.write(f"{0.0}\n")
|
||||||
|
|
||||||
ics = study.river.initial_conditions.get(edge)
|
ics = study.river.initial_conditions.get(edge)
|
||||||
data = self._export_condin_init_data(ics)
|
data = self._export_condin_init_data(ics)
|
||||||
|
|
@ -392,7 +471,9 @@ class Rubar3(CommandLineSolver):
|
||||||
first = profiles[0]
|
first = profiles[0]
|
||||||
last = profiles[-1]
|
last = profiles[-1]
|
||||||
|
|
||||||
|
# if first not in data or last not in data:
|
||||||
if first.rk not in data or last.rk not in data:
|
if first.rk not in data or last.rk not in data:
|
||||||
|
print(data)
|
||||||
logger.error(
|
logger.error(
|
||||||
"Study initial condition is not fully defined"
|
"Study initial condition is not fully defined"
|
||||||
)
|
)
|
||||||
|
|
@ -493,8 +574,219 @@ class Rubar3(CommandLineSolver):
|
||||||
|
|
||||||
for bc in bcs:
|
for bc in bcs:
|
||||||
f.write(f"{len(bc)}\n")
|
f.write(f"{len(bc)}\n")
|
||||||
|
if bc.bctype == "ZD":
|
||||||
for d0, d1 in bc.data:
|
for d0, d1 in bc.data:
|
||||||
f.write(f"{d1} {d0}\n")
|
f.write(f"{d1} {d0}\n")
|
||||||
|
else:
|
||||||
|
for d0, d1 in bc.data:
|
||||||
|
f.write(f"{d0} {d1}\n")
|
||||||
|
|
||||||
|
def read_profil(self, study, fname, results, qlog=None, name="0"):
|
||||||
|
logger.info(f"read: profil.{name}")
|
||||||
|
with open(fname, "r") as f:
|
||||||
|
reachs = []
|
||||||
|
for i, edge in enumerate(study.river.enable_edges()):
|
||||||
|
reach = edge.reach
|
||||||
|
# Add results reach to reach list
|
||||||
|
res_reach = results.river.add(i)
|
||||||
|
reachs.append((res_reach, len(reach) + 1))
|
||||||
|
|
||||||
|
def read_data_line(f):
|
||||||
|
line = f.readline().split()
|
||||||
|
if len(line) > 3:
|
||||||
|
return tuple(map(float, line))
|
||||||
|
else:
|
||||||
|
return (0.0, 0.0, 0.0, 0.0)
|
||||||
|
|
||||||
|
def set_and_compute_limites(reach, ind, z, q, s):
|
||||||
|
reach.set(ind, timestamp, "Z", z)
|
||||||
|
reach.set(ind, timestamp, "Q", q)
|
||||||
|
reach.set(ind, timestamp, "V", s)
|
||||||
|
|
||||||
|
profile = reach.profile(ind)
|
||||||
|
limits = profile.geometry.get_water_limits(z)
|
||||||
|
reach.set(
|
||||||
|
ind, timestamp, "water_limits", limits
|
||||||
|
)
|
||||||
|
|
||||||
|
ts = set()
|
||||||
|
timestamp = next(filter(
|
||||||
|
lambda p: p.name == 'rubarbe_tinit',
|
||||||
|
study.river.get_params(self._type).parameters
|
||||||
|
)).value
|
||||||
|
if timestamp.count(':') == 3:
|
||||||
|
timestamp = old_pamhyr_date_to_timestamp(timestamp)
|
||||||
|
ts.add(timestamp)
|
||||||
|
|
||||||
|
# add initial condition
|
||||||
|
for r, edge in enumerate(study.river.enable_edges()):
|
||||||
|
reach = edge.reach
|
||||||
|
ics = study.river.initial_conditions.get(edge)
|
||||||
|
q = ics.get_discharge()
|
||||||
|
z = ics.get_elevation()
|
||||||
|
k = 0
|
||||||
|
for i, j in zip(z, q):
|
||||||
|
v = reach.profiles[k].speed(i, j)
|
||||||
|
set_and_compute_limites(reachs[r][0], k, i, j, v)
|
||||||
|
k += 1
|
||||||
|
|
||||||
|
# start read
|
||||||
|
|
||||||
|
end = False
|
||||||
|
while True:
|
||||||
|
line = f.readline()
|
||||||
|
if line == "":
|
||||||
|
results.set("timestamps", ts)
|
||||||
|
return
|
||||||
|
|
||||||
|
timestamp = float(line)
|
||||||
|
ts.add(timestamp)
|
||||||
|
|
||||||
|
logger.info(f"read: profil.{name}: timestamp = {timestamp}")
|
||||||
|
|
||||||
|
for reach, lm in reachs:
|
||||||
|
# First profile
|
||||||
|
h, s, q, z = read_data_line(f)
|
||||||
|
set_and_compute_limites(reach, 0, z+h, q, s)
|
||||||
|
|
||||||
|
# For each profile
|
||||||
|
ind = 1
|
||||||
|
ph, ps, pq, pz = read_data_line(f)
|
||||||
|
while ind < lm - 2:
|
||||||
|
h, s, q, z = read_data_line(f)
|
||||||
|
set_and_compute_limites(
|
||||||
|
reach, ind,
|
||||||
|
(pz + z + ph + h) / 2,
|
||||||
|
(pq + q) / 2,
|
||||||
|
(ps + s) / 2
|
||||||
|
)
|
||||||
|
|
||||||
|
ph = h
|
||||||
|
ps = s
|
||||||
|
pq = q
|
||||||
|
pz = z
|
||||||
|
ind += 1
|
||||||
|
|
||||||
|
# Last profile
|
||||||
|
h, s, q, z = read_data_line(f)
|
||||||
|
set_and_compute_limites(reach, ind, z+h, q, s)
|
||||||
|
|
||||||
|
@timer
|
||||||
|
def write_bin(self, study, fname, results, qlog=None, name="0"):
|
||||||
|
logger.info(f"write_bin: Start writing '{fname}' ...")
|
||||||
|
|
||||||
|
with open(fname, "wb") as f:
|
||||||
|
def newline(j): return np.asarray([j], dtype=np.int32).tofile(f)
|
||||||
|
def endline(j): return np.asarray([j], dtype=np.int32).tofile(f)
|
||||||
|
|
||||||
|
def write_int(i):
|
||||||
|
newline(len(i)*4)
|
||||||
|
np.array(i, dtype=np.int32).tofile(f)
|
||||||
|
endline(len(i)*4)
|
||||||
|
|
||||||
|
def write_float(i):
|
||||||
|
newline(len(i)*4)
|
||||||
|
np.array(i, dtype=np.float32).tofile(f)
|
||||||
|
endline(len(i)*4)
|
||||||
|
|
||||||
|
def write_float64(i):
|
||||||
|
newline(len(i)*8)
|
||||||
|
np.array(i, dtype=np.float64).tofile(f)
|
||||||
|
endline(len(i)*8)
|
||||||
|
|
||||||
|
def write_float64(i):
|
||||||
|
newline(len(i)*8)
|
||||||
|
np.array(i, dtype=np.float64).tofile(f)
|
||||||
|
endline(len(i)*8)
|
||||||
|
|
||||||
|
def write_data(npts, t, a, val):
|
||||||
|
newline(npts*4 + 13)
|
||||||
|
np.array(npts, dtype=np.int32).tofile(f)
|
||||||
|
np.array(t, dtype=np.float64).tofile(f)
|
||||||
|
np.array(bytearray(a.encode()), dtype=np.byte).tofile(f)
|
||||||
|
np.array(val, dtype=np.float32).tofile(f)
|
||||||
|
endline(npts*4 + 13)
|
||||||
|
|
||||||
|
ts_list = sorted(results.get("timestamps"))
|
||||||
|
profiles = []
|
||||||
|
for r in results.river.reachs:
|
||||||
|
profiles += r.profiles
|
||||||
|
|
||||||
|
# Meta data (1st line)
|
||||||
|
nb_reach = len(results.river)
|
||||||
|
nb_profile = len(profiles)
|
||||||
|
write_int([nb_reach, nb_profile, "82"])
|
||||||
|
|
||||||
|
# Reach information (2nd line)
|
||||||
|
is1 = []
|
||||||
|
is2 = []
|
||||||
|
ltmp = []
|
||||||
|
i = 1
|
||||||
|
for r in results.river.reachs:
|
||||||
|
j = i+len(r)-1
|
||||||
|
ltmp += [i, j]
|
||||||
|
is1.append(i)
|
||||||
|
is2.append(j)
|
||||||
|
i += i+len(r)
|
||||||
|
write_int(ltmp)
|
||||||
|
|
||||||
|
# X (3rd line)
|
||||||
|
rk = []
|
||||||
|
for r in results.river.reachs:
|
||||||
|
rk += r.geometry.get_rk()
|
||||||
|
write_float(rk)
|
||||||
|
|
||||||
|
# Z and Y (4th line)
|
||||||
|
# ltmp = []
|
||||||
|
# for r in results.river.reachs:
|
||||||
|
# for p in r.prifiles:
|
||||||
|
# ltpm.append(p.rk)
|
||||||
|
write_float(3*nb_profile*[0.0])
|
||||||
|
|
||||||
|
# Data
|
||||||
|
|
||||||
|
for timestamp in ts_list:
|
||||||
|
q = list(
|
||||||
|
map(
|
||||||
|
lambda p: p.get_ts_key(timestamp, "Q"),
|
||||||
|
profiles
|
||||||
|
)
|
||||||
|
)
|
||||||
|
write_data(nb_profile, timestamp, "Q", q)
|
||||||
|
z = list(
|
||||||
|
map(
|
||||||
|
lambda p: p.get_ts_key(timestamp, "Z"),
|
||||||
|
profiles
|
||||||
|
)
|
||||||
|
)
|
||||||
|
write_data(nb_profile, timestamp, "Z", z)
|
||||||
|
logger.info(f"write_bin: ... end with {len(ts_list)} timestamps")
|
||||||
|
|
||||||
|
@timer
|
||||||
|
def results(self, study, repertory, qlog=None, name="0"):
|
||||||
|
results = Results(
|
||||||
|
study=study,
|
||||||
|
solver=self,
|
||||||
|
repertory=repertory,
|
||||||
|
name=name,
|
||||||
|
)
|
||||||
|
results_file = f"profil.{name}"
|
||||||
|
|
||||||
|
fname = os.path.join(repertory, results_file)
|
||||||
|
if not os.path.isfile(fname):
|
||||||
|
logger.warning(f"Result file {results_file} does not exist")
|
||||||
|
return None
|
||||||
|
try:
|
||||||
|
self.read_profil(study, fname, results, qlog, name=name)
|
||||||
|
except Exception as e:
|
||||||
|
logger.error(f"Failed to read results")
|
||||||
|
logger_exception(e)
|
||||||
|
return None
|
||||||
|
|
||||||
|
fname = os.path.join(repertory, f"{name}.BIN")
|
||||||
|
self.write_bin(study, fname, results, qlog, name)
|
||||||
|
|
||||||
|
return results
|
||||||
|
|
||||||
|
|
||||||
class RubarBE(Rubar3):
|
class RubarBE(Rubar3):
|
||||||
|
|
@ -506,5 +798,5 @@ class RubarBE(Rubar3):
|
||||||
self._type = "rubarbe"
|
self._type = "rubarbe"
|
||||||
|
|
||||||
self._cmd_input = ""
|
self._cmd_input = ""
|
||||||
self._cmd_solver = "@path @input -o @output"
|
self._cmd_solver = "@path @args @input"
|
||||||
self._cmd_output = ""
|
self._cmd_output = ""
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@ from platformdirs import user_cache_dir
|
||||||
|
|
||||||
from Solver.AdisTS import AdisTS
|
from Solver.AdisTS import AdisTS
|
||||||
from Solver.Mage import Mage8
|
from Solver.Mage import Mage8
|
||||||
|
from Solver.RubarBE import Rubar3
|
||||||
from tools import logger_exception
|
from tools import logger_exception
|
||||||
|
|
||||||
from PyQt5 import QtGui
|
from PyQt5 import QtGui
|
||||||
|
|
@ -1414,7 +1415,10 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
|
||||||
if type(results) is str:
|
if type(results) is str:
|
||||||
logger.info(f"Open results from {os.path.dirname(results)}")
|
logger.info(f"Open results from {os.path.dirname(results)}")
|
||||||
|
|
||||||
|
if ".BIN" in results:
|
||||||
name = os.path.basename(results).replace(".BIN", "")
|
name = os.path.basename(results).replace(".BIN", "")
|
||||||
|
elif "profil." in results:
|
||||||
|
name = os.path.basename(results).replace("profil.", "")
|
||||||
|
|
||||||
def reading_fn():
|
def reading_fn():
|
||||||
self._tmp_results = solver.results(
|
self._tmp_results = solver.results(
|
||||||
|
|
@ -1545,7 +1549,7 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
|
||||||
dialog.setFileMode(QFileDialog.FileMode.ExistingFile)
|
dialog.setFileMode(QFileDialog.FileMode.ExistingFile)
|
||||||
dialog.setDefaultSuffix(".BIN")
|
dialog.setDefaultSuffix(".BIN")
|
||||||
# dialog.setFilter(dialog.filter() | QtCore.QDir.Hidden)
|
# dialog.setFilter(dialog.filter() | QtCore.QDir.Hidden)
|
||||||
dialog.setNameFilters(['Mage (*.BIN)'])
|
dialog.setNameFilters(['Mage (*.BIN)', 'Rubar3 (profil.*)'])
|
||||||
|
|
||||||
if self._study.filename is not None:
|
if self._study.filename is not None:
|
||||||
if self._last_solver is None:
|
if self._last_solver is None:
|
||||||
|
|
@ -1560,8 +1564,15 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
|
||||||
if dialog.exec_():
|
if dialog.exec_():
|
||||||
file_name = dialog.selectedFiles()
|
file_name = dialog.selectedFiles()
|
||||||
logger.info(f"Select results: {file_name}")
|
logger.info(f"Select results: {file_name}")
|
||||||
|
|
||||||
|
solver = None
|
||||||
|
if ".BIN" in file_name:
|
||||||
|
solver = Mage8("Mage8")
|
||||||
|
else:
|
||||||
|
solver = Rubar3("Rubar3")
|
||||||
|
|
||||||
self.open_solver_results(
|
self.open_solver_results(
|
||||||
Mage8("Mage"),
|
solver,
|
||||||
results=file_name[0]
|
results=file_name[0]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -116,7 +116,7 @@ class PlotAC(PamhyrPlot):
|
||||||
|
|
||||||
self.collection = self.canvas.axes.fill_between(
|
self.collection = self.canvas.axes.fill_between(
|
||||||
x, z, water_z,
|
x, z, water_z,
|
||||||
where=z <= water_z,
|
where=list(map(lambda x: x <= water_z, z)),
|
||||||
color=self.color_plot_river_water_zone,
|
color=self.color_plot_river_water_zone,
|
||||||
alpha=0.7, interpolate=True
|
alpha=0.7, interpolate=True
|
||||||
)
|
)
|
||||||
|
|
@ -263,7 +263,7 @@ class PlotAC(PamhyrPlot):
|
||||||
self.collection.remove()
|
self.collection.remove()
|
||||||
self.collection = self.canvas.axes.fill_between(
|
self.collection = self.canvas.axes.fill_between(
|
||||||
x, z, water_z,
|
x, z, water_z,
|
||||||
where=z <= water_z,
|
where=list(map(lambda x: x <= water_z, z)),
|
||||||
color=self.color_plot_river_water_zone,
|
color=self.color_plot_river_water_zone,
|
||||||
alpha=0.7, interpolate=True
|
alpha=0.7, interpolate=True
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -345,24 +345,29 @@ class ResultsWindowAdisTS(PamhyrWindow):
|
||||||
super(ResultsWindowAdisTS, self).closeEvent(event)
|
super(ResultsWindowAdisTS, self).closeEvent(event)
|
||||||
|
|
||||||
def _compute_status_label(self):
|
def _compute_status_label(self):
|
||||||
# Timestamp
|
return (self.text_bief() + " | " +
|
||||||
ts = self._timestamps[self._slider_time.value()]
|
self.text_profile() + " | " +
|
||||||
|
self.text_pollutant() + " | " +
|
||||||
t0 = datetime.fromtimestamp(0)
|
self.text_time())
|
||||||
fts = str(
|
|
||||||
datetime.fromtimestamp(ts) - t0
|
|
||||||
)
|
|
||||||
fts.replace("days", _translate("Results", "days"))\
|
|
||||||
.replace("day", _translate("Results", "day"))
|
|
||||||
|
|
||||||
|
def text_bief(self):
|
||||||
# Reach
|
# Reach
|
||||||
table = self.find(QTableView, f"tableView_reach")
|
table = self.find(QTableView, f"tableView_reach")
|
||||||
indexes = table.selectedIndexes()
|
indexes = table.selectedIndexes()
|
||||||
if len(indexes) == 0:
|
if len(indexes) == 0:
|
||||||
reach = self._study.river.edges()[0]
|
reach = self._study.river.enable_edges()[0]
|
||||||
else:
|
else:
|
||||||
reach = self._study.river.edges()[indexes[0].row()]
|
reach = self._study.river.enable_edges()[indexes[0].row()]
|
||||||
|
return f"{self._trad['reach']}: {reach.name}"
|
||||||
|
|
||||||
|
def text_profile(self):
|
||||||
|
# Reach
|
||||||
|
table = self.find(QTableView, f"tableView_reach")
|
||||||
|
indexes = table.selectedIndexes()
|
||||||
|
if len(indexes) == 0:
|
||||||
|
reach = self._study.river.enable_edges()[0]
|
||||||
|
else:
|
||||||
|
reach = self._study.river.enable_edges()[indexes[0].row()]
|
||||||
# Profile
|
# Profile
|
||||||
table = self.find(QTableView, f"tableView_profile")
|
table = self.find(QTableView, f"tableView_profile")
|
||||||
indexes = table.selectedIndexes()
|
indexes = table.selectedIndexes()
|
||||||
|
|
@ -372,7 +377,24 @@ class ResultsWindowAdisTS(PamhyrWindow):
|
||||||
profile = reach.reach.profile(indexes[0].row())
|
profile = reach.reach.profile(indexes[0].row())
|
||||||
|
|
||||||
pname = profile.name if profile.name != "" else profile.rk
|
pname = profile.name if profile.name != "" else profile.rk
|
||||||
|
return f"{self._trad['cross_section']}: {pname}"
|
||||||
|
|
||||||
|
def text_time(self):
|
||||||
|
# Timestamp
|
||||||
|
ts = self._timestamps[self._slider_time.value()]
|
||||||
|
|
||||||
|
t0 = datetime.fromtimestamp(0)
|
||||||
|
fts = str(
|
||||||
|
datetime.fromtimestamp(ts) - t0
|
||||||
|
)
|
||||||
|
fts = str(
|
||||||
|
datetime.fromtimestamp(ts) - t0
|
||||||
|
)
|
||||||
|
fts.replace("days", _translate("Results", "days"))\
|
||||||
|
.replace("day", _translate("Results", "day"))
|
||||||
|
return f"{self._trad['time']} : {fts} ({ts} sec)"
|
||||||
|
|
||||||
|
def text_pollutant(self):
|
||||||
# Pollutant
|
# Pollutant
|
||||||
table = self.find(QTableView, f"tableView_pollutants")
|
table = self.find(QTableView, f"tableView_pollutants")
|
||||||
indexes = table.selectedIndexes()
|
indexes = table.selectedIndexes()
|
||||||
|
|
@ -381,10 +403,7 @@ class ResultsWindowAdisTS(PamhyrWindow):
|
||||||
self._results.pollutants_list[i.row()+1] for i in indexes
|
self._results.pollutants_list[i.row()+1] for i in indexes
|
||||||
]
|
]
|
||||||
|
|
||||||
return (f"{self._trad['reach']}: {reach.name} | " +
|
return (f"Pollutant: {', '.join(self.pollutant_label)}")
|
||||||
f"{self._trad['cross_section']}: {pname} | " +
|
|
||||||
f"Pollutant: {', '.join(self.pollutant_label)} | " +
|
|
||||||
f"{self._trad['unit_time_s']} : {fts} ({ts} sec)")
|
|
||||||
|
|
||||||
def setup_statusbar(self):
|
def setup_statusbar(self):
|
||||||
txt = self._compute_status_label()
|
txt = self._compute_status_label()
|
||||||
|
|
|
||||||
|
|
@ -486,7 +486,8 @@ class SolverLogWindow(PamhyrWindow):
|
||||||
if self._results is None:
|
if self._results is None:
|
||||||
def reading_fn():
|
def reading_fn():
|
||||||
self._results = self._solver.results(
|
self._results = self._solver.results(
|
||||||
self._study, self._workdir, qlog=self._output
|
self._study, self._workdir,
|
||||||
|
qlog=self._output, name=self._study.name
|
||||||
)
|
)
|
||||||
|
|
||||||
dlg = ReadingResultsDialog(reading_fn=reading_fn, parent=self)
|
dlg = ReadingResultsDialog(reading_fn=reading_fn, parent=self)
|
||||||
|
|
|
||||||
|
|
@ -82,7 +82,7 @@ class SelectSolverWindowAdisTS(PamhyrDialog):
|
||||||
# solvers = self._config.solvers
|
# solvers = self._config.solvers
|
||||||
# solvers mage
|
# solvers mage
|
||||||
solvers = list(filter(
|
solvers = list(filter(
|
||||||
lambda x: "mage" not in x._type, self._config.solvers
|
lambda x: "adists" in x._type, self._config.solvers
|
||||||
))
|
))
|
||||||
solvers_name = list(
|
solvers_name = list(
|
||||||
map(
|
map(
|
||||||
|
|
@ -92,7 +92,8 @@ class SelectSolverWindowAdisTS(PamhyrDialog):
|
||||||
)
|
)
|
||||||
|
|
||||||
solvers_mage = list(filter(
|
solvers_mage = list(filter(
|
||||||
lambda x: "mage" in x._type.lower(), self._config.solvers
|
lambda x: "mage" or "rubar" in x._type.lower(),
|
||||||
|
self._config.solvers
|
||||||
))
|
))
|
||||||
solvers_mage_names = list(map(lambda x: x._name, solvers_mage))
|
solvers_mage_names = list(map(lambda x: x._name, solvers_mage))
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ logger = logging.getLogger()
|
||||||
|
|
||||||
class Config(SQL):
|
class Config(SQL):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self._version = '0.0.6'
|
self._version = '0.0.7'
|
||||||
self.filename = Config.filename()
|
self.filename = Config.filename()
|
||||||
self.set_default_value()
|
self.set_default_value()
|
||||||
|
|
||||||
|
|
@ -101,6 +101,7 @@ class Config(SQL):
|
||||||
# Add default solver
|
# Add default solver
|
||||||
posix = os.name == 'posix'
|
posix = os.name == 'posix'
|
||||||
ext = "" if posix else ".exe"
|
ext = "" if posix else ".exe"
|
||||||
|
path = os.path.join("@install_dir", "mage8", f"mage{ext}")
|
||||||
|
|
||||||
self.execute(f"""
|
self.execute(f"""
|
||||||
INSERT INTO solver VALUES (
|
INSERT INTO solver VALUES (
|
||||||
|
|
@ -111,7 +112,7 @@ class Config(SQL):
|
||||||
'', '', '',
|
'', '', '',
|
||||||
|
|
||||||
'',
|
'',
|
||||||
'@install_dir/mage/mage{ext} @args @input',
|
'{path} @args @input',
|
||||||
''
|
''
|
||||||
)
|
)
|
||||||
""")
|
""")
|
||||||
|
|
@ -135,16 +136,19 @@ class Config(SQL):
|
||||||
if int(release) < 5:
|
if int(release) < 5:
|
||||||
posix = os.name == 'posix'
|
posix = os.name == 'posix'
|
||||||
ext = "" if posix else ".exe"
|
ext = "" if posix else ".exe"
|
||||||
|
path = os.path.join("@install_dir", "mage8", f"mage{ext}")
|
||||||
|
|
||||||
self.execute(
|
self.execute(
|
||||||
"UPDATE solver SET cmd_solver=" +
|
"UPDATE solver SET cmd_solver=" +
|
||||||
f"'@install_dir/mage8/mage{ext} @args @input' "
|
f"'{path} @args @input' "
|
||||||
"WHERE name='default-mage'"
|
"WHERE name='default-mage'"
|
||||||
)
|
)
|
||||||
|
|
||||||
if int(release) < 6:
|
if int(release) < 6:
|
||||||
posix = os.name == 'posix'
|
posix = os.name == 'posix'
|
||||||
ext = "" if posix else ".exe"
|
ext = "" if posix else ".exe"
|
||||||
|
path = os.path.join("@install_dir",
|
||||||
|
"adists", f"adists{ext}")
|
||||||
|
|
||||||
self.execute(f"""
|
self.execute(f"""
|
||||||
INSERT INTO solver VALUES (
|
INSERT INTO solver VALUES (
|
||||||
|
|
@ -155,16 +159,41 @@ class Config(SQL):
|
||||||
'', '', '',
|
'', '', '',
|
||||||
|
|
||||||
'',
|
'',
|
||||||
'@install_dir/adists/adists{ext} @args @input',
|
'{path} @args @input',
|
||||||
''
|
''
|
||||||
)
|
)
|
||||||
""")
|
""")
|
||||||
self.execute(
|
self.execute(
|
||||||
"UPDATE solver SET cmd_solver=" +
|
"UPDATE solver SET cmd_solver=" +
|
||||||
f"'@install_dir/adists/adists{ext} @args @input' "
|
f"'{path} @args @input' "
|
||||||
"WHERE name='default-AdisTS'"
|
"WHERE name='default-AdisTS'"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if int(release) < 7:
|
||||||
|
posix = os.name == 'posix'
|
||||||
|
ext = "" if posix else ".exe"
|
||||||
|
path = os.path.join("@install_dir",
|
||||||
|
"rubar", f"rubar3{ext}")
|
||||||
|
|
||||||
|
self.execute(f"""
|
||||||
|
INSERT INTO solver VALUES (
|
||||||
|
'rubar3',
|
||||||
|
'default-Rubar3',
|
||||||
|
'Default Pamhyr2 Rubar 3 version',
|
||||||
|
|
||||||
|
'', '', '',
|
||||||
|
|
||||||
|
'',
|
||||||
|
'{path} @args @input',
|
||||||
|
''
|
||||||
|
)
|
||||||
|
""")
|
||||||
|
self.execute(
|
||||||
|
"UPDATE solver SET cmd_solver=" +
|
||||||
|
f"'{path} @args @input' "
|
||||||
|
"WHERE name='default-Rubar3'"
|
||||||
|
)
|
||||||
|
|
||||||
self.execute(
|
self.execute(
|
||||||
f"UPDATE info SET value='{self._version}' " +
|
f"UPDATE info SET value='{self._version}' " +
|
||||||
"WHERE key='version'"
|
"WHERE key='version'"
|
||||||
|
|
@ -327,14 +356,24 @@ class Config(SQL):
|
||||||
ctor = solver_type_list["mage8"]
|
ctor = solver_type_list["mage8"]
|
||||||
new = ctor("default-mage")
|
new = ctor("default-mage")
|
||||||
new._description = "Default Pamhyr2 mage 8 version"
|
new._description = "Default Pamhyr2 mage 8 version"
|
||||||
new._cmd_solver = f""""@install_dir/mage8/mage{ext}" @args @input"""
|
path = os.path.join("@install_dir", "mage8", "mage")
|
||||||
|
new._cmd_solver = f""""{path}{ext}" @args @input"""
|
||||||
self._solvers.append(new)
|
self._solvers.append(new)
|
||||||
|
|
||||||
# AdisTS
|
# AdisTS
|
||||||
ctor = solver_type_list["adistswc"]
|
ctor = solver_type_list["adistswc"]
|
||||||
new = ctor("default-AdisTS")
|
new = ctor("default-AdisTS")
|
||||||
new._description = "Default Pamhyr2 AdisTS version"
|
new._description = "Default Pamhyr2 AdisTS version"
|
||||||
new._cmd_solver = f""""@install_dir/adists/adists{ext}" @args @input"""
|
path = os.path.join("@install_dir", "adists", "adists")
|
||||||
|
new._cmd_solver = f""""{path}{ext}" @args @input"""
|
||||||
|
self._solvers.append(new)
|
||||||
|
|
||||||
|
# Rubar3
|
||||||
|
ctor = solver_type_list["rubar3"]
|
||||||
|
new = ctor("default-Rubar3")
|
||||||
|
new._description = "Default Pamhyr2 Rubar 3 version"
|
||||||
|
path = os.path.join("@install_dir", "rubar", f"rubar3{ext}")
|
||||||
|
new._cmd_solver = f""""{path}" @args @input"""
|
||||||
self._solvers.append(new)
|
self._solvers.append(new)
|
||||||
|
|
||||||
# Mage fake 7
|
# Mage fake 7
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue