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 Smbarmax(FemModel* femmodel){/*{{{*/
|
---|
150 |
|
---|
151 | /*Get time parameters*/
|
---|
152 | IssmDouble time,dt,starttime,tstep_arma;
|
---|
153 | femmodel->parameters->FindParam(&time,TimeEnum);
|
---|
154 | femmodel->parameters->FindParam(&dt,TimesteppingTimeStepEnum);
|
---|
155 | femmodel->parameters->FindParam(&starttime,TimesteppingStartTimeEnum);
|
---|
156 | femmodel->parameters->FindParam(&tstep_arma,SmbARMATimestepEnum);
|
---|
157 |
|
---|
158 | /*Determine if this is a time step for the ARMA model*/
|
---|
159 | bool isstepforarma = false;
|
---|
160 |
|
---|
161 | #ifndef _HAVE_AD_
|
---|
162 | if((fmod(time,tstep_arma)<fmod((time-dt),tstep_arma)) || (time<=starttime+dt) || tstep_arma==dt) isstepforarma = true;
|
---|
163 | #else
|
---|
164 | _error_("not implemented yet");
|
---|
165 | #endif
|
---|
166 |
|
---|
167 | /*Load parameters*/
|
---|
168 | bool isstochastic;
|
---|
169 | bool issmbstochastic = false;
|
---|
170 | int M,N,Narlagcoefs,Nmalagcoefs,arorder,maorder,numbasins,numelevbins,my_rank;
|
---|
171 | femmodel->parameters->FindParam(&numbasins,SmbNumBasinsEnum);
|
---|
172 | femmodel->parameters->FindParam(&arorder,SmbARMAarOrderEnum);
|
---|
173 | femmodel->parameters->FindParam(&maorder,SmbARMAmaOrderEnum);
|
---|
174 | femmodel->parameters->FindParam(&numelevbins,SmbNumElevationBinsEnum);
|
---|
175 | IssmDouble tinit_arma;
|
---|
176 | IssmDouble* termconstant = NULL;
|
---|
177 | IssmDouble* trend = NULL;
|
---|
178 | IssmDouble* arlagcoefs = NULL;
|
---|
179 | IssmDouble* malagcoefs = NULL;
|
---|
180 | IssmDouble* lapserates = NULL;
|
---|
181 | IssmDouble* elevbins = NULL;
|
---|
182 | IssmDouble* refelevation = NULL;
|
---|
183 |
|
---|
184 | femmodel->parameters->FindParam(&tinit_arma,SmbARMAInitialTimeEnum);
|
---|
185 | femmodel->parameters->FindParam(&termconstant,&M,SmbARMAconstEnum); _assert_(M==numbasins);
|
---|
186 | femmodel->parameters->FindParam(&trend,&M,SmbARMAtrendEnum); _assert_(M==numbasins);
|
---|
187 | femmodel->parameters->FindParam(&arlagcoefs,&M,&Narlagcoefs,SmbARMAarlagcoefsEnum); _assert_(M==numbasins); _assert_(Narlagcoefs==arorder);
|
---|
188 | femmodel->parameters->FindParam(&malagcoefs,&M,&Nmalagcoefs,SmbARMAmalagcoefsEnum); _assert_(M==numbasins); _assert_(Nmalagcoefs==maorder);
|
---|
189 | femmodel->parameters->FindParam(&lapserates,&M,&N,SmbLapseRatesEnum); _assert_(M==numbasins); _assert_(N==numelevbins);
|
---|
190 | femmodel->parameters->FindParam(&elevbins,&M,&N,SmbElevationBinsEnum); _assert_(M==numbasins); _assert_(N==numelevbins-1);
|
---|
191 | femmodel->parameters->FindParam(&refelevation,&M,SmbRefElevationEnum); _assert_(M==numbasins);
|
---|
192 |
|
---|
193 | femmodel->parameters->FindParam(&isstochastic,StochasticForcingIsStochasticForcingEnum);
|
---|
194 | if(isstochastic){
|
---|
195 | int numstochasticfields;
|
---|
196 | int* stochasticfields;
|
---|
197 | femmodel->parameters->FindParam(&numstochasticfields,StochasticForcingNumFieldsEnum);
|
---|
198 | femmodel->parameters->FindParam(&stochasticfields,&N,StochasticForcingFieldsEnum); _assert_(N==numstochasticfields);
|
---|
199 | for(int i=0;i<numstochasticfields;i++){
|
---|
200 | if(stochasticfields[i]==SMBarmaEnum) issmbstochastic = true;
|
---|
201 | }
|
---|
202 | xDelete<int>(stochasticfields);
|
---|
203 | }
|
---|
204 | /*Time elapsed with respect to ARMA model initial time*/
|
---|
205 | IssmDouble telapsed_arma = time-tinit_arma;
|
---|
206 |
|
---|
207 | /*Loop over each element to compute SMB at vertices*/
|
---|
208 | for(Object* &object:femmodel->elements->objects){
|
---|
209 | Element* element = xDynamicCast<Element*>(object);
|
---|
210 | /*Compute ARMA*/
|
---|
211 | element->ArmaProcess(isstepforarma,arorder,maorder,telapsed_arma,tstep_arma,termconstant,trend,arlagcoefs,malagcoefs,issmbstochastic,SMBarmaEnum);
|
---|
212 | /*Compute lapse rate adjustment*/
|
---|
213 | element->LapseRateBasinSMB(numelevbins,lapserates,elevbins,refelevation);
|
---|
214 | }
|
---|
215 |
|
---|
216 | /*Cleanup*/
|
---|
217 | xDelete<IssmDouble>(termconstant);
|
---|
218 | xDelete<IssmDouble>(trend);
|
---|
219 | xDelete<IssmDouble>(arlagcoefs);
|
---|
220 | xDelete<IssmDouble>(malagcoefs);
|
---|
221 | xDelete<IssmDouble>(lapserates);
|
---|
222 | xDelete<IssmDouble>(elevbins);
|
---|
223 | xDelete<IssmDouble>(refelevation);
|
---|
224 | }/*}}}*/
|
---|
225 | void Delta18oParameterizationx(FemModel* femmodel){/*{{{*/
|
---|
226 |
|
---|
227 | for(Object* & object : femmodel->elements->objects){
|
---|
228 | Element* element=xDynamicCast<Element*>(object);
|
---|
229 | element->Delta18oParameterization();
|
---|
230 | }
|
---|
231 |
|
---|
232 | }/*}}}*/
|
---|
233 | void MungsmtpParameterizationx(FemModel* femmodel){/*{{{*/
|
---|
234 |
|
---|
235 | for(Object* & object : femmodel->elements->objects){
|
---|
236 | Element* element=xDynamicCast<Element*>(object);
|
---|
237 | element->MungsmtpParameterization();
|
---|
238 | }
|
---|
239 |
|
---|
240 | }/*}}}*/
|
---|
241 | void Delta18opdParameterizationx(FemModel* femmodel){/*{{{*/
|
---|
242 |
|
---|
243 | for(Object* & object : femmodel->elements->objects){
|
---|
244 | Element* element=xDynamicCast<Element*>(object);
|
---|
245 | element->Delta18opdParameterization();
|
---|
246 | }
|
---|
247 |
|
---|
248 | }/*}}}*/
|
---|
249 | void PositiveDegreeDayx(FemModel* femmodel){/*{{{*/
|
---|
250 |
|
---|
251 | // void PositiveDegreeDayx(hd,vTempsea,vPrec,agd,Tsurf,ni){
|
---|
252 | // note "v" prefix means 12 monthly means, ie time dimension
|
---|
253 | // INPUT parameters: ni: working size of arrays
|
---|
254 | // INPUT: surface elevation (m): hd(NA)
|
---|
255 | // monthly mean surface sealevel temperature (degrees C): vTempsea(NA
|
---|
256 | // ,NTIME)
|
---|
257 | // monthly mean precip rate (m/yr water equivalent): vPrec(NA,NTIME)
|
---|
258 | // OUTPUT: mass-balance (m/yr ice): agd(NA)
|
---|
259 | // mean annual surface temperature (degrees C): Tsurf(NA)
|
---|
260 |
|
---|
261 | int it, jj, itm;
|
---|
262 | IssmDouble DT = 0.02, sigfac, snormfac;
|
---|
263 | IssmDouble signorm = 5.5; // signorm : sigma of the temperature distribution for a normal day
|
---|
264 | IssmDouble siglim; // sigma limit for the integration which is equal to 2.5 sigmanorm
|
---|
265 | IssmDouble signormc = signorm - 0.5; // sigma of the temperature distribution for cloudy day
|
---|
266 | IssmDouble siglimc, siglim0, siglim0c;
|
---|
267 | IssmDouble tstep, tsint, tint, tstepc;
|
---|
268 | int NPDMAX = 1504, NPDCMAX = 1454;
|
---|
269 | //IssmDouble pdds[NPDMAX]={0};
|
---|
270 | //IssmDouble pds[NPDCMAX]={0};
|
---|
271 | IssmDouble pddt, pd ; // pd : snow/precip fraction, precipitation falling as snow
|
---|
272 | IssmDouble PDup, PDCUT = 2.0; // PDcut: rain/snow cutoff temperature (C)
|
---|
273 | IssmDouble tstar; // monthly mean surface temp
|
---|
274 |
|
---|
275 | bool ismungsm;
|
---|
276 | bool issetpddfac;
|
---|
277 |
|
---|
278 | IssmDouble *pdds = NULL;
|
---|
279 | IssmDouble *pds = NULL;
|
---|
280 | Element *element = NULL;
|
---|
281 |
|
---|
282 | pdds=xNew<IssmDouble>(NPDMAX+1);
|
---|
283 | pds=xNew<IssmDouble>(NPDCMAX+1);
|
---|
284 |
|
---|
285 | // Get ismungsm parameter
|
---|
286 | femmodel->parameters->FindParam(&ismungsm,SmbIsmungsmEnum);
|
---|
287 |
|
---|
288 | // Get issetpddfac parameter
|
---|
289 | femmodel->parameters->FindParam(&issetpddfac,SmbIssetpddfacEnum);
|
---|
290 |
|
---|
291 | /* initialize PDD (creation of a lookup table)*/
|
---|
292 | tstep = 0.1;
|
---|
293 | tsint = tstep*0.5;
|
---|
294 | sigfac = -1.0/(2.0*pow(signorm,2));
|
---|
295 | snormfac = 1.0/(signorm*sqrt(2.0*acos(-1.0)));
|
---|
296 | siglim = 2.5*signorm;
|
---|
297 | siglimc = 2.5*signormc;
|
---|
298 | siglim0 = siglim/DT + 0.5;
|
---|
299 | siglim0c = siglimc/DT + 0.5;
|
---|
300 | PDup = siglimc+PDCUT;
|
---|
301 |
|
---|
302 | itm = reCast<int,IssmDouble>((2*siglim/DT + 1.5));
|
---|
303 |
|
---|
304 | if(itm >= NPDMAX) _error_("increase NPDMAX in massBalance.cpp");
|
---|
305 | for(it = 0; it < itm; it++){
|
---|
306 | // tstar = REAL(it)*DT-siglim;
|
---|
307 | tstar = it*DT-siglim;
|
---|
308 | tint = tsint;
|
---|
309 | pddt = 0.;
|
---|
310 | for ( jj = 0; jj < 600; jj++){
|
---|
311 | if (tint > (tstar+siglim)){break;}
|
---|
312 | pddt = pddt + tint*exp(sigfac*(pow((tint-tstar),2)))*tstep;
|
---|
313 | tint = tint+tstep;
|
---|
314 | }
|
---|
315 | pdds[it] = pddt*snormfac;
|
---|
316 | }
|
---|
317 | pdds[itm+1] = siglim + DT;
|
---|
318 |
|
---|
319 | //*********compute PD(T) : snow/precip fraction. precipitation falling as snow
|
---|
320 | tstepc = 0.1;
|
---|
321 | tsint = PDCUT-tstepc*0.5;
|
---|
322 | signormc = signorm - 0.5;
|
---|
323 | sigfac = -1.0/(2.0*pow(signormc,2));
|
---|
324 | snormfac = 1.0/(signormc*sqrt(2.0*acos(-1.0)));
|
---|
325 | siglimc = 2.5*signormc ;
|
---|
326 | itm = reCast<int,IssmDouble>((PDCUT+2.*siglimc)/DT + 1.5);
|
---|
327 | if(itm >= NPDCMAX) _error_("increase NPDCMAX in p35com");
|
---|
328 | for(it = 0; it < itm; it++ ){
|
---|
329 | tstar = it*DT-siglimc;
|
---|
330 | // tstar = REAL(it)*DT-siglimc;
|
---|
331 | tint = tsint; // start against upper bound
|
---|
332 | pd = 0.;
|
---|
333 | for (jj = 0; jj < 600; jj++){
|
---|
334 | if (tint<(tstar-siglimc)) {break;}
|
---|
335 | pd = pd + exp(sigfac*(pow((tint-tstar),2)))*tstepc;
|
---|
336 | tint = tint-tstepc;
|
---|
337 | }
|
---|
338 | pds[it] = pd*snormfac; // gaussian integral lookup table for snow fraction
|
---|
339 | }
|
---|
340 | pds[itm+1] = 0.;
|
---|
341 | // *******END initialize PDD
|
---|
342 |
|
---|
343 | for(Object* & object : femmodel->elements->objects){
|
---|
344 | element=xDynamicCast<Element*>(object);
|
---|
345 | element->PositiveDegreeDay(pdds,pds,signorm,ismungsm,issetpddfac);
|
---|
346 | }
|
---|
347 | /*free ressouces: */
|
---|
348 | xDelete<IssmDouble>(pdds);
|
---|
349 | xDelete<IssmDouble>(pds);
|
---|
350 | }/*}}}*/
|
---|
351 | void PositiveDegreeDaySicopolisx(FemModel* femmodel){/*{{{*/
|
---|
352 |
|
---|
353 | bool isfirnwarming;
|
---|
354 | femmodel->parameters->FindParam(&isfirnwarming,SmbIsfirnwarmingEnum);
|
---|
355 |
|
---|
356 | for(Object* & object : femmodel->elements->objects){
|
---|
357 | Element* element=xDynamicCast<Element*>(object);
|
---|
358 | element->PositiveDegreeDaySicopolis(isfirnwarming);
|
---|
359 | }
|
---|
360 |
|
---|
361 | }/*}}}*/
|
---|
362 | void SmbHenningx(FemModel* femmodel){/*{{{*/
|
---|
363 |
|
---|
364 | /*Intermediaries*/
|
---|
365 | IssmDouble z_critical = 1675.;
|
---|
366 | IssmDouble dz = 0;
|
---|
367 | IssmDouble a = -15.86;
|
---|
368 | IssmDouble b = 0.00969;
|
---|
369 | IssmDouble c = -0.235;
|
---|
370 | IssmDouble f = 1.;
|
---|
371 | IssmDouble g = -0.0011;
|
---|
372 | IssmDouble h = -1.54e-5;
|
---|
373 | IssmDouble smb,smbref,anomaly,yts,z;
|
---|
374 |
|
---|
375 | /* Get constants */
|
---|
376 | femmodel->parameters->FindParam(&yts,ConstantsYtsEnum);
|
---|
377 | /*iomodel->FindConstant(&yts,"md.constants.yts");*/
|
---|
378 | /*this->parameters->FindParam(&yts,ConstantsYtsEnum);*/
|
---|
379 | /*Mathieu original*/
|
---|
380 | /*IssmDouble smb,smbref,z;*/
|
---|
381 |
|
---|
382 | /*Loop over all the elements of this partition*/
|
---|
383 | for(Object* & object : femmodel->elements->objects){
|
---|
384 | Element* element=xDynamicCast<Element*>(object);
|
---|
385 |
|
---|
386 | /*Get reference SMB (uncorrected) and allocate all arrays*/
|
---|
387 | int numvertices = element->GetNumberOfVertices();
|
---|
388 | IssmDouble* surfacelist = xNew<IssmDouble>(numvertices);
|
---|
389 | IssmDouble* smblistref = xNew<IssmDouble>(numvertices);
|
---|
390 | IssmDouble* smblist = xNew<IssmDouble>(numvertices);
|
---|
391 | element->GetInputListOnVertices(surfacelist,SurfaceEnum);
|
---|
392 | element->GetInputListOnVertices(smblistref,SmbSmbrefEnum);
|
---|
393 |
|
---|
394 | /*Loop over all vertices of element and correct SMB as a function of altitude z*/
|
---|
395 | for(int v=0;v<numvertices;v++){
|
---|
396 |
|
---|
397 | /*Get vertex elevation, anoma smb*/
|
---|
398 | z = surfacelist[v];
|
---|
399 | anomaly = smblistref[v];
|
---|
400 |
|
---|
401 | /* Henning edited acc. to Riannes equations*/
|
---|
402 | /* Set SMB maximum elevation, if dz = 0 -> z_critical = 1675 */
|
---|
403 | z_critical = z_critical + dz;
|
---|
404 |
|
---|
405 | /* Calculate smb acc. to the surface elevation z */
|
---|
406 | if(z<z_critical){
|
---|
407 | smb = a + b*z + c;
|
---|
408 | }
|
---|
409 | else{
|
---|
410 | smb = (a + b*z)*(f + g*(z-z_critical) + h*(z-z_critical)*(z-z_critical)) + c;
|
---|
411 | }
|
---|
412 |
|
---|
413 | /* Compute smb including anomaly,
|
---|
414 | correct for number of seconds in a year [s/yr]*/
|
---|
415 | smb = smb/yts + anomaly;
|
---|
416 |
|
---|
417 | /*Update array accordingly*/
|
---|
418 | smblist[v] = smb;
|
---|
419 |
|
---|
420 | }
|
---|
421 |
|
---|
422 | /*Add input to element and Free memory*/
|
---|
423 | element->AddInput(SmbMassBalanceEnum,smblist,P1Enum);
|
---|
424 | xDelete<IssmDouble>(surfacelist);
|
---|
425 | xDelete<IssmDouble>(smblistref);
|
---|
426 | xDelete<IssmDouble>(smblist);
|
---|
427 | }
|
---|
428 |
|
---|
429 | }/*}}}*/
|
---|
430 | void SmbComponentsx(FemModel* femmodel){/*{{{*/
|
---|
431 |
|
---|
432 | // void SmbComponentsx(acc,evap,runoff,ni){
|
---|
433 | // INPUT parameters: ni: working size of arrays
|
---|
434 | // INPUT: surface accumulation (m/yr water equivalent): acc
|
---|
435 | // surface evaporation (m/yr water equivalent): evap
|
---|
436 | // surface runoff (m/yr water equivalent): runoff
|
---|
437 | // OUTPUT: mass-balance (m/yr ice): agd(NA)
|
---|
438 |
|
---|
439 | /*Loop over all the elements of this partition*/
|
---|
440 | for(Object* & object : femmodel->elements->objects){
|
---|
441 | Element* element=xDynamicCast<Element*>(object);
|
---|
442 |
|
---|
443 | /*Allocate all arrays*/
|
---|
444 | int numvertices = element->GetNumberOfVertices();
|
---|
445 | IssmDouble* acc = xNew<IssmDouble>(numvertices);
|
---|
446 | IssmDouble* evap = xNew<IssmDouble>(numvertices);
|
---|
447 | IssmDouble* runoff = xNew<IssmDouble>(numvertices);
|
---|
448 | IssmDouble* smb = xNew<IssmDouble>(numvertices);
|
---|
449 |
|
---|
450 | /*Recover Smb Components*/
|
---|
451 | element->GetInputListOnVertices(acc,SmbAccumulationEnum);
|
---|
452 | element->GetInputListOnVertices(evap,SmbEvaporationEnum);
|
---|
453 | element->GetInputListOnVertices(runoff,SmbRunoffEnum);
|
---|
454 |
|
---|
455 | // loop over all vertices
|
---|
456 | for(int v=0;v<numvertices;v++) smb[v]=acc[v]-evap[v]-runoff[v];
|
---|
457 |
|
---|
458 | /*Add input to element and Free memory*/
|
---|
459 | element->AddInput(SmbMassBalanceEnum,smb,P1Enum);
|
---|
460 | xDelete<IssmDouble>(acc);
|
---|
461 | xDelete<IssmDouble>(evap);
|
---|
462 | xDelete<IssmDouble>(runoff);
|
---|
463 | xDelete<IssmDouble>(smb);
|
---|
464 | }
|
---|
465 |
|
---|
466 | }/*}}}*/
|
---|
467 | void SmbMeltComponentsx(FemModel* femmodel){/*{{{*/
|
---|
468 |
|
---|
469 | // void SmbMeltComponentsx(acc,evap,melt,refreeze,ni){
|
---|
470 | // INPUT parameters: ni: working size of arrays
|
---|
471 | // INPUT: surface accumulation (m/yr water equivalent): acc
|
---|
472 | // surface evaporation (m/yr water equivalent): evap
|
---|
473 | // surface melt (m/yr water equivalent): melt
|
---|
474 | // refreeze of surface melt (m/yr water equivalent): refreeze
|
---|
475 | // OUTPUT: mass-balance (m/yr ice): agd(NA)
|
---|
476 |
|
---|
477 | /*Loop over all the elements of this partition*/
|
---|
478 | for(Object* & object : femmodel->elements->objects){
|
---|
479 | Element* element=xDynamicCast<Element*>(object);
|
---|
480 |
|
---|
481 | /*Allocate all arrays*/
|
---|
482 | int numvertices = element->GetNumberOfVertices();
|
---|
483 | IssmDouble* acc = xNew<IssmDouble>(numvertices);
|
---|
484 | IssmDouble* evap = xNew<IssmDouble>(numvertices);
|
---|
485 | IssmDouble* melt = xNew<IssmDouble>(numvertices);
|
---|
486 | IssmDouble* refreeze = xNew<IssmDouble>(numvertices);
|
---|
487 | IssmDouble* smb = xNew<IssmDouble>(numvertices);
|
---|
488 |
|
---|
489 | /*Recover Smb Components*/
|
---|
490 | element->GetInputListOnVertices(acc,SmbAccumulationEnum);
|
---|
491 | element->GetInputListOnVertices(evap,SmbEvaporationEnum);
|
---|
492 | element->GetInputListOnVertices(melt,SmbMeltEnum);
|
---|
493 | element->GetInputListOnVertices(refreeze,SmbRefreezeEnum);
|
---|
494 |
|
---|
495 | // loop over all vertices
|
---|
496 | for(int v=0;v<numvertices;v++) smb[v]=acc[v]-evap[v]-melt[v]+refreeze[v];
|
---|
497 |
|
---|
498 | /*Add input to element and Free memory*/
|
---|
499 | element->AddInput(SmbMassBalanceEnum,smb,P1Enum);
|
---|
500 | xDelete<IssmDouble>(acc);
|
---|
501 | xDelete<IssmDouble>(evap);
|
---|
502 | xDelete<IssmDouble>(melt);
|
---|
503 | xDelete<IssmDouble>(refreeze);
|
---|
504 | xDelete<IssmDouble>(smb);
|
---|
505 | }
|
---|
506 |
|
---|
507 | }/*}}}*/
|
---|
508 | void SmbDebrisMLx(FemModel* femmodel){/*{{{*/
|
---|
509 |
|
---|
510 | // The function is based on:
|
---|
511 | // Evatt GW, Abrahams ID, Heil M, Mayer C, Kingslake J, Mitchell SL, et al. Glacial melt under a porous debris layer. Journal of Glaciology 61 (2015) 825–836, doi:10.3189/2
|
---|
512 | // Constants/Values are taken from Mayer, Licciulli (2021): https://www.frontiersin.org/articles/10.3389/feart.2021.710276/full#B7
|
---|
513 | // function taken from https://github.com/carlolic/DebrisExp/blob/main/USFs/USF_DebrisCoverage.f90
|
---|
514 |
|
---|
515 | /*Intermediaries*/
|
---|
516 | // altitude gradients of the crucial parameters (radiation from Marty et al., TaAClimat; 2002)
|
---|
517 | IssmDouble LW=2.9; // W/m^2 /100m 2.9
|
---|
518 | IssmDouble SW=1.3; // W/m^2 /100m 1.3
|
---|
519 | IssmDouble HumidityG=0; // % /100m rough estimate
|
---|
520 | IssmDouble AirTemp=0.7; // C /100m
|
---|
521 | IssmDouble WindSpeed=0.02; // m/s /100m rough estimate 0.2
|
---|
522 |
|
---|
523 | // accumulation follows a linear increase above the ELA up to a plateau
|
---|
524 | IssmDouble AccG=0.1; // m w.e. /100m
|
---|
525 | IssmDouble AccMax=1.; // m w.e.
|
---|
526 | IssmDouble ReferenceElevation=2200.; // m M&L
|
---|
527 | IssmDouble AblationDays=120.; //
|
---|
528 |
|
---|
529 | IssmDouble In=100.; // Wm^-2 incoming long wave
|
---|
530 | IssmDouble Q=500.; // Wm^-2 incoming short wave
|
---|
531 | IssmDouble K=0.585; // Wm^-1K^-1 thermal conductivity 0.585
|
---|
532 | IssmDouble Qm=0.0012; // kg m^-3 measured humiditiy level
|
---|
533 | IssmDouble Qh=0.006 ; // kg m^-3 saturated humidity level
|
---|
534 | IssmDouble Tm=2.; // C air temperature
|
---|
535 | IssmDouble Rhoaa=1.22; // kgm^-3 air densitiy
|
---|
536 | IssmDouble Um=1.5; // ms^-1 measured wind speed
|
---|
537 | IssmDouble Xm=1.5; // ms^-1 measurement height
|
---|
538 | IssmDouble Xr=0.01; // ms^-1 surface roughness 0.01
|
---|
539 | IssmDouble Alphad=0.07; // debris albedo 0.07
|
---|
540 | IssmDouble Alphai=0.4; // ice ablbedo
|
---|
541 | IssmDouble Ustar=0.16; // ms^-1 friction velocity 0.16
|
---|
542 | IssmDouble Ca=1000.; // jkg^-1K^-1 specific heat capacity of air
|
---|
543 | IssmDouble Lm;//=3.34E+05; // jkg^-1K^-1 latent heat of ice melt
|
---|
544 | IssmDouble Lv=2.50E+06; // jkg^-1K^-1 latent heat of evaporation
|
---|
545 | IssmDouble Tf=273.; // K water freeezing temperature
|
---|
546 | IssmDouble Eps=0.95; // thermal emissivity
|
---|
547 | IssmDouble Rhoi=900.; // kgm^-3 ice density
|
---|
548 | IssmDouble Sigma=5.67E-08; // Wm^-2K^-4 Stefan Boltzmann constant
|
---|
549 | IssmDouble Kstar=0.4; // von kármán constant
|
---|
550 | IssmDouble Gamma=180.; // m^-1 wind speed attenuation 234
|
---|
551 | IssmDouble PhiD;//=0.005; // debris packing fraction 0.01
|
---|
552 | IssmDouble Humidity=0.2; // relative humidity
|
---|
553 |
|
---|
554 | IssmDouble smb,yts,z,debris;
|
---|
555 | IssmDouble MassBalanceCmDayDebris,MassBalanceMYearDebris;
|
---|
556 |
|
---|
557 | /*Get material parameters and constants */
|
---|
558 | //femmodel->parameters->FindParam(&Rhoi,MaterialsRhoIceEnum); // Note Carlo's model used as benchmark was run with different densities for debris and FS
|
---|
559 | femmodel->parameters->FindParam(&Lm,MaterialsLatentheatEnum);
|
---|
560 | femmodel->parameters->FindParam(&yts,ConstantsYtsEnum);
|
---|
561 | PhiD=0.;
|
---|
562 | //if(isdebris) femmodel->parameters->FindParam(&PhiD,DebrisPackingFractionEnum);
|
---|
563 |
|
---|
564 | /* Loop over all the elements of this partition */
|
---|
565 | for(Object* & object : femmodel->elements->objects){
|
---|
566 | Element* element=xDynamicCast<Element*>(object);
|
---|
567 |
|
---|
568 | /* Allocate all arrays */
|
---|
569 | int numvertices=element->GetNumberOfVertices();
|
---|
570 | IssmDouble* surfacelist=xNew<IssmDouble>(numvertices);
|
---|
571 | IssmDouble* smb=xNew<IssmDouble>(numvertices);
|
---|
572 | IssmDouble* debriscover=xNew<IssmDouble>(numvertices);
|
---|
573 | element->GetInputListOnVertices(surfacelist,SurfaceEnum);
|
---|
574 |
|
---|
575 | /* Get inputs */
|
---|
576 | element->GetInputListOnVertices(debriscover,DebrisThicknessEnum);
|
---|
577 |
|
---|
578 | /*Loop over all vertices of element and calculate SMB as function of Debris Cover and z */
|
---|
579 | for(int v=0;v<numvertices;v++){
|
---|
580 |
|
---|
581 | /*Get vertex elevation */
|
---|
582 | z=surfacelist[v];
|
---|
583 |
|
---|
584 | /* Get debris cover */
|
---|
585 | debris=debriscover[v];
|
---|
586 |
|
---|
587 | /*IssmDouble dk=1e-5; // TODO make Alphad and Alphai a user input
|
---|
588 | IssmDouble n=debris/dk;
|
---|
589 | IssmDouble nmax=1000;
|
---|
590 | IssmDouble Alphaeff;
|
---|
591 | if(n>nmax){
|
---|
592 | Alphaeff=Alphad;
|
---|
593 | } else {
|
---|
594 | Alphaeff=Alphai+n*(Alphad-Alphai)/nmax;
|
---|
595 | }*/
|
---|
596 |
|
---|
597 | // M&L
|
---|
598 | IssmDouble Alphaeff=Alphad;
|
---|
599 |
|
---|
600 | /* compute smb */
|
---|
601 | for (int ismb=0;ismb<2;ismb++){
|
---|
602 | if(ismb==0){
|
---|
603 | // calc a reference smb to identify accum and melt region; debris only develops in ablation area
|
---|
604 | debris=0.;
|
---|
605 | }else{
|
---|
606 | // only in the meltregime debris develops
|
---|
607 | if(-MassBalanceCmDayDebris<0) debris=debriscover[v];
|
---|
608 | }
|
---|
609 | MassBalanceCmDayDebris=(((In-(z-ReferenceElevation)*LW/100.)-(Eps*Sigma*(Tf*Tf*Tf*Tf))+
|
---|
610 | (Q+(z-ReferenceElevation)*SW/100.)*(1.-Alphaeff)+
|
---|
611 | (Rhoaa*Ca*Ustar*Ustar)/((Um-(z-ReferenceElevation)*
|
---|
612 | WindSpeed/100.)-Ustar*(2.-(exp(Gamma*Xr))))*(Tm-(z-
|
---|
613 | ReferenceElevation)*AirTemp/100.))/((1-PhiD)*Rhoi*Lm)/(1.+
|
---|
614 | ((Rhoaa*Ca*Ustar*Ustar)/((Um-(z-ReferenceElevation)*
|
---|
615 | WindSpeed/100.)-Ustar*(2.-(exp(Gamma*Xr))))+4.*Eps*Sigma*(Tf*Tf*Tf))/
|
---|
616 | K*debris)-(Lv*Ustar*Ustar*(Qh-(Qh*(Humidity-(z-
|
---|
617 | ReferenceElevation)*HumidityG/100.)))*(exp(-Gamma*Xr)))/((1.-PhiD)*
|
---|
618 | Rhoi*Lm*Ustar)/((((Um-(z-ReferenceElevation)*WindSpeed/100.)
|
---|
619 | -2.*Ustar)*exp(-Gamma*Xr))/Ustar+exp(Gamma*debris)))*100.*24.*60.*60.;
|
---|
620 | }
|
---|
621 |
|
---|
622 | /* account form ablation days, and convert to m/s */
|
---|
623 | MassBalanceMYearDebris=-MassBalanceCmDayDebris/100.*AblationDays/yts;
|
---|
624 |
|
---|
625 | /*Update array accordingly*/
|
---|
626 | smb[v]=MassBalanceMYearDebris;
|
---|
627 | }
|
---|
628 |
|
---|
629 | /*Add input to element and Free memory*/
|
---|
630 | element->AddInput(SmbMassBalanceEnum,smb,P1Enum);
|
---|
631 | xDelete<IssmDouble>(surfacelist);
|
---|
632 | xDelete<IssmDouble>(smb);
|
---|
633 | xDelete<IssmDouble>(debriscover);
|
---|
634 | }
|
---|
635 | }/*}}}*/
|
---|
636 | void SmbGradientsComponentsx(FemModel* femmodel){/*{{{*/
|
---|
637 |
|
---|
638 | for(Object* & object : femmodel->elements->objects){
|
---|
639 | Element* element=xDynamicCast<Element*>(object);
|
---|
640 | element->SmbGradCompParameterization();
|
---|
641 | }
|
---|
642 |
|
---|
643 | }/*}}}*/
|
---|
644 | #ifdef _HAVE_SEMIC_
|
---|
645 | void SmbSemicx(FemModel* femmodel){/*{{{*/
|
---|
646 |
|
---|
647 | for(Object* & object : femmodel->elements->objects){
|
---|
648 | Element* element=xDynamicCast<Element*>(object);
|
---|
649 | element->SmbSemic();
|
---|
650 | }
|
---|
651 |
|
---|
652 | }/*}}}*/
|
---|
653 | #else
|
---|
654 | void SmbSemicx(FemModel* femmodel){_error_("SEMIC not installed");}
|
---|
655 | #endif //_HAVE_SEMIC_
|
---|