[20733] | 1 | step=[7];
|
---|
[18198] | 2 |
|
---|
[20733] | 3 | if 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')
|
---|
| 17 |
|
---|
| 18 | % Load Velocities
|
---|
| 19 | nsidc_vel='../Data/Antarctica_ice_velocity.nc';
|
---|
| 20 |
|
---|
| 21 | % Get necessary data to build up the velocity grid
|
---|
[20733] | 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));
|
---|
[18198] | 33 | ymax = strtrim(ymax);
|
---|
[20733] | 34 | ymax = str2num(ymax(1:end-2));
|
---|
[18198] | 35 | spacing = strtrim(spacing);
|
---|
[20733] | 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;
|
---|
[18198] | 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
|
---|
[18202] | 55 | save ./Models/PIG.Mesh_generation md;
|
---|
[18198] | 56 | end
|
---|
| 57 |
|
---|
[20733] | 58 | if step==2 %Masks #2
|
---|
[18198] | 59 |
|
---|
[18202] | 60 | md = loadmodel('./Models/PIG.Mesh_generation');
|
---|
| 61 |
|
---|
[18198] | 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
|
---|
[18202] | 84 | save ./Models/PIG.SetMask md;
|
---|
[18198] | 85 | end
|
---|
| 86 |
|
---|
[20733] | 87 | if step==3 %Parameterization #3
|
---|
[18198] | 88 |
|
---|
[18202] | 89 | md = loadmodel('./Models/PIG.SetMask');
|
---|
[18198] | 90 | md = parameterize(md,'./Pig.par');
|
---|
| 91 |
|
---|
| 92 | % Use a MacAyeal flow model
|
---|
| 93 | md = setflowequation(md,'SSA','all');
|
---|
| 94 |
|
---|
| 95 | % Save model
|
---|
[18202] | 96 | save ./Models/PIG.Parameterization md;
|
---|
[18198] | 97 | end
|
---|
| 98 |
|
---|
[20733] | 99 | if step==4 %Control Method #4
|
---|
[18198] | 100 |
|
---|
[18202] | 101 | md = loadmodel('./Models/PIG.Parameterization');
|
---|
[18198] | 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
|
---|
[18202] | 139 | save ./Models/PIG.Control_drag md;
|
---|
[18198] | 140 | end
|
---|
| 141 |
|
---|
[20733] | 142 | if step==5 %Plot #5
|
---|
[18198] | 143 |
|
---|
[18202] | 144 | md = loadmodel('./Models/PIG.Control_drag');
|
---|
[18198] | 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);
|
---|
| 157 | end
|
---|
| 158 |
|
---|
[20733] | 159 | if step==6 %Higher-Order #6
|
---|
[18198] | 160 |
|
---|
| 161 | % Load Model
|
---|
| 162 |
|
---|
[18269] | 163 | % Disable inversion
|
---|
[18198] | 164 |
|
---|
[18260] | 165 | % Extrude Mesh
|
---|
[18198] | 166 |
|
---|
[18269] | 167 | % Set Flowequation
|
---|
| 168 |
|
---|
[18198] | 169 | % Solve
|
---|
| 170 |
|
---|
| 171 | % Save Model
|
---|
| 172 |
|
---|
| 173 | end
|
---|
| 174 |
|
---|
[20733] | 175 | if step==7 %Plot #7
|
---|
[18198] | 176 |
|
---|
[18202] | 177 | mdHO = loadmodel('./Models/PIG.ModelHO');
|
---|
| 178 | mdSSA = loadmodel('./Models/PIG.Control_drag');
|
---|
[18198] | 179 |
|
---|
| 180 | basal=find(mdHO.mesh.vertexonbase);
|
---|
| 181 | surf=find(mdHO.mesh.vertexonsurface);
|
---|
| 182 |
|
---|
[18260] | 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,...
|
---|
[18198] | 186 | 'FontSize#all',12,...
|
---|
[18269] | 187 | 'data',mdHO.initialization.vel,'title','Observed velocity',...
|
---|
[18198] | 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',...
|
---|
[18269] | 191 | 'data',mdHO.results.StressbalanceSolution.Vel,'title','Modeled HO surface Velocities',...
|
---|
[18198] | 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]',...
|
---|
[18269] | 196 | 'layer#5',1, 'log#1', 10,'log#3', 10,'log#5', 10);
|
---|
[18198] | 197 | end
|
---|