diff --git a/src/Model/Geometry/Reach.py b/src/Model/Geometry/Reach.py index 7458f3b1eff25849ab42f03e7823a4f3aee09fe4..782556532d374f8c58c2bdc0ea3453cf1a7d3839 100644 --- a/src/Model/Geometry/Reach.py +++ b/src/Model/Geometry/Reach.py @@ -364,6 +364,26 @@ class Reach(SQLSubModel): else: return 0.0 + def inter_profiles_kp(self): + res_kp = [self.profile(0).kp] + + profiles = iter(self.profiles) + previous = next(profile) + + for profile in profiles: + prev = previous.kp + curr = profile.kp + + diff = abs(previous.kp - profile.kp) + + new = previous.kp + (diff / 2.0) + res_kp.append(new) + + previous = profile + + res_kp.append(self.profile(len(self) - 1).kp) + return res_kp + # Sediment Layers def get_sl(self): diff --git a/src/Solver/RubarBE.py b/src/Solver/RubarBE.py index a6df9d3377eacc6db852e15a9ea01e34977bd2a9..66386c11802944acfadddb189a76880e1ff3560d 100644 --- a/src/Solver/RubarBE.py +++ b/src/Solver/RubarBE.py @@ -195,3 +195,40 @@ class RubarBE(CommandLineSolver): ) ind += 1 + + def _export_mail(self, study, repertory, files, qlog, name="0"): + if qlog is not None: + qlog.put("Export MAIL file") + + with open( + os.path.join( + repertory, f"mail.{name}" + ), "w+" + ) as f: + for edge in study.river.enable_edges(): + lm = len(edge) + 1 + + f.write(f"{lm:>13}") + + # TMAIL + ind = 0 + for inter in edge.reach.inter_profiles_kp(): + f.write(f"{inter:15.3f}") + + ind += 1 + if ind % 3 == 0: + f.write("\n") + + # New line (if last iteration do not finish with new + # line) + if ind % 3 != 0: + f.write("\n") + + # XTMAIL + ind = 0 + for profile in edge.reach.profiles: + f.write(f" {profile.kp:15.3f} ") + + ind += 1 + if ind % 3 == 0: + f.write("\n")