Skip to content

Commit

Permalink
Set noise so will work on GPU
Browse files Browse the repository at this point in the history
  • Loading branch information
jbisits committed Nov 26, 2024
1 parent e89bc57 commit c503f35
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/set_initial_conditions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -101,15 +101,23 @@ function set_noise!(model, noise::VelocityNoise)
end
"""
function set_noise!(model, noise::TracerNoise)
Add initial noise the `tracer` fields.
Add initial noise the `tracer` fields. The tracer noise is added to the values already in
the tracer `Field`s so if nothing else is set it will just be noise.
"""
function set_noise!(model, noise::TracerNoise)

S, T = model.tracers

S_noise = noise.S_magnitude * randn(size(S))
S_noise_field = similar(S)
set!(S_noise_field, S_noise)

T_noise = noise.T_magnitude * randn(size(T))
S₀ = S + S_noise
T₀ = T + T_noise
T_noise_field = similar(T)
set!(T_noise_field, T_noise)

S₀ = S + S_noise_field
T₀ = T + T_noise_field

set!(model, S = S₀, T = T₀)

Expand Down

0 comments on commit c503f35

Please sign in to comment.