Changeset 21759 for issm/branches/trunk-larour-NatGeoScience2016/src/py3/mech/steadystateiceshelftemp.py
- Timestamp:
- 06/07/17 10:50:54 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/branches/trunk-larour-NatGeoScience2016/src/py3/mech/steadystateiceshelftemp.py
r19895 r21759 1 import numpy as np y1 import numpy as np 2 2 3 3 def steadystateiceshelftemp(md,surfacetemp,basaltemp): … … 42 42 temperature=(Ts+Tb)/2 # where wi~=0 43 43 44 pos=np y.nonzero(abs(wi)>=1e-4) # to avoid division by zero44 pos=np.nonzero(abs(wi)>=1e-4) # to avoid division by zero 45 45 46 np y.seterr(over='raise',divide='raise') # raise errors if floating point exceptions are encountered in following calculation46 np.seterr(over='raise',divide='raise') # raise errors if floating point exceptions are encountered in following calculation 47 47 #calculate depth-averaged temperature (in Celsius) 48 48 try: 49 temperature[pos]=-( (Tb[pos]-Ts[pos])*ki/wi[pos] + Hi[pos]*Tb[pos] - (Hi[pos]*Ts[pos] + (Tb[pos]-Ts[pos])*ki/wi[pos])*np y.exp(Hi[pos]*wi[pos]/ki) )/( Hi[pos]*(npy.exp(Hi[pos]*wi[pos]/ki)-1))49 temperature[pos]=-( (Tb[pos]-Ts[pos])*ki/wi[pos] + Hi[pos]*Tb[pos] - (Hi[pos]*Ts[pos] + (Tb[pos]-Ts[pos])*ki/wi[pos])*np.exp(Hi[pos]*wi[pos]/ki) )/( Hi[pos]*(np.exp(Hi[pos]*wi[pos]/ki)-1)) 50 50 except FloatingPointError: 51 51 print('steadystateiceshelf warning: overflow encountered in multipy/divide/exp, trying another formulation.') 52 temperature[pos]=-( ((Tb[pos]-Ts[pos])*ki/wi[pos] + Hi[pos]*Tb[pos])/np y.exp(Hi[pos]*wi[pos]/ki) - Hi[pos]*Ts[pos] + (Tb[pos]-Ts[pos])*ki/wi[pos])/( Hi[pos]*(1-npy.exp(-Hi[pos]*wi[pos]/ki)))52 temperature[pos]=-( ((Tb[pos]-Ts[pos])*ki/wi[pos] + Hi[pos]*Tb[pos])/np.exp(Hi[pos]*wi[pos]/ki) - Hi[pos]*Ts[pos] + (Tb[pos]-Ts[pos])*ki/wi[pos])/( Hi[pos]*(1-np.exp(-Hi[pos]*wi[pos]/ki))) 53 53 54 54 #temperature should not be less than surface temp 55 pos=np y.nonzero(temperature<Ts)55 pos=np.nonzero(temperature<Ts) 56 56 temperature[pos]=Ts[pos] 57 57 58 58 # NaN where melt rates are too high (infinity/infinity in exponential) 59 pos=np y.nonzero(npy.isnan(temperature))59 pos=np.nonzero(np.isnan(temperature)) 60 60 temperature[pos]=Ts[pos] 61 61
Note:
See TracChangeset
for help on using the changeset viewer.