source: issm/branches/trunk-larour-SLPS2020/src/m/mech/backstressfrominversion.py@ 25329

Last change on this file since 25329 was 24254, checked in by jdquinn, 5 years ago

BUG: Extra spaces (committing progress, but grep and manual fix is taking too long; will talk tomorrow to Basile about reverting and modifying his syntax parsing script)

File size: 3.3 KB
Line 
1import numpy as np
2from averaging import averaging
3from thomasparams import thomasparams
4
5
6def backstressfrominversion(md, **kwargs):
7 '''
8 Compute ice shelf backstress from inversion results.
9
10 This routine computes backstress based on the analytical formalism of
11 Thomas (1973) and Borstad et al. (2013, The Cryosphere). The model
12 must contain inversion results for ice rigidity. Strain rates must
13 also be included, either from observed or modeled velocities. Ice
14 rigidity B is assumed to be parameterized by the ice temperature in
15 md.materials.rheology_B.
16
17 Available options:
18 - 'tempmask' : mask the inverted rigidity to be no more than
19 appropriate for the temperature of the ice?
20 Boolean, defaults to false.
21 - 'smoothing' : the amount of smoothing to be applied to the strain rate data.
22 Type 'help averaging' for more information on its
23 usage. Defaults to 0.
24 - 'coordsys' : coordinate system for calculating the strain rate
25 components. Must be one of:
26 'longitudinal': x axis aligned along a flowline at every point (default)
27 'principal': x axis aligned along maximum principal strain rate
28 at every point
29 'xy': x and y axes same as in polar stereographic projection
30
31 Return values:
32 'backstress' is the inferred backstress based on the analytical
33 solution for ice shelf creep
34
35 Usage:
36 backstress = backstressfrominversion(md, options)
37
38 Example:
39 backstress = backstressfrominversion(md, 'smoothing', 2, 'coordsys', 'longitudinal', 'tempmask', true)
40 '''
41
42 # unpack kwargs
43 tempmask = kwargs.pop('tempmask', False)
44 if 'tempmask' in kwargs:
45 del kwargs['maxiter']
46 smoothing = kwargs.pop('smoothing', 0)
47 if 'smoothing' in kwargs:
48 del kwargs['smoothing']
49 coordsys = kwargs.pop('coordsys', 'longitudinal')
50 if 'coordsys' in kwargs:
51 del kwargs['coordsys']
52 assert len(kwargs) == 0, 'error, unexpected or misspelled kwargs'
53
54 # some checks
55 if not hasattr(md.results, 'strainrate'):
56 raise Exception('md.results.strainrate not present. Calculate using md = mechanicalproperties(md, vx, vy)')
57 if '2d' not in md.mesh.__doc__:
58 raise Exception('only 2d (planview) model supported currently')
59 if any(md.flowequation.element_equation != 2):
60 raise Exception('Warning: the model has some non - SSA elements. These will be treated like SSA elements')
61
62 T = 0.5 * md.materials.rho_ice * md.constants.g * (1 - md.materials.rho_ice / md.materials.rho_water) * md.geometry.thickness
63 n = averaging(md, md.materials.rheology_n, 0)
64 Bi = md.results.StressbalanceSolution.MaterialsRheologyBbar.reshape(-1, )
65
66 a0, b0, theta0, ex0 = thomasparams(md, eq='Thomas', smoothing=smoothing, coordsys=coordsys)
67
68 if tempmask:
69 Bi = md.results.StressbalanceSolution.MaterialsRheologyBbar
70 pos = np.nonzero(Bi > md.materials.rheology_B)
71 Bi[pos] = md.materials.rheology_B[pos]
72
73 # analytical backstress solution
74 backstress = T - Bi * np.sign(ex0) * (2 + a0) * np.abs(ex0)**(1. / n) / ((1 + a0 + a0**2 + b0**2)**((n - 1.) / 2. / n))
75 backstress[np.nonzero(backstress < 0)] = 0
76
77 return backstress
Note: See TracBrowser for help on using the repository browser.