source: issm/branches/trunk-larour-NatGeoScience2016/src/m/classes/slr.m@ 22155

Last change on this file since 22155 was 22155, checked in by Eric.Larour, 7 years ago

CHG: rearranging the entire slr core

File size: 12.1 KB
Line 
1%SLR class definition
2%
3% Usage:
4% slr=slr();
5
6classdef slr
7 properties (SetAccess=public)
8 deltathickness = NaN;
9 sealevel = NaN;
10 spcthickness = NaN;
11 maxiter = 0;
12 reltol = 0;
13 abstol = 0;
14 love_h = 0; %provided by PREM model
15 love_k = 0; %ideam
16 love_l = 0; %ideam
17 tide_love_k = 0; %ideam
18 tide_love_h = 0; %ideam
19 fluid_love = 0;
20 equatorial_moi = 0;
21 polar_moi = 0;
22 angular_velocity = 0;
23 rigid = 0;
24 elastic = 0;
25 rotation = 0;
26 ocean_area_scaling = 0;
27 steric_rate = 0; %rate of ocean expansion from steric effects.
28 geodetic_run_frequency = 1; %how many time steps we skip before we run the geodetic part of the solver during transient
29 geodetic = 0; %compute geodetic SLR? (in addition to steric?)
30 degacc = 0;
31 loop_increment = 0;
32 horiz = 0;
33 requested_outputs = {};
34 transitions = {};
35 end
36 methods
37 function self = slr(varargin) % {{{
38 switch nargin
39 case 0
40 self=setdefaultparameters(self);
41 otherwise
42 error('constructor not supported');
43 end
44 end % }}}
45 function self = setdefaultparameters(self) % {{{
46
47 %Convergence criterion: absolute, relative and residual
48 self.reltol=NaN; %default
49 self.abstol=0.001; %1 mm of sea level rise
50
51 %maximum of non-linear iterations.
52 self.maxiter=10;
53 self.loop_increment=200;
54
55 %computational flags:
56 self.geodetic=0;
57 self.rigid=1;
58 self.elastic=1;
59 self.rotation=0;
60 self.ocean_area_scaling=0;
61 self.ocean_area_scaling=0;
62
63 %tidal love numbers:
64 self.tide_love_h=0.6149; %degree 2
65 self.tide_love_k=0.3055; % degree 2
66
67 %secular fluid love number:
68 self.fluid_love=0.942;
69
70 %moment of inertia:
71 self.equatorial_moi=8.0077*10^37; % [kg m^2]
72 self.polar_moi =8.0345*10^37; % [kg m^2]
73
74 % mean rotational velocity of earth
75 self.angular_velocity=7.2921*10^-5; % [s^-1]
76
77 %numerical discretization accuracy
78 self.degacc=.01;
79
80 %steric:
81 self.steric_rate=0;
82
83 %how many time steps we skip before we run SLR solver during transient
84 self.geodetic_run_frequency=1;
85
86 %output default:
87 self.requested_outputs={'default'};
88
89 %transitions should be a cell array of vectors:
90 self.transitions={};
91
92 %horizontal displacement? (not by default)
93 self.horiz=0;
94
95 end % }}}
96 function md = checkconsistency(self,md,solution,analyses) % {{{
97
98 if ~ismember('SealevelriseAnalysis',analyses), return; end
99 md = checkfield(md,'fieldname','slr.deltathickness','NaN',1,'Inf',1,'size',[md.mesh.numberofelements 1]);
100 md = checkfield(md,'fieldname','slr.sealevel','NaN',1,'Inf',1,'size',[md.mesh.numberofvertices 1]);
101 md = checkfield(md,'fieldname','slr.spcthickness','Inf',1,'timeseries',1);
102 md = checkfield(md,'fieldname','slr.love_h','NaN',1,'Inf',1);
103 md = checkfield(md,'fieldname','slr.love_k','NaN',1,'Inf',1);
104 md = checkfield(md,'fieldname','slr.love_l','NaN',1,'Inf',1);
105 md = checkfield(md,'fieldname','slr.tide_love_h','NaN',1,'Inf',1);
106 md = checkfield(md,'fieldname','slr.tide_love_k','NaN',1,'Inf',1);
107 md = checkfield(md,'fieldname','slr.fluid_love','NaN',1,'Inf',1);
108 md = checkfield(md,'fieldname','slr.equatorial_moi','NaN',1,'Inf',1);
109 md = checkfield(md,'fieldname','slr.polar_moi','NaN',1,'Inf',1);
110 md = checkfield(md,'fieldname','slr.angular_velocity','NaN',1,'Inf',1);
111 md = checkfield(md,'fieldname','slr.reltol','size',[1 1]);
112 md = checkfield(md,'fieldname','slr.abstol','size',[1 1]);
113 md = checkfield(md,'fieldname','slr.maxiter','size',[1 1],'>=',1);
114 md = checkfield(md,'fieldname','slr.geodetic_run_frequency','size',[1 1],'>=',1);
115 md = checkfield(md,'fieldname','slr.steric_rate','NaN',1,'Inf',1,'size',[md.mesh.numberofvertices 1]);
116 md = checkfield(md,'fieldname','slr.degacc','size',[1 1],'>=',1e-10);
117 md = checkfield(md,'fieldname','slr.requested_outputs','stringrow',1);
118 md = checkfield(md,'fieldname','slr.loop_increment','NaN',1,'Inf',1,'>=',1);
119 md = checkfield(md,'fieldname','slr.horiz','NaN',1,'Inf',1,'values',[0 1]);
120
121 %check that love numbers are provided at the same level of accuracy:
122 if (size(self.love_h,1)~=size(self.love_k,1) | size(self.love_h,1)~=size(self.love_l,1)),
123 error('slr error message: love numbers should be provided at the same level of accuracy');
124 end
125
126 %cross check that whereever we have an ice load, the mask is <0 on each vertex:
127 pos=find(self.deltathickness);
128 maskpos=md.mask.ice_levelset(md.mesh.elements(pos,:));
129 [els,vertices]=find(maskpos>0);
130 if length(els),
131 error('slr checkconsistency fail: there are elements with ice loads where some vertices are not on the ice!');
132 end
133
134 %check that if geodetic is requested, we are a mesh3dsurface model (planet), or if we are not,
135 %a coupler to a planet model is provided.
136 if self.geodetic,
137 if md.transient.iscoupler,
138 %we are good;
139 else
140 if strcmpi(class(md.mesh),'mesh3dsurface'),
141 %we are good
142 else
143 error('model is requesting geodetic computations without being a mesh3dsurface, or being coupled to one!');
144 end
145 end
146 end
147
148
149 end % }}}
150 function list=defaultoutputs(self,md) % {{{
151 list = {'Sealevel'};
152 end % }}}
153 function disp(self) % {{{
154 disp(sprintf(' slr parameters:'));
155
156 fielddisplay(self,'deltathickness','thickness change (main loading of the slr solution core [m]');
157 fielddisplay(self,'sealevel','current sea level (prior to computation) [m]');
158 fielddisplay(self,'spcthickness','thickness constraints (NaN means no constraint) [m]');
159 fielddisplay(self,'reltol','sea level rise relative convergence criterion, (default, NaN: not applied)');
160 fielddisplay(self,'abstol','sea level rise absolute convergence criterion, NaN: not applied');
161 fielddisplay(self,'maxiter','maximum number of nonlinear iterations');
162 fielddisplay(self,'love_h','load Love number for radial displacement');
163 fielddisplay(self,'love_k','load Love number for gravitational potential perturbation');
164 fielddisplay(self,'love_l','load Love number for horizontal displacements');
165 fielddisplay(self,'tide_love_k','tidal load Love number (deg 2)');
166 fielddisplay(self,'tide_love_h','tidal load Love number (deg 2)');
167 fielddisplay(self,'fluid_love','secular fluid Love number');
168 fielddisplay(self,'equatorial_moi','mean equatorial moment of inertia [kg m^2]');
169 fielddisplay(self,'polar_moi','polar moment of inertia [kg m^2]');
170 fielddisplay(self,'angular_velocity','mean rotational velocity of earth [per second]');
171 fielddisplay(self,'ocean_area_scaling','correction for model representation of ocean area [default: No correction]');
172 fielddisplay(self,'steric_rate','rate of steric ocean expansion (in mm/yr)');
173 fielddisplay(self,'geodetic_run_frequency','how many time steps we skip before we run SLR solver during transient (default: 1)');
174 fielddisplay(self,'rigid','rigid earth graviational potential perturbation');
175 fielddisplay(self,'elastic','elastic earth graviational potential perturbation');
176 fielddisplay(self,'rotation','earth rotational potential perturbation');
177 fielddisplay(self,'degacc','accuracy (default .01 deg) for numerical discretization of the Green''s functions');
178 fielddisplay(self,'transitions','indices into parts of the mesh that will be icecaps');
179 fielddisplay(self,'requested_outputs','additional outputs requested');
180
181 end % }}}
182 function marshall(self,prefix,md,fid) % {{{
183 WriteData(fid,prefix,'object',self,'fieldname','deltathickness','format','DoubleMat','mattype',2);
184 %WriteData(fid,prefix,'object',self,'fieldname','deltathickness','format','DoubleMat','mattype',1,'timeserieslength',md.mesh.numberofelements+1);
185 WriteData(fid,prefix,'object',self,'fieldname','sealevel','mattype',1,'format','DoubleMat','timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts);
186 WriteData(fid,prefix,'object',self,'fieldname','spcthickness','format','DoubleMat','mattype',1,'timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts);
187 WriteData(fid,prefix,'object',self,'fieldname','reltol','format','Double');
188 WriteData(fid,prefix,'object',self,'fieldname','abstol','format','Double');
189 WriteData(fid,prefix,'object',self,'fieldname','maxiter','format','Integer');
190 WriteData(fid,prefix,'object',self,'fieldname','love_h','format','DoubleMat','mattype',1);
191 WriteData(fid,prefix,'object',self,'fieldname','love_k','format','DoubleMat','mattype',1);
192 WriteData(fid,prefix,'object',self,'fieldname','love_l','format','DoubleMat','mattype',1);
193 WriteData(fid,prefix,'object',self,'fieldname','tide_love_h','format','Double');
194 WriteData(fid,prefix,'object',self,'fieldname','tide_love_k','format','Double');
195 WriteData(fid,prefix,'object',self,'fieldname','fluid_love','format','Double');
196 WriteData(fid,prefix,'object',self,'fieldname','equatorial_moi','format','Double');
197 WriteData(fid,prefix,'object',self,'fieldname','polar_moi','format','Double');
198 WriteData(fid,prefix,'object',self,'fieldname','angular_velocity','format','Double');
199 WriteData(fid,prefix,'object',self,'fieldname','rigid','format','Boolean');
200 WriteData(fid,prefix,'object',self,'fieldname','elastic','format','Boolean');
201 WriteData(fid,prefix,'object',self,'fieldname','rotation','format','Boolean');
202 WriteData(fid,prefix,'object',self,'fieldname','ocean_area_scaling','format','Boolean');
203 WriteData(fid,prefix,'object',self,'fieldname','geodetic_run_frequency','format','Integer');
204 WriteData(fid,prefix,'object',self,'fieldname','steric_rate','format','DoubleMat','mattype',1,'scale',1e-3/md.constants.yts);
205 WriteData(fid,prefix,'object',self,'fieldname','degacc','format','Double');
206 WriteData(fid,prefix,'object',self,'fieldname','transitions','format','MatArray');
207 WriteData(fid,prefix,'object',self,'fieldname','loop_increment','format','Integer');
208 WriteData(fid,prefix,'object',self,'fieldname','horiz','format','Integer');
209 WriteData(fid,prefix,'object',self,'fieldname','geodetic','format','Integer');
210
211 %process requested outputs
212 outputs = self.requested_outputs;
213 pos = find(ismember(outputs,'default'));
214 if ~isempty(pos),
215 outputs(pos) = []; %remove 'default' from outputs
216 outputs = [outputs defaultoutputs(self,md)]; %add defaults
217 end
218 WriteData(fid,prefix,'data',outputs,'name','md.slr.requested_outputs','format','StringArray');
219
220 end % }}}
221 function savemodeljs(self,fid,modelname) % {{{
222
223 writejs1Darray(fid,[modelname '.slr.deltathickness'],self.deltathickness);
224 writejs1Darray(fid,[modelname '.slr.sealevel'],self.sealevel);
225 writejs1Darray(fid,[modelname '.slr.spcthickness'],self.spcthickness);
226 writejsdouble(fid,[modelname '.slr.maxiter'],self.maxiter);
227 writejsdouble(fid,[modelname '.slr.reltol'],self.reltol);
228 writejsdouble(fid,[modelname '.slr.abstol'],self.abstol);
229 writejs1Darray(fid,[modelname '.slr.love_h'],self.love_h);
230 writejs1Darray(fid,[modelname '.slr.love_k'],self.love_k);
231 writejs1Darray(fid,[modelname '.slr.love_l'],self.love_l);
232 writejsdouble(fid,[modelname '.slr.tide_love_k'],self.tide_love_k);
233 writejsdouble(fid,[modelname '.slr.tide_love_h'],self.tide_love_h);
234 writejsdouble(fid,[modelname '.slr.fluid_love'],self.fluid_love);
235 writejsdouble(fid,[modelname '.slr.equatorial_moi'],self.equatorial_moi);
236 writejsdouble(fid,[modelname '.slr.polar_moi'],self.polar_moi);
237 writejsdouble(fid,[modelname '.slr.angular_velocity'],self.angular_velocity);
238 writejsdouble(fid,[modelname '.slr.rigid'],self.rigid);
239 writejsdouble(fid,[modelname '.slr.elastic'],self.elastic);
240 writejsdouble(fid,[modelname '.slr.rotation'],self.rotation);
241 writejsdouble(fid,[modelname '.slr.ocean_area_scaling'],self.ocean_area_scaling);
242 writejsdouble(fid,[modelname '.slr.geodetic_run_frequency'],self.geodetic_run_frequency);
243 writejsdouble(fid,[modelname '.slr.elastic'],self.elastic);
244 writejs1Darray(fid,[modelname '.slr.steric_rate'],self.steric_rate);
245 writejsdouble(fid,[modelname '.slr.degacc'],self.degacc);
246 writejscellstring(fid,[modelname '.slr.requested_outputs'],self.requested_outputs);
247 writejscellarray(fid,[modelname '.slr.transitions'],self.transitions);
248 end % }}}
249 function self = extrude(self,md) % {{{
250 self.sealevel=project3d(md,'vector',self.sealevel,'type','node');
251 end % }}}
252 end
253end
Note: See TracBrowser for help on using the repository browser.