-
Notifications
You must be signed in to change notification settings - Fork 33
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 n (passive) tracers #579
base: main
Are you sure you want to change the base?
Conversation
new syntax is add!(model, Tracer(:ch4)) # before initialize! or
add!(simulation, Tracer(:ch4)) # after tracers are now just identified with their |
Tracers can be added ( julia> simulation.prognostic_variables.tracers
Dict{Symbol, Tuple{LowerTriangularArray{ComplexF32, 2, Matrix{ComplexF32}}, LowerTriangularArray{ComplexF32, 2, Matrix{ComplexF32}}}} with 2 entries:
:ch4 => ([0.0+0.0im; 0.0+0.0im; … ; 0.0+0.0im; 0.0+0.0im;;], [0.0+0.0im; 0.0+0.0im; … ; 0.0+0.0im; 0.0+0.0im;;])
:co2 => ([0.0+0.0im; 0.0+0.0im; … ; 0.0+0.0im; 0.0+0.0im;;], [0.0+0.0im; 0.0+0.0im; … ; 0.0+0.0im; 0.0+0.0im;;]) can be julia> set!(simulation, ch4=1)
julia> simulation.prognostic_variables.tracers
Dict{Symbol, Tuple{LowerTriangularArray{ComplexF32, 2, Matrix{ComplexF32}}, LowerTriangularArray{ComplexF32, 2, Matrix{ComplexF32}}}} with 2 entries:
:ch4 => ([3.54491+0.0im; 0.0+0.0im; … ; 0.0+0.0im; 0.0+0.0im;;], [0.0+0.0im; 0.0+0.0im; … ; 0.0+0.0im; 0.0+0.0im;;])
:co2 => ([0.0+0.0im; 0.0+0.0im; … ; 0.0+0.0im; 0.0+0.0im;;], [0.0+0.0im; 0.0+0.0im; … ; 0.0+0.0im; 0.0+0.0im;;])
julia> set!(simulation, co2=2)
julia> simulation.prognostic_variables.tracers
Dict{Symbol, Tuple{LowerTriangularArray{ComplexF32, 2, Matrix{ComplexF32}}, LowerTriangularArray{ComplexF32, 2, Matrix{ComplexF32}}}} with 2 entries:
:ch4 => ([3.54491+0.0im; 0.0+0.0im; … ; 0.0+0.0im; 0.0+0.0im;;], [0.0+0.0im; 0.0+0.0im; … ; 0.0+0.0im; 0.0+0.0im;;])
:co2 => ([7.08982+0.0im; 0.0+0.0im; … ; 0.0+0.0im; 0.0+0.0im;;], [0.0+0.0im; 0.0+0.0im; … ; 0.0+0.0im; 0.0+0.0im;;]) @maximilian-gelbrecht which I implemented simply by checking whether additional julia> set!(simulation, co3=2)
ERROR: UndefVarError: `co3` not defined Technically we could do the same to avoid all the predefined |
This seems to work! out.mp4done via spectral_grid = SpectralGrid(trunc=63, nlayers=1)
model = ShallowWaterModel(spectral_grid)
# add tracer
add!(model, Tracer(:co2))
add!(model, SpeedyWeather.TracerOutput())
simulation = initialize!(model)
# set tracer and run a simulation
set!(simulation, co2 = (λ, φ, σ) -> 0 < λ < 10 ? 1 : 0)
run!(simulation, period=Day(10))
# reset tracer but continue simulation
set!(simulation, co2 = (λ, φ, σ) -> exp(-(λ-180)^2/10^2))
run!(simulation, period=Day(10), output=true) |
And T170 resolution and 20days long out.mp4 |
fixes #564 by
Tracer
(name, id, active)model.tracers
for a list of tracerslength(model.tracers)
add additional progn/diagn variablesset!
for tracers