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
RevLine 
[19984]1%SLR class definition
2%
3% Usage:
4% slr=slr();
5
6classdef slr
7 properties (SetAccess=public)
8 deltathickness = NaN;
[20154]9 sealevel = NaN;
[21324]10 spcthickness = NaN;
[19984]11 maxiter = 0;
12 reltol = 0;
13 abstol = 0;
14 love_h = 0; %provided by PREM model
15 love_k = 0; %ideam
[21000]16 love_l = 0; %ideam
[20349]17 tide_love_k = 0; %ideam
18 tide_love_h = 0; %ideam
[21759]19 fluid_love = 0;
20 equatorial_moi = 0;
21 polar_moi = 0;
22 angular_velocity = 0;
[20349]23 rigid = 0;
24 elastic = 0;
25 rotation = 0;
[21324]26 ocean_area_scaling = 0;
[21326]27 steric_rate = 0; %rate of ocean expansion from steric effects.
[22155]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?)
[20033]30 degacc = 0;
[22114]31 loop_increment = 0;
32 horiz = 0;
[20036]33 requested_outputs = {};
[20137]34 transitions = {};
[19984]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
[20074]48 self.reltol=NaN; %default
[19984]49 self.abstol=0.001; %1 mm of sea level rise
50
51 %maximum of non-linear iterations.
[20074]52 self.maxiter=10;
[22114]53 self.loop_increment=200;
[19984]54
55 %computational flags:
[22155]56 self.geodetic=0;
[19984]57 self.rigid=1;
58 self.elastic=1;
[21759]59 self.rotation=0;
[21324]60 self.ocean_area_scaling=0;
[21759]61 self.ocean_area_scaling=0;
[20033]62
[20349]63 %tidal love numbers:
64 self.tide_love_h=0.6149; %degree 2
65 self.tide_love_k=0.3055; % degree 2
[21759]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]
[20349]73
[21759]74 % mean rotational velocity of earth
75 self.angular_velocity=7.2921*10^-5; % [s^-1]
76
[20033]77 %numerical discretization accuracy
78 self.degacc=.01;
[21326]79
80 %steric:
81 self.steric_rate=0;
[21329]82
83 %how many time steps we skip before we run SLR solver during transient
[22155]84 self.geodetic_run_frequency=1;
[21329]85
[20036]86 %output default:
87 self.requested_outputs={'default'};
[20137]88
89 %transitions should be a cell array of vectors:
90 self.transitions={};
[22114]91
92 %horizontal displacement? (not by default)
93 self.horiz=0;
[20036]94
[19984]95 end % }}}
96 function md = checkconsistency(self,md,solution,analyses) % {{{
97
[21049]98 if ~ismember('SealevelriseAnalysis',analyses), return; end
[20322]99 md = checkfield(md,'fieldname','slr.deltathickness','NaN',1,'Inf',1,'size',[md.mesh.numberofelements 1]);
[20154]100 md = checkfield(md,'fieldname','slr.sealevel','NaN',1,'Inf',1,'size',[md.mesh.numberofvertices 1]);
[21324]101 md = checkfield(md,'fieldname','slr.spcthickness','Inf',1,'timeseries',1);
[19984]102 md = checkfield(md,'fieldname','slr.love_h','NaN',1,'Inf',1);
103 md = checkfield(md,'fieldname','slr.love_k','NaN',1,'Inf',1);
[21000]104 md = checkfield(md,'fieldname','slr.love_l','NaN',1,'Inf',1);
[20349]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);
[21759]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);
[19984]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);
[22155]114 md = checkfield(md,'fieldname','slr.geodetic_run_frequency','size',[1 1],'>=',1);
[21759]115 md = checkfield(md,'fieldname','slr.steric_rate','NaN',1,'Inf',1,'size',[md.mesh.numberofvertices 1]);
[20033]116 md = checkfield(md,'fieldname','slr.degacc','size',[1 1],'>=',1e-10);
[20036]117 md = checkfield(md,'fieldname','slr.requested_outputs','stringrow',1);
[22114]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]);
[19984]120
121 %check that love numbers are provided at the same level of accuracy:
[21000]122 if (size(self.love_h,1)~=size(self.love_k,1) | size(self.love_h,1)~=size(self.love_l,1)),
[19984]123 error('slr error message: love numbers should be provided at the same level of accuracy');
124 end
125
[20322]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
[22155]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
[19984]149 end % }}}
[20036]150 function list=defaultoutputs(self,md) % {{{
[20154]151 list = {'Sealevel'};
[20036]152 end % }}}
[19984]153 function disp(self) % {{{
154 disp(sprintf(' slr parameters:'));
155
156 fielddisplay(self,'deltathickness','thickness change (main loading of the slr solution core [m]');
[20154]157 fielddisplay(self,'sealevel','current sea level (prior to computation) [m]');
[21324]158 fielddisplay(self,'spcthickness','thickness constraints (NaN means no constraint) [m]');
[20074]159 fielddisplay(self,'reltol','sea level rise relative convergence criterion, (default, NaN: not applied)');
[19984]160 fielddisplay(self,'abstol','sea level rise absolute convergence criterion, NaN: not applied');
161 fielddisplay(self,'maxiter','maximum number of nonlinear iterations');
[21000]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)');
[21759]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]');
[21324]171 fielddisplay(self,'ocean_area_scaling','correction for model representation of ocean area [default: No correction]');
[21326]172 fielddisplay(self,'steric_rate','rate of steric ocean expansion (in mm/yr)');
[22155]173 fielddisplay(self,'geodetic_run_frequency','how many time steps we skip before we run SLR solver during transient (default: 1)');
[19984]174 fielddisplay(self,'rigid','rigid earth graviational potential perturbation');
175 fielddisplay(self,'elastic','elastic earth graviational potential perturbation');
[21759]176 fielddisplay(self,'rotation','earth rotational potential perturbation');
[20033]177 fielddisplay(self,'degacc','accuracy (default .01 deg) for numerical discretization of the Green''s functions');
[20137]178 fielddisplay(self,'transitions','indices into parts of the mesh that will be icecaps');
[20036]179 fielddisplay(self,'requested_outputs','additional outputs requested');
[19984]180
181 end % }}}
[20690]182 function marshall(self,prefix,md,fid) % {{{
183 WriteData(fid,prefix,'object',self,'fieldname','deltathickness','format','DoubleMat','mattype',2);
[21759]184 %WriteData(fid,prefix,'object',self,'fieldname','deltathickness','format','DoubleMat','mattype',1,'timeserieslength',md.mesh.numberofelements+1);
[20902]185 WriteData(fid,prefix,'object',self,'fieldname','sealevel','mattype',1,'format','DoubleMat','timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts);
[21324]186 WriteData(fid,prefix,'object',self,'fieldname','spcthickness','format','DoubleMat','mattype',1,'timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts);
[20690]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);
[21000]192 WriteData(fid,prefix,'object',self,'fieldname','love_l','format','DoubleMat','mattype',1);
[20891]193 WriteData(fid,prefix,'object',self,'fieldname','tide_love_h','format','Double');
[20690]194 WriteData(fid,prefix,'object',self,'fieldname','tide_love_k','format','Double');
[21759]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');
[20690]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');
[21324]202 WriteData(fid,prefix,'object',self,'fieldname','ocean_area_scaling','format','Boolean');
[22155]203 WriteData(fid,prefix,'object',self,'fieldname','geodetic_run_frequency','format','Integer');
[21759]204 WriteData(fid,prefix,'object',self,'fieldname','steric_rate','format','DoubleMat','mattype',1,'scale',1e-3/md.constants.yts);
[20690]205 WriteData(fid,prefix,'object',self,'fieldname','degacc','format','Double');
206 WriteData(fid,prefix,'object',self,'fieldname','transitions','format','MatArray');
[22114]207 WriteData(fid,prefix,'object',self,'fieldname','loop_increment','format','Integer');
208 WriteData(fid,prefix,'object',self,'fieldname','horiz','format','Integer');
[22155]209 WriteData(fid,prefix,'object',self,'fieldname','geodetic','format','Integer');
[20036]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
[20690]218 WriteData(fid,prefix,'data',outputs,'name','md.slr.requested_outputs','format','StringArray');
[20036]219
[19984]220 end % }}}
221 function savemodeljs(self,fid,modelname) % {{{
222
[20181]223 writejs1Darray(fid,[modelname '.slr.deltathickness'],self.deltathickness);
224 writejs1Darray(fid,[modelname '.slr.sealevel'],self.sealevel);
[21324]225 writejs1Darray(fid,[modelname '.slr.spcthickness'],self.spcthickness);
[20262]226 writejsdouble(fid,[modelname '.slr.maxiter'],self.maxiter);
[19984]227 writejsdouble(fid,[modelname '.slr.reltol'],self.reltol);
228 writejsdouble(fid,[modelname '.slr.abstol'],self.abstol);
[20181]229 writejs1Darray(fid,[modelname '.slr.love_h'],self.love_h);
230 writejs1Darray(fid,[modelname '.slr.love_k'],self.love_k);
[21000]231 writejs1Darray(fid,[modelname '.slr.love_l'],self.love_l);
[20349]232 writejsdouble(fid,[modelname '.slr.tide_love_k'],self.tide_love_k);
233 writejsdouble(fid,[modelname '.slr.tide_love_h'],self.tide_love_h);
[21759]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);
[19984]238 writejsdouble(fid,[modelname '.slr.rigid'],self.rigid);
[21759]239 writejsdouble(fid,[modelname '.slr.elastic'],self.elastic);
[20349]240 writejsdouble(fid,[modelname '.slr.rotation'],self.rotation);
[21324]241 writejsdouble(fid,[modelname '.slr.ocean_area_scaling'],self.ocean_area_scaling);
[22155]242 writejsdouble(fid,[modelname '.slr.geodetic_run_frequency'],self.geodetic_run_frequency);
[20262]243 writejsdouble(fid,[modelname '.slr.elastic'],self.elastic);
[21759]244 writejs1Darray(fid,[modelname '.slr.steric_rate'],self.steric_rate);
[20033]245 writejsdouble(fid,[modelname '.slr.degacc'],self.degacc);
[20036]246 writejscellstring(fid,[modelname '.slr.requested_outputs'],self.requested_outputs);
[20262]247 writejscellarray(fid,[modelname '.slr.transitions'],self.transitions);
[19984]248 end % }}}
[22091]249 function self = extrude(self,md) % {{{
250 self.sealevel=project3d(md,'vector',self.sealevel,'type','node');
251 end % }}}
[19984]252 end
253end
Note: See TracBrowser for help on using the repository browser.