Skip to content

Commit

Permalink
Update basic.jl to julia 1.10
Browse files Browse the repository at this point in the history
- info replaced by @info
JuliaLang/julia#24490

-linspace has been deprecated in favor of range with stop and length
keyword arguments (#25896).
JuliaLang/julia#25896
  • Loading branch information
Bachibouzouk committed Jul 22, 2024
1 parent 82f9086 commit 6bf840c
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions examples/basic/basic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import YAML # import <module> requires adding the module name, ie: `YAML.load`
function run(args)
# Use a main 'run' function. This is not mandatory, but is required for performance.
cfg_f = args[1] # index by 1, 1:2 translates to [1, 2], the first two elements
info("Loading parameters from $cfg_f")
@info("Loading parameters from $cfg_f")
cfg = open(YAML.load, cfg_f)
# load parameters
# load parameters
Expand All @@ -27,39 +27,39 @@ t2_max = cfg["t2_max"]
t3_max = cfg["t3_max"]

# setup system
info("Setting up system")
@info("Setting up system")
s = System("g")
energy!(s, "a", ω_a - ω_frame) # use a rotating frame
dipole!(s, "g", "a", 1.0)
lineshape!(s, "a", "a", t->g_homo(t, γ)+g_inhomo(t, σ)) # use an anonymous function for the lineshape

tg = TimeGrid(
linspace(0, t1_max, t1_n),
linspace(0, t2_max, t2_n),
linspace(0, t3_max, t3_n),
range(0, stop=t1_max, length=t1_n), # TODO previously linspace
range(0, stop=t2_max, length=t2_n),
range(0, stop=t3_max, length=t3_n),
)

info("Computing linear response")
@info("Computing linear response")
# compute linear
r_lin = linear(tg, s)
info("Saving to $(root)_rlin.txt")
@info("Saving to $(root)_rlin.txt")
writedlm("$(root)_rlin.txt", [tg.times[1] real(r_lin) imag(r_lin)])

r_lin[1] *= 0.5 # first interval is a half-interval
s_lin = fftshift(ifft(r_lin))
f_lin = fftshift(fftfreq(size(tg)[1], 1/(tg.times[1][2]-tg.times[1][1])))
info("Saving linear spectrum to $(root)_slin.txt")
@info("Saving linear spectrum to $(root)_slin.txt")
writedlm("$(root)_slin.txt", [f_lin real(s_lin) imag(s_lin)])

# compute rephasing and non-rephasing separately: the spectra will overlap if
# a fully rotating frame is used (ω_a == ω_frame)
info("Computing third order response")
@info("Computing third order response")
rr = R2(tg, s) + R3(tg, s)
rn = R1(tg, s) + R4(tg, s)

# save multidimensional data in binary format.
# Julia uses Fortran-contiguous arrays.
info("Saving to $(root)_rr.bin, $(root)_rn.bin")
@info("Saving to $(root)_rr.bin, $(root)_rn.bin")
write("$(root)_rr.bin", rr)
write("$(root)_rn.bin", rn)
# first interval is a half-interval
Expand All @@ -79,11 +79,11 @@ else
sa += flipdim(sr, 1)
end # if-else blocks terminated by 'end'. This is true of all code blocks.

info("Saving rephasing spectrum to $(root)_sr.bin")
@info("Saving rephasing spectrum to $(root)_sr.bin")
write("$(root)_sr.bin", sr)
info("Saving non-rephasing spectrum to $(root)_sn.bin")
@info("Saving non-rephasing spectrum to $(root)_sn.bin")
write("$(root)_sn.bin", sn)
info("Saving absorptive spectrum to $(root)_sa.bin")
@info("Saving absorptive spectrum to $(root)_sa.bin")
write("$(root)_sa.bin", sa)

end # terminating the `function run` code block
Expand Down

0 comments on commit 6bf840c

Please sign in to comment.