Skip to content

Commit 56d1d7a

Browse files
committed
Added aimd_static examples. May not be complete...
1 parent 12e8ff7 commit 56d1d7a

File tree

7 files changed

+223
-0
lines changed

7 files changed

+223
-0
lines changed

examples/aimd_static/cfg_0_10.yaml

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
e_frame: 1.75
2+
rootname: sys_0_10_xcorr_0_10
3+
sigma: 0.02
4+
states_fn: sys_0_10.txt
5+
t1: [0.0, 3.0, 6.0, 9.0, 12.0, 15.0, 18.0, 21.0, 24.0, 27.0, 30.0, 33.0, 36.0, 39.0,
6+
42.0, 45.0, 48.0, 51.0, 54.0, 57.0, 60.0, 63.0, 66.0, 69.0, 72.0, 75.0, 78.0, 81.0,
7+
84.0, 87.0, 90.0, 93.0, 96.0, 99.0, 102.0, 105.0, 108.0, 111.0, 114.0, 117.0, 120.0,
8+
123.0, 126.0, 129.0, 132.0, 135.0, 138.0, 141.0, 144.0, 147.0, 150.0, 153.0, 156.0,
9+
159.0, 162.0, 165.0, 168.0, 171.0, 174.0, 177.0, 180.0, 183.0, 186.0, 189.0, 192.0,
10+
195.0, 198.0, 201.0, 204.0, 207.0, 210.0, 213.0, 216.0, 219.0, 222.0, 225.0, 228.0,
11+
231.0, 234.0, 237.0, 240.0, 243.0, 246.0, 249.0, 252.0, 255.0, 258.0, 261.0, 264.0,
12+
267.0, 270.0, 273.0, 276.0, 279.0, 282.0, 285.0, 288.0, 291.0, 294.0, 297.0, 300.0,
13+
303.0, 306.0, 309.0, 312.0, 315.0, 318.0, 321.0, 324.0, 327.0, 330.0, 333.0, 336.0,
14+
339.0, 342.0, 345.0, 348.0, 351.0, 354.0, 357.0, 360.0, 363.0, 366.0, 369.0, 372.0,
15+
375.0, 378.0, 381.0, 384.0, 387.0, 390.0, 393.0, 396.0, 399.0, 402.0]
16+
t2: [0.0, 3.0, 6.0, 9.0, 12.0, 15.0, 18.0, 21.0, 24.0, 27.0, 30.0, 33.0, 36.0, 39.0,
17+
42.0, 45.0, 48.0, 51.0, 54.0, 57.0, 60.0, 63.0, 66.0, 69.0, 72.0, 75.0, 78.0, 81.0,
18+
84.0, 87.0, 90.0, 93.0, 96.0, 99.0, 102.0, 105.0, 108.0, 111.0, 114.0, 117.0, 120.0,
19+
123.0, 126.0, 129.0, 132.0, 135.0, 138.0, 141.0, 144.0, 147.0, 150.0, 153.0, 156.0,
20+
159.0, 162.0, 165.0, 168.0, 171.0, 174.0, 177.0, 180.0, 183.0, 186.0, 189.0, 192.0,
21+
195.0, 198.0, 201.0, 204.0, 207.0, 210.0, 213.0, 216.0, 219.0, 222.0, 225.0, 228.0,
22+
231.0, 234.0, 237.0, 240.0, 243.0, 246.0, 249.0, 252.0, 255.0, 258.0, 261.0, 264.0,
23+
267.0, 270.0, 273.0, 276.0, 279.0, 282.0, 285.0, 288.0, 291.0, 294.0, 297.0, 300.0,
24+
303.0, 306.0, 309.0, 312.0, 315.0, 318.0, 321.0, 324.0, 327.0, 330.0, 333.0, 336.0,
25+
339.0, 342.0, 345.0, 348.0, 351.0, 354.0, 357.0, 360.0, 363.0, 366.0, 369.0, 372.0,
26+
375.0, 378.0, 381.0, 384.0, 387.0, 390.0, 393.0, 396.0, 399.0]
27+
t3: [0.0, 3.0, 6.0, 9.0, 12.0, 15.0, 18.0, 21.0, 24.0, 27.0, 30.0, 33.0, 36.0, 39.0,
28+
42.0, 45.0, 48.0, 51.0, 54.0, 57.0, 60.0, 63.0, 66.0, 69.0, 72.0, 75.0, 78.0, 81.0,
29+
84.0, 87.0, 90.0, 93.0, 96.0, 99.0, 102.0, 105.0, 108.0, 111.0, 114.0, 117.0, 120.0,
30+
123.0, 126.0, 129.0, 132.0, 135.0, 138.0, 141.0, 144.0, 147.0, 150.0, 153.0, 156.0,
31+
159.0, 162.0, 165.0, 168.0, 171.0, 174.0, 177.0, 180.0, 183.0, 186.0, 189.0, 192.0,
32+
195.0, 198.0, 201.0, 204.0, 207.0, 210.0, 213.0, 216.0, 219.0, 222.0, 225.0, 228.0,
33+
231.0, 234.0, 237.0, 240.0, 243.0, 246.0, 249.0, 252.0, 255.0, 258.0, 261.0, 264.0,
34+
267.0, 270.0, 273.0, 276.0, 279.0, 282.0, 285.0, 288.0, 291.0, 294.0, 297.0, 300.0,
35+
303.0, 306.0, 309.0, 312.0, 315.0, 318.0, 321.0, 324.0, 327.0, 330.0, 333.0, 336.0,
36+
339.0, 342.0, 345.0, 348.0, 351.0, 354.0, 357.0, 360.0, 363.0, 366.0, 369.0, 372.0,
37+
375.0, 378.0, 381.0, 384.0, 387.0, 390.0, 393.0, 396.0, 399.0, 402.0]
38+
xcorr_fn: xcorr_0_10.txt
+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Set-PSDebug -Trace 1
2+
$cfg=$args[0]
3+
$root=$(Select-String -Path $cfg -Pattern '^rootname:\W*(.*)$').Matches.Groups[1].value
4+
julia .\third_order_xc.jl $cfg
5+
ls ${root}_r[nr].bin | %{julia .\spec_ft.jl $cfg $_ $_.Name.Replace("_r", "_s")}
6+
ls ${root}_s[nr].bin | %{python .\plot_spec.py $cfg $_}
7+
julia .\spec_abs.jl $cfg $root ${root}_sa.bin
8+
#rm *_[sr][rn].bin
9+
python .\plot_spec.py $cfg ${root}_sa.bin
10+
#python .\beatmap.py $cfg ${root}_sa.bin

