Skip to content

Commit

Permalink
errors for bad values
Browse files Browse the repository at this point in the history
  • Loading branch information
yoctoyotta1024 committed Jan 9, 2024
1 parent 5087dc6 commit 8b847c9
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions pySD/thermobinary_src/thermogen.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):

Expand All @@ -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):

Expand Down

0 comments on commit 8b847c9

Please sign in to comment.