1 | /*!\file SurfaceMassBalancex
|
---|
2 | * \brief: calculates SMB
|
---|
3 | */
|
---|
4 |
|
---|
5 | #include <config.h>
|
---|
6 | #include "./SurfaceMassBalancex.h"
|
---|
7 | #include "../../shared/shared.h"
|
---|
8 | #include "../../toolkits/toolkits.h"
|
---|
9 | #include "../modules.h"
|
---|
10 | #include "../../classes/Inputs/TransientInput.h"
|
---|
11 | #include "../../shared/Random/random.h"
|
---|
12 |
|
---|
13 | void SmbForcingx(FemModel* femmodel){/*{{{*/
|
---|
14 |
|
---|
15 | // void SmbForcingx(smb,ni){
|
---|
16 | // INPUT parameters: ni: working size of arrays
|
---|
17 | // OUTPUT: mass-balance (m/yr ice): agd(NA)
|
---|
18 |
|
---|
19 | }/*}}}*/
|
---|
20 | void SmbGradientsx(FemModel* femmodel){/*{{{*/
|
---|
21 |
|
---|
22 | // void SurfaceMassBalancex(hd,agd,ni){
|
---|
23 | // INPUT parameters: ni: working size of arrays
|
---|
24 | // INPUT: surface elevation (m): hd(NA)
|
---|
25 | // OUTPUT: mass-balance (m/yr ice): agd(NA)
|
---|
26 | int v;
|
---|
27 | IssmDouble rho_water; // density of fresh water
|
---|
28 | IssmDouble rho_ice; // density of ice
|
---|
29 | IssmDouble yts; // conversion factor year to second
|
---|
30 |
|
---|
31 | /*Loop over all the elements of this partition*/
|
---|
32 | for(Object* & object : femmodel->elements->objects){
|
---|
33 | Element* element=xDynamicCast<Element*>(object);
|
---|
34 |
|
---|
35 | /*Allocate all arrays*/
|
---|
36 | int numvertices = element->GetNumberOfVertices();
|
---|
37 | IssmDouble* Href = xNew<IssmDouble>(numvertices); // reference elevation from which deviations are used to calculate the SMB adjustment
|
---|
38 | IssmDouble* Smbref = xNew<IssmDouble>(numvertices); // reference SMB to which deviations are added
|
---|
39 | IssmDouble* b_pos = xNew<IssmDouble>(numvertices); // Hs-SMB relation parameter
|
---|
40 | IssmDouble* b_neg = xNew<IssmDouble>(numvertices); // Hs-SMB relation paremeter
|
---|
41 | IssmDouble* s = xNew<IssmDouble>(numvertices); // surface elevation (m)
|
---|
42 | IssmDouble* smb = xNew<IssmDouble>(numvertices);
|
---|
43 |
|
---|
44 | /*Recover SmbGradients*/
|
---|
45 | element->GetInputListOnVertices(Href,SmbHrefEnum);
|
---|
46 | element->GetInputListOnVertices(Smbref,SmbSmbrefEnum);
|
---|
47 | element->GetInputListOnVertices(b_pos,SmbBPosEnum);
|
---|
48 | element->GetInputListOnVertices(b_neg,SmbBNegEnum);
|
---|
49 |
|
---|
50 | /*Recover surface elevation at vertices: */
|
---|
51 | element->GetInputListOnVertices(s,SurfaceEnum);
|
---|
52 |
|
---|
53 | /*Get material parameters :*/
|
---|
54 | rho_ice=element->FindParam(MaterialsRhoIceEnum);
|
---|
55 | rho_water=element->FindParam(MaterialsRhoFreshwaterEnum);
|
---|
56 |
|
---|
57 | /* Get constants */
|
---|
58 | femmodel->parameters->FindParam(&yts,ConstantsYtsEnum);
|
---|
59 |
|
---|
60 | // loop over all vertices
|
---|
61 | for(v=0;v<numvertices;v++){
|
---|
62 | if(Smbref[v]>0){
|
---|
63 | smb[v]=Smbref[v]+b_pos[v]*(s[v]-Href[v]);
|
---|
64 | }
|
---|
65 | else{
|
---|
66 | smb[v]=Smbref[v]+b_neg[v]*(s[v]-Href[v]);
|
---|
67 | }
|
---|
68 |
|
---|
69 | smb[v]=smb[v]/1000*rho_water/rho_ice; // SMB in m/y ice
|
---|
70 | } //end of the loop over the vertices
|
---|
71 |
|
---|
72 | /*Add input to element and Free memory*/
|
---|
73 | element->AddInput(SmbMassBalanceEnum,smb,P1Enum);
|
---|
74 | xDelete<IssmDouble>(Href);
|
---|
75 | xDelete<IssmDouble>(Smbref);
|
---|
76 | xDelete<IssmDouble>(b_pos);
|
---|
77 | xDelete<IssmDouble>(b_neg);
|
---|
78 | xDelete<IssmDouble>(s);
|
---|
79 | xDelete<IssmDouble>(smb);
|
---|
80 | }
|
---|
81 |
|
---|
82 | }/*}}}*/
|
---|
83 | void SmbGradientsElax(FemModel* femmodel){/*{{{*/
|
---|
84 |
|
---|
85 | // void SurfaceMassBalancex(hd,agd,ni){
|
---|
86 | // INPUT parameters: ni: working size of arrays
|
---|
87 | // INPUT: surface elevation (m): hd(NA)
|
---|
88 | // OUTPUT: surface mass-balance (m/yr ice): agd(NA)
|
---|
89 | int v;
|
---|
90 |
|
---|
91 | /*Loop over all the elements of this partition*/
|
---|
92 | for(Object* & object : femmodel->elements->objects){
|
---|
93 | Element* element=xDynamicCast<Element*>(object);
|
---|
94 |
|
---|
95 | /*Allocate all arrays*/
|
---|
96 | int numvertices = element->GetNumberOfVertices();
|
---|
97 | IssmDouble* ela = xNew<IssmDouble>(numvertices); // Equilibrium Line Altitude (m a.s.l) to which deviations are used to calculate the SMB
|
---|
98 | IssmDouble* b_pos = xNew<IssmDouble>(numvertices); // SMB gradient above ELA (m ice eq. per m elevation change)
|
---|
99 | IssmDouble* b_neg = xNew<IssmDouble>(numvertices); // SMB gradient below ELA (m ice eq. per m elevation change)
|
---|
100 | IssmDouble* b_max = xNew<IssmDouble>(numvertices); // Upper cap on SMB rate (m/y ice eq.)
|
---|
101 | IssmDouble* b_min = xNew<IssmDouble>(numvertices); // Lower cap on SMB rate (m/y ice eq.)
|
---|
102 | IssmDouble* s = xNew<IssmDouble>(numvertices); // Surface elevation (m a.s.l.)
|
---|
103 | IssmDouble* smb = xNew<IssmDouble>(numvertices); // SMB (m/y ice eq.)
|
---|
104 |
|
---|
105 | /*Recover ELA, SMB gradients, and caps*/
|
---|
106 | element->GetInputListOnVertices(ela,SmbElaEnum);
|
---|
107 | element->GetInputListOnVertices(b_pos,SmbBPosEnum);
|
---|
108 | element->GetInputListOnVertices(b_neg,SmbBNegEnum);
|
---|
109 | element->GetInputListOnVertices(b_max,SmbBMaxEnum);
|
---|
110 | element->GetInputListOnVertices(b_min,SmbBMinEnum);
|
---|
111 |
|
---|
112 | /*Recover surface elevation at vertices: */
|
---|
113 | element->GetInputListOnVertices(s,SurfaceEnum);
|
---|
114 |
|
---|
115 | /*Loop over all vertices, calculate SMB*/
|
---|
116 | for(v=0;v<numvertices;v++){
|
---|
117 | // if surface is above the ELA
|
---|
118 | if(s[v]>ela[v]){
|
---|
119 | smb[v]=b_pos[v]*(s[v]-ela[v]);
|
---|
120 | }
|
---|
121 | // if surface is below or equal to the ELA
|
---|
122 | else{
|
---|
123 | smb[v]=b_neg[v]*(s[v]-ela[v]);
|
---|
124 | }
|
---|
125 |
|
---|
126 | // if SMB is larger than upper cap, set SMB to upper cap
|
---|
127 | if(smb[v]>b_max[v]){
|
---|
128 | smb[v]=b_max[v];
|
---|
129 | }
|
---|
130 | // if SMB is smaller than lower cap, set SMB to lower cap
|
---|
131 | if(smb[v]<b_min[v]){
|
---|
132 | smb[v]=b_min[v];
|
---|
133 | }
|
---|
134 | } //end of the loop over the vertices
|
---|
135 |
|
---|
136 | /*Add input to element and Free memory*/
|
---|
137 | element->AddInput(SmbMassBalanceEnum,smb,P1Enum);
|
---|
138 | xDelete<IssmDouble>(ela);
|
---|
139 | xDelete<IssmDouble>(b_pos);
|
---|
140 | xDelete<IssmDouble>(b_neg);
|
---|
141 | xDelete<IssmDouble>(b_max);
|
---|
142 | xDelete<IssmDouble>(b_min);
|
---|
143 | xDelete<IssmDouble>(s);
|
---|
144 | xDelete<IssmDouble>(smb);
|
---|
145 |
|
---|
146 | }
|
---|
147 |
|
---|
148 | }/*}}}*/
|
---|
149 | void SmbautoregressionInitx(FemModel* femmodel){/*{{{*/
|
---|
150 |
|
---|
151 | /*Initialization step of Smbautoregressionx*/
|
---|
152 | int M,N,Nphi,arorder,numbasins,my_rank;
|
---|
153 | IssmDouble starttime,tstep_ar,tinit_ar;
|
---|
154 | femmodel->parameters->FindParam(&numbasins,SmbNumBasinsEnum);
|
---|
155 | femmodel->parameters->FindParam(&arorder,SmbAutoregressiveOrderEnum);
|
---|
156 | IssmDouble* beta0 = NULL;
|
---|
157 | IssmDouble* beta1 = NULL;
|
---|
158 | IssmDouble* phi = NULL;
|
---|
159 | femmodel->parameters->FindParam(&starttime,TimesteppingStartTimeEnum);
|
---|
160 | femmodel->parameters->FindParam(&tstep_ar,SmbAutoregressionTimestepEnum);
|
---|
161 | femmodel->parameters->FindParam(&tinit_ar,SmbAutoregressionInitialTimeEnum);
|
---|
162 | femmodel->parameters->FindParam(&beta0,&M,SmbBeta0Enum); _assert_(M==numbasins);
|
---|
163 | femmodel->parameters->FindParam(&beta1,&M,SmbBeta1Enum); _assert_(M==numbasins);
|
---|
164 | femmodel->parameters->FindParam(&phi,&M,&Nphi,SmbPhiEnum); _assert_(M==numbasins); _assert_(Nphi==arorder);
|
---|
165 |
|
---|
166 | /*AR model spin-up with 0 noise to initialize SmbValuesAutoregressionEnum*/
|
---|
167 | int nspin{2*arorder+5};
|
---|
168 | for(Object* &object:femmodel->elements->objects){
|
---|
169 | Element* element = xDynamicCast<Element*>(object); //generate element object
|
---|
170 | element->AutoregressionInit(numbasins,arorder,nspin,starttime,tstep_ar,tinit_ar,beta0,beta1,phi,SMBautoregressionEnum);
|
---|
171 | }
|
---|
172 | /*Cleanup*/
|
---|
173 | xDelete<IssmDouble>(beta0);
|
---|
174 | xDelete<IssmDouble>(beta1);
|
---|
175 | xDelete<IssmDouble>(phi);
|
---|
176 | }/*}}}*/
|
---|
177 | void Smbautoregressionx(FemModel* femmodel){/*{{{*/
|
---|
178 |
|
---|
179 | /*Get time parameters*/
|
---|
180 | IssmDouble time,dt,starttime,tstep_ar;
|
---|
181 | femmodel->parameters->FindParam(&time,TimeEnum);
|
---|
182 | femmodel->parameters->FindParam(&dt,TimesteppingTimeStepEnum);
|
---|
183 | femmodel->parameters->FindParam(&starttime,TimesteppingStartTimeEnum);
|
---|
184 | femmodel->parameters->FindParam(&tstep_ar,SmbAutoregressionTimestepEnum);
|
---|
185 |
|
---|
186 | /*Initialize module at first time step*/
|
---|
187 | if(time<=starttime+dt){SmbautoregressionInitx(femmodel);}
|
---|
188 | /*Determine if this is a time step for the AR model*/
|
---|
189 | bool isstepforar = false;
|
---|
190 |
|
---|
191 | #ifndef _HAVE_AD_
|
---|
192 | if((fmod(time,tstep_ar)<fmod((time-dt),tstep_ar)) || (time<=starttime+dt) || tstep_ar==dt) isstepforar = true;
|
---|
193 | #else
|
---|
194 | _error_("not implemented yet");
|
---|
195 | #endif
|
---|
196 |
|
---|
197 | /*Load parameters*/
|
---|
198 | bool isstochastic;
|
---|
199 | int M,N,Nphi,arorder,numbasins,my_rank;
|
---|
200 | femmodel->parameters->FindParam(&numbasins,SmbNumBasinsEnum);
|
---|
201 | femmodel->parameters->FindParam(&arorder,SmbAutoregressiveOrderEnum);
|
---|
202 | IssmDouble tinit_ar;
|
---|
203 | IssmDouble* beta0 = NULL;
|
---|
204 | IssmDouble* beta1 = NULL;
|
---|
205 | IssmDouble* phi = NULL;
|
---|
206 |
|
---|
207 | femmodel->parameters->FindParam(&tinit_ar,SmbAutoregressionInitialTimeEnum);
|
---|
208 | femmodel->parameters->FindParam(&beta0,&M,SmbBeta0Enum); _assert_(M==numbasins);
|
---|
209 | femmodel->parameters->FindParam(&beta1,&M,SmbBeta1Enum); _assert_(M==numbasins);
|
---|
210 | femmodel->parameters->FindParam(&phi,&M,&Nphi,SmbPhiEnum); _assert_(M==numbasins); _assert_(Nphi==arorder);
|
---|
211 |
|
---|
212 | /*Retrieve noise terms if stochasticity, otherwise leave noiseterms as 0*/
|
---|
213 | IssmDouble* noiseterms = xNewZeroInit<IssmDouble>(numbasins);
|
---|
214 | femmodel->parameters->FindParam(&isstochastic,StochasticForcingIsStochasticForcingEnum);
|
---|
215 | if(isstochastic){
|
---|
216 | int numstochasticfields;
|
---|
217 | int* stochasticfields;
|
---|
218 | femmodel->parameters->FindParam(&numstochasticfields,StochasticForcingNumFieldsEnum);
|
---|
219 | femmodel->parameters->FindParam(&stochasticfields,&N,StochasticForcingFieldsEnum); _assert_(N==numstochasticfields);
|
---|
220 | for(int i=0;i<numstochasticfields;i++){
|
---|
221 | if(stochasticfields[i]==SMBautoregressionEnum){
|
---|
222 | femmodel->parameters->FindParam(&noiseterms,&M,SmbAutoregressionNoiseEnum); _assert_(M==numbasins);
|
---|
223 | }
|
---|
224 | }
|
---|
225 | xDelete<int>(stochasticfields);
|
---|
226 | }
|
---|
227 | /*Time elapsed with respect to AR model initial time*/
|
---|
228 | IssmDouble telapsed_ar = time-tinit_ar;
|
---|
229 |
|
---|
230 | /*Loop over each element to compute SMB at vertices*/
|
---|
231 | for(Object* &object:femmodel->elements->objects){
|
---|
232 | Element* element = xDynamicCast<Element*>(object);
|
---|
233 | element->Autoregression(isstepforar,arorder,telapsed_ar,beta0,beta1,phi,noiseterms,SMBautoregressionEnum);
|
---|
234 | }
|
---|
235 |
|
---|
236 | /*Cleanup*/
|
---|
237 | xDelete<IssmDouble>(beta0);
|
---|
238 | xDelete<IssmDouble>(beta1);
|
---|
239 | xDelete<IssmDouble>(phi);
|
---|
240 | xDelete<IssmDouble>(noiseterms);
|
---|
241 | }/*}}}*/
|
---|
242 | void Delta18oParameterizationx(FemModel* femmodel){/*{{{*/
|
---|
243 |
|
---|
244 | for(Object* & object : femmodel->elements->objects){
|
---|
245 | Element* element=xDynamicCast<Element*>(object);
|
---|
246 | element->Delta18oParameterization();
|
---|
247 | }
|
---|
248 |
|
---|
249 | }/*}}}*/
|
---|
250 | void MungsmtpParameterizationx(FemModel* femmodel){/*{{{*/
|
---|
251 |
|
---|
252 | for(Object* & object : femmodel->elements->objects){
|
---|
253 | Element* element=xDynamicCast<Element*>(object);
|
---|
254 | element->MungsmtpParameterization();
|
---|
255 | }
|
---|
256 |
|
---|
257 | }/*}}}*/
|
---|
258 | void Delta18opdParameterizationx(FemModel* femmodel){/*{{{*/
|
---|
259 |
|
---|
260 | for(Object* & object : femmodel->elements->objects){
|
---|
261 | Element* element=xDynamicCast<Element*>(object);
|
---|
262 | element->Delta18opdParameterization();
|
---|
263 | }
|
---|
264 |
|
---|
265 | }/*}}}*/
|
---|
266 | void PositiveDegreeDayx(FemModel* femmodel){/*{{{*/
|
---|
267 |
|
---|
268 | // void PositiveDegreeDayx(hd,vTempsea,vPrec,agd,Tsurf,ni){
|
---|
269 | // note "v" prefix means 12 monthly means, ie time dimension
|
---|
270 | // INPUT parameters: ni: working size of arrays
|
---|
271 | // INPUT: surface elevation (m): hd(NA)
|
---|
272 | // monthly mean surface sealevel temperature (degrees C): vTempsea(NA
|
---|
273 | // ,NTIME)
|
---|
274 | // monthly mean precip rate (m/yr water equivalent): vPrec(NA,NTIME)
|
---|
275 | // OUTPUT: mass-balance (m/yr ice): agd(NA)
|
---|
276 | // mean annual surface temperature (degrees C): Tsurf(NA)
|
---|
277 |
|
---|
278 | int it, jj, itm;
|
---|
279 | IssmDouble DT = 0.02, sigfac, snormfac;
|
---|
280 | IssmDouble signorm = 5.5; // signorm : sigma of the temperature distribution for a normal day
|
---|
281 | IssmDouble siglim; // sigma limit for the integration which is equal to 2.5 sigmanorm
|
---|
282 | IssmDouble signormc = signorm - 0.5; // sigma of the temperature distribution for cloudy day
|
---|
283 | IssmDouble siglimc, siglim0, siglim0c;
|
---|
284 | IssmDouble tstep, tsint, tint, tstepc;
|
---|
285 | int NPDMAX = 1504, NPDCMAX = 1454;
|
---|
286 | //IssmDouble pdds[NPDMAX]={0};
|
---|
287 | //IssmDouble pds[NPDCMAX]={0};
|
---|
288 | IssmDouble pddt, pd ; // pd : snow/precip fraction, precipitation falling as snow
|
---|
289 | IssmDouble PDup, PDCUT = 2.0; // PDcut: rain/snow cutoff temperature (C)
|
---|
290 | IssmDouble tstar; // monthly mean surface temp
|
---|
291 |
|
---|
292 | bool ismungsm;
|
---|
293 | bool issetpddfac;
|
---|
294 |
|
---|
295 | IssmDouble *pdds = NULL;
|
---|
296 | IssmDouble *pds = NULL;
|
---|
297 | Element *element = NULL;
|
---|
298 |
|
---|
299 | pdds=xNew<IssmDouble>(NPDMAX+1);
|
---|
300 | pds=xNew<IssmDouble>(NPDCMAX+1);
|
---|
301 |
|
---|
302 | // Get ismungsm parameter
|
---|
303 | femmodel->parameters->FindParam(&ismungsm,SmbIsmungsmEnum);
|
---|
304 |
|
---|
305 | // Get issetpddfac parameter
|
---|
306 | femmodel->parameters->FindParam(&issetpddfac,SmbIssetpddfacEnum);
|
---|
307 |
|
---|
308 | /* initialize PDD (creation of a lookup table)*/
|
---|
309 | tstep = 0.1;
|
---|
310 | tsint = tstep*0.5;
|
---|
311 | sigfac = -1.0/(2.0*pow(signorm,2));
|
---|
312 | snormfac = 1.0/(signorm*sqrt(2.0*acos(-1.0)));
|
---|
313 | siglim = 2.5*signorm;
|
---|
314 | siglimc = 2.5*signormc;
|
---|
315 | siglim0 = siglim/DT + 0.5;
|
---|
316 | siglim0c = siglimc/DT + 0.5;
|
---|
317 | PDup = siglimc+PDCUT;
|
---|
318 |
|
---|
319 | itm = reCast<int,IssmDouble>((2*siglim/DT + 1.5));
|
---|
320 |
|
---|
321 | if(itm >= NPDMAX) _error_("increase NPDMAX in massBalance.cpp");
|
---|
322 | for(it = 0; it < itm; it++){
|
---|
323 | // tstar = REAL(it)*DT-siglim;
|
---|
324 | tstar = it*DT-siglim;
|
---|
325 | tint = tsint;
|
---|
326 | pddt = 0.;
|
---|
327 | for ( jj = 0; jj < 600; jj++){
|
---|
328 | if (tint > (tstar+siglim)){break;}
|
---|
329 | pddt = pddt + tint*exp(sigfac*(pow((tint-tstar),2)))*tstep;
|
---|
330 | tint = tint+tstep;
|
---|
331 | }
|
---|
332 | pdds[it] = pddt*snormfac;
|
---|
333 | }
|
---|
334 | pdds[itm+1] = siglim + DT;
|
---|
335 |
|
---|
336 | //*********compute PD(T) : snow/precip fraction. precipitation falling as snow
|
---|
337 | tstepc = 0.1;
|
---|
338 | tsint = PDCUT-tstepc*0.5;
|
---|
339 | signormc = signorm - 0.5;
|
---|
340 | sigfac = -1.0/(2.0*pow(signormc,2));
|
---|
341 | snormfac = 1.0/(signormc*sqrt(2.0*acos(-1.0)));
|
---|
342 | siglimc = 2.5*signormc ;
|
---|
343 | itm = reCast<int,IssmDouble>((PDCUT+2.*siglimc)/DT + 1.5);
|
---|
344 | if(itm >= NPDCMAX) _error_("increase NPDCMAX in p35com");
|
---|
345 | for(it = 0; it < itm; it++ ){
|
---|
346 | tstar = it*DT-siglimc;
|
---|
347 | // tstar = REAL(it)*DT-siglimc;
|
---|
348 | tint = tsint; // start against upper bound
|
---|
349 | pd = 0.;
|
---|
350 | for (jj = 0; jj < 600; jj++){
|
---|
351 | if (tint<(tstar-siglimc)) {break;}
|
---|
352 | pd = pd + exp(sigfac*(pow((tint-tstar),2)))*tstepc;
|
---|
353 | tint = tint-tstepc;
|
---|
354 | }
|
---|
355 | pds[it] = pd*snormfac; // gaussian integral lookup table for snow fraction
|
---|
356 | }
|
---|
357 | pds[itm+1] = 0.;
|
---|
358 | // *******END initialize PDD
|
---|
359 |
|
---|
360 | for(Object* & object : femmodel->elements->objects){
|
---|
361 | element=xDynamicCast<Element*>(object);
|
---|
362 | element->PositiveDegreeDay(pdds,pds,signorm,ismungsm,issetpddfac);
|
---|
363 | }
|
---|
364 | /*free ressouces: */
|
---|
365 | xDelete<IssmDouble>(pdds);
|
---|
366 | xDelete<IssmDouble>(pds);
|
---|
367 | }/*}}}*/
|
---|
368 | void PositiveDegreeDaySicopolisx(FemModel* femmodel){/*{{{*/
|
---|
369 |
|
---|
370 | bool isfirnwarming;
|
---|
371 | femmodel->parameters->FindParam(&isfirnwarming,SmbIsfirnwarmingEnum);
|
---|
372 |
|
---|
373 | for(Object* & object : femmodel->elements->objects){
|
---|
374 | Element* element=xDynamicCast<Element*>(object);
|
---|
375 | element->PositiveDegreeDaySicopolis(isfirnwarming);
|
---|
376 | }
|
---|
377 |
|
---|
378 | }/*}}}*/
|
---|
379 | void SmbHenningx(FemModel* femmodel){/*{{{*/
|
---|
380 |
|
---|
381 | /*Intermediaries*/
|
---|
382 | IssmDouble z_critical = 1675.;
|
---|
383 | IssmDouble dz = 0;
|
---|
384 | IssmDouble a = -15.86;
|
---|
385 | IssmDouble b = 0.00969;
|
---|
386 | IssmDouble c = -0.235;
|
---|
387 | IssmDouble f = 1.;
|
---|
388 | IssmDouble g = -0.0011;
|
---|
389 | IssmDouble h = -1.54e-5;
|
---|
390 | IssmDouble smb,smbref,anomaly,yts,z;
|
---|
391 |
|
---|
392 | /* Get constants */
|
---|
393 | femmodel->parameters->FindParam(&yts,ConstantsYtsEnum);
|
---|
394 | /*iomodel->FindConstant(&yts,"md.constants.yts");*/
|
---|
395 | /*this->parameters->FindParam(&yts,ConstantsYtsEnum);*/
|
---|
396 | /*Mathieu original*/
|
---|
397 | /*IssmDouble smb,smbref,z;*/
|
---|
398 |
|
---|
399 | /*Loop over all the elements of this partition*/
|
---|
400 | for(Object* & object : femmodel->elements->objects){
|
---|
401 | Element* element=xDynamicCast<Element*>(object);
|
---|
402 |
|
---|
403 | /*Get reference SMB (uncorrected) and allocate all arrays*/
|
---|
404 | int numvertices = element->GetNumberOfVertices();
|
---|
405 | IssmDouble* surfacelist = xNew<IssmDouble>(numvertices);
|
---|
406 | IssmDouble* smblistref = xNew<IssmDouble>(numvertices);
|
---|
407 | IssmDouble* smblist = xNew<IssmDouble>(numvertices);
|
---|
408 | element->GetInputListOnVertices(surfacelist,SurfaceEnum);
|
---|
409 | element->GetInputListOnVertices(smblistref,SmbSmbrefEnum);
|
---|
410 |
|
---|
411 | /*Loop over all vertices of element and correct SMB as a function of altitude z*/
|
---|
412 | for(int v=0;v<numvertices;v++){
|
---|
413 |
|
---|
414 | /*Get vertex elevation, anoma smb*/
|
---|
415 | z = surfacelist[v];
|
---|
416 | anomaly = smblistref[v];
|
---|
417 |
|
---|
418 | /* Henning edited acc. to Riannes equations*/
|
---|
419 | /* Set SMB maximum elevation, if dz = 0 -> z_critical = 1675 */
|
---|
420 | z_critical = z_critical + dz;
|
---|
421 |
|
---|
422 | /* Calculate smb acc. to the surface elevation z */
|
---|
423 | if(z<z_critical){
|
---|
424 | smb = a + b*z + c;
|
---|
425 | }
|
---|
426 | else{
|
---|
427 | smb = (a + b*z)*(f + g*(z-z_critical) + h*(z-z_critical)*(z-z_critical)) + c;
|
---|
428 | }
|
---|
429 |
|
---|
430 | /* Compute smb including anomaly,
|
---|
431 | correct for number of seconds in a year [s/yr]*/
|
---|
432 | smb = smb/yts + anomaly;
|
---|
433 |
|
---|
434 | /*Update array accordingly*/
|
---|
435 | smblist[v] = smb;
|
---|
436 |
|
---|
437 | }
|
---|
438 |
|
---|
439 | /*Add input to element and Free memory*/
|
---|
440 | element->AddInput(SmbMassBalanceEnum,smblist,P1Enum);
|
---|
441 | xDelete<IssmDouble>(surfacelist);
|
---|
442 | xDelete<IssmDouble>(smblistref);
|
---|
443 | xDelete<IssmDouble>(smblist);
|
---|
444 | }
|
---|
445 |
|
---|
446 | }/*}}}*/
|
---|
447 | void SmbComponentsx(FemModel* femmodel){/*{{{*/
|
---|
448 |
|
---|
449 | // void SmbComponentsx(acc,evap,runoff,ni){
|
---|
450 | // INPUT parameters: ni: working size of arrays
|
---|
451 | // INPUT: surface accumulation (m/yr water equivalent): acc
|
---|
452 | // surface evaporation (m/yr water equivalent): evap
|
---|
453 | // surface runoff (m/yr water equivalent): runoff
|
---|
454 | // OUTPUT: mass-balance (m/yr ice): agd(NA)
|
---|
455 |
|
---|
456 | /*Loop over all the elements of this partition*/
|
---|
457 | for(Object* & object : femmodel->elements->objects){
|
---|
458 | Element* element=xDynamicCast<Element*>(object);
|
---|
459 |
|
---|
460 | /*Allocate all arrays*/
|
---|
461 | int numvertices = element->GetNumberOfVertices();
|
---|
462 | IssmDouble* acc = xNew<IssmDouble>(numvertices);
|
---|
463 | IssmDouble* evap = xNew<IssmDouble>(numvertices);
|
---|
464 | IssmDouble* runoff = xNew<IssmDouble>(numvertices);
|
---|
465 | IssmDouble* smb = xNew<IssmDouble>(numvertices);
|
---|
466 |
|
---|
467 | /*Recover Smb Components*/
|
---|
468 | element->GetInputListOnVertices(acc,SmbAccumulationEnum);
|
---|
469 | element->GetInputListOnVertices(evap,SmbEvaporationEnum);
|
---|
470 | element->GetInputListOnVertices(runoff,SmbRunoffEnum);
|
---|
471 |
|
---|
472 | // loop over all vertices
|
---|
473 | for(int v=0;v<numvertices;v++) smb[v]=acc[v]-evap[v]-runoff[v];
|
---|
474 |
|
---|
475 | /*Add input to element and Free memory*/
|
---|
476 | element->AddInput(SmbMassBalanceEnum,smb,P1Enum);
|
---|
477 | xDelete<IssmDouble>(acc);
|
---|
478 | xDelete<IssmDouble>(evap);
|
---|
479 | xDelete<IssmDouble>(runoff);
|
---|
480 | xDelete<IssmDouble>(smb);
|
---|
481 | }
|
---|
482 |
|
---|
483 | }/*}}}*/
|
---|
484 | void SmbMeltComponentsx(FemModel* femmodel){/*{{{*/
|
---|
485 |
|
---|
486 | // void SmbMeltComponentsx(acc,evap,melt,refreeze,ni){
|
---|
487 | // INPUT parameters: ni: working size of arrays
|
---|
488 | // INPUT: surface accumulation (m/yr water equivalent): acc
|
---|
489 | // surface evaporation (m/yr water equivalent): evap
|
---|
490 | // surface melt (m/yr water equivalent): melt
|
---|
491 | // refreeze of surface melt (m/yr water equivalent): refreeze
|
---|
492 | // OUTPUT: mass-balance (m/yr ice): agd(NA)
|
---|
493 |
|
---|
494 | /*Loop over all the elements of this partition*/
|
---|
495 | for(Object* & object : femmodel->elements->objects){
|
---|
496 | Element* element=xDynamicCast<Element*>(object);
|
---|
497 |
|
---|
498 | /*Allocate all arrays*/
|
---|
499 | int numvertices = element->GetNumberOfVertices();
|
---|
500 | IssmDouble* acc = xNew<IssmDouble>(numvertices);
|
---|
501 | IssmDouble* evap = xNew<IssmDouble>(numvertices);
|
---|
502 | IssmDouble* melt = xNew<IssmDouble>(numvertices);
|
---|
503 | IssmDouble* refreeze = xNew<IssmDouble>(numvertices);
|
---|
504 | IssmDouble* smb = xNew<IssmDouble>(numvertices);
|
---|
505 |
|
---|
506 | /*Recover Smb Components*/
|
---|
507 | element->GetInputListOnVertices(acc,SmbAccumulationEnum);
|
---|
508 | element->GetInputListOnVertices(evap,SmbEvaporationEnum);
|
---|
509 | element->GetInputListOnVertices(melt,SmbMeltEnum);
|
---|
510 | element->GetInputListOnVertices(refreeze,SmbRefreezeEnum);
|
---|
511 |
|
---|
512 | // loop over all vertices
|
---|
513 | for(int v=0;v<numvertices;v++) smb[v]=acc[v]-evap[v]-melt[v]+refreeze[v];
|
---|
514 |
|
---|
515 | /*Add input to element and Free memory*/
|
---|
516 | element->AddInput(SmbMassBalanceEnum,smb,P1Enum);
|
---|
517 | xDelete<IssmDouble>(acc);
|
---|
518 | xDelete<IssmDouble>(evap);
|
---|
519 | xDelete<IssmDouble>(melt);
|
---|
520 | xDelete<IssmDouble>(refreeze);
|
---|
521 | xDelete<IssmDouble>(smb);
|
---|
522 | }
|
---|
523 |
|
---|
524 | }/*}}}*/
|
---|
525 | void SmbGradientsComponentsx(FemModel* femmodel){/*{{{*/
|
---|
526 |
|
---|
527 | for(Object* & object : femmodel->elements->objects){
|
---|
528 | Element* element=xDynamicCast<Element*>(object);
|
---|
529 | element->SmbGradCompParameterization();
|
---|
530 | }
|
---|
531 |
|
---|
532 | }/*}}}*/
|
---|
533 | #ifdef _HAVE_SEMIC_
|
---|
534 | void SmbSemicx(FemModel* femmodel){/*{{{*/
|
---|
535 |
|
---|
536 | for(Object* & object : femmodel->elements->objects){
|
---|
537 | Element* element=xDynamicCast<Element*>(object);
|
---|
538 | element->SmbSemic();
|
---|
539 | }
|
---|
540 |
|
---|
541 | }/*}}}*/
|
---|
542 | #else
|
---|
543 | void SmbSemicx(FemModel* femmodel){_error_("SEMIC not installed");}
|
---|
544 | #endif //_HAVE_SEMIC_
|
---|