examples/aimd_static/spec_abs.jl

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# fourier transform coherences to 2d spectra
2+
# usage: julia spec_ft.jl <config> <out>
3+
4+
import YAML
5+
6+
function run(cfgf, root, outf)
7+
cfg = open(YAML.load, cfgf)
8+
sz = tuple(map(length, cfg["t$i"] for i=1:3)...)
9+
inf_r = root*"_sr.bin"
10+
inf_n = root*"_sn.bin"
11+
in_r = open(inf_r, "r+")
12+
in_n = open(inf_n, "r+")
13+
s_r = Mmap.mmap(in_r, Array{Complex128, 3}, sz)
14+
s_n = Mmap.mmap(in_n, Array{Complex128, 3}, sz)
15+
out = open(outf, "w+")
16+
try
17+
spec_abs = Mmap.mmap(out, Array{Complex128, 3}, sz)
18+
spec_abs[:] = copy(s_n)
19+
spec_abs[2:end,:,:] += flipdim(s_r[2:end,:,:], 1)
20+
finally
21+
close(out)
22+
close(in_r)
23+
close(in_n)
24+
end
25+
end
26+
27+
cfgf, root, outf = ARGS[1:3]
28+
run(cfgf, root, outf)

examples/aimd_static/spec_ft.jl

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# fourier transform coherences to 2d spectra
2+
# usage: julia spec_ft.jl <config> <in> <out>
3+
4+
import YAML
5+
6+
function run(cfgf, infn, outf)
7+
cfg = open(YAML.load, cfgf)
8+
sz = tuple(map(length, cfg["t$i"] for i=1:3)...)
9+
inf = open(infn, "r+")
10+
sig = Mmap.mmap(inf, Array{Complex128, 3}, sz)
11+
sig[1,:,:] *= 0.5
12+
sig[:,:,1] *= 0.5
13+
out = open(outf, "w+")
14+
spec2d = Mmap.mmap(out, Array{Complex128, 3}, sz)
15+
fill!(spec2d, 0)
16+
spec2d[:] = fftshift(ifft(sig, (1,3)), (1,3))
17+
close(out)
18+
sig[1,:,:] *= 2
19+
sig[:,:,1] *= 2
20+
close(inf)
21+
end
22+
23+
cfgf, infn, outf = ARGS[1:3]
24+
run(cfgf, infn, outf)

