source: issm/oecreview/Archive/24684-25833/ISSM-24793-24794.diff@ 25834

Last change on this file since 25834 was 25834, checked in by Mathieu Morlighem, 4 years ago

CHG: added 24684-25833

File size: 3.9 KB
  • ../trunk-jpl/src/m/materials/nye.py

     
    11import numpy as np
     2from warnings import warn
    23
     4
    35def nye(temperature, ice_type):
    4         """
    5    NYE - figure out the rigidity of ice (either CO2 or H2O) for a given temperature
    6         rigidity (in s^(1/n)Pa) is the flow law parameter in the flow law sigma=B*e(1/n) (Nye, p2000).
    7         temperature is in Kelvin degrees
     6    """
     7    NYE - figure out the rigidity of ice (either CO2 or H2O) for a given temperature
     8        rigidity (in s^(1/n)Pa) is the flow law parameter in the flow law sigma=B*e(1/n) (Nye, p2000).
     9        temperature is in Kelvin degrees
    810
    911   Usage:
    10            rigidity=nye(temperature,ice_type) % ice_type = 1: CO2 ice // ice_type = 2: H2O ice
    11         """
     12           rigidity=nye(temperature,ice_type) % ice_type = 1: CO2 ice // ice_type = 2: H2O ice
     13        """
    1214
    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)
     15    # Declaring temperature and rigidity arrays
     16    if np.ndim(temperature) == 2:
     17        T = temperature.flatten()
     18    elif isinstance(temperature, float) or isinstance(temperature, int):
     19        T = np.array([temperature])
     20    else:
     21        T = temperature
     22    rigidity = np.zeros_like(T)
    2123
    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.')
     24    # Beyond-melting-point cases
     25    if (ice_type == 1):
     26        for i in range(len(T)):
     27            if (200 < T[i] < 220):
     28                warn('CO2 ICE - POSSIBLE MELTING. Some temperature values are between 200K and 220K.')
     29            break
     30        if ((T >= 220).any()):
     31            warn('CO2 ICE - GUARANTEED MELTING. Some temperature values are beyond 220K.')
     32    elif (ice_type == 2) and ((T > 273.15).any()):
     33        warn('H2O ICE - GUARANTEED MELTING. Some temperature values are beyond 273.15K.')
    3234
    33         Rg = 8.3144598              # J mol^-1 K^-1
     35    Rg = 8.3144598              # J mol^-1 K^-1
    3436
    35         if ice_type == 1:           # CO2 ice
    36             A_const = 10**(13.0)    # s^-1 MPa
    37             Q = 66900.              # J mol^-1
    38             n = 8.                  # 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')
     37    if ice_type == 1:           # CO2 ice
     38        A_const = 1.0e13    # s^-1 MPa
     39        Q = 66900.              # J mol^-1
     40        n = 8.                  # Glen's exponent
     41    elif ice_type == 2:         # H2O ice
     42        A_const = 9 * 1.0e4       # s^-1 MPa
     43        Q = 60000.              #  J mol^-1
     44        n = 3.                  # Glen's exponent
     45    else:
     46        raise RuntimeError('Ice type not supported')
    4547
    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
     48    # Arrhenius Law
     49    A = A_const * np.exp(-1 * Q / (T * Rg)) # s^-1 MPa
     50    rigidity = A**(-1 / n) * 1.0e6 # s^(1/n) Pa
    4951
    50         # Return output
    51         return rigidity
     52    # Return output
     53    return rigidity
Note: See TracBrowser for help on using the repository browser.