AtChem / AtChem2

Atmospheric chemistry box-model for the MCM
MIT License
59 stars 23 forks source link

COSX threshold #276

Open spco opened 6 years ago

spco commented 6 years ago

The current value of cosx_threshold (1e-30) is equivalent to | x - pi/2 | < 10^{-30}, i.e. the sun is within 10^{-30} radians of the horizon, so that is probably not a useful threshold. This needs experimenting with to make sure the threshold kicks in before the numerics take a hit, but not too soon.

rs028 commented 6 years ago

Is this related to point 1 in issue #258?

spco commented 6 years ago

Yep. I think the current logic is the following in pseudo Fortran:

Read from environmentVariables.config:

select case(JFAC)
  case NOTUSED, set JFAC=1
  case CONSTRAINED, set JFAC directly from `environmentConstraints/JFAC`
  case CONSTANT, set JFAC to that constant
  case CALC, read in the JFAC species, and use the constrained date and photolysis factors for that species to calculate JFAC at time t
end case

So, if JFAC is CALC, then the photolysis rates should be set to zero at night, as long as our threshold is actually working. In all other cases, the photolysis rates are unaffected directly by time of day, but obviously a constrained JFAC or constrained photolysis rate may assert a dependence on time.

rs028 commented 6 years ago

I am wondering if this could be a bug. In principle, you would like a consistent behaviour with the various settings. If during nighttime (that is when SZA is above a given threshold) the photolysis rates go to zero, they should go to zero always, not only when JFAC is calculated. A few points:

  1. Should this depend on the settings of JFAC or on the settings of the photolysis rates? The two settings are related but they can have a number of permutations. My feeling is that this should depend on the photolysis rates, regardless of what JFAC does.

  2. The point of setting photolysis rates to zero (or extremely low value) is to eliminate the possibility of numerical artifacts during the night, when we assume that, without the Sun, these reactions cannot happen. So:

    • If the photolysis rates are calculated, does the algorithm set them to zero?
    • If they are constrained (all or just some of them), should the model override the constraints during the night? (the rationale being that any measurement in that period could be simply noise from the instrument).
    • If the photolysis rates are constant then they should never go to zero (obviously).
  3. Also, JFAC calculation currently does not work very well so it can't be relied upon to do other calculations.

  4. Keep in mind that what happens at sunrise and sunset is always critical because that's when the chemistry changes fast and mathematically it becomes more difficult. Therefore the transition to zero must be dealt with carefully.

It seems to me that the bottom line of this discussion is that issues in #16, #258, #272, #276 are all related and should be addressed all together. This probably warrant a bit of redesign (and better documentation) of how photolysis is treated in the model. what do you think?

BTW: I think that cosx is actually cos(SZA) so the threshold is arccosine(1e-30).

rs028 commented 6 years ago

I optionally add this to the milestone for version 1.1 because it completes the work on the photolysis rates (except for issue #16), but I am happy to have the new release without this.

spco commented 6 years ago

I'd recommend we push this back to v2, as it's a fair bit of work g I don't think we understand what the right thing to do is?