Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nexus: better error handling for bad Jastrow requests #3554

Merged
merged 2 commits into from
Oct 23, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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