Skip to content

Commit

Permalink
Merge pull request #3554 from jtkrogel/nx_ws21_fix2
Browse files Browse the repository at this point in the history
Nexus: better error handling for bad Jastrow requests
  • Loading branch information
ye-luo authored Oct 23, 2021
2 parents c92934d + 537802b commit 38bcf10
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions nexus/lib/qmcpack_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -5247,6 +5247,9 @@ def generate_jastrows_alt(

openbc = system.structure.is_open()

natoms = system.particles.count_ions()
nelec = system.particles.count_electrons()

jastrows = []
J2 |= J3
J1 |= J2
Expand All @@ -5256,6 +5259,9 @@ def generate_jastrows_alt(
#end if
rwigner = None
if J1:
if natoms<1:
QmcpackInput.class_error('One-body Jastrow (J1) requested, but no atoms are present','generate_jastrows_alt')
#end if
if J1_rcut is None:
if openbc:
J1_rcut = J1_rcut_open
Expand All @@ -5273,6 +5279,9 @@ def generate_jastrows_alt(
jastrows.append(J)
#end if
if J2:
if nelec<2:
QmcpackInput.class_error('Two-body Jastrow (J2) requested, but not enough electrons are present.\nElectrons required: 2 or more\nElectrons present: {}'.format(nelec),'generate_jastrows_alt')
#end if
if J2_rcut is None:
if openbc:
J2_rcut = J2_rcut_open
Expand All @@ -5290,6 +5299,9 @@ def generate_jastrows_alt(
jastrows.append(J)
#end if
if J3:
if natoms<1 or nelec<2:
QmcpackInput.class_error('Three-body Jastrow (J3) requested, but not enough particles are present.\nAtoms required: 1 or more\nElectrons required: 2 or more\nAtoms present: {}\nElectrons present: {}'.format(natoms,nelec),'generate_jastrows_alt')
#end if
if not openbc:
if rwigner is None:
rwigner = system.structure.rwigner(1)
Expand Down

0 comments on commit 38bcf10

Please sign in to comment.