examples/aimd_static/sys_0_10.txt

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
1.561819839679357891e+00 5.421701363481752356e-01
2+
1.611593186372745734e+00 5.131993707826494333e-01
3+
1.760613226452905300e+00 2.833814072832257502e-01
4+
1.794191783567134602e+00 2.761258042416964154e-01
5+
1.820523647294588709e+00 2.376053379524454001e-01
6+
1.852621442885769687e+00 2.412396021944760716e-01
7+
1.880126653306613438e+00 2.926030893243291020e-01
8+
1.913341082164327744e+00 4.056453378656108000e-01
9+
1.935171943887774360e+00 4.839319692370925852e-01
10+
1.968658517034066469e+00 3.471332581373224313e-01
+103
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
import YAML
2+
using Mbo
3+
using ProgressMeter
4+
5+
tag(i) = @sprintf "X%02d" i
6+
function parse_corr(fn)
7+
readdlm(fn)
8+
end
9+
10+
function run(args)
11+
t0 = now()
12+
cfgf = args[1]
13+
info("Loading parameters from $(cfgf)")
14+
cfg = open(YAML.load, cfgf)
15+
states_fn = cfg["states_fn"]
16+
cf_fn = cfg["xcorr_fn"]
17+
18+
t1 = convert.(Float64, cfg["t1"])
19+
t2 = convert.(Float64, cfg["t2"])
20+
t3 = convert.(Float64, cfg["t3"])
21+
sigma = cfg["sigma"]
22+
23+
info("Loading energies from $states_fn")
24+
states = readdlm(states_fn)
25+
energies = states[:,1]
26+
tdm = states[:,2]
27+
info("States count: $(size(states)[1])")
28+
info("Loading correlation matrix from $cf_fn")
29+
corrm = parse_corr(cf_fn)
30+
info("Correlation count: $(length(corrm))")
31+
32+
# build system
33+
info("Building system...")
34+
t0_sys = now()
35+
s = System("G")
36+
frame = ev2angphz(cfg["e_frame"])
37+
lut_grid = 0.0:1.0:sum(map(maximum, (t1, t2, t3)))
38+
for i=1:size(corrm)[1], j=1:size(corrm)[2]
39+
ti = tag(i)
40+
tj = tag(j)
41+
energy!(s, ti, ev2angphz(energies[i])-frame)
42+
dipole!(s, "G", ti, tdm[i])
43+
dipole!(s, ti, tj, 0)
44+
lineshape!(s, "G", ti, zero)
45+
lineshape!(s, ti, "G", zero)
46+
#if i == j
47+
lut = LineshapeLUT(t->(g_inhomo(t, ev2angphz(corrm[i,j]))
48+
+g_homo(t, ev2angphz(0.005))
49+
+g_inhomo(t, ev2angphz(sigma))), lut_grid)
50+
#else
51+
# we assume perfect correlation along the inhomogeneous coordinate.
52+
# lut = LineshapeLUT(t->(g_inhomo(t, ev2angphz(corrm[i,j]))
53+
# +g_inhomo(t, ev2angphz(sigma))), lut_grid)
54+
#end
55+
lineshape!(s, ti, tj, lut)
56+
end
57+
info(" Took $(now()-t0_sys)")
58+
info("Number of order 1 Hilbert Paths: $(length(collect(hilbert_paths(s, 1))))")
59+
info("Number of order 3 Hilbert Paths: $(length(collect(hilbert_paths(s, 3))))")
60+
61+
grd_lin = TimeGrid(t1)
62+
63+
info("Computing linear responses separately.")
64+
t0_calc = now()
65+
out_root = "$(splitext(basename(states_fn))[1])_$(splitext(basename(cf_fn))[1])"
66+
67+
# compute them separately
68+
totlin = zeros(Complex128, size(grd_lin))
69+
for p in hilbert_paths(s, 1)
70+
rlin = linear(grd_lin, s, p)
71+
totlin += rlin
72+
out_lin = out_root*"_lin_"*join(p.p[2:end-1], "-")*".txt"
73+
info("Saving linear to: $out_lin")
74+
writedlm(out_lin, [grid(grd_lin)[1] real(rlin) imag(rlin)])
75+
end
76+
writedlm(out_root*"_lin_tot.txt", [grid(grd_lin)[1] real(totlin) imag(totlin)])
77+
info(" Took $(now()-t0_calc)")
78+
info("Preparing calculation of third order response")
79+
grd_trd = TimeGrid(t1, t2, t3)
80+
info("Grid size: $(size(grd_trd))")
81+
82+
rr_fn = out_root*"_rr.bin"
83+
rn_fn = out_root*"_rn.bin"
84+
info("Saving rephasing to: $rr_fn")
85+
info("Saving nonrephasing to: $rr_fn")
86+
rr_out = open(rr_fn, "w+")
87+
rn_out = open(rn_fn, "w+")
88+
rr = Mmap.mmap(rr_out, Array{Complex128, 3}, size(grd_trd))
89+
rn = Mmap.mmap(rn_out, Array{Complex128, 3}, size(grd_trd))
90+
pm = Progress(4*length(collect(hilbert_paths(s, 3))))
91+
info("Computing third order response")
92+
t0_third = now()
93+
rr .+= R2(grd_trd, s, pm)
94+
rr .+= R3(grd_trd, s, pm)
95+
rn .+= R1(grd_trd, s, pm)
96+
rn .+= R4(grd_trd, s, pm)
97+
info(" Took $(now()-t0_third)")
98+
close(rr_out)
99+
close(rn_out)
100+
info("Total runtime: $(now()-t0)")
101+
end # run
102+
103+
run(ARGS)

