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

Last change on this file since 24864 was 24864, checked in by Mathieu Morlighem, 5 years ago

CHG: renaming groundedice_levelset -> ocean_levelset (negative if ocean present, positive outside

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