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 ee08458
Show file tree
Hide file tree
Showing 10 changed files with 103 additions and 103 deletions.
26 changes: 13 additions & 13 deletions examples/aimd_full/linear_xcf.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ end
function run(args)
t0 = now()
cfgf = args[1]
info("Loading parameters from $(cfgf)")
@info("Loading parameters from $(cfgf)")
cfg = open(YAML.load, cfgf)
states_fn = cfg["states_fn"]
cf_fn = cfg["cf_fn"]
Expand All @@ -26,17 +26,17 @@ t2 = convert.(Float64, cfg["t2"])
t3 = convert.(Float64, cfg["t3"])
σ = cfg["sigma"]

info("Loading energies from $states_fn")
@info("Loading energies from $states_fn")
states = readdlm(states_fn)
energies = states[:,1]
tdm = states[:,2]
info("States count: $(size(states)[1])")
info("Loading CF from $cf_fn")
@info("States count: $(size(states)[1])")
@info("Loading CF from $cf_fn")
cfs = parse_cf(cf_fn)
info("CF count: $(length(cfs))")
@info("CF count: $(length(cfs))")

# build system
info("Building system...")
@info("Building system...")
t0_sys = now()
s = System("G")
#energy!(s, "G", 0)
Expand All @@ -57,9 +57,9 @@ for (i, j) in keys(cfs)
lut = LineshapeLUT(t->(GriddedCF(cfs[i,j], dt)(t)+g_inhomo(t, ev2angphz(σ))), lut_grid)
lineshape!(s, ti, tj, lut)
end
info(" Took $(now()-t0_sys)")
info("Number of order 1 Hilbert Paths: $(length(collect(hilbert_paths(s, 1))))")
info("Number of order 3 Hilbert Paths: $(length(collect(hilbert_paths(s, 3))))")
@info(" Took $(now()-t0_sys)")
@info("Number of order 1 Hilbert Paths: $(length(collect(hilbert_paths(s, 1))))")
@info("Number of order 3 Hilbert Paths: $(length(collect(hilbert_paths(s, 3))))")

grd_lin = TimeGrid(t1)

Expand All @@ -73,17 +73,17 @@ for p in hilbert_paths(s, 1)
#writedlm(out_root*"_lin_$(p.p[2]).txt", [grid(grd_lin)[1] real(rlin) imag(rlin)])
totlin += rlin
end
info("Saving to $(out_root)_rlin.txt")
@info("Saving to $(out_root)_rlin.txt")
writedlm("$(out_root)_rlin.txt", [grid(grd_lin)[1] real(totlin) imag(totlin)])

totlin[1] *= 0.5
s_lin = fftshift(ifft(totlin))
f_lin = fftshift(fftfreq(size(grd_lin)[1], 1/(grd_lin.times[1][2]-grd_lin.times[1][1])))
info("Saving linear spectrum to $(out_root)_slin.txt")
@info("Saving linear spectrum to $(out_root)_slin.txt")
writedlm("$(out_root)_slin.txt", [f_lin real(s_lin) imag(s_lin)])

info(" Took $(now()-t0_calc)")
info("Total runtime: $(now()-t0)")
@info(" Took $(now()-t0_calc)")
@info("Total runtime: $(now()-t0)")
end # run

run(ARGS)
28 changes: 14 additions & 14 deletions examples/aimd_full/third_order_xcf.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ end
function run(args)
t0 = now()
cfgf = args[1]
info("Loading parameters from $(cfgf)")
@info("Loading parameters from $(cfgf)")
cfg = open(YAML.load, cfgf)
root = cfg["rootname"]
states_fn = cfg["states_fn"]
Expand All @@ -26,17 +26,17 @@ t2 = convert.(Float64, cfg["t2"])
t3 = convert.(Float64, cfg["t3"])
σ = cfg["sigma"]

