Changeset 26358


Ignore:
Timestamp:
07/24/21 17:33:34 (4 years ago)
Author:
jdquinn
Message:

CHG: Completed MATLAB -> Python updates for SE; archive updates now that GMSH can be used on macOS and Linux; various minor bug fixes; formatting; cleanup

Location:
issm/trunk-jpl
Files:
3 deleted
118 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified issm/trunk-jpl/jenkins/pine_island-mac-solid_earth

    r26270 r26358  
    8686# - Excluding 2006 until it can be debugged (file I/O)
    8787#
    88 MATLAB_NROPTIONS="'benchmark','slc','exclude',[2002 2003 2004 2005 2006 2007 2010 2011 2021 2051 2052 2053 2084 2085 2101 2424 2425]"
    89 PYTHON_NROPTIONS="--benchmark slc --exclude 2002 2003 2004 2005 2006 2007 2010 2011 2021 2051 2052 2053 2084 2085 2101 2424 2425"
     88MATLAB_NROPTIONS="'benchmark','slc','exclude',[2004 2006 2051 2052 2053 2084 2085 2424 2425]"
     89PYTHON_NROPTIONS="--benchmark slc --exclude 2004 2006 2051 2052 2053 2084 2085 2424 2425"
  • TabularUnified issm/trunk-jpl/jenkins/ross-debian_linux-solid_earth

    r26270 r26358  
    8686#
    8787# NOTE:
    88 # - Tests 2002, 2003, 2005, 2010, 2101, and 2021 are excluded as Gmsh produces
    89 # different-sized meshes on macOS and Linux for 3d objects (archives are
    90 # generated on macOS).
    9188# - Excluding 2006 until it can be debugged (PETSc crash)
    9289#
    93 MATLAB_NROPTIONS="'benchmark','slc','exclude',[2004 2005 2006 2007 2010 2011 2021 2051 2052 2053 2084 2085 2101 2424 2425]"
    94 PYTHON_NROPTIONS="--benchmark slc --exclude 2004 2005 2006 2007 2010 2011 2021 2051 2052 2053 2084 2085 2101 2424 2425"
     90MATLAB_NROPTIONS="'benchmark','slc','exclude',[2004 2006 2007 2051 2052 2053 2084 2085 2424 2425]"
     91PYTHON_NROPTIONS="--benchmark slc --exclude 2004 2006 2007 2051 2052 2053 2084 2085 2424 2425"
  • TabularUnified issm/trunk-jpl/packagers/linux/package-issm-linux-binaries-matlab.sh

    r25902 r26358  
    3030LIBGFORTRAN="/usr/lib/x86_64-linux-gnu/libgfortran.so.5.0.0" # Important that this is the library itself
    3131LIBGFORTRAN_DIST="${ISSM_DIR}/lib/libgfortran.so.5" # Important the file name matches the SONAME entry in the binaries and other shared libraries which link to it
    32 MATLAB_NROPTIONS="'benchmark','all','exclude',[125,126,234,235,418,420,435,444,445,701,702,703,1101,1102,1103,1104,1105,1106,1107,1108,1109,1110,1201,1202,1203,1204,1205,1206,1207,1208,1301,1302,1303,1304,1401,1402,1601,1602,2002,2003,2005,2006,2010,2020,2021,2051,2052,2053,2101,2102,3001:3200,3201,3202,3300,3480,3481,4001,4002,4003]" # NOTE: Combination of test suites from basic, Dakota, and Solid Earth builds, with tests that require a restart and those that require the JVM excluded
     32MATLAB_NROPTIONS="'benchmark','all','exclude',[125,126,234,235,418,420,435,444,445,701,702,703,1101,1102,1103,1104,1105,1106,1107,1108,1109,1110,1201,1202,1203,1204,1205,1206,1207,1208,1301,1302,1303,1304,1401,1402,1601,1602,2004,2006,2007,2011,2051,2052,2053,2084,2085,2424,2425,3001:3200,3201,3202,3300,3480,3481,4001,4002,4003]" # NOTE: Combination of test suites from basic, Dakota, and Solid Earth builds, with tests that require a restart and those that require the JVM excluded
    3333MATLAB_PATH="/usr/local/MATLAB/R2019b"
    3434
  • TabularUnified issm/trunk-jpl/packagers/linux/package-issm-linux-binaries-python.sh

    r25902 r26358  
    3030LIBGFORTRAN="/usr/lib/x86_64-linux-gnu/libgfortran.so.5.0.0" # Important that this is the library itself
    3131LIBGFORTRAN_DIST="${ISSM_DIR}/lib/libgfortran.so.5" # Important the file name matches the SONAME entry in the binaries and other shared libraries which link to it
    32 PYTHON_NROPTIONS="--benchmark all --exclude 125 126 234 235 418 420 435 444 445 701 702 703 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1201 1202 1203 1204 1205 1206 1207 1208 1301 1302 1303 1304 1401 1402 1601 1602 2002 2003 2005 2006 2010 2020 2021 2051 2052 2053 2101 2102 3001:3200 3201 3202 3300 3480 3481 4001 4002 4003" # NOTE: Combination of test suites from basic, Dakota, and Solid Earth builds, with tests that require a restart and those that require the JVM excluded
     32PYTHON_NROPTIONS="--benchmark all --exclude 125 126 234 235 418 420 435 444 445 701 702 703 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1201 1202 1203 1204 1205 1206 1207 1208 1301 1302 1303 1304 1401 1402 1601 1602 2004 2006 2007 2051 2052 2053 2084 2085 2424 2425 3001:3200 3201 3202 3300 3480 3481 4001 4002 4003" # NOTE: Combination of test suites from basic, Dakota, and Solid Earth builds, with tests that require a restart and those that require the JVM excluded
    3333
    3434## Environment
  • TabularUnified issm/trunk-jpl/packagers/mac/test-issm-mac-binaries-matlab.sh

    r25780 r26358  
    1111#
    1212INSTALL_DIR=.
    13 MATLAB_NROPTIONS="'benchmark','all','exclude',[125,126,234,235,418,420,435,444,445,701,702,703,1101,1102,1103,1104,1105,1106,1107,1108,1109,1110,1201,1202,1203,1204,1205,1206,1207,1208,1301,1302,1303,1304,1401,1402,1601,1602,2006,2020,2021,2051,2052,2053,3001:3200,3201,3202,3300,3480,3481,4001,4002,4003]" # NOTE: Combination of test suites from basic, Dakota, and Solid Earth builds, with tests that require a restart and those that require the JVM excluded
     13MATLAB_NROPTIONS="'benchmark','all','exclude',[125,126,234,235,418,420,435,444,445,701,702,703,1101,1102,1103,1104,1105,1106,1107,1108,1109,1110,1201,1202,1203,1204,1205,1206,1207,1208,1301,1302,1303,1304,1401,1402,1601,1602,2004,2006,2051,2052,2053,2084,2085,2424,2425,3001:3200,3201,3202,3300,3480,3481,4001,4002,4003]" # NOTE: Combination of test suites from basic, Dakota, and Solid Earth builds, with tests that require a restart and those that require the JVM excluded
    1414MATLAB_PATH="/Applications/MATLAB_R2018a.app"
    1515PKG="ISSM-macOS-MATLAB"
  • TabularUnified issm/trunk-jpl/packagers/mac/test-issm-mac-binaries-python.sh

    r25780 r26358  
    1212INSTALL_DIR=.
    1313PKG="ISSM-macOS-Python"
    14 PYTHON_NROPTIONS="--benchmark all --exclude 125 126 234 235 418 420 435 444 445 701 702 703 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1201 1202 1203 1204 1205 1206 1207 1208 1301 1302 1303 1304 1401 1402 1601 1602 2006 2020 2021 2051 2052 2053 3001:3200 3201 3202 3300 3480 3481 4001 4002 4003" # NOTE: Combination of test suites from basic, Dakota, and Solid Earth builds, with tests that require a restart and those that require the JVM excluded
     14PYTHON_NROPTIONS="--benchmark all --exclude 125 126 234 235 418 420 435 444 445 701 702 703 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1201 1202 1203 1204 1205 1206 1207 1208 1301 1302 1303 1304 1401 1402 1601 1602 2004 2006 2007 2051 2052 2053 2084 2085 2424 2425 3001:3200 3201 3202 3300 3480 3481 4001 4002 4003" # NOTE: Combination of test suites from basic, Dakota, and Solid Earth builds, with tests that require a restart and those that require the JVM excluded
    1515
    1616COMPRESSED_PKG="${PKG}.zip"
  • TabularUnified issm/trunk-jpl/src/m/archive/arch.py

    r24261 r26358  
    66
    77def archwrite(filename, *args):  # {{{
    8     """
    9     ARCHWRITE - Write data to a field, given the file name, field name, and data.
    10         Usage:
    11             archwrite('archive101.arch', 'variable_name', data)
     8    """ARCHWRITE - Write data to a field, given the file name, field name, and data.
     9
     10    Usage:
     11        archwrite('archive101.arch', 'variable_name', data)
    1212    """
    1313
     
    4545
    4646def archread(filename, fieldname):  # {{{
    47     """
    48     ARCHREAD - Given an arch file name, and a field name, find and return the data
    49                     associated with that field name.
    50         Usage:
    51             archread('archive101.arch', 'field_var_1')
     47    """ARCHREAD - Given an arch file name, and a field name, find and return
     48    the data associated with that field name.
     49
     50    Usage:
     51        archread('archive101.arch', 'field_var_1')
    5252    """
    5353    try:
     
    7676
    7777def archdisp(filename):  # {{{
    78     """
    79     ARCHDISP - Given an arch filename, display the contents of that file
    80 
    81         Usage:
    82             archdisp('archive101.arch')
     78    """ARCHDISP - Given an arch filename, display the contents of that file
     79
     80    Usage:
     81        archdisp('archive101.arch')
    8382    """
    8483    try:
     
    9796        print(('\t\tSize:\t\t{0}'.format(result['size'])))
    9897        print(('\t\tDatatype:\t{0}'.format(result['data_type'])))
    99     # go to next result
     98        # go to next result
    10099        result = read_field(fid)
    101100    # close file
     
    106105# Helper functions
    107106def write_field_name(fid, data):  # {{{
    108     """
    109     Routine to write field name (variable name) to an archive file.
     107    """Routine to write field name (variable name) to an archive file.
    110108    """
    111109    # write the length of the record
     
    125123
    126124def write_scalar(fid, data):  # {{{
    127     """
    128     Procedure to write a double to an arch file pointed to by fid
     125    """Procedure to write a double to an arch file pointed to by fid
    129126    """
    130127    # write length of record
     
    141138
    142139def write_vector(fid, data):  # {{{
    143     """
    144     Procedure to write a np.array to an arch file
     140    """Procedure to write a np.array to an arch file
    145141    """
    146142    # Make sure our vector is the correct shape.
     
    161157    reclen = 4 + 4 + 4 + 8 * sz[0] * sz[1]
    162158    # make sure we can fit data into file
    163     if reclen > 2**31:
     159    if reclen > pow(2, 31):
    164160        raise ValueError("archwrite error : can not write vector to binary file because it is too large")
    165161    fid.write(struct.pack('>i', reclen))
     
    176172
    177173def read_field(fid):  # {{{
    178     """
    179     Procedure to read a field and return a results list with the following attributes:
    180     result['field_name']     -> the name of the variable that was just read
    181     result['size']             -> size (dimensions) of the variable just read
    182     result['data_type']     -> the type of data that was just read
    183     result['data']             -> the actual data
     174    """Procedure to read a field and return a results list with the following
     175    attributes:
     176
     177        result['field_name']    -> the name of the variable that was just read
     178        result['size']          -> size (dimensions) of the variable just read
     179        result['data_type']     -> the type of data that was just read
     180        result['data']          -> the actual data
    184181    """
    185182
    186183    try:
    187184        # first, read the string
    188         #first read the size and continue reading
    189         struct.unpack('>i', fid.read(struct.calcsize('>i')))[0]  #name length
     185        # first read the size and continue reading
     186        struct.unpack('>i', fid.read(struct.calcsize('>i')))[0]  # name length
    190187        check_name = struct.unpack('>i', fid.read(struct.calcsize('>i')))[0]
    191188        if check_name != 1:
     
    194191        fieldname = struct.unpack('>{}s'.format(namelen), fid.read(namelen))[0]
    195192        # then, read the data
    196         #first read the size and continue reading
    197         struct.unpack('>i', fid.read(struct.calcsize('>i')))[0]  #data length
     193        # first read the size and continue reading
     194        struct.unpack('>i', fid.read(struct.calcsize('>i')))[0]  # data length
    198195        data_type = struct.unpack('>i', fid.read(struct.calcsize('>i')))[0]
    199196
     
    235232
    236233
    237 def format_archive_code(format):  # {{{
    238     """
    239     Given a variable, determine it's type and return
    240     an integer value:
    241 
    242     1 : string
    243     2 : double (scalar)
    244     3 : vector or matrix (of type double)
    245 
    246     """
    247     if isinstance(format, str):
     234def format_archive_code(var):  # {{{
     235    """Given a variable, determine it's type and return an integer value:
     236
     237        1 : string
     238        2 : double (scalar)
     239        3 : vector or matrix (of type double)
     240    """
     241    if isinstance(var, str):
    248242        code = 1
    249     elif format.shape[0] == 1 and format.shape[1] == 1:
     243    elif var.shape[0] == 1 and var.shape[1] == 1:
    250244        code = 2
    251     elif isinstance(format, (list, tuple, np.ndarray)):
     245    elif isinstance(var, (list, tuple, np.ndarray)):
    252246        code = 3
    253247    else:
    254         raise TypeError("archwrite error: data type '%s' is not valid." % type(format))
     248        raise TypeError('archwrite error: data type {} is not valid.'.format(type(var)))
    255249    return code
    256250    # }}}
  • TabularUnified issm/trunk-jpl/src/m/boundaryconditions/SetIceSheetBC.py

    r26059 r26358  
    1111    """
    1212
    13     #node on Dirichlet
     13    # node on Dirichlet
    1414    pos = np.nonzero(md.mesh.vertexonboundary)
    15     md.stressbalance.spcvx = float('nan') * np.ones((md.mesh.numberofvertices))
    16     md.stressbalance.spcvy = float('nan') * np.ones((md.mesh.numberofvertices))
    17     md.stressbalance.spcvz = float('nan') * np.ones((md.mesh.numberofvertices))
     15    md.stressbalance.spcvx = np.nan * np.ones((md.mesh.numberofvertices))
     16    md.stressbalance.spcvy = np.nan * np.ones((md.mesh.numberofvertices))
     17    md.stressbalance.spcvz = np.nan * np.ones((md.mesh.numberofvertices))
    1818    md.stressbalance.spcvx[pos] = 0
    1919    md.stressbalance.spcvy[pos] = 0
    2020    md.stressbalance.spcvz[pos] = 0
    21     md.stressbalance.referential = float('nan') * np.ones((md.mesh.numberofvertices, 6))
     21    md.stressbalance.referential = np.nan * np.ones((md.mesh.numberofvertices, 6))
    2222    md.stressbalance.loadingforce = 0 * np.ones((md.mesh.numberofvertices, 3))
    2323
    24     #Dirichlet Values
     24    # Dirichlet Values
    2525    if isinstance(md.inversion.vx_obs, np.ndarray) and np.size(md.inversion.vx_obs, axis=0) == md.mesh.numberofvertices and isinstance(md.inversion.vy_obs, np.ndarray) and np.size(md.inversion.vy_obs, axis=0) == md.mesh.numberofvertices:
    26         print("      boundary conditions for stressbalance model: spc set as observed velocities")
     26        print('      boundary conditions for stressbalance model: spc set as observed velocities')
    2727        md.stressbalance.spcvx[pos] = md.inversion.vx_obs[pos]
    2828        md.stressbalance.spcvy[pos] = md.inversion.vy_obs[pos]
    2929    else:
    30         print("      boundary conditions for stressbalance model: spc set as zero")
     30        print('      boundary conditions for stressbalance model: spc set as zero')
    3131
    32     #No ice front -> do nothing
     32    # No ice front -> do nothing
    3333
    34     #Initialize surface and basal forcings
     34    # Initialize surface and basal forcings
    3535    md.smb.initialize(md)
    3636    md.basalforcings.initialize(md)
    3737
    38     #Initialize ocean forcings and sealevel
     38    # Initialize ocean forcings and sealevel
    3939    md.dsl.initialize(md)
    4040
    41     #Deal with other boundary conditions
     41    # Deal with other boundary conditions
    4242    if np.all(np.isnan(md.balancethickness.thickening_rate)):
    4343        md.balancethickness.thickening_rate = np.zeros((md.mesh.numberofvertices))
    44         print("      no balancethickness.thickening_rate specified: values set as zero")
    45     md.masstransport.spcthickness = float('nan') * np.ones((md.mesh.numberofvertices))
    46     md.balancethickness.spcthickness = float('nan') * np.ones((md.mesh.numberofvertices))
    47     md.damage.spcdamage = float('nan') * np.ones((md.mesh.numberofvertices))
     44        print('      no balancethickness.thickening_rate specified: values set as zero')
     45    md.masstransport.spcthickness = np.nan * np.ones((md.mesh.numberofvertices))
     46    md.balancethickness.spcthickness = np.nan * np.ones((md.mesh.numberofvertices))
     47    md.damage.spcdamage = np.nan * np.ones((md.mesh.numberofvertices))
    4848
    4949    if isinstance(md.initialization.temperature, np.ndarray) and np.size(md.initialization.temperature, axis=0) == md.mesh.numberofvertices:
    50         md.thermal.spctemperature = float('nan') * np.ones((md.mesh.numberofvertices))
     50        md.thermal.spctemperature = np.nan * np.ones((md.mesh.numberofvertices))
    5151        if hasattr(md.mesh, 'vertexonsurface'):
    5252            pos = np.nonzero(md.mesh.vertexonsurface)[0]
    53             md.thermal.spctemperature[pos] = md.initialization.temperature[pos]  #impose observed temperature on surface
     53            md.thermal.spctemperature[pos] = md.initialization.temperature[pos]  # impose observed temperature on surface
    5454        if not isinstance(md.basalforcings.geothermalflux, np.ndarray) or not np.size(md.basalforcings.geothermalflux) == md.mesh.numberofvertices:
    55             md.basalforcings.geothermalflux = 50. * 10**-3 * np.ones((md.mesh.numberofvertices))  #50 mW / m^2
     55            md.basalforcings.geothermalflux = 50.0 * pow(10, -3) * np.ones((md.mesh.numberofvertices))  # 50 mW/m^2
    5656    else:
    57         print("      no thermal boundary conditions created: no observed temperature found")
     57        print('      no thermal boundary conditions created: no observed temperature found')
    5858
    5959    return md
  • TabularUnified issm/trunk-jpl/src/m/boundaryconditions/SetMarineIceSheetBC.py

    r26352 r26358  
    2424    #node on Dirichlet (boundary and ~icefront)
    2525    if icefrontfile:
    26         #User provided Front.exp, use it
     26        # User provided Front.exp, use it
    2727        if not os.path.exists(icefrontfile):
    28             raise IOError("SetMarineIceSheetBC error message: ice front file '%s' not found." % icefrontfile)
     28            raise IOError('SetMarineIceSheetBC error message: ice front file \'{}\' not found.'.format(icefrontfile))
    2929        incontour = ContourToMesh(md.mesh.elements, md.mesh.x, md.mesh.y, icefrontfile, 'node', 2)
    3030        vertexonicefront = np.logical_and(md.mesh.vertexonboundary, incontour.reshape(-1))
    3131    else:
    32         #Guess where the ice front is
     32        # Guess where the ice front is
    3333        vertexonfloatingice = np.zeros((md.mesh.numberofvertices))
    34         pos = np.nonzero(np.sum(md.mask.ocean_levelset[md.mesh.elements - 1] < 0., axis=1) > 0.)[0]
     34        pos = np.nonzero(np.sum(md.mask.ocean_levelset[md.mesh.elements - 1] < 0.0, axis=1) > 0.0)[0]
    3535        vertexonfloatingice[md.mesh.elements[pos].astype(int) - 1] = 1.
    36         vertexonicefront = np.logical_and(np.reshape(md.mesh.vertexonboundary, (-1, )), vertexonfloatingice > 0.)
     36        vertexonicefront = np.logical_and(np.reshape(md.mesh.vertexonboundary, (-1, )), vertexonfloatingice > 0.0)
    3737
    3838    #pos = find(md.mesh.vertexonboundary & ~vertexonicefront)
    3939    pos = np.nonzero(np.logical_and(md.mesh.vertexonboundary, np.logical_not(vertexonicefront)))[0]
    4040    if not np.size(pos):
    41         print("Warning: SetMarineIceSheetBC.py: ice front all around the glacier, no dirichlet found. Dirichlet must be added manually.")
     41        print('Warning: SetMarineIceSheetBC.py: ice front all around the glacier, no dirichlet found. Dirichlet must be added manually.')
    4242
    43     md.stressbalance.spcvx = float('nan') * np.ones(md.mesh.numberofvertices)
    44     md.stressbalance.spcvy = float('nan') * np.ones(md.mesh.numberofvertices)
    45     md.stressbalance.spcvz = float('nan') * np.ones(md.mesh.numberofvertices)
    46     md.stressbalance.referential = float('nan') * np.ones((md.mesh.numberofvertices, 6))
     43    md.stressbalance.spcvx = np.nan * np.ones(md.mesh.numberofvertices)
     44    md.stressbalance.spcvy = np.nan * np.ones(md.mesh.numberofvertices)
     45    md.stressbalance.spcvz = np.nan * np.ones(md.mesh.numberofvertices)
     46    md.stressbalance.referential = np.nan * np.ones((md.mesh.numberofvertices, 6))
    4747    md.stressbalance.loadingforce = 0 * np.ones((md.mesh.numberofvertices, 3))
    4848
    49     #Position of ice front
     49    # Position of ice front
    5050    pos = np.nonzero(vertexonicefront)[0]
    5151    md.mask.ice_levelset[pos] = 0
    5252
    53     #First find segments that are not completely on the front
     53    # First find segments that are not completely on the front
    5454    if md.mesh.elementtype() == 'Penta':
    5555        numbernodesfront = 4
     
    5757        numbernodesfront = 2
    5858    else:
    59         raise Exception("Mesh type not supported")
     59        raise Exception('Mesh type not supported')
    6060    if any(md.mask.ice_levelset <= 0):
    6161        values = md.mask.ice_levelset[md.mesh.segments[:, 0:-1] - 1]
     
    6363        np.sum(segmentsfront, axis=1) != numbernodesfront
    6464        segments = np.nonzero(np.sum(segmentsfront, axis=1) != numbernodesfront)[0]
    65     #Find all nodes for these segments and spc them
     65        # Find all nodes for these segments and spc them
    6666        pos = md.mesh.segments[segments, 0:-1] - 1
    6767    else:
     
    7171    md.stressbalance.spcvz[pos] = 0
    7272
    73     #Dirichlet Values
     73    # Dirichlet Values
    7474    if isinstance(md.inversion.vx_obs, np.ndarray) and np.size(md.inversion.vx_obs, axis=0) == md.mesh.numberofvertices and isinstance(md.inversion.vy_obs, np.ndarray) and np.size(md.inversion.vy_obs, axis=0) == md.mesh.numberofvertices:
    75         print("      boundary conditions for stressbalance model: spc set as observed velocities")
     75        print('      boundary conditions for stressbalance model: spc set as observed velocities')
    7676        md.stressbalance.spcvx[pos] = md.inversion.vx_obs[pos]
    7777        md.stressbalance.spcvy[pos] = md.inversion.vy_obs[pos]
    7878    else:
    79         print("      boundary conditions for stressbalance model: spc set as zero")
     79        print('      boundary conditions for stressbalance model: spc set as zero')
    8080
    8181    md.hydrology.spcwatercolumn = np.zeros((md.mesh.numberofvertices, 2))
     
    9090    if np.all(np.isnan(md.balancethickness.thickening_rate)):
    9191        md.balancethickness.thickening_rate = np.zeros((md.mesh.numberofvertices))
    92         print("      no balancethickness.thickening_rate specified: values set as zero")
     92        print('      no balancethickness.thickening_rate specified: values set as zero')
    9393
    94     md.masstransport.spcthickness = float('nan') * np.ones((md.mesh.numberofvertices))
    95     md.balancethickness.spcthickness = float('nan') * np.ones((md.mesh.numberofvertices))
    96     md.damage.spcdamage = float('nan') * np.ones((md.mesh.numberofvertices))
     94    md.masstransport.spcthickness = np.nan * np.ones((md.mesh.numberofvertices))
     95    md.balancethickness.spcthickness = np.nan * np.ones((md.mesh.numberofvertices))
     96    md.damage.spcdamage = np.nan * np.ones((md.mesh.numberofvertices))
    9797
    9898    if isinstance(md.initialization.temperature, np.ndarray) and np.size(md.initialization.temperature, axis=0) == md.mesh.numberofvertices:
    99         md.thermal.spctemperature = float('nan') * np.ones((md.mesh.numberofvertices))
     99        md.thermal.spctemperature = np.nan * np.ones((md.mesh.numberofvertices))
    100100        if hasattr(md.mesh, 'vertexonsurface'):
    101101            pos = np.nonzero(md.mesh.vertexonsurface)[0]
    102             md.thermal.spctemperature[pos] = md.initialization.temperature[pos]  #impose observed temperature on surface
     102            md.thermal.spctemperature[pos] = md.initialization.temperature[pos]  # impose observed temperature on surface
    103103        if not isinstance(md.basalforcings.geothermalflux, np.ndarray) or not np.size(md.basalforcings.geothermalflux, axis=0) == md.mesh.numberofvertices:
    104104            md.basalforcings.geothermalflux = np.zeros((md.mesh.numberofvertices))
    105             md.basalforcings.geothermalflux[np.nonzero(md.mask.ocean_levelset > 0.)] = 50. * 10.**- 3  #50mW / m2
     105            md.basalforcings.geothermalflux[np.nonzero(md.mask.ocean_levelset > 0.0)] = 50.0 * pow(10.0, -3)  # 50mW/m2
    106106    else:
    107         print("      no thermal boundary conditions created: no observed temperature found")
     107        print('      no thermal boundary conditions created: no observed temperature found')
    108108
    109109    return md
  • TabularUnified issm/trunk-jpl/src/m/classes/SMBcomponents.m

    r26209 r26358  
    2222                        end
    2323                end % }}}
     24                function disp(self) % {{{
     25                        disp(sprintf('   surface forcings parameters (SMB=accumulation-runoff-evaporation) :'));
     26                        fielddisplay(self,'accumulation','accumulated snow [m/yr ice eq]');
     27                        fielddisplay(self,'runoff','amount of ice melt lost from the ice column [m/yr ice eq]');
     28                        fielddisplay(self,'evaporation','amount of ice lost to evaporative processes [m/yr ice eq]');
     29                        fielddisplay(self, 'steps_per_step', 'number of smb steps per time step');
     30                        fielddisplay(self, 'averaging', 'averaging methods from short to long steps');
     31                        disp(sprintf('%51s  0: Arithmetic (default)',' '));
     32                        disp(sprintf('%51s  1: Geometric',' '));
     33                        disp(sprintf('%51s  2: Harmonic',' '));
     34                        fielddisplay(self,'requested_outputs','additional outputs requested');
     35                end % }}}
    2436                function self = extrude(self,md) % {{{
    2537
     
    3850                        if isnan(self.accumulation)
    3951                                self.accumulation=zeros(md.mesh.numberofvertices,1);
    40                                 disp('  no smb.accumulation specified: values set as zero');
     52                                disp('      no smb.accumulation specified: values set as zero');
    4153                        end
    4254                        if isnan(self.evaporation)
    4355                                self.evaporation=zeros(md.mesh.numberofvertices,1);
    44                                 disp('  no smb.evaporation specified: values set as zero');
     56                                disp('      no smb.evaporation specified: values set as zero');
    4557                        end
    4658                        if isnan(self.runoff)
    4759                                self.runoff=zeros(md.mesh.numberofvertices,1);
    48                                 disp('  no smb.runoff specified: values set as zero');
     60                                disp('      no smb.runoff specified: values set as zero');
    4961                        end
    5062
     
    6678                        md = checkfield(md,'fieldname','smb.requested_outputs','stringrow',1);
    6779                end % }}}
    68                 function disp(self) % {{{
    69                         disp(sprintf('    surface forcings parameters (SMB=accumulation-runoff-evaporation) :'));
    70                         fielddisplay(self,'accumulation','accumulated snow [m/yr ice eq]');
    71                         fielddisplay(self,'runoff','amount of ice melt lost from the ice column [m/yr ice eq]');
    72                         fielddisplay(self,'evaporation','amount of ice lost to evaporative processes [m/yr ice eq]');
    73                         fielddisplay(self, 'steps_per_step', 'number of smb steps per time step');
    74                         fielddisplay(self, 'averaging', 'averaging methods from short to long steps');
    75                         disp(sprintf('%51s  0: Arithmetic (default)',' '));
    76                         disp(sprintf('%51s  1: Geometric',' '));
    77                         disp(sprintf('%51s  2: Harmonic',' '));
    78                         fielddisplay(self,'requested_outputs','additional outputs requested');
    79                 end % }}}
    8080                function marshall(self,prefix,md,fid) % {{{
    8181
     
    9292                        pos  = find(ismember(outputs,'default'));
    9393                        if ~isempty(pos),
    94                                 outputs(pos) = [];                             %remove 'default' from outputs
     94                                outputs(pos) = [];                            %remove 'default' from outputs
    9595                                outputs  = [outputs defaultoutputs(self,md)]; %add defaults
    9696                        end
  • TabularUnified issm/trunk-jpl/src/m/classes/SMBcomponents.py

    r26208 r26358  
    2121        self.averaging = 0
    2222        self.requested_outputs = []
     23        self.isclimatology = np.nan
    2324
    2425        nargs = len(args)
     
    3031
    3132    def __repr__(self):  # {{{
    32         s = '   surface forcings parameters (SMB = accumulation-runoff-evaporation):\n'
     33        s = '   surface forcings parameters (SMB=accumulation-runoff-evaporation) :\n'
    3334        s += '{}\n'.format(fielddisplay(self, 'accumulation', 'accumulated snow [m/yr ice eq]'))
    3435        s += '{}\n'.format(fielddisplay(self, 'runoff', 'amount of ice melt lost from the ice column [m/yr ice eq]'))
     
    4445
    4546    def extrude(self, md):  # {{{
    46         self.mass_balance = project3d(md, 'vector', self.accumulation, 'type', 'node')
    47         self.mass_balance = project3d(md, 'vector', self.runoff, 'type', 'node')
    48         self.mass_balance = project3d(md, 'vector', self.evaporation, 'type', 'node')
     47        self.accumulation = project3d(md, 'vector', self.accumulation, 'type', 'node')
     48        self.runoff = project3d(md, 'vector', self.runoff, 'type', 'node')
     49        self.evaporation = project3d(md, 'vector', self.evaporation, 'type', 'node')
    4950        return self
    5051    # }}}
     
    5758        if np.all(np.isnan(self.accumulation)):
    5859            self.accumulation = np.zeros((md.mesh.numberofvertices))
    59             print("      no SMB.accumulation specified: values set as zero")
     60            print('      no SMB.accumulation specified: values set as zero')
     61        if np.all(np.isnan(self.evaporation)):
     62            self.evaporation = np.zeros((md.mesh.numberofvertices))
     63            print("      no SMB.evaporation specified: values set as zero")
    6064        if np.all(np.isnan(self.runoff)):
    6165            self.runoff = np.zeros((md.mesh.numberofvertices))
    6266            print("      no SMB.runoff specified: values set as zero")
    63 
    64         if np.all(np.isnan(self.evaporation)):
    65             self.evaporation = np.zeros((md.mesh.numberofvertices))
    66             print("      no SMB.evaporation specified: values set as zero")
    6767        return self
    6868    # }}}
     
    7979        md = checkfield(md, 'fieldname', 'smb.steps_per_step', '>=', 1, 'numel', [1])
    8080        md = checkfield(md, 'fieldname', 'smb.averaging', 'numel', [1], 'values', [0, 1, 2])
    81         md = checkfield(md, 'fieldname', 'masstransport.requested_outputs', 'stringrow', 1)
     81        md = checkfield(md, 'fieldname', 'smb.requested_outputs', 'stringrow', 1)
    8282        return md
    8383    # }}}
     
    8787
    8888        WriteData(fid, prefix, 'name', 'md.smb.model', 'data', 2, 'format', 'Integer')
    89         WriteData(fid, prefix, 'object', self, 'class', 'smb', 'fieldname', 'accumulation', 'format', 'DoubleMat', 'mattype', 1, 'scale', 1. / yts, 'timeserieslength', md.mesh.numberofvertices + 1, 'yts', yts)
    90         WriteData(fid, prefix, 'object', self, 'class', 'smb', 'fieldname', 'runoff', 'format', 'DoubleMat', 'mattype', 1, 'scale', 1. / yts, 'timeserieslength', md.mesh.numberofvertices + 1, 'yts', yts)
    91         WriteData(fid, prefix, 'object', self, 'class', 'smb', 'fieldname', 'evaporation', 'format', 'DoubleMat', 'mattype', 1, 'scale', 1. / yts, 'timeserieslength', md.mesh.numberofvertices + 1, 'yts', yts)
     89        WriteData(fid, prefix, 'object', self, 'class', 'smb', 'fieldname', 'accumulation', 'format', 'DoubleMat', 'mattype', 1, 'scale', 1 / yts, 'timeserieslength', md.mesh.numberofvertices + 1, 'yts', yts)
     90        WriteData(fid, prefix, 'object', self, 'class', 'smb', 'fieldname', 'runoff', 'format', 'DoubleMat', 'mattype', 1, 'scale', 1 / yts, 'timeserieslength', md.mesh.numberofvertices + 1, 'yts', yts)
     91        WriteData(fid, prefix, 'object', self, 'class', 'smb', 'fieldname', 'evaporation', 'format', 'DoubleMat', 'mattype', 1, 'scale', 1 / yts, 'timeserieslength', md.mesh.numberofvertices + 1, 'yts', yts)
    9292        WriteData(fid, prefix, 'object', self, 'fieldname', 'steps_per_step', 'format', 'Integer')
    9393        WriteData(fid, prefix, 'object', self, 'fieldname', 'averaging', 'format', 'Integer')
    94     #process requested outputs
     94        # Process requested outputs
    9595        outputs = self.requested_outputs
    9696        indices = [i for i, x in enumerate(outputs) if x == 'default']
  • TabularUnified issm/trunk-jpl/src/m/classes/SMBforcing.py

    r26208 r26358  
    1919        self.requested_outputs = []
    2020        self.averaging = 0
     21        self.isclimatology = np.nan
    2122
    2223        nargs = len(args)
     
    3132        s += '{}\n'.format(fielddisplay(self, 'mass_balance', 'surface mass balance [m/yr ice eq]'))
    3233        s += '{}\n'.format(fielddisplay(self, 'steps_per_step', 'number of smb steps per time step'))
     34        s += '{}\n'.format(fielddisplay(self, 'requested_outputs', 'additional outputs requested'))
    3335        s += '{}\n'.format(fielddisplay(self, 'averaging', 'averaging methods from short to long steps'))
    3436        s += '\t\t{}\n'.format('0: Arithmetic (default)')
    3537        s += '\t\t{}\n'.format('1: Geometric')
    3638        s += '\t\t{}\n'.format('2: Harmonic')
    37         s += '{}\n'.format(fielddisplay(self, 'requested_outputs', 'additional outputs requested'))
    3839        return s
    3940    #}}}
     
    5152        if np.all(np.isnan(self.mass_balance)):
    5253            self.mass_balance = np.zeros((md.mesh.numberofvertices))
    53             print("      no SMBforcing.mass_balance specified: values set as zero")
     54            print("      no smb.mass_balance specified: values set as zero")
    5455        return self
    5556    #}}}
     
    7172        yts = md.constants.yts
    7273        WriteData(fid, prefix, 'name', 'md.smb.model', 'data', 1, 'format', 'Integer')
    73         WriteData(fid, prefix, 'object', self, 'class', 'smb', 'fieldname', 'mass_balance', 'format', 'DoubleMat', 'mattype', 1, 'scale', 1. / yts, 'timeserieslength', md.mesh.numberofvertices + 1, 'yts', yts)
     74        WriteData(fid, prefix, 'object', self, 'class', 'smb', 'fieldname', 'mass_balance', 'format', 'DoubleMat', 'mattype', 1, 'scale', 1 / yts, 'timeserieslength', md.mesh.numberofvertices + 1, 'yts', yts)
    7475        WriteData(fid, prefix, 'object', self, 'fieldname', 'steps_per_step', 'format', 'Integer')
    7576        WriteData(fid, prefix, 'object', self, 'fieldname', 'averaging', 'format', 'Integer')
  • TabularUnified issm/trunk-jpl/src/m/classes/SMBgemb.m

    r26209 r26358  
    122122                requested_outputs      = {};
    123123
    124                 %Several fields are missing from the standard GEMB model, which are capture intrinsically by ISSM.
     124                %Several fields are missing from the standard GEMB model, which are
     125                %captured intrinsically by ISSM.
    125126                %dateN: that's the last row of the above fields.
    126127                %dt:    included in dateN. Not an input.
     
    138139                                        error('constructor not supported: need geometry and mesh to set defaults');
    139140                        end
    140                 end % }}}
    141                 function self = extrude(self,md) % {{{
    142 
    143                         self.Ta=project3d(md,'vector',self.Ta,'type','element');
    144                         self.V=project3d(md,'vector',self.V,'type','element');
    145                         self.dswrf=project3d(md,'vector',self.dswrf,'type','element');
    146                         self.dslrf=project3d(md,'vector',self.dslrf,'type','element');
    147                         self.P=project3d(md,'vector',self.P,'type','element');
    148                         self.eAir=project3d(md,'vector',self.eAir,'type','element');
    149                         self.pAir=project3d(md,'vector',self.pAir,'type','element');
    150 
    151                         if ~isnan(self.Dzini)
    152                                 self.Dzini=project3d(md,'vector',self.Dzini,'type','element');
    153                         end
    154                         if ~isnan(self.Dini)
    155                                 self.Dini=project3d(md,'vector',self.Dini,'type','element');
    156                         end
    157                         if ~isnan(self.Reini)
    158                                 self.Reini=project3d(md,'vector',self.Reini,'type','element');
    159                         end
    160                         if ~isnan(self.Gdnini)
    161                                 self.Gdnini=project3d(md,'vector',self.Gdnini,'type','element');
    162                         end
    163                         if ~isnan(self.Gspini)
    164                                 self.Gspini=project3d(md,'vector',self.Gspini,'type','element');
    165                         end
    166                         if ~isnan(self.ECini)
    167                                 self.ECini=project3d(md,'vector',self.ECini,'type','element');
    168                         end
    169                         if ~isnan(self.Wini)
    170                                 self.Wini=project3d(md,'vector',self.Wini,'type','element');
    171                         end
    172                         if ~isnan(self.Aini)
    173                                 self.Aini=project3d(md,'vector',self.Aini,'type','element');
    174                         end
    175                         if ~isnan(self.Adiffini)
    176                                 self.Adiffini=project3d(md,'vector',self.Adiffini,'type','element');
    177                         end
    178                         if ~isnan(self.Tini)
    179                                 self.Tini=project3d(md,'vector',self.Tini,'type','element');
    180                         end
    181 
    182                         if ~isnan(self.dswdiffrf)
    183                                 self.dswdiffrf=project3d(md,'vector',self.dswdiffrf,'type','element');
    184                         end
    185                         if ~isnan(self.szaValue)
    186                                 self.szaValue=project3d(md,'vector',self.szaValue,'type','element');
    187                         end
    188                         if ~isnan(self.cotValue)
    189                                 self.cotValue=project3d(md,'vector',self.cotValue,'type','element');
    190                         end
    191                         if ~isnan(self.ccsnowValue)
    192                                 self.ccsnowValue=project3d(md,'vector',self.ccsnowValue,'type','element');
    193                         end
    194                         if ~isnan(self.cciceValue)
    195                                 self.cciceValue=project3d(md,'vector',self.cciceValue,'type','element');
    196                         end
    197                         if (aIdx == 0) & ~isnan(self.aValue)
    198                                 self.aValue=project3d(md,'vector',self.aValue,'type','element');
    199                         end
    200                         if ~isnan(self.teValue)
    201                                 self.teValue=project3d(md,'vector',self.teValue,'type','element');
    202                         end
    203 
    204 
    205                 end % }}}
    206                 function list = defaultoutputs(self,md) % {{{
    207                         list = {'SmbMassBalance','SmbAccumulatedMassBalance'};
    208                 end % }}}
    209                 function self = setdefaultparameters(self,mesh,geometry) % {{{
    210 
    211                         self.isgraingrowth=1;
    212                         self.isalbedo=1;
    213                         self.isshortwave=1;
    214                         self.isthermal=1;
    215                         self.isaccumulation=1;
    216                         self.ismelt=1;
    217                         self.isdensification=1;
    218                         self.isturbulentflux=1;
    219                         self.isconstrainsurfaceT=0;
    220 
    221                         self.aIdx = 1;
    222                         self.swIdx = 1;
    223                         self.denIdx = 2;
    224                         self.dsnowIdx = 1;
    225                         self.zTop=10*ones(mesh.numberofelements,1);
    226                         self.dzTop = .05* ones (mesh.numberofelements,1);
    227                         self.dzMin = self.dzTop/2;
    228                         self.InitDensityScaling = 1.0;
    229                         self.ThermoDeltaTScaling = 1/11;
    230 
    231                         self.Vmean=10.0*ones(mesh.numberofelements,1);
    232 
    233                         self.zMax=250*ones(mesh.numberofelements,1);
    234                         self.zMin=130*ones(mesh.numberofelements,1);
    235                         self.zY = 1.025*ones(mesh.numberofelements,1);
    236                         self.outputFreq = 30;
    237 
    238                         %additional albedo parameters
    239                         self.aSnow = 0.85;
    240                         self.aIce = 0.48;
    241                         self.cldFrac = 0.1;
    242                         self.t0wet = 15;
    243                         self.t0dry = 30;
    244                         self.K = 7;
    245                         self.adThresh = 1023;
    246 
    247                         self.teValue = ones(mesh.numberofelements,1);
    248                         self.aValue = self.aSnow*ones(mesh.numberofelements,1);
    249 
    250                         self.dswdiffrf=0.0*ones(mesh.numberofelements,1);
    251                         self.szaValue=0.0*ones(mesh.numberofelements,1);
    252                         self.cotValue=0.0*ones(mesh.numberofelements,1);
    253                         self.ccsnowValue=0.0*ones(mesh.numberofelements,1);
    254                         self.cciceValue=0.0*ones(mesh.numberofelements,1);
    255 
    256                         self.Dzini=0.05*ones(mesh.numberofelements,2);
    257                         self.Dini=910.0*ones(mesh.numberofelements,2);
    258                         self.Reini=2.5*ones(mesh.numberofelements,2);
    259                         self.Gdnini=0.0*ones(mesh.numberofelements,2);
    260                         self.Gspini=0.0*ones(mesh.numberofelements,2);
    261                         self.ECini=0.0*ones(mesh.numberofelements,1);
    262                         self.Wini=0.0*ones(mesh.numberofelements,2);
    263                         self.Aini=self.aSnow*ones(mesh.numberofelements,2);
    264                         self.Adiffini=ones(mesh.numberofelements,2);
    265                         self.Tini=273.15*ones(mesh.numberofelements,2);
    266                         %               /!\ Default value of Tini must be equal to Tmean but don't know Tmean yet (computed when atmospheric forcings are interpolated on mesh).
    267                         %               If initialization without restart, this value will be overwritten when snow parameters are retrieved in Element.cpp
    268                         self.Sizeini=2*ones(mesh.numberofelements,1);
    269 
    270                 end % }}}
    271                 function md = checkconsistency(self,md,solution,analyses) % {{{
    272 
    273                         md = checkfield(md,'fieldname','smb.isgraingrowth','values',[0 1]);
    274                         md = checkfield(md,'fieldname','smb.isalbedo','values',[0 1]);
    275                         md = checkfield(md,'fieldname','smb.isshortwave','values',[0 1]);
    276                         md = checkfield(md,'fieldname','smb.isthermal','values',[0 1]);
    277                         md = checkfield(md,'fieldname','smb.isaccumulation','values',[0 1]);
    278                         md = checkfield(md,'fieldname','smb.ismelt','values',[0 1]);
    279                         md = checkfield(md,'fieldname','smb.isdensification','values',[0 1]);
    280                         md = checkfield(md,'fieldname','smb.isturbulentflux','values',[0 1]);
    281                         md = checkfield(md,'fieldname','smb.isconstrainsurfaceT','values',[0 1]);
    282 
    283                         md = checkfield(md,'fieldname','smb.Ta','timeseries',1,'NaN',1,'Inf',1,'>',273-100,'<',273+100); %-100/100 celsius min/max value
    284                         md = checkfield(md,'fieldname','smb.V','timeseries',1,'NaN',1,'Inf',1,'>=',0,'<',45,'size',size(self.Ta)); %max 500 km/h
    285                         md = checkfield(md,'fieldname','smb.dswrf','timeseries',1,'NaN',1,'Inf',1,'>=',0,'<=',1400,'size',size(self.Ta));
    286                         md = checkfield(md,'fieldname','smb.dswdiffrf','timeseries',1,'NaN',1,'Inf',1,'>=',0,'<=',1400);
    287                         md = checkfield(md,'fieldname','smb.dlwrf','timeseries',1,'NaN',1,'Inf',1,'>=',0,'size',size(self.Ta));
    288                         md = checkfield(md,'fieldname','smb.P','timeseries',1,'NaN',1,'Inf',1,'>=',0,'<=',200,'size',size(self.Ta));
    289                         md = checkfield(md,'fieldname','smb.eAir','timeseries',1,'NaN',1,'Inf',1,'size',size(self.Ta));
    290 
    291                         md = checkfield(md,'fieldname','smb.Tmean','size',[md.mesh.numberofelements 1],'NaN',1,'Inf',1,'>',273-100,'<',273+100); %-100/100 celsius min/max value
    292                         md = checkfield(md,'fieldname','smb.C','size',[md.mesh.numberofelements 1],'NaN',1,'Inf',1,'>',0);
    293                         md = checkfield(md,'fieldname','smb.Vmean','size',[md.mesh.numberofelements 1],'NaN',1,'Inf',1,'>=',0);
    294                         md = checkfield(md,'fieldname','smb.Tz','size',[md.mesh.numberofelements 1],'NaN',1,'Inf',1,'>=',0,'<=',5000);
    295                         md = checkfield(md,'fieldname','smb.Vz','size',[md.mesh.numberofelements 1],'NaN',1,'Inf',1,'>=',0,'<=',5000);
    296 
    297                         md = checkfield(md,'fieldname','smb.teValue','timeseries',1,'NaN',1,'Inf',1,'>=',0,'<=',1);
    298 
    299                         md = checkfield(md,'fieldname','smb.aIdx','NaN',1,'Inf',1,'values',[0,1,2,3,4]);
    300                         md = checkfield(md,'fieldname','smb.swIdx','NaN',1,'Inf',1,'values',[0,1]);
    301                         md = checkfield(md,'fieldname','smb.denIdx','NaN',1,'Inf',1,'values',[1,2,3,4,5,6,7]);
    302                         md = checkfield(md,'fieldname','smb.dsnowIdx','NaN',1,'Inf',1,'values',[0,1,2,3,4]);
    303 
    304                         md = checkfield(md,'fieldname','smb.zTop','NaN',1,'Inf',1,'>=',0);
    305                         md = checkfield(md,'fieldname','smb.dzTop','NaN',1,'Inf',1,'>',0);
    306                         md = checkfield(md,'fieldname','smb.dzMin','NaN',1,'Inf',1,'>',0);
    307                         md = checkfield(md,'fieldname','smb.zY','NaN',1,'Inf',1,'>=',1);
    308                         md = checkfield(md,'fieldname','smb.outputFreq','NaN',1,'Inf',1,'>',0,'<',10*365); %10 years max
    309                         md = checkfield(md,'fieldname','smb.InitDensityScaling','NaN',1,'Inf',1,'>=',0,'<=',1);
    310                         md = checkfield(md,'fieldname','smb.ThermoDeltaTScaling','NaN',1,'Inf',1,'>=',0,'<=',1);
    311                         md = checkfield(md,'fieldname','smb.adThresh','NaN',1,'Inf',1,'>=',0);
    312 
    313                         switch self.aIdx,
    314                                 case 0
    315                                         md = checkfield(md,'fieldname','smb.aValue','timeseries',1,'NaN',1,'Inf',1,'>=',0,'<=',1);
    316                                 case {1 2}
    317                                         md = checkfield(md,'fieldname','smb.aSnow','NaN',1,'Inf',1,'>=',.64,'<=',.89);
    318                                         md = checkfield(md,'fieldname','smb.aIce','NaN',1,'Inf',1,'>=',.27,'<=',.58);
    319                                         if self.aIdx==1
    320                                                 md = checkfield(md,'fieldname','smb.szaValue','timeseries',1,'NaN',1,'Inf',1,'>=',0,'<=',90);
    321                                                 md = checkfield(md,'fieldname','smb.cotValue','timeseries',1,'NaN',1,'Inf',1,'>=',0);
    322                                                 md = checkfield(md,'fieldname','smb.ccsnowValue','timeseries',1,'NaN',1,'Inf',1,'>=',0);
    323                                                 md = checkfield(md,'fieldname','smb.cciceValue','timeseries',1,'NaN',1,'Inf',1,'>=',0);
    324                                         end
    325                                 case 3
    326                                         md = checkfield(md,'fieldname','smb.cldFrac','NaN',1,'Inf',1,'>=',0,'<=',1);
    327                                 case 4
    328                                         md = checkfield(md,'fieldname','smb.t0wet','NaN',1,'Inf',1,'>=',15,'<=',21.9);
    329                                         md = checkfield(md,'fieldname','smb.t0dry','NaN',1,'Inf',1,'>=',30,'<=',30);
    330                                         md = checkfield(md,'fieldname','smb.K','NaN',1,'Inf',1,'>=',7,'<=',7);
    331                         end
    332 
    333                         %check zTop is < local thickness:
    334                         he=sum(md.geometry.thickness(md.mesh.elements),2)/size(md.mesh.elements,2);
    335                         if any(he<self.zTop),
    336                                 error('SMBgemb consistency check error: zTop should be smaller than local ice thickness');
    337                         end
    338                         md = checkfield(md,'fieldname','smb.steps_per_step','>=',1,'numel',[1]);
    339                         md = checkfield(md,'fieldname','smb.averaging','numel',[1],'values',[0 1 2]);
    340                         md = checkfield(md,'fieldname','smb.requested_outputs','stringrow',1);
    341 
    342141                end % }}}
    343142                function disp(self) % {{{
     
    444243
    445244                end % }}}
     245                function self = extrude(self,md) % {{{
     246
     247                        self.Ta=project3d(md,'vector',self.Ta,'type','element');
     248                        self.V=project3d(md,'vector',self.V,'type','element');
     249                        self.dswrf=project3d(md,'vector',self.dswrf,'type','element');
     250                        self.dslrf=project3d(md,'vector',self.dslrf,'type','element');
     251                        self.P=project3d(md,'vector',self.P,'type','element');
     252                        self.eAir=project3d(md,'vector',self.eAir,'type','element');
     253                        self.pAir=project3d(md,'vector',self.pAir,'type','element');
     254
     255                        if ~isnan(self.Dzini)
     256                                self.Dzini=project3d(md,'vector',self.Dzini,'type','element');
     257                        end
     258                        if ~isnan(self.Dini)
     259                                self.Dini=project3d(md,'vector',self.Dini,'type','element');
     260                        end
     261                        if ~isnan(self.Reini)
     262                                self.Reini=project3d(md,'vector',self.Reini,'type','element');
     263                        end
     264                        if ~isnan(self.Gdnini)
     265                                self.Gdnini=project3d(md,'vector',self.Gdnini,'type','element');
     266                        end
     267                        if ~isnan(self.Gspini)
     268                                self.Gspini=project3d(md,'vector',self.Gspini,'type','element');
     269                        end
     270                        if ~isnan(self.ECini)
     271                                self.ECini=project3d(md,'vector',self.ECini,'type','element');
     272                        end
     273                        if ~isnan(self.Wini)
     274                                self.Wini=project3d(md,'vector',self.Wini,'type','element');
     275                        end
     276                        if ~isnan(self.Aini)
     277                                self.Aini=project3d(md,'vector',self.Aini,'type','element');
     278                        end
     279                        if ~isnan(self.Adiffini)
     280                                self.Adiffini=project3d(md,'vector',self.Adiffini,'type','element');
     281                        end
     282                        if ~isnan(self.Tini)
     283                                self.Tini=project3d(md,'vector',self.Tini,'type','element');
     284                        end
     285
     286                        if ~isnan(self.dswdiffrf)
     287                                self.dswdiffrf=project3d(md,'vector',self.dswdiffrf,'type','element');
     288                        end
     289                        if ~isnan(self.szaValue)
     290                                self.szaValue=project3d(md,'vector',self.szaValue,'type','element');
     291                        end
     292                        if ~isnan(self.cotValue)
     293                                self.cotValue=project3d(md,'vector',self.cotValue,'type','element');
     294                        end
     295                        if ~isnan(self.ccsnowValue)
     296                                self.ccsnowValue=project3d(md,'vector',self.ccsnowValue,'type','element');
     297                        end
     298                        if ~isnan(self.cciceValue)
     299                                self.cciceValue=project3d(md,'vector',self.cciceValue,'type','element');
     300                        end
     301                        if (aIdx == 0) & ~isnan(self.aValue)
     302                                self.aValue=project3d(md,'vector',self.aValue,'type','element');
     303                        end
     304                        if ~isnan(self.teValue)
     305                                self.teValue=project3d(md,'vector',self.teValue,'type','element');
     306                        end
     307
     308
     309                end % }}}
     310                function list = defaultoutputs(self,md) % {{{
     311                        list = {'SmbMassBalance','SmbAccumulatedMassBalance'};
     312                end % }}}
     313                function self = setdefaultparameters(self,mesh,geometry) % {{{
     314
     315                        self.isgraingrowth=1;
     316                        self.isalbedo=1;
     317                        self.isshortwave=1;
     318                        self.isthermal=1;
     319                        self.isaccumulation=1;
     320                        self.ismelt=1;
     321                        self.isdensification=1;
     322                        self.isturbulentflux=1;
     323                        self.isconstrainsurfaceT=0;
     324
     325                        self.aIdx = 1;
     326                        self.swIdx = 1;
     327                        self.denIdx = 2;
     328                        self.dsnowIdx = 1;
     329                        self.zTop=10*ones(mesh.numberofelements,1);
     330                        self.dzTop = .05* ones (mesh.numberofelements,1);
     331                        self.dzMin = self.dzTop/2;
     332                        self.InitDensityScaling = 1.0;
     333                        self.ThermoDeltaTScaling = 1/11;
     334
     335                        self.Vmean=10.0*ones(mesh.numberofelements,1);
     336
     337                        self.zMax=250*ones(mesh.numberofelements,1);
     338                        self.zMin=130*ones(mesh.numberofelements,1);
     339                        self.zY = 1.025*ones(mesh.numberofelements,1);
     340                        self.outputFreq = 30;
     341
     342                        %additional albedo parameters
     343                        self.aSnow = 0.85;
     344                        self.aIce = 0.48;
     345                        self.cldFrac = 0.1;
     346                        self.t0wet = 15;
     347                        self.t0dry = 30;
     348                        self.K = 7;
     349                        self.adThresh = 1023;
     350
     351                        self.teValue = ones(mesh.numberofelements,1);
     352                        self.aValue = self.aSnow*ones(mesh.numberofelements,1);
     353
     354                        self.dswdiffrf=0.0*ones(mesh.numberofelements,1);
     355                        self.szaValue=0.0*ones(mesh.numberofelements,1);
     356                        self.cotValue=0.0*ones(mesh.numberofelements,1);
     357                        self.ccsnowValue=0.0*ones(mesh.numberofelements,1);
     358                        self.cciceValue=0.0*ones(mesh.numberofelements,1);
     359
     360                        self.Dzini=0.05*ones(mesh.numberofelements,2);
     361                        self.Dini=910.0*ones(mesh.numberofelements,2);
     362                        self.Reini=2.5*ones(mesh.numberofelements,2);
     363                        self.Gdnini=0.0*ones(mesh.numberofelements,2);
     364                        self.Gspini=0.0*ones(mesh.numberofelements,2);
     365                        self.ECini=0.0*ones(mesh.numberofelements,1);
     366                        self.Wini=0.0*ones(mesh.numberofelements,2);
     367                        self.Aini=self.aSnow*ones(mesh.numberofelements,2);
     368                        self.Adiffini=ones(mesh.numberofelements,2);
     369                        self.Tini=273.15*ones(mesh.numberofelements,2);
     370                        %               /!\ Default value of Tini must be equal to Tmean but don't know Tmean yet (computed when atmospheric forcings are interpolated on mesh).
     371                        %               If initialization without restart, this value will be overwritten when snow parameters are retrieved in Element.cpp
     372                        self.Sizeini=2*ones(mesh.numberofelements,1);
     373
     374                end % }}}
     375                function md = checkconsistency(self,md,solution,analyses) % {{{
     376
     377                        md = checkfield(md,'fieldname','smb.isgraingrowth','values',[0 1]);
     378                        md = checkfield(md,'fieldname','smb.isalbedo','values',[0 1]);
     379                        md = checkfield(md,'fieldname','smb.isshortwave','values',[0 1]);
     380                        md = checkfield(md,'fieldname','smb.isthermal','values',[0 1]);
     381                        md = checkfield(md,'fieldname','smb.isaccumulation','values',[0 1]);
     382                        md = checkfield(md,'fieldname','smb.ismelt','values',[0 1]);
     383                        md = checkfield(md,'fieldname','smb.isdensification','values',[0 1]);
     384                        md = checkfield(md,'fieldname','smb.isturbulentflux','values',[0 1]);
     385                        md = checkfield(md,'fieldname','smb.isconstrainsurfaceT','values',[0 1]);
     386
     387                        md = checkfield(md,'fieldname','smb.Ta','timeseries',1,'NaN',1,'Inf',1,'>',273-100,'<',273+100); %-100/100 celsius min/max value
     388                        md = checkfield(md,'fieldname','smb.V','timeseries',1,'NaN',1,'Inf',1,'>=',0,'<',45,'size',size(self.Ta)); %max 500 km/h
     389                        md = checkfield(md,'fieldname','smb.dswrf','timeseries',1,'NaN',1,'Inf',1,'>=',0,'<=',1400,'size',size(self.Ta));
     390                        md = checkfield(md,'fieldname','smb.dswdiffrf','timeseries',1,'NaN',1,'Inf',1,'>=',0,'<=',1400);
     391                        md = checkfield(md,'fieldname','smb.dlwrf','timeseries',1,'NaN',1,'Inf',1,'>=',0,'size',size(self.Ta));
     392                        md = checkfield(md,'fieldname','smb.P','timeseries',1,'NaN',1,'Inf',1,'>=',0,'<=',200,'size',size(self.Ta));
     393                        md = checkfield(md,'fieldname','smb.eAir','timeseries',1,'NaN',1,'Inf',1,'size',size(self.Ta));
     394
     395                        md = checkfield(md,'fieldname','smb.Tmean','size',[md.mesh.numberofelements 1],'NaN',1,'Inf',1,'>',273-100,'<',273+100); %-100/100 celsius min/max value
     396                        md = checkfield(md,'fieldname','smb.C','size',[md.mesh.numberofelements 1],'NaN',1,'Inf',1,'>',0);
     397                        md = checkfield(md,'fieldname','smb.Vmean','size',[md.mesh.numberofelements 1],'NaN',1,'Inf',1,'>=',0);
     398                        md = checkfield(md,'fieldname','smb.Tz','size',[md.mesh.numberofelements 1],'NaN',1,'Inf',1,'>=',0,'<=',5000);
     399                        md = checkfield(md,'fieldname','smb.Vz','size',[md.mesh.numberofelements 1],'NaN',1,'Inf',1,'>=',0,'<=',5000);
     400
     401                        md = checkfield(md,'fieldname','smb.teValue','timeseries',1,'NaN',1,'Inf',1,'>=',0,'<=',1);
     402
     403                        md = checkfield(md,'fieldname','smb.aIdx','NaN',1,'Inf',1,'values',[0,1,2,3,4]);
     404                        md = checkfield(md,'fieldname','smb.swIdx','NaN',1,'Inf',1,'values',[0,1]);
     405                        md = checkfield(md,'fieldname','smb.denIdx','NaN',1,'Inf',1,'values',[1,2,3,4,5,6,7]);
     406                        md = checkfield(md,'fieldname','smb.dsnowIdx','NaN',1,'Inf',1,'values',[0,1,2,3,4]);
     407
     408                        md = checkfield(md,'fieldname','smb.zTop','NaN',1,'Inf',1,'>=',0);
     409                        md = checkfield(md,'fieldname','smb.dzTop','NaN',1,'Inf',1,'>',0);
     410                        md = checkfield(md,'fieldname','smb.dzMin','NaN',1,'Inf',1,'>',0);
     411                        md = checkfield(md,'fieldname','smb.zY','NaN',1,'Inf',1,'>=',1);
     412                        md = checkfield(md,'fieldname','smb.outputFreq','NaN',1,'Inf',1,'>',0,'<',10*365); %10 years max
     413                        md = checkfield(md,'fieldname','smb.InitDensityScaling','NaN',1,'Inf',1,'>=',0,'<=',1);
     414                        md = checkfield(md,'fieldname','smb.ThermoDeltaTScaling','NaN',1,'Inf',1,'>=',0,'<=',1);
     415                        md = checkfield(md,'fieldname','smb.adThresh','NaN',1,'Inf',1,'>=',0);
     416
     417                        switch self.aIdx,
     418                                case 0
     419                                        md = checkfield(md,'fieldname','smb.aValue','timeseries',1,'NaN',1,'Inf',1,'>=',0,'<=',1);
     420                                case {1 2}
     421                                        md = checkfield(md,'fieldname','smb.aSnow','NaN',1,'Inf',1,'>=',.64,'<=',.89);
     422                                        md = checkfield(md,'fieldname','smb.aIce','NaN',1,'Inf',1,'>=',.27,'<=',.58);
     423                                        if self.aIdx==1
     424                                                md = checkfield(md,'fieldname','smb.szaValue','timeseries',1,'NaN',1,'Inf',1,'>=',0,'<=',90);
     425                                                md = checkfield(md,'fieldname','smb.cotValue','timeseries',1,'NaN',1,'Inf',1,'>=',0);
     426                                                md = checkfield(md,'fieldname','smb.ccsnowValue','timeseries',1,'NaN',1,'Inf',1,'>=',0);
     427                                                md = checkfield(md,'fieldname','smb.cciceValue','timeseries',1,'NaN',1,'Inf',1,'>=',0);
     428                                        end
     429                                case 3
     430                                        md = checkfield(md,'fieldname','smb.cldFrac','NaN',1,'Inf',1,'>=',0,'<=',1);
     431                                case 4
     432                                        md = checkfield(md,'fieldname','smb.t0wet','NaN',1,'Inf',1,'>=',15,'<=',21.9);
     433                                        md = checkfield(md,'fieldname','smb.t0dry','NaN',1,'Inf',1,'>=',30,'<=',30);
     434                                        md = checkfield(md,'fieldname','smb.K','NaN',1,'Inf',1,'>=',7,'<=',7);
     435                        end
     436
     437                        %check zTop is < local thickness:
     438                        he=sum(md.geometry.thickness(md.mesh.elements),2)/size(md.mesh.elements,2);
     439                        if any(he<self.zTop),
     440                                error('SMBgemb consistency check error: zTop should be smaller than local ice thickness');
     441                        end
     442                        md = checkfield(md,'fieldname','smb.steps_per_step','>=',1,'numel',[1]);
     443                        md = checkfield(md,'fieldname','smb.averaging','numel',[1],'values',[0 1 2]);
     444                        md = checkfield(md,'fieldname','smb.requested_outputs','stringrow',1);
     445
     446                end % }}}
    446447                function marshall(self,prefix,md,fid) % {{{
    447448
  • TabularUnified issm/trunk-jpl/src/m/classes/SMBgemb.py

    r26208 r26358  
    88
    99class SMBgemb(object):
     10    """SMBGEMB class definition
     11
     12    Usage:
     13        SMB = SMBgemb()
    1014    """
    11     SMBgemb Class definition
    12 
    13        Usage:
    14           SMB = SMBgemb()
    15     """
    1615
    1716    def __init__(self, *args):  # {{{
    18         #each one of these properties is a transient forcing to the GEMB model, loaded from meteorological data derived
    19         #from an automatic weather stations (AWS). Each property is therefore a matrix, of size (numberofvertices x number
    20         #of time steps. )
     17        """Each one of these properties is a transient forcing to the GEMB
     18        model, loaded from meteorological data derived from an automatic
     19        weather stations (AWS). Each property is therefore a matrix, of size
     20        (numberofvertices x number of time steps.
     21        """
    2122
    2223        #solution choices
    23         #check these:
    24         #self.isgraingrowth = 0
    25         #self.issmbgradients = 0
    26         #isalbedo
    27         #isshortwave
    28         #isthermal
    29         #isaccumulation
    30         #ismelt
    31         #isdensification
    32         #isturbulentflux
    33 
    34         #inputs:
     24        self.isgraingrowth
     25        self.isalbedo
     26        self.isshortwave
     27        self.isthermal
     28        self.isaccumulation
     29        self.ismelt
     30        self.isdensification
     31        self.isturbulentflux
     32        self.isconstrainsurfaceT
     33        self.isclimatology = np.nan
     34
     35        # Inputs
    3536        self.Ta                     = np.nan    # 2 m air temperature, in Kelvin
    3637        self.V                      = np.nan    # wind speed (m/s-1)
     
    4041        self.eAir                   = np.nan    # screen level vapor pressure [Pa]
    4142        self.pAir                   = np.nan    # surface pressure [Pa]
     43
    4244        self.Tmean                  = np.nan    # mean annual temperature [K]
    4345        self.Vmean                  = np.nan    # mean annual wind velocity [m s-1]
     
    4648        self.Vz                     = np.nan    # height above ground at which wind (V) was sampled [m]
    4749
    48         #optional inputs:
    49         self.aValue                 = np.nan    # Albedo forcing at every element.  Used only if aIdx == 0, or density exceeds adThresh
     50        # Optional inputs
     51        self.aValue                 = np.nan    # Albedo forcing at every element. Used only if aIdx == 0, or density exceeds adThresh.
    5052        self.teValue                = np.nan    # Outward longwave radiation thermal emissivity forcing at every element (default in code is 1)
    5153
     
    5456        self.Dini                   = np.nan    # snow density (kg m-3)
    5557        self.Reini                  = np.nan    # effective grain size (mm)
    56         self.Gdnini                 = np.nan    # grain dricity (0-1)
     58        self.Gdnini                 = np.nan    # grain dendricity (0-1)
    5759        self.Gspini                 = np.nan    # grain sphericity (0-1)
    5860        self.ECini                  = np.nan    # evaporation/condensation (kg m-2)
     
    6365        self.Sizeini                = np.nan    # Number of layers
    6466
    65         #settings:
     67        # Settings
    6668        self.aIdx                   = np.nan    # method for calculating albedo and subsurface absorption (default is 1)
    67             # 0: direct input from aValue parameter
    68             # 1: effective grain radius [Gardner & Sharp, 2009]
    69             # 2: effective grain radius [Brun et al., 1992; LeFebre et al., 2003], with swIdx=1, SW penetration follows grain size in 3 spectral bands (Brun et al., 1992)
    70             # 3: density and cloud amount [Greuell & Konzelmann, 1994]
    71             # 4: exponential time decay & wetness [Bougamont & Bamber, 2005]
    72 
    73         self.swIdx                  = np.nan    # apply all SW to top grid cell (0) or allow SW to penetrate surface (1) (default 1, if aIdx=2 function of effective radius (Brun et al., 1992) or else dependent on snow density (taken from Bassford, 2002))
     69        # 0: direct input from aValue parameter
     70        # 1: effective grain radius [Gardner & Sharp, 2009]
     71        # 2: effective grain radius [Brun et al., 1992; LeFebre et al., 2003], with swIdx=1, SW penetration follows grain size in 3 spectral bands (Brun et al., 1992)
     72        # 3: density and cloud amount [Greuell & Konzelmann, 1994]
     73        # 4: exponential time decay & wetness [Bougamont & Bamber, 2005]
     74
     75        self.swIdx                  = np.nan    # apply all SW to top grid cell (0) or allow SW to penetrate surface (1) (default 1, if aIdx=2 function of effective radius (Brun et al., 1992) or else dependent on snow density (taken from Bassford, 2002))
     76
    7477        self.denIdx                 = np.nan    # densification model to use (default is 2):
    75             # 1 = emperical model of Herron and Langway (1980)
    76             # 2 = semi-emperical model of Anthern et al. (2010)
    77             # 3 = DO NOT USE: physical model from Appendix B of Anthern et al. (2010)
    78             # 4 = DO NOT USE: emperical model of Li and Zwally (2004)
    79             # 5 = DO NOT USE: modified emperical model (4) by Helsen et al. (2008)
    80             # 6 = Antarctica semi-emperical model of Ligtenberg et al. (2011)
    81             # 7 = Greenland semi-emperical model of Kuipers Munneke et al. (2015)
     78        # 1 = emperical model of Herron and Langway (1980)
     79        # 2 = semi-emperical model of Anthern et al. (2010)
     80        # 3 = DO NOT USE: physical model from Appendix B of Anthern et al. (2010)
     81        # 4 = DO NOT USE: emperical model of Li and Zwally (2004)
     82        # 5 = DO NOT USE: modified emperical model (4) by Helsen et al. (2008)
     83        # 6 = Antarctica semi-emperical model of Ligtenberg et al. (2011)
     84        # 7 = Greenland semi-emperical model of Kuipers Munneke et al. (2015)
    8285
    8386        self.dsnowIdx               = np.nan    # model for fresh snow accumulation density (default is 1):
    84             # 0 = Original GEMB value, 150 kg/m^3
    85             # 1 = Antarctica value of fresh snow density, 350 kg/m^3
    86             # 2 = Greenland value of fresh snow density, 315 kg/m^3, Fausto et al. (2018)
    87             # 3 = Antarctica model of Kaspers et al. (2004)
    88             # 4 = Greenland model of Kuipers Munneke et al. (2015)
     87        # 0 = Original GEMB value, 150 kg/m^3
     88        # 1 = Antarctica value of fresh snow density, 350 kg/m^3
     89        # 2 = Greenland value of fresh snow density, 315 kg/m^3, Fausto et al. (2018)
     90        # 3 = Antarctica model of Kaspers et al. (2004)
     91        # 4 = Greenland model of Kuipers Munneke et al. (2015)
    8992
    9093        self.zTop                   = np.nan    # depth over which grid length is constant at the top of the snopack (default 10) [m]
    9194        self.dzTop                  = np.nan    # initial top vertical grid spacing (default .05) [m]
    9295        self.dzMin                  = np.nan    # initial min vertical allowable grid spacing (default dzMin/2) [m]
     96
    9397        self.zY                     = np.nan    # strech grid cells bellow top_z by a [top_dz * y ^ (cells bellow top_z)]
    9498        self.zMax                   = np.nan    # initial max model depth (default is min(thickness, 250)) [m]
     
    96100        self.outputFreq             = np.nan    # output frequency in days (default is monthly, 30)
    97101
    98         #specific albedo parameters:
    99         #Method 1
    100         dswdiffrf                   = np.nan    #downward diffusive shortwave radiation flux [W/m^2]
    101         szaValue                    = np.nan    #Solar Zenith Angle [degree]
    102         cotValue                    = np.nan    #Cloud Optical Thickness
    103         ccsnowValue                 = np.nan    #concentration of light absorbing carbon for snow [ppm1]
    104         cciceValue                  = np.nan    #concentration of light absorbing carbon for ice [ppm1]
    105         #Method 1 and 2:
     102        # Specific albedo parameters
     103        # Method 1
     104        self.dswdiffrf              = np.nan    # downward diffusive shortwave radiation flux [W/m^2]
     105        self.szaValue               = np.nan    # Solar Zenith Angle [degree]
     106        self.cotValue               = np.nan    # Cloud Optical Thickness
     107        self.ccsnowValue            = np.nan    # concentration of light absorbing carbon for snow [ppm1]
     108        self.cciceValue             = np.nan    # concentration of light absorbing carbon for ice [ppm1]
     109        # Method 1 and 2
    106110        self.aSnow                  = np.nan    # new snow albedo (0.64 - 0.89)
    107111        self.aIce                   = np.nan    # range 0.27-0.58 for old snow
     
    116120        # Default value is rho water (1023 kg m-3).
    117121
    118         #densities:
     122        # Densities
    119123        self.InitDensityScaling     = np.nan    # initial scaling factor multiplying the density of ice, which describes the density of the snowpack.
    120124
    121         #thermo:
     125        # Thermal
    122126        self.ThermoDeltaTScaling    = np.nan    # scaling factor to multiply the thermal diffusion timestep (delta t)
    123127
     
    126130        self.requested_outputs      = []
    127131
    128         #Several fields are missing from the standard GEMB model, which are capture intrinsically by ISSM.
     132        #Several fields are missing from the standard GEMB model, which are
     133        #captured intrinsically by ISSM.
    129134        #dateN: that's the last row of the above fields.
    130135        #dt:    included in dateN. Not an input.
     
    132137
    133138        nargin = len(args)
    134         if nargin:
    135             if nargin == 2:
    136                 mesh = args[0]
    137                 geometry = args[1]
    138                 self.setdefaultparameters(mesh, geometry)
    139             else:
    140                 raise Exception('constructor not supported: need mesh and geometry to set defaults')
     139        if nargin == 2:
     140            mesh = args[0]
     141            geometry = args[1]
     142            self.setdefaultparameters(mesh, geometry)
     143        else:
     144            raise Exception('constructor not supported: need mesh and geometry to set defaults')
    141145        #}}}
    142146
     
    145149        #string = "#s\n#s"%(string, fielddisplay(self, 'mass_balance', 'surface mass balance [m/yr ice eq]'))
    146150        #string = "#s\n#s"%(string, fielddisplay(self, 'requested_outputs', 'additional outputs requested'))
    147         string = '   surface forcings for SMB GEMB model :'
    148         string = "%s\n%s" % (string, fielddisplay(self, 'issmbgradients', 'is smb gradients method activated (0 or 1, default is 0)'))
    149         string = "%s\n%s" % (string, fielddisplay(self, 'isgraingrowth', 'run grain growth module (default true)'))
    150         string = "%s\n%s" % (string, fielddisplay(self, 'isalbedo', 'run albedo module (default true)'))
    151         string = "%s\n%s" % (string, fielddisplay(self, 'isshortwave', 'run short wave module (default true)'))
    152         string = "%s\n%s" % (string, fielddisplay(self, 'isthermal', 'run thermal module (default true)'))
    153         string = "%s\n%s" % (string, fielddisplay(self, 'isaccumulation', 'run accumulation module (default true)'))
    154         string = "%s\n%s" % (string, fielddisplay(self, 'ismelt', 'run melting module (default true)'))
    155         string = "%s\n%s" % (string, fielddisplay(self, 'isdensification', 'run densification module (default true)'))
    156         string = "%s\n%s" % (string, fielddisplay(self, 'isturbulentflux', 'run turbulant heat fluxes module (default true)'))
    157         string = "%s\n%s" % (string, fielddisplay(self, 'isconstrainsurfaceT', 'constrain surface temperatures to air temperature, turn off EC and surface flux contribution to surface temperature change'))
    158         string = "%s\n%s" % (string, fielddisplay(self, 'Ta', '2 m air temperature, in Kelvin'))
    159         string = "%s\n%s" % (string, fielddisplay(self, 'V', 'wind speed (m s-1)'))
    160         string = "%s\n%s" % (string, fielddisplay(self, 'dswrf', 'downward shortwave radiation flux [W/m^2]'))
    161         string = "%s\n%s" % (string, fielddisplay(self, 'dswdiffrf', 'downward diffusive portion of shortwave radiation flux (default to 0) [W/m^2]'))
    162         string = "%s\n%s" % (string, fielddisplay(self, 'dlwrf', 'downward longwave radiation flux [W/m^2]'))
    163         string = "%s\n%s" % (string, fielddisplay(self, 'P', 'precipitation [mm w.e. / m^2]'))
    164         string = "%s\n%s" % (string, fielddisplay(self, 'eAir', 'screen level vapor pressure [Pa]'))
    165         string = "%s\n%s" % (string, fielddisplay(self, 'pAir', 'surface pressure [Pa]'))
    166         string = "%s\n%s" % (string, fielddisplay(self, 'Tmean', 'mean annual temperature [K]'))
    167         string = "%s\n%s" % (string, fielddisplay(self, 'C', 'mean annual snow accumulation [kg m-2 yr-1]'))
    168         string = "%s\n%s" % (string, fielddisplay(self, 'Vmean', 'mean annual temperature [m s-1] (default 10 m/s)'))
    169         string = "%s\n%s" % (string, fielddisplay(self, 'Tz', 'height above ground at which temperature (T) was sampled [m]'))
    170         string = "%s\n%s" % (string, fielddisplay(self, 'Vz', 'height above ground at which wind (V) eas sampled [m]'))
    171         string = "%s\n%s" % (string, fielddisplay(self, 'zTop', 'depth over which grid length is constant at the top of the snopack (default 10) [m]'))
    172         string = "%s\n%s" % (string, fielddisplay(self, 'dzTop', 'initial top vertical grid spacing (default .05) [m] '))
    173         string = "%s\n%s" % (string, fielddisplay(self, 'dzMin', 'initial min vertical allowable grid spacing (default dzMin/2) [m] '))
    174         string = "%s\n%s" % (string, fielddisplay(self, 'zMax', 'initial max model depth (default is min(thickness, 500)) [m]'))
    175         string = "%s\n%s" % (string, fielddisplay(self, 'zMin', 'initial min model depth (default is min(thickness, 30)) [m]'))
    176         string = "%s\n%s" % (string, fielddisplay(self, 'zY', 'strech grid cells bellow top_z by a [top_dz * y ^ (cells bellow top_z)]'))
    177         string = "%s\n%s" % (string, fielddisplay(self, 'InitDensityScaling', ['initial scaling factor multiplying the density of ice', 'which describes the density of the snowpack.']))
    178         string = "%s\n%s" % (string, fielddisplay(self, 'ThermoDeltaTScaling', 'scaling factor to multiply the thermal diffusion timestep (delta t)'))
    179         string = "%s\n%s" % (string, fielddisplay(self, 'outputFreq', 'output frequency in days (default is monthly, 30)'))
    180         string = "%s\n%s" % (string, fielddisplay(self, 'adThresh', 'Apply aIdx method to all areas with densities below this value, ', 'or else apply direct input value from aValue, allowing albedo to be altered.'))
    181         string = "%s\n%s" % (string, fielddisplay(self, 'aIdx', ['method for calculating albedo and subsurface absorption (default is 1)',
    182                                                                  '0: direct input from aValue parameter',
    183                                                                  '1: effective grain radius [Gardner & Sharp, 2009]',
    184                                                                  '2: effective grain radius [Brun et al., 1992; LeFebre et al., 2003], with swIdx=1, SW penetration follows grain size in 3 spectral bands (Brun et al., 1992)',
    185                                                                  '3: density and cloud amount [Greuell & Konzelmann, 1994]',
    186                                                                  '4: exponential time decay & wetness [Bougamont & Bamber, 2005]']))
    187         string = "%s\n%s" % (string, fielddisplay(self, 'teValue', 'Outward longwave radiation thermal emissivity forcing at every element (default in code is 1)'))
    188         #snow properties init
    189         string = "%s\n%s" % (string, fielddisplay(self, 'Dzini', 'Initial cell depth when restart [m]'))
    190         string = "%s\n%s" % (string, fielddisplay(self, 'Dini', 'Initial snow density when restart [kg m-3]'))
    191         string = "%s\n%s" % (string, fielddisplay(self, 'Reini', 'Initial grain size when restart [mm]'))
    192         string = "%s\n%s" % (string, fielddisplay(self, 'Gdnini', 'Initial grain dricity when restart [-]'))
    193         string = "%s\n%s" % (string, fielddisplay(self, 'Gspini', 'Initial grain sphericity when restart [-]'))
    194         string = "%s\n%s" % (string, fielddisplay(self, 'ECini', 'Initial evaporation/condensation when restart [kg m-2]'))
    195         string = "%s\n%s" % (string, fielddisplay(self, 'Wini', 'Initial snow water content when restart [kg m-2]'))
    196         string = "%s\n%s" % (string, fielddisplay(self, 'Aini', 'Initial albedo when restart [-]'))
    197         string = "%s\n%s" % (string, fielddisplay(self, 'Adiffini', 'Initial diffusive radiation albedo when restart (default to 1) [-]'))
    198         string = "%s\n%s" % (string, fielddisplay(self, 'Tini', 'Initial snow temperature when restart [K]'))
    199         string = "%s\n%s" % (string, fielddisplay(self, 'Sizeini', 'Initial number of layers when restart [-]'))
    200 
    201         #additional albedo parameters:
    202         string = "%s\n%s" % (string, fielddisplay(self, 'aValue', 'Albedo forcing at every element'))
     151        s = '   surface forcings for SMB GEMB model :\n'
     152        s += '{}\n'.format(fielddisplay(self, 'isgraingrowth', 'run grain growth module (default true)'))
     153        s += '{}\n'.format(fielddisplay(self, 'isalbedo', 'run albedo module (default true)'))
     154        s += '{}\n'.format(fielddisplay(self, 'isshortwave', 'run short wave module (default true)'))
     155        s += '{}\n'.format(fielddisplay(self, 'isthermal', 'run thermal module (default true)'))
     156        s += '{}\n'.format(fielddisplay(self, 'isaccumulation', 'run accumulation module (default true)'))
     157        s += '{}\n'.format(fielddisplay(self, 'ismelt', 'run melting module (default true)'))
     158        s += '{}\n'.format(fielddisplay(self, 'isdensification', 'run densification module (default true)'))
     159        s += '{}\n'.format(fielddisplay(self, 'isturbulentflux', 'run turbulant heat fluxes module (default true)'))
     160        s += '{}\n'.format(fielddisplay(self, 'isconstrainsurfaceT', 'constrain surface temperatures to air temperature, turn off EC and surface flux contribution to surface temperature change'))
     161        s += '{}\n'.format(fielddisplay(self, 'Ta', '2 m air temperature, in Kelvin'))
     162        s += '{}\n'.format(fielddisplay(self, 'V', 'wind speed (m s-1)'))
     163        s += '{}\n'.format(fielddisplay(self, 'dswrf', 'downward shortwave radiation flux [W/m^2]'))
     164        s += '{}\n'.format(fielddisplay(self, 'dswdiffrf', 'downward diffusive portion of shortwave radiation flux (default to 0) [W/m^2]'))
     165        s += '{}\n'.format(fielddisplay(self, 'dlwrf', 'downward longwave radiation flux [W/m^2]'))
     166        s += '{}\n'.format(fielddisplay(self, 'P', 'precipitation [mm w.e. / m^2]'))
     167        s += '{}\n'.format(fielddisplay(self, 'eAir', 'screen level vapor pressure [Pa]'))
     168        s += '{}\n'.format(fielddisplay(self, 'pAir', 'surface pressure [Pa]'))
     169        s += '{}\n'.format(fielddisplay(self, 'Tmean', 'mean annual temperature [K]'))
     170        s += '{}\n'.format(fielddisplay(self, 'C', 'mean annual snow accumulation [kg m-2 yr-1]'))
     171        s += '{}\n'.format(fielddisplay(self, 'Vmean', 'mean annual temperature [m s-1] (default 10 m/s)'))
     172        s += '{}\n'.format(fielddisplay(self, 'Tz', 'height above ground at which temperature (T) was sampled [m]'))
     173        s += '{}\n'.format(fielddisplay(self, 'Vz', 'height above ground at which wind (V) eas sampled [m]'))
     174        s += '{}\n'.format(fielddisplay(self, 'zTop', 'depth over which grid length is constant at the top of the snopack (default 10) [m]'))
     175        s += '{}\n'.format(fielddisplay(self, 'dzTop', 'initial top vertical grid spacing (default .05) [m] '))
     176        s += '{}\n'.format(fielddisplay(self, 'dzMin', 'initial min vertical allowable grid spacing (default dzMin/2) [m] '))
     177        s += '{}\n'.format(fielddisplay(self, 'zMax', 'initial max model depth (default is min(thickness, 500)) [m]'))
     178        s += '{}\n'.format(fielddisplay(self, 'zMin', 'initial min model depth (default is min(thickness, 30)) [m]'))
     179        s += '{}\n'.format(fielddisplay(self, 'zY', 'strech grid cells bellow top_z by a [top_dz * y ^ (cells bellow top_z)]'))
     180        s += '{}\n'.format(fielddisplay(self, 'InitDensityScaling', ['initial scaling factor multiplying the density of ice', 'which describes the density of the snowpack.']))
     181        s += '{}\n'.format(fielddisplay(self, 'ThermoDeltaTScaling', 'scaling factor to multiply the thermal diffusion timestep (delta t)'))
     182        s += '{}\n'.format(fielddisplay(self, 'outputFreq', 'output frequency in days (default is monthly, 30)'))
     183        s += '{}\n'.format(fielddisplay(self, 'adThresh', 'Apply aIdx method to all areas with densities below this value, ', 'or else apply direct input value from aValue, allowing albedo to be altered.'))
     184        s += '{}\n'.format(fielddisplay(self, 'aIdx', ['method for calculating albedo and subsurface absorption (default is 1)',
     185            '0: direct input from aValue parameter',
     186            '1: effective grain radius [Gardner & Sharp, 2009]',
     187            '2: effective grain radius [Brun et al., 1992; LeFebre et al., 2003], with swIdx=1, SW penetration follows grain size in 3 spectral bands (Brun et al., 1992)',
     188            '3: density and cloud amount [Greuell & Konzelmann, 1994]',
     189            '4: exponential time decay & wetness [Bougamont & Bamber, 2005]']))
     190        s += '{}\n'.format(fielddisplay(self, 'teValue', 'Outward longwave radiation thermal emissivity forcing at every element (default in code is 1)'))
     191
     192        # Snow properties init
     193        s += '{}\n'.format(fielddisplay(self, 'Dzini', 'Initial cell depth when restart [m]'))
     194        s += '{}\n'.format(fielddisplay(self, 'Dini', 'Initial snow density when restart [kg m-3]'))
     195        s += '{}\n'.format(fielddisplay(self, 'Reini', 'Initial grain size when restart [mm]'))
     196        s += '{}\n'.format(fielddisplay(self, 'Gdnini', 'Initial grain dricity when restart [-]'))
     197        s += '{}\n'.format(fielddisplay(self, 'Gspini', 'Initial grain sphericity when restart [-]'))
     198        s += '{}\n'.format(fielddisplay(self, 'ECini', 'Initial evaporation/condensation when restart [kg m-2]'))
     199        s += '{}\n'.format(fielddisplay(self, 'Wini', 'Initial snow water content when restart [kg m-2]'))
     200        s += '{}\n'.format(fielddisplay(self, 'Aini', 'Initial albedo when restart [-]'))
     201        s += '{}\n'.format(fielddisplay(self, 'Adiffini', 'Initial diffusive radiation albedo when restart (default to 1) [-]'))
     202        s += '{}\n'.format(fielddisplay(self, 'Tini', 'Initial snow temperature when restart [K]'))
     203        s += '{}\n'.format(fielddisplay(self, 'Sizeini', 'Initial number of layers when restart [-]'))
     204
     205        # Additional albedo parameters
     206        s += '{}\n'.format(fielddisplay(self, 'aValue', 'Albedo forcing at every element'))
    203207        if isinstance(self.aIdx, (list, type(np.array([1, 2])))) and (self.aIdx == [1, 2] or (1 in self.aIdx and 2 in self.aIdx)):
    204             string = "%s\n%s" % (string, fielddisplay(self, 'aSnow', 'new snow albedo (0.64 - 0.89)'))
    205             string = "%s\n%s" % (string, fielddisplay(self, 'aIce', 'albedo of ice (0.27-0.58)'))
     208            s += '{}\n'.format(fielddisplay(self, 'aSnow', 'new snow albedo (0.64 - 0.89)'))
     209            s += '{}\n'.format(fielddisplay(self, 'aIce', 'albedo of ice (0.27-0.58)'))
    206210            if self.aIdx == 1:
    207                 string = "%s\n%s" % (string, fielddisplay(self,'szaValue','Solar Zenith Angle [degree]'))
    208                 string = "%s\n%s" % (string, fielddisplay(self,'cotValue','Cloud Optical Thickness'))
    209                 string = "%s\n%s" % (string, fielddisplay(self,'ccsnowValue','concentration of light absorbing carbon for snow [ppm1]'))
    210                 string = "%s\n%s" % (string, fielddisplay(self,'cciceValue','concentration of light absorbing carbon for snow [ppm1]'))
    211 
     211                s += '{}\n'.format(fielddisplay(self,'szaValue','Solar Zenith Angle [degree]'))
     212                s += '{}\n'.format(fielddisplay(self,'cotValue','Cloud Optical Thickness'))
     213                s += '{}\n'.format(fielddisplay(self,'ccsnowValue','concentration of light absorbing carbon for snow [ppm1]'))
     214                s += '{}\n'.format(fielddisplay(self,'cciceValue','concentration of light absorbing carbon for snow [ppm1]'))
    212215        elif self.aIdx == 3:
    213             string = "%s\n%s" % (string, fielddisplay(self, 'cldFrac', 'average cloud amount'))
     216            s += '{}\n'.format(fielddisplay(self, 'cldFrac', 'average cloud amount'))
    214217        elif self.aIdx == 4:
    215             string = "%s\n%s" % (string, fielddisplay(self, 't0wet', 'time scale for wet snow (15-21.9) [d]'))
    216             string = "%s\n%s" % (string, fielddisplay(self, 't0dry', 'warm snow timescale (30) [d]'))
    217             string = "%s\n%s" % (string, fielddisplay(self, 'K', 'time scale temperature coef. (7) [d]'))
    218 
    219         string = "%s\n%s" % (string, fielddisplay(self, 'swIdx', 'apply all SW to top grid cell (0) or allow SW to penetrate surface (1) [default 1, if aIdx=2 function of effective radius (Brun et al., 1992) or else dependent on snow density (taken from Bassford, 2002)]'))
    220         string = "%s\n%s" % (string, fielddisplay(self, 'denIdx', ['densification model to use (default is 2):',
    221                                                                    '1 = emperical model of Herron and Langway (1980)',
    222                                                                    '2 = semi-emperical model of Anthern et al. (2010)',
    223                                                                    '3 = DO NOT USE: physical model from Appix B of Anthern et al. (2010)',
    224                                                                    '4 = DO NOT USE: emperical model of Li and Zwally (2004)',
    225                                                                    '5 = DO NOT USE: modified emperical model (4) by Helsen et al. (2008)',
    226                                                                    '6 = Antarctica semi-emperical model of Ligtenberg et al. (2011)',
    227                                                                    '7 = Greenland semi-emperical model of Kuipers Munneke et al. (2015)']))
    228         string = "%s\n%s" % (string, fielddisplay(self, 'dsnowIdx', ['model for fresh snow accumulation density (default is 1):',
    229                                                                      '0 = Original GEMB value, 150 kg/m^3',
    230                                                                      '1 = Antarctica value of fresh snow density, 350 kg/m^3',
    231                                                                      '2 = Greenland value of fresh snow density, 315 kg/m^3, Fausto et al. (2018)',
    232                                                                      '3 = Antarctica model of Kaspers et al. (2004), Make sure to set Vmean accurately',
    233                                                                      '4 = Greenland model of Kuipers Munneke et al. (2015)']))
    234         string = "%s\n%s" % (string, fielddisplay(self, 'steps_per_step', 'number of smb steps per time step'))
    235         string = "%s\n%s" % (string, fielddisplay(self, 'averaging', 'averaging methods from short to long steps'))
    236         string = "%s\n\t\t%s" % (string, '0: Arithmetic (default)')
    237         string = "%s\n\t\t%s" % (string, '1: Geometric')
    238         string = "%s\n\t\t%s" % (string, '2: Harmonic')
    239         string = "%s\n%s" % (string, fielddisplay(self, 'requested_outputs', 'additional outputs requested'))
    240         return string
     218            s += '{}\n'.format(fielddisplay(self, 't0wet', 'time scale for wet snow (15-21.9) [d]'))
     219            s += '{}\n'.format(fielddisplay(self, 't0dry', 'warm snow timescale (30) [d]'))
     220            s += '{}\n'.format(fielddisplay(self, 'K', 'time scale temperature coef. (7) [d]'))
     221
     222        s += '{}\n'.format(fielddisplay(self, 'swIdx', 'apply all SW to top grid cell (0) or allow SW to penetrate surface (1) [default 1, if aIdx=2 function of effective radius (Brun et al., 1992) or else dependent on snow density (taken from Bassford, 2002)]'))
     223        s += '{}\n'.format(fielddisplay(self, 'denIdx', ['densification model to use (default is 2):',
     224            '1 = emperical model of Herron and Langway (1980)',
     225            '2 = semi-emperical model of Anthern et al. (2010)',
     226            '3 = DO NOT USE: physical model from Appix B of Anthern et al. (2010)',
     227            '4 = DO NOT USE: emperical model of Li and Zwally (2004)',
     228            '5 = DO NOT USE: modified emperical model (4) by Helsen et al. (2008)',
     229            '6 = Antarctica semi-emperical model of Ligtenberg et al. (2011)',
     230            '7 = Greenland semi-emperical model of Kuipers Munneke et al. (2015)']))
     231        s += '{}\n'.format(fielddisplay(self, 'dsnowIdx', ['model for fresh snow accumulation density (default is 1):',
     232            '0 = Original GEMB value, 150 kg/m^3',
     233            '1 = Antarctica value of fresh snow density, 350 kg/m^3',
     234            '2 = Greenland value of fresh snow density, 315 kg/m^3, Fausto et al. (2018)',
     235            '3 = Antarctica model of Kaspers et al. (2004), Make sure to set Vmean accurately',
     236            '4 = Greenland model of Kuipers Munneke et al. (2015)']))
     237
     238        s += '{}\n'.format(fielddisplay(self, 'steps_per_step', 'number of smb steps per time step'))
     239        s += '{}\n'.format(fielddisplay(self, 'averaging', 'averaging methods from short to long steps'))
     240        s += '\t\t{}\n'.format('0: Arithmetic (default)')
     241        s += '\t\t{}\n'.format('1: Geometric')
     242        s += '\t\t{}\n'.format('2: Harmonic')
     243        s += '{}\n'.format(fielddisplay(self, 'requested_outputs', 'additional outputs requested'))
     244        return s
    241245    #}}}
    242246
     
    245249        self.V = project3d(md, 'vector', self.V, 'type', 'element')
    246250        self.dswrf = project3d(md, 'vector', self.dswrf, 'type', 'element')
    247         self.dswrf = project3d(md, 'vector', self.dswrf, 'type', 'element')
     251        self.dslrf = project3d(md, 'vector', self.dslrf, 'type', 'element')
    248252        self.P = project3d(md, 'vector', self.P, 'type', 'element')
    249253        self.eAir = project3d(md, 'vector', self.eAir, 'type', 'element')
     
    270274        if not np.isnan(self.Tini):
    271275            self.Tini=project3d(md,'vector',self.Tini,'type','element');
     276
    272277        if not np.isnan(self.dswdiffrf):
    273278            self.dswdiffrf=project3d(md,'vector',self.dswdiffrf,'type','element');
     
    295300    def setdefaultparameters(self, mesh, geometry):  # {{{
    296301        self.isgraingrowth = 1
    297         self.issmbgradients = 0
    298302        self.isalbedo = 1
    299303        self.isshortwave = 1
     
    310314        self.dsnowIdx = 1
    311315        self.zTop = 10 * np.ones((mesh.numberofelements,))
    312         self.dzTop = .05 * np.ones((mesh.numberofelements,))
     316        self.dzTop = 0.05 * np.ones((mesh.numberofelements,))
    313317        self.dzMin = self.dzTop / 2
    314318        self.InitDensityScaling = 1.0
     
    322326        self.outputFreq = 30
    323327
    324         #additional albedo parameters
     328        # Additional albedo parameters
    325329        self.aSnow = 0.85
    326330        self.aIce = 0.48
     
    347351        self.ECini = 0.0 * np.ones((mesh.numberofelements,))
    348352        self.Wini = 0.0 * np.ones((mesh.numberofelements, 2))
    349         self.Aini = self.aSnow * np.ones((mesh.numberofelements, 2))
     353        self.Aini = 0.0 * np.ones((mesh.numberofelements, 2))
    350354        self.Adiffini = np.ones((mesh.numberofelements, 2))
    351355        self.Tini = 273.15 * np.ones((mesh.numberofelements, 2))
    352 #       /!\ Default value of Tini must be equal to Tmean but don't know Tmean yet (computed when atmospheric forcings are interpolated on mesh).
    353 #       If initialization without restart, this value will be overwritten when snow parameters are retrieved in Element.cpp
     356        #       /!\ Default value of Tini must be equal to Tmean but don't know
     357        #           Tmean yet (computed when atmospheric forcings are
     358        #           interpolated on mesh).
     359        #           If initialization without restart, this value will be
     360        #           overwritten when snow parameters are retrieved in
     361        #           Element.cpp
    354362        self.Sizeini = 2 * np.ones((mesh.numberofelements,))
    355363    #}}}
     
    358366
    359367        md = checkfield(md, 'fieldname', 'smb.isgraingrowth', 'values', [0, 1])
    360         md = checkfield(md, 'fieldname', 'smb.issmbgradients', 'values', [0, 1])
    361368        md = checkfield(md, 'fieldname', 'smb.isalbedo', 'values', [0, 1])
    362369        md = checkfield(md, 'fieldname', 'smb.isshortwave', 'values', [0, 1])
     
    398405        md = checkfield(md, 'fieldname', 'smb.adThresh', 'NaN', 1, 'Inf', 1, '>=', 0)
    399406
    400         if isinstance(self.aIdx, (list, type(np.array([1, 2])))) and (self.aIdx == [1, 2] or (1 in self.aIdx and 2 in self.aIdx)):
     407        if self.aIdx == 0:
     408            md = checkfield(md, 'fieldname', 'smb.aValue', 'timeseries', 1, 'NaN', 1, 'Inf', 1, '>=', 0, '<=', 1)
     409        elif isinstance(self.aIdx, (list, type(np.array([1, 2])))) and (self.aIdx == [1, 2] or (1 in self.aIdx and 2 in self.aIdx)):
    401410            md = checkfield(md, 'fieldname', 'smb.aSnow', 'NaN', 1, 'Inf', 1, '> = ', .64, '< = ', .89)
    402411            md = checkfield(md, 'fieldname', 'smb.aIce', 'NaN', 1, 'Inf', 1, '> = ', .27, '< = ', .58)
     
    406415                md = checkfield(md,'fieldname','smb.ccsnowValue','timeseries',1,'NaN',1,'Inf',1,'>=',0)
    407416                md = checkfield(md,'fieldname','smb.cciceValue','timeseries',1,'NaN',1,'Inf',1,'>=',0)
    408 
    409         elif self.aIdx == 0:
    410             md = checkfield(md, 'fieldname', 'smb.aValue', 'timeseries', 1, 'NaN', 1, 'Inf', 1, '>=', 0, '<=', 1)
    411417        elif self.aIdx == 3:
    412418            md = checkfield(md, 'fieldname', 'smb.cldFrac', 'NaN', 1, 'Inf', 1, '> = ', 0, '< = ', 1)
     
    416422            md = checkfield(md, 'fieldname', 'smb.K', 'NaN', 1, 'Inf', 1, '> = ', 7, '< = ', 7)
    417423
    418         #check zTop is < local thickness:
     424        # Check zTop is < local thickness
    419425        he = np.sum(md.geometry.thickness[md.mesh.elements - 1], axis=1) / np.size(md.mesh.elements, 1)
    420426        if np.any(he < self.zTop):
     
    432438
    433439        WriteData(fid, prefix, 'object', self, 'class', 'smb', 'fieldname', 'isgraingrowth', 'format', 'Boolean')
    434         WriteData(fid, prefix, 'object', self, 'class', 'smb', 'fieldname', 'issmbgradients', 'format', 'Boolean')
    435440        WriteData(fid, prefix, 'object', self, 'class', 'smb', 'fieldname', 'isalbedo', 'format', 'Boolean')
    436441        WriteData(fid, prefix, 'object', self, 'class', 'smb', 'fieldname', 'isshortwave', 'format', 'Boolean')
     
    441446        WriteData(fid, prefix, 'object', self, 'class', 'smb', 'fieldname', 'isturbulentflux', 'format', 'Boolean')
    442447        WriteData(fid, prefix, 'object', self, 'class', 'smb', 'fieldname', 'isconstrainsurfaceT', 'format', 'Boolean')
     448
    443449        WriteData(fid, prefix, 'object', self, 'class', 'smb', 'fieldname', 'Ta', 'format', 'DoubleMat', 'mattype', 2, 'timeserieslength', md.mesh.numberofelements + 1, 'yts', yts)
    444450        WriteData(fid, prefix, 'object', self, 'class', 'smb', 'fieldname', 'V', 'format', 'DoubleMat', 'mattype', 2, 'timeserieslength', md.mesh.numberofelements + 1, 'yts', yts)
     
    498504        WriteData(fid, prefix, 'object', self, 'fieldname', 'steps_per_step', 'format', 'Integer')
    499505        WriteData(fid, prefix, 'object', self, 'fieldname', 'averaging', 'format', 'Integer')
    500         #figure out dt from forcings:
     506        # Figure out dt from forcings
    501507        if (np.any(self.P[-1] - self.Ta[-1] != 0) | np.any(self.V[-1] - self.Ta[-1] != 0) | np.any(self.dswrf[-1] - self.Ta[-1] != 0) | np.any(self.dlwrf[-1] - self.Ta[-1] != 0) | np.any(self.eAir[-1] - self.Ta[-1] != 0) | np.any(self.pAir[-1] - self.Ta[-1] != 0)):
    502508            raise IOError('All GEMB forcings (Ta, P, V, dswrf, dlwrf, eAir, pAir) must have the same time steps in the final row!')
     
    517523            raise IOError('If GEMB forcing cciceValue is transient, it must have the same time steps as input Ta in the final row!')
    518524
    519         time = self.Ta[-1]  #assume all forcings are on the same time step
     525        time = self.Ta[-1]  # Assume all forcings are on the same time step
    520526        dtime = np.diff(time, n=1, axis=0)
    521527        dt = min(dtime)
     
    525531        # Check if smb_dt goes evenly into transient core time step
    526532        if (md.timestepping.time_step % dt >= 1e-10):
    527             raise IOError('smb_dt/dt = #f. The number of SMB time steps in one transient core time step has to be an an integer', md.timestepping.time_step / dt)
    528 
    529         #process requested outputs
     533            raise IOError('smb_dt/dt = {}. The number of SMB time steps in one transient core time step has to be an an integer'.format(md.timestepping.time_step / dt))
     534
     535        # Process requested outputs
    530536        outputs = self.requested_outputs
    531537        indices = [i for i, x in enumerate(outputs) if x == 'default']
  • TabularUnified issm/trunk-jpl/src/m/classes/SMBmeltcomponents.m

    r26209 r26358  
    1010                melt = NaN;
    1111                refreeze = NaN;
    12                 steps_per_step=1;
     12                steps_per_step = 1;
    1313                averaging = 0;
    14                 requested_outputs      = {};
     14                requested_outputs= {};
    1515                isclimatology;
    1616        end
     
    2222                                        error('constructor not supported');
    2323                        end
     24                end % }}}
     25                function disp(self) % {{{
     26                        disp(sprintf('   surface forcings parameters with melt (SMB=accumulation-evaporation-melt+refreeze) :'));
     27                        fielddisplay(self,'accumulation','accumulated snow [m/yr ice eq]');
     28                        fielddisplay(self,'evaporation','amount of ice lost to evaporative processes [m/yr ice eq]');
     29                        fielddisplay(self,'melt','amount of ice melt in ice column [m/yr ice eq]');
     30                        fielddisplay(self,'refreeze','amount of ice melt refrozen in ice column [m/yr ice eq]');
     31                        fielddisplay(self, 'steps_per_step', 'number of smb steps per time step');
     32                        fielddisplay(self, 'averaging', 'averaging methods from short to long steps');
     33                        disp(sprintf('%51s  0: Arithmetic (default)',' '));
     34                        disp(sprintf('%51s  1: Geometric',' '));
     35                        disp(sprintf('%51s  2: Harmonic',' '));
     36                        fielddisplay(self,'requested_outputs','additional outputs requested');
    2437                end % }}}
    2538                function self = extrude(self,md) % {{{
     
    7285                        md = checkfield(md,'fieldname','smb.requested_outputs','stringrow',1);
    7386                end % }}}
    74                 function disp(self) % {{{
    75                         disp(sprintf('   surface forcings parameters with melt (SMB=accumulation-evaporation-melt+refreeze) :'));
    76                         fielddisplay(self,'accumulation','accumulated snow [m/yr ice eq]');
    77                         fielddisplay(self,'evaporation','amount of ice lost to evaporative processes [m/yr ice eq]');
    78                         fielddisplay(self,'melt','amount of ice melt in ice column [m/yr ice eq]');
    79                         fielddisplay(self,'refreeze','amount of ice melt refrozen in ice column [m/yr ice eq]');
    80                         fielddisplay(self, 'steps_per_step', 'number of smb steps per time step');
    81                         fielddisplay(self, 'averaging', 'averaging methods from short to long steps');
    82                         disp(sprintf('%51s  0: Arithmetic (default)',' '));
    83                         disp(sprintf('%51s  1: Geometric',' '));
    84                         disp(sprintf('%51s  2: Harmonic',' '));
    85                         fielddisplay(self,'requested_outputs','additional outputs requested');
    86                 end % }}}
    8787                function marshall(self,prefix,md,fid) % {{{
    8888
  • TabularUnified issm/trunk-jpl/src/m/classes/SMBmeltcomponents.py

    r26208 r26358  
     1import numpy as np
     2
     3from checkfield import *
    14from fielddisplay import fielddisplay
    2 from checkfield import *
    35from project3d import *
    46from WriteData import *
     
    68
    79class SMBmeltcomponents(object):
    8     """
    9     SMBmeltcomponents Class definition
     10    """SMBMELTCOMPONENTS lass definition
    1011
    11        Usage:
    12           SMBmeltcomponents = SMBmeltcomponents();
     12    Usage:
     13        SMBmeltcomponents = SMBmeltcomponents();
    1314    """
    1415
    1516    def __init__(self):  # {{{
    16         self.accumulation = float('NaN')
    17         self.runoff = float('NaN')
    18         self.evaporation = float('NaN')
     17        self.accumulation = np.nan
     18        self.evaporation = np.nan
     19        self.melt = np.nan
     20        self.refreeze = np.nan
    1921        self.steps_per_step = 1
    2022        self.averaging = 0
    2123        self.requested_outputs = []
     24        self.isclimatology = np.nan
     25
     26        if len(args) == 0:
     27            pass
     28        else:
     29            error('constructor not supported')
    2230    #}}}
    2331
    2432    def __repr__(self):  # {{{
    25         string = "   surface forcings parameters with melt (SMB = accumulation-evaporation-melt+refreeze) :"
    26         string = "%s\n%s" % (string, fielddisplay(self, 'accumulation', 'accumulated snow [m/yr ice eq]'))
    27         string = "%s\n%s" % (string, fielddisplay(self, 'evaporation', 'mount of ice lost to evaporative processes [m/yr ice eq]'))
    28         string = "%s\n%s" % (string, fielddisplay(self, 'melt', 'amount of ice melt in the ice column [m/yr ice eq]'))
    29         string = "%s\n%s" % (string, fielddisplay(self, 'refreeze', 'amount of ice melt refrozen in the ice column [m/yr ice eq]'))
    30         string = "%s\n%s" % (string, fielddisplay(self, 'steps_per_step', 'number of smb steps per time step'))
    31         string = "%s\n%s" % (string, fielddisplay(self, 'averaging', 'averaging methods from short to long steps'))
    32         string = "%s\n\t\t%s" % (string, '0: Arithmetic (default)')
    33         string = "%s\n\t\t%s" % (string, '1: Geometric')
    34         string = "%s\n\t\t%s" % (string, '2: Harmonic')
    35         string = "%s\n%s" % (string, fielddisplay(self, 'requested_outputs', 'additional outputs requested'))
    36         return string
     33        s = '   surface forcings parameters with melt (SMB = accumulation-evaporation-melt+refreeze) :\n'
     34        s += '{}\n'.format(fielddisplay(self, 'accumulation', 'accumulated snow [m/yr ice eq]'))
     35        s += '{}\n'.format(fielddisplay(self, 'evaporation', 'mount of ice lost to evaporative processes [m/yr ice eq]'))
     36        s += '{}\n'.format(fielddisplay(self, 'melt', 'amount of ice melt in the ice column [m/yr ice eq]'))
     37        s += '{}\n'.format(fielddisplay(self, 'refreeze', 'amount of ice melt refrozen in the ice column [m/yr ice eq]'))
     38        s += '{}\n'.format(fielddisplay(self, 'steps_per_step', 'number of smb steps per time step'))
     39        s += '{}\n'.format(fielddisplay(self, 'averaging', 'averaging methods from short to long steps'))
     40        s += '\t\t{}\n'.format('0: Arithmetic (default)')
     41        s += '\t\t{}\n'.format('1: Geometric')
     42        s += '\t\t{}\n'.format('2: Harmonic')
     43        s += '{}\n'.format(fielddisplay(self, 'requested_outputs', 'additional outputs requested'))
     44        return s
    3745    #}}}
    3846
     
    5260        if np.all(np.isnan(self.accumulation)):
    5361            self.accumulation = np.zeros((md.mesh.numberofvertices))
    54             print("      no SMB.accumulation specified: values set as zero")
     62            print("      no smb.accumulation specified: values set as zero")
    5563
    5664        if np.all(np.isnan(self.evaporation)):
    5765            self.evaporation = np.zeros((md.mesh.numberofvertices))
    58             print("      no SMB.evaporation specified: values set as zero")
     66            print("      no smb.evaporation specified: values set as zero")
     67
     68        if np.all(np.isnan(self.refreeze)):
     69            self.refreeze = np.zeros((md.mesh.numberofvertices))
     70            print("      no smb.refreeze specified: values set as zero")
    5971
    6072        if np.all(np.isnan(self.melt)):
    6173            self.melt = np.zeros((md.mesh.numberofvertices))
    62             print("      no SMB.melt specified: values set as zero")
    63 
    64         if np.all(np.isnan(self.refreeze)):
    65             self.refreeze = np.zeros((md.mesh.numberofvertices))
    66             print("      no SMB.refreeze specified: values set as zero")
     74            print("      no smb.melt specified: values set as zero")
    6775
    6876        return self
    6977    #}}}
    7078
    71     def checkconsistency(self, md, solution, analyses):    # {{{
     79    def checkconsistency(self, md, solution, analyses):  # {{{
    7280        if 'MasstransportAnalysis' in analyses:
    7381            md = checkfield(md, 'fieldname', 'smb.accumulation', 'timeseries', 1, 'NaN', 1, 'Inf', 1)
     82            md = checkfield(md, 'fieldname', 'smb.evaporation', 'timeseries', 1, 'NaN', 1, 'Inf', 1)
     83            md = checkfield(md, 'fieldname', 'smb.refreeze', 'timeseries', 1, 'NaN', 1, 'Inf', 1)
    7484            md = checkfield(md, 'fieldname', 'smb.melt', 'timeseries', 1, 'NaN', 1, 'Inf', 1)
    75             md = checkfield(md, 'fieldname', 'smb.refreeze', 'timeseries', 1, 'NaN', 1, 'Inf', 1)
    76             md = checkfield(md, 'fieldname', 'smb.evaporation', 'timeseries', 1, 'NaN', 1, 'Inf', 1)
    7785
    7886        if 'BalancethicknessAnalysis' in analyses:
    7987            md = checkfield(md, 'fieldname', 'smb.accumulation', 'size', [md.mesh.numberofvertices], 'NaN', 1, 'Inf', 1)
     88            md = checkfield(md, 'fieldname', 'smb.evaporation', 'size', [md.mesh.numberofvertices], 'NaN', 1, 'Inf', 1)
     89            md = checkfield(md, 'fieldname', 'smb.refreeze', 'size', [md.mesh.numberofvertices], 'NaN', 1, 'Inf', 1)
    8090            md = checkfield(md, 'fieldname', 'smb.melt', 'size', [md.mesh.numberofvertices], 'NaN', 1, 'Inf', 1)
    81             md = checkfield(md, 'fieldname', 'smb.refreeze', 'size', [md.mesh.numberofvertices], 'NaN', 1, 'Inf', 1)
    82             md = checkfield(md, 'fieldname', 'smb.evaporation', 'size', [md.mesh.numberofvertices], 'NaN', 1, 'Inf', 1)
    8391
    8492        md = checkfield(md, 'fieldname', 'smb.steps_per_step', '>=', 1, 'numel', [1])
    8593        md = checkfield(md, 'fieldname', 'smb.averaging', 'numel', [1], 'values', [0, 1, 2])
    86         md = checkfield(md, 'fieldname', 'masstransport.requested_outputs', 'stringrow', 1)
     94        md = checkfield(md, 'fieldname', 'smb.requested_outputs', 'stringrow', 1)
    8795        return md
    8896    # }}}
    89     def marshall(self, prefix, md, fid):    # {{{
     97    def marshall(self, prefix, md, fid):  # {{{
    9098
    9199        yts = md.constants.yts
    92100
    93101        WriteData(fid, prefix, 'name', 'md.smb.model', 'data', 3, 'format', 'Integer')
    94         WriteData(fid, prefix, 'object', self, 'class', 'smb', 'fieldname', 'accumulation', 'format', 'DoubleMat', 'mattype', 1, 'scale', 1. / yts, 'timeserieslength', md.mesh.numberofvertices + 1, 'yts', yts)
    95         WriteData(fid, prefix, 'object', self, 'class', 'smb', 'fieldname', 'evaporation', 'format', 'DoubleMat', 'mattype', 1, 'scale', 1. / yts, 'timeserieslength', md.mesh.numberofvertices + 1, 'yts', yts)
    96         WriteData(fid, prefix, 'object', self, 'class', 'smb', 'fieldname', 'melt', 'format', 'DoubleMat', 'mattype', 1, 'scale', 1. / yts, 'timeserieslength', md.mesh.numberofvertices + 1, 'yts', yts)
    97         WriteData(fid, prefix, 'object', self, 'class', 'smb', 'fieldname', 'refreeze', 'format', 'DoubleMat', 'mattype', 1, 'scale', 1. / yts, 'timeserieslength', md.mesh.numberofvertices + 1, 'yts', yts)
     102        WriteData(fid, prefix, 'object', self, 'class', 'smb', 'fieldname', 'accumulation', 'format', 'DoubleMat', 'mattype', 1, 'scale', 1 / yts, 'timeserieslength', md.mesh.numberofvertices + 1, 'yts', yts)
     103        WriteData(fid, prefix, 'object', self, 'class', 'smb', 'fieldname', 'evaporation', 'format', 'DoubleMat', 'mattype', 1, 'scale', 1 / yts, 'timeserieslength', md.mesh.numberofvertices + 1, 'yts', yts)
     104        WriteData(fid, prefix, 'object', self, 'class', 'smb', 'fieldname', 'melt', 'format', 'DoubleMat', 'mattype', 1, 'scale', 1 / yts, 'timeserieslength', md.mesh.numberofvertices + 1, 'yts', yts)
     105        WriteData(fid, prefix, 'object', self, 'class', 'smb', 'fieldname', 'refreeze', 'format', 'DoubleMat', 'mattype', 1, 'scale', 1 / yts, 'timeserieslength', md.mesh.numberofvertices + 1, 'yts', yts)
    98106        WriteData(fid, prefix, 'object', self, 'fieldname', 'steps_per_step', 'format', 'Integer')
    99107        WriteData(fid, prefix, 'object', self, 'fieldname', 'averaging', 'format', 'Integer')
     
    106114            outputs = outputscopy
    107115        WriteData(fid, prefix, 'data', outputs, 'name', 'md.smb.requested_outputs', 'format', 'StringArray')
    108 
    109116    # }}}
  • TabularUnified issm/trunk-jpl/src/m/classes/basalforcings.m

    r21049 r26358  
    1111        end
    1212        methods
    13                 function self = extrude(self,md) % {{{
    14                         self.groundedice_melting_rate=project3d(md,'vector',self.groundedice_melting_rate,'type','node','layer',1);
    15                         self.floatingice_melting_rate=project3d(md,'vector',self.floatingice_melting_rate,'type','node','layer',1);
    16                         self.geothermalflux=project3d(md,'vector',self.geothermalflux,'type','node','layer',1); %bedrock only gets geothermal flux
    17                 end % }}}
    1813                function self = basalforcings(varargin) % {{{
    1914                        switch nargin
     
    2318                                        error('constructor not supported');
    2419                        end
     20                end % }}}
     21                function disp(self) % {{{
     22                        disp(sprintf('   basal forcings parameters:'));
     23
     24                        fielddisplay(self,'groundedice_melting_rate','basal melting rate (positive if melting) [m/yr]');
     25                        fielddisplay(self,'floatingice_melting_rate','basal melting rate (positive if melting) [m/yr]');
     26                        fielddisplay(self,'geothermalflux','geothermal heat flux [W/m^2]');
     27
     28                end % }}}
     29                function self = extrude(self,md) % {{{
     30                        self.groundedice_melting_rate=project3d(md,'vector',self.groundedice_melting_rate,'type','node','layer',1);
     31                        self.floatingice_melting_rate=project3d(md,'vector',self.floatingice_melting_rate,'type','node','layer',1);
     32                        self.geothermalflux=project3d(md,'vector',self.geothermalflux,'type','node','layer',1); %bedrock only gets geothermal flux
    2533                end % }}}
    2634                function self = initialize(self,md) % {{{
     
    5664                        end
    5765                end % }}}
    58                 function disp(self) % {{{
    59                         disp(sprintf('   basal forcings parameters:'));
    60 
    61                         fielddisplay(self,'groundedice_melting_rate','basal melting rate (positive if melting) [m/yr]');
    62                         fielddisplay(self,'floatingice_melting_rate','basal melting rate (positive if melting) [m/yr]');
    63                         fielddisplay(self,'geothermalflux','geothermal heat flux [W/m^2]');
    64 
    65                 end % }}}
    6666                function marshall(self,prefix,md,fid) % {{{
    6767
     
    6969
    7070                        WriteData(fid,prefix,'name','md.basalforcings.model','data',1,'format','Integer');
    71                         WriteData(fid,prefix,'object',self,'fieldname','groundedice_melting_rate','format','DoubleMat','mattype',1,'scale',1./yts,'timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts)
    72                         WriteData(fid,prefix,'object',self,'fieldname','floatingice_melting_rate','format','DoubleMat','mattype',1,'scale',1./yts,'timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts)
    73                         WriteData(fid,prefix,'object',self,'fieldname','geothermalflux','format','DoubleMat','mattype',1,'timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts);
     71                        WriteData(fid,prefix,'object',self,'fieldname','groundedice_melting_rate','format','DoubleMat','mattype',1,'scale',1./yts,'timeserieslength',md.mesh.numberofvertices+1,'yts',yts)
     72                        WriteData(fid,prefix,'object',self,'fieldname','floatingice_melting_rate','format','DoubleMat','mattype',1,'scale',1./yts,'timeserieslength',md.mesh.numberofvertices+1,'yts',yts)
     73                        WriteData(fid,prefix,'object',self,'fieldname','geothermalflux','format','DoubleMat','mattype',1,'timeserieslength',md.mesh.numberofvertices+1,'yts',yts);
    7474                end % }}}
    7575                function savemodeljs(self,fid,modelname) % {{{
  • TabularUnified issm/trunk-jpl/src/m/classes/basalforcings.py

    r26241 r26358  
    2323    def __repr__(self):  # {{{
    2424        s = '   basal forcings parameters:\n'
    25         s += '{}\n'.format(fielddisplay(self, "groundedice_melting_rate", "basal melting rate (positive if melting) [m / yr]"))
    26         s += '{}\n'.format(fielddisplay(self, "floatingice_melting_rate", "basal melting rate (positive if melting) [m / yr]"))
    27         s += '{}\n'.format(fielddisplay(self, "geothermalflux", "geothermal heat flux [W / m^2]"))
     25        s += '{}\n'.format(fielddisplay(self, 'groundedice_melting_rate', 'basal melting rate (positive if melting) [m/yr]'))
     26        s += '{}\n'.format(fielddisplay(self, 'floatingice_melting_rate', 'basal melting rate (positive if melting) [m/yr]'))
     27        s += '{}\n'.format(fielddisplay(self, 'geothermalflux', 'geothermal heat flux [W/m^2]'))
    2828        return s
    2929    #}}}
     
    3737        if np.all(np.isnan(self.groundedice_melting_rate)):
    3838            self.groundedice_melting_rate = np.zeros((md.mesh.numberofvertices, ))
    39             print("      no basalforcings.groundedice_melting_rate specified: values set as zero")
     39            print('      no basalforcings.groundedice_melting_rate specified: values set as zero')
    4040        if np.all(np.isnan(self.floatingice_melting_rate)):
    4141            self.floatingice_melting_rate = np.zeros((md.mesh.numberofvertices, ))
    42             print("      no basalforcings.floatingice_melting_rate specified: values set as zero")
     42            print('      no basalforcings.floatingice_melting_rate specified: values set as zero')
    4343        return self
    4444    #}}}
     
    6262        yts = md.constants.yts
    6363        WriteData(fid, prefix, 'name', 'md.basalforcings.model', 'data', 1, 'format', 'Integer')
    64         WriteData(fid, prefix, 'object', self, 'fieldname', 'groundedice_melting_rate', 'format', 'DoubleMat', 'mattype', 1, 'scale', 1. / yts, 'timeserieslength', md.mesh.numberofvertices + 1, 'yts', md.constants.yts)
    65         WriteData(fid, prefix, 'object', self, 'fieldname', 'floatingice_melting_rate', 'format', 'DoubleMat', 'mattype', 1, 'scale', 1. / yts, 'timeserieslength', md.mesh.numberofvertices + 1, 'yts', md.constants.yts)
    66         WriteData(fid, prefix, 'object', self, 'fieldname', 'geothermalflux', 'format', 'DoubleMat', 'mattype', 1, 'timeserieslength', md.mesh.numberofvertices + 1, 'yts', md.constants.yts)
     64        WriteData(fid, prefix, 'object', self, 'fieldname', 'groundedice_melting_rate', 'format', 'DoubleMat', 'mattype', 1, 'scale', 1 / yts, 'timeserieslength', md.mesh.numberofvertices + 1, 'yts', yts)
     65        WriteData(fid, prefix, 'object', self, 'fieldname', 'floatingice_melting_rate', 'format', 'DoubleMat', 'mattype', 1, 'scale', 1 / yts, 'timeserieslength', md.mesh.numberofvertices + 1, 'yts', yts)
     66        WriteData(fid, prefix, 'object', self, 'fieldname', 'geothermalflux', 'format', 'DoubleMat', 'mattype', 1, 'timeserieslength', md.mesh.numberofvertices + 1, 'yts', yts)
    6767    # }}}
  • TabularUnified issm/trunk-jpl/src/m/classes/clusters/generic.py

    r26353 r26358  
    5757
    5858    def __repr__(self):  # {{{
    59         #  display the object
     59        # Display the object
    6060        s = 'class \'{}\' object \'{}\' = \n'.format(type(self), 'self')
    6161        s += '    name: {}\n'.format(self.name)
     
    183183            fid.close()
    184184
    185         #in interactive mode, create a run file, and errlog and outlog file
     185        # In interactive mode, create a run file, and errlog and outlog file
    186186        if self.interactive:
    187187            fid = open(modelname + '.errlog', 'w')
     
    192192
    193193    def UploadQueueJob(self, modelname, dirname, filelist):  # {{{
    194         #compress the files into one zip.
     194        # Compress the files into one zip
    195195        compressstring = 'tar -zcf {}.tar.gz '.format(dirname)
    196196        for file in filelist:
     
    219219    def Download(self, dirname, filelist):  # {{{
    220220        if ispc():
    221             #do nothing
     221            # Do nothing
    222222            return
    223         #copy files from cluster to current directory
     223        # Copy files from cluster to current directory
    224224        directory = '{}/{}/'.format(self.executionpath, dirname)
    225225        issmscpin(self.name, self.login, self.port, directory, filelist)
  • TabularUnified issm/trunk-jpl/src/m/classes/constants.py

    r26225 r26358  
     1from checkfield import checkfield
    12from fielddisplay import fielddisplay
    2 from checkfield import checkfield
    33from WriteData import WriteData
    44
    55
    66class constants(object):
    7     """
    8     CONSTANTS class definition
     7    """CONSTANTS class definition
    98
    109       Usage:
     
    2322    #}}}
    2423    def __repr__(self):  # {{{
    25         string = "   constants parameters:"
    26 
    27         string = "%s\n%s" % (string, fielddisplay(self, "g", "gravitational acceleration [m / s^2]"))
    28         string = "%s\n%s" % (string, fielddisplay(self, "omega", "angular velocity of Earth [rad / s]"))
    29         string = "%s\n%s" % (string, fielddisplay(self, "yts", "number of seconds in a year [s / yr]"))
    30         string = "%s\n%s" % (string, fielddisplay(self, "referencetemperature", "reference temperature used in the enthalpy model [K]"))
    31         string = "%s\n%s" % (string, fielddisplay(self, "gravitational_constant", "Newtonian constant of gravitation [m^3/kg/s^2]"))
    32 
    33         return string
     24        s = '   constants parameters:\n'
     25        s += '{}\n'.format(fielddisplay(self, 'g', 'gravitational acceleration [m/s^2]'))
     26        s += '{}\n'.format(fielddisplay(self, 'omega', 'angular velocity of Earth [rad/s]'))
     27        s += '{}\n'.format(fielddisplay(self, 'yts', 'number of seconds in a year [s/yr]'))
     28        s += '{}\n'.format(fielddisplay(self, 'referencetemperature', 'reference temperature used in the enthalpy model [K]'))
     29        s += '{}\n'.format(fielddisplay(self, 'gravitational_constant', 'Newtonian constant of gravitation [m^3/kg/s^2]'))
     30        return s
    3431    #}}}
    3532    def setdefaultparameters(self):  # {{{
    36         #acceleration due to gravity (m / s^2)
     33        # Acceleration due to gravity (m / s^2)
    3734        self.g = 9.81
    3835
    39         #Earth's rotation speed
     36        # Earth's rotation speed
    4037        self.omega = 7.292 * 1e-5
    4138
    42         #converstion from year to seconds
    43         self.yts = 365. * 24. * 3600.
     39        # Converstion from year to seconds
     40        self.yts = 365.0 * 24.0 * 3600.0
    4441
    45         #the reference temperature for enthalpy model (cf Aschwanden)
     42        # The reference temperature for enthalpy model (cf Aschwanden)
    4643        self.referencetemperature = 223.15
    4744
    48         #gravitational constant:
     45        # Gravitational constant:
    4946        self.gravitational_constant = 6.67259e-11
    5047
     
    5249    #}}}
    5350    def checkconsistency(self, md, solution, analyses):  # {{{
    54         md = checkfield(md, 'fieldname', 'constants.g', '>=', 0, 'size', [1])
     51        md = checkfield(md, 'fieldname', 'constants.g', '>=', 0, 'size', [1]) # We allow 0 for validation tests
    5552        md = checkfield(md, 'fieldname', 'constants.omega', '>=', 0, 'size', [1])
    5653        md = checkfield(md, 'fieldname', 'constants.yts', '>', 0, 'size', [1])
  • TabularUnified issm/trunk-jpl/src/m/classes/dsl.m

    r26301 r26358  
    4141
    4242                        %Early return
    43                         if ~ismember('SealevelchangeAnalysis',analyses), return; end
    44                         if (strcmp(solution,'TransientSolution') & md.transient.isslc == 0), return; end
    45                         if (md.transient.isoceantransport==0) return;end
     43                        if ~ismember('SealevelchangeAnalysis',analyses) | (strcmp(solution,'TransientSolution') & md.transient.isslc == 0) | (md.transient.isoceantransport==0),
     44                                return;
     45                        end
    4646                        md = checkfield(md,'fieldname','dsl.global_average_thermosteric_sea_level','NaN',1,'Inf',1);
    4747                        md = checkfield(md,'fieldname','dsl.sea_surface_height_above_geoid','NaN',1,'Inf',1,'timeseries',1);
  • TabularUnified issm/trunk-jpl/src/m/classes/dsl.py

    r26319 r26358  
    4141    def checkconsistency(self, md, solution, analyses):  #{{{
    4242        # Early return
    43         if ('SealevelchangeAnalysis' not in analyses) or (solution == 'TransientSolution' and not md.transient.isslc) or (md.transient.isoceantransport == 0):
     43        if ('SealevelchangeAnalysis' not in analyses) or (solution == 'TransientSolution' and not md.transient.isslc) or (not md.transient.isoceantransport):
    4444            return md
    4545        md = checkfield(md, 'fieldname', 'dsl.global_average_thermosteric_sea_level', 'NaN', 1, 'Inf', 1)
     
    5656        yts = md.constants.yts
    5757        WriteData(fid, prefix, 'name', 'md.dsl.model', 'data', 1, 'format', 'Integer')
    58         WriteData(fid, prefix, 'object', self, 'fieldname', 'global_average_thermosteric_sea_level', 'format', 'DoubleMat', 'mattype', 2, 'timeseries', 1, 'yts', yts) # mattype 2, because we are sending a GMSL value identical everywhere on each element.
     58        WriteData(fid, prefix, 'object', self, 'fieldname', 'global_average_thermosteric_sea_level', 'format', 'DoubleMat', 'mattype', 2, 'timeseries', 1, 'timeserieslength', 2, 'yts', yts) # mattype 2, because we are sending a GMSL value identical everywhere on each element.
    5959        WriteData(fid, prefix, 'object', self, 'fieldname', 'sea_surface_height_above_geoid', 'format', 'DoubleMat', 'mattype', 1, 'timeserieslength', md.mesh.numberofvertices + 1, 'yts', yts)  # mattype 1 because we specify DSL at vertex locations.
    6060        WriteData(fid, prefix, 'object', self, 'fieldname', 'sea_water_pressure_at_sea_floor', 'format', 'DoubleMat', 'mattype', 1, 'timeserieslength', md.mesh.numberofvertices + 1, 'yts', yts)  # mattype 1 because we specify bottom pressure at vertex locations.
     
    6868
    6969    def initialize(self, md):  #{{{
     70        print('sdasa')
     71        exit()
    7072        if np.isnan(self.global_average_thermosteric_sea_level):
    7173            self.global_average_thermosteric_sea_level = np.array([0, 0]).reshape(-1, 1)
  • TabularUnified issm/trunk-jpl/src/m/classes/dslmme.m

    r26231 r26358  
    3535
    3636                        %Early return
    37                         if ~ismember('SealevelchangeAnalysis',analyses), return; end
    38                         if (strcmp(solution,'TransientSolution') & md.transient.isslc == 0), return; end
    39                         if (md.transient.isoceantransport==0) return;end
     37                        if ~ismember('SealevelchangeAnalysis',analyses) | (strcmp(solution,'TransientSolution') & md.transient.isslc == 0) | (md.transient.isoceantransport==0),
     38                                return;
     39                        end
    4040                        for i=1:length(self.global_average_thermosteric_sea_level),
    4141                                md = checkfield(md,'field',self.global_average_thermosteric_sea_level{i},'NaN',1,'Inf',1);
  • TabularUnified issm/trunk-jpl/src/m/classes/dslmme.py

    r26317 r26358  
    1313
    1414    def __init__(self, *args):  #{{{
    15         self.modelid = 0  # Index into the multi-model ensemble
    16         self.global_average_thermosteric_sea_level = []  # Corresponds to zostoga field in CMIP5 archives. Specified as a temporally variable quantity (in m) for each ensemble.
    17         self.sea_surface_height_above_geoid = []  # Corresponds to zos field in CMIP5 archives. Spatial average is 0. Specified as a spatio-temporally variable quantity (in m) for each ensemble.
    18         self.sea_water_pressure_at_sea_floor = []  #Corresponds to bpo field in CMIP5 archives. Specified as a spatio-temporally variable quantity (in m equivalent, not in Pa!) for each ensemble.
     15        self.modelid = 0  # Index into the multi-model ensemble, determine which field will be used
     16        self.global_average_thermosteric_sea_level = [] # Corresponds to zostoga field in CMIP5 archives. Specified as a temporally variable quantity (in m) for each ensemble.
     17        self.sea_surface_height_above_geoid = [] # Corresponds to zos field in CMIP5 archives. Spatial average is 0. Specified as a spatio-temporally variable quantity (in m) for each ensemble.
     18        self.sea_water_pressure_at_sea_floor = [] #Corresponds to bpo field in CMIP5 archives. Specified as a spatio-temporally variable quantity (in m equivalent, not in Pa!) for each ensemble.
    1919
    2020        nargs = len(args)
     
    4141    def checkconsistency(self, md, solution, analyses):  # {{{
    4242        # Early return
    43         if ('SealevelchangeAnalysis' not in analyses) or (solution == 'TransientSolution' and not md.transient.isslc):
     43        if ('SealevelchangeAnalysis' not in analyses) or (solution == 'TransientSolution' and not md.transient.isslc) or (not md.transient.isoceantransport):
    4444            return md
    4545
     
    6060        WriteData(fid, prefix, 'object', self, 'fieldname', 'modelid', 'format', 'Double')
    6161        WriteData(fid, prefix, 'name', 'md.dsl.nummodels', 'data', len(self.global_average_thermosteric_sea_level), 'format', 'Integer')
    62         WriteData(fid, prefix, 'object', self, 'fieldname', 'global_average_thermosteric_sea_level', 'format', 'MatArray', 'timeseries', 1, 'timeserieslength', 2, 'yts', md.constants.yts, 'scale', 1e-3 / md.constants.yts)
    63         WriteData(fid, prefix, 'object', self, 'fieldname', 'sea_water_pressure_at_sea_floor', 'format', 'MatArray', 'timeserieslength', md.mesh.numberofvertices + 1, 'yts', md.constants.yts, 'scale', 1e-3)
    64         WriteData(fid, prefix, 'object', self, 'fieldname', 'sea_surface_height_above_geoid', 'format', 'MatArray', 'timeserieslength', md.mesh.numberofvertices + 1, 'yts', md.constants.yts, 'scale', 1e-3 / md.constants.yts)
     62        WriteData(fid, prefix, 'object', self, 'fieldname', 'global_average_thermosteric_sea_level', 'format', 'MatArray', 'timeseries', 1, 'timeserieslength', 2)
     63        WriteData(fid, prefix, 'object', self, 'fieldname', 'sea_water_pressure_at_sea_floor', 'format', 'MatArray', 'timeserieslength', md.mesh.numberofvertices + 1)
     64        WriteData(fid, prefix, 'object', self, 'fieldname', 'sea_surface_height_above_geoid', 'format', 'MatArray', 'timeserieslength', md.mesh.numberofvertices + 1)
    6565    #}}}
    6666
  • TabularUnified issm/trunk-jpl/src/m/classes/fourierlove.py

    r26301 r26358  
    3838
    3939    def __repr__(self): #{{{
     40        # TODO:
     41        # - Correct display to match MATLAB
     42        #
    4043        s = '   Fourier Love class:\n'
    4144        s += '{}\n'.format(fielddisplay(self, 'nfreq', 'number of frequencies sampled (default: 1, elastic) [Hz]'))
     
    4346        s += '{}\n'.format(fielddisplay(self, 'sh_nmax', 'maximum spherical harmonic degree (default: 256, .35 deg, or 40 km at equator)'))
    4447        s += '{}\n'.format(fielddisplay(self, 'sh_nmin', 'minimum spherical harmonic degree (default: 1)'))
    45         s += '{}\n'.format(fielddisplay(self, 'g0', 'adimensioning constant for gravity (default: 10) [m / s^2]'))
    46         s += '{}\n'.format(fielddisplay(self, 'r0', 'adimensioning constant for radius (default: 6378e3) [m]'))
    47         s += '{}\n'.format(fielddisplay(self, 'mu0', 'adimensioning constant for stress (default: 1.0e11) [Pa]'))
     48        s += '{}\n'.format(fielddisplay(self, 'g0', 'adimensioning constant for gravity (default: 10) [m/s^2]'))
     49        s += '{}\n'.format(fielddisplay(self, 'r0', 'adimensioning constant for radius (default: 6371*10^3) [m]'))
     50        s += '{}\n'.format(fielddisplay(self, 'mu0', 'adimensioning constant for stress (default: 10^11) [Pa]'))
    4851        s += '{}\n'.format(fielddisplay(self, 'allow_layer_deletion', 'allow for migration of the integration boundary with increasing spherical harmonics degree (default: 1)'))
    4952        s += '{}\n'.format(fielddisplay(self, 'Gravitational_Constant', 'Newtonian constant of gravitation (default: 6.67259e-11 [m^3 kg^-1 s^-2])'))
     
    5154        s += '{}\n'.format(fielddisplay(self, 'underflow_tol', 'threshold of deep to surface love number ratio to trigger the deletion of layers (default: 1e-16)'))
    5255        s += '{}\n'.format(fielddisplay(self, 'integration_steps_per_layer', 'number of radial steps to propagate the yi system from the bottom to the top of each layer (default: 100)'))
    53         s += '{}\n'.format(fielddisplay(self, 'istemporal', {'1 for time-dependent love numbers, 0 for frequency-dependent or elastic love numbers (default: 0)', 'If 1: use fourierlove function build_frequencies_from_time to meet consistency'}))
     56        s += '{}\n'.format(fielddisplay(self, 'istemporal', ['1 for time-dependent love numbers, 0 for frequency-dependent or elastic love numbers (default: 0)', 'If 1: use fourierlove function build_frequencies_from_time to meet consistency']))
    5457        s += '{}\n'.format(fielddisplay(self, 'n_temporal_iterations', 'max number of iterations in the inverse Laplace transform. Also the number of spectral samples per time step requested (default: 8)'))
    5558        s += '{}\n'.format(fielddisplay(self, 'time', 'time vector for deformation if istemporal (default: 0) [s]'))
     
    121124            md = checkfield(md, 'fieldname', 'love.n_temporal_iterations', 'NaN', 1, 'Inf', 1, 'numel', 1, '>', 0)
    122125            md = checkfield(md, 'fieldname', 'love.time', 'NaN', 1, 'Inf', 1, 'numel', md.love.nfreq / 2 / md.love.n_temporal_iterations)
    123         if md.love.sh_nmin <= 1 and (md.love.forcing_type == 1 or md.love.forcing_type == 5 or md.love.forcing_type == 9):
     126        if md.love.sh_nmin <= 1 and (md.love.forcing_type == 9 or md.love.forcing_type == 5 or md.love.forcing_type == 1):
    124127            raise RuntimeError('Degree 1 not supported for forcing type {}. Use sh_min >= 2 for this kind of calculation.'.format(md.love.forcing_type))
    125128
  • TabularUnified issm/trunk-jpl/src/m/classes/geometry.py

    r26301 r26358  
    1414    """
    1515
    16     def __init__(self, *args): #{{{
     16    def __init__(self, *args):  # {{{
    1717        self.surface = np.nan
    1818        self.thickness = np.nan
     
    2525        else:
    2626            raise Exception('constructor not supported')
    27     #}}}
     27    # }}}
    2828
    29     def __repr__(self): #{{{
     29    def __repr__(self):  # {{{
    3030        s = '   geometry parameters:\n'
    3131        s += '{}\n'.format(fielddisplay(self, 'surface', 'ice upper surface elevation [m]'))
     
    3434        s += '{}\n'.format(fielddisplay(self, 'bed', 'bed elevation [m]'))
    3535        return s
    36     #}}}
     36    # }}}
    3737
    38     def setdefaultparameters(self): #{{{
     38    def setdefaultparameters(self):  # {{{
    3939        return
    40     #}}}
     40    # }}}
    4141
    42     def checkconsistency(self, md, solution, analyses): #{{{
     42    def checkconsistency(self, md, solution, analyses):  # {{{
    4343        if solution == 'LoveSolution':
    4444            return md
     
    6060    # }}}
    6161
    62     def marshall(self, prefix, md, fid): #{{{
     62    def marshall(self, prefix, md, fid):  # {{{
    6363        length_thickness = len(self.thickness)
    6464        if (length_thickness == md.mesh.numberofvertices) or (length_thickness == md.mesh.numberofvertices + 1):
    6565            WriteData(fid, prefix, 'object', self, 'fieldname', 'thickness', 'format', 'DoubleMat', 'mattype', 1, 'timeserieslength', md.mesh.numberofvertices + 1, 'yts', md.constants.yts)
    6666        elif (length_thickness == md.mesh.numberofelements) or (length_thickness == md.mesh.numberofelements + 1):
    67             WriteData(fid, prefix, 'object', self, 'fieldname', 'thickness', 'format', 'DoubleMat', 'mattype', 1, 'timeserieslength', md.mesh.numberofvertices + 1, 'yts', md.constants.yts)
     67            WriteData(fid, prefix, 'object', self, 'fieldname', 'thickness', 'format', 'DoubleMat', 'mattype', 1, 'timeserieslength', md.mesh.numberofelements + 1, 'yts', md.constants.yts)
    6868        else:
    6969            raise RuntimeError('geometry thickness time series should be a vertex or element time series')
     
    7575    # }}}
    7676
    77     def extrude(self, md): #{{{
     77    def extrude(self, md):  # {{{
    7878        self.surface = project3d(md, 'vector', self.surface, 'type', 'node')
    7979        self.thickness = project3d(md, 'vector', self.thickness, 'type', 'node')
     
    8282        self.bed = project3d(md, 'vector', self.bed, 'type', 'node')
    8383        return self
    84     #}}}
     84    # }}}
  • TabularUnified issm/trunk-jpl/src/m/classes/groundingline.py

    r24861 r26358  
    11import numpy as np
     2from checkfield import checkfield
    23from fielddisplay import fielddisplay
    3 from checkfield import checkfield
     4import MatlabFuncs as m
    45from WriteData import WriteData
    5 import MatlabFuncs as m
    66
    77
     
    1919        self.melt_interpolation = ''
    2020
    21     #set defaults
     21        # Set defaults
    2222        self.setdefaultparameters()
    2323
    24     #}}}
     24    # }}}
    2525
    2626    def __repr__(self):  # {{{
    27         string = '   grounding line migration parameters:'
    28 
    29         string = "%s\n%s" % (string, fielddisplay(self, 'migration', 'type of grounding line migration: ''SoftMigration'', ''SubelementMigration'', ''AggressiveMigration'', ''Contact'', ''None'''))
    30         string = "%s\n%s" % (string, fielddisplay(self, 'migration', 'type of friction interpolation on partially floating elements: ''SubelementFriction1'', ''SubelementFriction2'', ''NoFrictionOnPartiallyFloating'''))
    31         string = "%s\n%s" % (string, fielddisplay(self, 'migration', 'type of melt interpolation on partially floating elements: ''SubelementMelt1'', ''SubelementMelt2'', ''NoMeltOnPartiallyFloating'', ''FullMeltOnPartiallyFloating'''))
    32         return string
    33     #}}}
     27        s = '   grounding line migration parameters:\n'
     28        s += '{}\n'.format(fielddisplay(self, 'migration', 'type of grounding line migration: \'SoftMigration\', \'SubelementMigration\', \'AggressiveMigration\', \'Contact\', \'None\''))
     29        s += '{}\n'.format(fielddisplay(self, 'migration', 'type of friction interpolation on partially floating elements: ''SubelementFriction1'', ''SubelementFriction2'', ''NoFrictionOnPartiallyFloating'''))
     30        s += '{}\n'.format(fielddisplay(self, 'migration', 'type of melt interpolation on partially floating elements: \'SubelementMelt1\', \'SubelementMelt2\', \'NoMeltOnPartiallyFloating\', \'FullMeltOnPartiallyFloating\''))
     31        return s
     32    # }}}
    3433
    3534    def setdefaultparameters(self):  # {{{
    36 
    37         #Type of migration
     35        # Type of migration
    3836        self.migration = 'SubelementMigration'
    3937        self.friction_interpolation = 'SubelementFriction1'
     
    4139
    4240        return self
    43     #}}}
     41    # }}}
    4442
    4543    def checkconsistency(self, md, solution, analyses):  # {{{
    46 
    4744        md = checkfield(md, 'fieldname', 'groundingline.migration', 'values', ['None', 'SubelementMigration', 'AggressiveMigration', 'SoftMigration', 'Contact', 'GroundingOnly'])
    4845        md = checkfield(md, 'fieldname', 'groundingline.friction_interpolation', 'values', ['SubelementFriction1', 'SubelementFriction2', 'NoFrictionOnPartiallyFloating'])
     
    5350                md.checkmessage("requesting grounding line migration, but bathymetry is absent!")
    5451            pos = np.nonzero(md.mask.ocean_levelset > 0.)[0]
    55             if any(np.abs(md.geometry.base[pos] - md.geometry.bed[pos]) > 10**-10):
     52            if any(np.abs(md.geometry.base[pos] - md.geometry.bed[pos]) > pow(10, -10)):
    5653                md.checkmessage("base not equal to bed on grounded ice!")
    57             if any(md.geometry.bed - md.geometry.base > 10**-9):
     54            if any(md.geometry.bed - md.geometry.base > pow(10, -9)):
    5855                md.checkmessage("bed superior to base on floating ice!")
    5956
  • TabularUnified issm/trunk-jpl/src/m/classes/initialization.py

    r26302 r26358  
    3939    def __repr__(self): #{{{
    4040        s = '   initial field values:\n'
    41         s += '{}\n'.format(fielddisplay(self, 'vx', 'x component of velocity [m / yr]'))
    42         s += '{}\n'.format(fielddisplay(self, 'vy', 'y component of velocity [m / yr]'))
    43         s += '{}\n'.format(fielddisplay(self, 'vz', 'z component of velocity [m / yr]'))
    44         s += '{}\n'.format(fielddisplay(self, 'vel', 'velocity norm [m / yr]'))
     41        s += '{}\n'.format(fielddisplay(self, 'vx', 'x component of velocity [m/yr]'))
     42        s += '{}\n'.format(fielddisplay(self, 'vy', 'y component of velocity [m/yr]'))
     43        s += '{}\n'.format(fielddisplay(self, 'vz', 'z component of velocity [m/yr]'))
     44        s += '{}\n'.format(fielddisplay(self, 'vel', 'velocity norm [m/yr]'))
    4545        s += '{}\n'.format(fielddisplay(self, 'pressure', 'pressure [Pa]'))
    4646        s += '{}\n'.format(fielddisplay(self, 'temperature', 'temperature [K]'))
     
    7070            if solution == 'TransientSolution' and md.transient.isslc and md.transient.isoceantransport:
    7171                md = checkfield(md, 'fieldname', 'initialization.bottompressure', 'NaN', 1, 'Inf', 1, 'size', [md.mesh.numberofvertices])
     72                md = checkfield(md, 'fieldname', 'initialization.dsl', 'NaN', 1, 'Inf', 1, 'size', [md.mesh.numberofvertices])
     73                md = checkfield(md, 'fieldname', 'initialization.str', 'NaN', 1, 'Inf', 1, 'size', [1])
    7274        if 'BalancethicknessAnalysis' in analyses and solution == 'BalancethicknessSolution':
    7375            md = checkfield(md, 'fieldname', 'initialization.vx', 'NaN', 1, 'Inf', 1, 'size', [md.mesh.numberofvertices])
     
    155157        self.sealevel = project3d(md, 'vector', self.sealevel, 'type', 'node', 'layer', 1)
    156158        self.bottompressure = project3d(md, 'vector', self.bottompressure, 'type', 'node', 'layer', 1)
     159        self.dsl = project3d(md, 'vector', self.dsl, 'type', 'node', 'layer', 1)
     160        self.str = project3d(md, 'vector', self.str, 'type', 'node', 'layer', 1)
    157161
    158162        # Lithostatic pressure by default
  • TabularUnified issm/trunk-jpl/src/m/classes/issmsettings.py

    r26353 r26358  
    3939
    4040    def setdefaultparameters(self):  # {{{
    41         #are we short in memory ? (0 faster but requires more memory)
     41        # Are we short in memory? (0 faster but requires more memory)
    4242        self.lowmem = 0
    43         #i / o:
     43        # I/O:
    4444        self.io_gather = 1
    45         #results frequency by default every step
     45        # Results frequency by default every step
    4646        self.output_frequency = 1
    47         #coupling frequency of the stress balance solver by default every step
     47        # Coupling frequency of the stress balance solver by default every step
    4848        self.sb_coupling_frequency = 1
    49         #checkpoints frequency, by default never:
     49        # Checkpoints frequency, by default never:
    5050        self.checkpoint_frequency = 0
    51         #this option can be activated to load automatically the results
    52         #onto the model after a parallel run by waiting for the lock file
    53         #N minutes that is generated once the solution has converged
    54         #0 to deactivate
    55         self.waitonlock = 2**31 - 1
    56         #throw an error if solver residue exceeds this value
     51        # This option can be activated to load automatically the results onto
     52        # the model after a parallel run by waiting for the lock file N minutes
     53        # that is generated once the solution has converged
     54        # Set to 0 to deactivate
     55        self.waitonlock = pow(2, 31) - 1
     56        # Throw an error if solver residue exceeds this value
    5757        self.solver_residue_threshold = 1e-6
    5858
  • TabularUnified issm/trunk-jpl/src/m/classes/levelset.m

    r25842 r26358  
    99                spclevelset                     = NaN;
    1010                reinit_frequency        = 5;
    11                 kill_icebergs     = 0;
    12                 migration_max       = 0.;
    13                 fe                = 'P1';
     11                kill_icebergs           = 0;
     12                migration_max           = 0.;
     13                fe                                      = 'P1';
    1414        end
    1515        methods
     
    3232                        end
    3333                end % }}}
     34                function disp(self) % {{{
     35                        disp(sprintf('   Level-set parameters:'));
     36                        fielddisplay(self,'stabilization','0: no, 1: artificial_diffusivity, 2: streamline upwinding');
     37                        fielddisplay(self,'spclevelset','Levelset constraints (NaN means no constraint)');
     38                        fielddisplay(self,'reinit_frequency','Amount of time steps after which the levelset function in re-initialized');
     39                        fielddisplay(self,'kill_icebergs','remove floating icebergs to prevent rigid body motions (1: true, 0: false)');
     40                        fielddisplay(self,'migration_max','maximum allowed migration rate (m/a)');
     41                        fielddisplay(self,'fe','Finite Element type: ''P1'' (default), or ''P2''');
     42                end % }}}
    3443                function self = extrude(self,md) % {{{
    3544
     
    4251                        self.reinit_frequency = 5;
    4352                        self.kill_icebergs    = 1;
    44                         self.migration_max      = 1e12; % No need for general cases, unless specified
     53                        self.migration_max    = 1e12; % No need for general cases, unless specified
    4554
    4655                        %Linear elements by default
     
    5867                        md = checkfield(md,'fieldname','levelset.fe','values',{'P1','P2'});
    5968                end % }}}
    60                 function disp(self) % {{{
    61                         disp(sprintf('   Level-set parameters:'));
    62                         fielddisplay(self,'stabilization','0: no, 1: artificial_diffusivity, 2: streamline upwinding');
    63                         fielddisplay(self,'spclevelset','Levelset constraints (NaN means no constraint)');
    64                         fielddisplay(self,'reinit_frequency','Amount of time steps after which the levelset function in re-initialized');
    65                         fielddisplay(self,'kill_icebergs','remove floating icebergs to prevent rigid body motions (1: true, 0: false)');
    66                         fielddisplay(self,'migration_max','maximum allowed migration rate (m/a)');
    67                         fielddisplay(self,'fe','Finite Element type: ''P1'' (default), or ''P2''');
    68                 end % }}}
    6969                function marshall(self,prefix,md,fid) % {{{
    7070
     
    7272
    7373                        WriteData(fid,prefix,'object',self,'fieldname','stabilization','format','Integer');
    74                         WriteData(fid,prefix,'object',self,'fieldname','spclevelset','format','DoubleMat','mattype',1,'timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts);
     74                        WriteData(fid,prefix,'object',self,'fieldname','spclevelset','format','DoubleMat','mattype',1,'timeserieslength',md.mesh.numberofvertices+1,'yts',yts);
    7575                        WriteData(fid,prefix,'object',self,'fieldname','reinit_frequency','format','Integer');
    7676                        WriteData(fid,prefix,'object',self,'fieldname','kill_icebergs','format','Boolean');
  • TabularUnified issm/trunk-jpl/src/m/classes/levelset.py

    r25843 r26358  
     1import numpy as np
     2
     3from checkfield import checkfield
    14from fielddisplay import fielddisplay
    25from project3d import project3d
    3 from checkfield import checkfield
    46from WriteData import WriteData
    57
    68
    79class levelset(object):
    8     """
    9     LEVELSET class definition
     10    """LEVELSET class definition
    1011
    11        Usage:
    12           levelset = levelset()
     12    Usage:
     13        levelset = levelset()
    1314    """
    1415
    1516    def __init__(self):  # {{{
    16 
    1717        self.stabilization = 0
    18         self.spclevelset = float('NaN')
    19         self.reinit_frequency = 0
     18        self.spclevelset = np.nan
     19        self.reinit_frequency = 5
    2020        self.kill_icebergs = 0
    21         self.migration_max = 0.
     21        self.migration_max = 0
    2222        self.fe = 'P1'
    2323
    24     #set defaults
     24        # Set defaults
    2525        self.setdefaultparameters()
    26 
    2726    #}}}
    2827    def __repr__(self):  # {{{
    29         string = '   Level - set parameters:'
    30         string = "%s\n%s" % (string, fielddisplay(self, 'stabilization', '0: no, 1: artificial_diffusivity, 2: streamline upwinding'))
    31         string = "%s\n%s" % (string, fielddisplay(self, 'spclevelset', 'levelset constraints (NaN means no constraint)'))
    32         string = "%s\n%s" % (string, fielddisplay(self, 'reinit_frequency', 'Amount of time steps after which the levelset function in re-initialized'))
    33         string = "%s\n%s" % (string, fielddisplay(self, 'kill_icebergs', 'remove floating icebergs to prevent rigid body motions (1: true, 0: false)'))
    34         string = "%s\n%s" % (string, fielddisplay(self, 'migration_max', 'maximum allowed migration rate (m / a)'))
    35         string = "%s\n%s" % (string, fielddisplay(self, 'fe', 'Finite Element type: ''P1'' (default), or ''P2'''))
     28        s = '   Level-set parameters:\n'
     29        s += '{}\n'.format(fielddisplay(self, 'stabilization', '0: no, 1: artificial_diffusivity, 2: streamline upwinding'))
     30        s += '{}\n'.format(fielddisplay(self, 'spclevelset', 'Levelset constraints (NaN means no constraint)'))
     31        s += '{}\n'.format(fielddisplay(self, 'reinit_frequency', 'Amount of time steps after which the levelset function in re-initialized'))
     32        s += '{}\n'.format(fielddisplay(self, 'kill_icebergs', 'remove floating icebergs to prevent rigid body motions (1: true, 0: false)'))
     33        s += '{}\n'.format(fielddisplay(self, 'migration_max', 'maximum allowed migration rate (m/a)'))
     34        s += '{}\n'.format(fielddisplay(self, 'fe', 'Finite Element type: \'P1\' (default), or \'P2\''))
    3635
    37         return string
    38     #}}}
    39 
    40     def extrude(self, md):  # {{{
    41         self.spclevelset = project3d(md, 'vector', self.spclevelset, 'type', 'node')
    42         return self
     36        return s
    4337    #}}}
    4438
    4539    def setdefaultparameters(self):  # {{{
    46         #stabilization = 1 by default
     40        # Stabilization = 1 by default
    4741        self.stabilization = 1
    4842        self.reinit_frequency = 5
     
    5044        self.migration_max = 1e12 # No need for general cases, unless specified
    5145
    52     #Linear elements by default
     46        # Linear elements by default
    5347        self.fe = 'P1'
    5448
     
    5751
    5852    def checkconsistency(self, md, solution, analyses):  # {{{
    59         #Early return
     53        # Early return
    6054        if (solution != 'TransientSolution') or (not md.transient.ismovingfront):
    6155            return md
     
    7064    # }}}
    7165
     66    def extrude(self, md):  # {{{
     67        self.spclevelset = project3d(md, 'vector', self.spclevelset, 'type', 'node')
     68        return self
     69    #}}}
     70
    7271    def marshall(self, prefix, md, fid):  # {{{
    7372        yts = md.constants.yts
     
    7776        WriteData(fid, prefix, 'object', self, 'fieldname', 'reinit_frequency', 'format', 'Integer')
    7877        WriteData(fid, prefix, 'object', self, 'fieldname', 'kill_icebergs', 'format', 'Boolean')
    79         WriteData(fid, prefix, 'object', self, 'fieldname', 'migration_max', 'format', 'Double', 'scale', 1. / yts)
     78        WriteData(fid, prefix, 'object', self, 'fieldname', 'migration_max', 'format', 'Double', 'scale', 1 / yts)
    8079        WriteData(fid, prefix, 'object', self, 'fieldname', 'fe', 'format', 'String')
    8180    # }}}
  • TabularUnified issm/trunk-jpl/src/m/classes/lovenumbers.py

    r26317 r26358  
    8181        md = checkfield(md, 'fieldname', 'solidearth.lovenumbers.th', 'NaN', 1, 'Inf', 1)
    8282        md = checkfield(md, 'fieldname', 'solidearth.lovenumbers.tk', 'NaN', 1, 'Inf', 1)
     83        md = checkfield(md, 'fieldname', 'solidearth.lovenumbers.tl', 'NaN', 1, 'Inf', 1)
    8384        md = checkfield(md, 'fieldname', 'solidearth.lovenumbers.tk2secular', 'NaN', 1, 'Inf', 1)
    8485        md = checkfield(md, 'fieldname', 'solidearth.lovenumbers.timefreq', 'NaN', 1, 'Inf', 1)
  • TabularUnified issm/trunk-jpl/src/m/classes/matdamageice.m

    r26065 r26358  
    9595                        self.rheology_law='Paterson';
    9696
    97                         %SLR
    98                         self.earth_density= 5512;  % average density of the Earth, (kg/m^3)
     97                        %SLC
     98                        self.earth_density= 5512; % average density of the Earth (kg/m^3)
    9999
    100100                end % }}}
  • TabularUnified issm/trunk-jpl/src/m/classes/matdamageice.py

    r26317 r26358  
    66
    77class matdamageice(object):
    8     """
    9     MATICE class definition
     8    """MATICE class definition
    109
    1110       Usage:
     
    1413
    1514    def __init__(self):  # {{{
    16         self.rho_ice = 0.
    17         self.rho_water = 0.
    18         self.rho_freshwater = 0.
    19         self.mu_water = 0.
    20         self.heatcapacity = 0.
    21         self.latentheat = 0.
    22         self.thermalconductivity = 0.
    23         self.temperateiceconductivity = 0.
     15        self.rho_ice = 0
     16        self.rho_water = 0
     17        self.rho_freshwater = 0
     18        self.mu_water = 0
     19        self.heatcapacity = 0
     20        self.latentheat = 0
     21        self.thermalconductivity = 0
     22        self.temperateiceconductivity = 0
    2423        self.effectiveconductivity_averaging = 0
    25         self.meltingpoint = 0.
    26         self.beta = 0.
    27         self.mixed_layer_capacity = 0.
    28         self.thermal_exchange_velocity = 0.
    29         self.rheology_B = float('NaN')
    30         self.rheology_n = float('NaN')
     24        self.meltingpoint = 0
     25        self.beta = 0
     26        self.mixed_layer_capacity = 0
     27        self.thermal_exchange_velocity = 0
     28        self.rheology_B = np.nan
     29        self.rheology_n = np.nan
    3130        self.rheology_law = ''
    3231
    3332        #SLC
    34         self.earth_density = 5512  # average density of the Earth, (kg / m^3)
     33        self.earth_density = 0
    3534
    3635        self.setdefaultparameters()
     
    3837
    3938    def __repr__(self):  # {{{
    40         # TODO:
    41         # - Convert all formatting to calls to <string>.format (see any
    42         #   already converted <class>.__repr__ method for examples)
    43         #
    44         string = "   Materials:"
    45         string = "%s\n%s" % (string, fielddisplay(self, "rho_ice", "ice density [kg / m^3]"))
    46         string = "%s\n%s" % (string, fielddisplay(self, "rho_water", "water density [kg / m^3]"))
    47         string = "%s\n%s" % (string, fielddisplay(self, "rho_freshwater", "fresh water density [kg / m^3]"))
    48         string = "%s\n%s" % (string, fielddisplay(self, "mu_water", "water viscosity [N s / m^2]"))
    49         string = "%s\n%s" % (string, fielddisplay(self, "heatcapacity", "heat capacity [J / kg / K]"))
    50         string = "%s\n%s" % (string, fielddisplay(self, "thermalconductivity", "ice thermal conductivity [W / m / K]"))
    51         string = "%s\n%s" % (string, fielddisplay(self, "temperateiceconductivity", "temperate ice thermal conductivity [W / m / K]"))
    52         string = "%s\n%s" % (string, fielddisplay(self, "effectiveconductivity_averaging", "computation of effectiveconductivity: (0) arithmetic mean, (1) harmonic mean, (2) geometric mean (default)"))
    53         string = "%s\n%s" % (string, fielddisplay(self, "meltingpoint", "melting point of ice at 1atm in K"))
    54         string = "%s\n%s" % (string, fielddisplay(self, "latentheat", "latent heat of fusion [J / m^3]"))
    55         string = "%s\n%s" % (string, fielddisplay(self, "beta", "rate of change of melting point with pressure [K / Pa]"))
    56         string = "%s\n%s" % (string, fielddisplay(self, "mixed_layer_capacity", "mixed layer capacity [W / kg / K]"))
    57         string = "%s\n%s" % (string, fielddisplay(self, "thermal_exchange_velocity", "thermal exchange velocity [m / s]"))
    58         string = "%s\n%s" % (string, fielddisplay(self, "rheology_B", "flow law parameter [Pa s^(1 / n)]"))
    59         string = "%s\n%s" % (string, fielddisplay(self, "rheology_n", "Glen's flow law exponent"))
    60         string = "%s\n%s" % (string, fielddisplay(self, "rheology_law", "law for the temperature dependance of the rheology: 'None', 'BuddJacka', 'Cuffey', 'CuffeyTemperate', 'Paterson', 'Arrhenius' or 'LliboutryDuval'"))
    61         string = "%s\n%s" % (string, fielddisplay(self, "earth_density", "Mantle density [kg / m^ - 3]"))
     39        s = '   Materials:\n'
     40        s += '{}\n'.format(fielddisplay(self, 'rho_ice', 'ice density [kg/m^3]'))
     41        s += '{}\n'.format(fielddisplay(self, 'rho_water', 'water density [kg/m^3]'))
     42        s += '{}\n'.format(fielddisplay(self, 'rho_freshwater', 'fresh water density [kg/m^3]'))
     43        s += '{}\n'.format(fielddisplay(self, 'mu_water', 'water viscosity [N s/m^2]'))
     44        s += '{}\n'.format(fielddisplay(self, 'heatcapacity', 'heat capacity [J/kg/K]'))
     45        s += '{}\n'.format(fielddisplay(self, 'thermalconductivity', 'ice thermal conductivity [W/m/K]'))
     46        s += '{}\n'.format(fielddisplay(self, 'temperateiceconductivity', 'temperate ice thermal conductivity [W/m/K]'))
     47        s += '{}\n'.format(fielddisplay(self, 'effectiveconductivity_averaging', 'computation of effectiveconductivity: (0) arithmetic mean, (1) harmonic mean, (2) geometric mean (default)'))
     48        s += '{}\n'.format(fielddisplay(self, 'meltingpoint', 'melting point of ice at 1atm in K'))
     49        s += '{}\n'.format(fielddisplay(self, 'latentheat', 'latent heat of fusion [J/m^3]'))
     50        s += '{}\n'.format(fielddisplay(self, 'beta', 'rate of change of melting point with pressure [K/Pa]'))
     51        s += '{}\n'.format(fielddisplay(self, 'mixed_layer_capacity', 'mixed layer capacity [W/ kg/K]'))
     52        s += '{}\n'.format(fielddisplay(self, 'thermal_exchange_velocity', 'thermal exchange velocity [m/s]'))
     53        s += '{}\n'.format(fielddisplay(self, 'rheology_B', 'flow law parameter [Pa s^(1/n)]'))
     54        s += '{}\n'.format(fielddisplay(self, 'rheology_n', 'Glen\'s flow law exponent'))
     55        s += '{}\n'.format(fielddisplay(self, 'rheology_law', 'law for the temperature dependance of the rheology: \'None\', \'BuddJacka\', \'Cuffey\', \'CuffeyTemperate\', \'Paterson\', \'Arrhenius\' or \'LliboutryDuval\''))
     56        s += '{}\n'.format(fielddisplay(self, 'earth_density', 'Mantle density [kg m^-3]'))
    6257        return string
    6358    #}}}
     
    7065
    7166    def setdefaultparameters(self):  # {{{
    72         #ice density (kg / m^3)
    73         self.rho_ice = 917.
    74         #ocean water density (kg / m^3)
    75         self.rho_water = 1023.
    76         #fresh water density (kg / m^3)
    77         self.rho_freshwater = 1000.
    78         #water viscosity (N.s / m^2)
     67        # Ice density (kg/m^3)
     68        self.rho_ice = 917.0
     69        # Ocean water density (kg/m^3)
     70        self.rho_water = 1023.0
     71        # Fresh water density (kg/m^3)
     72        self.rho_freshwater = 1000.0
     73        # Water viscosity (N.s/m^2)
    7974        self.mu_water = 0.001787
    80         #ice heat capacity cp (J / kg / K)
    81         self.heatcapacity = 2093.
    82         #ice latent heat of fusion L (J / kg)
    83         self.latentheat = 3.34e5
    84         #ice thermal conductivity (W / m / K)
     75        # Ice heat capacity cp (J/kg/K)
     76        self.heatcapacity = 2093.0
     77        # Ice latent heat of fusion L (J/kg)
     78        self.latentheat = 3.34 * pow(10, 5)
     79        # Ice thermal conductivity (W/m/K)
    8580        self.thermalconductivity = 2.4
    86         #temperate ice thermal conductivity (W / m / K)
     81        # Temperate ice thermal conductivity (W/m/K)
    8782        self.temperateiceconductivity = 0.24
    88         #computation of effective conductivity
     83        # Computation of effective conductivity
    8984        self.effectiveconductivity_averaging = 1
    90         #the melting point of ice at 1 atmosphere of pressure in K
     85        # The melting point of ice at 1 atmosphere of pressure in K
    9186        self.meltingpoint = 273.15
    92         #rate of change of melting point with pressure (K / Pa)
    93         self.beta = 9.8e-8
    94         #mixed layer (ice-water interface) heat capacity (J / kg / K)
    95         self.mixed_layer_capacity = 3974.
    96         #thermal exchange velocity (ice-water interface) (m / s)
     87        # Rate of change of melting point with pressure (K/Pa)
     88        self.beta = 9.8 * pow(10, -8)
     89        # Mixed layer (ice-water interface) heat capacity (J/kg/K)
     90        self.mixed_layer_capacity = 3974.0
     91        # Thermal exchange velocity (ice-water interface) (m/s)
    9792        self.thermal_exchange_velocity = 1.00e-4
    98         #Rheology law: what is the temperature dependence of B with T
    99         #available: none, paterson and arrhenius
     93        # Rheology law: what is the temperature dependence of B with T
     94        # available: none, paterson and arrhenius
    10095        self.rheology_law = 'Paterson'
    10196
    102         #SLC
    103         self.earth_density = 5512  #average density of the Earth, (kg / m^3)
     97        # SLC
     98        self.earth_density = 5512  # average density of the Earth (kg/m^3)
    10499        return self
    105100    #}}}
  • TabularUnified issm/trunk-jpl/src/m/classes/matenhancedice.m

    r26059 r26358  
    6464
    6565                        %water viscosity (N.s/m^2)
    66                         self.mu_water=0.001787; 
     66                        self.mu_water=0.001787;
    6767
    6868                        %ice heat capacity cp (J/kg/K)
     
    8080                        %computation of effective conductivity
    8181                        self.effectiveconductivity_averaging=1;
    82            
     82
    8383                        %the melting point of ice at 1 atmosphere of pressure in K
    8484                        self.meltingpoint=273.15;
     
    9797                        self.rheology_law='Paterson';
    9898
    99                         %SLR
     99                        %SLC
    100100                        self.earth_density= 5512;  % average density of the Earth, (kg/m^3)
    101101
  • TabularUnified issm/trunk-jpl/src/m/classes/matenhancedice.py

    r26317 r26358  
     1import numpy as np
     2
    13from checkfield import checkfield
    24from fielddisplay import fielddisplay
     
    1214    """
    1315
    14     def __init__(self): #{{{
    15         self.rho_ice = 0.
    16         self.rho_water = 0.
    17         self.rho_freshwater = 0.
    18         self.mu_water = 0.
    19         self.heatcapacity = 0.
    20         self.latentheat = 0.
    21         self.thermalconductivity = 0.
    22         self.temperateiceconductivity = 0.
     16    def __init__(self):  # {{{
     17        self.rho_ice = 0
     18        self.rho_water = 0
     19        self.rho_freshwater = 0
     20        self.mu_water = 0
     21        self.heatcapacity = 0
     22        self.latentheat = 0
     23        self.thermalconductivity = 0
     24        self.temperateiceconductivity = 0
    2325        self.effectiveconductivity_averaging = 0
    24         self.meltingpoint = 0.
    25         self.beta = 0.
    26         self.mixed_layer_capacity = 0.
    27         self.thermal_exchange_velocity = 0.
    28         self.rheology_E = float('NaN')
    29         self.rheology_B = float('NaN')
    30         self.rheology_n = float('NaN')
     26        self.meltingpoint = 0
     27        self.beta = 0
     28        self.mixed_layer_capacity = 0
     29        self.thermal_exchange_velocity = 0
     30        self.rheology_E = np.nan
     31        self.rheology_B = np.nan
     32        self.rheology_n = np.nan
    3133        self.rheology_law = ''
    3234
    3335        #SLC
    34         self.earth_density = 0  # average density of the Earth, (kg/m^3)
     36        self.earth_density = 0
    3537
    3638        self.setdefaultparameters()
    37     #}}}
     39    # }}}
    3840
    39     def __repr__(self): #{{{
    40         # TODO:
    41         # - Convert all formatting to calls to <string>.format (see any
    42         #   already converted <class>.__repr__ method for examples)
    43         #
    44         s = "   Materials:"
    45         s = "%s\n%s" % (s, fielddisplay(self, "rho_ice", "ice density [kg/m^3]"))
    46         s = "%s\n%s" % (s, fielddisplay(self, "rho_water", "water density [kg/m^3]"))
    47         s = "%s\n%s" % (s, fielddisplay(self, "rho_freshwater", "fresh water density [kg/m^3]"))
    48         s = "%s\n%s" % (s, fielddisplay(self, "mu_water", "water viscosity [N s/m^2]"))
    49         s = "%s\n%s" % (s, fielddisplay(self, "heatcapacity", "heat capacity [J/kg/K]"))
    50         s = "%s\n%s" % (s, fielddisplay(self, "thermalconductivity", "ice thermal conductivity [W/m/K]"))
    51         s = "%s\n%s" % (s, fielddisplay(self, "temperateiceconductivity", "temperate ice thermal conductivity [W/m/K]"))
    52         s = "%s\n%s" % (s, fielddisplay(self, "effectiveconductivity_averaging", "computation of effectiveconductivity: (0) arithmetic mean, (1) harmonic mean, (2) geometric mean (default)"))
    53         s = "%s\n%s" % (s, fielddisplay(self, "meltingpoint", "melting point of ice at 1atm in K"))
    54         s = "%s\n%s" % (s, fielddisplay(self, "latentheat", "latent heat of fusion [J/m^3]"))
    55         s = "%s\n%s" % (s, fielddisplay(self, "beta", "rate of change of melting point with pressure [K/Pa]"))
    56         s = "%s\n%s" % (s, fielddisplay(self, "mixed_layer_capacity", "mixed layer capacity [W/kg/K]"))
    57         s = "%s\n%s" % (s, fielddisplay(self, "thermal_exchange_velocity", "thermal exchange velocity [m/s]"))
    58         s = "%s\n%s" % (s, fielddisplay(self, "rheology_E", "enhancement factor"))
    59         s = "%s\n%s" % (s, fielddisplay(self, "rheology_B", "flow law parameter [Pa s^(1/n)]"))
    60         s = "%s\n%s" % (s, fielddisplay(self, "rheology_n", "Glen's flow law exponent"))
    61         s = "%s\n%s" % (s, fielddisplay(self, "rheology_law", "law for the temperature dependance of the rheology: 'None', 'BuddJacka', 'Cuffey', 'CuffeyTemperate', 'Paterson', 'Arrhenius' or 'LliboutryDuval'"))
    62         s = "%s\n%s" % (s, fielddisplay(self, "earth_density", "Mantle density [kg/m^-3]"))
     41    def __repr__(self):  # {{{
     42        s = '   Materials:\n'
     43        s += '{}\n'.format(fielddisplay(self, 'rho_ice', 'ice density [kg/m^3]'))
     44        s += '{}\n'.format(fielddisplay(self, 'rho_water', 'water density [kg/m^3]'))
     45        s += '{}\n'.format(fielddisplay(self, 'rho_freshwater', 'fresh water density [kg/m^3]'))
     46        s += '{}\n'.format(fielddisplay(self, 'mu_water', 'water viscosity [N s/m^2]'))
     47        s += '{}\n'.format(fielddisplay(self, 'heatcapacity', 'heat capacity [J/kg/K]'))
     48        s += '{}\n'.format(fielddisplay(self, 'thermalconductivity', 'ice thermal conductivity [W/m/K]'))
     49        s += '{}\n'.format(fielddisplay(self, 'temperateiceconductivity', 'temperate ice thermal conductivity [W/m/K]'))
     50        s += '{}\n'.format(fielddisplay(self, 'effectiveconductivity_averaging', 'computation of effectiveconductivity: (0) arithmetic mean, (1) harmonic mean, (2) geometric mean (default)'))
     51        s += '{}\n'.format(fielddisplay(self, 'meltingpoint', 'melting point of ice at 1atm in K'))
     52        s += '{}\n'.format(fielddisplay(self, 'latentheat', 'latent heat of fusion [J/m^3]'))
     53        s += '{}\n'.format(fielddisplay(self, 'beta', 'rate of change of melting point with pressure [K/Pa]'))
     54        s += '{}\n'.format(fielddisplay(self, 'mixed_layer_capacity', 'mixed layer capacity [W/kg/K]'))
     55        s += '{}\n'.format(fielddisplay(self, 'thermal_exchange_velocity', 'thermal exchange velocity [m/s]'))
     56        s += '{}\n'.format(fielddisplay(self, 'rheology_E', 'enhancement factor'))
     57        s += '{}\n'.format(fielddisplay(self, 'rheology_B', 'flow law parameter [Pa s^(1/n)]'))
     58        s += '{}\n'.format(fielddisplay(self, 'rheology_n', 'Glen\'s flow law exponent'))
     59        s += '{}\n'.format(fielddisplay(self, 'rheology_law', 'law for the temperature dependance of the rheology: \'None\', \'BuddJacka\', \'Cuffey\', \'CuffeyTemperate\', \'Paterson\', \'Arrhenius\' or \'LliboutryDuval\''))
     60        s += '{}\n'.format(fielddisplay(self, 'earth_density', 'Mantle density [kg/m^-3]'))
    6361
    6462        return s
    65     #}}}
     63    # }}}
    6664
    67     def extrude(self, md): #{{{
     65    def extrude(self, md):  # {{{
    6866        self.rheology_E = project3d(md, 'vector', self.rheology_E, 'type', 'node')
    6967        self.rheology_B = project3d(md, 'vector', self.rheology_B, 'type', 'node')
    7068        self.rheology_n = project3d(md, 'vector', self.rheology_n, 'type', 'element')
    7169        return self
    72     #}}}
     70    # }}}
    7371
    74     def setdefaultparameters(self): #{{{
    75         #ice density (kg / m^3)
    76         self.rho_ice = 917.
    77         #ocean water density (kg / m^3)
    78         self.rho_water = 1023.
    79         #fresh water density (kg / m^3)
    80         self.rho_freshwater = 1000.
    81         #water viscosity (N.s / m^2)
     72    def setdefaultparameters(self):  # {{{
     73        # Ice density (kg/m^3)
     74        self.rho_ice = 917.0
     75        # Ocean water density (kg/m^3)
     76        self.rho_water = 1023.0
     77        # Fresh water density (kg/m^3)
     78        self.rho_freshwater = 1000.0
     79        # Water viscosity (N.s/m^2)
    8280        self.mu_water = 0.001787
    83         #ice heat capacity cp (J / kg / K)
    84         self.heatcapacity = 2093.
    85         #ice latent heat of fusion L (J / kg)
    86         self.latentheat = 3.34 * 10**5
    87         #ice thermal conductivity (W / m / K)
     81        # Ice heat capacity cp (J/kg/K)
     82        self.heatcapacity = 2093.0
     83        # Ice latent heat of fusion L (J/kg)
     84        self.latentheat = 3.34 * pow(10, 5)
     85        # Ice thermal conductivity (W/m/K)
    8886        self.thermalconductivity = 2.4
    89         #temperate ice thermal conductivity (W / m / K)
     87        # Temperate ice thermal conductivity (W/m/K)
    9088        self.temperateiceconductivity = 0.24
    91         #computation of effective conductivity
     89        # Computation of effective conductivity
    9290        self.effectiveconductivity_averaging = 1
    93         #the melting point of ice at 1 atmosphere of pressure in K
     91        # The melting point of ice at 1 atmosphere of pressure in K
    9492        self.meltingpoint = 273.15
    95         #rate of change of melting point with pressure (K / Pa)
    96         self.beta = 9.8 * 10**-8
    97         #mixed layer (ice-water interface) heat capacity (J / kg / K)
    98         self.mixed_layer_capacity = 3974.
    99         #thermal exchange velocity (ice-water interface) (m / s)
    100         self.thermal_exchange_velocity = 1.00 * 10**-4
    101         #Rheology law: what is the temperature dependence of B with T
    102         #available: none, paterson and arrhenius
     93        # Rate of change of melting point with pressure (K/Pa)
     94        self.beta = 9.8 * pow(10, -8)
     95        # Mixed layer (ice-water interface) heat capacity (J/kg/K)
     96        self.mixed_layer_capacity = 3974.0
     97        # Thermal exchange velocity (ice-water interface) (m/s)
     98        self.thermal_exchange_velocity = 1.00 * pow(10, -4)
     99        # Rheology law: what is the temperature dependence of B with T
     100        # available: none, paterson and arrhenius
    103101        self.rheology_law = 'Paterson'
    104102
    105         #GIA
    106         self.lithosphere_shear_modulus = 6.7 * 10**10  # (Pa)
    107         self.lithosphere_density = 3.32  # (g / cm^ - 3)
    108         self.mantle_shear_modulus = 1.45 * 10**11  # (Pa)
    109         self.mantle_density = 3.34  # (g / cm^ - 3)
    110 
    111         #SLC
    112         self.earth_density = 5512  #average density of the Earth, (kg / m^3)
     103        # SLC
     104        self.earth_density = 5512 # average density of the Earth, (kg/m^3)
    113105
    114106        return self
    115     #}}}
     107    # }}}
    116108
    117     def checkconsistency(self, md, solution, analyses): #{{{
     109    def checkconsistency(self, md, solution, analyses):  # {{{
    118110        md = checkfield(md, 'fieldname', 'materials.rho_ice', '>', 0)
    119111        md = checkfield(md, 'fieldname', 'materials.rho_water', '>', 0)
     
    131123    # }}}
    132124
    133     def marshall(self, prefix, md, fid): #{{{
     125    def marshall(self, prefix, md, fid):  # {{{
    134126        WriteData(fid, prefix, 'name', 'md.materials.type', 'data', 4, 'format', 'Integer')
    135127        WriteData(fid, prefix, 'object', self, 'class', 'materials', 'fieldname', 'rho_ice', 'format', 'Double')
  • TabularUnified issm/trunk-jpl/src/m/classes/materials.m

    r26351 r26358  
    175175                                switch nat
    176176                                case 'ice'
    177                                         disp(sprintf('   \nIce:'));
     177                                        disp(sprintf('\n      Ice:'));
    178178                                        fielddisplay(self,'rho_ice','ice density [kg/m^3]');
    179179                                        fielddisplay(self,'rho_water','ocean water density [kg/m^3]');
     
    192192                                        fielddisplay(self,'rheology_law',['law for the temperature dependance of the rheology: ''None'', ''BuddJacka'', Cuffey'', ''CuffeyTemperate'', ''Paterson'', ''Arrhenius'', ''LliboutryDuval'', ''NyeCO2'', or ''NyeH2O''']);
    193193                                case 'litho'
    194                                         disp(sprintf('   \nLitho:'));
     194                                        disp(sprintf('\n      Litho:'));
    195195                                        fielddisplay(self,'numlayers','number of layers (default: 2)');
    196196                                        fielddisplay(self,'radius','array describing the radius for each interface (numlayers+1) [m]');
     
    211211                                        fielddisplay(self,'issolid','array describing whether the layer is solid or liquid (default 1) (numlayers)');
    212212                                case 'hydro'
    213                                         disp(sprintf('   \nHydro:'));
     213                                        disp(sprintf('\n      Hydro:'));
    214214                                        fielddisplay(self,'rho_ice','ice density [kg/m^3]');
    215215                                        fielddisplay(self,'rho_water','ocean water density [kg/m^3]');
  • TabularUnified issm/trunk-jpl/src/m/classes/materials.py

    r26351 r26358  
    7676            nat = self.nature[i]
    7777            if nat == 'ice':
    78                 s += 'Ice:\n'
     78                s += '\n      Ice:\n'
    7979                s += '{}\n'.format(fielddisplay(self, 'rho_ice', 'ice density [kg/m^3]'))
    8080                s += '{}\n'.format(fielddisplay(self, 'rho_water', 'ocean water density [kg/m^3]'))
     
    9393                s += '{}\n'.format(fielddisplay(self, 'rheology_law', 'law for the temperature dependance of the rheology: \'None\', \'BuddJacka\', \'Cuffey\', \'CuffeyTemperate\', \'Paterson\', \'Arrhenius\', \'LliboutryDuval\', \'NyeCO2\', or \'NyeH2O\''))
    9494            elif nat == 'litho':
    95                 s += 'Litho:\n'
     95                s += '\n      Litho:\n'
    9696                s += '{}\n'.format(fielddisplay(self, 'numlayers', 'number of layers (default: 2)'))
    9797                s += '{}\n'.format(fielddisplay(self, 'radius', 'array describing the radius for each interface (numlayers + 1) [m]'))
     
    111111                s += '{}\n'.format(fielddisplay(self, 'issolid', 'array describing whether the layer is solid or liquid (default: 1) (numlayers)'))
    112112            elif nat == 'hydro':
    113                 s += 'Hydro:\n'
     113                s += '\n      Hydro:\n'
    114114                s += '{}\n'.format(fielddisplay(self, 'rho_ice', 'ice density [kg/m^3]'))
    115115                s += '{}\n'.format(fielddisplay(self, 'rho_water', 'ocean water density [kg/m^3]'))
     
    127127            if nat == 'ice':
    128128                # Ice density (kg/m^3)
    129                 self.rho_ice = 917
     129                self.rho_ice = 917.0
    130130
    131131                # Ocean water density (kg/m^3)
    132                 self.rho_water = 1023
     132                self.rho_water = 1023.0
    133133
    134134                # Fresh water density (kg/m^3)
    135                 self.rho_freshwater = 1000
     135                self.rho_freshwater = 1000.0
    136136
    137137                # Water viscosity (N.s/m^2)
     
    139139
    140140                # Ice heat capacity cp (J/kg/K)
    141                 self.heatcapacity = 2093
     141                self.heatcapacity = 2093.0
    142142
    143143                # Ice latent heat of fusion L (J/kg)
     
    160160
    161161                # Mixed layer (ice-water interface) heat capacity (J/kg/K)
    162                 self.mixed_layer_capacity = 3974
     162                self.mixed_layer_capacity = 3974.0
    163163
    164164                # Thermal exchange velocity (ice-water interface) (m/s)
     
    193193                self.ebm_tauh = [np.nan, np.nan]
    194194                self.rheologymodel = [0, 0]
    195                 self.density = [5.51e3, 5.50e3] # (Pa) # Mantle and lithosphere density [kg/m^3]
     195                self.density = [5.51 * 1e3, 5.50 * 1e3] # (Pa) # Mantle and lithosphere density [kg/m^3]
    196196                self.issolid = [1, 1] # Is layer solid or liquid?
    197197            elif nat == 'hydro':
    198198                # Ice density (kg/m^3)
    199                 self.rho_ice = 917
     199                self.rho_ice = 917.0
    200200
    201201                # Ocean water density (kg/m^3)
    202                 self.rho_water = 1023
     202                self.rho_water = 1023.0
    203203
    204204                # Fresh water density (kg/m^3)
    205                 self.rho_freshwater = 1000
     205                self.rho_freshwater = 1000.0
    206206            else:
    207207                raise RuntimeError("materials setdefaultparameters error message: nature of the material not supported yet! ('ice' or 'litho' or 'hydro')")
  • TabularUnified issm/trunk-jpl/src/m/classes/matestar.m

    r26059 r26358  
    2424                rheology_law                    = '';
    2525
    26                 %slc
     26                %SLC
    2727                earth_density                   = 0;
    2828
     
    8787                        %computation of effective conductivity
    8888                        self.effectiveconductivity_averaging=1;
    89            
     89
    9090                        %the melting point of ice at 1 atmosphere of pressure in K
    9191                        self.meltingpoint=273.15;
     
    104104                        self.rheology_law='Paterson';
    105105
    106                         %SLR
    107                         self.earth_density= 5512;  % average density of the Earth, (kg/m^3)
     106                        %SLC
     107                        self.earth_density= 5512; % average density of the Earth, (kg/m^3)
    108108
    109109                end % }}}
     
    118118                        md = checkfield(md,'fieldname','materials.rheology_law','values',{'None' 'BuddJacka' 'Cuffey' 'CuffeyTemperate' 'Paterson' 'Arrhenius' 'LliboutryDuval'});
    119119                        md = checkfield(md,'fieldname','materials.effectiveconductivity_averaging','numel',[1],'values',[0 1 2]);
    120            
     120
    121121                        if ismember('SealevelchangeAnalysis',analyses),
    122122                                md = checkfield(md,'fieldname','materials.earth_density','>',0,'numel',1);
  • TabularUnified issm/trunk-jpl/src/m/classes/matestar.py

    r26317 r26358  
    88
    99class matestar(object):
    10     '''
    11     MATESTAR class definition
     10    """MATESTAR class definition
    1211
    13         Usage:
    14             matestar = matestar()
    15     '''
     12    Usage:
     13        matestar = matestar()
     14    """
    1615
    17     def __init__(self): #{{{
     16    def __init__(self):  # {{{
    1817        self.rho_ice = 0.
    1918        self.rho_water = 0.
     
    3433        self.rheology_law = ''
    3534
    36         #slc
     35        # SLC
    3736        self.earth_density = 0
    3837
    39         #set default parameters
     38        # Set default parameters
    4039        self.setdefaultparameters()
    41     #}}}
     40    # }}}
    4241
    43     def __repr__(self): #{{{
    44         s = "   Materials:"
    45         s = "%s\n%s" % (s, fielddisplay(self, 'rho_ice', 'ice density [kg/m^3]'))
    46         s = "%s\n%s" % (s, fielddisplay(self, 'rho_water', 'ocean water density [kg/m^3]'))
    47         s = "%s\n%s" % (s, fielddisplay(self, 'rho_freshwater', 'fresh water density [kg/m^3]'))
    48         s = "%s\n%s" % (s, fielddisplay(self, 'mu_water', 'water viscosity [N s/m^2]'))
    49         s = "%s\n%s" % (s, fielddisplay(self, 'heatcapacity', 'heat capacity [J/kg/K]'))
    50         s = "%s\n%s" % (s, fielddisplay(self, 'thermalconductivity', ['ice thermal conductivity [W/m/K]']))
    51         s = "%s\n%s" % (s, fielddisplay(self, 'temperateiceconductivity', 'temperate ice thermal conductivity [W/m/K]'))
    52         s = "%s\n%s" % (s, fielddisplay(self, "effectiveconductivity_averaging", "computation of effectiveconductivity: (0) arithmetic mean, (1) harmonic mean, (2) geometric mean (default)"))
    53         s = "%s\n%s" % (s, fielddisplay(self, 'meltingpoint', 'melting point of ice at 1atm in K'))
    54         s = "%s\n%s" % (s, fielddisplay(self, 'latentheat', 'latent heat of fusion [J / kg]'))
    55         s = "%s\n%s" % (s, fielddisplay(self, 'beta', 'rate of change of melting point with pressure [K/Pa]'))
    56         s = "%s\n%s" % (s, fielddisplay(self, 'mixed_layer_capacity', 'mixed layer capacity [W/kg/K]'))
    57         s = "%s\n%s" % (s, fielddisplay(self, 'thermal_exchange_velocity', 'thermal exchange velocity [m/s]'))
    58         s = "%s\n%s" % (s, fielddisplay(self, 'rheology_B', 'flow law parameter [Pa s^(1/3)]'))
    59         s = "%s\n%s" % (s, fielddisplay(self, 'rheology_Ec', 'compressive enhancement factor'))
    60         s = "%s\n%s" % (s, fielddisplay(self, 'rheology_Es', 'shear enhancement factor'))
    61         s = "%s\n%s" % (s, fielddisplay(self, 'rheology_law', ['law for the temperature dependance of the rheology: ''None'', ''BuddJacka'', ''Cuffey'', ''CuffeyTemperate'', ''Paterson'', ''Arrhenius'' or ''LliboutryDuval''']))
    62         s = "%s\n%s" % (s, fielddisplay(self, 'earth_density', 'Mantle density [kg/m^-3]'))
     42    def __repr__(self):  # {{{
     43        s = '   Materials:\n'
     44        s += '{}\n'.format(fielddisplay(self, 'rho_ice', 'ice density [kg/m^3]'))
     45        s += '{}\n'.format(fielddisplay(self, 'rho_water', 'ocean water density [kg/m^3]'))
     46        s += '{}\n'.format(fielddisplay(self, 'rho_freshwater', 'fresh water density [kg/m^3]'))
     47        s += '{}\n'.format(fielddisplay(self, 'mu_water', 'water viscosity [N s/m^2]'))
     48        s += '{}\n'.format(fielddisplay(self, 'heatcapacity', 'heat capacity [J/kg/K]'))
     49        s += '{}\n'.format(fielddisplay(self, 'thermalconductivity', ['ice thermal conductivity [W/m/K]']))
     50        s += '{}\n'.format(fielddisplay(self, 'temperateiceconductivity', 'temperate ice thermal conductivity [W/m/K]'))
     51        s += '{}\n'.format(fielddisplay(self, "effectiveconductivity_averaging", "computation of effectiveconductivity: (0) arithmetic mean, (1) harmonic mean, (2) geometric mean (default)"))
     52        s += '{}\n'.format(fielddisplay(self, 'meltingpoint', 'melting point of ice at 1atm in K'))
     53        s += '{}\n'.format(fielddisplay(self, 'latentheat', 'latent heat of fusion [J/kg]'))
     54        s += '{}\n'.format(fielddisplay(self, 'beta', 'rate of change of melting point with pressure [K/Pa]'))
     55        s += '{}\n'.format(fielddisplay(self, 'mixed_layer_capacity', 'mixed layer capacity [W/kg/K]'))
     56        s += '{}\n'.format(fielddisplay(self, 'thermal_exchange_velocity', 'thermal exchange velocity [m/s]'))
     57        s += '{}\n'.format(fielddisplay(self, 'rheology_B', 'flow law parameter [Pa s^(1/3)]'))
     58        s += '{}\n'.format(fielddisplay(self, 'rheology_Ec', 'compressive enhancement factor'))
     59        s += '{}\n'.format(fielddisplay(self, 'rheology_Es', 'shear enhancement factor'))
     60        s += '{}\n'.format(fielddisplay(self, 'rheology_law', ['law for the temperature dependance of the rheology: \'None\', \'BuddJacka\', \'Cuffey\', \'CuffeyTemperate\', \'Paterson\', \'Arrhenius\' or \'LliboutryDuval\'']))
     61        s += '{}\n'.format(fielddisplay(self, 'earth_density', 'Mantle density [kg/m^-3]'))
    6362
    6463        return s
    65     #}}}
     64    # }}}
    6665
    67     def extrude(self, md): #{{{
     66    def extrude(self, md):  # {{{
    6867        self.rheology_B = project3d(md, 'vector', self.rheology_B, 'type', 'node')
    6968        self.rheology_Ec = project3d(md, 'vector', self.rheology_Ec, 'type', 'node')
     
    7170
    7271        return self
    73     #}}}
     72    # }}}
    7473
    75     def setdefaultparameters(self): #{{{
    76         #ice density (kg / m^3)
    77         self.rho_ice = 917.
    78         #ocean water density (kg / m^3)
    79         self.rho_water = 1023.
    80         #fresh water density (kg / m^3)
    81         self.rho_freshwater = 1000.
    82         #water viscosity (N.s / m^2)
     74    def setdefaultparameters(self):  # {{{
     75        # Ice density (kg/m^3)
     76        self.rho_ice = 917.0
     77        # Ocean water density (kg/m^3)
     78        self.rho_water = 1023.0
     79        # Fresh water density (kg/m^3)
     80        self.rho_freshwater = 1000.0
     81        # Water viscosity (N.s/m^2)
    8382        self.mu_water = 0.001787
    84         #ice heat capacity cp (J / kg / K)
    85         self.heatcapacity = 2093.
    86         #ice latent heat of fusion L (J / kg)
    87         self.latentheat = 3.34e5
    88         #ice thermal conductivity (W / m / K)
     83        # Ice heat capacity cp (J/kg/K)
     84        self.heatcapacity = 2093.0
     85        # Ice latent heat of fusion L (J/kg)
     86        self.latentheat = 3.34 * pow(10, 5)
     87        # Ice thermal conductivity (W/m/K)
    8988        self.thermalconductivity = 2.4
    90         #wet ice thermal conductivity (W / m / K)
     89        # Wet ice thermal conductivity (W/m/K)
    9190        self.temperateiceconductivity = 0.24
    92         #computation of effective conductivity
     91        # Computation of effective conductivity
    9392        self.effectiveconductivity_averaging = 1
    94         #the melting point of ice at 1 atmosphere of pressure in K
     93        # The melting point of ice at 1 atmosphere of pressure in K
    9594        self.meltingpoint = 273.15
    96         #rate of change of melting point with pressure (K / Pa)
    97         self.beta = 9.8e-8
    98         #mixed layer (ice-water interface) heat capacity (J / kg / K)
    99         self.mixed_layer_capacity = 3974.
    100         #thermal exchange velocity (ice-water interface) (m / s)
    101         self.thermal_exchange_velocity = 1.00e-4
    102         #Rheology law: what is the temperature dependence of B with T
    103         #available: none, paterson and arrhenius
     95        # Rate of change of melting point with pressure (K/Pa)
     96        self.beta = 9.8 * pow(10, -8)
     97        # Mixed layer (ice-water interface) heat capacity (J/kg/K)
     98        self.mixed_layer_capacity = 3974.0
     99        # Thermal exchange velocity (ice-water interface) (m/s)
     100        self.thermal_exchange_velocity = 1.00 * pow(10, -4)
     101        # Rheology law: what is the temperature dependence of B with T
     102        # available: none, paterson and arrhenius
    104103        self.rheology_law = 'Paterson'
    105         #slc
    106         self.earth_density = 5512  # average density of the Earth, (kg / m^3)
     104        # SLC
     105        self.earth_density = 5512 # average density of the Earth (kg/m^3)
    107106
    108107        return self
    109     #}}}
     108    # }}}
    110109
    111     def checkconsistency(self, md, solution, analyses): #{{{
     110    def checkconsistency(self, md, solution, analyses):  # {{{
    112111        md = checkfield(md, 'fieldname', 'materials.rho_ice', '>', 0)
    113112        md = checkfield(md, 'fieldname', 'materials.rho_water', '>', 0)
     
    126125    # }}}
    127126
    128     def marshall(self, prefix, md, fid): #{{{
     127    def marshall(self, prefix, md, fid):  # {{{
    129128        WriteData(fid, prefix, 'name', 'md.materials.type', 'data', 2, 'format', 'Integer')
    130129        WriteData(fid, prefix, 'object', self, 'class', 'materials', 'fieldname', 'rho_ice', 'format', 'Double')
  • TabularUnified issm/trunk-jpl/src/m/classes/matice.js

    r24092 r26358  
    22//
    33//   Usage:
    4 //      matice=matice();
     4//      matice = new matice();
    55
    66function matice(){
     7        //properties
     8        // {{{
     9        this.rho_ice                                                    = 0;
     10        this.rho_water                                                  = 0;
     11        this.rho_freshwater                                             = 0;
     12        this.mu_water                                                   = 0;
     13        this.heatcapacity                                               = 0;
     14        this.latentheat                                                 = 0;
     15        this.thermalconductivity                                = 0;
     16        this.temperateiceconductivity                   = 0;
     17        this.effectiveconductivity_averaging    = 0;
     18        this.meltingpoint                                               = 0;
     19        this.beta                                                               = 0;
     20        this.mixed_layer_capacity                               = 0;
     21        this.thermal_exchange_velocity                  = 0;
     22        this.rheology_B                                                 = NaN;
     23        this.rheology_n                                                 = NaN;
     24        this.rheology_law                                               = '';
     25
     26        //SLC
     27        this.earth_density= 5512; // average density of the Earth, (kg/m^3)
     28
     29        this.setdefaultparameters();
     30        //}}}
     31
    732        //methods
    833        this.setdefaultparameters = function(){ // {{{
    934
    1035                //ice density (kg/m^3)
    11                 this.rho_ice=917.;
     36                this.rho_ice=917;
    1237
    1338                //ocean water density (kg/m^3)
    14                 this.rho_water=1023.;
     39                this.rho_water=1023;
    1540
    1641                //fresh water density (kg/m^3)
    17                 this.rho_freshwater=1000.;
     42                this.rho_freshwater=1000;
    1843
    1944                //water viscosity (N.s/m^2)
    20                 this.mu_water=0.001787; 
     45                this.mu_water=0.001787;
    2146
    2247                //ice heat capacity cp (J/kg/K)
    23                 this.heatcapacity=2093.;
     48                this.heatcapacity=2093;
    2449
    2550                //ice latent heat of fusion L (J/kg)
    26                 this.latentheat=3.34*Math.pow(10,5);
     51                this.latentheat=3.34*Math.pow(10, 5);
    2752
    2853                //ice thermal conductivity (W/m/K)
     
    3257                this.temperateiceconductivity=.24;
    3358
     59                //computation of effective conductivity
     60                this.effectiveconductivity_averaging=1;
     61
    3462                //the melting point of ice at 1 atmosphere of pressure in K
    3563                this.meltingpoint=273.15;
    3664
    3765                //rate of change of melting point with pressure (K/Pa)
    38                 this.beta=9.8*Math.pow(10,-8);
     66                this.beta=9.8e-8;
    3967
    4068                //mixed layer (ice-water interface) heat capacity (J/kg/K)
    41                 this.mixed_layer_capacity=3974.;
     69                this.mixed_layer_capacity=3974;
    4270
    4371                //thermal exchange velocity (ice-water interface) (m/s)
    44                 this.thermal_exchange_velocity=1.00*Math.pow(10,-4);
     72                this.thermal_exchange_velocity=1.00*1e-4;
    4573
    4674                //Rheology law: what is the temperature dependence of B with T
     
    4876                this.rheology_law='Paterson';
    4977
    50                 // GIA:
    51                 this.lithosphere_shear_modulus  = 6.7*Math.pow(10,10);  // (Pa)
    52                 this.lithosphere_density        = 3.32;       // (g/cm^-3)
    53                 this.mantle_shear_modulus       = 1.45*Math.pow(10,11); // (Pa)
    54                 this.mantle_density             = 3.34;       // (g/cm^-3)
     78                // Rheology for ice
     79                this.rheology_B = 2.1 * 1e8
     80                this.rheology_n = 3
    5581
    56                 //SLR
    57                 this.earth_density= 5512;  // average density of the Earth, (kg/m^3)
     82                //SLC
     83                this.earth_density= 5512; // average density of the Earth, (kg/m^3)
    5884
    5985
     
    6995                fielddisplay(this,'thermalconductivity','ice thermal conductivity [W/m/K]');
    7096                fielddisplay(this,'temperateiceconductivity','temperate ice thermal conductivity [W/m/K]');
     97                fielddisplay(this,'effectiveconductivity_averaging','computation of effectiveconductivity: (0) arithmetic mean, (1) harmonic mean, (2) geometric mean (default)');
    7198                fielddisplay(this,'meltingpoint','melting point of ice at 1atm in K');
    7299                fielddisplay(this,'latentheat','latent heat of fusion [J/kg]');
     
    75102                fielddisplay(this,'thermal_exchange_velocity','thermal exchange velocity [m/s]');
    76103                fielddisplay(this,'rheology_B','flow law parameter [Pa s^(1/n)]');
    77                 fielddisplay(this,'rheology_n',"Glen's flow law exponent");
    78                 fielddisplay(this,'rheology_law',"law for the temperature dependance of the rheology: 'None', 'BuddJacka', 'Cuffey', 'CuffeyTemperate', 'Paterson', 'Arrhenius','LliboutryDuval','NyeH2O', or 'NyeCO2'");
    79                 fielddisplay(this,'lithosphere_shear_modulus','Lithosphere shear modulus [Pa]');
    80                 fielddisplay(this,'lithosphere_density','Lithosphere density [g/cm^-3]');
    81                 fielddisplay(this,'mantle_shear_modulus','Mantle shear modulus [Pa]');
    82                 fielddisplay(this,'mantle_density','Mantle density [g/cm^-3]');
     104                fielddisplay(this,'rheology_n','Glen\'s flow law exponent');
     105                fielddisplay(this,'rheology_law','law for the temperature dependance of the rheology: \'None\', \'BuddJacka\', \'Cuffey\', \'CuffeyTemperate\', \'Paterson\', \'Arrhenius\', \'LliboutryDuval\', \'NyeH2O\', or \'NyeCO2\'');
    83106                fielddisplay(this,'earth_density','Mantle density [kg/m^-3]');
    84107
     
    90113        }//}}}
    91114        this.classname = function() {// {{{
    92                 return "matice";
     115                return 'matice';
    93116        } // }}}
    94117        this.checkconsistency = function(md,solution,analyses) { // {{{
    95                 checkfield(md,'fieldname','materials.rho_ice','>',0);
    96                 checkfield(md,'fieldname','materials.rho_water','>',0);
    97                 checkfield(md,'fieldname','materials.rho_freshwater','>',0);
    98                 checkfield(md,'fieldname','materials.mu_water','>',0);
    99                 checkfield(md,'fieldname','materials.rheology_B','>',0,'timeseries',1,'NaN',1,'Inf',1);
    100                 checkfield(md,'fieldname','materials.rheology_n','>',0,'size',[md.mesh.numberofelements,1]);
    101                 checkfield(md,'fieldname','materials.rheology_law','values',['None','BuddJacka','Cuffey','CuffeyTemperate','Paterson','Arrhenius','LliboutryDuval','NyeH2O','NyeCO2']);
    102 
    103                 if(ArrayAnyEqual(ArrayIsMember('GiaAnalysis',analyses),1)){
    104                         checkfield(md,'fieldname','materials.lithosphere_shear_modulus','>',0,'numel',1);
    105                         checkfield(md,'fieldname','materials.lithosphere_density','>',0,'numel',1);
    106                         checkfield(md,'fieldname','materials.mantle_shear_modulus','>',0,'numel',1);
    107                         checkfield(md,'fieldname','materials.mantle_density','>',0,'numel',1);
     118                if (solution == 'TransientSolution' && md.transient.isslc) {
     119                        checkfield(md,'fieldname','materials.earth_density','>',0,'numel',[1])
     120                } else {
     121                        checkfield(md,'fieldname','materials.rho_ice','>',0);
     122                        checkfield(md,'fieldname','materials.rho_water','>',0);
     123                        checkfield(md,'fieldname','materials.rho_freshwater','>',0);
     124                        checkfield(md,'fieldname','materials.mu_water','>',0);
     125                        checkfield(md,'fieldname','materials.rheology_B','>',0,'universal',1,'NaN',1,'Inf',1);
     126                        checkfield(md,'fieldname','materials.rheology_n','>',0,'universal',1,'NaN',1,'Inf',1);
     127                        checkfield(md,'fieldname','materials.rheology_law','values',['None','BuddJacka','Cuffey','CuffeyTemperate','Paterson','Arrhenius','LliboutryDuval','NyeH2O','NyeCO2']);
     128                        checkfield(md,'fieldname','materials.effectiveconductivity_averaging','numel',[1],'values',[0,1,2])
    108129                }
    109                 if (ArrayAnyEqual(ArrayIsMember('SealevelriseAnalysis',analyses),1)){
    110                         checkfield(md,'fieldname','materials.earth_density','>',0,'numel',1);
    111                 }
    112 
    113 
    114130        } // }}}
    115131        this.marshall=function(md,prefix,fid) { //{{{
     
    123139                WriteData(fid,prefix,'object',this,'class','materials','fieldname','thermalconductivity','format','Double');
    124140                WriteData(fid,prefix,'object',this,'class','materials','fieldname','temperateiceconductivity','format','Double');
     141                WriteData(fid,prefix,'object',this,'class','materials','fieldname','effectiveconductivity_averaging','format','Integer');
    125142                WriteData(fid,prefix,'object',this,'class','materials','fieldname','meltingpoint','format','Double');
    126143                WriteData(fid,prefix,'object',this,'class','materials','fieldname','beta','format','Double');
    127144                WriteData(fid,prefix,'object',this,'class','materials','fieldname','mixed_layer_capacity','format','Double');
    128145                WriteData(fid,prefix,'object',this,'class','materials','fieldname','thermal_exchange_velocity','format','Double');
    129                 WriteData(fid,prefix,'object',this,'class','materials','fieldname','rheology_B','format','DoubleMat','mattype',1,'timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts);
     146                if ((shape(self.rheology_B)[0] == md.mesh.numberofvertices) || (shape(self.rheology_B)[0] == md.mesh.numberofvertices + 1) or (shape(self.rheology_B)[0] == md.mesh.numberofelements && shape(self.rheology_B)[1] > 1)) {
     147                        mattype = 1
     148                        tsl = md.mesh.numberofvertices
     149                } else {
     150                        mattype = 2
     151                        tsl = md.mesh.numberofelements
     152                }
     153                WriteData(fid,prefix,'object',this,'class','materials','fieldname','rheology_B','format','DoubleMat','mattype',mattype,'timeserieslength',tsl+1,'yts',md.constants.yts);
    130154                WriteData(fid,prefix,'object',this,'class','materials','fieldname','rheology_n','format','DoubleMat','mattype',2);
    131155                WriteData(fid,prefix,'data',this.rheology_law,'name','md.materials.rheology_law','format','String');
    132                 WriteData(fid,prefix,'object',this,'class','materials','fieldname','lithosphere_shear_modulus','format','Double');
    133                 WriteData(fid,prefix,'object',this,'class','materials','fieldname','lithosphere_density','format','Double','scale',Math.pow(10,3));
    134                 WriteData(fid,prefix,'object',this,'class','materials','fieldname','mantle_shear_modulus','format','Double');
    135                 WriteData(fid,prefix,'object',this,'class','materials','fieldname','mantle_density','format','Double','scale',Math.pow(10,3));
    136156                WriteData(fid,prefix,'object',this,'class','materials','fieldname','earth_density','format','Double');
    137157
     
    139159        this.fix=function() { //{{{
    140160        }//}}}
    141         //properties
    142         // {{{
    143                 this.rho_ice                    = 0.;
    144                 this.rho_water                  = 0.;
    145                 this.rho_freshwater             = 0.;
    146                 this.mu_water                   = 0.;
    147                 this.heatcapacity               = 0.;
    148                 this.latentheat                 = 0.;
    149                 this.thermalconductivity        = 0.;
    150                 this.temperateiceconductivity   = 0.;
    151                 this.meltingpoint               = 0.;
    152                 this.beta                       = 0.;
    153                 this.mixed_layer_capacity       = 0.;
    154                 this.thermal_exchange_velocity  = 0.;
    155                 this.rheology_B   = NaN;
    156                 this.rheology_n   = NaN;
    157                 this.rheology_law = '';
    158 
    159                 //giaivins:
    160                 this.lithosphere_shear_modulus  = 0.;
    161                 this.lithosphere_density        = 0.;
    162                 this.mantle_shear_modulus       = 0.;
    163                 this.mantle_density             = 0.;
    164 
    165                 //SLR
    166                 this.earth_density= 5512;  // average density of the Earth, (kg/m^3)
    167 
    168                 this.setdefaultparameters();
    169                 //}}}
    170161}
  • TabularUnified issm/trunk-jpl/src/m/classes/matice.m

    r26062 r26358  
    7575                        %wet ice thermal conductivity (W/m/K)
    7676                        self.temperateiceconductivity=.24;
    77                        
     77
    7878                        %computation of effective conductivity
    7979                        self.effectiveconductivity_averaging=1;
  • TabularUnified issm/trunk-jpl/src/m/classes/matice.py

    r26059 r26358  
    1414    """
    1515
    16     def __init__(self): #{{{
    17         self.rho_ice = 0.
    18         self.rho_water = 0.
    19         self.rho_freshwater = 0.
    20         self.mu_water = 0.
    21         self.heatcapacity = 0.
    22         self.latentheat = 0.
    23         self.thermalconductivity = 0.
    24         self.temperateiceconductivity = 0.
     16    def __init__(self):  # {{{
     17        self.rho_ice = 0
     18        self.rho_water = 0
     19        self.rho_freshwater = 0
     20        self.mu_water = 0
     21        self.heatcapacity = 0
     22        self.latentheat = 0
     23        self.thermalconductivity = 0
     24        self.temperateiceconductivity = 0
    2525        self.effectiveconductivity_averaging = 0
    26         self.meltingpoint = 0.
    27         self.beta = 0.
    28         self.mixed_layer_capacity = 0.
    29         self.thermal_exchange_velocity = 0.
     26        self.meltingpoint = 0
     27        self.beta = 0
     28        self.mixed_layer_capacity = 0
     29        self.thermal_exchange_velocity = 0
    3030        self.rheology_B = np.nan
    3131        self.rheology_n = np.nan
    3232        self.rheology_law = ''
    3333
    34         #slc
     34        # SLC
    3535        self.earth_density = 0
     36
    3637        self.setdefaultparameters()
    37     #}}}
     38    # }}}
    3839
    39     def __repr__(self): #{{{
    40         s = "   Materials:"
    41         s = "%s\n%s" % (s, fielddisplay(self, "rho_ice", "ice density [kg/m^3]"))
    42         s = "%s\n%s" % (s, fielddisplay(self, "rho_water", "water density [kg/m^3]"))
    43         s = "%s\n%s" % (s, fielddisplay(self, "rho_freshwater", "fresh water density [kg/m^3]"))
    44         s = "%s\n%s" % (s, fielddisplay(self, "mu_water", "water viscosity [Ns/m^2]"))
    45         s = "%s\n%s" % (s, fielddisplay(self, "heatcapacity", "heat capacity [J/kg/K]"))
    46         s = "%s\n%s" % (s, fielddisplay(self, "thermalconductivity", "ice thermal conductivity [W/m/K]"))
    47         s = "%s\n%s" % (s, fielddisplay(self, "temperateiceconductivity", "temperate ice thermal conductivity [W/m/K]"))
    48         s = "%s\n%s" % (s, fielddisplay(self, "effectiveconductivity_averaging", "computation of effectiveconductivity: (0) arithmetic mean, (1) harmonic mean, (2) geometric mean (default)"))
    49         s = "%s\n%s" % (s, fielddisplay(self, "meltingpoint", "melting point of ice at 1atm in K"))
    50         s = "%s\n%s" % (s, fielddisplay(self, "latentheat", "latent heat of fusion [J/m^3]"))
    51         s = "%s\n%s" % (s, fielddisplay(self, "beta", "rate of change of melting point with pressure [K/Pa]"))
    52         s = "%s\n%s" % (s, fielddisplay(self, "mixed_layer_capacity", "mixed layer capacity [W/kg/K]"))
    53         s = "%s\n%s" % (s, fielddisplay(self, "thermal_exchange_velocity", "thermal exchange velocity [m/s]"))
    54         s = "%s\n%s" % (s, fielddisplay(self, "rheology_B", "flow law parameter [Pa s^(1/n)]"))
    55         s = "%s\n%s" % (s, fielddisplay(self, "rheology_n", "Glen's flow law exponent"))
    56         s = "%s\n%s" % (s, fielddisplay(self, "rheology_law", "law for the temperature dependance of the rheology: 'None', 'BuddJacka', 'Cuffey', 'CuffeyTemperate', 'Paterson', 'Arrhenius', 'LliboutryDuval', 'NyeCO2', or 'NyeH2O'"))
    57         s = "%s\n%s" % (s, fielddisplay(self, "earth_density", "Mantle density [kg/m^-3]"))
     40    def __repr__(self):  # {{{
     41        s = '   Materials:\n'
     42        s += '{}\n'.format(fielddisplay(self, 'rho_ice', 'ice density [kg/m^3]'))
     43        s += '{}\n'.format(fielddisplay(self, 'rho_water', 'water density [kg/m^3]'))
     44        s += '{}\n'.format(fielddisplay(self, 'rho_freshwater', 'fresh water density [kg/m^3]'))
     45        s += '{}\n'.format(fielddisplay(self, 'mu_water', 'water viscosity [Ns/m^2]'))
     46        s += '{}\n'.format(fielddisplay(self, 'heatcapacity', 'heat capacity [J/kg/K]'))
     47        s += '{}\n'.format(fielddisplay(self, 'thermalconductivity', 'ice thermal conductivity [W/m/K]'))
     48        s += '{}\n'.format(fielddisplay(self, 'temperateiceconductivity', 'temperate ice thermal conductivity [W/m/K]'))
     49        s += '{}\n'.format(fielddisplay(self, 'effectiveconductivity_averaging', 'computation of effectiveconductivity: (0) arithmetic mean, (1) harmonic mean, (2) geometric mean (default)'))
     50        s += '{}\n'.format(fielddisplay(self, 'meltingpoint', 'melting point of ice at 1atm in K'))
     51        s += '{}\n'.format(fielddisplay(self, 'latentheat', 'latent heat of fusion [J/m^3]'))
     52        s += '{}\n'.format(fielddisplay(self, 'beta', 'rate of change of melting point with pressure [K/Pa]'))
     53        s += '{}\n'.format(fielddisplay(self, 'mixed_layer_capacity', 'mixed layer capacity [W/kg/K]'))
     54        s += '{}\n'.format(fielddisplay(self, 'thermal_exchange_velocity', 'thermal exchange velocity [m/s]'))
     55        s += '{}\n'.format(fielddisplay(self, 'rheology_B', 'flow law parameter [Pa s^(1/n)]'))
     56        s += '{}\n'.format(fielddisplay(self, 'rheology_n', 'Glen\'s flow law exponent'))
     57        s += '{}\n'.format(fielddisplay(self, 'rheology_law', 'law for the temperature dependance of the rheology: \'None\', \'BuddJacka\', \'Cuffey\', \'CuffeyTemperate\', \'Paterson\', \'Arrhenius\', \'LliboutryDuval\', \'NyeCO2\', or \'NyeH2O\''))
     58        s += '{}\n'.format(fielddisplay(self, 'earth_density', 'Mantle density [kg/m^-3]'))
     59        return s
     60    # }}}
    5861
    59         return s
    60     #}}}
    61 
    62     def extrude(self, md): #{{{
     62    def extrude(self, md):  # {{{
    6363        self.rheology_B = project3d(md, 'vector', self.rheology_B, 'type', 'node')
    6464        self.rheology_n = project3d(md, 'vector', self.rheology_n, 'type', 'element')
    6565        return self
    66     #}}}
     66    # }}}
    6767
    68     def setdefaultparameters(self): #{{{
    69         #ice density (kg/m^3)
    70         self.rho_ice = 917.
    71         #ocean water density (kg/m^3)
    72         self.rho_water = 1023.
    73         #fresh water density (kg/m^3)
    74         self.rho_freshwater = 1000.
    75         #water viscosity (N.s/m^2)
     68    def setdefaultparameters(self):  # {{{
     69        # Ice density (kg/m^3)
     70        self.rho_ice = 917.0
     71        # Ocean water density (kg/m^3)
     72        self.rho_water = 1023.0
     73        # Fresh water density (kg/m^3)
     74        self.rho_freshwater = 1000.0
     75        # Water viscosity (N.s/m^2)
    7676        self.mu_water = 0.001787
    77         #ice heat capacity cp (J/kg/K)
    78         self.heatcapacity = 2093.
    79         #ice latent heat of fusion L (J/kg)
    80         self.latentheat = 3.34e5
    81         #ice thermal conductivity (W/m/K)
     77        # Ice heat capacity cp (J/kg/K)
     78        self.heatcapacity = 2093.0
     79        # Ice latent heat of fusion L (J/kg)
     80        self.latentheat = 3.34 * pow(10, 5)
     81        # Ice thermal conductivity (W/m/K)
    8282        self.thermalconductivity = 2.4
    83         #temperate ice thermal conductivity (W/m/K)
     83        # Temperate ice thermal conductivity (W/m/K)
    8484        self.temperateiceconductivity = 0.24
    85         #computation of effective conductivity
     85        # Computation of effective conductivity
    8686        self.effectiveconductivity_averaging = 1
    87         #the melting point of ice at 1 atmosphere of pressure in K
     87        # The melting point of ice at 1 atmosphere of pressure in K
    8888        self.meltingpoint = 273.15
    89         #rate of change of melting point with pressure (K/Pa)
    90         self.beta = 9.8e-8
    91         #mixed layer (ice-water interface) heat capacity (J/kg/K)
    92         self.mixed_layer_capacity = 3974.
    93         #thermal exchange velocity (ice-water interface) (m/s)
    94         self.thermal_exchange_velocity = 1.00e-4
    95         #Rheology law: what is the temperature dependence of B with T
    96         #available: none, paterson and arrhenius
     89        # Rate of change of melting point with pressure (K/Pa)
     90        self.beta = 9.8 * pow(10, -8)
     91        # Mixed layer (ice-water interface) heat capacity (J/kg/K)
     92        self.mixed_layer_capacity = 3974.0
     93        # Thermal exchange velocity (ice-water interface) (m/s)
     94        self.thermal_exchange_velocity = 1.00 * pow(10, -4)
     95        # Rheology law: what is the temperature dependence of B with T
     96        # available: none, paterson and arrhenius
    9797        self.rheology_law = 'Paterson'
    9898
     
    103103        # SLR
    104104        self.earth_density = 5512  # average density of the Earth, (kg/m^3)
    105     #}}}
     105    # }}}
    106106
    107     def checkconsistency(self, md, solution, analyses): #{{{
     107    def checkconsistency(self, md, solution, analyses):  # {{{
    108108        if solution == 'TransientSolution' and md.transient.isslc:
    109109            md = checkfield(md, 'fieldname', 'materials.earth_density', '>', 0, 'numel', [1])
     
    116116            md = checkfield(md, 'fieldname', 'materials.rheology_n', '>', 0, 'universal',1, 'NaN', 1, 'Inf', 1)
    117117            md = checkfield(md, 'fieldname', 'materials.rheology_law', 'values', ['None', 'BuddJacka', 'Cuffey', 'CuffeyTemperate', 'Paterson', 'Arrhenius', 'LliboutryDuval', 'NyeCO2', 'NyeH2O'])
    118             md = checkfield(md,'fieldname','materials.effectiveconductivity_averaging', 'numel', [1], 'values', [0, 1, 2])
     118            md = checkfield(md, 'fieldname', 'materials.effectiveconductivity_averaging', 'numel', [1], 'values', [0, 1, 2])
    119119
    120120        return md
    121     #}}}
     121    # }}}
    122122
    123     def marshall(self, prefix, md, fid): #{{{
     123    def marshall(self, prefix, md, fid):  # {{{
    124124        WriteData(fid, prefix, 'name', 'md.materials.type', 'data', 3, 'format', 'Integer')
    125125        WriteData(fid, prefix, 'object', self, 'class', 'materials', 'fieldname', 'rho_ice', 'format', 'Double')
     
    136136        WriteData(fid, prefix, 'object', self, 'class', 'materials', 'fieldname', 'mixed_layer_capacity', 'format', 'Double')
    137137        WriteData(fid, prefix, 'object', self, 'class', 'materials', 'fieldname', 'thermal_exchange_velocity', 'format', 'Double')
    138         WriteData(fid, prefix, 'object', self, 'class', 'materials', 'fieldname', 'rheology_B', 'format', 'DoubleMat', 'mattype', 1, 'timeserieslength', md.mesh.numberofvertices + 1, 'yts', md.constants.yts)
     138        # NOTE: We first have to check if we have a NumPy array here
     139        if ((len(np.shape(self.rheology_B)) == 1 and (np.shape(self.rheology_B)[0] == md.mesh.numberofvertices or np.shape(self.rheology_B)[0] == md.mesh.numberofvertices + 1)) or (len(np.shape(self.rheology_B)) == 2 and np.shape(self.rheology_B)[0] == md.mesh.numberofelements and np.shape(self.rheology_B)[1] > 1)):
     140            mattype = 1
     141            tsl = md.mesh.numberofvertices
     142        else:
     143            mattype = 2
     144            tsl = md.mesh.numberofelements
     145        WriteData(fid, prefix, 'object', self, 'class', 'materials', 'fieldname', 'rheology_B', 'format', 'DoubleMat', 'mattype', mattype, 'timeserieslength', tsl + 1, 'yts', md.constants.yts)
    139146        WriteData(fid, prefix, 'object', self, 'class', 'materials', 'fieldname', 'rheology_n', 'format', 'DoubleMat', 'mattype', 2)
    140147        WriteData(fid, prefix, 'data', self.rheology_law, 'name', 'md.materials.rheology_law', 'format', 'String')
    141148        WriteData(fid, prefix, 'object', self, 'class', 'materials', 'fieldname', 'earth_density', 'format', 'Double')
    142     #}}}
     149    # }}}
  • TabularUnified issm/trunk-jpl/src/m/classes/model.m

    r26334 r26358  
    235235                        disp(sprintf('%19s: %-22s -- %s','thermal'         ,['[1x1 ' class(self.thermal) ']'],'parameters for thermal solution'));
    236236                        disp(sprintf('%19s: %-22s -- %s','steadystate'     ,['[1x1 ' class(self.steadystate) ']'],'parameters for steadystate solution'));
    237                         disp(sprintf('%19s: %-22s -- %s','transient'       ,['[1x1 ' class(self.transient) ']'],'parHwoameters for transient solution'));
     237                        disp(sprintf('%19s: %-22s -- %s','transient'       ,['[1x1 ' class(self.transient) ']'],'parameters for transient solution'));
    238238                        disp(sprintf('%19s: %-22s -- %s','levelset'        ,['[1x1 ' class(self.levelset) ']'],'parameters for moving boundaries (level-set method)'));
    239239                        disp(sprintf('%19s: %-22s -- %s','calving'         ,['[1x1 ' class(self.calving) ']'],'parameters for calving'));
  • TabularUnified issm/trunk-jpl/src/m/classes/plumebasalforcings.py

    r25688 r26358  
    3939        else:
    4040            error('constuctor not supported')
    41     #}}}
     41    # }}}
    4242
    4343    def __repr__(self):  # {{{
    4444        s = '   mantle plume basal melt parameterization:\n'
    45         s += '{}\n'.format(fielddisplay(self, 'groundedice_melting_rate', 'basal melting rate (positive if melting) [m / yr]'))
    46         s += '{}\n'.format(fielddisplay(self, 'floatingice_melting_rate', 'basal melting rate (positive if melting) [m / yr]'))
    47         s += '{}\n'.format(fielddisplay(self, 'mantleconductivity', 'mantle heat conductivity [W / m^3]'))
     45        s += '{}\n'.format(fielddisplay(self, 'groundedice_melting_rate', 'basal melting rate (positive if melting) [m/yr]'))
     46        s += '{}\n'.format(fielddisplay(self, 'floatingice_melting_rate', 'basal melting rate (positive if melting) [m/yr]'))
     47        s += '{}\n'.format(fielddisplay(self, 'mantleconductivity', 'mantle heat conductivity [W/m^3]'))
    4848        s += '{}\n'.format(fielddisplay(self, 'nusselt', 'nusselt number, ratio of mantle to plume [1]'))
    49         s += '{}\n'.format(fielddisplay(self, 'dtbg', 'background temperature gradient [degree / m]'))
     49        s += '{}\n'.format(fielddisplay(self, 'dtbg', 'background temperature gradient [degree/m]'))
    5050        s += '{}\n'.format(fielddisplay(self, 'plumeradius', 'radius of the mantle plume [m]'))
    5151        s += '{}\n'.format(fielddisplay(self, 'topplumedepth', 'depth of the mantle plume top below the crust [m]'))
     
    5555        s += '{}\n'.format(fielddisplay(self, 'crustthickness', 'thickness of the crust [m]'))
    5656        s += '{}\n'.format(fielddisplay(self, 'uppercrustthickness', 'thickness of the upper crust [m]'))
    57         s += '{}\n'.format(fielddisplay(self, 'uppercrustheat', 'volumic heat of the upper crust [w / m^3]'))
    58         s += '{}\n'.format(fielddisplay(self, 'lowercrustheat', 'volumic heat of the lowercrust [w / m^3]'))
     57        s += '{}\n'.format(fielddisplay(self, 'uppercrustheat', 'volumic heat of the upper crust [w/m^3]'))
     58        s += '{}\n'.format(fielddisplay(self, 'lowercrustheat', 'volumic heat of the lowercrust [w/m^3]'))
    5959        return s
    60     #}}}
     60    # }}}
    6161
    6262    def initialize(self, md):  #{{{
     
    6868            print('      no basalforcings.floatingice_melting_rate specified: values set as zero')
    6969        return self
    70     #}}}
     70    # }}}
    7171
    7272    def extrude(self, md):  # {{{
     
    7474        self.floatingice_melting_rate = project3d(md, 'vector', self.floatingice_melting_rate, 'type', 'node', 'layer', 1)
    7575        return self
    76     #}}}
     76    # }}}
    7777
    7878    def setdefaultparameters(self):  # {{{
     
    8080        self.mantleconductivity = 2.2
    8181        self.nusselt = 300
    82         self.dtbg = 11 / 1000.
     82        self.dtbg = 11 / 1000.0
    8383        self.plumeradius = 100000
    8484        self.topplumedepth = 10000
     
    8686        self.crustthickness = 30000
    8787        self.uppercrustthickness = 14000
    88         self.uppercrustheat = 1.7 * 10**-6
    89         self.lowercrustheat = 0.4 * 10**-6
     88        self.uppercrustheat = 1.7 * pow(10, -6)
     89        self.lowercrustheat = 0.4 * pow(10, -6)
    9090        return self
    91     #}}}
     91    # }}}
    9292
    9393    def checkconsistency(self, md, solution, analyses):  # {{{
  • TabularUnified issm/trunk-jpl/src/m/classes/rotational.m

    r26307 r26358  
    2121                function self = setdefaultparameters(self) % {{{
    2222
    23                         %moment of inertia: 
    24                         self.equatorialmoi      =8.0077*10^37; % [kg m^2] 
    25                         self.polarmoi           =8.0345*10^37; % [kg m^2] 
     23                        %moment of inertia:
     24                        self.equatorialmoi      =8.0077*10^37; % [kg m^2]
     25                        self.polarmoi           =8.0345*10^37; % [kg m^2]
    2626
    27                         % mean rotational velocity of earth 
    28                         self.angularvelocity=7.2921*10^-5; % [s^-1] 
     27                        % mean rotational velocity of earth
     28                        self.angularvelocity=7.2921*10^-5; % [s^-1]
    2929                end % }}}
    3030                function md = checkconsistency(self,md,solution,analyses) % {{{
  • TabularUnified issm/trunk-jpl/src/m/classes/rotational.py

    r26317 r26358  
    3333    def setdefaultparameters(self):  # {{{
    3434        # Moment of inertia
    35         self.equatorialmoi = 8.0077e37 # [kg m^2]
    36         self.polarmoi = 8.0345e37 # [kg m^2]
     35        self.equatorialmoi = 8.0077 * pow(10, 37) # [kg m^2]
     36        self.polarmoi = 8.0345 * pow(10, 37) # [kg m^2]
    3737
    3838        # Mean rotational velocity of earth
    39         self.angularvelocity = 7.2921e-5 # [s^-1]
     39        self.angularvelocity = 7.2921 * pow(10, -5) # [s^-1]
    4040        return self
    4141    #}}}
  • TabularUnified issm/trunk-jpl/src/m/classes/sealevelmodel.m

    r26352 r26358  
    44%      slm = sealevelmodel(varargin)
    55%
    6 %      where varargin is a variable list of options: 
     6%      where varargin is a variable list of options:
    77%
    8 %   Example: 
     8%   Example:
    99%      slm = sealevel('icecap',md_greenland,'icecap',md_antarctica,'earth',md_earth);
    1010
     
    3333                                options=pairoptions(varargin{:});
    3434
    35                                 %recover all the icecap models: 
    36                                 slm.icecaps=getfieldvalues(options,'ice_cap',{}); 
     35                                %recover all the icecap models:
     36                                slm.icecaps=getfieldvalues(options,'ice_cap',{});
    3737                               
    3838                                %recover the earth model:
    3939                                slm.earth = getfieldvalue(options,'earth',0);
    4040
    41                                 %set planet type: 
     41                                %set planet type:
    4242                                slm.planet=getfieldvalue(options,'planet','earth');
    4343
     
    4747                function checkconsistency(slm,solutiontype) % {{{
    4848
    49                         %is the coupler turned on? 
     49                        %is the coupler turned on?
    5050                        for i=1:length(slm.icecaps),
    5151                                if slm.icecaps{i}.transient.iscoupler==0,
     
    5858                        end
    5959
    60                         %check that the transition vectors have the right size: 
     60                        %check that the transition vectors have the right size:
    6161                        for i=1:length(slm.icecaps),
    6262                                if slm.icecaps{i}.mesh.numberofvertices ~= length(slm.earth.solidearth.transitions{i}),
     
    6565                        end
    6666                       
    67                         %check that runfrequency is the same everywhere: 
     67                        %check that runfrequency is the same everywhere:
    6868                        for i=1:length(slm.icecaps),
    6969                                if slm.icecaps{i}.solidearth.settings.runfrequency~=slm.earth.solidearth.settings.runfrequency,
     
    7272                        end
    7373
    74                         %make sure steric_rate is the same everywhere: 
    75                         for i=1:length(slm.icecaps),
    76                                 md= slm.icecaps{i}; 
     74                        %make sure steric_rate is the same everywhere:
     75                        for i=1:length(slm.icecaps),
     76                                md= slm.icecaps{i};
    7777                                if ~isempty(find(md.dsl.steric_rate - slm.earth.dsl.steric_rate(slm.earth.dsl.transitions{i}))),
    7878                                        error(sprintf('sealevelmodel.m::checkconsistency: steric rate on ice cap %s is not the same as for the earth\n',md.miscellaneous.name));
     
    8282                        %make sure grd is the same everywhere:
    8383                        for i=1:length(slm.icecaps),
    84                                 md= slm.icecaps{i}; 
     84                                md= slm.icecaps{i};
    8585                                if md.solidearthsettings.isgrd~=slm.earth.solidearthsettings.isgrd
    8686                                        error(sprintf('sealevelmodel.m::checkconsistency: isgrd on ice cap %s is not the same as for the earth\n',md.miscellaneous.name));
     
    8888                        end
    8989
    90                         %make sure that there is no solid earth external forcing on the basins: 
    91                         for i=1:length(slm.icecaps),
    92                                 md= slm.icecaps{i}; 
     90                        %make sure that there is no solid earth external forcing on the basins:
     91                        for i=1:length(slm.icecaps),
     92                                md= slm.icecaps{i};
    9393                                if ~isempty(md.solidearth.external),
    9494                                        error('sealevelmodel.m::checkconsistency: cannot run external forcings on an ice sheet when running a coupling earth/ice sheet model');
     
    9696
    9797                        end
    98                         %make sure that we have the right grd model for computing out sealevel patterns: 
    99                         for i=1:length(slm.icecaps),
    100                                 md= slm.icecaps{i}; 
     98                        %make sure that we have the right grd model for computing out sealevel patterns:
     99                        for i=1:length(slm.icecaps),
     100                                md= slm.icecaps{i};
    101101                                if md.solidearth.settings.grdmodel~=0
    102102                                        error(sprintf('sealevelmodel.m::checkconsistency: ice sheets do not run GRD module, specify solidearth.settings.grdmodel=0 on ice cap %i',i));
     
    135135                                        for k=1:length(champs),
    136136                                                if strcmpi(class(icecaps{1}.results.TransientSolution(j).(champs{k})),'double'),
    137                                                         %vertex or element? 
     137                                                        %vertex or element?
    138138                                                        if length(icecaps{1}.results.TransientSolution(j).(champs{k}))==icecaps{1}.mesh.numberofvertices,
    139139                                                                md.results.TransientSolution(j).(champs{k})=zeros(md.mesh.numberofvertices,1);
     
    142142                                                                        md.results.TransientSolution(j).(champs{k})(trans{l})=resultcap;
    143143                                                                end
    144                                                         else 
     144                                                        else
    145145                                                                if strcmpi(champs{k},'IceVolume') | strcmpi(champs{k},'IceVolumeAboveFloatation') ,
    146146                                                                        md.results.TransientSolution(j).(champs{k})=0;
     
    195195                function intersections2d(self,varargin) % {{{
    196196
    197                         options=pairoptions(varargin{:}); 
     197                        options=pairoptions(varargin{:});
    198198                        force=getfieldvalue(options,'force',0);
    199199                       
    200                         %initialize, to avoid issues of having more transitions than meshes. 
     200                        %initialize, to avoid issues of having more transitions than meshes.
    201201                        self.transitions={};
    202202                        self.eltransitions={};
     
    209209                                mdi=self.icecaps{i};
    210210               
    211                                 %for elements: 
     211                                %for elements:
    212212                                xei=mdi.mesh.x(mdi.mesh.elements)*[1;1;1]/3;
    213213                                yei=mdi.mesh.y(mdi.mesh.elements)*[1;1;1]/3;
     
    222222                function intersections(self,varargin) % {{{
    223223
    224                         options=pairoptions(varargin{:}); 
     224                        options=pairoptions(varargin{:});
    225225                        force=getfieldvalue(options,'force',0);
    226226                       
    227                         %initialize, to avoid issues of having more transitions than meshes. 
     227                        %initialize, to avoid issues of having more transitions than meshes.
    228228                        self.transitions={};
    229229                        self.eltransitions={};
     
    238238                                mdi=TwoDToThreeD(mdi,self.planet);
    239239               
    240                                 %for elements: 
     240                                %for elements:
    241241                                xei=mdi.mesh.x(mdi.mesh.elements)*[1;1;1]/3;
    242242                                yei=mdi.mesh.y(mdi.mesh.elements)*[1;1;1]/3;
     
    265265                end % }}}
    266266                function baslist=basinindx(self,varargin) % {{{
    267                         options=pairoptions(varargin{:}); 
     267                        options=pairoptions(varargin{:});
    268268                        continent=getfieldvalue(options,'continent','all');
    269269                        bas=getfieldvalue(options,'basin','all');
     
    273273                                if length(continent)==1,
    274274                                        if strcmpi(continent{1},'all'),
    275                                                 %need to transform this into a list of continents: 
    276                                                 continent={}; 
     275                                                %need to transform this into a list of continents:
     276                                                continent={};
    277277                                                for i=1:length(self.basins),
    278278                                                        continent{end+1}=self.basins{i}.continent;
     
    287287                        else
    288288                                if strcmpi(continent,'all'),
    289                                         %need to transform this into a list of continents: 
    290                                         continent={}; 
     289                                        %need to transform this into a list of continents:
     290                                        continent={};
    291291                                        for i=1:length(self.basins),
    292292                                                continent{end+1}=self.basins{i}.continent;
     
    302302                                if length(bas)==1,
    303303                                        if strcmpi(bas{1},'all'),
    304                                                 %need to transform this into a list of basins: 
     304                                                %need to transform this into a list of basins:
    305305                                                baslist=[];
    306306                                                for i=1:length(self.basins),
     
    323323                                        end
    324324                                else
    325                                         %we have a list of basin names: 
     325                                        %we have a list of basin names:
    326326                                        baslist=[];
    327327                                        for i=1:length(bas),
     
    374374                function caticecaps(self,varargin) % {{{
    375375                       
    376                         %recover options: 
    377                         options=pairoptions(varargin{:}); 
     376                        %recover options:
     377                        options=pairoptions(varargin{:});
    378378                        tolerance=getfieldvalue(options,'tolerance',.65);
    379379                        loneedgesdetect=getfieldvalue(options,'loneedgesdetect',0);
     
    386386                       
    387387                        %Plug all models together:
    388                         md=models{1}; 
     388                        md=models{1};
    389389                        for i=2:length(models),
    390390                                md=modelmerge3d(md,models{i},'tolerance',tolerance);
     
    405405                        end %}}}
    406406       
    407                         %Plug into earth: 
     407                        %Plug into earth:
    408408                        self.earth=md;
    409409
     
    414414                function caticecaps2d(self,varargin) % {{{
    415415
    416                         %recover options: 
    417                         options=pairoptions(varargin{:}); 
     416                        %recover options:
     417                        options=pairoptions(varargin{:});
    418418                        tolerance=getfieldvalue(options,'tolerance',1e-5);
    419419                        loneedgesdetect=getfieldvalue(options,'loneedgesdetect',0);
     
    421421
    422422                        %Plug all models together:
    423                         md=models{1}; 
     423                        md=models{1};
    424424                        for i=2:length(models),
    425425                                md=modelmerge2d(md,models{i},'tolerance',tolerance);
     
    437437                        end %}}}
    438438
    439                         %Plug into earth: 
     439                        %Plug into earth:
    440440                        self.earth=md;
    441441
     
    463463                end % }}}
    464464                function transfer(self,string) % {{{
    465                         %Recover field size in one icecap: 
     465                        %Recover field size in one icecap:
    466466                        eval(['n=size(self.icecaps{1}.' string ',1);']);
    467467                        if n==self.icecaps{1}.mesh.numberofvertices,
     
    471471                                end
    472472                        elseif n==(self.icecaps{1}.mesh.numberofvertices+1),
    473                                 %dealing with a transient dataset. 
     473                                %dealing with a transient dataset.
    474474                                %check that all timetags are similar between all icecaps:  %{{{
    475475                                for i=1:length(self.icecaps),
     
    482482                                        end
    483483                                end
    484                                 eval(['capfield1= self.icecaps{1}.' string ';']); 
     484                                eval(['capfield1= self.icecaps{1}.' string ';']);
    485485                                times=capfield1(end,:);
    486486                                nsteps=length(times);
     
    514514                        mintimestep=Inf;
    515515                        for  i=1:length(self.icecaps),
    516                                 ic=self.icecaps{i}; 
     516                                ic=self.icecaps{i};
    517517                                mintimestep=min(mintimestep, length(ic.results.TransientSolution));
    518518                        end
     
    522522                       
    523523                        for  i=1:length(self.icecaps),
    524                                 ic=self.icecaps{i}; 
     524                                ic=self.icecaps{i};
    525525                                ic.results.TransientSolution=ic.results.TransientSolution(1:mintimestep);
    526526                                self.icecaps{i}=ic;
  • TabularUnified issm/trunk-jpl/src/m/classes/sealevelmodel.py

    r26352 r26358  
    3535    """
    3636
    37     def __init__(self, *args):  #{{{
    38         self.icecaps = []  # list of land/ice models; name should be changed later
    39         self.earth = 0  # model for the whole earth
     37    def __init__(self, *args):  # {{{
     38        self.icecaps = [] # list of land/ice models; name should be changed later
     39        self.earth = 0 # model for the whole earth
    4040        self.basins = []  # list of basins, matching icecaps, where shapefile info is held
    4141        self.cluster = 0
     
    6161            # Set planet type
    6262            self.planet = options.getfieldvalue('planet', 'earth')
    63     #}}}
     63    # }}}
    6464
    6565    def __repr__(self):  # {{{
     
    7171
    7272        return s
    73     #}}}
     73    # }}}
    7474
    7575    def setdefaultparameters(self):  # {{{
     
    8383        self.eltransitions = []
    8484        self.planet = 'earth'
    85     #}}}
     85    # }}}
    8686
    8787    @staticmethod
     
    102102        # Check that run frequency is the same everywhere
    103103        for i in range(len(slm.icecaps)):
    104             if slm.icecaps[i].slr.geodetic_run_frequency != slm.earth.geodetic_run_frequency:
     104            if slm.icecaps[i].solidearth.settings.runfrequency != slm.earth.solidearth.settings.runfrequency:
    105105                raise Exception('sealevelmodel.py::checkconsistency: icecap model {} should have the same run frequency as earth!'.format(slm.icecaps[i].miscellaneous.name))
    106106
     
    108108        for i in range(len(slm.icecaps)):
    109109            md = slm.icecaps[i]
    110             if np.nonzero(md.slr.steric_rate - slm.earth.slr.steric_rate[slm.earth.slr.transitions[i]]) != []:
     110            if np.nonzero(md.dsl.steric_rate - slm.earth.dsl.steric_rate[slm.earth.dsl.transitions[i]]) != []:
    111111                raise Exception('sealevelmodel.py::checkconsistency: steric rate on ice cap {} is not the same as for the earth'.format(md.miscellaneous.name))
    112112
     
    116116            if md.solidearthsettings.isgrd != slm.earth.solidearthsettings.isgrd:
    117117                raise RuntimeError('sealevelmodel.py::checkconsistency: isgrd on ice cap {} is not the same as for the earth\n'.format(md.miscellaneous.name))
     118
    118119        # Make sure that there is no solid earth external forcing on the basins
    119120        for i in range(len(slm.icecaps)):
     
    126127            if md.solidearth.settings.grdmodel != 0:
    127128                raise RuntimeError('sealevelmodel.py::checkconsistency: ice sheets do not run GRD module, specify solidearth.settings.grdmodel=0 on ice cap {}'.format(i))
    128     #}}}
     129    # }}}
    129130
    130131    def mergeresults(self):  # {{{
     
    156157                        continue
    157158            self.mergedcaps[2 * i] = md
    158     #}}}
     159    # }}}
    159160
    160161    def listcaps(self):  # {{{
    161162        for i in range(len(self.icecaps)):
    162163            print('{}: {}'.format(i, self.icecaps[i].miscellaneous.name))
    163     #}}}
     164    # }}}
    164165
    165166    def ncaps(self): #{{{
    166167        return len(self.icecaps)
    167     #}}}
     168    # }}}
    168169
    169170    def continents(self):  # {{{
     
    172173            list.append = self.basins[i].continent
    173174        return np.unique(list)
    174     #}}}
     175    # }}}
    175176
    176177    def basinsfromcontinent(self, continent):  # {{{
     
    180181                list.append = self.basins[i].name
    181182        return np.unique(list)
    182     #}}}
     183    # }}}
    183184
    184185    def addbasin(self, bas):  # {{{
     
    186187            raise Exception('addbasin method only takes a \'basin\' class object as input')
    187188        self.basins.append(bas)
    188     #}}}
     189    # }}}
    189190
    190191    def intersections2d(self, *args): #{{{
     
    211212            self.transitions.append(meshintersect2d(self.earth.mesh.x, self.earth.mesh.y, mdi.mesh.x, mdi.mesh.y, 'force', force))
    212213            self.eltransitions.append(meshintersect2d(xe, ye, xei, yei, 'force', force))
    213     #}}}
    214 
    215     def intersections(self, *args):  #{{{
     214    # }}}
     215
     216    def intersections(self, *args):  # {{{
    216217        options = pairoptions(*args)
    217218        force = options.getfieldvalue('force', 0)
     
    239240            self.transitions.append(meshintersect3d(self.earth.mesh.x, self.earth.mesh.y, self.earth.mesh.z, mdi.mesh.x, mdi.mesh.y, mdi.mesh.z, 'force', force))
    240241            self.eltransitions.append(meshintersect3d(xe, ye, ze, xei, yei, zei, 'force', force))
    241     #}}}
    242 
    243     def checkintersections(self):  #{{{
     242    # }}}
     243
     244    def checkintersections(self):  # {{{
    244245        flags = np.zeros(self.earth.mesh.numberofvertices, 1)
    245246        for i in range(len(self.basins)):
    246247            flags[self.transitions[i]] = i
    247248        plotmodel(self.earth, 'data', flags, 'coastline', 'on')
    248     #}}}
    249 
    250     def checkbasinconsistency(self):  #{{{
     249    # }}}
     250
     251    def checkbasinconsistency(self):  # {{{
    251252        for i in range(len(self.basins)):
    252253            self.basins[i].checkconsistency()
    253     #}}}
    254 
    255     def basinindx(self, *args):  #{{{
     254    # }}}
     255
     256    def basinindx(self, *args):  # {{{
    256257        options = pairoptions(*args)
    257258        continent = options.getfieldvalue('continent', 'all')
     
    280281            else:
    281282                pass  # Nothing to do: assume we have a list of continents
    282         #}}}
     283        # }}}
    283284
    284285        # Expand basins list using the continent list above and the extra bas discriminator #{{{
     
    325326
    326327        return baslist
    327         #}}}
    328     #}}}
    329 
    330     def addicecap(self, md):  #{{{
     328        # }}}
     329    # }}}
     330
     331    def addicecap(self, md):  # {{{
    331332        if not type(md) == model:
    332333            raise Exception("addicecap method only takes a 'model' class object as input")
    333334
    334335        self.icecaps.append(md)
    335     #}}}
    336 
    337     def basinsplot3d(self, *args):  #{{{
     336    # }}}
     337
     338    def basinsplot3d(self, *args):  # {{{
    338339        for i in range(len(self.basins)):
    339340            self.basins[i].plot3d(*args)
    340     #}}}
    341 
    342     def caticecaps(self, *args):  #{{{
     341    # }}}
     342
     343    def caticecaps(self, *args):  # {{{
    343344        # Recover options
    344345        options = pairoptions(*args)
     
    372373        # Create mesh radius
    373374        self.earth.mesh.r = planetradius('earth') * np.ones((md.mesh.numberofvertices, ))
    374     #}}}
    375 
    376     def caticecaps2d(self, *args):  #{{{
     375    # }}}
     376
     377    def caticecaps2d(self, *args):  # {{{
    377378        # Recover options
    378379        options = pairoptions(*args)
     
    398399        # Plug into earth
    399400        self.earth = md
    400     #}}}
    401 
    402     def viscousiterations(self):  #{{{
     401    # }}}
     402
     403    def viscousiterations(self):  # {{{
    403404        for i in range(len(self.icecaps)):
    404405            ic = self.icecaps[i]
     
    407408                mvi = np.max(mvi, ic.results.TransientSolution[j].StressbalanceConvergenceNumSteps)
    408409            print("{}, {}: {}".format(i, self.icecaps[i].miscellaneous.name, mvi))
    409     #}}}
    410 
    411     def maxtimestep(self):  #{{{
     410    # }}}
     411
     412    def maxtimestep(self):  # {{{
    412413        for i in range(len(self.icecaps)):
    413414            ic = self.icecaps[i]
     
    419420        timei = self.earth.results.TransientSolution[-1].time
    420421        print("Earth: {}/{}", mvi, timei)
    421     #}}}
    422 
    423     def transfer(self, string):  #{{{
     422    # }}}
     423
     424    def transfer(self, string):  # {{{
    424425        # Recover field size in one icecap
    425426        n = getsubattr(self.icecaps[0], string).shape[0]
     
    442443            times = capfield1[-1, :]
    443444            nsteps = len(times)
    444             #}}}
     445            # }}}
    445446            # Initialize #{{{
    446447            field = np.zeros((self.earth.mesh.numberofvertices + 1, nsteps))
    447448            field[-1, :] = times  # Transfer the times only, not the values
    448             #}}}
     449            # }}}
    449450            # Transfer all the time fields #{{{
    450451            for i in range(len(self.icecaps)):
     
    453454                    field[self.transitions[i], j] = capfieldi[0:-1, j]  # Transfer only the values, not the time
    454455            setsubattr(self.earth, string, field)  # Do not forget to plug the field variable into its final location
    455             #}}}
     456            # }}}
    456457        elif n == (self.icecaps[0].mesh.numberofelements):
    457458            setsubattr(self.earth, string, np.zeros((self.earth.mesh.numberofelements, ))) # Assign array of zeros to target attribute
     
    461462        else:
    462463            raise Exception('not supported yet')
    463     #}}}
    464 
    465     def homogenize(self, noearth=0):  #{{{
     464    # }}}
     465
     466    def homogenize(self, noearth=0):  # {{{
    466467        mintimestep = np.inf
    467468
     
    486487
    487488        return self
    488     #}}}
    489 
    490     def initializemodels(self):  #{{{
     489    # }}}
     490
     491    def initializemodels(self):  # {{{
    491492        for i in range(len(self.basins)):
    492493            md = model()
    493494            md.miscellaneous.name = self.basins[i].name
    494495            self.addicecap(md)
    495     #}}}
     496    # }}}
  • TabularUnified issm/trunk-jpl/src/m/classes/solidearth.m

    r26307 r26358  
    6969                        self.requested_outputs={'default'};
    7070
    71                         %transitions should be a cell array of vectors: 
     71                        %transitions should be a cell array of vectors:
    7272                        self.transitions={};
    73                        
    74                         %no partitions requested for barystatic contribution: 
     73
     74                        %no partitions requested for barystatic contribution:
    7575                        self.partitionice=[];
    7676                        self.partitionhydro=[];
    7777                        self.partitionocean=[];
    7878
    79                         %no external solutions by default: 
     79                        %no external solutions by default:
    8080                        self.external=[];
    8181
    8282                        %planet radius
    8383                        self.planetradius= planetradius(planet);
    84                
     84
    8585                end % }}}
    8686                function md = checkconsistency(self,md,solution,analyses) % {{{
     
    116116                                npartice=0;
    117117                        end
     118
    118119                        if ~isempty(self.partitionhydro),
    119120                                nparthydro=max(self.partitionhydro)+2;
  • TabularUnified issm/trunk-jpl/src/m/classes/solidearth.py

    r26317 r26358  
    44from fielddisplay import fielddisplay
    55from lovenumbers import lovenumbers
     6from MatlabFuncs import *
    67from planetradius import planetradius
    78from project3d import project3d
     
    910from solidearthsettings import solidearthsettings
    1011from solidearthsolution import solidearthsolution
    11 from offlinesolidearthsolution import offlinesolidearthsolution
    12 from surfaceload import surfaceload
    1312from WriteData import WriteData
    1413
     
    2524    """
    2625
    27     def __init__(self, *args): #{{{
     26    def __init__(self, *args):  # {{{
    2827        self.settings           = solidearthsettings()
    29         self.external           = []
     28        self.external           = None
    3029        self.lovenumbers        = lovenumbers()
    3130        self.rotational         = rotational()
     
    4443        else:
    4544            raise Exception('solidearth constructor error message: zero or one argument only!')
    46     #}}}
    47     def __repr__(self): #{{{
     45    # }}}
     46    def __repr__(self):  # {{{
    4847        s = '   solidearthinputs, forcings and settings:\n'
    4948        s += '{}\n'.format(fielddisplay(self, 'planetradius', 'planet radius [m]'))
     
    5857        print(self.lovenumbers)
    5958        print(self.rotational)
    60         if self.external:
     59        if len(self.external):
    6160            print(self.external)
    6261        return s
    63     #}}}
    64     def setdefaultparameters(self, planet): #{{{
     62    # }}}
     63    def setdefaultparameters(self, planet):  # {{{
    6564        # Output default
    6665        self.requested_outputs = ['default']
     
    7574
    7675        # No external solutions by default
    77         self.external = []
     76        self.external = None
    7877
    7978        # Planet radius
    8079        self.planetradius = planetradius(planet)
    81     #}}}
    82     def checkconsistency(self, md, solution, analyses): #{{{
     80    # }}}
     81    def checkconsistency(self, md, solution, analyses):  # {{{
    8382        if ('SealevelchangeAnalysis' not in analyses) or (solution == 'TransientSolution' and not md.transient.isslc):
    8483            return md
     
    9089        self.rotational.checkconsistency(md, solution, analyses)
    9190        if self.external:
    92             if (not isinstance(self.external,solidearthsolution)) and (not isinstance(self.external,offlinesolidearthsolution)):
     91            if not isa(self.external, solidearthsolution):
    9392                raise Exception('solidearth consistency check: external field should be a solidearthsolution')
    9493            self.external.checkconsistency(md, solution, analyses)
    9594        return md
    96     #}}}
    97     def defaultoutputs(self, md): #{{{
     95    # }}}
     96    def defaultoutputs(self, md):  # {{{
    9897        return ['Sealevel']
    99     #}}}
    100     def marshall(self, prefix, md, fid): #{{{
     98    # }}}
     99    def marshall(self, prefix, md, fid):  # {{{
    101100        WriteData(fid, prefix, 'object', self, 'fieldname', 'planetradius', 'format', 'Double')
    102101        WriteData(fid, prefix, 'object', self, 'fieldname', 'transitions', 'format', 'MatArray')
     
    133132            WriteData(fid, prefix, 'data', 0, 'format', 'Integer', 'name', 'md.solidearth.isexternal')
    134133
    135         #process requested outputs
     134        # Process requested outputs
    136135        outputs = self.requested_outputs
    137136        pos = np.where(np.asarray(outputs) == 'default')[0]
    138137        if len(pos):
    139             outputs = np.delete(outputs, pos)  # remove 'default' from outputs
     138            outputs = np.delete(outputs, pos) # remove 'default' from outputs
    140139            outputs = np.append(outputs, self.defaultoutputs(md)) # add defaults
    141140        WriteData(fid, prefix, 'data', outputs, 'name', 'md.solidearth.requested_outputs', 'format', 'StringArray')
    142     #}}}
    143     def extrude(self, md): #{{{
     141    # }}}
     142    def extrude(self, md):  # {{{
    144143        return self
    145     #}}}
     144    # }}}
  • TabularUnified issm/trunk-jpl/src/m/classes/solidearthsettings.m

    r26301 r26358  
    5656                end % }}}
    5757                function self = setdefaultparameters(self) % {{{
    58                
    59                 %Convergence criterion: absolute, relative and residual
    60                 self.reltol=0.01; % 1 percent
    61                 self.abstol=NaN;  % default
    6258
    63                 %maximum of non-linear iterations.
    64                 self.maxiter=5;
     59                        %Convergence criterion: absolute, relative and residual
     60                        self.reltol=0.01; % 1 percent
     61                        self.abstol=NaN;  % default
    6562
    66                 %computational flags:
    67                 self.selfattraction=1;
    68                 self.elastic=1;
    69                 self.viscous=1;
    70                 self.rotation=1;
    71                 self.grdocean=1;
    72                 self.ocean_area_scaling=0;
    73                 self.compute_bp_grd=0;
    74                 self.isgrd=0;
    75                 self.sealevelloading=1;
     63                        %maximum of non-linear iterations.
     64                        self.maxiter=5;
    7665
    77                 %numerical discretization accuracy
    78                 self.degacc=.01;
    79                 self.timeacc=1;
     66                        %computational flags:
     67                        self.selfattraction=1;
     68                        self.elastic=1;
     69                        self.viscous=1;
     70                        self.rotation=1;
     71                        self.grdocean=1;
     72                        self.ocean_area_scaling=0;
     73                        self.compute_bp_grd=0;
     74                        self.isgrd=0;
     75                        self.sealevelloading=1;
    8076
    81                 %how many time steps we skip before we run solidearthsettings solver during transient
    82                 self.runfrequency=1;
     77                        %numerical discretization accuracy
     78                        self.degacc=.01;
     79                        self.timeacc=1;
    8380
    84                 %horizontal displacement? (not on by default)
    85                 self.horiz=0;
     81                        %how many time steps we skip before we run solidearthsettings solver during transient
     82                        self.runfrequency=1;
    8683
    87                 %cross section for Ivins model
    88                 self.cross_section_shape=1; %square as default (see iedge in GiaDeflectionCorex)
     84                        %horizontal displacement? (not on by default)
     85                        self.horiz=0;
    8986
    90                 %no grd model by default:
    91                 self.grdmodel=0;
     87                        %cross section for Ivins model
     88                        self.cross_section_shape=1; %square as default (see iedge in GiaDeflectionCorex)
     89
     90                        %no grd model by default:
     91                        self.grdmodel=0;
    9292
    9393                end % }}}
     
    179179                end % }}}
    180180                function savemodeljs(self,fid,modelname) % {{{
    181                
     181                        % TODO: Update the following fields so that coverage is complete
    182182                        writejsdouble(fid,[modelname '.solidearth.settings.maxiter'],self.maxiter);
    183183                        writejsdouble(fid,[modelname '.solidearth.settings.reltol'],self.reltol);
  • TabularUnified issm/trunk-jpl/src/m/classes/solidearthsettings.py

    r26353 r26358  
    1313    """
    1414
    15     def __init__(self, *args): #{{{
     15    def __init__(self, *args):  # {{{
    1616        self.reltol                 = 0
    1717        self.abstol                 = 0
     
    3737        else:
    3838            raise Exception('constructor not supported')
    39     #}}}
     39    # }}}
    4040
    41     def __repr__(self): #{{{
     41    def __repr__(self):  # {{{
    4242        s = '   solidearth settings:\n'
    4343        s += '{}\n'.format(fielddisplay(self, 'reltol', 'sea level change relative convergence criterion (default, NaN: not applied)'))
     
    5959        s += '{}\n'.format(fielddisplay(self, 'cross_section_shape', '1: square-edged (default). 2: elliptical. See iedge in GiaDeflectionCore'))
    6060        return s
    61     #}}}
     61    # }}}
    6262
    63     def setdefaultparameters(self): #{{{
     63    def setdefaultparameters(self):  # {{{
    6464        # Convergence criterion: absolute, relative, and residual
    6565        self.reltol = 0.01  # 1 percent
     
    8181
    8282        # Numerical discretization accuracy
    83         self.degacc = .01
     83        self.degacc = 0.01
    8484        self.timeacc = 1
    8585
     
    9595        # No GRD model by default
    9696        self.grdmodel = 0
    97     #}}}
     97    # }}}
    9898
    99     def checkconsistency(self, md, solution, analyses): #{{{
     99    def checkconsistency(self, md, solution, analyses):  # {{{
    100100        if ('SealevelchangeAnalysis' not in analyses) or (solution == 'TransientSolution' and not md.transient.isslc):
    101101            return md
     
    131131
    132132        return md
    133     #}}}
     133    # }}}
    134134
    135     def marshall(self, prefix, md, fid): #{{{
     135    def marshall(self, prefix, md, fid):  # {{{
    136136        WriteData(fid, prefix, 'object', self, 'fieldname', 'reltol', 'name', 'md.solidearth.settings.reltol', 'format', 'Double');
    137137        WriteData(fid, prefix, 'object', self, 'fieldname', 'abstol', 'name', 'md.solidearth.settings.abstol', 'format', 'Double');
     
    145145        WriteData(fid, prefix, 'object', self, 'fieldname', 'runfrequency', 'name', 'md.solidearth.settings.runfrequency', 'format', 'Integer');
    146146        WriteData(fid, prefix, 'object', self, 'fieldname', 'degacc', 'name', 'md.solidearth.settings.degacc', 'format', 'Double');
    147         WriteData(fid, prefix, 'object', self, 'fieldname', 'timeacc', 'name', 'md.solidearth.settings.timeacc', 'format', 'Double', 'scale',md.constants.yts);
     147        WriteData(fid, prefix, 'object', self, 'fieldname', 'timeacc', 'name', 'md.solidearth.settings.timeacc', 'format', 'Double', 'scale', md.constants.yts);
    148148        WriteData(fid, prefix, 'object', self, 'fieldname', 'horiz', 'name', 'md.solidearth.settings.horiz', 'format', 'Integer');
    149149        WriteData(fid, prefix, 'object', self, 'fieldname', 'sealevelloading', 'name', 'md.solidearth.settings.sealevelloading', 'format', 'Integer');
     
    152152        WriteData(fid, prefix, 'object', self, 'fieldname', 'grdmodel', 'name', 'md.solidearth.settings.grdmodel', 'format', 'Integer');
    153153        WriteData(fid, prefix, 'object', self, 'fieldname', 'cross_section_shape', 'name', 'md.solidearth.settings.cross_section_shape', 'format', 'Integer');
    154     #}}}
     154    # }}}
    155155
    156     def extrude(self, md): #{{{
     156    def extrude(self, md):  # {{{
    157157        return self
    158     #}}}
     158    # }}}
  • TabularUnified issm/trunk-jpl/src/m/classes/solidearthsolution.m

    r26317 r26358  
    2020                        end
    2121                end % }}}
     22                function disp(self) % {{{
     23                        disp(sprintf('%s','         units for time series is (yr)'));
     24                        fielddisplay(self,'displacementeast','solid-Earth Eastwards bedrock displacement series (m)');
     25                        fielddisplay(self,'displacementnorth','solid-Earth Northwards bedrock displacement time series (m)');
     26                        fielddisplay(self,'displacementup','solid-Earth bedrock uplift time series (m)');
     27                        fielddisplay(self,'geoid','solid-Earth geoid time series (m)');
     28
     29                end % }}}
    2230                function self = setdefaultparameters(self) % {{{
    2331       
     
    3442                        md = checkfield(md,'fieldname','solidearth.external.displacementup','Inf',1,'timeseries',1);
    3543                        md = checkfield(md,'fieldname','solidearth.external.geoid','Inf',1,'timeseries',1);
    36 
    37                 end % }}}
    38                 function disp(self) % {{{
    39                         disp(sprintf('%s','         units for time series is (yr)'));
    40                         fielddisplay(self,'displacementeast','solid-Earth Eastwards bedrock displacement series (m)');
    41                         fielddisplay(self,'displacementnorth','solid-Earth Northwards bedrock displacement time series (m)');
    42                         fielddisplay(self,'displacementup','solid-Earth bedrock uplift time series (m)');
    43                         fielddisplay(self,'geoid','solid-Earth geoid time series (m)');
    4444
    4545                end % }}}
  • TabularUnified issm/trunk-jpl/src/m/classes/solidearthsolution.py

    r26352 r26358  
    1313    """
    1414
    15     def __init__(self, *args): #{{{
    16         self.displacementeast = None
    17         self.displacementnorth = None
    18         self.displacementup = None
    19         self.geoid = None
     15    def __init__(self, *args):  # {{{
     16        self.displacementeast = []
     17        self.displacementnorth = []
     18        self.displacementup = []
     19        self.geoid = []
    2020
    2121        if len(args) == 0:
     
    2323        else:
    2424            raise RuntimeError('constructor not supported')
    25     #}}}
     25    # }}}
    2626
    27     def __repr__(self): #{{{
     27    def __repr__(self):  # {{{
    2828        s = '         units for time series is (yr)\n'
    2929        s += '{}\n'.format(fielddisplay(self, 'displacementeast', 'solid-Earth Eastwards bedrock displacement series (m)'))
     
    3333
    3434        return s
    35     #}}}
     35    # }}}
    3636
    37     def setdefaultparameters(self): #{{{
     37    def setdefaultparameters(self):  # {{{
    3838        self.displacementeast = []
    3939        self.displacementnorth = []
    4040        self.displacementup = []
    4141        self.geoid = []
    42     #}}}
     42    # }}}
    4343
    44     def checkconsistency(self, md, solution, analyses): #{{{
     44    def checkconsistency(self, md, solution, analyses):  # {{{
    4545        md = checkfield(md, 'fieldname', 'solidearth.external.displacementeast', 'Inf', 1, 'timeseries', 1)
    4646        md = checkfield(md, 'fieldname', 'solidearth.external.displacementnorth', 'Inf', 1, 'timeseries', 1)
    4747        md = checkfield(md, 'fieldname', 'solidearth.external.displacementup', 'Inf', 1, 'timeseries', 1)
    4848        md = checkfield(md, 'fieldname', 'solidearth.external.geoid', 'Inf', 1, 'timeseries', 1)
    49     #}}}
     49    # }}}
    5050
    51     def marshall(self, prefix, md, fid): #{{{
     51    def marshall(self, prefix, md, fid):  # {{{
    5252        yts = md.constants.yts
    5353
     54        print('sadjsda')
     55        exit()
     56
    5457        # Transform our time series into time series rates
    55         if len(np.shape(self.displacementeast)) == 1:
     58        if np.shape(self.displacementeast)[1] == 1:
    5659            print('solidearthsolution.py::marshall: Warning: only one time step provided, assuming the values are rates per year')
    5760            displacementeast_rate = np.append(np.array(self.displacementeast).reshape(-1, 1), 0)
     
    7679        WriteData(fid, prefix, 'object', self, 'fieldname', 'displacementnorth', 'data', displacementnorth_rate,'format', 'DoubleMat', 'name', 'md.solidearth.external.displacementnorth', 'mattype', 1, 'scale', 1 / yts,'timeserieslength', md.mesh.numberofvertices + 1, 'yts', yts);
    7780        WriteData(fid, prefix, 'object', self, 'fieldname', 'geoid', 'data', geoid_rate,'format', 'DoubleMat', 'name', 'md.solidearth.external.geoid', 'mattype', 1, 'scale', 1 / yts,'timeserieslength', md.mesh.numberofvertices + 1, 'yts', yts);
    78     #}}}
     81    # }}}
    7982
    80     def extrude(self, md): #{{{
     83    def extrude(self, md):  # {{{
    8184        return self
    82     #}}}
     85    # }}}
  • TabularUnified issm/trunk-jpl/src/m/classes/stressbalance.m

    r25942 r26358  
    5353                function self = setdefaultparameters(self) % {{{
    5454
    55                          %maximum of non-linear iterations.
    56                          self.maxiter=100;
    57 
    58                          %Convergence criterion: absolute, relative and residual
    59                          self.restol=10^-4;
    60                          self.reltol=0.01;
    61                          self.abstol=10;
    62 
    63                          self.FSreconditioning=10^13;
    64                          self.shelf_dampening=0;
    65 
    66                          %Penalty factor applied kappa=max(stiffness matrix)*10^penalty_factor
    67                          self.penalty_factor=3;
    68 
    69                          %Stop the iterations of rift if below a threshold
    70                          self.rift_penalty_threshold=0;
    71 
    72                          %in some solutions, it might be needed to stop a run when only
    73                          %a few constraints remain unstable. For thermal computation, this
    74                          %parameter is often used.
    75                          self.rift_penalty_lock=10;
    76 
    77                          %output default:
    78                          self.requested_outputs={'default'};
     55                        %maximum of non-linear iterations.
     56                        self.maxiter=100;
     57
     58                        %Convergence criterion: absolute, relative and residual
     59                        self.restol=10^-4;
     60                        self.reltol=0.01;
     61                        self.abstol=10;
     62
     63                        self.FSreconditioning=10^13;
     64                        self.shelf_dampening=0;
     65
     66                        %Penalty factor applied kappa=max(stiffness matrix)*10^penalty_factor
     67                        self.penalty_factor=3;
     68
     69                        %Stop the iterations of rift if below a threshold
     70                        self.rift_penalty_threshold=0;
     71
     72                        %in some solutions, it might be needed to stop a run when only
     73                        %a few constraints remain unstable. For thermal computation, this
     74                        %parameter is often used.
     75                        self.rift_penalty_lock=10;
     76
     77                        %output default:
     78                        self.requested_outputs={'default'};
    7979
    8080                end % }}}
  • TabularUnified issm/trunk-jpl/src/m/classes/stressbalance.py

    r25688 r26358  
    1818
    1919    def __init__(self):  # {{{
    20         self.spcvx = float('NaN')
    21         self.spcvy = float('NaN')
    22         self.spcvz = float('NaN')
     20        self.spcvx = np.nan
     21        self.spcvy = np.nan
     22        self.spcvz = np.nan
    2323        self.restol = 0
    2424        self.reltol = 0
     
    2626        self.isnewton = 0
    2727        self.FSreconditioning = 0
    28         self.icefront = float('NaN')
     28        self.icefront = np.nan
    2929        self.maxiter = 0
    3030        self.shelf_dampening = 0
    31         self.vertex_pairing = float('NaN')
    32         self.penalty_factor = float('NaN')
    33         self.rift_penalty_lock = float('NaN')
     31        self.vertex_pairing = np.nan
     32        self.penalty_factor = np.nan
     33        self.rift_penalty_lock = np.nan
    3434        self.rift_penalty_threshold = 0
    35         self.referential = float('NaN')
    36         self.loadingforce = float('NaN')
     35        self.referential = np.nan
     36        self.loadingforce = np.nan
    3737        self.requested_outputs = []
    3838
    39     #set defaults
     39        # Set defaults
    4040        self.setdefaultparameters()
    4141
    42     #}}}
     42    # }}}
     43
    4344    def __repr__(self):  # {{{
    4445        s = '   StressBalance solution parameters:\n'
     
    4748        s += '{}\n'.format(fielddisplay(self, 'reltol', 'velocity relative convergence criterion, NaN: not applied'))
    4849        s += '{}\n'.format(fielddisplay(self, 'abstol', 'velocity absolute convergence criterion, NaN: not applied'))
    49         s += '{}\n'.format(fielddisplay(self, 'isnewton', "0: Picard's fixed point, 1: Newton's method, 2: hybrid"))
     50        s += '{}\n'.format(fielddisplay(self, 'isnewton', '0: Picard\'s fixed point, 1: Newton\'s method, 2: hybrid'))
    5051        s += '{}\n'.format(fielddisplay(self, 'maxiter', 'maximum number of nonlinear iterations'))
    5152        s += '      boundary conditions:\n'
    52         s += '{}\n'.format(fielddisplay(self, 'spcvx', 'x - axis velocity constraint (NaN means no constraint) [m / yr]'))
    53         s += '{}\n'.format(fielddisplay(self, 'spcvy', 'y - axis velocity constraint (NaN means no constraint) [m / yr]'))
    54         s += '{}\n'.format(fielddisplay(self, 'spcvz', 'z - axis velocity constraint (NaN means no constraint) [m / yr]'))
     53        s += '{}\n'.format(fielddisplay(self, 'spcvx', 'x-axis velocity constraint (NaN means no constraint) [m / yr]'))
     54        s += '{}\n'.format(fielddisplay(self, 'spcvy', 'y-axis velocity constraint (NaN means no constraint) [m / yr]'))
     55        s += '{}\n'.format(fielddisplay(self, 'spcvz', 'z-axis velocity constraint (NaN means no constraint) [m / yr]'))
    5556        s += '{}\n'.format(fielddisplay(self, 'icefront', 'segments on ice front list (last column 0: Air, 1: Water, 2: Ice'))
    56         s = "%s\n%s" % (s, '\n      Rift options:')
     57        s += '      Rift options:\n'
    5758        s += '{}\n'.format(fielddisplay(self, 'rift_penalty_threshold', 'threshold for instability of mechanical constraints'))
    5859        s += '{}\n'.format(fielddisplay(self, 'rift_penalty_lock', 'number of iterations before rift penalties are locked'))
    5960        s += '      Penalty options:\n'
    60         s += '{}\n'.format(fielddisplay(self, 'penalty_factor', 'offset used by penalties: penalty = Kmax * 1.0**offset'))
     61        s += '{}\n'.format(fielddisplay(self, 'penalty_factor', 'offset used by penalties: penalty = Kmax * 10^offset'))
    6162        s += '{}\n'.format(fielddisplay(self, 'vertex_pairing', 'pairs of vertices that are penalized'))
    6263        s += '      Other:\n'
     
    6465        s += '{}\n'.format(fielddisplay(self, 'FSreconditioning', 'multiplier for incompressibility equation. Only for FS model'))
    6566        s += '{}\n'.format(fielddisplay(self, 'referential', 'local referential'))
    66         s += '{}\n'.format(fielddisplay(self, 'loadingforce', 'loading force applied on each point [N / m^3]'))
     67        s += '{}\n'.format(fielddisplay(self, 'loadingforce', 'loading force applied on each point [N/m^3]'))
    6768        s += '{}\n'.format(fielddisplay(self, 'requested_outputs', 'additional outputs requested'))
    6869        return s
    69     #}}}
     70    # }}}
    7071
    7172    def extrude(self, md):  # {{{
     
    7778
    7879        return self
    79     #}}}
     80    # }}}
    8081
    8182    def setdefaultparameters(self):  # {{{
    82         #maximum of non - linear iterations.
     83        # Maximum of non-linear iterations
    8384        self.maxiter = 100
    84         #Convergence criterion: absolute, relative and residual
    85         self.restol = 1.0e-4
     85
     86        # Convergence criterion: absolute, relative and residual
     87        self.restol = pow(10, -4)
    8688        self.reltol = 0.01
    8789        self.abstol = 10
    88         self.FSreconditioning = 10**13
     90
     91        self.FSreconditioning = pow(10, 13)
    8992        self.shelf_dampening = 0
    90         #Penalty factor applied kappa = max(stiffness matrix) * 1.0**penalty_factor
     93
     94        # Penalty factor applied kappa = max(stiffness matrix) * 1.0^penalty_factor
    9195        self.penalty_factor = 3
    92         #Stop the iterations of rift if below a threshold
     96
     97        # Stop the iterations of rift if below a threshold
    9398        self.rift_penalty_threshold = 0
    94         #in some solutions, it might be needed to stop a run when only
    95         #a few constraints remain unstable. For thermal computation, this
    96         #parameter is often used.
     99
     100        # In some solutions, it might be needed to stop a run when only a few
     101        # constraints remain unstable. For thermal computation, this parameter
     102        # is often used.
    97103        self.rift_penalty_lock = 10
    98         #output default:
     104
     105        # Output default
    99106        self.requested_outputs = ['default']
    100107        return self
    101     #}}}
     108    # }}}
    102109
    103110    def defaultoutputs(self, md):  # {{{
     
    107114            list = ['Vx', 'Vy', 'Vel', 'Pressure']
    108115        return list
    109     #}}}
     116    # }}}
    110117
    111118    def checkconsistency(self, md, solution, analyses):  # {{{
     
    131138        if not np.any(np.isnan(self.vertex_pairing)) and len(self.vertex_pairing) > 0:
    132139            md = checkfield(md, 'fieldname', 'stressbalance.vertex_pairing', '>', 0)
    133         #singular solution
     140        # Singular solution
    134141        #        if ~any((~isnan(md.stressbalance.spcvx) + ~isnan(md.stressbalance.spcvy)) == 2),
    135142        if not np.any(np.logical_and(np.logical_not(np.isnan(md.stressbalance.spcvx)), np.logical_not(np.isnan(md.stressbalance.spcvy)))):
    136143            print("\n !!! Warning: no spc applied, model might not be well posed if no basal friction is applied, check for solution crash\n")
    137         #CHECK THAT EACH LINES CONTAINS ONLY NAN VALUES OR NO NAN VALUES
     144        # CHECK THAT EACH LINES CONTAINS ONLY NAN VALUES OR NO NAN VALUES
    138145        #        if any(sum(isnan(md.stressbalance.referential), 2)~=0 & sum(isnan(md.stressbalance.referential), 2)~=6),
    139146        if np.any(np.logical_and(np.sum(np.isnan(md.stressbalance.referential), axis=1) != 0, np.sum(np.isnan(md.stressbalance.referential), axis=1) != 6)):
    140147            md.checkmessage("Each line of stressbalance.referential should contain either only NaN values or no NaN values")
    141         #CHECK THAT THE TWO VECTORS PROVIDED ARE ORTHOGONAL
     148        # CHECK THAT THE TWO VECTORS PROVIDED ARE ORTHOGONAL
    142149        #        if any(sum(isnan(md.stressbalance.referential), 2) == 0),
    143150        if np.any(np.sum(np.isnan(md.stressbalance.referential), axis=1) == 0):
     
    149156                if np.abs(np.inner(item[0:2], item[3:5])) > sys.float_info.epsilon:
    150157                    md.checkmessage("Vectors in stressbalance.referential (columns 1 to 3 and 4 to 6) must be orthogonal")
    151         #CHECK THAT NO rotation specified for FS Grounded ice at base
     158        # CHECK THAT NO rotation specified for FS Grounded ice at base
    152159        if m.strcmp(md.mesh.domaintype(), '3D') and md.flowequation.isFS:
    153160            pos = np.nonzero(np.logical_and(md.mask.ocean_levelset, md.mesh.vertexonbase))
  • TabularUnified issm/trunk-jpl/src/m/classes/surfaceload.m

    r26059 r26358  
    6565                end % }}}
    6666                function marshall(self,prefix,md,fid) % {{{
    67                        
     67
    6868                        %deal with ice thickness change: {{{
    6969                        if isempty(self.icethicknesschange),
    7070                                self.icethicknesschange=zeros(md.mesh.numberofelements+1,1);
    7171                        end
    72                        
     72
    7373                        yts=md.constants.yts;
    7474
  • TabularUnified issm/trunk-jpl/src/m/classes/surfaceload.py

    r26317 r26358  
    5151
    5252    def marshall(self, prefix, md, fid):  #{{{
    53         if np.isnan(self.icethicknesschange).all():
    54             self.icethicknesschange = np.zeros((md.mesh.numberofelements + 1))
    55         if np.isnan(self.waterheightchange).all():
    56             self.waterheightchange = np.zeros((md.mesh.numberofelements + 1))
    57         if np.isnan(self.other).all():
    58             self.other = np.zeros((md.mesh.numberofelements + 1))
    59         WriteData(fid, prefix, 'object', self, 'fieldname', 'icethicknesschange', 'name', 'md.solidearth.surfaceload.icethicknesschange', 'format', 'DoubleMat', 'mattype', 2, 'timeserieslength', md.mesh.numberofelements + 1, 'yts', md.constants.yts)
    60         WriteData(fid, prefix, 'object', self, 'fieldname', 'waterheightchange', 'name', 'md.solidearth.surfaceload.waterheightchange', 'format', 'DoubleMat', 'mattype', 2, 'timeserieslength', md.mesh.numberofelements + 1, 'yts', md.constants.yts)
    61         WriteData(fid, prefix, 'object', self, 'fieldname', 'other', 'name', 'md.solidearth.surfaceload.other', 'format', 'DoubleMat', 'mattype', 2, 'timeserieslength', md.mesh.numberofelements + 1, 'yts', md.constants.yts)
     53        # TODO
     54        # - When surfaceload class is used eventually, check premarshall
     55        # modifications against those done in MATLAB
     56        #
     57
     58        # Deal with ice thickness change
     59        if np.isempty(self.icethicknesschange):
     60            self.icethicknesschange = np.zeros((md.mesh.numberofelements + 1, ))
     61
     62        yts = md.constants.yts
     63
     64        WriteData(fid, prefix, 'object', self, 'fieldname', 'icethicknesschange', 'name', 'md.solidearth.surfaceload.icethicknesschange', 'format', 'MatArray', 'timeserieslength', md.mesh.numberofelements + 1, 'yts', yts, 'scale', 1 / yts)
     65
     66        # Deal with ice thickness change
     67        if np.isempty(self.waterheightchange):
     68            self.waterheightchange = np.zeros((md.mesh.numberofelements + 1, ))
     69
     70        WriteData(fid, prefix, 'object', self, 'fieldname', 'waterheightchange', 'name', 'md.solidearth.surfaceload.waterheightchange', 'format', 'MatArray', 'timeserieslength', md.mesh.numberofelements + 1, 'yts', yts, 'scale', 1 / yts)
     71
     72        # Deal with ice thickness change
     73        if np.isempty(self.otherchange):
     74            self.otherchange = np.zeros((md.mesh.numberofelements + 1, ))
     75
     76        WriteData(fid, prefix, 'object', self, 'fieldname', 'otherchange', 'name', 'md.solidearth.surfaceload.otherchange', 'format', 'MatArray', 'timeserieslength', md.mesh.numberofelements + 1, 'yts', yts, 'scale', 1 / yts)
    6277    #}}}
    6378
  • TabularUnified issm/trunk-jpl/src/m/classes/transient.m

    r26059 r26358  
    3434
    3535                        %full analysis: Stressbalance, Masstransport and Thermal but no groundingline migration for now
    36                         self.issmb           = 0;
    37                         self.ismasstransport = 0;
    38                         self.isoceantransport= 0;
    39                         self.isstressbalance = 0;
    40                         self.isthermal       = 0;
    41                         self.isgroundingline = 0;
    42                         self.isesa           = 0;
     36                        self.issmb             = 0;
     37                        self.ismasstransport   = 0;
     38                        self.isoceantransport  = 0;
     39                        self.isstressbalance   = 0;
     40                        self.isthermal         = 0;
     41                        self.isgroundingline   = 0;
     42                        self.isesa             = 0;
    4343                        self.isdamageevolution = 0;
    44                         self.ismovingfront   =0;
    45                         self.ishydrology     = 0;
    46                         self.issampling      = 0;
    47                         self.isslc           = 0;
    48                         self.isoceancoupling = 0;
    49                         self.amr_frequency      = 0;
     44                        self.ismovingfront     = 0;
     45                        self.ishydrology       = 0;
     46                        self.issampling        = 0;
     47                        self.isslc             = 0;
     48                        self.isoceancoupling   = 0;
     49                        self.amr_frequency     = 0;
    5050
    5151                        %default output
     
    5555
    5656                        %full analysis: Stressbalance, Masstransport and Thermal but no groundingline migration for now
    57                         self.issmb           = 1;
    58                         self.ismasstransport = 1;
    59                         self.isoceantransport = 0;
    60                         self.isstressbalance = 1;
    61                         self.isthermal       = 1;
    62                         self.isgroundingline = 0;
    63                         self.isesa           = 0;
     57                        self.issmb             = 1;
     58                        self.ismasstransport   = 1;
     59                        self.isoceantransport  = 0;
     60                        self.isstressbalance   = 1;
     61                        self.isthermal         = 1;
     62                        self.isgroundingline   = 0;
     63                        self.isesa             = 0;
    6464                        self.isdamageevolution = 0;
    65                         self.ismovingfront   = 0;
    66                         self.ishydrology     = 0;
    67                         self.issampling      = 0;
    68                         self.isslc           = 0;
    69                         self.isoceancoupling = 0;
    70                         self.amr_frequency      = 0;
     65                        self.ismovingfront     = 0;
     66                        self.ishydrology       = 0;
     67                        self.issampling        = 0;
     68                        self.isslc             = 0;
     69                        self.isoceancoupling   = 0;
     70                        self.amr_frequency     = 0;
    7171
    7272                        %default output
  • TabularUnified issm/trunk-jpl/src/m/classes/transient.py

    r26064 r26358  
    2929
    3030        self.setdefaultparameters()
    31     #}}}
     31    # }}}
    3232
    3333    def __repr__(self):  # {{{
     
    4949        s += '{}\n'.format(fielddisplay(self, 'requested_outputs', 'list of additional outputs requested'))
    5050        return s
    51     #}}}
     51    # }}}
    5252
    5353    def defaultoutputs(self, md):  # {{{
     
    5656        else:
    5757            return []
    58     #}}}
     58    # }}}
    5959
    6060    def deactivateall(self):  #{{{
     
    7777        self.requested_outputs = []
    7878        return self
    79     #}}}
     79    # }}}
    8080
    8181    def setdefaultparameters(self):  # {{{
    82         #full analysis: Stressbalance, Masstransport and Thermal but no groundingline migration for now
     82        # Full analysis: Stressbalance, Masstransport and Thermal but no
     83        # groundingline migration for now
    8384        self.issmb = 1
    8485        self.ismasstransport = 1
     
    99100        self.requested_outputs = ['default']
    100101        return self
    101     #}}}
     102    # }}}
    102103
    103104    def checkconsistency(self, md, solution, analyses):  # {{{
  • TabularUnified issm/trunk-jpl/src/m/classes/verbose.py

    r24240 r26358  
    44
    55class verbose(object):
    6     """
    7     VERBOSE class definition
     6    """VERBOSE class definition
    87
    9        Available verbosity levels:
    10           mprocessor  : model processing
    11           module      : modules
    12           solution    : solution sequence
    13           solver      : solver info (extensive)
    14           convergence : convergence criteria
    15           control     : control method
    16           qmu         : sensitivity analysis
    17           autodiff    : AD analysis
    18           smb         : SMB analysis
     8    Available verbosity levels:
     9        mprocessor  : model processing
     10        module      : modules
     11        solution    : solution sequence
     12        solver      : solver info (extensive)
     13        convergence : convergence criteria
     14        control     : control method
     15        qmu         : sensitivity analysis
     16        autodiff    : AD analysis
     17        smb         : SMB analysis
    1918
    20        Usage:
    21           verbose = verbose()
    22           verbose = verbose(3)
    23           verbose = verbose('001100')
    24           verbose = verbose('module', True, 'solver', False)
     19    Usage:
     20        verbose = verbose()
     21        verbose = verbose(3)
     22        verbose = verbose('001100')
     23        verbose = verbose('module', True, 'solver', False)
    2524
    26     WARNING: some parts of this file are Synchronized with src/c/shared/Numerics/Verbosity.h
    27              Do not modify these sections. See src/c/shared/Numerics/README for more info
     25    NOTE:
     26    - Some parts of this file are Synchronized with
     27    src/c/shared/Numerics/Verbosity.h. Do not modify these sections. See
     28    src/c/shared/Numerics/README for more info.
    2829    """
    2930
     
    4243
    4344        if not len(args):
    44             #Don't do anything
     45            # Don't do anything
    4546            self.solution = True
    4647            self.qmu = True
     
    5253            if isinstance(binary, str):
    5354                if binary.lower() == 'all':
    54                     binary = 2**11 - 1  #all ones
     55                    binary = pow(2, 11) - 1  # all ones
    5556                    self.BinaryToVerbose(binary)
    56                     self.solver = False  #Do not use by default
     57                    self.solver = False  # Do not use by default
    5758                else:
    5859                    binary = int(binary, 2)
     
    6263
    6364        else:
    64             #Use options to initialize object
     65            # Use options to initialize object
    6566            self = pairoptions(*args).AssignObjectFields(self)
    6667
    67             #Cast to logicals
     68            # Cast to logicals
    6869            listproperties = vars(self)
    6970            for fieldname, fieldvalue in list(listproperties.items()):
  • TabularUnified issm/trunk-jpl/src/m/consistency/ismodelselfconsistent.py

    r26318 r26358  
    66    """
    77
    8     #initialize consistency as true
     8    # Initialize consistency as true
    99    md.private.isconsistent = True
    1010
     
    1212    # exit()
    1313
    14     #Get solution and associated analyses
     14    # Get solution and associated analyses
    1515    solution = md.private.solution
    1616    analyses = AnalysisConfiguration(solution)
    17     #Go through a model fields, check that it is a class, and call checkconsistency
     17    # Go through a model fields, check that it is a class, and call checkconsistency
    1818    #fields = vars(md)
    1919    #for field in fields.iterkeys():
    2020    for field in md.properties():
    21         #Some properties do not need to be checked
     21        # Some properties do not need to be checked
    2222        if field in ['results', 'debug', 'radaroverlay']:
    2323            continue
    2424
    25         #Check that current field is an object
     25        # Check that current field is an object
    2626        if not hasattr(getattr(md, field), 'checkconsistency'):
    2727            md.checkmessage('field {} is not an object.'.format(field))
    2828
    29         #Check consistency of the object
    30         exec("md.{}.checkconsistency(md, '{}', {})".format(field, solution, analyses))
     29        # Check consistency of the object
     30        exec('md.{}.checkconsistency(md, \'{}\', {})'.format(field, solution, analyses))
    3131
    32     #error message if mode is not consistent
     32    # Error message if mode is not consistent
    3333    if not md.private.isconsistent:
    3434        raise RuntimeError('Model not consistent, see messages above.')
    35 #}}}
     35# }}}
    3636
    3737
    3838def AnalysisConfiguration(solutiontype):  #{{{
    39     '''
    40     ANALYSISCONFIGURATION - return type of analyses, number of analyses
     39    """ANALYSISCONFIGURATION - return type of analyses, number of analyses
    4140
    42         Usage:
    43                 [analyses] = AnalysisConfiguration(solutiontype)
    44     '''
     41    Usage:
     42        [analyses] = AnalysisConfiguration(solutiontype)
     43    """
    4544
    4645    if solutiontype == 'StressbalanceSolution':
     
    8685
    8786    return analyses
    88 #}}}
     87# }}}
  • TabularUnified issm/trunk-jpl/src/m/coordsystems/ll2xy.py

    r24254 r26358  
    33
    44def ll2xy(lat, lon, sgn=-1, central_meridian=0, standard_parallel=71):
    5     '''
    6     LL2XY - converts lat lon to polar stereographic
     5    """LL2XY - converts lat lon to polar stereographic
    76
    8    Converts from geodetic latitude and longitude to Polar
    9    Stereographic (X, Y) coordinates for the polar regions.
    10    Author: Michael P. Schodlok, December 2003 (map2ll)
     7    Converts from geodetic latitude and longitude to Polar
     8    Stereographic (X, Y) coordinates for the polar regions.
     9    Author: Michael P. Schodlok, December 2003 (map2ll)
    1110
    12    Usage:
    13       x, y = ll2xy(lat, lon, sgn)
    14       x, y = ll2xy(lat, lon, sgn, central_meridian, standard_parallel)
     11    Usage:
     12        x, y = ll2xy(lat, lon, sgn)
     13        x, y = ll2xy(lat, lon, sgn, central_meridian, standard_parallel)
    1514
    16  - sgn = Sign of latitude       1 : north latitude (default is mer = 45 lat = 70)
    17                                                    -1 : south latitude (default is mer = 0  lat = 71)
    18     '''
     15    - sgn = Sign of latitude    1 : north latitude (default is mer = 45 lat = 70)
     16                                                   -1 : south latitude (default is mer = 0  lat = 71)
     17    """
    1918
    2019    assert sgn == 1 or sgn == -1, 'error: sgn should be either 1 or -1'
     
    3332    #cde = 57.29577951
    3433    # Radius of the earth in meters
    35     re = 6378.273 * 10**3
     34    re = 6378.273 * pow(10, 3)
    3635    # Eccentricity of the Hughes ellipsoid squared
    37     ex2 = .006693883
     36    ex2 = 0.006693883
    3837    # Eccentricity of the Hughes ellipsoid
    3938    ex = np.sqrt(ex2)
  • TabularUnified issm/trunk-jpl/src/m/coordsystems/xy2ll.py

    r24254 r26358  
    44
    55def xy2ll(x, y, sgn, *args):
    6     '''
    7     XY2LL - converts xy to lat long
     6    """XY2LL - converts xy to lat long
    87
    98    Converts Polar  Stereographic (X, Y) coordinates for the polar regions to
     
    1312
    1413    Usage:
    15        [lat, lon] = xy2ll(x, y, sgn)
    16        [lat, lon] = xy2ll(x, y, sgn, central_meridian, standard_parallel)
     14        [lat, lon] = xy2ll(x, y, sgn)
     15        [lat, lon] = xy2ll(x, y, sgn, central_meridian, standard_parallel)
    1716
    18      - sgn = Sign of latitude   1 : north latitude (default is mer = 45 lat = 70)
    19                                                    -1 : south latitude (default is mer = 0  lat = 71)
    20     '''
     17    - sgn = Sign of latitude    1 : north latitude (default is mer = 45 lat = 70)
     18                                                   -1 : south latitude (default is mer = 0  lat = 71)
     19    """
    2120
    22     #Get central_meridian and standard_parallel depending on hemisphere
     21    # Get central_meridian and standard_parallel depending on hemisphere
    2322    if len(args) == 2:
    2423        delta = args[0]
     
    4746    #cde = 57.29577951
    4847    # Radius of the earth in meters
    49     re = 6378.273 * 10**3
     48    re = 6378.273 * pow(10, 3)
    5049    # Eccentricity of the Hughes ellipsoid squared
    51     ex2 = .006693883
     50    ex2 = 0.006693883
    5251    # Eccentricity of the Hughes ellipsoid
    5352    ex = np.sqrt(ex2)
    5453
    55     sl = slat * pi / 180.
     54    sl = slat * pi / 180.0
    5655    rho = np.sqrt(x**2 + y**2)
    5756    cm = np.cos(sl) / np.sqrt(1.0 - ex2 * (np.sin(sl)**2))
  • TabularUnified issm/trunk-jpl/src/m/materials/cuffey.py

    r24260 r26358  
    33
    44def cuffey(temperature):
    5     """
    6     CUFFEY - calculates ice rigidity as a function of temperature
     5    """CUFFEY - calculates ice rigidity as a function of temperature
    76
    8        rigidity (in s^(1 / 3)Pa) is the flow law parameter in the flow law sigma = B * e(1 / 3)
    9         (Cuffey and Paterson, p75).
    10        temperature is in Kelvin degrees
     7    rigidity (in s^(1/3)Pa) is the flow law parameter in the flow law
     8    sigma = B * e(1/3) (Cuffey and Paterson, p75).
    119
    12        Usage:
    13           rigidity = cuffey(temperature)
     10    temperature is in Kelvin degrees
     11
     12    Usage:
     13        rigidity = cuffey(temperature)
    1414    """
    1515
    16     if np.any(temperature < 0.):
    17         raise RuntimeError("input temperature should be in Kelvin (positive)")
     16    if np.any(temperature < 0.0):
     17        raise RuntimeError('input temperature should be in Kelvin (positive)')
    1818
    1919    if np.ndim(temperature) == 2:
     
    2828    pos = np.nonzero(T <= -45)
    2929    if len(pos):
    30         rigidity[pos] = 10**8 * (-0.000396645116301 * (T[pos] + 50)**3 + 0.013345579471334 * (T[pos] + 50)**2 - 0.356868703259105 * (T[pos] + 50) + 7.272363035371383)
     30        rigidity[pos] = pow(10, 8) * (-0.000396645116301 * (T[pos] + 50)**3 + 0.013345579471334 * (T[pos] + 50)**2 - 0.356868703259105 * (T[pos] + 50) + 7.272363035371383)
    3131    pos = np.nonzero(np.logical_and(-45 <= T, T < -40))
    3232    if len(pos):
    33         rigidity[pos] = 10**8 * (-0.000396645116301 * (T[pos] + 45)**3 + 0.007395902726819 * (T[pos] + 45)**2 - 0.253161292268336 * (T[pos] + 45) + 5.772078366321591)
     33        rigidity[pos] = pow(10, 8) * (-0.000396645116301 * (T[pos] + 45)**3 + 0.007395902726819 * (T[pos] + 45)**2 - 0.253161292268336 * (T[pos] + 45) + 5.772078366321591)
    3434    pos = np.nonzero(np.logical_and(-40 <= T, T < -35))
    3535    if len(pos):
    36         rigidity[pos] = 10**8 * (0.000408322072669 * (T[pos] + 40)**3 + 0.001446225982305 * (T[pos] + 40)**2 - 0.208950648722716 * (T[pos] + 40) + 4.641588833612773)
     36        rigidity[pos] = pow(10, 8) * (0.000408322072669 * (T[pos] + 40)**3 + 0.001446225982305 * (T[pos] + 40)**2 - 0.208950648722716 * (T[pos] + 40) + 4.641588833612773)
    3737    pos = np.nonzero(np.logical_and(-35 <= T, T < -30))
    3838    if len(pos):
    39         rigidity[pos] = 10**8 * (-0.000423888728124 * (T[pos] + 35)**3 + 0.007571057072334 * (T[pos] + 35)**2 - 0.163864233449525 * (T[pos] + 35) + 3.684031498640382)
     39        rigidity[pos] = pow(10, 8) * (-0.000423888728124 * (T[pos] + 35)**3 + 0.007571057072334 * (T[pos] + 35)**2 - 0.163864233449525 * (T[pos] + 35) + 3.684031498640382)
    4040    pos = np.nonzero(np.logical_and(-30 <= T, T < -25))
    4141    if len(pos):
    42         rigidity[pos] = 10**8 * (0.000147154327025 * (T[pos] + 30)**3 + 0.001212726150476 * (T[pos] + 30)**2 - 0.119945317335478 * (T[pos] + 30) + 3.001000667185614)
     42        rigidity[pos] = pow(10, 8) * (0.000147154327025 * (T[pos] + 30)**3 + 0.001212726150476 * (T[pos] + 30)**2 - 0.119945317335478 * (T[pos] + 30) + 3.001000667185614)
    4343    pos = np.nonzero(np.logical_and(-25 <= T, T < -20))
    4444    if len(pos):
    45         rigidity[pos] = 10**8 * (-0.000193435838672 * (T[pos] + 25)**3 + 0.003420041055847 * (T[pos] + 25)**2 - 0.096781481303861 * (T[pos] + 25) + 2.449986525148220)
     45        rigidity[pos] = pow(10, 8) * (-0.000193435838672 * (T[pos] + 25)**3 + 0.003420041055847 * (T[pos] + 25)**2 - 0.096781481303861 * (T[pos] + 25) + 2.449986525148220)
    4646    pos = np.nonzero(np.logical_and(-20 <= T, T < -15))
    4747    if len(pos):
    48         rigidity[pos] = 10**8 * (0.000219771255067 * (T[pos] + 20)**3 + 0.000518503475772 * (T[pos] + 20)**2 - 0.077088758645767 * (T[pos] + 20) + 2.027400665191131)
     48        rigidity[pos] = pow(10, 8) * (0.000219771255067 * (T[pos] + 20)**3 + 0.000518503475772 * (T[pos] + 20)**2 - 0.077088758645767 * (T[pos] + 20) + 2.027400665191131)
    4949    pos = np.nonzero(np.logical_and(-15 <= T, T < -10))
    5050    if len(pos):
    51         rigidity[pos] = 10**8 * (-0.000653438900191 * (T[pos] + 15)**3 + 0.003815072301777 * (T[pos] + 15)**2 - 0.055420879758021 * (T[pos] + 15) + 1.682390865739973)
     51        rigidity[pos] = pow(10, 8) * (-0.000653438900191 * (T[pos] + 15)**3 + 0.003815072301777 * (T[pos] + 15)**2 - 0.055420879758021 * (T[pos] + 15) + 1.682390865739973)
    5252    pos = np.nonzero(np.logical_and(-10 <= T, T < -5))
    5353    if len(pos):
    54         rigidity[pos] = 10**8 * (0.000692439419762 * (T[pos] + 10)**3 - 0.005986511201093 * (T[pos] + 10)**2 - 0.066278074254598 * (T[pos] + 10) + 1.418983411970382)
     54        rigidity[pos] = pow(10, 8) * (0.000692439419762 * (T[pos] + 10)**3 - 0.005986511201093 * (T[pos] + 10)**2 - 0.066278074254598 * (T[pos] + 10) + 1.418983411970382)
    5555    pos = np.nonzero(np.logical_and(-5 <= T, T < -2))
    5656    if len(pos):
    57         rigidity[pos] = 10**8 * (-0.000132282004110 * (T[pos] + 5)**3 + 0.004400080095332 * (T[pos] + 5)**2 - 0.074210229783403 * (T[pos] + 5) + 1.024485188140279)
     57        rigidity[pos] = pow(10, 8) * (-0.000132282004110 * (T[pos] + 5)**3 + 0.004400080095332 * (T[pos] + 5)**2 - 0.074210229783403 * (T[pos] + 5) + 1.024485188140279)
    5858    pos = np.nonzero(-2 <= T)
    5959    if len(pos):
    60         rigidity[pos] = 10**8 * (-0.000132282004110 * (T[pos] + 2)**3 + 0.003209542058346 * (T[pos] + 2)**2 - 0.051381363322371 * (T[pos] + 2) + 0.837883605537096)
     60        rigidity[pos] = pow(10, 8) * (-0.000132282004110 * (T[pos] + 2)**3 + 0.003209542058346 * (T[pos] + 2)**2 - 0.051381363322371 * (T[pos] + 2) + 0.837883605537096)
    6161
    62     #Now make sure that rigidity is positive
     62    # Now make sure that rigidity is positive
    6363    pos = np.nonzero(rigidity < 0)
    64     rigidity[pos] = 1**6
     64    rigidity[pos] = pow(1, 6)
    6565
    6666    return rigidity
  • TabularUnified issm/trunk-jpl/src/m/materials/paterson.py

    r24261 r26358  
    33
    44def paterson(temperature):
    5     """
    6     PATERSON - figure out the rigidity of ice for a given temperature
     5    """PATERSON - figure out the rigidity of ice for a given temperature
    76
    8        rigidity (in s^(1 / 3)Pa) is the flow law paramter in the flow law sigma = B * e(1 / 3) (Paterson, p97).
    9        temperature is in Kelvin degrees
     7    rigidity (in s^(1/3)Pa) is the flow law paramter in the flow law
     8    sigma = B * e(1/3) (Paterson, p97).
    109
    11        Usage:
    12           rigidity = paterson(temperature)
     10    temperature is in Kelvin degrees
     11
     12    Usage:
     13        rigidity = paterson(temperature)
    1314    """
    1415
    15     if np.any(temperature < 0.):
    16         raise RuntimeError("input temperature should be in Kelvin (positive)")
     16    if np.any(temperature < 0.0):
     17        raise RuntimeError('input temperature should be in Kelvin (positive)')
    1718
    1819    if np.ndim(temperature) == 2:
     
    2425        T = temperature - 273.15
    2526
    26     #The routine below is equivalent to:
     27    # The routine below is equivalent to:
    2728
    2829    # n = 3; T = temperature-273
     
    4041    pos1 = np.nonzero(T <= -45)[0]
    4142    if len(pos1):
    42         rigidity[pos1] = 10**8 * (-0.000292866376675 * (T[pos1] + 50)**3 + 0.011672640664130 * (T[pos1] + 50)**2 - 0.325004442485481 * (T[pos1] + 50) + 6.524779401948101)
     43        rigidity[pos1] = pow(10, 8) * (-0.000292866376675 * (T[pos1] + 50)**3 + 0.011672640664130 * (T[pos1] + 50)**2 - 0.325004442485481 * (T[pos1] + 50) + 6.524779401948101)
    4344    pos2 = np.nonzero(np.logical_and(-45 <= T, T < -40))[0]
    4445    if len(pos2):
    45         rigidity[pos2] = 10**8 * (-0.000292866376675 * (T[pos2] + 45)**3 + 0.007279645014004 * (T[pos2] + 45)**2 - 0.230243014094813 * (T[pos2] + 45) + 5.154964909039554)
     46        rigidity[pos2] = pow(10, 8) * (-0.000292866376675 * (T[pos2] + 45)**3 + 0.007279645014004 * (T[pos2] + 45)**2 - 0.230243014094813 * (T[pos2] + 45) + 5.154964909039554)
    4647    pos3 = np.nonzero(np.logical_and(-40 <= T, T < -35))[0]
    4748    if len(pos3):
    48         rigidity[pos3] = 10**8 * (0.000072737147457 * (T[pos3] + 40)**3 + 0.002886649363879 * (T[pos3] + 40)**2 - 0.179411542205399 * (T[pos3] + 40) + 4.149132666831214)
     49        rigidity[pos3] = pow(10, 8) * (0.000072737147457 * (T[pos3] + 40)**3 + 0.002886649363879 * (T[pos3] + 40)**2 - 0.179411542205399 * (T[pos3] + 40) + 4.149132666831214)
    4950    pos4 = np.nonzero(np.logical_and(-35 <= T, T < -30))[0]
    5051    if len(pos4):
    51         rigidity[pos4] = 10**8 * (-0.000086144770023 * (T[pos4] + 35)**3 + 0.003977706575736 * (T[pos4] + 35)**2 - 0.145089762507325 * (T[pos4] + 35) + 3.333333333333331)
     52        rigidity[pos4] = pow(10, 8) * (-0.000086144770023 * (T[pos4] + 35)**3 + 0.003977706575736 * (T[pos4] + 35)**2 - 0.145089762507325 * (T[pos4] + 35) + 3.333333333333331)
    5253    pos5 = np.nonzero(np.logical_and(-30 <= T, T < -25))[0]
    5354    if len(pos5):
    54         rigidity[pos5] = 10**8 * (-0.000043984685769 * (T[pos5] + 30)**3 + 0.002685535025386 * (T[pos5] + 30)**2 - 0.111773554501713 * (T[pos5] + 30) + 2.696559088937191)
     55        rigidity[pos5] = pow(10, 8) * (-0.000043984685769 * (T[pos5] + 30)**3 + 0.002685535025386 * (T[pos5] + 30)**2 - 0.111773554501713 * (T[pos5] + 30) + 2.696559088937191)
    5556    pos6 = np.nonzero(np.logical_and(-25 <= T, T < -20))[0]
    5657    if len(pos6):
    57         rigidity[pos6] = 10**8 * (-0.000029799523463 * (T[pos6] + 25)**3 + 0.002025764738854 * (T[pos6] + 25)**2 - 0.088217055680511 * (T[pos6] + 25) + 2.199331606342181)
     58        rigidity[pos6] = pow(10, 8) * (-0.000029799523463 * (T[pos6] + 25)**3 + 0.002025764738854 * (T[pos6] + 25)**2 - 0.088217055680511 * (T[pos6] + 25) + 2.199331606342181)
    5859    pos7 = np.nonzero(np.logical_and(-20 <= T, T < -15))[0]
    5960    if len(pos7):
    60         rigidity[pos7] = 10**8 * (0.000136920904777 * (T[pos7] + 20)**3 + 0.001578771886910 * (T[pos7] + 20)**2 - 0.070194372551690 * (T[pos7] + 20) + 1.805165505978111)
     61        rigidity[pos7] = pow(10, 8) * (0.000136920904777 * (T[pos7] + 20)**3 + 0.001578771886910 * (T[pos7] + 20)**2 - 0.070194372551690 * (T[pos7] + 20) + 1.805165505978111)
    6162    pos8 = np.nonzero(np.logical_and(-15 <= T, T < -10))[0]
    6263    if len(pos8):
    63         rigidity[pos8] = 10**8 * (-0.000899763781026 * (T[pos8] + 15)**3 + 0.003632585458564 * (T[pos8] + 15)**2 - 0.044137585824322 * (T[pos8] + 15) + 1.510778053489523)
     64        rigidity[pos8] = pow(10, 8) * (-0.000899763781026 * (T[pos8] + 15)**3 + 0.003632585458564 * (T[pos8] + 15)**2 - 0.044137585824322 * (T[pos8] + 15) + 1.510778053489523)
    6465    pos9 = np.nonzero(np.logical_and(-10 <= T, T < -5))[0]
    6566    if len(pos9):
    66         rigidity[pos9] = 10**8 * (0.001676964325070 * (T[pos9] + 10)**3 - 0.009863871256831 * (T[pos9] + 10)**2 - 0.075294014815659 * (T[pos9] + 10) + 1.268434288203714)
     67        rigidity[pos9] = pow(10, 8) * (0.001676964325070 * (T[pos9] + 10)**3 - 0.009863871256831 * (T[pos9] + 10)**2 - 0.075294014815659 * (T[pos9] + 10) + 1.268434288203714)
    6768    pos10 = np.nonzero(np.logical_and(-5 <= T, T < -2))[0]
    6869    if len(pos10):
    69         rigidity[pos10] = 10**8 * (-0.003748937622487 * (T[pos10] + 5)**3 + 0.015290593619213 * (T[pos10] + 5)**2 - 0.048160403003748 * (T[pos10] + 5) + 0.854987973338348)
     70        rigidity[pos10] = pow(10, 8) * (-0.003748937622487 * (T[pos10] + 5)**3 + 0.015290593619213 * (T[pos10] + 5)**2 - 0.048160403003748 * (T[pos10] + 5) + 0.854987973338348)
    7071    pos11 = np.nonzero(-2 <= T)[0]
    7172    if len(pos11):
    72         rigidity[pos11] = 10**8 * (-0.003748937622488 * (T[pos11] + 2)**3 - 0.018449844983174 * (T[pos11] + 2)**2 - 0.057638157095631 * (T[pos11] + 2) + 0.746900791092860)
     73        rigidity[pos11] = pow(10, 8) * (-0.003748937622488 * (T[pos11] + 2)**3 - 0.018449844983174 * (T[pos11] + 2)**2 - 0.057638157095631 * (T[pos11] + 2) + 0.746900791092860)
    7374
    7475    #Now make sure that rigidity is positive
    7576    pos = np.nonzero(rigidity < 0)[0]
    7677    if len(pos):
    77         rigidity[pos] = 1.e6
     78        rigidity[pos] = 1.0e6
    7879
    7980    return rigidity
  • TabularUnified issm/trunk-jpl/src/m/mech/mechanicalproperties.m

    r22997 r26358  
    11function md=mechanicalproperties(md,vx,vy,varargin)
    2 %MECHANICALPROPERTIES - compute stress and strain rate for a goven velocity
     2%MECHANICALPROPERTIES - compute stress and strain rate for a given velocity
    33%
    44%   this routine computes the components of the (deviatoric) stress tensor,
  • TabularUnified issm/trunk-jpl/src/m/mech/mechanicalproperties.py

    r24254 r26358  
    55
    66def mechanicalproperties(md, vx, vy, **kwargs):
    7     """
    8     MECHANICALPROPERTIES - compute stress and strain rate for a goven velocity
     7    """MECHANICALPROPERTIES - compute stress and strain rate for a given
     8    velocity
    99
    10    this routine computes the components of the stress tensor
    11    strain rate tensor and their respective principal directions.
    12    the results are in the model md: md.results
     10    This routine computes the components of the stress tensor strain rate
     11    tensor and their respective principal directions. The results are in the
     12    model md: md.results
    1313
    14    Usage:
    15       md = mechanicalproperties(md, vx, vy)
     14    Usage:
     15        md = mechanicalproperties(md, vx, vy)
    1616
    17    Example:
    18       md = mechanicalproperties(md, md.initialization.vx, md.initialization.vy)
    19       md = mechanicalproperties(md, md.inversion.vx_obs, md.inversion.vy_obs)
     17    Example:
     18        md = mechanicalproperties(md, md.initialization.vx, md.initialization.vy)
     19        md = mechanicalproperties(md, md.inversion.vx_obs, md.inversion.vy_obs)
    2020    """
    2121
     
    7575    #some corrections
    7676    location = np.nonzero(np.logical_and(second_inv == 0, power != 0))
    77     nu[location] = 10**18 #arbitrary maximum viscosity to apply where there is no effective shear
     77    nu[location] = pow(10, 18) #arbitrary maximum viscosity to apply where there is no effective shear
    7878
    7979    if 'matice' in md.materials.__module__:
     
    8383        nu[location] = B_bar[location]
    8484        location = np.nonzero(np.logical_and(second_inv == 0, power != 0))
    85         nu[location] = 10**18
     85        nu[location] = pow(10, 18)
    8686    elif 'matdamageice' in md.materials.__module__ and damage is not None:
    8787        print('computing damage-dependent properties!')
  • TabularUnified issm/trunk-jpl/src/m/mesh/bamg.py

    r25455 r26358  
    2323    Available options (for more details see ISSM website http://issm.jpl.nasa.gov/):
    2424
    25     - domain :            followed by an ARGUS file that prescribes the domain outline
    26     - holes :             followed by an ARGUS file that prescribes the holes
    27     - subdomains :        followed by an ARGUS file that prescribes the list of
    28                         subdomains (that need to be inside domain)
    29 
    30     - hmin :              minimum edge length (default is 1.0e - 100)
    31     - hmax :              maximum edge length (default is 1.0e100)
    32     - hVertices :         imposed edge length for each vertex (geometry or mesh)
    33     - hminVertices :      minimum edge length for each vertex (mesh)
    34     - hmaxVertices :      maximum edge length for each vertex (mesh)
    35 
    36     - anisomax :          maximum ratio between the smallest and largest edges (default is 1.0e30)
    37     - coeff :             coefficient applied to the metric (2 -> twice as many elements, default is 1)
    38     - cutoff :            scalar used to compute the metric when metric type 2 or 3 are applied
    39     - err :               error used to generate the metric from a field
    40     - errg :              geometric error (default is 0.1)
    41     - field :             field of the model that will be used to compute the metric
    42                                    to apply several fields, use one column per field
    43     - gradation :         maximum ratio between two adjacent edges
    44     - Hessiantype :       0 -> use double P2 projection (default)
    45                             1 -> use Green formula
    46     - KeepVertices :      try to keep initial vertices when adaptation is done on an existing mesh (default 1)
    47     - NoBoundaryRefinement: do not refine boundary, only follow contour provided (default 0). Allow subdomain boundary refinement though
    48     - NoBoundaryRefinementAllBoundaries: do not refine boundary, only follow contour provided (default 0)
    49     - maxnbv :            maximum number of vertices used to allocate memory (default is 1.0e6)
    50     - maxsubdiv :         maximum subdivision of exisiting elements (default is 10)
    51     - metric :            matrix (numberofnodes x 3) used as a metric
    52     - Metrictype :        1 -> absolute error          c / (err coeff^2) * Abs(H)        (default)
    53                                    2 -> relative error          c / (err coeff^2) * Abs(H) / max(s, cutoff * max(s))
    54                                    3 -> rescaled absolute error c / (err coeff^2) * Abs(H) / (smax - smin)
    55     - nbjacoby :          correction used by Hessiantype = 1 (default is 1)
    56     - nbsmooth :          number of metric smoothing procedure (default is 3)
    57     - omega :             relaxation parameter of the smoothing procedure (default is 1.8)
    58     - power :             power applied to the metric (default is 1)
    59     - splitcorners :      split triangles whuch have 3 vertices on the outline (default is 1)
    60     - verbose :           level of verbosity (default is 1)
    61 
    62     - rifts :             followed by an ARGUS file that prescribes the rifts
    63     - toltip :            tolerance to move tip on an existing point of the domain outline
    64     - tracks :            followed by an ARGUS file that prescribes the tracks that the mesh will stick to
    65     - RequiredVertices :  mesh vertices that are required. [x, y, ref]; ref is optional
    66     - tol :               if the distance between 2 points of the domain outline is less than tol, they
    67                              will be merged
     25    - domain :                              followed by an ARGUS file that
     26                                            prescribes the domain outline
     27    - holes :                               followed by an ARGUS file that
     28                                            prescribes the holes
     29    - subdomains :                          followed by an ARGUS file that
     30                                            prescribes the list of subdomains
     31                                            (that need to be inside domain)
     32
     33    - hmin :                                minimum edge length (default is
     34                                            1.0e-100)
     35    - hmax :                                maximum edge length (default is
     36                                            1.0e100)
     37    - hVertices :                           imposed edge length for each vertex
     38                                            (geometry or mesh)
     39    - hminVertices :                        minimum edge length for each vertex
     40                                            (mesh)
     41    - hmaxVertices :                        maximum edge length for each vertex
     42                                            (mesh)
     43
     44    - anisomax :                            maximum ratio between the smallest
     45                                            and largest edges (default is
     46                                            1.0e30)
     47    - coeff :                               coefficient applied to the metric
     48                                            (2 -> twice as many elements,
     49                                            default is 1)
     50    - cutoff :                              scalar used to compute the metric
     51                                            when metric type 2 or 3 are applied
     52    - err :                                 error used to generate the metric
     53                                            from a field
     54    - errg :                                geometric error (default is 0.1)
     55    - field :                               field of the model that will be
     56                                            used to compute the metric to apply
     57                                            several fields, use one column per
     58                                            field
     59    - gradation :                           maximum ratio between two adjacent
     60                                            edges
     61    - Hessiantype :                         0 -> use double P2 projection
     62                                            (default)
     63                                            1 -> use Green formula
     64    - KeepVertices :                        try to keep initial vertices when
     65                                            adaptation is done on an existing
     66                                            mesh (default 1)
     67    - NoBoundaryRefinement :                do not refine boundary, only follow
     68                                            contour provided (default 0). Allow
     69                                            subdomain boundary refinement
     70                                            though
     71    - NoBoundaryRefinementAllBoundaries :   do not refine boundary, only follow
     72                                            contour provided (default 0)
     73    - maxnbv :                              maximum number of vertices used to
     74                                            allocate memory (default is 1.0e6)
     75    - maxsubdiv :                           maximum subdivision of exisiting
     76                                            elements (default is 10)
     77    - metric :                              matrix (numberofnodes x 3) used as
     78                                            a metric
     79    - Metrictype :                          1 -> absolute error
     80                                            c/(err coeff^2) * Abs(H) (default)
     81                                            2 -> relative error
     82                                            c / (err coeff^2) * Abs(H) /
     83                                            max(s, cutoff * max(s))
     84                                            3 -> rescaled absolute error
     85                                            c / (err coeff^2) * Abs(H) /
     86                                            (smax - smin)
     87    - nbjacoby :                            correction used by Hessiantype = 1
     88                                            (default is 1)
     89    - nbsmooth :                            number of metric smoothing
     90                                            procedure (default is 3)
     91    - omega :                               relaxation parameter of the
     92                                            smoothing procedure (default is
     93                                            1.8)
     94    - power :                               power applied to the metric
     95                                            (default is 1)
     96    - splitcorners :                        split triangles which have 3
     97                                            vertices on the outline (default is
     98                                            1)
     99    - verbose :                             level of verbosity (default is 1)
     100
     101    - rifts :                               followed by an ARGUS file that
     102                                            prescribes the rifts
     103    - toltip :                              tolerance to move tip on an
     104                                            existing point of the domain
     105                                            outline
     106    - tracks :                              followed by an ARGUS file that
     107                                            prescribes the tracks that the mesh
     108                                            will stick to
     109    - RequiredVertices :                    mesh vertices that are required.
     110                                            [x, y, ref]; ref is optional
     111    - tol :                                 if the distance between 2 points of
     112                                            the domain outline is less than
     113                                            tol, they will be merged
    68114
    69115    Examples:
     
    76122    """
    77123
    78     #process options
     124    # Process options
    79125    options = pairoptions(*args)
    80126    #options = deleteduplicates(options, 1)
    81127
    82     #initialize the structures required as input of Bamg
     128    # Initialize the structures required as input of Bamg
    83129    bamg_options = OrderedDict()
    84130    bamg_geometry = bamggeom()
     
    138184                        holes = holesfile
    139185                    else:
    140                         raise Exception("bamg error message: if 'holes' is a list, its elements must be of type dict or OrderedDict")
     186                        raise Exception('bamg error message: if \'holes\' is a list, its elements must be of type dict or OrderedDict')
    141187                else:
    142188                    holes = holesfile
     
    144190                holes = [holesfile]
    145191            else:
    146                 raise Exception("'holes' type {} not supported yet".format(type(holesfile)))
     192                raise Exception('\'holes\' type {} not supported yet'.format(type(holesfile)))
    147193
    148194        subdomains = []
     
    151197            if type(subdomainsfile) == str:
    152198                if not os.path.exists(subdomainsfile):
    153                     raise IOError("bamg error message: file {} not found".format(subdomainsfile))
     199                    raise IOError('bamg error message: file {} not found'.format(subdomainsfile))
    154200
    155201                # Read subdomains accoridng to its extension
     
    166212                        subdomains = subdomainsfile
    167213                    else:
    168                         raise Exception("bamg error message: if 'subdomains' is a list, its elements must be of type dict or OrderedDict")
     214                        raise Exception('bamg error message: if \'subdomains\' is a list, its elements must be of type dict or OrderedDict')
    169215                else:
    170216                    subdomains = subdomainsfile
     
    172218                subdomains = [subdomainsfile]
    173219            else:
    174                 raise Exception("'subdomains' type {} not supported yet".format(type(subdomainsfile)))
     220                raise Exception('\'subdomains\' type {} not supported yet'.format(type(subdomainsfile)))
    175221
    176222        # Build geometry
     
    179225            # Check that the domain is closed
    180226            if (domain[i]['x'][0] != domain[i]['x'][-1] or domain[i]['y'][0] != domain[i]['y'][-1]):
    181                 raise RuntimeError("bamg error message: all contours provided in ''domain'' should be closed")
     227                raise RuntimeError('bamg error message: all contours provided in \'domain\' should be closed')
    182228
    183229            # Check that all holes are INSIDE the principle domain outline
     
    185231                flags = ContourToNodes(domain[i]['x'], domain[i]['y'], [domain[0]], 0)[0] # NOTE: Down stack call to FetchPythonData requires contour to be a list of struct if we are not passing in a path to a file, hence the odd addressing: '[domain[0]]'
    186232                if np.any(np.logical_not(flags)):
    187                     raise RuntimeError("bamg error message: All holes should be strictly inside the principal domain")
     233                    raise RuntimeError('bamg error message: All holes should be strictly inside the principal domain')
    188234
    189235            # Check orientation
     
    221267            # heck that the hole is closed
    222268            if (holes[i]['x'][0] != holes[i]['x'][-1] or holes[i]['y'][0] != holes[i]['y'][-1]):
    223                 raise RuntimeError("bamg error message: all contours provided in ''hole'' should be closed")
     269                raise RuntimeError('bamg error message: all contours provided in \'hole\' should be closed')
    224270
    225271            # Check that all holes are INSIDE the principal domain (principal domain should be index 0)
    226272            flags = ContourToNodes(holes[i]['x'], holes[i]['y'], [domain[0]], 0)[0] # NOTE: Down stack call to FetchPythonData requires contour to be a list of struct if we are not passing in a path to a file, hence the odd addressing: '[domain[0]]'
    227273            if np.any(np.logical_not(flags)):
    228                 raise RuntimeError("bamg error message: All holes should be strictly inside the principal domain")
     274                raise RuntimeError('bamg error message: All holes should be strictly inside the principal domain')
    229275
    230276            # Check that hole is correctly oriented
     
    249295            # Check that the subdomain is closed
    250296            if (subdomains[i]['x'][0] != subdomains[i]['x'][-1] or subdomains[i]['y'][0] != subdomains[i]['y'][-1]):
    251                 raise RuntimeError("bamg error message: all contours provided in ''subdomains'' should be closed")
     297                raise RuntimeError('bamg error message: all contours provided in \'subdomains\' should be closed')
    252298
    253299            # Check that all subdomains are INSIDE the principal domain (principal domain should be index 0)
    254300            flags = ContourToNodes(subdomains[i]['x'], subdomains[i]['y'], [domain[0]], 0)[0] # NOTE: Down stack call to FetchPythonData requires contour to be a list of struct if we are not passing in a path to a file, hence the odd addressing: '[domain[0]]'
    255301            if np.any(np.logical_not(flags)):
    256                 raise RuntimeError("bamg error message: All subdomains should be strictly inside the principal domain")
     302                raise RuntimeError('bamg error message: All subdomains should be strictly inside the principal domain')
    257303
    258304            # Check that subdomain is correctly oriented
     
    277323        if options.getfieldvalue('vertical', 0):
    278324            if np.size(options.getfieldvalue('Markers', [])) != np.size(bamg_geometry.Edges, 0):
    279                 raise RuntimeError('for 2d vertical mesh, ''Markers'' option is required, and should be of size ' + str(np.size(bamg_geometry.Edges, 0)))
     325                raise RuntimeError('for 2d vertical mesh, \'Markers\' option is required, and should be of size {}'.format(str(np.size(bamg_geometry.Edges, 0))))
    280326        if np.size(options.getfieldvalue('Markers', [])) == np.size(bamg_geometry.Edges, 0):
    281327            bamg_geometry.Edges[:, 2] = options.getfieldvalue('Markers')
     
    291337                rift = shpread(riftfile)
    292338            else:
    293                 raise IOError("bamg error message: file '{}' format not supported (.exp or .shp)".format(riftfile))
     339                raise IOError('bamg error message: file \'{}\' format not supported (.exp or .shp)'.format(riftfile))
    294340
    295341            for i in range(len(rift)):
     
    297343                flags = ContourToNodes(rift[i]['x'], rift[i]['y'], [domain[0]], 0)[0] # NOTE: Down stack call to FetchPythonData requires contour to be a list of struct if we are not passing in a path to a file, hence the odd addressing: '[domain[0]]'
    298344                if np.all(np.logical_not(flags)):
    299                     raise RuntimeError("one rift has all its points outside of the domain outline")
     345                    raise RuntimeError('one rift has all its points outside of the domain outline')
    300346                elif np.any(np.logical_not(flags)):
    301347                    # We have LOTS of work to do
    302                     print("Rift tip outside of or on the domain has been detected and is being processed...")
     348                    print('Rift tip outside of or on the domain has been detected and is being processed...')
    303349
    304350                    # Check that only one point is outside (for now)
    305351                    if np.sum(np.logical_not(flags).astype(int)) != 1:
    306                         raise RuntimeError("bamg error message: only one point outside of the domain is supported at this time")
     352                        raise RuntimeError('bamg error message: only one point outside of the domain is supported at this time')
    307353
    308354                    # Move tip outside to the first position
     
    314360                        rift[i]['y'] = np.flipud(rift[i]['y'])
    315361                    else:
    316                         raise RuntimeError("bamg error message: only a rift tip can be outside of the domain")
     362                        raise RuntimeError('bamg error message: only a rift tip can be outside of the domain')
    317363
    318364                    # Get coordinate of intersection point
     
    341387
    342388                            if np.min(tipdis) / segdis < options.getfieldvalue('toltip', 0):
    343                                 print("moving tip-domain intersection point")
     389                                print('moving tip-domain intersection point')
    344390
    345391                                # Get position of the closer point
     
    370416                                pos = np.nonzero(np.logical_and(bamg_geometry.Edges[:, 0] == i1, bamg_geometry.Edges[:, 1] == i2))[0]
    371417                                if not pos:
    372                                     raise RuntimeError("bamg error message: a problem occurred...")
     418                                    raise RuntimeError('bamg error message: a problem occurred...')
    373419                                bamg_geometry.Edges = np.vstack((
    374420                                    bamg_geometry.Edges[0:pos - 1, :],
     
    507553    # Bamg options {{{
    508554    bamg_options['Crack'] = options.getfieldvalue('Crack', 0)
    509     bamg_options['anisomax'] = options.getfieldvalue('anisomax', 10.**18)
    510     bamg_options['coeff'] = options.getfieldvalue('coeff', 1.)
    511     bamg_options['cutoff'] = options.getfieldvalue('cutoff', 10.**-5)
     555    bamg_options['anisomax'] = options.getfieldvalue('anisomax', pow(10.0, 18))
     556    bamg_options['coeff'] = options.getfieldvalue('coeff', 1.0)
     557    bamg_options['cutoff'] = options.getfieldvalue('cutoff', pow(10.0, -5))
    512558    bamg_options['err'] = options.getfieldvalue('err', np.array([[0.01]]))
    513559    bamg_options['errg'] = options.getfieldvalue('errg', 0.1)
     
    515561    bamg_options['gradation'] = options.getfieldvalue('gradation', 1.5)
    516562    bamg_options['Hessiantype'] = options.getfieldvalue('Hessiantype', 0)
    517     bamg_options['hmin'] = options.getfieldvalue('hmin', 10.**-100)
    518     bamg_options['hmax'] = options.getfieldvalue('hmax', 10.**100)
     563    bamg_options['hmin'] = options.getfieldvalue('hmin', pow(10.0, -100))
     564    bamg_options['hmax'] = options.getfieldvalue('hmax', pow(10.0, 100))
    519565    bamg_options['hminVertices'] = options.getfieldvalue('hminVertices', np.empty((0, 1)))
    520566    bamg_options['hmaxVertices'] = options.getfieldvalue('hmaxVertices', np.empty((0, 1)))
    521567    bamg_options['hVertices'] = options.getfieldvalue('hVertices', np.empty((0, 1)))
    522568    bamg_options['KeepVertices'] = options.getfieldvalue('KeepVertices', 1)
    523     bamg_options['maxnbv'] = options.getfieldvalue('maxnbv', 10**6)
    524     bamg_options['maxsubdiv'] = options.getfieldvalue('maxsubdiv', 10.)
     569    bamg_options['maxnbv'] = options.getfieldvalue('maxnbv', pow(10, 6))
     570    bamg_options['maxsubdiv'] = options.getfieldvalue('maxsubdiv', 10.0)
    525571    bamg_options['metric'] = options.getfieldvalue('metric', np.empty((0, 1)))
    526572    bamg_options['Metrictype'] = options.getfieldvalue('Metrictype', 0)
     
    528574    bamg_options['nbsmooth'] = options.getfieldvalue('nbsmooth', 3)
    529575    bamg_options['omega'] = options.getfieldvalue('omega', 1.8)
    530     bamg_options['power'] = options.getfieldvalue('power', 1.)
     576    bamg_options['power'] = options.getfieldvalue('power', 1.0)
    531577    bamg_options['splitcorners'] = options.getfieldvalue('splitcorners', 1)
    532578    bamg_options['verbose'] = options.getfieldvalue('verbose', 1)
     
    595641    md.mesh.elementconnectivity = md.mesh.elementconnectivity.astype(int)
    596642
    597     #Check for orphan
     643    # Check for orphan
    598644    if np.any(np.logical_not(np.in1d(np.arange(1, md.mesh.numberofvertices + 1), md.mesh.elements.flat))):
    599         raise RuntimeError("Output mesh has orphans. Check your Domain and / or RequiredVertices")
     645        raise RuntimeError('Output mesh has orphans. Check your Domain and/or RequiredVertices')
    600646
    601647    return md
     
    603649
    604650def processgeometry(geom, tol, outline):  # {{{
    605     raise RuntimeError("bamg.py::processgeometry is not complete.")
     651    raise RuntimeError('bamg.py::processgeometry is not complete.')
    606652
    607653    # Deal with edges
    608     print("Checking Edge crossing...")
     654    print('Checking Edge crossing...')
    609655    i = 0
    610656    while (i < np.size(geom.Edges, axis=0)):
     
    659705
    660706    # Check point outside
    661     print("Checking for points outside the domain...")
     707    print('Checking for points outside the domain...')
    662708    i = 0
    663709    num = 0
     
    687733
    688734    if num:
    689         print(("WARNING: %d points outside the domain outline have been removed" % num))
     735        print(('WARNING: {} points outside the domain outline have been removed'.format(num)))
    690736
    691737    """
  • TabularUnified issm/trunk-jpl/src/m/mesh/planet/gmsh/gmshplanet.m

    r26354 r26358  
    197197        mesh.z=radius*sind(mesh.lat);
    198198
    199 
    200199        %erase files:
    201200        system('rm -rf sphere.geo sphere.msh sphere.pos');
  • TabularUnified issm/trunk-jpl/src/m/mesh/planet/gmsh/gmshplanet.py

    r26354 r26358  
    8282        curvename = 'Curve Loop'
    8383
    84     fid.write('%s(13) = {2, 8, -10};\n' % curvename)
     84    fid.write('%s(13) = {2,8,-10};\n' % curvename)
    8585    fid.write('Surface(14) = {13};\n')
    86     fid.write('%s(15) = {10, 3, 7};\n' % curvename)
     86    fid.write('%s(15) = {10,3,7};\n' % curvename)
    8787    fid.write('Surface(16) = {15};\n')
    88     fid.write('%s(17) = {-8, -9, 1};\n' % curvename)
     88    fid.write('%s(17) = {-8,-9,1};\n' % curvename)
    8989    fid.write('Surface(18) = {17};\n')
    90     fid.write('%s(19) = {-11, -2, 5};\n' % curvename)
     90    fid.write('%s(19) = {-11,-2,5};\n' % curvename)
    9191    fid.write('Surface(20) = {19};\n')
    92     fid.write('%s(21) = {-5, -12, -1};\n' % curvename)
     92    fid.write('%s(21) = {-5,-12,-1};\n' % curvename)
    9393    fid.write('Surface(22) = {21};\n')
    94     fid.write('%s(23) = {-3, 11, 6};\n' % curvename)
     94    fid.write('%s(23) = {-3,11,6};\n' % curvename)
    9595    fid.write('Surface(24) = {23};\n')
    96     fid.write('%s(25) = {-7, 4, 9};\n' % curvename)
     96    fid.write('%s(25) = {-7,4,9};\n' % curvename)
    9797    fid.write('Surface(26) = {25};\n')
    98     fid.write('%s(27) = {-4, 12, -6};\n' % curvename)
     98    fid.write('%s(27) = {-4,12,-6};\n' % curvename)
    9999    fid.write('Surface(28) = {27};\n')
    100     fid.write('Surface Loop(29) = {28, 26, 16, 14, 20, 24, 22, 18};\n')
     100    fid.write('Surface Loop(29) = {28,26,16,14,20,24,22,18};\n')
    101101    fid.write('Volume(30) = {29};\n')
    102     fid.write('Physical Surface(1) = {28, 26, 16, 14, 20, 24, 22, 18};\n')
     102    fid.write('Physical Surface(1) = {28,26,16,14,20,24,22,18};\n')
    103103    fid.write('Physical Volume(2) = 30;\n')
    104104    fid.close()
     
    112112        fid = open('sphere.pos', 'w')
    113113
    114         fid.write('View "background mesh" [;\n')
     114        fid.write('View "background mesh" {;\n')
    115115        for i in range(meshini.numberofelements):
    116             fid.write('ST(%g, %g, %g, %g, %g, %g, %g, %g, %g)[%g, %g, %g];\n',
    117                       meshini.x(meshini.elements(i, 0)), meshini.y(meshini.elements(i, 0)), meshini.z(meshini.elements(i, 0)),
    118                       meshini.x(meshini.elements(i, 1)), meshini.y(meshini.elements(i, 1)), meshini.z(meshini.elements(i, 1)),
    119                       meshini.x(meshini.elements(i, 2)), meshini.y(meshini.elements(i, 2)), meshini.z(meshini.elements(i, 2)),
    120                       metric(meshini.elements(i, 0)), metric(meshini.elements(i, 1)), metric(meshini.elements(i, 2)))
    121         fid.write('];\n')
     116            fid.write('ST(%g,%g,%g,%g,%g,%g,%g,%g,%g){%g,%g,%g};\n',
     117                meshini.x(meshini.elements(i, 0)), meshini.y(meshini.elements(i, 0)), meshini.z(meshini.elements(i, 0)),
     118                meshini.x(meshini.elements(i, 1)), meshini.y(meshini.elements(i, 1)), meshini.z(meshini.elements(i, 1)),
     119                meshini.x(meshini.elements(i, 2)), meshini.y(meshini.elements(i, 2)), meshini.z(meshini.elements(i, 2)),
     120                metric(meshini.elements(i, 0)), metric(meshini.elements(i, 1)), metric(meshini.elements(i, 2)))
     121        fid.write('};\n')
    122122        fid.close()
    123123        #}}}
     
    182182    #}}}
    183183
    184     #figure out other fields in mesh3dsurface:
    185     mesh.r = np.sqrt(mesh.x**2 + mesh.y**2 + mesh.z**2)
    186     mesh.lat = np.arcsin(mesh.z / mesh.r) / np.pi * 180
    187     mesh.long = np.arctan2(mesh.y, mesh.x) / np.pi * 180
     184    # A little technicality here. The mesh is not exactly on the sphere. We
     185    # create lat,long coordiantes, and reproject onto an exact sphere.
     186    mesh.r = np.sqrt(mesh.x ** 2 + mesh.y ** 2 + mesh.z ** 2)
     187
     188    # Make sure we don't have south and north pole
     189    pos = np.where(np.logical_and.reduce((mesh.x == 0, mesh.y == 0)))[0]
     190    mesh.lat = asind(mesh.z / mesh.r)
     191    mesh.long = atan2d(mesh.y, mesh.x)
     192    pos = np.where(mesh.lat == 90)[0]
     193    mesh.lat[pos] = 90 - 0.01
     194    pos = np.where(mesh.lat == -90)[0]
     195    mesh.lat[pos] = -90 + 0.01
     196
     197    mesh.r = radius * np.ones((mesh.numberofvertices, ))
     198    mesh.x = radius * cosd(mesh.lat) * cosd(mesh.long)
     199    mesh.y = radius * cosd(mesh.lat) * sind(mesh.long)
     200    mesh.z = radius * sind(mesh.lat)
    188201
    189202    # Erase files
  • TabularUnified issm/trunk-jpl/src/m/miscellaneous/MatlabFuncs.py

    r26353 r26358  
    1 """
    2 A collection of functions that replicate the behavior of MATLAB built-in
     1"""A collection of functions that replicate the behavior of MATLAB built-in
    32functions of the same, respective name.
    43
     
    87"""
    98
    10 def acosd(X):  #{{{
    11     """ function acosd - Inverse cosine in degrees
     9def acosd(X):  # {{{
     10    """function acosd - Inverse cosine in degrees
    1211
    1312    Usage:
     
    1716
    1817    return np.degrees(np.arccos(X))
    19 #}}}
    20 
    21 def asind(X):  #{{{
    22     """ function asind - Inverse sine in degrees
     18# }}}
     19
     20def asind(X):  # {{{
     21    """function asind - Inverse sine in degrees
    2322
    2423    Usage:
     
    2827
    2928    return np.degrees(np.arcsin(X))
    30 #}}}
    31 
    32 def atand(X):  #{{{
    33     """ function atand - Inverse tangent in degrees
     29# }}}
     30
     31def atand(X):  # {{{
     32    """function atand - Inverse tangent in degrees
    3433
    3534    Usage:
     
    3938
    4039    return np.degrees(np.arctan(X))
    41 #}}}
    42 
    43 
    44 def atan2d(Y, X):  #{{{
     40# }}}
     41
     42
     43def atan2d(Y, X):  # {{{
    4544    """function atan2d - Four-quadrant inverse tangent in degrees
    4645
     
    5150
    5251    return np.degrees(np.arctan2(Y, X))
    53 #}}}
    54 
    55 def det(a):  #{{{
     52# }}}
     53
     54def cosd(X):  # {{{
     55    """function cosd - Cosine of argument in degrees
     56
     57    Usage:
     58        Y = cosd(X)
     59    """
     60    import numpy as np
     61
     62    if type(X) == np.ndarray:
     63        Y = np.array([])
     64        for x in X:
     65            Y = np.append(Y, cosdsingle(x))
     66        return Y
     67    else:
     68        return cosdsingle(X)
     69# }}}
     70
     71def cosdsingle(x):  # {{{
     72    """function cosdsingle - Helper function for cosd to reduce repetition of
     73    logic
     74
     75    Usage:
     76        y = cosdsingle(x)
     77    """
     78    import numpy as np
     79
     80    while x >= 360:
     81        x = x - 360
     82
     83    if x == 0:
     84        return 1
     85    elif x == 90 or x == 270:
     86        return 0
     87    elif x == 180:
     88        return -1
     89    else:
     90        return np.cos(np.radians(x))
     91# }}}
     92
     93def det(a):  # {{{
    5694    if a.shape == (1, ):
    5795        return a[0]
     
    6199        return a[0, 0] * a[1, 1] - a[0, 1] * a[1, 0]
    62100    else:
    63         raise TypeError("MatlabFunc.det only implemented for shape (2, 2), not for shape %s." % str(a.shape))
    64 #}}}
    65 
    66 def error(msg):  #{{{
     101        raise TypeError('MatlabFunc.det only implemented for shape (2, 2), not for shape {}.'.format(a.shape))
     102# }}}
     103
     104def error(msg):  # {{{
    67105    raise Exception(msg)
    68 #}}}
    69 
    70 def etime(t2, t1):  #{{{
     106# }}}
     107
     108def etime(t2, t1):  # {{{
    71109    return t2 - t1
    72 #}}}
    73 
    74 def find(*args):  #{{{
     110# }}}
     111
     112def find(*args):  # {{{
    75113    nargs = len(args)
    76114    if nargs >= 1 or nargs <= 2:
     
    86124    else:
    87125        raise Exception('find: must have 1 or 2 arguments')
    88 #}}}
    89 
    90 def floor(X):  #{{{
     126# }}}
     127
     128def floor(X):  # {{{
    91129    import math
    92130
    93131    return int(math.floor(X))
    94 #}}}
    95 
    96 def heaviside(x):  #{{{
     132# }}}
     133
     134def heaviside(x):  # {{{
    97135    import numpy as np
    98136
     
    102140
    103141    return y
    104 #}}}
    105 
    106 def isa(A, dataType):  #{{{
     142# }}}
     143
     144def isa(A, dataType):  # {{{
    107145    """FUNCTION ISA
    108146
     
    112150    """
    113151    return type(A) == dataType
    114 #}}}
    115 
    116 def isfile(fileName):  #{{{
     152# }}}
     153
     154# NOTE: Conflicts with definition of isempty in $ISSM_DIR/src/m/qmu/helpers.py
     155#
     156# def isempty(A):  # {{{
     157#     return len(A) > 0
     158# # }}}
     159
     160def isfile(fileName):  # {{{
    117161    import os
    118162
    119163    return os.path.exists(fileName)
    120 #}}}
    121 
    122 def ismac():  #{{{
     164# }}}
     165
     166def ismac():  # {{{
    123167    import platform
    124168
     
    127171    else:
    128172        return False
    129 #}}}
    130 
    131 def ismember(a, s):  #{{{
     173# }}}
     174
     175def ismember(a, s):  # {{{
    132176    import numpy as np
    133177
     
    149193
    150194    return b
    151 #}}}
    152 
    153 def isnan(A):  #{{{
     195# }}}
     196
     197def isnan(A):  # {{{
    154198    import numpy as np
    155199
    156200    return np.isnan(A)
    157 #}}}
    158 
    159 def ispc():  #{{{
     201# }}}
     202
     203def ispc():  # {{{
    160204    import platform
    161205
     
    164208    else:
    165209        return False
    166 #}}}
    167 
    168 def isprop(obj, PropertyName):  #{{{
     210# }}}
     211
     212def isprop(obj, PropertyName):  # {{{
    169213    return hasattr(obj, PropertyName)
    170 #}}}
    171 
    172 def mod(a, m):  #{{{
     214# }}}
     215
     216def mod(a, m):  # {{{
    173217    return a % m
    174 #}}}
    175 
    176 def pause(n):  #{{{
     218# }}}
     219
     220def pause(n):  # {{{
    177221    import time
    178222
    179223    time.sleep(n)
    180 #}}}
    181 
    182 def pwd():  #{{{
     224# }}}
     225
     226def pwd():  # {{{
    183227    import os
    184228
    185229    return os.getcwd()
    186 #}}}
    187 
    188 def oshostname():  #{{{
     230# }}}
     231
     232def oshostname():  # {{{
    189233    import socket
    190234
    191235    return socket.gethostname()
    192 #}}}
    193 
    194 def rem(a, b):  #{{{
     236# }}}
     237
     238def rem(a, b):  # {{{
    195239    return a % b
    196 #}}}
    197 
    198 def sparse(ivec, jvec, svec, m=0, n=0, nzmax=0):  #{{{
     240# }}}
     241
     242def sind(X):  # {{{
     243    """function sind - Sine of argument in degrees
     244
     245    Usage:
     246        Y = sind(X)
     247    """
     248    import numpy as np
     249
     250    if type(X) == np.ndarray:
     251        Y = np.array([])
     252        for x in X:
     253            Y = np.append(Y, sindsingle(x))
     254        return Y
     255    else:
     256        return sindsingle(X)
     257# }}}
     258
     259def sindsingle(x):  # {{{
     260    """function sindsingle - Helper function for sind to reduce repetition of
     261    logic
     262
     263    Usage:
     264        y = sindsingle(x)
     265    """
     266    import numpy as np
     267
     268    while x >= 360:
     269        x = x - 360
     270
     271    if x == 0 or x == 180:
     272        return 0
     273    elif x == 90:
     274        return 1
     275    elif x == 270:
     276        return -1
     277    else:
     278        return np.sin(np.radians(x))
     279# }}}
     280
     281def sparse(ivec, jvec, svec, m=0, n=0, nzmax=0):  # {{{
    199282    import numpy as np
    200283
     
    210293
    211294    return a
    212 #}}}
    213 
    214 def strcmp(s1, s2):  #{{{
     295# }}}
     296
     297def strcmp(s1, s2):  # {{{
    215298    if s1 == s2:
    216299        return True
    217300    else:
    218301        return False
    219 #}}}
    220 
    221 def strcmpi(s1, s2):  #{{{
     302# }}}
     303
     304def strcmpi(s1, s2):  # {{{
    222305    if s1.lower() == s2.lower():
    223306        return True
    224307    else:
    225308        return False
    226 #}}}
    227 
    228 def strjoin(*args):  #{{{
     309# }}}
     310
     311def strjoin(*args):  # {{{
    229312    nargs = len(args)
    230313    if nargs >= 1 or nargs <= 2:
     
    235318    else:
    236319        raise Exception('strjoin: must have 1 or 2 arguments')
    237 #}}}
    238 
    239 def strncmp(s1, s2, n):  #{{{
     320# }}}
     321
     322def strncmp(s1, s2, n):  # {{{
    240323    if s1[0:n] == s2[0:n]:
    241324        return True
    242325    else:
    243326        return False
    244 #}}}
    245 
    246 def strncmpi(s1, s2, n):  #{{{
     327# }}}
     328
     329def strncmpi(s1, s2, n):  # {{{
    247330    if s1.lower()[0:n] == s2.lower()[0:n]:
    248331        return True
    249332    else:
    250333        return False
    251 #}}}
     334# }}}
  • TabularUnified issm/trunk-jpl/src/m/miscellaneous/pretty_print.m

    r25688 r26358  
    3030                if shape(2)>6
    3131                        output=sprintf('[[%.8f %.8f %.8f ... %.8f %.8f %.8f]\n',data(1,1),data(1,2),data(1,3),data(1,end-2),data(1,end-1),data(1,end));
    32                         output=sprintf('%s [%.8f %.8f %.8f ... %.8f %.8f %.8f]\n',data(2,1),data(2,2),data(2,3),data(2,end-2),data(2,end-1),data(2,end));
    33                         output=sprintf('%s [%.8f %.8f %.8f ... %.8f %.8f %.8f]\n',data(3,1),data(3,2),data(3,3),data(3,end-2),data(3,end-1),data(3,end));
     32                        output=sprintf('%s [%.8f %.8f %.8f ... %.8f %.8f %.8f]\n',output,data(2,1),data(2,2),data(2,3),data(2,end-2),data(2,end-1),data(2,end));
     33                        output=sprintf('%s [%.8f %.8f %.8f ... %.8f %.8f %.8f]\n',output,data(3,1),data(3,2),data(3,3),data(3,end-2),data(3,end-1),data(3,end));
    3434                        output=sprintf('%s ...\n',output);
    35                         output=sprintf('%s [%.8f %.8f %.8f ... %.8f %.8f %.8f]\n',data(end-2,1),data(end-2,2),data(end-2,3),data(end-2,end-2),data(end-2,end-1),data(end-2,end));
    36                         output=sprintf('%s [%.8f %.8f %.8f ... %.8f %.8f %.8f]\n',data(end-1,1),data(end-1,2),data(end-1,3),data(end-1,end-2),data(end-1,end-1),data(end-1,end));
    37                         output=sprintf('%s [%.8f %.8f %.8f ... %.8f %.8f %.8f]]',data(end,1),data(end,2),data(end,3),data(end,end-2),data(end,end-1),data(end,end));
     35                        output=sprintf('%s [%.8f %.8f %.8f ... %.8f %.8f %.8f]\n',output,data(end-2,1),data(end-2,2),data(end-2,3),data(end-2,end-2),data(end-2,end-1),data(end-2,end));
     36                        output=sprintf('%s [%.8f %.8f %.8f ... %.8f %.8f %.8f]\n',output,data(end-1,1),data(end-1,2),data(end-1,3),data(end-1,end-2),data(end-1,end-1),data(end-1,end));
     37                        output=sprintf('%s [%.8f %.8f %.8f ... %.8f %.8f %.8f]]',output,data(end,1),data(end,2),data(end,3),data(end,end-2),data(end,end-1),data(end,end));
    3838                else
    3939                        output=sprintf('[[%.8f]\n',data(1,:));
  • TabularUnified issm/trunk-jpl/src/m/plot/checkplotoptions.py

    r24261 r26358  
    33
    44def checkplotoptions(md, options):
    5     '''
    6     CHECKPLOTOPTIONS - build a structure that holds all plot options
     5    """CHECKPLOTOPTIONS - build a structure that holds all plot options
    76
    8         Usage:
    9             options = checkplotoptions(md, options)
     7    Usage:
     8        options = checkplotoptions(md, options)
    109
    11         See also: PLOTMODEL
     10    See also: PLOTMODEL
    1211
    13         NOTE: not fully implemented yet
    14     '''
     12    NOTE: not fully implemented yet
     13    """
    1514
    1615    # {{{ units
    1716    if options.exist('unit'):
    1817        if 'km' in options.getfieldvalue('unit', 'km'):
    19             options.changefieldvalue('unit', 10**-3)
     18            options.changefieldvalue('unit', pow(10, -3))
    2019        elif '100km' in options.getfieldvalue('unit', '100km'):
    21             options.changefieldvalue('unit', 10**-5)
     20            options.changefieldvalue('unit', pow(10, -5))
    2221    # }}}
    2322    # {{{ density
     
    6261        textlist.extend([text] if isinstance(text, str) else text)
    6362        numtext = len(textlist)
    64     # text position
     63        # text position
    6564        textpos = options.getfieldvalue('textposition', [0.5, 0.5])
    6665        if not isinstance(textpos, list):
     
    7574            raise Exception('textposition should contain one list of x, y vertices for every text instance')
    7675
    77     # font size
     76        # font size
    7877        if options.exist('textfontsize'):
    7978            textfontsize = options.getfieldvalue('textfontsize', 12)
     
    8584            sizelist = np.tile(sizelist, numtext)
    8685
    87     # font color
     86        # font color
    8887        if options.exist('textcolor'):
    8988            textcolor = options.getfieldvalue('textcolor', 'k')
     
    9594            colorlist = np.tile(colorlist, numtext)
    9695
    97     # textweight
     96        # textweight
    9897        if options.exist('textweight'):
    9998            textweight = options.getfieldvalue('textweight')
     
    105104            weightlist = np.tile(weightlist, numtext)
    106105
    107     # text rotation
     106        # text rotation
    108107        if options.exist('textrotation'):
    109108            textrotation = options.getfieldvalue('textrotation', 0)
     
    152151    if options.exist('northarrow'):
    153152        if 'on' in options.getfieldvalue('northarrow', 'on'):
    154             #default values
     153            # default values
    155154            Lx = max(md.mesh.x) - min(md.mesh.x)
    156155            Ly = max(md.mesh.y) - min(md.mesh.y)
  • TabularUnified issm/trunk-jpl/src/m/solve/loadresultfromdisk.py

    r25817 r26358  
    44
    55def loadresultfromdisk(filename, step, name, *args):  # {{{
    6     """
    7     LOADRESULTFROMDISK - load specific result of solution sequence from disk
     6    """LOADRESULTFROMDISK - load specific result of solution sequence from disk
    87    file "filename"
    98
    10         Usage:
    11             variable = loadresultsfromdisk(filename, step, name)
     9    Usage:
     10        variable = loadresultsfromdisk(filename, step, name)
    1211
    13         TODO:
    14         - Test this module against output of src/m/solve/loadresultsfromdisk.m
     12    TODO:
     13    - Test this module against output of src/m/solve/loadresultsfromdisk.m
    1514    """
    16     print('Got hwrwefew')
    17     exit()
     15
    1816    # Open file
    1917    try:
     
    5957                for i in range(M):
    6058                    field[i, :] = struct.unpack('{}i'.format(N), fid.read(N * struct.calcsize('i')))
     59            elif datatype == 5:
     60                # TODO:
     61                # - Check that the following results in the same output as
     62                # MATLAB
     63                #
     64                N = struct.unpack('i', fid.read(struct.calcsize('i')))[0]
     65                fieldr = np.zeros(shape=(M, N), dtype=float)
     66                fieldi = np.zeros(shape=(M, N), dtype=float)
     67                for i in range(M):
     68                    fieldr[i, :] = struct.unpack('{}d'.format(N), fid.read(N * struct.calcsize('d')))
     69                    fieldi[i, :] = struct.unpack('{}d'.format(N), fid.read(N * struct.calcsize('d')))
     70                field = np.vectorize(complex)(fieldr, fieldi)
     71                print(field)
    6172            else:
    6273                raise TypeError("cannot read data of type {}".format(datatype))
  • TabularUnified issm/trunk-jpl/src/m/solve/loadresultsfromcluster.py

    r26332 r26358  
    11import os
     2import subprocess
     3
    24from helpers import *
    35from loadresultsfromdisk import loadresultsfromdisk
  • TabularUnified issm/trunk-jpl/src/m/solve/loadresultsfromdisk.py

    r25817 r26358  
    1616    # Check number of inputs/outputs
    1717    if not md or not filename:
    18         raise ValueError("loadresultsfromdisk: error message.")
     18        raise ValueError('loadresultsfromdisk: error message.')
    1919
    2020    if not md.qmu.isdakota:
     
    3131            return
    3232
    33         # Initialize md.results if not a structure yet
     33        # Initialize md.results if it is not a structure yet
    3434        if not isinstance(md.results, results):
    3535            md.results = results()
     
    3838        structure = parseresultsfromdisk(md, filename, not md.settings.io_gather)
    3939        if not structure:
    40             raise RuntimeError("No result found in binary file '{}'. Check for solution crash.".format(filename))
     40            raise RuntimeError('No result found in binary file \'{}\'. Check for solution crash.'.format(filename))
    4141        if not hasattr(structure[0], 'SolutionType'):
    4242            if hasattr(structure[-1], 'SolutionType'):
     
    6464
    6565        if getattr(md.results, structure[0].SolutionType)[0].errlog:
    66             print("loadresultsfromdisk info message: error during solution. Check your errlog and outlog model fields.")
     66            print('loadresultsfromdisk info message: error during solution. Check your errlog and outlog model fields.')
    6767
    6868        # If only one solution, extract it from list for user friendliness
  • TabularUnified issm/trunk-jpl/src/m/solve/marshall.m

    r26301 r26358  
    4444st=fclose(fid);
    4545
    46 % Uncomment the following to make a copy of the binary input file for debugging
    47 % purposes (can be fed into scripts/BinRead.py).
    48 % copyfile([md.miscellaneous.name '.bin'], [md.miscellaneous.name '.m.bin'])
    49 
    5046if st==-1,
    5147        error(['marshall error message: could not close file ' [md.miscellaneous.name '.bin']]);
    5248end
     49
     50% Uncomment the following to make a copy of the binary input file for debugging
     51% purposes (can be fed into scripts/BinRead.py).
     52copyfile([md.miscellaneous.name '.bin'], [md.miscellaneous.name '.m.bin'])
  • TabularUnified issm/trunk-jpl/src/m/solve/marshall.py

    r26301 r26358  
    1717        print("marshalling file {}.bin".format(md.miscellaneous.name))
    1818
    19     #open file for binary writing
     19    # Open file for binary writing
    2020    try:
    2121        fid = open(md.miscellaneous.name + '.bin', 'wb')
     
    2626    fields.sort() # sort fields so that comparison of binary files is easier
    2727    for field in fields:
    28         #Some properties do not need to be marshalled
     28        # Some properties do not need to be marshalled
    2929        if field in ['results', 'radaroverlay', 'toolkits', 'cluster', 'private']:
    3030            continue
    3131
    32         #Check that current field is an object
     32        # Check that current field is an object
    3333        if not hasattr(getattr(md, field), 'marshall'):
    3434            raise TypeError("field '{}' is not an object.".format(field))
    3535
    36         #Marshall current object
    37         #print "marshalling %s ..." % field #Uncomment for debugging
    38         exec("md.{}.marshall('md.{}', md, fid)".format(field, field))
     36        # Marshall current object
     37        #print('marshalling {} ...'.format(field) # Uncomment for debugging
     38        exec('md.{}.marshall(\'md.{}\', md, fid)'.format(field, field))
    3939
    4040    #Last, write "md.EOF" to make sure that the binary file is not corrupt
     
    4545        fid.close()
    4646
    47         # Uncomment the following to make a copy of the binary input file for
    48         # debugging purposes (can be fed into scripts/BinRead.py).
    49         # copy_cmd = "cp {}.bin {}.py.bin".format(md.miscellaneous.name, md.miscellaneous.name)
    50         # subprocess.call(copy_cmd, shell=True)
     47    except IOError as e:
     48        print('marshall error message: could not close file \'{}.bin\' due to:'.format(md.miscellaneous.name), e)
    5149
    52     except IOError as e:
    53         print("marshall error message: could not close file '{}.bin' due to:".format(md.miscellaneous.name), e)
     50    # Uncomment the following to make a copy of the binary input file for
     51    # debugging purposes (can be fed into scripts/BinRead.py).
     52    copy_cmd = 'cp {}.bin {}.py.bin'.format(md.miscellaneous.name, md.miscellaneous.name)
     53    subprocess.call(copy_cmd, shell=True)
  • TabularUnified issm/trunk-jpl/src/m/solve/parseresultsfromdisk.py

    r26271 r26358  
    8080        fid = open(filename, 'rb')
    8181    except IOError as e:
    82         raise IOError("parseresultsfromdisk error message: could not open {} for binary reading".format(filename))
     82        raise IOError('parseresultsfromdisk error message: could not open {} for binary reading'.format(filename))
    8383
    8484    # Collect all results in a list
     
    127127    """
    128128
    129     #read field
     129    # Read field
    130130    try:
    131131        length = struct.unpack('i', fid.read(struct.calcsize('i')))[0]
    132132        fieldname = struct.unpack('{}s'.format(length), fid.read(length))[0][:-1]
    133         fieldname = fieldname.decode()  #strings are binaries when stored so need to be converted back
     133        fieldname = fieldname.decode() # strings are binaries when stored so need to be converted back
    134134        time = struct.unpack('d', fid.read(struct.calcsize('d')))[0]
    135135        step = struct.unpack('i', fid.read(struct.calcsize('i')))[0]
     
    145145        elif datatype == 3:
    146146            N = struct.unpack('i', fid.read(struct.calcsize('i')))[0]
    147     #field = transpose(fread(fid, [N M], 'double'))
     147            #field = transpose(fread(fid, [N M], 'double'))
    148148            field = np.zeros(shape=(M, N), dtype=float)
    149149            for i in range(M):
     
    152152        elif datatype == 4:
    153153            N = struct.unpack('i', fid.read(struct.calcsize('i')))[0]
    154     # field = transpose(fread(fid, [N M], 'int'))
     154            #field = transpose(fread(fid, [N M], 'int'))
    155155            field = np.zeros(shape=(M, N), dtype=int)
    156156            for i in range(M):
     
    158158
    159159        else:
    160             raise TypeError("cannot read data of datatype {}".format(datatype))
    161 
    162         #Process units here FIXME: this should not be done here!
     160            raise TypeError('cannot read data of datatype {}'.format(datatype))
     161
     162        # Process units here FIXME: this should not be done here!
    163163        yts = md.constants.yts
    164164        if fieldname == 'BalancethicknessThickeningRate':
     
    193193            field = field * yts
    194194        elif fieldname == 'TotalFloatingBmb':
    195             field = field / 10.**12 * yts  #(GigaTon/year)
     195            field = field / pow(10.0, 12) * yts # (GigaTon/year)
    196196        elif fieldname == 'TotalFloatingBmbScaled':
    197             field = field / 10.**12 * yts  #(GigaTon/year)
     197            field = field / pow(10.0, 12) * yts # (GigaTon/year)
    198198        elif fieldname == 'TotalGroundedBmb':
    199             field = field / 10.**12 * yts  #(GigaTon/year)
     199            field = field / pow(10.0, 12) * yts # (GigaTon/year)
    200200        elif fieldname == 'TotalGroundedBmbScaled':
    201             field = field / 10.**12 * yts  #(GigaTon/year)
     201            field = field / pow(10.0, 12) * yts # (GigaTon/year)
    202202        elif fieldname == 'TotalSmb':
    203             field = field / 10.**12 * yts  #(GigaTon/year)
     203            field = field / pow(10.0, 12) * yts # (GigaTon/year)
    204204        elif fieldname == 'TotalSmbScaled':
    205             field = field / 10.**12 * yts  #(GigaTon/year)
     205            field = field / pow(10.0, 12) * yts # (GigaTon/year)
    206206        elif fieldname == 'GroundinglineMassFlux':
    207             field = field / 10.**12 * yts  #(GigaTon/year)
     207            field = field / pow(10.0, 12) * yts # (GigaTon/year)
    208208        elif fieldname == 'IcefrontMassFlux':
    209             field = field / 10.**12 * yts  #(GigaTon/year)
     209            field = field / pow(10.0, 12) * yts # (GigaTon/year)
    210210        elif fieldname == 'IcefrontMassFluxLevelset':
    211             field = field / 10.**12 * yts  #(GigaTon/year)
     211            field = field / pow(10.0, 12) * yts # (GigaTon/year)
    212212        elif fieldname == 'SmbMassBalance':
    213213            field = field * yts
  • TabularUnified issm/trunk-jpl/src/m/solve/solve.m

    r26353 r26358  
    4747elseif strcmpi(solutionstring,'mt') || strcmpi(solutionstring,'Masstransport')
    4848        solutionstring = 'MasstransportSolution';
    49 elseif strcmpi(solutionstring,'oceanmt') || strcmpi(solutionstring,'Oceantransport')
     49elseif strcmpi(solutionstring,'oceant') || strcmpi(solutionstring,'Oceantransport')
    5050        solutionstring = 'OceantransportSolution';
    5151elseif strcmpi(solutionstring,'th') || strcmpi(solutionstring,'Thermal')
  • TabularUnified issm/trunk-jpl/src/m/solve/solve.py

    r26353 r26358  
    8484        solutionstring = 'SamplingSolution'
    8585    else:
    86         raise ValueError("solutionstring '%s' not supported!" % solutionstring)
     86        raise ValueError('solutionstring {} not supported!'.format(solutionstring))
    8787    options = pairoptions('solutionstring', solutionstring, *args)
    8888
     
    101101        ismodelselfconsistent(md)
    102102
     103    # If we are restarting, actually use the provided runtime name
     104    restart = options.getfieldvalue('restart', '')
    103105    # First, build a runtime name that is unique
    104     restart = options.getfieldvalue('restart', '')
    105106    if restart == 1:
    106         pass  # do nothing
     107        pass # Leave the runtimename as is
    107108    else:
    108109        if not isempty(restart):
     
    130131    cluster.BuildQueueScript(md.private.runtimename, md.miscellaneous.name, md.private.solution, md.settings.io_gather, md.debug.valgrind, md.debug.gprof, md.qmu.isdakota, md.transient.isoceancoupling) # queue file
    131132
    132     # Stop here if batch mode
    133     if options.getfieldvalue('batch', 'no') == 'yes':
    134         print('batch mode requested: not launching job interactively')
    135         print('launch solution sequence on remote cluster by hand')
    136         return md
     133    # Upload all required files
     134    modelname = md.miscellaneous.name
     135    filelist = [modelname + '.bin', modelname + '.toolkits']
    137136
    138     # Upload all required files:
    139     modelname = md.miscellaneous.name
    140     filelist = [modelname + '.bin ', modelname + '.toolkits ', modelname + '.queue ']
     137    if ispc():
     138        filelist.append(modelname + '.bat')
     139    else:
     140        filelist.append(modelname + '.queue')
     141
    141142    if md.qmu.isdakota:
    142143        filelist.append(modelname + '.qmu.in')
    143144
    144     if not restart:
     145    if isempty(restart):
    145146        cluster.UploadQueueJob(md.miscellaneous.name, md.private.runtimename, filelist)
    146147
    147148    # Launch job
    148149    cluster.LaunchQueueJob(md.miscellaneous.name, md.private.runtimename, filelist, restart, batch)
     150
     151    # Return if batch
     152    if batch:
     153        if md.verbose.solution:
     154            print('batch mode requested: not launching job interactively')
     155            print('launch solution sequence on remote cluster by hand')
     156        return md
    149157
    150158    # Wait on lock
  • TabularUnified issm/trunk-jpl/src/m/solve/solveslm.m

    r26059 r26358  
    33%
    44%   Usage:
    5 %      slm=solve(slm,solutionstring,varargin)
     5%      slm=solveslm(slm,solutionstring,varargin)
    66%      where varargin is a lit of paired arguments of string OR enums
    77%
     
    99%      - 'Transient'
    1010%
    11 extra options:
     11 extra options:
    1212%
    1313%   Examples:
    14 %      slm=solve(slm,'Transient');
     14%      slm=solveslm(slm,'Transient');
    1515
    1616%recover and process solve options
  • TabularUnified issm/trunk-jpl/src/m/solve/solveslm.py

    r26059 r26358  
    1313
    1414    Usage:
    15         slm=solve(slm,solutionstring,varargin)
     15        slm=solveslm(slm,solutionstring,varargin)
    1616        where varargin is a lit of paired arguments of string OR enums
    1717
     
    2222
    2323    Examples:
    24         slm=solve(slm,'Transient');
     24        slm=solveslm(slm,'Transient');
    2525    """
     26
     27    print('Yep')
     28    exit()
    2629
    2730    # Recover and process solve options
  • TabularUnified issm/trunk-jpl/test/NightlyRun/test2001.py

    r26299 r26358  
    11#Test Name: SquareSheetConstrainedGia2d
    22#GIA test, based off of test101. Running default GIA Ivins class.
    3 from socket import gethostname
    4 
    53import numpy as np
    64
    75from materials import *
     6from MatlabFuncs import *
    87from model import *
    98from parameterize import *
     
    2928md.materials.viscosity = [1e21, 0]
    3029md.initialization.sealevel = np.zeros(md.mesh.numberofvertices)
    31 md.solidearth.settings.cross_section_shape = 1 # for square-edged x-section 
     30md.solidearth.settings.cross_section_shape = 1 # for square-edged x-section
    3231md.solidearth.settings.grdocean = 0 # do not compute sea level, only deformation
    3332md.solidearth.settings.sealevelloading = 0 # do not compute sea level, only deformation
     
    5756
    5857#Solve for GIA deflection
    59 md.cluster = generic('name', gethostname(), 'np', 3)
    60 md.verbose = verbose('11111111111')
     58md.cluster = generic('name', oshostname(), 'np', 3)
    6159md.verbose.solver = 0
    6260md = solve(md, 'Transient')
  • TabularUnified issm/trunk-jpl/test/NightlyRun/test2002.m

    r26303 r26358  
    33%mesh earth:
    44md=model;
    5 load ../Data/SlcTestMesh.mat;
    6 md.mesh=SlcMesh; %700 km resolution mesh
     5md.mesh=gmshplanet('radius',6.371012*10^3,'resolution',700.);
    76
    87%Geometry for the bed, arbitrary thickness of 100:
     
    2524longe=atan2d(ye,xe);
    2625pos=find(late < -80);
    27 md.masstransport.spcthickness(md.mesh.elements(pos,:))= md.masstransport.spcthickness(md.mesh.elements(pos,:))-100;
     26md.masstransport.spcthickness(md.mesh.elements(pos,:))=md.masstransport.spcthickness(md.mesh.elements(pos,:))-100;
    2827posant=pos;
    2928
    3029%greenland
    3130pos=find(late>60 & late<90 & longe>-75 & longe<-15);
    32 md.masstransport.spcthickness(md.mesh.elements(pos,:))= md.masstransport.spcthickness(md.mesh.elements(pos,:))-100;
     31md.masstransport.spcthickness(md.mesh.elements(pos,:))=md.masstransport.spcthickness(md.mesh.elements(pos,:))-100;
    3332posgre=pos;
    3433
  • TabularUnified issm/trunk-jpl/test/NightlyRun/test2002.py

    r26303 r26358  
    11#Test Name: EarthSlc
    22import numpy as np
    3 
    4 from MatlabFuncs import *
    53
    64from gmshplanet import *
     
    97from materials import *
    108from model import *
    11 from parameterize import *
    129from paterson import *
    1310from solve import *
    1411
    1512
    16 # Mesh earth
    17 #
    18 # NOTE: In MATLAB, we currently use cached mesh to account for differences in
    19 # mesh generated under Linux versus under macOS
    20 #
    2113md = model()
    2214md.mesh = gmshplanet('radius', 6.371012 * 1e3, 'resolution', 700.) # 700 km resolution mesh
     
    4133longe = atan2d(ye, xe)
    4234pos = np.where(late < -80)[0]
    43 md.masstransport.spcthickness[md.mesh.elements[pos]] = md.masstransport.spcthickness[md.mesh.elements[pos]] - 100
     35md.masstransport.spcthickness[md.mesh.elements[pos, :] - 1] = md.masstransport.spcthickness[md.mesh.elements[pos, :] - 1] - 100
    4436posant = pos
    4537
    4638# Greenland
    4739pos = np.where(np.logical_and.reduce((late > 60, late < 90, longe > -75, longe < -15)))[0]
    48 md.masstransport.spcthickness[md.mesh.elements[pos]] = md.masstransport.spcthickness[md.mesh.elements[pos]] - 100
     40md.masstransport.spcthickness[md.mesh.elements[pos, :] - 1] = md.masstransport.spcthickness[md.mesh.elements[pos, :] - 1] - 100
    4941posgre = pos
    5042
     
    6052
    6153icemask = np.ones((md.mesh.numberofvertices, ))
    62 icemask[md.mesh.elements[posant]] = -1
    63 icemask[md.mesh.elements[posgre]] = -1
     54# NOTE: Need to be careful here: when using multidimensional array elements to
     55# address a one-dimensional array in MATLAB, only first column is used
     56#
     57icemask[md.mesh.elements[posant][:, 0] - 1] = -1
     58icemask[md.mesh.elements[posgre][:, 0] - 1] = -1
    6459
    6560md.mask.ice_levelset = icemask
  • TabularUnified issm/trunk-jpl/test/NightlyRun/test2003.m

    r26303 r26358  
    33%mesh earth:
    44md=model;
    5 load ../Data/SlcTestMesh.mat;
    6 md.mesh=SlcMesh; %700 km resolution mesh
     5md.mesh=gmshplanet('radius',6.371012*10^3,'resolution',700.);
    76
    87%Geometry for the bed, arbitrary thickness of 1000:
     
    2423late=asind(ze./re);
    2524longe=atan2d(ye,xe);
     25
    2626%greenland
    2727pos=find(late>60 & late<90 & longe>-75 & longe<-15);
     
    3131%elastic loading from love numbers:
    3232md.solidearth.lovenumbers=lovenumbers('maxdeg',100);
    33 
    3433%}}}
    3534%mask:  {{{
     
    7069
    7170%Physics:
    72 md.transient.issmb=0; 
     71md.transient.issmb=0;
    7372md.transient.isstressbalance=0;
    7473md.transient.isthermal=0;
    7574md.transient.ismasstransport=1;
    7675md.transient.isslc=1;
    77  
     76
    7877md.timestepping.start_time=0;
    7978md.timestepping.time_step=1;
  • TabularUnified issm/trunk-jpl/test/NightlyRun/test2003.py

    r26303 r26358  
    11#Test Name: EarthSlc_rotationalFeedback
    22import numpy as np
    3 
    4 from socket import gethostname
    53
    64from gmshplanet import *
    75from gmtmask import *
    86from lovenumbers import *
     7from MatlabFuncs import *
    98from model import *
    109from paterson import *
     
    1211
    1312
    14 # Mesh earth
    15 #
    16 # NOTE: In MATLAB, we currently use cached mesh to account for differences in
    17 # mesh generated under Linux versus under macOS
    18 #
    1913md = model()
    2014md.mesh = gmshplanet('radius', 6.371012 * 1e3, 'resolution', 700.) # 700 km resolution mesh
    2115
    2216# Geometry for the bed, arbitrary thickness of 100
    23 md.geometry.bed = -1 * np.ones(md.mesh.numberofvertices)
     17md.geometry.bed = -1 * np.ones((md.mesh.numberofvertices, ))
    2418md.geometry.base = md.geometry.bed
    25 md.geometry.thickness = 1000 * np.ones(md.mesh.numberofvertices)
     19md.geometry.thickness = 1000 * np.ones((md.mesh.numberofvertices, ))
    2620md.geometry.surface = md.geometry.bed + md.geometry.thickness
    2721
     
    3832late = asind(ze / re)
    3933longe = atan2d(ye, xe)
     34
    4035# Greenland
    4136pos = np.where(np.logical_and.reduce((late > 60, late < 90, longe > -75, longe < -15)))[0]
    42 md.masstransport.spcthickness[md.mesh.elements[pos]] = md.masstransport.spcthickness[md.mesh.elements[pos]] - 1000
     37md.masstransport.spcthickness[md.mesh.elements[pos, :] - 1] = md.masstransport.spcthickness[md.mesh.elements[pos, :] - 1] - 1000
    4338posice = pos
    4439
     
    5045mask = gmtmask(md.mesh.lat, md.mesh.long)
    5146icemask = np.ones(md.mesh.numberofvertices)
    52 icemask[md.mesh.elements[posice]] = -1
     47icemask[md.mesh.elements[posice, :] - 1] = -1
    5348md.mask.ice_levelset = icemask
    5449oceanmask = -1 * np.ones(md.mesh.numberofvertices)
     
    10095md.solidearth.settings.rotation = 0
    10196md.solidearth.settings.viscous = 0
    102 md.cluster = generic('name', gethostname(), 'np', 3)
     97md.cluster = generic('name', oshostname(), 'np', 3)
    10398#md.verbose = verbose('111111111')
    10499md = solve(md, 'Transient')
     
    113108md.solidearth.settings.rotation = 1
    114109md.solidearth.settings.viscous = 0
    115 md.cluster = generic('name', gethostname(), 'np', 3)
     110md.cluster = generic('name', oshostname(), 'np', 3)
    116111#md.verbose = verbose('111111111')
    117112md = solve(md, 'Transient')
  • TabularUnified issm/trunk-jpl/test/NightlyRun/test2004.m

    r26296 r26358  
    7272%meshing parameters:  {{{
    7373hmin=500; hmax=700; hmin=hmin*1000; hmax=hmax*1000;
    74 tolerance=100; %tolerance of 100m on Earth position when mergin 3d meshes
     74tolerance=100; %tolerance of 100m on Earth position when merging 3d meshes
    7575threshold=5;
    7676defaultoptions={'KeepVertices',0,'MaxCornerAngle',0.0000000001,'NoBoundaryRefinement',1};
     
    269269                latGIS=delH(:,2);
    270270                delHGIS=delH(:,3);
    271                 % points=[longGIS,latGIS];
    272                 % index=delaunayn(points);
    273271                index=BamgTriangulate(longGIS, latGIS);
    274272                lat=md.mesh.lat;
     
    277275                long(pos)=long(pos)-360;
    278276                delHGIS=InterpFromMeshToMesh2d(index,longGIS,latGIS,delHGIS,long,lat);
    279                 delHGISe=delHGIS(md.mesh.elements)*[1;1;1]/3;
    280277
    281278                delH=textread('../Data/GLA_delH_trend_15regions.txt');
     
    283280                latGLA=delH(:,2);
    284281                delHGLA=sum(delH(:,3:end),2);
    285                 % points=[longGLA,latGLA];
    286                 % index=delaunayn(points);
    287282                index=BamgTriangulate(longGLA, latGLA);
    288283                lat=md.mesh.lat;
     
    291286                long(pos)=long(pos)-360;
    292287                delHGLA=InterpFromMeshToMesh2d(index,longGLA,latGLA,delHGLA,long,lat);
    293                 delHGLAe=delHGLA(md.mesh.elements)*[1;1;1]/3;
    294288
    295289                pos=find(delHGIS);
    296                 md.masstransport.spcthickness(pos)= md.masstransport.spcthickness(pos)-delHGIS(pos)/100;
     290                md.masstransport.spcthickness(pos) = md.masstransport.spcthickness(pos)-delHGIS(pos)/100;
    297291                pos=find(delHGLA);
    298292                md.masstransport.spcthickness(pos)= md.masstransport.spcthickness(pos)-delHGLA(pos)/100;
     
    376370
    377371% }}}
    378 %Solve Sea-level equation on Earth only:  {{{
     372%Solve Sea-level eqEricuation on Earth only:  {{{
    379373md=sl.earth; %we don't do computations on ice sheets or land.
    380374
     
    426420md.solidearth.settings.elastic=0;
    427421md.solidearth.settings.rotation=0;
     422md.solidearth.settings.viscous=0;
    428423md.solidearth.requested_outputs= {'default',...
    429424        'DeltaIceThickness','Sealevel','SealevelUGrd',...
     
    436431md.solidearth.settings.elastic=0;
    437432md.solidearth.settings.rotation=0;
     433md.solidearth.settings.viscous=0;
    438434md=solve(md,'Transient');
    439435Sselfattraction=md.results.TransientSolution.Sealevel;
     
    443439md.solidearth.settings.elastic=1;
    444440md.solidearth.settings.rotation=0;
     441md.solidearth.settings.viscous=0;
    445442md=solve(md,'Transient');
    446443Selastic=md.results.TransientSolution.Sealevel;
     
    450447md.solidearth.settings.elastic=1;
    451448md.solidearth.settings.rotation=1;
     449md.solidearth.settings.viscous=0;
    452450md=solve(md,'Transient');
    453451Srotation=md.results.TransientSolution.Sealevel;
  • TabularUnified issm/trunk-jpl/test/NightlyRun/test2004.py

    r25763 r26358  
    114114hmin = hmin * 1000
    115115hmax = hmax * 1000
    116 tolerance = 100
     116tolerance = 100 # tolerance of 100m on Earth position when merging 3d meshes
    117117threshold = 5
    118118defaultoptions = [
     
    145145    # Vertex connectivity
    146146    md.mesh.vertexconnectivity = NodeConnectivity(md.mesh.elements, md.mesh.numberofvertices)
     147
    147148    # Add model to sl icecaps
    148149    sl.addicecap(md)
     
    178179        print('      reading bedrock')
    179180        md.geometry.bed = -np.ones((md.mesh.numberofvertices, ))
    180     #}}}
    181 
    182     # SLR #{{{
     181        md.geometry.base = md.geometry.bed
     182        md.geometry.thickness = 1000 * np.ones((md.mesh.numberofvertices, ))
     183        md.geometry.surface = md.geometry.bed + md.geometry.thickness
     184    #}}}
     185
     186    # SLC #{{{
    183187    if bas.iscontinentany('antarctica'):
    184188        if testagainst2002:
    185189            # TODO: Check if the following works as expected: 'pos' is empty, so nothing is assigned to 'md.solidearth.surfaceload.icethicknesschange[pos]'
    186             md.solidearth.surfaceload.icethicknesschange = np.zeros((md.mesh.numberofelements, ))
     190            md.masstransport.spcthickness = np.zeros((md.mesh.numberofvertices, ))
    187191            # Antarctica
    188192            late = np.sum(md.mesh.lat[md.mesh.elements - 1], axis=1) / 3
     
    190194            pos = np.where(late < -85)[0]
    191195            ratio = 0.225314032985172 / 0.193045366574523
    192             md.solidearth.surfaceload.icethicknesschange[pos] = -100 * ratio
     196            md.masstransport.spcthickness[md.mesh.elements[pos]] = md.masstransport.spcthickness[md.mesh.elements[pos]] - 100 * ratio
    193197        else:
    194198            delH = np.loadtxt('../Data/AIS_delH_trend.txt')
     
    201205            pos = np.where(longe > 360)[0]
    202206            longe[pos] = longe[pos] - 360
    203             delHAIS = InterpFromMesh2d(index, longAIS, latAIS, delHAIS, longe, late)  # NOTE: Compare to corresponding output under MATLAB to understand why we offset triangle indices by 1 (only caught because Triangle.cpp was producing triangles with negative areas)
     207            delHAIS = InterpFromMesh2d(index, longAIS, latAIS, delHAIS, longe, late) # NOTE: Compare to corresponding output under MATLAB to understand why we offset triangle indices by 1 (only caught because Triangle.cpp was producing triangles with negative areas)
    204208            northpole = find_point(md.mesh.long, md.mesh.lat, 0, 90)
    205209            delHAIS[northpole] = 0
    206             md.solidearth.surfaceload.icethicknesschange = np.mean(delHAIS[md.mesh.elements - 1], axis=1) / 100
    207 
    208         md.solidearth.initialsealevel = np.zeros((md.mesh.numberofvertices, ))
    209 
    210         md.dsl.global_average_thermostatic_sea_level_change = np.zeros((2, 1))
    211         md.dsl.sea_surface_height_change_above_geoid = np.zeros((md.mesh.numberofvertices + 1, 1))
    212         md.dsl.sea_water_pressure_change_at_sea_floor = np.zeros((md.mesh.numberofvertices + 1, 1))
     210            md.masstransport.spcthickness = delHAIS / 100
     211
     212        md.initialization.sealevel = np.zeros((md.mesh.numberofvertices, ))
     213
     214        md.dsl.global_average_thermosteric_sea_level = np.zeros((2, 1))
     215        md.dsl.sea_surface_height_above_geoid = np.zeros((md.mesh.numberofvertices + 1, 1))
     216        md.dsl.sea_water_pressure_at_sea_floor = np.zeros((md.mesh.numberofvertices + 1, 1))
    213217    #}}}
    214218
     
    226230# Parameterize continents #{{{
    227231for ind in sl.basinindx('continent', ['hemisphereeast', 'hemispherewest']):
    228     print("Masks for basin {}".format(sl.icecaps[ind].miscellaneous.name))
     232    print('Masks for basin {}'.format(sl.icecaps[ind].miscellaneous.name))
    229233    md = sl.icecaps[ind]
    230234    bas = sl.basins[ind]
     
    283287    #}}}
    284288
    285     # SLR loading/calibration #{{{
    286     md.solidearth.surfaceload.icethicknesschange = np.zeros((md.mesh.numberofelements, ))
     289    # SLC loading/calibration #{{{
     290    md.masstransport.spcthickness = np.zeros((md.mesh.numberofvertices, ))
    287291
    288292    if testagainst2002:
     
    293297        pos = np.where(np.logical_and.reduce((late > 70, late < 80, longe > -60, longe < -30)))[0]
    294298        ratio = .3823 / .262344
     299        md.masstransport.spcthickness[md.mesh.elements[pos]] = md.masstransport.spcthickness[md.mesh.elements[pos]] - 100 * ratio
    295300
    296301        # Correct mask
     
    307312        pos = np.where(longe > 360)[0]
    308313        longe[pos] = longe[pos] - 360
    309         delHGIS = InterpFromMeshToMesh2d(index, longGIS, latGIS, delHGIS, longe, late) # NOTE: Compare to corresponding ouptut under MATLAB to understand why we offset triangle indices by 1 (only caught because Triangle.cpp was producing triangles with negative areas)
    310         delHGISe = np.mean(delHGIS[md.mesh.elements - 1], axis=1).flatten()
     314        delHGIS = InterpFromMeshToMesh2d(index, longGIS, latGIS, delHGIS, longe, late)
    311315
    312316        delH = np.loadtxt('../Data/GLA_delH_trend_15regions.txt')
     
    319323        pos = np.where(longe > 360)[0]
    320324        longe[pos] = longe[pos] - 360
    321         delHGLA = InterpFromMeshToMesh2d(index, longGLA, latGLA, delHGLA, longe, late) # NOTE: Compare to corresponding ouptut under MATLAB to understand why we offset triangle indices by 1 (only caught because Triangle.cpp was producing triangles with negative areas)
    322         delHGLAe = np.mean(delHGLA[md.mesh.elements - 1], axis=1).flatten()
    323 
    324         pos = np.nonzero(delHGISe)[0]
    325         md.solidearth.surfaceload.icethicknesschange[pos] = delHGISe[pos] / 100
    326         pos = np.nonzero(delHGLAe)[0]
    327         md.solidearth.surfaceload.icethicknesschange[pos] = delHGLAe[pos] / 100
     325        delHGLA = InterpFromMeshToMesh2d(index, longGLA, latGLA, delHGLA, longe, late)
     326
     327        # NOTE: For some reason, cannot apply pos to multiple arrays in a
     328        #       singlelike we might do in MATLAB. Instead, we iterate over
     329        #       elements of pos.
     330        #
     331        pos = np.nonzero(delHGIS)[0]
     332        for p in pos:
     333            md.masstransport.spcthickness[p] = md.masstransport.spcthickness[p] - delHGIS[p] / 100
     334        pos = np.nonzero(delHGLA)[0]
     335        for p in pos:
     336            md.masstransport.spcthickness[p] = md.masstransport.spcthickness[p] - delHGLA[p] / 100
    328337
    329338        # Adjust mask accordingly
    330         pos = np.nonzero(md.solidearth.surfaceload.icethicknesschange)[0]
    331         flags = np.zeros((md.mesh.numberofvertices, ))
    332         flags[md.mesh.elements[pos, :] - 1] = 1
    333         pos = np.nonzero(flags)[0]
     339        pos = np.nonzero(md.masstransport.spcthickness)[0]
    334340        md.mask.ice_levelset[pos] = -1
    335341        md.mask.ocean_levelset[pos] = 1
    336342
    337     md.solidearth.initialsealevel = np.zeros((md.mesh.numberofvertices, ))
    338 
    339     md.dsl.global_average_thermostatic_sea_level_change = np.zeros((2, 1))
    340     md.dsl.sea_surface_height_change_above_geoid = np.zeros((md.mesh.numberofvertices + 1, 1))
    341     md.dsl.sea_water_pressure_change_at_sea_floor = np.zeros((md.mesh.numberofvertices + 1, 1))
    342     #}}}
     343    md.initialization.sealevel = np.zeros((md.mesh.numberofvertices, ))
     344
     345    md.dsl.global_average_thermosteric_sea_level = np.zeros((2, 1))
     346    md.dsl.sea_surface_height_above_geoid = np.zeros((md.mesh.numberofvertices + 1, 1))
     347    md.dsl.sea_water_pressure_at_sea_floor = np.zeros((md.mesh.numberofvertices + 1, 1))
     348    #}}}
     349
    343350    # Geometry #{{{
    344351    di = md.materials.rho_ice / md.materials.rho_water
    345352    md.geometry.bed = -np.ones((md.mesh.numberofvertices, ))
     353    md.geometry.base = md.geometry.bed
     354    md.geometry.thickness = 1000 * np.ones((md.mesh.numberofvertices, ))
     355    md.geometry.surface = md.geometry.bed + md.geometry.thickness
    346356    #}}}
    347357    # Materials #{{{
     
    375385sl.transfer('mask.ocean_levelset')
    376386sl.transfer('geometry.bed')
     387sl.transfer('geometry.surface')
     388sl.transfer('geometry.thickness')
     389sl.transfer('geometry.base')
    377390sl.transfer('mesh.lat')
    378391sl.transfer('mesh.long')
    379 sl.transfer('solidearth.surfaceload.icethicknesschange') #
    380 sl.transfer('solidearth.initialsealevel')
    381 sl.transfer('dsl.sea_surface_height_change_above_geoid')
    382 sl.transfer('dsl.sea_water_pressure_change_at_sea_floor')
     392sl.transfer('masstransport.spcthickness') #
     393sl.transfer('initialization.sealevel')
     394sl.transfer('dsl.sea_surface_height_above_geoid')
     395sl.transfer('dsl.sea_water_pressure_at_sea_floor')
    383396
    384397# Radius
     
    398411
    399412# Solve Sea-level equation on Earth only #{{{
    400 md = sl.earth #we don't do computations on ice sheets or land
     413md = sl.earth # we don't do computations on ice sheets or land
    401414
    402415#Materials
    403 md.materials=materials('hydro')
     416md.materials = materials('hydro')
    404417
    405418# Elastic loading from love numbers
     
    411424
    412425# New stuff
    413 md.dsl.global_average_thermosteric_sea_level_change = np.array([[(1.1 + .38)], [0]]) # steric + water storage AR5
     426md.dsl.global_average_thermosteric_sea_level = np.array([[(1.1 + .38)], [0]]) # steric + water storage AR5
    414427
    415428# Solutuion parameters
    416429md.solidearth.settings.reltol = np.nan
    417430md.solidearth.settings.abstol = 1e-3
    418 md.solidearth.settings.computesealevelchange = 1
     431md.solidearth.settings.sealevelloading = 1
     432md.solidearth.settings.isgrd = 1
     433md.solidearth.settings.ocean_area_scaling = 1
     434md.solidearth.settings.grdmodel = 1
    419435md.timestepping.time_step = 1
     436
     437# Physics
     438md.transient.issmb = 0
     439md.transient.isstressbalance = 0
     440md.transient.isthermal = 0
     441md.transient.ismasstransport = 1
     442md.transient.isslc = 1
     443
     444# Initializations
     445md.basalforcings.groundedice_melting_rate = np.zeros((md.mesh.numberofvertices,))
     446md.basalforcings.floatingice_melting_rate = np.zeros((md.mesh.numberofvertices,))
     447md.initialization.vx = np.zeros((md.mesh.numberofvertices,))
     448md.initialization.vy = np.zeros((md.mesh.numberofvertices,))
     449md.initialization.sealevel = np.zeros((md.mesh.numberofvertices,))
     450md.initialization.bottompressure = np.zeros((md.mesh.numberofvertices,))
     451md.initialization.dsl = np.zeros((md.mesh.numberofvertices,))
     452md.initialization.str = 0
     453md.smb.mass_balance = np.zeros((md.mesh.numberofvertices,))
    420454
    421455# Max number of iterations reverted back to 10 (i.e. the original default value)
     
    423457
    424458# Eustatic run:
    425 md.solidearth.settings.rigid = 0
     459md.solidearth.settings.selfattraction = 0
    426460md.solidearth.settings.elastic = 0
    427461md.solidearth.settings.rotation = 0
     462md.solidearth.settings.viscous = 0
    428463md.solidearth.requested_outputs = [
    429464    'default',
    430     'SurfaceloadIceThicknessChange',
     465    'DeltaIceThickness',
    431466    'Sealevel',
    432     'SealevelRSLRate',
    433     'SealevelriseCumDeltathickness',
    434     'SealevelNEsaRate',
    435     'SealevelUEsaRate',
    436     'NGiaRate',
    437     'UGiaRate',
    438     'SealevelEustaticMask',
    439     'SealevelEustaticOceanMask'
     467    'SealevelUGrd',
     468    'SealevelchangeBarystaticMask',
     469    'SealevelchangeBarystaticOceanMask',
    440470]
    441 md = solve(md, 'Sealevelrise')
    442 Seustatic = md.results.SealevelriseSolution.Sealevel
    443 
    444 # Eustatic + rigid run
    445 md.solidearth.settings.rigid = 1
     471md = solve(md, 'Transient')
     472Seustatic = md.results.TransientSolution.Sealevel
     473
     474# Eustatic + selfattraction run
     475md.solidearth.settings.selfattraction = 1
    446476md.solidearth.settings.elastic = 0
    447477md.solidearth.settings.rotation = 0
    448 md = solve(md, 'Sealevelrise')
    449 Srigid = md.results.SealevelriseSolution.Sealevel
    450 
    451 # Eustatic + rigid + elastic run
    452 md.solidearth.settings.rigid = 1
     478md.solidearth.settings.viscous = 0
     479md = solve(md, 'Transient')
     480Sselfattraction = md.results.TransientSolution.Sealevel
     481
     482# Eustatic + selfattraction + elastic run
     483md.solidearth.settings.selfattraction = 1
    453484md.solidearth.settings.elastic = 1
    454485md.solidearth.settings.rotation = 0
    455 md = solve(md, 'Sealevelrise')
    456 Selastic = md.results.SealevelriseSolution.Sealevel
    457 
    458 # Eustatic + rigid + elastic + rotation run
    459 md.solidearth.settings.rigid = 1
     486md.solidearth.settings.viscous = 0
     487md = solve(md, 'Transient')
     488Selastic = md.results.TransientSolution.Sealevel
     489
     490# Eustatic + selfattraction + elastic + rotation run
     491md.solidearth.settings.selfattraction = 1
    460492md.solidearth.settings.elastic = 1
    461493md.solidearth.settings.rotation = 1
    462 md = solve(md, 'Sealevelrise')
    463 Srotation = md.results.SealevelriseSolution.Sealevel
     494md.solidearth.settings.viscous = 0
     495md = solve(md, 'Transient')
     496Srotation = md.results.TransientSolution.Sealevel
    464497
    465498#Fields and tolerances to track changes
    466499field_names = ['Eustatic', 'Rigid', 'Elastic', 'Rotation']
    467500field_tolerances = [1e-13, 1e-13, 1e-13, 1e-13]
    468 field_values = [Seustatic, Srigid, Selastic, Srotation]
     501field_values = [Seustatic, Sselfattraction, Selastic, Srotation]
  • TabularUnified issm/trunk-jpl/test/NightlyRun/test2005.m

    r26296 r26358  
    33%mesh earth:
    44md=model;
    5 load ../Data/SlcTestMesh.mat;
    6 md.mesh=SlcMesh; %700 km resolution mesh
     5md.mesh=gmshplanet('radius',6.371012*10^3,'resolution',700.);
    76
    87%Geometry for the bed, arbitrary thickness of 100:
  • TabularUnified issm/trunk-jpl/test/NightlyRun/test2005.py

    r26054 r26358  
    1616md.mesh = gmshplanet('radius', 6.371012 * 1e3, 'resolution', 700.) #700 km resolution mesh
    1717
    18 # Parameterize solidearth solution
     18# Geometry for the bed, arbitrary thickness of 100
     19md.geometry.bed = np.zeros((md.mesh.numberofvertices, ))
     20md.geometry.base = md.geometry.bed
     21md.geometry.thickness = 100 * np.ones((md.mesh.numberofvertices, ))
     22md.geometry.surface = md.geometry.bed + md.geometry.thickness
     23
    1924# Solidearth loading #{{{
    20 md.solidearth.surfaceload.icethicknesschange = np.zeros((md.mesh.numberofelements, 1))
    21 md.solidearth.initialsealevel = np.zeros((md.mesh.numberofvertices, 1))
    22 md.dsl.global_average_thermosteric_sea_level_change = np.zeros((2, 1))
    23 md.dsl.sea_surface_height_change_above_geoid = np.zeros((md.mesh.numberofvertices + 1, 1))
    24 md.dsl.sea_water_pressure_change_at_sea_floor = np.zeros((md.mesh.numberofvertices + 1, 1))
     25md.masstransport.spcthickness = np.append(md.geometry.thickness, 0)
     26md.smb.mass_balance = np.zeros((md.mesh.numberofvertices, ))
     27# Antarctica
     28xe = md.mesh.x[md.mesh.elements - 1].sum(axis=1) / 3
     29ye = md.mesh.y[md.mesh.elements - 1].sum(axis=1) / 3
     30ze = md.mesh.z[md.mesh.elements - 1].sum(axis=1) / 3
     31re = pow((pow(xe, 2) + pow(ye, 2) + pow(ze, 2)), 0.5)
    2532
    26 # Antarctica
    27 late = md.mesh.lat[md.mesh.elements - 1].sum(axis=1) / 3
    28 longe = md.mesh.long[md.mesh.elements - 1].sum(axis=1) / 3
     33late = asind(ze / re)
     34longe = atan2d(ye, xe)
    2935pos = np.where(late < -80)[0]
    30 md.solidearth.surfaceload.icethicknesschange[pos] = -100
     36md.masstransport.spcthickness[md.mesh.elements[pos, :] - 1] = md.masstransport.spcthickness[md.mesh.elements[pos, :] - 1] - 100
     37posant = pos
    3138# Greenland
    32 pos = np.where(np.logical_and.reduce((late > 70, late < 80, longe > -60, longe < -30)))[0]
    33 md.solidearth.surfaceload.icethicknesschange[pos] = -100
     39pos = np.where(np.logical_and.reduce((late > 60, late < 90, longe > -75, longe < -15)))[0]
     40md.masstransport.spcthickness[md.mesh.elements[pos, :] - 1] = md.masstransport.spcthickness[md.mesh.elements[pos, :] - 1] - 100
     41posgre = pos
    3442
    3543# Elastic loading from love numbers
    36 md.solidearth.lovenumbers = lovenumbers('maxdeg', 100)
     44md.solidearth.lovenumbers = lovenumbers('maxdeg', 1000)
    3745#}}}
    3846
    3947# Mask #{{{
    4048mask = gmtmask(md.mesh.lat, md.mesh.long)
     49oceanmask = -1 * np.ones((md.mesh.numberofvertices, 1))
     50pos = np.where(mask == 0)[0]
     51oceanmask[pos] = 1
     52
    4153icemask = np.ones((md.mesh.numberofvertices, 1))
    42 pos = np.where(mask == 0)[0]
    43 icemask[pos] = -1
    44 pos = np.where(mask[md.mesh.elements - 1].sum(axis=1) < 3)[0]
    45 icemask[md.mesh.elements[pos, :] - 1] = -1
     54# NOTE: Need to be careful here: when addressing with multidimensional array in
     55# MATLAB, only first column of values are used as indices
     56#
     57icemask[md.mesh.elements[posant][:,0] - 1] = -1
     58icemask[md.mesh.elements[posgre][:,0] - 1] = -1
     59
    4660md.mask.ice_levelset = icemask
    47 md.mask.ocean_levelset = -icemask
     61md.mask.ocean_levelset = oceanmask
    4862
    49 # Make sure that the elements that have loads are fully grounded
    50 pos = np.nonzero(md.solidearth.surfaceload.icethicknesschange)[0]
    51 md.mask.ocean_levelset[md.mesh.elements[pos, :] - 1] = 1
     63# Time stepping
     64md.timestepping.start_time = 0
     65md.timestepping.time_step = 1
     66md.timestepping.final_time = 10
    5267
    53 # Make sure wherever there is an ice load, that the mask is set to ice:
    54 #pos = np.nonzero(md.solidearth.surfaceload.icethicknesschange)[0] # TODO: Do we need to do this twice?
    55 md.mask.ice_levelset[md.mesh.elements[pos, :] - 1] = -1
    56 # }}}
    57 
    58 md.solidearth.settings.ocean_area_scaling = 0
    59 
    60 # Geometry for the bed; arbitrary
    61 md.geometry.bed = -np.ones((md.mesh.numberofvertices, 1))
     68# Masstransport
     69md.basalforcings.groundedice_melting_rate = np.zeros((md.mesh.numberofvertices, ))
     70md.basalforcings.floatingice_melting_rate = np.zeros((md.mesh.numberofvertices, ))
     71md.initialization.vx = np.zeros((md.mesh.numberofvertices, ))
     72md.initialization.vy = np.zeros((md.mesh.numberofvertices, ))
     73md.initialization.sealevel = np.zeros((md.mesh.numberofvertices, ))
     74md.initialization.str = 0
    6275
    6376# Materials
     
    6881
    6982# Solution parameters
     83md.cluster.np = 3
    7084md.solidearth.settings.reltol = np.nan
    7185md.solidearth.settings.abstol = 1e-3
    72 md.solidearth.settings.computesealevelchange = 1
     86md.solidearth.settings.sealevelloading = 1
     87md.solidearth.settings.isgrd = 1
     88md.solidearth.settings.ocean_area_scaling = 0
     89md.solidearth.settings.grdmodel = 1
    7390
    74 # Max number of iterations reverted back to 10 (i.e. the original default value)
    75 md.solidearth.settings.maxiter = 10
    76 
    77 # Eustatic + rigid + elastic + rotation run
    78 md.solidearth.settings.rigid = 1
     91md.solidearth.settings.selfattraction = 1
    7992md.solidearth.settings.elastic = 1
    8093md.solidearth.settings.rotation = 1
     94md.solidearth.settings.viscous = 0
    8195
    82 # Transient settings
    83 md.timestepping.start_time = 0
    84 md.timestepping.final_time = 10
    85 md.timestepping.time_step = 1
    86 md.transient.isslc = 1
     96# Physics
    8797md.transient.issmb = 0
    88 md.transient.ismasstransport = 0
    8998md.transient.isstressbalance = 0
    9099md.transient.isthermal = 0
    91 dh = np.asarray(md.solidearth.surfaceload.icethicknesschange).T
    92 deltathickness = np.zeros((md.mesh.numberofelements + 1, 10))
    93 for i in range(10):
    94     deltathickness[0:-1, i] = dh * (i + 1)
    95 deltathickness[-1, :] = np.arange(0, 10, 1)
    96 md.solidearth.surfaceload.icethicknesschange = deltathickness
     100md.transient.ismasstransport = 1
     101md.transient.isslc = 1
     102md.solidearth.requested_outputs = ['Sealevel']
    97103
     104dh = md.masstransport.spcthickness
     105deltathickness = np.zeros((md.mesh.numberofvertices + 1, 10 + 1)) # NOTE: Need to add another row as it is added in loop in MATLAB, which causes a RuntimeError in Python
     106for i in range(10 + 1):
     107    deltathickness[0:-1, i] = md.geometry.thickness + dh[0:-1] * i
     108deltathickness[-1, :] = np.arange(0, 10 + 1, 1)
     109md.masstransport.spcthickness = deltathickness
    98110# Hack
    99111md.geometry.surface = np.zeros((md.mesh.numberofvertices, 1))
     
    110122Seus10 = md.results.TransientSolution[10 - 1].Bslc
    111123
    112 #Fields and tolerances to track changes
     124# Fields and tolerances to track changes
    113125field_names = ['Sealevel1', 'Sealevel5', 'Sealevel10', 'Seustatic10']
    114126field_tolerances = [1e-13, 1e-13, 1e-13, 1e-13]
  • TabularUnified issm/trunk-jpl/test/NightlyRun/test2006.m

    r26296 r26358  
    33%mesh earth:
    44md=model;
    5 load ../Data/SlcTestMesh.mat;
    6 md.mesh=SlcMesh; %700 km resolution mesh
     5md.mesh=gmshplanet('radius',6.371012*10^3,'resolution',700.);
    76
    87%Geometry for the bed, arbitrary thickness of 100:
  • TabularUnified issm/trunk-jpl/test/NightlyRun/test2006.py

    r26054 r26358  
    77from lovenumbers import *
    88from materials import *
     9from MatlabFuncs import *
    910from model import *
    1011from nodalvalue import *
     
    1920md.mesh = gmshplanet('radius', 6.371012 * 1e3, 'resolution', 700.) #700 km resolution mesh
    2021
    21 # Parameterize solidearth solution
     22# Geometry for the bed, arbitrary thickness of 100
     23md.geometry.bed = np.zeros((md.mesh.numberofvertices, ))
     24md.geometry.base = md.geometry.bed
     25md.geometry.thickness = 100 * np.ones((md.mesh.numberofvertices, ))
     26md.geometry.surface = md.geometry.bed + md.geometry.thickness
     27
    2228# Solidearth loading #{{{
    23 md.solidearth.surfaceload.icethicknesschange = np.zeros((md.mesh.numberofelements, 1))
    24 md.solidearth.initialsealevel = np.zeros((md.mesh.numberofvertices, 1))
    25 md.dsl.global_average_thermosteric_sea_level_change = np.zeros((2, 1))
    26 md.dsl.sea_surface_height_change_above_geoid = np.zeros((md.mesh.numberofvertices + 1, 1))
    27 md.dsl.sea_water_pressure_change_at_sea_floor = np.zeros((md.mesh.numberofvertices + 1, 1))
    28 
     29md.masstransport.spcthickness = np.append(md.geometry.thickness, 0)
     30md.smb.mass_balance = np.zeros((md.mesh.numberofvertices, ))
    2931# Antarctica
    30 late = md.mesh.lat[md.mesh.elements - 1].sum(axis=1) / 3
    31 longe = md.mesh.long[md.mesh.elements - 1].sum(axis=1) / 3
     32xe = md.mesh.x[md.mesh.elements - 1].sum(axis=1) / 3
     33ye = md.mesh.y[md.mesh.elements - 1].sum(axis=1) / 3
     34ze = md.mesh.z[md.mesh.elements - 1].sum(axis=1) / 3
     35re = pow((pow(xe, 2) + pow(ye, 2) + pow(ze, 2)), 0.5)
     36
     37late = asind(ze / re)
     38longe = atan2d(ye, xe)
    3239pos = np.where(late < -80)[0]
    33 md.solidearth.surfaceload.icethicknesschange[pos] = -100
     40md.masstransport.spcthickness[md.mesh.elements[pos, :] - 1] = md.masstransport.spcthickness[md.mesh.elements[pos, :] - 1] - 100
     41posant = pos
    3442# Greenland
    35 pos = np.where(np.logical_and.reduce((late > 70, late < 80, longe > -60, longe < -30)))[0]
    36 md.solidearth.surfaceload.icethicknesschange[pos] = -100
     43pos = np.where(np.logical_and.reduce((late > 60, late < 90, longe > -75, longe < -15)))[0]
     44md.masstransport.spcthickness[md.mesh.elements[pos, :] - 1] = md.masstransport.spcthickness[md.mesh.elements[pos, :] - 1] - 100
     45posgre = pos
    3746
    3847# Elastic loading from love numbers
     
    4251# Mask #{{{
    4352mask = gmtmask(md.mesh.lat, md.mesh.long)
     53oceanmask = -1 * np.ones((md.mesh.numberofvertices, 1))
     54pos = np.where(mask == 0)[0]
     55oceanmask[pos] = 1
     56
    4457icemask = np.ones((md.mesh.numberofvertices, 1))
    45 pos = np.where(mask == 0)[0]
    46 icemask[pos] = -1
    47 pos = np.where(mask[md.mesh.elements - 1].sum(axis=1) < 3)[0]
    48 icemask[md.mesh.elements[pos, :] - 1] = -1
     58# NOTE: Need to be careful here: when addressing with multidimensional array in
     59# MATLAB, only first column of values are used as indices
     60#
     61icemask[md.mesh.elements[posant][:,0] - 1] = -1
     62icemask[md.mesh.elements[posgre][:,0] - 1] = -1
     63
    4964md.mask.ice_levelset = icemask
    50 md.mask.ocean_levelset = -icemask
    51 
    52 # Make sure that the elements that have loads are fully grounded
    53 pos = np.nonzero(md.solidearth.surfaceload.icethicknesschange)[0]
    54 md.mask.ocean_levelset[md.mesh.elements[pos, :] - 1] = 1
    55 
    56 # Make sure wherever there is an ice load, that the mask is set to ice:
    57 #pos = np.nonzero(md.solidearth.surfaceload.icethicknesschange)[0] # TODO: Do we need to do this twice?
    58 md.mask.ice_levelset[md.mesh.elements[pos, :] - 1] = -1
    59 # }}}
    60 
    61 md.solidearth.settings.ocean_area_scaling = 0
    62 
    63 # Geometry for the bed; arbitrary
    64 md.geometry.bed = -np.ones((md.mesh.numberofvertices, 1))
     65md.mask.ocean_levelset = oceanmask
     66
     67# Time stepping
     68md.timestepping.start_time = 0
     69md.timestepping.time_step = 1
     70md.timestepping.final_time = 10
     71
     72# Masstransport
     73md.basalforcings.groundedice_melting_rate = np.zeros((md.mesh.numberofvertices, ))
     74md.basalforcings.floatingice_melting_rate = np.zeros((md.mesh.numberofvertices, ))
     75md.initialization.vx = np.zeros((md.mesh.numberofvertices, ))
     76md.initialization.vy = np.zeros((md.mesh.numberofvertices, ))
     77md.initialization.sealevel = np.zeros((md.mesh.numberofvertices, ))
     78md.initialization.str = 0
    6579
    6680# Materials
     
    7185
    7286# Solution parameters
     87md.cluster.np = 3
    7388md.solidearth.settings.reltol = np.nan
    7489md.solidearth.settings.abstol = 1e-3
    75 md.solidearth.settings.computesealevelchange = 1
    76 
    77 # Max number of iterations reverted back to 10 (i.e. the original default value)
    78 md.solidearth.settings.maxiter = 10
    79 
    80 # Eustatic + rigid + elastic + rotation run
    81 md.solidearth.settings.rigid = 1
     90md.solidearth.settings.sealevelloading = 1
     91md.solidearth.settings.isgrd = 1
     92md.solidearth.settings.ocean_area_scaling = 0
     93md.solidearth.settings.grdmodel = 1
     94
     95md.solidearth.settings.selfattraction = 1
    8296md.solidearth.settings.elastic = 1
    8397md.solidearth.settings.rotation = 1
    84 
    85 # Transient settings
    86 md.timestepping.start_time = 0
    87 md.timestepping.final_time = 10
    88 md.timestepping.time_step = 1
    89 md.transient.isslc = 1
     98md.solidearth.settings.viscous = 0
     99
     100# Physics
    90101md.transient.issmb = 0
    91 md.transient.ismasstransport = 0
    92102md.transient.isstressbalance = 0
    93103md.transient.isthermal = 0
    94 dh = np.asarray(md.solidearth.surfaceload.icethicknesschange).T
    95 deltathickness = np.zeros((md.mesh.numberofelements + 1, 10))
    96 for i in range(10):
    97     deltathickness[0:-1, i] = dh * (i + 1)
    98 deltathickness[-1, :] = np.arange(0, 10, 1)
    99 md.solidearth.surfaceload.icethicknesschange = deltathickness
     104md.transient.ismasstransport = 1
     105md.transient.isslc = 1
     106md.solidearth.requested_outputs = ['Sealevel']
     107
     108dh = md.masstransport.spcthickness
     109deltathickness = np.zeros((md.mesh.numberofvertices + 1, 10 + 1)) # NOTE: Need to add another row as it is added in loop in MATLAB, which causes a RuntimeError in Python
     110for i in range(10 + 1):
     111    deltathickness[0:-1, i] = md.geometry.thickness + dh[0:-1] * i
     112deltathickness[-1, :] = np.arange(0, 10 + 1, 1)
     113md.masstransport.spcthickness = deltathickness
    100114
    101115# Hack
     
    109123npart = 1
    110124nt = 1
    111 partition = -np.ones((md.mesh.numberofelements, 1))
     125partition = -1 * np.ones((md.mesh.numberofelements, 1))
    112126pos = np.where(late < -80)[0]
    113127partition[pos] = 0
  • TabularUnified issm/trunk-jpl/test/NightlyRun/test2007.m

    r26296 r26358  
    33%mesh earth:
    44md=model;
    5 load ../Data/SlcTestMesh.mat;
    6 md.mesh=SlcMesh; %700 km resolution mesh
     5md.mesh=gmshplanet('radius',6.371012*10^3,'resolution',700.);
    76
    87%Geometry for the bed, arbitrary
     
    5049md.solidearth.settings.horiz=1;
    5150
    52 %Physics:
     51%Physics: bary
    5352md.transient.issmb=0;
    5453md.transient.isstressbalance=0;
  • TabularUnified issm/trunk-jpl/test/NightlyRun/test2008.m

    r26296 r26358  
    33%mesh earth:
    44md=model;
    5 load ../Data/SlcTestMesh.mat;
    6 md.mesh=SlcMesh; %700 km resolution mesh
     5md.mesh=gmshplanet('radius',6.371012*10^3,'resolution',700.);
    76
    87%Geometry for the bed, arbitrary thickness of 100:
  • TabularUnified issm/trunk-jpl/test/NightlyRun/test2010.m

    r26296 r26358  
    33%mesh earth:
    44md=model;
    5 load ../Data/SlcTestMesh.mat;
    6 md.mesh=SlcMesh; %700 km resolution mesh
     5md.mesh=gmshplanet('radius',6.371012*10^3,'resolution',700.);
    76
    8 %Geometry for the bed, arbitrary thickness of 1000:
     7%Geometry for the bed, arbitrary thickness of 100:
    98md.geometry.bed=-ones(md.mesh.numberofvertices,1);
    109md.geometry.base=md.geometry.bed;
     
    1211md.geometry.surface=md.geometry.bed+md.geometry.thickness;
    1312
    14 
    1513%parameterize slc solution:
    1614%solidearth loading:  {{{
    1715md.masstransport.spcthickness=[md.geometry.thickness;0];
    1816md.smb.mass_balance=zeros(md.mesh.numberofvertices,1);
    19 
    2017
    2118xe=md.mesh.x(md.mesh.elements)*[1;1;1]/3;
     
    4643md.mask.ocean_levelset=oceanmask;
    4744
    48 % use model representation of ocen area (not the true area)
     45% use model representation of ocean area (not the true area)
    4946md.solidearth.settings.ocean_area_scaling = 0;
    5047
     
    7168md.solidearth.settings.grdmodel=1;
    7269md.solidearth.settings.horiz=1;
    73 md.solidearth.requested_outputs={'Sealevel','SealevelBarystaticIceArea','SealevelBarystaticIceLoad','SealevelBarystaticIceMask','SealevelBarystaticIceLatbar' 'SealevelBarystaticIceLongbar'};
     70md.solidearth.requested_outputs={'Sealevel','SealevelBarystaticIceArea','SealevelBarystaticIceLoad','SealevelBarystaticIceMask','SealevelBarystaticIceLatbar','SealevelBarystaticIceLongbar'};
    7471
    7572%Physics:
     
    7976md.transient.ismasstransport=1;
    8077md.transient.isslc=1;
    81  
     78
    8279md.timestepping.start_time=0;
    8380md.timestepping.time_step=1;
     
    117114moi_yz = sum(-loadice.*areaice.*rad_e^2.*sin(lat).*cos(lat).*sin(lon));
    118115moi_zz = sum(-loadice.*areaice.*rad_e^2.*(1.0-sin(lat).^2));
    119 theoretical_value_check=[moixz/moi_xz moiyz/moi_yz moizz/moizz]
     116theoretical_value_check=[moixz/moi_xz moiyz/moi_yz moizz/moi_zz]
    120117% }}}
    121118
    122119%Fields and tolerances to track changes
    123120field_names     ={'eus','slc','moixz','moiyz','moizz'};
    124 field_tolerances={1e-13,1e-13,1e-13,1e-13};
     121field_tolerances={1e-13,1e-13,1e-13,1e-13,1e-13};
    125122field_values={eus,slc,moixz,moiyz,moizz};
    126123
  • TabularUnified issm/trunk-jpl/test/NightlyRun/test2010.py

    r25956 r26358  
    11#Test Name: MomentOfIntertia
    2 from socket import gethostname
    3 
    42import numpy as np
    53
     
    75from gmtmask import *
    86from lovenumbers import *
     7from MatlabFuncs import *
    98from model import *
    109from paterson import *
     
    1211
    1312
    14 #mesh earth:
     13# Mesh earth
    1514md = model()
    16 rad_e = 6.371012 * 1e3  # mean radius of Earth, km
    17 md.mesh = gmshplanet('radius', rad_e, 'resolution', 1000.0)  # km resolution
     15md.mesh = gmshplanet('radius', 6.371012 * 1e3, 'resolution', 700.) #700 km resolution mesh
    1816
    19 #parameterize solidearth solution:
    20 #solidearth loading:  {{{
    21 late = md.mesh.lat[md.mesh.elements - 1].sum(axis=1) / 3
    22 longe = md.mesh.long[md.mesh.elements - 1].sum(axis=1) / 3
     17# Geometry for the bed, arbitrary thickness of 100
     18md.geometry.bed = -1 * np.ones((md.mesh.numberofvertices, ))
     19md.geometry.base = md.geometry.bed
     20md.geometry.thickness = 100 * np.ones((md.mesh.numberofvertices, ))
     21md.geometry.surface = md.geometry.bed + md.geometry.thickness
    2322
    24 md.solidearth.surfaceload.icethicknesschange = np.zeros((md.mesh.numberofelements, 1))
    25 pos = np.intersect1d(np.array(np.where(late < -75)), np.array(np.where(longe > 0)))
    26 #NOTE: Python does not include last element in array slices: (6:7) -> [5:7]
    27 md.solidearth.surfaceload.icethicknesschange[pos[5:7]] = -1
     23# Parameterize SLC solution
     24# Solidearth loading  {{{
     25md.masstransport.spcthickness = np.append(md.geometry.thickness, 0)
     26md.smb.mass_balance = np.zeros((md.mesh.numberofvertices, ))
    2827
    29 md.solidearth.initialsealevel = np.zeros(md.mesh.numberofvertices)
    30 md.dsl.global_average_thermosteric_sea_level_change = np.zeros((2, 1))
    31 md.dsl.sea_surface_height_change_above_geoid = np.zeros((md.mesh.numberofvertices + 1, 1))
    32 md.dsl.sea_water_pressure_change_at_sea_floor = np.zeros((md.mesh.numberofvertices + 1, 1))
     28xe = md.mesh.x[md.mesh.elements - 1].sum(axis=1) / 3
     29ye = md.mesh.y[md.mesh.elements - 1].sum(axis=1) / 3
     30ze = md.mesh.z[md.mesh.elements - 1].sum(axis=1) / 3
     31re = pow((pow(xe, 2) + pow(ye, 2) + pow(ze, 2)), 0.5)
    3332
    34 md.solidearth.settings.ocean_area_scaling = 1
     33late = asind(ze / re)
     34longe = atan2d(ye, xe)
     35# Greenland
     36pos = np.where(np.logical_and.reduce((late > 60, late < 90, longe > -75, longe < -15)))[0]
     37md.masstransport.spcthickness[md.mesh.elements[pos, :] - 1] = md.masstransport.spcthickness[md.mesh.elements[pos, :] - 1] - 100
     38posice = pos
    3539
    36 #elastic loading from love numbers:
    37 md.solidearth.lovenumbers = lovenumbers('maxdeg', 1000)
     40# Elastic loading from love numbers
     41md.solidearth.lovenumbers = lovenumbers('maxdeg', 100)
    3842
    3943#}}}
     
    4145mask = gmtmask(md.mesh.lat, md.mesh.long)
    4246icemask = np.ones((md.mesh.numberofvertices, 1))
     47icemask[md.mesh.elements[posice, :] - 1] = -0.5
     48
     49oceanmask = -1 * np.ones((md.mesh.numberofvertices, 1))
    4350pos = np.where(mask == 0)[0]
    44 icemask[pos] = -1
    45 pos = np.where(mask[md.mesh.elements - 1].sum(axis=1) < 3)[0]
    46 icemask[md.mesh.elements[pos, :] - 1] = -1
     51oceanmask[pos] = 1
     52icemask[np.logical_not(pos).astype(int)] = 1
     53
    4754md.mask.ice_levelset = icemask
    48 md.mask.ocean_levelset = -icemask
     55md.mask.ocean_levelset = oceanmask
    4956
    50 #make sure that the elements that have loads are fully grounded
    51 pos = np.nonzero(md.solidearth.surfaceload.icethicknesschange)[0]
    52 md.mask.ocean_levelset[md.mesh.elements[pos, :] - 1] = 1
     57# Use model representation of ocean area (not the true area)
     58md.solidearth.settings.ocean_area_scaling = 0
    5359
    54 #make sure wherever there is an ice load, that the mask is set to ice:
    55 md.mask.ice_levelset = np.ones((md.mesh.numberofvertices, 1))
    56 #pos = np.nonzero(md.solidearth.surfaceload.icethicknesschange)[0] # Do we need to do this twice?
    57 md.mask.ice_levelset[md.mesh.elements[pos, :] - 1] = -1
    58 # }}}
     60# Materials
     61md.initialization.temperature = 273.25 * np.ones((md.mesh.numberofvertices, 1))
     62md.initialization.sealevel = np.zeros((md.mesh.numberofvertices, 1))
     63md.initialization.str = 0
    5964
    60 #geometry {{{
    61 di = md.materials.rho_ice / md.materials.rho_water
    62 md.geometry.thickness = np.ones((md.mesh.numberofvertices, 1))
    63 md.geometry.surface = (1 - di) * np.zeros((md.mesh.numberofvertices, 1))
    64 md.geometry.base = md.geometry.surface - md.geometry.thickness
    65 md.geometry.bed = md.geometry.base
    66 # }}}
    67 #materials {{{
    68 md.initialization.temperature = 273.25 * np.ones((md.mesh.numberofvertices, 1))
    69 md.materials.rheology_B = paterson(md.initialization.temperature)
    70 md.materials.rheology_n = 3 * np.ones((md.mesh.numberofelements, 1))
    71 # }}}
    72 #Miscellaneous {{{
     65md.basalforcings.groundedice_melting_rate = np.zeros((md.mesh.numberofvertices, ))
     66md.basalforcings.floatingice_melting_rate = np.zeros((md.mesh.numberofvertices, ))
     67md.initialization.vx = np.zeros((md.mesh.numberofvertices, ))
     68md.initialization.vy = np.zeros((md.mesh.numberofvertices, ))
     69
     70# Miscellaneous
    7371md.miscellaneous.name = 'test2010'
    74 # }}}
    75 #Solution parameters {{{
     72
     73# Solution parameters
    7674md.solidearth.settings.reltol = np.nan
    7775md.solidearth.settings.abstol = 1e-3
    78 md.solidearth.settings.computesealevelchange = 1
    79 # }}}
     76md.solidearth.settings.sealevelloading = 0
     77md.solidearth.settings.grdocean = 1
     78md.solidearth.settings.isgrd = 1
     79md.solidearth.settings.ocean_area_scaling = 0
     80md.solidearth.settings.grdmodel = 1
     81md.solidearth.settings.horiz = 1
     82md.solidearth.requested_outputs = [
     83    'Sealevel',
     84    'SealevelBarystaticIceArea',
     85    'SealevelBarystaticIceLoad',
     86    'SealevelBarystaticIceMask',
     87    'SealevelBarystaticIceLatbar',
     88    'SealevelBarystaticIceLongbar'
     89]
    8090
    81 #eustatic + rigid + elastic run:
    82 md.solidearth.settings.rigid = 1
     91# Physics
     92md.transient.issmb = 0
     93md.transient.isstressbalance = 0
     94md.transient.isthermal = 0
     95md.transient.ismasstransport = 1
     96md.transient.isslc = 1
     97
     98md.timestepping.start_time = 0
     99md.timestepping.time_step = 1
     100md.timestepping.final_time = 1
     101
     102# Eustatic + selfattraction + elastic + rotation run
     103md.solidearth.settings.selfattraction = 1
    83104md.solidearth.settings.elastic = 1
    84105md.solidearth.settings.rotation = 1
    85 md.cluster = generic('name', gethostname(), 'np', 3)
     106md.solidearth.settings.viscous = 0
     107md.cluster = generic('name', oshostname(), 'np', 3)
     108md = solve(md, 'Transient')
    86109
     110moi_p = md.solidearth.rotational.polarmoi
     111moi_e = md.solidearth.rotational.equatorialmoi
     112tide_love_k2 = md.solidearth.lovenumbers.tk[2]
     113load_love_k2 = md.solidearth.lovenumbers.k[2]
     114tide_love_k2secular = md.solidearth.lovenumbers.tk2secular
    87115# uncomment following 2 lines for
    88 md = solve(md, 'Sealevelrise')
    89 eus = md.results.SealevelriseSolution.Bslc
    90 slc = md.results.SealevelriseSolution.Sealevel
    91 moixz = md.results.SealevelriseSolution.SealevelInertiaTensorXZ
    92 moiyz = md.results.SealevelriseSolution.SealevelInertiaTensorYZ
    93 moizz = md.results.SealevelriseSolution.SealevelInertiaTensorZZ
     116eus = md.results.TransientSolution.Bslc
     117slc = md.results.TransientSolution.Sealevel
     118moixz = md.results.TransientSolution.SealevelInertiaTensorXZ / (1 / (1 - tide_love_k2 / tide_love_k2secular) * (1 + load_love_k2) / (moi_p - moi_e))
     119moiyz = md.results.TransientSolution.SealevelInertiaTensorYZ / (1 / (1 - tide_love_k2 / tide_love_k2secular) * (1 + load_love_k2) / (moi_p - moi_e))
     120moizz = md.results.TransientSolution.SealevelInertiaTensorZZ / ( -(1 + load_love_k2) / moi_p)
     121
     122areaice = md.results.TransientSolution.SealevelBarystaticIceArea
     123loadice = md.results.TransientSolution.SealevelBarystaticIceLoad
    94124
    95125# analytical moi = > just checking FOR ICE only!!! {{{
    96 # ...have to mute**solidearth induced MOI in Tria.cpp**prior to the comparison
    97 #rad_e = rad_e * 1e3  # now in meters
    98 #areas = GetAreasSphericalTria(md.mesh.elements, md.mesh.lat, md.mesh.long, rad_e)
    99 #lat = late * pi / 180 lon = longe * pi / 180
    100 #moi_xz = sum(-md.materials.rho_freshwater. * md.solidearth.deltathickness. * areas. * rad_e^2. * sin(lat). * cos(lat). * cos(lon))
    101 #moi_yz = sum(-md.materials.rho_freshwater. * md.solidearth.deltathickness. * areas. * rad_e^2. * sin(lat). * cos(lat). * sin(lon))
     126# ...have to mute ** slc induced MOI in Tria.cpp**prior to the comparison
     127rad_e = md.solidearth.planetradius
     128
     129lat = md.results.TransientSolution.SealevelBarystaticIceLatbar * np.pi / 180
     130lon = md.results.TransientSolution.SealevelBarystaticIceLongbar * np.pi / 180
     131moi_xz = sum(-loadice * areaice * pow(rad_e, 2) * np.sin(lat) * np.cos(lat) * np.cos(lon))
     132moi_yz = sum(-loadice * areaice * pow(rad_e, 2) * np.sin(lat) * np.cos(lat) * np.sin(lon))
     133moi_zz = sum(-loadice * areaice * pow(rad_e, 2) * (1 - np.sin(lat) ** 2))
     134theoretical_value_check = [moixz / moi_xz, moiyz / moi_yz, moizz / moi_zz]
     135print('\ntheoretical_value_check =\n')
     136print('\t{}\n'.format(theoretical_value_check))
    102137# }}}
    103138
  • TabularUnified issm/trunk-jpl/test/NightlyRun/test2011.m

    r26296 r26358  
    33%mesh earth:
    44md=model;
    5 load ../Data/SlcTestMesh.mat;
    6 md.mesh=SlcMesh; %700 km resolution mesh
     5md.mesh=gmshplanet('radius',6.371012*10^3,'resolution',700.);
    76
    87%Geometry for the bed, arbitrary thickness of 1000:
  • TabularUnified issm/trunk-jpl/test/NightlyRun/test2021.m

    r25956 r26358  
    1 %Test Name: SESAWslc 
    2 % SESAW method of solving GRD slc 
    3 % reference: Adhikari et al., 2016, GMD, https://doi.org/10.5194/gmd-9-1087-2016 
     1%Test Name: SESAWslc
     2% SESAW method of solving GRD slc
     3% reference: Adhikari et al., 2016, GMD, https://doi.org/10.5194/gmd-9-1087-2016
    44
    55md=model;
    6 md.mesh=gmshplanet('radius',6.371012*10^3,'resolution',500); %500 km resolution mesh
     6md.mesh=gmshplanet('radius',6.371012*10^3,'resolution',700.); %700 km resolution mesh
    77
    8 % read in love numbers. 
     8% read in love numbers.
    99love_numbers = lovenumbers('maxdeg',10000);
    1010
    11 % compute Green's functions 
    12 disp(['Computing Greens functions...']); 
    13 [Grigid,Gelastic,Uelastic]=greensfunctions(md.mesh.elements,md.mesh.lat,md.mesh.long,love_numbers); 
     11% compute Green's functions
     12disp(['Computing Greens functions...']);
     13[Grigid,Gelastic,Uelastic]=greensfunctions(md.mesh.elements,md.mesh.lat,md.mesh.long,love_numbers);
    1414greens.Grigid = Grigid;
    1515greens.Gelast = Gelastic;
     
    1717clearvars Grigid Gelastic Uelastic
    1818
    19 % compute lat,long at elemental centroids. 
    20 [late,longe] = latelonge(md.mesh.elements,md.mesh.lat,md.mesh.long); 
     19% compute lat,long at elemental centroids.
     20[late,longe] = latelonge(md.mesh.elements,md.mesh.lat,md.mesh.long);
    2121
    22 % load GRACE data. Same as used in test2020. 
    23 load('../Data/GRACE_JPL_April2002_WEH.mat'); 
     22% load GRACE data. Same as used in test2020.
     23load('../Data/GRACE_JPL_April2002_WEH.mat');
    2424lat = repmat(lat',720,1);
    2525lon = repmat(lon,1,360);
    26 F = scatteredInterpolant(lat(:),lon(:),weh(:)); 
     26F = scatteredInterpolant(lat(:),lon(:),weh(:));
    2727
    28 % map GRACE data onto elemental centorids. 
     28% map GRACE data onto elemental centorids.
    2929loads_element = F(late,longe);
    3030loads_element(isnan(loads_element))=0;
    3131
    32 % ocean mask mapped onto the elemental centroids. 
    33 ocean_element = gmtmask(late,longe); 
     32% ocean mask mapped onto the elemental centroids.
     33ocean_element = gmtmask(late,longe);
    3434
    3535% Area of individual elements
    36 area_element=GetAreasSphericalTria(md.mesh.elements,md.mesh.lat,md.mesh.long,md.solidearth.planetradius); 
     36area_element=GetAreasSphericalTria(md.mesh.elements,md.mesh.lat,md.mesh.long,md.solidearth.planetradius);
    3737
    38 % Parameters input for SESAWslc solver. 
    39 para.ocean_element = ocean_element; 
    40 para.loads_element = loads_element; 
    41 para.area_element = area_element; 
    42 para.earth_density = md.materials.earth_density; 
     38% Parameters input for SESAWslc solver.
     39para.ocean_element = ocean_element;
     40para.loads_element = loads_element;
     41para.area_element = area_element;
     42para.earth_density = md.materials.earth_density;
    4343para.ocean_density = md.materials.rho_water;
    44 para.loads_density = md.materials.rho_freshwater; % if land loads are ice, use ice density. 
     44para.loads_density = md.materials.rho_freshwater; % if land loads are ice, use ice density.
    4545
    46 para.rel_tol = 1e-5; 
     46para.rel_tol = 1e-5;
    4747
    48 % solid earth rheology. 
    49 para.solidearth = 'rigid'; % 'rigid' or 'elastic'; 
     48% solid earth rheology.
     49para.solidearth = 'rigid'; % 'rigid' or 'elastic';
    5050
    51 % rotational feedbacks. 
    52 para.rotational.flag = 0; % Rotational flag on (1) or off (0) 
    53 para.rotational.earth_radius = md.solidearth.planetradius; 
    54 para.rotational.load_love_k2 = love_numbers.k(3); 
    55 para.rotational.tide_love_k2 = love_numbers.tk(3); 
    56 para.rotational.tide_love_h2 = love_numbers.th(3); 
    57 para.rotational.tide_love_k2secular = love_numbers.tk2secular; 
    58 para.rotational.moi_p = md.solidearth.rotational.polarmoi; 
    59 para.rotational.moi_e = md.solidearth.rotational.equatorialmoi; 
     51% rotational feedbacks.
     52para.rotational.flag = 0; % Rotational flag on (1) or off (0)
     53para.rotational.earth_radius = md.solidearth.planetradius;
     54para.rotational.load_love_k2 = love_numbers.k(3);
     55para.rotational.tide_love_k2 = love_numbers.tk(3);
     56para.rotational.tide_love_h2 = love_numbers.th(3);
     57para.rotational.tide_love_k2secular = love_numbers.tk2secular;
     58para.rotational.moi_p = md.solidearth.rotational.polarmoi;
     59para.rotational.moi_e = md.solidearth.rotational.equatorialmoi;
    6060para.rotational.omega = md.solidearth.rotational.angularvelocity;
    6161
    62 % solve: Rigid without rotational feedbacks. 
    63 disp(['Solving sesaw-slc for Rigid Earth WITHOUT rotational feedback...']); 
    64 [eus_rigid,rsl_rigid] = SESAWslr(md.mesh.elements,md.mesh.lat,md.mesh.long,greens,para); 
     62% solve: Rigid without rotational feedbacks.
     63disp(['Solving sesaw-slc for Rigid Earth WITHOUT rotational feedback...']);
     64[eus_rigid,rsl_rigid] = SESAWslr(md.mesh.elements,md.mesh.lat,md.mesh.long,greens,para);
    6565
    66 % solve: Rigid with rotational feedbacks. 
    67 para.rotational.flag = 1; 
    68 disp(['Solving sesaw-slc for Rigid Earth WITH rotational feedback...']); 
    69 [eus_rigid_rot,rsl_rigid_rot] = SESAWslr(md.mesh.elements,md.mesh.lat,md.mesh.long,greens,para); 
     66% solve: Rigid with rotational feedbacks.
     67para.rotational.flag = 1;
     68disp(['Solving sesaw-slc for Rigid Earth WITH rotational feedback...']);
     69[eus_rigid_rot,rsl_rigid_rot] = SESAWslr(md.mesh.elements,md.mesh.lat,md.mesh.long,greens,para);
    7070
    71 % solve: Elastic with rotational feedbacks. 
    72 para.solidearth = 'elastic'; 
    73 disp(['Solving sesaw-slc for Elastic Earth WITH rotational feedback...']); 
    74 [eus_elast_rot,rsl_elast_rot] = SESAWslr(md.mesh.elements,md.mesh.lat,md.mesh.long,greens,para); 
     71% solve: Elastic with rotational feedbacks.
     72para.solidearth = 'elastic';
     73disp(['Solving sesaw-slc for Elastic Earth WITH rotational feedback...']);
     74[eus_elast_rot,rsl_elast_rot] = SESAWslr(md.mesh.elements,md.mesh.lat,md.mesh.long,greens,para);
    7575
    76 % solve: Elastic with rotational feedbacks. 
    77 para.rotational.flag = 0; 
    78 disp(['Solving sesaw-slc for Elastic Earth WITHOUT rotational feedback...']); 
    79 [eus_elast,rsl_elast] = SESAWslr(md.mesh.elements,md.mesh.lat,md.mesh.long,greens,para); 
     76% solve: Elastic with rotational feedbacks.
     77para.rotational.flag = 0;
     78disp(['Solving sesaw-slc for Elastic Earth WITHOUT rotational feedback...']);
     79[eus_elast,rsl_elast] = SESAWslr(md.mesh.elements,md.mesh.lat,md.mesh.long,greens,para);
    8080
    8181%Fields and tolerances to track changes
    8282field_names={'eus_rigid','eus_rigid_rot','eus_elast','eus_elast_rot',...
    83                   'rsl_rigid','rsl_rigid_rot','rsl_elast','rsl_elast_rot'};
     83             'rsl_rigid','rsl_rigid_rot','rsl_elast','rsl_elast_rot'};
    8484field_tolerances={1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13};
    8585field_values={eus_rigid,eus_rigid_rot,eus_elast,eus_elast_rot,...
    86                   rsl_rigid,rsl_rigid_rot,rsl_elast,rsl_elast_rot};
     86             rsl_rigid,rsl_rigid_rot,rsl_elast,rsl_elast_rot};
    8787
  • TabularUnified issm/trunk-jpl/test/NightlyRun/test2084.m

    r26242 r26358  
    99md.cluster=generic('name',oshostname(),'np',1);
    1010
    11 % set validation=1 for comparing against the Spada benchark.   
     11% set validation=1 for comparing against the Spada benchark.
    1212validation=0;
    1313
     
    2626md.materials.lame_lambda=md.materials.lame_mu*0+5e17;
    2727md.materials.issolid=[1 0 1 1 1 1]';
    28 md.materials.rheologymodel=0*ones(md.materials.numlayers,1);
     28md.materials.rheologymodel=zeros(md.materials.numlayers,1);
    2929md.materials.burgers_mu=md.materials.lame_mu/3;
    3030md.materials.burgers_viscosity=md.materials.viscosity/10;
     
    4444md.love.integration_steps_per_layer=200;
    4545
    46 
    4746md.love.istemporal=1;
    4847md.love.n_temporal_iterations=8;
     
    5150md.love.love_kernels=1;
    5251if md.love.istemporal
    53 md.love=md.love.build_frequencies_from_time;
     52        md.love=md.love.build_frequencies_from_time;
    5453end
    5554
     
    6463%hs=permute(hs,[3 2 1]);
    6564%[ht,h,hsig,hconv]=postwidder_love(md,md.love.n_temporal_iterations,t,hs,1e-5);
    66 
    67 
    6865
    6966%Fields and tolerances to track changes
     
    7673        (md.results.LoveSolution.LoveLr(:,1)),...
    7774        };
    78 
    7975
    8076% validate elastic loading solutions against the Spada benchmark. {{{
  • TabularUnified issm/trunk-jpl/test/NightlyRun/test2084.py

    r24256 r26358  
    11#Test Name: GiaCaron
    2 #Forward Love number solution for a viscoelastic earth,
    3 #model M3 - L70 - V01 from Spada, G., Barletta, V. R., Klemann, V., Riva, R. E. M.,
    4 #Martinec, Z., Gasperini, P., Lund, B., Wolf, D., Vermeersen, L. L. A.
    5 #and King, M. A. (2011), A benchmark study for glacial isostatic
    6 #adjustment codes. Geophysical Journal International,
    7 #185: 106 - 132. doi:10.1111 / j.1365 - 246X.2011.04952.x
    8 
    9 from model import *
    10 from socket import gethostname
    11 from solve import *
    12 from numpy import *
     2# Forward Love number solution for a viscoelastic earth, model M3-L70-V01 from
     3# Spada, G., Barletta, V. R., Klemann, V., Riva, R. E. M., Martinec, Z.,
     4# Gasperini, P., Lund, B., Wolf, D., Vermeersen, L. L. A. and King, M. A.
     5# (2011), A benchmark study for glacial isostatic adjustment codes. Geophysical
     6# Journal International, 185: 106--132. doi:10.1111/j.1365-246X.2011.04952.x
     7
     8import numpy as np
     9
    1310from generic import generic
    1411from materials import *
     12from MatlabFuncs import *
     13from model import *
     14from solve import *
    1515
    1616md = model()
    17 md.cluster = generic('name', gethostname(), 'np', 1)
     17md.cluster = generic('name', oshostname(), 'np', 1)
     18
     19# Set validation=1 for comparing against the Spada benchark
     20validation = 0
    1821
    1922md.materials = materials('litho')
     
    3336md.materials.viscosity = np.array([0, 0, 2.0000e+00, 1.0000e+00, 1.0000e+00,
    3437                                   1.0000e+25]).reshape(-1, 1) * 1e21
    35 md.materials.lame_lambda = np.array(md.materials.lame_mu) * 0 + 5e14
     38md.materials.lame_lambda = np.array(md.materials.lame_mu) * 0 + 5e17
    3639md.materials.issolid = np.array([1, 0, 1, 1, 1, 1]).reshape(-1, 1)
    37 md.materials.isburgers = np.zeros((md.materials.numlayers, 1))
     40md.materials.rheologymodel = np.zeros((md.materials.numlayers, 1))
     41md.materials.burgers_mu = md.materials.lame_mu / 3
     42md.materials.burgers_viscosity = md.materials.viscosity / 10
     43md.materials.ebm_alpha = np.ones((md.materials.numlayers, 1)) * 0.9
     44md.materials.ebm_delta = np.ones((md.materials.numlayers, 1)) * 0.2
     45md.materials.ebm_taul = np.ones((md.materials.numlayers, 1)) * 54 * 60 # 54 min
     46md.materials.ebm_tauh = np.ones((md.materials.numlayers, 1)) * 18.6 * cst / 1e3 # 18.6 yr
     47#setlitho2prem(md.materials)
    3848
    3949md.love.allow_layer_deletion = 1
    40 md.love.frequencies = (np.array([0]) * 2 * pi).reshape(-1, 1) / cst
    41 md.love.nfreq = len(md.love.frequencies)
     50md.love.frequencies = (np.array([0]) * 2 * np.pi).reshape(-1, 1) / cst
     51md.love.nfreq = len(md.love.frequencies)
     52md.love.sh_nmin = 1
    4253md.love.sh_nmax = 256
    43 
    44 md.materials.burgers_mu = md.materials.lame_mu
    45 md.materials.burgers_viscosity = md.materials.viscosity
    46 
    47 md = solve(md, 'lv')
     54md.love.underflow_tol = 1e-20
     55md.love.Gravitational_Constant = 6.6732e-11
     56md.love.integration_steps_per_layer = 200
     57
     58md.love.istemporal = 1
     59md.love.n_temporal_iterations = 8
     60#md.love.time = np.logspace(-4, 5, 2).reshape(-1, 1) * cst
     61md.love.time = np.logspace(-1, 2, 50).reshape(-1, 1) * cst
     62md.love.love_kernels = 1
     63if md.love.istemporal:
     64    md.love = md.love.build_frequencies_from_time
     65
     66md = solve(md, 'lv')
     67
     68ht2 = md.results.LoveSolution.LoveHr
     69lt2 = md.results.LoveSolution.LoveLr
     70kt2 = md.results.LoveSolution.LoveKr
     71t = md.love.time / cst * 1e3
    4872
    4973#Fields and tolerances to track changes
    5074#loading love numbers
    5175field_names = ['LoveH_loading_elastic', 'LoveK_loading_elastic', 'LoveL_loading_elastic']
    52 field_tolerances = [4.3e-9, 4.3e-9, 4.3e-9]
    53 field_values = [np.array(md.results.LoveSolution.LoveHr)[:, 0],
    54                 np.array(md.results.LoveSolution.LoveKr)[:, 0],
    55                 np.array(md.results.LoveSolution.LoveLr)[:, 0]]
    56 
    57 md.love.frequencies = (np.array([1e-3, 1e-2, 1e-1, 1, -1e-3, -1e-2, -1e-1, -1]) * 2 * pi).reshape(-1, 1) / cst
     76field_tolerances = [2.0e-8, 2.0e-8, 2.0e-8]
     77field_values = [
     78    np.array(md.results.LoveSolution.LoveHr)[:, 0],
     79    np.array(md.results.LoveSolution.LoveKr)[:, 0],
     80    np.array(md.results.LoveSolution.LoveLr)[:, 0]
     81]
     82
     83# Validate elastic loading solutions against the Spada benchmark {{{
     84
     85# TODO:
     86# - Implement read from file and comparison
     87# - Implement plot
     88#
     89
     90#}}}
     91
     92md.love.frequencies = (np.array([1e-3, 1e-2, 1e-1, 1, -1e-3, -1e-2, -1e-1, -1]) * 2 * np.np.pi).reshape(-1, 1) / cst
    5893md.love.nfreq = len(md.love.frequencies)
    5994md.love.sh_nmax = 256
     
    6499
    65100#Fields and tolerances to track changes
    66 #loading love numbers
    67101field_names += ['LoveH_loading_realpart', 'LoveK_loading_realpart', 'LoveL_loading_realpart', 'LoveH_loading_imagpart', 'LoveK_loading_imagpart', 'LoveL_loading_imagpart']
    68102field_tolerances += [5e-7, 5e-7, 5e-7, 5e-7, 5e-7, 5e-7]
    69 field_values += [np.array(md.results.LoveSolution.LoveHr),
    70                  np.array(md.results.LoveSolution.LoveKr),
    71                  np.array(md.results.LoveSolution.LoveLr),
    72                  np.array(md.results.LoveSolution.LoveHi),
    73                  np.array(md.results.LoveSolution.LoveKi),
    74                  np.array(md.results.LoveSolution.LoveLi)]
     103field_values += [
     104    np.array(md.results.LoveSolution.LoveHr),
     105    np.array(md.results.LoveSolution.LoveKr),
     106    np.array(md.results.LoveSolution.LoveLr),
     107    np.array(md.results.LoveSolution.LoveHi),
     108    np.array(md.results.LoveSolution.LoveKi),
     109    np.array(md.results.LoveSolution.LoveLi)
     110]
    75111
    76112md.love.forcing_type = 9
    77113md.love.sh_nmin = 2
    78 md.love.frequencies = ((np.array([0, 1e-3, 1e-2, 1e-1, 1, -1e-3, -1e-2, -1e-1, -1]) * 2 * pi).reshape(-1, 1) / cst)
    79 md.love.nfreq = len(md.love.frequencies)
    80 
    81 md = solve(md, 'lv')
     114md.love.frequencies = ((np.array([0, 1e-3, 1e-2, 1e-1, 1, -1e-3, -1e-2, -1e-1, -1]) * 2 * np.pi).reshape(-1, 1) / cst)
     115md.love.nfreq = len(md.love.frequencies)
     116md = solve(md, 'lv')
     117
     118# Validate elastic tidal solutions against the Spada benchmark #{{{
     119
     120# TODO:
     121# - Implement read from file and comparison
     122# - Implement plot
     123#
     124
     125#}}}
    82126
    83127#tidal love numbers, check
    84128field_names += ['LoveH_tidal_elastic', 'LoveK_tidal_elastic', 'LoveL_tidal_elastic', 'LoveH_tidal_realpart', 'LoveK_tidal_realpart', 'LoveL_tidal_realpart', 'LoveH_tidal_imagpart', 'LoveK_tidal_imagpart', 'LoveL_tidal_imagpart']
    85129field_tolerances += [8e-6, 8e-6, 8e-6, 8e-6, 8e-6, 8e-6, 8e-6, 8e-6, 8e-6]
    86 field_values += [np.array(md.results.LoveSolution.LoveHr)[:, 0],
    87                  np.array(md.results.LoveSolution.LoveKr)[:, 0],
    88                  np.array(md.results.LoveSolution.LoveLr)[:, 0],
    89                  np.array(md.results.LoveSolution.LoveHr)[:, 1:],
    90                  np.array(md.results.LoveSolution.LoveKr)[:, 1:],
    91                  np.array(md.results.LoveSolution.LoveLr)[:, 1:],
    92                  np.array(md.results.LoveSolution.LoveHi)[:, 1:],
    93                  np.array(md.results.LoveSolution.LoveKi)[:, 1:],
    94                  np.array(md.results.LoveSolution.LoveLi)[:, 1:]]
    95 
    96 #Many layers PREM - based model
     130field_values += [
     131    np.array(md.results.LoveSolution.LoveHr)[:, 0],
     132    np.array(md.results.LoveSolution.LoveKr)[:, 0],
     133    np.array(md.results.LoveSolution.LoveLr)[:, 0],
     134    np.array(md.results.LoveSolution.LoveHr)[:, 1:],
     135    np.array(md.results.LoveSolution.LoveKr)[:, 1:],
     136    np.array(md.results.LoveSolution.LoveLr)[:, 1:],
     137    np.array(md.results.LoveSolution.LoveHi)[:, 1:],
     138    np.array(md.results.LoveSolution.LoveKi)[:, 1:],
     139    np.array(md.results.LoveSolution.LoveLi)[:, 1:]
     140]
     141
     142# Many layers PREM-based model
    97143#data = load('../Data/PREM_500layers')
    98144#md.love.sh_nmin = 1
     
    115161#md.materials.burgers_mu = md.materials.lame_mu
    116162#md.materials.burgers_viscosity = md.materials.viscosity
    117 #md.materials.isburgers = md.materials.issolid * 0
     163#md.materials.rheologymodel = md.materials.issolid * 0
    118164#md.love.forcing_type = 11
    119165#md.materials.numlayers = len(md.materials.viscosity)
     
    133179#       (md.results.LoveSolution.LoveLi[:][1:]),
    134180#       ]
    135 #Model VSS96 from Vermeersen, L.L.A., Sabadini, R. & Spada, G., 1996a. Analytical visco - elastic relaxation models, Geophys. Res. Lett., 23, 697 - 700.
    136 
     181
     182# Model VSS96 from Vermeersen, L.L.A., Sabadini, R. & Spada, G., 1996a. Analytical visco-elastic relaxation models, Geophys. Res. Lett., 23, 697-700.
    137183md.materials.radius = np.array([10, 1222.5, 3480., 3600., 3630.5, 3700., 3900., 4000.,
    138184                                4200., 4300., 4500., 4600., 4800., 4900., 5100., 5200.,
     
    168214md.materials.burgers_mu = md.materials.lame_mu
    169215md.materials.burgers_viscosity = md.materials.viscosity
    170 md.materials.isburgers = md.materials.issolid * 0
     216md.materials.rheologymodel = md.materials.issolid * 0
    171217md.love.forcing_type = 11
    172218md.love.sh_nmin = 1
    173219md.love.sh_nmax = 100
    174 
    175 md = solve(md, 'lv')
    176 
    177 md.love.frequencies = (np.array([0, 1e-3, 1e-2, 1, -1e-3, -1e-2,
    178                                  -1]) * 2 * pi).reshape(-1, 1) / cst
    179 md.love.nfreq = len(md.love.frequencies)
    180 
    181 field_names += ['LoveH_loadingVSS96_elastic', 'LoveK_loadingVSS96_elastic', 'LoveL_loadingVSS96_elastic', 'LoveH_loadingVSS96_realpart', 'LoveK_loadingVSS96_realpart', 'LoveL_loadingVSS96_realpart', 'LoveH_loadingVSS96_imagpart', 'LoveK_loadingVSS96_imagpart', 'LoveL_loadingVSS96_imagpart']
     220md = solve(md, 'lv')
     221md.love.frequencies = (np.array([0, 1e-3, 1e-2, 1, -1e-3, -1e-2, -1]) * 2 * np.pi).reshape(-1, 1) / cst
     222md.love.nfreq = len(md.love.frequencies)
     223
     224field_names += [
     225    'LoveH_loadingVSS96_elastic',
     226    'LoveK_loadingVSS96_elastic',
     227    'LoveL_loadingVSS96_elastic',
     228    'LoveH_loadingVSS96_realpart',
     229    'LoveK_loadingVSS96_realpart',
     230    'LoveL_loadingVSS96_realpart',
     231    'LoveH_loadingVSS96_imagpart',
     232    'LoveK_loadingVSS96_imagpart',
     233    'LoveL_loadingVSS96_imagpart'
     234]
    182235field_tolerances += [2e-6, 2e-6, 2e-6, 2e-6, 2e-6, 2e-6, 2e-6, 2e-6, 2e-6]
    183 field_values += [np.array(md.results.LoveSolution.LoveHr)[:, 0],
    184                  np.array(md.results.LoveSolution.LoveKr)[:, 0],
    185                  np.array(md.results.LoveSolution.LoveLr)[:, 0],
    186                  np.array(md.results.LoveSolution.LoveHr)[:, 1:],
    187                  np.array(md.results.LoveSolution.LoveKr)[:, 1:],
    188                  np.array(md.results.LoveSolution.LoveLr)[:, 1:],
    189                  np.array(md.results.LoveSolution.LoveHi)[:, 1:],
    190                  np.array(md.results.LoveSolution.LoveKi)[:, 1:],
    191                  np.array(md.results.LoveSolution.LoveLi)[:, 1:]]
     236field_values += [
     237    np.array(md.results.LoveSolution.LoveHr)[:, 0],
     238    np.array(md.results.LoveSolution.LoveKr)[:, 0],
     239    np.array(md.results.LoveSolution.LoveLr)[:, 0],
     240    np.array(md.results.LoveSolution.LoveHr)[:, 1:],
     241    np.array(md.results.LoveSolution.LoveKr)[:, 1:],
     242    np.array(md.results.LoveSolution.LoveLr)[:, 1:],
     243    np.array(md.results.LoveSolution.LoveHi)[:, 1:],
     244    np.array(md.results.LoveSolution.LoveKi)[:, 1:],
     245    np.array(md.results.LoveSolution.LoveLi)[:, 1:]
     246]
  • TabularUnified issm/trunk-jpl/test/NightlyRun/test2090.m

    r26296 r26358  
    33%mesh earth:
    44md=model;
    5 load ../Data/SlcTestMesh.mat;
    6 md.mesh=SlcMesh; %700 km resolution mesh
     5md.mesh=gmshplanet('radius',6.371012*10^3,'resolution',700.);
    76
    87%Geometry for the bed, arbitrary thickness of 1000:
  • TabularUnified issm/trunk-jpl/test/NightlyRun/test2101.m

    r25166 r26358  
    44%mesh earth:
    55md=model;
    6 md.mesh=gmshplanet('radius',6.371012*10^3,'resolution',1000);
     6md.mesh=gmshplanet('radius',6.371012*10^3,'resolution',700);
    77
    88% define load
  • TabularUnified issm/trunk-jpl/test/NightlyRun/test2101.py

    r25158 r26358  
    1515#mesh earth:
    1616md = model()
    17 md.mesh = gmshplanet('radius', 6.371012 * 1e3, 'resolution', 1000)
     17md.mesh = gmshplanet('radius', 6.371012 * 1e3, 'resolution', 700)
    1818
    1919#define load
  • TabularUnified issm/trunk-jpl/test/Par/SquareSheetConstrained.py

    r26066 r26358  
     1import inspect
    12import os.path
    23import numpy as np
    3 import inspect
    4 from verbose import verbose
     4from arch import *
    55from InterpFromMeshToMesh2d import InterpFromMeshToMesh2d
    66from paterson import paterson
    77from SetIceSheetBC import SetIceSheetBC
    8 from arch import *
     8from verbose import verbose
    99
    1010#Start defining model parameters here
    1111
    12 #Geometry
    13 hmin = 300.
    14 hmax = 1000.
     12# Geometry
     13hmin = 300.0
     14hmax = 1000.0
    1515ymin = np.min(md.mesh.y)
    1616ymax = np.max(md.mesh.y)
     
    1818xmax = np.max(md.mesh.x)
    1919md.geometry.thickness = hmax + (hmin - hmax) * (md.mesh.y - ymin) / (ymax - ymin) + 0.1 * (hmin - hmax) * (md.mesh.x - xmin) / (xmax - xmin)
    20 md.geometry.base = -md.materials.rho_ice / md.materials.rho_water * md.geometry.thickness + 20.
     20md.geometry.base = -md.materials.rho_ice / md.materials.rho_water * md.geometry.thickness + 20.0
    2121md.geometry.bed = md.geometry.base
    2222md.geometry.surface = md.geometry.base + md.geometry.thickness
     
    3535
    3636#Materials
    37 md.initialization.temperature = (273. - 20.) * np.ones((md.mesh.numberofvertices))
     37md.initialization.temperature = (273.0 - 20.0) * np.ones((md.mesh.numberofvertices))
    3838md.materials.rheology_B = paterson(md.initialization.temperature)
    39 md.materials.rheology_n = 3. * np.ones((md.mesh.numberofelements))
     39md.materials.rheology_n = 3.0 * np.ones((md.mesh.numberofelements))
    4040
    4141#Calving
     
    4444
    4545#Friction
    46 md.friction.coefficient = 20. * np.ones((md.mesh.numberofvertices))
    47 md.friction.coefficient[np.where(md.mask.ocean_levelset < 0.)[0]] = 0.
     46md.friction.coefficient = 20.0 * np.ones((md.mesh.numberofvertices))
     47md.friction.coefficient[np.where(md.mask.ocean_levelset < 0.0)[0]] = 0.0
    4848md.friction.p = np.ones((md.mesh.numberofelements))
    4949md.friction.q = np.ones((md.mesh.numberofelements))
    5050
    5151#Numerical parameters
    52 md.masstransport.stabilization = 1.
    53 md.thermal.stabilization = 1.
     52md.masstransport.stabilization = 1.0
     53md.thermal.stabilization = 1.0
    5454md.verbose = verbose(0)
    5555md.settings.waitonlock = 30
     
    5858md.stressbalance.reltol = 0.05
    5959md.stressbalance.abstol = np.nan
    60 md.timestepping.time_step = 1.
    61 md.timestepping.final_time = 3.
     60md.timestepping.time_step = 1.0
     61md.timestepping.final_time = 3.0
    6262md.groundingline.migration = 'None'
    6363
Note: See TracChangeset for help on using the changeset viewer.