source: issm/trunk-jpl/examples/Pig/runme.m@ 20733

Last change on this file since 20733 was 20733, checked in by seroussi, 9 years ago

CHG: finished update pig test for the workshop

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