Browse Source

Improve scripts for full K catalogue scans

master
Jean-Sébastien 2 years ago
parent
commit
5e22173316

+ 79
- 0
scripts/catalogue/c_fixed_N_prog_data.sh View File

@@ -0,0 +1,79 @@
1
+#! /bin/zsh
2
+
3
+# We use zsh here to support floats (not supported in bash)
4
+
5
+# This script produces a whole stack of subdirectories,
6
+# for a range of values of c centered on 4 with 8 up/down factors of 2,
7
+# and momenta in range from 0 to nkmax * kF/4.
8
+
9
+# For each c, the LiebLin_Catalogue_Fixed_c_Nscaling
10
+# executable is invoked, which computes up to the highest N possible in the allocated time.
11
+
12
+# This script is restartable: a new run will pick up where a previous left off,
13
+# provided the previous run terminated cleanly.
14
+
15
+if [[ $# -ne 5 ]]; then
16
+    echo "Arguments needed: whichDSF, kBT, target_sumrule, nkmax (max momentum in units of kF/4), nr_minutes (for each c value)."
17
+    exit 1
18
+fi
19
+
20
+if [[ $1 != 'd' && $1 != 'g' && $1 != 'o' ]]; then
21
+    echo "Only the d, g and o scanning options are implemented."
22
+    exit 1
23
+fi
24
+
25
+if [[ $2 -lt 0 ]]; then
26
+    echo "Temperature kBT must be > 0."
27
+    exit 1
28
+fi
29
+
30
+if [[ $3 -lt 0 || $3 -gt 1 ]]; then
31
+    echo "Requirement: 0 < target_sumrule < 1."
32
+    exit 1
33
+fi
34
+
35
+if [[ $4 -lt 0 ]]; then
36
+    echo "nkmax must be > 0."
37
+    exit 1
38
+fi
39
+
40
+if [[ $5 -lt 1 ]]; then
41
+    echo "Please give a positive nr_minutes."
42
+    exit 1
43
+fi
44
+
45
+zmodload zsh/datetime
46
+
47
+whichDSF=$1
48
+kBT=$2
49
+target_sumrule=$3
50
+nkmax=$4
51
+nr_minutes=$5
52
+
53
+correlator='rho-rho'
54
+if [[ $whichDSF == 'o' ]]; then
55
+    correlator='psidag-psi'
56
+elif [[ $whichDSF == 'g' ]]; then
57
+    correlator='psi-psidag'
58
+fi
59
+
60
+mkdir -p logs
61
+logfile='logs/c_fixed_N_prog_'$whichDSF'_kBT_'$kBT'_sr_'$target_sumrule'_nkmax_'$nkmax'_nr_minutes_'$nr_minutes'_'$(date '+%Y-%m-%d-%Hh%M')'.log'
62
+touch $logfile
63
+
64
+clist=(0.015625 0.03125 0.0625 0.125 0.25 0.5 1 2 4 8 16 32 64 128 256 512 1024)
65
+
66
+basedir="$(pwd)"
67
+
68
+for c in $clist
69
+do
70
+    echo '** Starting run for c =' $c | tee -a $logfile
71
+    dir='Lieb-Liniger/'$correlator'/T_'$kBT'/c_fixed_N_prog/c_'$c'/k_0_to_'${(l:2::0:)nkmax}'kFo4/sr_'$target_sumrule'/prelim'
72
+    mkdir -p $dir
73
+    cd $dir
74
+    LiebLin_Catalogue_Fixed_c_Nscaling $whichDSF $c $nkmax $kBT $target_sumrule 0 $nr_minutes | tee -a $basedir/$logfile
75
+    cd $basedir
76
+    echo '++ Successfully completed run for c =' $c'.\n' | tee -a $logfile
77
+done
78
+
79
+echo '\n\n++ Successfully completed c_fixed_N_prog_data on '$(date '+%Y-%m-%d-%Hh%M')'.\n' | tee -a $logfile

+ 74
- 0
scripts/catalogue/c_fixed_N_prog_dsfs.sh View File

@@ -0,0 +1,74 @@
1
+#! /bin/zsh
2
+
3
+# We use zsh here to support floats (not supported in bash)
4
+
5
+# This script produces the .dsfs files and figures for the `c_fixed_N_prog` runs
6
+# which achieved the required sumrule saturation.
7
+
8
+if [[ $# -ne 5 ]]; then
9
+    echo "Arguments needed: whichDSF, kBT, target_sumrule, nkmax (max momentum in units of kF/4), width."
10
+    exit 1
11
+fi
12
+
13
+if [[ $1 != 'd' && $1 != 'g' && $1 != 'o' ]]; then
14
+    echo "Only the d, g and o scanning options are implemented."
15
+    exit 1
16
+fi
17
+
18
+if [[ $2 -lt 0 ]]; then
19
+    echo "Temperature kBT must be > 0."
20
+    exit 1
21
+fi
22
+
23
+if [[ $3 -lt 0 || $3 -gt 1 ]]; then
24
+    echo "Requirement: 0 < target_sumrule < 1."
25
+    exit 1
26
+fi
27
+
28
+if [[ $4 -lt 0 ]]; then
29
+    echo "nkmax must be > 0."
30
+    exit 1
31
+fi
32
+
33
+if [[ $5 -lt 0 ]]; then
34
+    echo "width must be > 0."
35
+    exit 1
36
+fi
37
+
38
+whichDSF=$1
39
+kBT=$2
40
+target_sumrule=$3
41
+nkmax=$4
42
+width=$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
+clist=(0.015625 0.03125 0.0625 0.125 0.25 0.5 1 2 4 8 16 32 64 128 256 512 1024)
52
+
53
+basedir="$(pwd)"
54
+
55
+ommin=0
56
+ommax=$(($nkmax*($nkmax - 8))) # use lower branch of 1ph continuum
57
+Nom=1000
58
+
59
+for c in $clist
60
+do
61
+    echo 'Starting computation of DSFs for c =' $c
62
+    dir='Lieb-Liniger/'$correlator'/T_'$kBT'/c_fixed_N_prog/c_'$c'/k_0_to_'${(l:2::0:)nkmax}'kFo4/sr_'$target_sumrule'/store/data'
63
+    cd $dir
64
+    for datadir in *
65
+    do
66
+	cd $datadir
67
+	N=${datadir#"N_"}
68
+	iKmax=$(($nkmax * $N/8))
69
+	Smoothen_LiebLin_DSF_Scaled $whichDSF $c $N $N 0 $iKmax $kBT 0 $ommin $ommax $Nom $width
70
+	cd ..
71
+    done
72
+    cd $basedir
73
+    echo ' Successfully computed DSFs for c =' $c
74
+done

+ 95
- 0
scripts/catalogue/c_fixed_N_prog_plots.sh View File

@@ -0,0 +1,95 @@
1
+#! /bin/zsh
2
+
3
+# We use zsh here to support floats (not supported in bash)
4
+
5
+# This script produces the .dsfs files and figures for the `c_fixed_N_prog` runs
6
+# which achieved the required sumrule saturation.
7
+
8
+if [[ $# -ne 5 ]]; then
9
+    echo "Arguments needed: whichDSF, kBT, target_sumrule, nkmax (max momentum in units of kF/4), width."
10
+    exit 1
11
+fi
12
+
13
+if [[ $1 != 'd' && $1 != 'g' && $1 != 'o' ]]; then
14
+    echo "Only the d, g and o scanning options are implemented."
15
+    exit 1
16
+fi
17
+
18
+if [[ $2 -lt 0 ]]; then
19
+    echo "Temperature kBT must be > 0."
20
+    exit 1
21
+fi
22
+
23
+if [[ $3 -lt 0 || $3 -gt 1 ]]; then
24
+    echo "Requirement: 0 < target_sumrule < 1."
25
+    exit 1
26
+fi
27
+
28
+if [[ $4 -lt 0 ]]; then
29
+    echo "nkmax must be > 0."
30
+    exit 1
31
+fi
32
+
33
+if [[ $5 -lt 0 ]]; then
34
+    echo "width must be > 0."
35
+    exit 1
36
+fi
37
+
38
+whichDSF=$1
39
+kBT=$2
40
+target_sumrule=$3
41
+nkmax=$4
42
+width=$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
+clist=(0.015625 0.03125 0.0625 0.125 0.25 0.5 1 2 4 8 16 32 64 128 256 512 1024)
52
+
53
+basedir="$(pwd)"
54
+
55
+ommin=0
56
+ommax=$(($nkmax*($nkmax - 8))) # use lower branch of 1ph continuum
57
+Nom=1000
58
+
59
+for c in $clist
60
+do
61
+    echo 'Starting plotting of DSFs for c =' $c
62
+    dir='Lieb-Liniger/'$correlator'/T_'$kBT'/c_fixed_N_prog/c_'$c'/k_0_to_'${(l:2::0:)nkmax}'kFo4/sr_'$target_sumrule'/store/data'
63
+    cd $dir
64
+    for datadir in *
65
+    do
66
+	cd $datadir
67
+	N=${datadir#"N_"}
68
+	mkdir -p ../../plots/N_$N
69
+	cd ../../plots/N_$N
70
+	# Move all K_, Omega_ and .dsfs files here
71
+	mv ../../data/N_$N/K_* .
72
+	mv ../../data/N_$N/Omega_* .
73
+	mv ../../data/N_$N/*dsfs .
74
+
75
+	# Find the K and Omega file
76
+	for file in *
77
+	do
78
+	    if [[ $file = Omega* ]]; then
79
+		omegafile=$file
80
+	    elif [[ $file = K_* ]]; then
81
+		kfile=$file
82
+	    fi
83
+	done
84
+	# For each .dsfs file, plot
85
+	for file in *_w_$width.dsfs
86
+	do
87
+	    echo 'Found file ' $file
88
+	    # invoke the python script
89
+	    plot_dsf_k_range.py $kfile $omegafile $file
90
+	done
91
+	cd ../../data
92
+    done
93
+    cd $basedir
94
+    echo ' Successfully computed DSFs for c =' $c
95
+done

+ 82
- 0
scripts/catalogue/c_scan_N_fixed_animation.py View File

@@ -0,0 +1,82 @@
1
+#! /usr/bin/env python
2
+
3
+"""
4
+Plot DSF.
5
+
6
+Usage: c_scan_N_fixed_animation.py [N] [width]
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
+
53
+
54
+fig, ax = plt.subplots()
55
+
56
+# To determine the y axis limits, we look at the lowest value of c (sharpest peak)
57
+dsfsmax = 0.5
58
+
59
+ymax = omega[-1]
60
+xtext = 0.05 * k[-1]
61
+ytext = 0.9 * ymax
62
+
63
+ax.text(xtext, ytext, f'c = {clist[0]:10.6f}', color='white', fontsize='large')
64
+pcm = ax.pcolormesh(k, omega, dsfs[str(clist[0])], vmax=dsfsmax)
65
+fig.colorbar(pcm, ax=ax)
66
+def animate(i):
67
+    ax.clear()
68
+    ax.set_title(f'c scan, rho={rho} (N={N}), w={width}', fontsize='x-large')
69
+    ax.text(xtext, ytext, f'c = {clist[i]:10.6f}', color='white', fontsize='x-large')
70
+    ax.pcolormesh(k, omega, dsfs[str(clist[i])], vmax=dsfsmax)
71
+
72
+ani = animation.FuncAnimation(fig, animate, frames=len(clist), interval=100, repeat=False)
73
+
74
+outfilename = (dsffile.partition('_c_')[0].rpartition('/')[2] + '_c_scan_' +
75
+               dsffile.partition('_c_')[2].partition('_')[2].partition('.dsfs')[0])
76
+
77
+ani.save(outfilename + '.mp4')
78
+
79
+with open(outfilename + '.html', 'w') as file:
80
+    file.write(ani.to_html5_video())
81
+
82
+#plt.show()

+ 94
- 0
scripts/catalogue/c_scan_N_fixed_data.sh View File

@@ -0,0 +1,94 @@
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
+# The data can then be used to produce animated graphs (with c_int evolving),
8
+# see the `c_scan_N_fixed_dsfs[_plot]` scripts.
9
+
10
+if [[ $# -ne 5 ]]; then
11
+    echo "Arguments needed: whichDSF, kBT, target_sumrule, N, nkmax (max momentum in units of kF/4)."
12
+    exit 1
13
+fi
14
+
15
+if [[ $1 != 'd' && $1 != 'g' && $1 != 'o' ]]; then
16
+    echo "Only the d, g and o scanning options are implemented."
17
+    exit 1
18
+fi
19
+
20
+if [[ $2 -lt 0 ]]; then
21
+    echo "Temperature kBT must be > 0."
22
+    exit 1
23
+fi
24
+
25
+if [[ $3 -lt 0 || $3 -gt 1 ]]; then
26
+    echo "Requirement: 0 < target_sumrule < 1."
27
+    exit 1
28
+fi
29
+
30
+if [[ $4 -lt 0 ]]; then
31
+    echo "N must be > 0."
32
+    exit 1
33
+fi
34
+
35
+if [[ $5 -lt 0 ]]; then
36
+    echo "nkmax must be > 0."
37
+    exit 1
38
+fi
39
+
40
+
41
+whichDSF=$1
42
+kBT=$2
43
+target_sumrule=$3
44
+N=$4
45
+nkmax=$5
46
+
47
+correlator='rho-rho'
48
+if [[ $whichDSF == 'o' ]]; then
49
+    correlator='psidag-psi'
50
+elif [[ $whichDSF == 'g' ]]; then
51
+    correlator='psi-psidag'
52
+fi
53
+
54
+mkdir -p logs
55
+logfile='logs/c_scan_N_fixed_'$whichDSF'_kBT_'$kBT'_sr_'$target_sumrule'_N_'$N'_nkmax_'$nkmax'_'$(date '+%Y-%m-%d-%Hh%M')'.log'
56
+touch $logfile
57
+
58
+iKmax=$(($nkmax * $N/8))
59
+
60
+Max_Secs=3600
61
+refine=0
62
+
63
+# List of interactions: fractional powers of 2
64
+clist_raw=()
65
+for nc in {-160..160}
66
+do
67
+    clist_raw=($clist_raw $(( 2**($nc/16.) )))
68
+done
69
+# Now cast the integer values to true integers
70
+zmodload zsh/mathfunc
71
+clist=()
72
+for c in $clist_raw
73
+do
74
+    if [[ $((floor($c))) == $((ceil($c))) ]]; then
75
+	clist=($clist $((int($c))))
76
+    else
77
+	clist=($clist $c)
78
+    fi
79
+done
80
+
81
+basedir="$(pwd)"
82
+
83
+for c in $clist
84
+do
85
+    echo '** Starting run for c =' $c', N = '$N | tee -a $logfile
86
+    dir='Lieb-Liniger/'$correlator'/T_'$kBT'/c_scan_N_fixed/k_0_to_'${(l:2::0:)nkmax}'kFo4/sr_'$target_sumrule'/store/data/N_'$N'/c_'$c
87
+    mkdir -p $dir
88
+    cd $dir
89
+    LiebLin_DSF $whichDSF $c $N $N 0 $iKmax $kBT $Max_Secs $target_sumrule $refine
90
+    cd $basedir
91
+    echo '++ Successfully computed DSFs for c =' $c', N = '$N'.\n' | tee -a $logfile
92
+done
93
+
94
+echo '\n\n++ Successfully completed c_scan_N_fixed_data for N = '$N' on '$(date '+%Y-%m-%d-%Hh%M')'.\n' | tee -a $logfile

+ 96
- 0
scripts/catalogue/c_scan_N_fixed_dsfs.sh View File

@@ -0,0 +1,96 @@
1
+#! /bin/zsh
2
+
3
+# For given N (L) this
4
+# computes the smoothened dsfs and produces the animated figure
5
+# for a `c_scan_N_fixed` run.
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
+ommin=0
60
+ommax=$(($nkmax*$nkmax)) # use mid-point between upper and lower branch of 1ph continuum
61
+Nom=1000
62
+
63
+# store location for these runs
64
+dirstore='Lieb-Liniger/'$correlator'/T_'$kBT'/c_scan_N_fixed/k_0_to_'${(l:2::0:)nkmax}'kFo4/sr_'$target_sumrule'/store'
65
+
66
+# List of interactions: fractional powers of 2
67
+clist_raw=()
68
+for nc in {-160..160}
69
+do
70
+    clist_raw=($clist_raw $(( 2**($nc/16.) )))
71
+done
72
+# Now cast the integer values to true integers
73
+zmodload zsh/mathfunc
74
+clist=()
75
+for c in $clist_raw
76
+do
77
+    if [[ $((floor($c))) == $((ceil($c))) ]]; then
78
+	clist=($clist $((int($c))))
79
+    else
80
+	clist=($clist $c)
81
+    fi
82
+done
83
+
84
+basedir="$(pwd)"
85
+
86
+for c in $clist
87
+do
88
+    echo '** Starting computation of DSFs for c =' $c', N = '$N
89
+    # First construct the dsfs
90
+
91
+dir=$dirstore'/data/N_'$N'/c_'$c # dir='Lieb-Liniger/'$correlator'/T_'$kBT'/c_scan_N_fixed/k_0_to_'${(l:2::0:)nkmax}'kFo4/sr_'$target_sumrule'/store/data/N_'$N'/c_'$c
92
+    cd $dir
93
+    Smoothen_LiebLin_DSF_Scaled $whichDSF $c $N $N 0 $iKmax $kBT 0 $ommin $ommax $Nom $width
94
+    cd $basedir
95
+    echo ' Successfully computed DSFs for c =' $c', N = '$N'.\n'
96
+done

+ 75
- 0
scripts/catalogue/c_scan_N_fixed_plot.sh View File

@@ -0,0 +1,75 @@
1
+#! /bin/zsh
2
+
3
+# For given N (L) this
4
+# computes the smoothened dsfs and produces the animated figure
5
+# for a `c_scan_N_fixed` run.
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
+ommin=0
60
+ommax=$(($nkmax*$nkmax)) # use mid-point between upper and lower branch of 1ph continuum
61
+Nom=1000
62
+
63
+# store location for these runs
64
+dirstore='Lieb-Liniger/'$correlator'/T_'$kBT'/c_scan_N_fixed/k_0_to_'${(l:2::0:)nkmax}'kFo4/sr_'$target_sumrule'/store'
65
+
66
+basedir="$(pwd)"
67
+
68
+# Now create the animation
69
+echo '** Animating c_scan_N_fixed for N = '$N'...'
70
+dirplots=$dirstore'/plots/N_'$N
71
+mkdir -p $dirplots
72
+cd $dirplots
73
+c_scan_N_fixed_animation.py $N $width
74
+cd $basedir
75
+echo '** Successfully animated c_scan_N_fixed for N = '$N'.\n'

Loading…
Cancel
Save