Skip to content

Commit

Permalink
Merge branch 'develop' into update-SplineSPO
Browse files Browse the repository at this point in the history
  • Loading branch information
ye-luo authored Oct 18, 2024
2 parents 105a3b3 + e80f956 commit 7f3fe2e
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 21 deletions.
26 changes: 15 additions & 11 deletions nexus/bin/qdens
Original file line number Diff line number Diff line change
Expand Up @@ -309,8 +309,8 @@ class SingleDensity(QDBase):
self.check_type('grid' ,grid ,'tuple/list/ndarray',(tuple,list,np.ndarray))
self.check_type('structure',structure,'Structure' ,Structure)
self.check_type('extension',extension,'string' ,str)
self.check_type('density_cell' ,grid ,'tuple/list/ndarray',(tuple,list,np.ndarray))
self.check_type('density_corner',grid ,'tuple/list/ndarray',(tuple,list,np.ndarray))
self.check_type('density_cell' ,grid,'tuple/list/ndarray',(tuple,list,np.ndarray))
self.check_type('density_corner',grid,'tuple/list/ndarray',(tuple,list,np.ndarray))
# process other inputs
if mean is not None:
self.mean = np.array(mean,dtype=float)
Expand All @@ -335,19 +335,12 @@ class SingleDensity(QDBase):
self._error('inputted density_corner must have length 3, received {0}'.format(density_corner))
#end if
self.density_corner = np.array(density_corner,dtype=float)
else:
self.density_corner = np.zeros(3) # If density_corner is not given, use [0, 0, 0] as corner
#end if
if density_cell is not None:
if len(np.array(density_cell).ravel())!=9:
self._error('inputted density_cell must have length 9, received {0}'.format(density_cell))
#end if
self.density_cell = np.array(density_cell,dtype=float)
else:
# If density_cell is not given, use the structure cell
s = self.structure.copy()
s.change_units('A')
self.density_cell = s.axes
#end if
if data is not None:
self.analyze(data)
Expand Down Expand Up @@ -1128,12 +1121,21 @@ class QMCDensityProcessor(QDBase):
self.error('could not identify grid data for spin density named "{0}"\bin QMCPACK input file: {1}'.format(name,opt.input))
#end if
if 'cell' in sd:
self.error('Currently, the cell keyword is not supported due to a bug: See https://github.com/QMCPACK/qmcpack/issues/5201')
density_cell = sd.cell.copy()
density_cell = convert(density_cell, 'B', 'A')
else:
# If density_cell is not given, use the structure cell
dens_struct = structure.copy()
dens_struct.change_units('A')
density_cell = dens_struct.axes
#end if
if 'corner' in sd:
self.error('Currently, the corner keyword is not supported due to a bug: See https://github.com/QMCPACK/qmcpack/issues/5201')
density_corner = sd.corner.copy()
density_corner = convert(density_corner, 'B', 'A')
else:
density_corner = np.zeros(3) # If density_corner is not given, use [0, 0, 0] as corner
#end if
elif name not in grids and isinstance(xml,density_xml):
sd = xml
Expand Down Expand Up @@ -1203,6 +1205,7 @@ class QMCDensityProcessor(QDBase):

# --density_cell option
if opt.density_cell is not None:
self.error('Currently, the cell keyword is not supported due to a bug: See https://github.com/QMCPACK/qmcpack/issues/5201')
density_cell = input_list(opt.density_cell)
try:
density_cell = np.array(density_cell,dtype=float)
Expand All @@ -1220,11 +1223,12 @@ class QMCDensityProcessor(QDBase):

# --density_corner option
if opt.density_corner is not None:
self.error('Currently, the corner keyword is not supported due to a bug: See https://github.com/QMCPACK/qmcpack/issues/5201')
density_corner = input_list(opt.density_corner)
try:
density_corner = np.array(density_corner,dtype=int)
density_corner = np.array(density_corner,dtype=float)
except:
self.error('--density_corner input misformatted\nexpected a list of integers\nreceived: {0}'.format(density_corner))
self.error('--density_corner input misformatted\nexpected a list of floats\nreceived: {0}'.format(density_corner))
#end try
if len(density_corner)!=3:
self.error('--density_corner input misformatted\nexpected 3 elements\nreceived {0} elements with values: {1}'.format(len(density_corner),density_corner))
Expand Down
26 changes: 16 additions & 10 deletions nexus/lib/qmcpack.py
Original file line number Diff line number Diff line change
Expand Up @@ -931,16 +931,22 @@ def incorporate_result(self,result_name,result,sim):
J3 = optwf.get('J3')
if J3 is not None:
corr = J3.get('correlation')
j3_ids = []
for j3_term in corr:
j3_id = j3_term.coefficients.id
j3_ids.append(j3_id)
#end for
for j3_id in j3_ids:
if 'ud' in j3_id:
delattr(corr, j3_id)
#end if
#end for
if hasattr(corr, 'coefficients'):
# For single-species systems, the data structure changes.
# In this case, the only J3 term should be 'uu'.
# Otherwise, the user might be trying to do something strange.
assert 'uu' in corr.coefficients.id, 'Only uu J3 terms are allowed in SOC calculations.'
else:
j3_ids = []
for j3_term in corr:
j3_id = j3_term.coefficients.id
j3_ids.append(j3_id)
#end for
for j3_id in j3_ids:
if 'ud' in j3_id:
delattr(corr, j3_id)
#end if
#end for
#end if
#end if
def process_jastrow(wf):
Expand Down

0 comments on commit 7f3fe2e

Please sign in to comment.