source: issm/trunk-jpl/test/SandBox/test2004.m@ 24775

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

CHG: slr test out of a sealevel class model, concept is working.

File size: 13.0 KB
Line 
1%Test Name: Earth_Antarctica_GIA
2
3%Data paths: {{{
4modeldatapath='/Users/larour/ModelData';
5shppath='/Users/larour/issm-jpl/proj-group/qgis/NightlyRun';
6gshhsshapefile=[modeldatapath '/Gshhg/Shp/GSHHS_shp/c/GSHHS_c_L1.shp'];
7%}}}
8
9%create sealevel model to hold our information:
10 sl=sealevelmodel();
11
12%Create basins using boundaries from shapefile:
13%some projections we'll rely on: %{{{
14proj4326=epsg2proj(4326);
15proj3031=epsg2proj(3031);
16%}}}
17%HemisphereWest: {{{
18sl.addbasin(basin('continent','hemispherewest','name','hemispherewest','proj',laea(0,-90),'boundaries',{... %Peru projection 3587
19 boundary('shppath',shppath,'shpfilename','HemisphereSplit','proj',proj4326,'orientation','reverse'),...
20 boundary('shppath',shppath,'shpfilename','NorthAntarctica','proj',proj3031),...
21 boundary('shppath',shppath,'shpfilename','RonneBrunt','proj',proj3031,'orientation','reverse'),...
22 boundary('shppath',shppath,'shpfilename','RonneEastSummit','proj',proj3031),...
23 boundary('shppath',shppath,'shpfilename','RonneFront','proj',proj3031,'orientation','reverse'),...
24 boundary('shppath',shppath,'shpfilename','RonneWestSummit','proj',proj3031),...
25 boundary('shppath',shppath,'shpfilename','WestAntarctica2','proj',proj3031,'orientation','reverse'),...
26 boundary('shppath',shppath,'shpfilename','SouthAntarctica','proj',proj3031)...
27 }));
28 %}}}
29 %HemisphereEast: {{{
30 sl.addbasin(basin('continent','hemisphereeast','name','hemisphereeast','proj',laea(0,+90),'boundaries',{... %Australian projection lat,long
31 boundary('shppath',shppath,'shpfilename','HemisphereSplit','proj',proj4326),...
32 boundary('shppath',shppath,'shpfilename','SouthAntarctica','proj',proj3031),...
33 boundary('shppath',shppath,'shpfilename','EastAntarctica2','proj',proj3031,'orientation','reverse'),...
34 boundary('shppath',shppath,'shpfilename','NorthAntarctica','proj',proj3031)...
35 }));
36%}}}
37%Antarctica excluding Ronne: {{{
38sl.addbasin(basin('continent','antarctica','name','antarctica-grounded','proj',proj3031,'boundaries',{...
39 boundary('shppath',shppath,'shpfilename','NorthAntarctica','proj',proj3031),...
40 boundary('shppath',shppath,'shpfilename','EastAntarctica2','proj',proj3031),...
41 boundary('shppath',shppath,'shpfilename','SouthAntarctica','proj',proj3031),...
42 boundary('shppath',shppath,'shpfilename','WestAntarctica2','proj',proj3031)...
43 boundary('shppath',shppath,'shpfilename','RonneWestSummit','proj',proj3031)...
44 boundary('shppath',shppath,'shpfilename','RonneIceShelf','proj',proj3031)...
45 boundary('shppath',shppath,'shpfilename','RonneEastSummit','proj',proj3031)...
46 boundary('shppath',shppath,'shpfilename','RonneBrunt','proj',proj3031)...
47 }));
48 %}}}
49 %Ronne: {{{
50 sl.addbasin(basin('continent','antarctica','name','ronne','proj',proj3031,'boundaries',{...
51 boundary('shppath',shppath,'shpfilename','RonneWestSummit','proj',proj3031),...
52 boundary('shppath',shppath,'shpfilename','RonneIceShelf','proj',proj3031),...
53 boundary('shppath',shppath,'shpfilename','RonneEastSummit','proj',proj3031),...
54 boundary('shppath',shppath,'shpfilename','RonneFront','proj',proj3031,'orientation','reverse')...
55 }));
56%}}}
57
58%Meshing
59%Go through basins and mesh: %{{{
60%meshing parameters: {{{
61hmin=2000; hmax=10000; hmin=hmin*1000; hmax=hmax*1000;
62tolerance=100; %tolerance of 100m on Earth position when mergin 3d meshes
63threshold=5;
64defaultoptions={'KeepVertices',0,'MaxCornerAngle',0.0000000001,'NoBoundaryRefinment',1};
65alreadyloaded=0;
66%}}}
67for i=sl.basinindx('basin','all'),
68
69 bas=sl.basins{i};
70 disp(sprintf('Meshing basin %s\n',bas.name));
71
72 %recover basin domain:
73 domain=bas.contour();
74
75 %recover coastline inside basin, using GSHHS_c_L1. It's a lat,long file, hence epsg 4326
76 coastline=bas.shapefilecrop('shapefile',gshhsshapefile,'epsgshapefile',4326,'threshold',threshold);
77
78 %mesh:
79 md=bamg(model,'domain',domain,'subdomains',coastline,'hmin',hmin,'hmax',hmax,defaultoptions{:});
80 plotmodel(md,'data','mesh');pause(1);
81
82 %miscellaneous:
83 md.mesh.proj=bas.proj; md.miscellaneous.name=bas.name;
84
85 %recover mask where we have land:
86 md.private.bamg.landmask=double(md.private.bamg.mesh.Triangles(:,4)>=1);
87
88 %vertex connectivity:
89 md.mesh.vertexconnectivity=NodeConnectivity(md.mesh.elements,md.mesh.numberofvertices);
90
91 %add model to sl icecaps:
92 sl.addicecap(md);
93end
94%}}}
95
96%Parameterization:
97%Parameterize ice sheets : {{{
98
99for ind=sl.basinindx('continent',{'antarctica'}),
100 disp(sprintf('Parameterizing basin %s\n', sl.icecaps{ind}.miscellaneous.name));
101
102 md=sl.icecaps{ind}; bas=sl.basins{ind};
103 %masks : %{{{
104 %new type of mask:
105 md.mask=maskpsl;
106
107 %land and ocean:
108 md.mask.land_levelset=ones(md.mesh.numberofvertices,1);
109 md.mask.ocean_levelset=zeros(md.mesh.numberofvertices,1);
110
111 %ice levelset from domain outlines:
112 md.mask.ice_levelset=-ones(md.mesh.numberofvertices,1);
113 pos=find(md.mesh.vertexonboundary); md.mask.ice_levelset(pos)=0;
114
115 %ice front:
116 pos=find(md.mask.ice_levelset==0); md.mask.ocean_levelset(pos)=-1; md.mask.land_levelset(pos)=1;
117
118 %now, glaciers:
119 md.mask.glacier_levelset=zeros(md.mesh.numberofvertices,1);
120 %}}}
121 %initial grounding line position: {{{
122 if bas.isnameany('antarctica-grounded'),
123
124 md.mask.groundedice_levelset=ones(md.mesh.numberofvertices,1);
125 end
126 if bas.isnameany('ronne'),
127
128 md.mask.groundedice_levelset=-ones(md.mesh.numberofvertices,1);
129
130 %correction to land and ocean levelset: ice shelf is not on land!
131 pos=find(md.mask.ice_levelset<=0 & md.mask.groundedice_levelset<=0);
132 md.mask.ocean_levelset(pos)=1;
133 md.mask.land_levelset(pos)=-1;
134 end
135 %}}}
136 %latlong: % {{{
137 [md.mesh.long,md.mesh.lat]=gdaltransform(md.mesh.x,md.mesh.y,md.mesh.proj,'EPSG:4326');
138 %}}}
139 %geometry: {{{
140 if bas.iscontinentany('antarctica'),
141 di=md.materials.rho_ice/md.materials.rho_water;
142
143 disp(' reading bedrock');
144 md.geometry.bed=interpBedmap2(md.mesh.x,md.mesh.y,'bed');
145 end % }}}
146 %Slr: {{{
147 if bas.iscontinentany('antarctica'),
148
149 delH=textread([modeldatapath '/AdhikariSciAdvTrends/AIS_delH_trend.txt']);
150 longAIS=delH(:,1);
151 latAIS=delH(:,2);
152 delHAIS=delH(:,3);
153 index=delaunay(latAIS,longAIS);
154
155 lat=md.mesh.lat;
156 long=md.mesh.long+360;
157 pos=find(long>360);long(pos)=long(pos)-360;
158
159 delHAIS=InterpFromMesh2d(index,longAIS,latAIS,delHAIS,long,lat);
160 northpole=find_point(md.mesh.long,md.mesh.lat,0,90); delHAIS(northpole)=0;
161
162 md.slr.deltathickness=delHAIS(md.mesh.elements)*[1;1;1]/3/100;
163
164 md.slr.sealevel=zeros(md.mesh.numberofvertices,1);
165 md.slr.spcthickness=NaN*ones(md.mesh.numberofvertices,1);
166 md.slr.Ngia=zeros(md.mesh.numberofvertices,1);
167 md.slr.Ugia=zeros(md.mesh.numberofvertices,1);
168
169 md.dsl.global_average_thermosteric_sea_level_change=[0;0];
170 md.dsl.sea_surface_height_change_above_geoid=zeros(md.mesh.numberofvertices+1,1);
171 md.dsl.sea_water_pressure_change_at_sea_floor=zeros(md.mesh.numberofvertices+1,1);
172 md.slr.hydro_rate = zeros(md.mesh.numberofvertices,1);
173
174 end %}}}
175 % material properties: {{{
176 md.materials=materials('hydro');
177 %}}}
178 %diverse: {{{
179 md.miscellaneous.name=bas.name;
180 % }}}
181
182 sl.icecaps{ind}=md;
183end
184%}}}
185% ParameterizeContinents {{{
186
187sl.basinindx('continent',{'hemisphereeast','hemispherewest'})
188
189for ind=sl.basinindx('continent',{'hemisphereeast','hemispherewest'}),
190 disp(sprintf('Masks for basin %s\n', sl.icecaps{ind}.miscellaneous.name));
191 md=sl.icecaps{ind}; bas=sl.basins{ind};
192
193 %recover lat,long:
194 [md.mesh.long,md.mesh.lat]=gdaltransform(md.mesh.x,md.mesh.y,md.mesh.proj,'EPSG:4326');
195
196 %mask: %{{{
197 %new type of mask:
198 md.mask=maskpsl;
199 %Figure out mask from initial mesh: deal with land and ocean masks (land include grounded ice). %{{{
200 %first, transform land element mask into vertex driven one.
201 land=md.private.bamg.landmask;
202 land_mask=-ones(md.mesh.numberofvertices,1);
203
204 landels=find(land);
205 land_mask(md.mesh.elements(landels,:))=1;
206
207 %gothrough edges of each land element
208 connectedels=md.mesh.elementconnectivity(landels,:);
209 connectedisonocean=~land(connectedels);
210 sumconnectedisonocean=sum(connectedisonocean,2);
211
212 %figure out which land elements are connected to the ocean:
213 landelsconocean=landels(find(sumconnectedisonocean));
214
215 ind1=[md.mesh.elements(landelsconocean,1); md.mesh.elements(landelsconocean,2); md.mesh.elements(landelsconocean,3)];
216 ind2=[md.mesh.elements(landelsconocean,2); md.mesh.elements(landelsconocean,3); md.mesh.elements(landelsconocean,1)];
217
218 h=waitbar(0,'Starting mask processing');
219
220 %edge ind1 and ind2:
221 for i=1:length(ind1),
222 if ~mod(i,100),
223 waitbar(i/length(ind1),h,sprintf('%.2i%% along...',i/length(ind1)*100));
224 end
225
226 els1=md.mesh.vertexconnectivity(ind1(i),1: md.mesh.vertexconnectivity(ind1(i),end));
227 els2=md.mesh.vertexconnectivity(ind2(i),1: md.mesh.vertexconnectivity(ind2(i),end));
228 els=intersect(els1,els2);
229
230 if length(find(land(els)))==1,
231 %this edge is on the beach, 0 the edge:
232 land_mask(ind1(i))=0;
233 land_mask(ind2(i))=0;
234 end
235 end
236 md.mask.land_levelset=land_mask;
237 close(h);
238 %}}}
239 %work on ocean, glaciers and ice: {{{
240 %ocean: opposite of land:
241 md.mask.ocean_levelset=-md.mask.land_levelset;
242
243 %initliaze:
244 md.mask.ice_levelset=ones(md.mesh.numberofvertices,1);
245
246 %grounded ice:
247 md.mask.groundedice_levelset=-ones(md.mesh.numberofvertices,1);
248
249 md.mask.glacier_levelset=zeros(md.mesh.numberofvertices,1);
250
251 % }}}
252 %}}}
253 %slr loading/calibration: {{{
254
255 md.slr.sealevel=zeros(md.mesh.numberofvertices,1);
256 md.slr.deltathickness=zeros(md.mesh.numberofelements,1);
257 md.slr.spcthickness=NaN*ones(md.mesh.numberofvertices,1);
258 md.slr.Ngia=zeros(md.mesh.numberofvertices,1);
259 md.slr.Ugia=zeros(md.mesh.numberofvertices,1);
260
261 md.dsl.global_average_thermosteric_sea_level_change=[0;0];
262 %md.slr.steric_rate=(1.1+.38)*ones(md.mesh.numberofvertices,1); %steric + water storage.
263 md.dsl.sea_surface_height_change_above_geoid=zeros(md.mesh.numberofvertices+1,1);
264 md.dsl.sea_water_pressure_change_at_sea_floor=zeros(md.mesh.numberofvertices+1,1);
265 md.slr.hydro_rate = zeros(md.mesh.numberofvertices,1);
266
267 %love numbers:
268 md.slr.ocean_area_scaling=1;
269 %}}}
270 %geometry: {{{
271 di=md.materials.rho_ice/md.materials.rho_water;
272 md.geometry.bed=-ones(md.mesh.numberofvertices,1);
273 % }}}
274 %materials: {{{
275 md.materials=materials('hydro');
276 % }}}
277 sl.icecaps{ind}=md;
278end
279% }}}
280
281%%Assemble Earth in 3D {{{
282
283%parameters:
284plotting=1;
285tolerance=100;
286loneedgesdetect=0;
287
288%create earth model by concatenating all the icecaps in 3d:
289sl.caticecaps('tolerance',tolerance,'loneedgesdetect',loneedgesdetect);
290
291%figure out how each icecap's mesh connects to the larger earth mesh:
292sl.intersections('force',1);
293
294%figure out connectivity:
295disp('Mesh connectivity');
296sl.earth.mesh.vertexconnectivity=NodeConnectivity(sl.earth.mesh.elements,sl.earth.mesh.numberofvertices);
297
298%areas:
299disp('Mesh nodal areas');
300sl.earth.mesh.area=averaging(sl.earth,GetAreas3DTria(sl.earth.mesh.elements,sl.earth.mesh.x,sl.earth.mesh.y,sl.earth.mesh.z),4);
301
302%transfer a list of fields from each icecap and continent back to Earth:
303sl.transfer('mask.groundedice_levelset');
304sl.transfer('mask.ice_levelset');
305sl.transfer('mask.ocean_levelset');
306sl.transfer('mask.land_levelset');
307sl.transfer('mask.glacier_levelset');
308sl.transfer('geometry.bed');
309sl.transfer('mesh.lat');
310sl.transfer('mesh.long');
311sl.transfer('slr.deltathickness');
312sl.transfer('slr.spcthickness');
313sl.transfer('slr.Ngia');
314sl.transfer('slr.Ugia');
315sl.transfer('slr.hydro_rate');
316sl.transfer('slr.sealevel');
317sl.transfer('dsl.sea_surface_height_change_above_geoid');
318sl.transfer('dsl.sea_water_pressure_change_at_sea_floor');
319
320%radius:
321sl.earth.mesh.r=sqrt(sl.earth.mesh.x.^2+sl.earth.mesh.y.^2+sl.earth.mesh.z.^2);
322
323%check on the mesh transitions: {{{
324plotting=1;
325if plotting,
326 flags=ones(sl.earth.mesh.numberofelements,1);
327 for i=1:length(sl.eltransitions),
328 flags(sl.eltransitions{i})=i;
329 end
330 plotmodel(sl.earth,'data',flags,'shading','faceted','coastline','on','coast_color','g')
331end
332%}}}}
333
334% }}}
335
336%Solve Sea-level equation on Earth only: {{{
337md=sl.earth; %we don't do computations on ice sheets or land.
338
339%Materials:
340md.materials=materials('hydro');
341
342%elastic loading from love numbers:
343nlov=1001;
344md.slr.love_h = love_numbers('h'); md.slr.love_h(nlov+1:end)=[];
345md.slr.love_k = love_numbers('k'); md.slr.love_k(nlov+1:end)=[];
346md.slr.love_l = love_numbers('l'); md.slr.love_l(nlov+1:end)=[];
347md.slr.ocean_area_scaling = 0;
348
349%Miscellaneous
350md.miscellaneous.name='test2004';
351
352%New stuff
353md.dsl.global_average_thermosteric_sea_level_change=[0;0];
354
355%Solution parameters
356md.slr.reltol=NaN;
357md.slr.abstol=1e-3;
358md.slr.geodetic=1;
359
360%eustatic:
361md.slr.rigid=0; md.slr.elastic=0; md.slr.rotation=0;
362md.cluster=generic('name',oshostname(),'np',10);
363md=solve(md,'Sealevelrise');
364
365%eustatic + rigid + elastic run:
366md.slr.rigid=1; md.slr.elastic=1; md.slr.rotation=0;
367md.cluster=generic('name',oshostname(),'np',16);
368md.verbose=verbose('111111111');
369md=solve(md,'Sealevelrise');
370SnoRotation=md.results.SealevelriseSolution.Sealevel;
371
372%eustatic + rigid + elastic + rotation run:
373md.slr.rigid=1; md.slr.elastic=1; md.slr.rotation=1;
374md.cluster=generic('name',oshostname(),'np',3);
375%md.verbose=verbose('111111111');
376md=solve(md,'Sealevelrise');
377SRotation=md.results.SealevelriseSolution.Sealevel;
378
379%Fields and tolerances to track changes
380field_names ={'noRotation','Rotation'};
381field_tolerances={1e-13,1e-13};
382field_values={SnoRotation,SRotation};
383
384%}}}
Note: See TracBrowser for help on using the repository browser.