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

Clamp in ZonalWind to [0, 1] for sqrt #649

Merged
merged 3 commits into from
Jan 6, 2025
Merged

Clamp in ZonalWind to [0, 1] for sqrt #649

merged 3 commits into from
Jan 6, 2025

Conversation

milankl
Copy link
Member

@milankl milankl commented Jan 6, 2025

@simone-silvestri found a bug

julia> spectral_grid = SpectralGrid(trunc=119, Grid=FullClenshawGrid, dealiasing=2)
SpectralGrid:
├ Spectral:   T119 LowerTriangularMatrix{Complex{Float32}}, radius = 6.371e6 m
├ Grid:       179-ring FullClenshawGrid{Float32}, 64440 grid points
├ Resolution: 89km (average)
├ Vertical:   8-layer SigmaCoordinates
└ Device:     CPU using Array

julia> model = PrimitiveWetModel(spectral_grid)

julia> simulation = initialize!(model)
[ Info: Time step changed from 640000 to 600000 milliseconds (-6%) to match output frequency.
ERROR: DomainError with -2.4943467069604708e-8:
sqrt was called with a negative real argument but will only return a complex result if called with a complex argument. Try sqrt(Complex(x)).
Stacktrace:
 [1] throw_complex_domainerror(f::Symbol, x::Float64)
   @ Base.Math ./math.jl:33
 [2] sqrt
   @ ./math.jl:608 [inlined]
 [3] initialize!(progn::PrognosticVariables{…}, initial_conditions::ZonalWind, model::PrimitiveWetModel{…})
   @ SpeedyWeather ~/.julia/packages/SpeedyWeather/qwHr6/src/dynamics/initial_conditions.jl:293

@milankl milankl added the bug 🐞 Something isn't working label Jan 6, 2025
@milankl milankl merged commit 7dadb87 into main Jan 6, 2025
5 of 6 checks passed
@milankl milankl deleted the mk/zonalwind branch January 8, 2025 00:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐞 Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant