cctk.GaussianFile¶
- class cctk.GaussianFile(job_types=None, route_card=None, link0=None, footer=None, title='title', success=0, elapsed_time=0.0, molecule=None)[source]¶
Bases:
File
Class representing Gaussian input/output files.
- ensemble¶
ConformationalEnsemble
instance- Type:
- job_types¶
list of job_type` instances
- Type:
list
- route_card¶
optional, route card of .gjf file
- Type:
str
- link0¶
optional, dictionary of Link 0 commands (e.g. {“mem”: “32GB”, “nprocshared”: 16})
- Type:
dict
optional, footer of .gjf file
- Type:
str
- successful_terminations¶
number of successful terminations (should be 1 for an opt, 2 for opt and then freq, 1 for a single point energy, etc)
- Type:
int
- elapsed_time¶
total time for job in seconds
- Type:
float
- title¶
optional, title of .gjf file
- Type:
str
- __init__(job_types=None, route_card=None, link0=None, footer=None, title='title', success=0, elapsed_time=0.0, molecule=None)[source]¶
Create new GaussianFile object.
- Parameters:
job_types (list) – list of
job_type
instancesroute_card (str) – optional, route card of
.gjf
filelink0 (dict) – optional, Link 0 commands of
.gjf
filefooter (str) – optional, footer of
.gjf
filetitle (str) – optional, title of
.gjf
filesuccess (int) – num successful terminations
elapsed_time (float) – total time for job in seconds
molecule (cctk.Molecule) – molecule to initiate, if desired
Methods
__init__
([job_types, route_card, link0, ...])Create new GaussianFile object.
add_custom_basis_set
(name[, ...])Appends custom basis sets (from Basis Set Exchange) to
self.footer
.append_to_file
(filename, text)Appends output text to a file.
Checks that the file has all the appropriate properties for its job types, and raises ValueError if not.
get_molecule
([num, properties])Returns the last molecule (from an optimization job) or the only molecule (from other jobs).
Returns the imaginary frequencies, rounded to the nearest integer.
Returns the number of imaginary frequencies.
read_file
(filename[, return_lines, ...])Reads a Gaussian``.out`` or
.gjf
file and populates the attributes accordingly.write_ensemble_to_file
(filename, ensemble, ...)Write each structure in the specified ensemble to a single Gaussian input file by using the Link1 specification.
write_file
(filename[, molecule, route_card, ...])Write a
.gjf
file, using object attributes.write_molecule_to_file
(filename, molecule, ...)Write a
.gjf
file using the given molecule.- add_custom_basis_set(name, add_all_elements=False, return_string=False)[source]¶
Appends custom basis sets (from Basis Set Exchange) to
self.footer
. Should be used in combination with thegen
keyword.- Parameters:
name (str) – name of basis set (look it up on Basis Set Exchange)
add_all_elements (bool) – whether the complete basis set should be added or just the elements of interest
return_string (bool) – if the basis set should be appended to the footer or returned as a string (no change to
self
)
- Returns:
nothing (if return_string is
False
) string of basis set definition (if return string isTrue
)
- static append_to_file(filename, text)¶
Appends output text to a file.
- Parameters:
filename (str) – path to file, including name (e.g.
path/to/input.gjf
)text (str) – desired contents of file
- Returns:
True
if write succeeded,False
otherwise
- check_has_properties()[source]¶
Checks that the file has all the appropriate properties for its job types, and raises ValueError if not.
This only checks the last molecule in
self.ensemble
, for now.
- get_molecule(num=None, properties=False)[source]¶
Returns the last molecule (from an optimization job) or the only molecule (from other jobs).
If
num
is specified, returnsself.ensemble.molecule_list()[num]
Ifproperties
is True, returns(molecule, properties)
.
- classmethod read_file(filename, return_lines=False, extended_opt_info=False, fail_silently=True)[source]¶
Reads a Gaussian``.out`` or
.gjf
file and populates the attributes accordingly. Only footers fromopt=modredundant
can be read automatically –genecep
custom basis sets, &c must be specified manually.Note:
Will throw
ValueError
if there have been no successful iterations.- Parameters:
filename (str) – path to the out file
return_lines (Bool) – whether the lines of the file should be returned
extended_opt_info (Bool) – if full parameters about each opt step should be collected (by default, only
rms_displacement
andrms_force
are collected)fail_silently (Bool) – if true, files that fail validation will just be omitted and parsing will continue. useful for monitoring jobs which are in-progress and may not have all properties written.
- Returns:
GaussianFile
object (or list ofGaussianFile
objects for Link1 files) (optional) the lines of the file (or list of lines of file for Link1 files) as Lines object
- classmethod write_ensemble_to_file(filename, ensemble, route_card, link0={'mem': '32GB', 'nprocshared': 16}, footer=None, title='title', print_symbol=False)[source]¶
Write each structure in the specified ensemble to a single Gaussian input file by using the Link1 specification.
- Parameters:
filename (str) – where to write the file
ensemble (Ensemble) –
Ensemble
object to writeroute_card (str or list) – to use the same route card for every link, use a single string; otherwise, provide a list whose entries parallel the ensemble members
link0 (dict or list of dicts) – to use the same memory/processors for every link, use a single string; otherwise, provide a list
footer (None/str or list) – use None for no text after geometry, provide a str to specify a footer, or provide some combination of the above as a list
title (str or list) – use a single string to provide a generic title for every link or a list as above
print_symbol (bool or list) – whether to print atomic symbols or atomic numbers in the geometry specification; use a single bool or a list as above
- write_file(filename, molecule=None, route_card=None, link0=None, footer=None, **kwargs)[source]¶
Write a
.gjf
file, using object attributes. If no header/footer is specified, the object’s header/footer will be used.- Parameters:
filename (str) – path to the new file
molecule (int) – which molecule to use – passed to
self.get_molecule()
. Default is -1 (e.g. the last molecule), but positive integers will select from self.ensemble(1-indexed). AMolecule
object can also be passed, in which case that molecule will be written to the file.route_card (str) – route card for new file
link0 (dict) – dictionary of Link 0 commands (e.g. {“mem”: “32GB”, “nprocshared”: 16}
footer (str) – footer for new file
- classmethod write_molecule_to_file(filename, molecule, route_card, link0={'mem': '32GB', 'nprocshared': 16}, footer=None, title='title', append=False, print_symbol=False, point_charges=None)[source]¶
Write a
.gjf
file using the given molecule.- Parameters:
filename (str) – path to the new file
molecule (Molecule) – which molecule to use – a
Molecule
object.route_card (str) – route card for new file
link0 (dict) – dictionary of Link 0 commands
footer (str) – footer for new file
title (str) – title of the file, defaults to “title”
append (Bool) – whether or not to append to file using Link1 specifications
print_symbol (Bool) – whether to print atomic symbols (instead of atomic numbers)