本文整理汇总了Python中molecule.Molecule.add_quantum方法的典型用法代码示例。如果您正苦于以下问题:Python Molecule.add_quantum方法的具体用法?Python Molecule.add_quantum怎么用?Python Molecule.add_quantum使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类molecule.Molecule
的用法示例。
在下文中一共展示了Molecule.add_quantum方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: QChem
# 需要导入模块: from molecule import Molecule [as 别名]
# 或者: from molecule.Molecule import add_quantum [as 别名]
class QChem(object):
"""
Class for facilitating Q-Chem calculations. I wrote this
because it was helpful to execute a chain of calculations on a
single geometry.
"""
def __init__(self, fin, ftype=None, charge=None, mult=None, method=None,
basis=None, qcin=None, qcout=None, qcdir=None, readsave=None,
readguess=True, clean=False, qcsave=True):
"""
Create a QChem object.
Parameters
----------
fin : str
Name of input .xyz or .in file (other coordinate files in
molecule.py supported as well). The .in file will contain
settings for the Q-Chem calculation whereas the .xyz file
does not; in this case, default fields are filled in, but
the user must procide charge / mult / method / basis.
ftype : str, optional
Force the Molecule class to read the input file as this format.
charge : int, optional
Net charge. Required if xyz coordinates are provided. If
Q-Chem input and charge are both provided, this will override.
mult : int, optional
Spin multiplicity. Required if xyz coordinates are provided.
If Q-Chem input and mult are both provided, this will override.
method : str, optional
Electronic structure method (e.g. b3lyp). This is written
to the "method" field in the Q-Chem input file - supported
by Q-Chem 4.2 and later. Required if xyz coordinate are
provided. If Q-Chem input and method are both provided, this
will override.
basis : str, optional
Gaussian basis set (e.g. 6-31g*). This is written to the
"basis" field in the Q-Chem input file. Required if xyz
coordinate are provided. If Q-Chem input and basis
are both provided, this will override.
qcin : str, optional
Base name of Q-Chem input files to be written. If not provided,
will use "fin" (extension will be changed to ".qcin" if necessary
to avoid overwriting input file.)
qcout : str, optional
Base name of Q-Chem output files. If not provided, will use "qcin"
base name and ".out" extension.
qcdir : str, optional
Base name of Q-Chem temporary folder. If not provided, will use "qcin"
base name and ".d" extension. NOTE: This folder will be removed prior
to calculation start! Also, will create a ".dsav" folder used to recover
from failed calculations, think of it as a "save game file".
readsave : str or bool, optional
If set to True, the "qcdsav" (i.e. qcdir+"sav") folder will automatically
be used to initialize this calculation.
If string, this is a folder containing Q-Chem files used to initialize
this calculation. This folder will be copied to "self.qcdsav" and self.qcdsav
will NOT be removed prior to calculation start.
If not provided, self.qcdsav will be removed prior to calculation start.
readguess : bool, optional
Write "scf_guess read" to Q-Chem input file. If readsave is provided,
then the very first calculation will read the SCF guess as well.
clean : bool, optional
When set, this calculation never updates qcdsav. However, if readsave is
provided it will still be used to initialize each calculation. Use this
if you never want the calculation result to depend on the previous state.
Note that this is relatively uncommon (e.g. if we want to run a series
of calculations without reading the SCF guess from the previous one.)
qcsave : bool, optional
Append the "-save" argument to the system call to Q-Chem. This results
in more files being saved to qcdir.
"""
# Name of the input file.
self.fin = fin
# Molecule object from loading the input file.
self.M = Molecule(fin, ftype)
if 'elem' not in self.M.Data.keys():
raise RuntimeError('Input file contains no atoms')
# Q-Chem input file that will be written for each Q-Chem execution.
# If the original input file happens to also be a Q-Chem input file,
# then use the suffix 'qcin' add an underscore so we
# don't accidentally overwrite our original file.
if qcin == None:
qcin = os.path.splitext(fin)[0]+'.in'
if qcin == fin and fin.endswith('.in'):
self.qcin = os.path.splitext(fin)[0]+'.qcin'
elif qcin == fin:
raise RuntimeError('Please do not provide a file with extension .qcin')
else:
self.qcin = qcin
# Keep track of the number of calculations done.
self.ncalc = 0
# Whether a Hessian calculation has been done.
self.haveH = 0
# Set Q-Chem calculation options ($rem variables).
if 'qcrems' not in self.M.Data.keys():
if method == None or basis == None or charge == None or mult == None:
raise RuntimeError('Must provide charge/mult/method/basis!')
# Print a Q-Chem template file.
prepare_template(qcrem_default, '.qtemp.in', charge, mult, method, basis, molecule=self.M)
self.M.add_quantum('.qtemp.in')
#.........这里部分代码省略.........