Skip to content

Commit

Permalink
Clamp in ZonalWind to [0, 1] for sqrt (#649)
Browse files Browse the repository at this point in the history
* clamp in ZonalWind to [0, 1] for sqrt

* update changelog

* Test initialize + time step for uncommon resolutions
  • Loading branch information
milankl authored Jan 6, 2025
1 parent 9302240 commit 7dadb87
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## Unreleased

- Bug: ZonalWind had sqrt of negative for uncommon resolutions [#649](https://github.com/SpeedyWeather/SpeedyWeather.jl/pull/649)
- Spectral Gradients are now differentiable, with correctness check in extended CI [#638](https://github.com/SpeedyWeather/SpeedyWeather.jl/pull/638)
- Tracer advection [#579](https://github.com/SpeedyWeather/SpeedyWeather.jl/pull/579)
- Buildkite CI with dummy pipeline [#646](https://github.com/SpeedyWeather/SpeedyWeather.jl/pull/646)
Expand Down
2 changes: 1 addition & 1 deletion src/dynamics/initial_conditions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ function initialize!( progn::PrognosticVariables{NF},
R = radius*perturb_radius # spatial extent of perturbation

# great circle distance to perturbation
X = sinφc*sinφ + cosφc*cosφ*cosd(λij-λc)
X = clamp(sinφc*sinφ + cosφc*cosφ*cosd(λij-λc), 0, 1)
X_norm = 1/sqrt(1-X^2)
r = radius*acos(X)
exp_decay = exp(-(r/R)^2)
Expand Down
9 changes: 9 additions & 0 deletions test/resolutions.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
@testset "Single time step at uncommon resolutions" begin
@testset for trunc in rand(15:200, 10)
spectral_grid = SpectralGrid(; trunc, Grid=FullClenshawGrid)
model = PrimitiveWetModel(spectral_grid)
simulation = initialize!(model)
run!(simulation, period=Day(0))
@test simulation.model.feedback.nars_detected == false
end
end
1 change: 1 addition & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ include("random_process.jl")
include("stochastic_physics.jl")

# INITIALIZATION AND INTEGRATION
include("resolutions.jl")
include("run_speedy.jl")

# EXTENSION
Expand Down

0 comments on commit 7dadb87

Please sign in to comment.