Changeset 25171


Ignore:
Timestamp:
06/28/20 00:26:36 (5 years ago)
Author:
jdquinn
Message:

BUG: Fix for test2002; additional MATLAB -> Python translation; cleanup

Location:
issm/trunk-jpl
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/m/classes/matenhancedice.py

    r24261 r25171  
    99    MATICE class definition
    1010
    11        Usage:
    12           matenhancedice = matenhancedice()
     11        Usage:
     12            matenhancedice = matenhancedice()
    1313    """
    1414
    15     def __init__(self):  # {{{
     15    def __init__(self): #{{{
    1616        self.rho_ice = 0.
    1717        self.rho_water = 0.
     
    3232        self.rheology_law = ''
    3333
    34     #giaivins:
     34        #GIA
    3535        self.lithosphere_shear_modulus = 0.
    3636        self.lithosphere_density = 0.
     
    3838        self.mantle_density = 0.
    3939
    40     #SLR
    41         self.earth_density = 0  # average density of the Earth, (kg / m^3)
     40        #SLR
     41        self.earth_density = 0  # average density of the Earth, (kg/m^3)
    4242        self.setdefaultparameters()
    4343    #}}}
    4444
    45     def __repr__(self):  # {{{
    46         string = "   Materials:"
    47         string = "%s\n%s" % (string, fielddisplay(self, "rho_ice", "ice density [kg / m^3]"))
    48         string = "%s\n%s" % (string, fielddisplay(self, "rho_water", "water density [kg / m^3]"))
    49         string = "%s\n%s" % (string, fielddisplay(self, "rho_freshwater", "fresh water density [kg / m^3]"))
    50         string = "%s\n%s" % (string, fielddisplay(self, "mu_water", "water viscosity [N s / m^2]"))
    51         string = "%s\n%s" % (string, fielddisplay(self, "heatcapacity", "heat capacity [J / kg / K]"))
    52         string = "%s\n%s" % (string, fielddisplay(self, "thermalconductivity", "ice thermal conductivity [W / m / K]"))
    53         string = "%s\n%s" % (string, fielddisplay(self, "temperateiceconductivity", "temperate ice thermal conductivity [W / m / K]"))
    54         string = "%s\n%s" % (string, fielddisplay(self, "effectiveconductivity_averaging", "computation of effectiveconductivity: (0) arithmetic mean, (1) harmonic mean, (2) geometric mean (default)"))
    55         string = "%s\n%s" % (string, fielddisplay(self, "meltingpoint", "melting point of ice at 1atm in K"))
    56         string = "%s\n%s" % (string, fielddisplay(self, "latentheat", "latent heat of fusion [J / m^3]"))
    57         string = "%s\n%s" % (string, fielddisplay(self, "beta", "rate of change of melting point with pressure [K / Pa]"))
    58         string = "%s\n%s" % (string, fielddisplay(self, "mixed_layer_capacity", "mixed layer capacity [W / kg / K]"))
    59         string = "%s\n%s" % (string, fielddisplay(self, "thermal_exchange_velocity", "thermal exchange velocity [m / s]"))
    60         string = "%s\n%s" % (string, fielddisplay(self, "rheology_E", "enhancement factor"))
    61         string = "%s\n%s" % (string, fielddisplay(self, "rheology_B", "flow law parameter [Pa s^(1 / n)]"))
    62         string = "%s\n%s" % (string, fielddisplay(self, "rheology_n", "Glen's flow law exponent"))
    63         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'"))
    64         string = "%s\n%s" % (string, fielddisplay(self, "lithosphere_shear_modulus", "Lithosphere shear modulus [Pa]"))
    65         string = "%s\n%s" % (string, fielddisplay(self, "lithosphere_density", "Lithosphere density [g / cm^ - 3]"))
    66         string = "%s\n%s" % (string, fielddisplay(self, "mantle_shear_modulus", "Mantle shear modulus [Pa]"))
    67         string = "%s\n%s" % (string, fielddisplay(self, "mantle_density", "Mantle density [g / cm^ - 3]"))
    68         string = "%s\n%s" % (string, fielddisplay(self, "earth_density", "Mantle density [kg / m^ - 3]"))
    69         return string
     45    def __repr__(self): #{{{
     46        s = "   Materials:"
     47        s = "%s\n%s" % (s, fielddisplay(self, "rho_ice", "ice density [kg/m^3]"))
     48        s = "%s\n%s" % (s, fielddisplay(self, "rho_water", "water density [kg/m^3]"))
     49        s = "%s\n%s" % (s, fielddisplay(self, "rho_freshwater", "fresh water density [kg/m^3]"))
     50        s = "%s\n%s" % (s, fielddisplay(self, "mu_water", "water viscosity [N s/m^2]"))
     51        s = "%s\n%s" % (s, fielddisplay(self, "heatcapacity", "heat capacity [J/kg/K]"))
     52        s = "%s\n%s" % (s, fielddisplay(self, "thermalconductivity", "ice thermal conductivity [W/m/K]"))
     53        s = "%s\n%s" % (s, fielddisplay(self, "temperateiceconductivity", "temperate ice thermal conductivity [W/m/K]"))
     54        s = "%s\n%s" % (s, fielddisplay(self, "effectiveconductivity_averaging", "computation of effectiveconductivity: (0) arithmetic mean, (1) harmonic mean, (2) geometric mean (default)"))
     55        s = "%s\n%s" % (s, fielddisplay(self, "meltingpoint", "melting point of ice at 1atm in K"))
     56        s = "%s\n%s" % (s, fielddisplay(self, "latentheat", "latent heat of fusion [J/m^3]"))
     57        s = "%s\n%s" % (s, fielddisplay(self, "beta", "rate of change of melting point with pressure [K/Pa]"))
     58        s = "%s\n%s" % (s, fielddisplay(self, "mixed_layer_capacity", "mixed layer capacity [W/kg/K]"))
     59        s = "%s\n%s" % (s, fielddisplay(self, "thermal_exchange_velocity", "thermal exchange velocity [m/s]"))
     60        s = "%s\n%s" % (s, fielddisplay(self, "rheology_E", "enhancement factor"))
     61        s = "%s\n%s" % (s, fielddisplay(self, "rheology_B", "flow law parameter [Pa s^(1/n)]"))
     62        s = "%s\n%s" % (s, fielddisplay(self, "rheology_n", "Glen's flow law exponent"))
     63        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'"))
     64        s = "%s\n%s" % (s, fielddisplay(self, "lithosphere_shear_modulus", "Lithosphere shear modulus [Pa]"))
     65        s = "%s\n%s" % (s, fielddisplay(self, "lithosphere_density", "Lithosphere density [g/cm^-3]"))
     66        s = "%s\n%s" % (s, fielddisplay(self, "mantle_shear_modulus", "Mantle shear modulus [Pa]"))
     67        s = "%s\n%s" % (s, fielddisplay(self, "mantle_density", "Mantle density [g/cm^-3]"))
     68        s = "%s\n%s" % (s, fielddisplay(self, "earth_density", "Mantle density [kg/m^-3]"))
     69
     70        return s
    7071    #}}}
    7172
    72     def extrude(self, md):  # {{{
     73    def extrude(self, md): #{{{
    7374        self.rheology_E = project3d(md, 'vector', self.rheology_E, 'type', 'node')
    7475        self.rheology_B = project3d(md, 'vector', self.rheology_B, 'type', 'node')
     
    7778    #}}}
    7879
    79     def setdefaultparameters(self):  # {{{
     80    def setdefaultparameters(self): #{{{
    8081        #ice density (kg / m^3)
    8182        self.rho_ice = 917.
     
    120121    #}}}
    121122
    122     def checkconsistency(self, md, solution, analyses):  # {{{
     123    def checkconsistency(self, md, solution, analyses): #{{{
    123124        md = checkfield(md, 'fieldname', 'materials.rho_ice', '>', 0)
    124125        md = checkfield(md, 'fieldname', 'materials.rho_water', '>', 0)
     
    136137            md = checkfield(md, 'fieldname', 'materials.mantle_shear_modulus', '>', 0, 'numel', 1)
    137138            md = checkfield(md, 'fieldname', 'materials.mantle_density', '>', 0, 'numel', 1)
     139           
    138140        if 'SealevelriseAnalysis' in analyses:
    139141            md = checkfield(md, 'fieldname', 'materials.earth_density', '>', 0, 'numel', 1)
     
    141143    # }}}
    142144
    143     def marshall(self, prefix, md, fid):  # {{{
     145    def marshall(self, prefix, md, fid): #{{{
    144146        WriteData(fid, prefix, 'name', 'md.materials.type', 'data', 4, 'format', 'Integer')
    145147        WriteData(fid, prefix, 'object', self, 'class', 'materials', 'fieldname', 'rho_ice', 'format', 'Double')
  • issm/trunk-jpl/src/m/classes/matestar.py

    r25125 r25171  
     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 matestar(object):
    8     """
    9     matestar class definition
     10    '''
     11    MATESTAR class definition
    1012
    11        Usage:
    12           matestar = matestar()
    13     """
     13        Usage:
     14            matestar = matestar()
     15    '''
    1416
    15     def __init__(self):  # {{{
     17    def __init__(self): #{{{
    1618        self.rho_ice = 0.
    1719        self.rho_water = 0.
     
    2729        self.mixed_layer_capacity = 0.
    2830        self.thermal_exchange_velocity = 0.
    29         self.rheology_B = float('NaN')
    30         self.rheology_Ec = float('NaN')
    31         self.rheology_Es = float('NaN')
     31        self.rheology_B = np.nan
     32        self.rheology_Ec = np.nan
     33        self.rheology_Es = np.nan
    3234        self.rheology_law = ''
    3335
    34         #giaivins:
     36        #GIA
    3537        self.lithosphere_shear_modulus = 0.
    3638        self.lithosphere_density = 0.
     
    3840        self.mantle_density = 0.
    3941
    40         #slr
     42        #SLR
    4143        self.earth_density = 0
    4244
    43         #set default parameters:
     45        #set default parameters
    4446        self.setdefaultparameters()
    4547    #}}}
    4648
    47     def __repr__(self):  # {{{
    48         string = "   Materials:"
    49         string = "%s\n%s" % (string, fielddisplay(self, 'rho_ice', 'ice density [kg / m^3]'))
    50         string = "%s\n%s" % (string, fielddisplay(self, 'rho_water', 'ocean water density [kg / m^3]'))
    51         string = "%s\n%s" % (string, fielddisplay(self, 'rho_freshwater', 'fresh water density [kg / m^3]'))
    52         string = "%s\n%s" % (string, fielddisplay(self, 'mu_water', 'water viscosity [N s / m^2]'))
    53         string = "%s\n%s" % (string, fielddisplay(self, 'heatcapacity', 'heat capacity [J / kg / K]'))
    54         string = "%s\n%s" % (string, fielddisplay(self, 'thermalconductivity', ['ice thermal conductivity [W / m / K]']))
    55         string = "%s\n%s" % (string, fielddisplay(self, 'temperateiceconductivity', 'temperate ice thermal conductivity [W / m / K]'))
    56         string = "%s\n%s" % (string, fielddisplay(self, "effectiveconductivity_averaging", "computation of effectiveconductivity: (0) arithmetic mean, (1) harmonic mean, (2) geometric mean (default)"))
    57         string = "%s\n%s" % (string, fielddisplay(self, 'meltingpoint', 'melting point of ice at 1atm in K'))
    58         string = "%s\n%s" % (string, fielddisplay(self, 'latentheat', 'latent heat of fusion [J / kg]'))
    59         string = "%s\n%s" % (string, fielddisplay(self, 'beta', 'rate of change of melting point with pressure [K / Pa]'))
    60         string = "%s\n%s" % (string, fielddisplay(self, 'mixed_layer_capacity', 'mixed layer capacity [W / kg / K]'))
    61         string = "%s\n%s" % (string, fielddisplay(self, 'thermal_exchange_velocity', 'thermal exchange velocity [m / s]'))
    62         string = "%s\n%s" % (string, fielddisplay(self, 'rheology_B', 'flow law parameter [Pa s^(1 / 3)]'))
    63         string = "%s\n%s" % (string, fielddisplay(self, 'rheology_Ec', 'compressive enhancement factor'))
    64         string = "%s\n%s" % (string, fielddisplay(self, 'rheology_Es', 'shear enhancement factor'))
    65         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''']))
    66         string = "%s\n%s" % (string, fielddisplay(self, 'lithosphere_shear_modulus', 'Lithosphere shear modulus [Pa]'))
    67         string = "%s\n%s" % (string, fielddisplay(self, 'lithosphere_density', 'Lithosphere density [g / cm^ - 3]'))
    68         string = "%s\n%s" % (string, fielddisplay(self, 'mantle_shear_modulus', 'Mantle shear modulus [Pa]'))
    69         string = "%s\n%s" % (string, fielddisplay(self, 'mantle_density', 'Mantle density [g / cm^ - 3]'))
    70         string = "%s\n%s" % (string, fielddisplay(self, 'earth_density', 'Mantle density [kg / m^ - 3]'))
    71         return string
     49    def __repr__(self): #{{{
     50        s = "   Materials:"
     51        s = "%s\n%s" % (s, fielddisplay(self, 'rho_ice', 'ice density [kg/m^3]'))
     52        s = "%s\n%s" % (s, fielddisplay(self, 'rho_water', 'ocean water density [kg/m^3]'))
     53        s = "%s\n%s" % (s, fielddisplay(self, 'rho_freshwater', 'fresh water density [kg/m^3]'))
     54        s = "%s\n%s" % (s, fielddisplay(self, 'mu_water', 'water viscosity [N s/m^2]'))
     55        s = "%s\n%s" % (s, fielddisplay(self, 'heatcapacity', 'heat capacity [J/kg/K]'))
     56        s = "%s\n%s" % (s, fielddisplay(self, 'thermalconductivity', ['ice thermal conductivity [W/m/K]']))
     57        s = "%s\n%s" % (s, fielddisplay(self, 'temperateiceconductivity', 'temperate ice thermal conductivity [W/m/K]'))
     58        s = "%s\n%s" % (s, fielddisplay(self, "effectiveconductivity_averaging", "computation of effectiveconductivity: (0) arithmetic mean, (1) harmonic mean, (2) geometric mean (default)"))
     59        s = "%s\n%s" % (s, fielddisplay(self, 'meltingpoint', 'melting point of ice at 1atm in K'))
     60        s = "%s\n%s" % (s, fielddisplay(self, 'latentheat', 'latent heat of fusion [J / kg]'))
     61        s = "%s\n%s" % (s, fielddisplay(self, 'beta', 'rate of change of melting point with pressure [K/Pa]'))
     62        s = "%s\n%s" % (s, fielddisplay(self, 'mixed_layer_capacity', 'mixed layer capacity [W/kg/K]'))
     63        s = "%s\n%s" % (s, fielddisplay(self, 'thermal_exchange_velocity', 'thermal exchange velocity [m/s]'))
     64        s = "%s\n%s" % (s, fielddisplay(self, 'rheology_B', 'flow law parameter [Pa s^(1/3)]'))
     65        s = "%s\n%s" % (s, fielddisplay(self, 'rheology_Ec', 'compressive enhancement factor'))
     66        s = "%s\n%s" % (s, fielddisplay(self, 'rheology_Es', 'shear enhancement factor'))
     67        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''']))
     68        s = "%s\n%s" % (s, fielddisplay(self, 'lithosphere_shear_modulus', 'Lithosphere shear modulus [Pa]'))
     69        s = "%s\n%s" % (s, fielddisplay(self, 'lithosphere_density', 'Lithosphere density [g/cm^-3]'))
     70        s = "%s\n%s" % (s, fielddisplay(self, 'mantle_shear_modulus', 'Mantle shear modulus [Pa]'))
     71        s = "%s\n%s" % (s, fielddisplay(self, 'mantle_density', 'Mantle density [g/cm^-3]'))
     72        s = "%s\n%s" % (s, fielddisplay(self, 'earth_density', 'Mantle density [kg/m^-3]'))
     73
     74        return s
    7275    #}}}
    7376
    74     def extrude(self, md):  # {{{
     77    def extrude(self, md): #{{{
    7578        self.rheology_B = project3d(md, 'vector', self.rheology_B, 'type', 'node')
    7679        self.rheology_Ec = project3d(md, 'vector', self.rheology_Ec, 'type', 'node')
    7780        self.rheology_Es = project3d(md, 'vector', self.rheology_Es, 'type', 'node')
     81
    7882        return self
    7983    #}}}
    8084
    81     def setdefaultparameters(self):  # {{{
     85    def setdefaultparameters(self): #{{{
    8286        #ice density (kg / m^3)
    8387        self.rho_ice = 917.
     
    109113        #available: none, paterson and arrhenius
    110114        self.rheology_law = 'Paterson'
    111     # GIA:
     115        # GIA
    112116        self.lithosphere_shear_modulus = 6.7e10  # (Pa)
    113117        self.lithosphere_density = 3.32  # (g / cm^ - 3)
    114118        self.mantle_shear_modulus = 1.45e11  # (Pa)
    115119        self.mantle_density = 3.34  # (g / cm^ - 3)
    116     #SLR
     120        #SLR
    117121        self.earth_density = 5512  # average density of the Earth, (kg / m^3)
    118122
     
    120124    #}}}
    121125
    122     def checkconsistency(self, md, solution, analyses):  # {{{
     126    def checkconsistency(self, md, solution, analyses): #{{{
    123127        md = checkfield(md, 'fieldname', 'materials.rho_ice', '>', 0)
    124128        md = checkfield(md, 'fieldname', 'materials.rho_water', '>', 0)
     
    143147    # }}}
    144148
    145     def marshall(self, prefix, md, fid):  # {{{
     149    def marshall(self, prefix, md, fid): #{{{
    146150        WriteData(fid, prefix, 'name', 'md.materials.type', 'data', 2, 'format', 'Integer')
    147151        WriteData(fid, prefix, 'object', self, 'class', 'materials', 'fieldname', 'rho_ice', 'format', 'Double')
  • issm/trunk-jpl/src/m/classes/rotational.py

    r25158 r25171  
    4646
    4747    def checkconsistency(self, md, solution, analyses): # {{{
    48         if ('SealevelriseAnalysis' not in analyses) or (solution == 'TransientSolution' and md.transient.isrotational == 0):
     48        if ('SealevelriseAnalysis' not in analyses) or (solution == 'TransientSolution' and md.transient.isslr == 0):
    4949            return md
    5050
  • issm/trunk-jpl/src/m/classes/slr.py

    r25170 r25171  
    122122    def checkconsistency(self, md, solution, analyses):  # {{{
    123123        #Early return
    124         if (solution != 'SealevelriseAnalysis') or (solution == 'TransientSolution' and not md.transient.isslr):
     124        if (solution != 'SealevelriseAnalysis') or (solution == 'TransientSolution' and md.transient.isslr == 0):
    125125            return md
    126126
     
    147147
    148148        #check that love numbers are provided at the same level of accuracy:
    149         if (size(self.love_h, 0) != size(self.love_k, 0) | size(self.love_h, 0) != size(self.love_l, 0)):
    150             error('slr error message: love numbers should be provided at the same level of accuracy')
     149        if (size(self.love_h, 0) != size(self.love_k, 0)) or (size(self.love_h, 0) != size(self.love_l, 0)):
     150            raise Exception('slr error message: love numbers should be provided at the same level of accuracy')
    151151
    152152        #cross check that whereever we have an ice load, the mask is < 0 on each vertex:
     
    160160        #a coupler to a planet model is provided.
    161161        if self.geodetic and not md.transient.iscoupler and domaintype(md.mesh) != 'mesh3dsurface':
    162             error('model is requesting geodetic computations without being a mesh3dsurface, or being coupled to one!')
     162            raise Exception('model is requesting geodetic computations without being a mesh3dsurface, or being coupled to one!')
    163163        return md
    164164    # }}}
  • issm/trunk-jpl/src/m/classes/surfaceload.py

    r25158 r25171  
    4141
    4242    def checkconsistency(self, md, solution, analyses): # {{{
    43         if ('SealevelriseAnalysis' not in analyses) or (solution == 'TransientSolution' and md.transient.issurfaceload == 0):
     43        if ('SealevelriseAnalysis' not in analyses) or (solution == 'TransientSolution' and md.transient.isslr == 0):
    4444            return md
    4545
    46         if len(self.icethicknesschange) > 0:
     46        if len(self.icethicknesschange):
    4747            md  = checkfield(md,'fieldname', 'solidearth.surfaceload.icethicknesschange', 'timeseries', 1, 'NaN', 1, 'Inf', 1)
    4848
    49         if len(self.waterheightchange) > 0:
     49        if len(self.waterheightchange):
    5050            md  = checkfield(md,'fieldname', 'solidearth.surfaceload.waterheightchange', 'timeseries', 1, 'NaN', 1, 'Inf', 1)
    5151
    52         if len(self.other) > 0:
     52        if len(self.other):
    5353            md  = checkfield(md,'fieldname', 'solidearth.surfaceload.other', 'timeseries', 1, 'NaN', 1, 'Inf', 1)
    5454
  • issm/trunk-jpl/test/NightlyRun/test2002.py

    r25169 r25171  
    2020md.solidearth.surfaceload.icethicknesschange = np.zeros((md.mesh.numberofelements, 1))
    2121md.solidearth.sealevel = np.zeros((md.mesh.numberofvertices, 1))
    22 md.dsl.global_average_thermosteric_sea_level_change = np.zeros((1, 1))
     22md.dsl.global_average_thermosteric_sea_level_change = np.zeros((2, 1))
    2323md.dsl.sea_surface_height_change_above_geoid = np.zeros((md.mesh.numberofvertices + 1, 1))
    2424md.dsl.sea_water_pressure_change_at_sea_floor = np.zeros((md.mesh.numberofvertices + 1, 1))
Note: See TracChangeset for help on using the changeset viewer.