Browse Source

Add further plotting scripts

master
Jean-Sébastien 2 years ago
parent
commit
d9a1d4be1c

+ 1
- 2
scripts/DSF_iK.py View File

@@ -1,3 +1,4 @@
1
+#! /usr/bin/env python
1 2
 import argparse
2 3
 import plotly.graph_objects as go
3 4
 import numpy
@@ -16,5 +17,3 @@ y = [d for d in dsf]
16 17
 fig = go.Figure(data=go.Scatter(x=x, y=y))
17 18
 fig.update_layout(title=args.dsffile.rpartition('/')[2])
18 19
 fig.show()
19
-
20
-

+ 20
- 21
scripts/build_LiebLin_catalogue_k_fixed.sh View File

@@ -11,28 +11,28 @@
11 11
 
12 12
 
13 13
 if [[ $# -ne 4 ]]; then
14
-	echo "Arguments needed: whichDSF, kBT, target_sumrule, nr_minutes (for each c, k combination)."
15
-	exit 1
14
+    echo "Arguments needed: whichDSF, kBT, target_sumrule, nr_minutes (for each c, k combination)."
15
+    exit 1
16 16
 fi
17 17
 
18 18
 if [[ $1 != 'd' && $1 != 'g' && $1 != 'o' ]]; then
19
-	echo "Only the d, g and o scanning options are implemented."
20
-	exit 1
19
+    echo "Only the d, g and o scanning options are implemented."
20
+    exit 1
21 21
 fi
22 22
 
23 23
 if [[ $2 -lt 0 ]]; then
24
-	echo "Temperature kBT must be > 0."
25
-	exit 1
24
+    echo "Temperature kBT must be > 0."
25
+    exit 1
26 26
 fi
27 27
 
28 28
 if [[ $3 -lt 0 || $3 -gt 1 ]]; then
29
-	echo "Requirement: 0 < target_sumrule < 1."
30
-	exit 1
29
+    echo "Requirement: 0 < target_sumrule < 1."
30
+    exit 1
31 31
 fi
32 32
 
33 33
 if [[ $4 -lt 1 ]]; then
34
-	echo "Please give a positive nr_minutes."
35
-	exit 1
34
+    echo "Please give a positive nr_minutes."
35
+    exit 1
36 36
 fi
37 37
 
38 38
 zmodload zsh/datetime
@@ -52,15 +52,14 @@ basedir="$(pwd)"
52 52
 
53 53
 for c in $clist
54 54
 do
55
-	for nk in {1..16}
56
-	do
57
-		echo 'Starting run for c =' $c', kfact = '$nk | tee -a $logfile
58
-		dir='c_'$c'/kBT_'$kBT'/k_fixed/k_'${(l:2::0:)nk}'kFo4/sr_'$target_sumrule
59
-		echo $dir
60
-		mkdir -p $dir
61
-		cd $dir
62
-		LiebLin_Catalogue_Fixed_c_k_Nscaling $whichDSF $c $nk $kBT $target_sumrule 0 $nr_minutes | tee -a $basedir/$logfile
63
-		cd $basedir
64
-		echo ' Successfully completed run for c =' $c', kfact = '$nk'\n' | tee -a $logfile
65
-	done
55
+    for nk in {1..16}
56
+    do
57
+	echo 'Starting run for c =' $c', kfact = '$nk | tee -a $logfile
58
+	dir='c_'$c'/kBT_'$kBT'/k_fixed/k_'${(l:2::0:)nk}'kFo4/sr_'$target_sumrule
59
+	mkdir -p $dir
60
+	cd $dir
61
+	LiebLin_Catalogue_Fixed_c_k_Nscaling $whichDSF $c $nk $kBT $target_sumrule 0 $nr_minutes | tee -a $basedir/$logfile
62
+	cd $basedir
63
+	echo ' Successfully completed run for c =' $c', kfact = '$nk'\n' | tee -a $logfile
64
+    done
66 65
 done

+ 68
- 0
scripts/build_LiebLin_catalogue_k_fixed_dsf.sh View File

@@ -0,0 +1,68 @@
1
+#! /bin/zsh
2
+
3
+# We use zsh here to support floats (not supported in bash)
4
+
5
+# This script produces the .dsf files for the runs from `build_LiebLin_catalogue_k_fixed`
6
+# runs which achieved the required sumrule saturation.
7
+
8
+if [[ $# -ne 4 ]]; then
9
+    echo "Arguments needed: whichDSF, kBT, target_sumrule, 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 "width must be > 0."
30
+    exit 1
31
+fi
32
+
33
+whichDSF=$1
34
+kBT=$2
35
+target_sumrule=$3
36
+width=$4
37
+
38
+clist=(1024 512 256 128 64 32 16 8 4 2 1 0.5 0.25 0.125 0.0625 0.03125 0.015625)
39
+
40
+basedir="$(pwd)"
41
+
42
+
43
+for c in $clist
44
+do
45
+    for nk in {1..16}
46
+    do
47
+	# ommin is set to zero for all
48
+	ommin=0
49
+	# ommax is set to about 2x the Tonks-Girardeau dispersion at this momentum:
50
+	# w_TG = k^2 + 2\pi n |k|  with k=2pi*iK/L and iK=nk*N/8, so (with N=L) k=pi/4 nk and
51
+	# w_TG = pi^2/16 nk^2 + pi^2/2 nk = pi^2 nk (nk/16 + 1/2)
52
+	# We take pi^2 -> 8 for convenience, so 2*w_TG is about
53
+	ommax=$(($nk*($nk + 8)))
54
+	# Number of points:
55
+	Nom=1000
56
+	echo 'Starting computation of DSFs for c =' $c', kfact = '$nk | tee -a $logfile
57
+	dir='c_'$c'/kBT_'$kBT'/k_fixed/k_'${(l:2::0:)nk}'kFo4/sr_'$target_sumrule
58
+	cd $dir
59
+	echo $dir
60
+	mkdir -p plots/
61
+	LiebLin_Catalogue_Fixed_c_k_Nscaling_Smoothen_DSF $whichDSF $c $nk $kBT $target_sumrule $ommin $ommax $Nom $width
62
+	mv *dsfs plots/
63
+	mv K_* plots/
64
+	mv Omega_* plots/
65
+	cd $basedir
66
+	echo ' Successfully computed DSFs for c =' $c', kfact = '$nk'\n' | tee -a $logfile
67
+    done
68
+done

+ 69
- 0
scripts/build_LiebLin_catalogue_k_fixed_plot_dsf.sh View File

@@ -0,0 +1,69 @@
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_fixed`
6
+# runs which achieved the required sumrule saturation.
7
+
8
+if [[ $# -ne 3 ]]; then
9
+    echo "Arguments needed: whichDSF, kBT, target_sumrule."
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
+
29
+
30
+whichDSF=$1
31
+kBT=$2
32
+target_sumrule=$3
33
+width=$4
34
+
35
+clist=(1024 512 256 128 64 32 16 8 4 2 1 0.5 0.25 0.125 0.0625 0.03125 0.015625)
36
+
37
+basedir="$(pwd)"
38
+
39
+
40
+for c in $clist
41
+do
42
+    for nk in {1..16}
43
+    do
44
+	echo 'Starting plotting of DSFs for c =' $c', kfact = '$nk | tee -a $logfile
45
+	dir='c_'$c'/kBT_'$kBT'/k_fixed/k_'${(l:2::0:)nk}'kFo4/sr_'$target_sumrule'/plots'
46
+	cd $dir
47
+	dirlist="$(ls)"
48
+	# Find the Omega file
49
+	for file in *
50
+	do
51
+	    if [[ $file = Omega* ]]; then
52
+		omegafile=$file
53
+	    fi
54
+	done
55
+	echo 'Omega file: ' $omegafile
56
+	# For each .dsfs file, plot
57
+	for file in *
58
+	do
59
+	    if [[ $file = LiebLin*dsfs ]]; then
60
+		echo 'Found file ' $file
61
+		# invoke the python script
62
+		plot_dsf_k_fixed.py $omegafile $file
63
+	    fi
64
+	done
65
+
66
+	cd $basedir
67
+	echo ' Successfully plotted DSFs for c =' $c', kfact = '$nk'\n' | tee -a $logfile
68
+    done
69
+done

+ 1
- 1
scripts/plot_benchmarks.py View File

@@ -1,5 +1,5 @@
1 1
 """
2
-Plots benchmark files produced from Benchmark_RAW_File.
2
+Plot benchmark files produced from Benchmark_RAW_File.
3 3
 
4 4
 Usage: python plot_benchmarks.py [benchmark file name].
5 5
 

+ 36
- 0
scripts/plot_dsf_k_fixed.py View File

@@ -0,0 +1,36 @@
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 matplotlib.pyplot as plt
10
+import numpy as np
11
+import sys
12
+
13
+omegafile = str(sys.argv[1])
14
+dsffile = str(sys.argv[2])
15
+
16
+omega = np.loadtxt(omegafile)
17
+dsf = np.loadtxt(dsffile)
18
+
19
+plt.plot(omega, dsf)
20
+
21
+plt.xlabel('$\omega$')
22
+plt.ylabel('$S (k, \omega)$')
23
+
24
+elements = dsffile.split('_')
25
+
26
+c_int = elements[4]
27
+L = elements[6]
28
+N = elements[8]
29
+iK = elements[13]
30
+width = elements[23].partition('.')[0]
31
+
32
+rho = int(N)/int(L)
33
+kokF = int(iK)*0.5/int(L)
34
+plt.title(f'c={c_int}, rho={rho} (N={N}), k={kokF}k_F, w={width}')
35
+
36
+plt.savefig(dsffile.replace('.', '_') + '.png')

+ 109
- 0
src/EXECS/LiebLin_Catalogue_Fixed_c_k_Nscaling_Smoothen_DSF.cc View File

@@ -0,0 +1,109 @@
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_k_Nscaling_Smoothen_DSF.cc
10
+
11
+Purpose:  Produces smoothened DSF for output from LiebLin_Catalogue_Fixed_c_k_Nscaling.cc
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 != 10) { // 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_Smoothen_DSF 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 kfact \t\t momentum factor: momemntum 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 << "DP ommin" << endl << "DP ommax \t\t Min and max frequencies to cover in smoothened DSF" << endl;
37
+    cout << "Nom \t\t\t Number of frequency points used for discretization" << endl;
38
+    cout << "DP width \t\t Gaussian width used in smoothing, in units of two-particle level spacing" << endl;
39
+  }
40
+
41
+  else { // correct nr of arguments
42
+    int ia = 1;
43
+    char whichDSF = *argv[ia++];
44
+    DP c_int = atof(argv[ia++]);
45
+    int kfact = atoi(argv[ia++]);
46
+    DP kBT = atof(argv[ia++]);
47
+    DP target_sumrule = atof(argv[ia++]);
48
+    int DiK = 1; // only do fixed momentum
49
+    DP ommin = atof(argv[ia++]);
50
+    DP ommax = atof(argv[ia++]);
51
+    int Nom = atoi(argv[ia++]);
52
+    DP width = atof(argv[ia++]);
53
+
54
+    int iN = 0;
55
+
56
+    int nN = 16;
57
+    Vect<int> Nv(nN);
58
+    // Multiples of 32 up to 256
59
+    for (int i = 1; i <= 8; ++i) Nv[i-1] = 32*i;
60
+    // Then steps of 64 up to 512
61
+    for (int i = 1; i <= 4; ++i) Nv[7+i] = 256 + 64*i;
62
+    // Then steps of 128 up to 1024
63
+    for (int i = 1; i <= 4; ++i) Nv[11+i] = 512 + 128*i;
64
+
65
+    for (int iN = 0; iN < nN; ++iN) {
66
+
67
+      int N = Nv[iN];
68
+      DP L = N;
69
+      int iKmin = (kfact * N)/8;
70
+      int iKmax = iKmin;
71
+      DP srsat = 0.0;
72
+
73
+      stringstream SRC_stringstream;  string SRC_string;
74
+      Data_File_Name (SRC_stringstream, whichDSF, c_int, L, N, iKmin, iKmax, kBT, 0.0, "");
75
+      SRC_stringstream << ".src";
76
+      SRC_string = SRC_stringstream.str();    const char* SRC_Cstr = SRC_string.c_str();
77
+
78
+      fstream srcfile;
79
+      srcfile.open(SRC_Cstr, fstream::in);
80
+      if (srcfile.fail()) {
81
+	srsat = 0.0;
82
+      }
83
+      else {
84
+	srcfile >> srsat;
85
+      }
86
+      srcfile.close();
87
+
88
+      if (srsat > target_sumrule) {
89
+	// Compute the DSF
90
+	stringstream filenameprefix;
91
+	Data_File_Name (filenameprefix, whichDSF, c_int, L, N, iKmin, iKmax, kBT, 0.0, "");
92
+	string prefix = filenameprefix.str();
93
+
94
+	DP normalization = twoPI * L;
95
+
96
+	Write_K_File (L, iKmin, iKmax);
97
+	Write_Omega_File (Nom, ommin, ommax);
98
+
99
+	// We use the scaled width function as default:
100
+	DP sumcheck;
101
+	sumcheck = Smoothen_RAW_into_SF_LiebLin_Scaled (prefix, L, N, iKmin, iKmax, DiK, ommin, ommax, Nom, width, normalization);
102
+      }
103
+
104
+    } // for N
105
+
106
+  } // else if arguments given OK
107
+
108
+  return(0);
109
+}

Loading…
Cancel
Save