From c1249ece8bfa0c283f597621c2e49d08e461a41b Mon Sep 17 00:00:00 2001 From: Jonas Schwab Date: Sat, 6 Feb 2021 22:43:56 +0100 Subject: [PATCH 01/10] Adapted for submodule hamiltonians. This is done somewhat sloppily to allow work with ALF versions both with submodule hamiltonians and without. --- default_variables.py | 4 ++++ py_alf.py | 20 ++++++++++++++++---- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/default_variables.py b/default_variables.py index 7590ede..8b556b2 100644 --- a/default_variables.py +++ b/default_variables.py @@ -52,6 +52,10 @@ IN_HAM = { 'Examples': ["VAR_Lattice", "VAR_Model_Generic", "VAR_Hubbard", "VAR_LRC"], } +PARAMS_GENERIC["VAR_ham_name"] = { + "ham_name": ["Hubbard", "Name of Hamiltonian"] + } + PARAMS_GENERIC["VAR_QMC"] = { # General parameters for the Monte Carlo algorithm "Nwrap" : [10, "Stabilization. Green functions will be computed from scratch after each time interval Nwrap*Dtau."], diff --git a/py_alf.py b/py_alf.py index a2eec3c..b96036e 100644 --- a/py_alf.py +++ b/py_alf.py @@ -66,6 +66,7 @@ class Simulation: """ self.ham_name = ham_name self.sim_dict = sim_dict + self.sim_dict["ham_name"] = str(ham_name) self.alf_dir = os.path.abspath(os.path.expanduser(alf_dir)) self.sim_dir = os.path.abspath(os.path.expanduser(os.path.join( kwargs.pop("sim_root", "ALF_data"), @@ -123,7 +124,9 @@ class Simulation: env = getenv(self.config, self.alf_dir) env['OMP_NUM_THREADS'] = str(self.n_omp) - executable = os.path.join(self.alf_dir, 'Prog', self.ham_name+'.out') + executable = os.path.join(self.alf_dir, 'Prog', 'ALF.out') + if not os.path.isfile(executable): + executable = os.path.join(self.alf_dir, 'Prog', self.ham_name+'.out') with cd(self.sim_dir): print('Run {}'.format(executable)) try: @@ -239,8 +242,14 @@ def _update_var(params, var, value): for name in params: for var2 in params[name]: if var2.lower() == var.lower(): - params[name][var2][0] = value - return params + try: + params[name][var2][0] = value + return params + except TypeError: + print("TypeError in _update_var") + print(params) + print(var, value) + raise Exception("TypeError in _update_var") raise Exception('"{}" does not correspond to a parameter'.format(var)) @@ -302,7 +311,10 @@ def compile_alf(alf_dir='ALF', branch=None, config='GNU noMPI', target='all', print('Compiling ALF... ', end='') subprocess.run(['make', 'clean'], check=True, env=env) subprocess.run(['make', 'ana'], check=True, env=env) - subprocess.run(['make', target], check=True, env=env) + try: + subprocess.run(['make', target], check=True, env=env) + except subprocess.CalledProcessError: + subprocess.run(['make', 'program'], check=True, env=env) print('Done.') -- GitLab From bdfbc9bff077e14411fbd0adc76703ade9bbdd7b Mon Sep 17 00:00:00 2001 From: Jonas Schwab Date: Sun, 7 Feb 2021 18:11:45 +0100 Subject: [PATCH 02/10] compile_alf: Remove old executables in Prog --- py_alf.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/py_alf.py b/py_alf.py index b96036e..7ccf2f9 100644 --- a/py_alf.py +++ b/py_alf.py @@ -310,6 +310,9 @@ def compile_alf(alf_dir='ALF', branch=None, config='GNU noMPI', target='all', env = getenv(config) print('Compiling ALF... ', end='') subprocess.run(['make', 'clean'], check=True, env=env) + for file in os.listdir('Prog'): + if file.endswith('.out'): + os.remove(os.path.join('Prog', file)) subprocess.run(['make', 'ana'], check=True, env=env) try: subprocess.run(['make', target], check=True, env=env) -- GitLab From 0e3f0ee32b2f7950c7c1f19b48b61edec298075f Mon Sep 17 00:00:00 2001 From: Jonas Schwab Date: Sun, 7 Feb 2021 18:30:52 +0100 Subject: [PATCH 03/10] Streamline .gitlab-ci.yml --- .gitlab-ci.yml | 52 +++++++++++++++++++------------------------------- 1 file changed, 20 insertions(+), 32 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d1e713a..16b95cb 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -10,25 +10,11 @@ variables: - default_variables.py - py_alf.py script: - - apt-get update && apt-get install -y pylint3 python3-numpy python3-colorama git + - apt-get update && apt-get install -y pylint3 python3-numpy git - pylint3 -E Run.py default_variables.py py_alf.py + - export PATH="/opt/pgi/linux86-64/2019/bin:$PATH" # Only relevant for images with PGI compiler - git clone https://git.physik.uni-wuerzburg.de/ALF/ALF.git - - ./Run.py -R --alfdir ./ALF --machine "GNU" --branch_R $BRANCH_R --ham_name_R Hubbard_Plain_Vanilla - -.test_template-PGI: &test_definition-PGI - rules: - - if: '$BRANCH_T' - when: never - - changes: - - Run.py - - default_variables.py - - py_alf.py - script: - - apt-get update && apt-get install -y pylint3 python3-numpy python3-colorama git - - pylint3 -E Run.py default_variables.py py_alf.py - - export PATH="/opt/pgi/linux86-64/2019/bin:$PATH" - - git clone https://git.physik.uni-wuerzburg.de/ALF/ALF.git - - ./Run.py -R --alfdir ./ALF --machine "PGI" --branch_R $BRANCH_R --ham_name_R Hubbard_Plain_Vanilla + - ./Run.py -R --alfdir ./ALF --machine $MACHINE --branch_R $BRANCH_R --ham_name_R Hubbard_Plain_Vanilla .warn_template: &warn_definition allow_failure: true @@ -40,7 +26,7 @@ variables: - default_variables.py - py_alf.py script: - - apt-get update && apt-get install -y pylint3 python3-numpy python3-colorama + - apt-get update && apt-get install -y pylint3 python3-numpy - pylint3 Run.py default_variables.py py_alf.py .test_branch_template: &test_branch_definition @@ -49,33 +35,29 @@ variables: when: always script: - apt-get update && apt-get install -y python3-numpy git + - export PATH="/opt/pgi/linux86-64/2019/bin:$PATH" # Only relevant for images with PGI compiler - export PYTHONPATH="$PWD:$PYTHONPATH" - cd Scripts - - ./test_branch.py --branch_R $BRANCH_R --branch_T $BRANCH_T - -.test_branch_template-PGI: &test_branch_definition-PGI - rules: - - if: '$BRANCH_T' - when: always - script: - - apt-get update && apt-get install -y python3-numpy git - - export PATH="/opt/pgi/linux86-64/2019/bin:$PATH" - - export PYTHONPATH="$PWD:$PYTHONPATH" - - cd Scripts - - ./test_branch.py --branch_R $BRANCH_R --branch_T $BRANCH_T --machine PGI + - ./test_branch.py --branch_R $BRANCH_R --branch_T $BRANCH_T --machine $MACHINE Test_Buster: image: git.physik.uni-wuerzburg.de:25812/z03/pdi/debian:buster-gfortran-blas-lapack-fftw-hdf5-scipy + variables: + MACHINE: "GNU" <<: *test_definition Test_Stretch: image: git.physik.uni-wuerzburg.de:25812/z03/pdi/debian:stretch-gfortran-blas-lapack-fftw-hdf5-scipy + variables: + MACHINE: "GNU" <<: *test_definition Test_Buster-PGI: image: git.physik.uni-wuerzburg.de:25812/z03/pdi/debian:buster-pgi1910 - <<: *test_definition-PGI + variables: + MACHINE: "PGI" + <<: *test_definition Warn_Buster: @@ -85,12 +67,18 @@ Warn_Buster: Test_branch_Buster: image: git.physik.uni-wuerzburg.de:25812/z03/pdi/debian:buster-gfortran-blas-lapack-fftw-hdf5-scipy + variables: + MACHINE: "GNU" <<: *test_branch_definition Test_branch_Stretch: image: git.physik.uni-wuerzburg.de:25812/z03/pdi/debian:stretch-gfortran-blas-lapack-fftw-hdf5-scipy + variables: + MACHINE: "GNU" <<: *test_branch_definition Test_branch_Buster-PGI: image: git.physik.uni-wuerzburg.de:25812/z03/pdi/debian:buster-pgi1910 - <<: *test_branch_definition-PGI + variables: + MACHINE: "PGI" + <<: *test_branch_definition -- GitLab From c5b92108dae1c5da4a0879dd52c204834d3275ef Mon Sep 17 00:00:00 2001 From: Jonas Schwab Date: Sat, 13 Feb 2021 20:13:11 +0100 Subject: [PATCH 04/10] Pipeline: Change PGI image to version 20.11 from nvidia server --- .gitlab-ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 16b95cb..cef21fe 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -53,8 +53,8 @@ Test_Stretch: MACHINE: "GNU" <<: *test_definition -Test_Buster-PGI: - image: git.physik.uni-wuerzburg.de:25812/z03/pdi/debian:buster-pgi1910 +Test-PGI: + image: nvcr.io/nvidia/nvhpc:20.11-devel-cuda_multi-ubuntu20.04 variables: MACHINE: "PGI" <<: *test_definition @@ -77,8 +77,8 @@ Test_branch_Stretch: MACHINE: "GNU" <<: *test_branch_definition -Test_branch_Buster-PGI: - image: git.physik.uni-wuerzburg.de:25812/z03/pdi/debian:buster-pgi1910 +Test_branch-PGI: + image: nvcr.io/nvidia/nvhpc:20.11-devel-cuda_multi-ubuntu20.04 variables: MACHINE: "PGI" <<: *test_branch_definition -- GitLab From 67b7a06c1b6ccebc69bd29873746d71a899a5823 Mon Sep 17 00:00:00 2001 From: Jonas Schwab Date: Sat, 13 Feb 2021 20:41:48 +0100 Subject: [PATCH 05/10] Work on pipeline --- .gitlab-ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index cef21fe..595a8ab 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -10,8 +10,8 @@ variables: - default_variables.py - py_alf.py script: - - apt-get update && apt-get install -y pylint3 python3-numpy git - - pylint3 -E Run.py default_variables.py py_alf.py + - apt-get update && apt-get install -y pylint python3-numpy git + - pylint -E Run.py default_variables.py py_alf.py - export PATH="/opt/pgi/linux86-64/2019/bin:$PATH" # Only relevant for images with PGI compiler - git clone https://git.physik.uni-wuerzburg.de/ALF/ALF.git - ./Run.py -R --alfdir ./ALF --machine $MACHINE --branch_R $BRANCH_R --ham_name_R Hubbard_Plain_Vanilla @@ -26,8 +26,8 @@ variables: - default_variables.py - py_alf.py script: - - apt-get update && apt-get install -y pylint3 python3-numpy - - pylint3 Run.py default_variables.py py_alf.py + - apt-get update && apt-get install -y pylint python3-numpy + - pylint Run.py default_variables.py py_alf.py .test_branch_template: &test_branch_definition rules: -- GitLab From 10754b31c9bb31637bd843cd71a32b10661853a9 Mon Sep 17 00:00:00 2001 From: Jonas Schwab Date: Sat, 13 Feb 2021 21:06:42 +0100 Subject: [PATCH 06/10] Work on pipeline --- .gitlab-ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 595a8ab..11ca50a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -10,7 +10,7 @@ variables: - default_variables.py - py_alf.py script: - - apt-get update && apt-get install -y pylint python3-numpy git + - apt-get update && apt-get install -y pylint3 python3-numpy git - pylint -E Run.py default_variables.py py_alf.py - export PATH="/opt/pgi/linux86-64/2019/bin:$PATH" # Only relevant for images with PGI compiler - git clone https://git.physik.uni-wuerzburg.de/ALF/ALF.git @@ -26,8 +26,8 @@ variables: - default_variables.py - py_alf.py script: - - apt-get update && apt-get install -y pylint python3-numpy - - pylint Run.py default_variables.py py_alf.py + - apt-get update && apt-get install -y pylint3 python3-numpy + - pylint3 Run.py default_variables.py py_alf.py .test_branch_template: &test_branch_definition rules: -- GitLab From 017b723377b558cce7dc3a45d4a8ae903e772dc1 Mon Sep 17 00:00:00 2001 From: Jonas Schwab Date: Sat, 13 Feb 2021 21:20:55 +0100 Subject: [PATCH 07/10] Work on pipeline --- .gitlab-ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 11ca50a..fcddcf3 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -11,7 +11,8 @@ variables: - py_alf.py script: - apt-get update && apt-get install -y pylint3 python3-numpy git - - pylint -E Run.py default_variables.py py_alf.py + - if [ $(command -v pylint3) ]; then linter='pylint3'; else linter='pylint'; fi + - $linter -E Run.py default_variables.py py_alf.py - export PATH="/opt/pgi/linux86-64/2019/bin:$PATH" # Only relevant for images with PGI compiler - git clone https://git.physik.uni-wuerzburg.de/ALF/ALF.git - ./Run.py -R --alfdir ./ALF --machine $MACHINE --branch_R $BRANCH_R --ham_name_R Hubbard_Plain_Vanilla -- GitLab From a792d3aca35202a4288450e1b0c97262e335b45b Mon Sep 17 00:00:00 2001 From: Jonas Schwab Date: Wed, 17 Feb 2021 17:16:31 +0100 Subject: [PATCH 08/10] Adapt py_alf to only work with submodule hamiltonians, but in a more robust way. --- default_variables.py | 12 +++++------ py_alf.py | 47 ++++++++++++++++++++++++-------------------- 2 files changed, 31 insertions(+), 28 deletions(-) diff --git a/default_variables.py b/default_variables.py index 8b556b2..a3b33ad 100644 --- a/default_variables.py +++ b/default_variables.py @@ -28,13 +28,16 @@ def default_params(ham_name): return params -def params_list(ham_name): +def params_list(ham_name, include_generic=False): """Return list of parameter names for hamiltonian, transformed in all upper case. """ p_list = [] for name in IN_HAM[ham_name]: p_list += list(PARAMS_MODEL[name]) + if include_generic: + for nlist_name, nlist in PARAMS_GENERIC.items(): + p_list += list(nlist) return [i.upper() for i in p_list] @@ -44,16 +47,11 @@ PARAMS_MODEL = OrderedDict() IN_HAM = { 'Hubbard': ["VAR_Lattice", "VAR_Model_Generic", "VAR_Hubbard"], - 'Hubbard_Plain_Vanilla': ["VAR_Lattice","VAR_Hubbard_Plain_Vanilla"], + 'Hubbard_Plain_Vanilla': ["VAR_Lattice", "VAR_Hubbard_Plain_Vanilla"], 'Kondo': ["VAR_Lattice", "VAR_Model_Generic", "VAR_Kondo"], 'tV': ["VAR_Lattice", "VAR_Model_Generic", "VAR_tV"], 'LRC': ["VAR_Lattice", "VAR_Model_Generic", "VAR_LRC"], 'Z2_Matter': ["VAR_Lattice", "VAR_Z2_Matter"], - 'Examples': ["VAR_Lattice", "VAR_Model_Generic", "VAR_Hubbard", "VAR_LRC"], - } - -PARAMS_GENERIC["VAR_ham_name"] = { - "ham_name": ["Hubbard", "Name of Hamiltonian"] } PARAMS_GENERIC["VAR_QMC"] = { diff --git a/py_alf.py b/py_alf.py index 7ccf2f9..8ef8011 100644 --- a/py_alf.py +++ b/py_alf.py @@ -66,7 +66,6 @@ class Simulation: """ self.ham_name = ham_name self.sim_dict = sim_dict - self.sim_dict["ham_name"] = str(ham_name) self.alf_dir = os.path.abspath(os.path.expanduser(alf_dir)) self.sim_dir = os.path.abspath(os.path.expanduser(os.path.join( kwargs.pop("sim_root", "ALF_data"), @@ -85,6 +84,22 @@ class Simulation: if self.tempering: self.mpi = True + # Check if all parameters in sim_dict are defined in default_variables + p_list = params_list(self.ham_name, include_generic=True) + if self.tempering: + for sim_dict0 in self.sim_dict: + for par_name in sim_dict0: + if par_name.upper() not in p_list: + raise Exception( + 'Parameter {} not listet in default_variables' + .format(par_name)) + else: + for par_name in self.sim_dict: + if par_name.upper() not in p_list: + raise Exception( + 'Parameter {} not listet in default_variables' + .format(par_name)) + if self.mpi and self.n_mpi is None: raise Exception('You have to specify n_mpi if you use MPI.') @@ -105,9 +120,9 @@ class Simulation: if self.tempering: self.config += ' TEMPERING' - def compile(self, target='all'): + def compile(self): """Compiles ALF. Clones a new repository if alf_dir does not exist.""" - compile_alf(self.alf_dir, self.branch, self.config, target) + compile_alf(self.alf_dir, self.branch, self.config) def run(self): """Prepares simulation directory and runs ALF.""" @@ -125,8 +140,6 @@ class Simulation: env = getenv(self.config, self.alf_dir) env['OMP_NUM_THREADS'] = str(self.n_omp) executable = os.path.join(self.alf_dir, 'Prog', 'ALF.out') - if not os.path.isfile(executable): - executable = os.path.join(self.alf_dir, 'Prog', self.ham_name+'.out') with cd(self.sim_dir): print('Run {}'.format(executable)) try: @@ -242,14 +255,8 @@ def _update_var(params, var, value): for name in params: for var2 in params[name]: if var2.lower() == var.lower(): - try: - params[name][var2][0] = value - return params - except TypeError: - print("TypeError in _update_var") - print(params) - print(var, value) - raise Exception("TypeError in _update_var") + params[name][var2][0] = value + return params raise Exception('"{}" does not correspond to a parameter'.format(var)) @@ -261,6 +268,10 @@ def set_param(ham_name, sim_dict): """ params = default_params(ham_name) + params["VAR_ham_name"] = { + "ham_name": [ham_name, "Name of Hamiltonian"] + } + for name, value in sim_dict.items(): params = _update_var(params, name, value) return params @@ -287,7 +298,7 @@ def getenv(config, alf_dir='.'): return env -def compile_alf(alf_dir='ALF', branch=None, config='GNU noMPI', target='all', +def compile_alf(alf_dir='ALF', branch=None, config='GNU noMPI', url='https://git.physik.uni-wuerzburg.de/ALF/ALF.git'): """Compile ALF. Clone a new repository if alf_dir does not exist.""" @@ -310,14 +321,8 @@ def compile_alf(alf_dir='ALF', branch=None, config='GNU noMPI', target='all', env = getenv(config) print('Compiling ALF... ', end='') subprocess.run(['make', 'clean'], check=True, env=env) - for file in os.listdir('Prog'): - if file.endswith('.out'): - os.remove(os.path.join('Prog', file)) subprocess.run(['make', 'ana'], check=True, env=env) - try: - subprocess.run(['make', target], check=True, env=env) - except subprocess.CalledProcessError: - subprocess.run(['make', 'program'], check=True, env=env) + subprocess.run(['make', 'program'], check=True, env=env) print('Done.') -- GitLab From 0e5c61d48b52fba8a7ba59954745043757b4d38a Mon Sep 17 00:00:00 2001 From: Jonas Schwab Date: Mon, 22 Mar 2021 13:44:24 +0100 Subject: [PATCH 09/10] Small fix --- Scripts/test_branch.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Scripts/test_branch.py b/Scripts/test_branch.py index 04e98b0..f218161 100755 --- a/Scripts/test_branch.py +++ b/Scripts/test_branch.py @@ -24,7 +24,7 @@ def test_branch(alf_dir, sim_dict, branch_R, branch_T, branch=branch_R, mpi=mpi, n_mpi=n_mpi) - sim_R.compile(target=ham_name) + sim_R.compile() sim_R.run() sim_R.analysis() obs_R = sim_R.get_obs() @@ -35,7 +35,7 @@ def test_branch(alf_dir, sim_dict, branch_R, branch_T, mpi=mpi, n_mpi=n_mpi) sim_T.sim_dir = sim_T.sim_dir + '_test' - sim_T.compile(target=ham_name) + sim_T.compile() sim_T.run() sim_T.analysis() obs_T = sim_T.get_obs() -- GitLab From 85e30d842385adb799ee9a072d11f5b99fd897f3 Mon Sep 17 00:00:00 2001 From: Jonas Schwab Date: Mon, 22 Mar 2021 13:55:55 +0100 Subject: [PATCH 10/10] Small fix --- Run.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Run.py b/Run.py index 0540f81..71a0ded 100755 --- a/Run.py +++ b/Run.py @@ -81,7 +81,7 @@ if __name__ == "__main__": sim_R = Simulation(ham_name_R, sim_dict, alf_dir, machine=machine, branch=branch_R, mpi=mpi, n_mpi=n_mpi) - sim_R.compile(target=ham_name_R) + sim_R.compile() sim_R.run() sim_R.analysis() obs_R = sim_R.get_obs() @@ -91,7 +91,7 @@ if __name__ == "__main__": machine=machine, branch=branch_T, mpi=mpi, n_mpi=n_mpi) sim_T.sim_dir = sim_T.sim_dir + '_test' - sim_T.compile(target=ham_name_T) + sim_T.compile() sim_T.run() sim_T.analysis() obs_T = sim_T.get_obs() -- GitLab