Ignore:
Timestamp:
06/01/22 05:01:48 (3 years ago)
Author:
Mathieu Morlighem
Message:

merged trunk-jpl and trunk for revision 27033

Location:
issm/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk

  • issm/trunk/src

  • issm/trunk/src/m/classes/fourierlove.py

    r26744 r27035  
    2222        self.mu0 = 0
    2323        self.Gravitational_Constant = 0
     24        self.chandler_wobble = 0
    2425        self.allow_layer_deletion = 0
    2526        self.underflow_tol = 0
     27        self.pw_threshold = 0
    2628        self.integration_steps_per_layer = 0
    2729        self.istemporal = 0
     
    5153        s += '{}\n'.format(fielddisplay(self, 'allow_layer_deletion', 'allow for migration of the integration boundary with increasing spherical harmonics degree (default: 1)'))
    5254        s += '{}\n'.format(fielddisplay(self, 'Gravitational_Constant', 'Newtonian constant of gravitation (default: 6.67259e-11 [m^3 kg^-1 s^-2])'))
     55        s += '{}\n'.format(fielddisplay(self, 'chandler_wobble', 'includes the inertial terms for the chandler wobble in the rotational feedback love numbers, only for forcing_type=11 (default: 0) (/!\\ 1 has not been validated yet)'))
    5356        s += '{}\n'.format(fielddisplay(self, 'allow_layer_deletion', 'allow for migration of the integration boundary with increasing spherical harmonics degree (default: 1)'))
    54         s += '{}\n'.format(fielddisplay(self, 'underflow_tol', 'threshold of deep to surface love number ratio to trigger the deletion of layers (default: 1e-16)'))
     57        s += '{}\n'.format(fielddisplay(self, 'pw_threshold', 'if relative variation across frequencies is smaller than this ratio, the post-widder transform for time-dependent love numbers is bypassed (default (1e-3)'))
     58        s += '{}\n'.format(fielddisplay(self, 'chandler_wobble', 'includes the inertial terms for the chandler wobble in the rotational feedback love numbers, only for forcing_type=11 (default: 0) (/!\\ 1 is untested)'))
    5559        s += '{}\n'.format(fielddisplay(self, 'integration_steps_per_layer', 'number of radial steps to propagate the yi system from the bottom to the top of each layer (default: 100)'))
    5660        s += '{}\n'.format(fielddisplay(self, 'istemporal', ['1 for time-dependent love numbers, 0 for frequency-dependent or elastic love numbers (default: 0)', 'If 1: use fourierlove function build_frequencies_from_time to meet consistency']))
     
    8892        self.mu0 = 1e11 # Pa
    8993        self.Gravitational_Constant = 6.67259e-11 # m^3 kg^-1 s^-2
     94        self.chandler_wobble = 0
    9095        self.allow_layer_deletion = 1
    9196        self.underflow_tol = 1e-16 # Threshold of deep to surface love number ratio to trigger the deletion of layer
     97        self.pw_threshold = 1e-3 # If relative variation across frequencies is smaller than this ratio, the post-widder transform for time-dependent love numbers is bypassed
    9298        self.integration_steps_per_layer = 100
    9399        self.istemporal = 0
     
    113119        md = checkfield(md, 'fieldname', 'love.mu0', 'NaN', 1, 'Inf', 1, 'numel', 1, '>', 0)
    114120        md = checkfield(md, 'fieldname', 'love.Gravitational_Constant', 'NaN', 1, 'Inf', 1, 'numel', 1, '>', 0)
     121        md = checkfield(md, 'fieldname', 'love.chandler_wobble', 'values', [0, 1])
    115122        md = checkfield(md, 'fieldname', 'love.allow_layer_deletion', 'values', [0, 1])
    116123        md = checkfield(md, 'fieldname', 'love.underflow_tol', 'NaN', 1, 'Inf', 1, 'numel', 1, '>', 0)
     124        md = checkfield(md, 'fieldname', 'love.pw_threshold', 'NaN', 1, 'Inf', 1, 'numel', 1, '>', 0)
    117125        md = checkfield(md, 'fieldname', 'love.integration_steps_per_layer', 'NaN', 1, 'Inf', 1, 'numel', 1, '>', 0)
    118126        md = checkfield(md, 'fieldname', 'love.love_kernels', 'values', [0, 1])
     
    127135            raise RuntimeError('Degree 1 not supported for forcing type {}. Use sh_min >= 2 for this kind of calculation.'.format(md.love.forcing_type))
    128136
     137        if md.love.chandler_wobble  == 1:
     138            print('Warning: Chandler wobble in Love number calculator has not been validated yet')
     139
    129140        # Need 'litho' material
    130         if not hasattr(md.materials, 'materials') or 'litho' not in md.materials.nature:
     141        if md.materials.__class__.__name__ != 'materials' or 'litho' not in md.materials.nature:
    131142            raise RuntimeError('Need a \'litho\' material to run a Fourier Love number analysis')
    132143
    133         mat = np.where(np.array(nature) == 'litho')[0]
     144        mat = np.where(np.array(md.materials.nature) == 'litho')[0]
    134145        if md.love.forcing_type <= 4:
    135146            md = checkfield(md, 'fieldname', 'love.inner_core_boundary', 'NaN', 1, 'Inf', 1, 'numel', 1, '>', 0, '<=', md.materials[mat].numlayers)
     
    149160        WriteData(fid, prefix, 'object', self, 'fieldname', 'mu0', 'format', 'Double')
    150161        WriteData(fid, prefix, 'object', self, 'fieldname', 'Gravitational_Constant', 'format', 'Double')
     162        WriteData(fid, prefix, 'object', self, 'fieldname', 'chandler_wobble', 'format', 'Boolean')
    151163        WriteData(fid, prefix, 'object', self, 'fieldname', 'allow_layer_deletion', 'format', 'Boolean')
    152164        WriteData(fid, prefix, 'object', self, 'fieldname', 'underflow_tol', 'format', 'Double')
     165        WriteData(fid, prefix, 'object', self, 'fieldname', 'pw_threshold', 'format', 'Double')
    153166        WriteData(fid, prefix, 'object', self, 'fieldname', 'integration_steps_per_layer', 'format', 'Integer')
    154167        WriteData(fid, prefix, 'object', self, 'fieldname', 'istemporal', 'format', 'Boolean')
     
    171184        print('Temporal love numbers: Overriding md.love.nfreq and md.love.frequencies')
    172185        self.nfreq = len(self.time) * 2 * self.n_temporal_iterations
    173         self.frequencies = np.zeros((self.nfreq, 1))
     186        self.frequencies = np.zeros((self.nfreq,))
    174187        for i in range(len(self.time)):
    175188            for j in range(2 * self.n_temporal_iterations):
    176                 self.frequencies[(i - 1) * 2 * self.n_temporal_iterations + j] = j * np.log(2) / self.time[i] / 2 / np.pi
     189                if self.time[i] == 0:
     190                    self.frequencies[(i - 1) * 2 * self.n_temporal_iterations + j] = 0 # Convention to avoid marshalling infinite numbers
     191                else:
     192                    self.frequencies[(i - 1) * 2 * self.n_temporal_iterations + j] = j * np.log(2) / self.time[i] / 2 / np.pi
     193        return self
    177194    #}}}
Note: See TracChangeset for help on using the changeset viewer.