[5046] | 1 | % This file can be run to check that the advection-diffusion is correctly modeled.
|
---|
| 2 | % There is u=v=0 and w=cst everywhere the only thermal boundary conditions are an imposed temperature
|
---|
| 3 | % at upper surface and an impose flux at its base.
|
---|
| 4 | % Just run this file in Matlab, with a properly setup Ice code.
|
---|
| 5 |
|
---|
| 6 | md=model;
|
---|
| 7 | md=mesh(md,'../Exp/Square.exp',100000);
|
---|
| 8 | md=geography(md,'','');
|
---|
| 9 | md=parameterize(md,'../Par/SquareThermal.par');
|
---|
| 10 | md=extrude(md,30,1); %NB: the more one extrudes, the better (10-> relative~0.35%, 20->0.1%, 30->0.05%)
|
---|
| 11 | md=setelementstype(md,'Pattyn','all');
|
---|
| 12 |
|
---|
| 13 | %Thermal boundary conditions
|
---|
| 14 | pos1=find(md.elementonbed); md.spctemperature(md.elements(pos1,1:3),1)=1; md.spctemperature(md.elements(pos1,1:3),2)=10;
|
---|
| 15 | pos2=find(md.elementonsurface); md.spctemperature(md.elements(pos2,4:6),1)=1; md.spctemperature(md.elements(pos2,4:6),2)=0;
|
---|
| 16 | md.vz=0.1*ones(md.numberofgrids,1);
|
---|
| 17 | md.vel=sqrt( md.vx.^2+ md.vy.^2+ md.vz.^2);
|
---|
| 18 | md.pressure=zeros(md.numberofgrids,1);
|
---|
| 19 |
|
---|
| 20 | %analytical results
|
---|
| 21 | %d2T/dz2-w*rho_ice*c/k*dT/dz=0 T(surface)=0 T(bed)=10 => T=A exp(alpha z)+B
|
---|
| 22 | alpha=0.1/md.yts*md.rho_ice*md.heatcapacity/md.thermalconductivity; %alpha=w rho_ice c /k and w=0.1m/an
|
---|
| 23 | A=10/(exp(alpha*(-1000))-1); %A=T(bed)/(exp(alpha*bed)-1) with bed=-1000 T(bed)=10
|
---|
| 24 | B=-A;
|
---|
| 25 | md.observed_temperature=A*exp(alpha*md.z)+B;
|
---|
| 26 |
|
---|
| 27 | %modeled results
|
---|
| 28 | md=solve(md,'analysis_type',ThermalSolutionEnum);
|
---|
| 29 |
|
---|
| 30 | %plot results
|
---|
| 31 | comp_temp=zeros(md.numberofgrids,1);
|
---|
| 32 | comp_temp(md.results.ThermalSolution.Temperature.index)=md.results.ThermalSolution.Temperature.value;
|
---|
| 33 | relative=abs((comp_temp-md.observed_temperature)./md.observed_temperature)*100;
|
---|
| 34 | relative(find(comp_temp==md.observed_temperature))=0;
|
---|
| 35 | plotmodel(md,'data',comp_temp,'title','modeled temperature','data','observed_temperature','view',3,'title','analytical temperature','view',3,'data',comp_temp-md.observed_temperature,'title','absolute error','view',3,'data',relative,'title','relative error [%]','view',3)
|
---|
[5098] | 36 |
|
---|
| 37 | %Fields and tolerances to track changes
|
---|
| 38 | field_names ={'AdvectionTemperature'};
|
---|
| 39 | field_tolerances={1e-13};
|
---|
| 40 | field_values ={comp_temp};
|
---|