From 8b847c91d7720d6c6ab37da4952d26b94691ad32 Mon Sep 17 00:00:00 2001 From: Clara Levante Date: Tue, 9 Jan 2024 19:05:07 +0100 Subject: [PATCH] errors for bad values --- pySD/thermobinary_src/thermogen.py | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/pySD/thermobinary_src/thermogen.py b/pySD/thermobinary_src/thermogen.py index fdc5e1507..5b6b68e62 100644 --- a/pySD/thermobinary_src/thermogen.py +++ b/pySD/thermobinary_src/thermogen.py @@ -452,13 +452,19 @@ def __init__(self, configfile, constsfile, self.RGAS_DRY = inputs["RGAS_DRY"] def temp1(self, z): - - return self.TEMP0 - self.TEMPlapses[0] * z + + temp1 = self.TEMP0 - self.TEMPlapses[0] * z + if np.any((temp1 <= 0.0)): + raise ValueError("TEMP > 0.0K") + return temp1 def temp2(self, z): T_Zbase = self.temp1(self.Zbase) # TEMP at Zbase - return T_Zbase - self.TEMPlapses[1] * (z - self.Zbase) + temp2 = T_Zbase - self.TEMPlapses[1] * (z - self.Zbase) + if np.any((temp2 <= 0.0)): + raise ValueError("TEMP > 0.0K") + return temp2 def hydrostatic_pressure(self, P0, integral): @@ -479,12 +485,17 @@ def press2(self, z): def qvap1(self, z): - return self.qvap0 - self.qvaplapses[0] * z + qvap1 = self.qvap0 - self.qvaplapses[0] * z + if np.any((qvap1 <= 0.0)): + raise ValueError("TEMP > 0.0K") + return qvap1 def qvap2(self, z): - qvap_Zbase = self.qvap1(self.Zbase) # qvap at Zbase - return qvap_Zbase - self.qvaplapses[1] * (z - self.Zbase) + qvap2 = qvap_Zbase - self.qvaplapses[1] * (z - self.Zbase) + if np.any((qvap2 <= 0.0)): + raise ValueError("TEMP > 0.0K") + return qvap2 def below_above_zbase(self, zfulls, func1, func2):