Changeset 24101


Ignore:
Timestamp:
07/22/19 14:05:11 (6 years ago)
Author:
schlegel
Message:

CHG: minor updates to nye functions

Location:
issm/trunk-jpl/src/m/materials
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified issm/trunk-jpl/src/m/materials/nye.m

    r24092 r24101  
    33%
    44%   Compute rigidity of ice (either CO2 or H2O) for a given temperature
    5 %   rigidity (in s^(1/3)Pa) is the flow law parameter in the flow law
    6 %   sigma=B*e(1/3) (Nye, p2000).  temperature is in Kelvin degrees
     5%   rigidity (in s^(1/n)Pa) is the flow law parameter in the flow law
     6%   sigma=B*e(1/n) (Nye, p2000).  temperature is in Kelvin degrees
    77%
    88%   Usage:
    99%      rigidity=nye(temperature,ice_type) % ice_type = 1: CO2 ice // ice_type = 2: H2O ice
    10         if ((ice_type == 1) && (any(temperature > 195)))
    11                 error('Input temperature for CO2 ice out of bounds (T>195)');
    12         elseif ((ice_type == 2) && (any(temperature > 273.15)))
    13                 error('Input temperature for H2O ice out of bounds (T>273.15)');
     10
     11        % Beyond-melting-point cases
     12        warning OFF BACKTRACE
     13        if (ice_type==1)
     14                if (any(temperature>200&temperature<220))
     15                        warning('CO2 ICE - POSSIBLE MELTING. Some temperature values are between 200K and 220K.\nLook at indexes: %s', mat2str(find(temperature>200 & temperature<220))');
     16                end
     17                if (any(temperature>=220))
     18                        warning('CO2 ICE - GUARANTEED MELTING. Some temperature values are beyond 220K.\nLook at indexes: %s', mat2str(find(temperature>=220))');
     19                end
     20        elseif ((ice_type==2)&&(any(temperature>273.15)))
     21                warning('H2O ICE - GUARANTEED MELTING. Some temperature values are beyond 273.15K.\nLook at indexes: %s', mat2str(find(temperature>273.15))');
    1422        end
    1523
    16         Rg = 8.3144598; % J mol^-1 K^-1
     24        % Coefficients
     25        Rg=8.3144598;       % J mol^-1 K^-1
    1726
    18         if(ice_type==1) %CO2 ice
    19                 A_const = 10^(10.8); % s^-1 MPa
    20                 Q       = 63000;     % J mol^-1
    21                 n       = 7;         % Glen's exponent
    22 
     27        if(ice_type==1)     % CO2 ice
     28                A_const     = 10^(10.8);    % s^-1 MPa
     29                Q           = 63000;        % J mol^-1
     30                n           = 7;            % Glen's exponent
    2331        elseif(ice_type==2) % H2O ice
    24                 A_const = 9e4;   % s^-1 MPa
    25                 Q       = 60000; % J mol^-1
    26                 n       = 3;     % Glen's exponent
    27 
     32                A_const     = 9e4;          % s^-1 MPa
     33                Q           = 60000;        % J mol^-1
     34                n           = 3;            % Glen's exponent
    2835        else
    29                 error('ice type not supported');
     36                error('Ice type not supported');
    3037        end
    3138
    32         %Arhenius law
    33         A = A_const*exp(-Q./(temperature*Rg)); % s^-1 MPa
    34         rigidity = A.^(-1/n)*1e6; % s^(1/n) Pa
     39        % Arrhenius Law
     40        A=A_const*exp(-Q./(temperature*Rg)); % s^-1 MPa
     41        rigidity=A.^(-1/n)*1e6;              % s^(1/n) Pa
    3542
    3643end
  • TabularUnified issm/trunk-jpl/src/m/materials/nye.py

    r24096 r24101  
    44        """
    55   NYE - figure out the rigidity of ice (either CO2 or H2O) for a given temperature
    6         rigidity (in s^(1/3)Pa) is the flow law parameter in the flow law sigma=B*e(1/3) (Nye, p2000).
     6        rigidity (in s^(1/n)Pa) is the flow law parameter in the flow law sigma=B*e(1/n) (Nye, p2000).
    77        temperature is in Kelvin degrees
    88
     
    1111        """
    1212
    13         if (ice_type == 1) and (np.any(temperature > 195)):
    14                 raise RuntimeError("Input temperature for CO2 ice out of bounds (T>195)")
    15         elif (ice_type == 2) and (np.any(temperature > 273)):
    16                 raise RuntimeError("Input temperature for H2O ice out of bounds (T>273)")
     13        # Declaring temperature and rigidity arrays
     14        if np.ndim(temperature)==2:
     15            T=temperature.flatten()
     16        elif isinstance(temperature,float) or isinstance(temperature,int):
     17            T=np.array([temperature])
     18        else:
     19            T=temperature
     20        rigidity=np.zeros_like(T)
     21
     22        # Beyond-melting-point cases
     23        if (ice_type==1):
     24            for i in range(len(T)):
     25                if (200<T[i]<220):
     26                    warnings.warn('CO2 ICE - POSSIBLE MELTING. Some temperature values are between 200K and 220K.')
     27                break
     28            if ((T>=220).any()):
     29                warnings.warn('CO2 ICE - GUARANTEED MELTING. Some temperature values are beyond 220K.')
     30        elif (ice_type==2) and ((T>273.15).any()):
     31            warnings.warn('H2O ICE - GUARANTEED MELTING. Some temperature values are beyond 273.15K.')
    1732
    1833        Rg = 8.3144598 # J mol^-1 K^-1
    1934
    20         if np.ndim(temperature)==2:
    21                 T = temperature.flatten()
    22         elif isinstance(temperature,float) or isinstance(temperature,int):
    23                 T = np.array([temperature])
    24         else:
    25                 T = temperature
    26                
    27         B=np.zeros_like(T)
     35        if ice_type == 1: # CO2 ice
     36            A_const = 10**(10.8) # s^-1 MPa
     37            Q = 63000. # J mol^-1
     38            n = 7. # Glen's exponent
     39        elif ice_type == 2: # H2O ice
     40            A_const = 9*10**4 # s^-1 MPa
     41            Q = 60000. #  J mol^-1
     42            n = 3. # Glen's exponent
     43        else:
     44            raise RuntimeError('Ice type not supported')
    2845
    29         if ice_type == 1: # CO2 ice
    30                 A_const = 10**(10.8) # s^-1 MPa
    31                 Q = 63000. # J mol^-1
    32                 n = 7. # Glen's exponent
     46        # Arrhenius Law
     47        A=A_const*np.exp(-1*Q/(T*Rg)) # s^-1 MPa
     48        rigidity=A**(-1/n)*10**6 # s^(1/n) Pa
    3349
    34         if ice_type == 2: # H2O ice
    35                 A_const = 9*10**4 # s^-1 MPa
    36                 Q = 60000. #  J mol^-1
    37                 n = 3. # Glen's exponent
    38 
    39         A = A_const*np.exp(-1*Q/(T*Rg)) # s^-1 MPa
    40         rigidity = A**(-1/n)*10**6 # s^(1/n) Pa
    41 
    42         return rigidity
     50        # Return output
     51        return rigidity
Note: See TracChangeset for help on using the changeset viewer.