mirror of https://gitlab.com/pamhyr/pamhyr2
Export files 1
parent
1e4761609d
commit
bd4222adfa
|
|
@ -57,6 +57,10 @@ class D90AdisTSList(PamhyrModelList):
|
|||
self._status.modified()
|
||||
return n
|
||||
|
||||
@property
|
||||
def D90_AdisTS_List(self):
|
||||
return self.lst
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -57,6 +57,10 @@ class DIFAdisTSList(PamhyrModelList):
|
|||
self._status.modified()
|
||||
return n
|
||||
|
||||
@property
|
||||
def DIF_AdisTS_List(self):
|
||||
return self.lst
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -57,6 +57,10 @@ class InitialConditionsAdisTSList(PamhyrModelList):
|
|||
self._status.modified()
|
||||
return n
|
||||
|
||||
@property
|
||||
def Initial_Conditions_List(self):
|
||||
return self.lst
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ class Study(SQLModel):
|
|||
StudyNetworkReachChecker(),
|
||||
StudyGeometryChecker(),
|
||||
StudyInitialConditionsChecker(),
|
||||
StudyBoundaryConditionChecker(),
|
||||
#StudyBoundaryConditionChecker(),
|
||||
# DummyOK(),
|
||||
# DummyWARNING(),
|
||||
# DummyERROR(),
|
||||
|
|
|
|||
|
|
@ -182,7 +182,145 @@ class AdisTSlc(AdisTS):
|
|||
|
||||
return lst
|
||||
|
||||
def _export_POLs(self, study, repertory, qlog=None, name="0"):
|
||||
|
||||
files = []
|
||||
|
||||
if qlog is not None:
|
||||
qlog.put("Export POLS files")
|
||||
|
||||
pollutants = study.river.Pollutants.Pollutants_List
|
||||
|
||||
for pollutant in pollutants:
|
||||
name = pollutant.name
|
||||
with adists_file_open(os.path.join(repertory, f"{name}.POL"), "w+") as f:
|
||||
files.append(f"{name}.POL")
|
||||
f.write(f"*Polluant A contaminé aux PCB\n")
|
||||
f.write(f"name = {name}\n")
|
||||
|
||||
self._export_POL_Characteristics(study, pollutant._data, f, qlog)
|
||||
|
||||
POL_ICs = next(filter(lambda ic: ic.pollutant == pollutant.id,\
|
||||
study.river.initial_conditions_adists.Initial_Conditions_List))
|
||||
|
||||
if POL_ICs.concentration != None:
|
||||
self._export_ICs_AdisTS(study, repertory, POL_ICs, qlog, name)
|
||||
|
||||
return files
|
||||
|
||||
def _export_ICs_AdisTS(self, study, repertory, POL_IC_default, qlog, POL_name):
|
||||
|
||||
if qlog is not None:
|
||||
qlog.put("Export POL ICs files")
|
||||
|
||||
with adists_file_open(os.path.join(repertory, f"{POL_name}.INI"), "w+") as f:
|
||||
f.write(f"*État initial pour le polluant {POL_name}\n")
|
||||
f.write(f"{POL_IC_default.name} = {POL_IC_default.concentration} {POL_IC_default.eg} "+
|
||||
f"{POL_IC_default.em} {POL_IC_default.ed}\n")
|
||||
|
||||
def _export_POL_Characteristics(self, study, pol_data, f, qlog, name="0"):
|
||||
|
||||
list_characteristics = ["type", "diametre", "rho", "porosity", "cdc_riv", "cdc_cas", "apd", "ac", "bc"]
|
||||
|
||||
if len(list_characteristics) == (len(pol_data[0])-1):
|
||||
for l in range(len(list_characteristics)):
|
||||
f.write(f"{list_characteristics[l]} = {pol_data[0][l]}\n")
|
||||
|
||||
def _export_D90(self, study, repertory, qlog=None, name="0"):
|
||||
|
||||
files = []
|
||||
|
||||
if qlog is not None:
|
||||
qlog.put("Export D90 file")
|
||||
|
||||
with adists_file_open(os.path.join(repertory, f"{name}.D90"), "w+") as f:
|
||||
files.append(f"{name}.D90")
|
||||
|
||||
f.write(f"*Diamètres caractéristiques du fond stable\n")
|
||||
|
||||
d90AdisTS = study.river.d90_adists.D90_AdisTS_List
|
||||
|
||||
f.write(f"{d90AdisTS[0].name} = {d90AdisTS[0].d90}\n")
|
||||
|
||||
self._export_d90_spec(study, d90AdisTS[0]._data, f, qlog)
|
||||
|
||||
return files
|
||||
|
||||
def _export_d90_spec(self, study, d90_spec_data, f, qlog, name="0"):
|
||||
|
||||
for d90_spec in d90_spec_data:
|
||||
if (d90_spec.name is None) or (d90_spec.reach is None) or (d90_spec.start_kp is None) or \
|
||||
(d90_spec.end_kp is None) or (d90_spec.d90 is None):
|
||||
return
|
||||
|
||||
edges = study.river.enable_edges()
|
||||
|
||||
id_edges = list(map(lambda x: x.id, edges))
|
||||
|
||||
id_reach = d90_spec.reach
|
||||
|
||||
if id_reach not in id_edges:
|
||||
return
|
||||
|
||||
f.write(f"{d90_spec.name} = {id_reach} {d90_spec.start_kp} {d90_spec.end_kp} {d90_spec.d90}\n")
|
||||
|
||||
def _export_DIF(self, study, repertory, qlog=None, name="0"):
|
||||
|
||||
files = []
|
||||
|
||||
if qlog is not None:
|
||||
qlog.put("Export DIF file")
|
||||
|
||||
with adists_file_open(os.path.join(repertory, f"{name}.DIF"), "w+") as f:
|
||||
files.append(f"{name}.DIF")
|
||||
|
||||
f.write(f"*Définition des paramètres des fonctions de calcul du\n")
|
||||
f.write(f"*coefficient de diffusion\n")
|
||||
|
||||
difAdisTS = study.river.dif_adists.DIF_AdisTS_List
|
||||
|
||||
if difAdisTS[0].method != "generique":
|
||||
f.write(f"defaut = {difAdisTS[0].method} {difAdisTS[0].dif }\n")
|
||||
else:
|
||||
f.write(f"defaut = {difAdisTS[0].method} {difAdisTS[0].dif} {difAdisTS[0].b} {difAdisTS[0].c}\n")
|
||||
|
||||
self._export_dif_spec(study, difAdisTS[0]._data, f, qlog)
|
||||
|
||||
return files
|
||||
|
||||
def _export_dif_spec(self, study, dif_spec_data, f, qlog, name="0"):
|
||||
|
||||
for dif_spec in dif_spec_data:
|
||||
if (dif_spec.reach is None) or (dif_spec.start_kp is None) or \
|
||||
(dif_spec.end_kp is None) or (dif_spec.dif is None) or (dif_spec.b is None) or (dif_spec.c is None):
|
||||
return
|
||||
|
||||
edges = study.river.enable_edges()
|
||||
|
||||
id_edges = list(map(lambda x: x.id, edges))
|
||||
|
||||
id_reach = dif_spec.reach
|
||||
|
||||
if id_reach not in id_edges:
|
||||
return
|
||||
|
||||
if dif_spec.method != "generique":
|
||||
f.write(f"{dif_spec.method} = {id_reach} {dif_spec.start_kp} {dif_spec.end_kp} {dif_spec.dif}\n")
|
||||
else:
|
||||
f.write(f"{dif_spec.method} = {id_reach} {dif_spec.start_kp} {dif_spec.end_kp} {dif_spec.dif}" +
|
||||
f"{dif_spec.b} {dif_spec.c}\n")
|
||||
|
||||
def _export_NUM(self, study, repertory, qlog=None, name="0"):
|
||||
|
||||
dict_names = {"init_time":"start_date",
|
||||
"final_time":"end_date",
|
||||
"timestep":"dt0",
|
||||
"implicitation_parameter":"theta",
|
||||
"timestep_screen":"dtscr",
|
||||
"timestep_bin":"dtbin",
|
||||
"timestep_csv":"dtcsv",
|
||||
"timestep_mage":"dtMage",
|
||||
"initial_concentration":"c_initiale"}
|
||||
files = []
|
||||
|
||||
if qlog is not None:
|
||||
|
|
@ -202,7 +340,8 @@ class AdisTSlc(AdisTS):
|
|||
f"export: NUM: {name}: {value} ({p.value})"
|
||||
)
|
||||
|
||||
f.write(f"{name} {value}\n")
|
||||
if name != "command_line_arguments":
|
||||
f.write(f"{dict_names[name]} = {value}\n")
|
||||
|
||||
outputkps = study.river.Output_kp_adists.OutputKp_List
|
||||
|
||||
|
|
@ -231,6 +370,9 @@ class AdisTSlc(AdisTS):
|
|||
def export_func_dict(self):
|
||||
return [
|
||||
self._export_NUM,
|
||||
self._export_DIF,
|
||||
self._export_D90,
|
||||
self._export_POLs,
|
||||
]
|
||||
|
||||
|
||||
|
|
|
|||
Binary file not shown.
Loading…
Reference in New Issue