[20764] | 1 | step=[1];
|
---|
[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')
|
---|
[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] | 57 | end
|
---|
| 58 |
|
---|
[20733] | 59 | if 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] | 86 | end
|
---|
| 87 |
|
---|
[20733] | 88 | if 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] | 98 | end
|
---|
| 99 |
|
---|
[20733] | 100 | if 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
|
---|
[20754] | 140 | save ./Models/PIG_Control_drag md;
|
---|
[18198] | 141 | end
|
---|
| 142 |
|
---|
[20733] | 143 | if step==5 %Plot #5
|
---|
[18198] | 144 |
|
---|
[20754] | 145 | md = loadmodel('./Models/PIG_Control_drag');
|
---|
[18198] | 146 |
|
---|
[20795] | 147 | plotmodel(md,'axis#all','equal',...
|
---|
[18198] | 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 |
|
---|
[20733] | 160 | if step==6 %Higher-Order #6
|
---|
[18198] | 161 |
|
---|
| 162 | % Load Model
|
---|
[20951] | 163 |
|
---|
[18269] | 164 | % Disable inversion
|
---|
[20951] | 165 |
|
---|
[18260] | 166 | % Extrude Mesh
|
---|
[20951] | 167 |
|
---|
[18269] | 168 | % Set Flowequation
|
---|
[20951] | 169 |
|
---|
[18198] | 170 | % Solve
|
---|
[20951] | 171 |
|
---|
[18198] | 172 | % Save Model
|
---|
| 173 |
|
---|
| 174 | end
|
---|
| 175 |
|
---|
[20733] | 176 | if step==7 %Plot #7
|
---|
[18198] | 177 |
|
---|
[20754] | 178 | mdHO = loadmodel('./Models/PIG_ModelHO');
|
---|
| 179 | mdSSA = loadmodel('./Models/PIG_Control_drag');
|
---|
[18198] | 180 |
|
---|
| 181 | basal=find(mdHO.mesh.vertexonbase);
|
---|
| 182 | surf=find(mdHO.mesh.vertexonsurface);
|
---|
| 183 |
|
---|
[20795] | 184 | plotmodel(mdHO,'nlines',3,'ncols',2,'axis#all','equal',...
|
---|
[18260] | 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,...
|
---|
[18198] | 187 | 'FontSize#all',12,...
|
---|
[18269] | 188 | 'data',mdHO.initialization.vel,'title','Observed velocity',...
|
---|
[18198] | 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',...
|
---|
[18269] | 192 | 'data',mdHO.results.StressbalanceSolution.Vel,'title','Modeled HO surface Velocities',...
|
---|
[18198] | 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]',...
|
---|
[18269] | 197 | 'layer#5',1, 'log#1', 10,'log#3', 10,'log#5', 10);
|
---|
[18198] | 198 | end
|
---|