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

Add optional initial temperature guess #128

Merged
merged 3 commits into from
Oct 1, 2022
Merged

Add optional initial temperature guess #128

merged 3 commits into from
Oct 1, 2022

Conversation

charleskawczynski
Copy link
Member

This PR:

  • Adds an optional initial temperature guess
  • Adds appropriate docs
  • Fixes some docs

@tapios, I've added a test that I think may be useful for us to review interactively.

Closes #32.

test/relations.jl Outdated Show resolved Hide resolved
test/relations.jl Outdated Show resolved Hide resolved
Copy link
Contributor

@tapios tapios left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Some comments on tests below.

Would it be difficult to set maxiter by default to 1 is T_guess if given, and to something larger otherwise? If so, we may get away with a reasonable O(0.1 K) convergence tolerance in all cases.

bors bot added a commit that referenced this pull request Sep 27, 2022
132: Add data collection mechanism r=charleskawczynski a=charleskawczynski

One concern we've had recently is whether our tolerance for saturation adjustment is reasonable or not because it's a bit difficult to reason about. If the tolerance is occasionally poor, we could have convergence issues with reasonable inputs and, at the moment, it's a bit difficult to know that since the inputs are not in more intuitive variables like temperature. #128 is an attempt to make sure that we start with a reasonable guess, however, knowing whether this is a good idea or not requires collecting data from a real-world run, and we don't have a clean way to do that at the moment.

This PR adds a module dedicated to collecting data, to help us better understand statistics of some important information:
 - Maximum number of iterations performed
 - Average number of iterations performed
 - Number of converged and non-converged calls (if / when we set `TD.error_on_non_convergence() = false`)

Here's a simple script for running the moist baroclinic wave in ClimaAtmos:

```julia
using Revise; include("examples/hybrid/cli_options.jl");
dict = parsed_args_per_job_id();
parsed_args = dict["sphere_baroclinic_wave_rhoe_equilmoist"];
parsed_args["enable_threading"] = false
import Thermodynamics
import RootSolvers
Thermodynamics.solution_type() = RootSolvers.VerboseSolution()
include("examples/hybrid/driver.jl")
Thermodynamics.DataCollection.print_summary()
```

At the moment, this produces

```julia
julia> Thermodynamics.DataCollection.print_summary()
┌ Info: Thermodynamics saturation_adjustment statistics:
│   max_iter = 1
│   call_counter = 15904225
│   average_max_iter = 6.287637404526156e-8
│   converged_counter = 15904225
└   non_converged_counter = 0
```
Which seems pretty good, however, this is running at coarse resolution, for only 6 days (1152 `step!`s). Runtime was about 4 min, so we can definitely crank things up.

Co-authored-by: Charles Kawczynski <kawczynski.charles@gmail.com>
bors bot added a commit that referenced this pull request Sep 27, 2022
132: Add data collection mechanism r=charleskawczynski a=charleskawczynski

One concern we've had recently is whether our tolerance for saturation adjustment is reasonable or not because it's a bit difficult to reason about. If the tolerance is occasionally poor, we could have convergence issues with reasonable inputs and, at the moment, it's a bit difficult to know that since the inputs are not in more intuitive variables like temperature. #128 is an attempt to make sure that we start with a reasonable guess, however, knowing whether this is a good idea or not requires collecting data from a real-world run, and we don't have a clean way to do that at the moment.

This PR adds a module dedicated to collecting data, to help us better understand statistics of some important information:
 - Maximum number of iterations performed
 - Average number of iterations performed
 - Number of converged and non-converged calls (if / when we set `TD.error_on_non_convergence() = false`)

Here's a simple script for running the moist baroclinic wave in ClimaAtmos:

```julia
using Revise; include("examples/hybrid/cli_options.jl");
dict = parsed_args_per_job_id();
parsed_args = dict["sphere_baroclinic_wave_rhoe_equilmoist"];
parsed_args["enable_threading"] = false
import Thermodynamics
import RootSolvers
Thermodynamics.solution_type() = RootSolvers.VerboseSolution()
include("examples/hybrid/driver.jl")
Thermodynamics.DataCollection.print_summary()
```

At the moment, this produces

```julia
julia> Thermodynamics.DataCollection.print_summary()
┌ Info: Thermodynamics saturation_adjustment statistics:
│   max_iter = 1
│   call_counter = 15904225
│   average_max_iter = 6.287637404526156e-8
│   converged_counter = 15904225
└   non_converged_counter = 0
```
Which seems pretty good, however, this is running at coarse resolution, for only 6 days (1152 `step!`s). Runtime was about 4 min, so we can definitely crank things up.

Co-authored-by: Charles Kawczynski <kawczynski.charles@gmail.com>
bors bot added a commit that referenced this pull request Sep 27, 2022
132: Add data collection mechanism r=charleskawczynski a=charleskawczynski

One concern we've had recently is whether our tolerance for saturation adjustment is reasonable or not because it's a bit difficult to reason about. If the tolerance is occasionally poor, we could have convergence issues with reasonable inputs and, at the moment, it's a bit difficult to know that since the inputs are not in more intuitive variables like temperature. #128 is an attempt to make sure that we start with a reasonable guess, however, knowing whether this is a good idea or not requires collecting data from a real-world run, and we don't have a clean way to do that at the moment.

