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

Last change on this file since 20947 was 20947, checked in by agscott1, 9 years ago

CHG: Changed md.materials.rheology_law to use a String for marshalling instead of an integer

  • Property svn:executable set to *
File size: 6.5 KB
RevLine 
[20764]1step=[1];
[18198]2
[20733]3if step==1 %Mesh Generation #1
[18198]4 %Mesh parameters
5 domain =['./DomainOutline.exp'];
[20733]6 hinit=10000; % element size for the initial mesh
[18198]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)
[20733]13 md=bamg(model,'domain',domain,'hmax',hinit);
[18198]14
15 %ploting
16 plotmodel(md,'data','mesh')
[20795]17 return;
[18198]18
19 % Load Velocities
20 nsidc_vel='../Data/Antarctica_ice_velocity.nc';
21
22 % Get necessary data to build up the velocity grid
[20733]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));
[18198]34 ymax = strtrim(ymax);
[20733]35 ymax = str2num(ymax(1:end-2));
[18198]36 spacing = strtrim(spacing);
[20733]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;
[18198]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
[20754]56 save ./Models/PIG_Mesh_generation md;
[18198]57end
58
[20733]59if step==2 %Masks #2
[18198]60
[20754]61 md = loadmodel('./Models/PIG_Mesh_generation');
[18202]62
[18198]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
[20754]85 save ./Models/PIG_SetMask md;
[18198]86end
87
[20733]88if step==3 %Parameterization #3
[18198]89
[20754]90 md = loadmodel('./Models/PIG_SetMask');
[18198]91 md = parameterize(md,'./Pig.par');
92
93 % Use a MacAyeal flow model
94 md = setflowequation(md,'SSA','all');
95
96 % Save model
[20754]97 save ./Models/PIG_Parameterization md;
[18198]98end
99
[20733]100if step==4 %Control Method #4
[18198]101
[20754]102 md = loadmodel('./Models/PIG_Parameterization');
[18198]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
[20947]140<<<<<<< .mine
141 save ./Models/PIG_ModelHO md;
142=======
[20754]143 save ./Models/PIG_Control_drag md;
[20947]144>>>>>>> .r20806
[18198]145end
146
[20733]147if step==5 %Plot #5
[18198]148
[20754]149 md = loadmodel('./Models/PIG_Control_drag');
[18198]150
[20795]151 plotmodel(md,'axis#all','equal',...
[18198]152 'xlim#all',[min(md.mesh.x) max(md.mesh.x)]/10^3,...
153 'ylim#all',[min(md.mesh.y) max(md.mesh.y)]/10^3,...
154 'FontSize#all',12,...
155 'data',md.initialization.vel,'title','Observed velocity',...
156 'data',md.results.StressbalanceSolution.Vel,'title','Modeled Velocity',...
157 'data',md.geometry.base,'title','Bed elevation',...
158 'data',md.results.StressbalanceSolution.FrictionCoefficient,'title','Friction Coefficient',...
159 'colorbar#all','on','colorbartitle#1-2','[m/yr]',...
160 'caxis#1-2',([1.5,4000]),...
161 'colorbartitle#3','[m]', 'log#1-2',10);
162end
163
[20733]164if step==6 %Higher-Order #6
[18198]165
166 % Load Model
[20947]167 md = loadmodel('./Models/PIG_Control_drag.mat');
[18269]168 % Disable inversion
[20947]169 md.inversion.iscontrol = 0;
[18260]170 % Extrude Mesh
[20947]171 md = extrude(md, 10, 1);
[18269]172 % Set Flowequation
[20947]173 md = setflowequation(md,'HO','all');
[18198]174 % Solve
[20947]175 md.cluster=generic('name',oshostname,'np',2);
176 md=solve(md,StressbalanceSolutionEnum);
[18198]177 % Save Model
[20947]178 save ./Models/PIG_Control_drag md;
179
[18198]180
181end
182
[20733]183if step==7 %Plot #7
[18198]184
[20754]185 mdHO = loadmodel('./Models/PIG_ModelHO');
186 mdSSA = loadmodel('./Models/PIG_Control_drag');
[18198]187
188 basal=find(mdHO.mesh.vertexonbase);
189 surf=find(mdHO.mesh.vertexonsurface);
190
[20795]191 plotmodel(mdHO,'nlines',3,'ncols',2,'axis#all','equal',...
[18260]192 'xlim#all',[min(mdHO.mesh.x) max(mdHO.mesh.x)]/10^3,...
193 'ylim#all',[min(mdHO.mesh.y) max(mdHO.mesh.y)]/10^3,...
[18198]194 'FontSize#all',12,...
[18269]195 'data',mdHO.initialization.vel,'title','Observed velocity',...
[18198]196 'data',(mdHO.results.StressbalanceSolution.Vel(surf)-mdHO.initialization.vel(surf)),'title','(HO-observed) velocities',...
197 'data',mdSSA.results.StressbalanceSolution.Vel,'title','Modeled SSA Velocity',...
198 'data',(mdHO.results.StressbalanceSolution.Vel(surf)-mdSSA.results.StressbalanceSolution.Vel),'title','(HO-SSA) velocities',...
[18269]199 'data',mdHO.results.StressbalanceSolution.Vel,'title','Modeled HO surface Velocities',...
[18198]200 'data',(mdHO.results.StressbalanceSolution.Vel(surf)-mdHO.results.StressbalanceSolution.Vel(basal)),'title','(HOsurf-HO base) velocities',...
201 'caxis#1',([1.5,4000]),'caxis#3',([1.5,4000]),'caxis#5',([1.5,4000]),...
202 'colorbar#all','on','view#all',2,...
203 'colorbartitle#all','[m/yr]',...
[18269]204 'layer#5',1, 'log#1', 10,'log#3', 10,'log#5', 10);
[18198]205end
Note: See TracBrowser for help on using the repository browser.