Browse Source

Add scripts for c_int scan at fixed N, k

master
Jean-Sébastien 2 years ago
parent
commit
9d03fcdd66

+ 0
- 1
ABACUS.org View File

@@ -80,7 +80,6 @@ The `Integral_result_CX Integrate_optimal_using_table` functions are not yet imp
80 80
   :END:
81 81
 
82 82
 
83
-
84 83
 * Planning (long term)				     :ABACUS:Dev:PlanningLT:
85 84
   :PROPERTIES:
86 85
   :ARCHIVE: %s_archive::* Planning (long term)

+ 87
- 0
scripts/build_LiebLin_c_scan_k_fixed.sh View File

@@ -0,0 +1,87 @@
1
+#! /bin/zsh
2
+
3
+# For given N (L) and k_fact (multiple of kF/4), 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, nk (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 "nk must be > 0."
34
+    exit 1
35
+fi
36
+
37
+
38
+whichDSF=$1
39
+kBT=$2
40
+target_sumrule=$3
41
+N=$4
42
+nk=$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
+iK=$(($nk * $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_fixed/k_'${(l:2::0:)nk}'kFo4/sr_'$target_sumrule'/N_'$N'/data/store/c_'$c
82
+    mkdir -p $dir
83
+    cd $dir
84
+    LiebLin_DSF $whichDSF $c $N $N $iK $iK $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_fixed_dsfs.sh View File

@@ -0,0 +1,92 @@
1
+#! /bin/zsh
2
+
3
+# For given N (L) and k_fact (multiple of kF/4), this
4
+# computes the smoothened dsfs for a `build_LiebLin_c_scan_k_fixed` run.
5
+
6
+if [[ $# -ne 6 ]]; then
7
+    echo "Arguments needed: whichDSF, kBT, target_sumrule, N, nk (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 "nk 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
+nk=$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
+iK=$(($nk * $N/8))
57
+
58
+ommin=0
59
+ommax=$(($nk*($nk + 8)))
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_fixed/k_'${(l:2::0:)nk}'kFo4/sr_'$target_sumrule'/N_'$N'/data/store/c_'$c
88
+    cd $dir
89
+    Smoothen_LiebLin_DSF_Scaled $whichDSF $c $N $N $iK $iK $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_fixed_dsfs_plot.sh View File

@@ -0,0 +1,90 @@
1
+#! /bin/zsh
2
+
3
+# For given N (L) and k_fact (multiple of kF/4), this
4
+# produces an interactive (tunable c_int) plot for S(k, \omega)
5
+# from data produced from `build_LiebLin_c_scan_k_fixed[_dsfs]` scripts.
6
+
7
+if [[ $# -ne 6 ]]; then
8
+    echo "Arguments needed: whichDSF, kBT, target_sumrule, N, nk (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 "nk 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
+nk=$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
+iK=$(($nk * $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_fixed/k_'${(l:2::0:)nk}'kFo4/sr_'$target_sumrule'/N_'$N'/data/plots'
86
+mkdir -p $dir
87
+cd $dir
88
+plot_c_scan_k_fixed_dsfs.py $width
89
+cd $basedir
90
+echo ' Successfully computed DSFs for N = '$N'.\n'

+ 70
- 0
scripts/plot_c_scan_k_fixed_dsfs.py View File

@@ -0,0 +1,70 @@
1
+#! /usr/bin/env python
2
+
3
+"""
4
+Plot fixed momentum DSF.
5
+
6
+Usage: python plot_dsf_k_fixed.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
+width = str(sys.argv[1])
17
+
18
+
19
+# Get the list of interactions which have been computed
20
+dirlist = os.listdir('../store/')
21
+clist = sorted([float(c.lstrip('c_')) for c in dirlist])
22
+
23
+# Get the Omega file
24
+omegafile = glob.glob('../store/c_%s*/Omega*' % str(clist[0]).rstrip('.0')[:12])[0]
25
+omega = np.loadtxt(omegafile)
26
+
27
+# Load all the available dsfs from the data store
28
+dsfs = {}
29
+for c in clist:
30
+    # Do some black magic here: for matching the interaction,
31
+    # first try for exact match, stripping '.0' to treat integer values, e.g. 4.0 into 4
32
+    # and then (if it doesn't work) use only the first 12 characters, plus wildcard, to cover rounding errors
33
+    try:
34
+        dsffile = glob.glob('../store/c_%s/*_w_%s.dsfs' % (str(c).rstrip('.0'), width))[0]
35
+    except IndexError:
36
+        dsffile = glob.glob('../store/c_%s*/*_w_%s.dsfs' % (str(c).rstrip('.0')[:12], width))[0]
37
+    dsfs[str(c)] = np.loadtxt(dsffile)
38
+
39
+fig, ax = plt.subplots()
40
+
41
+ax.set_xlim(omega[0], omega[-1])
42
+# To determine the y axis limits, we look at the lowest value of c (sharpest peak)
43
+dsfsmax = max(dsfs[str(clist[0])])
44
+print('dsfsmax = ', dsfsmax)
45
+
46
+ymax = 1.2 * dsfsmax
47
+xtext = 0.6 * omega[-1]
48
+ytext = 1.1 * dsfsmax
49
+
50
+ax.set_ylim([0, ymax])
51
+ax.text(xtext, ytext, f'c = {clist[0]}')
52
+ax.plot(omega, dsfs[str(clist[0])])
53
+def animate(i):
54
+    ax.clear()
55
+    ax.set_xlim(omega[0], omega[-1])
56
+    ax.set_ylim([0, ymax])
57
+    ax.text(xtext, ytext, f'c = {clist[i]:10.6f}')
58
+    ax.plot(omega, dsfs[str(clist[i])])
59
+
60
+ani = animation.FuncAnimation(fig, animate, frames=len(clist), interval=100, repeat=False)
61
+
62
+outfilename = (dsffile.partition('_c_')[0].rpartition('/')[2] + '_c_scan_' +
63
+               dsffile.partition('_c_')[2].partition('_')[2].partition('.dsfs')[0])
64
+
65
+ani.save(outfilename + '.mp4')
66
+
67
+with open(outfilename + '.html', 'w') as file:
68
+    file.write(ani.to_html5_video())
69
+
70
+#plt.show()

+ 8
- 8
src/UTILS/Data_File_Name.cc View File

@@ -42,12 +42,12 @@ namespace ABACUS {
42 42
     else if (whichDSF == 'C') name << "BECoverlap";
43 43
     else ABACUSerror("Option not implemented in Data_File_Name");
44 44
 
45
-    name << "_c_" << c_int << "_L_" << L << "_N_" << N;
45
+    name << "_c_" << setprecision(16) << c_int << "_L_" << L << "_N_" << N;
46 46
     if (defaultScanStatename == "") name << "_" << N << "_0_"; // simulates label of ground state
47 47
     else name << "_" << defaultScanStatename;
48 48
     if (iKmin == iKmax) name << "_iK_" << iKmin;
49 49
     else name << "_iKmin_" << iKmin << "_iKmax_" << iKmax;
50
-    if (kBT > 0.0) name << "_kBT_" << kBT;
50
+    if (kBT > 0.0) name << "_kBT_" << setprecision(16) << kBT;
51 51
     if (whichDSF == 'q') name << "_L2_" << L2;
52 52
 
53 53
     return;
@@ -67,11 +67,11 @@ namespace ABACUS {
67 67
     else if (whichDSF == 'C') name << "BECoverlap";
68 68
     else ABACUSerror("Option not implemented in Data_File_Name");
69 69
 
70
-    name << "_c_" << State.c_int << "_L_" << State.L << "_N_" << State.N;
70
+    name << "_c_" << setprecision(16) << State.c_int << "_L_" << State.L << "_N_" << State.N;
71 71
     if (defaultScanStatename == "") name << "_" << State.label;
72 72
     else name << "_" << defaultScanStatename;
73 73
     if (iKmin == iKmax) name << "_iK_" << iKmin;  else name << "_iKmin_" << iKmin << "_iKmax_" << iKmax;
74
-    if (kBT > 0.0) name << "_kBT_" << kBT;
74
+    if (kBT > 0.0) name << "_kBT_" << setprecision(16) << kBT;
75 75
     if (whichDSF == 'q') name << "_L2_" << RefScanState.L;
76 76
 
77 77
     return;
@@ -97,13 +97,13 @@ namespace ABACUS {
97 97
       ABACUSerror("Option not implemented in Data_File_Name");
98 98
     }
99 99
 
100
-    name << "_D_" << Delta << "_N_" << N << "_M_";
100
+    name << "_D_" << setprecision(16) << Delta << "_N_" << N << "_M_";
101 101
     for (int i = 0; i < int(log10(DP(N/2))) - int(log10(DP(M))); ++i) name << "0";
102 102
     name << M;
103 103
     if (defaultScanStatename == "") name << "_" << M << "_0_"; // simulates label of ground state
104 104
     else name << "_" << defaultScanStatename;
105 105
 
106
-    if (kBT > 0.0) name << "_kBT_" << kBT;
106
+    if (kBT > 0.0) name << "_kBT_" << setprecision(16) << kBT;
107 107
     if (whichDSF == 'q') name << "_N2_" << N2;
108 108
 
109 109
     return;
@@ -126,12 +126,12 @@ namespace ABACUS {
126 126
       ABACUSerror("Option not implemented in Data_File_Name");
127 127
     }
128 128
 
129
-    name << "_D_" << State.chain.Delta << "_N_" << State.chain.Nsites << "_M_";
129
+    name << "_D_" << setprecision(16) << State.chain.Delta << "_N_" << State.chain.Nsites << "_M_";
130 130
     for (int i = 0; i < int(log10(DP(State.chain.Nsites/2))) - int(log10(DP(State.base.Mdown))); ++i) name << "0";
131 131
     name << State.base.Mdown;
132 132
     if (defaultScanStatename == "") name << "_" << State.label;
133 133
     else name << "_" << defaultScanStatename;
134
-    if (kBT > 0.0) name << "_kBT_" << kBT;
134
+    if (kBT > 0.0) name << "_kBT_" << setprecision(16) << kBT;
135 135
     if (whichDSF == 'q') name << "_N2_" << RefScanState.chain.Nsites;
136 136
 
137 137
     return;

Loading…
Cancel
Save