gaussianclasses
One of the two core libraries of pyssian. Contains the Classes that represent Gaussian Files (input and output).
- To do:
Create a Class to represent the basis and core electronic pontentials
GaussianInFile
Accepts a context manager usage similar to 'with open(file) as F:...'
Does not parse ONIOM calculation inputs
Does not parse MM calculation inputs
Not tested for z-matrix inputs
- class pyssian.GaussianInFile(file=None)[source]
Gaussian 09/16 .in file parent class, if any special type of input requires different processing it should be a subclass of this one.
- Parameters:
file (io.TextIOBase or str) -- File instance (Result of open(filename,'r')) or valid filename.
- preprocessing
Dictionary in which each key corresponds to a certain Link0 keyword
- Type:
dict
- commandline
Dictionary that contains the information of how the calculation will be carried out.
- Type:
dict
- title
title of the calculation.
- Type:
str
- method
If it cannot be recognized in the command line it will be empty.
- Type:
str
- basis
If it cannot be recognized in the command line it will be empty.
- Type:
str
- spin
- Type:
int
- charge
- Type:
int
- geometry
It should be able to write the text block of an input file upon calling str(geometry)
- Type:
str-ish
- tail
List of str in which each should be separated from the others by a single blank line in the input file.
- Type:
list
- structure
A string holding the structure of the input file. Used to write new Input files.
- Type:
str
- nprocs
property to easily access and change the preprocessing['nprocshared'] value
- Type:
int
- mem
property to easily access and change the preprocessing['mem'] value
- Type:
int
- extra_printout
Controls the behaviour of the command line's "#" or "#p". If True the command line will appear with the "#p". It is True by default.
- Type:
bool
- solvent
When set to None the solvation is still active but no solvent has been specified. When set to 'gas' the solvation is completely removed and when set to a different string, the string is assumed to be a valid name for the solvent in gaussian.
- Type:
str or None
- solvent_model
This property controls the keyword scrf and has three possible values: None -> the scrf keyword is not included 'pcm' -> the 'pcm' suboption within scrf is included 'smd' -> the 'smd' suboption within the scrf is included.
- Type:
str or None
- add_chk(name=None)[source]
Adds the chk to the file, with the specified name. If none is provided defaults to the file name ended in .chk
- add_kwd(keyword, where=None)[source]
Adds a keyword to the command line.
- Parameters:
keyword (str) -- keyword to add to the command line.
where (str, optional) -- if provided it adds the keyword as a suboption of the "where" keyword i.e. add_kwd('smd',where='scrf') or add_kwd('cartesian',where='opt')
- add_l0_kwd(keyword, where=None)[source]
Adds a keyword to the preprocessing.
- Parameters:
keyword (str) -- keyword to add to the preprocessing.
where (str, optional) -- if provided it adds the keyword as a suboption of the "where" keyword i.e. add_l0_kwd('job1.chk',where='chk') or add_kwd('40GB',where='mem')
- change_basis(basis)[source]
Changes appropiately the basis of the calculation. Running self.basis = basis makes a call to this function.
- Parameters:
basis (str) -- A string representation of a valid method if specified in the command line.
- Raises:
NotImplementedError -- If the basis is not within the registered basis keywords
- change_method(method)[source]
Changes appropiately the method of the calculation. Running self.method = method makes a call to this function.
- Parameters:
method (str) -- A string representation of a valid method
- Raises:
NotImplementedError -- If the method is not within the registered methods keywords
- commandline_as_str()[source]
Transforms the commandline attribute to a suitable string representation.
- Returns:
string corresponding to the commandline of the input file.
- Return type:
str
- disable_extra_printout()[source]
When used, the string representation of the object will not include the #p in the command line.
- enable_extra_printout()[source]
When used, the string representation of the object will include the #p in the command line.
- classmethod from_str(text)[source]
Creates a GaussianInFile object from a gaussian input file read as a string, parses it and populates the attributes of the class.
- Parameters:
text (str) --
Contents of a Gaussian input file as a string. i.e. .. code:: python
- with open('somefile.com','r') as F:
text = F.read()
name (str) -- Name to represent the GaussianInFile
- Returns:
A populated GaussianInFile object
- Return type:
- parse_commandline(lines)[source]
Parses the lines that contain the calculation commands keywords and transforms them into a dictionary representation.
- Parameters:
lines (list) -- list of strings previously stripped and split. Empty lines will be ignored.
- parse_geometry(lines)[source]
Parses each line that contains 'Atom x y z' in an appropiate form and saves it to self.geometry
- Parameters:
lines (list) -- list of strings previously stripped. Should not contain empty lines
- parse_preprocessing(lines)[source]
Parses the lines that contain the Link 0 keywords and transforms them into a dictionary representation.
- Parameters:
lines (list) -- list of strings previously stripped. Empty lines will be ignored.
- parse_tail(lines)[source]
Chops the set of lines into different blocks of text using as reference the emptylines/blank lines
- Parameters:
lines (list) -- list of strings previously stripped.
- Returns:
Description of returned object.
- Return type:
type
- Raises:
ExceptionName -- Why the exception is raised.
- pop_chk(default=None)[source]
Removes the chk from the file, returns 'default' if the chk was not included already
- pop_kwd(keyword, where=None)[source]
Removes a keyword from the command line and returns it.
- Parameters:
keyword (str) -- keyword to remove from the command line.
where (str, optional) -- if provided it searches the keyword as a suboption of the "where" keyword i.e. pop_kwd('smd',where='scrf') or pop_kwd('cartesian',where='opt')
- Returns:
Returns the removed keyword (or None when the keyword was not in the command line)
- Return type:
str or None
- pop_l0_kwd(keyword, where=None)[source]
Removes a keyword from the preprocessing and returns it.
- Parameters:
keyword (str) -- keyword to remove from the preprocessing.
where (str, optional) -- if provided it searches the keyword as a suboption of the "where" keyword i.e. pop_l0_kwd('job1.chk',where='oldchk')
- Returns:
Returns the removed keyword (or None when the keyword was not in the preprocessing)
- Return type:
str or None
MultiGaussianInFile
Allows the concatenation of multiple GaussianInFile instances to create a linked (--Link1--) gaussian input.
Provides some convenience methods to enforce same resources across each concatenated job
It was conceived for writing gaussian input files rather than reading gaussian input files with linked calculations, so no much testing was put into this task.
- class pyssian.MultiGaussianInFile(file=None)[source]
Container class of multiple GausianInFiles linked together in a single gaussian input calculation.
- Parameters:
file (io.TextIOBase or str (the default is None)) -- File instance (Result of open(filename,'r')) or valid filename.
- jobs
List providing access to each one of the individual GaussianInFile objects representing each one of the linked calculations.
- Type:
list
- enforce_continuous_chk(basename=None)[source]
Enforces that the chk of job i-1 is retained and a copy of it is used at the start of job i. For an example with two jobs, the first link0 section will look like:
%chk=basename_job0.chk
Then the link0 of the second job will look like:
- Parameters:
basename (str, optional) -- basename of the chk to use, if none is provided it defaults to the one of the first job.
- enforce_same_chk(chk=None)[source]
Enforces the same chk file in all jobs.
- Parameters:
chk (str, optional) -- filename of the chk to use, if none is provided it defaults to the one of the first job.
- enforce_same_mem(mem=None)[source]
Enforces the same memory in all jobs.
- Parameters:
mem (int, optional) -- Memory to use in a calculation, if none is provided it defaults to the value of the mem of the first job.
- enforce_same_method(method)[source]
Enforces the same method in all jobs.
- Parameters:
method (str, optional) -- method to use in a calculation, if none is provided it defaults to the value of the first job's method.
GaussianOutFile
Accepts a context manager usage similar to 'with open(file) as F:...'
Will only parse a Gaussian Output File that has the "#p".
- class pyssian.GaussianOutFile(file, parselist=None)[source]
Gaussian 09/16 '.log' file parent class, if any special type of calculation requires different processing it should be a subclass of this one. Accepts a context manager usage similar to 'with open(file) as F:...' For a Gaussian .log file to be parsable it requires that its corresponding input has the additional printout enabled (#p)
- Parameters:
file (io.TextIOBase or str) -- File instance (Result of open(filename,'r')) or valid filename.
parselist (list) -- List of integrers that represent which types of Links to parse (the default is None).
- InternalJobs
List of InternalJobs done by gaussian i.e an gaussian calculation with the opt freq keywords will run first an InternalJob for the Optimization and after an InternalJob for the Frequency calculation.
- get_links(*LinkIds)[source]
Wrapper Method to get a list of Links with certain Ids across the different Internal Jobs.
- Parameters:
*LinkIds (int) -- Integrers that correspond to the type of links to be return.
- Return type:
list
- update(clean=True, FinalPrint=False)[source]
Tries to fetch new data. If it exists it parses it appropiately otherwise it fails silently.
- Parameters:
clean (Bool) -- If True removes all the EmptyLinkJobs found (the default is True).
FinalPrint (Bool) -- If True after a normal execution has finished it will print in the console a message to notify the user (the default is False).
InternalJob
- class pyssian.InternalJob(number=None)[source]
Gaussian 09/16 InternalJob parent class, if any special type of Job requires different parsing it should be a subclass of this one.
- Parameters:
number (int) -- ordinal number of the InternalJob (the default is None).
- type
string identifier for the job.
- Links
List of the different Links that belong to the InternalJob.
- number