NGEET / fates

repository for the Functionally Assembled Terrestrial Ecosystem Simulator (FATES)
Other
105 stars 92 forks source link

Refactor spitfire fuel calculations #1247

Closed adrifoster closed 1 week ago

adrifoster commented 2 months ago

Refactors the SPITFIRE fuel calculation subroutine and adds a fuel class

Description:

Major changes to the way fuel characteristics are calculated in the SPITFIRE module. Changes are not B4B, but should be round off.

Expectation of Answer Changes:

Round off differences due to order of operation changes. Testing in progress...

Checklist

Contributor

Integrator

Test Results:

Testing ongoing... currently having issues with some divide by zero errors (in rate_of_spread) for only some tests... I'm not sure why this is happening since the code should check and not let SAV, bulk density, etc. equal zero.

/glade/derecho/scratch/afoster/tests_0912-094039de

CTSM (or) E3SM (specify which) test hash-tag:

CTSM (or) E3SM (specify which) baseline hash-tag:

FATES baseline hash-tag:

Test Output:

adrifoster commented 2 months ago

Okay so I've tracked down this error. And it seems to originate from a negative value in the sum of fine leaf litter. (leaf_fines -2.3394756489679232E-006)

This exists in main branch too - I think the old way of calculating fuel was hiding it.

I am going to file an issue.

@rgknox @glemieux any ideas?

glemieux commented 2 months ago

Okay so I've tracked down this error. And it seems to originate from a negative value in the sum of fine leaf litter. (leaf_fines -2.3394756489679232E-006)

This exists in main branch too - I think the old way of calculating fuel was hiding it.

I am going to file an issue.

@rgknox @glemieux any ideas?

We can ignore this per #1249.

adrifoster commented 1 month ago

Okay I think I have fixed all the overflow and divide-by-zero issues. I am re-running testing but I think this is now ready for a review.

adrifoster commented 1 month ago

fates test suite tests are in /glade/derecho/scratch/afoster/tests_0924-151742de

all tests PASS or FAIL due to a BASELINE DIFF, as expected

will run through and make sure all DIFF's are round off

adrifoster commented 1 month ago

All DIFFs are due to roundoff - this is ready for a review.

adrifoster commented 1 month ago

@rgknox asked for some functional testing plots:

Plot of Nesterov Index over time using driver data from an interior Alaska site

Nesterov_plot

Corresponding fuel moisture for above NI values, for 3 different synthetic fuel models (see module

fuel_moisture_plot

Fuel loading for fuel types:

Fuel loading_plot

Fractional loading

Fractional fuel loading_plot

Fuel bulk density

Fuel bulk density_plot

Fuel SAV

Fuel surface area to volume ratio_plot

rgknox commented 1 month ago

One general comment. This is something that was already in the code that kind of bothered me. We all know we break up litter into component groups for both decomposition and fire. Both modules use almost the same groups, which are governed by size and location (above and below ground). In general, I'd like this to be a little cleaner, where the super-set of all delineations is contained in a process agnostic module, and decomposition and fire could inherit those delineations and group/use them how they see fit. I don't see this as in-scope for this PR necessarily, but I'm curious how you see all this, and if its still a problem.

adrifoster commented 1 month ago

One general comment. This is something that was already in the code that kind of bothered me. We all know we break up litter into component groups for both decomposition and fire. Both modules use almost the same groups, which are governed by size and location (above and below ground). In general, I'd like this to be a little cleaner, where the super-set of all delineations is contained in a process agnostic module, and decomposition and fire could inherit those delineations and group/use them how they see fit. I don't see this as in-scope for this PR necessarily, but I'm curious how you see all this, and if its still a problem.

Totally agree. I wanted to try to merge them somehow but they are slightly different in terms of how they are grouped and used, so I wasn't sure how to do it efficiently for this PR. I think it warrants a small group of us sitting down to discuss. If we merged them it would also make further discretizing the litter/fuel easier (i.e. PFT-specific, etc.).

I also don't love that the litter is decayed in one spot, the fuel is combusted in another, etc. And seemingly we do (?) make sure these things align?

adrifoster commented 1 month ago

Great work! This is so much better organized and easier to understand. I just have some rather minor comments.

Thanks @samsrabin! Great suggestions, will get started on applying them.

adrifoster commented 3 weeks ago

I've addressed @samsrabin's comments and made all suggested changes.

adrifoster commented 1 week ago

Thanks to @glemieux for finding the issue with this PR. All tests now pass.