info("Loading energies from $states_fn")
@info("Loading energies from $states_fn")
states = readdlm(states_fn)
energies = states[:,1]
tdm = states[:,2]
info("States count: $(size(states)[1])")
info("Loading CF from $cf_fn")
@info("States count: $(size(states)[1])")
@info("Loading CF from $cf_fn")
cfs = parse_cf(cf_fn)
info("CF count: $(length(cfs))")
@info("CF count: $(length(cfs))")

# build system
info("Building system...")
@info("Building system...")
t0_sys = now()
s = System("G")
frame = ev2angphz(cfg["e_frame"])
Expand All @@ -53,24 +53,24 @@ for (i, j) in keys(cfs)
lut = LineshapeLUT(t->(GriddedCF(cfs[i,j], 1.0)(t)+g_inhomo(t, ev2angphz(σ))), lut_grid)
lineshape!(s, ti, tj, lut)
end
info(" Took $(now()-t0_sys)")
info("Number of order 1 Hilbert Paths: $(length(collect(hilbert_paths(s, 1))))")
info("Number of order 3 Hilbert Paths: $(length(collect(hilbert_paths(s, 3))))")
@info(" Took $(now()-t0_sys)")
@info("Number of order 1 Hilbert Paths: $(length(collect(hilbert_paths(s, 1))))")
@info("Number of order 3 Hilbert Paths: $(length(collect(hilbert_paths(s, 3))))")

info("Preparing calculation of third order response")
@info("Preparing calculation of third order response")
grd_trd = TimeGrid(t1, t2, t3)
info("Grid size: $(size(grd_trd))")
@info("Grid size: $(size(grd_trd))")

rr_fn = root*"_rr.bin"
rn_fn = root*"_rn.bin"
info("Saving rephasing to: $rr_fn")
info("Saving nonrephasing to: $rr_fn")
@info("Saving rephasing to: $rr_fn")
@info("Saving nonrephasing to: $rr_fn")
rr_out = open(rr_fn, "w+")
rn_out = open(rn_fn, "w+")
rr = Mmap.mmap(rr_out, Array{Complex128, 3}, size(grd_trd))
rn = Mmap.mmap(rn_out, Array{Complex128, 3}, size(grd_trd))
pm = Progress(4*length(collect(hilbert_paths(s, 3))))
info("Computing third order response")
@info("Computing third order response")
t0_third = now()
rr .+= R2(grd_trd, s, pm)
rr .+= R3(grd_trd, s, pm)
Expand Down
26 changes: 13 additions & 13 deletions examples/aimd_static/third_order_xc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ end
function run(args)
t0 = now()
cfgf = args[1]
info("Loading parameters from $(cfgf)")
@info("Loading parameters from $(cfgf)")
cfg = open(YAML.load, cfgf)
states_fn = cfg["states_fn"]
cf_fn = cfg["xcorr_fn"]
Expand All @@ -20,17 +20,17 @@ t2 = convert.(Float64, cfg["t2"])
t3 = convert.(Float64, cfg["t3"])
sigma = cfg["sigma"]

info("Loading energies from $states_fn")
@info("Loading energies from $states_fn")
states = readdlm(states_fn)
energies = states[:,1]
tdm = states[:,2]
info("States count: $(size(states)[1])")
info("Loading correlation matrix from $cf_fn")
@info("States count: $(size(states)[1])")
@info("Loading correlation matrix from $cf_fn")
corrm = parse_corr(cf_fn)
info("Correlation count: $(length(corrm))")
@info("Correlation count: $(length(corrm))")

# build system
info("Building system...")
@info("Building system...")
t0_sys = now()
s = System("G")
frame = ev2angphz(cfg["e_frame"])
Expand All @@ -54,13 +54,13 @@ for i=1:size(corrm)[1], j=1:size(corrm)[2]
#end
lineshape!(s, ti, tj, lut)
end
info(" Took $(now()-t0_sys)")
info("Number of order 1 Hilbert Paths: $(length(collect(hilbert_paths(s, 1))))")
info("Number of order 3 Hilbert Paths: $(length(collect(hilbert_paths(s, 3))))")
@info(" Took $(now()-t0_sys)")
@info("Number of order 1 Hilbert Paths: $(length(collect(hilbert_paths(s, 1))))")
@info("Number of order 3 Hilbert Paths: $(length(collect(hilbert_paths(s, 3))))")

