Skip to content

Commit

Permalink
Merge branch 'develop' into add_dense_hamiltonian
Browse files Browse the repository at this point in the history
  • Loading branch information
mmorale3 authored Dec 6, 2019
2 parents bd5619c + efdfa85 commit 09b3063
Show file tree
Hide file tree
Showing 5 changed files with 144 additions and 57 deletions.
77 changes: 74 additions & 3 deletions nexus/lib/gamess.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,13 @@


import os
import numpy as np
from numpy import array,ndarray,abs
from generic import obj
from developer import DevBase
from debug import *
from simulation import Simulation
from gamess_input import GamessInput,generate_gamess_input,FormattedGroup,KeywordGroup,GuessGroup
from gamess_input import GamessInput,generate_gamess_input,FormattedGroup,KeywordGroup,GuessGroup,GIarray
from gamess_analyzer import GamessAnalyzer


Expand Down Expand Up @@ -67,6 +68,16 @@ def restore_default_settings():
#end def restore_default_settings


def __init__(self,**kwargs):
self.mo_reorder = None
mo_reorder = kwargs.pop('mo_reorder',None)
if mo_reorder is not None:
self.mo_reorder = [s.lower() for s in mo_reorder]
#end if
Simulation.__init__(self,**kwargs)
#end def __init__


