NCAR / micm

A model-independent chemistry module for atmosphere models
https://ncar.github.io/micm/
Apache License 2.0
5 stars 5 forks source link

Some data in the State variable may be corrupt #625

Open sjsprecious opened 3 weeks ago

sjsprecious commented 3 weeks ago

As identified by this issue https://github.com/NCAR/MUSICA-Performance-Comparison/issues/62, if we reuse the State variable between different iterations of solve function, the results are corrupt and we get fail to converge error message later.

Kyle commented that this was also the reason why he had to initialize the LU matrix to zero originally (https://github.com/NCAR/micm/issues/587).

This issue indicates that the LU matrix in State variable is not overwritten correctly between iterations (or we should not expect it to be overwritten correctly at all?).

K20shores commented 3 weeks ago

The state should be completely reusable without any zeroing, from my understanding. The fact that it isn't is a problem

sjsprecious commented 3 weeks ago

Thanks Kyle for the clarification. I looked at these two lines https://github.com/NCAR/micm/blob/main/include/micm/solver/lu_decomposition.inl#L201 and https://github.com/NCAR/micm/blob/main/include/micm/solver/lu_decomposition.inl#L214. Could the Uvector use the values from the previous time step without a zeroing?

K20shores commented 3 weeks ago

We set them just before those, but it's in an if block so maybe not all of the values are zeros. Perhaps we should add back a zero of L and U

sjsprecious commented 3 weeks ago

Thanks @K20shores for your comments. Hmm, interesting. For the first time when the State variable is generated, are the L and U matrices zeroed?