1 | step=[1];
|
---|
2 |
|
---|
3 | if step==1 %Mesh Generation #1
|
---|
4 | %Mesh parameters
|
---|
5 | domain =['./DomainOutline.exp'];
|
---|
6 | hinit=10000; % element size for the initial mesh
|
---|
7 | hmax=40000; % maximum element size of the final mesh
|
---|
8 | hmin=5000; % minimum element size of the final mesh
|
---|
9 | gradation=1.7; % maximum size ratio between two neighboring elements
|
---|
10 | err=8; % maximum error between interpolated and control field
|
---|
11 |
|
---|
12 | % Generate an initial uniform mesh (resolution = hinit m)
|
---|
13 | md=bamg(model,'domain',domain,'hmax',hinit);
|
---|
14 |
|
---|
15 | %ploting
|
---|
16 | plotmodel(md,'data','mesh')
|
---|
17 | return;
|
---|
18 |
|
---|
19 | % Load Velocities
|
---|
20 | nsidc_vel='../Data/Antarctica_ice_velocity.nc';
|
---|
21 |
|
---|
22 | % Get necessary data to build up the velocity grid
|
---|
23 | xmin = ncreadatt(nsidc_vel,'/','xmin');
|
---|
24 | ymax = ncreadatt(nsidc_vel,'/','ymax');
|
---|
25 | spacing = ncreadatt(nsidc_vel,'/','spacing');
|
---|
26 | nx = double(ncreadatt(nsidc_vel,'/','nx'));
|
---|
27 | ny = double(ncreadatt(nsidc_vel,'/','ny'));
|
---|
28 | vx = double(ncread(nsidc_vel,'vx'));
|
---|
29 | vy = double(ncread(nsidc_vel,'vy'));
|
---|
30 |
|
---|
31 | % Read coordinates
|
---|
32 | xmin = strtrim(xmin);
|
---|
33 | xmin = str2num(xmin(1:end-2));
|
---|
34 | ymax = strtrim(ymax);
|
---|
35 | ymax = str2num(ymax(1:end-2));
|
---|
36 | spacing = strtrim(spacing);
|
---|
37 | spacing = str2num(spacing(1:end-2));
|
---|
38 |
|
---|
39 | % Build the coordinates
|
---|
40 | x=xmin+(0:1:nx)'*spacing;
|
---|
41 | y=(ymax-ny*spacing)+(0:1:ny)'*spacing;
|
---|
42 |
|
---|
43 | % Interpolate velocities onto coarse mesh
|
---|
44 | vx_obs=InterpFromGridToMesh(x,y,flipud(vx'),md.mesh.x,md.mesh.y,0);
|
---|
45 | vy_obs=InterpFromGridToMesh(x,y,flipud(vy'),md.mesh.x,md.mesh.y,0);
|
---|
46 | vel_obs=sqrt(vx_obs.^2+vy_obs.^2);
|
---|
47 | clear vx vy x y;
|
---|
48 |
|
---|
49 | % Adapt the mesh to minimize error in velocity interpolation
|
---|
50 | md=bamg(md,'hmax',hmax,'hmin',hmin,'gradation',gradation,'field',vel_obs,'err',err);
|
---|
51 |
|
---|
52 | %ploting
|
---|
53 | plotmodel(md,'data','mesh')
|
---|
54 |
|
---|
55 | % Save model
|
---|
56 | save ./Models/PIG_Mesh_generation md;
|
---|
57 | end
|
---|
58 |
|
---|
59 | if step==2 %Masks #2
|
---|
60 |
|
---|
61 | md = loadmodel('./Models/PIG_Mesh_generation');
|
---|
62 |
|
---|
63 | % Load SeaRISe dataset for Antarctica
|
---|
64 | % http://websrv.cs.umt.edu/isis/index.php/Present_Day_Antarctica
|
---|
65 | searise='../Data/Antarctica_5km_withshelves_v0.75.nc';
|
---|
66 |
|
---|
67 | %read thickness mask from SeaRISE
|
---|
68 | x1=double(ncread(searise,'x1'));
|
---|
69 | y1=double(ncread(searise,'y1'));
|
---|
70 | thkmask=double(ncread(searise,'thkmask'));
|
---|
71 |
|
---|
72 | %interpolate onto our mesh vertices
|
---|
73 | groundedice=double(InterpFromGridToMesh(x1,y1,thkmask',md.mesh.x,md.mesh.y,0));
|
---|
74 | groundedice(groundedice<=0)=-1;
|
---|
75 | clear thkmask;
|
---|
76 |
|
---|
77 | %fill in the md.mask structure
|
---|
78 | md.mask.groundedice_levelset=groundedice; %ice is grounded for mask equal one
|
---|
79 | md.mask.ice_levelset=-1*ones(md.mesh.numberofvertices,1);%ice is present when negatvie
|
---|
80 |
|
---|
81 | %ploting
|
---|
82 | plotmodel(md,'data',md.mask.groundedice_levelset,'title','grounded/floating','data',md.mask.ice_levelset,'title','ice/no-ice')
|
---|
83 |
|
---|
84 | % Save model
|
---|
85 | save ./Models/PIG_SetMask md;
|
---|
86 | end
|
---|
87 |
|
---|
88 | if step==3 %Parameterization #3
|
---|
89 |
|
---|
90 | md = loadmodel('./Models/PIG_SetMask');
|
---|
91 | md = parameterize(md,'./Pig.par');
|
---|
92 |
|
---|
93 | % Use a MacAyeal flow model
|
---|
94 | md = setflowequation(md,'SSA','all');
|
---|
95 |
|
---|
96 | % Save model
|
---|
97 | save ./Models/PIG_Parameterization md;
|
---|
98 | end
|
---|
99 |
|
---|
100 | if step==4 %Control Method #4
|
---|
101 |
|
---|
102 | md = loadmodel('./Models/PIG_Parameterization');
|
---|
103 |
|
---|
104 | % Control general
|
---|
105 | md.inversion.iscontrol=1;
|
---|
106 | md.inversion.maxsteps=20;
|
---|
107 | md.inversion.maxiter=40;
|
---|
108 | md.inversion.dxmin=0.1;
|
---|
109 | md.inversion.gttol=1.0e-4;
|
---|
110 | md.verbose=verbose('solution',true,'control',true);
|
---|
111 |
|
---|
112 | % Cost functions
|
---|
113 | md.inversion.cost_functions=[101 103 501];
|
---|
114 | md.inversion.cost_functions_coefficients=ones(md.mesh.numberofvertices,3);
|
---|
115 | md.inversion.cost_functions_coefficients(:,1)=1;
|
---|
116 | md.inversion.cost_functions_coefficients(:,2)=1;
|
---|
117 | md.inversion.cost_functions_coefficients(:,3)=8e-15;
|
---|
118 |
|
---|
119 | % Controls
|
---|
120 | md.inversion.control_parameters={'FrictionCoefficient'};
|
---|
121 | md.inversion.min_parameters=1*ones(md.mesh.numberofvertices,1);
|
---|
122 | md.inversion.max_parameters=200*ones(md.mesh.numberofvertices,1);
|
---|
123 |
|
---|
124 | % Additional parameters
|
---|
125 | md.stressbalance.restol=0.01;
|
---|
126 | md.stressbalance.reltol=0.1;
|
---|
127 | md.stressbalance.abstol=NaN;
|
---|
128 |
|
---|
129 | % Solve
|
---|
130 | md.toolkits=toolkits;
|
---|
131 | md.cluster=generic('name',oshostname,'np',2);
|
---|
132 | md=solve(md,StressbalanceSolutionEnum);
|
---|
133 |
|
---|
134 | % Update model friction fields accordingly
|
---|
135 | md.friction.coefficient=md.results.StressbalanceSolution.FrictionCoefficient;
|
---|
136 |
|
---|
137 | plotmodel(md,'data',md.friction.coefficient)
|
---|
138 |
|
---|
139 | % Save model
|
---|
140 | save ./Models/PIG_Control_drag md;
|
---|
141 | end
|
---|
142 |
|
---|
143 | if step==5 %Plot #5
|
---|
144 |
|
---|
145 | md = loadmodel('./Models/PIG_Control_drag');
|
---|
146 |
|
---|
147 | plotmodel(md,'axis#all','equal',...
|
---|
148 | 'xlim#all',[min(md.mesh.x) max(md.mesh.x)]/10^3,...
|
---|
149 | 'ylim#all',[min(md.mesh.y) max(md.mesh.y)]/10^3,...
|
---|
150 | 'FontSize#all',12,...
|
---|
151 | 'data',md.initialization.vel,'title','Observed velocity',...
|
---|
152 | 'data',md.results.StressbalanceSolution.Vel,'title','Modeled Velocity',...
|
---|
153 | 'data',md.geometry.base,'title','Bed elevation',...
|
---|
154 | 'data',md.results.StressbalanceSolution.FrictionCoefficient,'title','Friction Coefficient',...
|
---|
155 | 'colorbar#all','on','colorbartitle#1-2','[m/yr]',...
|
---|
156 | 'caxis#1-2',([1.5,4000]),...
|
---|
157 | 'colorbartitle#3','[m]', 'log#1-2',10);
|
---|
158 | end
|
---|
159 |
|
---|
160 | if step==6 %Higher-Order #6
|
---|
161 |
|
---|
162 | % Load Model
|
---|
163 |
|
---|
164 | % Disable inversion
|
---|
165 |
|
---|
166 | % Extrude Mesh
|
---|
167 |
|
---|
168 | % Set Flowequation
|
---|
169 |
|
---|
170 | % Solve
|
---|
171 |
|
---|
172 | % Save Model
|
---|
173 |
|
---|
174 | end
|
---|
175 |
|
---|
176 | if step==7 %Plot #7
|
---|
177 |
|
---|
178 | mdHO = loadmodel('./Models/PIG_ModelHO');
|
---|
179 | mdSSA = loadmodel('./Models/PIG_Control_drag');
|
---|
180 |
|
---|
181 | basal=find(mdHO.mesh.vertexonbase);
|
---|
182 | surf=find(mdHO.mesh.vertexonsurface);
|
---|
183 |
|
---|
184 | plotmodel(mdHO,'nlines',3,'ncols',2,'axis#all','equal',...
|
---|
185 | 'xlim#all',[min(mdHO.mesh.x) max(mdHO.mesh.x)]/10^3,...
|
---|
186 | 'ylim#all',[min(mdHO.mesh.y) max(mdHO.mesh.y)]/10^3,...
|
---|
187 | 'FontSize#all',12,...
|
---|
188 | 'data',mdHO.initialization.vel,'title','Observed velocity',...
|
---|
189 | 'data',(mdHO.results.StressbalanceSolution.Vel(surf)-mdHO.initialization.vel(surf)),'title','(HO-observed) velocities',...
|
---|
190 | 'data',mdSSA.results.StressbalanceSolution.Vel,'title','Modeled SSA Velocity',...
|
---|
191 | 'data',(mdHO.results.StressbalanceSolution.Vel(surf)-mdSSA.results.StressbalanceSolution.Vel),'title','(HO-SSA) velocities',...
|
---|
192 | 'data',mdHO.results.StressbalanceSolution.Vel,'title','Modeled HO surface Velocities',...
|
---|
193 | 'data',(mdHO.results.StressbalanceSolution.Vel(surf)-mdHO.results.StressbalanceSolution.Vel(basal)),'title','(HOsurf-HO base) velocities',...
|
---|
194 | 'caxis#1',([1.5,4000]),'caxis#3',([1.5,4000]),'caxis#5',([1.5,4000]),...
|
---|
195 | 'colorbar#all','on','view#all',2,...
|
---|
196 | 'colorbartitle#all','[m/yr]',...
|
---|
197 | 'layer#5',1, 'log#1', 10,'log#3', 10,'log#5', 10);
|
---|
198 | end
|
---|