Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Negatises anfix #46

Merged

Conversation

MichaelBarryBMT
Copy link
Contributor

@MichaelBarryBMT MichaelBarryBMT commented Feb 16, 2022

Hi Matt

I think this is what we were talking about today - nfix not conserving mass with internal nutrients simulated.

It is down to signs of various quantities. When the flux of N is computed on the line below, nuptake(phy_i,:) is summed to get total uptake, and the sum is negatised. This is fine for amm and no3 - their uptakes are negative quantities, so summing them and negatising the sum provides a positive uptake quantity.

Nitrogen fixing uptake at nuptake(phy_i,4) (anfix) however is computed as a positive uptake quantity and so adding it to the negative amm and no3 uptakes means that the terms partially cancel, and are not added up correctly: a positive anfix uptake is added to the two negative amm and no3 uptakes, and then the sum negatised. I included the debug info on the right hand side of the screen shot below so you can see the signs of the elements of the nuptake array.

I have suggested the below fix in aed_bio_utils, that is, reporting anfix uptake as a negative quantity back to aed_phytoplankton. This way, all the summed uptakes are the same sign (negative) before the sum is negatised. This suggestion might have flow on effects elsewhere in the code though, so I am not sure.

When I make this change in my local repo I get mass to conserve to 0.2% over a month. Without the fix the divergence was greater than 20%.

MB

image

Quick update: the new diagnostic below will also be affected by the sign of anfix. The sum on nuptake will be potentially cancelling rather than additive.

image

@matthipsey matthipsey merged commit 546512a into AquaticEcoDynamics:master Mar 7, 2022
@MichaelBarryBMT MichaelBarryBMT deleted the INi-flux-calc branch March 7, 2022 22:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants