Replies: 5 comments 11 replies
-
Hi @jagoosw Not sure this is going to be of any help, but I have a code snippet for that here. This is also done in the biogeochemical modeling using PSOM (from Amala's group). I noticed that, of course, if the gradients are extremely high by the initial conditions or something else, the machine-level negative values propagate and blow up everything and even zeroing negative values won't help. In my simulations I checked and it was conserving mass (with some very little oscillations). I think that would be interesting to somehow inform user about mass conservation problems, or add some extra output for that? |
Beta Was this translation helpful? Give feedback.
-
Thanks @jagoosw and @iuryt. Having this capability is a great idea. Negative tracers can cause problems in some cases and it would be great to at least have the option to maintain positive values. Regarding the mass/tracer conservation, its a good idea to have a diagnostic for this (like we do for nitrate in the LOBSTER model). I think that a diagnostic would be preferable to a warning though since there are likely going to be use cases where the tracers aren't conserved (e.g. adding a forcing term to mimic nutrient upwelling). |
Beta Was this translation helpful? Give feedback.
-
Another approach is to use the "Patankar trick" described here: https://www.sciencedirect.com/science/article/pii/S0168927403001016 This is not a strict guarantee of positivity, however, because it also requires both positive-preserving advection schemes and for diffusivities to play nice (if diffusion is treated implicitly). |
Beta Was this translation helpful? Give feedback.
-
In the mean time before we can implement a proper positivity preserving time stepper I did some experiments with different ways to force positivity. My test case is a system that I run for a year and where for around 100 days the ammonia is very low. I can make this run with no negatives if I set the time step to around 1.5minutes and am testing the methods with a 5minute time step (so this is probably a fairly extreme scenario and with smaller timesteps the errors would be smaller). My results are:
This is the total budget as a fraction of the initial budget, the two small ones are Here is the primary production difference, you can see that when we force to zero its just like adding more nutrients, where as re scaling is more of a perturbation that it has an oscillatory (although still biased positive - perhaps todo with other factors like light availability, maybe experimenting with constant light would be better) response to: And finally some poorly formatted heatmaps of the systems - original showing that the change when we rescale is much more contained but that there is a larger P and NO From this I tend to think that re-scaling is the better temporary solution @johnryantaylor @syou83syou83? We could interfere even more and only shuffle negative amounts between the sub-groups, e.g. if NH |
Beta Was this translation helpful? Give feedback.
-
This is great, thanks @jagoosw! It might be useful to plot the difference as a percentage of the total, but they look quite small (a few percent which is arguably well within the 'tolerance' given many uncertainties in the BGC system). |
Beta Was this translation helpful? Give feedback.
-
I was looking through NEMO's PISCES source code and noticed that they enforce that tracers can't be negative with this routine:
With the changes in #45 it would be fairly straight forward for me to add a (optional) similar check to the tracers integration where it multiplies all of the tendencies by
xnegtr
if we thought that was a good idea?I'll have to check that this still conserves mass when individuals exert a tendency on a tracer as I imagine it may not (I think it would cause the system to gain mass unless the integration of individuals properties was added into the same sort of system, which it could and maybe should be), but this sort of thing could be a good idea anyway.
Beta Was this translation helpful? Give feedback.
All reactions