Browse Source

Add scripts for c scan with k_range

master
Jean-Sébastien 2 years ago
parent
commit
9276bc8008

+ 87
- 0
scripts/build_LiebLin_c_scan_k_range.sh View File

@@ -0,0 +1,87 @@
1
+#! /bin/zsh
2
+
3
+# For given N (L), this
4
+# computes the required DSF (up to required sumrule)
5
+# over a range of values of c_int.
6
+
7
+if [[ $# -ne 5 ]]; then
8
+    echo "Arguments needed: whichDSF, kBT, target_sumrule, N, nkmax (max momentum in units of kF/4)."
9
+    exit 1
10
+fi
11
+
12
+if [[ $1 != 'd' && $1 != 'g' && $1 != 'o' ]]; then
13
+    echo "Only the d, g and o scanning options are implemented."
14
+    exit 1
15
+fi
16
+
17
+if [[ $2 -lt 0 ]]; then
18
+    echo "Temperature kBT must be > 0."
19
+    exit 1
20
+fi
21
+
22
+if [[ $3 -lt 0 || $3 -gt 1 ]]; then
23
+    echo "Requirement: 0 < target_sumrule < 1."
24
+    exit 1
25
+fi
26
+
27
+if [[ $4 -lt 0 ]]; then
28
+    echo "N must be > 0."
29
+    exit 1
30
+fi
31
+
32
+if [[ $5 -lt 0 ]]; then
33
+    echo "nkmax must be > 0."
34
+    exit 1
35
+fi
36
+
37
+
38
+whichDSF=$1
39
+kBT=$2
40
+target_sumrule=$3
41
+N=$4
42
+nkmax=$5
43
+
44
+correlator='rho-rho'
45
+if [[ $whichDSF == 'o' ]]; then
46
+    correlator='psidag-psi'
47
+elif [[ $whichDSF == 'g' ]]; then
48
+    correlator='psi-psidag'
49
+fi
50
+
51
+iKmax=$(($nkmax * $N/8))
52
+
53
+Max_Secs=3600
54
+refine=0
55
+
56
+#clist=(1024 512 256 128 64 32 16 8 4 2 1 0.5 0.25 0.125 0.0625 0.03125 0.015625)
57
+
58
+# List of interactions: fractional powers of 2
59
+clist_raw=()
60
+for nc in {-128..128}
61
+do
62
+    clist_raw=($clist_raw $(( 4 * 2**($nc/16.) )))
63
+done
64
+# Now cast the integer values to true integers
65
+zmodload zsh/mathfunc
66
+clist=()
67
+for c in $clist_raw
68
+do
69
+    if [[ $((floor($c))) == $((ceil($c))) ]]; then
70
+	clist=($clist $((int($c))))
71
+    else
72
+	clist=($clist $c)
73
+    fi
74
+done
75
+
76
+basedir="$(pwd)"
77
+
78
+for c in $clist
79
+do
80
+    echo '** Starting run for c =' $c', N = '$N
81
+    dir='Lieb-Liniger/'$correlator'/T_'$kBT'/c_scan/k_range/k_0_to_'${(l:2::0:)nkmax}'kFo4/sr_'$target_sumrule'/store/data/N_'$N'/c_'$c
82
+    mkdir -p $dir
83
+    cd $dir
84
+    LiebLin_DSF $whichDSF $c $N $N 0 $iKmax $kBT $Max_Secs $target_sumrule $refine
85
+    cd $basedir
86
+    echo ' Successfully computed DSFs for c =' $c', N = '$N'.\n'
87
+done

+ 92
- 0
scripts/build_LiebLin_c_scan_k_range_dsfs.sh View File

@@ -0,0 +1,92 @@
1
+#! /bin/zsh
2
+
3
+# For given N (L) this
4
+# computes the smoothened dsfs for a `build_LiebLin_c_scan_k_range` run.
5
+
6
+if [[ $# -ne 6 ]]; then
7
+    echo "Arguments needed: whichDSF, kBT, target_sumrule, N, nkmax (max momentum in units of kF/4), width."
8
+    exit 1
9
+fi
10
+
11
+if [[ $1 != 'd' && $1 != 'g' && $1 != 'o' ]]; then
12
+    echo "Only the d, g and o scanning options are implemented."
13
+    exit 1
14
+fi
15
+
16
+if [[ $2 -lt 0 ]]; then
17
+    echo "Temperature kBT must be > 0."
18
+    exit 1
19
+fi
20
+
21
+if [[ $3 -lt 0 || $3 -gt 1 ]]; then
22
+    echo "Requirement: 0 < target_sumrule < 1."
23
+    exit 1
24
+fi
25
+
26
+if [[ $4 -lt 0 ]]; then
27
+    echo "N must be > 0."
28
+    exit 1
29
+fi
30
+
31
+if [[ $5 -lt 0 ]]; then
32
+    echo "nkmax must be > 0."
33
+    exit 1
34
+fi
35
+
36
+if [[ $6 -lt 0 ]]; then
37
+    echo "width must be > 0."
38
+    exit 1
39
+fi
40
+
41
+
42
+whichDSF=$1
43
+kBT=$2
44
+target_sumrule=$3
45
+N=$4
46
+nkmax=$5
47
+width=$6
48
+
49
+correlator='rho-rho'
50
+if [[ $whichDSF == 'o' ]]; then
51
+    correlator='psidag-psi'
52
+elif [[ $whichDSF == 'g' ]]; then
53
+    correlator='psi-psidag'
54
+fi
55
+
56
+iKmax=$(($nkmax * $N/8))
57
+
58
+ommin=0
59
+ommax=$(($nkmax*($nkmax - 8))) # use lower branch of 1ph continuum
60
+Nom=1000
61
+
62
+#clist=(1024 512 256 128 64 32 16 8 4 2 1 0.5 0.25 0.125 0.0625 0.03125 0.015625)
63
+
64
+# List of interactions: fractional powers of 2
65
+clist_raw=()
66
+for nc in {-128..128}
67
+do
68
+    clist_raw=($clist_raw $(( 4 * 2**($nc/16.) )))
69
+done
70
+# Now cast the integer values to true integers
71
+zmodload zsh/mathfunc
72
+clist=()
73
+for c in $clist_raw
74
+do
75
+    if [[ $((floor($c))) == $((ceil($c))) ]]; then
76
+	clist=($clist $((int($c))))
77
+    else
78
+	clist=($clist $c)
79
+    fi
80
+done
81
+
82
+basedir="$(pwd)"
83
+
84
+for c in $clist
85
+do
86
+    echo '** Starting computation of DSFs for c =' $c', N = '$N
87
+    dir='Lieb-Liniger/'$correlator'/T_'$kBT'/c_scan/k_range/k_0_to_'${(l:2::0:)nkmax}'kFo4/sr_'$target_sumrule'/store/data/N_'$N'/c_'$c
88
+    cd $dir
89
+    Smoothen_LiebLin_DSF_Scaled $whichDSF $c $N $N 0 $iKmax $kBT 0 $ommin $ommax $Nom $width
90
+    cd $basedir
91
+    echo ' Successfully computed DSFs for c =' $c', N = '$N'.\n'
92
+done

+ 90
- 0
scripts/build_LiebLin_c_scan_k_range_dsfs_plot.sh View File

@@ -0,0 +1,90 @@
1
+#! /bin/zsh
2
+
3
+# For given N (L) this
4
+# produces an interactive (tunable c_int) plot for S(k, \omega)
5
+# from data produced from `build_LiebLin_c_scan_k_range[_dsfs]` scripts.
6
+
7
+if [[ $# -ne 6 ]]; then
8
+    echo "Arguments needed: whichDSF, kBT, target_sumrule, N, nkmax (max momentum in units of kF/4), width."
9
+    exit 1
10
+fi
11
+
12
+if [[ $1 != 'd' && $1 != 'g' && $1 != 'o' ]]; then
13
+    echo "Only the d, g and o scanning options are implemented."
14
+    exit 1
15
+fi
16
+
17
+if [[ $2 -lt 0 ]]; then
18
+    echo "Temperature kBT must be > 0."
19
+    exit 1
20
+fi
21
+
22
+if [[ $3 -lt 0 || $3 -gt 1 ]]; then
23
+    echo "Requirement: 0 < target_sumrule < 1."
24
+    exit 1
25
+fi
26
+
27
+if [[ $4 -lt 0 ]]; then
28
+    echo "N must be > 0."
29
+    exit 1
30
+fi
31
+
32
+if [[ $5 -lt 0 ]]; then
33
+    echo "nkmax must be > 0."
34
+    exit 1
35
+fi
36
+
37
+if [[ $6 -lt 0 ]]; then
38
+    echo "width must be > 0."
39
+    exit 1
40
+fi
41
+
42
+
43
+whichDSF=$1
44
+kBT=$2
45
+target_sumrule=$3
46
+N=$4
47
+nkmax=$5
48
+width=$6
49
+
50
+correlator='rho-rho'
51
+if [[ $whichDSF == 'o' ]]; then
52
+    correlator='psidag-psi'
53
+elif [[ $whichDSF == 'g' ]]; then
54
+    correlator='psi-psidag'
55
+fi
56
+
57
+iKmax=$(($nkmax * $N/8))
58
+
59
+Max_Secs=3600
60
+refine=0
61
+
62
+#clist=(1024 512 256 128 64 32 16 8 4 2 1 0.5 0.25 0.125 0.0625 0.03125 0.015625)
63
+
64
+# List of interactions: fractional powers of 2
65
+clist_raw=()
66
+for nc in {-128..128}
67
+do
68
+    clist_raw=($clist_raw $(( 4 * 2**($nc/16.) )))
69
+done
70
+# Now cast the integer values to true integers
71
+zmodload zsh/mathfunc
72
+clist=()
73
+for c in $clist_raw
74
+do
75
+    if [[ $((floor($c))) == $((ceil($c))) ]]; then
76
+	clist=($clist $((int($c))))
77
+    else
78
+	clist=($clist $c)
79
+    fi
80
+done
81
+
82
+basedir="$(pwd)"
83
+
84
+echo '** Starting run for N = '$N
85
+dir='Lieb-Liniger/'$correlator'/T_'$kBT'/c_scan/k_range/k_0_to_'${(l:2::0:)nkmax}'kFo4/sr_'$target_sumrule'/store/plots'
86
+mkdir -p $dir
87
+cd $dir
88
+plot_c_scan_k_range_dsfs.py $N $width
89
+cd $basedir
90
+echo ' Successfully computed DSFs for N = '$N'.\n'

+ 0
- 1
scripts/plot_c_scan_k_fixed_dsfs.py View File

@@ -53,7 +53,6 @@ fig, ax = plt.subplots()
53 53
 ax.set_xlim(omega[0], omega[-1])
54 54
 # To determine the y axis limits, we look at the lowest value of c (sharpest peak)
55 55
 dsfsmax = max(dsfs[str(clist[0])])
56
-print('dsfsmax = ', dsfsmax)
57 56
 
58 57
 ymax = 1.01 * dsfsmax
59 58
 ymax=4

+ 83
- 0
scripts/plot_c_scan_k_range_dsfs.py View File

@@ -0,0 +1,83 @@
1
+#! /usr/bin/env python
2
+
3
+"""
4
+Plot DSF.
5
+
6
+Usage: python plot_dsf_k_range.py [omega file] [dsf file]
7
+"""
8
+
9
+import glob
10
+import matplotlib.pyplot as plt
11
+import matplotlib.animation as animation
12
+import numpy as np
13
+import os
14
+import sys
15
+
16
+N = str(sys.argv[1])
17
+width = str(sys.argv[2])
18
+
19
+
20
+# Get the list of interactions which have been computed
21
+dirlist = os.listdir('../data/N_%s' % N)
22
+clist = sorted([float(c.lstrip('c_')) for c in dirlist])
23
+
24
+# Get the K file
25
+kfile = glob.glob('../data/N_%s/c_%s*/K_*' % (N, str(clist[0]).rstrip('.0')[:12]))[0]
26
+k = np.loadtxt(kfile)
27
+
28
+# Get the Omega file
29
+omegafile = glob.glob('../data/N_%s/c_%s*/Omega*' % (N, str(clist[0]).rstrip('.0')[:12]))[0]
30
+omega = np.loadtxt(omegafile)
31
+
32
+# Load all the available dsfs from the data store
33
+dsfs = {}
34
+for c in clist:
35
+    # Do some black magic here: for matching the interaction,
36
+    # first try for exact match, stripping '.0' to treat integer values, e.g. 4.0 into 4
37
+    # and then (if it doesn't work) use only the first 12 characters, plus wildcard, to cover rounding errors
38
+    try:
39
+        dsffile = glob.glob('../data/N_%s/c_%s/*_w_%s.dsfs' % (N, str(c).rstrip('.0'), width))[0]
40
+    except IndexError:
41
+        dsffile = glob.glob('../data/N_%s/c_%s*/*_w_%s.dsfs' % (N, str(c).rstrip('.0')[:12], width))[0]
42
+    dsfs[str(c)] = np.loadtxt(dsffile)
43
+
44
+# Read some useful parameters from (last) file name:
45
+elements = dsffile.rpartition('/')[2].split('_')
46
+L = elements[5]
47
+#N = elements[7]
48
+iKmax = elements[14]
49
+width = elements[22].rpartition('.')[0]
50
+# which leads to
51
+rho = int(N)/int(L)
52
+#kokF = int(iK)*0.5/int(L)
53
+
54
+
55
+fig, ax = plt.subplots()
56
+
57
+# To determine the y axis limits, we look at the lowest value of c (sharpest peak)
58
+dsfsmax = 0.5
59
+
60
+ymax = omega[-1]
61
+xtext = 0.05 * k[-1]
62
+ytext = 0.9 * ymax
63
+
64
+ax.text(xtext, ytext, f'c = {clist[0]:10.6f}', color='white', fontsize='large')
65
+pcm = ax.pcolormesh(k, omega, dsfs[str(clist[0])], vmax=dsfsmax)
66
+fig.colorbar(pcm, ax=ax)
67
+def animate(i):
68
+    ax.clear()
69
+    ax.set_title(f'c scan, rho={rho} (N={N}), w={width}', fontsize='x-large')
70
+    ax.text(xtext, ytext, f'c = {clist[i]:10.6f}', color='white', fontsize='x-large')
71
+    ax.pcolormesh(k, omega, dsfs[str(clist[i])], vmax=dsfsmax)
72
+
73
+ani = animation.FuncAnimation(fig, animate, frames=len(clist), interval=100, repeat=False)
74
+
75
+outfilename = (dsffile.partition('_c_')[0].rpartition('/')[2] + '_c_scan_' +
76
+               dsffile.partition('_c_')[2].partition('_')[2].partition('.dsfs')[0])
77
+
78
+ani.save(outfilename + '.mp4')
79
+
80
+with open(outfilename + '.html', 'w') as file:
81
+    file.write(ani.to_html5_video())
82
+
83
+#plt.show()

Loading…
Cancel
Save