Browse Source

Add scripts and functions for catalogue over k range

master
Jean-Sébastien 2 years ago
parent
commit
25f4b1ac28

+ 1
- 1
scripts/build_LiebLin_catalogue_k_fixed.sh View File

@@ -50,7 +50,7 @@ elif [[ $whichDSF == 'g' ]]; then
50 50
 fi
51 51
 
52 52
 mkdir -p logs
53
-logfile='logs/run_'$whichDSF'_kBT_'$kBT'_sr_'$target_sumrule'_'$(date '+%Y-%m-%d-%Hh%M')'.log'
53
+logfile='logs/run_'$whichDSF'_kBT_'$kBT'_k_fixed_sr_'$target_sumrule'_'$(date '+%Y-%m-%d-%Hh%M')'.log'
54 54
 touch $logfile
55 55
 
56 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)

+ 25
- 18
scripts/build_LiebLin_catalogue_k_fixed_dsfs_plots.sh View File

@@ -52,25 +52,32 @@ do
52 52
 	dir='Lieb-Liniger/'$correlator'/T_'$kBT'/c_fixed/c_'$c'/k_fixed/k_'${(l:2::0:)nk}'kFo4/sr_'$target_sumrule'/store/plots'
53 53
 	mkdir -p $dir
54 54
 	cd $dir
