Changeset 27460


Ignore:
Timestamp:
12/10/22 00:44:18 (2 years ago)
Author:
jdquinn
Message:

CHG: MATLAB > Python translation; cleanup

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

Legend:

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

    r27458 r27460  
    4141                        self.min_thickness = 0.;
    4242
    43                         %parameters for the spatial temporal seperation
     43                        %Parameters for the spatial temporal separation
    4444                        %The coefficient follows: gamma= f(x)
    4545                        % 0 - f(x) = y_{o} + \alpha (x+x_{o})
     
    4848                        % the amplifier
    4949                        self.theta = 0;
    50                         % the slope alpha 
     50                        % the slope alpha
    5151                        self.alpha = 0;
    52                         % offset in x-axis 
     52                        % offset in x-axis
    5353                        self.xoffset = 0;
    54                         % offset in y-axis 
     54                        % offset in y-axis
    5555                        self.yoffset = 0;
    5656                        % velocity thresholds to reduce calving rate
    57                         vel_upperbound = 6000; % m/a
    58                         vel_lowerbound = 0; % m/a
     57                        self.vel_upperbound = 6000; % m/a
     58                        self.vel_lowerbound = 0; % m/a
    5959                end % }}}
    6060                function md = checkconsistency(self,md,solution,analyses) % {{{
  • issm/trunk-jpl/src/m/classes/calvingparameterization.py

    r27458 r27460  
    1212    """
    1313
    14     def __init__(self):  # {{{
    15         self.stress_threshold_groundedice = 0
    16         self.stress_threshold_floatingice = 0
     14    def __init__(self, *args):  # {{{
    1715        self.min_thickness = 0
    1816        self.use_param = 0
    19         self.scale_theta = 0
    20         self.amp_alpha = 0
    21         self.midp = 0
    22         self.nonlinearlaw = 0
     17        self.theta = 0
     18        self.alpha = 0
     19        self.xoffset = 0
     20        self.yoffset = 0
     21        self.vel_upperbound = 0
     22        self.vel_threshold = 0
     23        self.vel_lowerbound = 0
    2324
    2425        nargs = len(args)
     
    3334
    3435    def __repr__(self):  # {{{
    35         s = '   Calving VonMises parameters:\n'
    36         s += '{}\n'.format(fielddisplay(self, 'stress_threshold_groundedice', 'sigma_max applied to grounded ice only [Pa]'))
    37         s += '{}\n'.format(fielddisplay(self, 'stress_threshold_floatingice', 'sigma_max applied to floating ice only [Pa]'))
     36        s = '   Calving test parameters:\n'
    3837        s += '{}\n'.format(fielddisplay(self, 'min_thickness', 'minimum thickness below which no ice is allowed [m]'))
     38        s += '{}\n'.format(fielddisplay(self, 'use_param', '-1 - just use frontal ablation rate, 0 - f(x) = y_{o} + \alpha (x+x_{o}), 1 - f(x)=y_{o}-\frac{\theta}{2}\tanh(\alpha(x+x_{o})), 2 - tanh(thickness), 3 - tanh(normalized vel), 4 - tanh(truncated vel), 5 - linear(truncated vel)'))
     39        s += '{}\n'.format(fielddisplay(self, 'theta', 'the amplifier'))
     40        s += '{}\n'.format(fielddisplay(self, 'alpha', 'the slope'))
     41        s += '{}\n'.format(fielddisplay(self, 'xoffset', 'offset in x-axis'))
     42        s += '{}\n'.format(fielddisplay(self, 'yoffset', 'offset in y-axis'))
     43        s += '{}\n'.format(fielddisplay(self, 'vel_lowerbound', 'lowerbound of ice velocity to reduce the calving rate [m/a]'))
     44        s += '{}\n'.format(fielddisplay(self, 'vel_threshold', 'threshold of ice velocity to reduce the calving rate [m/a]'))
     45        s += '{}\n'.format(fielddisplay(self, 'vel_upperbound', 'upperbound of ice velocity to reduce the calving rate [m/a]'))
    3946        return s
    4047    # }}}
     
    4552
    4653    def setdefaultparameters(self):  # {{{
    47         # Default sigma max
    48         self.stress_threshold_groundedice = 1e6
    49         self.stress_threshold_floatingice = 150e3
     54        # For now we turn this off by setting the threshold to 0
     55        self.min_thickness = 0.
    5056
    51         # Turn off min_thickness by default
    52         self.min_thickness = 0.
     57        # Parameters for the spatial temporal separation
     58        # The coefficient follows: gamma= f(x)
     59        # 0 - f(x) = y_{o} + \alpha (x+x_{o})
     60        # 1 - f(x)=y_{o}-\frac{\theta}{2}\tanh(\alpha(x+x_{o}))
     61        self.use_param = 0
     62
     63        # The amplifier
     64        self.theta = 0
     65
     66        # The slope alpha
     67        self.alpha = 0
     68
     69        # Offset in x-axis
     70        self.xoffset
     71
     72        # Offset in y-axis
     73        self.yoffset
     74
     75        # Velocity thresholds to reduce calving rate
     76        self.vel_upperbound = 6000 # m/a
     77        self.vel_lowerbound = 0 # m/a
    5378        return self
    5479    # }}}
     
    5681    def checkconsistency(self, md, solution, analyses):  # {{{
    5782        # Early return
    58         if solution == 'TransientSolution' or not md.transient.ismovingfront:
     83        if not solution == 'TransientSolution' or not md.transient.ismovingfront:
    5984            return
    6085
    61         md = checkfield(md, 'fieldname', 'calving.stress_threshold_groundedice', '>', 0, 'nan', 1, 'Inf', 1, 'size', 'universal')
    62         md = checkfield(md, 'fieldname', 'calving.stress_threshold_floatingice', '>', 0, 'nan', 1, 'Inf', 1, 'size', 'universal')
    63         md = checkfield(md, 'fieldname', 'calving.min_thickness', '>=', 0, 'NaN', 1, 'Inf', 1, 'numel', [1])
     86        md = checkfield(md, 'fieldname', 'calving.min_thickness', '>=', 0, 'NaN', 1, 'Inf', 1, 'numel', 1)
     87        md = checkfield(md, 'fieldname', 'calving.use_param', 'values', [-1, 0, 1, 2, 3, 4, 5])
     88        md = checkfield(md, 'fieldname', 'calving.theta', 'NaN', 1, 'Inf', 1, 'numel', 1)
     89        md = checkfield(md, 'fieldname', 'calving.alpha', 'NaN', 1, 'Inf', 1, 'numel', 1)
     90        md = checkfield(md, 'fieldname', 'calving.xoffset', 'NaN', 1, 'Inf', 1, 'numel', 1)
     91        md = checkfield(md, 'fieldname', 'calving.yoffset', 'NaN', 1, 'Inf', 1, 'numel', 1)
     92        md = checkfield(md, 'fieldname', 'calving.vel_lowerbound', 'NaN', 1, 'Inf', 1, 'numel', 1)
     93        md = checkfield(md, 'fieldname', 'calving.vel_threshold', 'NaN', 1, 'Inf', 1, 'numel', 1)
     94        md = checkfield(md, 'fieldname', 'calving.vel_upperbound', 'NaN', 1, 'Inf', 1, 'numel', 1)
    6495
    6596        return md
     
    6899    def marshall(self, prefix, md, fid):  # {{{
    69100        yts = md.constants.yts
    70         WriteData(fid, prefix, 'name', 'md.calving.law', 'data', 2, 'format', 'Integer')
    71         WriteData(fid, prefix, 'object', self, 'fieldname', 'stress_threshold_groundedice', 'format', 'DoubleMat', 'mattype', 1, 'timeserieslength', md.mesh.numberofvertices + 1, 'yts', yts )
    72         WriteData(fid, prefix, 'object', self, 'fieldname', 'stress_threshold_floatingice', 'format', 'DoubleMat', 'mattype', 1, 'timeserieslength', md.mesh.numberofvertices + 1, 'yts', yts)
     101        WriteData(fid, prefix, 'name', 'md.calving.law', 'data', 9, 'format', 'Integer')
    73102        WriteData(fid, prefix, 'object', self, 'fieldname', 'min_thickness', 'format', 'Double')
     103        WriteData(fid, prefix, 'object', self, 'fieldname', 'use_param', 'format', 'Integer')
     104        WriteData(fid, prefix, 'object', self, 'fieldname', 'theta', 'format', 'Double')
     105        WriteData(fid, prefix, 'object', self, 'fieldname', 'alpha', 'format', 'Double')
     106        WriteData(fid, prefix, 'object', self, 'fieldname', 'xoffset', 'format', 'Double')
     107        WriteData(fid, prefix, 'object', self, 'fieldname', 'yoffset', 'format', 'Double')
     108        WriteData(fid, prefix, 'object', self, 'fieldname', 'vel_lowerbound', 'format', 'Double', 'scale', 1. / yts)
     109        WriteData(fid, prefix, 'object', self, 'fieldname', 'vel_threshold','format', 'Double', 'scale', 1. / yts)
     110        WriteData(fid, prefix, 'object', self, 'fieldname', 'vel_upperbound', 'format', 'Double', 'scale', 1. / yts)
    74111    # }}}
Note: See TracChangeset for help on using the changeset viewer.