1 | import numpy as np
|
---|
2 | from checkfield import checkfield
|
---|
3 | from fielddisplay import fielddisplay
|
---|
4 | from project3d import project3d
|
---|
5 | from structtoobj import structtoobj
|
---|
6 | from WriteData import WriteData
|
---|
7 |
|
---|
8 |
|
---|
9 | class frictionschoof(object):
|
---|
10 | """FRICTIONSCHOOF class definition
|
---|
11 |
|
---|
12 | Usage:
|
---|
13 | friction = frictionschoof()
|
---|
14 | """
|
---|
15 |
|
---|
16 | def __init__(self, *args): # {{{
|
---|
17 | self.C = np.nan
|
---|
18 | self.Cmax = np.nan
|
---|
19 | self.m = np.nan
|
---|
20 | self.coupling = 0
|
---|
21 | self.effective_pressure = np.nan
|
---|
22 | self.effective_pressure_limit = 0
|
---|
23 |
|
---|
24 | nargs = len(args)
|
---|
25 | if nargs == 0:
|
---|
26 | self.setdefaultparameters()
|
---|
27 | elif nargs == 1:
|
---|
28 | self = structtoobj(self, args[0])
|
---|
29 | else:
|
---|
30 | raise Exception('constructor not supported')
|
---|
31 | #}}}
|
---|
32 | def __repr__(self): # {{{
|
---|
33 | # See Brondex et al. 2019 https://www.the-cryosphere.net/13/177/2019/
|
---|
34 | s = 'Schoof sliding law parameters:\n'
|
---|
35 | s += ' Schoof\'s sliding law reads:\n'
|
---|
36 | s += ' C^2 |u_b|^(m-1) \n'
|
---|
37 | s += ' tau_b = - _____________________________ u_b \n'
|
---|
38 | s += ' (1+(C^2/(Cmax N))^1/m |u_b| )^m \n'
|
---|
39 | s += '\n'
|
---|
40 | s += "{}\n".format(fielddisplay(self, 'C', 'friction coefficient [SI]'))
|
---|
41 | s += "{}\n".format(fielddisplay(self, 'Cmax', 'Iken\'s bound (typically between 0.17 and 0.84) [SI]'))
|
---|
42 | s += "{}\n".format(fielddisplay(self, 'm', 'm exponent (generally taken as m = 1/n = 1/3)'))
|
---|
43 | s += '{}\n'.format(fielddisplay(self, 'coupling', 'Coupling flag 0: uniform sheet (negative pressure ok, default), 1: ice pressure only, 2: water pressure assuming uniform sheet (no negative pressure), 3: use provided effective_pressure, 4: used coupled model (not implemented yet)'))
|
---|
44 | s += '{}\n'.format(fielddisplay(self, 'effective_pressure', 'Effective Pressure for the forcing if not coupled [Pa]'))
|
---|
45 | s += "{}\n".format(fielddisplay(self, 'effective_pressure_limit', 'fNeff do not allow to fall below a certain limit: effective_pressure_limit*rho_ice*g*thickness (default 0)'))
|
---|
46 | return s
|
---|
47 | #}}}
|
---|
48 | def setdefaultparameters(self): # {{{
|
---|
49 | self.effective_pressure_limit = 0
|
---|
50 | return self
|
---|
51 | #}}}
|
---|
52 | def extrude(self, md): # {{{
|
---|
53 | self.C = project3d(md, 'vector', self.C, 'type', 'node')
|
---|
54 | self.Cmax = project3d(md, 'vector', self.Cmax, 'type', 'node')
|
---|
55 | self.m = project3d(md, 'vector', self.m, 'type', 'element')
|
---|
56 | if self.coupling in [3, 4]:
|
---|
57 | self.effective_pressure = project3d(md, 'vector', self.effective_pressure, 'type', 'node', 'layer', 1)
|
---|
58 | return self
|
---|
59 | #}}}
|
---|
60 | def checkconsistency(self, md, solution, analyses): # {{{
|
---|
61 | # Early return
|
---|
62 | if 'StressbalanceAnalysis' not in analyses and 'ThermalAnalysis' not in analyses:
|
---|
63 | return md
|
---|
64 | md = checkfield(md, 'fieldname', 'friction.C', 'timeseries', 1, 'NaN', 1, 'Inf', 1, '>',0.)
|
---|
65 | md = checkfield(md, 'fieldname', 'friction.Cmax', 'timeseries', 1, 'NaN', 1, 'Inf', 1, '>', 0.)
|
---|
66 | md = checkfield(md, 'fieldname', 'friction.m', 'NaN', 1, 'Inf', 1, '>', 0., 'size', [md.mesh.numberofelements, 1])
|
---|
67 | md = checkfield(md, 'fieldname', 'friction.effective_pressure_limit', 'numel', [1], '>=', 0)
|
---|
68 | md = checkfield(md, 'fieldname', 'friction.coupling', 'numel', [1], 'values', [0, 1, 2, 3, 4])
|
---|
69 | if self.coupling == 3:
|
---|
70 | md = checkfield(md, 'fieldname', 'friction.effective_pressure', 'NaN', 1, 'Inf', 1, 'timeseries', 1)
|
---|
71 | return md
|
---|
72 | # }}}
|
---|
73 | def marshall(self, prefix, md, fid): # {{{
|
---|
74 | yts = md.constants.yts
|
---|
75 |
|
---|
76 | WriteData(fid, prefix, 'name', 'md.friction.law', 'data', 11, 'format', 'Integer')
|
---|
77 | WriteData(fid, prefix, 'class', 'friction', 'object', self, 'fieldname', 'C', 'format', 'DoubleMat', 'mattype', 1, 'timeserieslength', md.mesh.numberofvertices + 1, 'yts', md.constants.yts)
|
---|
78 | WriteData(fid, prefix, 'class', 'friction', 'object', self, 'fieldname', 'Cmax', 'format', 'DoubleMat', 'mattype', 1, 'timeserieslength', md.mesh.numberofvertices + 1, 'yts', md.constants.yts)
|
---|
79 | WriteData(fid, prefix, 'class', 'friction', 'object', self, 'fieldname', 'm', 'format', 'DoubleMat', 'mattype', 2)
|
---|
80 | WriteData(fid, prefix, 'class', 'friction', 'object', self, 'fieldname', 'coupling', 'format', 'Integer')
|
---|
81 | WriteData(fid, prefix, 'object', self, 'class', 'friction', 'fieldname', 'effective_pressure_limit', 'format', 'Double')
|
---|
82 | if self.coupling == 3 or self.coupling == 4:
|
---|
83 | WriteData(fid, prefix, 'class', 'friction', 'object', self, 'fieldname', 'effective_pressure', 'format', 'DoubleMat', 'mattype', 1, 'timeserieslength', md.mesh.numberofvertices + 1, 'yts', md.constants.yts)
|
---|
84 | # }}}
|
---|