[17085] | 1 | /*!\file SurfaceMassBalancex
|
---|
[23366] | 2 | * \brief: calculates SMB
|
---|
[17085] | 3 | */
|
---|
| 4 |
|
---|
[26479] | 5 | #include <config.h>
|
---|
[17085] | 6 | #include "./SurfaceMassBalancex.h"
|
---|
| 7 | #include "../../shared/shared.h"
|
---|
| 8 | #include "../../toolkits/toolkits.h"
|
---|
[23814] | 9 | #include "../modules.h"
|
---|
[25379] | 10 | #include "../../classes/Inputs/TransientInput.h"
|
---|
[26477] | 11 | #include "../../shared/Random/random.h"
|
---|
[17085] | 12 |
|
---|
[23814] | 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 | }/*}}}*/
|
---|
[17085] | 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)
|
---|
[18001] | 26 | int v;
|
---|
| 27 | IssmDouble rho_water; // density of fresh water
|
---|
| 28 | IssmDouble rho_ice; // density of ice
|
---|
[21469] | 29 | IssmDouble yts; // conversion factor year to second
|
---|
[17085] | 30 |
|
---|
[18001] | 31 | /*Loop over all the elements of this partition*/
|
---|
[25539] | 32 | for(Object* & object : femmodel->elements->objects){
|
---|
| 33 | Element* element=xDynamicCast<Element*>(object);
|
---|
[18001] | 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*/
|
---|
[19527] | 45 | element->GetInputListOnVertices(Href,SmbHrefEnum);
|
---|
| 46 | element->GetInputListOnVertices(Smbref,SmbSmbrefEnum);
|
---|
| 47 | element->GetInputListOnVertices(b_pos,SmbBPosEnum);
|
---|
| 48 | element->GetInputListOnVertices(b_neg,SmbBNegEnum);
|
---|
[18001] | 49 |
|
---|
[18266] | 50 | /*Recover surface elevation at vertices: */
|
---|
[18001] | 51 | element->GetInputListOnVertices(s,SurfaceEnum);
|
---|
| 52 |
|
---|
| 53 | /*Get material parameters :*/
|
---|
[23644] | 54 | rho_ice=element->FindParam(MaterialsRhoIceEnum);
|
---|
| 55 | rho_water=element->FindParam(MaterialsRhoFreshwaterEnum);
|
---|
[18001] | 56 |
|
---|
[21469] | 57 | /* Get constants */
|
---|
| 58 | femmodel->parameters->FindParam(&yts,ConstantsYtsEnum);
|
---|
| 59 |
|
---|
[18001] | 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 | }
|
---|
[21469] | 68 |
|
---|
[18266] | 69 | smb[v]=smb[v]/1000*rho_water/rho_ice; // SMB in m/y ice
|
---|
[18001] | 70 | } //end of the loop over the vertices
|
---|
| 71 |
|
---|
| 72 | /*Add input to element and Free memory*/
|
---|
[25379] | 73 | element->AddInput(SmbMassBalanceEnum,smb,P1Enum);
|
---|
[18001] | 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);
|
---|
[17085] | 80 | }
|
---|
| 81 |
|
---|
| 82 | }/*}}}*/
|
---|
[21469] | 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*/
|
---|
[25539] | 92 | for(Object* & object : femmodel->elements->objects){
|
---|
| 93 | Element* element=xDynamicCast<Element*>(object);
|
---|
[21469] | 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
|
---|
[23366] | 118 | if(s[v]>ela[v]){
|
---|
[21469] | 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*/
|
---|
[25379] | 137 | element->AddInput(SmbMassBalanceEnum,smb,P1Enum);
|
---|
[21469] | 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 | }/*}}}*/
|
---|
[27250] | 149 | void Smbarmax(FemModel* femmodel){/*{{{*/
|
---|
[26483] | 150 |
|
---|
[26615] | 151 | /*Get time parameters*/
|
---|
[27250] | 152 | IssmDouble time,dt,starttime,tstep_arma;
|
---|
[26615] | 153 | femmodel->parameters->FindParam(&time,TimeEnum);
|
---|
| 154 | femmodel->parameters->FindParam(&dt,TimesteppingTimeStepEnum);
|
---|
| 155 | femmodel->parameters->FindParam(&starttime,TimesteppingStartTimeEnum);
|
---|
[27250] | 156 | femmodel->parameters->FindParam(&tstep_arma,SmbARMATimestepEnum);
|
---|
[26482] | 157 |
|
---|
[27250] | 158 | /*Determine if this is a time step for the ARMA model*/
|
---|
| 159 | bool isstepforarma = false;
|
---|
[26479] | 160 |
|
---|
[26615] | 161 | #ifndef _HAVE_AD_
|
---|
[27250] | 162 | if((fmod(time,tstep_arma)<fmod((time-dt),tstep_arma)) || (time<=starttime+dt) || tstep_arma==dt) isstepforarma = true;
|
---|
[26615] | 163 | #else
|
---|
| 164 | _error_("not implemented yet");
|
---|
| 165 | #endif
|
---|
[26479] | 166 |
|
---|
[26615] | 167 | /*Load parameters*/
|
---|
| 168 | bool isstochastic;
|
---|
| 169 | bool issmbstochastic = false;
|
---|
[27250] | 170 | int M,N,Narlagcoefs,arorder,numbasins,numelevbins,my_rank;
|
---|
[26615] | 171 | femmodel->parameters->FindParam(&numbasins,SmbNumBasinsEnum);
|
---|
[27250] | 172 | femmodel->parameters->FindParam(&arorder,SmbARMAarOrderEnum);
|
---|
[26947] | 173 | femmodel->parameters->FindParam(&numelevbins,SmbNumElevationBinsEnum);
|
---|
[27250] | 174 | IssmDouble tinit_arma;
|
---|
[27246] | 175 | IssmDouble* termconstant = NULL;
|
---|
| 176 | IssmDouble* trend = NULL;
|
---|
[27250] | 177 | IssmDouble* arlagcoefs = NULL;
|
---|
[26947] | 178 | IssmDouble* lapserates = NULL;
|
---|
| 179 | IssmDouble* elevbins = NULL;
|
---|
| 180 | IssmDouble* refelevation = NULL;
|
---|
[26526] | 181 |
|
---|
[27250] | 182 | femmodel->parameters->FindParam(&tinit_arma,SmbARMAInitialTimeEnum);
|
---|
| 183 | femmodel->parameters->FindParam(&termconstant,&M,SmbARMAconstEnum); _assert_(M==numbasins);
|
---|
| 184 | femmodel->parameters->FindParam(&trend,&M,SmbARMAtrendEnum); _assert_(M==numbasins);
|
---|
| 185 | femmodel->parameters->FindParam(&arlagcoefs,&M,&Narlagcoefs,SmbARMAarlagcoefsEnum); _assert_(M==numbasins); _assert_(Narlagcoefs==arorder);
|
---|
| 186 | femmodel->parameters->FindParam(&lapserates,&M,&N,SmbLapseRatesEnum); _assert_(M==numbasins); _assert_(N==numelevbins);
|
---|
| 187 | femmodel->parameters->FindParam(&elevbins,&M,&N,SmbElevationBinsEnum); _assert_(M==numbasins); _assert_(N==numelevbins-1);
|
---|
| 188 | femmodel->parameters->FindParam(&refelevation,&M,SmbRefElevationEnum); _assert_(M==numbasins);
|
---|
[26481] | 189 |
|
---|
[26615] | 190 | femmodel->parameters->FindParam(&isstochastic,StochasticForcingIsStochasticForcingEnum);
|
---|
[26526] | 191 | if(isstochastic){
|
---|
[26615] | 192 | int numstochasticfields;
|
---|
[26526] | 193 | int* stochasticfields;
|
---|
| 194 | femmodel->parameters->FindParam(&numstochasticfields,StochasticForcingNumFieldsEnum);
|
---|
| 195 | femmodel->parameters->FindParam(&stochasticfields,&N,StochasticForcingFieldsEnum); _assert_(N==numstochasticfields);
|
---|
| 196 | for(int i=0;i<numstochasticfields;i++){
|
---|
[27250] | 197 | if(stochasticfields[i]==SMBarmaEnum) issmbstochastic = true;
|
---|
[26615] | 198 | }
|
---|
| 199 | xDelete<int>(stochasticfields);
|
---|
| 200 | }
|
---|
[27250] | 201 | /*Time elapsed with respect to ARMA model initial time*/
|
---|
| 202 | IssmDouble telapsed_arma = time-tinit_arma;
|
---|
[26481] | 203 |
|
---|
[26615] | 204 | /*Loop over each element to compute SMB at vertices*/
|
---|
| 205 | for(Object* &object:femmodel->elements->objects){
|
---|
| 206 | Element* element = xDynamicCast<Element*>(object);
|
---|
[27250] | 207 | /*Compute ARMA*/
|
---|
| 208 | element->Autoregression(isstepforarma,arorder,telapsed_arma,tstep_arma,termconstant,trend,arlagcoefs,issmbstochastic,SMBarmaEnum);
|
---|
[26810] | 209 | /*Compute lapse rate adjustment*/
|
---|
[26947] | 210 | element->LapseRateBasinSMB(numelevbins,lapserates,elevbins,refelevation);
|
---|
[26810] | 211 | }
|
---|
[26481] | 212 |
|
---|
[26615] | 213 | /*Cleanup*/
|
---|
[27246] | 214 | xDelete<IssmDouble>(termconstant);
|
---|
| 215 | xDelete<IssmDouble>(trend);
|
---|
[27250] | 216 | xDelete<IssmDouble>(arlagcoefs);
|
---|
[26947] | 217 | xDelete<IssmDouble>(lapserates);
|
---|
| 218 | xDelete<IssmDouble>(elevbins);
|
---|
[26810] | 219 | xDelete<IssmDouble>(refelevation);
|
---|
[26477] | 220 | }/*}}}*/
|
---|
[17085] | 221 | void Delta18oParameterizationx(FemModel* femmodel){/*{{{*/
|
---|
| 222 |
|
---|
[25539] | 223 | for(Object* & object : femmodel->elements->objects){
|
---|
| 224 | Element* element=xDynamicCast<Element*>(object);
|
---|
[17085] | 225 | element->Delta18oParameterization();
|
---|
| 226 | }
|
---|
| 227 |
|
---|
| 228 | }/*}}}*/
|
---|
[18968] | 229 | void MungsmtpParameterizationx(FemModel* femmodel){/*{{{*/
|
---|
| 230 |
|
---|
[25539] | 231 | for(Object* & object : femmodel->elements->objects){
|
---|
| 232 | Element* element=xDynamicCast<Element*>(object);
|
---|
[18968] | 233 | element->MungsmtpParameterization();
|
---|
| 234 | }
|
---|
| 235 |
|
---|
| 236 | }/*}}}*/
|
---|
[19172] | 237 | void Delta18opdParameterizationx(FemModel* femmodel){/*{{{*/
|
---|
| 238 |
|
---|
[25539] | 239 | for(Object* & object : femmodel->elements->objects){
|
---|
| 240 | Element* element=xDynamicCast<Element*>(object);
|
---|
[19172] | 241 | element->Delta18opdParameterization();
|
---|
| 242 | }
|
---|
| 243 |
|
---|
| 244 | }/*}}}*/
|
---|
[17085] | 245 | void PositiveDegreeDayx(FemModel* femmodel){/*{{{*/
|
---|
| 246 |
|
---|
| 247 | // void PositiveDegreeDayx(hd,vTempsea,vPrec,agd,Tsurf,ni){
|
---|
| 248 | // note "v" prefix means 12 monthly means, ie time dimension
|
---|
| 249 | // INPUT parameters: ni: working size of arrays
|
---|
| 250 | // INPUT: surface elevation (m): hd(NA)
|
---|
| 251 | // monthly mean surface sealevel temperature (degrees C): vTempsea(NA
|
---|
[23366] | 252 | // ,NTIME)
|
---|
[17085] | 253 | // monthly mean precip rate (m/yr water equivalent): vPrec(NA,NTIME)
|
---|
| 254 | // OUTPUT: mass-balance (m/yr ice): agd(NA)
|
---|
| 255 | // mean annual surface temperature (degrees C): Tsurf(NA)
|
---|
| 256 |
|
---|
[25539] | 257 | int it, jj, itm;
|
---|
[17085] | 258 | IssmDouble DT = 0.02, sigfac, snormfac;
|
---|
[23366] | 259 | IssmDouble signorm = 5.5; // signorm : sigma of the temperature distribution for a normal day
|
---|
[17085] | 260 | IssmDouble siglim; // sigma limit for the integration which is equal to 2.5 sigmanorm
|
---|
| 261 | IssmDouble signormc = signorm - 0.5; // sigma of the temperature distribution for cloudy day
|
---|
| 262 | IssmDouble siglimc, siglim0, siglim0c;
|
---|
| 263 | IssmDouble tstep, tsint, tint, tstepc;
|
---|
| 264 | int NPDMAX = 1504, NPDCMAX = 1454;
|
---|
[23366] | 265 | //IssmDouble pdds[NPDMAX]={0};
|
---|
[17085] | 266 | //IssmDouble pds[NPDCMAX]={0};
|
---|
| 267 | IssmDouble pddt, pd ; // pd : snow/precip fraction, precipitation falling as snow
|
---|
| 268 | IssmDouble PDup, PDCUT = 2.0; // PDcut: rain/snow cutoff temperature (C)
|
---|
| 269 | IssmDouble tstar; // monthly mean surface temp
|
---|
| 270 |
|
---|
[18968] | 271 | bool ismungsm;
|
---|
[22448] | 272 | bool issetpddfac;
|
---|
[18968] | 273 |
|
---|
[17085] | 274 | IssmDouble *pdds = NULL;
|
---|
| 275 | IssmDouble *pds = NULL;
|
---|
| 276 | Element *element = NULL;
|
---|
| 277 |
|
---|
[23366] | 278 | pdds=xNew<IssmDouble>(NPDMAX+1);
|
---|
| 279 | pds=xNew<IssmDouble>(NPDCMAX+1);
|
---|
[17085] | 280 |
|
---|
[18968] | 281 | // Get ismungsm parameter
|
---|
[19527] | 282 | femmodel->parameters->FindParam(&ismungsm,SmbIsmungsmEnum);
|
---|
[18968] | 283 |
|
---|
[22448] | 284 | // Get issetpddfac parameter
|
---|
| 285 | femmodel->parameters->FindParam(&issetpddfac,SmbIssetpddfacEnum);
|
---|
| 286 |
|
---|
[17085] | 287 | /* initialize PDD (creation of a lookup table)*/
|
---|
| 288 | tstep = 0.1;
|
---|
| 289 | tsint = tstep*0.5;
|
---|
| 290 | sigfac = -1.0/(2.0*pow(signorm,2));
|
---|
| 291 | snormfac = 1.0/(signorm*sqrt(2.0*acos(-1.0)));
|
---|
| 292 | siglim = 2.5*signorm;
|
---|
| 293 | siglimc = 2.5*signormc;
|
---|
| 294 | siglim0 = siglim/DT + 0.5;
|
---|
| 295 | siglim0c = siglimc/DT + 0.5;
|
---|
| 296 | PDup = siglimc+PDCUT;
|
---|
| 297 |
|
---|
| 298 | itm = reCast<int,IssmDouble>((2*siglim/DT + 1.5));
|
---|
| 299 |
|
---|
| 300 | if(itm >= NPDMAX) _error_("increase NPDMAX in massBalance.cpp");
|
---|
[23366] | 301 | for(it = 0; it < itm; it++){
|
---|
[17085] | 302 | // tstar = REAL(it)*DT-siglim;
|
---|
| 303 | tstar = it*DT-siglim;
|
---|
| 304 | tint = tsint;
|
---|
| 305 | pddt = 0.;
|
---|
| 306 | for ( jj = 0; jj < 600; jj++){
|
---|
| 307 | if (tint > (tstar+siglim)){break;}
|
---|
| 308 | pddt = pddt + tint*exp(sigfac*(pow((tint-tstar),2)))*tstep;
|
---|
| 309 | tint = tint+tstep;
|
---|
| 310 | }
|
---|
| 311 | pdds[it] = pddt*snormfac;
|
---|
| 312 | }
|
---|
| 313 | pdds[itm+1] = siglim + DT;
|
---|
| 314 |
|
---|
| 315 | //*********compute PD(T) : snow/precip fraction. precipitation falling as snow
|
---|
| 316 | tstepc = 0.1;
|
---|
| 317 | tsint = PDCUT-tstepc*0.5;
|
---|
| 318 | signormc = signorm - 0.5;
|
---|
| 319 | sigfac = -1.0/(2.0*pow(signormc,2));
|
---|
| 320 | snormfac = 1.0/(signormc*sqrt(2.0*acos(-1.0)));
|
---|
| 321 | siglimc = 2.5*signormc ;
|
---|
| 322 | itm = reCast<int,IssmDouble>((PDCUT+2.*siglimc)/DT + 1.5);
|
---|
| 323 | if(itm >= NPDCMAX) _error_("increase NPDCMAX in p35com");
|
---|
| 324 | for(it = 0; it < itm; it++ ){
|
---|
| 325 | tstar = it*DT-siglimc;
|
---|
| 326 | // tstar = REAL(it)*DT-siglimc;
|
---|
| 327 | tint = tsint; // start against upper bound
|
---|
| 328 | pd = 0.;
|
---|
| 329 | for (jj = 0; jj < 600; jj++){
|
---|
| 330 | if (tint<(tstar-siglimc)) {break;}
|
---|
| 331 | pd = pd + exp(sigfac*(pow((tint-tstar),2)))*tstepc;
|
---|
| 332 | tint = tint-tstepc;
|
---|
| 333 | }
|
---|
| 334 | pds[it] = pd*snormfac; // gaussian integral lookup table for snow fraction
|
---|
| 335 | }
|
---|
| 336 | pds[itm+1] = 0.;
|
---|
| 337 | // *******END initialize PDD
|
---|
| 338 |
|
---|
[25539] | 339 | for(Object* & object : femmodel->elements->objects){
|
---|
| 340 | element=xDynamicCast<Element*>(object);
|
---|
[22448] | 341 | element->PositiveDegreeDay(pdds,pds,signorm,ismungsm,issetpddfac);
|
---|
[17085] | 342 | }
|
---|
| 343 | /*free ressouces: */
|
---|
| 344 | xDelete<IssmDouble>(pdds);
|
---|
| 345 | xDelete<IssmDouble>(pds);
|
---|
| 346 | }/*}}}*/
|
---|
[23317] | 347 | void PositiveDegreeDaySicopolisx(FemModel* femmodel){/*{{{*/
|
---|
[23366] | 348 |
|
---|
[23317] | 349 | bool isfirnwarming;
|
---|
[23328] | 350 | femmodel->parameters->FindParam(&isfirnwarming,SmbIsfirnwarmingEnum);
|
---|
[23366] | 351 |
|
---|
[25539] | 352 | for(Object* & object : femmodel->elements->objects){
|
---|
| 353 | Element* element=xDynamicCast<Element*>(object);
|
---|
[23317] | 354 | element->PositiveDegreeDaySicopolis(isfirnwarming);
|
---|
| 355 | }
|
---|
| 356 |
|
---|
| 357 | }/*}}}*/
|
---|
[17085] | 358 | void SmbHenningx(FemModel* femmodel){/*{{{*/
|
---|
| 359 |
|
---|
[17087] | 360 | /*Intermediaries*/
|
---|
[17403] | 361 | IssmDouble z_critical = 1675.;
|
---|
| 362 | IssmDouble dz = 0;
|
---|
| 363 | IssmDouble a = -15.86;
|
---|
| 364 | IssmDouble b = 0.00969;
|
---|
| 365 | IssmDouble c = -0.235;
|
---|
| 366 | IssmDouble f = 1.;
|
---|
| 367 | IssmDouble g = -0.0011;
|
---|
| 368 | IssmDouble h = -1.54e-5;
|
---|
| 369 | IssmDouble smb,smbref,anomaly,yts,z;
|
---|
[22249] | 370 |
|
---|
| 371 | /* Get constants */
|
---|
| 372 | femmodel->parameters->FindParam(&yts,ConstantsYtsEnum);
|
---|
| 373 | /*iomodel->FindConstant(&yts,"md.constants.yts");*/
|
---|
| 374 | /*this->parameters->FindParam(&yts,ConstantsYtsEnum);*/
|
---|
| 375 | /*Mathieu original*/
|
---|
| 376 | /*IssmDouble smb,smbref,z;*/
|
---|
| 377 |
|
---|
[17087] | 378 | /*Loop over all the elements of this partition*/
|
---|
[25539] | 379 | for(Object* & object : femmodel->elements->objects){
|
---|
| 380 | Element* element=xDynamicCast<Element*>(object);
|
---|
[17087] | 381 |
|
---|
| 382 | /*Get reference SMB (uncorrected) and allocate all arrays*/
|
---|
| 383 | int numvertices = element->GetNumberOfVertices();
|
---|
| 384 | IssmDouble* surfacelist = xNew<IssmDouble>(numvertices);
|
---|
| 385 | IssmDouble* smblistref = xNew<IssmDouble>(numvertices);
|
---|
| 386 | IssmDouble* smblist = xNew<IssmDouble>(numvertices);
|
---|
| 387 | element->GetInputListOnVertices(surfacelist,SurfaceEnum);
|
---|
[19527] | 388 | element->GetInputListOnVertices(smblistref,SmbSmbrefEnum);
|
---|
[17087] | 389 |
|
---|
| 390 | /*Loop over all vertices of element and correct SMB as a function of altitude z*/
|
---|
| 391 | for(int v=0;v<numvertices;v++){
|
---|
| 392 |
|
---|
[17403] | 393 | /*Get vertex elevation, anoma smb*/
|
---|
[17087] | 394 | z = surfacelist[v];
|
---|
[17403] | 395 | anomaly = smblistref[v];
|
---|
[17087] | 396 |
|
---|
[22249] | 397 | /* Henning edited acc. to Riannes equations*/
|
---|
| 398 | /* Set SMB maximum elevation, if dz = 0 -> z_critical = 1675 */
|
---|
| 399 | z_critical = z_critical + dz;
|
---|
| 400 |
|
---|
| 401 | /* Calculate smb acc. to the surface elevation z */
|
---|
| 402 | if(z<z_critical){
|
---|
[17403] | 403 | smb = a + b*z + c;
|
---|
[17087] | 404 | }
|
---|
| 405 | else{
|
---|
[22249] | 406 | smb = (a + b*z)*(f + g*(z-z_critical) + h*(z-z_critical)*(z-z_critical)) + c;
|
---|
[17087] | 407 | }
|
---|
[22249] | 408 |
|
---|
[18584] | 409 | /* Compute smb including anomaly,
|
---|
| 410 | correct for number of seconds in a year [s/yr]*/
|
---|
| 411 | smb = smb/yts + anomaly;
|
---|
| 412 |
|
---|
[17087] | 413 | /*Update array accordingly*/
|
---|
| 414 | smblist[v] = smb;
|
---|
| 415 |
|
---|
| 416 | }
|
---|
| 417 |
|
---|
| 418 | /*Add input to element and Free memory*/
|
---|
[25379] | 419 | element->AddInput(SmbMassBalanceEnum,smblist,P1Enum);
|
---|
[17087] | 420 | xDelete<IssmDouble>(surfacelist);
|
---|
| 421 | xDelete<IssmDouble>(smblistref);
|
---|
| 422 | xDelete<IssmDouble>(smblist);
|
---|
[17085] | 423 | }
|
---|
| 424 |
|
---|
| 425 | }/*}}}*/
|
---|
[18001] | 426 | void SmbComponentsx(FemModel* femmodel){/*{{{*/
|
---|
| 427 |
|
---|
| 428 | // void SmbComponentsx(acc,evap,runoff,ni){
|
---|
| 429 | // INPUT parameters: ni: working size of arrays
|
---|
| 430 | // INPUT: surface accumulation (m/yr water equivalent): acc
|
---|
| 431 | // surface evaporation (m/yr water equivalent): evap
|
---|
| 432 | // surface runoff (m/yr water equivalent): runoff
|
---|
| 433 | // OUTPUT: mass-balance (m/yr ice): agd(NA)
|
---|
[23814] | 434 |
|
---|
[18001] | 435 | /*Loop over all the elements of this partition*/
|
---|
[25539] | 436 | for(Object* & object : femmodel->elements->objects){
|
---|
| 437 | Element* element=xDynamicCast<Element*>(object);
|
---|
[18001] | 438 |
|
---|
| 439 | /*Allocate all arrays*/
|
---|
| 440 | int numvertices = element->GetNumberOfVertices();
|
---|
[23366] | 441 | IssmDouble* acc = xNew<IssmDouble>(numvertices);
|
---|
[18001] | 442 | IssmDouble* evap = xNew<IssmDouble>(numvertices);
|
---|
[23366] | 443 | IssmDouble* runoff = xNew<IssmDouble>(numvertices);
|
---|
[18001] | 444 | IssmDouble* smb = xNew<IssmDouble>(numvertices);
|
---|
| 445 |
|
---|
| 446 | /*Recover Smb Components*/
|
---|
[26208] | 447 | element->GetInputListOnVertices(acc,SmbAccumulationEnum);
|
---|
| 448 | element->GetInputListOnVertices(evap,SmbEvaporationEnum);
|
---|
| 449 | element->GetInputListOnVertices(runoff,SmbRunoffEnum);
|
---|
[18001] | 450 |
|
---|
| 451 | // loop over all vertices
|
---|
[24335] | 452 | for(int v=0;v<numvertices;v++) smb[v]=acc[v]-evap[v]-runoff[v];
|
---|
[18001] | 453 |
|
---|
| 454 | /*Add input to element and Free memory*/
|
---|
[25379] | 455 | element->AddInput(SmbMassBalanceEnum,smb,P1Enum);
|
---|
[18001] | 456 | xDelete<IssmDouble>(acc);
|
---|
| 457 | xDelete<IssmDouble>(evap);
|
---|
| 458 | xDelete<IssmDouble>(runoff);
|
---|
| 459 | xDelete<IssmDouble>(smb);
|
---|
| 460 | }
|
---|
| 461 |
|
---|
| 462 | }/*}}}*/
|
---|
| 463 | void SmbMeltComponentsx(FemModel* femmodel){/*{{{*/
|
---|
| 464 |
|
---|
| 465 | // void SmbMeltComponentsx(acc,evap,melt,refreeze,ni){
|
---|
| 466 | // INPUT parameters: ni: working size of arrays
|
---|
| 467 | // INPUT: surface accumulation (m/yr water equivalent): acc
|
---|
| 468 | // surface evaporation (m/yr water equivalent): evap
|
---|
| 469 | // surface melt (m/yr water equivalent): melt
|
---|
| 470 | // refreeze of surface melt (m/yr water equivalent): refreeze
|
---|
| 471 | // OUTPUT: mass-balance (m/yr ice): agd(NA)
|
---|
[23814] | 472 |
|
---|
[18001] | 473 | /*Loop over all the elements of this partition*/
|
---|
[25539] | 474 | for(Object* & object : femmodel->elements->objects){
|
---|
| 475 | Element* element=xDynamicCast<Element*>(object);
|
---|
[18001] | 476 |
|
---|
| 477 | /*Allocate all arrays*/
|
---|
| 478 | int numvertices = element->GetNumberOfVertices();
|
---|
| 479 | IssmDouble* acc = xNew<IssmDouble>(numvertices);
|
---|
[23366] | 480 | IssmDouble* evap = xNew<IssmDouble>(numvertices);
|
---|
[18001] | 481 | IssmDouble* melt = xNew<IssmDouble>(numvertices);
|
---|
| 482 | IssmDouble* refreeze = xNew<IssmDouble>(numvertices);
|
---|
| 483 | IssmDouble* smb = xNew<IssmDouble>(numvertices);
|
---|
| 484 |
|
---|
| 485 | /*Recover Smb Components*/
|
---|
[26208] | 486 | element->GetInputListOnVertices(acc,SmbAccumulationEnum);
|
---|
| 487 | element->GetInputListOnVertices(evap,SmbEvaporationEnum);
|
---|
| 488 | element->GetInputListOnVertices(melt,SmbMeltEnum);
|
---|
| 489 | element->GetInputListOnVertices(refreeze,SmbRefreezeEnum);
|
---|
[18001] | 490 |
|
---|
| 491 | // loop over all vertices
|
---|
[24335] | 492 | for(int v=0;v<numvertices;v++) smb[v]=acc[v]-evap[v]-melt[v]+refreeze[v];
|
---|
[18001] | 493 |
|
---|
| 494 | /*Add input to element and Free memory*/
|
---|
[25379] | 495 | element->AddInput(SmbMassBalanceEnum,smb,P1Enum);
|
---|
[18001] | 496 | xDelete<IssmDouble>(acc);
|
---|
| 497 | xDelete<IssmDouble>(evap);
|
---|
| 498 | xDelete<IssmDouble>(melt);
|
---|
| 499 | xDelete<IssmDouble>(refreeze);
|
---|
| 500 | xDelete<IssmDouble>(smb);
|
---|
| 501 | }
|
---|
| 502 |
|
---|
| 503 | }/*}}}*/
|
---|
[23366] | 504 | void SmbGradientsComponentsx(FemModel* femmodel){/*{{{*/
|
---|
| 505 |
|
---|
[25539] | 506 | for(Object* & object : femmodel->elements->objects){
|
---|
| 507 | Element* element=xDynamicCast<Element*>(object);
|
---|
[23366] | 508 | element->SmbGradCompParameterization();
|
---|
| 509 | }
|
---|
| 510 |
|
---|
| 511 | }/*}}}*/
|
---|
[23540] | 512 | #ifdef _HAVE_SEMIC_
|
---|
| 513 | void SmbSemicx(FemModel* femmodel){/*{{{*/
|
---|
| 514 |
|
---|
[25539] | 515 | for(Object* & object : femmodel->elements->objects){
|
---|
| 516 | Element* element=xDynamicCast<Element*>(object);
|
---|
[23540] | 517 | element->SmbSemic();
|
---|
| 518 | }
|
---|
| 519 |
|
---|
| 520 | }/*}}}*/
|
---|
| 521 | #else
|
---|
| 522 | void SmbSemicx(FemModel* femmodel){_error_("SEMIC not installed");}
|
---|
| 523 | #endif //_HAVE_SEMIC_
|
---|