grd_lin = TimeGrid(t1)

info("Computing linear responses separately.")
@info("Computing linear responses separately.")
t0_calc = now()
out_root = "$(splitext(basename(states_fn))[1])_$(splitext(basename(cf_fn))[1])"

Expand All @@ -70,12 +70,12 @@ for p in hilbert_paths(s, 1)
rlin = linear(grd_lin, s, p)
totlin += rlin
out_lin = out_root*"_lin_"*join(p.p[2:end-1], "-")*".txt"
info("Saving linear to: $out_lin")
@info("Saving linear to: $out_lin")
writedlm(out_lin, [grid(grd_lin)[1] real(rlin) imag(rlin)])
end
writedlm(out_root*"_lin_tot.txt", [grid(grd_lin)[1] real(totlin) imag(totlin)])
info(" Took $(now()-t0_calc)")
info("Preparing calculation of third order response")
@info(" Took $(now()-t0_calc)")
@info("Preparing calculation of third order response")
grd_trd = TimeGrid(t1, t2, t3)
info("Grid size: $(size(grd_trd))")

Expand Down
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
8 changes: 4 additions & 4 deletions examples/cohmap_electronic/diamond.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import YAML

function run(args)
cfg_f = args[1]
info("Loading parameters from $cfg_f")
@info("Loading parameters from $cfg_f")
cfg = open(YAML.load, cfg_f)
# load parameters
root = cfg["rootname"]
Expand All @@ -37,7 +37,7 @@ t1_max = cfg["t1_max"]
t2_max = cfg["t2_max"]
t3_max = cfg["t3_max"]

info("Setting up system")
@info("Setting up system")
s = System("g")
energy!(s, "a", ωa)
energy!(s, "b", ωb)
Expand Down Expand Up @@ -66,9 +66,9 @@ tg = TimeGrid(
linspace(0, t3_max, t3_n),
)

info("Computing linear response")
@info("Computing linear response")
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
Expand Down
2 changes: 1 addition & 1 deletion examples/cohmap_vibrational/vibrational_ia.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import YAML

function run(args)
cfg_f = args[1]
info("Loading parameters from $cfg_f")
@info("Loading parameters from $cfg_f")
cfg = open(YAML.load, cfg_f)
# load parameters
root = cfg["rootname"]
Expand Down
22 changes: 11 additions & 11 deletions examples/electronic/ecoh.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import YAML

function run(args)
cfg_f = args[1]
info("Loading parameters from $cfg_f")
@info("Loading parameters from $cfg_f")
cfg = open(YAML.load, cfg_f)
# load parameters
root = cfg["rootname"]
Expand All @@ -28,7 +28,7 @@ t1_max = cfg["t1_max"]
t2_max = cfg["t2_max"]
t3_max = cfg["t3_max"]

info("Setting up system")
@info("Setting up system")
s = System("g")
for tag1 in ["A", "B"], tag2 in ["A", "B"]
energy!(s, tag1, ev2angphz(cfg["e_$(tag1)"]) - ω_frame)
Expand All @@ -45,24 +45,24 @@ tg = TimeGrid(
linspace(0, t3_max, t3_n),
)

info("Computing linear response")
@info("Computing linear response")
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
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)])

info("Computing third order response")
@info("Computing third order response")
tic()
rr = R2(tg, s) + R3(tg, s)
rn = R1(tg, s) + R4(tg, s)
dt = toq()
info("Calulation took $(dt) s")
info("Saving to $(root)_rr.bin, $(root)_rn.bin")
@info("Calulation took $(dt) s")
@info("Saving to $(root)_rr.bin, $(root)_rn.bin")
write("$(root)_rr.bin", rr)
write("$(root)_rn.bin", rn)
rr[1,:,:] *= 0.5
Expand All @@ -79,11 +79,11 @@ else
sa += flipdim(sr, 1)
end

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 # function main
Expand Down
Loading

0 comments on commit ee08458

Please sign in to comment.