mdekauwe / GDAY

GDAY simulates carbon, nitrogen & water dynamics
14 stars 31 forks source link

SPA spin-up #12

Open mdekauwe opened 7 years ago

mdekauwe commented 7 years ago

If you're using SPA then the time involved to spin-up the model is pretty costly.

Test case: model spin-up & then a 12 year simulation at a 30 minute timestep for Tumbarumba

First, the impact of SAS on simulation time = ~57% improvement using the SAS spin-up. SPA off, brute force spin-up (i.e. our classic GDAY just at 30 mins): 2m 20 SPA off, SAS spin-up: 0 m 59

But turning SPA on, leads to a ridiculously long simulation time. SPA on, SAS spin-up: 17 m 46

Causes?

  1. Drainage through the soil water profile, this involves all the costly calls to numerical recipes for the integration funcs (odein, rkck, rkqs).
  2. Calculating a new rooting distribution at the end of the year, this involves a call to zbrent to do a minimisation.
  3. Using 20 soil layers, obviously that also impacts on (1) as well.
  4. Potentially too strict a stopping criteria for the passive pool.

Solution 1

Assume a fixed drainage rate, I took an average across 10,000 SPA iterations for the Tumbarumba soil, finding a rate ~7%. So I tested the assumption that 10% of water in a layer can drain during a step for the spin-up (obviously one would test for a more robust value!). Then for the actual simulations I go back to using the SPA calculations for drainage. This gets you a total run time of:

SPA on, SAS spin-up, fast drainage: 3 m 43.6

Solution 2

Either (1) assume a fixed rooting distribution as in CABLE, or (2) fix the slope term in the rooting distribution function from SPA, to remove the call to zbrent. I tested 2 and it makes things a few seconds faster, so this is a small issue.

Solution 3

A bit arbitrary...We could play with a few different soil layers numbers and see at what point we lose important resolution.

I tested using 6 layers instead of 20:

SPA on, SAS spin-up, 6 layers: 5 m 56

Solution 4

Relax the stopping criteria. Currently we stop once the change in the passive pool is < 0.05 t/ha, if I make that 0.5 t/ha

SPA on, SAS spin up, delta passive < 0.5: 8 m 3

Moving to the impact on simulated fluxes ...

Solution 1: Drainage

Here EXP is the fixed rate drainage and CTRL is standard GDAY-SPA. NB. the fixed drainage rate is only used during spin-up, during the actual simulation we switch back.

Dry down 1

tumbarumba_spa_comparison_20020801_20030801

Dry down 2

tumbarumba_spa_comparison_20040101_20040101

Makes no differences, so I think that is a viable spin-up assumption?

Solution 2: 6 layers vs. 20

As you'd expect this has more of an impact, not sure what the right balance is here. For this test I just made 6 equal sized layers, clearly a few smaller ones and a single larger one might be preferable.

Dry down 1

tumbarumba_spa_comparison_20020801_20030801

Dry down 2

tumbarumba_spa_comparison_20040101_20040101

Solution 4: relaxed stopping criteria

Dry down 1

tumbarumba_spa_comparison_20020801_20030801

Dry down 2

tumbarumba_spa_comparison_20040101_20040101

How fast could we go?

Fixed drainage, relaxed stopping criteria: 1 m 42s Fixed drainage, relaxed stopping criteria, 6 layers: 0 m 48s