# Difference between revisions of "KPP solvers FAQ"

(→Can I still use SMVGEAR?) |
(→Example: Tightening tolerances for SOA simulations) |
||

(43 intermediate revisions by 2 users not shown) | |||

Line 1: | Line 1: | ||

− | + | == Current KPP documentation == | |

+ | We have migrated our KPP-for-GEOS-Chem documentation to '''https://kpp.readthedocs.io'''. | ||

− | + | --[[User:Bmy|Bob Yantosca]] ([[User talk:Bmy|talk]]) 16:45, 2 March 2021 (UTC) | |

− | + | == How do I choose the absolute and relative tolerance? == | |

− | + | ||

− | + | ||

− | + | ||

− | + | ||

− | + | ||

− | + | ||

− | == | + | |

− | + | The tolerance are set in the <tt>DO_FLEXCHEM</tt> routine (in <tt>flexchem_mod.F90</tt>). GEOS-Chem 13.0.0 uses these default values: | |

− | + | !%%%%% CONVERGENCE CRITERIA %%%%% | |

− | + | ||

− | + | ||

− | + | ||

− | + | ||

− | + | ||

− | + | ! Absolute tolerance | |

− | + | ATOL = 1e-2_dp | |

− | + | ||

− | + | ||

− | + | ||

− | + | ||

− | + | ||

− | + | ||

− | + | ||

− | + | ||

− | + | ||

− | + | ||

− | + | ||

− | + | ||

− | + | ||

− | + | ||

− | + | ||

− | + | ||

− | + | ||

− | = | + | |

− | + | ||

− | + | ||

− | + | ||

− | + | ||

− | + | ||

− | + | ||

− | + | ||

− | + | ||

− | + | ||

− | + | ||

− | + | ||

− | + | ||

− | + | ||

− | + | ||

− | + | ||

− | + | ||

− | + | ||

− | + | ||

− | + | ||

− | + | ||

− | + | ||

− | + | ||

− | + | ||

− | + | ||

− | + | ||

− | + | ||

− | + | ||

− | + | ||

− | + | ||

− | + | ||

− | + | ||

− | + | ||

− | + | ||

− | + | ||

− | + | ! Relative tolerance | |

− | + | IF ( Input_Opt%LUCX ) THEN | |

− | + | ! UCX-based mechanisms | |

− | + | !RTOL = 2e-2_dp | |

− | + | !RTOL = 1e-2_dp | |

− | + | RTOL = 0.5e-2_dp | |

− | + | ELSE | |

− | + | ! Non-UCX mechanisms | |

− | + | RTOL = 1e-2_dp | |

− | + | ENDIF | |

− | + | ||

− | + | ||

− | + | ||

− | + | ||