55
-	# Move all K_, Omega_ and .dsfs files to the plots directory
56
-	mv ../data/*/K_* .
57
-	mv ../data/*/Omega_* .
58
-	mv ../data/*/*dsfs .
59
-	dirlist="$(ls)"
60
-	# Find the Omega file
61
-	for file in *
62
-	do
63
-	    if [[ $file = Omega* ]]; then
64
-		omegafile=$file
65
-	    fi
66
-	done
67
-	echo 'Omega file: ' $omegafile
68
-	# For each .dsfs file, plot
69
-	for file in *.dsfs
55
+
56
+	for datadir in ../data/*
70 57
 	do
71
-	    echo 'Found file ' $file
72
-	    # invoke the python script
73
-	    plot_dsf_k_fixed.py $omegafile $file
58
+	    N=${datadir#"../data/N_"}
59
+	    mkdir -p 'N_'$N
60
+	    cd 'N_'$N
61
+	    # Move all K_, Omega_ and .dsfs files here
62
+	    mv ../../data/N_$N/K_* .
63
+	    mv ../../data/N_$N/Omega_* .
64
+	    mv ../../data/N_$N/*dsfs .
65
+
66
+	    # Find the K and Omega file
67
+	    for file in *
68
+	    do
69
+		if [[ $file = Omega* ]]; then
70
+		    omegafile=$file
71
+		fi
72
+	    done
73
+	    # For each .dsfs file, plot
74
+	    for file in *.dsfs
75
+	    do
76
+		echo 'Found file ' $file
77
+		# invoke the python script
78
+		plot_dsf_k_fixed.py $omegafile $file
79
+	    done
80
+	    cd ..
74 81
 	done
75 82
 
76 83
 	cd $basedir

+ 76
- 0
scripts/build_LiebLin_catalogue_k_range.sh View File

@@ -0,0 +1,76 @@
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 4kF.
8
+
9
+# For each c, the LiebLin_Catalogue_Fixed_c_Nscaling
10
+# executable is invoked.
11
+
12
+
13
+if [[ $# -ne 5 ]]; then
14
+    echo "Arguments needed: whichDSF, kBT, target_sumrule, nkmax (max momentum in units of kF/4), nr_minutes (for each c value)."
15
+    exit 1
16
+fi
17
+
18
+if [[ $1 != 'd' && $1 != 'g' && $1 != 'o' ]]; then
19
+    echo "Only the d, g and o scanning options are implemented."
20
+    exit 1
21
+fi
22
+
23
+if [[ $2 -lt 0 ]]; then
24
+    echo "Temperature kBT must be > 0."
25
+    exit 1
26
+fi
27
+
28
+if [[ $3 -lt 0 || $3 -gt 1 ]]; then
29
+    echo "Requirement: 0 < target_sumrule < 1."
30
+    exit 1
31
+fi
32
+
33
+if [[ $4 -lt 0 ]]; then
34
+    echo "nkmax must be > 0."
35
+    exit 1
36
+fi
37
+
38
+if [[ $5 -lt 1 ]]; then
39
+    echo "Please give a positive nr_minutes."
40
+    exit 1
41
+fi
42
+
43
+zmodload zsh/datetime
44
+
45
+whichDSF=$1
46
+kBT=$2
47
+target_sumrule=$3
48
+nkmax=$4
49
+nr_minutes=$5
50
+
51
+correlator='rho-rho'
52
+if [[ $whichDSF == 'o' ]]; then
53
+    correlator='psidag-psi'
54
+elif [[ $whichDSF == 'g' ]]; then
55
+    correlator='psi-psidag'
56
+fi
57
+
58
+mkdir -p logs
59
+logfile='logs/run_'$whichDSF'_kBT_'$kBT'_k_range_sr_'$target_sumrule'_'$(date '+%Y-%m-%d-%Hh%M')'.log'
60
+touch $logfile
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
+basedir="$(pwd)"
65
+
66
+
67
+for c in $clist
68
+do
69
+    echo '** Starting run for c =' $c | tee -a $logfile
70
+    dir='Lieb-Liniger/'$correlator'/T_'$kBT'/c_fixed/c_'$c'/k_range/k_0_to_'$nkmax'kFo4/sr_'$target_sumrule'/prelim'
71
+    mkdir -p $dir
72
+    cd $dir
73
+    LiebLin_Catalogue_Fixed_c_Nscaling $whichDSF $c $nkmax $kBT $target_sumrule 0 $nr_minutes | tee -a $basedir/$logfile
74
+    cd $basedir
75
+    echo '** Successfully completed run for c =' $c', kfact = '$nk'.\n' | tee -a $logfile
76
+done

+ 74
- 0
scripts/build_LiebLin_catalogue_k_range_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 for the runs from `build_LiebLin_catalogue_k_range`
6
+# runs 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=(1024 512 256 128 64 32 16 8 4 2 1 0.5 0.25 0.125 0.0625 0.03125 0.015625)
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/c_'$c'/k_range/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/build_LiebLin_catalogue_k_range_dsfs_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 plots for the runs from `build_LiebLin_catalogue_k_range`
6
+# runs 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
+
39
+whichDSF=$1
40
+kBT=$2
41
+target_sumrule=$3
42
+nkmax=$4
43
+width=$5
44
+
45
+correlator='rho-rho'
46
+if [[ $whichDSF == 'o' ]]; then
47
+    correlator='psidag-psi'
48
+elif [[ $whichDSF == 'g' ]]; then
49
+    correlator='psi-psidag'
50
+fi
51
+
52
+clist=(1024 512 256 128 64 32 16 8 4 2 1 0.5 0.25 0.125 0.0625 0.03125 0.015625)
53
+
54
+basedir="$(pwd)"
55
+
56
+
57
+for c in $clist
58
+do
59
+    echo '** Starting plotting of DSFs for c =' $c
60
+    dir='Lieb-Liniger/'$correlator'/T_'$kBT'/c_fixed/c_'$c'/k_range/k_0_to_'${(l:2::0:)nkmax}'kFo4/sr_'$target_sumrule'/store/plots'
61
+    mkdir -p $dir
62
+    cd $dir
63
+    for datadir in ../data/*
64
+    do
65
+	N=${datadir#"../data/N_"}
66
+	mkdir -p 'N_'$N
67
+	cd 'N_'$N
68
+	# Move all K_, Omega_ and .dsfs files here
69
+	mv ../../data/N_$N/K_* .
70
+	mv ../../data/N_$N/Omega_* .
71
+	mv ../../data/N_$N/*dsfs .
72
+
73
+	# Find the K and Omega file
74
+	for file in *
75
+	do
76
+	    if [[ $file = Omega* ]]; then
77
+		omegafile=$file
78
+	    elif [[ $file = K_* ]]; then
79
+		kfile=$file
80
+	    fi
81
+	done
82
+	# For each .dsfs file, plot
83
+	for file in *.dsfs
84
+	do
85
+	    echo 'Found file ' $file
86
+	    # invoke the python script
87
+	    plot_dsf_k_range.py $kfile $omegafile $file
88
+	done
89
+	cd ..
90
+    done
91
+
92
+    cd $basedir
93
+    echo '** Successfully plotted DSFs for c =' $c'.\n'
94
+
95
+done

+ 39
- 0
scripts/plot_dsf_k_range.py View File

@@ -0,0 +1,39 @@
1
+#! /usr/bin/env python
2
+
3
+"""
4
+Plot DSF.
5
+
6
+Usage: python plot_dsf_k_range.py [k file] [omega file] [dsf file]
7
+"""
8
+
9
+import matplotlib.pyplot as plt
10
+import numpy as np
11
+import sys
12
+
13
+kfile = str(sys.argv[1])
14
+omegafile = str(sys.argv[2])
15
+dsffile = str(sys.argv[3])
16
+
17
+k = np.loadtxt(kfile)
18
+omega = np.loadtxt(omegafile)
19
+dsf = np.loadtxt(dsffile)
20
+
21
+dsfsmax = 0.5
22
+
23
+plt.pcolormesh(k, omega, dsf, vmax=dsfsmax)
24
+plt.colorbar()
25
+plt.xlabel('$k$')
26
+plt.ylabel('$\omega$')
27
+
28
+elements = dsffile.split('_')
29
+
30
+c_int = elements[3]
31
+L = elements[5]
32
+N = elements[7]
33
+width = elements[22].partition('.')[0]
34
+
35
+rho = int(N)/int(L)
36
+
37
+plt.title(f'c={c_int}, rho={rho} (N={N}), w={width}')
38
+
39
+plt.savefig(dsffile.replace('.', '_') + '.png')

+ 142
- 0
src/EXECS/LiebLin_Catalogue_Fixed_c_Nscaling.cc View File

@@ -0,0 +1,142 @@
1
+/**********************************************************
2
+
3
+This software is part of J.-S. Caux's ABACUS library.
4
+
5
+Copyright (c) J.-S. Caux.
6
+
7
+-----------------------------------------------------------
8
+
9
+File:  LiebLin_Catalogue_Fixed_c_Nscaling.cc
10
+
11
+Purpose:  Produces sets of data files for correlations, increasing system size at fixed c.
12
+
13
+***********************************************************/
14
+
15
+#include <omp.h>
16
+#include "ABACUS.h"
17
+
18
+using namespace std;
19
+using namespace ABACUS;
20
+
21
+
22
+int main(int argc, char* argv[])
23
+{
24
+
25
+  if (argc != 8) { // provide some info
26
+
27
+    cout << endl << "Welcome to ABACUS\t(copyright J.-S. Caux)." << endl;
28
+    cout << endl << "Usage of LiebLin_Catalogue_Fixed_c_k_Nscaling executable: " << endl;
29
+    cout << endl << "Provide the following arguments:" << endl << endl;
30
+    cout << "char whichDSF \t\t Which structure factor should be calculated ?  Options are:  "
31
+      "d for rho rho, g for psi psi{dagger}, o for psi{dagger} psi" << endl;
32
+    cout << "DP c_int \t\t Value of the interaction parameter:  use positive real values only" << endl;
33
+    cout << "int kfactmax \t\t max momentum factor: max momentum will be set to kfact * kF/4" << endl;
34
+    cout << "DP kBT \t\t Temperature (positive only of course)" << endl;
35
+    cout << "DP target_sumrule \t sumrule saturation you're satisfied with" << endl;
36
+    cout << "int Hrs \t\t Allowed computational time (hours)" << endl;
37
+    cout << "int Mns \t\t Allowed computational time (minutes)" << endl;
38
+  }
39
+
40
+  else { // correct nr of arguments
41
+    int ia = 1;
42
+    char whichDSF = *argv[ia++];
43
+    DP c_int = atof(argv[ia++]);
44
+    int kfact = atoi(argv[ia++]);
45
+    DP kBT = atof(argv[ia++]);
46
+    DP target_sumrule = atof(argv[ia++]);
47
+    int Max_Secs = 3600*atoi(argv[ia++]) + 60*atoi(argv[ia++]);
48
+
49
+    double StartTime = omp_get_wtime();
50
+
51
+    double ActualTime = omp_get_wtime();
52
+
53
+    int Secs_left = Max_Secs;
54
+
55
+    int iN = 0;
56
+
57
+    int nN = 16;
58
+    Vect<int> Nv(nN);
59
+    // Multiples of 32 up to 256
60
+    for (int i = 1; i <= 8; ++i) Nv[i-1] = 32*i;
61
+    // Then steps of 64 up to 512
62
+    for (int i = 1; i <= 4; ++i) Nv[7+i] = 256 + 64*i;
63
+    // Then steps of 128 up to 1024
64
+    for (int i = 1; i <= 4; ++i) Nv[11+i] = 512 + 128*i;
65
+
66
+    for (int iN = 0; iN < nN; ++iN) {
67
+
68
+      int N = Nv[iN];
69
+      DP L = N;
70
+      int iKmin = 0;
71
+      int iKmax = (kfact * N)/8;
72
+      DP srsat = 0.0;
73
+      bool refine = false;
74
+
75
+      stringstream SRC_stringstream;  string SRC_string;
76
+      Data_File_Name (SRC_stringstream, whichDSF, c_int, L, N, iKmin, iKmax, kBT, 0.0, "");
77
+      SRC_stringstream << ".src";
78
+      SRC_string = SRC_stringstream.str();    const char* SRC_Cstr = SRC_string.c_str();
79
+
80
+      fstream srcfile;
81
+      srcfile.open(SRC_Cstr, fstream::in);
82
+      if (srcfile.fail()) {
83
+	srsat = 0.0;
84
+	refine = false;
85
+      }
86
+      else {
87
+	srcfile >> srsat;
88
+	refine = true;
89
+      }
90
+      srcfile.close();
91
+
92
+      ActualTime = omp_get_wtime();
93
+      Secs_left = int(Max_Secs - (ActualTime - StartTime));
94
+
95
+      Scan_Info resulting_info;
96
+      if (srsat < target_sumrule && Secs_left > Max_Secs/2) {
97
+	// Improve the icmin calculation by one chunk:
98
+	cout << "---\nTime left = " << Secs_left << " seconds." << endl;
99
+	if (srsat > 0) {
100
+	  cout << "Continue with N = " << N << ". Sumrule previously achieved: " << srsat << endl;
101
+	} else {
102
+	  cout << "Start with N = " << N << "." << endl;
103
+	}
104
+	resulting_info = Scan_LiebLin (whichDSF, c_int, L, N, iKmin, iKmax, kBT,
105
+				       Secs_left, target_sumrule, refine);
106
+	cout << "Done with N = " << N
107
+	     << ". Sumrule obtained: " << resulting_info.sumrule_obtained
108
+	     << endl;
109
+      }
110
+
111
+      if (resulting_info.sumrule_obtained > target_sumrule) {
112
+	// Move files to storage, keeping a copy of the .src file in the current directory
113
+	string command1 = "mkdir -p ../store/data/N_" + to_string(N);
114
+	system(command1.c_str());
115
+	string command2 = "mv *_N_" + to_string(N) + "* ../store/data/N_" + to_string(N) + "/";
116
+	system(command2.c_str());
117
+	string command3 = "cp ../store/data/N_" + to_string(N) + "/*src .";
118
+	system(command3.c_str());
119
+      }
120
+
121
+      ActualTime = omp_get_wtime();
122
+
123
+      Secs_left = int(Max_Secs - (ActualTime - StartTime));
124
+
125
+      if (Secs_left < 30) {
126
+	if (resulting_info.sumrule_obtained > target_sumrule) {
127
+	  cout << "---\nBreaking out after completing N = " << N
128
+	       << " since time left = " << Secs_left << " seconds." << endl;
129
+	}
130
+	else {
131
+	  cout << "---\nBreaking out while working on N = " << N
132
+	       << " since allocated time is exhausted." << endl;
133
+	}
134
+	break;
135
+      }
136
+
137
+    } // while there is time
138
+
139
+  } // else if arguments given OK
140
+
141
+  return(0);
142
+}

Loading…
Cancel
Save