source:
issm/oecreview/Archive/21724-22754/ISSM-22735-22736.diff
Last change on this file was 22755, checked in by , 7 years ago | |
---|---|
File size: 2.7 KB |
-
../trunk-jpl/src/c/modules/SurfaceMassBalancex/Gembx.cpp
1332 1332 for(int i=0;i<n;i++) exsT[i]= fmax(0.0, T[i] - CtoK); // [K] to [degC] 1333 1333 1334 1334 // new grid point center temperature, T [K] 1335 // for(int i=0;i<n;i++) T[i]-=exsT[i];1335 // for(int i=0;i<n;i++) T[i]-=exsT[i]; 1336 1336 for(int i=0;i<n;i++) T[i]=fmin(T[i],CtoK); 1337 1337 1338 1338 // specify irreducible water content saturation [fraction] … … 1381 1381 surpE=xNew<IssmDouble>(n); for(int i=0;i<n;i++)surpE[i] = surpT[i] * CI * m[i]; 1382 1382 1383 1383 int i = 0; 1384 while (cellsum(surpE,n) > 0.0 + Ttol){ 1384 while (cellsum(surpE,n) > 0.0 + Ttol && i<n-1){ 1385 1385 1386 // use surplus energy to increase the temperature of lower cell 1386 1387 T[i+1] = surpE[i]/m[i+1]/CI + T[i+1]; 1387 1388 exsT[i+1] = fmax(0.0, T[i+1] - CtoK) + exsT[i+1]; 1389 T[i+1] = fmin(CtoK, T[i+1]); 1390 1391 surpT[i+1] = fmax(0.0, exsT[i+1] - LF/CI); 1388 surpT[i+1] = fmax(0.0, (T[i+1] - CtoK - LF/CI)); 1392 1389 surpE[i+1] = surpT[i+1] * CI * m[i+1]; 1393 1390 1394 1391 // adjust current cell properties (again 159.1342 is the max T) 1395 exsT[i] = LF/CI;1392 T[i] = T[i]-surpE[i]/m[i+1]/CI; 1396 1393 surpE[i] = 0.0; 1397 1394 i = i + 1; 1398 1395 } 1396 // recalculate temperature excess above 0 deg C 1397 for(int i=0;i<n;i++) exsT[i] = fmax(0.0, T[i] - CtoK); 1399 1398 } 1400 1399 1401 1400 // convert temperature excess to melt [kg] … … 1689 1688 // printf("Total depth < zMin %f \n", Ztot); 1690 1689 // mass and energy to be added 1691 1690 mAdd = m[n-1]+W[n-1]; 1692 addE = T[n-1]*m[n-1]*CI ;1691 addE = T[n-1]*m[n-1]*CI + W[n-1]*(LF+CtoK*CI); 1693 1692 1694 1693 // add a grid cell of the same size and temperature to the bottom 1695 1694 dz_bot=dz[n-1]; … … 1723 1722 // printf("Total depth > zMax %f \n", Ztot); 1724 1723 // mass and energy loss 1725 1724 mAdd = -(m[n-1]+W[n-1]); 1726 addE = -(T[n-1]*m[n-1]*CI) ;1725 addE = -(T[n-1]*m[n-1]*CI) - (W[n-1]*(LF+CtoK*CI)); 1727 1726 dz_add=-(dz[n-1]); 1728 1727 1729 1728 // remove a grid cell from the bottom … … 1744 1743 celldelete(&EW,n,D,D_size); 1745 1744 n=D_size; 1746 1745 xDelete<int>(D); 1747 1748 1746 } 1749 1747 1750 1748 //// CHECK FOR MASS AND ENERGY CONSERVATION … … 1762 1760 1763 1761 /*only in forward mode! avoid round in AD mode as it is not differentiable: */ 1764 1762 #ifndef _HAVE_ADOLC_ 1765 dm = round( mSum0 - mSum1 + mAdd);1763 dm = round((mSum0 - mSum1 + mAdd)*1000); 1766 1764 dE = round(sumE0 - sumE1 - sumER + addE); 1767 1765 if (dm !=0 || dE !=0) _error_("mass or energy are not conserved in melt equations\n" 1768 1766 << "dm: " << dm << " dE: " << dE << "\n");
Note:
See TracBrowser
for help on using the repository browser.