source: issm/oecreview/Archive/15392-16133/ISSM-15831-15832.diff@ 16134

Last change on this file since 16134 was 16134, checked in by Mathieu Morlighem, 12 years ago

Added Archive/15392-16133

File size: 4.6 KB
  • TabularUnified ../trunk-jpl/src/m/mech/steadystateiceshelftemp.py

     
     1import numpy as npy
     2
     3def steadystateiceshelftemp(md,surfacetemp,basaltemp):
     4        """
     5        Compute the depth-averaged steady-state temperature of an ice shelf
     6        This routine computes the depth-averaged temperature accounting for vertical advection
     7        and diffusion of heat into the base of the ice shelf as a function of surface and basal
     8        temperature and the basal melting rate.  Horizontal advection is ignored.
     9   The solution is a depth-averaged version of Equation 25 in Holland and Jenkins (1999).
     10
     11        In addition to supplying md, the surface and basal temperatures of the ice shelf must be supplied in degrees Kelvin.
     12
     13        The model md must also contain the fields:
     14        md.geometry.thickness
     15        md.basalforcings.melting_rate (positive for melting, negative for freezing)
     16
     17   Usage:
     18      temperature=steadystateiceshelftemp(md,surfacetemp,basaltemp)
     19        """
     20
     21        if len(md.geometry.thickness)!=md.mesh.numberofvertices:
     22                raise ValueError('steadystateiceshelftemp error message: thickness should have a length of ' + md.mesh.numberofvertices)
     23       
     24        #surface and basal temperatures in degrees C
     25        if len(surfacetemp)!=md.mesh.numberofvertices:
     26                raise ValueError('steadystateiceshelftemp error message: surfacetemp should have a length of ' + md.mesh.numberofvertices)
     27       
     28        if len(basaltemp)!=md.mesh.numberofvertices:
     29                raise ValueError('steadystateiceshelftemp error message: basaltemp should have a length of ' +md.mesh.numberofvertices)
     30       
     31        # Convert temps to Celsius for Holland and Jenkins (1999) equation
     32        Ts=-273.15+surfacetemp
     33        Tb=-273.15+basaltemp
     34       
     35        Hi=md.geometry.thickness
     36        ki=1.14e-6*md.constants.yts # ice shelf thermal diffusivity from Holland and Jenkins (1999) converted to m^2/yr
     37       
     38        #vertical velocity of ice shelf, calculated from melting rate
     39        wi=md.materials.rho_water/md.materials.rho_ice*md.basalforcings.melting_rate
     40       
     41        #temperature profile is linear if melting rate is zero, depth-averaged temp is simple average in this case
     42        temperature=(Ts+Tb)/2  # where wi~=0
     43       
     44        pos=npy.nonzero(abs(wi)>=1e-4) # to avoid division by zero
     45
     46        npy.seterr(over='raise',divide='raise') # raise errors if floating point exceptions are encountered in following calculation
     47        #calculate depth-averaged temperature (in Celsius)
     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])*npy.exp(Hi[pos]*wi[pos]/ki) )/( Hi[pos]*(npy.exp(Hi[pos]*wi[pos]/ki)-1))
     50        except FloatingPointError:
     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])/npy.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)))
     53       
     54        #temperature should not be less than surface temp
     55        pos=npy.nonzero(temperature<Ts)
     56        temperature[pos]=Ts[pos]
     57       
     58        # NaN where melt rates are too high (infinity/infinity in exponential)
     59        pos=npy.nonzero(npy.isnan(temperature))
     60        temperature[pos]=Ts[pos]
     61       
     62        #convert to Kelvin
     63        temperature=temperature+273.15
     64
     65        return temperature
  • TabularUnified ../trunk-jpl/src/m/mech/steadystateiceshelftemp.m

     
    4545pos=find(abs(wi)>=1e-4); % to avoid division by zero
    4646
    4747%calculate depth-averaged temperature (in Celsius)
    48 temperature(pos)=-( (Tb(pos)-Ts(pos))*ki./wi(pos) + Hi(pos).*Tb(pos) - (Hi(pos).*Ts(pos) + (Tb(pos)-Ts(pos))*ki./wi(pos)).*exp(Hi(pos).*wi(pos)/ki) )./( Hi(pos).*(exp(Hi(pos).*wi(pos)/ki)-1));
    49 %temperature(pos)=-( ((Tb(pos)-Ts(pos))*ki./wi(pos) + Hi(pos).*Tb(pos))./exp(Hi(pos).*wi(pos)/ki) - Hi(pos).*Ts(pos) + (Tb(pos)-Ts(pos))*ki./wi(pos))./( Hi(pos).*(1-exp(-Hi(pos).*wi(pos)/ki)));
     48%temperature(pos)=-( (Tb(pos)-Ts(pos))*ki./wi(pos) + Hi(pos).*Tb(pos) - (Hi(pos).*Ts(pos) + (Tb(pos)-Ts(pos))*ki./wi(pos)).*exp(Hi(pos).*wi(pos)/ki) )./( Hi(pos).*(exp(Hi(pos).*wi(pos)/ki)-1));
     49temperature(pos)=-( ((Tb(pos)-Ts(pos))*ki./wi(pos) + Hi(pos).*Tb(pos))./exp(Hi(pos).*wi(pos)/ki) - Hi(pos).*Ts(pos) + (Tb(pos)-Ts(pos))*ki./wi(pos))./( Hi(pos).*(1-exp(-Hi(pos).*wi(pos)/ki)));
    5050
    5151%temperature should not be less than surface temp
    5252pos=find(temperature<Ts);
Note: See TracBrowser for help on using the repository browser.