− | + | For the Rodas-3 Rosenbrock solver, runtime and accuracy of the solution for various set of tolerances are [http://acmg.seas.harvard.edu/geos/word_pdf_docs/rodas3_smvgear_comp.pdf described in this pdf]. | |

− | + | If you switch to Livermore solver (LSODE), you do need to set ATOL between 1d4 and 1d6, to have a performance similar to SMVGEAR. | |

− | = | + | For an accurate solution with Radau5, you need small tolerances: RTOL=1d-8 for example. |

− | + | === Solver convergence issues posted on Github === | |

− | + | See these issues: | |

− | + | #[https://github.com/geoschem/geos-chem/issues/66 geoschem/geos-chem #66] | |

− | + | === Example: Tightening tolerances for SOA simulations === | |

− | + | ||

− | + | ||

− | + | ||

− | + | ||

− | + | ||

− | + | ||

− | + | ||

− | == | + | |

− | + | ||

− | + | ||

− | + | ||

− | + | ||

− | + | ||

− | + | ||

− | + | ||

− | + | ||

− | + | ||

− | + | ||

− | + | ||

− | + | ||

− | + | ||

− | + | ||

− | + | ||

− | + | ||

− | + | ||

− | + | ||

− | + | ||

Here is an instance in which the relative error tolerance <tt>RTOL</tt> had to be tightened when performing a GEOS-Chem simulation with the secondary organic aerosol tracers: | Here is an instance in which the relative error tolerance <tt>RTOL</tt> had to be tightened when performing a GEOS-Chem simulation with the secondary organic aerosol tracers: | ||

− | '''''Amos P.K. Tai | + | '''''Amos P.K. Tai] wrote:''''' |

− | + | <blockquote>I've performed a few 3-month 4x5 GEOS-5 runs with the v8-02-03 KPP solver with two different relative tolerance levels (<tt>RTOL</tt>) in the <tt>GCKPP_DRIVER</tt> subroutine in the <tt>chemistry_mod.f</tt> module. Then I counted the number of times I got the following error:</blockquote> | |

Forced exit from Rosenbrock due to the following error: | Forced exit from Rosenbrock due to the following error: | ||

Line 143: | Line 49: | ||

T= 2690.36541862269 and H= 6.025073049527794E-013 | T= 2690.36541862269 and H= 6.025073049527794E-013 | ||

− | + | <blockquote>When this error occurs once in a row, the run would continue; but if it occurs twice in a row, the run crashes. I counted the number of this error in each of my 3-month runs that went without crashing. | |

− | + | *For RTOL = 2d-1 (recommended), I've done four 3-month runs; the number of error ranges from 92 to 114. | |

− | + | *For RTOL = 5d-2 (reduced), I've done two 3-month runs (otherwise all the same as before); no errors were detected in both runs. | |

− | + | So, reducing the tolerance level, as you have suggested before, appears to solve the problem of KPP solver leading to a crash.</blockquote> | |

--[[User:Bmy|Bob Y.]] 10:22, 10 November 2009 (EST) | --[[User:Bmy|Bob Y.]] 10:22, 10 November 2009 (EST) | ||

− | == | + | === More about tolerances === |

− | + | '''''[mailto:Tao.Zeng@dnr.state.ga.us Tao Zeng] wrote:''''' | |

− | + | ||

− | + | ||

− | + | ||

− | + | <blockquote> | |

− | + | By reducing RTOL from 0.2 to 0.05, you were able to run the model for longer time without errors. | |

− | RTOL. | + | |

− | + | ||

− | + | I tried your method and found it works. But I am quite confused with the setting. To my understanding, we enlarge the tolerance to make it not so strict, it's like to open the door a little wider. But why does it work in the opposite way in the KPP case? | |

− | + | </blockquote> | |

− | + | ||

− | + | '''''Claire Carouge wrote:''''' | |

− | + | <blockquote>I am not sure of what is happening but I think I have an idea. | |

− | + | ||

− | + | ||

− | + | ||

− | + | ||

− | + | ||

− | + | ||

− | + | ||

− | + | ||

− | + | ||

− | + | ||

− | + | ||

− | + | ||

− | + | ||

− | + | ||

− | + | The errors occur because the system arrives to a state too far from the truth to be able to converge. By tightening the tolerances, you make sure the system stays closer to the truth at every time step. Then, the problematic time steps start the chemistry with a system closer to the true state, enabling the chemistry to converge even with a tighter tolerance. | |

− | + | ||

− | + | Typically, if the first time step of chemistry couldn't converge, tightening the tolerances wouldn't work but loosening the tolerance would. Since here it is not the first time step, tightening the tolerances can work by keeping the system errors smaller before.</blockquote> | |

− | + | ||

− | + | ||

− | + | ||

− | --[[User: | + | --[[User:Bmy|Bob Y.]] 10:35, 11 March 2010 (EST) |

## Latest revision as of 16:54, 2 March 2021

## Contents

## Current KPP documentation

We have migrated our KPP-for-GEOS-Chem documentation to **https://kpp.readthedocs.io**.

--Bob Yantosca (talk) 16:45, 2 March 2021 (UTC)

## How do I choose the absolute and relative tolerance?

The tolerance are set in the `DO_FLEXCHEM` routine (in `flexchem_mod.F90`). GEOS-Chem 13.0.0 uses these default values:

!%%%%% CONVERGENCE CRITERIA %%%%% ! Absolute tolerance ATOL = 1e-2_dp ! Relative tolerance IF ( Input_Opt%LUCX ) THEN ! UCX-based mechanisms !RTOL = 2e-2_dp !RTOL = 1e-2_dp RTOL = 0.5e-2_dp ELSE ! Non-UCX mechanisms RTOL = 1e-2_dp ENDIF

For the Rodas-3 Rosenbrock solver, runtime and accuracy of the solution for various set of tolerances are described in this pdf.

If you switch to Livermore solver (LSODE), you do need to set ATOL between 1d4 and 1d6, to have a performance similar to SMVGEAR.

For an accurate solution with Radau5, you need small tolerances: RTOL=1d-8 for example.

### Solver convergence issues posted on Github

See these issues:

### Example: Tightening tolerances for SOA simulations

Here is an instance in which the relative error tolerance `RTOL` had to be tightened when performing a GEOS-Chem simulation with the secondary organic aerosol tracers:

**Amos P.K. Tai] wrote:**

I've performed a few 3-month 4x5 GEOS-5 runs with the v8-02-03 KPP solver with two different relative tolerance levels (RTOL) in theGCKPP_DRIVERsubroutine in thechemistry_mod.fmodule. Then I counted the number of times I got the following error:

Forced exit from Rosenbrock due to the following error: --> Step size too small: T + 10*H = T or H < Roundoff T= 2690.36541862269 and H= 6.025073049527794E-013

When this error occurs once in a row, the run would continue; but if it occurs twice in a row, the run crashes. I counted the number of this error in each of my 3-month runs that went without crashing.So, reducing the tolerance level, as you have suggested before, appears to solve the problem of KPP solver leading to a crash.

- For RTOL = 2d-1 (recommended), I've done four 3-month runs; the number of error ranges from 92 to 114.
- For RTOL = 5d-2 (reduced), I've done two 3-month runs (otherwise all the same as before); no errors were detected in both runs.

--Bob Y. 10:22, 10 November 2009 (EST)

### More about tolerances

**Tao Zeng wrote:**

By reducing RTOL from 0.2 to 0.05, you were able to run the model for longer time without errors.

I tried your method and found it works. But I am quite confused with the setting. To my understanding, we enlarge the tolerance to make it not so strict, it's like to open the door a little wider. But why does it work in the opposite way in the KPP case?

**Claire Carouge wrote:**

I am not sure of what is happening but I think I have an idea.The errors occur because the system arrives to a state too far from the truth to be able to converge. By tightening the tolerances, you make sure the system stays closer to the truth at every time step. Then, the problematic time steps start the chemistry with a system closer to the true state, enabling the chemistry to converge even with a tighter tolerance.

Typically, if the first time step of chemistry couldn't converge, tightening the tolerances wouldn't work but loosening the tolerance would. Since here it is not the first time step, tightening the tolerances can work by keeping the system errors smaller before.

--Bob Y. 10:35, 11 March 2010 (EST)