def init_job_extra(self):
# gamess seems to need lots of environment variables to run properly
# nearly all of these are names of output/work files
Expand Down Expand Up @@ -114,6 +125,9 @@ def get_result(self,result_name,sim):
result.norbitals = analyzer.punch.norbitals
result.vec = analyzer.punch.vec
#end if
if 'orbitals' in analyzer:
result.orbitals = analyzer.orbitals
#end if
else:
self.error('ability to get result '+result_name+' has not been implemented')
#end if
Expand All @@ -135,7 +149,64 @@ def incorporate_result(self,result_name,result,sim):
else:
norb = result.norbitals
#end if
input.guess.clear()
if 'norder' not in input.guess:
input.guess.clear()
#end if
if self.mo_reorder is not None:
if 'orbitals' not in result:
self.error('Orbital information from prior calculation "{}" located at {} cannot be found. You requested orbital reordering via the "mo_reorder" input keyword. Due to missing information, this operation cannot be performed. The current simulation "{}" is located at {}.'.format(sim.identifier,sim.locdir,self.identifier,self.locdir))
self.block()
#end if
guess_inputs = obj()
ecounts = self.system.particles.electron_counts()
orbs = result.orbitals
order_map = obj(up='iorder',down='jorder')
nelec_map = obj(up=ecounts[0],down=ecounts[1])
for spin,vname in order_map.items():
nelec = nelec_map[spin]
if len(self.mo_reorder)<nelec:
self.error('Too few symmetries provided in "mo_reorder" for spin "{0}".\nNumber of electrons with spin "{0}": {1}\nNumber of entries in "mo_reorder": {2}\nContents of "mo_reorder": {3}\nSimulation identifier: {4}\nSimulation location: {5}'.format(spin,nelec,len(self.mo_reorder),self.mo_reorder,self.identifier,self.locdir))
#end if
symmetries = [s.lower() for s in orbs[spin].symmetry]
missing = set(self.mo_reorder)-set(symmetries)
if len(missing)>0:
self.error('Symmetries provided by "mo_reorder" keyword are not found in the outputted MOs.\nSet of symmetries provided in "mo_reorder": {}\nSet of symmetries present in MOs: {}\nContents of "mo_reorder": {}\nSimulation identifier: {}\nSimulation location: {}'.format(sorted(set(self.mo_reorder)),sorted(set(symmetries)),self.mo_reorder,self.identifier,self.locdir))
#end if
occ = np.zeros(len(symmetries),dtype=bool)
for symm in self.mo_reorder[:nelec]:
for i,(s,o) in enumerate(zip(symmetries,occ)):
if not o and symm==s:
occ[i] = True
break
#end if
#end for
#end for
if occ.sum()<nelec:
self.error('Too few orbitals occupied based on "mo_reorder" request.\nNumber of orbitals occupied: {}\nNumber of spin "{}" electrons: {}\nContents of "mo_reorder": {}\nSimulation identifier: {}\nSimulation location: {}'.format(occ.sum(),spin,nelec,self.mo_reorder,self.identifier,self.locdir))
#end if
indices = np.arange(len(symmetries),dtype=int)[occ]+1
start = 0
found = False
for i in range(len(indices)):
start = i
if indices[i]!=i+1:
found = True
break
#end if
#end if
if found:
reduced_indices = indices[start:]
start+=1
else:
reduced_indices = []
#end if
if len(reduced_indices)>0:
guess_inputs.norder = 1
guess_inputs[vname] = GIarray({start:reduced_indices})
#end if
#end for
input.guess.set(**guess_inputs)
#end if
input.guess.set(
guess = 'moread',
norb = norb,
Expand Down Expand Up @@ -194,7 +265,7 @@ def output_filepath(self,name):


def generate_gamess(**kwargs):
sim_args,inp_args = Gamess.separate_inputs(kwargs,copy_pseudos=False)
sim_args,inp_args = Gamess.separate_inputs(kwargs,copy_pseudos=False,sim_kw=['mo_reorder'])

if not 'input' in sim_args:
sim_args.input = generate_gamess_input(**inp_args)
Expand Down
89 changes: 47 additions & 42 deletions nexus/lib/gamess_analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def analyze_log(self):
#end if

# try to get the up/down orbitals
if 'counts' in self and False: # don't read orbitals, large
if 'counts' in self:
orbitals = obj()
try:
self.read_orbitals(log,orbitals,'up' ,'-- ALPHA SET --')
Expand Down Expand Up @@ -264,39 +264,43 @@ def read_orbitals(self,log,orbs,spec,header):
#end if
eigenvalue.extend(log.readtokens())
symmetry.extend(log.readtokens())
coeff = []
# skip large coefficient data
for icao in xrange(cao_tot):
tokens = log.readtokens()
if not have_basis:
e = tokens[1]
element.append(e[0].upper()+e[1:].lower())
spec_index.append(tokens[2])
angular.append(tokens[3])
#end if
coeff.append(tokens[4:])
log.readline()
#end for
coefficients.extend(array(coeff,dtype=float).T)
if not have_basis:
stype = []
ptype = []
dtype = []
ftype = []
for ia in xrange(len(angular)):
a = angular[ia].lower()
if a in GamessAnalyzer.stypes:
stype.append(ia)
elif a in GamessAnalyzer.ptypes:
ptype.append(ia)
elif a in GamessAnalyzer.dtypes:
dtype.append(ia)
elif a in GamessAnalyzer.ftypes:
ftype.append(ia)
elif self.info.exit:
self.error('unrecognized angular type: {0}'.format(angular[ia]))
#end if
#end for
#end if
have_basis = True
#coeff = []
#for icao in xrange(cao_tot):
# tokens = log.readtokens()
# if not have_basis:
# e = tokens[1]
# element.append(e[0].upper()+e[1:].lower())
# spec_index.append(tokens[2])
# angular.append(tokens[3])
# #end if
# coeff.append(tokens[4:])
##end for
#coefficients.extend(array(coeff,dtype=float).T)
#if not have_basis:
# stype = []
# ptype = []
# dtype = []
# ftype = []
# for ia in xrange(len(angular)):
# a = angular[ia].lower()
# if a in GamessAnalyzer.stypes:
# stype.append(ia)
# elif a in GamessAnalyzer.ptypes:
# ptype.append(ia)
# elif a in GamessAnalyzer.dtypes:
# dtype.append(ia)
# elif a in GamessAnalyzer.ftypes:
# ftype.append(ia)
# elif self.info.exit:
# self.error('unrecognized angular type: {0}'.format(angular[ia]))
# #end if
# #end for
##end if
#have_basis = True
mos_found = len(eigenvalue)
i+=1
#end while
Expand All @@ -309,16 +313,17 @@ def read_orbitals(self,log,orbs,spec,header):
orbs[spec] = obj(
eigenvalue = array(eigenvalue ,dtype=float),
symmetry = array(symmetry ,dtype=str ),
coefficients = array(coefficients,dtype=float),
basis = obj(
element = array(element ,dtype=str),
spec_index = array(spec_index,dtype=int),
angular = array(angular ,dtype=str),
stype = array(stype ,dtype=int),
ptype = array(ptype ,dtype=int),
dtype = array(dtype ,dtype=int),
ftype = array(ftype ,dtype=int),
)
# skip large coefficient data
#coefficients = array(coefficients,dtype=float),
#basis = obj(
# element = array(element ,dtype=str),
# spec_index = array(spec_index,dtype=int),
# angular = array(angular ,dtype=str),
# stype = array(stype ,dtype=int),
# ptype = array(ptype ,dtype=int),
# dtype = array(dtype ,dtype=int),
# ftype = array(ftype ,dtype=int),
# )
)
#end if
return success
Expand Down
9 changes: 7 additions & 2 deletions nexus/lib/simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,14 +284,19 @@ def code_name(cls):

# test needed
@classmethod
def separate_inputs(cls,kwargs,overlapping_kw=-1,copy_pseudos=True):
def separate_inputs(cls,kwargs,overlapping_kw=-1,copy_pseudos=True,sim_kw=None):
if overlapping_kw==-1:
overlapping_kw = set(['system'])
elif overlapping_kw is None:
overlapping_kw = set()
#end if
if sim_kw is None:
sim_kw = set()
else:
sim_kw = set(sim_kw)
#end if
kw = set(kwargs.keys())
sim_kw = kw & Simulation.allowed_inputs
sim_kw = kw & (Simulation.allowed_inputs | sim_kw)
inp_kw = (kw - sim_kw) | (kw & overlapping_kw)
sim_args = obj()
inp_args = obj()
Expand Down
2 changes: 1 addition & 1 deletion src/QMCTools/PyscfToQmcpack.py
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ def order_mo_coef(ll):
GroupCell.create_dataset("LatticeVectors",(3,3),dtype="f8",data=loc_cell.lattice_vectors())

def get_mo(mo_coeff, cart):
return order_mo_coef(mo_coeff) if cart else zip(*mo_coeff)
return order_mo_coef(mo_coeff) if cart else list(zip(*mo_coeff))

#Supertwist Coordinate
GroupDet.create_dataset("Coord",(1,3),dtype="f8",data=sp_twist)
Expand Down
24 changes: 15 additions & 9 deletions tests/test_automation/nightly_anl_bora.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,31 @@
# Run the "short" nightlies
#

# load necessary modules
source /etc/profile.d/z00_lmod.sh
if [ -d /scratch/packages/modulefiles ]; then
module use /scratch/packages/modulefiles
fi

module load intel-mkl intel/18.4
module load openmpi/4.0.2-intel
module load cuda/10.1

export TEST_SITE_NAME=bora.alcf.anl.gov
export N_PROCS_BUILD=16
export N_PROCS=16
export N_PROCS_BUILD=16
export N_CONCURRENT_TESTS=16
export CC=mpicc
export CXX=mpicxx
export BOOST_ROOT=/sandbox/opt/boost_1_61_0

# run on socket 1
NUMA_ID=1

#CUDA
export PATH=/sandbox/opt/NVIDIA/cuda-10.0/bin:$PATH
export LD_LIBRARY_PATH=/sandbox/opt/NVIDIA/cuda-10.0/lib64:$LD_LIBRARY_PATH

QE_BIN=/sandbox/opt/qe-stable/qe-6.4.1/bin
QMC_DATA=/sandbox/opt/h5data
QE_BIN=/scratch/opt/qe-stable/qe-6.4.1/bin
QMC_DATA=/scratch/opt/h5data

#Must be an absolute path
place=/sandbox/QMCPACK_CI_BUILDS_DO_NOT_REMOVE
place=/scratch/QMCPACK_CI_BUILDS_DO_NOT_REMOVE

#define and load compiler
compiler=Intel2018
Expand Down

0 comments on commit 09b3063

Please sign in to comment.