This PR adds a module dedicated to collecting data, to help us better understand statistics of some important information:
 - Maximum number of iterations performed
 - Average number of iterations performed
 - Number of converged and non-converged calls (if / when we set `TD.error_on_non_convergence() = false`)

Here's a simple script for running the moist baroclinic wave in ClimaAtmos:

```julia
using Revise; include("examples/hybrid/cli_options.jl");
dict = parsed_args_per_job_id();
parsed_args = dict["sphere_baroclinic_wave_rhoe_equilmoist"];
parsed_args["enable_threading"] = false
import Thermodynamics
import RootSolvers
Thermodynamics.solution_type() = RootSolvers.VerboseSolution()
include("examples/hybrid/driver.jl")
Thermodynamics.DataCollection.print_summary()
```

At the moment, this produces

```julia
julia> Thermodynamics.DataCollection.print_summary()
┌ Info: Thermodynamics saturation_adjustment statistics:
│   max_iter = 1
│   call_counter = 15904225
│   average_max_iter = 6.287637404526156e-8
│   converged_counter = 15904225
└   non_converged_counter = 0
```
Which seems pretty good, however, this is running at coarse resolution, for only 6 days (1152 `step!`s). Runtime was about 4 min, so we can definitely crank things up.

Co-authored-by: Charles Kawczynski <kawczynski.charles@gmail.com>
bors bot added a commit that referenced this pull request Sep 27, 2022
132: Add data collection mechanism r=charleskawczynski a=charleskawczynski

One concern we've had recently is whether our tolerance for saturation adjustment is reasonable or not because it's a bit difficult to reason about. If the tolerance is occasionally poor, we could have convergence issues with reasonable inputs and, at the moment, it's a bit difficult to know that since the inputs are not in more intuitive variables like temperature. #128 is an attempt to make sure that we start with a reasonable guess, however, knowing whether this is a good idea or not requires collecting data from a real-world run, and we don't have a clean way to do that at the moment.

This PR adds a module dedicated to collecting data, to help us better understand statistics of some important information:
 - Maximum number of iterations performed
 - Average number of iterations performed
 - Number of converged and non-converged calls (if / when we set `TD.error_on_non_convergence() = false`)

Here's a simple script for running the moist baroclinic wave in ClimaAtmos:

```julia
using Revise; include("examples/hybrid/cli_options.jl");
dict = parsed_args_per_job_id();
parsed_args = dict["sphere_baroclinic_wave_rhoe_equilmoist"];
parsed_args["enable_threading"] = false
import Thermodynamics
import RootSolvers
Thermodynamics.solution_type() = RootSolvers.VerboseSolution()
include("examples/hybrid/driver.jl")
Thermodynamics.DataCollection.print_summary()
```

At the moment, this produces

```julia
julia> Thermodynamics.DataCollection.print_summary()
┌ Info: Thermodynamics saturation_adjustment statistics:
│   max_iter = 1
│   call_counter = 15904225
│   average_max_iter = 6.287637404526156e-8
│   converged_counter = 15904225
└   non_converged_counter = 0
```
Which seems pretty good, however, this is running at coarse resolution, for only 6 days (1152 `step!`s). Runtime was about 4 min, so we can definitely crank things up.

Co-authored-by: Charles Kawczynski <kawczynski.charles@gmail.com>
@charleskawczynski
Copy link
Member Author

bors r+

bors bot added a commit that referenced this pull request Sep 28, 2022
128: Add optional initial temperature guess r=charleskawczynski a=charleskawczynski

This PR:
 - Adds an optional initial temperature guess
 - Adds appropriate docs
 - Fixes some docs

`@tapios,` I've added a test that I think may be useful for us to review interactively.

Closes #32.

Co-authored-by: Charles Kawczynski <kawczynski.charles@gmail.com>
@bors
Copy link
Contributor

bors bot commented Sep 28, 2022

Build failed:

WIP

Revert tolerance change

Exercise T_guess in test suite
@codecov
Copy link

codecov bot commented Oct 1, 2022

Codecov Report

Base: 93.63% // Head: 93.10% // Decreases project coverage by -0.52% ⚠️

Coverage data is based on head (28c0ff0) compared to base (4973ca2).
Patch coverage: 66.66% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #128      +/-   ##
==========================================
- Coverage   93.63%   93.10%   -0.53%     
==========================================
  Files           9        9              
  Lines        1053     1074      +21     
==========================================
+ Hits          986     1000      +14     
- Misses         67       74       +7     
Impacted Files Coverage Δ
src/states.jl 94.48% <ø> (ø)
src/config_numerical_method.jl 60.78% <63.15%> (+0.31%) ⬆️
src/relations.jl 96.15% <80.00%> (-0.13%) ⬇️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@charleskawczynski
Copy link
Member Author

bors r+

@bors bors bot merged commit e549ef2 into main Oct 1, 2022
@bors bors bot deleted the ck/T_guess branch October 1, 2022 18:14
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.

Add option to pass T_initial_guess to PhaseEquil
2 participants