Changeset 26299


Ignore:
Timestamp:
06/05/21 15:30:12 (4 years ago)
Author:
jdquinn
Message:

CHG: test2001 MATLAB -> Python; clean up

Location:
issm/trunk-jpl
Files:
10 edited

Legend:

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

    r26062 r26299  
    3333        end
    3434        methods
    35                 function self = extrude(self,md) % {{{
    36                         self.surface=project3d(md,'vector',self.surface,'type','node');
    37                         self.thickness=project3d(md,'vector',self.thickness,'type','node');
    38                         self.hydrostatic_ratio=project3d(md,'vector',self.hydrostatic_ratio,'type','node');
    39                         self.base=project3d(md,'vector',self.base,'type','node');
    40                         self.bed=project3d(md,'vector',self.bed,'type','node');
    41                 end % }}}
    4235                function self = geometry(varargin) % {{{
    4336                        switch nargin
     
    9992                        WriteData(fid,prefix,'object',self,'fieldname','hydrostatic_ratio','format','DoubleMat','mattype',1);
    10093                end % }}}
     94                function self = extrude(self,md) % {{{
     95                        self.surface=project3d(md,'vector',self.surface,'type','node');
     96                        self.thickness=project3d(md,'vector',self.thickness,'type','node');
     97                        self.hydrostatic_ratio=project3d(md,'vector',self.hydrostatic_ratio,'type','node');
     98                        self.base=project3d(md,'vector',self.base,'type','node');
     99                        self.bed=project3d(md,'vector',self.bed,'type','node');
     100                end % }}}
    101101                function savemodeljs(self,fid,modelname) % {{{
    102102               
  • issm/trunk-jpl/src/m/classes/geometry.py

    r26059 r26299  
    2121        self.hydrostatic_ratio = np.nan
    2222
    23         nargs = len(args)
    24         if nargs == 0:
     23        if len(args) == 0:
    2524            self.setdefaultparameters()
    2625        else:
     
    3736    #}}}
    3837
    39     def extrude(self, md): #{{{
    40         self.surface = project3d(md, 'vector', self.surface, 'type', 'node')
    41         self.thickness = project3d(md, 'vector', self.thickness, 'type', 'node')
    42         self.hydrostatic_ratio = project3d(md, 'vector', self.hydrostatic_ratio, 'type', 'node')
    43         self.base = project3d(md, 'vector', self.base, 'type', 'node')
    44         self.bed = project3d(md, 'vector', self.bed, 'type', 'node')
    45         return self
    46     #}}}
    47 
    4838    def setdefaultparameters(self): #{{{
    4939        return self
     
    5646            md = checkfield(md, 'fieldname', 'geometry.surface', 'NaN', 1, 'Inf', 1, 'size', [md.mesh.numberofvertices])
    5747            md = checkfield(md, 'fieldname', 'geometry.base', 'NaN', 1, 'Inf', 1, 'size', [md.mesh.numberofvertices])
    58             md = checkfield(md, 'fieldname', 'geometry.thickness', 'NaN', 1, 'Inf', 1, 'size', [md.mesh.numberofvertices], '>', 0, 'timeseries', 1)
    59             if any(abs(self.thickness - self.surface + self.base) > 10**-9):
    60                 md.checkmessage("equality thickness = surface-base violated")
     48            md = checkfield(md, 'fieldname', 'geometry.thickness', 'NaN', 1, 'Inf', 1, 'size', [md.mesh.numberofvertices], '>=', 0)
     49            if any(abs(self.thickness - self.surface + self.base) > 1e-9):
     50                md.checkmessage('equality thickness = surface-base violated')
    6151            if solution == 'TransientSolution' and md.transient.isgroundingline:
    6252                md = checkfield(md, 'fieldname', 'geometry.bed', 'NaN', 1, 'Inf', 1, 'size', [md.mesh.numberofvertices])
    63                 if np.any(self.bed - self.base > 10**-12):
     53                if np.any(self.bed - self.base > 1e-12):
    6454                    md.checkmessage('base < bed on one or more vertex')
    6555                pos = np.where(md.mask.ocean_levelset > 0)
    66                 if np.any(np.abs(self.bed[pos] - self.base[pos]) > 10**-9):
     56                if np.any(np.abs(self.bed[pos] - self.base[pos]) > 1e-9):
    6757                    md.checkmessage('equality base = bed on grounded ice violated')
    6858                md = checkfield(md, 'fieldname', 'geometry.bed', 'NaN', 1, 'Inf', 1, 'size', [md.mesh.numberofvertices])
     
    7161
    7262    def marshall(self, prefix, md, fid): #{{{
    73         if (len(self.thickness) == md.mesh.numberofvertices) or (len(self.thickness) == md.mesh.numberofvertices + 1):
     63        length_thickness = len(self.thickness)
     64        if (length_thickness == md.mesh.numberofvertices) or (length_thickness == md.mesh.numberofvertices + 1):
    7465            WriteData(fid, prefix, 'object', self, 'fieldname', 'thickness', 'format', 'DoubleMat', 'mattype', 1, 'timeserieslength', md.mesh.numberofvertices + 1, 'yts', md.constants.yts)
    75         elif (len(self.thickness) == md.mesh.numberofelements) or (len(self.thickness) == md.mesh.numberofelements + 1):
     66        elif (length_thickness == md.mesh.numberofelements) or (length_thickness == md.mesh.numberofelements + 1):
    7667            WriteData(fid, prefix, 'object', self, 'fieldname', 'thickness', 'format', 'DoubleMat', 'mattype', 1, 'timeserieslength', md.mesh.numberofvertices + 1, 'yts', md.constants.yts)
    7768        else:
     
    8374        WriteData(fid, prefix, 'object', self, 'fieldname', 'hydrostatic_ratio', 'format', 'DoubleMat', 'mattype', 1)
    8475    # }}}
     76
     77    def extrude(self, md): #{{{
     78        self.surface = project3d(md, 'vector', self.surface, 'type', 'node')
     79        self.thickness = project3d(md, 'vector', self.thickness, 'type', 'node')
     80        self.hydrostatic_ratio = project3d(md, 'vector', self.hydrostatic_ratio, 'type', 'node')
     81        self.base = project3d(md, 'vector', self.base, 'type', 'node')
     82        self.bed = project3d(md, 'vector', self.bed, 'type', 'node')
     83        return self
     84    #}}}
  • issm/trunk-jpl/src/m/classes/materials.m

    r26233 r26299  
    9696
    9797                                        %ice latent heat of fusion L (J/kg)
    98                                         self.latentheat=3.34*10^5;
     98                                        self.latentheat=3.34*1e5;
    9999
    100100                                        %ice thermal conductivity (W/m/K)
     
    111111
    112112                                        %rate of change of melting point with pressure (K/Pa)
    113                                         self.beta=9.8*10^-8;
     113                                        self.beta=9.8*1e-8;
    114114
    115115                                        %mixed layer (ice-water interface) heat capacity (J/kg/K)
     
    117117
    118118                                        %thermal exchange velocity (ice-water interface) (m/s)
    119                                         self.thermal_exchange_velocity=1.00*10^-4;
     119                                        self.thermal_exchange_velocity=1.00*1e-4;
    120120
    121121                                        %Rheology law: what is the temperature dependence of B with T
     
    124124
    125125                                        %Rheology fields default:
    126                                         self.rheology_B   = 1*1e8;
     126                                        self.rheology_B   = 1 * 1e8;
    127127                                        self.rheology_n   = 3;
    128128
     
    136136
    137137                                        self.viscosity=[1e21;1e40]; %mantle and lithosphere viscosity (respectively) [Pa.s]
    138                                         self.lame_mu=[1.45*1e11;6.7*10^10];  % (Pa) %lithosphere and mantle shear modulus (respectively) [Pa]
     138                                        self.lame_mu=[1.45*1e11;6.7*1e10];  % (Pa) %lithosphere and mantle shear modulus (respectively) [Pa]
    139139                                        self.lame_lambda=self.lame_mu;  % (Pa) %mantle and lithosphere lamba parameter (respectively) [Pa]
    140140                                        self.burgers_viscosity=[NaN;NaN];
     
    193193                                case 'litho'
    194194                                        disp(sprintf('   \nLitho:'));
    195                                         fielddisplay(self,'numlayers','number of layers (default 2)');
     195                                        fielddisplay(self,'numlayers','number of layers (default: 2)');
    196196                                        fielddisplay(self,'radius','array describing the radius for each interface (numlayers+1) [m]');
    197197                                        fielddisplay(self,'viscosity','array describing each layer''s viscosity (numlayers) [Pa.s]');
     
    207207
    208208
    209                                         fielddisplay(self,'rheologymodel','array describing whether we adopt a MaxWell (0), Burgers (1) or EBM (2) rheology (default 0)');
     209                                        fielddisplay(self,'rheologymodel','array describing whether we adopt a Maxwell (0), Burgers (1) or EBM (2) rheology (default: 0)');
    210210                                        fielddisplay(self,'density','array describing each layer''s density (numlayers) [kg/m^3]');
    211211                                        fielddisplay(self,'issolid','array describing whether the layer is solid or liquid (default 1) (numlayers)');
     
    261261                                        end
    262262                                        if md.materials.issolid(1)==0 | md.materials.lame_mu(1)==0
    263                                                         error('First layer must be solid (issolid(1) > 0 AND lame_mu(1) > 0). Add a weak inner core if necessary.');
     263                                                error('First layer must be solid (issolid(1) > 0 AND lame_mu(1) > 0). Add a weak inner core if necessary.');
    264264                                        end
    265265                                        ind=find(md.materials.issolid==0);
    266266                                        if sum(ismember(diff(ind),1)>=1) %if there are at least two consecutive indices that contain issolid = 0
    267                                                         error(['Fluid layers detected at layers #', num2str(ind'), ', but having 2 or more adjacent fluid layers is not supported yet. Consider merging them.'])
     267                                                error(['Fluid layers detected at layers #', num2str(ind'), ', but having 2 or more adjacent fluid layers is not supported yet. Consider merging them.'])
    268268                                        end
    269269
     
    323323                                        earth_density=0;
    324324                                        for i=1:self.numlayers,
    325                                                 earth_density=earth_density+ (self.radius(i+1)^3-self.radius(i)^3)*self.density(i);
     325                                                earth_density=earth_density + (self.radius(i+1)^3-self.radius(i)^3)*self.density(i);
    326326                                        end
    327327                                        earth_density=earth_density/self.radius(self.numlayers+1)^3;
     
    565565        for i=1:length(strnat),
    566566                switch strnat{i},
    567                         case 'damageice'
     567                case 'damageice'
    568568                        intnat(i)=1;
    569569                case 'estar'
  • issm/trunk-jpl/src/m/classes/materials.py

    r26059 r26299  
    1616    def __init__(self, *args): #{{{
    1717        self.nature = []
    18         if not len(args):
     18        if len(args) == 0:
    1919            self.nature = ['ice']
    2020        else:
     
    2525                raise RuntimeError("materials constructor error message: nature of the material not supported yet! ('ice' or 'litho' or 'hydro')")
    2626
    27         #start filling in the dynamic fields:
    28         for i in range(len(self.nature)):
    29             nat = self.nature[i]
    30             if nat == 'ice':
    31                 setattr(self, 'rho_ice', 0)
    32                 setattr(self, 'rho_water', 0)
    33                 setattr(self, 'rho_freshwater', 0)
    34                 setattr(self, 'mu_water', 0)
    35                 setattr(self, 'heatcapacity', 0)
    36                 setattr(self, 'latentheat', 0)
    37                 setattr(self, 'thermalconductivity', 0)
    38                 setattr(self, 'temperateiceconductivity', 0)
    39                 setattr(self, 'effectiveconductivity_averaging', 0)
    40                 setattr(self, 'meltingpoint', 0)
    41                 setattr(self, 'beta', 0)
    42                 setattr(self, 'mixed_layer_capacity', 0)
    43                 setattr(self, 'thermal_exchange_velocity', 0)
    44                 setattr(self, 'rheology_B', 0)
    45                 setattr(self, 'rheology_n', 0)
    46                 setattr(self, 'rheology_law', 0)
    47             elif nat == 'litho':
    48                 setattr(self, 'numlayers', 0)
    49                 setattr(self, 'radius', 0)
    50                 setattr(self, 'viscosity', 0)
    51                 setattr(self, 'lame_lambda', 0)
    52                 setattr(self, 'lame_mu', 0)
    53                 setattr(self, 'burgers_viscosity', 0)
    54                 setattr(self, 'burgers_mu', 0)
    55                 setattr(self, 'isburgers', 0)
    56                 setattr(self, 'density', 0)
    57                 setattr(self, 'issolid', 0)
    58             elif nat == 'hydro':
    59                 setattr(self, 'rho_ice', 0)
    60                 setattr(self, 'rho_water', 0)
    61                 setattr(self, 'rho_freshwater', 0)
     27        for i in range(len(self.nature)):
     28            nat = self.nature[i]
     29            if nat == 'ice':
     30                self.rho_ice = 0
     31                self.rho_water = 0
     32                self.rho_freshwater = 0
     33                self.mu_water = 0
     34                self.heatcapacity = 0
     35                self.latentheat = 0
     36                self.thermalconductivity = 0
     37                self.temperateiceconductivity = 0
     38                self.effectiveconductivity_averaging = 0
     39                self.meltingpoint = 0
     40                self.beta = 0
     41                self.mixed_layer_capacity = 0
     42                self.thermal_exchange_velocity = 0
     43                self.rheology_B = 0
     44                self.rheology_n = 0
     45                self.rheology_law = 0
     46            elif nat == 'litho':
     47                self.numlayers = 0
     48                self.radius = 0
     49                self.viscosity = 0
     50                self.lame_lambda = 0
     51                self.lame_mu = 0
     52                self.burgers_viscosity = 0
     53                self.burgers_mu = 0
     54                self.ebm_alpha = 0
     55                self.ebm_delta = 0
     56                self.ebm_taul = 0
     57                self.ebm_tauh = 0
     58                self.rheologymodel = 0
     59                self.density = 0
     60                self.issolid = 0
     61            elif nat == 'hydro':
     62                self.rho_ice = 0
     63                self.rho_water = 0
     64                self.rho_freshwater = 0
    6265            else:
    6366                raise RuntimeError("materials constructor error message: nature of the material not supported yet! ('ice' or 'litho' or 'hydro')")
    64         setattr(self, 'earth_density', 0)
    65 
    66         #set default parameters:
     67        self.earth_density = 0
     68
     69        # Set default parameters
    6770        self.setdefaultparameters()
    6871    #}}}
    6972
     73    def __repr__(self): #{{{
     74        s = '   Materials:\n'
     75        for i in range(len(self.nature)):
     76            nat = self.nature[i]
     77            if nat == 'ice':
     78                s += 'Ice:\n'
     79                s += '{}\n'.format(fielddisplay(self, 'rho_ice', 'ice density [kg/m^3]'))
     80                s += '{}\n'.format(fielddisplay(self, 'rho_water', 'ocean water density [kg/m^3]'))
     81                s += '{}\n'.format(fielddisplay(self, 'rho_freshwater', 'fresh water density [kg/m^3]'))
     82                s += '{}\n'.format(fielddisplay(self, 'mu_water', 'water viscosity [N s/m^2]'))
     83                s += '{}\n'.format(fielddisplay(self, 'heatcapacity', 'heat capacity [J/kg/K]'))
     84                s += '{}\n'.format(fielddisplay(self, 'thermalconductivity', 'ice thermal conductivity [W/m/K]'))
     85                s += '{}\n'.format(fielddisplay(self, 'temperateiceconductivity', 'temperate ice thermal conductivity [W/m/K]'))
     86                s += '{}\n'.format(fielddisplay(self, 'meltingpoint', 'melting point of ice at 1atm in K'))
     87                s += '{}\n'.format(fielddisplay(self, 'latentheat', 'latent heat of fusion [J/m^3]'))
     88                s += '{}\n'.format(fielddisplay(self, 'beta', 'rate of change of melting point with pressure [K/Pa]'))
     89                s += '{}\n'.format(fielddisplay(self, 'mixed_layer_capacity', 'mixed layer capacity [W/kg/K]'))
     90                s += '{}\n'.format(fielddisplay(self, 'thermal_exchange_velocity', 'thermal exchange velocity [m/s]'))
     91                s += '{}\n'.format(fielddisplay(self, 'rheology_B', 'flow law parameter [Pa s^(1/n)]'))
     92                s += '{}\n'.format(fielddisplay(self, 'rheology_n', 'Glen\'s flow law exponent'))
     93                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\''))
     94            elif nat == 'litho':
     95                s += 'Litho:\n'
     96                s += '{}\n'.format(fielddisplay(self, 'numlayers', 'number of layers (default: 2)'))
     97                s += '{}\n'.format(fielddisplay(self, 'radius', 'array describing the radius for each interface (numlayers + 1) [m]'))
     98                s += '{}\n'.format(fielddisplay(self, 'viscosity', 'array describing each layer\'s viscosity (numlayers) [Pa.s]'))
     99                s += '{}\n'.format(fielddisplay(self, 'lame_lambda', 'array describing the lame lambda parameter (numlayers) [Pa]'))
     100                s += '{}\n'.format(fielddisplay(self, 'lame_mu', 'array describing the shear modulus for each layers (numlayers) [Pa]'))
     101                s += '{}\n'.format(fielddisplay(self, 'burgers_viscosity', 'array describing each layer\'s transient viscosity, only for Burgers rheologies  (numlayers) [Pa.s]'))
     102                s += '{}\n'.format(fielddisplay(self, 'burgers_mu', 'array describing each layer\'s transient shear modulus, only for Burgers rheologies  (numlayers) [Pa]'))
     103
     104                s += '{}\n'.format(fielddisplay(self, 'ebm_alpha', 'array describing each layer\'s exponent parameter controlling the shape of shear modulus curve between taul and tauh, only for EBM rheology (numlayers)'))
     105                s += '{}\n'.format(fielddisplay(self, 'ebm_delta', 'array describing each layer\'s amplitude of the transient relaxation (ratio between elastic rigity to pre-maxwell relaxation rigity), only for EBM rheology (numlayers)'))
     106                s += '{}\n'.format(fielddisplay(self, 'ebm_taul', 'array describing each layer\'s starting period for transient relaxation, only for EBM rheology  (numlayers) [s]'))
     107                s += '{}\n'.format(fielddisplay(self, 'ebm_tauh', 'array describing each layer''s array describing each layer\'s end period for transient relaxation, only for Burgers rheology  (numlayers) [s]'))
     108
     109                s += '{}\n'.format(fielddisplay(self, 'rheologymodel', 'array describing whether we adopt a Maxwell (0), Burgers (1) or EBM (2) rheology (default: 0)'))
     110                s += '{}\n'.format(fielddisplay(self, 'density', 'array describing each layer\'s density (numlayers) [kg/m^3]'))
     111                s += '{}\n'.format(fielddisplay(self, 'issolid', 'array describing whether the layer is solid or liquid (default 1) (numlayers)'))
     112            elif nat == 'hydro':
     113                s += 'Hydro:\n'
     114                s += '{}\n'.format(fielddisplay(self, 'rho_ice', 'ice density [kg/m^3]'))
     115                s += '{}\n'.format(fielddisplay(self, 'rho_water', 'ocean water density [kg/m^3]'))
     116                s += '{}\n'.format(fielddisplay(self, 'earth_density', 'mantle density [kg/m^3]'))
     117                s += '{}\n'.format(fielddisplay(self, 'rho_freshwater', 'fresh water density [kg/m^3]'))
     118
     119            else:
     120                raise RuntimeError('materials constructor error message: nature of the material not supported yet! (\'ice\' or \'litho\' or \'hydro\')')
     121        return s
     122    #}}}
     123
    70124    def setdefaultparameters(self): #{{{
    71125        for i in range(len(self.nature)):
    72126            nat = self.nature[i]
    73127            if nat == 'ice':
    74                 #ice density (kg/m^3)
     128                # Ice density (kg/m^3)
    75129                self.rho_ice = 917.
    76130
    77                 #ocean water density (kg/m^3)
     131                # Ocean water density (kg/m^3)
    78132                self.rho_water = 1023.
    79133
    80                 #fresh water density (kg/m^3)
     134                # Fresh water density (kg/m^3)
    81135                self.rho_freshwater = 1000.
    82136
    83                 #water viscosity (N.s/m^2)
     137                # Water viscosity (N.s/m^2)
    84138                self.mu_water = 0.001787
    85139
    86                 #ice heat capacity cp (J/kg/K)
     140                # Ice heat capacity cp (J/kg/K)
    87141                self.heatcapacity = 2093.
    88142
    89                 #ice latent heat of fusion L (J / kg)
    90                 self.latentheat = 3.34e5
    91 
    92                 #ice thermal conductivity (W/m/K)
     143                # Ice latent heat of fusion L (J/kg)
     144                self.latentheat = 3.34 * 1e5
     145
     146                # Ice thermal conductivity (W/m/K)
    93147                self.thermalconductivity = 2.4
    94148
    95                 #wet ice thermal conductivity (W/m/K)
     149                # Wet ice thermal conductivity (W/m/K)
    96150                self.temperateiceconductivity = 0.24
    97151
    98                 #computation of effective conductivity
     152                # Computation of effective conductivity
    99153                self.effectiveconductivity_averaging = 1
    100154
    101                 #the melting point of ice at 1 atmosphere of pressure in K
     155                # The melting point of ice at 1 atmosphere of pressure in K
    102156                self.meltingpoint = 273.15
    103157
    104                 #rate of change of melting point with pressure (K/Pa)
    105                 self.beta = 9.8e-8
    106 
    107                 #mixed layer (ice-water interface) heat capacity (J/kg/K)
     158                # Rate of change of melting point with pressure (K/Pa)
     159                self.beta = 9.8 * 1e-8
     160
     161                # Mixed layer (ice-water interface) heat capacity (J/kg/K)
    108162                self.mixed_layer_capacity = 3974.
    109163
    110                 #thermal exchange velocity (ice-water interface) (m/s)
    111                 self.thermal_exchange_velocity = 1.00e-4
    112 
    113                 #Rheology law: what is the temperature dependence of B with T
    114                 #available: none, paterson and arrhenius
     164                # Thermal exchange velocity (ice-water interface) (m/s)
     165                self.thermal_exchange_velocity = 1.00 * 1e-4
     166
     167                # Rheology law: what is the temperature dependence of B with T
     168                # available: none, paterson and arrhenius
    115169                self.rheology_law = 'Paterson'
    116170
    117                 #Rheology fields default
    118                 self.rheology_B = 1e8
     171                # Rheology fields default
     172                self.rheology_B = 1 * 1e8
    119173                self.rheology_n = 3
    120174            elif nat == 'litho':
    121                 #we default to a configuration that enables running GIA solutions using giacaron and/or giaivins.
     175                # We default to a configuration that enables running GIA
     176                # solutions using giacaron and/or giaivins
    122177                self.numlayers = 2
    123178
    124                 #center of the earth (approximation, must not be 0), then the lab (lithosphere / asthenosphere boundary) then the surface
    125                 #(with 1d3 to avoid numerical singularities)
    126                 self.radius = [1e3, 6278e3, 6378e3]
    127 
    128                 self.viscosity = [1e21, 1e40]  #mantle and lithosphere viscosity (respectively) [Pa.s]
    129                 self.lame_mu = [1.45e11, 6.7e10]  # (Pa)  #lithosphere and mantle shear modulus (respectively) [Pa]
    130                 self.lame_lambda = self.lame_mu  # (Pa)  #mantle and lithosphere lamba parameter (respectively) [Pa]
     179                # Center of the earth (approximation, must not be 0), then the
     180                # lab (lithosphere/asthenosphere boundary) then the surface
     181                # (with 1d3 to avoid numerical singularities)
     182                self.radius = [1e3, 6278 * 1e3, 6378 * 1e3]
     183
     184                self.viscosity = [1e21, 1e40] # Mantle and lithosphere viscosity (respectively) [Pa.s]
     185                self.lame_mu = [1.45 * 1e11, 6.7 * 1e10] # (Pa) # Lithosphere and mantle shear modulus (respectively) [Pa]
     186                self.lame_lambda = self.lame_mu # (Pa) # Mantle and lithosphere lamba parameter (respectively) [Pa]
    131187                self.burgers_viscosity = [np.nan, np.nan]
    132188                self.burgers_mu = [np.nan, np.nan]
    133                 self.isburgers = [0, 0]
    134                 self.density = [5.51e3, 5.50e3]  # (Pa)  #mantle and lithosphere density [kg/m^3]
    135                 self.issolid = [1, 1]  # is layer solid or liquid.
    136             elif nat == 'hydro':
    137                 #ice density (kg/m^3)
     189
     190                self.ebm_alpha = [np.nan, np.nan]
     191                self.ebm_delta = [np.nan, np.nan]
     192                self.ebm_taul = [np.nan, np.nan]
     193                self.ebm_tauh = [np.nan, np.nan]
     194                self.rheologymodel = [0, 0]
     195                self.density = [5.51e3, 5.50e3]  # (Pa) # Mantle and lithosphere density [kg/m^3]
     196                self.issolid = [1, 1]  # Is layer solid or liquid?
     197            elif nat == 'hydro':
     198                # Ice density (kg/m^3)
    138199                self.rho_ice = 917.
    139200
    140                 #ocean water density (kg/m^3)
     201                # Ocean water density (kg/m^3)
    141202                self.rho_water = 1023.
    142203
    143                 #fresh water density (kg/m^3)
     204                # Fresh water density (kg/m^3)
    144205                self.rho_freshwater = 1000.
    145206            else:
    146207                raise RuntimeError("materials setdefaultparameters error message: nature of the material not supported yet! ('ice' or 'litho' or 'hydro')")
    147208
    148             #average density of the Earth (kg/m^3)
     209            # Average density of the Earth (kg/m^3)
    149210            self.earth_density = 5512
    150     #}}}
    151 
    152     def __repr__(self): #{{{
    153         string = "   Materials:"
    154         for i in range(len(self.nature)):
    155             nat = self.nature[i]
    156             if nat == 'ice':
    157                 string = "%s\n%s" % (string, 'Ice:')
    158                 string = "%s\n%s" % (string, fielddisplay(self, "rho_ice", "ice density [kg/m^3]"))
    159                 string = "%s\n%s" % (string, fielddisplay(self, "rho_water", "ocean water density [kg/m^3]"))
    160                 string = "%s\n%s" % (string, fielddisplay(self, "rho_freshwater", "fresh water density [kg/m^3]"))
    161                 string = "%s\n%s" % (string, fielddisplay(self, "mu_water", "water viscosity [N s/m^2]"))
    162                 string = "%s\n%s" % (string, fielddisplay(self, "heatcapacity", "heat capacity [J/kg/K]"))
    163                 string = "%s\n%s" % (string, fielddisplay(self, "thermalconductivity", "ice thermal conductivity [W/m/K]"))
    164                 string = "%s\n%s" % (string, fielddisplay(self, "temperateiceconductivity", "temperate ice thermal conductivity [W/m/K]"))
    165                 string = "%s\n%s" % (string, fielddisplay(self, "meltingpoint", "melting point of ice at 1atm in K"))
    166                 string = "%s\n%s" % (string, fielddisplay(self, "latentheat", "latent heat of fusion [J/m^3]"))
    167                 string = "%s\n%s" % (string, fielddisplay(self, "beta", "rate of change of melting point with pressure [K/Pa]"))
    168                 string = "%s\n%s" % (string, fielddisplay(self, "mixed_layer_capacity", "mixed layer capacity [W/kg/K]"))
    169                 string = "%s\n%s" % (string, fielddisplay(self, "thermal_exchange_velocity", "thermal exchange velocity [m/s]"))
    170                 string = "%s\n%s" % (string, fielddisplay(self, "rheology_B", "flow law parameter [Pa s^(1/n)]"))
    171                 string = "%s\n%s" % (string, fielddisplay(self, "rheology_n", "Glen's flow law exponent"))
    172                 string = "%s\n%s" % (string, fielddisplay(self, "rheology_law", "law for the temperature dependance of the rheology: 'None', 'BuddJacka', 'Cuffey', 'CuffeyTemperate', 'Paterson', 'Arrhenius', 'LliboutryDuval', 'NyeCO2', or 'NyeH2O'"))
    173             elif nat == 'litho':
    174                 string = "%s\n%s" % (string, 'Litho:')
    175                 string = "%s\n%s" % (string, fielddisplay(self, 'numlayers', 'number of layers (default 2)'))
    176                 string = "%s\n%s" % (string, fielddisplay(self, 'radius', 'array describing the radius for each interface (numlayers + 1) [m]'))
    177                 string = "%s\n%s" % (string, fielddisplay(self, 'viscosity', 'array describing each layer''s viscosity (numlayers) [Pa.s]'))
    178                 string = "%s\n%s" % (string, fielddisplay(self, 'lame_lambda', 'array describing the lame lambda parameter (numlayers) [Pa]'))
    179                 string = "%s\n%s" % (string, fielddisplay(self, 'lame_mu', 'array describing the shear modulus for each layers (numlayers) [Pa]'))
    180                 string = "%s\n%s" % (string, fielddisplay(self, 'burgers_viscosity', 'array describing each layer''s transient viscosity, only for Burgers rheologies  (numlayers) [Pa.s]'))
    181                 string = "%s\n%s" % (string, fielddisplay(self, 'burgers_mu', 'array describing each layer''s transient shear modulus, only for Burgers rheologies  (numlayers) [Pa]'))
    182                 string = "%s\n%s" % (string, fielddisplay(self, 'isburgers', 'array describing whether we adopt a MaxWell (0) or Burgers (1) rheology (default 0)'))
    183                 string = "%s\n%s" % (string, fielddisplay(self, 'density', 'array describing each layer''s density (numlayers) [kg/m^3]'))
    184                 string = "%s\n%s" % (string, fielddisplay(self, 'issolid', 'array describing whether the layer is solid or liquid (default 1) (numlayers)'))
    185             elif nat == 'hydro':
    186                 string = "%s\n%s" % (string, 'Hydro:')
    187                 string = "%s\n%s" % (string, fielddisplay(self, "rho_ice", "ice density [kg/m^3]"))
    188                 string = "%s\n%s" % (string, fielddisplay(self, "rho_water", "ocean water density [kg/m^3]"))
    189                 string = "%s\n%s" % (string, fielddisplay(self, "earth_density", "mantle density [kg/m^3]"))
    190                 string = "%s\n%s" % (string, fielddisplay(self, "rho_freshwater", "fresh water density [kg/m^3]"))
    191 
    192             else:
    193                 raise RuntimeError("materials constructor error message: nature of the material not supported yet! ('ice' or 'litho' or 'hydro')")
    194 
    195         return string
    196211    #}}}
    197212
     
    218233                md = checkfield(md, 'fieldname', 'materials.density', 'NaN', 1, 'Inf', 1, 'size', [md.materials.numlayers, 1], '>', 0)
    219234                md = checkfield(md, 'fieldname', 'materials.viscosity', 'NaN', 1, 'Inf', 1, 'size', [md.materials.numlayers, 1], '>=', 0)
    220                 md = checkfield(md, 'fieldname', 'materials.isburgers', 'NaN', 1, 'Inf', 1, 'size', [md.materials.numlayers, 1], '>=', 0, '<=', 1)
     235                md = checkfield(md, 'fieldname', 'materials.rheologymodel', 'NaN', 1, 'Inf', 1, 'size', [md.materials.numlayers, 1], '>=', 0, '<=', 2)
    221236                md = checkfield(md, 'fieldname', 'materials.burgers_viscosity', 'Inf', 1, 'size', [md.materials.numlayers, 1], '>=', 0)
    222237                md = checkfield(md, 'fieldname', 'materials.burgers_mu', 'Inf', 1, 'size', [md.materials.numlayers, 1], '>=', 0)
     238                md = checkfield(md, 'fieldname', 'materials.ebm_alpha', 'Inf', 1, 'size', [md.materials.numlayers, 1], '>=', 0)
     239                md = checkfield(md, 'fieldname', 'materials.ebm_delta', 'Inf', 1, 'size', [md.materials.numlayers, 1], '>=', 0)
     240                md = checkfield(md, 'fieldname', 'materials.ebm_taul', 'Inf', 1, 'size', [md.materials.numlayers, 1], '>=', 0)
     241                md = checkfield(md, 'fieldname', 'materials.ebm_tauh', 'Inf', 1, 'size', [md.materials.numlayers, 1], '>=', 0)
    223242
    224243                for i in range(md.materials.numlayers):
    225                     if md.materials.isburgers[i] and (np.isnan(md.materials.burgers_viscosity[i] or np.isnan(md.materials.burgers_mu[i]))):
    226                         raise RuntimeError("materials checkconsistency error message: Litho burgers_viscosity or burgers_mu has NaN values, inconsistent with isburgers choice")
    227 
    228                     if md.materials.issolid[0] == 0 or md.materials.lame_mu[0] == 0:
    229                         raise RuntimeError('First layer must be solid (issolid(1) > 0 AND lame_mu(1) > 0). Add a weak inner core if necessary.')
    230 
    231                     for i in range(md.materials.numlayers - 1):
    232                         if (not md.materials.issolid[i]) and (not md.materials.issolid[i + 1]):  #if there are at least two consecutive indices that contain issolid = 0
    233                             raise RuntimeError("%s%i%s" % ('2 or more adjacent fluid layers detected starting at layer ', i, '. This is not supported yet. Consider merging them.'))
     244                    if md.materials.rheologymodel[i] == 1 and (np.isnan(md.materials.burgers_viscosity[i] or np.isnan(md.materials.burgers_mu[i]))):
     245                        raise RuntimeError('materials checkconsistency error message: Litho burgers_viscosity or burgers_mu has NaN values, inconsistent with rheologymodel choice')
     246
     247                    if md.materials.rheologymodel[i] == 2 and (np.isnan(md.materials.ebm_alpha[i]) or np.isnan(md.materials.ebm_delta[i]) or np.isnan(md.materials.ebm_taul[i]) or np.isnan(md.materials.ebm_tauh[i])):
     248                        raise RuntimeError('materials checkconsistency error message: Litho ebm_alpha, ebm_delta, ebm_taul or ebm_tauh has NaN values, inconsistent with rheologymodel choice')
     249                if md.materials.issolid[0] == 0 or md.materials.lame_mu[0] == 0:
     250                    raise RuntimeError('First layer must be solid (issolid[0] > 0 AND lame_mu[0] > 0). Add a weak inner core if necessary.')
     251                ind = np.where(md.materials.issolid == 0)[0]
     252                if np.sum(np.in1d(np.diff(ind),1) >= 1): # If there are at least two consecutive indices that contain issolid = 0
     253                    raise RuntimeError('Fluid layers detected at layers #{} but having 2 or more adjacent fluid layers is not supported yet. Consider merging them.'.format(i))
     254
    234255            elif nat == 'hydro':
    235256                md = checkfield(md, 'fieldname', 'materials.rho_ice', '>', 0)
     
    238259                md = checkfield(md, 'fieldname', 'materials.rho_freshwater', '>', 0)
    239260            else:
    240                 raise RuntimeError("materials checkconsistency error message: nature of the material not supported yet! ('ice' or 'litho' or 'hydro')")
     261                raise RuntimeError('materials checkconsistency error message: nature of the material not supported yet! (\'ice\' or \'litho\' or \'hydro\')')
    241262
    242263        return md
     
    250271            nat = self.nature[i]
    251272            if nat == 'ice':
    252                 WriteData(fid, prefix, 'name', 'md.materials.type', 'data', 3, 'format', 'Integer')
    253273                WriteData(fid, prefix, 'object', self, 'class', 'materials', 'fieldname', 'rho_ice', 'format', 'Double')
    254274                WriteData(fid, prefix, 'object', self, 'class', 'materials', 'fieldname', 'rho_water', 'format', 'Double')
     
    275295                WriteData(fid, prefix, 'object', self, 'class', 'materials', 'fieldname', 'density', 'format', 'DoubleMat', 'mattype', 3)
    276296                WriteData(fid, prefix, 'object', self, 'class', 'materials', 'fieldname', 'viscosity', 'format', 'DoubleMat', 'mattype', 3)
    277                 WriteData(fid, prefix, 'object', self, 'class', 'materials', 'fieldname', 'isburgers', 'format', 'DoubleMat', 'mattype', 3)
     297                WriteData(fid, prefix, 'object', self, 'class', 'materials', 'fieldname', 'rheologymodel', 'format', 'DoubleMat', 'mattype', 3)
    278298                WriteData(fid, prefix, 'object', self, 'class', 'materials', 'fieldname', 'burgers_viscosity', 'format', 'DoubleMat', 'mattype', 3)
    279299                WriteData(fid, prefix, 'object', self, 'class', 'materials', 'fieldname', 'burgers_mu', 'format', 'DoubleMat', 'mattype', 3)
     300                WriteData(fid, prefix, 'object', self, 'class', 'materials', 'fieldname', 'ebm_alpha', 'format', 'DoubleMat', 'mattype', 3)
     301                WriteData(fid, prefix, 'object', self, 'class', 'materials', 'fieldname', 'ebm_delta', 'format', 'DoubleMat', 'mattype', 3)
     302                WriteData(fid, prefix, 'object', self, 'class', 'materials', 'fieldname', 'ebm_taul', 'format', 'DoubleMat', 'mattype', 3)
     303                WriteData(fid, prefix, 'object', self, 'class', 'materials', 'fieldname', 'ebm_tauh', 'format', 'DoubleMat', 'mattype', 3)
    280304                # Compute earth density compatible with our layer density distribution
    281305                earth_density = 0
    282                 for i in range(len(self.numlayers)):
    283                     earth_density = earth_density + (self.radius[i + 1] ** 3 - self.radius[i] ** 3) * self.density[i]
    284                 earth_density = earth_density / self.radius[self.numlayers + 1] ** 3
     306                for i in range(self.numlayers):
     307                    earth_density = earth_density + (pow(self.radius[i + 1], 3) - pow(self.radius[i], 3)) * self.density[i]
     308                earth_density = earth_density / pow(self.radius[self.numlayers], 3)
    285309                self.earth_density = earth_density
    286310            elif nat == 'hydro':
     
    289313                WriteData(fid, prefix, 'object', self, 'class', 'materials', 'fieldname', 'rho_freshwater', 'format', 'Double')
    290314            else:
    291                 raise RuntimeError("materials constructor error message: nature of the material not supported yet! ('ice' or 'litho' or 'hydro')")
     315                raise RuntimeError('materials constructor error message: nature of the material not supported yet! (\'ice\' or \'litho\' or \'hydro\')')
    292316        WriteData(fid, prefix, 'data', self.earth_density, 'name', 'md.materials.earth_density', 'format', 'Double')
    293317    #}}}
     
    322346            intnat[i] = 7
    323347        else:
    324             raise RuntimeError("materials constructor error message: nature of the material not supported yet! ('ice' or 'litho' or 'hydro')")
     348            raise RuntimeError('materials constructor error message: nature of the material not supported yet! (\'ice\' or \'litho\' or \'hydro\')')
    325349
    326350    return intnat
  • issm/trunk-jpl/src/m/classes/solidearth.m

    r26099 r26299  
    8383                        end
    8484
    85                        
    8685                end % }}}
    8786                function list=defaultoutputs(self,md) % {{{
     
    107106                end % }}}
    108107                function marshall(self,prefix,md,fid) % {{{
    109                        
     108
    110109                        WriteData(fid,prefix,'object',self,'fieldname','planetradius','format','Double');
    111110                        WriteData(fid,prefix,'object',self,'fieldname','transitions','format','MatArray');
    112                
     111
    113112                        if ~isempty(self.partitionice),
    114113                                npartice=max(self.partitionice)+2;
     
    127126                        end
    128127
    129 
    130                        
    131128                        WriteData(fid,prefix,'object',self,'fieldname','partitionice','mattype',1,'format','DoubleMat');
    132129                        WriteData(fid,prefix,'data',npartice,'format','Integer','name','md.solidearth.npartice');
     
    135132                        WriteData(fid,prefix,'object',self,'fieldname','partitionocean','mattype',1,'format','DoubleMat');
    136133                        WriteData(fid,prefix,'data',npartocean,'format','Integer','name','md.solidearth.npartocean');
    137                        
     134
    138135                        self.settings.marshall(prefix,md,fid);
    139136                        self.lovenumbers.marshall(prefix,md,fid);
     
    145142                                WriteData(fid,prefix,'data',0,'format','Integer','name','md.solidearth.isexternal');
    146143                        end
    147                        
     144
    148145                        %process requested outputs
    149146                        outputs = self.requested_outputs;
    150                         pos  = find(ismember(outputs,'default'));
     147                        pos = find(ismember(outputs,'default'));
    151148                        if ~isempty(pos),
    152149                                outputs(pos) = [];                         %remove 'default' from outputs
     
    155152                        WriteData(fid,prefix,'data',outputs,'name','md.solidearth.requested_outputs','format','StringArray');
    156153
     154                end % }}}
     155                function self = extrude(self,md) % {{{
    157156                end % }}}
    158157                function savemodeljs(self,fid,modelname) % {{{
     
    168167                        writejscellarray(fid,[modelname '.solidearth.partition'],self.partition);
    169168                end % }}}
    170                 function self = extrude(self,md) % {{{
    171                 end % }}}
    172169        end
    173170end
  • issm/trunk-jpl/src/m/classes/solidearth.py

    r25969 r26299  
    1919    """
    2020
    21     def __init__(self, *args):  #{{{
    22         self.initialsealevel    = np.nan
     21    def __init__(self, *args): #{{{
    2322        self.settings           = solidearthsettings()
    2423        self.external           = []
    25         self.surfaceload        = surfaceload()
    2624        self.lovenumbers        = lovenumbers()
    2725        self.rotational         = rotational()
     
    3129        self.partitionice       = []
    3230        self.partitionhydro     = []
     31        self.partitionocean     = []
    3332
    3433        nargs = len(args)
    35 
    3634        if nargs == 0:
    3735            self.setdefaultparameters('earth')
     
    4139            raise Exception('solidearth constructor error message: zero or one argument only!')
    4240    #}}}
    43     def __repr__(self):  # {{{
     41    def __repr__(self): #{{{
    4442        s = '   solidearthinputs, forcings and settings:\n'
    45         s += '{}\n'.format(fielddisplay(self, 'initialsealevel', 'sea level at the start of computation [m]'))
    4643        s += '{}\n'.format(fielddisplay(self, 'planetradius', 'planet radius [m]'))
    4744        s += '{}\n'.format(fielddisplay(self, 'transitions', 'indices into parts of the mesh that will be icecaps'))
     
    4946        s += '{}\n'.format(fielddisplay(self, 'partitionice', 'ice partition vector for barystatic contribution'))
    5047        s += '{}\n'.format(fielddisplay(self, 'partitionhydro', 'hydro partition vector for barystatic contribution'))
     48        s += '{}\n'.format(fielddisplay(self, 'partitionocean', 'ocean partition vector for barystatic contribution'))
    5149        if not self.external:
    5250            s += '{}\n'.format(fielddisplay(self, 'external', 'external solution, of the type solidearthsolution'))
    5351        print(self.settings)
    54         print(self.surfaceload)
    5552        print(self.lovenumbers)
    5653        print(self.rotational)
     
    5956        return s
    6057    #}}}
    61     def setdefaultparameters(self, planet):  # {{{
    62         # Default output
     58    def setdefaultparameters(self, planet): #{{{
     59        # Output default
    6360        self.requested_outputs = ['default']
    6461
     
    6966        self.partitionice = []
    7067        self.partitionhydro = []
     68        self.partitionocean = []
    7169
    72         # No external solutions by defalt
     70        # No external solutions by default
    7371        self.external = []
    7472
     
    7674        self.planetradius = planetradius(planet)
    7775    #}}}
    78     def checkconsistency(self, md, solution, analyses):  # {{{
     76    def checkconsistency(self, md, solution, analyses): #{{{
    7977        if ('SealevelriseAnalysis' not in analyses) or (solution == 'TransientSolution' and not md.transient.isslc):
    8078            return md
    81         md = checkfield(md, 'fieldname', 'solidearth.initialsealevel', 'NaN', 1, 'Inf', 1, 'size', [md.mesh.numberofvertices])
     79
    8280        md = checkfield(md, 'fieldname', 'solidearth.requested_outputs', 'stringrow', 1)
    8381
    8482        self.settings.checkconsistency(md, solution, analyses)
    85         self.surfaceload.checkconsistency(md, solution, analyses)
    8683        self.lovenumbers.checkconsistency(md, solution, analyses)
    8784        self.rotational.checkconsistency(md, solution, analyses)
    8885        if self.external:
    89             if not isinstance(self.external,'solidearthsolution'):
     86            if not isinstance(self.external, 'solidearthsolution'):
    9087                raise Exception('solidearth consistency check: external field should be a solidearthsolution')
    9188            end
    92             self.external.checkconsistency(md,solution,analyses)
     89            self.external.checkconsistency(md, solution, analyses)
    9390        return md
    9491    #}}}
    95     def defaultoutputs(self, md):  #{{{
     92    def defaultoutputs(self, md): #{{{
    9693        return ['Sealevel']
    9794    #}}}
    98     def marshall(self, prefix, md, fid):  #{{{
    99         WriteData(fid, prefix, 'object', self, 'fieldname', 'initialsealevel', 'mattype', 1, 'format', 'DoubleMat', 'timeserieslength', md.mesh.numberofvertices + 1, 'yts', md.constants.yts)
     95    def marshall(self, prefix, md, fid): #{{{
    10096        WriteData(fid, prefix, 'object', self, 'fieldname', 'planetradius', 'format', 'Double')
    10197        WriteData(fid, prefix, 'object', self, 'fieldname', 'transitions', 'format', 'MatArray')
     
    111107            nparthydro = 0
    112108
     109        if len(self.partitionocean):
     110            npartocean = np.max(self.partitionocean) + 2
     111        else:
     112            npartocean = 0
     113
    113114        WriteData(fid, prefix, 'object', self, 'fieldname', 'partitionice', 'mattype', 1, 'format', 'DoubleMat');
    114115        WriteData(fid, prefix, 'data', npartice, 'format', 'Integer', 'name', 'md.solidearth.npartice');
    115116        WriteData(fid, prefix, 'object', self, 'fieldname', 'partitionhydro', 'mattype', 1, 'format', 'DoubleMat');
    116117        WriteData(fid, prefix, 'data', nparthydro,'format', 'Integer', 'name','md.solidearth.nparthydro');
     118        WriteData(fid, prefix, 'object', self, 'fieldname', 'partitionocean', 'mattype', 1, 'format', 'DoubleMat');
     119        WriteData(fid, prefix, 'data', npartocean,'format', 'Integer', 'name','md.solidearth.npartocean');
    117120
    118121        self.settings.marshall(prefix, md, fid)
    119         self.surfaceload.marshall(prefix, md, fid)
    120122        self.lovenumbers.marshall(prefix, md, fid)
    121123        self.rotational.marshall(prefix, md, fid)
    122124        if self.external:
     125            WriteData(fid, prefix, 'data', 1, 'format', 'Integer', 'name', 'md.solidearth.isexternal')
    123126            self.external.marshall(prefix, md, fid)
     127        else:
     128            WriteData(fid, prefix, 'data', 0, 'format', 'Integer', 'name', 'md.solidearth.isexternal')
    124129
    125130        #process requested outputs
     
    127132        pos = np.where(np.asarray(outputs) == 'default')[0]
    128133        if len(pos):
    129             outputs = np.delete(outputs, pos)  #remove 'default' from outputs
    130             outputs = np.append(outputs, self.defaultoutputs(md))  #add defaults
     134            outputs = np.delete(outputs, pos)  # remove 'default' from outputs
     135            outputs = np.append(outputs, self.defaultoutputs(md)) # add defaults
    131136        WriteData(fid, prefix, 'data', outputs, 'name', 'md.solidearth.requested_outputs', 'format', 'StringArray')
    132137    #}}}
    133138    def extrude(self, md): #{{{
    134         self.initialsealevel = project3d(md, 'vector', self.initialsealevel, 'type', 'node')
    135139        return self
    136140    #}}}
  • issm/trunk-jpl/src/m/classes/solidearthsettings.m

    r26296 r26299  
    55
    66classdef solidearthsettings
    7         properties (SetAccess=public) 
     7        properties (SetAccess=public)
    88                reltol                 = 0;
    99                abstol                 = 0;
     
    1313                viscous                = 1;
    1414                rotation               = 1;
    15                 grdocean               = 1;
     15                grdocean               = 1;
    1616                ocean_area_scaling     = 0;
    1717                runfrequency           = 1; %how many time steps we skip before we run grd_core
     
    2020                compute_bp_grd         = 0; %will GRD patterns for bottom pressures be computed?
    2121                degacc                 = 0; %degree increment for resolution of Green tables.
    22                 timeacc                = 0; %time step accurary required to compute Green tables
     22                timeacc                = 0; %time step accuracy required to compute Green tables
    2323                horiz                  = 0; %compute horizontal deformation
    24                 grdmodel               = 0; %grd model (0 by default, 1 for (visco)-elastic, 2 for Ivins)
     24                grdmodel               = 0; %grd model (0 by default, 1 for (visco-)elastic, 2 for Ivins)
    2525                cross_section_shape    = 0; %cross section only used when grd model is Ivins
    2626        end
     
    8181                %how many time steps we skip before we run solidearthsettings solver during transient
    8282                self.runfrequency=1;
    83                
    84                 %horizontal displacement?  (not by default)
     83
     84                %horizontal displacement? (not on by default)
    8585                self.horiz=0;
    86                
    87                 %cross section for Ivins model 
     86
     87                %cross section for Ivins model
    8888                self.cross_section_shape=1; %square as default (see iedge in GiaDeflectionCorex)
    8989
     
    106106                        md = checkfield(md,'fieldname','solidearth.settings.grdmodel','>=',0,'<=',2);
    107107                        md = checkfield(md,'fieldname','solidearth.settings.cross_section_shape','numel',[1],'values',[1,2]);
     108
    108109                        if self.elastic==1 & self.selfattraction==0,
    109110                                error('solidearthsettings checkconsistency error message: need selfattraction on if elastic flag is set');
     
    137138                        disp(sprintf('   solidearth settings:'));
    138139
    139                         fielddisplay(self,'reltol','sea level change relative convergence criterion, (default, NaN: not applied)');
    140                         fielddisplay(self,'abstol','sea level change absolute convergence criterion, NaN: not applied');
     140                        fielddisplay(self,'reltol','sea level change relative convergence criterion (default, NaN: not applied)');
     141                        fielddisplay(self,'abstol','sea level change absolute convergence criterion(default, NaN: not applied)');
    141142                        fielddisplay(self,'maxiter','maximum number of nonlinear iterations');
    142                         fielddisplay(self,'grdocean','does this planet have an ocean, if set to 1: global water mass is conserved in GRD module [default: 1]');
    143                         fielddisplay(self,'ocean_area_scaling','correction for model representation of ocean area [default: No correction]');
    144                         fielddisplay(self,'sealevelloading','enables surface loading from sea-level change (default 1)');
    145                         fielddisplay(self,'isgrd','compute GRD patterns (default 1)');
    146                         fielddisplay(self,'compute_bp_grd','compute GRD patterns for bottom pressure loads (default 1)');
     143                        fielddisplay(self,'grdocean','does this planet have an ocean, if set to 1: global water mass is conserved in GRD module (default: 1)');
     144                        fielddisplay(self,'ocean_area_scaling','correction for model representation of ocean area (default: No correction)');
     145                        fielddisplay(self,'sealevelloading','enables surface loading from sea-level change (default: 1)');
     146                        fielddisplay(self,'isgrd','compute GRD patterns (default: 1)');
     147                        fielddisplay(self,'compute_bp_grd','compute GRD patterns for bottom pressure loads (default: 1)');
    147148                        fielddisplay(self,'runfrequency','how many time steps we skip before we run solidearthsettings solver during transient (default: 1)');
    148149                        fielddisplay(self,'selfattraction','enables surface mass load to perturb the gravity field');
     
    150151                        fielddisplay(self,'viscous','enables viscous deformation from surface loading');
    151152                        fielddisplay(self,'rotation','enables polar motion to feedback on the GRD fields');
    152                         fielddisplay(self,'degacc','accuracy (default .01 deg) for numerical discretization of the Green''s functions');
    153                         fielddisplay(self,'timeacc','time accuracy (default 1 yr) for numerical discretization of the Green''s functions');
     153                        fielddisplay(self,'degacc','accuracy (default: .01 deg) for numerical discretization of the Green''s functions');
     154                        fielddisplay(self,'timeacc','time accuracy (default: 1 yr) for numerical discretization of the Green''s functions');
    154155                        fielddisplay(self,'grdmodel','type of deformation model, 0 for no GRD, 1 for spherical GRD model (SESAW model), 2 for half-space planar GRD (visco-elastic model from Ivins)');
    155156                        fielddisplay(self,'cross_section_shape','1: square-edged (default). 2: elliptical. See iedge in GiaDeflectionCore');
     
    175176                        WriteData(fid,prefix,'object',self,'fieldname','cross_section_shape','name','md.solidearth.settings.cross_section_shape','format','Integer');
    176177                end % }}}
     178                function self = extrude(self,md) % {{{
     179                end % }}}
    177180                function savemodeljs(self,fid,modelname) % {{{
    178181               
     
    191194                        writejsdouble(fid,[modelname '.solidearth.settings.cross_section_shape'],self.cross_section_shape);
    192195                end % }}}
    193                 function self = extrude(self,md) % {{{
    194                 end % }}}
    195196        end
    196197end
  • issm/trunk-jpl/src/m/classes/solidearthsettings.py

    r26178 r26299  
    1313    """
    1414
    15     def __init__(self, *args):  #{{{
     15    def __init__(self, *args): #{{{
    1616        self.reltol                 = 0
    1717        self.abstol                 = 0
    1818        self.maxiter                = 0
    19         self.rigid                  = 0
    20         self.elastic                = 0
    21         self.rotation               = 0
     19        self.selfattraction         = 1
     20        self.elastic                = 1
     21        self.viscous                = 1
     22        self.rotation               = 1
     23        self.grdocean               = 1
    2224        self.ocean_area_scaling     = 0
    2325        self.runfrequency           = 1 # How many time steps we skip before we run grd_core
    24         self.computesealevelchange  = 1 # Will grd_core compute sea level?
    25         self.isgrd                  = 1 # Will GRD patterns be computed?
    26         self.compute_bp_grd         = 1 # Will GRD patterns for bottom pressures be computed?
     26        self.sealevelloading        = 1 # Will sea-level loads be computed?
     27        self.isgrd                  = 0 # Will GRD patterns be computed?
     28        self.compute_bp_grd         = 0 # Will GRD patterns for bottom pressures be computed?
    2729        self.degacc                 = 0 # Degree increment for resolution of Green tables
    28         self.horiz                  = 0 # Compute horizontal displacement?
    29         self.glfraction             = 1 # Barystatic contribution: full or fractional (default: fractional)
    30         self.grdmodel               = 0 # GRD model (0 by default, 1 for elastic, 2 for Ivins)
     30        self.timeacc                = 0 # Time step accuracy required to compute Green tables
     31        self.horiz                  = 0 # Compute horizontal deformation?
     32        self.grdmodel               = 0 # GRD model (0 by default, 1 for (visco-)elastic, 2 for Ivins)
    3133        self.cross_section_shape    = 0 # Cross section only used when GRD model is Ivins
    3234
    33         nargin = len(args)
    34 
    35         if nargin == 0:
     35        if len(args) == 0:
    3636            self.setdefaultparameters()
    3737        else:
     
    3939    #}}}
    4040
    41     def __repr__(self):  # {{{
     41    def __repr__(self): #{{{
    4242        s = '   solidearth settings:\n'
    43         s += '{}\n'.format(fielddisplay(self, 'reltol', 'sea level rise relative convergence criterion, (default, NaN: not applied)'))
    44         s += '{}\n'.format(fielddisplay(self, 'abstol', 'sea level rise absolute convergence criterion, NaN: not applied'))
     43        s += '{}\n'.format(fielddisplay(self, 'reltol', 'sea level change relative convergence criterion (default, NaN: not applied)'))
     44        s += '{}\n'.format(fielddisplay(self, 'abstol', 'sea level change absolute convergence criterion (default, NaN: not applied)'))
    4545        s += '{}\n'.format(fielddisplay(self, 'maxiter', 'maximum number of nonlinear iterations'))
    46         s += '{}\n'.format(fielddisplay(self, 'ocean_area_scaling', 'correction for model representation of ocean area [default: No correction]'))
    47         s += '{}\n'.format(fielddisplay(self, 'computesealevelchange', 'compute sealevel change from GRD in addition to steric?) default 0'))
     46        s += '{}\n'.format(fielddisplay(self, 'grdocean', 'does this planet have an ocean, if set to 1: global water mass is conserved in GRD module (default: 1)'))
     47        s += '{}\n'.format(fielddisplay(self, 'ocean_area_scaling', 'correction for model representation of ocean area (default: No correction)'))
     48        s += '{}\n'.format(fielddisplay(self, 'sealevelloading', 'enables surface loading from sea-level change (default: 1)'))
    4849        s += '{}\n'.format(fielddisplay(self, 'isgrd', 'compute GRD patterns (default: 1'))
    4950        s += '{}\n'.format(fielddisplay(self, 'compute_bp_grd', 'compute GRD patterns for bottom pressure loads (default 1)'))
    5051        s += '{}\n'.format(fielddisplay(self, 'runfrequency', 'how many time steps we skip before we run solidearthsettings solver during transient (default: 1)'))
    51         s += '{}\n'.format(fielddisplay(self, 'rigid', 'rigid earth graviational potential perturbation'))
    52         s += '{}\n'.format(fielddisplay(self, 'elastic', 'elastic earth graviational potential perturbation'))
    53         s += '{}\n'.format(fielddisplay(self, 'degacc', 'accuracy (default .01 deg) for numerical discretization of the Green\'s functions'))
    54         s += '{}\n'.format(fielddisplay(self, 'glfraction', 'contribute fractionally (default, 1) to barystatic sea level'))
    55         s += '{}\n'.format(fielddisplay(self, 'grdmodel', 'type of deformation model, 1 for elastic, 2 for visco-elastic from Ivins'))
     52        s += '{}\n'.format(fielddisplay(self, 'selfattraction', 'enables surface mass load to perturb the gravity field'))
     53        s += '{}\n'.format(fielddisplay(self, 'elastic', 'enables elastic deformation from surface loading'))
     54        s += '{}\n'.format(fielddisplay(self, 'viscous', 'enables viscous deformation from surface loading'))
     55        s += '{}\n'.format(fielddisplay(self, 'rotation', 'enables polar motion to feedback on the GRD fields'))
     56        s += '{}\n'.format(fielddisplay(self, 'degacc', 'accuracy (default: .01 deg) for numerical discretization of the Green\'s functions'))
     57        s += '{}\n'.format(fielddisplay(self, 'timeacc', 'time accuracy (default: 1 year) for numerical discretization of the Green\'s functions'))
     58        s += '{}\n'.format(fielddisplay(self, 'grdmodel', 'type of deformation model, 0 for no GRD, 1 for spherical GRD model (SESAW model), 2 for half-space planar GRD (visco-elastic model from Ivins)'))
    5659        s += '{}\n'.format(fielddisplay(self, 'cross_section_shape', '1: square-edged (default). 2: elliptical. See iedge in GiaDeflectionCore'))
    5760        return s
    5861    #}}}
    5962
    60     def setdefaultparameters(self):  # {{{
     63    def setdefaultparameters(self): #{{{
    6164        # Convergence criterion: absolute, relative, and residual
    6265        self.reltol = 0.01  # 1 percent
     
    6770
    6871        # Computational flags
    69         self.rigid = 1
     72        self.selfattraction = 1
    7073        self.elastic = 1
     74        self.viscous = 1
    7175        self.rotation = 1
     76        self.grdocean = 1
    7277        self.ocean_area_scaling = 0
    73         self.compute_bp_grd = 1
     78        self.compute_bp_grd = 0
    7479        self.isgrd = 0
    75         self.computesealevelchange = 1
     80        self.sealevelloading = 1
    7681
    7782        # Numerical discretization accuracy
    7883        self.degacc = .01
     84        self.timeacc = 1
    7985
    8086        # How many time steps we skip before we run solidearthsettings solver during transient
    8187        self.runfrequency = 1
    82 
    83         # Fractional contribution
    84         self.glfraction = 1
    8588
    8689        # Horizontal displacement? (not on by default)
     
    8891
    8992        # Cross section for Ivins model
    90         self.cross_section_shape = 1 # Square as default (see iedde in GiaDeflectionCorex)
     93        self.cross_section_shape = 1 # Square as default (see iedge in GiaDeflectionCorex)
    9194
    9295        # No GRD model by default
     
    9497    #}}}
    9598
    96     def checkconsistency(self, md, solution, analyses):  # {{{
     99    def checkconsistency(self, md, solution, analyses): #{{{
    97100        if ('SealevelriseAnalysis' not in analyses) or (solution == 'TransientSolution' and not md.transient.isslc):
    98101            return md
     102
    99103        md = checkfield(md, 'fieldname', 'solidearth.settings.reltol', 'size', [1])
    100104        md = checkfield(md, 'fieldname', 'solidearth.settings.abstol', 'size', [1])
     
    102106        md = checkfield(md, 'fieldname', 'solidearth.settings.runfrequency', 'size', [1], '>=', 1)
    103107        md = checkfield(md, 'fieldname', 'solidearth.settings.degacc', 'size', [1], '>=', 1e-10)
     108        md = checkfield(md, 'fieldname', 'solidearth.settings.timeacc', 'size', [1], '>', 0)
    104109        md = checkfield(md, 'fieldname', 'solidearth.settings.horiz', 'NaN', 1, 'Inf', 1, 'values', [0, 1])
    105         md = checkfield(md, 'fieldname', 'solidearth.settings.glfraction', 'values', [0, 1])
    106         md = checkfield(md, 'fieldname', 'solidearth.settings.grdmodel', 'values', [1, 2])
     110        md = checkfield(md, 'fieldname', 'solidearth.settings.grdmodel', '>=', 0, '<=', 2)
    107111        md = checkfield(md, 'fieldname', 'solidearth.settings.cross_section_shape', 'numel', [1], 'values', [1, 2])
    108112
    109         # Checks on computational flags
    110         if self.elastic and not self.rigid:
    111             raise Exception('solidearthsettings checkconsistency error message: need rigid on if elastic flag is set')
     113        if self.elastic and not self.selfattraction:
     114            raise Exception('solidearthsettings checkconsistency error message: need selfattraction on if elastic flag is set')
     115        if self.viscous and not self.elastic:
     116            raise Exception('solidearthsettings checkconsistency error message: need elastic on if viscous flag is set')
    112117
    113118        # A GRD computation has been requested, make some checks on the nature of the meshes provided
     
    119124                    if self.grdmodel == 1:
    120125                        raise RuntimeException('model requires a 3D surface mesh to run GRD computations (change mesh from mesh2d to mesh3dsurface)')
     126            if self.sealevelloading and not self.grdocean:
     127                raise RuntimeException('solidearthsettings checkconsistency error message: need grdocean on if sealevelloading flag is set')
    121128
    122129        if self.compute_bp_grd and not md.solidearth.settings.isgrd:
     
    126133    #}}}
    127134
    128     def marshall(self, prefix, md, fid):  #{{{
     135    def marshall(self, prefix, md, fid): #{{{
    129136        WriteData(fid, prefix, 'object', self, 'fieldname', 'reltol', 'name', 'md.solidearth.settings.reltol', 'format', 'Double')
    130137        WriteData(fid, prefix, 'object', self, 'fieldname', 'abstol', 'name', 'md.solidearth.settings.abstol', 'format', 'Double')
    131138        WriteData(fid, prefix, 'object', self, 'fieldname', 'maxiter', 'name', 'md.solidearth.settings.maxiter', 'format', 'Integer')
    132         WriteData(fid, prefix, 'object', self, 'fieldname', 'rigid', 'name', 'md.solidearth.settings.rigid', 'format', 'Boolean')
     139        WriteData(fid, prefix, 'object', self, 'fieldname', 'selfattraction', 'name', 'md.solidearth.settings.selfattraction', 'format', 'Boolean')
    133140        WriteData(fid, prefix, 'object', self, 'fieldname', 'elastic', 'name', 'md.solidearth.settings.elastic', 'format', 'Boolean')
     141        WriteData(fid, prefix, 'object', self, 'fieldname', 'viscous', 'name', 'md.solidearth.settings.viscous', 'format', 'Boolean')
    134142        WriteData(fid, prefix, 'object', self, 'fieldname', 'rotation', 'name', 'md.solidearth.settings.rotation', 'format', 'Boolean')
    135         WriteData(fid, prefix, 'object', self, 'fieldname', 'ocean_area_scaling', 'name', 'md.solidearth.settings.ocean_area_scaling', 'format', 'Boolean')
     143        WriteData(fid, prefix, 'object', self, 'fieldname', 'grdocean', 'name', 'md.solidearth.settings.grdocean', 'format', 'Boolean')
     144        WriteData(fid, prefix, 'object', self, 'fieldname', 'ocean_area_scaling', 'name', 'md.solidearth.settings.ocean_area_scaling', 'format', 'Integer')
    136145        WriteData(fid, prefix, 'object', self, 'fieldname', 'runfrequency', 'name', 'md.solidearth.settings.runfrequency', 'format', 'Integer')
    137146        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)
    138148        WriteData(fid, prefix, 'object', self, 'fieldname', 'horiz', 'name', 'md.solidearth.settings.horiz', 'format', 'Integer')
    139         WriteData(fid, prefix, 'object', self, 'fieldname', 'computesealevelchange', 'name', 'md.solidearth.settings.computesealevelchange', 'format', 'Integer')
     149        WriteData(fid, prefix, 'object', self, 'fieldname', 'sealevelloading', 'name', 'md.solidearth.settings.sealevelloading', 'format', 'Integer')
    140150        WriteData(fid, prefix, 'object', self, 'fieldname','isgrd', 'name', 'md.solidearth.settings.isgrd', 'format', 'Integer')
    141151        WriteData(fid, prefix, 'object', self, 'fieldname', 'compute_bp_grd', 'name', 'md.solidearth.settings.compute_bp_grd', 'format', 'Integer')
    142         WriteData(fid, prefix, 'object', self, 'fieldname','glfraction', 'name', 'md.solidearth.settings.glfraction', 'format', 'Integer')
    143152        WriteData(fid, prefix, 'object', self, 'fieldname', 'grdmodel', 'name', 'md.solidearth.settings.grdmodel', 'format', 'Integer')
    144153        WriteData(fid, prefix, 'object', self, 'fieldname', 'cross_section_shape', 'name', 'md.solidearth.settings.cross_section_shape', 'format', 'Integer')
    145154    #}}}
    146155
    147     def extrude(self, md):  #{{{
     156    def extrude(self, md): #{{{
    148157        return self
    149158    #}}}
  • issm/trunk-jpl/test/NightlyRun/test2001.m

    r26296 r26299  
    11%Test Name: SquareSheetConstrainedGia2d
    2 %GIA test, inspired on test101. Running default GIA Ivins class.
     2%GIA test, based off of test101. Running default GIA Ivins class.
    33md=triangle(model(),'../Exp/Square.exp',100000.);
    44md=setmask(md,'','');
  • issm/trunk-jpl/test/NightlyRun/test2001.py

    r26059 r26299  
    11#Test Name: SquareSheetConstrainedGia2d
     2#GIA test, based off of test101. Running default GIA Ivins class.
    23from socket import gethostname
    34
     
    1920# GIA Ivins, 2 layer model
    2021md.solidearth.settings.grdmodel = 2
     22md.solidearth.settings.isgrd = 1
    2123
    2224md.materials = materials('litho','ice')
     
    2830md.initialization.sealevel = np.zeros(md.mesh.numberofvertices)
    2931md.solidearth.settings.cross_section_shape = 1 # for square-edged x-section
    30 md.solidearth.settings.computesealevelchange = 0 # do not compute sea level, only deformation
    31 md.solidearth.requested_outputs = ['Sealevel', 'SealevelUGrd']
     32md.solidearth.settings.grdocean = 0 # do not compute sea level, only deformation
     33md.solidearth.settings.sealevelloading = 0 # do not compute sea level, only deformation
     34md.solidearth.requested_outputs = ['Sealevel', 'BedGRD']
    3235
    3336# Loading history
     
    3639# To get rid of default final_time, make sure final_time > start_time
    3740md.timestepping.final_time = 2400000  # 2,400 kyr
    38 md.masstransport.spcthickness np.array([
     41md.masstransport.spcthickness = np.array([
    3942    np.append(md.geometry.thickness, 0),
    4043    np.append(md.geometry.thickness, 2400000)
     
    5053md.transient.isstressbalance = 0
    5154md.transient.isthermal = 0
    52 md.transient.ismasstransport = 0
    53 md.transient.isslc = 0
     55md.transient.ismasstransport = 1
     56md.transient.isslc = 1
    5457
    5558#Solve for GIA deflection
    56 md.cluster = generic('name', gethostname(), 'np', 1)
    5759md.cluster = generic('name', gethostname(), 'np', 3)
    5860md.verbose = verbose('11111111111')
     
    6365field_names = ['UGrd']
    6466field_tolerances = [1e-13]
    65 field_values = [md.results.TransientSolution[0].SealevelUGrd]
     67field_values = [md.results.TransientSolution[1].BedGRD]
Note: See TracChangeset for help on using the changeset viewer.