CH-Earth / summa

Structure for Unifying Multiple Modeling Alternatives:
http://www.ral.ucar.edu/projects/summa
GNU General Public License v3.0
80 stars 105 forks source link

Limit the amount of compaction to maintain volumetric fractions #364

Closed arbennett closed 4 years ago

arbennett commented 4 years ago

This attempts to fix #363 and has two portions, but still has some issues. The first is in snwCompact.f90 and works by computing the maximum allowable amount of snow compaction to ensure that the volumetric fractions of ice and liquid sum to 1. Then, if the computed compaction is greater than this, the maximum is substituted. The second is in coupled_em.f90 to address a follow-on issue. When the amount of compaction is great enough to run into this issue it is possible for the snow layering to drop below the threshold-minimum level. I have added a check to see if we need to do any layer merging after the compaction routine to avoid this issue.

There is still one outstanding problem with this pull request that I would like feedback on, perhaps @martynpclark and @bartnijssen have ideas?

There is still a case where the snow density can be too low, especially when there are very small volumetric fractions of ice in a layer and the layer depth is small. It seems the fix for this should be to add the layer merge call, but the condition for applying a layer merge is much smaller (verySmall = 1e-6) than the minimum layer depth in many cases. Because of this, the low density error can still occur. Relaxing the constraint on doing layer merges to ensure that tiny layers aren't leftover here ends up breaking mass balance.

arbennett commented 4 years ago

My latest commit provides a better estimate on whether or not we need to do a top layer merge after compaction occurs. It appears to fix the problem in general.

arbennett commented 4 years ago

This pull request will break bit-for-bit compatibility with the test cases. Here is a summary of some of the differences:

Test   0 - Filename: celia1990_output_testSumma_timestep.nc                           
  Total difference: 0.0      
  Normalized Mean Abs err: 0.0     
Test   1 - Filename: colbeck1976-exp1_output_testSumma_timestep.nc                    
  Total difference: 0.0      
  Normalized Mean Abs err: 0.0     
Test   2 - Filename: colbeck1976-exp2_output_testSumma_timestep.nc                    
  Total difference: 0.0      
  Normalized Mean Abs err: 0.0     
Test   3 - Filename: colbeck1976-exp3_output_testSumma_timestep.nc                    
  Total difference: 0.0      
  Normalized Mean Abs err: 0.0     
Test   4 - Filename: millerClay_output_testSumma_timestep.nc                          
  Total difference: 0.0      
  Normalized Mean Abs err: 0.0     
Test   5 - Filename: millerLoam_output_testSumma_timestep.nc                          
  Total difference: 0.0      
  Normalized Mean Abs err: 0.0     
Test   6 - Filename: millerSand_output_testSumma_timestep.nc                          
  Total difference: 0.0      
  Normalized Mean Abs err: 0.0     
Test   7 - Filename: mizoguchi1990_output_testSumma_timestep.nc                       
  Total difference: 0.0      
  Normalized Mean Abs err: 0.0     
Test   8 - Filename: syntheticHillslope-exp1_output_testSumma_timestep.nc             
  Total difference: 0.0      
  Normalized Mean Abs err: 0.0     
Test   9 - Filename: syntheticHillslope-exp2_output_testSumma_timestep.nc             
  Total difference: 0.0      
  Normalized Mean Abs err: 0.0     
Test  10 - Filename: vegImpactsRad_output_riparianAspenBeersLaw_timestep.nc           
  Total difference: -5.528321084127075 
  Normalized Mean Abs err: 1.6326525032153776e-05
Test  11 - Filename: vegImpactsRad_output_riparianAspenCLM2stream_timestep.nc         
  Total difference: -5.062797956182857 
  Normalized Mean Abs err: 1.052360911391567e-05
Test  12 - Filename: vegImpactsRad_output_riparianAspenNLscatter_timestep.nc          
  Total difference: -198.9430320460869 
  Normalized Mean Abs err: 0.00029841212843521907
