Stretching in reverse_mode requires domain boundaries to be <=0
- Dominant language
- Julia
- Stars
- 117
- Forks
- 19
- Avg merge
- 3d 4h
- Merged PRs (30d)
- 41
Description
## Describe the bug
When using "reverse_mode = true" for the [`GeneralizedExponentialStretching`](https://github.com/CliMA/ClimaCore.jl/blob/25942f9d837efff103f0619fc1be188691aac91b/src/Meshes/interval.jl#L175), method of [`IntervalMesh`](https://github.com/CliMA/ClimaCore.jl/blob/25942f9d837efff103f0619fc1be188691aac91b/src/Meshes/interval.jl#L194), the domain boundaries zlim = (zmin, zmax) must satisfy zmin < zmax <=0.
In general this won't be true. It's fine to work with this for the near term as the land model has not implemented topography yet, and this is not needed for AMIP runs, but I wanted to flag the issue. The stretching should be independent of zlim and only depend on zmax-zmin, dz_top, dz_bottom, I think.
## To Reproduce
```
(ClimaLSM) pkg> status ClimaCore
Project ClimaLSM v0.3.1
Status `~/Desktop/code/ClimaLSM.jl/Project.toml`
[d414da3d] ClimaCore v0.10.48
julia> using ClimaCore
julia> zlim = (1.0, 2.0);
julia> domain = ClimaCore.Domains.IntervalDomain(
ClimaCore.Geometry.ZPoint{Float64}(zlim[1]),
ClimaCore.Geometry.ZPoint{Float64}(zlim[2]);
boundary_tags = (:bottom, :top),
);
julia> stretch = ClimaCore.Meshes.GeneralizedExponentialStretching{Float64}(
0.1,
0.01,
);
julia> nelems = 20;
julia> ClimaCore.Meshes.IntervalMesh(domain, stretch; nelems=nelems, reverse_mode=true)
ERROR: h_bottom root failed to converge for dz_bottom: 0.01 on domain (2.0, -1.0)
Stacktrace:
[1] error(s::String)
@ Base ./error.jl:35
[2] ClimaCore.Meshes.IntervalMesh(domain::ClimaCore.Domains.IntervalDomain{ClimaCore.Geometry.ZPoint{Float64}, Tuple{Symbol, Symbol}}, stretch::ClimaCore.Meshes.GeneralizedExponentialStretching{Float64}; nelems::Int64, FT_solve::Type{Float64}, tol::Float64, reverse_mode::Bool)
@ ClimaCore.Meshes ~/.julia/packages/ClimaCore/zZ21b/src/Meshes/interval.jl:250
[3] top-level scope
@ REPL[13]:1
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start in src/Meshes/interval.jl at GeneralizedExponentialStretching and the IntervalMesh constructor around the reverse_mode handling, then reproduce the failure with the positive zlim example in the issue. Determine how the domain range and dz_top/dz_bottom are used; done means reverse_mode works without requiring zmax <= 0 and the relevant mesh tests pass.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- julia
- Domain
- hpc
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100