Commit bb98eb91 authored by Jonas Schwab's avatar Jonas Schwab
Browse files

Merge branch '20-adapt-py_alf-for-submodule-hamiltonians-2' into 'master'

Resolve "Adapt py_alf for Submodule Hamiltonians"

Closes #20

See merge request !16
parents 9df00b64 4a891e53
......@@ -10,25 +10,12 @@ variables:
- 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
- apt-get update && apt-get install -y pylint3 python3-numpy git
- 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 "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 +27,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 +36,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
Test-PGI:
image: nvcr.io/nvidia/nvhpc:20.11-devel-cuda_multi-ubuntu20.04
variables:
MACHINE: "PGI"
<<: *test_definition
Warn_Buster:
......@@ -85,12 +68,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
Test_branch-PGI:
image: nvcr.io/nvidia/nvhpc:20.11-devel-cuda_multi-ubuntu20.04
variables:
MACHINE: "PGI"
<<: *test_branch_definition
......@@ -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()
......
......@@ -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()
......
......@@ -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,12 +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_QMC"] = {
......
......@@ -84,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.')
......@@ -104,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."""
......@@ -123,7 +139,7 @@ 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')
with cd(self.sim_dir):
print('Run {}'.format(executable))
try:
......@@ -252,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
......@@ -278,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."""
......@@ -302,7 +322,7 @@ 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)
subprocess.run(['make', 'program'], check=True, env=env)
print('Done.')
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment