SetGlobas Translation - Most
Internal methods translations: read_keywords, check_keywords, print_keywords, read_potential Signed-off-by: Vitor Hideyoshi <vitor.h.n.batista@gmail.com>
This commit is contained in:
@@ -20,10 +20,12 @@ class System:
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|
||||||
self.molecule = []
|
self.molecule = []
|
||||||
|
self.nmols = []
|
||||||
|
|
||||||
def add_molecule(self, m):
|
def add_type(self,nmols, m):
|
||||||
|
|
||||||
self.molecule.append(m)
|
self.molecule.append(m)
|
||||||
|
self.nmols = nmols
|
||||||
|
|
||||||
# Função que calcula a distância entre dois centros de massa
|
# Função que calcula a distância entre dois centros de massa
|
||||||
# e por se tratar de uma função de dois atomos não deve ser
|
# e por se tratar de uma função de dois atomos não deve ser
|
||||||
@@ -192,6 +194,7 @@ class Molecule:
|
|||||||
self.gradient = None # Array Numpy
|
self.gradient = None # Array Numpy
|
||||||
self.hessian = None # Array Numpy
|
self.hessian = None # Array Numpy
|
||||||
self.total_mass = 0
|
self.total_mass = 0
|
||||||
|
self.com = None
|
||||||
|
|
||||||
def add_atom(self, a):
|
def add_atom(self, a):
|
||||||
|
|
||||||
@@ -210,7 +213,7 @@ class Molecule:
|
|||||||
|
|
||||||
com = com / total_mass
|
com = com / total_mass
|
||||||
|
|
||||||
return com
|
self.com = com
|
||||||
|
|
||||||
def center_of_mass_to_origin(self):
|
def center_of_mass_to_origin(self):
|
||||||
|
|
||||||
@@ -477,4 +480,3 @@ class Atom:
|
|||||||
self.eps = eps # Double
|
self.eps = eps # Double
|
||||||
self.sig = sig # Double
|
self.sig = sig # Double
|
||||||
self.mass = atommass[self.na] # Double
|
self.mass = atommass[self.na] # Double
|
||||||
|
|
||||||
@@ -144,440 +144,440 @@ env = ["OMP_STACKSIZE"]
|
|||||||
## Functions to process the input files and store the values in the global variables ##
|
## Functions to process the input files and store the values in the global variables ##
|
||||||
##########################################################################################
|
##########################################################################################
|
||||||
|
|
||||||
def read_keywords(infile):
|
# def read_keywords(infile):
|
||||||
|
|
||||||
try:
|
# try:
|
||||||
with open(infile) as fh:
|
# with open(infile) as fh:
|
||||||
controlfile = fh.readlines()
|
# controlfile = fh.readlines()
|
||||||
except EnvironmentError:
|
# except EnvironmentError:
|
||||||
sys.exit("Error: cannot open file {}".format(infile))
|
# sys.exit("Error: cannot open file {}".format(infile))
|
||||||
|
|
||||||
for line in controlfile:
|
# for line in controlfile:
|
||||||
|
|
||||||
key, value = line.partition("=")[::2] # Discards the '='
|
# key, value = line.partition("=")[::2] # Discards the '='
|
||||||
key = key.strip().lower()
|
# key = key.strip().lower()
|
||||||
if key in ('title', 'keywords'):
|
# if key in ('title', 'keywords'):
|
||||||
value = value.strip()
|
# value = value.strip()
|
||||||
else:
|
# else:
|
||||||
value = value.split()
|
# value = value.split()
|
||||||
|
|
||||||
#### Read the Diceplayer related keywords
|
# #### Read the Diceplayer related keywords
|
||||||
if key in player and len(value) != 0: ## 'value' is not empty!
|
# if key in player and len(value) != 0: ## 'value' is not empty!
|
||||||
|
|
||||||
if key == 'qmprog' and value[0].lower() in ("g03", "g09", "g16", "molcas"):
|
# if key == 'qmprog' and value[0].lower() in ("g03", "g09", "g16", "molcas"):
|
||||||
player[key] = value[0].lower()
|
# player[key] = value[0].lower()
|
||||||
|
|
||||||
elif key == 'opt' and value[0].lower() in ("yes", "no", "ts"):
|
# elif key == 'opt' and value[0].lower() in ("yes", "no", "ts"):
|
||||||
player[key] = value[0].lower()
|
# player[key] = value[0].lower()
|
||||||
|
|
||||||
#elif key == 'zipprog' and value[0].lower() in ("zip", "gzip", "bzip"):
|
# #elif key == 'zipprog' and value[0].lower() in ("zip", "gzip", "bzip"):
|
||||||
#player[key] = value[0].lower()
|
# #player[key] = value[0].lower()
|
||||||
|
|
||||||
elif key in ('lps', 'ghosts') and value[0].lower() in ("yes", "no"):
|
# elif key in ('lps', 'ghosts') and value[0].lower() in ("yes", "no"):
|
||||||
player[key] = value[0].lower()
|
# player[key] = value[0].lower()
|
||||||
|
|
||||||
elif key in ('readhessian', 'vdwforces') and value[0].lower() in ("yes", "no"):
|
# elif key in ('readhessian', 'vdwforces') and value[0].lower() in ("yes", "no"):
|
||||||
player[key] = value[0].lower()
|
# player[key] = value[0].lower()
|
||||||
|
|
||||||
elif key in ('maxcyc', 'initcyc', 'nprocs', 'altsteps', 'switchcyc'):
|
# elif key in ('maxcyc', 'initcyc', 'nprocs', 'altsteps', 'switchcyc'):
|
||||||
err = "Error: expected a positive integer for keyword {} in file {}".format(key, infile)
|
# err = "Error: expected a positive integer for keyword {} in file {}".format(key, infile)
|
||||||
try:
|
# try:
|
||||||
new_value = int(value[0])
|
# new_value = int(value[0])
|
||||||
if new_value >= 1:
|
# if new_value >= 1:
|
||||||
player[key] = new_value
|
# player[key] = new_value
|
||||||
elif key == 'altsteps' and new_value == 0:
|
# elif key == 'altsteps' and new_value == 0:
|
||||||
player[key] = 0
|
# player[key] = 0
|
||||||
except ValueError:
|
# except ValueError:
|
||||||
sys.exit(err)
|
# sys.exit(err)
|
||||||
|
|
||||||
elif key == 'maxstep': # Cannot be less than 0.01
|
# elif key == 'maxstep': # Cannot be less than 0.01
|
||||||
err = "Error: expected a float greater than 0.01 for keyword {} in file {}".format(key, infile)
|
# err = "Error: expected a float greater than 0.01 for keyword {} in file {}".format(key, infile)
|
||||||
try:
|
# try:
|
||||||
new_value = float(value[0])
|
# new_value = float(value[0])
|
||||||
if new_value < 0.01:
|
# if new_value < 0.01:
|
||||||
sys.exit(err)
|
# sys.exit(err)
|
||||||
else:
|
# else:
|
||||||
player[key] = new_value
|
# player[key] = new_value
|
||||||
except ValueError:
|
# except ValueError:
|
||||||
sys.exit(err)
|
# sys.exit(err)
|
||||||
|
|
||||||
#### Read the Dice related keywords
|
# #### Read the Dice related keywords
|
||||||
elif key in dice and len(value) != 0: ## 'value' is not empty!
|
# elif key in dice and len(value) != 0: ## 'value' is not empty!
|
||||||
|
|
||||||
if key == 'title':
|
# if key == 'title':
|
||||||
dice[key] = value
|
# dice[key] = value
|
||||||
|
|
||||||
elif key in ('ljname', 'outname', 'progname'):
|
# elif key in ('ljname', 'outname', 'progname'):
|
||||||
dice[key] = value[0]
|
# dice[key] = value[0]
|
||||||
|
|
||||||
elif key in ('ncores', 'isave'):
|
# elif key in ('ncores', 'isave'):
|
||||||
err = "Error: expected a positive integer for keyword {} in file {}".format(key, infile)
|
# err = "Error: expected a positive integer for keyword {} in file {}".format(key, infile)
|
||||||
if not value[0].isdigit():
|
# if not value[0].isdigit():
|
||||||
sys.exit(err)
|
# sys.exit(err)
|
||||||
new_value = int(value[0])
|
# new_value = int(value[0])
|
||||||
if new_value >= 1:
|
# if new_value >= 1:
|
||||||
dice[key] = new_value
|
# dice[key] = new_value
|
||||||
|
|
||||||
elif key in ('temp', 'press', 'dens'): # Cannot be less than 1e-10
|
# elif key in ('temp', 'press', 'dens'): # Cannot be less than 1e-10
|
||||||
err = "Error: expected a positive float for keyword {} in file {}".format(key, infile)
|
# err = "Error: expected a positive float for keyword {} in file {}".format(key, infile)
|
||||||
try:
|
# try:
|
||||||
new_value = float(value[0])
|
# new_value = float(value[0])
|
||||||
if new_value < 1e-10:
|
# if new_value < 1e-10:
|
||||||
sys.exit(err)
|
# sys.exit(err)
|
||||||
else:
|
# else:
|
||||||
dice[key] = new_value
|
# dice[key] = new_value
|
||||||
except ValueError:
|
# except ValueError:
|
||||||
sys.exit(err)
|
# sys.exit(err)
|
||||||
|
|
||||||
elif key == 'nmol': # If defined, must be well defined (only positive integer values)
|
# elif key == 'nmol': # If defined, must be well defined (only positive integer values)
|
||||||
err = "Error: expected 1 to 4 positive integers for keyword {} in file {}".format(key, infile)
|
# err = "Error: expected 1 to 4 positive integers for keyword {} in file {}".format(key, infile)
|
||||||
args = min(4, len(value))
|
# args = min(4, len(value))
|
||||||
for i in range(args):
|
# for i in range(args):
|
||||||
if value[i].isdigit():
|
# if value[i].isdigit():
|
||||||
new_value = int(value[i])
|
# new_value = int(value[i])
|
||||||
if new_value < 1:
|
# if new_value < 1:
|
||||||
sys.exit(err)
|
# sys.exit(err)
|
||||||
else:
|
# else:
|
||||||
dice[key].append(new_value)
|
# dice[key].append(new_value)
|
||||||
elif i == 0:
|
# elif i == 0:
|
||||||
sys.exit(err)
|
# sys.exit(err)
|
||||||
else:
|
# else:
|
||||||
break
|
# break
|
||||||
|
|
||||||
elif key == 'nstep': # If defined, must be well defined (only positive integer values)
|
# elif key == 'nstep': # If defined, must be well defined (only positive integer values)
|
||||||
err = "Error: expected 2 or 3 positive integers for keyword {} in file {}".format(key, infile)
|
# err = "Error: expected 2 or 3 positive integers for keyword {} in file {}".format(key, infile)
|
||||||
if len(value) < 2:
|
# if len(value) < 2:
|
||||||
sys.exit(err)
|
# sys.exit(err)
|
||||||
args = min(3, len(value))
|
# args = min(3, len(value))
|
||||||
for i in range(args):
|
# for i in range(args):
|
||||||
if value[i].isdigit():
|
# if value[i].isdigit():
|
||||||
new_value = int(value[i])
|
# new_value = int(value[i])
|
||||||
if new_value < 1:
|
# if new_value < 1:
|
||||||
sys.exit(err)
|
# sys.exit(err)
|
||||||
else:
|
# else:
|
||||||
dice[key].append(new_value)
|
# dice[key].append(new_value)
|
||||||
elif i < 2:
|
# elif i < 2:
|
||||||
sys.exit(err)
|
# sys.exit(err)
|
||||||
else:
|
# else:
|
||||||
break
|
# break
|
||||||
|
|
||||||
#### Read the Gaussian related keywords
|
# #### Read the Gaussian related keywords
|
||||||
elif key in gaussian and len(value) != 0: ## 'value' is not empty!
|
# elif key in gaussian and len(value) != 0: ## 'value' is not empty!
|
||||||
|
|
||||||
if key == 'mem': # Memory in MB (minimum of 100)
|
# if key == 'mem': # Memory in MB (minimum of 100)
|
||||||
err = "Error: expected a positive integer for keyword {} in file {}".format(key, infile)
|
# err = "Error: expected a positive integer for keyword {} in file {}".format(key, infile)
|
||||||
if not value[0].isdigit():
|
# if not value[0].isdigit():
|
||||||
sys.exit(err)
|
# sys.exit(err)
|
||||||
new_value = int(value[0])
|
# new_value = int(value[0])
|
||||||
if new_value >= 100:
|
# if new_value >= 100:
|
||||||
gaussian[key] = new_value
|
# gaussian[key] = new_value
|
||||||
|
|
||||||
elif key == 'keywords':
|
# elif key == 'keywords':
|
||||||
gaussian[key] = value
|
# gaussian[key] = value
|
||||||
|
|
||||||
elif key == 'chgmult': # If defined, must be well defined (2 integer values)
|
# elif key == 'chgmult': # If defined, must be well defined (2 integer values)
|
||||||
err = "Error: expected 2 integers for keyword {} in file {}".format(key, infile)
|
# err = "Error: expected 2 integers for keyword {} in file {}".format(key, infile)
|
||||||
if len(value) < 2:
|
# if len(value) < 2:
|
||||||
sys.exit(err)
|
# sys.exit(err)
|
||||||
for i in range (2):
|
# for i in range (2):
|
||||||
try:
|
# try:
|
||||||
gaussian[key][i] = int(value[i])
|
# gaussian[key][i] = int(value[i])
|
||||||
except ValueError:
|
# except ValueError:
|
||||||
sys.exit(err)
|
# sys.exit(err)
|
||||||
|
|
||||||
elif key in ('level', 'chglevel'):
|
# elif key in ('level', 'chglevel'):
|
||||||
gaussian[key] = value[0]
|
# gaussian[key] = value[0]
|
||||||
|
|
||||||
elif key in ('gmiddle', 'gbottom'):
|
# elif key in ('gmiddle', 'gbottom'):
|
||||||
gaussian[key] = value[0]
|
# gaussian[key] = value[0]
|
||||||
|
|
||||||
elif key == 'pop' and value[0].lower() in ("chelpg", "mk", "nbo"):
|
# elif key == 'pop' and value[0].lower() in ("chelpg", "mk", "nbo"):
|
||||||
gaussian[key] = value[0].lower()
|
# gaussian[key] = value[0].lower()
|
||||||
|
|
||||||
#### Read the Molcas related keywords
|
# #### Read the Molcas related keywords
|
||||||
elif key in molcas and len(value) != 0: ## 'value' is not empty!
|
# elif key in molcas and len(value) != 0: ## 'value' is not empty!
|
||||||
|
|
||||||
if key == 'root': # If defined, must be well defined (only positive integer values)
|
# if key == 'root': # If defined, must be well defined (only positive integer values)
|
||||||
err = "Error: expected a positive integer for keyword {} in file {}".format(key, infile)
|
# err = "Error: expected a positive integer for keyword {} in file {}".format(key, infile)
|
||||||
if not value[0].isdigit():
|
# if not value[0].isdigit():
|
||||||
sys.exit(err)
|
# sys.exit(err)
|
||||||
new_value = int(value[0])
|
# new_value = int(value[0])
|
||||||
if new_value >= 1:
|
# if new_value >= 1:
|
||||||
molcas[key] = new_value
|
# molcas[key] = new_value
|
||||||
|
|
||||||
elif key in ('mbottom', 'orbfile'):
|
# elif key in ('mbottom', 'orbfile'):
|
||||||
molcas[key] = value[0]
|
# molcas[key] = value[0]
|
||||||
|
|
||||||
elif key == 'basis':
|
# elif key == 'basis':
|
||||||
molcas[key] = value[0]
|
# molcas[key] = value[0]
|
||||||
|
|
||||||
#### End
|
# #### End
|
||||||
return
|
# return
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def check_keywords(infile):
|
# def check_keywords(infile):
|
||||||
|
|
||||||
min_steps = 20000
|
# min_steps = 20000
|
||||||
|
|
||||||
if dice['ljname'] == None:
|
# if dice['ljname'] == None:
|
||||||
sys.exit("Error: 'ljname' keyword not specified in file {}".format(infile))
|
# sys.exit("Error: 'ljname' keyword not specified in file {}".format(infile))
|
||||||
|
|
||||||
if dice['outname'] == None:
|
# if dice['outname'] == None:
|
||||||
sys.exit("Error: 'outname' keyword not specified in file {}".format(infile))
|
# sys.exit("Error: 'outname' keyword not specified in file {}".format(infile))
|
||||||
|
|
||||||
if dice['dens'] == None:
|
# if dice['dens'] == None:
|
||||||
sys.exit("Error: 'dens' keyword not specified in file {}".format(infile))
|
# sys.exit("Error: 'dens' keyword not specified in file {}".format(infile))
|
||||||
|
|
||||||
if len(dice['nmol']) == 0:
|
# if len(dice['nmol']) == 0:
|
||||||
sys.exit("Error: 'nmol' keyword not defined appropriately in file {}".format(infile))
|
# sys.exit("Error: 'nmol' keyword not defined appropriately in file {}".format(infile))
|
||||||
|
|
||||||
if len(dice['nstep']) == 0:
|
# if len(dice['nstep']) == 0:
|
||||||
sys.exit("Error: 'nstep' keyword not defined appropriately in file {}".format(infile))
|
# sys.exit("Error: 'nstep' keyword not defined appropriately in file {}".format(infile))
|
||||||
|
|
||||||
## Check only if QM program is Gaussian:
|
# ## Check only if QM program is Gaussian:
|
||||||
if player['qmprog'] in ("g03", "g09", "g16"):
|
# if player['qmprog'] in ("g03", "g09", "g16"):
|
||||||
if gaussian['level'] == None:
|
# if gaussian['level'] == None:
|
||||||
sys.exit("Error: 'level' keyword not specified in file {}".format(infile))
|
# sys.exit("Error: 'level' keyword not specified in file {}".format(infile))
|
||||||
|
|
||||||
if gaussian['gmiddle'] != None:
|
# if gaussian['gmiddle'] != None:
|
||||||
if not os.path.isfile(gaussian['gmiddle']):
|
# if not os.path.isfile(gaussian['gmiddle']):
|
||||||
sys.exit("Error: file {} not found".format(gaussian['gmiddle']))
|
# sys.exit("Error: file {} not found".format(gaussian['gmiddle']))
|
||||||
|
|
||||||
if gaussian['gbottom'] != None:
|
# if gaussian['gbottom'] != None:
|
||||||
if not os.path.isfile(gaussian['gbottom']):
|
# if not os.path.isfile(gaussian['gbottom']):
|
||||||
sys.exit("Error: file {} not found".format(gaussian['gbottom']))
|
# sys.exit("Error: file {} not found".format(gaussian['gbottom']))
|
||||||
|
|
||||||
if gaussian['pop'] != "chelpg" and (player['ghosts'] == "yes" or player['lps'] == "yes"):
|
# if gaussian['pop'] != "chelpg" and (player['ghosts'] == "yes" or player['lps'] == "yes"):
|
||||||
sys.exit("Error: ghost atoms or lone pairs only available with 'pop = chelpg')")
|
# sys.exit("Error: ghost atoms or lone pairs only available with 'pop = chelpg')")
|
||||||
|
|
||||||
if gaussian['chglevel'] == None:
|
# if gaussian['chglevel'] == None:
|
||||||
gaussian['chglevel'] = gaussian['level']
|
# gaussian['chglevel'] = gaussian['level']
|
||||||
|
|
||||||
## Check only if QM program is Molcas:
|
# ## Check only if QM program is Molcas:
|
||||||
if player['qmprog'] == "molcas":
|
# if player['qmprog'] == "molcas":
|
||||||
|
|
||||||
if molcas['mbottom'] == None:
|
# if molcas['mbottom'] == None:
|
||||||
sys.exit("Error: 'mbottom' keyword not specified in file {}".format(infile))
|
# sys.exit("Error: 'mbottom' keyword not specified in file {}".format(infile))
|
||||||
else:
|
# else:
|
||||||
if not os.path.isfile(molcas['mbottom']):
|
# if not os.path.isfile(molcas['mbottom']):
|
||||||
sys.exit("Error: file {} not found".format(molcas['mbottom']))
|
# sys.exit("Error: file {} not found".format(molcas['mbottom']))
|
||||||
|
|
||||||
if molcas['basis'] == None:
|
# if molcas['basis'] == None:
|
||||||
sys.exit("Error: 'basis' keyword not specified in file {}".format(infile))
|
# sys.exit("Error: 'basis' keyword not specified in file {}".format(infile))
|
||||||
|
|
||||||
|
|
||||||
if player['altsteps'] != 0:
|
# if player['altsteps'] != 0:
|
||||||
|
|
||||||
### Verifica se tem mais de 1 molecula QM
|
# ### Verifica se tem mais de 1 molecula QM
|
||||||
### (No futuro usar o RMSD fit para poder substituir todas as moleculas QM
|
# ### (No futuro usar o RMSD fit para poder substituir todas as moleculas QM
|
||||||
### no arquivo outname.xy - Need to change the make_init_file!!)
|
# ### no arquivo outname.xy - Need to change the make_init_file!!)
|
||||||
if dice['nmol'][0] > 1:
|
# if dice['nmol'][0] > 1:
|
||||||
sys.exit("Error: altsteps > 0 only possible with 1 QM molecule (nmol = 1 n2 n3 n4)")
|
# sys.exit("Error: altsteps > 0 only possible with 1 QM molecule (nmol = 1 n2 n3 n4)")
|
||||||
|
|
||||||
# if not zero, altsteps cannot be less than min_steps
|
# # if not zero, altsteps cannot be less than min_steps
|
||||||
player['altsteps'] = max(min_steps, player['altsteps'])
|
# player['altsteps'] = max(min_steps, player['altsteps'])
|
||||||
# altsteps value is always the nearest multiple of 1000
|
# # altsteps value is always the nearest multiple of 1000
|
||||||
player['altsteps'] = round(player['altsteps'] / 1000) * 1000
|
# player['altsteps'] = round(player['altsteps'] / 1000) * 1000
|
||||||
|
|
||||||
|
|
||||||
for i in range(len(dice['nstep'])):
|
# for i in range(len(dice['nstep'])):
|
||||||
# nstep can never be less than min_steps
|
# # nstep can never be less than min_steps
|
||||||
dice['nstep'][i] = max(min_steps, dice['nstep'][i])
|
# dice['nstep'][i] = max(min_steps, dice['nstep'][i])
|
||||||
# nstep values are always the nearest multiple of 1000
|
# # nstep values are always the nearest multiple of 1000
|
||||||
dice['nstep'][i] = round(dice['nstep'][i] / 1000) * 1000
|
# dice['nstep'][i] = round(dice['nstep'][i] / 1000) * 1000
|
||||||
|
|
||||||
# isave must be between 100 and 2000
|
# # isave must be between 100 and 2000
|
||||||
dice['isave'] = max(100, dice['isave'])
|
# dice['isave'] = max(100, dice['isave'])
|
||||||
dice['isave'] = min(2000, dice['isave'])
|
# dice['isave'] = min(2000, dice['isave'])
|
||||||
# isave value is always the nearest multiple of 100
|
# # isave value is always the nearest multiple of 100
|
||||||
dice['isave'] = round(dice['isave'] / 100) * 100
|
# dice['isave'] = round(dice['isave'] / 100) * 100
|
||||||
|
|
||||||
return
|
# return
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def print_keywords(fh):
|
# def print_keywords(fh):
|
||||||
|
|
||||||
fh.write("##########################################################################################\n"
|
# fh.write("##########################################################################################\n"
|
||||||
"############# Welcome to DICEPLAYER version 1.0 #############\n"
|
# "############# Welcome to DICEPLAYER version 1.0 #############\n"
|
||||||
"##########################################################################################\n"
|
# "##########################################################################################\n"
|
||||||
"\n")
|
# "\n")
|
||||||
fh.write("Your python version is {}\n".format(sys.version))
|
# fh.write("Your python version is {}\n".format(sys.version))
|
||||||
fh.write("\n")
|
# fh.write("\n")
|
||||||
fh.write("Program started on {}\n".format(weekday_date_time()))
|
# fh.write("Program started on {}\n".format(weekday_date_time()))
|
||||||
fh.write("\n")
|
# fh.write("\n")
|
||||||
fh.write("Environment variables:\n")
|
# fh.write("Environment variables:\n")
|
||||||
for var in env:
|
# for var in env:
|
||||||
fh.write("{} = {}\n".format(var,
|
# fh.write("{} = {}\n".format(var,
|
||||||
(os.environ[var] if var in os.environ else "Not set")))
|
# (os.environ[var] if var in os.environ else "Not set")))
|
||||||
|
|
||||||
fh.write("\n==========================================================================================\n"
|
# fh.write("\n==========================================================================================\n"
|
||||||
" CONTROL variables being used in this run:\n"
|
# " CONTROL variables being used in this run:\n"
|
||||||
"------------------------------------------------------------------------------------------\n"
|
# "------------------------------------------------------------------------------------------\n"
|
||||||
"\n")
|
# "\n")
|
||||||
|
|
||||||
for key in sorted(player):
|
# for key in sorted(player):
|
||||||
if player[key] != None:
|
# if player[key] != None:
|
||||||
if isinstance(player[key], list):
|
# if isinstance(player[key], list):
|
||||||
string = " ".join(str(x) for x in player[key])
|
# string = " ".join(str(x) for x in player[key])
|
||||||
fh.write("{} = {}\n".format(key, string))
|
# fh.write("{} = {}\n".format(key, string))
|
||||||
else:
|
# else:
|
||||||
fh.write("{} = {}\n".format(key, player[key]))
|
# fh.write("{} = {}\n".format(key, player[key]))
|
||||||
|
|
||||||
fh.write("\n")
|
# fh.write("\n")
|
||||||
|
|
||||||
fh.write("------------------------------------------------------------------------------------------\n"
|
# fh.write("------------------------------------------------------------------------------------------\n"
|
||||||
" DICE variables being used in this run:\n"
|
# " DICE variables being used in this run:\n"
|
||||||
"------------------------------------------------------------------------------------------\n"
|
# "------------------------------------------------------------------------------------------\n"
|
||||||
"\n")
|
# "\n")
|
||||||
|
|
||||||
for key in sorted(dice):
|
# for key in sorted(dice):
|
||||||
if dice[key] != None:
|
# if dice[key] != None:
|
||||||
if isinstance(dice[key], list):
|
# if isinstance(dice[key], list):
|
||||||
string = " ".join(str(x) for x in dice[key])
|
# string = " ".join(str(x) for x in dice[key])
|
||||||
fh.write("{} = {}\n".format(key, string))
|
# fh.write("{} = {}\n".format(key, string))
|
||||||
else:
|
# else:
|
||||||
fh.write("{} = {}\n".format(key, dice[key]))
|
# fh.write("{} = {}\n".format(key, dice[key]))
|
||||||
|
|
||||||
fh.write("\n")
|
# fh.write("\n")
|
||||||
|
|
||||||
if player['qmprog'] in ("g03", "g09", "g16"):
|
# if player['qmprog'] in ("g03", "g09", "g16"):
|
||||||
|
|
||||||
fh.write("------------------------------------------------------------------------------------------\n"
|
# fh.write("------------------------------------------------------------------------------------------\n"
|
||||||
" GAUSSIAN variables being used in this run:\n"
|
# " GAUSSIAN variables being used in this run:\n"
|
||||||
"------------------------------------------------------------------------------------------\n"
|
# "------------------------------------------------------------------------------------------\n"
|
||||||
"\n")
|
# "\n")
|
||||||
|
|
||||||
for key in sorted(gaussian):
|
# for key in sorted(gaussian):
|
||||||
if gaussian[key] != None:
|
# if gaussian[key] != None:
|
||||||
if isinstance(gaussian[key], list):
|
# if isinstance(gaussian[key], list):
|
||||||
string = " ".join(str(x) for x in gaussian[key])
|
# string = " ".join(str(x) for x in gaussian[key])
|
||||||
fh.write("{} = {}\n".format(key, string))
|
# fh.write("{} = {}\n".format(key, string))
|
||||||
else:
|
# else:
|
||||||
fh.write("{} = {}\n".format(key, gaussian[key]))
|
# fh.write("{} = {}\n".format(key, gaussian[key]))
|
||||||
|
|
||||||
fh.write("\n")
|
# fh.write("\n")
|
||||||
|
|
||||||
elif player['qmprog'] == "molcas":
|
# elif player['qmprog'] == "molcas":
|
||||||
|
|
||||||
fh.write("------------------------------------------------------------------------------------------\n"
|
# fh.write("------------------------------------------------------------------------------------------\n"
|
||||||
" MOLCAS variables being used in this run:\n"
|
# " MOLCAS variables being used in this run:\n"
|
||||||
"------------------------------------------------------------------------------------------\n"
|
# "------------------------------------------------------------------------------------------\n"
|
||||||
"\n")
|
# "\n")
|
||||||
|
|
||||||
for key in sorted(molcas):
|
# for key in sorted(molcas):
|
||||||
if molcas[key] != None:
|
# if molcas[key] != None:
|
||||||
if isinstance(molcas[key], list):
|
# if isinstance(molcas[key], list):
|
||||||
string = " ".join(str(x) for x in molcas[key])
|
# string = " ".join(str(x) for x in molcas[key])
|
||||||
fh.write("{} = {}\n".format(key, string))
|
# fh.write("{} = {}\n".format(key, string))
|
||||||
else:
|
# else:
|
||||||
fh.write("{} = {}\n".format(key, molcas[key]))
|
# fh.write("{} = {}\n".format(key, molcas[key]))
|
||||||
|
|
||||||
fh.write("\n")
|
# fh.write("\n")
|
||||||
|
|
||||||
return
|
# return
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def read_potential(infile): # Deve ser atualizado para o uso de
|
# def read_potential(infile): # Deve ser atualizado para o uso de
|
||||||
|
|
||||||
try:
|
# try:
|
||||||
with open(dice['ljname']) as file:
|
# with open(dice['ljname']) as file:
|
||||||
ljfile = file.readlines()
|
# ljfile = file.readlines()
|
||||||
except EnvironmentError as err:
|
# except EnvironmentError as err:
|
||||||
sys.exit(err)
|
# sys.exit(err)
|
||||||
|
|
||||||
combrule = ljfile.pop(0).split()[0]
|
# combrule = ljfile.pop(0).split()[0]
|
||||||
if combrule not in ("*", "+"):
|
# if combrule not in ("*", "+"):
|
||||||
sys.exit("Error: expected a '*' or a '+' sign in 1st line of file {}".format(dice['ljname']))
|
# sys.exit("Error: expected a '*' or a '+' sign in 1st line of file {}".format(dice['ljname']))
|
||||||
dice['combrule'] = combrule
|
# dice['combrule'] = combrule
|
||||||
|
|
||||||
ntypes = ljfile.pop(0).split()[0]
|
# ntypes = ljfile.pop(0).split()[0]
|
||||||
if not ntypes.isdigit():
|
# if not ntypes.isdigit():
|
||||||
sys.exit("Error: expected an integer in the 2nd line of file {}".format(dice['ljname']))
|
# sys.exit("Error: expected an integer in the 2nd line of file {}".format(dice['ljname']))
|
||||||
ntypes = int(ntypes)
|
# ntypes = int(ntypes)
|
||||||
|
|
||||||
if ntypes != len(dice['nmol']):
|
# if ntypes != len(dice['nmol']):
|
||||||
sys.exit("Error: number of molecule types in file {} must match that of 'nmol' keyword in file {}".format(
|
# sys.exit("Error: number of molecule types in file {} must match that of 'nmol' keyword in file {}".format(
|
||||||
dice['ljname'], infile))
|
# dice['ljname'], infile))
|
||||||
|
|
||||||
line = 2
|
# line = 2
|
||||||
for i in range(ntypes):
|
# for i in range(ntypes):
|
||||||
line += 1
|
# line += 1
|
||||||
nsites = ljfile.pop(0).split()[0]
|
# nsites = ljfile.pop(0).split()[0]
|
||||||
if not nsites.isdigit():
|
# if not nsites.isdigit():
|
||||||
sys.exit("Error: expected an integer in line {} of file {}".format(line, dice['ljname']))
|
# sys.exit("Error: expected an integer in line {} of file {}".format(line, dice['ljname']))
|
||||||
|
|
||||||
nsites = int(nsites)
|
# nsites = int(nsites)
|
||||||
molecules.append([])
|
# molecules.append([])
|
||||||
|
|
||||||
for j in range(nsites):
|
# for j in range(nsites):
|
||||||
line += 1
|
# line += 1
|
||||||
new_atom = ljfile.pop(0).split()
|
# new_atom = ljfile.pop(0).split()
|
||||||
|
|
||||||
if len(new_atom) < 8:
|
# if len(new_atom) < 8:
|
||||||
sys.exit("Error: expected at least 8 fields in line {} of file {}".format(line, dice['ljname']))
|
# sys.exit("Error: expected at least 8 fields in line {} of file {}".format(line, dice['ljname']))
|
||||||
|
|
||||||
molecules[i].append({})
|
# molecules[i].append({})
|
||||||
|
|
||||||
if not new_atom[0].isdigit():
|
# if not new_atom[0].isdigit():
|
||||||
sys.exit("Error: expected an integer in field 1, line {} of file {}".format(line, dice['ljname']))
|
# sys.exit("Error: expected an integer in field 1, line {} of file {}".format(line, dice['ljname']))
|
||||||
molecules[i][j]['lbl'] = int(new_atom[0])
|
# molecules[i][j]['lbl'] = int(new_atom[0])
|
||||||
|
|
||||||
if not new_atom[1].isdigit():
|
# if not new_atom[1].isdigit():
|
||||||
sys.exit("Error: expected an integer in field 2, line {} of file {}".format(line, dice['ljname']))
|
# sys.exit("Error: expected an integer in field 2, line {} of file {}".format(line, dice['ljname']))
|
||||||
|
|
||||||
atnumber = int(new_atom[1])
|
# atnumber = int(new_atom[1])
|
||||||
if atnumber == ghost_number and i == 0: # Ghost atom not allowed in the QM molecule
|
# if atnumber == ghost_number and i == 0: # Ghost atom not allowed in the QM molecule
|
||||||
sys.exit("Error: found a ghost atom in line {} of file {}".format(line, dice['ljname']))
|
# sys.exit("Error: found a ghost atom in line {} of file {}".format(line, dice['ljname']))
|
||||||
molecules[i][j]['na'] = atnumber
|
# molecules[i][j]['na'] = atnumber
|
||||||
|
|
||||||
try:
|
# try:
|
||||||
molecules[i][j]['rx'] = float(new_atom[2])
|
# molecules[i][j]['rx'] = float(new_atom[2])
|
||||||
except:
|
# except:
|
||||||
sys.exit("Error: expected a float in field 3, line {} of file {}".format(line, dice['ljname']))
|
# sys.exit("Error: expected a float in field 3, line {} of file {}".format(line, dice['ljname']))
|
||||||
|
|
||||||
try:
|
# try:
|
||||||
molecules[i][j]['ry'] = float(new_atom[3])
|
# molecules[i][j]['ry'] = float(new_atom[3])
|
||||||
except:
|
# except:
|
||||||
sys.exit("Error: expected a float in field 4, line {} of file {}".format(line, dice['ljname']))
|
# sys.exit("Error: expected a float in field 4, line {} of file {}".format(line, dice['ljname']))
|
||||||
|
|
||||||
try:
|
# try:
|
||||||
molecules[i][j]['rz'] = float(new_atom[4])
|
# molecules[i][j]['rz'] = float(new_atom[4])
|
||||||
except:
|
# except:
|
||||||
sys.exit("Error: expected a float in field 5, line {} of file {}".format(line, dice['ljname']))
|
# sys.exit("Error: expected a float in field 5, line {} of file {}".format(line, dice['ljname']))
|
||||||
|
|
||||||
try:
|
# try:
|
||||||
molecules[i][j]['chg'] = float(new_atom[5])
|
# molecules[i][j]['chg'] = float(new_atom[5])
|
||||||
except:
|
# except:
|
||||||
sys.exit("Error: expected a float in field 6, line {} of file {}".format(line, dice['ljname']))
|
# sys.exit("Error: expected a float in field 6, line {} of file {}".format(line, dice['ljname']))
|
||||||
|
|
||||||
try:
|
# try:
|
||||||
molecules[i][j]['eps'] = float(new_atom[6])
|
# molecules[i][j]['eps'] = float(new_atom[6])
|
||||||
except:
|
# except:
|
||||||
sys.exit("Error: expected a float in field 7, line {} of file {}".format(line, dice['ljname']))
|
# sys.exit("Error: expected a float in field 7, line {} of file {}".format(line, dice['ljname']))
|
||||||
|
|
||||||
try:
|
# try:
|
||||||
molecules[i][j]['sig'] = float(new_atom[7])
|
# molecules[i][j]['sig'] = float(new_atom[7])
|
||||||
except:
|
# except:
|
||||||
sys.exit("Error: expected a float in field 8, line {} of file {}".format(line, dice['ljname']))
|
# sys.exit("Error: expected a float in field 8, line {} of file {}".format(line, dice['ljname']))
|
||||||
|
|
||||||
molecules[i][j]['mass'] = atommass[molecules[i][j]['na']]
|
# molecules[i][j]['mass'] = atommass[molecules[i][j]['na']]
|
||||||
|
|
||||||
if len(new_atom) > 8:
|
# if len(new_atom) > 8:
|
||||||
masskey, mass = new_atom[8].partition("=")[::2]
|
# masskey, mass = new_atom[8].partition("=")[::2]
|
||||||
if masskey.lower() == 'mass' and len(mass) !=0:
|
# if masskey.lower() == 'mass' and len(mass) !=0:
|
||||||
try:
|
# try:
|
||||||
new_mass = float(mass)
|
# new_mass = float(mass)
|
||||||
if new_mass > 0:
|
# if new_mass > 0:
|
||||||
molecules[i][j]['mass'] = new_mass
|
# molecules[i][j]['mass'] = new_mass
|
||||||
except:
|
# except:
|
||||||
sys.exit(
|
# sys.exit(
|
||||||
"Error: expected a positive float after 'mass=' in field 9, line {} of file {}".format(
|
# "Error: expected a positive float after 'mass=' in field 9, line {} of file {}".format(
|
||||||
line, dice['ljname']))
|
# line, dice['ljname']))
|
||||||
|
|
||||||
return
|
# return
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -2,14 +2,21 @@ import os, sys
|
|||||||
import shutil
|
import shutil
|
||||||
import textwrap
|
import textwrap
|
||||||
|
|
||||||
|
from DPpack.MolHandling import *
|
||||||
from DPpack.PTable import *
|
from DPpack.PTable import *
|
||||||
from DPpack.Misc import *
|
from DPpack.Misc import *
|
||||||
|
|
||||||
|
env = ["OMP_STACKSIZE"]
|
||||||
|
|
||||||
|
bohr2ang = 0.52917721092
|
||||||
|
ang2bohr = 1/bohr2ang
|
||||||
|
|
||||||
class Internal:
|
class Internal:
|
||||||
|
|
||||||
def __init__(self, infile):
|
def __init__(self, infile):
|
||||||
|
|
||||||
self.infile = infile
|
self.infile = infile
|
||||||
|
self.system = System()
|
||||||
|
|
||||||
self.player = self.Player()
|
self.player = self.Player()
|
||||||
self.player_keywords = [a for a in dir(self.player) if not a.startswith('__') and not callable(getattr(self.player, a))]
|
self.player_keywords = [a for a in dir(self.player) if not a.startswith('__') and not callable(getattr(self.player, a))]
|
||||||
@@ -20,8 +27,8 @@ class Internal:
|
|||||||
self.gaussian = self.Gaussian()
|
self.gaussian = self.Gaussian()
|
||||||
self.gaussian_keywords = [a for a in dir(self.gaussian) if not a.startswith('__') and not callable(getattr(self.gaussian, a))]
|
self.gaussian_keywords = [a for a in dir(self.gaussian) if not a.startswith('__') and not callable(getattr(self.gaussian, a))]
|
||||||
|
|
||||||
self.molcas = self.Molcas()
|
# self.molcas = self.Molcas()
|
||||||
self.molcas_keywords = [a for a in dir(self.molcas) if not a.startswith('__') and not callable(getattr(self.molcas, a))]
|
# self.molcas_keywords = [a for a in dir(self.molcas) if not a.startswith('__') and not callable(getattr(self.molcas, a))]
|
||||||
|
|
||||||
## Constanst that shall be set for global use
|
## Constanst that shall be set for global use
|
||||||
|
|
||||||
@@ -189,7 +196,7 @@ class Internal:
|
|||||||
elif key in self.molcas_keywords and len(value) != 0: ## 'value' is not empty!
|
elif key in self.molcas_keywords and len(value) != 0: ## 'value' is not empty!
|
||||||
|
|
||||||
if key == 'root': # If defined, must be well defined (only positive integer values)
|
if key == 'root': # If defined, must be well defined (only positive integer values)
|
||||||
err = "Error: expected a positive integer for keyword {} in file {}".format(key, infile)
|
err = "Error: expected a positive integer for keyword {} in file {}".format(key, self.infile)
|
||||||
if not value[0].isdigit():
|
if not value[0].isdigit():
|
||||||
sys.exit(err)
|
sys.exit(err)
|
||||||
new_value = int(value[0])
|
new_value = int(value[0])
|
||||||
@@ -204,12 +211,276 @@ class Internal:
|
|||||||
|
|
||||||
#### End
|
#### End
|
||||||
|
|
||||||
|
|
||||||
|
def check_keywords(self):
|
||||||
|
|
||||||
|
min_steps = 20000
|
||||||
|
|
||||||
|
if self.dice.ljname == None:
|
||||||
|
sys.exit("Error: 'ljname' keyword not specified in file {}".format(self.infile))
|
||||||
|
|
||||||
|
if self.dice.outname == None:
|
||||||
|
sys.exit("Error: 'outname' keyword not specified in file {}".format(self.infile))
|
||||||
|
|
||||||
|
if self.dice.dens == None:
|
||||||
|
sys.exit("Error: 'dens' keyword not specified in file {}".format(self.infile))
|
||||||
|
|
||||||
|
if len(self.dice.nmol) == 0:
|
||||||
|
sys.exit("Error: 'nmol' keyword not defined appropriately in file {}".format(self.infile))
|
||||||
|
|
||||||
|
if len(self.dice.nstep) == 0:
|
||||||
|
sys.exit("Error: 'nstep' keyword not defined appropriately in file {}".format(self.infile))
|
||||||
|
|
||||||
|
## Check only if QM program is Gaussian:
|
||||||
|
if self.player.qmprog in ("g03", "g09", "g16"):
|
||||||
|
|
||||||
|
if self.gaussian.level == None:
|
||||||
|
sys.exit("Error: 'level' keyword not specified in file {}".format(self.infile))
|
||||||
|
|
||||||
|
if self.gaussian.gmiddle != None:
|
||||||
|
if not os.path.isfile(self.gaussian.gmiddle):
|
||||||
|
sys.exit("Error: file {} not found".format(self.gaussian.gmiddle))
|
||||||
|
|
||||||
|
if self.gaussian.gbottom != None:
|
||||||
|
if not os.path.isfile(self.gaussian.gbottom):
|
||||||
|
sys.exit("Error: file {} not found".format(self.gaussian.gbottom))
|
||||||
|
|
||||||
|
if self.gaussian.pop != "chelpg" and (self.player.ghosts == "yes" or self.player.lps == "yes"):
|
||||||
|
sys.exit("Error: ghost atoms or lone pairs only available with 'pop = chelpg')")
|
||||||
|
|
||||||
|
if self.gaussian.chglevel == None:
|
||||||
|
self.gaussian.chglevel = self.gaussian.level
|
||||||
|
|
||||||
|
## Check only if QM program is Molcas:
|
||||||
|
# if self.player.qmprog == "molcas":
|
||||||
|
|
||||||
|
# if self.molcas.mbottom == None:
|
||||||
|
# sys.exit("Error: 'mbottom' keyword not specified in file {}".format(self.infile))
|
||||||
|
# else:
|
||||||
|
# if not os.path.isfile(self.molcas.mbottom):
|
||||||
|
# sys.exit("Error: file {} not found".format(self.molcas.mbottom))
|
||||||
|
|
||||||
|
# if self.molcas.basis == None:
|
||||||
|
# sys.exit("Error: 'basis' keyword not specified in file {}".format(self.infile))
|
||||||
|
|
||||||
|
|
||||||
|
if self.player.altsteps != 0:
|
||||||
|
|
||||||
|
### Verifica se tem mais de 1 molecula QM
|
||||||
|
### (No futuro usar o RMSD fit para poder substituir todas as moleculas QM
|
||||||
|
### no arquivo outname.xy - Need to change the make_init_file!!)
|
||||||
|
if self.dice.nmol[0] > 1:
|
||||||
|
sys.exit("Error: altsteps > 0 only possible with 1 QM molecule (nmol = 1 n2 n3 n4)")
|
||||||
|
|
||||||
|
# if not zero, altsteps cannot be less than min_steps
|
||||||
|
self.player.altsteps = max(min_steps, self.player.altsteps)
|
||||||
|
# altsteps value is always the nearest multiple of 1000
|
||||||
|
self.player.altsteps = round(self.player.altsteps / 1000) * 1000
|
||||||
|
|
||||||
|
|
||||||
|
for i in range(len(self.dice.nstep)):
|
||||||
|
# nstep can never be less than min_steps
|
||||||
|
self.dice.nstep[i] = max(min_steps, self.dice.nstep[i])
|
||||||
|
# nstep values are always the nearest multiple of 1000
|
||||||
|
self.dice.nstep[i] = round(self.dice.nstep[i] / 1000) * 1000
|
||||||
|
|
||||||
|
# isave must be between 100 and 2000
|
||||||
|
self.dice.isave = max(100, self.dice.isave)
|
||||||
|
self.dice.isave = min(2000, self.dice.isave)
|
||||||
|
# isave value is always the nearest multiple of 100
|
||||||
|
self.dice.isave = round(self.dice.isave / 100) * 100
|
||||||
|
|
||||||
|
def print_keywords(self, fh):
|
||||||
|
|
||||||
|
fh.write("##########################################################################################\n"
|
||||||
|
"############# Welcome to DICEPLAYER version 1.0 #############\n"
|
||||||
|
"##########################################################################################\n"
|
||||||
|
"\n")
|
||||||
|
fh.write("Your python version is {}\n".format(sys.version))
|
||||||
|
fh.write("\n")
|
||||||
|
fh.write("Program started on {}\n".format(weekday_date_time()))
|
||||||
|
fh.write("\n")
|
||||||
|
fh.write("Environment variables:\n")
|
||||||
|
for var in env:
|
||||||
|
fh.write("{} = {}\n".format(var,
|
||||||
|
(os.environ[var] if var in os.environ else "Not set")))
|
||||||
|
|
||||||
|
fh.write("\n==========================================================================================\n"
|
||||||
|
" CONTROL variables being used in this run:\n"
|
||||||
|
"------------------------------------------------------------------------------------------\n"
|
||||||
|
"\n")
|
||||||
|
|
||||||
|
for key in sorted(self.player_keywords):
|
||||||
|
if getattr(self.player,key) != None:
|
||||||
|
if isinstance(getattr(self.player,key), list):
|
||||||
|
string = " ".join(str(x) for x in getattr(self.player,key))
|
||||||
|
fh.write("{} = {}\n".format(key, string))
|
||||||
|
else:
|
||||||
|
fh.write("{} = {}\n".format(key, getattr(self.player,key)))
|
||||||
|
|
||||||
|
fh.write("\n")
|
||||||
|
|
||||||
|
fh.write("------------------------------------------------------------------------------------------\n"
|
||||||
|
" DICE variables being used in this run:\n"
|
||||||
|
"------------------------------------------------------------------------------------------\n"
|
||||||
|
"\n")
|
||||||
|
|
||||||
|
for key in sorted(self.dice_keywords):
|
||||||
|
if getattr(self.dice,key) != None:
|
||||||
|
if isinstance(getattr(self.dice,key), list):
|
||||||
|
string = " ".join(str(x) for x in getattr(self.dice,key))
|
||||||
|
fh.write("{} = {}\n".format(key, string))
|
||||||
|
else:
|
||||||
|
fh.write("{} = {}\n".format(key, getattr(self.dice,key)))
|
||||||
|
|
||||||
|
fh.write("\n")
|
||||||
|
|
||||||
|
if self.player.qmprog in ("g03", "g09", "g16"):
|
||||||
|
|
||||||
|
fh.write("------------------------------------------------------------------------------------------\n"
|
||||||
|
" GAUSSIAN variables being used in this run:\n"
|
||||||
|
"------------------------------------------------------------------------------------------\n"
|
||||||
|
"\n")
|
||||||
|
|
||||||
|
for key in sorted(self.gaussian_keywords):
|
||||||
|
if getattr(self.gaussian,key) != None:
|
||||||
|
if isinstance(getattr(self.gaussian,key), list):
|
||||||
|
string = " ".join(str(x) for x in getattr(self.gaussian,key))
|
||||||
|
fh.write("{} = {}\n".format(key, string))
|
||||||
|
else:
|
||||||
|
fh.write("{} = {}\n".format(key, getattr(self.gaussian,key)))
|
||||||
|
|
||||||
|
fh.write("\n")
|
||||||
|
|
||||||
|
# elif self.player.qmprog == "molcas":
|
||||||
|
|
||||||
|
# fh.write("------------------------------------------------------------------------------------------\n"
|
||||||
|
# " MOLCAS variables being used in this run:\n"
|
||||||
|
# "------------------------------------------------------------------------------------------\n"
|
||||||
|
# "\n")
|
||||||
|
|
||||||
|
# for key in sorted(molcas):
|
||||||
|
# if molcas[key] != None:
|
||||||
|
# if isinstance(molcas[key], list):
|
||||||
|
# string = " ".join(str(x) for x in molcas[key])
|
||||||
|
# fh.write("{} = {}\n".format(key, string))
|
||||||
|
# else:
|
||||||
|
# fh.write("{} = {}\n".format(key, molcas[key]))
|
||||||
|
|
||||||
|
# fh.write("\n")
|
||||||
|
|
||||||
|
def read_potential(self): # Deve ser atualizado para o uso de
|
||||||
|
|
||||||
|
try:
|
||||||
|
with open(self.dice.ljname) as file:
|
||||||
|
ljfile = file.readlines()
|
||||||
|
except EnvironmentError as err:
|
||||||
|
sys.exit(err)
|
||||||
|
|
||||||
|
combrule = ljfile.pop(0).split()[0]
|
||||||
|
if combrule not in ("*", "+"):
|
||||||
|
sys.exit("Error: expected a '*' or a '+' sign in 1st line of file {}".format(self.dice.ljname))
|
||||||
|
self.dice.combrule = combrule
|
||||||
|
|
||||||
|
ntypes = ljfile.pop(0).split()[0]
|
||||||
|
if not ntypes.isdigit():
|
||||||
|
sys.exit("Error: expected an integer in the 2nd line of file {}".format(self.dice.ljname))
|
||||||
|
ntypes = int(ntypes)
|
||||||
|
|
||||||
|
if ntypes != len(self.dice.nmol):
|
||||||
|
sys.exit("Error: number of molecule types in file {} must match that of 'nmol' keyword in file {}".format(
|
||||||
|
self.dice.ljname, self.infile))
|
||||||
|
|
||||||
|
line = 2
|
||||||
|
for i in range(ntypes):
|
||||||
|
|
||||||
|
line += 1
|
||||||
|
nsites = ljfile.pop(0).split()[0]
|
||||||
|
if not nsites.isdigit():
|
||||||
|
sys.exit("Error: expected an integer in line {} of file {}".format(line, self.dice.ljname))
|
||||||
|
|
||||||
|
nsites = int(nsites)
|
||||||
|
self.system.add_type(Molecule())
|
||||||
|
|
||||||
|
for j in range(nsites):
|
||||||
|
|
||||||
|
line += 1
|
||||||
|
new_atom = ljfile.pop(0).split()
|
||||||
|
|
||||||
|
if len(new_atom) < 8:
|
||||||
|
sys.exit("Error: expected at least 8 fields in line {} of file {}".format(line, dice['ljname']))
|
||||||
|
|
||||||
|
self.system.molecule[i].add_atom()
|
||||||
|
|
||||||
|
if not new_atom[0].isdigit():
|
||||||
|
sys.exit("Error: expected an integer in field 1, line {} of file {}".format(line, dice['ljname']))
|
||||||
|
lbl = int(new_atom[0])
|
||||||
|
|
||||||
|
if not new_atom[1].isdigit():
|
||||||
|
sys.exit("Error: expected an integer in field 2, line {} of file {}".format(line, dice['ljname']))
|
||||||
|
|
||||||
|
atnumber = int(new_atom[1])
|
||||||
|
if atnumber == ghost_number and i == 0: # Ghost atom not allowed in the QM molecule
|
||||||
|
sys.exit("Error: found a ghost atom in line {} of file {}".format(line, dice['ljname']))
|
||||||
|
na = atnumber
|
||||||
|
|
||||||
|
try:
|
||||||
|
rx = float(new_atom[2])
|
||||||
|
except:
|
||||||
|
sys.exit("Error: expected a float in field 3, line {} of file {}".format(line, dice['ljname']))
|
||||||
|
|
||||||
|
try:
|
||||||
|
ry = float(new_atom[3])
|
||||||
|
except:
|
||||||
|
sys.exit("Error: expected a float in field 4, line {} of file {}".format(line, dice['ljname']))
|
||||||
|
|
||||||
|
try:
|
||||||
|
rz = float(new_atom[4])
|
||||||
|
except:
|
||||||
|
sys.exit("Error: expected a float in field 5, line {} of file {}".format(line, dice['ljname']))
|
||||||
|
|
||||||
|
try:
|
||||||
|
chg = float(new_atom[5])
|
||||||
|
except:
|
||||||
|
sys.exit("Error: expected a float in field 6, line {} of file {}".format(line, dice['ljname']))
|
||||||
|
|
||||||
|
try:
|
||||||
|
eps = float(new_atom[6])
|
||||||
|
except:
|
||||||
|
sys.exit("Error: expected a float in field 7, line {} of file {}".format(line, dice['ljname']))
|
||||||
|
|
||||||
|
try:
|
||||||
|
sig = float(new_atom[7])
|
||||||
|
except:
|
||||||
|
sys.exit("Error: expected a float in field 8, line {} of file {}".format(line, dice['ljname']))
|
||||||
|
|
||||||
|
mass = atommass[na]
|
||||||
|
|
||||||
|
if len(new_atom) > 8:
|
||||||
|
masskey, mass = new_atom[8].partition("=")[::2]
|
||||||
|
if masskey.lower() == 'mass' and len(mass) !=0:
|
||||||
|
try:
|
||||||
|
new_mass = float(mass)
|
||||||
|
if new_mass > 0:
|
||||||
|
mass = new_mass
|
||||||
|
except:
|
||||||
|
sys.exit(
|
||||||
|
"Error: expected a positive float after 'mass=' in field 9, line {} of file {}".format(
|
||||||
|
line, dice['ljname']))
|
||||||
|
|
||||||
|
self.system.molecule[i].add_atom(Atom(lbl,na,rx,ry,rz,chg,eps,sig,mass))
|
||||||
|
|
||||||
|
to_delete = ['lbl','na','rx','ry','rz','chg','eps','sig','mass']
|
||||||
|
for _var in to_delete:
|
||||||
|
if _var in locals() or _var in globals():
|
||||||
|
exec(f'del {_var}')
|
||||||
|
|
||||||
class Player:
|
class Player:
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|
||||||
self.maxcyc = None
|
self.maxcyc = None
|
||||||
self.initcyc = 1
|
# self.initcyc = 1 Eliminated
|
||||||
self.nprocs = 1
|
self.nprocs = 1
|
||||||
self.switchcyc = 3
|
self.switchcyc = 3
|
||||||
self.altsteps = 20000
|
self.altsteps = 20000
|
||||||
@@ -237,7 +508,7 @@ class Internal:
|
|||||||
self.ncores = 1
|
self.ncores = 1
|
||||||
|
|
||||||
self.dens = None # Investigate the possibility of using 'box = Lx Ly Lz' instead.
|
self.dens = None # Investigate the possibility of using 'box = Lx Ly Lz' instead.
|
||||||
#dice['box'] = None # So 'geom' would be set by diceplayer and 'cutoff' would be
|
# self.box = None # So 'geom' would be set by diceplayer and 'cutoff' would be
|
||||||
# switched off. One of them must be given.
|
# switched off. One of them must be given.
|
||||||
self.ljname = None
|
self.ljname = None
|
||||||
self.outname = None
|
self.outname = None
|
||||||
@@ -261,12 +532,12 @@ class Internal:
|
|||||||
|
|
||||||
self.level = None
|
self.level = None
|
||||||
|
|
||||||
class Molcas:
|
# class Molcas:
|
||||||
|
|
||||||
def __init(self):
|
# def __init(self):
|
||||||
|
|
||||||
self.orbfile = "input.exporb"
|
# self.orbfile = "input.exporb"
|
||||||
self.root = 1
|
# self.root = 1
|
||||||
|
|
||||||
self.mbottom = None
|
# self.mbottom = None
|
||||||
self.basis = None
|
# self.basis = None
|
||||||
Reference in New Issue
Block a user