examples/aimd_static/xcorr_0_10.txt

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
4.087452459290188272e-02 3.630889293716435540e-02 3.286830737009410752e-02 3.382167758160792292e-02 3.422752399138342949e-02 2.809560537724520649e-02 3.300191972712920863e-02 2.501988921409759384e-02 2.279167471652290139e-02 2.609973013632716290e-02
2+
3.630889293716435540e-02 3.548786907339005620e-02 2.990804695203031285e-02 2.830750100865434687e-02 2.867135074440373826e-02 2.642927010813047456e-02 3.002235141376016422e-02 2.316426700524965715e-02 2.010527027931844832e-02 2.247395102925969779e-02
3+
3.286830737009410752e-02 2.990804695203031285e-02 3.173017607196557816e-02 2.870322593045149945e-02 2.810510740025148890e-02 2.300875665305159717e-02 2.756556054995471655e-02 2.250985127726257834e-02 2.121887819665617056e-02 2.365889249231832928e-02
4+
3.382167758160792292e-02 2.830750100865434687e-02 2.870322593045149945e-02 3.285563114019410258e-02 3.121266978998517641e-02 2.308462075196793251e-02 2.788389502491780969e-02 2.203627535989740802e-02 2.188458636072978733e-02 2.476908182934962205e-02
5+
3.422752399138342949e-02 2.867135074440373826e-02 2.810510740025148890e-02 3.121266978998517641e-02 3.323494132043854771e-02 2.463587600880751821e-02 2.852101694886700206e-02 2.328042367987211841e-02 2.308167736070790982e-02 2.576519414747168585e-02
6+
2.809560537724520649e-02 2.642927010813047456e-02 2.300875665305159717e-02 2.308462075196793251e-02 2.463587600880751821e-02 2.356163794577150958e-02 2.385205758254578534e-02 1.935496707159090057e-02 1.834417230938027721e-02 1.979222504115265430e-02
7+
3.300191972712920863e-02 3.002235141376016422e-02 2.756556054995471655e-02 2.788389502491780969e-02 2.852101694886700206e-02 2.385205758254578534e-02 2.873707343835913558e-02 2.212929276798631176e-02 2.051240658578280807e-02 2.301343215528761643e-02
8+
2.501988921409759384e-02 2.316426700524965715e-02 2.250985127726257834e-02 2.203627535989740802e-02 2.328042367987211841e-02 1.935496707159090057e-02 2.212929276798631176e-02 2.023299591951278203e-02 2.040160044953351695e-02 2.042871080739329381e-02
9+
2.279167471652290139e-02 2.010527027931844832e-02 2.121887819665617056e-02 2.188458636072978733e-02 2.308167736070790982e-02 1.834417230938027721e-02 2.051240658578280807e-02 2.040160044953351695e-02 2.480529741786694289e-02 2.197884204119718646e-02
10+
2.609973013632716290e-02 2.247395102925969779e-02 2.365889249231832928e-02 2.476908182934962205e-02 2.576519414747168585e-02 1.979222504115265430e-02 2.301343215528761643e-02 2.042871080739329381e-02 2.197884204119718646e-02 2.290775574235751066e-02

0 commit comments

Comments
 (0)