-
Notifications
You must be signed in to change notification settings - Fork 141
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3676 from mcbennet/nxs-test-qdens-radial
Nexus: Add unit tests and example for qdens-radial tool
- Loading branch information
Showing
50 changed files
with
7,345 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
122 changes: 122 additions & 0 deletions
122
nexus/examples/qmcpack/rsqmc_misc/diamond_radial_density/diamond_spin.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
#! /usr/bin/env python | ||
|
||
from nexus import settings | ||
from nexus import job | ||
from nexus import run_project | ||
from nexus import generate_physical_system | ||
from nexus import generate_pwscf | ||
from nexus import generate_projwfc | ||
from nexus import generate_pw2qmcpack | ||
from nexus import generate_qmcpack | ||
from nexus import vmc | ||
|
||
from structure import * | ||
|
||
from qmcpack_input import spindensity | ||
|
||
settings( | ||
pseudo_dir = '../../pseudopotentials', | ||
runs = 'runs_spin', | ||
results = '', | ||
status_only = 0, | ||
generate_only = 0, | ||
skip_submit = 0, | ||
sleep = 3, | ||
machine = 'ws4' | ||
) | ||
|
||
dia16 = generate_physical_system( | ||
units = 'A', | ||
axes = [[ 1.785, 1.785, 0. ], | ||
[ 0. , 1.785, 1.785], | ||
[ 1.785, 0. , 1.785]], | ||
elem = ['C','C'], | ||
pos = [[ 0. , 0. , 0. ], | ||
[ 0.8925, 0.8925, 0.8925]], | ||
tiling = (1,1,1), | ||
C = 4 | ||
) | ||
|
||
# k-mesh used for density | ||
scf_kg = dia16.structure.kgrid_from_kspacing(0.5) # Get SCF kmesh from k-spacing | ||
|
||
# twist-mesh used for qmc | ||
dia16.structure.add_symmetrized_kmesh(kgrid=(2,2,2),kshift=(0,0,0)) | ||
|
||
|
||
number_of_ks_orbs = 11 | ||
|
||
scf = generate_pwscf( | ||
identifier = 'scf', | ||
path = 'scf', | ||
job = job(cores=1,app='pw.x',hours=1), | ||
input_type = 'generic', | ||
calculation = 'scf', | ||
nspin = 2, | ||
tot_magnetization = 0, | ||
nbnd = number_of_ks_orbs, | ||
input_dft = 'lda', | ||
ecutwfc = 200, | ||
conv_thr = 1e-8, | ||
nosym = False, | ||
wf_collect = False, | ||
system = dia16, | ||
kgrid = scf_kg, | ||
kshift = (0,0,0), | ||
pseudos = ['C.BFD.upf'], | ||
) | ||
|
||
nscf = generate_pwscf( | ||
identifier = 'nscf', | ||
path = 'nscf', | ||
job = job(cores=1,app='pw.x',hours=1), | ||
input_type = 'generic', | ||
calculation = 'nscf', | ||
input_dft = 'lda', | ||
ecutwfc = 200, | ||
nspin = 2, | ||
tot_magnetization = 0, | ||
conv_thr = 1e-8, | ||
nosym = True, | ||
wf_collect = True, | ||
system = dia16, | ||
nbnd = number_of_ks_orbs, | ||
verbosity = 'high', #verbosity must be set to high | ||
pseudos = ['C.BFD.upf'], | ||
dependencies = (scf,'charge_density'), | ||
) | ||
|
||
# Generate orbital h5 file | ||
conv = generate_pw2qmcpack( | ||
identifier = 'conv', | ||
path = 'nscf', | ||
job = job(cores=1,app='pw2qmcpack.x',hours=1), | ||
write_psir = False, | ||
dependencies = (nscf,'orbitals'), | ||
) | ||
|
||
|
||
qmc = generate_qmcpack( | ||
identifier = 'vmc', | ||
path = 'vmc', | ||
job = job(cores=3,app='qmcpack_complex',hours=1), | ||
input_type = 'basic', | ||
system = dia16, | ||
pseudos = ['C.BFD.xml'], | ||
estimators = [spindensity(dr=(0.5,0.5,0.5))], | ||
jastrows = [], | ||
calculations = [ | ||
vmc( | ||
walkers = 1, | ||
warmupsteps = 20, | ||
blocks = 200, | ||
steps = 10, | ||
substeps = 2, | ||
timestep = .4 | ||
) | ||
], | ||
dependencies = (conv,'orbitals'), | ||
) | ||
|
||
run_project() | ||
|
5 changes: 5 additions & 0 deletions
5
nexus/examples/qmcpack/rsqmc_misc/diamond_radial_density/qdens-radial.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/usr/bin/env bash | ||
|
||
qdens-radial -s C -r 0.6 runs_spin/vmc/vmc.avg.s000.SpinDensity_u+d.xsf | ||
qdens-radial -s C -r 0.6 -c runs_spin/vmc/vmc.avg.s000.SpinDensity_u+d.xsf | ||
|
4 changes: 4 additions & 0 deletions
4
nexus/examples/qmcpack/rsqmc_misc/diamond_radial_density/qdens.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/usr/bin/env bash | ||
|
||
qdens -a -v -e 10 -f xsf -i runs_spin/vmc/vmc.g000.twistnum_0.in.xml runs_spin/vmc/*.stat.h5 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,157 @@ | ||
|
||
import versions | ||
import testing | ||
from testing import execute,text_eq,check_value_eq | ||
|
||
|
||
if versions.spglib_available: | ||
def test_radial_density(): | ||
import os | ||
|
||
tpath = testing.setup_unit_test_output_directory('qdens_radial','test_radial_density') | ||
|
||
exe = testing.executable_path('qdens-radial') | ||
|
||
qr_vmc_files_path = testing.unit_test_file_path('qdens_radial','diamond_twist/vmc') | ||
command = 'rsync -a {} {}'.format(qr_vmc_files_path,tpath) | ||
out,err,rc = execute(command) | ||
assert(rc==0) | ||
vmc_path = os.path.join(tpath,'vmc') | ||
vmc_infile = os.path.join(vmc_path,'vmc.g000.twistnum_0.in.xml') | ||
assert(os.path.exists(vmc_infile)) | ||
vmc_infile = os.path.join(vmc_path,'vmc.g001.twistnum_1.in.xml') | ||
assert(os.path.exists(vmc_infile)) | ||
vmc_infile = os.path.join(vmc_path,'vmc.g002.twistnum_2.in.xml') | ||
assert(os.path.exists(vmc_infile)) | ||
vmc_infile = os.path.join(vmc_path,'vmc.g003.twistnum_3.in.xml') | ||
assert(os.path.exists(vmc_infile)) | ||
|
||
files_bef = ''' | ||
vmc.avg.s000.SpinDensity_u+d+err.xsf vmc.avg.s000.SpinDensity_u+d-err.xsf | ||
vmc.avg.s000.SpinDensity_u+d.xsf vmc.g000.twistnum_0.in.xml | ||
vmc.g000.s000.scalar.dat vmc.g001.s000.scalar.dat | ||
vmc.g000.twistnum_0.in.g000.qmc vmc.g001.twistnum_1.in.g001.qmc | ||
vmc.g001.twistnum_1.in.xml vmc.g002.twistnum_2.in.xml | ||
vmc.g002.s000.scalar.dat vmc.g003.s000.scalar.dat | ||
vmc.g002.twistnum_2.in.g002.qmc vmc.g003.twistnum_3.in.g003.qmc | ||
vmc.g003.twistnum_3.in.xml vmc.out | ||
vmc.in vmc.info.xml | ||
'''.split() | ||
|
||
qr_dmc_files_path = testing.unit_test_file_path('qdens_radial','diamond_twist/dmc') | ||
command = 'rsync -a {} {}'.format(qr_dmc_files_path,tpath) | ||
out,err,rc = execute(command) | ||
assert(rc==0) | ||
dmc_path = os.path.join(tpath,'dmc') | ||
dmc_infile = os.path.join(dmc_path,'dmc.g000.twistnum_0.in.xml') | ||
assert(os.path.exists(dmc_infile)) | ||
dmc_infile = os.path.join(dmc_path,'dmc.g001.twistnum_1.in.xml') | ||
assert(os.path.exists(dmc_infile)) | ||
dmc_infile = os.path.join(dmc_path,'dmc.g002.twistnum_2.in.xml') | ||
assert(os.path.exists(dmc_infile)) | ||
dmc_infile = os.path.join(dmc_path,'dmc.g003.twistnum_3.in.xml') | ||
assert(os.path.exists(dmc_infile)) | ||
|
||
files_bef = ''' | ||
dmc.avg.s001.SpinDensity_u+d+err.xsf dmc.avg.s001.SpinDensity_u+d-err.xsf | ||
dmc.avg.s001.SpinDensity_u+d.xsf dmc.g001.s001.scalar.dat | ||
dmc.g000.s000.scalar.dat dmc.g000.s001.scalar.dat | ||
dmc.g000.twistnum_0.in.g000.qmc dmc.g001.twistnum_1.in.g001.qmc | ||
dmc.g000.twistnum_0.in.xml dmc.g001.twistnum_1.in.xml | ||
dmc.g001.s000.scalar.dat dmc.g002.s000.scalar.dat | ||
dmc.g002.s001.scalar.dat dmc.g003.s001.scalar.dat | ||
dmc.g002.twistnum_2.in.g002.qmc dmc.g003.twistnum_3.in.g003.qmc | ||
dmc.g002.twistnum_2.in.xml dmc.g003.twistnum_3.in.xml | ||
dmc.g003.s000.scalar.dat dmc.in | ||
dmc.out | ||
'''.split() | ||
|
||
assert(check_value_eq(set(os.listdir(dmc_path)),set(files_bef))) | ||
|
||
# VMC non-cumulative | ||
command = '{0} -s C -r 0.6 {1}/vmc.avg.s000.SpinDensity_u+d.xsf'.format(exe,vmc_path) | ||
out,err,rc = execute(command) | ||
|
||
# Assert that return code is 0 | ||
assert(rc==0) | ||
|
||
# Assert that output is consistent with reference | ||
out_ref = ''' | ||
Norm: tot = 8.00000003 | ||
Non-Cumulative Value of C Species at Cutoff 0.6 is: 4.773264912162242 | ||
''' | ||
assert(text_eq(out,out_ref)) | ||
|
||
# VMC cumulative | ||
command = '{0} -s C -r 0.6 -c {1}/vmc.avg.s000.SpinDensity_u+d.xsf'.format(exe,vmc_path) | ||
out,err,rc = execute(command) | ||
|
||
# Assert that return code is 0 | ||
assert(rc==0) | ||
|
||
# Assert that output is consistent with reference | ||
out_ref = ''' | ||
Norm: tot = 8.00000003 | ||
Cumulative Value of C Species at Cutoff 0.6 is: 1.0684248641866259 | ||
''' | ||
|
||
# DMC extrapolated non-cumulative | ||
command = '{0} -s C -r 0.6 --vmc={1}/vmc.avg.s000.SpinDensity_u+d.xsf {2}/dmc.avg.s001.SpinDensity_u+d.xsf'.format(exe,vmc_path,dmc_path) | ||
out,err,rc = execute(command) | ||
|
||
# Assert that return code is 0 | ||
assert(rc==0) | ||
|
||
# Assert that output is consistent with reference | ||
out_ref = ''' | ||
Extrapolating from VMC and DMC densities... | ||
Norm: tot = 7.999999969999998 | ||
Non-Cumulative Value of C Species at Cutoff 0.6 is: 4.910093964664309 | ||
''' | ||
assert(text_eq(out,out_ref)) | ||
|
||
# DMC extrapolated cumulative | ||
command = '{0} -s C -r 0.6 -c --vmc={1}/vmc.avg.s000.SpinDensity_u+d.xsf {2}/dmc.avg.s001.SpinDensity_u+d.xsf'.format(exe,vmc_path,dmc_path) | ||
out,err,rc = execute(command) | ||
|
||
# Assert that return code is 0 | ||
assert(rc==0) | ||
|
||
# Assert that output is consistent with reference | ||
out_ref = ''' | ||
Extrapolating from VMC and DMC densities... | ||
Norm: tot = 7.999999969999998 | ||
Cumulative Value of C Species at Cutoff 0.6 is: 1.1078267486386275 | ||
''' | ||
assert(text_eq(out,out_ref)) | ||
|
||
|
||
# DMC extrapolated cumulative with error bar | ||
command = '{0} -s C -r 0.6 -c -n 3 --seed=0 --vmc={1}/vmc.avg.s000.SpinDensity_u+d.xsf --vmcerr={1}/vmc.avg.s000.SpinDensity_u+d+err.xsf --dmcerr={2}/dmc.avg.s001.SpinDensity_u+d+err.xsf {2}/dmc.avg.s001.SpinDensity_u+d.xsf'.format(exe,vmc_path,dmc_path) | ||
out,err,rc = execute(command) | ||
|
||
# Assert that return code is 0 | ||
assert(rc==0) | ||
|
||
# Assert that output is consistent with reference | ||
out_ref = ''' | ||
Extrapolating from VMC and DMC densities... | ||
Resampling to obtain error bar (NOTE: This can be slow)... | ||
Will compute 3 samples... | ||
sample: 0 | ||
sample: 1 | ||
sample: 2 | ||
Norm: tot = 7.999999969999998 | ||
Cumulative Value of C Species at Cutoff 0.6 is: 1.1078267486386275+/-0.0016066467833404942 | ||
''' | ||
assert(text_eq(out,out_ref)) | ||
#end def test_radial_density | ||
#end if |
Oops, something went wrong.