Test  13 - Filename: vegImpactsRad_output_riparianAspenUEB2stream_timestep.nc         
  Total difference: 0.18935790759331353 
  Normalized Mean Abs err: 2.914605185353422e-05
Test  14 - Filename: vegImpactsRad_output_riparianAspenVegParamPerturb_timestep.nc    
  Total difference: -119.49007886952595 
  Normalized Mean Abs err: 3.6199605544410666e-05
Test  15 - Filename: vegImpactsWind_output_riparianAspenWindParamPerturb_timestep.nc  
  Total difference: 114798.67517991932 
  Normalized Mean Abs err: 0.018537922152051876
Test  16 - Filename: vegImpactsWind_output_riparianAspenExpWindProfile_timestep.nc    
  Total difference: -123975.80247728106 
  Normalized Mean Abs err: 0.07128374931688891
Test  17 - Filename: storckSite_output_hedpom9697_timestep.nc                         
  Total difference: 0.0      
  Normalized Mean Abs err: 0.0     
Test  18 - Filename: storckSite_output_hedpom9798_timestep.nc                         
  Total difference: 0.0      
  Normalized Mean Abs err: 0.0     
Test  19 - Filename: storckSite_output_storck9697_timestep.nc                         
  Total difference: 0.0      
  Normalized Mean Abs err: 0.0     
Test  20 - Filename: storckSite_output_storck9798_timestep.nc                         
  Total difference: 0.0      
  Normalized Mean Abs err: 0.0     
Test  21 - Filename: albedoTest_output_reynoldsConstantDecayRate_timestep.nc          
  Total difference: -35.51972058857248 
  Normalized Mean Abs err: 0.00024659889524330196
Test  22 - Filename: albedoTest_output_reynoldsVariableDecayRate_timestep.nc          
  Total difference: -25.626282200129726 
  Normalized Mean Abs err: 0.00019581913387707348
Test  23 - Filename: albedoTest_output_senatorConstantDecayRate_timestep.nc           
  Total difference: -60276.167342877576 
  Normalized Mean Abs err: 0.023287350405324318
Test  24 - Filename: albedoTest_output_senatorVariableDecayRate_timestep.nc           
  Total difference: 1.2816591263421009 
  Normalized Mean Abs err: 0.0001831866325482091
Test  25 - Filename: vegImpactsTranspire_output_ballBerry_timestep.nc                 
  Total difference: 0.0      
  Normalized Mean Abs err: 0.0     
Test  26 - Filename: vegImpactsTranspire_output_jarvis_timestep.nc                    
  Total difference: 0.0      
  Normalized Mean Abs err: 0.0     
Test  27 - Filename: vegImpactsTranspire_output_simpleResistance_timestep.nc          
  Total difference: 0.0      
  Normalized Mean Abs err: 0.0     
Test  28 - Filename: vegImpactsTranspire_output_perturbRoots_timestep.nc              
  Total difference: 0.0      
  Normalized Mean Abs err: 0.0     
Test  29 - Filename: basinRunoff_output_1dRichards_timestep.nc                        
  Total difference: 0.0      
  Normalized Mean Abs err: 0.0     
Test  30 - Filename: basinRunoff_output_distributedTopmodel_timestep.nc               
  Total difference: 57966.5751338639 
  Normalized Mean Abs err: 0.00720097830291871
Test  31 - Filename: basinRunoff_output_lumpedTopmodel_timestep.nc                    
  Total difference: -120471.07635314342 
  Normalized Mean Abs err: 0.04260036295837695

The occasional "larger" normalized mean ab errors are due to times when there used to be one and now there are no snow layers. Here is an example showing this difference in mLayerTemp for the 16th test case (Highest avg error):

image

After some extensive testing and plotting I feel that these deviations from the test cases are acceptable. I will produce a new set of benchmark test output following the merge of this pull request.