Module with functions for Psi4/Cfour interface. Portions that require calls to Boost Python psi4 module are here, otherwise in qcdb module. Also calls to qcdb module are here and not elsewhere in driver. Organizationally, this module isolates qcdb code from psi4 code.
For a given output file whose path is constructed with dir + ‘/’ + prefix + ‘-‘ + item + ‘.out’, tests that the file exists and has prefix RESULTS lines for each piece of information requested in list keys and that those lines correspond to the appropriate linkage and item. Returns keys along with their scanned values in dict reapings, along with error and success messages in instructions and a boolean isOk indicating whether all keys reaped sucessfully.
Evaluate the output file status of jobs in zmats which should exist at dir + ‘/’ + prefix + ‘-‘ + job + ‘.out’. Returns string with formatted summary of job status and boolean of whether all complete. Return boolean isOk signals whether all zmats have completed and, if validate_func present, are validated.
Perform vibrational second-order perturbation computation through Cfour to get anharmonic frequencies. This version uses c4 for the disp and pt2 but gets gradients from p4.
Parameters: | c4full (boolean) – 'on' || Indicates whether when name indicates a Cfour method and mode indicates a sow/reap approach, sown files are direct ZMAT files and FJOBARC files are expected to reap, so that Cfour only, not Cfour-through-Psi4, is needed for distributed jobs. |
---|
Caution
Some features are not yet implemented. Buy a developer a coffee.
Stores all the instructions to the user for running vpt2() in sowreap mode. Depending on the stage, Pieces together instruction strings for the appropriate stage individualized by working directory dir and sown inputs zmats information.
Provided with the particular displacement number item and the associated zmat file with geometry and linkage, returns the FJOBARC contents. Depending on the mode settings of isC4notP4, isSowReap, and isC4fully, either runs (using lowername and kwargs) or reaps contents. outdir is where psi4 was invoked, scrdir is the psi4 scratch directory, and c4scrdir is Cfour scratch directory within.
Function to check that all parenthesis and brackets in input_string are paired. On that condition, exit_on_error =1, otherwise 0.
Function to squash multiline arrays into a single line until all parentheses and brackets are fully paired.
Function to preprocess raw input, the text of the input file, then parse it, validate it for format, and convert it into legitimate Python. raw_input is printed to the output file unless print_level =0. Does a series of regular expression filters, where the matching portion of the input is replaced by the output of the corresponding function (in this module) call. Returns a string concatenating module import lines, a copy of the user’s .psi4rc files, a setting of the scratch directory, a dummy molecule, and the processed raw_input.
Function to find array inputs that are spread across multiple lines and squash them into a single line.
Function to process a line with set or in a set block into global/local domain and keyword/value.
Function to process match of print and transform it to psi4.print_out().
Function to process match of all individual set (module_list) key {[value_list] or $value or value}.
Module to hold and distribute the -D dispersion correction parameters.
Function to serve up dispersion correction parameters in whatever form needed. When mode is ‘dftd3’, returns a string suitable for writing to ./dftd3_parameters to calculuate the correction at dashlvl with the default parameters for functional func. When mode is ‘psi4’, returns a tuple of arguments suitable for building a Dispersion object with dashlvl parameters for functional func.
There are four computational dashlvl choices. ‘d2p4’ calls the -D2 correction within psi4 (hence, faked for mode=’dftd3’). The other three, ‘d2gr’, ‘d3zero’, and ‘d3bj’ call the three dftd3 modes of operation (corresponding to -old, -zero, -bj). Additionally, there are three aliased dashlvl choices since the aliases in dash_alias above are imposed.
Function complementary to optimize(). Carries out one gradient pass, deciding analytic or finite difference.
Function complementary to frequency(). Computes force constants, deciding analytic, finite difference of gradients, or finite difference of energies.
Module with non-generic exceptions classes.
Module with functions that call upon those in modules proc, driver, and wrappers.
Module to provide lightweight definitions of functionals and SuperFunctionals
Module with utility functions that act on molecule objects.
Perform a breadth-first search (BFS) on the real atoms in molecule, returning an array of atom indices of fragments. Relies upon van der Waals radii and so faulty for close (esp. hydrogen-bonded) fragments. Original code from Michael S. Marshall.
Function to dynamically add extra members to the psi4.Molecule class.
Function to returns a LIST of all subclusters of the molecule mol of real size cluster_size. If cluster_size = 0, returns all possible combinations of cluster size.
Function to return all subclusters of the molecule mol of real size cluster_size and all other atoms ghosted if ghost equals true, all other atoms discarded if ghost is false. If cluster_size = 0, returns all possible combinations of cluster size.
A computation on a given molecule with various relevant integrals and such cached for later as tensors or numpy memory maps.
Clear all data matching regex
@param regex: The regular expression to search for in the name of the datum @type regex: str or re.RegexObject @param fail_if_missing: Whether or not to raise an exception if no data match the regex @param flags: Flags to compile the regular expression with. Ignored if regex is an instance of re.RegexObject. @type flags: int @raise ValueError: if no data names match the regex and fail_if_missing is True @return: The number of data removed @rtype: int
Clear a datum from the computation. If the datum has a file associated with it, delete the file.
@param name: The name of the datum to clear @type name: str @param fail_if_missing: Whether or not to raise an exception if the datum is not found @type fail_if_missing: bool @raise ValueError: if the datum named name is not found @return: True if the datum was found and deleted, False otherwise @rtype: bool
Callable, picklable class that CachedComputation.__reduce_ex__ returns an instance of. Pickling and unpickling proceeds by automatic mechanisms
Anything from a computation that might need to be cached. Assuming value is picklable, the pickling functionality of this class is trivial. Subclasses may override for more complex unpickling behavior
An instance of a numpy.ndarray subclass to be cached. Only the filename is pickled
A set of computations cached in a given directory
Clear all data matching regex from known computations
@param regex: The regular expression to search for in the name of the datum @type regex: str or compiled regex @param fail_if_missing: Whether or not to raise an exception if no data match the regex @param flags: Flags to compile the regular expression with. Ignored if regex is an instance of re.RegexObject. @type flags: int @raise ValueError: if no data names match the regex and fail_if_missing is True @return: Length 2 tuple of the number of data removed and the number of computations it was removed from. @rtype: tuple @see CachedComputation.clear_data_regex
Clear datum named datum_name from all computations in the cache
@param datum_name: The name of the datum to clear from all known computations @type datum_name: str @param fail_if_missing: Whether or not to raise an exception if no computations have a datum named datum_name @return: The number of data deleted @rtype: int @see CachedComputation.clear_datum, clear_data_regex
@param molecule: @type molecule: Molecule, str, or anything for which Molecule(molecule) is sensible @param needed_data: @type needed_data: NoneType, Iterable @rtype: CachedComputation
For now, this just returns the xyz string representation of the Molecule object. A more sophisticated means could be devised if constant recomputation becomes a problem, but it would be a total mess (see my attempts in the MoleculeStub class in grendel)
Abstract parent class of AOTEIGetter and MOTEIGetter
Module with functions that interface with Grimme’s DFTD3 code.
Implements a class to do the actual parsing of input files and store the results in Sections and Keywords. The parseFile() method returns a Getkw object.
Placehoder for keyword objects
Module with classes to integrate MM charges into a QM calculation.
Module with functions for Psi4/Cfour interface. Portions that require calls to Boost Python psi4 module are here, otherwise in qcdb module. Also calls to qcdb module are here and not elsewhere in driver. Organizationally, this module isolates qcdb code from psi4 code.
Form list of Cfour analytic gradient() arguments.
Form dictionary of PSI Variables set by Cfour methods.
Module with functions that call the four main driver functions: driver.energy, driver.optimize, driver.response, and driver.frequency.
Detects fragments if the user does not supply them. Currently only used for the WebMO implementation of SAPT Returns a new fragmented molecule
usage: auto_fragments(‘’)
Function to make primary function call to energy(), opt(), etc. with options dictionary largs. Useful when funcarg to call is stored in variable.
Function to reform a bracketed basis set string from a sequential series of basis sets (e.g, form ‘cc-pv[q5]z’ from array [cc-pvqz, cc-pv5z]). The basis set array is extracted from the f_basis field of a NEED dictionary in complete_basis_set(). Result is used to print a nicely formatted basis set string in the results table.
Function used by complete_basis_set() to separate menial ‘scftot’ into [scf, tot] and ‘mp2corl’ into [mp2, corl].
Function that prints the header for the changable-width results tables in db(). tbl_maxrgt is the number of reagent columns the table must plan for. tbl_delimit is a string of dashes of the correct length to set off the table. ttype is 1 for tables comparing the computed values to the reference or 2 for simple tabulation and sum of the computed values.
Function to transform and validate basis sets for cbs(). A basis set with no paired square brackets is passed through with zeta level 0 (e.g., ‘6-31+G(d,p)’ is returned as [6-31+G(d,p)] and [0]). A basis set with square brackets is checked for sensible sequence and Dunning-ness and returned as separate basis sets (e.g., ‘cc-pV[Q5]Z’ is returned as [cc-pVQZ, cc-pV5Z] and [4, 5]). Note that this function has no communication with the basis set library to check if the basis actually exists. Used by complete_basis_set().
Function called by each extrapolation scheme in complete_basis_set(). Checks that all the input arguments are present and suitable so that the scheme function can focus on defining the extrapolation.
Function encoding sequence of PSI module calls for an algebraic diagrammatic construction calculation.
Caution
Get rid of active molecule lines- should be handled in energy.
Function encoding sequence of PSI module calls for a Brueckner CCD calculation.
Function encoding sequence of PSI module calls for a Brueckner CCD(T) calculation.
Function encoding sequence of PSI module calls for a CCSD and CCSD(T) gradient calculation.
Function encoding sequence of PSI module calls for all CC property calculations.
Function encoding sequence of PSI module calls for a CCSD, CC2, and CC3 calculation.
Function encoding sequence of PSI module calls for a cholesky-decomposed MP2 computation
Function encoding sequence of PSI module calls for a cholesky-decomposed orbital-optimized MP2 computation
Function encoding sequence of PSI module calls for a cepa-like calculation.
>>> energy('cepa(1)')
Function encoding sequence of PSI module calls for a CEPA (LCCD) computation
Function encoding sequence of PSI module calls for a CEPA(0) gradient calculation.
Function encoding sequence of PSI module calls for a density cumulant functional theory calculation.
Function encoding sequence of PSI module calls for DCFT gradient calculation.
Function encoding sequence of PSI module calls for a configuration interaction calculation, namely FCI, CIn, MPn, and ZAPTn.
Function encoding sequence of PSI module calls for a configuration interaction calculation, namely FCI, CIn, MPn, and ZAPTn, computing properties.
Function encoding sequence of PSI module calls for a density-fitted MP2 calculation.
Function encoding sequence of PSI module calls for a DFMP2 gradient calculation.
Function encoding sequence of PSI module calls for a DFMP2 property calculation.
Function encoding sequence of PSI module calls for an density-fitted orbital-optimized MP2 computation
Function encoding sequence of PSI module calls for a density-functional-theory calculation.
Function encoding sequence of PSI module calls for a density-functional-theory gradient calculation.
Function encoding sequence of PSI module calls for an EOM-CC calculation, namely EOM-CC2, EOM-CCSD, and EOM-CC3.
Function encoding sequence of PSI module calls for an EOM-CCSD gradient calculation.
Function encoding sequence of PSI module calls for a QCISD(T), CCSD(T), MP2.5, MP3, and MP4 computation.
>>> energy('fno-ccsd(t)')
Function encoding sequence of PSI module calls for a DF-CCSD(T) computation.
>>> energy('df-ccsd(t)')
Function encoding sequence of PSI module calls for a calculation through libfock, namely RCPHF, RCIS, RTDHF, RTDA, and RTDDFT.
Function encoding sequence of PSI module calls for an LMP2 theory calculation.
Function encoding sequence of PSI module calls for a multiconfigurational self-consistent-field calculation.
Function encoding sequence of PSI module calls for a MP2 calculation.
Function encoding sequence of PSI module calls for a MP2.5 calculation.
Function encoding sequence of PSI module calls for a MP3 gradient calculation.
Function encoding sequence of PSI module calls for a MP2 gradient calculation.
Function selecting the algorithm for a MP2 energy call and directing toward the OCC (conv MP2) or the DFMP2 modules.
Function selecting the algorithm for a MP2 gradient call and directing toward the OCC (conv MP2) or the DFMP2 modules.
Function encoding sequence of PSI module calls for a coupled MP2 calculation.
Function encoding sequence of PSI module calls for a MP3 calculation.
Function encoding sequence of PSI module calls for a MP3 gradient calculation.
Function that prepares environment and input files for a calculation calling Kallay’s MRCC code.
Function encoding sequence of PSI module calls for an orbital-optimized CEPA computation
Function encoding sequence of PSI module calls for OCEPA gradient calculation.
Function encoding sequence of PSI module calls for a MP2 calculation.
Function encoding sequence of PSI module calls for an orbital-optimized MP2 computation
Function encoding sequence of PSI module calls for an orbital-optimized MP2.5 computation
Function encoding sequence of PSI module calls for OMP2.5 gradient calculation.
Function encoding sequence of PSI module calls for OMP2 gradient calculation.
Function encoding sequence of PSI module calls for an orbital-optimized MP3 computation
Function encoding sequence of PSI module calls for OMP3 gradient calculation.
Function encoding sequence of PSI module calls for a PSIMRCC computation using a reference from the MCSCF module
Function encoding sequence of PSI module calls for a PSIMRCC computation using a reference from the SCF module
Function encoding sequence of PSI module calls for a SAPT calculation of any level.
Function encoding sequence of PSI module calls for a charge-transfer SAPT calcuation of any level.
Function encoding sequence of PSI module calls for a self-consistent-field theory (HF & DFT) calculation.
Function encoding sequence of PSI module calls for a SCF gradient calculation.
Function encoding sequence of PSI module calls for SCF calculations. This is a simple alias to run_scf() since SCF properties all handled through oeprop.
Function encoding sequence of PSI module calls for a spin-component scaled OMP2 computation
Function encoding sequence of PSI module calls for a spin-component scaled OMP3 computation
Function encoding sequence of PSI module calls for a spin-opposite scaled OMP2 computation
Module to facilitate quantum chemical computations on chemical databases. Contains Molecule class and physical constants from psi4 suite.
File to
Function that given an array or array of arrays seq, returns an array without any duplicate entries. There is no guarantee of which duplicate entry is dropped.
Class to store the elements, coordinates, fragmentation pattern, charge, multiplicity of a molecule. Largely replicates psi4’s libmints Molecule class, developed by Justin M. Turney and Andy M. Simmonett with incremental improvements by other psi4 developers. Major differences from the C++ class are: no basisset handling, no symmetry, no pubchem, no efp, no discarding dummies. This class translated so that databases can function independently of psi4.
>>> H2OH2O = qcdb.Molecule("""
0 1
O1 -1.551007 -0.114520 0.000000
H1 -1.934259 0.762503 0.000000
H2 -0.599677 0.040712 0.000000
--
0 1
X 0.000000 0.000000 0.000000
O2 1.350625 0.111469 0.000000
H3 1.680398 -0.373741 -0.758561
H4 1.680398 -0.373741 0.758561
no_com
no_reorient
units angstrom
""")
>>> H2O = qcdb.Molecule.init_with_xyz('h2o.xyz')
Add an atom to the molecule Z atomic number x cartesian coordinate y cartesian coordinate z cartesian coordinate symb atomic symbol to use mass mass to use if non standard charge charge to use if non standard lineno line number when taken from a string
Tests to see of an atom is at the passed position b in Bohr with a tolerance tol.
>>> print H2OH2O.atom_at_position([1.35*(1.0/psi_bohr2angstroms), 0.10*(1.0/psi_bohr2angstroms), 0.0*(1.0/psi_bohr2angstroms)])
3
NYI Converts an atom number to the number of its generating unique atom. The return value is in [0, nunique).
NYI Converts an atom number to the offset of this atom in the list of generated atoms. The unique atom itself is allowed offset 0.
Computes center of mass of molecule (does not translate molecule).
>>> H2OH2O.center_of_mass()
[-0.12442647346606871, 0.00038657002584110707, 0.0]
Returns charge of atom (0-indexed). Related to SAD guess in libmints version.
>>> print H2OH2O.charge(4)
1.0
Whether the charge was given by the user
>>> print H2OH2O.charge_specified()
True
Given a string text of psi4-style geometry specification (including newlines to separate lines), builds a new molecule. Called from constructor.
Regenerates a input file molecule specification string from the current state of the Molecule. Contains geometry info, fragmentation, charges and multiplicities, and any frame restriction.
Computes a matrix depicting distances between atoms. Prints formatted and returns array.
>>> H2OH2O.distance_matrix()
Interatomic Distances (Angstroms)
[1] [2] [3] [4] [5] [6]
[1] 0.00000
[2] 0.95711 0.00000
[3] 0.96391 1.51726 0.00000
[4] 2.91042 3.34878 1.95159 0.00000
[5] 3.32935 3.86422 2.43843 0.95895 0.00000
[6] 3.32935 3.86422 2.43843 0.95895 1.51712 0.00000
Makes a copy of the molecule, returning a new molecule with only certain fragment atoms present as either ghost or real atoms reals: The list or int of fragments (1-indexed) that should be present in the molecule as real atoms. ghosts: The list or int of fragments (1-indexed) that should be present in the molecule as ghosts. (method name in libmints is extract_subsets. This is different in qcdb because the psi4 input parser tries to process lines with that term, giving rise to Boost:Python type conlicts.) See usage at extract_fragments().
Wrapper for extract_fragments(). See note there. This function can be used as long as not in psi4 input file. Use extract_fragments directly, then.
>>> H2OH2O.extract_subsets(2) # monomer B, unCP-corrected
>>> H2OH2O.extract_subsets(2,1) # monomer B, CP-corrected
>>> obj.extract_subsets(1,[2,3]) # monomer A, CP-corrected if obj is tri-molecular complex
Returns charge of atom (0-indexed, includes dummies). Related to SAD guess in libmints version.
>>> print H2OH2O.fcharge(4)
8.0
NYI Find computational molecular point group, user can override this with the “symmetry” keyword
Fix the orientation at its current frame (method name in libmints is set_orientation_fixed)
Returns the original label of the atom (0-indexed) as given in the input file (C2, H4) (includes dummies)
>>> print H2OH2O.flabel(4)
O2
Returns mass of atom (0-indexed, includes dummies)
>>> print H2OH2O.fmass(4)
15.9949146196
NYI Initialize molecular specific symmetry information. Uses the point group object obtain by calling point_group()
Returns the cleaned up label of the atom (C2 => C, H4 = H) (includes dummies)
>>> print H2OH2O.fsymbol(4)
O
Returns the full (dummies included) geometry in Bohr as a N X 3 array.
>>> print H2OH2O.full_geometry()
[[-2.930978460188563, -0.21641143673806384, 0.0], [-3.655219780069251, 1.4409218455037016, 0.0], [-1.1332252981904638, 0.0769345303220403, 0.0], [0.0, 0.0, 0.0], [2.5523113582286716, 0.21064588230662976, 0.0], [3.175492014248769, -0.7062681346308132, -1.4334725450878665], [3.175492014248769, -0.7062681346308132, 1.4334725450878665]]
NYI Return n in Cnv, etc.; If there is no n (e.g. Td) it’s the highest-order rotation axis.
x position of atom (0-indexed, includes dummies) in Bohr
>>> print H2OH2O.fx(4)
2.55231135823
Returns a Vector3 with x, y, z position of atom (0-indexed) in Bohr (includes dummies)
>>> print H2OH2O.fxyz(4)
[2.5523113582286716, 0.21064588230662976, 0.0]
y position of atom (0-indexed, includes dummies) in Bohr
>>> print H2OH2O.fy(4)
0.210645882307
z position of atom (0-indexed, includes dummies) in Bohr
>>> print H2OH2O.fz(4)
0.0
Returns the geometry in Bohr as a N X 3 array.
>>> print H2OH2O.geometry()
[[-2.930978460188563, -0.21641143673806384, 0.0], [-3.655219780069251, 1.4409218455037016, 0.0], [-1.1332252981904638, 0.0769345303220403, 0.0], [2.5523113582286716, 0.21064588230662976, 0.0], [3.175492014248769, -0.7062681346308132, -1.4334725450878665], [3.175492014248769, -0.7062681346308132, 1.4334725450878665]]
Attempts to interpret a string vstr as an atom specifier in a zmatrix. Takes the current line for error message printing. Returns the atom number (adjusted to zero-based counting).
Attempts to interpret a string as a double, if not it assumes it’s a variable.
NYI Return point group name such as C3v or S8. (method name in libmints is full_point_group)
Checks to see if the variable str is in the list, sets it to val and returns true if it is, and returns false if not.
NYI Whether molecule satisfies the vector symmetry operation op
Compute inertia tensor.
>>> print H2OH2O.inertia_tensor()
[[8.704574864178731, -8.828375721817082, 0.0], [-8.828375721817082, 280.82861714077666, 0.0], [0.0, 0.0, 281.249500988553]]
NYI Pull information from the chkpt object passed (method name in libmints is init_with_chkpt)
NYI Pull information from a chkpt object created from psio (method name in libmints is init_with_psio)
Pull information from an XYZ file. No fragment or chg/mult info detected.
>>> H2O = qcdb.Molecule.init_with_xyz('h2o.xyz')
Is axis an axis of order order with respect to origin?
Is the molecule linear, or planar?
>>> print H2OH2O.is_linear_planar()
(False, False)
Checks to see if the variable str is in the list, returns true if it is, and returns false if not.
>>> H2OH2O.is_variable('R')
False
Returns the original label of the atom (0-indexed) as given in the input file (C2, H4).
>>> print H2OH2O.label(4)
H3
Returns which worldaxis axis most overlaps with. Inverts axis when indicated.
Whether the multiplicity was given by the user
>>> print H2OH2O.multiplicity_specified()
True
The number of active fragments in the molecule.
>>> print H2OH2O.nactive_fragments()
2
Number of frozen core for molecule given freezing state.
>>> print H2OH2O.nfrozen_core()
2
Computes nuclear repulsion energy.
>>> print H2OH2O.nuclear_repulsion_energy()
36.6628478528
Computes nuclear repulsion energy derivatives
>>> print H2OH2O.nuclear_repulsion_energy_deriv1()
[[3.9020946901323774, 2.76201566471991, 0.0], [1.3172905807089021, -2.3486366050337293, 0.0], [-1.8107598525022435, -0.32511212499256564, 0.0], [-1.217656141385739, -2.6120090867576717, 0.0], [-1.0954846384766488, 1.2618710760320282, 2.1130743287465603], [-1.0954846384766488, 1.2618710760320282, -2.1130743287465603]]
Get whether or not orientation is fixed.
>>> H2OH2O.orientation_fixed()
True
Print the geometrical parameters (bond_angles) of the molecule.
>>> print H2OH2O.print_bond_angles()
Bond Angles (degrees)
Angle 2-1-3: 104.337
Angle 2-1-4: 109.152
Angle 2-1-5: 117.387
...
Print the geometrical parameters (dihedrals) of the molecule.
>>> print H2OH2O.print_dihedrals()
Dihedral Angles (Degrees)
Dihedral 1-2-3-4: 180.000
Dihedral 1-2-3-5: 133.511
Dihedral 1-2-3-6: 133.511
...
Print the geometrical parameters (distances) of the molecule. suspect libmints version actually prints Bohr.
>>> print H2OH2O.print_distances()
Interatomic Distances (Angstroms)
Distance 1 to 2 0.957
Distance 1 to 3 0.964
Distance 1 to 4 2.910
...
Print full atom list. Same as print_out() only displays dummy atoms.
Print the molecule. (method name in libmints is print)
>>> H2OH2O.print_out()
Geometry (in Angstrom), charge = -2, multiplicity = 3:
Center X Y Z
------------ ----------------- ----------------- -----------------
O -1.551007000000 -0.114520000000 0.000000000000
H -1.934259000000 0.762503000000 0.000000000000
H -0.599677000000 0.040712000000 0.000000000000
O 1.350625000000 0.111469000000 0.000000000000
H 1.680398000000 -0.373741000000 -0.758561000000
H 1.680398000000 -0.373741000000 0.758561000000
Print the molecule in Angstroms. Same as print_out() only always in Angstroms. (method name in libmints is print_in_angstrom)
Print the molecule in Bohr. Same as print_out() only in Bohr. (method name in libmints is print_in_bohr)
Print the geometrical parameters (out_of_planes) of the molecule.
>>> print H2OH2O.print_out_of_planes()
Out-Of-Plane Angles (Degrees)
Out-of-plane 1-2-3-4: 0.000
Out-of-plane 1-2-3-5: -7.373
Out-of-plane 1-2-3-6: 7.373
...
Reinterpret the fragments for reals/ghosts and build the atom list.
Do we reinterpret coordentries during a call to update_geometry? (method name in libmints is set_reinterpret_coordentry)
Rotates the molecule using rotation matrix R.
>>> H2OH2O.rotate([[0,-1,0],[-1,0,0],[0,0,1]])
Rotates the full molecule using rotation matrix R.
>>> H2OH2O.rotate_full([[0,-1,0],[-1,0,0],[0,0,1]])
Compute the rotational constants and return them in wavenumbers
Save a string for a XYZ-style file.
>>> H2OH2O.save_string_xyz()
6
_
O -1.551007000000 -0.114520000000 0.000000000000
H -1.934259000000 0.762503000000 0.000000000000
H -0.599677000000 0.040712000000 0.000000000000
O 1.350625000000 0.111469000000 0.000000000000
H 1.680398000000 -0.373741000000 -0.758561000000
H 1.680398000000 -0.373741000000 0.758561000000
NYI Save information to checkpoint file (method name in libmints is save_to_chkpt)
NYI Assigns basis name to all atoms with label.
NYI Assigns basis name to atom number number (1-indexed, includes dummies).
NYI Assigns basis name to all symbol atoms.
NYI Fix the center of mass at its current frame. Not used in libmints so not implemented.
Sets the full geometry (dummies included), given a N X 3 array of coordinates geom in Bohr.
>>> H2OH2O.set_full geometry([[1,2,3],[4,5,6],[7,8,9],[0,0,0],[-1,-2,-3],[-4,-5,-6],[-7,-8,-9]])
Sets the geometry, given a N X 3 array of coordinates geom in Bohr.
>>> H2OH2O.set_geometry([[1,2,3],[4,5,6],[7,8,9],[-1,-2,-3],[-4,-5,-6],[-7,-8,-9]])
Sets the presence of any zmatrix entry
>>> H2OH2O.set_has_zmatrix(True)
Sets the multiplicity (defined as 2Ms + 1)
>>> H2OH2O.set_multiplicity(3)
Assigns the value val to the variable labelled string in the list of geometry variables. Also calls update_geometry()
Returns the cleaned up label of the atom (C2 => C, H4 = H) (0-indexed)
>>> print H2OH2O.symbol(4)
H
NYI Force the molecule to have the symmetry specified in pg. This is to handle noise coming in from optking.
Determine symmetry reference frame. If noreorient is not set, this is the rotation matrix applied to the geometry in update_geometry.
>>> print H2OH2O.symmetry_frame()
[[1.0, -0.0, 0.0], [0.0, 1.0, 0.0], [0.0, -0.0, 1.0]]
Returns the symmetry specified in the input.
>>> print H2OH2O.symmetry_from_input()
C1
Updates the geometry, by (re)interpreting the string used to create the molecule, and the current values of the variables. The atoms list is cleared, and then rebuilt by this routine. This function must be called after first instantiation of Molecule.
>>> H2 = qcdb.Molecule("H\nH 1 0.74\n")
>>> print H2.natom()
0
>>> H2.update_geometry()
>>> print H2.natom()
2
Module (auto-generated from make_dunning.pl script) with commands building BasisFamily objects that encode the Dunning basis set orbital definitions in psi4/lib/basis/NOTES and fitting bases designed for those orbital bases.
Here, chgeMol and chgeGrd need to be turned into the native Cfour orientation embodied by permMol. Currently for vpt2.
Return an array of Cfour methods with analytical gradients. Appended to procedures[‘gradient’].
Return an array of Cfour methods with energies. Appended to procedures[‘energy’].
Return a dict with keys of most Cfour methods and values of dicts with the PSI Variables returned by those methods. Used by cbs() wrapper to avoid unnecessary computations in compound methods. Result is appended to VARH.
Takes the key results from a gradient computation (energy, element Z list elem, coordinates, gradient, dipole, and atom ordering map) and writes a string fja that exactly mimics the contents of a Cfour FJOBARC file.
Parses all the pieces of output from Cfour: the stdout in c4out and the contents of various scratch files like GRD stored in their namesake keys in largs. Since all Cfour output uses its own orientation and atom ordering for the given molecule, a qcdb.Molecule p4Mol, if supplied, is used to transform the Cfour output back into consistency with p4Mol.
Parses the contents dipol of the Cfour DIPOL file into a dipol vector.
Parses the contents grd of the Cfour GRD file into the gradient array and coordinate information. The coordinate info is converted into a rather dinky Molecule (no charge, multiplicity, or fragment), but this is these coordinates that govern the reading of molecule orientation by Cfour. Return qcdb.Molecule and gradient array.
Function to read CFOUR output file outtext and parse important quantum chemical information from it in
Function to separate portions of a CFOUR output file outtest, divided by xjoda.
Parses the contents of the Cfour ZMAT file into array and coordinate information. The coordinate info is converted into a rather dinky Molecule (no fragment, but does read charge, mult, unit). Return qcdb.Molecule. Written for findif zmat* where geometry always Cartesian and Bohr.
Returns a Molecule from entries in dictionary jajodic extracted from JAINDX and JOBARC.
Transform calculation method name and derivative level dertype into options for cfour. While deliberately requested pieces, generally CFOUR_DERIV_LEVEL and CFOUR_CALC_LEVEL, are set to complain if contradicted (‘clobber’ set to True), other ‘recommended’ settings, like CFOUR_CC_PROGRAM, can be countermanded by keywords in input file (‘clobber’ set to False). Occasionally, want these pieces to actually overcome keywords in input file (‘superclobber’ set to True).
Translate psi4 keywords opt that have been explicitly set into their Cfour counterparts. Since explicitly set Cfour module keyword values will always be used preferentially to these inferred from psi4, the ‘clobber’ property is set to False.
Module to largely replicate in python the psi4 libmints CoordValue and CoordEntry classes, which were developed by Justin M. Turney, with incremental improvements by other psi4 developers.
Class to hold all information about an atom, including its coordinate specification as three Cartesians.
Computes the values of the coordinates (in whichever units were inputted), returning them in a Vector
Prints the updated geometry, in the format provided by the user. This, for Cfour, not different from regular version.
Class to
An abstract class to handle storage of Cartesian coordinate values, which may be defined in terms of other variables through this mechanism, greatly simplifying Z-matrix specification, for example.
Specialization of CoordValue that is simply a number to be stored.
Specialization of CoordValue, where the current value depends on the list of geometry values stored by the molecule.
Class to hold all information about an atom, including its coordinate specification as any position of ZMatrix.
Prints the updated geometry, in the format provided by the user
Class to store quantum chemical quantities extracted from output files. Extends the dictionary object to (1) store key as all-caps version of itself and (2) validate value for duplicate values for the same key by testing which has more decimal places and whether value the same within a plausing rounding error. Allows consistency checks when parsing output files without loss of precision.
Module to facilitate quantum chemical computations on chemical databases. Contains Molecule class and physical constants from psi4 suite.
Class to store python extensions to the MoleculeLibmints class. Multiple classes allows separation of libmints and extension methods.
Perform a breadth-first search (BFS) on the real atoms in molecule, returning an array of atom indices of fragments. Relies upon van der Waals radii and so faulty for close (esp. hydrogen-bonded) fragments. Original code from Michael S. Marshall.
Detects fragments in an unfragmented molecule using BFS algorithm. Returns a new Molecule in Cartesian, fixed-geom (no variable values), no dummy-atom format. Any non-default charge and multiplicity assigned to first fragment.
Computes center of charge of molecule (does not translate molecule).
>>> H2OH2O.center_of_charge()
[-0.073339893272065401, 0.002959783555632145, 0.0]
Function to print the BASIS=SPECIAL block for Cfour according to the active atoms in Molecule. Special short basis names are used by Psi4 libmints GENBAS-writer in accordance with Cfour constraints.
Function to print Molecule in a form readable by Cfour. This version works as long as zmat is composed entirely of variables, not internal values, while cartesian is all internal values, no variables. Cutting off this line of development because, with getting molecules after passing through libmints Molecule, all zmats with dummies (Cfour’s favorite kind) have already been converted into cartesian. Next step, if this line was pursued would be to shift any zmat internal values to external and any cartesian external values to internal.
Function to call Grimme’s dftd3 program (http://toc.uni-muenster.de/DFTD3/) to compute the -D correction of level dashlvl using parameters for the functional func. The dictionary dashparam can be used to supply a full set of dispersion parameters in the absense of func or to supply individual overrides in the presence of func. The dftd3 executable must be independently compiled and found in :envvar:PATH.
Compute inertia tensor.
>>> print H2OH2O.inertia_tensor()
[[8.704574864178731, -8.828375721817082, 0.0], [-8.828375721817082, 280.82861714077666, 0.0], [0.0, 0.0, 281.249500988553]]
Compute inertia tensor based on atoms in part.
Solve inertial system based on atoms in part
Pull information from an XYZ file. No fragment info detected. Bohr/Angstrom pulled from first line if available. Charge, multiplicity, tagline pulled from second line if available. Body accepts atom symbol or atom charge in first column. Arguments no_com and no_reorient can be used to turn off shift and rotation. If xyzfilename is a string of the contents of an XYZ file, rather than the name of a file, set contentsNotFilename to True.
>>> H2O = qcdb.Molecule.init_with_xyz('h2o.xyz')
Save a string for a XYZ-style file.
>>> H2OH2O.save_string_xyz()
6
-2 3 water_dimer
O -1.551007000000 -0.114520000000 0.000000000000
H -1.934259000000 0.762503000000 0.000000000000
H -0.599677000000 0.040712000000 0.000000000000
O 1.350625000000 0.111469000000 0.000000000000
H 1.680398000000 -0.373741000000 -0.758561000000
H 1.680398000000 -0.373741000000 0.758561000000
Returns the least restrictive negative exponent of the power 10 that would achieve the floating point convergence criterium val.
Function to reformat value val for option opt from python into cfour-speak. Arrays are the primary target.
Function to take the full snapshot of the liboptions object encoded in dictionary options, find the options directable toward Cfour (options[‘CFOUR’][‘CFOUR_**’]) that aren’t default, then write a CFOUR deck with those options.
Function to take the full snapshot of the liboptions object encoded in dictionary full and reconcile it with proposed options value changes in partial. Overwrites full with partial if option untouched, touches full if full and partial are in agreement, balks if full and partial conflict. Returns full.
Class to encode a transformation between two molecular coordinate systems. After initializing with two qcdb.Molecule objects at the same geometry in possible different frames and orderings, class can apply the appropriate transformations to coordinate, gradient, Hessian, etc. arrays.
Finds the shift, rotation, axis exchange, axis inversion, and atom remapping necessary to bring the geometry of Cmol into coincidence with the geometry of Pmol. Pmol and Cmol must be qcdb.Molecule and represent the same geometry. Presently catches some errors of orientation that Cfour as Cmol should properly fulfill. These are unnecessary restrictions and can be relaxed later.
Applies to elem the transformation appropriate to bring a list of atomic numbers in molChangeable orientation into molPermanent orientation. In particular, applies a row exchange to place it in the atom ordering.
Applies to arr the transformation appropriate to bring a gradient in molChangeable orientation into molPermanent orientation. In particular, applies a rotation to place it in the inertial frame, a column exchange and phasing to place it in the axis system, a row exchange to place it in the atom ordering, and a rotation to remove it from the inertial frame.
Applies to vec the transformation appropriate to bring a vector in molChangeable orientation into molPermanent orientation. In particular, applies a rotation to place it in the inertial frame, a column exchange and phasing to place it in the axis system, and a rotation to remove it from the inertial frame.
File for accessory procedures in the chem module. Credit for the libmints vector3 class to Justin M. Turney and incremental improvements by other psi4 developers.
Parent classes for quantum chemistry program input and output file formats.
For Dunning basis sets, returns strings from which auxiliary basis sets and heavy-aug can be constructed. Note that valence/core-valence/etc. is conserved and X-zeta/(X+d)zeta is not, since this is the usual aux basis pattern. augbasis is round up to the nearest aug-cc-pVXZ rootbasis is round down to the nearest cc-pVXZ auxbasis is round up to the nearest cc-pVXZ or aug-cc-pVXZ
Module with non-generic exceptions classes.
Error called for functions defined but not yet implemented. Also for functions defined that will never be implemented.
Error raised when not all variables in an atom specification have been defined at compute time. May be a temporary situation so message not printed but appears as traceback when error persists.
Error called for problems with syntax from a QC output file. Prints error message msg to standard output stream.
Error called for problems with syntax input file. Prints error message msg to standard output stream.
Reads binary files JOBARC and JAINDX and returns contents of each record in reclabelarray.
Module with commands building BasisFamily objects for Pople and other non-Dunning orbital basis sets. Some plausible fitting basis sets are supplied as defaults.
Elemental masses (most common isotope), symbols, and atomic numbers from psi4.
Stuff stolen from psi. Should import or not as necessary or some better way. Apologies to the coders.
Function to compare two matrices. Prints util.success() when elements of matrix computed match elements of matrix expected to number of digits. Performs a system exit on failure to match symmetry structure, dimensions, or element values. Used in input files in the test suite.
Function to compare two values. Prints util.success() when value computed matches value expected to number of digits. Performs a system exit on failure. Used in input files in the test suite.
Ask a yes/no question via raw_input() and return their answer.
question is a string that is presented to the user. default is the presumed answer if the user just hits <Enter>. It must be yes (the default), no or None (meaning an answer is required of the user).
The return value is one of True or False.
Module to define a class BasisFamily that associates fitting basis sets to an orbital basis and to provide functions to query appropriate fitting bases for any orbital basis distributed with Psi4.
Class to associate with an orbital basis name ornate the gbs file names in which the orbital basis orbital (usually the coded form of ornate) and jkfit, rifit, and dualfit auxiliary bases can be found.
Function to add basis fit as associated helper basis member dualfit to a BasisFamily object.
Function to add basis fit as associated fitting basis member jkfit to a BasisFamily object.
Function to return an appropriate DUAL helper basis for the orbital basis name in coded or ornate form. None is returned if no fitting basis is defined or if the orbital basis is not found.
Function to return an appropriate JK fitting basis for the orbital basis name in coded or ornate form. None is returned if no fitting basis is defined or if the orbital basis is not found.
Function to validate if the orbital basis name in coded or ornate form is in Psi4’s standard installed bases list. None is returned if the orbital basis is not found.
Function to return an appropriate RI fitting basis for the orbital basis name in coded or ornate form. None is returned if no fitting basis is defined or if the orbital basis is not found.
Function to load into the array basisfamily_list BasisFamily objects for all Psi4’s standard installed bases.
alias of CaseInsensativeOpenStruct
A ‘raw’ list, by syntactic analogy to the Python raw string literal.
>>> r[1,2,3]
[1, 2, 3]
>>> r[1, ..., 3]
[1, Ellipsis, 3]
>>> r[...]
[Ellipsis]
>>> r[...,...]
[Ellipsis, Ellipsis]
>>> r[...,...,1:3]
[Ellipsis, Ellipsis, slice(1, 3, None)]
>>> r[...,...,1:3:5]
[Ellipsis, Ellipsis, slice(1, 3, 5)]
>>> r[...,...,1:3:5,'hello']
[Ellipsis, Ellipsis, slice(1, 3, 5), 'hello']
>>> r['hello']
['hello']
Get the name of the calling function as a str
Returns : |
---|
Examples : |
---|
>>> def foo():
... print caller()
...
>>> def bar():
... foo()
...
>>> bar()
bar
>>> def foobar():
... bar()
...
>>> foobar()
bar
A simple way to accept arguments that can be an Iterable or a bunch of arguments that should be treated as a single Iterable. (This method is pretty trivial, but I find myself doing it a whole lot.) The reason you can’t just use list() for this purpose is that if an Iterable is given as the only argument, list(args) will return a list of Iterables rather than a single Iterable.
Examples : |
---|
>>> def test(*args):
... return listify_args(*args)
...
>>> test(1,2,3)
[1, 2, 3]
>>> test([1,2,3])
[1, 2, 3]
>>> test([1,2,3], 4)
[[1, 2, 3], 4]
>>> test("1,2,3", 4)
['1,2,3', 4]
>>> test("1,2,3")
['1,2,3']
Utility function for getting the value of a keyword argument that can be named multiple things. This function also checks to make sure no more than one of the possible names is specified in the keyword dictionary kwarg_dict. If the None of the keywords given are found in kwarg_dict, None is returned.
Utility function for getting the value of a keyword argument that can be named multiple things. This function also checks to make sure no more than one of the possible names is specified in the keyword dictionary kwarg_dict. If the None of the keywords given are found in kwarg_dict, None is returned.
Utility function for getting the value of a keyword argument that can be named multiple things and popping that value off of the kwarg dictionary. If the None of the keywords given are found in kwarg_dict, None is returned.
See Also: |
---|
get_multikwarg
Utility function for getting the value of a keyword argument that can be named multiple things and popping that value off of the kwarg dictionary. If the None of the keywords given are found in kwarg_dict, None is returned.
See Also: |
---|
get_multikwarg
Converts a CamalCase string to a lower_case_string_with_underscores If the divider argument is given, it is used instead of underscores to join words.
Examples : |
---|
Convenience method for getting the typename as a string from the <type ‘Something’> string sent back by str(type(obj))
Alias a function as something else. Set the documentation of the new method to “Alias for <function>()” and add “Aliased as <alias>()” to the documentation of function. Not inteded to be used as a decorator.
Examples : |
---|
>>> def foo(a, b, c):
... '''Print a test message.'''
... print "testing {0}, {1}, {2}".format(a, b, c)
...
>>> foo(1, 2, 3)
testing 1, 2, 3
>>> bar = function_alias('bar', foo)
>>> bar(4, 5, 6)
testing 4, 5, 6
>>> print bar.__doc__
Alias for `foo()`
>>> print foo.__doc__
Print a test message.
Aliased as `bar()`
>>> baz = function_alias('baz', foo)
>>> baz(7, 8, 9)
testing 7, 8, 9
>>> print foo.__doc__
Print a test message.
Aliased as `baz()`, `bar()`
Inside a class
>>> class FooBar(object):
... def testfunc(self, *args):
... '''Print out the args.'''
... print "testing " + ', '.join(str(a) for a in args)
... another_name = function_alias('another_name', testfunc)
... test_func = function_alias('test_func', testfunc)
...
>>> f = FooBar()
>>> f.test_func(1, 2, 3, 4)
testing 1, 2, 3, 4
>>> print FooBar.test_func.__doc__
Alias for `testfunc()`
>>> print FooBar.testfunc.__doc__
Print out the args.
Aliased as `test_func()`, `another_name()`
Alias for indented()
Aliased as indent()
Returns True if a call of callable with args raises an error, and False if not. Note that the callable will get called, so don’t do anything that takes a long time or changes things in a way you don’t want them to be changed. If the optional keyword argument ‘error’ is given as either an Exception subclass or an Iterable, raises_error returns True if the call of callable raises the error given or one of the errors given in the list. (The keyword argument can also be named ‘errors’). Any other keyword arguments are passed through to callable.
Technical note: As per the Python manual, only exceptions that subclass from Exception (and not BaseException directly) will be recognized. According to the python users manual, you should never implement a user exception that subclasses from BaseException directly.
Examples : |
---|
>>> raises_error(int, "5")
False
>>> raises_error(int, "0x5ab7", 0)
False
>>> raises_error(lambda x: int(x), "5")
False
>>> raises_error(int, "abc")
True
>>> raises_error(int, "abc", error = ValueError)
True
>>> raises_error(int, "abc", error = BufferError)
False
>>> raises_error(int, "abc", error = (BufferError, EnvironmentError))
False
>>> raises_error(int, "abc", error = [BufferError, ValueError])
True
>>> raises_error(float, "abc")
True
>>> # Use raises_error to see what errors raises_error raises
... # Raise a type error if the first argument is not a callable (i.e. 17(25) doesn't make sense to Python)
... raises_error(raises_error, 17, 25, error = TypeError)
True
>>> # Raise a TypeError if the error keyword argument is not a subclass of Exception
... raises_error(lambda x: raises_error(int, x, error = "hello world"), 25, error = TypeError)
True
>>> raises_error(lambda x: raises_error(int, x, error = BaseException), 25, error = TypeError)
True
Aliased as shortstr()
Alias for short_str()
Returns the unicode string subscript equivalent of num as a unicode string
Returns the unicode string superscript equivalent of num as a unicode string
Metaclass for a general unit of something.
Aliased as is_unit()
Alias for isunit()
Alias for convert_units()
Aliased as convert()
Aliased as iscompatible()
Alias for compatible_units()
General superclass for all distance units
General superclass for all energy units
alias of Wavenumber
General superclass for all angular units
General superclass for all units of electric charge
General superclass for all units of mass
alias of AtomicMassUnit
General superclass for all time units
alias of Angstrom
alias of YottaAngstrom
alias of YottaAngstrom
alias of Angstrom
alias of ZettaAngstrom
alias of ZettaAngstrom
alias of Angstrom
alias of ExaAngstrom
alias of ExaAngstrom
alias of Angstrom
alias of PetaAngstrom
alias of PetaAngstrom
alias of Angstrom
alias of TeraAngstrom
alias of TeraAngstrom
alias of Angstrom
alias of GigaAngstrom
alias of GigaAngstrom
alias of Angstrom
alias of MegaAngstrom
alias of MegaAngstrom
alias of Angstrom
alias of KiloAngstrom
alias of KiloAngstrom
alias of Angstrom
alias of HectoAngstrom
alias of HectoAngstrom
alias of Angstrom
alias of DecaAngstrom
alias of DecaAngstrom
alias of Angstrom
alias of DeciAngstrom
alias of DeciAngstrom
alias of Angstrom
alias of CentiAngstrom
alias of CentiAngstrom
alias of Angstrom
alias of MilliAngstrom
alias of MilliAngstrom
alias of Angstrom
alias of MicroAngstrom
alias of MicroAngstrom
alias of Angstrom
alias of NanoAngstrom
alias of NanoAngstrom
alias of Angstrom
alias of PicoAngstrom
alias of PicoAngstrom
alias of Angstrom
alias of FemtoAngstrom
alias of FemtoAngstrom
alias of Angstrom
alias of AttoAngstrom
alias of AttoAngstrom
alias of Angstrom
alias of ZeptoAngstrom
alias of ZeptoAngstrom
alias of Angstrom
alias of YoctoAngstrom
alias of YoctoAngstrom
alias of Bohr
alias of Bohr
alias of Bohr
alias of Bohr
alias of Bohr
alias of Bohr
alias of Bohr
alias of Bohr
alias of Bohr
alias of Bohr
alias of Bohr
alias of Bohr
alias of Bohr
alias of Bohr
alias of Bohr
alias of Bohr
alias of Bohr
alias of Bohr
alias of Bohr
alias of Bohr
alias of YottaAtomicUnitOfDistance
alias of ZettaAtomicUnitOfDistance
alias of ExaAtomicUnitOfDistance
alias of PetaAtomicUnitOfDistance
alias of TeraAtomicUnitOfDistance
alias of GigaAtomicUnitOfDistance
alias of MegaAtomicUnitOfDistance
alias of KiloAtomicUnitOfDistance
alias of HectoAtomicUnitOfDistance
alias of DecaAtomicUnitOfDistance
alias of DeciAtomicUnitOfDistance
alias of CentiAtomicUnitOfDistance
alias of MilliAtomicUnitOfDistance
alias of MicroAtomicUnitOfDistance
alias of NanoAtomicUnitOfDistance
alias of PicoAtomicUnitOfDistance
alias of FemtoAtomicUnitOfDistance
alias of AttoAtomicUnitOfDistance
alias of ZeptoAtomicUnitOfDistance
alias of YoctoAtomicUnitOfDistance
alias of Meter
alias of YottaMeter
alias of YottaMeter
alias of Meter
alias of ZettaMeter
alias of ZettaMeter
alias of Meter
alias of Meter
alias of Meter
alias of Meter
alias of Meter
alias of Meter
alias of Meter
alias of HectoMeter
alias of HectoMeter
alias of Meter
alias of Meter
alias of Meter
alias of CentiMeter
alias of CentiMeter
alias of Meter
alias of MilliMeter
alias of MilliMeter
alias of Meter
alias of MicroMeter
alias of MicroMeter
alias of Meter
alias of Meter
alias of Meter
alias of FemtoMeter
alias of FemtoMeter
alias of Meter
alias of Meter
alias of ZeptoMeter
alias of ZeptoMeter
alias of Meter
alias of YoctoMeter
alias of YoctoMeter
alias of Degree
alias of YottaDegree
alias of YottaDegree
alias of Degree
alias of ZettaDegree
alias of ZettaDegree
alias of Degree
alias of Degree
alias of PetaDegree
alias of PetaDegree
alias of Degree
alias of TeraDegree
alias of TeraDegree
alias of Degree
alias of GigaDegree
alias of GigaDegree
alias of Degree
alias of MegaDegree
alias of MegaDegree
alias of Degree
alias of KiloDegree
alias of KiloDegree
alias of Degree
alias of HectoDegree
alias of HectoDegree
alias of Degree
alias of DecaDegree
alias of DecaDegree
alias of Degree
alias of DeciDegree
alias of DeciDegree
alias of Degree
alias of CentiDegree
alias of CentiDegree
alias of Degree
alias of MilliDegree
alias of MilliDegree
alias of Degree
alias of MicroDegree
alias of MicroDegree
alias of Degree
alias of NanoDegree
alias of NanoDegree
alias of Degree
alias of PicoDegree
alias of PicoDegree
alias of Degree
alias of FemtoDegree
alias of FemtoDegree
alias of Degree
alias of AttoDegree
alias of AttoDegree
alias of Degree
alias of ZeptoDegree
alias of ZeptoDegree
alias of Degree
alias of YoctoDegree
alias of YoctoDegree
alias of Radian
alias of YottaRadian
alias of YottaRadian
alias of Radian
alias of ZettaRadian
alias of ZettaRadian
alias of Radian
alias of Radian
alias of PetaRadian
alias of PetaRadian
alias of Radian
alias of TeraRadian
alias of TeraRadian
alias of Radian
alias of GigaRadian
alias of GigaRadian
alias of Radian
alias of MegaRadian
alias of MegaRadian
alias of Radian
alias of KiloRadian
alias of KiloRadian
alias of Radian
alias of HectoRadian
alias of HectoRadian
alias of Radian
alias of DecaRadian
alias of DecaRadian
alias of Radian
alias of DeciRadian
alias of DeciRadian
alias of Radian
alias of CentiRadian
alias of CentiRadian
alias of Radian
alias of MilliRadian
alias of MilliRadian
alias of Radian
alias of MicroRadian
alias of MicroRadian
alias of Radian
alias of NanoRadian
alias of NanoRadian
alias of Radian
alias of PicoRadian
alias of PicoRadian
alias of Radian
alias of FemtoRadian
alias of FemtoRadian
alias of Radian
alias of AttoRadian
alias of AttoRadian
alias of Radian
alias of ZeptoRadian
alias of ZeptoRadian
alias of Radian
alias of YoctoRadian
alias of YoctoRadian
alias of Joule
alias of YottaJoule
alias of YottaJoule
alias of Joule
alias of ZettaJoule
alias of ZettaJoule
alias of Joule
alias of Joule
alias of Joule
alias of Joule
alias of Joule
alias of Joule
alias of Joule
alias of HectoJoule
alias of HectoJoule
alias of Joule
alias of Joule
alias of Joule
alias of CentiJoule
alias of CentiJoule
alias of Joule
alias of MilliJoule
alias of MilliJoule
alias of Joule
alias of MicroJoule
alias of MicroJoule
alias of Joule
alias of Joule
alias of Joule
alias of FemtoJoule
alias of FemtoJoule
alias of Joule
alias of Joule
alias of ZeptoJoule
alias of ZeptoJoule
alias of Joule
alias of YoctoJoule
alias of YoctoJoule
alias of Wavenumber
alias of Wavenumber
alias of Wavenumber
alias of YottaWavenumber
alias of YottaWavenumber
alias of Wavenumber
alias of Wavenumber
alias of ZettaWavenumber
alias of ZettaWavenumber
alias of Wavenumber
alias of Wavenumber
alias of ExaWavenumber
alias of ExaWavenumber
alias of Wavenumber
alias of Wavenumber
alias of PetaWavenumber
alias of PetaWavenumber
alias of Wavenumber
alias of Wavenumber
alias of TeraWavenumber
alias of TeraWavenumber
alias of Wavenumber
alias of Wavenumber
alias of GigaWavenumber
alias of GigaWavenumber
alias of Wavenumber
alias of Wavenumber
alias of MegaWavenumber
alias of MegaWavenumber
alias of Wavenumber
alias of Wavenumber
alias of KiloWavenumber
alias of KiloWavenumber
alias of Wavenumber
alias of Wavenumber
alias of HectoWavenumber
alias of HectoWavenumber
alias of Wavenumber
alias of Wavenumber
alias of DecaWavenumber
alias of DecaWavenumber
alias of Wavenumber
alias of Wavenumber
alias of DeciWavenumber
alias of DeciWavenumber
alias of Wavenumber
alias of Wavenumber
alias of CentiWavenumber
alias of CentiWavenumber
alias of Wavenumber
alias of Wavenumber
alias of MilliWavenumber
alias of MilliWavenumber
alias of Wavenumber
alias of Wavenumber
alias of MicroWavenumber
alias of MicroWavenumber
alias of Wavenumber
alias of Wavenumber
alias of NanoWavenumber
alias of NanoWavenumber
alias of Wavenumber
alias of Wavenumber
alias of PicoWavenumber
alias of PicoWavenumber
alias of Wavenumber
alias of Wavenumber
alias of FemtoWavenumber
alias of FemtoWavenumber
alias of Wavenumber
alias of Wavenumber
alias of AttoWavenumber
alias of AttoWavenumber
alias of Wavenumber
alias of Wavenumber
alias of ZeptoWavenumber
alias of ZeptoWavenumber
alias of Wavenumber
alias of Wavenumber
alias of YoctoWavenumber
alias of YoctoWavenumber
alias of ElectronVolt
alias of ElectronVolt
alias of ElectronVolt
alias of ElectronVolt
alias of ElectronVolt
alias of ElectronVolt
alias of ElectronVolt
alias of ElectronVolt
alias of ElectronVolt
alias of ElectronVolt
alias of ElectronVolt
alias of ElectronVolt
alias of ElectronVolt
alias of ElectronVolt
alias of ElectronVolt
alias of ElectronVolt
alias of ElectronVolt
alias of ElectronVolt
alias of ElectronVolt
alias of ElectronVolt
alias of ElectronVolt
alias of ElectronVolt
alias of ElectronVolt
alias of ElectronVolt
alias of ElectronVolt
alias of ElectronVolt
alias of ElectronVolt
alias of ElectronVolt
alias of ElectronVolt
alias of ElectronVolt
alias of ElectronVolt
alias of ElectronVolt
alias of ElectronVolt
alias of ElectronVolt
alias of ElectronVolt
alias of ElectronVolt
alias of ElectronVolt
alias of ElectronVolt
alias of ElectronVolt
alias of ElectronVolt
alias of ElectronVolt
alias of Hertz
alias of YottaHertz
alias of YottaHertz
alias of Hertz
alias of ZettaHertz
alias of ZettaHertz
alias of Hertz
alias of Hertz
alias of Hertz
alias of Hertz
alias of Hertz
alias of Hertz
alias of Hertz
alias of HectoHertz
alias of HectoHertz
alias of Hertz
alias of Hertz
alias of Hertz
alias of CentiHertz
alias of CentiHertz
alias of Hertz
alias of MilliHertz
alias of MilliHertz
alias of Hertz
alias of MicroHertz
alias of MicroHertz
alias of Hertz
alias of Hertz
alias of Hertz
alias of FemtoHertz
alias of FemtoHertz
alias of Hertz
alias of Hertz
alias of ZeptoHertz
alias of ZeptoHertz
alias of Hertz
alias of YoctoHertz
alias of YoctoHertz
alias of Hartree
alias of YottaHartree
alias of YottaHartree
alias of Hartree
alias of ZettaHartree
alias of ZettaHartree
alias of Hartree
alias of ExaHartree
alias of ExaHartree
alias of Hartree
alias of PetaHartree
alias of PetaHartree
alias of Hartree
alias of TeraHartree
alias of TeraHartree
alias of Hartree
alias of GigaHartree
alias of GigaHartree
alias of Hartree
alias of MegaHartree
alias of MegaHartree
alias of Hartree
alias of KiloHartree
alias of KiloHartree
alias of Hartree
alias of HectoHartree
alias of HectoHartree
alias of Hartree
alias of DecaHartree
alias of DecaHartree
alias of Hartree
alias of DeciHartree
alias of DeciHartree
alias of Hartree
alias of CentiHartree
alias of CentiHartree
alias of Hartree
alias of MilliHartree
alias of MilliHartree
alias of Hartree
alias of MicroHartree
alias of MicroHartree
alias of Hartree
alias of NanoHartree
alias of NanoHartree
alias of Hartree
alias of PicoHartree
alias of PicoHartree
alias of Hartree
alias of FemtoHartree
alias of FemtoHartree
alias of Hartree
alias of AttoHartree
alias of AttoHartree
alias of Hartree
alias of ZeptoHartree
alias of ZeptoHartree
alias of Hartree
alias of YoctoHartree
alias of YoctoHartree
alias of YottaAtomicUnitOfEnergy
alias of ZettaAtomicUnitOfEnergy
alias of ExaAtomicUnitOfEnergy
alias of PetaAtomicUnitOfEnergy
alias of TeraAtomicUnitOfEnergy
alias of GigaAtomicUnitOfEnergy
alias of MegaAtomicUnitOfEnergy
alias of KiloAtomicUnitOfEnergy
alias of HectoAtomicUnitOfEnergy
alias of DecaAtomicUnitOfEnergy
alias of DeciAtomicUnitOfEnergy
alias of CentiAtomicUnitOfEnergy
alias of MilliAtomicUnitOfEnergy
alias of MicroAtomicUnitOfEnergy
alias of NanoAtomicUnitOfEnergy
alias of PicoAtomicUnitOfEnergy
alias of FemtoAtomicUnitOfEnergy
alias of AttoAtomicUnitOfEnergy
alias of ZeptoAtomicUnitOfEnergy
alias of YoctoAtomicUnitOfEnergy
alias of KiloCaloriePerMol
alias of KiloCaloriePerMol
alias of KiloCaloriePerMol
alias of KiloCaloriePerMol
alias of KiloCaloriePerMol
alias of KiloCaloriePerMol
alias of KiloCaloriePerMol
alias of KiloJoulePerMol
alias of KiloJoulePerMol
alias of KiloJoulePerMol
alias of KiloJoulePerMol
alias of Second
alias of YottaSecond
alias of YottaSecond
alias of Second
alias of ZettaSecond
alias of ZettaSecond
alias of Second
alias of Second
alias of PetaSecond
alias of PetaSecond
alias of Second
alias of TeraSecond
alias of TeraSecond
alias of Second
alias of GigaSecond
alias of GigaSecond
alias of Second
alias of MegaSecond
alias of MegaSecond
alias of Second
alias of KiloSecond
alias of KiloSecond
alias of Second
alias of HectoSecond
alias of HectoSecond
alias of Second
alias of DecaSecond
alias of DecaSecond
alias of Second
alias of DeciSecond
alias of DeciSecond
alias of Second
alias of CentiSecond
alias of CentiSecond
alias of Second
alias of MilliSecond
alias of MilliSecond
alias of Second
alias of MicroSecond
alias of MicroSecond
alias of Second
alias of NanoSecond
alias of NanoSecond
alias of Second
alias of PicoSecond
alias of PicoSecond
alias of Second
alias of FemtoSecond
alias of FemtoSecond
alias of Second
alias of AttoSecond
alias of AttoSecond
alias of Second
alias of ZeptoSecond
alias of ZeptoSecond
alias of Second
alias of YoctoSecond
alias of YoctoSecond
alias of AtomicUnitOfTime
alias of AtomicUnitOfTime
alias of AtomicUnitOfTime
alias of AtomicUnitOfTime
alias of AtomicUnitOfTime
alias of AtomicUnitOfTime
alias of AtomicUnitOfTime
alias of AtomicUnitOfTime
alias of AtomicUnitOfTime
alias of AtomicUnitOfTime
alias of AtomicUnitOfTime
alias of AtomicUnitOfTime
alias of AtomicUnitOfTime
alias of AtomicUnitOfTime
alias of AtomicUnitOfTime
alias of AtomicUnitOfTime
alias of AtomicUnitOfTime
alias of AtomicUnitOfTime
alias of AtomicUnitOfTime
alias of AtomicUnitOfTime
alias of AtomicUnitOfTime
alias of AtomicUnitOfTime
alias of AtomicUnitOfTime
alias of AtomicUnitOfTime
alias of AtomicUnitOfTime
alias of AtomicUnitOfTime
alias of AtomicUnitOfTime
alias of AtomicUnitOfTime
alias of AtomicUnitOfTime
alias of AtomicUnitOfTime
alias of AtomicUnitOfTime
alias of AtomicUnitOfTime
alias of AtomicUnitOfTime
alias of AtomicUnitOfTime
alias of AtomicUnitOfTime
alias of AtomicUnitOfTime
alias of AtomicUnitOfTime
alias of AtomicUnitOfTime
alias of AtomicUnitOfTime
alias of AtomicUnitOfTime
alias of AtomicUnitOfTime
alias of Minute
alias of YottaMinute
alias of YottaMinute
alias of Minute
alias of ZettaMinute
alias of ZettaMinute
alias of Minute
alias of Minute
alias of PetaMinute
alias of PetaMinute
alias of Minute
alias of TeraMinute
alias of TeraMinute
alias of Minute
alias of GigaMinute
alias of GigaMinute
alias of Minute
alias of MegaMinute
alias of MegaMinute
alias of Minute
alias of KiloMinute
alias of KiloMinute
alias of Minute
alias of HectoMinute
alias of HectoMinute
alias of Minute
alias of DecaMinute
alias of DecaMinute
alias of Minute
alias of DeciMinute
alias of DeciMinute
alias of Minute
alias of CentiMinute
alias of CentiMinute
alias of Minute
alias of MilliMinute
alias of MilliMinute
alias of Minute
alias of MicroMinute
alias of MicroMinute
alias of Minute
alias of NanoMinute
alias of NanoMinute
alias of Minute
alias of PicoMinute
alias of PicoMinute
alias of Minute
alias of FemtoMinute
alias of FemtoMinute
alias of Minute
alias of AttoMinute
alias of AttoMinute
alias of Minute
alias of ZeptoMinute
alias of ZeptoMinute
alias of Minute
alias of YoctoMinute
alias of YoctoMinute
alias of Hour
alias of Hour
alias of Hour
alias of Hour
alias of Hour
alias of Hour
alias of Hour
alias of Hour
alias of Hour
alias of Hour
alias of Hour
alias of Hour
alias of Hour
alias of Hour
alias of Hour
alias of Hour
alias of Hour
alias of Hour
alias of Hour
alias of Hour
alias of Day
alias of Day
alias of Day
alias of Day
alias of Day
alias of Day
alias of Day
alias of Day
alias of Day
alias of Day
alias of Day
alias of Day
alias of Day
alias of Day
alias of Day
alias of Day
alias of Day
alias of Day
alias of Day
alias of Day
alias of Week
alias of Week
alias of Week
alias of Week
alias of Week
alias of Week
alias of Week
alias of Week
alias of Week
alias of Week
alias of Week
alias of Week
alias of Week
alias of Week
alias of Week
alias of Week
alias of Week
alias of Week
alias of Week
alias of Week
alias of Year
alias of Year
alias of Year
alias of Year
alias of Year
alias of Year
alias of Year
alias of Year
alias of Year
alias of Year
alias of Year
alias of Year
alias of Year
alias of Year
alias of Year
alias of Year
alias of Year
alias of Year
alias of Year
alias of Year
alias of Decade
alias of YottaDecade
alias of YottaDecade
alias of Decade
alias of ZettaDecade
alias of ZettaDecade
alias of Decade
alias of Decade
alias of PetaDecade
alias of PetaDecade
alias of Decade
alias of TeraDecade
alias of TeraDecade
alias of Decade
alias of GigaDecade
alias of GigaDecade
alias of Decade
alias of MegaDecade
alias of MegaDecade
alias of Decade
alias of KiloDecade
alias of KiloDecade
alias of Decade
alias of HectoDecade
alias of HectoDecade
alias of Decade
alias of DecaDecade
alias of DecaDecade
alias of Decade
alias of DeciDecade
alias of DeciDecade
alias of Decade
alias of CentiDecade
alias of CentiDecade
alias of Decade
alias of MilliDecade
alias of MilliDecade
alias of Decade
alias of MicroDecade
alias of MicroDecade
alias of Decade
alias of NanoDecade
alias of NanoDecade
alias of Decade
alias of PicoDecade
alias of PicoDecade
alias of Decade
alias of FemtoDecade
alias of FemtoDecade
alias of Decade
alias of AttoDecade
alias of AttoDecade
alias of Decade
alias of ZeptoDecade
alias of ZeptoDecade
alias of Decade
alias of YoctoDecade
alias of YoctoDecade
alias of Century
alias of YottaCentury
alias of YottaCentury
alias of Century
alias of ZettaCentury
alias of ZettaCentury
alias of Century
alias of ExaCentury
alias of ExaCentury
alias of Century
alias of PetaCentury
alias of PetaCentury
alias of Century
alias of TeraCentury
alias of TeraCentury
alias of Century
alias of GigaCentury
alias of GigaCentury
alias of Century
alias of MegaCentury
alias of MegaCentury
alias of Century
alias of KiloCentury
alias of KiloCentury
alias of Century
alias of HectoCentury
alias of HectoCentury
alias of Century
alias of DecaCentury
alias of DecaCentury
alias of Century
alias of DeciCentury
alias of DeciCentury
alias of Century
alias of CentiCentury
alias of CentiCentury
alias of Century
alias of MilliCentury
alias of MilliCentury
alias of Century
alias of MicroCentury
alias of MicroCentury
alias of Century
alias of NanoCentury
alias of NanoCentury
alias of Century
alias of PicoCentury
alias of PicoCentury
alias of Century
alias of FemtoCentury
alias of FemtoCentury
alias of Century
alias of AttoCentury
alias of AttoCentury
alias of Century
alias of ZeptoCentury
alias of ZeptoCentury
alias of Century
alias of YoctoCentury
alias of YoctoCentury
alias of Millennium
alias of Millennium
alias of Millennium
alias of YottaMillennium
alias of YottaMillennium
alias of Millennium
alias of Millennium
alias of ZettaMillennium
alias of ZettaMillennium
alias of Millennium
alias of Millennium
alias of ExaMillennium
alias of ExaMillennium
alias of Millennium
alias of Millennium
alias of PetaMillennium
alias of PetaMillennium
alias of Millennium
alias of Millennium
alias of TeraMillennium
alias of TeraMillennium
alias of Millennium
alias of Millennium
alias of GigaMillennium
alias of GigaMillennium
alias of Millennium
alias of Millennium
alias of MegaMillennium
alias of MegaMillennium
alias of Millennium
alias of Millennium
alias of KiloMillennium
alias of KiloMillennium
alias of Millennium
alias of Millennium
alias of HectoMillennium
alias of HectoMillennium
alias of Millennium
alias of Millennium
alias of DecaMillennium
alias of DecaMillennium
alias of Millennium
alias of Millennium
alias of DeciMillennium
alias of DeciMillennium
alias of Millennium
alias of Millennium
alias of CentiMillennium
alias of CentiMillennium
alias of Millennium
alias of Millennium
alias of MilliMillennium
alias of MilliMillennium
alias of Millennium
alias of Millennium
alias of MicroMillennium
alias of MicroMillennium
alias of Millennium
alias of Millennium
alias of NanoMillennium
alias of NanoMillennium
alias of Millennium
alias of Millennium
alias of PicoMillennium
alias of PicoMillennium
alias of Millennium
alias of Millennium
alias of FemtoMillennium
alias of FemtoMillennium
alias of Millennium
alias of Millennium
alias of AttoMillennium
alias of AttoMillennium
alias of Millennium
alias of Millennium
alias of ZeptoMillennium
alias of ZeptoMillennium
alias of Millennium
alias of Millennium
alias of YoctoMillennium
alias of YoctoMillennium
alias of Coulomb
alias of YottaCoulomb
alias of YottaCoulomb
alias of Coulomb
alias of ZettaCoulomb
alias of ZettaCoulomb
alias of Coulomb
alias of ExaCoulomb
alias of ExaCoulomb
alias of Coulomb
alias of PetaCoulomb
alias of PetaCoulomb
alias of Coulomb
alias of TeraCoulomb
alias of TeraCoulomb
alias of Coulomb
alias of GigaCoulomb
alias of GigaCoulomb
alias of Coulomb
alias of MegaCoulomb
alias of MegaCoulomb
alias of Coulomb
alias of KiloCoulomb
alias of KiloCoulomb
alias of Coulomb
alias of HectoCoulomb
alias of HectoCoulomb
alias of Coulomb
alias of DecaCoulomb
alias of DecaCoulomb
alias of Coulomb
alias of DeciCoulomb
alias of DeciCoulomb
alias of Coulomb
alias of CentiCoulomb
alias of CentiCoulomb
alias of Coulomb
alias of MilliCoulomb
alias of MilliCoulomb
alias of Coulomb
alias of MicroCoulomb
alias of MicroCoulomb
alias of Coulomb
alias of NanoCoulomb
alias of NanoCoulomb
alias of Coulomb
alias of PicoCoulomb
alias of PicoCoulomb
alias of Coulomb
alias of FemtoCoulomb
alias of FemtoCoulomb
alias of Coulomb
alias of AttoCoulomb
alias of AttoCoulomb
alias of Coulomb
alias of ZeptoCoulomb
alias of ZeptoCoulomb
alias of Coulomb
alias of YoctoCoulomb
alias of YoctoCoulomb
alias of AtomicUnitOfElectricCharge
alias of AtomicUnitOfElectricCharge
alias of AtomicUnitOfElectricCharge
alias of AtomicUnitOfElectricCharge
alias of AtomicUnitOfElectricCharge
alias of AtomicUnitOfElectricCharge
alias of AtomicUnitOfElectricCharge
alias of AtomicUnitOfElectricCharge
alias of AtomicUnitOfElectricCharge
alias of AtomicUnitOfElectricCharge
alias of AtomicUnitOfElectricCharge
alias of AtomicUnitOfElectricCharge
alias of AtomicUnitOfElectricCharge
alias of AtomicUnitOfElectricCharge
alias of AtomicUnitOfElectricCharge
alias of AtomicUnitOfElectricCharge
alias of AtomicUnitOfElectricCharge
alias of AtomicUnitOfElectricCharge
alias of AtomicUnitOfElectricCharge
alias of AtomicUnitOfElectricCharge
alias of AtomicUnitOfElectricCharge
alias of AtomicUnitOfElectricCharge
alias of AtomicUnitOfElectricCharge
alias of AtomicUnitOfElectricCharge
alias of AtomicUnitOfElectricCharge
alias of AtomicUnitOfElectricCharge
alias of AtomicUnitOfElectricCharge
alias of AtomicUnitOfElectricCharge
alias of AtomicUnitOfElectricCharge
alias of AtomicUnitOfElectricCharge
alias of AtomicUnitOfElectricCharge
alias of AtomicUnitOfElectricCharge
alias of AtomicUnitOfElectricCharge
alias of AtomicUnitOfElectricCharge
alias of AtomicUnitOfElectricCharge
alias of AtomicUnitOfElectricCharge
alias of AtomicUnitOfElectricCharge
alias of AtomicUnitOfElectricCharge
alias of AtomicUnitOfElectricCharge
alias of AtomicUnitOfElectricCharge
alias of AtomicUnitOfElectricCharge
alias of AtomicUnitOfElectricCharge
alias of AtomicUnitOfElectricCharge
alias of AtomicUnitOfElectricCharge
alias of YottaAtomicUnitOfCharge
alias of AtomicUnitOfElectricCharge
alias of ZettaAtomicUnitOfCharge
alias of AtomicUnitOfElectricCharge
alias of ExaAtomicUnitOfCharge
alias of AtomicUnitOfElectricCharge
alias of PetaAtomicUnitOfCharge
alias of AtomicUnitOfElectricCharge
alias of TeraAtomicUnitOfCharge
alias of AtomicUnitOfElectricCharge
alias of GigaAtomicUnitOfCharge
alias of AtomicUnitOfElectricCharge
alias of MegaAtomicUnitOfCharge
alias of AtomicUnitOfElectricCharge
alias of KiloAtomicUnitOfCharge
alias of AtomicUnitOfElectricCharge
alias of HectoAtomicUnitOfCharge
alias of AtomicUnitOfElectricCharge
alias of DecaAtomicUnitOfCharge
alias of AtomicUnitOfElectricCharge
alias of DeciAtomicUnitOfCharge
alias of AtomicUnitOfElectricCharge
alias of CentiAtomicUnitOfCharge
alias of AtomicUnitOfElectricCharge
alias of MilliAtomicUnitOfCharge
alias of AtomicUnitOfElectricCharge
alias of MicroAtomicUnitOfCharge
alias of AtomicUnitOfElectricCharge
alias of NanoAtomicUnitOfCharge
alias of AtomicUnitOfElectricCharge
alias of PicoAtomicUnitOfCharge
alias of AtomicUnitOfElectricCharge
alias of FemtoAtomicUnitOfCharge
alias of AtomicUnitOfElectricCharge
alias of AttoAtomicUnitOfCharge
alias of AtomicUnitOfElectricCharge
alias of ZeptoAtomicUnitOfCharge
alias of AtomicUnitOfElectricCharge
alias of YoctoAtomicUnitOfCharge
alias of Gram
alias of Gram
alias of Gram
alias of Gram
alias of Gram
alias of Gram
alias of Gram
alias of Gram
alias of Gram
alias of Gram
alias of Gram
alias of Gram
alias of Gram
alias of Gram
alias of Gram
alias of Gram
alias of Gram
alias of Gram
alias of Gram
alias of Gram
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicUnitOfMass
alias of AtomicUnitOfMass
alias of AtomicUnitOfMass
alias of AtomicUnitOfMass
alias of AtomicUnitOfMass
alias of AtomicUnitOfMass
alias of AtomicUnitOfMass
alias of AtomicUnitOfMass
alias of AtomicUnitOfMass
alias of AtomicUnitOfMass
alias of AtomicUnitOfMass
alias of AtomicUnitOfMass
alias of AtomicUnitOfMass
alias of AtomicUnitOfMass
alias of AtomicUnitOfMass
alias of AtomicUnitOfMass
alias of AtomicUnitOfMass
alias of AtomicUnitOfMass
alias of AtomicUnitOfMass
alias of AtomicUnitOfMass
alias of AtomicUnitOfMass
alias of AtomicUnitOfMass
alias of AtomicUnitOfMass
alias of AtomicUnitOfMass
alias of AtomicUnitOfMass
alias of AtomicUnitOfMass
alias of AtomicUnitOfMass
alias of AtomicUnitOfMass
alias of AtomicUnitOfMass
alias of AtomicUnitOfMass
alias of AtomicUnitOfMass
alias of AtomicUnitOfMass
alias of AtomicUnitOfMass
alias of AtomicUnitOfMass
alias of AtomicUnitOfMass
alias of AtomicUnitOfMass
alias of AtomicUnitOfMass
alias of AtomicUnitOfMass
alias of AtomicUnitOfMass
alias of AtomicUnitOfMass
alias of AtomicUnitOfMass
A class for composite units, e.g. Joules/Angstrom^2
Analog of Unit.genre. Always returns CompositeUnit
The name of the composite unit, as a product of base units
Reduce the composite unit into the fewest base units possible.
Examples : |
---|
>>> from grendel.util.units import *
>>> (Angstroms**2/Bohr).reduced()
(1.88972612457 Angstrom)
>>> (Degree / (Bohr**2)).reduced()
Degree / Bohr**2
>>> (Degree / (Bohr*Meter)).reduced()
(5.2917721092e-11 Degree / Bohr**2)
Exception for attempted incompatible unit conversions
Exception for attempted conversion of something that is not a subclass of Unit
For errors encountered in handling unitized objects
Alias for has_units()
Aliased as hasunits()
Aliased as stripunits()
Alias for strip_units()
A class for encapsulating a physical constant and it’s units.
Attributes : |
---|
Abstract base class for things with units. It requires its subclasses to implement the properties ‘value’ and ‘units’. Unitized subclasses are also expected have __mul__, __div__, __truediv__, __pow__, __add__, __sub__, __neg__, __pos__, and __abs__ handle units correctly, when implemented in the given subclass.
Raised when a function within the web_getter module cannot find a molecule with the given identifier.
Iterate over all possible partitions of a sequence
Examples : |
---|
This iterates over the brace notation combinations from Allen, et al. Mol. Phys. 89 (1996), 1213-1221 See the explanation of its funtion therein. This is needed for the arbitrary order B tensor formulae.
Examples : |
---|
>>> [tuple(''.join(part) for part in parts) for parts in brace_notation_iter(['AB', 'C', 'D'])]
[('AB', 'C', 'D'), ('AC', 'B', 'D'), ('AD', 'B', 'C'), ('BC', 'A', 'D'), ('BD', 'A', 'C'), ('CD', 'A', 'B')]
chain(*iterables) –> chain object
Return a chain object whose .next() method returns elements from the first iterable until it is exhausted, then elements from the next iterable, until all of the iterables are exhausted.
chain.from_iterable(iterable) –> chain object
Alternate chain() contructor taking a single iterable argument that evaluates lazily.
x.next() -> the next value, or raise StopIteration
combinations_with_replacement(iterable, r) –> combinations_with_replacement object
Return successive r-length combinations of elements in the iterable allowing individual elements to have successive repeats. combinations_with_replacement(‘ABC’, 2) –> AA AB AC BB BC CC
x.next() -> the next value, or raise StopIteration
Iterate over the progressive cumulative sum of the items in the iterable.
Examples : |
---|
>>> [i for i in cummulative_sum(xrange(6))]
[0, 1, 3, 6, 10, 15]
>>> [a for a in cummulative_sum('ABCD', '')]
['A', 'AB', 'ABC', 'ABCD']
>>> [a for a in cummulative_sum(cummulative_sum('ABCD', ''), '')]
['A', 'AAB', 'AABABC', 'AABABCABCD']
>>> [i for i in cummulative_sum(xrange(1,6), 1, op=operator.mul)]
[1, 2, 6, 24, 120]
cycle(iterable) –> cycle object
Return elements from the iterable until it is exhausted. Then repeat the sequence indefinitely.
x.next() -> the next value, or raise StopIteration
Flatten across all levels of iteration.
Examples : |
---|
>>> [f for f in flattened([1,2,3,[4,5,[6]]])]
[1, 2, 3, 4, 5, 6]
>>> [f for f in flattened([1,2,3,[4,5,[6],[[xrange(1,17)]]]])]
[1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]
>>> [f for f in flattened([range(1,4),1,2,3,[4,5,[6],[[xrange(1,17)]]]])]
[1, 2, 3, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]
>>> [f for f in flattened([1, [3, 4], [["hello", ["world"]]], {"yes": True}])]
[1, 3, 4, 'h', 'e', 'l', 'l', 'o', 'w', 'o', 'r', 'l', 'd', 'y', 'e', 's']
>>> [f for f in flattened([1, [3, 4], [["hello", ["world"]]], {"yes": True}], keep_types=str)]
[1, 3, 4, 'hello', 'world', 'yes']
>>> [f for f in flattened([1, [3, 4], [["hello", ["world"]]], {"yes": True}], keep_types=(str, dict))]
[1, 3, 4, 'hello', 'world', {'yes': True}]
>>> [f for f in flattened([1, [3, 4], [["hello", ["world"]]], {"yes": True}], keep_types=(str, dict, list))]
[[1, [3, 4], [['hello', ['world']]], {'yes': True}]]
group(3, ‘ABCDEFG’, ‘x’) –> ABC DEF Gxx
islice(iterable, [start,] stop [, step]) –> islice object
Return an iterator whose next() method returns selected values from an iterable. If start is specified, will skip all preceding elements; otherwise, start defaults to zero. Step defaults to one. If specified as another value, step determines how many values are skipped between successive calls. Works like a slice() on a list but returns an iterator.
x.next() -> the next value, or raise StopIteration
izip_longest(iter1 [,iter2 [...]], [fillvalue=None]) –> izip_longest object
Return an izip_longest object whose .next() method returns a tuple where the i-th element comes from the i-th iterable argument. The .next() method continues until the longest iterable in the argument sequence is exhausted and then it raises StopIteration. When the shorter iterables are exhausted, the fillvalue is substituted in their place. The fillvalue defaults to None or can be specified by a keyword argument.
x.next() -> the next value, or raise StopIteration
OVERVIEW
This function returns a generator that produces all distinct distributions of distinguishable balls among distinguishable boxes, with specified box sizes (capacities). This is a generalization of the most common formulation of the problem, where each box is sufficiently large to accommodate all of the balls.
CONSTRUCTOR INPUTS
n: the number of balls
box_sizes: This argument is a list of length 1 or greater. The length of the list corresponds to the number of boxes. box_sizes[i] is a positive integer that specifies the maximum capacity of the ith box. If box_sizes[i] equals n (or greater), then the ith box can accommodate all n balls and thus effectively has unlimited capacity.
EXAMPLE
Issue the following statement issued at the IPython prompt:
list(labeled_balls_in_labeled_boxes(3,[2,2]))
The output is as follows:
OVERVIEW
This function returns a generator that produces all distinct distributions of distinguishable balls among indistinguishable boxes, with specified box sizes (capacities). This is a generalization of the most common formulation of the problem, where each box is sufficiently large to accommodate all of the balls. It might be asked, ‘In what sense are the boxes indistinguishable if they have different capacities?’ The answer is that the box capacities must be considered when distributing the balls, but once the balls have been distributed, the identities of the boxes no longer matter.
CONSTRUCTOR INPUTS
n: the number of balls
box_sizes: This argument is a list of length 1 or greater. The length of the list corresponds to the number of boxes. box_sizes[i] is a positive integer that specifies the maximum capacity of the ith box. If box_sizes[i] equals n (or greater), then the ith box can accommodate all n balls and thus effectively has unlimited capacity.
NOTE
For labeled_balls_in_unlabeled_boxes, the order of the elements of the box_sizes list is unimportant because the code will sort it into non- increasing order before any other processing is done.
see ordered_partitions_iter
This iterates over the P^k,m operator from Allen, et al. Mol. Phys. 89 (1996), 1213-1221 See the explanation of its funtion therein. This is needed for the arbitrary order B tensor formulae.
Examples : |
---|
>>> [tuple(''.join(part) for part in parts) for parts in ordered_partitions_iter('ABCD', 2)]
[('A', 'BCD'), ('AB', 'CD')]
>>> [tuple(''.join(part) for part in parts) for parts in ordered_partitions_iter('ABCDEF', 3)]
[('A', 'B', 'CDEF'), ('A', 'BC', 'DEF'), ('AB', 'CD', 'EF')]
Iterate over iterable in chunks of sizes given in partitions. If partitions runs out before iterable does, partitions will be cycled (i.e. the next partition size will be the first element of partitions, the following size will be the second, and so on). If there are not enough elements remaining to fill the last partition, the last item yielded will be shorter (just as if a slice running over the end of the list were taken).
Examples : |
---|
>>> [''.join(a) for a in partitioned('ABCDEFG', (1, 3, 2, 1))]
['A', 'BCD', 'EF', 'G']
>>> [''.join(a) for a in partitioned('ABCDEFGHIJ', (1, 3, 2, 1))]
['A', 'BCD', 'EF', 'G', 'H', 'IJ']
>>> [''.join(a) for a in partitioned('ABCDEFGHIJK', (2,))]
['AB', 'CD', 'EF', 'GH', 'IJ', 'K']
>>> [''.join(a) for a in partitioned('ABC', (1, 3, 2, 1))]
['A', 'BC']
>>> [i for i in partitioned('abcdef', (0,3))]
[(), ('a', 'b', 'c'), (), ('d', 'e', 'f'), ()]
>>> [i for i in partitioned('abcdef', (3,1,0,3))]
[('a', 'b', 'c'), ('d',), (), ('e', 'f')]
>>> [i for i in partitioned('abcdef', (3,1,0))]
[('a', 'b', 'c'), ('d',), (), ('e', 'f')]
repeat each element n times before moving on.
Examples : |
---|
>>> [s for s in stutter([1, 2, 3, 4], 3)]
[1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4]
>>> ''.join(a for a in stutter('hello', 2))
'hheelllloo'
tee(iterable, n=2) –> tuple of n independent iterators.
OVERVIEW
This function returns a generator that produces all distinct distributions of indistinguishable balls among labeled boxes with specified box sizes (capacities). This is a generalization of the most common formulation of the problem, where each box is sufficiently large to accommodate all of the balls, and is an important example of a class of combinatorics problems called ‘weak composition’ problems.
CONSTRUCTOR INPUTS
n: the number of balls
box_sizes: This argument is a list of length 1 or greater. The length of the list corresponds to the number of boxes. box_sizes[i] is a positive integer that specifies the maximum capacity of the ith box. If box_sizes[i] equals n (or greater), then the ith box can accommodate all n balls and thus effectively has unlimited capacity.
ACKNOWLEDGMENT
I’d like to thank Chris Rebert for helping me to convert my prototype class-based code into a generator function.
OVERVIEW
This function returns a generator that produces all distinct distributions of indistinguishable balls among indistinguishable boxes, with specified box sizes (capacities). This is a generalization of the most common formulation of the problem, where each box is sufficiently large to accommodate all of the balls. It might be asked, ‘In what sense are the boxes indistinguishable if they have different capacities?’ The answer is that the box capacities must be considered when distributing the balls, but once the balls have been distributed, the identities of the boxes no longer matter.
CONSTRUCTOR INPUTS
n: the number of balls
box_sizes: This argument is a list of length 1 or greater. The length of the list corresponds to the number of boxes. box_sizes[i] is a positive integer that specifies the maximum capacity of the ith box. If box_sizes[i] equals n (or greater), then the ith box can accommodate all n balls and thus effectively has unlimited capacity.
NOTE
For unlabeled_balls_in_unlabeled_boxes, the order of the elements of the box_sizes list is unimportant because the code will sort it into non- increasing order before any other processing is done.
A sequence of regular expressions for parsing a piece of data from a file. The sequence can have optional activation (“start”) and deactivation (“stop”) sequences, and matches are collected from every match of the main regex (or main list of regexes) given. The Ellipsis object may be given in the main sequence (or the start/stop sequences) to indicate that any number of lines may come in between the preceeding and succeding regexes. A RegexSequence.RepeatedRegex object can be used to indicate that a regex can be repeated without invalidating the sequence.
The RegexSequence object is used by passing a file in line by line to the parse_line() method.
A mechanism for allowing a certain part of a pattern to be duplicated an arbitrary number of times in a line.
A super-lightweight class to hold an interlude
Returns the main regex, in order to conform with the Regex class protocol
A regex that may be repeated on multiple consecutive lines without invalidating the sequence. The RepeatedRegex may be repeated an arbitrary (repeats = None, the default) or specified number of times. Currently, the behavior of repeated regexes with exact=False is not stable when multiple (different) RepeatedRegex objects are given consecutively and the number of intervening lines to be matched is fewer than the number of consecutive RepeatedRegex objects minus 1. This is a fairly extreme edge case that is demonstrated in the test suite in test_expected_failures() in the file “test_parsing.py”.
True if reset() would change nothing
Returns a tuple containing all the match groups from all the matches. If the flat argument is True, (default) the groups are flattened across all matches. If flat is False, the groups are only flattened within a given series (this makes no difference for cases where the main regex is a single expression rather than a list of regexes; in this case a flat list of groups is always returned).
The name “groups” is meant to correspond roughly with the naming convention in Python’s re module.
A (possibly nested) list of the matches collected thus far.
Parse a line from a file.
Reset the regex sequence. Do this, for instance, when you’ve finished parsing one file and need to start parsing another. This gets called by the constructor. Most internal uses of this class should already do this when it is supposed to be done.
Abstract base class for regular expressions. For now, anything that responds to ‘match’, ‘search’, and has the attributes ‘flags’ and ‘pattern’ is considered a Regex object. You can’t instantiate a Regex object; the __new__() just returns re.compile() with the same arguments.
Examples : |
---|
>>> import re
>>> isinstance(re.compile(r'test123'), Regex)
True
>>> isinstance(r'test123', Regex)
False
A mechanism for allowing a certain part of a pattern to be duplicated an arbitrary number of times in a line.
A super-lightweight class to hold an interlude
Returns the main regex, in order to conform with the Regex class protocol
alias of RepeatedRegex
A regex that may be repeated on multiple consecutive lines without invalidating the sequence. The RepeatedRegex may be repeated an arbitrary (repeats = None, the default) or specified number of times. Currently, the behavior of repeated regexes with exact=False is not stable when multiple (different) RepeatedRegex objects are given consecutively and the number of intervening lines to be matched is fewer than the number of consecutive RepeatedRegex objects minus 1. This is a fairly extreme edge case that is demonstrated in the test suite in test_expected_failures() in the file “test_parsing.py”.
True if reset() would change nothing
Change to a certain working directory for the execution of a block of code, then change back upon (any kind of) exit.
Generate the factors of an integer.
Examples : |
---|
>>> for i in divisors(12): print i
...
1
2
3
4
6
12
Mostly a wrapper for the NumPy ndarray class. This gives us a place to put tensor-related functionality that we need but is not available in NumPy.
Copy all properties of the tensor except for the data.
Same as numpy.ndarray.flatten, but modified to return a Vector object
Examples : |
---|
>>> t = Tensor([[[1,2],[3,4]],[[5,6],[7,8]]])
>>> t
Tensor([[[ 1., 2.],
[ 3., 4.]],
[[ 5., 6.],
[ 7., 8.]]])
>>> t.flatten()
Vector([ 1., 2., 3., ..., 6., 7., 8.])
List of pointers to IndexRange objects over which the tensor is defined.
Returns True if all elements of self have absolute values less than cutoff, which defaults to Tensor.zero_cutoff
Note
Tensor.zero_cutoff is treated as a pseudo-class attribute for Tensor instances, meaning individual instances can also set a zero_cutoff attribute which will take precidence over the class-level default.
Given any number of Tensor objects that are the same up to a phase factor, return a list of Tensor objects that have been. Copies are only made if necessary. The chosen phase is the one that makes the first non-zero element (in the numpy.nditer(tensor) iterator, using the cutoff keyword argument or Tensor.zero_cutoff if one is not given) positive.
Allows conformance with the Unitized protocol.
Round off near-integer values (within thresh) to integers for each value in the Tensor.
Same as chop, but does not modify the original and instead returns a copy.
A tensor with elements that can be computed as needed.
Warning
Using this class is a very bad idea. It makes development a nightmare. Don’t do it.
Returns True if and only if the tensor has the item without having to compute it. Same as item in self.
Encapsulates a vector. Most functionality gets passed up to Tensor, which in turn passes things up to numpy.ndarray. Special functionality for vectors gets implemented here.
Examples : |
---|
Multiplication >>> from grendel.gmath import Matrix, Vector >>> Matrix([1,2],[3,4]) * Vector([5,6]) Vector([ 17., 39.])
Cartesian components >>> vtwo = Vector(1., 2.) >>> vthree = Vector(1.11, 2.22, 3.33) >>> vtwo[0] 1.0 >>> vtwo.x 1.0 >>> vtwo.y == vtwo[1] True >>> vthree[2] == vthree.z True >>> # Can also set: >>> vtwo.x = -1 >>> vtwo.y = -2 >>> vtwo Vector([-1., -2.]) >>> vthree.x, vthree.z, vthree.y = 1, 3, 2 >>> vthree Vector([ 1., 2., 3.])
Return the column-vector version of self, which is currently implemented as a Matrix object. Note that matrix-vector multiplication will work without getting column first, so don’t use this unless you have a good reason to do so.
Returns cross product of self with other. Wrapper to numpy.cross
Same as normalize(), but does not modify self
Overrides the numpy.ndarray reshape function to make things make sense.
Examples : |
---|
>>> v = Vector([1,2,3,4])
>>> v.reshape((2,2))
Matrix([[ 1., 2.],
[ 3., 4.]])
>>> # `v` is unchanged:
>>> v
Vector([ 1., 2., 3., 4.])
>>> v.reshape((4,1))
Matrix([[ 1.],
[ 2.],
[ 3.],
[ 4.]])
>>> import numpy as np
>>> np.reshape(v, (2,2))
Matrix([[ 1., 2.],
[ 3., 4.]])
The x component of a cartesian vector
Raises : |
---|
The y component of a cartesian vector
Raises : |
---|
The z component of a cartesian vector
Raises : |
---|
Wrapper to numpy.cross which viewcasts the result as a Vector if the first two arguments are Vector objects
Examples : |
---|
>>> cross( Vector(1, 2, 3), Vector(4, 5, 6) )
Vector([-3., 6., -3.])
>>> # Can also be called as a method of Vector
>>> Vector(1, 2, 3).cross( Vector(4, 5, 6) )
Vector([-3., 6., -3.])
Wrapper for Vector.magnitude()
Examples : |
---|
>>> magnitude(Vector(3.0, 4.0))
5.0
Wrapper for Vector.magnitude()
Examples : |
---|
>>> magnitude(Vector(3.0, 4.0))
5.0
Encapsulates a vector. Most functionality gets passed up to Tensor, which in turn passes things up to numpy.ndarray. Special functionality for vectors gets implemented here.
Wrapper to numpy.eigh and numpy.eig for symmetric and non-symmetric matrices, respectively. Note that the eigenvectors are column vectors in the returned matrix.
Number of columns that self has
Number of rows that self has
Returns the Cartesian vector point rotated about axis by angle
Returns the angle between the two vectors, in radians
Allows for the definition of special indices that cover specific ranges and subranges of Tensor axes in einstein summations.
Examples : |
---|
>>> IndexRange.clear_known_ranges() # Don't do this in your program; this is just for the doctest
>>> p = IndexRange('p,q,r,s', 5).with_subranges(
... IndexRange('i,j,k,l', 0, 2),
... IndexRange('a,b,c,d', 2, 5)
... )
>>> p
<IndexRange object covering slice 0:5 represented by indices ['p', 'q', 'r', 's']>
>>> p.subranges[0]
<IndexRange object covering slice 0:2 represented by indices ['i', 'j', 'k', 'l']>
>>> p.subranges[1]
<IndexRange object covering slice 2:5 represented by indices ['a', 'b', 'c', 'd']>
>>> prime = IndexRange["m, m',m''", 10, "m range"].with_subranges(
... IndexRange["n,n',n''", ..., 6, "n range"],
... IndexRange["o,o',o''", 6, ...]
... )
>>> prime
<IndexRange named 'm range' represented by indices ['m', 'm'', 'm''']>
>>> prime.subranges[0]
<IndexRange named 'n range' represented by indices ['n', 'n'', 'n''']>
>>> prime.subranges[1]
<IndexRange object covering slice 6:10 represented by indices ['o', 'o'', 'o''']>
Add a subrange to the list of subranges for self. Note that this returns subrange (with subrange.parent modified) to allow for a ‘pass-through’ like usage (see examples below)
Examples : |
---|
>>> IndexRange.reset_ranges()
>>> p = IndexRange('p,q,r,s', 4, name="orbital space")
>>> # Convenient "pass-through" usage for saving subranges:
>>> i = p.add_subrange(IndexRange('i,j,k,l', 0, 2, name="occupied space"))
>>> a = p.add_subrange(IndexRange('a,b,c,d',2,4))
>>> a
<IndexRange object covering slice 2:4 represented by indices ['a', 'b', 'c', 'd']>
>>> p.subranges[0]
<IndexRange named 'occupied space' represented by indices ['i', 'j', 'k', 'l']>
>>> p.subranges[1]
<IndexRange object covering slice 2:4 represented by indices ['a', 'b', 'c', 'd']>
>>> a.parent
<IndexRange named 'orbital space' represented by indices ['p', 'q', 'r', 's']>
Clears the known ranges. Use with care and only if you’re sure you know what you’re doing!
Clears the known ranges. Use with care and only if you’re sure you know what you’re doing!
Gets the slice of parent_range represented by self (parent_range need not be a direct parent of self, but it should be a parent. See is_subrange())
Examples : |
---|
>>> IndexRange.reset_ranges()
>>> p = IndexRange('p,q,r,s',4)
>>> i = p.add_subrange(IndexRange('i,j,k,l',0,2))
>>> a = p.add_subrange(IndexRange('a,b,c,d',2,4))
>>> a.slice_in(p)
slice(2, 4, None)
Basically the same thing as calling add_subrange() multiple times, except returns self instead of the subrange, allowing for a different syntax (see below)
Examples : |
---|
>>> IndexRange.reset_ranges()
>>> orb = DeclareIndexRange('p,q,r,s', 10, name="Orbital space").with_subranges(
... DeclareIndexRange('i,j,k,l', 0, 3, name="Occupied space").with_subranges(
... DeclareIndexRange("i*,j*,k*,l*", 0, 1, name="Core"),
... DeclareIndexRange("i',j',k',l'", 1, 3)
... ),
... DeclareIndexRange('a,b,c,d', 3, 10, name="Virtual space")
... )
>>> orb
<IndexRange named 'Orbital space' represented by indices ['p', 'q', 'r', 's']>
>>> len(orb.subranges)
2
>>> len(orb.subranges[0].subranges)
2
Alias for IndexRange constructor that more accurately describes what is actually going on.
alias of IndexRangeSet
Returns True if child_range is parent_range or child_range is a child of parent_range (analogous to isinstance from the python standard library)
Returns True if child_range is parent_range or child_range is a child of parent_range (analogous to isinstance from the python standard library)
Metaclass for defining Abstract Base Classes (ABCs).
Use this metaclass to create an ABC. An ABC can be subclassed directly, and then acts as a mix-in class. You can also register unrelated concrete classes (even built-in classes) and unrelated ABCs as ‘virtual subclasses’ – these and their descendants will be considered subclasses of the registering ABC by the built-in issubclass() function, but the registering ABC won’t show up in their MRO (Method Resolution Order) nor will method implementations defined by the registering ABC be callable (not even via super()).
Register a virtual subclass of an ABC.
Abstract base class for things that you are allowed to take derivatives of.
The value of the differentiable property. If this function is not overridden, assume that self can be added and subtracted, as well as multiplied by a float.
An arbitrary finite difference derivative with respect to k FiniteDifferenceVariable instances (not necessarily distinct) of a FiniteDifferenceFunction of an arbitrary number of FiniteDifferenceVariable instances whose output is a Differentiable instance. Ideally, the derivative can be calculated to an arbitrary order of robustness in the displacement, though in practice not all orders may be implemented yet.
Save a little bit of time by prepopulating the single variable displacement formulas dictionary up to max_derivative and max_order. If forward is True, the forward formulas are precomputed instead of the central ones.
A formula for a given finite difference derivative.
The displacement amounts for each of the variables.
Get a value for the displacement corresponding to the (variable, number of deltas) pairs given in the argument pairs
The list of FiniteDifferenceVariable instances on which the function depends.
This class implements rational numbers.
In the two-argument form of the constructor, Fraction(8, 6) will produce a rational number equivalent to 4/3. Both arguments must be Rational. The numerator defaults to 0 and the denominator defaults to 1 so that Fraction(3) == 3 and Fraction() == 0.
Fractions can also be constructed from:
- numeric strings similar to those accepted by the float constructor (for example, ‘-2.3’ or ‘1e10’)
- strings of the form ‘123/456’
- float and Decimal instances
- other Rational instances (including integers)
Converts a finite Decimal instance to a rational number, exactly.
Converts a finite float to a rational number, exactly.
Beware that Fraction.from_float(0.3) != Fraction(3, 10).
Closest Fraction to self with denominator at most max_denominator.
>>> Fraction('3.141592653589793').limit_denominator(10)
Fraction(22, 7)
>>> Fraction('3.141592653589793').limit_denominator(100)
Fraction(311, 99)
>>> Fraction(4321, 8765).limit_denominator(10000)
Fraction(4321, 8765)
A read-only attribute. See SpecialAttribute for initialization variables standard to all SpecialAttribute subclasses.
Attributes : |
---|
Mostly a wrapper for the NumPy ndarray class. This gives us a place to put tensor-related functionality that we need but is not available in NumPy.
Copy all properties of the tensor except for the data.
Same as numpy.ndarray.flatten, but modified to return a Vector object
Examples : |
---|
>>> t = Tensor([[[1,2],[3,4]],[[5,6],[7,8]]])
>>> t
Tensor([[[ 1., 2.],
[ 3., 4.]],
[[ 5., 6.],
[ 7., 8.]]])
>>> t.flatten()
Vector([ 1., 2., 3., ..., 6., 7., 8.])
List of pointers to IndexRange objects over which the tensor is defined.
Returns True if all elements of self have absolute values less than cutoff, which defaults to Tensor.zero_cutoff
Note
Tensor.zero_cutoff is treated as a pseudo-class attribute for Tensor instances, meaning individual instances can also set a zero_cutoff attribute which will take precidence over the class-level default.
Given any number of Tensor objects that are the same up to a phase factor, return a list of Tensor objects that have been. Copies are only made if necessary. The chosen phase is the one that makes the first non-zero element (in the numpy.nditer(tensor) iterator, using the cutoff keyword argument or Tensor.zero_cutoff if one is not given) positive.
Allows conformance with the Unitized protocol.
A decorator indicating abstract methods.
Requires that the metaclass is ABCMeta or derived from it. A class that has a metaclass derived from ABCMeta cannot be instantiated unless all of its abstract methods are overridden. The abstract methods can be called using any of the normal ‘super’ call mechanisms.
Usage:
- class C:
__metaclass__ = ABCMeta @abstractmethod def my_abstract_method(self, ...):
...
A decorator indicating abstract properties.
Requires that the metaclass is ABCMeta or derived from it. A class that has a metaclass derived from ABCMeta cannot be instantiated unless all of its abstract properties are overridden. The abstract properties can be called using any of the normal ‘super’ call mechanisms.
Usage:
- class C:
__metaclass__ = ABCMeta @abstractproperty def my_abstract_property(self):
...
This defines a read-only property; you can also define a read-write abstract property using the ‘long’ form of property declaration:
- class C:
- __metaclass__ = ABCMeta def getx(self): ... def setx(self, value): ... x = abstractproperty(getx, setx)
add(a, b) – Same as a + b.
attrgetter(attr, ...) –> attrgetter object
Return a callable object that fetches the given attribute(s) from its operand. After f = attrgetter(‘name’), the call f(r) returns r.name. After g = attrgetter(‘name’, ‘date’), the call g(r) returns (r.name, r.date). After h = attrgetter(‘name.first’, ‘name.last’), the call h(r) returns (r.name.first, r.name.last).
From Fornberg, Bengt. Mathematics of Computation 51 (1988), p. 699-706 M: “the order of the highest derivative we wish to approximate” N: given “a set of N + 1 grid points” x0: the point at which we wish to take the derivative alpha: alpha_i is the ith grid point
groupby(iterable[, keyfunc]) -> create an iterator which returns (key, sub-iterator) grouped by each value of key(value).
x.next() -> the next value, or raise StopIteration
Aliased as indent()
A simple way to accept arguments that can be an Iterable or a bunch of arguments that should be treated as a single Iterable. (This method is pretty trivial, but I find myself doing it a whole lot.) The reason you can’t just use list() for this purpose is that if an Iterable is given as the only argument, list(args) will return a list of Iterables rather than a single Iterable.
Examples : |
---|
>>> def test(*args):
... return listify_args(*args)
...
>>> test(1,2,3)
[1, 2, 3]
>>> test([1,2,3])
[1, 2, 3]
>>> test([1,2,3], 4)
[[1, 2, 3], 4]
>>> test("1,2,3", 4)
['1,2,3', 4]
>>> test("1,2,3")
['1,2,3']
mul(a, b) – Same as a * b.
Type checking for functions and methods.
Allows the creation of functions with case insensative, alternately named keyword arguments.
Examples : |
---|
>>> @with_flexible_arguments(
... required=[
... ('name', 'greet', 'name_to_greet'),
... ('from_where', 'source')
... ],
... optional=[
... ('greeting', 'hello_phrase', 'salutation'),
... ('message',)
... ]
... )
... def say_hello(name, from_where, greeting='Hello', message=''):
... print(greeting + ', ' + name + ', from ' + from_where + '!' + message)
...
>>> say_hello('moon', 'Earth')
Hello, moon, from Earth!
>>> say_hello('world', source='the moon')
Hello, world, from the moon!
>>> say_hello(source='France', name_to_greet='visitor', salutation='Bonjour')
Bonjour, visitor, from France!
>>> say_hello('earthlings', 'outer space', 'Greetings', message=' We come in peace!')
Greetings, earthlings, from outer space! We come in peace!
Decorator for properties with cached return values. The decorator creates a property that stores the return value of the method call in a variable named _[func_name] (where [func_name] is the name of the function).
Examples : |
---|
>>> class Factorializer(object):
...
... n = None
...
... def __init__(self, n):
... self.n = n
...
... @CachedProperty
... def thirty_plus_n_fact(self):
... ret_val = 1
... for i in xrange(2, self.n + 31):
... ret_val *= i
... return ret_val
...
>>> f = Factorializer(3000)
>>> # Takes some time...
>>> var = f.thirty_plus_n_fact
>>> # Should take no time...
>>> for i in xrange(100):
... var = f.thirty_plus_n_fact
...
>>> # Be careful... Remember to invalidate the cache when the appropriate variables are updated...
>>> f.n = 2500
>>> # Takes no time but gives the wrong answer:
>>> var = f.thirty_plus_n_fact
>>> # Invalidate the cache:
>>> f._thirty_plus_n_fact = None
>>> # This should take some time again, but now it will get the right answer
>>> var = f.thirty_plus_n_fact
Abstract base class for a general coordinate of a Molecule.
Coordinate`s are the components in which `Molecule`s are represented. The most important thing about `Coordinate`s is that they are immutible, like Python’s `str and tuple classes. [#f1]_ Let me say that again a bit louder:
Note
All coordinates are immutable!
Parentage and the molecule attribute: Coordinate instances are typically (though not always) associated with a Representation, accessible through the parent read-only attribute. Coordinate instances that do not have a parent associated with them are called “orphaned” coordinates, and can be identified using the is_orphaned() instance method. Even orphaned coordinates must have a Molecule associated with them in one way or another. This happens in one of three ways:
- If the Coordinate is not orphaned, then parent‘s molecule attribute is used. Note that in this case, the Coordinate protocol requires the Coordinate‘s constituant atoms to have a parent molecule that is exactly the same instance as parent‘s molecule attribute. (If you aren’t doing something weird, this shouldn’t be an issue).
- If the Coordinate is orphaned, it still must be composed of one or more Atom instances, accessible through the atoms attribute. These Atom`s may themselves be orphaned, but if they are not, the first non-orphaned `Atom‘s parent is used. Note that if one Atom is non-orphaned, the Coordinate protocol requires that all of them must not be orphaned (i. e. the Coordinate constructor enforces this when sanity_checking_enabled is True)
- If the Coordinate is orphaned and all of its Atom`s are also orphaned (as is the case, for instance, with `Coordinate instances created for the purpose of finite difference B tensor computation), the Coordinate‘s base_analog attribute may be set to a Coordinate instance whose constituate Atom instances correspond to the derived Coordinate‘s atoms’ base_atom attributes. In this case, the base_analog‘s molecule attribute is used, though it should be utilized for index translation purposes only, since the positions of the atoms in the base molecule will not correspond to the positions of the Coordinate‘s atoms. (The base_analog, in turn, may be an orphaned coordinate of this third type, in which case that coordinate’s base_analog will be used, and so on recursively.)
- If the Coordinate is orphaned and no base_analog is given, then all of the atoms must have a base_atom that either has a parent_molecule or also has a base_atom defined (and so on so that a base_atom eventually has a parent_molecule somewhere up the line). In this case, the Coordinate protocol requires that all the atoms refer to the same Molecule obtained in this manner. Coordinates created in the course of analytic computation of B tensors fall into this catagory.
Indexing schemes: Because all Coordinate`s may be austensibly associated with a `Molecule instance in one way or another, there are two different ways to index various tensor properties of a Coordinate: the Molecule‘s indices (3 * natoms total indices) and the Coordinate‘s indexing scheme (3 * len(coord.atoms) total indices, where coord is a Coordinate instance). The internal indexing scheme makes a lot more sense in many instances, (see the documentation of Coordinate.atoms for a simple example), but for determining properties of the whole molecule, we need to use the Molecule‘s indexing scheme. All of this should be handled seemlessly behind the scenes, but it’s a good distinction to be aware of.
Getting a Coordinate‘s value: Coordinate has a number of methods that can be used to get the value of a Coordinate in a particular scenario. They hierarchically call each other to determine the value of the Coordinate. The basic scheme is as follows:
}
The reason for this relatively complex hierarchy is that there are instances in which I have needed each variety for some reason or another. Nodes with dotted borders must be implemented in the relevant subclasses: SimpleInternalCoordinate subclasses must implement value_for_xyz, InternalCoordinate subclasses must implement value_for_positions, and Coordinate subclasses must implement value_for_molecule_matrix().
Subclassing: |
---|
TODO: write this part
Footnotes
[1] | Since Python doesn’t really have private attributes, you could in theory change some of the attributes of a Coordinate instance after it is created; the designation of “immutible” here merely means that the class is not guarenteed to work if you do. While it’s technically more of a “please don’t” than a “you can’t”, I for one will not be held responsible for your code not working if you do something like that, and the way these private attributes are used and changed is not guarenteed to stay the same between different versions. Bottom line: just don’t do it. If you don’t know what I’m talking about, you’re probably okay. Just don’t access or modify any attributes that start with a single underscore (you should never do this anyway from outside of a class). |
The indices of the atom(s) the Coordinate depends on in the Molecule the Coordinate depends on.
This is guarenteed to work whether or not the Coordinate is orphaned. For each of the various possible Coordinate–Molecule relationships detailed in the Coordinate class documentation, the reason the method works is as follows:
Use this carefully. Don’t ever retrieve an atom’s position by its index in the parent molecule, since that atom may not be the same instance (or even in the same position) as the Coordinate‘s atom.
List of the Atom instances that the Coordinate depends on. In the case of a CartesianCoordinate, for instance, this is trivially one Atom, but in the case of other coordinates it can be much more substantial. In the case of a NormalCoordinate, this is all the atoms in the parent Molecule.
The presence of an atoms list is essential to establish an internal indexing scheme that can be converted to the indexing scheme of the parent molecule. Besides making the B tensor code much more managable, the use of an internal indexing scheme make Coordinate instances much more self-contained, making “orphaned” coordinates much more viable. Consider the following example:
>>> from grendel.util.units import Degrees
>>> from grendel.coordinates.bond_angle import BondAngle
>>> ba = BondAngle(
... Atom('O', [0.0, 0.0, 0.0]),
... Atom('H', [0.0, 1.0, 0.0]),
... Atom('H', [0.0, 0.0, 1.0]),
... units=Degrees
... )
>>> round(ba.value)
90.
If orphaned coordinates where not allowed to exist, we would have to create a Molecule instance containing those three atoms, construct an InternalRepresentation containing the BondAngle instance (which would need to be a valid, complete representation, a non-trivial task in the general case), pair that InternalRepresentation instance with the Molecule instance, get the right Coordinate instance from the InternalRepresentation corresponding to the BondAngle we want, and then get that coordinate’s value. If all of the coordinate’s complicated methods were not implemented in terms of the Coordinate’s own indexing scheme, it would have to have all of this structure in place just to get a value.
Note
Since all Coordinate`s depend on `Atom`s and `Atom`s are not immutible, a `Coordinate`s `value and other properties such as its b_vector can change even if the Coordinate itself cannot. The one way around this is to specify freeze_value as True in the Coordinate‘s constructor. If that is done, the value of the Coordinate will not change over the life of the instance, even if the positions of the constituant atoms does change (so if you use this, make sure you know what you are doing). This behavior is useful, for instance, in the use of CartesianRepresentation`s as “snapshots” of a `Molecule instance to be used for the parsing of a particular RepresentationDependentProperty.
Analogous Coordinate object on the base molecule, if self is a Coordinate on a displaced Molecule, or the Coordinate from which an orphaned displaced Coordinate was created, if the coordinate was created this way.
Every coordinate must define a reasonable default amount for a finite displacement of that kind of coordinate. This should be a class attribute.
Whether or not the Coordinate instance has a parent Representation
Default implementation for coordinates dependent on atoms directly (basically anything but a CartesianCoordinate or some sort of symmetrized cartesian coordinate).
The molecule associated with the Coordinate.
Note
The molecule’s atoms’ positions may not correspond to the positions of the atoms the coordinate describes. See the class documentation for Coordinate for details.
The InternalRepresentation instance which the coordinate self is a part of.
The InternalRepresentation instance which the coordinate self is a part of.
The units in which the coordinate’s value is expressed.
Get the value of the coordinate for the XYZ matrix mat, which is a (self.molecule.natoms) by 3 matrix. In other words, the matrix argument uses the parent Molecule‘s indexing scheme, not the Coordinate‘s own indexing scheme.
Note
For angular coordinates, this always returns a value in Radians. value, value_with_units, and value_for_molecule, however, return values in self.units
Encapsulates the concept of an (energy) derivative with respect to a coordinate. This may later be expanded (in a backwards compatible manner) to include other types of derivatives, e.g. dipole moment derivatives
Attributes : |
---|
The Molecule object to which the coordinate
The order of the derivative. ‘1’ indicates first derivative, ‘2’ indicates second derivative, etc.
A tensor with elements that can be computed as needed.
Warning
Using this class is a very bad idea. It makes development a nightmare. Don’t do it.
Returns True if and only if the tensor has the item without having to compute it. Same as item in self.
Abstract base class for a general coordinate of a Molecule.
Coordinate`s are the components in which `Molecule`s are represented. The most important thing about `Coordinate`s is that they are immutible, like Python’s `str and tuple classes. [#f1]_ Let me say that again a bit louder:
Note
All coordinates are immutable!
Parentage and the molecule attribute: Coordinate instances are typically (though not always) associated with a Representation, accessible through the parent read-only attribute. Coordinate instances that do not have a parent associated with them are called “orphaned” coordinates, and can be identified using the is_orphaned() instance method. Even orphaned coordinates must have a Molecule associated with them in one way or another. This happens in one of three ways:
- If the Coordinate is not orphaned, then parent‘s molecule attribute is used. Note that in this case, the Coordinate protocol requires the Coordinate‘s constituant atoms to have a parent molecule that is exactly the same instance as parent‘s molecule attribute. (If you aren’t doing something weird, this shouldn’t be an issue).
- If the Coordinate is orphaned, it still must be composed of one or more Atom instances, accessible through the atoms attribute. These Atom`s may themselves be orphaned, but if they are not, the first non-orphaned `Atom‘s parent is used. Note that if one Atom is non-orphaned, the Coordinate protocol requires that all of them must not be orphaned (i. e. the Coordinate constructor enforces this when sanity_checking_enabled is True)
- If the Coordinate is orphaned and all of its Atom`s are also orphaned (as is the case, for instance, with `Coordinate instances created for the purpose of finite difference B tensor computation), the Coordinate‘s base_analog attribute may be set to a Coordinate instance whose constituate Atom instances correspond to the derived Coordinate‘s atoms’ base_atom attributes. In this case, the base_analog‘s molecule attribute is used, though it should be utilized for index translation purposes only, since the positions of the atoms in the base molecule will not correspond to the positions of the Coordinate‘s atoms. (The base_analog, in turn, may be an orphaned coordinate of this third type, in which case that coordinate’s base_analog will be used, and so on recursively.)
- If the Coordinate is orphaned and no base_analog is given, then all of the atoms must have a base_atom that either has a parent_molecule or also has a base_atom defined (and so on so that a base_atom eventually has a parent_molecule somewhere up the line). In this case, the Coordinate protocol requires that all the atoms refer to the same Molecule obtained in this manner. Coordinates created in the course of analytic computation of B tensors fall into this catagory.
Indexing schemes: Because all Coordinate`s may be austensibly associated with a `Molecule instance in one way or another, there are two different ways to index various tensor properties of a Coordinate: the Molecule‘s indices (3 * natoms total indices) and the Coordinate‘s indexing scheme (3 * len(coord.atoms) total indices, where coord is a Coordinate instance). The internal indexing scheme makes a lot more sense in many instances, (see the documentation of Coordinate.atoms for a simple example), but for determining properties of the whole molecule, we need to use the Molecule‘s indexing scheme. All of this should be handled seemlessly behind the scenes, but it’s a good distinction to be aware of.
Getting a Coordinate‘s value: Coordinate has a number of methods that can be used to get the value of a Coordinate in a particular scenario. They hierarchically call each other to determine the value of the Coordinate. The basic scheme is as follows:
}
The reason for this relatively complex hierarchy is that there are instances in which I have needed each variety for some reason or another. Nodes with dotted borders must be implemented in the relevant subclasses: SimpleInternalCoordinate subclasses must implement value_for_xyz, InternalCoordinate subclasses must implement value_for_positions, and Coordinate subclasses must implement value_for_molecule_matrix().
Subclassing: |
---|
TODO: write this part
Footnotes
[2] | Since Python doesn’t really have private attributes, you could in theory change some of the attributes of a Coordinate instance after it is created; the designation of “immutible” here merely means that the class is not guarenteed to work if you do. While it’s technically more of a “please don’t” than a “you can’t”, I for one will not be held responsible for your code not working if you do something like that, and the way these private attributes are used and changed is not guarenteed to stay the same between different versions. Bottom line: just don’t do it. If you don’t know what I’m talking about, you’re probably okay. Just don’t access or modify any attributes that start with a single underscore (you should never do this anyway from outside of a class). |
The indices of the atom(s) the Coordinate depends on in the Molecule the Coordinate depends on.
This is guarenteed to work whether or not the Coordinate is orphaned. For each of the various possible Coordinate–Molecule relationships detailed in the Coordinate class documentation, the reason the method works is as follows:
Use this carefully. Don’t ever retrieve an atom’s position by its index in the parent molecule, since that atom may not be the same instance (or even in the same position) as the Coordinate‘s atom.
List of the Atom instances that the Coordinate depends on. In the case of a CartesianCoordinate, for instance, this is trivially one Atom, but in the case of other coordinates it can be much more substantial. In the case of a NormalCoordinate, this is all the atoms in the parent Molecule.
The presence of an atoms list is essential to establish an internal indexing scheme that can be converted to the indexing scheme of the parent molecule. Besides making the B tensor code much more managable, the use of an internal indexing scheme make Coordinate instances much more self-contained, making “orphaned” coordinates much more viable. Consider the following example:
>>> from grendel.util.units import Degrees
>>> from grendel.coordinates.bond_angle import BondAngle
>>> ba = BondAngle(
... Atom('O', [0.0, 0.0, 0.0]),
... Atom('H', [0.0, 1.0, 0.0]),
... Atom('H', [0.0, 0.0, 1.0]),
... units=Degrees
... )
>>> round(ba.value)
90.
If orphaned coordinates where not allowed to exist, we would have to create a Molecule instance containing those three atoms, construct an InternalRepresentation containing the BondAngle instance (which would need to be a valid, complete representation, a non-trivial task in the general case), pair that InternalRepresentation instance with the Molecule instance, get the right Coordinate instance from the InternalRepresentation corresponding to the BondAngle we want, and then get that coordinate’s value. If all of the coordinate’s complicated methods were not implemented in terms of the Coordinate’s own indexing scheme, it would have to have all of this structure in place just to get a value.
Note
Since all Coordinate`s depend on `Atom`s and `Atom`s are not immutible, a `Coordinate`s `value and other properties such as its b_vector can change even if the Coordinate itself cannot. The one way around this is to specify freeze_value as True in the Coordinate‘s constructor. If that is done, the value of the Coordinate will not change over the life of the instance, even if the positions of the constituant atoms does change (so if you use this, make sure you know what you are doing). This behavior is useful, for instance, in the use of CartesianRepresentation`s as “snapshots” of a `Molecule instance to be used for the parsing of a particular RepresentationDependentProperty.
Analogous Coordinate object on the base molecule, if self is a Coordinate on a displaced Molecule, or the Coordinate from which an orphaned displaced Coordinate was created, if the coordinate was created this way.
Every coordinate must define a reasonable default amount for a finite displacement of that kind of coordinate. This should be a class attribute.
Whether or not the Coordinate instance has a parent Representation
Default implementation for coordinates dependent on atoms directly (basically anything but a CartesianCoordinate or some sort of symmetrized cartesian coordinate).
The molecule associated with the Coordinate.
Note
The molecule’s atoms’ positions may not correspond to the positions of the atoms the coordinate describes. See the class documentation for Coordinate for details.
The InternalRepresentation instance which the coordinate self is a part of.
The InternalRepresentation instance which the coordinate self is a part of.
The units in which the coordinate’s value is expressed.
Get the value of the coordinate for the XYZ matrix mat, which is a (self.molecule.natoms) by 3 matrix. In other words, the matrix argument uses the parent Molecule‘s indexing scheme, not the Coordinate‘s own indexing scheme.
Note
For angular coordinates, this always returns a value in Radians. value, value_with_units, and value_for_molecule, however, return values in self.units
A collection of derivatives with indices that are coordinates in a given representation.
An Iterable that is not an instance of basestring
All numbers inherit from this class.
If you just want to check if an argument x is a number, without caring what kind, use isinstance(x, Number).
Superclass of all the representations types.
Attributes : |
|
---|
Make a copy of self that is the same in every way except for the molecule attribute. New Coordinate objects are created using the Coordinate.copy_for_representation() method for each element of self.coords. This is an abstract method that must be implemented by all Representation subclasses.
Apply the Displacement instance disp to the molecule and current representation, generating a new molecule and a new representation (which start as a deepcopy and the return value of Representation.copy_with_molecule, respectively) with the displacement applied. This is an abstract method that must be implemented by all Representation subclasses.
Alias for values_for_matrix()
Alias for values_for_molecule()
Aliased as value_for_matrix()
Aliased as value_for_molecule()
Mostly a wrapper for the NumPy ndarray class. This gives us a place to put tensor-related functionality that we need but is not available in NumPy.
Copy all properties of the tensor except for the data.
Same as numpy.ndarray.flatten, but modified to return a Vector object
Examples : |
---|
>>> t = Tensor([[[1,2],[3,4]],[[5,6],[7,8]]])
>>> t
Tensor([[[ 1., 2.],
[ 3., 4.]],
[[ 5., 6.],
[ 7., 8.]]])
>>> t.flatten()
Vector([ 1., 2., 3., ..., 6., 7., 8.])
List of pointers to IndexRange objects over which the tensor is defined.
Returns True if all elements of self have absolute values less than cutoff, which defaults to Tensor.zero_cutoff
Note
Tensor.zero_cutoff is treated as a pseudo-class attribute for Tensor instances, meaning individual instances can also set a zero_cutoff attribute which will take precidence over the class-level default.
Given any number of Tensor objects that are the same up to a phase factor, return a list of Tensor objects that have been. Copies are only made if necessary. The chosen phase is the one that makes the first non-zero element (in the numpy.nditer(tensor) iterator, using the cutoff keyword argument or Tensor.zero_cutoff if one is not given) positive.
Allows conformance with the Unitized protocol.
Shallow copy operation on arbitrary Python objects.
See the module’s __doc__ string for more info.
Alias for has_units()
Alias for indented()
permutations(iterable[, r]) –> permutations object
Return successive r-length permutations of elements in the iterable.
permutations(range(3), 2) –> (0,1), (0,2), (1,0), (1,2), (2,0), (2,1)
x.next() -> the next value, or raise StopIteration
Alias for short_str()
Type checking for functions and methods.
Encapsulates specifics about how the calculation was/is to be carried out, such as level of theory, basis set, program, etc. Can be subclassed for specific programs which may require special detail setting methods.
Effectively clones details. Used internally for making a details into a ComputationDetails subclass
Mostly for use by templates, this method returns a string of keyword-value pairs in using the given format for each argument in the argument list. format should use the str.format() protocol from the python standard library with the named slots {key} where the keyword name should go and {value} where the value of the detail should go (or, if the value of the detail is a Keyword object, the contents of the value attribute for that Keyword, or, if the value attribute for the keyword is not defined, the _name attribute for the Keyword object in question.
Aliased as keywordify
Mostly for use by templates, this method returns a string of keyword-value pairs in using the given format for each argument in the argument list. format should use the str.format() protocol from the python standard library with the named slots {key} where the keyword name should go and {value} where the value of the detail should go (or, if the value of the detail is a Keyword object, the contents of the value attribute for that Keyword, or, if the value attribute for the keyword is not defined, the _name attribute for the Keyword object in question.
Aliased as keywordify
Abstract base class for a general coordinate of a Molecule.
Coordinate`s are the components in which `Molecule`s are represented. The most important thing about `Coordinate`s is that they are immutible, like Python’s `str and tuple classes. [#f1]_ Let me say that again a bit louder:
Note
All coordinates are immutable!
Parentage and the molecule attribute: Coordinate instances are typically (though not always) associated with a Representation, accessible through the parent read-only attribute. Coordinate instances that do not have a parent associated with them are called “orphaned” coordinates, and can be identified using the is_orphaned() instance method. Even orphaned coordinates must have a Molecule associated with them in one way or another. This happens in one of three ways:
- If the Coordinate is not orphaned, then parent‘s molecule attribute is used. Note that in this case, the Coordinate protocol requires the Coordinate‘s constituant atoms to have a parent molecule that is exactly the same instance as parent‘s molecule attribute. (If you aren’t doing something weird, this shouldn’t be an issue).
- If the Coordinate is orphaned, it still must be composed of one or more Atom instances, accessible through the atoms attribute. These Atom`s may themselves be orphaned, but if they are not, the first non-orphaned `Atom‘s parent is used. Note that if one Atom is non-orphaned, the Coordinate protocol requires that all of them must not be orphaned (i. e. the Coordinate constructor enforces this when sanity_checking_enabled is True)
- If the Coordinate is orphaned and all of its Atom`s are also orphaned (as is the case, for instance, with `Coordinate instances created for the purpose of finite difference B tensor computation), the Coordinate‘s base_analog attribute may be set to a Coordinate instance whose constituate Atom instances correspond to the derived Coordinate‘s atoms’ base_atom attributes. In this case, the base_analog‘s molecule attribute is used, though it should be utilized for index translation purposes only, since the positions of the atoms in the base molecule will not correspond to the positions of the Coordinate‘s atoms. (The base_analog, in turn, may be an orphaned coordinate of this third type, in which case that coordinate’s base_analog will be used, and so on recursively.)
- If the Coordinate is orphaned and no base_analog is given, then all of the atoms must have a base_atom that either has a parent_molecule or also has a base_atom defined (and so on so that a base_atom eventually has a parent_molecule somewhere up the line). In this case, the Coordinate protocol requires that all the atoms refer to the same Molecule obtained in this manner. Coordinates created in the course of analytic computation of B tensors fall into this catagory.
Indexing schemes: Because all Coordinate`s may be austensibly associated with a `Molecule instance in one way or another, there are two different ways to index various tensor properties of a Coordinate: the Molecule‘s indices (3 * natoms total indices) and the Coordinate‘s indexing scheme (3 * len(coord.atoms) total indices, where coord is a Coordinate instance). The internal indexing scheme makes a lot more sense in many instances, (see the documentation of Coordinate.atoms for a simple example), but for determining properties of the whole molecule, we need to use the Molecule‘s indexing scheme. All of this should be handled seemlessly behind the scenes, but it’s a good distinction to be aware of.
Getting a Coordinate‘s value: Coordinate has a number of methods that can be used to get the value of a Coordinate in a particular scenario. They hierarchically call each other to determine the value of the Coordinate. The basic scheme is as follows:
}
The reason for this relatively complex hierarchy is that there are instances in which I have needed each variety for some reason or another. Nodes with dotted borders must be implemented in the relevant subclasses: SimpleInternalCoordinate subclasses must implement value_for_xyz, InternalCoordinate subclasses must implement value_for_positions, and Coordinate subclasses must implement value_for_molecule_matrix().
Subclassing: |
---|
TODO: write this part
Footnotes
[3] | Since Python doesn’t really have private attributes, you could in theory change some of the attributes of a Coordinate instance after it is created; the designation of “immutible” here merely means that the class is not guarenteed to work if you do. While it’s technically more of a “please don’t” than a “you can’t”, I for one will not be held responsible for your code not working if you do something like that, and the way these private attributes are used and changed is not guarenteed to stay the same between different versions. Bottom line: just don’t do it. If you don’t know what I’m talking about, you’re probably okay. Just don’t access or modify any attributes that start with a single underscore (you should never do this anyway from outside of a class). |
The indices of the atom(s) the Coordinate depends on in the Molecule the Coordinate depends on.
This is guarenteed to work whether or not the Coordinate is orphaned. For each of the various possible Coordinate–Molecule relationships detailed in the Coordinate class documentation, the reason the method works is as follows:
Use this carefully. Don’t ever retrieve an atom’s position by its index in the parent molecule, since that atom may not be the same instance (or even in the same position) as the Coordinate‘s atom.
List of the Atom instances that the Coordinate depends on. In the case of a CartesianCoordinate, for instance, this is trivially one Atom, but in the case of other coordinates it can be much more substantial. In the case of a NormalCoordinate, this is all the atoms in the parent Molecule.
The presence of an atoms list is essential to establish an internal indexing scheme that can be converted to the indexing scheme of the parent molecule. Besides making the B tensor code much more managable, the use of an internal indexing scheme make Coordinate instances much more self-contained, making “orphaned” coordinates much more viable. Consider the following example:
>>> from grendel.util.units import Degrees
>>> from grendel.coordinates.bond_angle import BondAngle
>>> ba = BondAngle(
... Atom('O', [0.0, 0.0, 0.0]),
... Atom('H', [0.0, 1.0, 0.0]),
... Atom('H', [0.0, 0.0, 1.0]),
... units=Degrees
... )
>>> round(ba.value)
90.
If orphaned coordinates where not allowed to exist, we would have to create a Molecule instance containing those three atoms, construct an InternalRepresentation containing the BondAngle instance (which would need to be a valid, complete representation, a non-trivial task in the general case), pair that InternalRepresentation instance with the Molecule instance, get the right Coordinate instance from the InternalRepresentation corresponding to the BondAngle we want, and then get that coordinate’s value. If all of the coordinate’s complicated methods were not implemented in terms of the Coordinate’s own indexing scheme, it would have to have all of this structure in place just to get a value.
Note
Since all Coordinate`s depend on `Atom`s and `Atom`s are not immutible, a `Coordinate`s `value and other properties such as its b_vector can change even if the Coordinate itself cannot. The one way around this is to specify freeze_value as True in the Coordinate‘s constructor. If that is done, the value of the Coordinate will not change over the life of the instance, even if the positions of the constituant atoms does change (so if you use this, make sure you know what you are doing). This behavior is useful, for instance, in the use of CartesianRepresentation`s as “snapshots” of a `Molecule instance to be used for the parsing of a particular RepresentationDependentProperty.
Analogous Coordinate object on the base molecule, if self is a Coordinate on a displaced Molecule, or the Coordinate from which an orphaned displaced Coordinate was created, if the coordinate was created this way.
Every coordinate must define a reasonable default amount for a finite displacement of that kind of coordinate. This should be a class attribute.
Whether or not the Coordinate instance has a parent Representation
Default implementation for coordinates dependent on atoms directly (basically anything but a CartesianCoordinate or some sort of symmetrized cartesian coordinate).
The molecule associated with the Coordinate.
Note
The molecule’s atoms’ positions may not correspond to the positions of the atoms the coordinate describes. See the class documentation for Coordinate for details.
The InternalRepresentation instance which the coordinate self is a part of.
The InternalRepresentation instance which the coordinate self is a part of.
The units in which the coordinate’s value is expressed.
Get the value of the coordinate for the XYZ matrix mat, which is a (self.molecule.natoms) by 3 matrix. In other words, the matrix argument uses the parent Molecule‘s indexing scheme, not the Coordinate‘s own indexing scheme.
Note
For angular coordinates, this always returns a value in Radians. value, value_with_units, and value_for_molecule, however, return values in self.units
Abstract base class for things that you are allowed to take derivatives of.
The value of the differentiable property. If this function is not overridden, assume that self can be added and subtracted, as well as multiplied by a float.
Encapsulates a displacement from a base molecule.
Attributes : |
---|
The displaced molecule object resulting from applying self to Molecule
The displaced molecule object resulting from applying self to Molecule
A function (in the finite_difference.FiniteDifferenceFunction sense) that can get values for displacements of some base molecule.
General superclass for all distance units
alias of Angstrom
alias of Angstrom
The displacement amounts for each of the variables.
Get a value for the displacement corresponding to the (variable, number of deltas) pairs given in the argument pairs
The list of FiniteDifferenceVariable instances on which the function depends.
Exception for attempted incompatible unit conversions
Abstract base class for all properties
Attributes : |
---|
molecule : Molecule units : CompositeUnit or class with Unit metaclass
Retrieve the value of the property from a tuple of groups matched in a RegexSequence. See RegexSequence.groups()
Retrieve the value of the property from a RegexSequence object that has already been used on a file. By default, this just calls self.from_groups() with seq.groups(flatten) where flatten comes from self.from_groups.flatten.
The new paradigm for obtaining values. Call the callable instance attribute getter with the arguments and keyword arguments passed in.
The value of the molecular property.
Encapsulates all of the functionality and attributes of a Molecule itself.
Signatures : |
|
---|---|
Parameters : |
Other Parameters: | |
---|---|
Attributes : |
---|
atoms : list of Atom internal_representations : list of InternalRepresentation normal_representation : NormalRepresentation cartesian_representation : CartesianRepresentation description : str
Examples : |
---|
Constructor
>>> Molecule("""
... 5
...
... C 0.000000 0.000000 0.000000
... H 0.000000 0.000000 1.089000
... H 1.026719 0.000000 -0.363000
... H -0.513360 -0.889165 -0.363000
... H -0.513360 0.889165 -0.363000
... """)
Molecule([
Atom('C', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('H', [ 0.00000000, 0.00000000, 1.08900000 ] ),
Atom('H', [ 1.02671900, 0.00000000, -0.36300000 ] ),
Atom('H', [ -0.51336000, -0.88916500, -0.36300000 ] ),
Atom('H', [ -0.51336000, 0.88916500, -0.36300000 ] )
])
>>> Molecule([
... Atom('H', [0,0,0]),
... Atom('H', [0,0,0.75])
... ])
Molecule([
Atom('H', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('H', [ 0.00000000, 0.00000000, 0.75000000 ] )
])
>>> Molecule(['H','C'], Matrix([[0,0,0],[1,0.5,0]]))
Molecule([
Atom('H', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('C', [ 1.00000000, 0.50000000, 0.00000000 ] )
])
>>> mol = Molecule("""
... 5
...
... C 0.000000 0.000000 0.000000
... H 0.000000 0.000000 1.089000
... H 1.026719 0.000000 -0.363000
... H -0.513360 -0.889165 -0.363000
... H -0.513360 0.889165 -0.363000
... """)
>>> mol
Molecule([
Atom('C', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('H', [ 0.00000000, 0.00000000, 1.08900000 ] ),
Atom('H', [ 1.02671900, 0.00000000, -0.36300000 ] ),
Atom('H', [ -0.51336000, -0.88916500, -0.36300000 ] ),
Atom('H', [ -0.51336000, 0.88916500, -0.36300000 ] )
])
Iteration
>>> from __future__ import print_function
>>> for atom in mol:
... print(repr(atom))
...
Atom('C', [ 0.00000000, 0.00000000, 0.00000000 ] )
Atom('H', [ 0.00000000, 0.00000000, 1.08900000 ] )
Atom('H', [ 1.02671900, 0.00000000, -0.36300000 ] )
Atom('H', [ -0.51336000, -0.88916500, -0.36300000 ] )
Atom('H', [ -0.51336000, 0.88916500, -0.36300000 ] )
The first principal axis of rotation, a. The positive phase is always chosen.
Note
This property depends directly on Molecule.principal_axes(), which is cached. See discussion of caching in A_e
The second principal axis of rotation, b. The positive phase is always chosen.
Note
This property depends directly on Molecule.principal_axes(), which is cached. See discussion of caching in A_e
The third principal axis of rotation, c. The positive phase is always chosen.
Note
This property depends directly on Molecule.principal_axes(), which is cached. See discussion of caching in A_e
The current default cartesian representation associated with the molecule. If the molecule has multiple cartesian representations, the first in the list self.cartesian_representations is returned. The setter for this property pushes the cartesian representation onto the front of the list.
Note
The setter does not check for uniqueness (unless it’s exactly the same object as another CartesianRepresentation). Thus, you should check to make sure the CartesianRepresentation you are assigning to the molecule is not already part of the molecule’s list of representations (to the degree of accuracy required for your particular application) before assigning. Repeatedly failing to do this check could cause runaway memory usage.
Returns a Vector giving the center of mass of the molecule in the current Cartesian representation. The units of the returned value are self.cartesian_units.
Note
This result of this method is cached, and the cached value gets flushed in update_cartesian_representation(). If you change an atom’s position (or mass) and forget to call update_cartesian_representation(), you may get some funny results for this method or any methods that depend on it, including recenter(), reorient(), and principal_moments_of_inertia(). You can detect whether caching is causing problems by setting the environment variable GRENDEL_NO_CACHE to 1 and rerunning your tests. If tests that were failing subsequently succeed, you probably forgot to call update_cartesian_representation() somewhere, or you were assuming that it was automatically called somewhere when in fact it was not getting called.
Create a Molecule object using only the name, SMILES, InChIKey, etc.
The easiest way to call Molecule.from_identifier() is to give it a single argument that is one of the following properties: * smiles * stdinchikey * stdinchi * ncicadd_identifier # (for FICTS, FICuS, uuuuu) * hashisy * cas_number * chemspider_id # input must be chemspider_id=1234567 * opsin_name * cir_name (These are resolved in roughly this order.) Visit the NIH CIR documentation for (some) explaination of what these identifiers are: http://cactus.nci.nih.gov/chemical/structure/documentation
Molecule.from_identifier() can be called with any (single) keyword argument in the grendel.util.web_getter.input_identifiers list. In this form, there must be only
This can also be called using an argument that is the value of a property and a second argument that is a list of fields to search for that property in.
Note: Molecule.get() is a very useful alias for this.
Examples : |
---|
TODO
TODO Document this more
Examples : |
---|
>>> Molecule.from_z_matrix("""
... O
... H1 O 1.0
... H2 O 1.0 H1 90.0
... """)
Molecule([
Atom('O', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('H', [ 0.00000000, 0.00000000, 1.00000000 ] ),
Atom('H', [ 0.00000000, -1.00000000, -0.00000000 ] )
])
>>> Molecule.from_z_matrix(
... [
... ['H'],
... ['O', 1, 0.9],
... ['O', 2, 1.4, 1, 105.0],
... ['H', 3, 0.9, 2, 105.0, 1, 120.0]
... ]
... )
Molecule([
Atom('H', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('O', [ 0.00000000, 0.00000000, 0.90000000 ] ),
Atom('O', [ 0.00000000, 1.35229616, 1.26234666 ] ),
Atom('H', [ -0.75286467, 1.46479616, 1.74249095 ] )
])
>>> Molecule.from_z_matrix(
... ['H'],
... ['O', 1, 0.9]
... )
Molecule([
Atom('H', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('O', [ 0.00000000, 0.00000000, 0.90000000 ] )
])
@param string: String containing a z-matrix with labels defined at the end using e.g. a234=8.5 @param args: Passed on to Molecule.from_z_matrix @param kwargs: Passed on to Molecule.from_z_matrix @return: Molecule object corresponding to the z-matrix passed in
Return a list of geometrically separated moieties of the molecule. Note: sub-molecules returned will have charge 0 and multiplicity 1 for now
@param n_vdw_radii: How many Van der Waals radii two atoms may be separated by and still be considered bonded @param default_vdw_radius: Van der Waals radius to use for elements that grendel doesn’t know the VDW radius of. @return: list of moieties as Molecule objects.
Create a Molecule object using only the name, SMILES, InChIKey, etc.
The easiest way to call Molecule.from_identifier() is to give it a single argument that is one of the following properties: * smiles * stdinchikey * stdinchi * ncicadd_identifier # (for FICTS, FICuS, uuuuu) * hashisy * cas_number * chemspider_id # input must be chemspider_id=1234567 * opsin_name * cir_name (These are resolved in roughly this order.) Visit the NIH CIR documentation for (some) explaination of what these identifiers are: http://cactus.nci.nih.gov/chemical/structure/documentation
Molecule.from_identifier() can be called with any (single) keyword argument in the grendel.util.web_getter.input_identifiers list. In this form, there must be only
This can also be called using an argument that is the value of a property and a second argument that is a list of fields to search for that property in.
Note: Molecule.get() is a very useful alias for this.
Examples : |
---|
TODO
Returns True if the elements of self correspond directly to the elements of other (i.e. self.atoms[0].element == other.atoms[0].element and self.atoms[1].element == other.atoms[1].element and ...)
Returns True if all of the elements are the same (including isotope and nuclear spin) and the reoriented() versions of self and other have no atoms whose pairwise position difference has a magnitude greater than tol (which defaults to 1e-8 Angstroms)
Examples : |
---|
>>> mol = Molecule('''
... O 1.5 0.0 0.0
... H 0.2 0.0 0.0
... ''')
>>> m1 = Molecule('''
... O 0.0 1.5 0.0
... H 0.0 0.2 0.0
... ''')
>>> m2 = Molecule('''
... O 0.00000 0.00000 0.200000
... H 0.00000 0.00000 1.500001
... ''')
>>> m3 = Molecule('''
... H 0.0 0.0 0.0
... H 0.0 -1.3 0.0
... ''')
>>> mol.has_same_geometry(m1)
True
>>> m1.has_same_geometry(m2)
False
>>> m1.has_same_geometry(m2, 1e-5)
True
>>> m2.has_same_geometry(mol, 1e-5)
True
>>> m1.has_same_geometry(m3)
False
True if op is a valid symmetry operation on self Each coordinate of the transformed atoms must differ from the original by less than
Returns the index of atom in the atoms array of the molecule
Note
This method returns a cached property Atom.index. If you reorder the atoms in a molecule, be sure and flush this cache by setting atom._index to None for all of the atoms in the reordered molecule.
Raises : |
---|
IndexError : if atom is not found in self
Examples : |
---|
>>> from grendel.chemistry import SampleMolecules, init_sample_molecules
>>> init_sample_molecules()
>>> h2o = SampleMolecules['water']
>>> atom1 = h2o[0]
>>> atom2 = h2o[1]
>>> atom3 = h2o[2]
>>> h2o
Molecule([
Atom('O', [ 0.00000000, 0.00000000, 0.11815400 ] ),
Atom('H', [ 0.00000000, 0.75873400, -0.47261400 ] ),
Atom('H', [ 0.00000000, -0.75873400, -0.47261400 ] )
])
>>> h2o.index(atom2)
1
>>> h2o.index(atom1)
0
>>> # It must be exactly the same instance to avoid raising an index error
>>> h2o.index(Atom('O', [ 0.00000000, 0.00000000, 0.11815400 ] ))
Traceback (most recent call last):
...
IndexError: ...
Returns a tuple of the principal moments of inertia vector and the principal axes matrix.
mol.inertial_system()
Computes the principal moments of inertia and the principal axes.
Note
This funtion mol.recenter() if the molecule is not centered, so any CartesianRepresentations that are not both frozen and referenced elsewhere (e.g. in a RepresentationDependentProperty) will be lost forever.
Note
This method is cached. See discussion of the consequences of caching in Molecule.center_of_mass()
Returns : |
---|
A tuple with types (Vector, Matrix) containing the principal moments of inertia and the principal axes, respectively. These should be aligned (i.e. ret_val[0][1] corresponds to the vector ret_val[1][1])
Examples : |
---|
>>> hnco = Molecule.from_z_matrix("""
... N
... C N 1.2145
... O C 1.1634 N 172.22
... H N 1.0030 C 123.34 O 180.0
... """
... )
>>> i = hnco.inertial_system()
>>> i[0]
Vector([ 0.60187342, 45.48378728, 46.0856607 ])
>>> i[1]
Matrix([[ 0. , 0. , 1. ],
[ 0.09870438, -0.9951168 , 0. ],
[ 0.9951168 , 0.09870438, 0. ]])
>>> j = hnco.inertial_system()
>>> i == j
True
>>> hnco.A_e
28.0085955528 Wavenumber
>>> hnco.B_e
0.370629408869 Wavenumber
>>> hnco.C_e
0.365789031483 Wavenumber
>>> hnco.a
Vector([ 0. , 0.09870438, 0.9951168 ])
>>> hnco.b
Vector([ 0. , -0.9951168 , 0.09870438])
>>> hnco.c
Vector([ 1., 0., 0.])
The first internal representations (of type InternalRepresentation), or None if it does not exist yet.
True if the center of mass is at the origin. This actually computes the vector from the origin to the center of mass and then determines if the magnitude of that vector is less than tol.
Parameters : |
---|
True if the molecule is linear to within tol. All diatomics should return True.
If tol is a ValueWithUnits and tol.units is an AngularUnit, then this method returns True only if all angles in the molecule are within tol of 180 Degrees. If tol.units is a unit-compatible with a moment of inertia (i.e. MassUnit * DistanceUnit**2 ), then this method returns True if the smallest principal moment of inertia is less than tol and the difference between the two largest principal moments of inertia is less than tol. If no units are given (i.e. tol is a float or other float-compatible unit), tol is assumed to have units of AngularUnit.default and the method proceeds as if tol.units was an AngularUnit subclass.
Parameters : |
---|
Examples : |
---|
>>> from grendel.chemistry import SampleMolecules, init_sample_molecules
>>> init_sample_molecules()
>>> SampleMolecules['water'].is_linear()
False
>>> SampleMolecules['CO2'].is_linear()
True
>>> SampleMolecules['Benzene'].is_linear()
False
The principal moments of inertia, as a Vector
Note
This funtion mol.recenter() if the molecule is not centered, so any CartesianRepresentations that are not both frozen and referenced elsewhere (e.g. in a RepresentationDependentProperty) will be lost forever.
Note
This method is cached. See discussion of the consequences of caching in Molecule.center_of_mass()
Examples: >>> hnco = Molecule.from_z_matrix(""" ... N ... C N 1.2145 ... O C 1.1634 N 172.22 ... H N 1.0030 C 123.34 O 180.0 ... """ ... ) >>> hnco.principal_moments_of_inertia() Vector([ 0.60187342, 45.48378728, 46.0856607 ]) >>> hnco.pmi() Vector([ 0.60187342, 45.48378728, 46.0856607 ])
See Also: principal_axes, inertial_system, A_e, B_e, C_e
Aliased as principal_moments_of_inertia()
The molecule’s position as a natoms x 3 Matrix. The ordering of rows is (as expected) the same as the ordering of the Molecule.atoms list attribute. Aliased to xyz_mat and position (the latter to be “consistant-ish” with the naming in Atom.
The principal axes as column vectors in a Matrix. The Vector object mol.principal_axes()[:,i] corresponds to the i`th moment of inertia, `mol.principal_moments_of_inertia()[i].
mol.principal_axes()
Note
This funtion mol.recenter() if the molecule is not centered, so any CartesianRepresentations that are not both frozen and referenced elsewhere (e.g. in a RepresentationDependentProperty) will be lost forever.
Note
This method is cached. See discussion of the consequences of caching in Molecule.center_of_mass()
Examples : |
---|
>>> hnco = Molecule.from_z_matrix("""
... N
... C N 1.2145
... O C 1.1634 N 172.22
... H N 1.0030 C 123.34 O 180.0
... """
... )
>>> hnco.principal_axes()
Matrix([[ 0. , 0. , 1. ],
[ 0.09870438, -0.9951168 , 0. ],
[ 0.9951168 , 0.09870438, 0. ]])
See Also: |
---|
principal_moments_of_inertia, inertial_system, A_e, B_e, C_e
Alias for pmi()
Recenters the molecule about the center of mass This modifies the molecule in place.
Examples : |
---|
>>> m = Molecule([Atom("O", [1.1, 1.3, 1.7])])
>>> m
Molecule([
Atom('O', [ 1.10000000, 1.30000000, 1.70000000 ] )
])
>>> m.recenter()
>>> m
Molecule([
Atom('O', [ 0.00000000, 0.00000000, 0.00000000 ] )
])
>>> m = Molecule(['H','H'], Matrix([[0,0,0],[1,0.0,0]]))
>>> m
Molecule([
Atom('H', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('H', [ 1.00000000, 0.00000000, 0.00000000 ] )
])
>>> m.recenter()
>>> m
Molecule([
Atom('H', [ -0.50000000, 0.00000000, 0.00000000 ] ),
Atom('H', [ 0.50000000, 0.00000000, 0.00000000 ] )
])
Same as recenter, but makes returns a copy. self is not modified.
Examples : |
---|
>>> foo = Molecule([Atom("O", [1.3, 1.7, 2.0])])
>>> bar = foo.recentered()
>>> foo.recenter()
>>> foo
Molecule([
Atom('O', [ 0.00000000, 0.00000000, 0.00000000 ] )
])
>>> foo == bar
True
>>> foo is bar
False
Reorient the molecule to align the x, y, and z axes with the principal axes of rotation.
Parameters : |
---|
Examples : |
---|
>>> from grendel.chemistry import SampleMolecules, init_sample_molecules
>>> init_sample_molecules()
>>> from grendel.gmath import chopped
>>> h2o = SampleMolecules['quantum water']
>>> h2o.principal_axes()
Matrix([[-0. , 0. , 1. ],
[-0.53654222, -0.84387348, 0. ],
[-0.84387348, 0.53654222, 0. ]])
>>> h2o.reorient()
>>> # Use chopped to get rid of very small numerical artifacts...
>>> # using abs to get rid of phase factor
>>> abs(chopped(h2o.principal_axes()))
Matrix([[ 0., 0., 1.],
[ 1., 0., 0.],
[ 0., 1., 0.]])
>>> h2o.reorient("I")
>>> from grendel.gmath import chopped
>>> abs(chopped(h2o.principal_axes()))
Matrix([[ 0., 1., 0.],
[ 0., 0., 1.],
[ 1., 0., 0.]])
>>> h2o.reorient("III")
>>> abs(chopped(h2o.principal_axes()))
Matrix([[ 1., 0., 0.],
[ 0., 1., 0.],
[ 0., 0., 1.]])
Same as reorient, but makes returns a copy. self is not modified.
Examples : |
---|
>>> from grendel.chemistry import SampleMolecules, init_sample_molecules
>>> init_sample_molecules()
>>> from grendel.gmath import chopped
>>> h2o = Molecule([
... Atom('O', [ 0.00000000, 0.00000000, 0.00000000 ] ),
... Atom('H', [ 0.00000000, 0.00000000, 1.00000000 ] ),
... Atom('H', [ 0.00000000, -1.00000000, -0.00000000 ] )
... ])
>>> new = h2o.reoriented()
>>> # Use chopped to get rid of very small numerical artifacts...
>>> chopped(new.principal_axes())
Matrix([[ 0., 0., 1.],
[-1., 0., 0.],
[ 0., 1., 0.]])
>>> new is h2o
False
>>> # original molecule is unchanged...
>>> h2o
Molecule([
Atom('O', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('H', [ 0.00000000, 0.00000000, 1.00000000 ] ),
Atom('H', [ 0.00000000, -1.00000000, -0.00000000 ] )
])
Rotates the molecule about axis (a Vector) by angle
Writes the Molecule to the standard xyz format.
See Molecule.xyz_string() for more details.
See Also: |
---|
xyz_string
The molecule’s position as a natoms x 3 Matrix. The ordering of rows is (as expected) the same as the ordering of the Molecule.atoms list attribute. Aliased to xyz_mat and position (the latter to be “consistant-ish” with the naming in Atom.
The molecule’s position as a natoms x 3 Matrix. The ordering of rows is (as expected) the same as the ordering of the Molecule.atoms list attribute. Aliased to xyz_mat and position (the latter to be “consistant-ish” with the naming in Atom.
The molecule, represented as a string in standard xyz format.
The first line will always be the number of atoms. The second line (which is a comment in the xyz specification) is filled by the description first line of the description attribute.
Parameters : |
---|
Examples : |
---|
>>> from __future__ import print_function
>>> from grendel.chemistry import SampleMolecules, init_sample_molecules
>>> init_sample_molecules()
>>> print(SampleMolecules['water'].xyz_string())
3
CCSD(T)/aug-cc-pVTZ Water
O 0.00000000 0.00000000 0.11815400
H 0.00000000 0.75873400 -0.47261400
H 0.00000000 -0.75873400 -0.47261400
>>> print(Molecule("O 1.0 0.5 1.5").xyz_string("Atom: %2s, x: %3.1f, y: %4.2f, z: %5.3f"))
1
Atom: O, x: 1.0, y: 0.50, z: 1.500
>>> print(Molecule("O 1.0 0.5 1.5").xyz_string("Atom: %2s, x: %3.1f, y: %4.2f, z: %5.3f", False))
Atom: O, x: 1.0, y: 0.50, z: 1.500
A read-only attribute. See SpecialAttribute for initialization variables standard to all SpecialAttribute subclasses.
Attributes : |
---|
Superclass of all the representations types.
Attributes : |
|
---|
Make a copy of self that is the same in every way except for the molecule attribute. New Coordinate objects are created using the Coordinate.copy_for_representation() method for each element of self.coords. This is an abstract method that must be implemented by all Representation subclasses.
Apply the Displacement instance disp to the molecule and current representation, generating a new molecule and a new representation (which start as a deepcopy and the return value of Representation.copy_with_molecule, respectively) with the displacement applied. This is an abstract method that must be implemented by all Representation subclasses.
Alias for values_for_matrix()
Alias for values_for_molecule()
Aliased as value_for_matrix()
Aliased as value_for_molecule()
A property whose value is dependent on a given representation of the molecule.
Aliased as iscompatible()
Shallow copy operation on arbitrary Python objects.
See the module’s __doc__ string for more info.
Alias for has_units()
Aliased as indent()
Type checking for functions and methods.
A representations of a molecule in Cartesian coordinates. Since Atom objects already have Cartesian vectors associated with them, this class mostly consists of helper functions and convenience (accessor) functions that make CartesianRepresentation compatible with the parent Representation class.
Add an atom to the representation by creating a CartesianCoordinate object cooresponding to the atom.
Add a CartesianCoordinate to the representation.
Convenience method for accessing atoms. Returns self.molecule.atoms[number]
Convenience property for referencing the atoms list in the molecule associated with self.
Returns the index of the parameter atom in the representation self.
Parameters : |
---|
Raises : |
---|
Returns the value of the representation as a light vector
Renew the coordinates for an atom to coincide with the atom’s current position
A collection of derivatives with indices that are coordinates in a given representation.
Return the Tensor object corresponding to the `order`th order derivative.
A function (in the finite_difference.FiniteDifferenceFunction sense) that can get values for displacements of some base molecule.
The energy of a molecule.
alias of Wavenumber
An arbitrary finite difference derivative with respect to k FiniteDifferenceVariable instances (not necessarily distinct) of a FiniteDifferenceFunction of an arbitrary number of FiniteDifferenceVariable instances whose output is a Differentiable instance. Ideally, the derivative can be calculated to an arbitrary order of robustness in the displacement, though in practice not all orders may be implemented yet.
Save a little bit of time by prepopulating the single variable displacement formulas dictionary up to max_derivative and max_order. If forward is True, the forward formulas are precomputed instead of the central ones.
An internal coordinate representations of a molecule. TODO: More thoroughly document what this means.
The El’yashevich–Wilson B matrix pseudoinverse, with the Sayvetz conditions used to generate the inverse mass external conditions.
The El’yashevich–Wilson B matrix for the molecule in the representation.
Alias for MolecularPropertyDerivative()
permutations(iterable[, r]) –> permutations object
Return successive r-length permutations of elements in the iterable.
permutations(range(3), 2) –> (0,1), (0,2), (1,0), (1,2), (2,0), (2,1)
x.next() -> the next value, or raise StopIteration
alias of combinations_with_replacement
Type checking for functions and methods.
General superclass for all angular units
alias of Degree
alias of Degree
Decorator for properties with cached return values. The decorator creates a property that stores the return value of the method call in a variable named _[func_name] (where [func_name] is the name of the function).
Examples : |
---|
>>> class Factorializer(object):
...
... n = None
...
... def __init__(self, n):
... self.n = n
...
... @CachedProperty
... def thirty_plus_n_fact(self):
... ret_val = 1
... for i in xrange(2, self.n + 31):
... ret_val *= i
... return ret_val
...
>>> f = Factorializer(3000)
>>> # Takes some time...
>>> var = f.thirty_plus_n_fact
>>> # Should take no time...
>>> for i in xrange(100):
... var = f.thirty_plus_n_fact
...
>>> # Be careful... Remember to invalidate the cache when the appropriate variables are updated...
>>> f.n = 2500
>>> # Takes no time but gives the wrong answer:
>>> var = f.thirty_plus_n_fact
>>> # Invalidate the cache:
>>> f._thirty_plus_n_fact = None
>>> # This should take some time again, but now it will get the right answer
>>> var = f.thirty_plus_n_fact
A representations of a molecule in Cartesian coordinates. Since Atom objects already have Cartesian vectors associated with them, this class mostly consists of helper functions and convenience (accessor) functions that make CartesianRepresentation compatible with the parent Representation class.
Add an atom to the representation by creating a CartesianCoordinate object cooresponding to the atom.
Add a CartesianCoordinate to the representation.
Convenience method for accessing atoms. Returns self.molecule.atoms[number]
Convenience property for referencing the atoms list in the molecule associated with self.
Returns the index of the parameter atom in the representation self.
Parameters : |
---|
Raises : |
---|
Returns the value of the representation as a light vector
Renew the coordinates for an atom to coincide with the atom’s current position
Abstract base class for a general coordinate of a Molecule.
Coordinate`s are the components in which `Molecule`s are represented. The most important thing about `Coordinate`s is that they are immutible, like Python’s `str and tuple classes. [#f1]_ Let me say that again a bit louder:
Note
All coordinates are immutable!
Parentage and the molecule attribute: Coordinate instances are typically (though not always) associated with a Representation, accessible through the parent read-only attribute. Coordinate instances that do not have a parent associated with them are called “orphaned” coordinates, and can be identified using the is_orphaned() instance method. Even orphaned coordinates must have a Molecule associated with them in one way or another. This happens in one of three ways:
- If the Coordinate is not orphaned, then parent‘s molecule attribute is used. Note that in this case, the Coordinate protocol requires the Coordinate‘s constituant atoms to have a parent molecule that is exactly the same instance as parent‘s molecule attribute. (If you aren’t doing something weird, this shouldn’t be an issue).
- If the Coordinate is orphaned, it still must be composed of one or more Atom instances, accessible through the atoms attribute. These Atom`s may themselves be orphaned, but if they are not, the first non-orphaned `Atom‘s parent is used. Note that if one Atom is non-orphaned, the Coordinate protocol requires that all of them must not be orphaned (i. e. the Coordinate constructor enforces this when sanity_checking_enabled is True)
- If the Coordinate is orphaned and all of its Atom`s are also orphaned (as is the case, for instance, with `Coordinate instances created for the purpose of finite difference B tensor computation), the Coordinate‘s base_analog attribute may be set to a Coordinate instance whose constituate Atom instances correspond to the derived Coordinate‘s atoms’ base_atom attributes. In this case, the base_analog‘s molecule attribute is used, though it should be utilized for index translation purposes only, since the positions of the atoms in the base molecule will not correspond to the positions of the Coordinate‘s atoms. (The base_analog, in turn, may be an orphaned coordinate of this third type, in which case that coordinate’s base_analog will be used, and so on recursively.)
- If the Coordinate is orphaned and no base_analog is given, then all of the atoms must have a base_atom that either has a parent_molecule or also has a base_atom defined (and so on so that a base_atom eventually has a parent_molecule somewhere up the line). In this case, the Coordinate protocol requires that all the atoms refer to the same Molecule obtained in this manner. Coordinates created in the course of analytic computation of B tensors fall into this catagory.
Indexing schemes: Because all Coordinate`s may be austensibly associated with a `Molecule instance in one way or another, there are two different ways to index various tensor properties of a Coordinate: the Molecule‘s indices (3 * natoms total indices) and the Coordinate‘s indexing scheme (3 * len(coord.atoms) total indices, where coord is a Coordinate instance). The internal indexing scheme makes a lot more sense in many instances, (see the documentation of Coordinate.atoms for a simple example), but for determining properties of the whole molecule, we need to use the Molecule‘s indexing scheme. All of this should be handled seemlessly behind the scenes, but it’s a good distinction to be aware of.
Getting a Coordinate‘s value: Coordinate has a number of methods that can be used to get the value of a Coordinate in a particular scenario. They hierarchically call each other to determine the value of the Coordinate. The basic scheme is as follows:
}
The reason for this relatively complex hierarchy is that there are instances in which I have needed each variety for some reason or another. Nodes with dotted borders must be implemented in the relevant subclasses: SimpleInternalCoordinate subclasses must implement value_for_xyz, InternalCoordinate subclasses must implement value_for_positions, and Coordinate subclasses must implement value_for_molecule_matrix().
Subclassing: |
---|
TODO: write this part
Footnotes
[4] | Since Python doesn’t really have private attributes, you could in theory change some of the attributes of a Coordinate instance after it is created; the designation of “immutible” here merely means that the class is not guarenteed to work if you do. While it’s technically more of a “please don’t” than a “you can’t”, I for one will not be held responsible for your code not working if you do something like that, and the way these private attributes are used and changed is not guarenteed to stay the same between different versions. Bottom line: just don’t do it. If you don’t know what I’m talking about, you’re probably okay. Just don’t access or modify any attributes that start with a single underscore (you should never do this anyway from outside of a class). |
The indices of the atom(s) the Coordinate depends on in the Molecule the Coordinate depends on.
This is guarenteed to work whether or not the Coordinate is orphaned. For each of the various possible Coordinate–Molecule relationships detailed in the Coordinate class documentation, the reason the method works is as follows:
Use this carefully. Don’t ever retrieve an atom’s position by its index in the parent molecule, since that atom may not be the same instance (or even in the same position) as the Coordinate‘s atom.
List of the Atom instances that the Coordinate depends on. In the case of a CartesianCoordinate, for instance, this is trivially one Atom, but in the case of other coordinates it can be much more substantial. In the case of a NormalCoordinate, this is all the atoms in the parent Molecule.
The presence of an atoms list is essential to establish an internal indexing scheme that can be converted to the indexing scheme of the parent molecule. Besides making the B tensor code much more managable, the use of an internal indexing scheme make Coordinate instances much more self-contained, making “orphaned” coordinates much more viable. Consider the following example:
>>> from grendel.util.units import Degrees
>>> from grendel.coordinates.bond_angle import BondAngle
>>> ba = BondAngle(
... Atom('O', [0.0, 0.0, 0.0]),
... Atom('H', [0.0, 1.0, 0.0]),
... Atom('H', [0.0, 0.0, 1.0]),
... units=Degrees
... )
>>> round(ba.value)
90.
If orphaned coordinates where not allowed to exist, we would have to create a Molecule instance containing those three atoms, construct an InternalRepresentation containing the BondAngle instance (which would need to be a valid, complete representation, a non-trivial task in the general case), pair that InternalRepresentation instance with the Molecule instance, get the right Coordinate instance from the InternalRepresentation corresponding to the BondAngle we want, and then get that coordinate’s value. If all of the coordinate’s complicated methods were not implemented in terms of the Coordinate’s own indexing scheme, it would have to have all of this structure in place just to get a value.
Note
Since all Coordinate`s depend on `Atom`s and `Atom`s are not immutible, a `Coordinate`s `value and other properties such as its b_vector can change even if the Coordinate itself cannot. The one way around this is to specify freeze_value as True in the Coordinate‘s constructor. If that is done, the value of the Coordinate will not change over the life of the instance, even if the positions of the constituant atoms does change (so if you use this, make sure you know what you are doing). This behavior is useful, for instance, in the use of CartesianRepresentation`s as “snapshots” of a `Molecule instance to be used for the parsing of a particular RepresentationDependentProperty.
Analogous Coordinate object on the base molecule, if self is a Coordinate on a displaced Molecule, or the Coordinate from which an orphaned displaced Coordinate was created, if the coordinate was created this way.
Every coordinate must define a reasonable default amount for a finite displacement of that kind of coordinate. This should be a class attribute.
Whether or not the Coordinate instance has a parent Representation
Default implementation for coordinates dependent on atoms directly (basically anything but a CartesianCoordinate or some sort of symmetrized cartesian coordinate).
The molecule associated with the Coordinate.
Note
The molecule’s atoms’ positions may not correspond to the positions of the atoms the coordinate describes. See the class documentation for Coordinate for details.
The InternalRepresentation instance which the coordinate self is a part of.
The InternalRepresentation instance which the coordinate self is a part of.
The units in which the coordinate’s value is expressed.
Get the value of the coordinate for the XYZ matrix mat, which is a (self.molecule.natoms) by 3 matrix. In other words, the matrix argument uses the parent Molecule‘s indexing scheme, not the Coordinate‘s own indexing scheme.
Note
For angular coordinates, this always returns a value in Radians. value, value_with_units, and value_for_molecule, however, return values in self.units
Encapsulates a displacement from a base molecule.
Attributes : |
---|
The displaced molecule object resulting from applying self to Molecule
The displaced molecule object resulting from applying self to Molecule
Exception for attempted incompatible unit conversions
An internal coordinate representations of a molecule. TODO: More thoroughly document what this means.
The El’yashevich–Wilson B matrix pseudoinverse, with the Sayvetz conditions used to generate the inverse mass external conditions.
The El’yashevich–Wilson B matrix for the molecule in the representation.
alias of Iterable
Encapsulates all of the functionality and attributes of a Molecule itself.
Signatures : |
|
---|---|
Parameters : |
Other Parameters: | |
---|---|
Attributes : |
---|
atoms : list of Atom internal_representations : list of InternalRepresentation normal_representation : NormalRepresentation cartesian_representation : CartesianRepresentation description : str
Examples : |
---|
Constructor
>>> Molecule("""
... 5
...
... C 0.000000 0.000000 0.000000
... H 0.000000 0.000000 1.089000
... H 1.026719 0.000000 -0.363000
... H -0.513360 -0.889165 -0.363000
... H -0.513360 0.889165 -0.363000
... """)
Molecule([
Atom('C', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('H', [ 0.00000000, 0.00000000, 1.08900000 ] ),
Atom('H', [ 1.02671900, 0.00000000, -0.36300000 ] ),
Atom('H', [ -0.51336000, -0.88916500, -0.36300000 ] ),
Atom('H', [ -0.51336000, 0.88916500, -0.36300000 ] )
])
>>> Molecule([
... Atom('H', [0,0,0]),
... Atom('H', [0,0,0.75])
... ])
Molecule([
Atom('H', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('H', [ 0.00000000, 0.00000000, 0.75000000 ] )
])
>>> Molecule(['H','C'], Matrix([[0,0,0],[1,0.5,0]]))
Molecule([
Atom('H', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('C', [ 1.00000000, 0.50000000, 0.00000000 ] )
])
>>> mol = Molecule("""
... 5
...
... C 0.000000 0.000000 0.000000
... H 0.000000 0.000000 1.089000
... H 1.026719 0.000000 -0.363000
... H -0.513360 -0.889165 -0.363000
... H -0.513360 0.889165 -0.363000
... """)
>>> mol
Molecule([
Atom('C', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('H', [ 0.00000000, 0.00000000, 1.08900000 ] ),
Atom('H', [ 1.02671900, 0.00000000, -0.36300000 ] ),
Atom('H', [ -0.51336000, -0.88916500, -0.36300000 ] ),
Atom('H', [ -0.51336000, 0.88916500, -0.36300000 ] )
])
Iteration
>>> from __future__ import print_function
>>> for atom in mol:
... print(repr(atom))
...
Atom('C', [ 0.00000000, 0.00000000, 0.00000000 ] )
Atom('H', [ 0.00000000, 0.00000000, 1.08900000 ] )
Atom('H', [ 1.02671900, 0.00000000, -0.36300000 ] )
Atom('H', [ -0.51336000, -0.88916500, -0.36300000 ] )
Atom('H', [ -0.51336000, 0.88916500, -0.36300000 ] )
The first principal axis of rotation, a. The positive phase is always chosen.
Note
This property depends directly on Molecule.principal_axes(), which is cached. See discussion of caching in A_e
The second principal axis of rotation, b. The positive phase is always chosen.
Note
This property depends directly on Molecule.principal_axes(), which is cached. See discussion of caching in A_e
The third principal axis of rotation, c. The positive phase is always chosen.
Note
This property depends directly on Molecule.principal_axes(), which is cached. See discussion of caching in A_e
The current default cartesian representation associated with the molecule. If the molecule has multiple cartesian representations, the first in the list self.cartesian_representations is returned. The setter for this property pushes the cartesian representation onto the front of the list.
Note
The setter does not check for uniqueness (unless it’s exactly the same object as another CartesianRepresentation). Thus, you should check to make sure the CartesianRepresentation you are assigning to the molecule is not already part of the molecule’s list of representations (to the degree of accuracy required for your particular application) before assigning. Repeatedly failing to do this check could cause runaway memory usage.
Returns a Vector giving the center of mass of the molecule in the current Cartesian representation. The units of the returned value are self.cartesian_units.
Note
This result of this method is cached, and the cached value gets flushed in update_cartesian_representation(). If you change an atom’s position (or mass) and forget to call update_cartesian_representation(), you may get some funny results for this method or any methods that depend on it, including recenter(), reorient(), and principal_moments_of_inertia(). You can detect whether caching is causing problems by setting the environment variable GRENDEL_NO_CACHE to 1 and rerunning your tests. If tests that were failing subsequently succeed, you probably forgot to call update_cartesian_representation() somewhere, or you were assuming that it was automatically called somewhere when in fact it was not getting called.
Create a Molecule object using only the name, SMILES, InChIKey, etc.
The easiest way to call Molecule.from_identifier() is to give it a single argument that is one of the following properties: * smiles * stdinchikey * stdinchi * ncicadd_identifier # (for FICTS, FICuS, uuuuu) * hashisy * cas_number * chemspider_id # input must be chemspider_id=1234567 * opsin_name * cir_name (These are resolved in roughly this order.) Visit the NIH CIR documentation for (some) explaination of what these identifiers are: http://cactus.nci.nih.gov/chemical/structure/documentation
Molecule.from_identifier() can be called with any (single) keyword argument in the grendel.util.web_getter.input_identifiers list. In this form, there must be only
This can also be called using an argument that is the value of a property and a second argument that is a list of fields to search for that property in.
Note: Molecule.get() is a very useful alias for this.
Examples : |
---|
TODO
TODO Document this more
Examples : |
---|
>>> Molecule.from_z_matrix("""
... O
... H1 O 1.0
... H2 O 1.0 H1 90.0
... """)
Molecule([
Atom('O', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('H', [ 0.00000000, 0.00000000, 1.00000000 ] ),
Atom('H', [ 0.00000000, -1.00000000, -0.00000000 ] )
])
>>> Molecule.from_z_matrix(
... [
... ['H'],
... ['O', 1, 0.9],
... ['O', 2, 1.4, 1, 105.0],
... ['H', 3, 0.9, 2, 105.0, 1, 120.0]
... ]
... )
Molecule([
Atom('H', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('O', [ 0.00000000, 0.00000000, 0.90000000 ] ),
Atom('O', [ 0.00000000, 1.35229616, 1.26234666 ] ),
Atom('H', [ -0.75286467, 1.46479616, 1.74249095 ] )
])
>>> Molecule.from_z_matrix(
... ['H'],
... ['O', 1, 0.9]
... )
Molecule([
Atom('H', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('O', [ 0.00000000, 0.00000000, 0.90000000 ] )
])
@param string: String containing a z-matrix with labels defined at the end using e.g. a234=8.5 @param args: Passed on to Molecule.from_z_matrix @param kwargs: Passed on to Molecule.from_z_matrix @return: Molecule object corresponding to the z-matrix passed in
Return a list of geometrically separated moieties of the molecule. Note: sub-molecules returned will have charge 0 and multiplicity 1 for now
@param n_vdw_radii: How many Van der Waals radii two atoms may be separated by and still be considered bonded @param default_vdw_radius: Van der Waals radius to use for elements that grendel doesn’t know the VDW radius of. @return: list of moieties as Molecule objects.
Create a Molecule object using only the name, SMILES, InChIKey, etc.
The easiest way to call Molecule.from_identifier() is to give it a single argument that is one of the following properties: * smiles * stdinchikey * stdinchi * ncicadd_identifier # (for FICTS, FICuS, uuuuu) * hashisy * cas_number * chemspider_id # input must be chemspider_id=1234567 * opsin_name * cir_name (These are resolved in roughly this order.) Visit the NIH CIR documentation for (some) explaination of what these identifiers are: http://cactus.nci.nih.gov/chemical/structure/documentation
Molecule.from_identifier() can be called with any (single) keyword argument in the grendel.util.web_getter.input_identifiers list. In this form, there must be only
This can also be called using an argument that is the value of a property and a second argument that is a list of fields to search for that property in.
Note: Molecule.get() is a very useful alias for this.
Examples : |
---|
TODO
Returns True if the elements of self correspond directly to the elements of other (i.e. self.atoms[0].element == other.atoms[0].element and self.atoms[1].element == other.atoms[1].element and ...)
Returns True if all of the elements are the same (including isotope and nuclear spin) and the reoriented() versions of self and other have no atoms whose pairwise position difference has a magnitude greater than tol (which defaults to 1e-8 Angstroms)
Examples : |
---|
>>> mol = Molecule('''
... O 1.5 0.0 0.0
... H 0.2 0.0 0.0
... ''')
>>> m1 = Molecule('''
... O 0.0 1.5 0.0
... H 0.0 0.2 0.0
... ''')
>>> m2 = Molecule('''
... O 0.00000 0.00000 0.200000
... H 0.00000 0.00000 1.500001
... ''')
>>> m3 = Molecule('''
... H 0.0 0.0 0.0
... H 0.0 -1.3 0.0
... ''')
>>> mol.has_same_geometry(m1)
True
>>> m1.has_same_geometry(m2)
False
>>> m1.has_same_geometry(m2, 1e-5)
True
>>> m2.has_same_geometry(mol, 1e-5)
True
>>> m1.has_same_geometry(m3)
False
True if op is a valid symmetry operation on self Each coordinate of the transformed atoms must differ from the original by less than
Returns the index of atom in the atoms array of the molecule
Note
This method returns a cached property Atom.index. If you reorder the atoms in a molecule, be sure and flush this cache by setting atom._index to None for all of the atoms in the reordered molecule.
Raises : |
---|
IndexError : if atom is not found in self
Examples : |
---|
>>> from grendel.chemistry import SampleMolecules, init_sample_molecules
>>> init_sample_molecules()
>>> h2o = SampleMolecules['water']
>>> atom1 = h2o[0]
>>> atom2 = h2o[1]
>>> atom3 = h2o[2]
>>> h2o
Molecule([
Atom('O', [ 0.00000000, 0.00000000, 0.11815400 ] ),
Atom('H', [ 0.00000000, 0.75873400, -0.47261400 ] ),
Atom('H', [ 0.00000000, -0.75873400, -0.47261400 ] )
])
>>> h2o.index(atom2)
1
>>> h2o.index(atom1)
0
>>> # It must be exactly the same instance to avoid raising an index error
>>> h2o.index(Atom('O', [ 0.00000000, 0.00000000, 0.11815400 ] ))
Traceback (most recent call last):
...
IndexError: ...
Returns a tuple of the principal moments of inertia vector and the principal axes matrix.
mol.inertial_system()
Computes the principal moments of inertia and the principal axes.
Note
This funtion mol.recenter() if the molecule is not centered, so any CartesianRepresentations that are not both frozen and referenced elsewhere (e.g. in a RepresentationDependentProperty) will be lost forever.
Note
This method is cached. See discussion of the consequences of caching in Molecule.center_of_mass()
Returns : |
---|
A tuple with types (Vector, Matrix) containing the principal moments of inertia and the principal axes, respectively. These should be aligned (i.e. ret_val[0][1] corresponds to the vector ret_val[1][1])
Examples : |
---|
>>> hnco = Molecule.from_z_matrix("""
... N
... C N 1.2145
... O C 1.1634 N 172.22
... H N 1.0030 C 123.34 O 180.0
... """
... )
>>> i = hnco.inertial_system()
>>> i[0]
Vector([ 0.60187342, 45.48378728, 46.0856607 ])
>>> i[1]
Matrix([[ 0. , 0. , 1. ],
[ 0.09870438, -0.9951168 , 0. ],
[ 0.9951168 , 0.09870438, 0. ]])
>>> j = hnco.inertial_system()
>>> i == j
True
>>> hnco.A_e
28.0085955528 Wavenumber
>>> hnco.B_e
0.370629408869 Wavenumber
>>> hnco.C_e
0.365789031483 Wavenumber
>>> hnco.a
Vector([ 0. , 0.09870438, 0.9951168 ])
>>> hnco.b
Vector([ 0. , -0.9951168 , 0.09870438])
>>> hnco.c
Vector([ 1., 0., 0.])
The first internal representations (of type InternalRepresentation), or None if it does not exist yet.
True if the center of mass is at the origin. This actually computes the vector from the origin to the center of mass and then determines if the magnitude of that vector is less than tol.
Parameters : |
---|
True if the molecule is linear to within tol. All diatomics should return True.
If tol is a ValueWithUnits and tol.units is an AngularUnit, then this method returns True only if all angles in the molecule are within tol of 180 Degrees. If tol.units is a unit-compatible with a moment of inertia (i.e. MassUnit * DistanceUnit**2 ), then this method returns True if the smallest principal moment of inertia is less than tol and the difference between the two largest principal moments of inertia is less than tol. If no units are given (i.e. tol is a float or other float-compatible unit), tol is assumed to have units of AngularUnit.default and the method proceeds as if tol.units was an AngularUnit subclass.
Parameters : |
---|
Examples : |
---|
>>> from grendel.chemistry import SampleMolecules, init_sample_molecules
>>> init_sample_molecules()
>>> SampleMolecules['water'].is_linear()
False
>>> SampleMolecules['CO2'].is_linear()
True
>>> SampleMolecules['Benzene'].is_linear()
False
The principal moments of inertia, as a Vector
Note
This funtion mol.recenter() if the molecule is not centered, so any CartesianRepresentations that are not both frozen and referenced elsewhere (e.g. in a RepresentationDependentProperty) will be lost forever.
Note
This method is cached. See discussion of the consequences of caching in Molecule.center_of_mass()
Examples: >>> hnco = Molecule.from_z_matrix(""" ... N ... C N 1.2145 ... O C 1.1634 N 172.22 ... H N 1.0030 C 123.34 O 180.0 ... """ ... ) >>> hnco.principal_moments_of_inertia() Vector([ 0.60187342, 45.48378728, 46.0856607 ]) >>> hnco.pmi() Vector([ 0.60187342, 45.48378728, 46.0856607 ])
See Also: principal_axes, inertial_system, A_e, B_e, C_e
Aliased as principal_moments_of_inertia()
The molecule’s position as a natoms x 3 Matrix. The ordering of rows is (as expected) the same as the ordering of the Molecule.atoms list attribute. Aliased to xyz_mat and position (the latter to be “consistant-ish” with the naming in Atom.
The principal axes as column vectors in a Matrix. The Vector object mol.principal_axes()[:,i] corresponds to the i`th moment of inertia, `mol.principal_moments_of_inertia()[i].
mol.principal_axes()
Note
This funtion mol.recenter() if the molecule is not centered, so any CartesianRepresentations that are not both frozen and referenced elsewhere (e.g. in a RepresentationDependentProperty) will be lost forever.
Note
This method is cached. See discussion of the consequences of caching in Molecule.center_of_mass()
Examples : |
---|
>>> hnco = Molecule.from_z_matrix("""
... N
... C N 1.2145
... O C 1.1634 N 172.22
... H N 1.0030 C 123.34 O 180.0
... """
... )
>>> hnco.principal_axes()
Matrix([[ 0. , 0. , 1. ],
[ 0.09870438, -0.9951168 , 0. ],
[ 0.9951168 , 0.09870438, 0. ]])
See Also: |
---|
principal_moments_of_inertia, inertial_system, A_e, B_e, C_e
Alias for pmi()
Recenters the molecule about the center of mass This modifies the molecule in place.
Examples : |
---|
>>> m = Molecule([Atom("O", [1.1, 1.3, 1.7])])
>>> m
Molecule([
Atom('O', [ 1.10000000, 1.30000000, 1.70000000 ] )
])
>>> m.recenter()
>>> m
Molecule([
Atom('O', [ 0.00000000, 0.00000000, 0.00000000 ] )
])
>>> m = Molecule(['H','H'], Matrix([[0,0,0],[1,0.0,0]]))
>>> m
Molecule([
Atom('H', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('H', [ 1.00000000, 0.00000000, 0.00000000 ] )
])
>>> m.recenter()
>>> m
Molecule([
Atom('H', [ -0.50000000, 0.00000000, 0.00000000 ] ),
Atom('H', [ 0.50000000, 0.00000000, 0.00000000 ] )
])
Same as recenter, but makes returns a copy. self is not modified.
Examples : |
---|
>>> foo = Molecule([Atom("O", [1.3, 1.7, 2.0])])
>>> bar = foo.recentered()
>>> foo.recenter()
>>> foo
Molecule([
Atom('O', [ 0.00000000, 0.00000000, 0.00000000 ] )
])
>>> foo == bar
True
>>> foo is bar
False
Reorient the molecule to align the x, y, and z axes with the principal axes of rotation.
Parameters : |
---|
Examples : |
---|
>>> from grendel.chemistry import SampleMolecules, init_sample_molecules
>>> init_sample_molecules()
>>> from grendel.gmath import chopped
>>> h2o = SampleMolecules['quantum water']
>>> h2o.principal_axes()
Matrix([[-0. , 0. , 1. ],
[-0.53654222, -0.84387348, 0. ],
[-0.84387348, 0.53654222, 0. ]])
>>> h2o.reorient()
>>> # Use chopped to get rid of very small numerical artifacts...
>>> # using abs to get rid of phase factor
>>> abs(chopped(h2o.principal_axes()))
Matrix([[ 0., 0., 1.],
[ 1., 0., 0.],
[ 0., 1., 0.]])
>>> h2o.reorient("I")
>>> from grendel.gmath import chopped
>>> abs(chopped(h2o.principal_axes()))
Matrix([[ 0., 1., 0.],
[ 0., 0., 1.],
[ 1., 0., 0.]])
>>> h2o.reorient("III")
>>> abs(chopped(h2o.principal_axes()))
Matrix([[ 1., 0., 0.],
[ 0., 1., 0.],
[ 0., 0., 1.]])
Same as reorient, but makes returns a copy. self is not modified.
Examples : |
---|
>>> from grendel.chemistry import SampleMolecules, init_sample_molecules
>>> init_sample_molecules()
>>> from grendel.gmath import chopped
>>> h2o = Molecule([
... Atom('O', [ 0.00000000, 0.00000000, 0.00000000 ] ),
... Atom('H', [ 0.00000000, 0.00000000, 1.00000000 ] ),
... Atom('H', [ 0.00000000, -1.00000000, -0.00000000 ] )
... ])
>>> new = h2o.reoriented()
>>> # Use chopped to get rid of very small numerical artifacts...
>>> chopped(new.principal_axes())
Matrix([[ 0., 0., 1.],
[-1., 0., 0.],
[ 0., 1., 0.]])
>>> new is h2o
False
>>> # original molecule is unchanged...
>>> h2o
Molecule([
Atom('O', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('H', [ 0.00000000, 0.00000000, 1.00000000 ] ),
Atom('H', [ 0.00000000, -1.00000000, -0.00000000 ] )
])
Rotates the molecule about axis (a Vector) by angle
Writes the Molecule to the standard xyz format.
See Molecule.xyz_string() for more details.
See Also: |
---|
xyz_string
The molecule’s position as a natoms x 3 Matrix. The ordering of rows is (as expected) the same as the ordering of the Molecule.atoms list attribute. Aliased to xyz_mat and position (the latter to be “consistant-ish” with the naming in Atom.
The molecule’s position as a natoms x 3 Matrix. The ordering of rows is (as expected) the same as the ordering of the Molecule.atoms list attribute. Aliased to xyz_mat and position (the latter to be “consistant-ish” with the naming in Atom.
The molecule, represented as a string in standard xyz format.
The first line will always be the number of atoms. The second line (which is a comment in the xyz specification) is filled by the description first line of the description attribute.
Parameters : |
---|
Examples : |
---|
>>> from __future__ import print_function
>>> from grendel.chemistry import SampleMolecules, init_sample_molecules
>>> init_sample_molecules()
>>> print(SampleMolecules['water'].xyz_string())
3
CCSD(T)/aug-cc-pVTZ Water
O 0.00000000 0.00000000 0.11815400
H 0.00000000 0.75873400 -0.47261400
H 0.00000000 -0.75873400 -0.47261400
>>> print(Molecule("O 1.0 0.5 1.5").xyz_string("Atom: %2s, x: %3.1f, y: %4.2f, z: %5.3f"))
1
Atom: O, x: 1.0, y: 0.50, z: 1.500
>>> print(Molecule("O 1.0 0.5 1.5").xyz_string("Atom: %2s, x: %3.1f, y: %4.2f, z: %5.3f", False))
Atom: O, x: 1.0, y: 0.50, z: 1.500
All numbers inherit from this class.
If you just want to check if an argument x is a number, without caring what kind, use isinstance(x, Number).
alias of Radian
A read-only attribute. See SpecialAttribute for initialization variables standard to all SpecialAttribute subclasses.
Attributes : |
---|
Superclass of all the representations types.
Attributes : |
|
---|
Make a copy of self that is the same in every way except for the molecule attribute. New Coordinate objects are created using the Coordinate.copy_for_representation() method for each element of self.coords. This is an abstract method that must be implemented by all Representation subclasses.
Apply the Displacement instance disp to the molecule and current representation, generating a new molecule and a new representation (which start as a deepcopy and the return value of Representation.copy_with_molecule, respectively) with the displacement applied. This is an abstract method that must be implemented by all Representation subclasses.
Alias for values_for_matrix()
Alias for values_for_molecule()
Aliased as value_for_matrix()
Aliased as value_for_molecule()
Encapsulates a vector. Most functionality gets passed up to Tensor, which in turn passes things up to numpy.ndarray. Special functionality for vectors gets implemented here.
Examples : |
---|
Multiplication >>> from grendel.gmath import Matrix, Vector >>> Matrix([1,2],[3,4]) * Vector([5,6]) Vector([ 17., 39.])
Cartesian components >>> vtwo = Vector(1., 2.) >>> vthree = Vector(1.11, 2.22, 3.33) >>> vtwo[0] 1.0 >>> vtwo.x 1.0 >>> vtwo.y == vtwo[1] True >>> vthree[2] == vthree.z True >>> # Can also set: >>> vtwo.x = -1 >>> vtwo.y = -2 >>> vtwo Vector([-1., -2.]) >>> vthree.x, vthree.z, vthree.y = 1, 3, 2 >>> vthree Vector([ 1., 2., 3.])
Return the column-vector version of self, which is currently implemented as a Matrix object. Note that matrix-vector multiplication will work without getting column first, so don’t use this unless you have a good reason to do so.
Returns cross product of self with other. Wrapper to numpy.cross
Same as normalize(), but does not modify self
Overrides the numpy.ndarray reshape function to make things make sense.
Examples : |
---|
>>> v = Vector([1,2,3,4])
>>> v.reshape((2,2))
Matrix([[ 1., 2.],
[ 3., 4.]])
>>> # `v` is unchanged:
>>> v
Vector([ 1., 2., 3., 4.])
>>> v.reshape((4,1))
Matrix([[ 1.],
[ 2.],
[ 3.],
[ 4.]])
>>> import numpy as np
>>> np.reshape(v, (2,2))
Matrix([[ 1., 2.],
[ 3., 4.]])
The x component of a cartesian vector
Raises : |
---|
The y component of a cartesian vector
Raises : |
---|
The z component of a cartesian vector
Raises : |
---|
Aliased as iscompatible()
Alias for has_units()
product(*iterables) –> product object
Cartesian product of input iterables. Equivalent to nested for-loops.
For example, product(A, B) returns the same as: ((x,y) for x in A for y in B). The leftmost iterators are in the outermost for-loop, so the output tuples cycle in a manner similar to an odometer (with the rightmost element changing on every iteration).
To compute the product of an iterable with itself, specify the number of repetitions with the optional repeat keyword argument. For example, product(A, repeat=4) means the same as product(A, A, A, A).
product(‘ab’, range(3)) –> (‘a’,0) (‘a’,1) (‘a’,2) (‘b’,0) (‘b’,1) (‘b’,2) product((0,1), (0,1), (0,1)) –> (0,0,0) (0,0,1) (0,1,0) (0,1,1) (1,0,0) ...
x.next() -> the next value, or raise StopIteration
Aliased as stripunits()
Type checking for functions and methods.
Allows the creation of functions with case insensative, alternately named keyword arguments.
Examples : |
---|
>>> @with_flexible_arguments(
... required=[
... ('name', 'greet', 'name_to_greet'),
... ('from_where', 'source')
... ],
... optional=[
... ('greeting', 'hello_phrase', 'salutation'),
... ('message',)
... ]
... )
... def say_hello(name, from_where, greeting='Hello', message=''):
... print(greeting + ', ' + name + ', from ' + from_where + '!' + message)
...
>>> say_hello('moon', 'Earth')
Hello, moon, from Earth!
>>> say_hello('world', source='the moon')
Hello, world, from the moon!
>>> say_hello(source='France', name_to_greet='visitor', salutation='Bonjour')
Bonjour, visitor, from France!
>>> say_hello('earthlings', 'outer space', 'Greetings', message=' We come in peace!')
Greetings, earthlings, from outer space! We come in peace!
Abstract base class for a general coordinate of a Molecule.
Coordinate`s are the components in which `Molecule`s are represented. The most important thing about `Coordinate`s is that they are immutible, like Python’s `str and tuple classes. [#f1]_ Let me say that again a bit louder:
Note
All coordinates are immutable!
Parentage and the molecule attribute: Coordinate instances are typically (though not always) associated with a Representation, accessible through the parent read-only attribute. Coordinate instances that do not have a parent associated with them are called “orphaned” coordinates, and can be identified using the is_orphaned() instance method. Even orphaned coordinates must have a Molecule associated with them in one way or another. This happens in one of three ways:
- If the Coordinate is not orphaned, then parent‘s molecule attribute is used. Note that in this case, the Coordinate protocol requires the Coordinate‘s constituant atoms to have a parent molecule that is exactly the same instance as parent‘s molecule attribute. (If you aren’t doing something weird, this shouldn’t be an issue).
- If the Coordinate is orphaned, it still must be composed of one or more Atom instances, accessible through the atoms attribute. These Atom`s may themselves be orphaned, but if they are not, the first non-orphaned `Atom‘s parent is used. Note that if one Atom is non-orphaned, the Coordinate protocol requires that all of them must not be orphaned (i. e. the Coordinate constructor enforces this when sanity_checking_enabled is True)
- If the Coordinate is orphaned and all of its Atom`s are also orphaned (as is the case, for instance, with `Coordinate instances created for the purpose of finite difference B tensor computation), the Coordinate‘s base_analog attribute may be set to a Coordinate instance whose constituate Atom instances correspond to the derived Coordinate‘s atoms’ base_atom attributes. In this case, the base_analog‘s molecule attribute is used, though it should be utilized for index translation purposes only, since the positions of the atoms in the base molecule will not correspond to the positions of the Coordinate‘s atoms. (The base_analog, in turn, may be an orphaned coordinate of this third type, in which case that coordinate’s base_analog will be used, and so on recursively.)
- If the Coordinate is orphaned and no base_analog is given, then all of the atoms must have a base_atom that either has a parent_molecule or also has a base_atom defined (and so on so that a base_atom eventually has a parent_molecule somewhere up the line). In this case, the Coordinate protocol requires that all the atoms refer to the same Molecule obtained in this manner. Coordinates created in the course of analytic computation of B tensors fall into this catagory.
Indexing schemes: Because all Coordinate`s may be austensibly associated with a `Molecule instance in one way or another, there are two different ways to index various tensor properties of a Coordinate: the Molecule‘s indices (3 * natoms total indices) and the Coordinate‘s indexing scheme (3 * len(coord.atoms) total indices, where coord is a Coordinate instance). The internal indexing scheme makes a lot more sense in many instances, (see the documentation of Coordinate.atoms for a simple example), but for determining properties of the whole molecule, we need to use the Molecule‘s indexing scheme. All of this should be handled seemlessly behind the scenes, but it’s a good distinction to be aware of.
Getting a Coordinate‘s value: Coordinate has a number of methods that can be used to get the value of a Coordinate in a particular scenario. They hierarchically call each other to determine the value of the Coordinate. The basic scheme is as follows:
}
The reason for this relatively complex hierarchy is that there are instances in which I have needed each variety for some reason or another. Nodes with dotted borders must be implemented in the relevant subclasses: SimpleInternalCoordinate subclasses must implement value_for_xyz, InternalCoordinate subclasses must implement value_for_positions, and Coordinate subclasses must implement value_for_molecule_matrix().
Subclassing: |
---|
TODO: write this part
Footnotes
[5] | Since Python doesn’t really have private attributes, you could in theory change some of the attributes of a Coordinate instance after it is created; the designation of “immutible” here merely means that the class is not guarenteed to work if you do. While it’s technically more of a “please don’t” than a “you can’t”, I for one will not be held responsible for your code not working if you do something like that, and the way these private attributes are used and changed is not guarenteed to stay the same between different versions. Bottom line: just don’t do it. If you don’t know what I’m talking about, you’re probably okay. Just don’t access or modify any attributes that start with a single underscore (you should never do this anyway from outside of a class). |
The indices of the atom(s) the Coordinate depends on in the Molecule the Coordinate depends on.
This is guarenteed to work whether or not the Coordinate is orphaned. For each of the various possible Coordinate–Molecule relationships detailed in the Coordinate class documentation, the reason the method works is as follows:
Use this carefully. Don’t ever retrieve an atom’s position by its index in the parent molecule, since that atom may not be the same instance (or even in the same position) as the Coordinate‘s atom.
List of the Atom instances that the Coordinate depends on. In the case of a CartesianCoordinate, for instance, this is trivially one Atom, but in the case of other coordinates it can be much more substantial. In the case of a NormalCoordinate, this is all the atoms in the parent Molecule.
The presence of an atoms list is essential to establish an internal indexing scheme that can be converted to the indexing scheme of the parent molecule. Besides making the B tensor code much more managable, the use of an internal indexing scheme make Coordinate instances much more self-contained, making “orphaned” coordinates much more viable. Consider the following example:
>>> from grendel.util.units import Degrees
>>> from grendel.coordinates.bond_angle import BondAngle
>>> ba = BondAngle(
... Atom('O', [0.0, 0.0, 0.0]),
... Atom('H', [0.0, 1.0, 0.0]),
... Atom('H', [0.0, 0.0, 1.0]),
... units=Degrees
... )
>>> round(ba.value)
90.
If orphaned coordinates where not allowed to exist, we would have to create a Molecule instance containing those three atoms, construct an InternalRepresentation containing the BondAngle instance (which would need to be a valid, complete representation, a non-trivial task in the general case), pair that InternalRepresentation instance with the Molecule instance, get the right Coordinate instance from the InternalRepresentation corresponding to the BondAngle we want, and then get that coordinate’s value. If all of the coordinate’s complicated methods were not implemented in terms of the Coordinate’s own indexing scheme, it would have to have all of this structure in place just to get a value.
Note
Since all Coordinate`s depend on `Atom`s and `Atom`s are not immutible, a `Coordinate`s `value and other properties such as its b_vector can change even if the Coordinate itself cannot. The one way around this is to specify freeze_value as True in the Coordinate‘s constructor. If that is done, the value of the Coordinate will not change over the life of the instance, even if the positions of the constituant atoms does change (so if you use this, make sure you know what you are doing). This behavior is useful, for instance, in the use of CartesianRepresentation`s as “snapshots” of a `Molecule instance to be used for the parsing of a particular RepresentationDependentProperty.
Analogous Coordinate object on the base molecule, if self is a Coordinate on a displaced Molecule, or the Coordinate from which an orphaned displaced Coordinate was created, if the coordinate was created this way.
Every coordinate must define a reasonable default amount for a finite displacement of that kind of coordinate. This should be a class attribute.
Whether or not the Coordinate instance has a parent Representation
Default implementation for coordinates dependent on atoms directly (basically anything but a CartesianCoordinate or some sort of symmetrized cartesian coordinate).
The molecule associated with the Coordinate.
Note
The molecule’s atoms’ positions may not correspond to the positions of the atoms the coordinate describes. See the class documentation for Coordinate for details.
The InternalRepresentation instance which the coordinate self is a part of.
The InternalRepresentation instance which the coordinate self is a part of.
The units in which the coordinate’s value is expressed.
Get the value of the coordinate for the XYZ matrix mat, which is a (self.molecule.natoms) by 3 matrix. In other words, the matrix argument uses the parent Molecule‘s indexing scheme, not the Coordinate‘s own indexing scheme.
Note
For angular coordinates, this always returns a value in Radians. value, value_with_units, and value_for_molecule, however, return values in self.units
A cartesian coordinate compatible with the Coordinate class. CartesianCoordinate objects are immutable. If you need a different cartesian coordinate, create a new CartesianCoordinate objects.
Attributes : |
---|
The atom to which the cartesian coordinate refers.
The direction (x, y, or z) that the coordinate describes. (0 for X, 1 for Y, 2 for Z, which are also class constants)
The index in the parent representation. This allows for the retrieval of the value for the coordinate on a different molecule, for instance.
General superclass for all types internal coordinates. Internal coordinates may only refer to one representation.
Compute the analytic B tensor of a given order and return a tensor indexed by the coordinate’s own indexing scheme.
Retrieve an element of the Coordinate’s B tensor using CartesianCoordinate instances and/or integer indices in the molecule’s indexing scheme.
Fill the coordinate’s own _btensor attribute for a given order. (The _btensor attribute should be retrieved using the get_b_tensor() method, which calls this if the _btensor has not already been computed.) If the b tensor cannot be computed analytically at the given order, this method returns NotImplemented. Otherwise, it computes the B tensor to the given order and returns None. If the optional B argument is given, this Coordinate’s part of the Representation-based TensorCollection that B refers to is filled as well.
Computes the B tensor for order order by finite difference of B tensors of order order-1, taking into account permutational symmetry. If use_parent_indices is False, a Tensor is returned that is indexed by the coordinate’s internal indices rather than the parent molecule’s atom indices. Otherwise, a DerivativeTensor is returned with its representation attribute set to the coordinate’s parent molecule’s cartesian_representation attribute.
Get the coordinate’s b tensor as a Coordinate-based DerivativeCollection. If it has not already done so, the coordinate will fill in the b tensor up to max_order. The returned value uses the Coordinate‘s internal indexing scheme.
Superclass for all types of simple (non-symmetry, non-normal) internal coordinates.
Attributes : |
---|
Returns the number of the atom (as an index in self.molecule) that the i’th atom composing the coordinate self refers to.
Returns the b vector corresponding to a coordinate with atoms in the positions given as arguments (assumed to be Vector or at least LightVector instances). Note that the returned value uses the indexing scheme corresponding to the order of the argument’s passed in, not the indexing scheme corresponding to a Molecule instance somewhere.
Get the value of the coordinate position vectors xyz.
Note
For angular coordinates, this always returns a value in Radians. value, value_with_units, and value_for_molecule, however, return values in self.units
Value for the xyz matrix constructed from the coordinates of the atoms for the coordinate. For instance, for a
Abstract base class for a general coordinate of a Molecule.
Coordinate`s are the components in which `Molecule`s are represented. The most important thing about `Coordinate`s is that they are immutible, like Python’s `str and tuple classes. [#f1]_ Let me say that again a bit louder:
Note
All coordinates are immutable!
Parentage and the molecule attribute: Coordinate instances are typically (though not always) associated with a Representation, accessible through the parent read-only attribute. Coordinate instances that do not have a parent associated with them are called “orphaned” coordinates, and can be identified using the is_orphaned() instance method. Even orphaned coordinates must have a Molecule associated with them in one way or another. This happens in one of three ways:
- If the Coordinate is not orphaned, then parent‘s molecule attribute is used. Note that in this case, the Coordinate protocol requires the Coordinate‘s constituant atoms to have a parent molecule that is exactly the same instance as parent‘s molecule attribute. (If you aren’t doing something weird, this shouldn’t be an issue).
- If the Coordinate is orphaned, it still must be composed of one or more Atom instances, accessible through the atoms attribute. These Atom`s may themselves be orphaned, but if they are not, the first non-orphaned `Atom‘s parent is used. Note that if one Atom is non-orphaned, the Coordinate protocol requires that all of them must not be orphaned (i. e. the Coordinate constructor enforces this when sanity_checking_enabled is True)
- If the Coordinate is orphaned and all of its Atom`s are also orphaned (as is the case, for instance, with `Coordinate instances created for the purpose of finite difference B tensor computation), the Coordinate‘s base_analog attribute may be set to a Coordinate instance whose constituate Atom instances correspond to the derived Coordinate‘s atoms’ base_atom attributes. In this case, the base_analog‘s molecule attribute is used, though it should be utilized for index translation purposes only, since the positions of the atoms in the base molecule will not correspond to the positions of the Coordinate‘s atoms. (The base_analog, in turn, may be an orphaned coordinate of this third type, in which case that coordinate’s base_analog will be used, and so on recursively.)
- If the Coordinate is orphaned and no base_analog is given, then all of the atoms must have a base_atom that either has a parent_molecule or also has a base_atom defined (and so on so that a base_atom eventually has a parent_molecule somewhere up the line). In this case, the Coordinate protocol requires that all the atoms refer to the same Molecule obtained in this manner. Coordinates created in the course of analytic computation of B tensors fall into this catagory.
Indexing schemes: Because all Coordinate`s may be austensibly associated with a `Molecule instance in one way or another, there are two different ways to index various tensor properties of a Coordinate: the Molecule‘s indices (3 * natoms total indices) and the Coordinate‘s indexing scheme (3 * len(coord.atoms) total indices, where coord is a Coordinate instance). The internal indexing scheme makes a lot more sense in many instances, (see the documentation of Coordinate.atoms for a simple example), but for determining properties of the whole molecule, we need to use the Molecule‘s indexing scheme. All of this should be handled seemlessly behind the scenes, but it’s a good distinction to be aware of.
Getting a Coordinate‘s value: Coordinate has a number of methods that can be used to get the value of a Coordinate in a particular scenario. They hierarchically call each other to determine the value of the Coordinate. The basic scheme is as follows:
}
The reason for this relatively complex hierarchy is that there are instances in which I have needed each variety for some reason or another. Nodes with dotted borders must be implemented in the relevant subclasses: SimpleInternalCoordinate subclasses must implement value_for_xyz, InternalCoordinate subclasses must implement value_for_positions, and Coordinate subclasses must implement value_for_molecule_matrix().
Subclassing: |
---|
TODO: write this part
Footnotes
[6] | Since Python doesn’t really have private attributes, you could in theory change some of the attributes of a Coordinate instance after it is created; the designation of “immutible” here merely means that the class is not guarenteed to work if you do. While it’s technically more of a “please don’t” than a “you can’t”, I for one will not be held responsible for your code not working if you do something like that, and the way these private attributes are used and changed is not guarenteed to stay the same between different versions. Bottom line: just don’t do it. If you don’t know what I’m talking about, you’re probably okay. Just don’t access or modify any attributes that start with a single underscore (you should never do this anyway from outside of a class). |
The indices of the atom(s) the Coordinate depends on in the Molecule the Coordinate depends on.
This is guarenteed to work whether or not the Coordinate is orphaned. For each of the various possible Coordinate–Molecule relationships detailed in the Coordinate class documentation, the reason the method works is as follows:
Use this carefully. Don’t ever retrieve an atom’s position by its index in the parent molecule, since that atom may not be the same instance (or even in the same position) as the Coordinate‘s atom.
List of the Atom instances that the Coordinate depends on. In the case of a CartesianCoordinate, for instance, this is trivially one Atom, but in the case of other coordinates it can be much more substantial. In the case of a NormalCoordinate, this is all the atoms in the parent Molecule.
The presence of an atoms list is essential to establish an internal indexing scheme that can be converted to the indexing scheme of the parent molecule. Besides making the B tensor code much more managable, the use of an internal indexing scheme make Coordinate instances much more self-contained, making “orphaned” coordinates much more viable. Consider the following example:
>>> from grendel.util.units import Degrees
>>> from grendel.coordinates.bond_angle import BondAngle
>>> ba = BondAngle(
... Atom('O', [0.0, 0.0, 0.0]),
... Atom('H', [0.0, 1.0, 0.0]),
... Atom('H', [0.0, 0.0, 1.0]),
... units=Degrees
... )
>>> round(ba.value)
90.
If orphaned coordinates where not allowed to exist, we would have to create a Molecule instance containing those three atoms, construct an InternalRepresentation containing the BondAngle instance (which would need to be a valid, complete representation, a non-trivial task in the general case), pair that InternalRepresentation instance with the Molecule instance, get the right Coordinate instance from the InternalRepresentation corresponding to the BondAngle we want, and then get that coordinate’s value. If all of the coordinate’s complicated methods were not implemented in terms of the Coordinate’s own indexing scheme, it would have to have all of this structure in place just to get a value.
Note
Since all Coordinate`s depend on `Atom`s and `Atom`s are not immutible, a `Coordinate`s `value and other properties such as its b_vector can change even if the Coordinate itself cannot. The one way around this is to specify freeze_value as True in the Coordinate‘s constructor. If that is done, the value of the Coordinate will not change over the life of the instance, even if the positions of the constituant atoms does change (so if you use this, make sure you know what you are doing). This behavior is useful, for instance, in the use of CartesianRepresentation`s as “snapshots” of a `Molecule instance to be used for the parsing of a particular RepresentationDependentProperty.
Analogous Coordinate object on the base molecule, if self is a Coordinate on a displaced Molecule, or the Coordinate from which an orphaned displaced Coordinate was created, if the coordinate was created this way.
Every coordinate must define a reasonable default amount for a finite displacement of that kind of coordinate. This should be a class attribute.
Whether or not the Coordinate instance has a parent Representation
Default implementation for coordinates dependent on atoms directly (basically anything but a CartesianCoordinate or some sort of symmetrized cartesian coordinate).
The molecule associated with the Coordinate.
Note
The molecule’s atoms’ positions may not correspond to the positions of the atoms the coordinate describes. See the class documentation for Coordinate for details.
The InternalRepresentation instance which the coordinate self is a part of.
The InternalRepresentation instance which the coordinate self is a part of.
The units in which the coordinate’s value is expressed.
Get the value of the coordinate for the XYZ matrix mat, which is a (self.molecule.natoms) by 3 matrix. In other words, the matrix argument uses the parent Molecule‘s indexing scheme, not the Coordinate‘s own indexing scheme.
Note
For angular coordinates, this always returns a value in Radians. value, value_with_units, and value_for_molecule, however, return values in self.units
A coordinate that is a function of one or more other Coordinate instances
General superclass for all types internal coordinates. Internal coordinates may only refer to one representation.
Compute the analytic B tensor of a given order and return a tensor indexed by the coordinate’s own indexing scheme.
Retrieve an element of the Coordinate’s B tensor using CartesianCoordinate instances and/or integer indices in the molecule’s indexing scheme.
Fill the coordinate’s own _btensor attribute for a given order. (The _btensor attribute should be retrieved using the get_b_tensor() method, which calls this if the _btensor has not already been computed.) If the b tensor cannot be computed analytically at the given order, this method returns NotImplemented. Otherwise, it computes the B tensor to the given order and returns None. If the optional B argument is given, this Coordinate’s part of the Representation-based TensorCollection that B refers to is filled as well.
Computes the B tensor for order order by finite difference of B tensors of order order-1, taking into account permutational symmetry. If use_parent_indices is False, a Tensor is returned that is indexed by the coordinate’s internal indices rather than the parent molecule’s atom indices. Otherwise, a DerivativeTensor is returned with its representation attribute set to the coordinate’s parent molecule’s cartesian_representation attribute.
Get the coordinate’s b tensor as a Coordinate-based DerivativeCollection. If it has not already done so, the coordinate will fill in the b tensor up to max_order. The returned value uses the Coordinate‘s internal indexing scheme.
An internal coordinate representations of a molecule. TODO: More thoroughly document what this means.
The El’yashevich–Wilson B matrix pseudoinverse, with the Sayvetz conditions used to generate the inverse mass external conditions.
The El’yashevich–Wilson B matrix for the molecule in the representation.
alias of Radian
Superclass for all types of simple (non-symmetry, non-normal) internal coordinates.
Attributes : |
---|
Returns the number of the atom (as an index in self.molecule) that the i’th atom composing the coordinate self refers to.
Returns the b vector corresponding to a coordinate with atoms in the positions given as arguments (assumed to be Vector or at least LightVector instances). Note that the returned value uses the indexing scheme corresponding to the order of the argument’s passed in, not the indexing scheme corresponding to a Molecule instance somewhere.
Get the value of the coordinate position vectors xyz.
Note
For angular coordinates, this always returns a value in Radians. value, value_with_units, and value_for_molecule, however, return values in self.units
Value for the xyz matrix constructed from the coordinates of the atoms for the coordinate. For instance, for a
Mostly a wrapper for the NumPy ndarray class. This gives us a place to put tensor-related functionality that we need but is not available in NumPy.
Copy all properties of the tensor except for the data.
Same as numpy.ndarray.flatten, but modified to return a Vector object
Examples : |
---|
>>> t = Tensor([[[1,2],[3,4]],[[5,6],[7,8]]])
>>> t
Tensor([[[ 1., 2.],
[ 3., 4.]],
[[ 5., 6.],
[ 7., 8.]]])
>>> t.flatten()
Vector([ 1., 2., 3., ..., 6., 7., 8.])
List of pointers to IndexRange objects over which the tensor is defined.
Returns True if all elements of self have absolute values less than cutoff, which defaults to Tensor.zero_cutoff
Note
Tensor.zero_cutoff is treated as a pseudo-class attribute for Tensor instances, meaning individual instances can also set a zero_cutoff attribute which will take precidence over the class-level default.
Given any number of Tensor objects that are the same up to a phase factor, return a list of Tensor objects that have been. Copies are only made if necessary. The chosen phase is the one that makes the first non-zero element (in the numpy.nditer(tensor) iterator, using the cutoff keyword argument or Tensor.zero_cutoff if one is not given) positive.
Allows conformance with the Unitized protocol.
A class for encapsulating a physical constant and it’s units.
Attributes : |
---|
Encapsulates a vector. Most functionality gets passed up to Tensor, which in turn passes things up to numpy.ndarray. Special functionality for vectors gets implemented here.
Examples : |
---|
Multiplication >>> from grendel.gmath import Matrix, Vector >>> Matrix([1,2],[3,4]) * Vector([5,6]) Vector([ 17., 39.])
Cartesian components >>> vtwo = Vector(1., 2.) >>> vthree = Vector(1.11, 2.22, 3.33) >>> vtwo[0] 1.0 >>> vtwo.x 1.0 >>> vtwo.y == vtwo[1] True >>> vthree[2] == vthree.z True >>> # Can also set: >>> vtwo.x = -1 >>> vtwo.y = -2 >>> vtwo Vector([-1., -2.]) >>> vthree.x, vthree.z, vthree.y = 1, 3, 2 >>> vthree Vector([ 1., 2., 3.])
Return the column-vector version of self, which is currently implemented as a Matrix object. Note that matrix-vector multiplication will work without getting column first, so don’t use this unless you have a good reason to do so.
Returns cross product of self with other. Wrapper to numpy.cross
Same as normalize(), but does not modify self
Overrides the numpy.ndarray reshape function to make things make sense.
Examples : |
---|
>>> v = Vector([1,2,3,4])
>>> v.reshape((2,2))
Matrix([[ 1., 2.],
[ 3., 4.]])
>>> # `v` is unchanged:
>>> v
Vector([ 1., 2., 3., 4.])
>>> v.reshape((4,1))
Matrix([[ 1.],
[ 2.],
[ 3.],
[ 4.]])
>>> import numpy as np
>>> np.reshape(v, (2,2))
Matrix([[ 1., 2.],
[ 3., 4.]])
The x component of a cartesian vector
Raises : |
---|
The y component of a cartesian vector
Raises : |
---|
The z component of a cartesian vector
Raises : |
---|
group(3, ‘ABCDEFG’, ‘x’) –> ABC DEF Gxx
Return true if the object is an instance method.
Aliased as is_unit()
partial(func, *args, **keywords) - new function with partial application of the given arguments and keywords.
tuple of arguments to future partial calls
function object to use in future partial calls
dictionary of keyword arguments to future partial calls
product(*iterables) –> product object
Cartesian product of input iterables. Equivalent to nested for-loops.
For example, product(A, B) returns the same as: ((x,y) for x in A for y in B). The leftmost iterators are in the outermost for-loop, so the output tuples cycle in a manner similar to an odometer (with the rightmost element changing on every iteration).
To compute the product of an iterable with itself, specify the number of repetitions with the optional repeat keyword argument. For example, product(A, repeat=4) means the same as product(A, A, A, A).
product(‘ab’, range(3)) –> (‘a’,0) (‘a’,1) (‘a’,2) (‘b’,0) (‘b’,1) (‘b’,2) product((0,1), (0,1), (0,1)) –> (0,0,0) (0,0,1) (0,1,0) (0,1,1) (1,0,0) ...
x.next() -> the next value, or raise StopIteration
Aliased as stripunits()
alias of Angstrom
Encapsulates an atom. Molecules are made up of Atoms.
Attributes : |
---|
Creates an orphaned copy of atom and displaces it by disp_vect
The Element object corresponding to self. Updated transparently using the symbol property
The isotope of the element that self is composed of. Defaults to element.principal_isotope
The atom’s mass as a float (in AMU). Automatically retrieved from the element and isotope attributes.
Alias for the parent_molecule attribute.
Alias for self.position. pos is also an alias for self.position
The atomic symbol from the periodic table (as a str object) , with correct capitalization. Updating this property transparently updates the Element object associated with self.
Alias for self.position. pos is also an alias for self.position
General superclass for all distance units
alias of Angstrom
alias of Angstrom
An internal coordinate representations of a molecule. TODO: More thoroughly document what this means.
The El’yashevich–Wilson B matrix pseudoinverse, with the Sayvetz conditions used to generate the inverse mass external conditions.
The El’yashevich–Wilson B matrix for the molecule in the representation.
alias of Iterable
Returns True if the vector is Cartesian (i.e. if the vector is two or three dimensional).
Alias for Tensor.is_zero()
Returns cross product of self with other. Wrapper to numpy.cross
Same as l_normalize(), but does not modify self
Aliased as normalized()
The magnitude of the vector.
Aliased as norm()
Alias for magnitude()
Performs an in-place normalization of self.
Examples : |
---|
>>> Vector(2.0, 0.0, 0.0).normalize()
Vector([ 1., 0., 0.])
>>> Vector(0.5, 0.5, 0.5).normalize()
Vector([ 0.57735027, 0.57735027, 0.57735027])
>>> v = Vector(-0.5, 0.5, -0.5).normalize()
>>> v
Vector([-0.57735027, 0.57735027, -0.57735027])
>>> v.magnitude()
1.0
Alias for l_normalized()
The number of entries in the vector
Encapsulates a vector. Most functionality gets passed up to Tensor, which in turn passes things up to numpy.ndarray. Special functionality for vectors gets implemented here.
Wrapper to numpy.eigh and numpy.eig for symmetric and non-symmetric matrices, respectively. Note that the eigenvectors are column vectors in the returned matrix.
Number of columns that self has
Number of rows that self has
Encapsulates all of the functionality and attributes of a Molecule itself.
Signatures : |
|
---|---|
Parameters : |
Other Parameters: | |
---|---|
Attributes : |
---|
atoms : list of Atom internal_representations : list of InternalRepresentation normal_representation : NormalRepresentation cartesian_representation : CartesianRepresentation description : str
Examples : |
---|
Constructor
>>> Molecule("""
... 5
...
... C 0.000000 0.000000 0.000000
... H 0.000000 0.000000 1.089000
... H 1.026719 0.000000 -0.363000
... H -0.513360 -0.889165 -0.363000
... H -0.513360 0.889165 -0.363000
... """)
Molecule([
Atom('C', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('H', [ 0.00000000, 0.00000000, 1.08900000 ] ),
Atom('H', [ 1.02671900, 0.00000000, -0.36300000 ] ),
Atom('H', [ -0.51336000, -0.88916500, -0.36300000 ] ),
Atom('H', [ -0.51336000, 0.88916500, -0.36300000 ] )
])
>>> Molecule([
... Atom('H', [0,0,0]),
... Atom('H', [0,0,0.75])
... ])
Molecule([
Atom('H', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('H', [ 0.00000000, 0.00000000, 0.75000000 ] )
])
>>> Molecule(['H','C'], Matrix([[0,0,0],[1,0.5,0]]))
Molecule([
Atom('H', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('C', [ 1.00000000, 0.50000000, 0.00000000 ] )
])
>>> mol = Molecule("""
... 5
...
... C 0.000000 0.000000 0.000000
... H 0.000000 0.000000 1.089000
... H 1.026719 0.000000 -0.363000
... H -0.513360 -0.889165 -0.363000
... H -0.513360 0.889165 -0.363000
... """)
>>> mol
Molecule([
Atom('C', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('H', [ 0.00000000, 0.00000000, 1.08900000 ] ),
Atom('H', [ 1.02671900, 0.00000000, -0.36300000 ] ),
Atom('H', [ -0.51336000, -0.88916500, -0.36300000 ] ),
Atom('H', [ -0.51336000, 0.88916500, -0.36300000 ] )
])
Iteration
>>> from __future__ import print_function
>>> for atom in mol:
... print(repr(atom))
...
Atom('C', [ 0.00000000, 0.00000000, 0.00000000 ] )
Atom('H', [ 0.00000000, 0.00000000, 1.08900000 ] )
Atom('H', [ 1.02671900, 0.00000000, -0.36300000 ] )
Atom('H', [ -0.51336000, -0.88916500, -0.36300000 ] )
Atom('H', [ -0.51336000, 0.88916500, -0.36300000 ] )
The first principal axis of rotation, a. The positive phase is always chosen.
Note
This property depends directly on Molecule.principal_axes(), which is cached. See discussion of caching in A_e
The second principal axis of rotation, b. The positive phase is always chosen.
Note
This property depends directly on Molecule.principal_axes(), which is cached. See discussion of caching in A_e
The third principal axis of rotation, c. The positive phase is always chosen.
Note
This property depends directly on Molecule.principal_axes(), which is cached. See discussion of caching in A_e
The current default cartesian representation associated with the molecule. If the molecule has multiple cartesian representations, the first in the list self.cartesian_representations is returned. The setter for this property pushes the cartesian representation onto the front of the list.
Note
The setter does not check for uniqueness (unless it’s exactly the same object as another CartesianRepresentation). Thus, you should check to make sure the CartesianRepresentation you are assigning to the molecule is not already part of the molecule’s list of representations (to the degree of accuracy required for your particular application) before assigning. Repeatedly failing to do this check could cause runaway memory usage.
Returns a Vector giving the center of mass of the molecule in the current Cartesian representation. The units of the returned value are self.cartesian_units.
Note
This result of this method is cached, and the cached value gets flushed in update_cartesian_representation(). If you change an atom’s position (or mass) and forget to call update_cartesian_representation(), you may get some funny results for this method or any methods that depend on it, including recenter(), reorient(), and principal_moments_of_inertia(). You can detect whether caching is causing problems by setting the environment variable GRENDEL_NO_CACHE to 1 and rerunning your tests. If tests that were failing subsequently succeed, you probably forgot to call update_cartesian_representation() somewhere, or you were assuming that it was automatically called somewhere when in fact it was not getting called.
Create a Molecule object using only the name, SMILES, InChIKey, etc.
The easiest way to call Molecule.from_identifier() is to give it a single argument that is one of the following properties: * smiles * stdinchikey * stdinchi * ncicadd_identifier # (for FICTS, FICuS, uuuuu) * hashisy * cas_number * chemspider_id # input must be chemspider_id=1234567 * opsin_name * cir_name (These are resolved in roughly this order.) Visit the NIH CIR documentation for (some) explaination of what these identifiers are: http://cactus.nci.nih.gov/chemical/structure/documentation
Molecule.from_identifier() can be called with any (single) keyword argument in the grendel.util.web_getter.input_identifiers list. In this form, there must be only
This can also be called using an argument that is the value of a property and a second argument that is a list of fields to search for that property in.
Note: Molecule.get() is a very useful alias for this.
Examples : |
---|
TODO
TODO Document this more
Examples : |
---|
>>> Molecule.from_z_matrix("""
... O
... H1 O 1.0
... H2 O 1.0 H1 90.0
... """)
Molecule([
Atom('O', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('H', [ 0.00000000, 0.00000000, 1.00000000 ] ),
Atom('H', [ 0.00000000, -1.00000000, -0.00000000 ] )
])
>>> Molecule.from_z_matrix(
... [
... ['H'],
... ['O', 1, 0.9],
... ['O', 2, 1.4, 1, 105.0],
... ['H', 3, 0.9, 2, 105.0, 1, 120.0]
... ]
... )
Molecule([
Atom('H', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('O', [ 0.00000000, 0.00000000, 0.90000000 ] ),
Atom('O', [ 0.00000000, 1.35229616, 1.26234666 ] ),
Atom('H', [ -0.75286467, 1.46479616, 1.74249095 ] )
])
>>> Molecule.from_z_matrix(
... ['H'],
... ['O', 1, 0.9]
... )
Molecule([
Atom('H', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('O', [ 0.00000000, 0.00000000, 0.90000000 ] )
])
@param string: String containing a z-matrix with labels defined at the end using e.g. a234=8.5 @param args: Passed on to Molecule.from_z_matrix @param kwargs: Passed on to Molecule.from_z_matrix @return: Molecule object corresponding to the z-matrix passed in
Return a list of geometrically separated moieties of the molecule. Note: sub-molecules returned will have charge 0 and multiplicity 1 for now
@param n_vdw_radii: How many Van der Waals radii two atoms may be separated by and still be considered bonded @param default_vdw_radius: Van der Waals radius to use for elements that grendel doesn’t know the VDW radius of. @return: list of moieties as Molecule objects.
Create a Molecule object using only the name, SMILES, InChIKey, etc.
The easiest way to call Molecule.from_identifier() is to give it a single argument that is one of the following properties: * smiles * stdinchikey * stdinchi * ncicadd_identifier # (for FICTS, FICuS, uuuuu) * hashisy * cas_number * chemspider_id # input must be chemspider_id=1234567 * opsin_name * cir_name (These are resolved in roughly this order.) Visit the NIH CIR documentation for (some) explaination of what these identifiers are: http://cactus.nci.nih.gov/chemical/structure/documentation
Molecule.from_identifier() can be called with any (single) keyword argument in the grendel.util.web_getter.input_identifiers list. In this form, there must be only
This can also be called using an argument that is the value of a property and a second argument that is a list of fields to search for that property in.
Note: Molecule.get() is a very useful alias for this.
Examples : |
---|
TODO
Returns True if the elements of self correspond directly to the elements of other (i.e. self.atoms[0].element == other.atoms[0].element and self.atoms[1].element == other.atoms[1].element and ...)
Returns True if all of the elements are the same (including isotope and nuclear spin) and the reoriented() versions of self and other have no atoms whose pairwise position difference has a magnitude greater than tol (which defaults to 1e-8 Angstroms)
Examples : |
---|
>>> mol = Molecule('''
... O 1.5 0.0 0.0
... H 0.2 0.0 0.0
... ''')
>>> m1 = Molecule('''
... O 0.0 1.5 0.0
... H 0.0 0.2 0.0
... ''')
>>> m2 = Molecule('''
... O 0.00000 0.00000 0.200000
... H 0.00000 0.00000 1.500001
... ''')
>>> m3 = Molecule('''
... H 0.0 0.0 0.0
... H 0.0 -1.3 0.0
... ''')
>>> mol.has_same_geometry(m1)
True
>>> m1.has_same_geometry(m2)
False
>>> m1.has_same_geometry(m2, 1e-5)
True
>>> m2.has_same_geometry(mol, 1e-5)
True
>>> m1.has_same_geometry(m3)
False
True if op is a valid symmetry operation on self Each coordinate of the transformed atoms must differ from the original by less than
Returns the index of atom in the atoms array of the molecule
Note
This method returns a cached property Atom.index. If you reorder the atoms in a molecule, be sure and flush this cache by setting atom._index to None for all of the atoms in the reordered molecule.
Raises : |
---|
IndexError : if atom is not found in self
Examples : |
---|
>>> from grendel.chemistry import SampleMolecules, init_sample_molecules
>>> init_sample_molecules()
>>> h2o = SampleMolecules['water']
>>> atom1 = h2o[0]
>>> atom2 = h2o[1]
>>> atom3 = h2o[2]
>>> h2o
Molecule([
Atom('O', [ 0.00000000, 0.00000000, 0.11815400 ] ),
Atom('H', [ 0.00000000, 0.75873400, -0.47261400 ] ),
Atom('H', [ 0.00000000, -0.75873400, -0.47261400 ] )
])
>>> h2o.index(atom2)
1
>>> h2o.index(atom1)
0
>>> # It must be exactly the same instance to avoid raising an index error
>>> h2o.index(Atom('O', [ 0.00000000, 0.00000000, 0.11815400 ] ))
Traceback (most recent call last):
...
IndexError: ...
Returns a tuple of the principal moments of inertia vector and the principal axes matrix.
mol.inertial_system()
Computes the principal moments of inertia and the principal axes.
Note
This funtion mol.recenter() if the molecule is not centered, so any CartesianRepresentations that are not both frozen and referenced elsewhere (e.g. in a RepresentationDependentProperty) will be lost forever.
Note
This method is cached. See discussion of the consequences of caching in Molecule.center_of_mass()
Returns : |
---|
A tuple with types (Vector, Matrix) containing the principal moments of inertia and the principal axes, respectively. These should be aligned (i.e. ret_val[0][1] corresponds to the vector ret_val[1][1])
Examples : |
---|
>>> hnco = Molecule.from_z_matrix("""
... N
... C N 1.2145
... O C 1.1634 N 172.22
... H N 1.0030 C 123.34 O 180.0
... """
... )
>>> i = hnco.inertial_system()
>>> i[0]
Vector([ 0.60187342, 45.48378728, 46.0856607 ])
>>> i[1]
Matrix([[ 0. , 0. , 1. ],
[ 0.09870438, -0.9951168 , 0. ],
[ 0.9951168 , 0.09870438, 0. ]])
>>> j = hnco.inertial_system()
>>> i == j
True
>>> hnco.A_e
28.0085955528 Wavenumber
>>> hnco.B_e
0.370629408869 Wavenumber
>>> hnco.C_e
0.365789031483 Wavenumber
>>> hnco.a
Vector([ 0. , 0.09870438, 0.9951168 ])
>>> hnco.b
Vector([ 0. , -0.9951168 , 0.09870438])
>>> hnco.c
Vector([ 1., 0., 0.])
The first internal representations (of type InternalRepresentation), or None if it does not exist yet.
True if the center of mass is at the origin. This actually computes the vector from the origin to the center of mass and then determines if the magnitude of that vector is less than tol.
Parameters : |
---|
True if the molecule is linear to within tol. All diatomics should return True.
If tol is a ValueWithUnits and tol.units is an AngularUnit, then this method returns True only if all angles in the molecule are within tol of 180 Degrees. If tol.units is a unit-compatible with a moment of inertia (i.e. MassUnit * DistanceUnit**2 ), then this method returns True if the smallest principal moment of inertia is less than tol and the difference between the two largest principal moments of inertia is less than tol. If no units are given (i.e. tol is a float or other float-compatible unit), tol is assumed to have units of AngularUnit.default and the method proceeds as if tol.units was an AngularUnit subclass.
Parameters : |
---|
Examples : |
---|
>>> from grendel.chemistry import SampleMolecules, init_sample_molecules
>>> init_sample_molecules()
>>> SampleMolecules['water'].is_linear()
False
>>> SampleMolecules['CO2'].is_linear()
True
>>> SampleMolecules['Benzene'].is_linear()
False
The principal moments of inertia, as a Vector
Note
This funtion mol.recenter() if the molecule is not centered, so any CartesianRepresentations that are not both frozen and referenced elsewhere (e.g. in a RepresentationDependentProperty) will be lost forever.
Note
This method is cached. See discussion of the consequences of caching in Molecule.center_of_mass()
Examples: >>> hnco = Molecule.from_z_matrix(""" ... N ... C N 1.2145 ... O C 1.1634 N 172.22 ... H N 1.0030 C 123.34 O 180.0 ... """ ... ) >>> hnco.principal_moments_of_inertia() Vector([ 0.60187342, 45.48378728, 46.0856607 ]) >>> hnco.pmi() Vector([ 0.60187342, 45.48378728, 46.0856607 ])
See Also: principal_axes, inertial_system, A_e, B_e, C_e
Aliased as principal_moments_of_inertia()
The molecule’s position as a natoms x 3 Matrix. The ordering of rows is (as expected) the same as the ordering of the Molecule.atoms list attribute. Aliased to xyz_mat and position (the latter to be “consistant-ish” with the naming in Atom.
The principal axes as column vectors in a Matrix. The Vector object mol.principal_axes()[:,i] corresponds to the i`th moment of inertia, `mol.principal_moments_of_inertia()[i].
mol.principal_axes()
Note
This funtion mol.recenter() if the molecule is not centered, so any CartesianRepresentations that are not both frozen and referenced elsewhere (e.g. in a RepresentationDependentProperty) will be lost forever.
Note
This method is cached. See discussion of the consequences of caching in Molecule.center_of_mass()
Examples : |
---|
>>> hnco = Molecule.from_z_matrix("""
... N
... C N 1.2145
... O C 1.1634 N 172.22
... H N 1.0030 C 123.34 O 180.0
... """
... )
>>> hnco.principal_axes()
Matrix([[ 0. , 0. , 1. ],
[ 0.09870438, -0.9951168 , 0. ],
[ 0.9951168 , 0.09870438, 0. ]])
See Also: |
---|
principal_moments_of_inertia, inertial_system, A_e, B_e, C_e
Alias for pmi()
Recenters the molecule about the center of mass This modifies the molecule in place.
Examples : |
---|
>>> m = Molecule([Atom("O", [1.1, 1.3, 1.7])])
>>> m
Molecule([
Atom('O', [ 1.10000000, 1.30000000, 1.70000000 ] )
])
>>> m.recenter()
>>> m
Molecule([
Atom('O', [ 0.00000000, 0.00000000, 0.00000000 ] )
])
>>> m = Molecule(['H','H'], Matrix([[0,0,0],[1,0.0,0]]))
>>> m
Molecule([
Atom('H', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('H', [ 1.00000000, 0.00000000, 0.00000000 ] )
])
>>> m.recenter()
>>> m
Molecule([
Atom('H', [ -0.50000000, 0.00000000, 0.00000000 ] ),
Atom('H', [ 0.50000000, 0.00000000, 0.00000000 ] )
])
Same as recenter, but makes returns a copy. self is not modified.
Examples : |
---|
>>> foo = Molecule([Atom("O", [1.3, 1.7, 2.0])])
>>> bar = foo.recentered()
>>> foo.recenter()
>>> foo
Molecule([
Atom('O', [ 0.00000000, 0.00000000, 0.00000000 ] )
])
>>> foo == bar
True
>>> foo is bar
False
Reorient the molecule to align the x, y, and z axes with the principal axes of rotation.
Parameters : |
---|
Examples : |
---|
>>> from grendel.chemistry import SampleMolecules, init_sample_molecules
>>> init_sample_molecules()
>>> from grendel.gmath import chopped
>>> h2o = SampleMolecules['quantum water']
>>> h2o.principal_axes()
Matrix([[-0. , 0. , 1. ],
[-0.53654222, -0.84387348, 0. ],
[-0.84387348, 0.53654222, 0. ]])
>>> h2o.reorient()
>>> # Use chopped to get rid of very small numerical artifacts...
>>> # using abs to get rid of phase factor
>>> abs(chopped(h2o.principal_axes()))
Matrix([[ 0., 0., 1.],
[ 1., 0., 0.],
[ 0., 1., 0.]])
>>> h2o.reorient("I")
>>> from grendel.gmath import chopped
>>> abs(chopped(h2o.principal_axes()))
Matrix([[ 0., 1., 0.],
[ 0., 0., 1.],
[ 1., 0., 0.]])
>>> h2o.reorient("III")
>>> abs(chopped(h2o.principal_axes()))
Matrix([[ 1., 0., 0.],
[ 0., 1., 0.],
[ 0., 0., 1.]])
Same as reorient, but makes returns a copy. self is not modified.
Examples : |
---|
>>> from grendel.chemistry import SampleMolecules, init_sample_molecules
>>> init_sample_molecules()
>>> from grendel.gmath import chopped
>>> h2o = Molecule([
... Atom('O', [ 0.00000000, 0.00000000, 0.00000000 ] ),
... Atom('H', [ 0.00000000, 0.00000000, 1.00000000 ] ),
... Atom('H', [ 0.00000000, -1.00000000, -0.00000000 ] )
... ])
>>> new = h2o.reoriented()
>>> # Use chopped to get rid of very small numerical artifacts...
>>> chopped(new.principal_axes())
Matrix([[ 0., 0., 1.],
[-1., 0., 0.],
[ 0., 1., 0.]])
>>> new is h2o
False
>>> # original molecule is unchanged...
>>> h2o
Molecule([
Atom('O', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('H', [ 0.00000000, 0.00000000, 1.00000000 ] ),
Atom('H', [ 0.00000000, -1.00000000, -0.00000000 ] )
])
Rotates the molecule about axis (a Vector) by angle
Writes the Molecule to the standard xyz format.
See Molecule.xyz_string() for more details.
See Also: |
---|
xyz_string
The molecule’s position as a natoms x 3 Matrix. The ordering of rows is (as expected) the same as the ordering of the Molecule.atoms list attribute. Aliased to xyz_mat and position (the latter to be “consistant-ish” with the naming in Atom.
The molecule’s position as a natoms x 3 Matrix. The ordering of rows is (as expected) the same as the ordering of the Molecule.atoms list attribute. Aliased to xyz_mat and position (the latter to be “consistant-ish” with the naming in Atom.
The molecule, represented as a string in standard xyz format.
The first line will always be the number of atoms. The second line (which is a comment in the xyz specification) is filled by the description first line of the description attribute.
Parameters : |
---|
Examples : |
---|
>>> from __future__ import print_function
>>> from grendel.chemistry import SampleMolecules, init_sample_molecules
>>> init_sample_molecules()
>>> print(SampleMolecules['water'].xyz_string())
3
CCSD(T)/aug-cc-pVTZ Water
O 0.00000000 0.00000000 0.11815400
H 0.00000000 0.75873400 -0.47261400
H 0.00000000 -0.75873400 -0.47261400
>>> print(Molecule("O 1.0 0.5 1.5").xyz_string("Atom: %2s, x: %3.1f, y: %4.2f, z: %5.3f"))
1
Atom: O, x: 1.0, y: 0.50, z: 1.500
>>> print(Molecule("O 1.0 0.5 1.5").xyz_string("Atom: %2s, x: %3.1f, y: %4.2f, z: %5.3f", False))
Atom: O, x: 1.0, y: 0.50, z: 1.500
Superclass for all types of simple (non-symmetry, non-normal) internal coordinates.
Attributes : |
---|
Returns the number of the atom (as an index in self.molecule) that the i’th atom composing the coordinate self refers to.
Returns the b vector corresponding to a coordinate with atoms in the positions given as arguments (assumed to be Vector or at least LightVector instances). Note that the returned value uses the indexing scheme corresponding to the order of the argument’s passed in, not the indexing scheme corresponding to a Molecule instance somewhere.
Get the value of the coordinate position vectors xyz.
Note
For angular coordinates, this always returns a value in Radians. value, value_with_units, and value_for_molecule, however, return values in self.units
Value for the xyz matrix constructed from the coordinates of the atoms for the coordinate. For instance, for a
Encapsulates a vector. Most functionality gets passed up to Tensor, which in turn passes things up to numpy.ndarray. Special functionality for vectors gets implemented here.
Examples : |
---|
Multiplication >>> from grendel.gmath import Matrix, Vector >>> Matrix([1,2],[3,4]) * Vector([5,6]) Vector([ 17., 39.])
Cartesian components >>> vtwo = Vector(1., 2.) >>> vthree = Vector(1.11, 2.22, 3.33) >>> vtwo[0] 1.0 >>> vtwo.x 1.0 >>> vtwo.y == vtwo[1] True >>> vthree[2] == vthree.z True >>> # Can also set: >>> vtwo.x = -1 >>> vtwo.y = -2 >>> vtwo Vector([-1., -2.]) >>> vthree.x, vthree.z, vthree.y = 1, 3, 2 >>> vthree Vector([ 1., 2., 3.])
Return the column-vector version of self, which is currently implemented as a Matrix object. Note that matrix-vector multiplication will work without getting column first, so don’t use this unless you have a good reason to do so.
Returns cross product of self with other. Wrapper to numpy.cross
Same as normalize(), but does not modify self
Overrides the numpy.ndarray reshape function to make things make sense.
Examples : |
---|
>>> v = Vector([1,2,3,4])
>>> v.reshape((2,2))
Matrix([[ 1., 2.],
[ 3., 4.]])
>>> # `v` is unchanged:
>>> v
Vector([ 1., 2., 3., 4.])
>>> v.reshape((4,1))
Matrix([[ 1.],
[ 2.],
[ 3.],
[ 4.]])
>>> import numpy as np
>>> np.reshape(v, (2,2))
Matrix([[ 1., 2.],
[ 3., 4.]])
The x component of a cartesian vector
Raises : |
---|
The y component of a cartesian vector
Raises : |
---|
The z component of a cartesian vector
Raises : |
---|
Shallow copy operation on arbitrary Python objects.
See the module’s __doc__ string for more info.
TODO Document this
Aliased as is_unit()
Overload a function the Pythonic (at least, Python 2) way.
Types can be specified using the overloaded instance decorator method overload_with (which is aliased as overload, submethod, and subfunction).
Examples : |
---|
>>> @overloaded
... def test():
... raise TypeError
...
>>> @test.overload_with(int, int)
... def test(a, b=5):
... return a+b
...
>>> @test.overload_with(str)
... def test(string, *args, **kwargs):
... return string + (' ' if len(args) else '') + ', '.join(list(args) + kwargs.keys())
...
>>> @test.overload_with(list, func=callable)
... def test(lst, func, *args):
... for item in lst:
... if func(item, *args):
... return item
...
>>> test(1, 3)
4
>>> test(17)
22
>>> test("Hello")
'Hello'
>>> test("Hello", "World")
'Hello World'
>>> test("Hello", "Earth", "Mars", "Jupiter")
'Hello Earth, Mars, Jupiter'
>>> test([1, 2, 3], lambda x: x**2 % 2 == 0)
2
>>> test([1, 2, 3], lambda x, y: x**2 % y == 0, 1)
1
>>> test(3.14159, 3.234)
Traceback (most recent call last):
...
TypeError: invalid function signature test(float, float).
Available signatures are:
test(a: int, b: int=5)
Not valid signature because: argument 'a' is not of the correct type
test(string: str, *args, **kwargs)
Not valid signature because: argument 'string' is not of the correct type
test(lst: list, func: <something for which callable(func) returns True>, *args)
Not valid signature because: argument 'lst' is not of the correct type
>>> # giving multiple values for a keyword argument means there is no match. For instance:
>>> test('Hello', 'World', string='this is wrong')
Traceback (most recent call last):
...
TypeError: invalid function signature test(str, str, string=str).
Available signatures are:
test(a: int, b: int=5)
Not valid signature because: argument 'a' is not of the correct type
test(string: str, *args, **kwargs)
Not valid signature because: got multiple values for keyword argument 'string'
test(lst: list, func: <something for which callable(func) returns True>, *args)
Not valid signature because: argument 'lst' is not of the correct type
>>> # Methods in classes
>>> class Foo(object):
... @overloaded
... def bar(self, *args, **kwargs): pass
...
... @bar.overload_with(a=int, b=int)
... def bar(self, a, b):
... if not hasattr(self, 'total'):
... self.total = 0
... self.total += a + b
... return a + b
...
>>> foo = Foo()
>>> foo.bar(1,2)
3
>>> foo.bar(4,5)
9
>>> foo.total
12
>>> Foo.bar(foo, 7, 8)
15
>>> foo.total
27
A representations of a molecule in Cartesian coordinates. Since Atom objects already have Cartesian vectors associated with them, this class mostly consists of helper functions and convenience (accessor) functions that make CartesianRepresentation compatible with the parent Representation class.
Add an atom to the representation by creating a CartesianCoordinate object cooresponding to the atom.
Add a CartesianCoordinate to the representation.
Convenience method for accessing atoms. Returns self.molecule.atoms[number]
Convenience property for referencing the atoms list in the molecule associated with self.
Returns the index of the parameter atom in the representation self.
Parameters : |
---|
Raises : |
---|
Returns the value of the representation as a light vector
Renew the coordinates for an atom to coincide with the atom’s current position
Superclass of all the representations types.
Attributes : |
|
---|
Make a copy of self that is the same in every way except for the molecule attribute. New Coordinate objects are created using the Coordinate.copy_for_representation() method for each element of self.coords. This is an abstract method that must be implemented by all Representation subclasses.
Apply the Displacement instance disp to the molecule and current representation, generating a new molecule and a new representation (which start as a deepcopy and the return value of Representation.copy_with_molecule, respectively) with the displacement applied. This is an abstract method that must be implemented by all Representation subclasses.
Alias for values_for_matrix()
Alias for values_for_molecule()
Aliased as value_for_matrix()
Aliased as value_for_molecule()
An internal coordinate representations of a molecule. TODO: More thoroughly document what this means.
The El’yashevich–Wilson B matrix pseudoinverse, with the Sayvetz conditions used to generate the inverse mass external conditions.
The El’yashevich–Wilson B matrix for the molecule in the representation.
alias of AtomicMassUnit
alias of Angstrom
alias of AttoJoule
alias of CentiMeter
General superclass for all distance units
alias of Angstrom
alias of Angstrom
alias of Hartree
An internal coordinate representations of a molecule. TODO: More thoroughly document what this means.
The El’yashevich–Wilson B matrix pseudoinverse, with the Sayvetz conditions used to generate the inverse mass external conditions.
The El’yashevich–Wilson B matrix for the molecule in the representation.
alias of Joule
alias of KiloGram
Encapsulates a vector. Most functionality gets passed up to Tensor, which in turn passes things up to numpy.ndarray. Special functionality for vectors gets implemented here.
Wrapper to numpy.eigh and numpy.eig for symmetric and non-symmetric matrices, respectively. Note that the eigenvectors are column vectors in the returned matrix.
Number of columns that self has
Number of rows that self has
Superclass of all the representations types.
Attributes : |
|
---|
Make a copy of self that is the same in every way except for the molecule attribute. New Coordinate objects are created using the Coordinate.copy_for_representation() method for each element of self.coords. This is an abstract method that must be implemented by all Representation subclasses.
Apply the Displacement instance disp to the molecule and current representation, generating a new molecule and a new representation (which start as a deepcopy and the return value of Representation.copy_with_molecule, respectively) with the displacement applied. This is an abstract method that must be implemented by all Representation subclasses.
Alias for values_for_matrix()
Alias for values_for_molecule()
Aliased as value_for_matrix()
Aliased as value_for_molecule()
Encapsulates a vector. Most functionality gets passed up to Tensor, which in turn passes things up to numpy.ndarray. Special functionality for vectors gets implemented here.
Examples : |
---|
Multiplication >>> from grendel.gmath import Matrix, Vector >>> Matrix([1,2],[3,4]) * Vector([5,6]) Vector([ 17., 39.])
Cartesian components >>> vtwo = Vector(1., 2.) >>> vthree = Vector(1.11, 2.22, 3.33) >>> vtwo[0] 1.0 >>> vtwo.x 1.0 >>> vtwo.y == vtwo[1] True >>> vthree[2] == vthree.z True >>> # Can also set: >>> vtwo.x = -1 >>> vtwo.y = -2 >>> vtwo Vector([-1., -2.]) >>> vthree.x, vthree.z, vthree.y = 1, 3, 2 >>> vthree Vector([ 1., 2., 3.])
Return the column-vector version of self, which is currently implemented as a Matrix object. Note that matrix-vector multiplication will work without getting column first, so don’t use this unless you have a good reason to do so.
Returns cross product of self with other. Wrapper to numpy.cross
Same as normalize(), but does not modify self
Overrides the numpy.ndarray reshape function to make things make sense.
Examples : |
---|
>>> v = Vector([1,2,3,4])
>>> v.reshape((2,2))
Matrix([[ 1., 2.],
[ 3., 4.]])
>>> # `v` is unchanged:
>>> v
Vector([ 1., 2., 3., 4.])
>>> v.reshape((4,1))
Matrix([[ 1.],
[ 2.],
[ 3.],
[ 4.]])
>>> import numpy as np
>>> np.reshape(v, (2,2))
Matrix([[ 1., 2.],
[ 3., 4.]])
The x component of a cartesian vector
Raises : |
---|
The y component of a cartesian vector
Raises : |
---|
The z component of a cartesian vector
Raises : |
---|
alias of Wavenumber
Shallow copy operation on arbitrary Python objects.
See the module’s __doc__ string for more info.
Deep copy operation on arbitrary Python objects.
See the module’s __doc__ string for more info.
Because NumPy’s prod function uses 32-bit integer arithmetic with silent handling of overflows, results are wrong if the correct answer would exceed the limits of a signed 32-bit integer. When operating on a sequence of integers, the prod function that we define here uses large integer arithmetic and thus always gives correct results.
product(*iterables) –> product object
Cartesian product of input iterables. Equivalent to nested for-loops.
For example, product(A, B) returns the same as: ((x,y) for x in A for y in B). The leftmost iterators are in the outermost for-loop, so the output tuples cycle in a manner similar to an odometer (with the rightmost element changing on every iteration).
To compute the product of an iterable with itself, specify the number of repetitions with the optional repeat keyword argument. For example, product(A, repeat=4) means the same as product(A, A, A, A).
product(‘ab’, range(3)) –> (‘a’,0) (‘a’,1) (‘a’,2) (‘b’,0) (‘b’,1) (‘b’,2) product((0,1), (0,1), (0,1)) –> (0,0,0) (0,0,1) (0,1,0) (0,1,1) (1,0,0) ...
x.next() -> the next value, or raise StopIteration
Type checking for functions and methods.
Encapsulates an element. Contains attributes that are constant for a given element.
The most abundant isotope. This contains the default mass for the element.
Struct for containing the information about an isotope. For abundance, None means trace abundance
alias of KiloJoulePerMol
alias of AtomicMassUnit
alias of PicoMeter
Encapsulates an atom. Molecules are made up of Atoms.
Attributes : |
---|
Creates an orphaned copy of atom and displaces it by disp_vect
The Element object corresponding to self. Updated transparently using the symbol property
The isotope of the element that self is composed of. Defaults to element.principal_isotope
The atom’s mass as a float (in AMU). Automatically retrieved from the element and isotope attributes.
Alias for the parent_molecule attribute.
Alias for self.position. pos is also an alias for self.position
The atomic symbol from the periodic table (as a str object) , with correct capitalization. Updating this property transparently updates the Element object associated with self.
Alias for self.position. pos is also an alias for self.position
Encapsulates all of the functionality and attributes of a Molecule itself.
Signatures : |
|
---|---|
Parameters : |
Other Parameters: | |
---|---|
Attributes : |
---|
atoms : list of Atom internal_representations : list of InternalRepresentation normal_representation : NormalRepresentation cartesian_representation : CartesianRepresentation description : str
Examples : |
---|
Constructor
>>> Molecule("""
... 5
...
... C 0.000000 0.000000 0.000000
... H 0.000000 0.000000 1.089000
... H 1.026719 0.000000 -0.363000
... H -0.513360 -0.889165 -0.363000
... H -0.513360 0.889165 -0.363000
... """)
Molecule([
Atom('C', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('H', [ 0.00000000, 0.00000000, 1.08900000 ] ),
Atom('H', [ 1.02671900, 0.00000000, -0.36300000 ] ),
Atom('H', [ -0.51336000, -0.88916500, -0.36300000 ] ),
Atom('H', [ -0.51336000, 0.88916500, -0.36300000 ] )
])
>>> Molecule([
... Atom('H', [0,0,0]),
... Atom('H', [0,0,0.75])
... ])
Molecule([
Atom('H', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('H', [ 0.00000000, 0.00000000, 0.75000000 ] )
])
>>> Molecule(['H','C'], Matrix([[0,0,0],[1,0.5,0]]))
Molecule([
Atom('H', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('C', [ 1.00000000, 0.50000000, 0.00000000 ] )
])
>>> mol = Molecule("""
... 5
...
... C 0.000000 0.000000 0.000000
... H 0.000000 0.000000 1.089000
... H 1.026719 0.000000 -0.363000
... H -0.513360 -0.889165 -0.363000
... H -0.513360 0.889165 -0.363000
... """)
>>> mol
Molecule([
Atom('C', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('H', [ 0.00000000, 0.00000000, 1.08900000 ] ),
Atom('H', [ 1.02671900, 0.00000000, -0.36300000 ] ),
Atom('H', [ -0.51336000, -0.88916500, -0.36300000 ] ),
Atom('H', [ -0.51336000, 0.88916500, -0.36300000 ] )
])
Iteration
>>> from __future__ import print_function
>>> for atom in mol:
... print(repr(atom))
...
Atom('C', [ 0.00000000, 0.00000000, 0.00000000 ] )
Atom('H', [ 0.00000000, 0.00000000, 1.08900000 ] )
Atom('H', [ 1.02671900, 0.00000000, -0.36300000 ] )
Atom('H', [ -0.51336000, -0.88916500, -0.36300000 ] )
Atom('H', [ -0.51336000, 0.88916500, -0.36300000 ] )
The first principal axis of rotation, a. The positive phase is always chosen.
Note
This property depends directly on Molecule.principal_axes(), which is cached. See discussion of caching in A_e
The second principal axis of rotation, b. The positive phase is always chosen.
Note
This property depends directly on Molecule.principal_axes(), which is cached. See discussion of caching in A_e
The third principal axis of rotation, c. The positive phase is always chosen.
Note
This property depends directly on Molecule.principal_axes(), which is cached. See discussion of caching in A_e
The current default cartesian representation associated with the molecule. If the molecule has multiple cartesian representations, the first in the list self.cartesian_representations is returned. The setter for this property pushes the cartesian representation onto the front of the list.
Note
The setter does not check for uniqueness (unless it’s exactly the same object as another CartesianRepresentation). Thus, you should check to make sure the CartesianRepresentation you are assigning to the molecule is not already part of the molecule’s list of representations (to the degree of accuracy required for your particular application) before assigning. Repeatedly failing to do this check could cause runaway memory usage.
Returns a Vector giving the center of mass of the molecule in the current Cartesian representation. The units of the returned value are self.cartesian_units.
Note
This result of this method is cached, and the cached value gets flushed in update_cartesian_representation(). If you change an atom’s position (or mass) and forget to call update_cartesian_representation(), you may get some funny results for this method or any methods that depend on it, including recenter(), reorient(), and principal_moments_of_inertia(). You can detect whether caching is causing problems by setting the environment variable GRENDEL_NO_CACHE to 1 and rerunning your tests. If tests that were failing subsequently succeed, you probably forgot to call update_cartesian_representation() somewhere, or you were assuming that it was automatically called somewhere when in fact it was not getting called.
Create a Molecule object using only the name, SMILES, InChIKey, etc.
The easiest way to call Molecule.from_identifier() is to give it a single argument that is one of the following properties: * smiles * stdinchikey * stdinchi * ncicadd_identifier # (for FICTS, FICuS, uuuuu) * hashisy * cas_number * chemspider_id # input must be chemspider_id=1234567 * opsin_name * cir_name (These are resolved in roughly this order.) Visit the NIH CIR documentation for (some) explaination of what these identifiers are: http://cactus.nci.nih.gov/chemical/structure/documentation
Molecule.from_identifier() can be called with any (single) keyword argument in the grendel.util.web_getter.input_identifiers list. In this form, there must be only
This can also be called using an argument that is the value of a property and a second argument that is a list of fields to search for that property in.
Note: Molecule.get() is a very useful alias for this.
Examples : |
---|
TODO
TODO Document this more
Examples : |
---|
>>> Molecule.from_z_matrix("""
... O
... H1 O 1.0
... H2 O 1.0 H1 90.0
... """)
Molecule([
Atom('O', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('H', [ 0.00000000, 0.00000000, 1.00000000 ] ),
Atom('H', [ 0.00000000, -1.00000000, -0.00000000 ] )
])
>>> Molecule.from_z_matrix(
... [
... ['H'],
... ['O', 1, 0.9],
... ['O', 2, 1.4, 1, 105.0],
... ['H', 3, 0.9, 2, 105.0, 1, 120.0]
... ]
... )
Molecule([
Atom('H', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('O', [ 0.00000000, 0.00000000, 0.90000000 ] ),
Atom('O', [ 0.00000000, 1.35229616, 1.26234666 ] ),
Atom('H', [ -0.75286467, 1.46479616, 1.74249095 ] )
])
>>> Molecule.from_z_matrix(
... ['H'],
... ['O', 1, 0.9]
... )
Molecule([
Atom('H', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('O', [ 0.00000000, 0.00000000, 0.90000000 ] )
])
@param string: String containing a z-matrix with labels defined at the end using e.g. a234=8.5 @param args: Passed on to Molecule.from_z_matrix @param kwargs: Passed on to Molecule.from_z_matrix @return: Molecule object corresponding to the z-matrix passed in
Return a list of geometrically separated moieties of the molecule. Note: sub-molecules returned will have charge 0 and multiplicity 1 for now
@param n_vdw_radii: How many Van der Waals radii two atoms may be separated by and still be considered bonded @param default_vdw_radius: Van der Waals radius to use for elements that grendel doesn’t know the VDW radius of. @return: list of moieties as Molecule objects.
Create a Molecule object using only the name, SMILES, InChIKey, etc.
The easiest way to call Molecule.from_identifier() is to give it a single argument that is one of the following properties: * smiles * stdinchikey * stdinchi * ncicadd_identifier # (for FICTS, FICuS, uuuuu) * hashisy * cas_number * chemspider_id # input must be chemspider_id=1234567 * opsin_name * cir_name (These are resolved in roughly this order.) Visit the NIH CIR documentation for (some) explaination of what these identifiers are: http://cactus.nci.nih.gov/chemical/structure/documentation
Molecule.from_identifier() can be called with any (single) keyword argument in the grendel.util.web_getter.input_identifiers list. In this form, there must be only
This can also be called using an argument that is the value of a property and a second argument that is a list of fields to search for that property in.
Note: Molecule.get() is a very useful alias for this.
Examples : |
---|
TODO
Returns True if the elements of self correspond directly to the elements of other (i.e. self.atoms[0].element == other.atoms[0].element and self.atoms[1].element == other.atoms[1].element and ...)
Returns True if all of the elements are the same (including isotope and nuclear spin) and the reoriented() versions of self and other have no atoms whose pairwise position difference has a magnitude greater than tol (which defaults to 1e-8 Angstroms)
Examples : |
---|
>>> mol = Molecule('''
... O 1.5 0.0 0.0
... H 0.2 0.0 0.0
... ''')
>>> m1 = Molecule('''
... O 0.0 1.5 0.0
... H 0.0 0.2 0.0
... ''')
>>> m2 = Molecule('''
... O 0.00000 0.00000 0.200000
... H 0.00000 0.00000 1.500001
... ''')
>>> m3 = Molecule('''
... H 0.0 0.0 0.0
... H 0.0 -1.3 0.0
... ''')
>>> mol.has_same_geometry(m1)
True
>>> m1.has_same_geometry(m2)
False
>>> m1.has_same_geometry(m2, 1e-5)
True
>>> m2.has_same_geometry(mol, 1e-5)
True
>>> m1.has_same_geometry(m3)
False
True if op is a valid symmetry operation on self Each coordinate of the transformed atoms must differ from the original by less than
Returns the index of atom in the atoms array of the molecule
Note
This method returns a cached property Atom.index. If you reorder the atoms in a molecule, be sure and flush this cache by setting atom._index to None for all of the atoms in the reordered molecule.
Raises : |
---|
IndexError : if atom is not found in self
Examples : |
---|
>>> from grendel.chemistry import SampleMolecules, init_sample_molecules
>>> init_sample_molecules()
>>> h2o = SampleMolecules['water']
>>> atom1 = h2o[0]
>>> atom2 = h2o[1]
>>> atom3 = h2o[2]
>>> h2o
Molecule([
Atom('O', [ 0.00000000, 0.00000000, 0.11815400 ] ),
Atom('H', [ 0.00000000, 0.75873400, -0.47261400 ] ),
Atom('H', [ 0.00000000, -0.75873400, -0.47261400 ] )
])
>>> h2o.index(atom2)
1
>>> h2o.index(atom1)
0
>>> # It must be exactly the same instance to avoid raising an index error
>>> h2o.index(Atom('O', [ 0.00000000, 0.00000000, 0.11815400 ] ))
Traceback (most recent call last):
...
IndexError: ...
Returns a tuple of the principal moments of inertia vector and the principal axes matrix.
mol.inertial_system()
Computes the principal moments of inertia and the principal axes.
Note
This funtion mol.recenter() if the molecule is not centered, so any CartesianRepresentations that are not both frozen and referenced elsewhere (e.g. in a RepresentationDependentProperty) will be lost forever.
Note
This method is cached. See discussion of the consequences of caching in Molecule.center_of_mass()
Returns : |
---|
A tuple with types (Vector, Matrix) containing the principal moments of inertia and the principal axes, respectively. These should be aligned (i.e. ret_val[0][1] corresponds to the vector ret_val[1][1])
Examples : |
---|
>>> hnco = Molecule.from_z_matrix("""
... N
... C N 1.2145
... O C 1.1634 N 172.22
... H N 1.0030 C 123.34 O 180.0
... """
... )
>>> i = hnco.inertial_system()
>>> i[0]
Vector([ 0.60187342, 45.48378728, 46.0856607 ])
>>> i[1]
Matrix([[ 0. , 0. , 1. ],
[ 0.09870438, -0.9951168 , 0. ],
[ 0.9951168 , 0.09870438, 0. ]])
>>> j = hnco.inertial_system()
>>> i == j
True
>>> hnco.A_e
28.0085955528 Wavenumber
>>> hnco.B_e
0.370629408869 Wavenumber
>>> hnco.C_e
0.365789031483 Wavenumber
>>> hnco.a
Vector([ 0. , 0.09870438, 0.9951168 ])
>>> hnco.b
Vector([ 0. , -0.9951168 , 0.09870438])
>>> hnco.c
Vector([ 1., 0., 0.])
The first internal representations (of type InternalRepresentation), or None if it does not exist yet.
True if the center of mass is at the origin. This actually computes the vector from the origin to the center of mass and then determines if the magnitude of that vector is less than tol.
Parameters : |
---|
True if the molecule is linear to within tol. All diatomics should return True.
If tol is a ValueWithUnits and tol.units is an AngularUnit, then this method returns True only if all angles in the molecule are within tol of 180 Degrees. If tol.units is a unit-compatible with a moment of inertia (i.e. MassUnit * DistanceUnit**2 ), then this method returns True if the smallest principal moment of inertia is less than tol and the difference between the two largest principal moments of inertia is less than tol. If no units are given (i.e. tol is a float or other float-compatible unit), tol is assumed to have units of AngularUnit.default and the method proceeds as if tol.units was an AngularUnit subclass.
Parameters : |
---|
Examples : |
---|
>>> from grendel.chemistry import SampleMolecules, init_sample_molecules
>>> init_sample_molecules()
>>> SampleMolecules['water'].is_linear()
False
>>> SampleMolecules['CO2'].is_linear()
True
>>> SampleMolecules['Benzene'].is_linear()
False
The principal moments of inertia, as a Vector
Note
This funtion mol.recenter() if the molecule is not centered, so any CartesianRepresentations that are not both frozen and referenced elsewhere (e.g. in a RepresentationDependentProperty) will be lost forever.
Note
This method is cached. See discussion of the consequences of caching in Molecule.center_of_mass()
Examples: >>> hnco = Molecule.from_z_matrix(""" ... N ... C N 1.2145 ... O C 1.1634 N 172.22 ... H N 1.0030 C 123.34 O 180.0 ... """ ... ) >>> hnco.principal_moments_of_inertia() Vector([ 0.60187342, 45.48378728, 46.0856607 ]) >>> hnco.pmi() Vector([ 0.60187342, 45.48378728, 46.0856607 ])
See Also: principal_axes, inertial_system, A_e, B_e, C_e
Aliased as principal_moments_of_inertia()
The molecule’s position as a natoms x 3 Matrix. The ordering of rows is (as expected) the same as the ordering of the Molecule.atoms list attribute. Aliased to xyz_mat and position (the latter to be “consistant-ish” with the naming in Atom.
The principal axes as column vectors in a Matrix. The Vector object mol.principal_axes()[:,i] corresponds to the i`th moment of inertia, `mol.principal_moments_of_inertia()[i].
mol.principal_axes()
Note
This funtion mol.recenter() if the molecule is not centered, so any CartesianRepresentations that are not both frozen and referenced elsewhere (e.g. in a RepresentationDependentProperty) will be lost forever.
Note
This method is cached. See discussion of the consequences of caching in Molecule.center_of_mass()
Examples : |
---|
>>> hnco = Molecule.from_z_matrix("""
... N
... C N 1.2145
... O C 1.1634 N 172.22
... H N 1.0030 C 123.34 O 180.0
... """
... )
>>> hnco.principal_axes()
Matrix([[ 0. , 0. , 1. ],
[ 0.09870438, -0.9951168 , 0. ],
[ 0.9951168 , 0.09870438, 0. ]])
See Also: |
---|
principal_moments_of_inertia, inertial_system, A_e, B_e, C_e
Alias for pmi()
Recenters the molecule about the center of mass This modifies the molecule in place.
Examples : |
---|
>>> m = Molecule([Atom("O", [1.1, 1.3, 1.7])])
>>> m
Molecule([
Atom('O', [ 1.10000000, 1.30000000, 1.70000000 ] )
])
>>> m.recenter()
>>> m
Molecule([
Atom('O', [ 0.00000000, 0.00000000, 0.00000000 ] )
])
>>> m = Molecule(['H','H'], Matrix([[0,0,0],[1,0.0,0]]))
>>> m
Molecule([
Atom('H', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('H', [ 1.00000000, 0.00000000, 0.00000000 ] )
])
>>> m.recenter()
>>> m
Molecule([
Atom('H', [ -0.50000000, 0.00000000, 0.00000000 ] ),
Atom('H', [ 0.50000000, 0.00000000, 0.00000000 ] )
])
Same as recenter, but makes returns a copy. self is not modified.
Examples : |
---|
>>> foo = Molecule([Atom("O", [1.3, 1.7, 2.0])])
>>> bar = foo.recentered()
>>> foo.recenter()
>>> foo
Molecule([
Atom('O', [ 0.00000000, 0.00000000, 0.00000000 ] )
])
>>> foo == bar
True
>>> foo is bar
False
Reorient the molecule to align the x, y, and z axes with the principal axes of rotation.
Parameters : |
---|
Examples : |
---|
>>> from grendel.chemistry import SampleMolecules, init_sample_molecules
>>> init_sample_molecules()
>>> from grendel.gmath import chopped
>>> h2o = SampleMolecules['quantum water']
>>> h2o.principal_axes()
Matrix([[-0. , 0. , 1. ],
[-0.53654222, -0.84387348, 0. ],
[-0.84387348, 0.53654222, 0. ]])
>>> h2o.reorient()
>>> # Use chopped to get rid of very small numerical artifacts...
>>> # using abs to get rid of phase factor
>>> abs(chopped(h2o.principal_axes()))
Matrix([[ 0., 0., 1.],
[ 1., 0., 0.],
[ 0., 1., 0.]])
>>> h2o.reorient("I")
>>> from grendel.gmath import chopped
>>> abs(chopped(h2o.principal_axes()))
Matrix([[ 0., 1., 0.],
[ 0., 0., 1.],
[ 1., 0., 0.]])
>>> h2o.reorient("III")
>>> abs(chopped(h2o.principal_axes()))
Matrix([[ 1., 0., 0.],
[ 0., 1., 0.],
[ 0., 0., 1.]])
Same as reorient, but makes returns a copy. self is not modified.
Examples : |
---|
>>> from grendel.chemistry import SampleMolecules, init_sample_molecules
>>> init_sample_molecules()
>>> from grendel.gmath import chopped
>>> h2o = Molecule([
... Atom('O', [ 0.00000000, 0.00000000, 0.00000000 ] ),
... Atom('H', [ 0.00000000, 0.00000000, 1.00000000 ] ),
... Atom('H', [ 0.00000000, -1.00000000, -0.00000000 ] )
... ])
>>> new = h2o.reoriented()
>>> # Use chopped to get rid of very small numerical artifacts...
>>> chopped(new.principal_axes())
Matrix([[ 0., 0., 1.],
[-1., 0., 0.],
[ 0., 1., 0.]])
>>> new is h2o
False
>>> # original molecule is unchanged...
>>> h2o
Molecule([
Atom('O', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('H', [ 0.00000000, 0.00000000, 1.00000000 ] ),
Atom('H', [ 0.00000000, -1.00000000, -0.00000000 ] )
])
Rotates the molecule about axis (a Vector) by angle
Writes the Molecule to the standard xyz format.
See Molecule.xyz_string() for more details.
See Also: |
---|
xyz_string
The molecule’s position as a natoms x 3 Matrix. The ordering of rows is (as expected) the same as the ordering of the Molecule.atoms list attribute. Aliased to xyz_mat and position (the latter to be “consistant-ish” with the naming in Atom.
The molecule’s position as a natoms x 3 Matrix. The ordering of rows is (as expected) the same as the ordering of the Molecule.atoms list attribute. Aliased to xyz_mat and position (the latter to be “consistant-ish” with the naming in Atom.
The molecule, represented as a string in standard xyz format.
The first line will always be the number of atoms. The second line (which is a comment in the xyz specification) is filled by the description first line of the description attribute.
Parameters : |
---|
Examples : |
---|
>>> from __future__ import print_function
>>> from grendel.chemistry import SampleMolecules, init_sample_molecules
>>> init_sample_molecules()
>>> print(SampleMolecules['water'].xyz_string())
3
CCSD(T)/aug-cc-pVTZ Water
O 0.00000000 0.00000000 0.11815400
H 0.00000000 0.75873400 -0.47261400
H 0.00000000 -0.75873400 -0.47261400
>>> print(Molecule("O 1.0 0.5 1.5").xyz_string("Atom: %2s, x: %3.1f, y: %4.2f, z: %5.3f"))
1
Atom: O, x: 1.0, y: 0.50, z: 1.500
>>> print(Molecule("O 1.0 0.5 1.5").xyz_string("Atom: %2s, x: %3.1f, y: %4.2f, z: %5.3f", False))
Atom: O, x: 1.0, y: 0.50, z: 1.500
Raised if a line of a z-matrix has the wrong number of entries.
Raised if an invalid string in the XYZ format is passed into the Molecule class constructor
Encapsulates an element. Contains attributes that are constant for a given element.
The most abundant isotope. This contains the default mass for the element.
Struct for containing the information about an isotope. For abundance, None means trace abundance
Metaclass for defining Abstract Base Classes (ABCs).
Use this metaclass to create an ABC. An ABC can be subclassed directly, and then acts as a mix-in class. You can also register unrelated concrete classes (even built-in classes) and unrelated ABCs as ‘virtual subclasses’ – these and their descendants will be considered subclasses of the registering ABC by the built-in issubclass() function, but the registering ABC won’t show up in their MRO (Method Resolution Order) nor will method implementations defined by the registering ABC be callable (not even via super()).
Register a virtual subclass of an ABC.
Abstract base class for things that you are allowed to take derivatives of.
The value of the differentiable property. If this function is not overridden, assume that self can be added and subtracted, as well as multiplied by a float.
General superclass for all distance units
alias of Angstrom
alias of Angstrom
The energy of a molecule.
alias of Wavenumber
General superclass for all energy units
alias of Wavenumber
alias of Joule
Exception for attempted incompatible unit conversions
A property whose value is a matrix.
Placeholder implementation to satisfy abstract class requirements. Everything is already taken care of in MatrixProperty.from_sequence
Default implementation for matrix properties; only works if seq is a MatrixRegexSequence
Special subclass of RegexSequence that make parsing matrices easier.
Abstract base class for all properties
Attributes : |
---|
molecule : Molecule units : CompositeUnit or class with Unit metaclass
Retrieve the value of the property from a tuple of groups matched in a RegexSequence. See RegexSequence.groups()
Retrieve the value of the property from a RegexSequence object that has already been used on a file. By default, this just calls self.from_groups() with seq.groups(flatten) where flatten comes from self.from_groups.flatten.
The new paradigm for obtaining values. Call the callable instance attribute getter with the arguments and keyword arguments passed in.
The value of the molecular property.
Encapsulates all of the functionality and attributes of a Molecule itself.
Signatures : |
|
---|---|
Parameters : |
Other Parameters: | |
---|---|
Attributes : |
---|
atoms : list of Atom internal_representations : list of InternalRepresentation normal_representation : NormalRepresentation cartesian_representation : CartesianRepresentation description : str
Examples : |
---|
Constructor
>>> Molecule("""
... 5
...
... C 0.000000 0.000000 0.000000
... H 0.000000 0.000000 1.089000
... H 1.026719 0.000000 -0.363000
... H -0.513360 -0.889165 -0.363000
... H -0.513360 0.889165 -0.363000
... """)
Molecule([
Atom('C', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('H', [ 0.00000000, 0.00000000, 1.08900000 ] ),
Atom('H', [ 1.02671900, 0.00000000, -0.36300000 ] ),
Atom('H', [ -0.51336000, -0.88916500, -0.36300000 ] ),
Atom('H', [ -0.51336000, 0.88916500, -0.36300000 ] )
])
>>> Molecule([
... Atom('H', [0,0,0]),
... Atom('H', [0,0,0.75])
... ])
Molecule([
Atom('H', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('H', [ 0.00000000, 0.00000000, 0.75000000 ] )
])
>>> Molecule(['H','C'], Matrix([[0,0,0],[1,0.5,0]]))
Molecule([
Atom('H', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('C', [ 1.00000000, 0.50000000, 0.00000000 ] )
])
>>> mol = Molecule("""
... 5
...
... C 0.000000 0.000000 0.000000
... H 0.000000 0.000000 1.089000
... H 1.026719 0.000000 -0.363000
... H -0.513360 -0.889165 -0.363000
... H -0.513360 0.889165 -0.363000
... """)
>>> mol
Molecule([
Atom('C', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('H', [ 0.00000000, 0.00000000, 1.08900000 ] ),
Atom('H', [ 1.02671900, 0.00000000, -0.36300000 ] ),
Atom('H', [ -0.51336000, -0.88916500, -0.36300000 ] ),
Atom('H', [ -0.51336000, 0.88916500, -0.36300000 ] )
])
Iteration
>>> from __future__ import print_function
>>> for atom in mol:
... print(repr(atom))
...
Atom('C', [ 0.00000000, 0.00000000, 0.00000000 ] )
Atom('H', [ 0.00000000, 0.00000000, 1.08900000 ] )
Atom('H', [ 1.02671900, 0.00000000, -0.36300000 ] )
Atom('H', [ -0.51336000, -0.88916500, -0.36300000 ] )
Atom('H', [ -0.51336000, 0.88916500, -0.36300000 ] )
The first principal axis of rotation, a. The positive phase is always chosen.
Note
This property depends directly on Molecule.principal_axes(), which is cached. See discussion of caching in A_e
The second principal axis of rotation, b. The positive phase is always chosen.
Note
This property depends directly on Molecule.principal_axes(), which is cached. See discussion of caching in A_e
The third principal axis of rotation, c. The positive phase is always chosen.
Note
This property depends directly on Molecule.principal_axes(), which is cached. See discussion of caching in A_e
The current default cartesian representation associated with the molecule. If the molecule has multiple cartesian representations, the first in the list self.cartesian_representations is returned. The setter for this property pushes the cartesian representation onto the front of the list.
Note
The setter does not check for uniqueness (unless it’s exactly the same object as another CartesianRepresentation). Thus, you should check to make sure the CartesianRepresentation you are assigning to the molecule is not already part of the molecule’s list of representations (to the degree of accuracy required for your particular application) before assigning. Repeatedly failing to do this check could cause runaway memory usage.
Returns a Vector giving the center of mass of the molecule in the current Cartesian representation. The units of the returned value are self.cartesian_units.
Note
This result of this method is cached, and the cached value gets flushed in update_cartesian_representation(). If you change an atom’s position (or mass) and forget to call update_cartesian_representation(), you may get some funny results for this method or any methods that depend on it, including recenter(), reorient(), and principal_moments_of_inertia(). You can detect whether caching is causing problems by setting the environment variable GRENDEL_NO_CACHE to 1 and rerunning your tests. If tests that were failing subsequently succeed, you probably forgot to call update_cartesian_representation() somewhere, or you were assuming that it was automatically called somewhere when in fact it was not getting called.
Create a Molecule object using only the name, SMILES, InChIKey, etc.
The easiest way to call Molecule.from_identifier() is to give it a single argument that is one of the following properties: * smiles * stdinchikey * stdinchi * ncicadd_identifier # (for FICTS, FICuS, uuuuu) * hashisy * cas_number * chemspider_id # input must be chemspider_id=1234567 * opsin_name * cir_name (These are resolved in roughly this order.) Visit the NIH CIR documentation for (some) explaination of what these identifiers are: http://cactus.nci.nih.gov/chemical/structure/documentation
Molecule.from_identifier() can be called with any (single) keyword argument in the grendel.util.web_getter.input_identifiers list. In this form, there must be only
This can also be called using an argument that is the value of a property and a second argument that is a list of fields to search for that property in.
Note: Molecule.get() is a very useful alias for this.
Examples : |
---|
TODO
TODO Document this more
Examples : |
---|
>>> Molecule.from_z_matrix("""
... O
... H1 O 1.0
... H2 O 1.0 H1 90.0
... """)
Molecule([
Atom('O', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('H', [ 0.00000000, 0.00000000, 1.00000000 ] ),
Atom('H', [ 0.00000000, -1.00000000, -0.00000000 ] )
])
>>> Molecule.from_z_matrix(
... [
... ['H'],
... ['O', 1, 0.9],
... ['O', 2, 1.4, 1, 105.0],
... ['H', 3, 0.9, 2, 105.0, 1, 120.0]
... ]
... )
Molecule([
Atom('H', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('O', [ 0.00000000, 0.00000000, 0.90000000 ] ),
Atom('O', [ 0.00000000, 1.35229616, 1.26234666 ] ),
Atom('H', [ -0.75286467, 1.46479616, 1.74249095 ] )
])
>>> Molecule.from_z_matrix(
... ['H'],
... ['O', 1, 0.9]
... )
Molecule([
Atom('H', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('O', [ 0.00000000, 0.00000000, 0.90000000 ] )
])
@param string: String containing a z-matrix with labels defined at the end using e.g. a234=8.5 @param args: Passed on to Molecule.from_z_matrix @param kwargs: Passed on to Molecule.from_z_matrix @return: Molecule object corresponding to the z-matrix passed in
Return a list of geometrically separated moieties of the molecule. Note: sub-molecules returned will have charge 0 and multiplicity 1 for now
@param n_vdw_radii: How many Van der Waals radii two atoms may be separated by and still be considered bonded @param default_vdw_radius: Van der Waals radius to use for elements that grendel doesn’t know the VDW radius of. @return: list of moieties as Molecule objects.
Create a Molecule object using only the name, SMILES, InChIKey, etc.
The easiest way to call Molecule.from_identifier() is to give it a single argument that is one of the following properties: * smiles * stdinchikey * stdinchi * ncicadd_identifier # (for FICTS, FICuS, uuuuu) * hashisy * cas_number * chemspider_id # input must be chemspider_id=1234567 * opsin_name * cir_name (These are resolved in roughly this order.) Visit the NIH CIR documentation for (some) explaination of what these identifiers are: http://cactus.nci.nih.gov/chemical/structure/documentation
Molecule.from_identifier() can be called with any (single) keyword argument in the grendel.util.web_getter.input_identifiers list. In this form, there must be only
This can also be called using an argument that is the value of a property and a second argument that is a list of fields to search for that property in.
Note: Molecule.get() is a very useful alias for this.
Examples : |
---|
TODO
Returns True if the elements of self correspond directly to the elements of other (i.e. self.atoms[0].element == other.atoms[0].element and self.atoms[1].element == other.atoms[1].element and ...)
Returns True if all of the elements are the same (including isotope and nuclear spin) and the reoriented() versions of self and other have no atoms whose pairwise position difference has a magnitude greater than tol (which defaults to 1e-8 Angstroms)
Examples : |
---|
>>> mol = Molecule('''
... O 1.5 0.0 0.0
... H 0.2 0.0 0.0
... ''')
>>> m1 = Molecule('''
... O 0.0 1.5 0.0
... H 0.0 0.2 0.0
... ''')
>>> m2 = Molecule('''
... O 0.00000 0.00000 0.200000
... H 0.00000 0.00000 1.500001
... ''')
>>> m3 = Molecule('''
... H 0.0 0.0 0.0
... H 0.0 -1.3 0.0
... ''')
>>> mol.has_same_geometry(m1)
True
>>> m1.has_same_geometry(m2)
False
>>> m1.has_same_geometry(m2, 1e-5)
True
>>> m2.has_same_geometry(mol, 1e-5)
True
>>> m1.has_same_geometry(m3)
False
True if op is a valid symmetry operation on self Each coordinate of the transformed atoms must differ from the original by less than
Returns the index of atom in the atoms array of the molecule
Note
This method returns a cached property Atom.index. If you reorder the atoms in a molecule, be sure and flush this cache by setting atom._index to None for all of the atoms in the reordered molecule.
Raises : |
---|
IndexError : if atom is not found in self
Examples : |
---|
>>> from grendel.chemistry import SampleMolecules, init_sample_molecules
>>> init_sample_molecules()
>>> h2o = SampleMolecules['water']
>>> atom1 = h2o[0]
>>> atom2 = h2o[1]
>>> atom3 = h2o[2]
>>> h2o
Molecule([
Atom('O', [ 0.00000000, 0.00000000, 0.11815400 ] ),
Atom('H', [ 0.00000000, 0.75873400, -0.47261400 ] ),
Atom('H', [ 0.00000000, -0.75873400, -0.47261400 ] )
])
>>> h2o.index(atom2)
1
>>> h2o.index(atom1)
0
>>> # It must be exactly the same instance to avoid raising an index error
>>> h2o.index(Atom('O', [ 0.00000000, 0.00000000, 0.11815400 ] ))
Traceback (most recent call last):
...
IndexError: ...
Returns a tuple of the principal moments of inertia vector and the principal axes matrix.
mol.inertial_system()
Computes the principal moments of inertia and the principal axes.
Note
This funtion mol.recenter() if the molecule is not centered, so any CartesianRepresentations that are not both frozen and referenced elsewhere (e.g. in a RepresentationDependentProperty) will be lost forever.
Note
This method is cached. See discussion of the consequences of caching in Molecule.center_of_mass()
Returns : |
---|
A tuple with types (Vector, Matrix) containing the principal moments of inertia and the principal axes, respectively. These should be aligned (i.e. ret_val[0][1] corresponds to the vector ret_val[1][1])
Examples : |
---|
>>> hnco = Molecule.from_z_matrix("""
... N
... C N 1.2145
... O C 1.1634 N 172.22
... H N 1.0030 C 123.34 O 180.0
... """
... )
>>> i = hnco.inertial_system()
>>> i[0]
Vector([ 0.60187342, 45.48378728, 46.0856607 ])
>>> i[1]
Matrix([[ 0. , 0. , 1. ],
[ 0.09870438, -0.9951168 , 0. ],
[ 0.9951168 , 0.09870438, 0. ]])
>>> j = hnco.inertial_system()
>>> i == j
True
>>> hnco.A_e
28.0085955528 Wavenumber
>>> hnco.B_e
0.370629408869 Wavenumber
>>> hnco.C_e
0.365789031483 Wavenumber
>>> hnco.a
Vector([ 0. , 0.09870438, 0.9951168 ])
>>> hnco.b
Vector([ 0. , -0.9951168 , 0.09870438])
>>> hnco.c
Vector([ 1., 0., 0.])
The first internal representations (of type InternalRepresentation), or None if it does not exist yet.
True if the center of mass is at the origin. This actually computes the vector from the origin to the center of mass and then determines if the magnitude of that vector is less than tol.
Parameters : |
---|
True if the molecule is linear to within tol. All diatomics should return True.
If tol is a ValueWithUnits and tol.units is an AngularUnit, then this method returns True only if all angles in the molecule are within tol of 180 Degrees. If tol.units is a unit-compatible with a moment of inertia (i.e. MassUnit * DistanceUnit**2 ), then this method returns True if the smallest principal moment of inertia is less than tol and the difference between the two largest principal moments of inertia is less than tol. If no units are given (i.e. tol is a float or other float-compatible unit), tol is assumed to have units of AngularUnit.default and the method proceeds as if tol.units was an AngularUnit subclass.
Parameters : |
---|
Examples : |
---|
>>> from grendel.chemistry import SampleMolecules, init_sample_molecules
>>> init_sample_molecules()
>>> SampleMolecules['water'].is_linear()
False
>>> SampleMolecules['CO2'].is_linear()
True
>>> SampleMolecules['Benzene'].is_linear()
False
The principal moments of inertia, as a Vector
Note
This funtion mol.recenter() if the molecule is not centered, so any CartesianRepresentations that are not both frozen and referenced elsewhere (e.g. in a RepresentationDependentProperty) will be lost forever.
Note
This method is cached. See discussion of the consequences of caching in Molecule.center_of_mass()
Examples: >>> hnco = Molecule.from_z_matrix(""" ... N ... C N 1.2145 ... O C 1.1634 N 172.22 ... H N 1.0030 C 123.34 O 180.0 ... """ ... ) >>> hnco.principal_moments_of_inertia() Vector([ 0.60187342, 45.48378728, 46.0856607 ]) >>> hnco.pmi() Vector([ 0.60187342, 45.48378728, 46.0856607 ])
See Also: principal_axes, inertial_system, A_e, B_e, C_e
Aliased as principal_moments_of_inertia()
The molecule’s position as a natoms x 3 Matrix. The ordering of rows is (as expected) the same as the ordering of the Molecule.atoms list attribute. Aliased to xyz_mat and position (the latter to be “consistant-ish” with the naming in Atom.
The principal axes as column vectors in a Matrix. The Vector object mol.principal_axes()[:,i] corresponds to the i`th moment of inertia, `mol.principal_moments_of_inertia()[i].
mol.principal_axes()
Note
This funtion mol.recenter() if the molecule is not centered, so any CartesianRepresentations that are not both frozen and referenced elsewhere (e.g. in a RepresentationDependentProperty) will be lost forever.
Note
This method is cached. See discussion of the consequences of caching in Molecule.center_of_mass()
Examples : |
---|
>>> hnco = Molecule.from_z_matrix("""
... N
... C N 1.2145
... O C 1.1634 N 172.22
... H N 1.0030 C 123.34 O 180.0
... """
... )
>>> hnco.principal_axes()
Matrix([[ 0. , 0. , 1. ],
[ 0.09870438, -0.9951168 , 0. ],
[ 0.9951168 , 0.09870438, 0. ]])
See Also: |
---|
principal_moments_of_inertia, inertial_system, A_e, B_e, C_e
Alias for pmi()
Recenters the molecule about the center of mass This modifies the molecule in place.
Examples : |
---|
>>> m = Molecule([Atom("O", [1.1, 1.3, 1.7])])
>>> m
Molecule([
Atom('O', [ 1.10000000, 1.30000000, 1.70000000 ] )
])
>>> m.recenter()
>>> m
Molecule([
Atom('O', [ 0.00000000, 0.00000000, 0.00000000 ] )
])
>>> m = Molecule(['H','H'], Matrix([[0,0,0],[1,0.0,0]]))
>>> m
Molecule([
Atom('H', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('H', [ 1.00000000, 0.00000000, 0.00000000 ] )
])
>>> m.recenter()
>>> m
Molecule([
Atom('H', [ -0.50000000, 0.00000000, 0.00000000 ] ),
Atom('H', [ 0.50000000, 0.00000000, 0.00000000 ] )
])
Same as recenter, but makes returns a copy. self is not modified.
Examples : |
---|
>>> foo = Molecule([Atom("O", [1.3, 1.7, 2.0])])
>>> bar = foo.recentered()
>>> foo.recenter()
>>> foo
Molecule([
Atom('O', [ 0.00000000, 0.00000000, 0.00000000 ] )
])
>>> foo == bar
True
>>> foo is bar
False
Reorient the molecule to align the x, y, and z axes with the principal axes of rotation.
Parameters : |
---|
Examples : |
---|
>>> from grendel.chemistry import SampleMolecules, init_sample_molecules
>>> init_sample_molecules()
>>> from grendel.gmath import chopped
>>> h2o = SampleMolecules['quantum water']
>>> h2o.principal_axes()
Matrix([[-0. , 0. , 1. ],
[-0.53654222, -0.84387348, 0. ],
[-0.84387348, 0.53654222, 0. ]])
>>> h2o.reorient()
>>> # Use chopped to get rid of very small numerical artifacts...
>>> # using abs to get rid of phase factor
>>> abs(chopped(h2o.principal_axes()))
Matrix([[ 0., 0., 1.],
[ 1., 0., 0.],
[ 0., 1., 0.]])
>>> h2o.reorient("I")
>>> from grendel.gmath import chopped
>>> abs(chopped(h2o.principal_axes()))
Matrix([[ 0., 1., 0.],
[ 0., 0., 1.],
[ 1., 0., 0.]])
>>> h2o.reorient("III")
>>> abs(chopped(h2o.principal_axes()))
Matrix([[ 1., 0., 0.],
[ 0., 1., 0.],
[ 0., 0., 1.]])
Same as reorient, but makes returns a copy. self is not modified.
Examples : |
---|
>>> from grendel.chemistry import SampleMolecules, init_sample_molecules
>>> init_sample_molecules()
>>> from grendel.gmath import chopped
>>> h2o = Molecule([
... Atom('O', [ 0.00000000, 0.00000000, 0.00000000 ] ),
... Atom('H', [ 0.00000000, 0.00000000, 1.00000000 ] ),
... Atom('H', [ 0.00000000, -1.00000000, -0.00000000 ] )
... ])
>>> new = h2o.reoriented()
>>> # Use chopped to get rid of very small numerical artifacts...
>>> chopped(new.principal_axes())
Matrix([[ 0., 0., 1.],
[-1., 0., 0.],
[ 0., 1., 0.]])
>>> new is h2o
False
>>> # original molecule is unchanged...
>>> h2o
Molecule([
Atom('O', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('H', [ 0.00000000, 0.00000000, 1.00000000 ] ),
Atom('H', [ 0.00000000, -1.00000000, -0.00000000 ] )
])
Rotates the molecule about axis (a Vector) by angle
Writes the Molecule to the standard xyz format.
See Molecule.xyz_string() for more details.
See Also: |
---|
xyz_string
The molecule’s position as a natoms x 3 Matrix. The ordering of rows is (as expected) the same as the ordering of the Molecule.atoms list attribute. Aliased to xyz_mat and position (the latter to be “consistant-ish” with the naming in Atom.
The molecule’s position as a natoms x 3 Matrix. The ordering of rows is (as expected) the same as the ordering of the Molecule.atoms list attribute. Aliased to xyz_mat and position (the latter to be “consistant-ish” with the naming in Atom.
The molecule, represented as a string in standard xyz format.
The first line will always be the number of atoms. The second line (which is a comment in the xyz specification) is filled by the description first line of the description attribute.
Parameters : |
---|
Examples : |
---|
>>> from __future__ import print_function
>>> from grendel.chemistry import SampleMolecules, init_sample_molecules
>>> init_sample_molecules()
>>> print(SampleMolecules['water'].xyz_string())
3
CCSD(T)/aug-cc-pVTZ Water
O 0.00000000 0.00000000 0.11815400
H 0.00000000 0.75873400 -0.47261400
H 0.00000000 -0.75873400 -0.47261400
>>> print(Molecule("O 1.0 0.5 1.5").xyz_string("Atom: %2s, x: %3.1f, y: %4.2f, z: %5.3f"))
1
Atom: O, x: 1.0, y: 0.50, z: 1.500
>>> print(Molecule("O 1.0 0.5 1.5").xyz_string("Atom: %2s, x: %3.1f, y: %4.2f, z: %5.3f", False))
Atom: O, x: 1.0, y: 0.50, z: 1.500
All numbers inherit from this class.
If you just want to check if an argument x is a number, without caring what kind, use isinstance(x, Number).
alias of Wavenumber
Append some attributes to be set after the initialization is performed. Note that these override anything done in the class’s __init__, so don’t do anything stupid.
A property whose value is a scalar
By default, just get the last group matched.
Mostly a wrapper for the NumPy ndarray class. This gives us a place to put tensor-related functionality that we need but is not available in NumPy.
Copy all properties of the tensor except for the data.
Same as numpy.ndarray.flatten, but modified to return a Vector object
Examples : |
---|
>>> t = Tensor([[[1,2],[3,4]],[[5,6],[7,8]]])
>>> t
Tensor([[[ 1., 2.],
[ 3., 4.]],
[[ 5., 6.],
[ 7., 8.]]])
>>> t.flatten()
Vector([ 1., 2., 3., ..., 6., 7., 8.])
List of pointers to IndexRange objects over which the tensor is defined.
Returns True if all elements of self have absolute values less than cutoff, which defaults to Tensor.zero_cutoff
Note
Tensor.zero_cutoff is treated as a pseudo-class attribute for Tensor instances, meaning individual instances can also set a zero_cutoff attribute which will take precidence over the class-level default.
Given any number of Tensor objects that are the same up to a phase factor, return a list of Tensor objects that have been. Copies are only made if necessary. The chosen phase is the one that makes the first non-zero element (in the numpy.nditer(tensor) iterator, using the cutoff keyword argument or Tensor.zero_cutoff if one is not given) positive.
Allows conformance with the Unitized protocol.
A property whose value is an n-dimensional tensor
Abstract base class for things with units. It requires its subclasses to implement the properties ‘value’ and ‘units’. Unitized subclasses are also expected have __mul__, __div__, __truediv__, __pow__, __add__, __sub__, __neg__, __pos__, and __abs__ handle units correctly, when implemented in the given subclass.
Raised when a MolecularProperty is requested but not available for whatever reason.
A class for encapsulating a physical constant and it’s units.
Attributes : |
---|
A property whose value is a vector.
A decorator indicating abstract methods.
Requires that the metaclass is ABCMeta or derived from it. A class that has a metaclass derived from ABCMeta cannot be instantiated unless all of its abstract methods are overridden. The abstract methods can be called using any of the normal ‘super’ call mechanisms.
Usage:
- class C:
__metaclass__ = ABCMeta @abstractmethod def my_abstract_method(self, ...):
...
Convenience method for getting the typename as a string from the <type ‘Something’> string sent back by str(type(obj))
Alias for has_units()
Aliased as is_unit()
partial(func, *args, **keywords) - new function with partial application of the given arguments and keywords.
tuple of arguments to future partial calls
function object to use in future partial calls
dictionary of keyword arguments to future partial calls
Type checking for functions and methods.
Decorator allowing the assignment of attributes to a function.
Convenience error to raise when an argument is not of the right types.
A representations of a molecule in Cartesian coordinates. Since Atom objects already have Cartesian vectors associated with them, this class mostly consists of helper functions and convenience (accessor) functions that make CartesianRepresentation compatible with the parent Representation class.
Add an atom to the representation by creating a CartesianCoordinate object cooresponding to the atom.
Add a CartesianCoordinate to the representation.
Convenience method for accessing atoms. Returns self.molecule.atoms[number]
Convenience property for referencing the atoms list in the molecule associated with self.
Returns the index of the parameter atom in the representation self.
Parameters : |
---|
Raises : |
---|
Returns the value of the representation as a light vector
Renew the coordinates for an atom to coincide with the atom’s current position
Placeholder implementation to satisfy abstract class requirements. Everything is already taken care of in from_sequence
Expects a MatrixRegexSequence which returns a Nx3 matrix
The energy of a molecule.
alias of Wavenumber
alias of _PartiallyConstructed___EnergyDerivative1_0
alias of _PartiallyConstructed___EnergyDerivative2_1
alias of _PartiallyConstructed___EnergyDerivative1_0
alias of _PartiallyConstructed___EnergyDerivative1_0
alias of _PartiallyConstructed___EnergyDerivative2_1
Exception for attempted incompatible unit conversions
An internal coordinate representations of a molecule. TODO: More thoroughly document what this means.
The El’yashevich–Wilson B matrix pseudoinverse, with the Sayvetz conditions used to generate the inverse mass external conditions.
The El’yashevich–Wilson B matrix for the molecule in the representation.
Special subclass of RegexSequence that make parsing matrices easier.
Abstract base class for all properties
Attributes : |
---|
molecule : Molecule units : CompositeUnit or class with Unit metaclass
Retrieve the value of the property from a tuple of groups matched in a RegexSequence. See RegexSequence.groups()
Retrieve the value of the property from a RegexSequence object that has already been used on a file. By default, this just calls self.from_groups() with seq.groups(flatten) where flatten comes from self.from_groups.flatten.
The new paradigm for obtaining values. Call the callable instance attribute getter with the arguments and keyword arguments passed in.
The value of the molecular property.
Factory for creating MolecularProperty subclasses that represent the nth derivative of a MolecularProperty with respect to some set of coordinates.
Several possibilities for representation: If it’s a Representation subclass, then we want that representation of the molecule in question (used when requesting the derivative). If it’s a representation instance, then we want the Derivative with respect to that specific representation (raises an error if it is not compatible). If it’s an arbitrary callable, then the callable is called with the contents of the file and should return a representation, which the (typically parsed-from-a-file) derivative is considered to be with respect to. The default is CartesianRepresentation.
Derivative properties can be automatically or manually transformed to other representations.
Aliased as PropertyDerivative()
Append some attributes to be set after the initialization is performed. Note that these override anything done in the class’s __init__, so don’t do anything stupid.
Alias for MolecularPropertyDerivative()
Superclass of all the representations types.
Attributes : |
|
---|
Make a copy of self that is the same in every way except for the molecule attribute. New Coordinate objects are created using the Coordinate.copy_for_representation() method for each element of self.coords. This is an abstract method that must be implemented by all Representation subclasses.
Apply the Displacement instance disp to the molecule and current representation, generating a new molecule and a new representation (which start as a deepcopy and the return value of Representation.copy_with_molecule, respectively) with the displacement applied. This is an abstract method that must be implemented by all Representation subclasses.
Alias for values_for_matrix()
Alias for values_for_molecule()
Aliased as value_for_matrix()
Aliased as value_for_molecule()
A property whose value is dependent on a given representation of the molecule.
A property whose value is an n-dimensional tensor
Alias a function as something else. Set the documentation of the new method to “Alias for <function>()” and add “Aliased as <alias>()” to the documentation of function. Not inteded to be used as a decorator.
Examples : |
---|
>>> def foo(a, b, c):
... '''Print a test message.'''
... print "testing {0}, {1}, {2}".format(a, b, c)
...
>>> foo(1, 2, 3)
testing 1, 2, 3
>>> bar = function_alias('bar', foo)
>>> bar(4, 5, 6)
testing 4, 5, 6
>>> print bar.__doc__
Alias for `foo()`
>>> print foo.__doc__
Print a test message.
Aliased as `bar()`
>>> baz = function_alias('baz', foo)
>>> baz(7, 8, 9)
testing 7, 8, 9
>>> print foo.__doc__
Print a test message.
Aliased as `baz()`, `bar()`
Inside a class
>>> class FooBar(object):
... def testfunc(self, *args):
... '''Print out the args.'''
... print "testing " + ', '.join(str(a) for a in args)
... another_name = function_alias('another_name', testfunc)
... test_func = function_alias('test_func', testfunc)
...
>>> f = FooBar()
>>> f.test_func(1, 2, 3, 4)
testing 1, 2, 3, 4
>>> print FooBar.test_func.__doc__
Alias for `testfunc()`
>>> print FooBar.testfunc.__doc__
Print out the args.
Aliased as `test_func()`, `another_name()`
Returns True if a call of callable with args raises an error, and False if not. Note that the callable will get called, so don’t do anything that takes a long time or changes things in a way you don’t want them to be changed. If the optional keyword argument ‘error’ is given as either an Exception subclass or an Iterable, raises_error returns True if the call of callable raises the error given or one of the errors given in the list. (The keyword argument can also be named ‘errors’). Any other keyword arguments are passed through to callable.
Technical note: As per the Python manual, only exceptions that subclass from Exception (and not BaseException directly) will be recognized. According to the python users manual, you should never implement a user exception that subclasses from BaseException directly.
Examples : |
---|
>>> raises_error(int, "5")
False
>>> raises_error(int, "0x5ab7", 0)
False
>>> raises_error(lambda x: int(x), "5")
False
>>> raises_error(int, "abc")
True
>>> raises_error(int, "abc", error = ValueError)
True
>>> raises_error(int, "abc", error = BufferError)
False
>>> raises_error(int, "abc", error = (BufferError, EnvironmentError))
False
>>> raises_error(int, "abc", error = [BufferError, ValueError])
True
>>> raises_error(float, "abc")
True
>>> # Use raises_error to see what errors raises_error raises
... # Raise a type error if the first argument is not a callable (i.e. 17(25) doesn't make sense to Python)
... raises_error(raises_error, 17, 25, error = TypeError)
True
>>> # Raise a TypeError if the error keyword argument is not a subclass of Exception
... raises_error(lambda x: raises_error(int, x, error = "hello world"), 25, error = TypeError)
True
>>> raises_error(lambda x: raises_error(int, x, error = BaseException), 25, error = TypeError)
True
Raised when something that’s not allowed in group theory is done.
Encapsulates a point group.
Returns the element that is the same as op in the group self. This allows us to avoid duplication. When self._generate_elements is True, this adds op to self.operations if no operation is found that is the same as op (this should pretty much only be used by the internal PointGroup._close_group() private method. If you come up with another use for it, use it with care!) Otherwise, if an equivalent of op is not found, a GroupTheoryError is raised.
Returns the element that has the matrix mat in the group self. Raises a GroupTheoryError indicating the group is not closed if no such element is found.
Returns the number of (unique) axes of order n in the point group
Adds an element to the conjugacy class (if it has not already been added)
The abstract superclass for elements of point groups.
Attributes : |
---|
True if the axes a1 and a2 are parallel or antiparallel. Note that normalized versions of a1 and a2 are used, so normalizing before passing in will just slow things down. If parallel_only is True (it is False by default), this method only returns True if the two axes are parallel, not anti_parallel.
True if (a1-a2).norm() < SymmetryOperation.same_operation_tolerance (See ~pyobj:grendel.gmath.tensor.Tensor.norm for description of what is meant by norm here)
The Matrix that transforms the molecule according to the symmetry operation self
The Molecule that the operation acts on
A rotation (C_n^m) element of a point group.
Attributes : |
---|
The angle of rotation, in Radians
A reflection (sigma) element of a point group.
Whether or not the reflection is a sigma_d
An inversion (i) element of a point group.
An improper rotation (S_n^m) element of a point group.
Attributes : |
---|
Metaclass for defining Abstract Base Classes (ABCs).
Use this metaclass to create an ABC. An ABC can be subclassed directly, and then acts as a mix-in class. You can also register unrelated concrete classes (even built-in classes) and unrelated ABCs as ‘virtual subclasses’ – these and their descendants will be considered subclasses of the registering ABC by the built-in issubclass() function, but the registering ABC won’t show up in their MRO (Method Resolution Order) nor will method implementations defined by the registering ABC be callable (not even via super()).
Register a virtual subclass of an ABC.
Convenience error to raise when an argument is not of the right types.
A representations of a molecule in Cartesian coordinates. Since Atom objects already have Cartesian vectors associated with them, this class mostly consists of helper functions and convenience (accessor) functions that make CartesianRepresentation compatible with the parent Representation class.
Add an atom to the representation by creating a CartesianCoordinate object cooresponding to the atom.
Add a CartesianCoordinate to the representation.
Convenience method for accessing atoms. Returns self.molecule.atoms[number]
Convenience property for referencing the atoms list in the molecule associated with self.
Returns the index of the parameter atom in the representation self.
Parameters : |
---|
Raises : |
---|
Returns the value of the representation as a light vector
Renew the coordinates for an atom to coincide with the atom’s current position
Base class for all classes encapsulating runs of external programs
Checks to see if an identical input file with an identical name has already been run in the computation’s directory to produce an output file of some sort (if that output file has errors, you probably don’t want to rerun the exact same input file, so this doesn’t do that by default. If you need to do that, call Computation.run() with the force_rerun argument set to True).
True if and only if the calculation has finished running. (regardless of success or failure). Setting completed to True triggers the output parser.
The types of the properties in the self.properties list.
Convert strings to standard form for attributes. Strings with spaces, underscore_joined_strings, Uppercase_Underscore_Strings, and lowerCamelCase strings are all converted to UpperCamelCase.
Examples : |
---|
>>> Computation.standardize_attribute("basis_set")
'BasisSet'
>>> Computation.standardize_attribute("basis set")
'BasisSet'
>>> Computation.standardize_attribute("basis!Set")
'BasisSet'
>>> # Only _ and space serve as CamelCase separators:
>>> Computation.standardize_attribute("basis!set")
'Basisset'
>>> Computation.standardize_attribute("Level___of!*theory")
'LevelOftheory'
>>> # "Accidental" caps are not fixed...
>>> Computation.standardize_attribute("Level___of!*tHEory")
'LevelOftHEory'
>>> #All caps gets translated into title case
>>> Computation.standardize_attribute("Level&$#of__THEORY")
'LevelofTheory'
Encapsulates specifics about how the calculation was/is to be carried out, such as level of theory, basis set, program, etc. Can be subclassed for specific programs which may require special detail setting methods.
Effectively clones details. Used internally for making a details into a ComputationDetails subclass
Mostly for use by templates, this method returns a string of keyword-value pairs in using the given format for each argument in the argument list. format should use the str.format() protocol from the python standard library with the named slots {key} where the keyword name should go and {value} where the value of the detail should go (or, if the value of the detail is a Keyword object, the contents of the value attribute for that Keyword, or, if the value attribute for the keyword is not defined, the _name attribute for the Keyword object in question.
Aliased as keywordify
Mostly for use by templates, this method returns a string of keyword-value pairs in using the given format for each argument in the argument list. format should use the str.format() protocol from the python standard library with the named slots {key} where the keyword name should go and {value} where the value of the detail should go (or, if the value of the detail is a Keyword object, the contents of the value attribute for that Keyword, or, if the value attribute for the keyword is not defined, the _name attribute for the Keyword object in question.
Aliased as keywordify
Thrown when a computation fails for one reason or another
Alias for can_get_property_for_molecule()
Aliased as has_property(), can_get_property()
Alias for can_get_property_for_molecule()
Raised when a computation can’t be generated either because a compatible input template can’t be found or a valid output parser can’t be found
Placeholder implementation to satisfy abstract class requirements. Everything is already taken care of in from_sequence
Expects a MatrixRegexSequence which returns a Nx3 matrix
Abstract base class for things that you are allowed to take derivatives of.
The value of the differentiable property. If this function is not overridden, assume that self can be added and subtracted, as well as multiplied by a float.
General superclass for all distance units
alias of Angstrom
alias of Angstrom
The energy of a molecule.
alias of Wavenumber
alias of _PartiallyConstructed___EnergyDerivative1_0
alias of _PartiallyConstructed___EnergyDerivative2_1
General superclass for all energy units
alias of Wavenumber
alias of Joule
alias of _PartiallyConstructed___EnergyDerivative1_0
alias of _PartiallyConstructed___EnergyDerivative1_0
alias of _PartiallyConstructed___EnergyDerivative2_1
Exception for attempted incompatible unit conversions
Abstract base class for classes that generate input files.
Determine if we will be able to generate an input.
An internal coordinate representations of a molecule. TODO: More thoroughly document what this means.
The El’yashevich–Wilson B matrix pseudoinverse, with the Sayvetz conditions used to generate the inverse mass external conditions.
The El’yashevich–Wilson B matrix for the molecule in the representation.
A property whose value is a matrix.
Placeholder implementation to satisfy abstract class requirements. Everything is already taken care of in MatrixProperty.from_sequence
Default implementation for matrix properties; only works if seq is a MatrixRegexSequence
Special subclass of RegexSequence that make parsing matrices easier.
Abstract base class for all properties
Attributes : |
---|
molecule : Molecule units : CompositeUnit or class with Unit metaclass
Retrieve the value of the property from a tuple of groups matched in a RegexSequence. See RegexSequence.groups()
Retrieve the value of the property from a RegexSequence object that has already been used on a file. By default, this just calls self.from_groups() with seq.groups(flatten) where flatten comes from self.from_groups.flatten.
The new paradigm for obtaining values. Call the callable instance attribute getter with the arguments and keyword arguments passed in.
The value of the molecular property.
Factory for creating MolecularProperty subclasses that represent the nth derivative of a MolecularProperty with respect to some set of coordinates.
Several possibilities for representation: If it’s a Representation subclass, then we want that representation of the molecule in question (used when requesting the derivative). If it’s a representation instance, then we want the Derivative with respect to that specific representation (raises an error if it is not compatible). If it’s an arbitrary callable, then the callable is called with the contents of the file and should return a representation, which the (typically parsed-from-a-file) derivative is considered to be with respect to. The default is CartesianRepresentation.
Derivative properties can be automatically or manually transformed to other representations.
Aliased as PropertyDerivative()
Encapsulates all of the functionality and attributes of a Molecule itself.
Signatures : |
|
---|---|
Parameters : |
Other Parameters: | |
---|---|
Attributes : |
---|
atoms : list of Atom internal_representations : list of InternalRepresentation normal_representation : NormalRepresentation cartesian_representation : CartesianRepresentation description : str
Examples : |
---|
Constructor
>>> Molecule("""
... 5
...
... C 0.000000 0.000000 0.000000
... H 0.000000 0.000000 1.089000
... H 1.026719 0.000000 -0.363000
... H -0.513360 -0.889165 -0.363000
... H -0.513360 0.889165 -0.363000
... """)
Molecule([
Atom('C', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('H', [ 0.00000000, 0.00000000, 1.08900000 ] ),
Atom('H', [ 1.02671900, 0.00000000, -0.36300000 ] ),
Atom('H', [ -0.51336000, -0.88916500, -0.36300000 ] ),
Atom('H', [ -0.51336000, 0.88916500, -0.36300000 ] )
])
>>> Molecule([
... Atom('H', [0,0,0]),
... Atom('H', [0,0,0.75])
... ])
Molecule([
Atom('H', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('H', [ 0.00000000, 0.00000000, 0.75000000 ] )
])
>>> Molecule(['H','C'], Matrix([[0,0,0],[1,0.5,0]]))
Molecule([
Atom('H', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('C', [ 1.00000000, 0.50000000, 0.00000000 ] )
])
>>> mol = Molecule("""
... 5
...
... C 0.000000 0.000000 0.000000
... H 0.000000 0.000000 1.089000
... H 1.026719 0.000000 -0.363000
... H -0.513360 -0.889165 -0.363000
... H -0.513360 0.889165 -0.363000
... """)
>>> mol
Molecule([
Atom('C', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('H', [ 0.00000000, 0.00000000, 1.08900000 ] ),
Atom('H', [ 1.02671900, 0.00000000, -0.36300000 ] ),
Atom('H', [ -0.51336000, -0.88916500, -0.36300000 ] ),
Atom('H', [ -0.51336000, 0.88916500, -0.36300000 ] )
])
Iteration
>>> from __future__ import print_function
>>> for atom in mol:
... print(repr(atom))
...
Atom('C', [ 0.00000000, 0.00000000, 0.00000000 ] )
Atom('H', [ 0.00000000, 0.00000000, 1.08900000 ] )
Atom('H', [ 1.02671900, 0.00000000, -0.36300000 ] )
Atom('H', [ -0.51336000, -0.88916500, -0.36300000 ] )
Atom('H', [ -0.51336000, 0.88916500, -0.36300000 ] )
The first principal axis of rotation, a. The positive phase is always chosen.
Note
This property depends directly on Molecule.principal_axes(), which is cached. See discussion of caching in A_e
The second principal axis of rotation, b. The positive phase is always chosen.
Note
This property depends directly on Molecule.principal_axes(), which is cached. See discussion of caching in A_e
The third principal axis of rotation, c. The positive phase is always chosen.
Note
This property depends directly on Molecule.principal_axes(), which is cached. See discussion of caching in A_e
The current default cartesian representation associated with the molecule. If the molecule has multiple cartesian representations, the first in the list self.cartesian_representations is returned. The setter for this property pushes the cartesian representation onto the front of the list.
Note
The setter does not check for uniqueness (unless it’s exactly the same object as another CartesianRepresentation). Thus, you should check to make sure the CartesianRepresentation you are assigning to the molecule is not already part of the molecule’s list of representations (to the degree of accuracy required for your particular application) before assigning. Repeatedly failing to do this check could cause runaway memory usage.
Returns a Vector giving the center of mass of the molecule in the current Cartesian representation. The units of the returned value are self.cartesian_units.
Note
This result of this method is cached, and the cached value gets flushed in update_cartesian_representation(). If you change an atom’s position (or mass) and forget to call update_cartesian_representation(), you may get some funny results for this method or any methods that depend on it, including recenter(), reorient(), and principal_moments_of_inertia(). You can detect whether caching is causing problems by setting the environment variable GRENDEL_NO_CACHE to 1 and rerunning your tests. If tests that were failing subsequently succeed, you probably forgot to call update_cartesian_representation() somewhere, or you were assuming that it was automatically called somewhere when in fact it was not getting called.
Create a Molecule object using only the name, SMILES, InChIKey, etc.
The easiest way to call Molecule.from_identifier() is to give it a single argument that is one of the following properties: * smiles * stdinchikey * stdinchi * ncicadd_identifier # (for FICTS, FICuS, uuuuu) * hashisy * cas_number * chemspider_id # input must be chemspider_id=1234567 * opsin_name * cir_name (These are resolved in roughly this order.) Visit the NIH CIR documentation for (some) explaination of what these identifiers are: http://cactus.nci.nih.gov/chemical/structure/documentation
Molecule.from_identifier() can be called with any (single) keyword argument in the grendel.util.web_getter.input_identifiers list. In this form, there must be only
This can also be called using an argument that is the value of a property and a second argument that is a list of fields to search for that property in.
Note: Molecule.get() is a very useful alias for this.
Examples : |
---|
TODO
TODO Document this more
Examples : |
---|
>>> Molecule.from_z_matrix("""
... O
... H1 O 1.0
... H2 O 1.0 H1 90.0
... """)
Molecule([
Atom('O', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('H', [ 0.00000000, 0.00000000, 1.00000000 ] ),
Atom('H', [ 0.00000000, -1.00000000, -0.00000000 ] )
])
>>> Molecule.from_z_matrix(
... [
... ['H'],
... ['O', 1, 0.9],
... ['O', 2, 1.4, 1, 105.0],
... ['H', 3, 0.9, 2, 105.0, 1, 120.0]
... ]
... )
Molecule([
Atom('H', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('O', [ 0.00000000, 0.00000000, 0.90000000 ] ),
Atom('O', [ 0.00000000, 1.35229616, 1.26234666 ] ),
Atom('H', [ -0.75286467, 1.46479616, 1.74249095 ] )
])
>>> Molecule.from_z_matrix(
... ['H'],
... ['O', 1, 0.9]
... )
Molecule([
Atom('H', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('O', [ 0.00000000, 0.00000000, 0.90000000 ] )
])
@param string: String containing a z-matrix with labels defined at the end using e.g. a234=8.5 @param args: Passed on to Molecule.from_z_matrix @param kwargs: Passed on to Molecule.from_z_matrix @return: Molecule object corresponding to the z-matrix passed in
Return a list of geometrically separated moieties of the molecule. Note: sub-molecules returned will have charge 0 and multiplicity 1 for now
@param n_vdw_radii: How many Van der Waals radii two atoms may be separated by and still be considered bonded @param default_vdw_radius: Van der Waals radius to use for elements that grendel doesn’t know the VDW radius of. @return: list of moieties as Molecule objects.
Create a Molecule object using only the name, SMILES, InChIKey, etc.
The easiest way to call Molecule.from_identifier() is to give it a single argument that is one of the following properties: * smiles * stdinchikey * stdinchi * ncicadd_identifier # (for FICTS, FICuS, uuuuu) * hashisy * cas_number * chemspider_id # input must be chemspider_id=1234567 * opsin_name * cir_name (These are resolved in roughly this order.) Visit the NIH CIR documentation for (some) explaination of what these identifiers are: http://cactus.nci.nih.gov/chemical/structure/documentation
Molecule.from_identifier() can be called with any (single) keyword argument in the grendel.util.web_getter.input_identifiers list. In this form, there must be only
This can also be called using an argument that is the value of a property and a second argument that is a list of fields to search for that property in.
Note: Molecule.get() is a very useful alias for this.
Examples : |
---|
TODO
Returns True if the elements of self correspond directly to the elements of other (i.e. self.atoms[0].element == other.atoms[0].element and self.atoms[1].element == other.atoms[1].element and ...)
Returns True if all of the elements are the same (including isotope and nuclear spin) and the reoriented() versions of self and other have no atoms whose pairwise position difference has a magnitude greater than tol (which defaults to 1e-8 Angstroms)
Examples : |
---|
>>> mol = Molecule('''
... O 1.5 0.0 0.0
... H 0.2 0.0 0.0
... ''')
>>> m1 = Molecule('''
... O 0.0 1.5 0.0
... H 0.0 0.2 0.0
... ''')
>>> m2 = Molecule('''
... O 0.00000 0.00000 0.200000
... H 0.00000 0.00000 1.500001
... ''')
>>> m3 = Molecule('''
... H 0.0 0.0 0.0
... H 0.0 -1.3 0.0
... ''')
>>> mol.has_same_geometry(m1)
True
>>> m1.has_same_geometry(m2)
False
>>> m1.has_same_geometry(m2, 1e-5)
True
>>> m2.has_same_geometry(mol, 1e-5)
True
>>> m1.has_same_geometry(m3)
False
True if op is a valid symmetry operation on self Each coordinate of the transformed atoms must differ from the original by less than
Returns the index of atom in the atoms array of the molecule
Note
This method returns a cached property Atom.index. If you reorder the atoms in a molecule, be sure and flush this cache by setting atom._index to None for all of the atoms in the reordered molecule.
Raises : |
---|
IndexError : if atom is not found in self
Examples : |
---|
>>> from grendel.chemistry import SampleMolecules, init_sample_molecules
>>> init_sample_molecules()
>>> h2o = SampleMolecules['water']
>>> atom1 = h2o[0]
>>> atom2 = h2o[1]
>>> atom3 = h2o[2]
>>> h2o
Molecule([
Atom('O', [ 0.00000000, 0.00000000, 0.11815400 ] ),
Atom('H', [ 0.00000000, 0.75873400, -0.47261400 ] ),
Atom('H', [ 0.00000000, -0.75873400, -0.47261400 ] )
])
>>> h2o.index(atom2)
1
>>> h2o.index(atom1)
0
>>> # It must be exactly the same instance to avoid raising an index error
>>> h2o.index(Atom('O', [ 0.00000000, 0.00000000, 0.11815400 ] ))
Traceback (most recent call last):
...
IndexError: ...
Returns a tuple of the principal moments of inertia vector and the principal axes matrix.
mol.inertial_system()
Computes the principal moments of inertia and the principal axes.
Note
This funtion mol.recenter() if the molecule is not centered, so any CartesianRepresentations that are not both frozen and referenced elsewhere (e.g. in a RepresentationDependentProperty) will be lost forever.
Note
This method is cached. See discussion of the consequences of caching in Molecule.center_of_mass()
Returns : |
---|
A tuple with types (Vector, Matrix) containing the principal moments of inertia and the principal axes, respectively. These should be aligned (i.e. ret_val[0][1] corresponds to the vector ret_val[1][1])
Examples : |
---|
>>> hnco = Molecule.from_z_matrix("""
... N
... C N 1.2145
... O C 1.1634 N 172.22
... H N 1.0030 C 123.34 O 180.0
... """
... )
>>> i = hnco.inertial_system()
>>> i[0]
Vector([ 0.60187342, 45.48378728, 46.0856607 ])
>>> i[1]
Matrix([[ 0. , 0. , 1. ],
[ 0.09870438, -0.9951168 , 0. ],
[ 0.9951168 , 0.09870438, 0. ]])
>>> j = hnco.inertial_system()
>>> i == j
True
>>> hnco.A_e
28.0085955528 Wavenumber
>>> hnco.B_e
0.370629408869 Wavenumber
>>> hnco.C_e
0.365789031483 Wavenumber
>>> hnco.a
Vector([ 0. , 0.09870438, 0.9951168 ])
>>> hnco.b
Vector([ 0. , -0.9951168 , 0.09870438])
>>> hnco.c
Vector([ 1., 0., 0.])
The first internal representations (of type InternalRepresentation), or None if it does not exist yet.
True if the center of mass is at the origin. This actually computes the vector from the origin to the center of mass and then determines if the magnitude of that vector is less than tol.
Parameters : |
---|
True if the molecule is linear to within tol. All diatomics should return True.
If tol is a ValueWithUnits and tol.units is an AngularUnit, then this method returns True only if all angles in the molecule are within tol of 180 Degrees. If tol.units is a unit-compatible with a moment of inertia (i.e. MassUnit * DistanceUnit**2 ), then this method returns True if the smallest principal moment of inertia is less than tol and the difference between the two largest principal moments of inertia is less than tol. If no units are given (i.e. tol is a float or other float-compatible unit), tol is assumed to have units of AngularUnit.default and the method proceeds as if tol.units was an AngularUnit subclass.
Parameters : |
---|
Examples : |
---|
>>> from grendel.chemistry import SampleMolecules, init_sample_molecules
>>> init_sample_molecules()
>>> SampleMolecules['water'].is_linear()
False
>>> SampleMolecules['CO2'].is_linear()
True
>>> SampleMolecules['Benzene'].is_linear()
False
The principal moments of inertia, as a Vector
Note
This funtion mol.recenter() if the molecule is not centered, so any CartesianRepresentations that are not both frozen and referenced elsewhere (e.g. in a RepresentationDependentProperty) will be lost forever.
Note
This method is cached. See discussion of the consequences of caching in Molecule.center_of_mass()
Examples: >>> hnco = Molecule.from_z_matrix(""" ... N ... C N 1.2145 ... O C 1.1634 N 172.22 ... H N 1.0030 C 123.34 O 180.0 ... """ ... ) >>> hnco.principal_moments_of_inertia() Vector([ 0.60187342, 45.48378728, 46.0856607 ]) >>> hnco.pmi() Vector([ 0.60187342, 45.48378728, 46.0856607 ])
See Also: principal_axes, inertial_system, A_e, B_e, C_e
Aliased as principal_moments_of_inertia()
The molecule’s position as a natoms x 3 Matrix. The ordering of rows is (as expected) the same as the ordering of the Molecule.atoms list attribute. Aliased to xyz_mat and position (the latter to be “consistant-ish” with the naming in Atom.
The principal axes as column vectors in a Matrix. The Vector object mol.principal_axes()[:,i] corresponds to the i`th moment of inertia, `mol.principal_moments_of_inertia()[i].
mol.principal_axes()
Note
This funtion mol.recenter() if the molecule is not centered, so any CartesianRepresentations that are not both frozen and referenced elsewhere (e.g. in a RepresentationDependentProperty) will be lost forever.
Note
This method is cached. See discussion of the consequences of caching in Molecule.center_of_mass()
Examples : |
---|
>>> hnco = Molecule.from_z_matrix("""
... N
... C N 1.2145
... O C 1.1634 N 172.22
... H N 1.0030 C 123.34 O 180.0
... """
... )
>>> hnco.principal_axes()
Matrix([[ 0. , 0. , 1. ],
[ 0.09870438, -0.9951168 , 0. ],
[ 0.9951168 , 0.09870438, 0. ]])
See Also: |
---|
principal_moments_of_inertia, inertial_system, A_e, B_e, C_e
Alias for pmi()
Recenters the molecule about the center of mass This modifies the molecule in place.
Examples : |
---|
>>> m = Molecule([Atom("O", [1.1, 1.3, 1.7])])
>>> m
Molecule([
Atom('O', [ 1.10000000, 1.30000000, 1.70000000 ] )
])
>>> m.recenter()
>>> m
Molecule([
Atom('O', [ 0.00000000, 0.00000000, 0.00000000 ] )
])
>>> m = Molecule(['H','H'], Matrix([[0,0,0],[1,0.0,0]]))
>>> m
Molecule([
Atom('H', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('H', [ 1.00000000, 0.00000000, 0.00000000 ] )
])
>>> m.recenter()
>>> m
Molecule([
Atom('H', [ -0.50000000, 0.00000000, 0.00000000 ] ),
Atom('H', [ 0.50000000, 0.00000000, 0.00000000 ] )
])
Same as recenter, but makes returns a copy. self is not modified.
Examples : |
---|
>>> foo = Molecule([Atom("O", [1.3, 1.7, 2.0])])
>>> bar = foo.recentered()
>>> foo.recenter()
>>> foo
Molecule([
Atom('O', [ 0.00000000, 0.00000000, 0.00000000 ] )
])
>>> foo == bar
True
>>> foo is bar
False
Reorient the molecule to align the x, y, and z axes with the principal axes of rotation.
Parameters : |
---|
Examples : |
---|
>>> from grendel.chemistry import SampleMolecules, init_sample_molecules
>>> init_sample_molecules()
>>> from grendel.gmath import chopped
>>> h2o = SampleMolecules['quantum water']
>>> h2o.principal_axes()
Matrix([[-0. , 0. , 1. ],
[-0.53654222, -0.84387348, 0. ],
[-0.84387348, 0.53654222, 0. ]])
>>> h2o.reorient()
>>> # Use chopped to get rid of very small numerical artifacts...
>>> # using abs to get rid of phase factor
>>> abs(chopped(h2o.principal_axes()))
Matrix([[ 0., 0., 1.],
[ 1., 0., 0.],
[ 0., 1., 0.]])
>>> h2o.reorient("I")
>>> from grendel.gmath import chopped
>>> abs(chopped(h2o.principal_axes()))
Matrix([[ 0., 1., 0.],
[ 0., 0., 1.],
[ 1., 0., 0.]])
>>> h2o.reorient("III")
>>> abs(chopped(h2o.principal_axes()))
Matrix([[ 1., 0., 0.],
[ 0., 1., 0.],
[ 0., 0., 1.]])
Same as reorient, but makes returns a copy. self is not modified.
Examples : |
---|
>>> from grendel.chemistry import SampleMolecules, init_sample_molecules
>>> init_sample_molecules()
>>> from grendel.gmath import chopped
>>> h2o = Molecule([
... Atom('O', [ 0.00000000, 0.00000000, 0.00000000 ] ),
... Atom('H', [ 0.00000000, 0.00000000, 1.00000000 ] ),
... Atom('H', [ 0.00000000, -1.00000000, -0.00000000 ] )
... ])
>>> new = h2o.reoriented()
>>> # Use chopped to get rid of very small numerical artifacts...
>>> chopped(new.principal_axes())
Matrix([[ 0., 0., 1.],
[-1., 0., 0.],
[ 0., 1., 0.]])
>>> new is h2o
False
>>> # original molecule is unchanged...
>>> h2o
Molecule([
Atom('O', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('H', [ 0.00000000, 0.00000000, 1.00000000 ] ),
Atom('H', [ 0.00000000, -1.00000000, -0.00000000 ] )
])
Rotates the molecule about axis (a Vector) by angle
Writes the Molecule to the standard xyz format.
See Molecule.xyz_string() for more details.
See Also: |
---|
xyz_string
The molecule’s position as a natoms x 3 Matrix. The ordering of rows is (as expected) the same as the ordering of the Molecule.atoms list attribute. Aliased to xyz_mat and position (the latter to be “consistant-ish” with the naming in Atom.
The molecule’s position as a natoms x 3 Matrix. The ordering of rows is (as expected) the same as the ordering of the Molecule.atoms list attribute. Aliased to xyz_mat and position (the latter to be “consistant-ish” with the naming in Atom.
The molecule, represented as a string in standard xyz format.
The first line will always be the number of atoms. The second line (which is a comment in the xyz specification) is filled by the description first line of the description attribute.
Parameters : |
---|
Examples : |
---|
>>> from __future__ import print_function
>>> from grendel.chemistry import SampleMolecules, init_sample_molecules
>>> init_sample_molecules()
>>> print(SampleMolecules['water'].xyz_string())
3
CCSD(T)/aug-cc-pVTZ Water
O 0.00000000 0.00000000 0.11815400
H 0.00000000 0.75873400 -0.47261400
H 0.00000000 -0.75873400 -0.47261400
>>> print(Molecule("O 1.0 0.5 1.5").xyz_string("Atom: %2s, x: %3.1f, y: %4.2f, z: %5.3f"))
1
Atom: O, x: 1.0, y: 0.50, z: 1.500
>>> print(Molecule("O 1.0 0.5 1.5").xyz_string("Atom: %2s, x: %3.1f, y: %4.2f, z: %5.3f", False))
Atom: O, x: 1.0, y: 0.50, z: 1.500
All numbers inherit from this class.
If you just want to check if an argument x is a number, without caring what kind, use isinstance(x, Number).
alias of Wavenumber
Abstract base class for classes that parse the output file for a computation.
Container for the various custom classes needed to run a calculation in a given software package.
alias of Computation
alias of ComputationDetails
Load a package with the given name to be used for computations. Optionally, specify specific subclasses to use for certain things.
Append some attributes to be set after the initialization is performed. Note that these override anything done in the class’s __init__, so don’t do anything stupid.
Alias for MolecularPropertyDerivative()
Superclass of all the representations types.
Attributes : |
|
---|
Make a copy of self that is the same in every way except for the molecule attribute. New Coordinate objects are created using the Coordinate.copy_for_representation() method for each element of self.coords. This is an abstract method that must be implemented by all Representation subclasses.
Apply the Displacement instance disp to the molecule and current representation, generating a new molecule and a new representation (which start as a deepcopy and the return value of Representation.copy_with_molecule, respectively) with the displacement applied. This is an abstract method that must be implemented by all Representation subclasses.
Alias for values_for_matrix()
Alias for values_for_molecule()
Aliased as value_for_matrix()
Aliased as value_for_molecule()
A property whose value is dependent on a given representation of the molecule.
Abstract base class for classes that run a computation (or an equivalent task, such as submit a job to a PBS queue). Not all Computation objects need a runner; for instance XML-parsed computations are constructed in an already-run state.
Run in a blocking manner. Default implementation calls wait() on the process returned by start(). Overload it if this doesn’t make sense.
Determine if we will be able to run. Raise a ComputationUnavailableError if running will cause a crash
A property whose value is a scalar
By default, just get the last group matched.
Create and return a temporary file. Arguments: ‘prefix’, ‘suffix’, ‘dir’ – as for mkstemp. ‘mode’ – the mode argument to os.fdopen (default “w+b”). ‘bufsize’ – the buffer size argument to os.fdopen (default -1). The file is created as mkstemp() would do it.
Returns an object with a file-like interface. The file has no name, and will cease to exist when it is closed.
Mostly a wrapper for the NumPy ndarray class. This gives us a place to put tensor-related functionality that we need but is not available in NumPy.
Copy all properties of the tensor except for the data.
Same as numpy.ndarray.flatten, but modified to return a Vector object
Examples : |
---|
>>> t = Tensor([[[1,2],[3,4]],[[5,6],[7,8]]])
>>> t
Tensor([[[ 1., 2.],
[ 3., 4.]],
[[ 5., 6.],
[ 7., 8.]]])
>>> t.flatten()
Vector([ 1., 2., 3., ..., 6., 7., 8.])
List of pointers to IndexRange objects over which the tensor is defined.
Returns True if all elements of self have absolute values less than cutoff, which defaults to Tensor.zero_cutoff
Note
Tensor.zero_cutoff is treated as a pseudo-class attribute for Tensor instances, meaning individual instances can also set a zero_cutoff attribute which will take precidence over the class-level default.
Given any number of Tensor objects that are the same up to a phase factor, return a list of Tensor objects that have been. Copies are only made if necessary. The chosen phase is the one that makes the first non-zero element (in the numpy.nditer(tensor) iterator, using the cutoff keyword argument or Tensor.zero_cutoff if one is not given) positive.
Allows conformance with the Unitized protocol.
A property whose value is an n-dimensional tensor
Abstract base class for things with units. It requires its subclasses to implement the properties ‘value’ and ‘units’. Unitized subclasses are also expected have __mul__, __div__, __truediv__, __pow__, __add__, __sub__, __neg__, __pos__, and __abs__ handle units correctly, when implemented in the given subclass.
Raised when a MolecularProperty is requested but not available for whatever reason.
A class for encapsulating a physical constant and it’s units.
Attributes : |
---|
A property whose value is a vector.
A decorator indicating abstract methods.
Requires that the metaclass is ABCMeta or derived from it. A class that has a metaclass derived from ABCMeta cannot be instantiated unless all of its abstract methods are overridden. The abstract methods can be called using any of the normal ‘super’ call mechanisms.
Usage:
- class C:
__metaclass__ = ABCMeta @abstractmethod def my_abstract_method(self, ...):
...
Execute code with a lock acquired before the block of code and released afterwards
Convenience method for getting the typename as a string from the <type ‘Something’> string sent back by str(type(obj))
Alias a function as something else. Set the documentation of the new method to “Alias for <function>()” and add “Aliased as <alias>()” to the documentation of function. Not inteded to be used as a decorator.
Examples : |
---|
>>> def foo(a, b, c):
... '''Print a test message.'''
... print "testing {0}, {1}, {2}".format(a, b, c)
...
>>> foo(1, 2, 3)
testing 1, 2, 3
>>> bar = function_alias('bar', foo)
>>> bar(4, 5, 6)
testing 4, 5, 6
>>> print bar.__doc__
Alias for `foo()`
>>> print foo.__doc__
Print a test message.
Aliased as `bar()`
>>> baz = function_alias('baz', foo)
>>> baz(7, 8, 9)
testing 7, 8, 9
>>> print foo.__doc__
Print a test message.
Aliased as `baz()`, `bar()`
Inside a class
>>> class FooBar(object):
... def testfunc(self, *args):
... '''Print out the args.'''
... print "testing " + ', '.join(str(a) for a in args)
... another_name = function_alias('another_name', testfunc)
... test_func = function_alias('test_func', testfunc)
...
>>> f = FooBar()
>>> f.test_func(1, 2, 3, 4)
testing 1, 2, 3, 4
>>> print FooBar.test_func.__doc__
Alias for `testfunc()`
>>> print FooBar.testfunc.__doc__
Print out the args.
Aliased as `test_func()`, `another_name()`
group(3, ‘ABCDEFG’, ‘x’) –> ABC DEF Gxx
Alias for has_units()
Alias for indented()
islice(iterable, [start,] stop [, step]) –> islice object
Return an iterator whose next() method returns selected values from an iterable. If start is specified, will skip all preceding elements; otherwise, start defaults to zero. Step defaults to one. If specified as another value, step determines how many values are skipped between successive calls. Works like a slice() on a list but returns an iterator.
x.next() -> the next value, or raise StopIteration
Aliased as is_unit()
partial(func, *args, **keywords) - new function with partial application of the given arguments and keywords.
tuple of arguments to future partial calls
function object to use in future partial calls
dictionary of keyword arguments to future partial calls
Utility function for getting the value of a keyword argument that can be named multiple things and popping that value off of the kwarg dictionary. If the None of the keywords given are found in kwarg_dict, None is returned.
See Also: |
---|
get_multikwarg
Returns True if a call of callable with args raises an error, and False if not. Note that the callable will get called, so don’t do anything that takes a long time or changes things in a way you don’t want them to be changed. If the optional keyword argument ‘error’ is given as either an Exception subclass or an Iterable, raises_error returns True if the call of callable raises the error given or one of the errors given in the list. (The keyword argument can also be named ‘errors’). Any other keyword arguments are passed through to callable.
Technical note: As per the Python manual, only exceptions that subclass from Exception (and not BaseException directly) will be recognized. According to the python users manual, you should never implement a user exception that subclasses from BaseException directly.
Examples : |
---|
>>> raises_error(int, "5")
False
>>> raises_error(int, "0x5ab7", 0)
False
>>> raises_error(lambda x: int(x), "5")
False
>>> raises_error(int, "abc")
True
>>> raises_error(int, "abc", error = ValueError)
True
>>> raises_error(int, "abc", error = BufferError)
False
>>> raises_error(int, "abc", error = (BufferError, EnvironmentError))
False
>>> raises_error(int, "abc", error = [BufferError, ValueError])
True
>>> raises_error(float, "abc")
True
>>> # Use raises_error to see what errors raises_error raises
... # Raise a type error if the first argument is not a callable (i.e. 17(25) doesn't make sense to Python)
... raises_error(raises_error, 17, 25, error = TypeError)
True
>>> # Raise a TypeError if the error keyword argument is not a subclass of Exception
... raises_error(lambda x: raises_error(int, x, error = "hello world"), 25, error = TypeError)
True
>>> raises_error(lambda x: raises_error(int, x, error = BaseException), 25, error = TypeError)
True
Type checking for functions and methods.
Issue a warning, or maybe ignore it or raise an exception.
Decorator allowing the assignment of attributes to a function.
Allows the creation of functions with case insensative, alternately named keyword arguments.
Examples : |
---|
>>> @with_flexible_arguments(
... required=[
... ('name', 'greet', 'name_to_greet'),
... ('from_where', 'source')
... ],
... optional=[
... ('greeting', 'hello_phrase', 'salutation'),
... ('message',)
... ]
... )
... def say_hello(name, from_where, greeting='Hello', message=''):
... print(greeting + ', ' + name + ', from ' + from_where + '!' + message)
...
>>> say_hello('moon', 'Earth')
Hello, moon, from Earth!
>>> say_hello('world', source='the moon')
Hello, world, from the moon!
>>> say_hello(source='France', name_to_greet='visitor', salutation='Bonjour')
Bonjour, visitor, from France!
>>> say_hello('earthlings', 'outer space', 'Greetings', message=' We come in peace!')
Greetings, earthlings, from outer space! We come in peace!
Change to a certain working directory for the execution of a block of code, then change back upon (any kind of) exit.
Encapsulates specifics about how the calculation was/is to be carried out, such as level of theory, basis set, program, etc. Can be subclassed for specific programs which may require special detail setting methods.
Effectively clones details. Used internally for making a details into a ComputationDetails subclass
Mostly for use by templates, this method returns a string of keyword-value pairs in using the given format for each argument in the argument list. format should use the str.format() protocol from the python standard library with the named slots {key} where the keyword name should go and {value} where the value of the detail should go (or, if the value of the detail is a Keyword object, the contents of the value attribute for that Keyword, or, if the value attribute for the keyword is not defined, the _name attribute for the Keyword object in question.
Aliased as keywordify
Mostly for use by templates, this method returns a string of keyword-value pairs in using the given format for each argument in the argument list. format should use the str.format() protocol from the python standard library with the named slots {key} where the keyword name should go and {value} where the value of the detail should go (or, if the value of the detail is a Keyword object, the contents of the value attribute for that Keyword, or, if the value attribute for the keyword is not defined, the _name attribute for the Keyword object in question.
Aliased as keywordify
Simple container for keyword-like objects (“sentinal values”). Can also be used as a container for sub-keywords via instance objects. Sub-keywords are case-insensative. Keywords cannot be assigned values using the value attribute (note that this means you can’t create a sub-keyword called ‘value’).
Warning
Since there is exactly one instance of every unique keyword (with two keywords that differ by capitalization not being unique), storing a value can have some unexpected consequences. For instance:
>>> Hello = Keyword('Hello')
>>> foo = Hello.World
>>> foo.value = "good bye"
>>> # ...some time later...
>>> Hello.WORLD.value = "good night"
>>> foo.value
'good night'
Note
Since value, parent, _parent, parents, _name, and any of the double-underscore methods inherited from object are already attributes of Keyword objects, you can’t make sub-keywords with these names. Everything else is fair game.
Examples : |
---|
>>> Hello = Keyword('Hello')
>>> Hello.World
Hello.World
>>> # Any future changes in case simply refer back to the original
>>> Hello.WoRlD
Hello.World
>>> # But, of course, not for the first level
>>> hEllO.World
Traceback (most recent call last):
...
NameError: name 'hEllO' is not defined
>>> # Multiple levels can be created at once
>>> Hello.there.world
Hello.there.world
>>> Hello.there == Hello.ThErE
True
>>> Hello.there == Hello.ThErE.world
False
>>> Hello.there.WORLD == Hello.ThErE.world
True
>>> Hello.There.World.value = "Hello World"
>>> Hello.THERE.WORLD.value
'Hello World'
Simple container for keyword-like objects (“sentinal values”). Can also be used as a container for sub-keywords via instance objects. Sub-keywords are case-insensative. Keywords cannot be assigned values using the value attribute (note that this means you can’t create a sub-keyword called ‘value’).
Warning
Since there is exactly one instance of every unique keyword (with two keywords that differ by capitalization not being unique), storing a value can have some unexpected consequences. For instance:
>>> Hello = Keyword('Hello')
>>> foo = Hello.World
>>> foo.value = "good bye"
>>> # ...some time later...
>>> Hello.WORLD.value = "good night"
>>> foo.value
'good night'
Note
Since value, parent, _parent, parents, _name, and any of the double-underscore methods inherited from object are already attributes of Keyword objects, you can’t make sub-keywords with these names. Everything else is fair game.
Examples : |
---|
>>> Hello = Keyword('Hello')
>>> Hello.World
Hello.World
>>> # Any future changes in case simply refer back to the original
>>> Hello.WoRlD
Hello.World
>>> # But, of course, not for the first level
>>> hEllO.World
Traceback (most recent call last):
...
NameError: name 'hEllO' is not defined
>>> # Multiple levels can be created at once
>>> Hello.there.world
Hello.there.world
>>> Hello.there == Hello.ThErE
True
>>> Hello.there == Hello.ThErE.world
False
>>> Hello.there.WORLD == Hello.ThErE.world
True
>>> Hello.There.World.value = "Hello World"
>>> Hello.THERE.WORLD.value
'Hello World'
Simple container for keyword-like objects (“sentinal values”). Can also be used as a container for sub-keywords via instance objects. Sub-keywords are case-insensative. Keywords cannot be assigned values using the value attribute (note that this means you can’t create a sub-keyword called ‘value’).
Warning
Since there is exactly one instance of every unique keyword (with two keywords that differ by capitalization not being unique), storing a value can have some unexpected consequences. For instance:
>>> Hello = Keyword('Hello')
>>> foo = Hello.World
>>> foo.value = "good bye"
>>> # ...some time later...
>>> Hello.WORLD.value = "good night"
>>> foo.value
'good night'
Note
Since value, parent, _parent, parents, _name, and any of the double-underscore methods inherited from object are already attributes of Keyword objects, you can’t make sub-keywords with these names. Everything else is fair game.
Examples : |
---|
>>> Hello = Keyword('Hello')
>>> Hello.World
Hello.World
>>> # Any future changes in case simply refer back to the original
>>> Hello.WoRlD
Hello.World
>>> # But, of course, not for the first level
>>> hEllO.World
Traceback (most recent call last):
...
NameError: name 'hEllO' is not defined
>>> # Multiple levels can be created at once
>>> Hello.there.world
Hello.there.world
>>> Hello.there == Hello.ThErE
True
>>> Hello.there == Hello.ThErE.world
False
>>> Hello.there.WORLD == Hello.ThErE.world
True
>>> Hello.There.World.value = "Hello World"
>>> Hello.THERE.WORLD.value
'Hello World'
Metaclass for defining Abstract Base Classes (ABCs).
Use this metaclass to create an ABC. An ABC can be subclassed directly, and then acts as a mix-in class. You can also register unrelated concrete classes (even built-in classes) and unrelated ABCs as ‘virtual subclasses’ – these and their descendants will be considered subclasses of the registering ABC by the built-in issubclass() function, but the registering ABC won’t show up in their MRO (Method Resolution Order) nor will method implementations defined by the registering ABC be callable (not even via super()).
Register a virtual subclass of an ABC.
Base class for all classes encapsulating runs of external programs
Checks to see if an identical input file with an identical name has already been run in the computation’s directory to produce an output file of some sort (if that output file has errors, you probably don’t want to rerun the exact same input file, so this doesn’t do that by default. If you need to do that, call Computation.run() with the force_rerun argument set to True).
True if and only if the calculation has finished running. (regardless of success or failure). Setting completed to True triggers the output parser.
The types of the properties in the self.properties list.
Convert strings to standard form for attributes. Strings with spaces, underscore_joined_strings, Uppercase_Underscore_Strings, and lowerCamelCase strings are all converted to UpperCamelCase.
Examples : |
---|
>>> Computation.standardize_attribute("basis_set")
'BasisSet'
>>> Computation.standardize_attribute("basis set")
'BasisSet'
>>> Computation.standardize_attribute("basis!Set")
'BasisSet'
>>> # Only _ and space serve as CamelCase separators:
>>> Computation.standardize_attribute("basis!set")
'Basisset'
>>> Computation.standardize_attribute("Level___of!*theory")
'LevelOftheory'
>>> # "Accidental" caps are not fixed...
>>> Computation.standardize_attribute("Level___of!*tHEory")
'LevelOftHEory'
>>> #All caps gets translated into title case
>>> Computation.standardize_attribute("Level&$#of__THEORY")
'LevelofTheory'
Alias for can_get_property_for_molecule()
Aliased as has_property(), can_get_property()
Alias for can_get_property_for_molecule()
Raised when a computation can’t be generated either because a compatible input template can’t be found or a valid output parser can’t be found
Abstract base class for all properties
Attributes : |
---|
molecule : Molecule units : CompositeUnit or class with Unit metaclass
Retrieve the value of the property from a tuple of groups matched in a RegexSequence. See RegexSequence.groups()
Retrieve the value of the property from a RegexSequence object that has already been used on a file. By default, this just calls self.from_groups() with seq.groups(flatten) where flatten comes from self.from_groups.flatten.
The new paradigm for obtaining values. Call the callable instance attribute getter with the arguments and keyword arguments passed in.
The value of the molecular property.
Abstract base class for all classes that encapsulate a method of retrieving a (set of) properties of a molecule from a computational chemistry package. An instance of a ResultGetter object should know how to turn a request for a given molecular property into a Computation object (which, in turn, houses MolecularProperty objects for one or more Molecule objects). ResultGetter objects generate Computation objects. Any ResultGetter subclass should always check for an available computation on (exactly) the same molecule that already has the result available.
A decorator indicating abstract methods.
Requires that the metaclass is ABCMeta or derived from it. A class that has a metaclass derived from ABCMeta cannot be instantiated unless all of its abstract methods are overridden. The abstract methods can be called using any of the normal ‘super’ call mechanisms.
Usage:
- class C:
__metaclass__ = ABCMeta @abstractmethod def my_abstract_method(self, ...):
...
Shallow copy operation on arbitrary Python objects.
See the module’s __doc__ string for more info.
Alias a function as something else. Set the documentation of the new method to “Alias for <function>()” and add “Aliased as <alias>()” to the documentation of function. Not inteded to be used as a decorator.
Examples : |
---|
>>> def foo(a, b, c):
... '''Print a test message.'''
... print "testing {0}, {1}, {2}".format(a, b, c)
...
>>> foo(1, 2, 3)
testing 1, 2, 3
>>> bar = function_alias('bar', foo)
>>> bar(4, 5, 6)
testing 4, 5, 6
>>> print bar.__doc__
Alias for `foo()`
>>> print foo.__doc__
Print a test message.
Aliased as `bar()`
>>> baz = function_alias('baz', foo)
>>> baz(7, 8, 9)
testing 7, 8, 9
>>> print foo.__doc__
Print a test message.
Aliased as `baz()`, `bar()`
Inside a class
>>> class FooBar(object):
... def testfunc(self, *args):
... '''Print out the args.'''
... print "testing " + ', '.join(str(a) for a in args)
... another_name = function_alias('another_name', testfunc)
... test_func = function_alias('test_func', testfunc)
...
>>> f = FooBar()
>>> f.test_func(1, 2, 3, 4)
testing 1, 2, 3, 4
>>> print FooBar.test_func.__doc__
Alias for `testfunc()`
>>> print FooBar.testfunc.__doc__
Print out the args.
Aliased as `test_func()`, `another_name()`
Metaclass for defining Abstract Base Classes (ABCs).
Use this metaclass to create an ABC. An ABC can be subclassed directly, and then acts as a mix-in class. You can also register unrelated concrete classes (even built-in classes) and unrelated ABCs as ‘virtual subclasses’ – these and their descendants will be considered subclasses of the registering ABC by the built-in issubclass() function, but the registering ABC won’t show up in their MRO (Method Resolution Order) nor will method implementations defined by the registering ABC be callable (not even via super()).
Register a virtual subclass of an ABC.
Encapsulates specifics about how the calculation was/is to be carried out, such as level of theory, basis set, program, etc. Can be subclassed for specific programs which may require special detail setting methods.
Effectively clones details. Used internally for making a details into a ComputationDetails subclass
Mostly for use by templates, this method returns a string of keyword-value pairs in using the given format for each argument in the argument list. format should use the str.format() protocol from the python standard library with the named slots {key} where the keyword name should go and {value} where the value of the detail should go (or, if the value of the detail is a Keyword object, the contents of the value attribute for that Keyword, or, if the value attribute for the keyword is not defined, the _name attribute for the Keyword object in question.
Aliased as keywordify
Mostly for use by templates, this method returns a string of keyword-value pairs in using the given format for each argument in the argument list. format should use the str.format() protocol from the python standard library with the named slots {key} where the keyword name should go and {value} where the value of the detail should go (or, if the value of the detail is a Keyword object, the contents of the value attribute for that Keyword, or, if the value attribute for the keyword is not defined, the _name attribute for the Keyword object in question.
Aliased as keywordify
Raised when a computation can’t be generated either because a compatible input template can’t be found or a valid output parser can’t be found
Superclass for classes that are compatible with specific ComputationDetail objects or any ComputationDetail object more specifically specifice than the details variable.
Abstract base class for things that you are allowed to take derivatives of.
The value of the differentiable property. If this function is not overridden, assume that self can be added and subtracted, as well as multiplied by a float.
General superclass for all distance units
alias of Angstrom
alias of Angstrom
The energy of a molecule.
alias of Wavenumber
General superclass for all energy units
alias of Wavenumber
alias of Joule
Exception for attempted incompatible unit conversions
Abstract base class for classes that generate input files.
Determine if we will be able to generate an input.
A collection of convenience methods for generating InputGenerator classes
Simple container for keyword-like objects (“sentinal values”). Can also be used as a container for sub-keywords via instance objects. Sub-keywords are case-insensative. Keywords cannot be assigned values using the value attribute (note that this means you can’t create a sub-keyword called ‘value’).
Warning
Since there is exactly one instance of every unique keyword (with two keywords that differ by capitalization not being unique), storing a value can have some unexpected consequences. For instance:
>>> Hello = Keyword('Hello')
>>> foo = Hello.World
>>> foo.value = "good bye"
>>> # ...some time later...
>>> Hello.WORLD.value = "good night"
>>> foo.value
'good night'
Note
Since value, parent, _parent, parents, _name, and any of the double-underscore methods inherited from object are already attributes of Keyword objects, you can’t make sub-keywords with these names. Everything else is fair game.
Examples : |
---|
>>> Hello = Keyword('Hello')
>>> Hello.World
Hello.World
>>> # Any future changes in case simply refer back to the original
>>> Hello.WoRlD
Hello.World
>>> # But, of course, not for the first level
>>> hEllO.World
Traceback (most recent call last):
...
NameError: name 'hEllO' is not defined
>>> # Multiple levels can be created at once
>>> Hello.there.world
Hello.there.world
>>> Hello.there == Hello.ThErE
True
>>> Hello.there == Hello.ThErE.world
False
>>> Hello.there.WORLD == Hello.ThErE.world
True
>>> Hello.There.World.value = "Hello World"
>>> Hello.THERE.WORLD.value
'Hello World'
The keyword immediately preceding self in the heirarchical keyword notation. For instance:
>>> Hello = Keyword('Hello')
>>> Hello.World.parent
Hello
>>> Hello.There.World.parent
Hello.There
list of all parent keywords, ordered from immediate parent to most distant
A property whose value is a matrix.
Placeholder implementation to satisfy abstract class requirements. Everything is already taken care of in MatrixProperty.from_sequence
Default implementation for matrix properties; only works if seq is a MatrixRegexSequence
Special subclass of RegexSequence that make parsing matrices easier.
Abstract base class for all properties
Attributes : |
---|
molecule : Molecule units : CompositeUnit or class with Unit metaclass
Retrieve the value of the property from a tuple of groups matched in a RegexSequence. See RegexSequence.groups()
Retrieve the value of the property from a RegexSequence object that has already been used on a file. By default, this just calls self.from_groups() with seq.groups(flatten) where flatten comes from self.from_groups.flatten.
The new paradigm for obtaining values. Call the callable instance attribute getter with the arguments and keyword arguments passed in.
The value of the molecular property.
Encapsulates all of the functionality and attributes of a Molecule itself.
Signatures : |
|
---|---|
Parameters : |
Other Parameters: | |
---|---|
Attributes : |
---|
atoms : list of Atom internal_representations : list of InternalRepresentation normal_representation : NormalRepresentation cartesian_representation : CartesianRepresentation description : str
Examples : |
---|
Constructor
>>> Molecule("""
... 5
...
... C 0.000000 0.000000 0.000000
... H 0.000000 0.000000 1.089000
... H 1.026719 0.000000 -0.363000
... H -0.513360 -0.889165 -0.363000
... H -0.513360 0.889165 -0.363000
... """)
Molecule([
Atom('C', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('H', [ 0.00000000, 0.00000000, 1.08900000 ] ),
Atom('H', [ 1.02671900, 0.00000000, -0.36300000 ] ),
Atom('H', [ -0.51336000, -0.88916500, -0.36300000 ] ),
Atom('H', [ -0.51336000, 0.88916500, -0.36300000 ] )
])
>>> Molecule([
... Atom('H', [0,0,0]),
... Atom('H', [0,0,0.75])
... ])
Molecule([
Atom('H', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('H', [ 0.00000000, 0.00000000, 0.75000000 ] )
])
>>> Molecule(['H','C'], Matrix([[0,0,0],[1,0.5,0]]))
Molecule([
Atom('H', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('C', [ 1.00000000, 0.50000000, 0.00000000 ] )
])
>>> mol = Molecule("""
... 5
...
... C 0.000000 0.000000 0.000000
... H 0.000000 0.000000 1.089000
... H 1.026719 0.000000 -0.363000
... H -0.513360 -0.889165 -0.363000
... H -0.513360 0.889165 -0.363000
... """)
>>> mol
Molecule([
Atom('C', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('H', [ 0.00000000, 0.00000000, 1.08900000 ] ),
Atom('H', [ 1.02671900, 0.00000000, -0.36300000 ] ),
Atom('H', [ -0.51336000, -0.88916500, -0.36300000 ] ),
Atom('H', [ -0.51336000, 0.88916500, -0.36300000 ] )
])
Iteration
>>> from __future__ import print_function
>>> for atom in mol:
... print(repr(atom))
...
Atom('C', [ 0.00000000, 0.00000000, 0.00000000 ] )
Atom('H', [ 0.00000000, 0.00000000, 1.08900000 ] )
Atom('H', [ 1.02671900, 0.00000000, -0.36300000 ] )
Atom('H', [ -0.51336000, -0.88916500, -0.36300000 ] )
Atom('H', [ -0.51336000, 0.88916500, -0.36300000 ] )
The first principal axis of rotation, a. The positive phase is always chosen.
Note
This property depends directly on Molecule.principal_axes(), which is cached. See discussion of caching in A_e
The second principal axis of rotation, b. The positive phase is always chosen.
Note
This property depends directly on Molecule.principal_axes(), which is cached. See discussion of caching in A_e
The third principal axis of rotation, c. The positive phase is always chosen.
Note
This property depends directly on Molecule.principal_axes(), which is cached. See discussion of caching in A_e
The current default cartesian representation associated with the molecule. If the molecule has multiple cartesian representations, the first in the list self.cartesian_representations is returned. The setter for this property pushes the cartesian representation onto the front of the list.
Note
The setter does not check for uniqueness (unless it’s exactly the same object as another CartesianRepresentation). Thus, you should check to make sure the CartesianRepresentation you are assigning to the molecule is not already part of the molecule’s list of representations (to the degree of accuracy required for your particular application) before assigning. Repeatedly failing to do this check could cause runaway memory usage.
Returns a Vector giving the center of mass of the molecule in the current Cartesian representation. The units of the returned value are self.cartesian_units.
Note
This result of this method is cached, and the cached value gets flushed in update_cartesian_representation(). If you change an atom’s position (or mass) and forget to call update_cartesian_representation(), you may get some funny results for this method or any methods that depend on it, including recenter(), reorient(), and principal_moments_of_inertia(). You can detect whether caching is causing problems by setting the environment variable GRENDEL_NO_CACHE to 1 and rerunning your tests. If tests that were failing subsequently succeed, you probably forgot to call update_cartesian_representation() somewhere, or you were assuming that it was automatically called somewhere when in fact it was not getting called.
Create a Molecule object using only the name, SMILES, InChIKey, etc.
The easiest way to call Molecule.from_identifier() is to give it a single argument that is one of the following properties: * smiles * stdinchikey * stdinchi * ncicadd_identifier # (for FICTS, FICuS, uuuuu) * hashisy * cas_number * chemspider_id # input must be chemspider_id=1234567 * opsin_name * cir_name (These are resolved in roughly this order.) Visit the NIH CIR documentation for (some) explaination of what these identifiers are: http://cactus.nci.nih.gov/chemical/structure/documentation
Molecule.from_identifier() can be called with any (single) keyword argument in the grendel.util.web_getter.input_identifiers list. In this form, there must be only
This can also be called using an argument that is the value of a property and a second argument that is a list of fields to search for that property in.
Note: Molecule.get() is a very useful alias for this.
Examples : |
---|
TODO
TODO Document this more
Examples : |
---|
>>> Molecule.from_z_matrix("""
... O
... H1 O 1.0
... H2 O 1.0 H1 90.0
... """)
Molecule([
Atom('O', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('H', [ 0.00000000, 0.00000000, 1.00000000 ] ),
Atom('H', [ 0.00000000, -1.00000000, -0.00000000 ] )
])
>>> Molecule.from_z_matrix(
... [
... ['H'],
... ['O', 1, 0.9],
... ['O', 2, 1.4, 1, 105.0],
... ['H', 3, 0.9, 2, 105.0, 1, 120.0]
... ]
... )
Molecule([
Atom('H', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('O', [ 0.00000000, 0.00000000, 0.90000000 ] ),
Atom('O', [ 0.00000000, 1.35229616, 1.26234666 ] ),
Atom('H', [ -0.75286467, 1.46479616, 1.74249095 ] )
])
>>> Molecule.from_z_matrix(
... ['H'],
... ['O', 1, 0.9]
... )
Molecule([
Atom('H', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('O', [ 0.00000000, 0.00000000, 0.90000000 ] )
])
@param string: String containing a z-matrix with labels defined at the end using e.g. a234=8.5 @param args: Passed on to Molecule.from_z_matrix @param kwargs: Passed on to Molecule.from_z_matrix @return: Molecule object corresponding to the z-matrix passed in
Return a list of geometrically separated moieties of the molecule. Note: sub-molecules returned will have charge 0 and multiplicity 1 for now
@param n_vdw_radii: How many Van der Waals radii two atoms may be separated by and still be considered bonded @param default_vdw_radius: Van der Waals radius to use for elements that grendel doesn’t know the VDW radius of. @return: list of moieties as Molecule objects.
Create a Molecule object using only the name, SMILES, InChIKey, etc.
The easiest way to call Molecule.from_identifier() is to give it a single argument that is one of the following properties: * smiles * stdinchikey * stdinchi * ncicadd_identifier # (for FICTS, FICuS, uuuuu) * hashisy * cas_number * chemspider_id # input must be chemspider_id=1234567 * opsin_name * cir_name (These are resolved in roughly this order.) Visit the NIH CIR documentation for (some) explaination of what these identifiers are: http://cactus.nci.nih.gov/chemical/structure/documentation
Molecule.from_identifier() can be called with any (single) keyword argument in the grendel.util.web_getter.input_identifiers list. In this form, there must be only
This can also be called using an argument that is the value of a property and a second argument that is a list of fields to search for that property in.
Note: Molecule.get() is a very useful alias for this.
Examples : |
---|
TODO
Returns True if the elements of self correspond directly to the elements of other (i.e. self.atoms[0].element == other.atoms[0].element and self.atoms[1].element == other.atoms[1].element and ...)
Returns True if all of the elements are the same (including isotope and nuclear spin) and the reoriented() versions of self and other have no atoms whose pairwise position difference has a magnitude greater than tol (which defaults to 1e-8 Angstroms)
Examples : |
---|
>>> mol = Molecule('''
... O 1.5 0.0 0.0
... H 0.2 0.0 0.0
... ''')
>>> m1 = Molecule('''
... O 0.0 1.5 0.0
... H 0.0 0.2 0.0
... ''')
>>> m2 = Molecule('''
... O 0.00000 0.00000 0.200000
... H 0.00000 0.00000 1.500001
... ''')
>>> m3 = Molecule('''
... H 0.0 0.0 0.0
... H 0.0 -1.3 0.0
... ''')
>>> mol.has_same_geometry(m1)
True
>>> m1.has_same_geometry(m2)
False
>>> m1.has_same_geometry(m2, 1e-5)
True
>>> m2.has_same_geometry(mol, 1e-5)
True
>>> m1.has_same_geometry(m3)
False
True if op is a valid symmetry operation on self Each coordinate of the transformed atoms must differ from the original by less than
Returns the index of atom in the atoms array of the molecule
Note
This method returns a cached property Atom.index. If you reorder the atoms in a molecule, be sure and flush this cache by setting atom._index to None for all of the atoms in the reordered molecule.
Raises : |
---|
IndexError : if atom is not found in self
Examples : |
---|
>>> from grendel.chemistry import SampleMolecules, init_sample_molecules
>>> init_sample_molecules()
>>> h2o = SampleMolecules['water']
>>> atom1 = h2o[0]
>>> atom2 = h2o[1]
>>> atom3 = h2o[2]
>>> h2o
Molecule([
Atom('O', [ 0.00000000, 0.00000000, 0.11815400 ] ),
Atom('H', [ 0.00000000, 0.75873400, -0.47261400 ] ),
Atom('H', [ 0.00000000, -0.75873400, -0.47261400 ] )
])
>>> h2o.index(atom2)
1
>>> h2o.index(atom1)
0
>>> # It must be exactly the same instance to avoid raising an index error
>>> h2o.index(Atom('O', [ 0.00000000, 0.00000000, 0.11815400 ] ))
Traceback (most recent call last):
...
IndexError: ...
Returns a tuple of the principal moments of inertia vector and the principal axes matrix.
mol.inertial_system()
Computes the principal moments of inertia and the principal axes.
Note
This funtion mol.recenter() if the molecule is not centered, so any CartesianRepresentations that are not both frozen and referenced elsewhere (e.g. in a RepresentationDependentProperty) will be lost forever.
Note
This method is cached. See discussion of the consequences of caching in Molecule.center_of_mass()
Returns : |
---|
A tuple with types (Vector, Matrix) containing the principal moments of inertia and the principal axes, respectively. These should be aligned (i.e. ret_val[0][1] corresponds to the vector ret_val[1][1])
Examples : |
---|
>>> hnco = Molecule.from_z_matrix("""
... N
... C N 1.2145
... O C 1.1634 N 172.22
... H N 1.0030 C 123.34 O 180.0
... """
... )
>>> i = hnco.inertial_system()
>>> i[0]
Vector([ 0.60187342, 45.48378728, 46.0856607 ])
>>> i[1]
Matrix([[ 0. , 0. , 1. ],
[ 0.09870438, -0.9951168 , 0. ],
[ 0.9951168 , 0.09870438, 0. ]])
>>> j = hnco.inertial_system()
>>> i == j
True
>>> hnco.A_e
28.0085955528 Wavenumber
>>> hnco.B_e
0.370629408869 Wavenumber
>>> hnco.C_e
0.365789031483 Wavenumber
>>> hnco.a
Vector([ 0. , 0.09870438, 0.9951168 ])
>>> hnco.b
Vector([ 0. , -0.9951168 , 0.09870438])
>>> hnco.c
Vector([ 1., 0., 0.])
The first internal representations (of type InternalRepresentation), or None if it does not exist yet.
True if the center of mass is at the origin. This actually computes the vector from the origin to the center of mass and then determines if the magnitude of that vector is less than tol.
Parameters : |
---|
True if the molecule is linear to within tol. All diatomics should return True.
If tol is a ValueWithUnits and tol.units is an AngularUnit, then this method returns True only if all angles in the molecule are within tol of 180 Degrees. If tol.units is a unit-compatible with a moment of inertia (i.e. MassUnit * DistanceUnit**2 ), then this method returns True if the smallest principal moment of inertia is less than tol and the difference between the two largest principal moments of inertia is less than tol. If no units are given (i.e. tol is a float or other float-compatible unit), tol is assumed to have units of AngularUnit.default and the method proceeds as if tol.units was an AngularUnit subclass.
Parameters : |
---|
Examples : |
---|
>>> from grendel.chemistry import SampleMolecules, init_sample_molecules
>>> init_sample_molecules()
>>> SampleMolecules['water'].is_linear()
False
>>> SampleMolecules['CO2'].is_linear()
True
>>> SampleMolecules['Benzene'].is_linear()
False
The principal moments of inertia, as a Vector
Note
This funtion mol.recenter() if the molecule is not centered, so any CartesianRepresentations that are not both frozen and referenced elsewhere (e.g. in a RepresentationDependentProperty) will be lost forever.
Note
This method is cached. See discussion of the consequences of caching in Molecule.center_of_mass()
Examples: >>> hnco = Molecule.from_z_matrix(""" ... N ... C N 1.2145 ... O C 1.1634 N 172.22 ... H N 1.0030 C 123.34 O 180.0 ... """ ... ) >>> hnco.principal_moments_of_inertia() Vector([ 0.60187342, 45.48378728, 46.0856607 ]) >>> hnco.pmi() Vector([ 0.60187342, 45.48378728, 46.0856607 ])
See Also: principal_axes, inertial_system, A_e, B_e, C_e
Aliased as principal_moments_of_inertia()
The molecule’s position as a natoms x 3 Matrix. The ordering of rows is (as expected) the same as the ordering of the Molecule.atoms list attribute. Aliased to xyz_mat and position (the latter to be “consistant-ish” with the naming in Atom.
The principal axes as column vectors in a Matrix. The Vector object mol.principal_axes()[:,i] corresponds to the i`th moment of inertia, `mol.principal_moments_of_inertia()[i].
mol.principal_axes()
Note
This funtion mol.recenter() if the molecule is not centered, so any CartesianRepresentations that are not both frozen and referenced elsewhere (e.g. in a RepresentationDependentProperty) will be lost forever.
Note
This method is cached. See discussion of the consequences of caching in Molecule.center_of_mass()
Examples : |
---|
>>> hnco = Molecule.from_z_matrix("""
... N
... C N 1.2145
... O C 1.1634 N 172.22
... H N 1.0030 C 123.34 O 180.0
... """
... )
>>> hnco.principal_axes()
Matrix([[ 0. , 0. , 1. ],
[ 0.09870438, -0.9951168 , 0. ],
[ 0.9951168 , 0.09870438, 0. ]])
See Also: |
---|
principal_moments_of_inertia, inertial_system, A_e, B_e, C_e
Alias for pmi()
Recenters the molecule about the center of mass This modifies the molecule in place.
Examples : |
---|
>>> m = Molecule([Atom("O", [1.1, 1.3, 1.7])])
>>> m
Molecule([
Atom('O', [ 1.10000000, 1.30000000, 1.70000000 ] )
])
>>> m.recenter()
>>> m
Molecule([
Atom('O', [ 0.00000000, 0.00000000, 0.00000000 ] )
])
>>> m = Molecule(['H','H'], Matrix([[0,0,0],[1,0.0,0]]))
>>> m
Molecule([
Atom('H', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('H', [ 1.00000000, 0.00000000, 0.00000000 ] )
])
>>> m.recenter()
>>> m
Molecule([
Atom('H', [ -0.50000000, 0.00000000, 0.00000000 ] ),
Atom('H', [ 0.50000000, 0.00000000, 0.00000000 ] )
])
Same as recenter, but makes returns a copy. self is not modified.
Examples : |
---|
>>> foo = Molecule([Atom("O", [1.3, 1.7, 2.0])])
>>> bar = foo.recentered()
>>> foo.recenter()
>>> foo
Molecule([
Atom('O', [ 0.00000000, 0.00000000, 0.00000000 ] )
])
>>> foo == bar
True
>>> foo is bar
False
Reorient the molecule to align the x, y, and z axes with the principal axes of rotation.
Parameters : |
---|
Examples : |
---|
>>> from grendel.chemistry import SampleMolecules, init_sample_molecules
>>> init_sample_molecules()
>>> from grendel.gmath import chopped
>>> h2o = SampleMolecules['quantum water']
>>> h2o.principal_axes()
Matrix([[-0. , 0. , 1. ],
[-0.53654222, -0.84387348, 0. ],
[-0.84387348, 0.53654222, 0. ]])
>>> h2o.reorient()
>>> # Use chopped to get rid of very small numerical artifacts...
>>> # using abs to get rid of phase factor
>>> abs(chopped(h2o.principal_axes()))
Matrix([[ 0., 0., 1.],
[ 1., 0., 0.],
[ 0., 1., 0.]])
>>> h2o.reorient("I")
>>> from grendel.gmath import chopped
>>> abs(chopped(h2o.principal_axes()))
Matrix([[ 0., 1., 0.],
[ 0., 0., 1.],
[ 1., 0., 0.]])
>>> h2o.reorient("III")
>>> abs(chopped(h2o.principal_axes()))
Matrix([[ 1., 0., 0.],
[ 0., 1., 0.],
[ 0., 0., 1.]])
Same as reorient, but makes returns a copy. self is not modified.
Examples : |
---|
>>> from grendel.chemistry import SampleMolecules, init_sample_molecules
>>> init_sample_molecules()
>>> from grendel.gmath import chopped
>>> h2o = Molecule([
... Atom('O', [ 0.00000000, 0.00000000, 0.00000000 ] ),
... Atom('H', [ 0.00000000, 0.00000000, 1.00000000 ] ),
... Atom('H', [ 0.00000000, -1.00000000, -0.00000000 ] )
... ])
>>> new = h2o.reoriented()
>>> # Use chopped to get rid of very small numerical artifacts...
>>> chopped(new.principal_axes())
Matrix([[ 0., 0., 1.],
[-1., 0., 0.],
[ 0., 1., 0.]])
>>> new is h2o
False
>>> # original molecule is unchanged...
>>> h2o
Molecule([
Atom('O', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('H', [ 0.00000000, 0.00000000, 1.00000000 ] ),
Atom('H', [ 0.00000000, -1.00000000, -0.00000000 ] )
])
Rotates the molecule about axis (a Vector) by angle
Writes the Molecule to the standard xyz format.
See Molecule.xyz_string() for more details.
See Also: |
---|
xyz_string
The molecule’s position as a natoms x 3 Matrix. The ordering of rows is (as expected) the same as the ordering of the Molecule.atoms list attribute. Aliased to xyz_mat and position (the latter to be “consistant-ish” with the naming in Atom.
The molecule’s position as a natoms x 3 Matrix. The ordering of rows is (as expected) the same as the ordering of the Molecule.atoms list attribute. Aliased to xyz_mat and position (the latter to be “consistant-ish” with the naming in Atom.
The molecule, represented as a string in standard xyz format.
The first line will always be the number of atoms. The second line (which is a comment in the xyz specification) is filled by the description first line of the description attribute.
Parameters : |
---|
Examples : |
---|
>>> from __future__ import print_function
>>> from grendel.chemistry import SampleMolecules, init_sample_molecules
>>> init_sample_molecules()
>>> print(SampleMolecules['water'].xyz_string())
3
CCSD(T)/aug-cc-pVTZ Water
O 0.00000000 0.00000000 0.11815400
H 0.00000000 0.75873400 -0.47261400
H 0.00000000 -0.75873400 -0.47261400
>>> print(Molecule("O 1.0 0.5 1.5").xyz_string("Atom: %2s, x: %3.1f, y: %4.2f, z: %5.3f"))
1
Atom: O, x: 1.0, y: 0.50, z: 1.500
>>> print(Molecule("O 1.0 0.5 1.5").xyz_string("Atom: %2s, x: %3.1f, y: %4.2f, z: %5.3f", False))
Atom: O, x: 1.0, y: 0.50, z: 1.500
All numbers inherit from this class.
If you just want to check if an argument x is a number, without caring what kind, use isinstance(x, Number).
alias of Wavenumber
Append some attributes to be set after the initialization is performed. Note that these override anything done in the class’s __init__, so don’t do anything stupid.
Contains the filename of a template that generates the input file for the computation of a molecular property, optionally with a set of specific details for which the template is valid. This class is mostly to mirror the OutputParser and PropertyParser from the output side of things.
A property whose value is a scalar
By default, just get the last group matched.
The simplest form of a generator. Takes a Mako-style template file, passes in the Computation object in as the argument “computation”, and runs the Mako templete engine.
Mostly a wrapper for the NumPy ndarray class. This gives us a place to put tensor-related functionality that we need but is not available in NumPy.
Copy all properties of the tensor except for the data.
Same as numpy.ndarray.flatten, but modified to return a Vector object
Examples : |
---|
>>> t = Tensor([[[1,2],[3,4]],[[5,6],[7,8]]])
>>> t
Tensor([[[ 1., 2.],
[ 3., 4.]],
[[ 5., 6.],
[ 7., 8.]]])
>>> t.flatten()
Vector([ 1., 2., 3., ..., 6., 7., 8.])
List of pointers to IndexRange objects over which the tensor is defined.
Returns True if all elements of self have absolute values less than cutoff, which defaults to Tensor.zero_cutoff
Note
Tensor.zero_cutoff is treated as a pseudo-class attribute for Tensor instances, meaning individual instances can also set a zero_cutoff attribute which will take precidence over the class-level default.
Given any number of Tensor objects that are the same up to a phase factor, return a list of Tensor objects that have been. Copies are only made if necessary. The chosen phase is the one that makes the first non-zero element (in the numpy.nditer(tensor) iterator, using the cutoff keyword argument or Tensor.zero_cutoff if one is not given) positive.
Allows conformance with the Unitized protocol.
A property whose value is an n-dimensional tensor
Abstract base class for things with units. It requires its subclasses to implement the properties ‘value’ and ‘units’. Unitized subclasses are also expected have __mul__, __div__, __truediv__, __pow__, __add__, __sub__, __neg__, __pos__, and __abs__ handle units correctly, when implemented in the given subclass.
Raised when a MolecularProperty is requested but not available for whatever reason.
A class for encapsulating a physical constant and it’s units.
Attributes : |
---|
A property whose value is a vector.
A decorator indicating abstract methods.
Requires that the metaclass is ABCMeta or derived from it. A class that has a metaclass derived from ABCMeta cannot be instantiated unless all of its abstract methods are overridden. The abstract methods can be called using any of the normal ‘super’ call mechanisms.
Usage:
- class C:
__metaclass__ = ABCMeta @abstractmethod def my_abstract_method(self, ...):
...
Converts a CamalCase string to a lower_case_string_with_underscores If the divider argument is given, it is used instead of underscores to join words.
Examples : |
---|
Convenience method for getting the typename as a string from the <type ‘Something’> string sent back by str(type(obj))
Alias for has_units()
Aliased as is_unit()
partial(func, *args, **keywords) - new function with partial application of the given arguments and keywords.
tuple of arguments to future partial calls
function object to use in future partial calls
dictionary of keyword arguments to future partial calls
Type checking for functions and methods.
Issue a warning, or maybe ignore it or raise an exception.
Decorator allowing the assignment of attributes to a function.
Metaclass for defining Abstract Base Classes (ABCs).
Use this metaclass to create an ABC. An ABC can be subclassed directly, and then acts as a mix-in class. You can also register unrelated concrete classes (even built-in classes) and unrelated ABCs as ‘virtual subclasses’ – these and their descendants will be considered subclasses of the registering ABC by the built-in issubclass() function, but the registering ABC won’t show up in their MRO (Method Resolution Order) nor will method implementations defined by the registering ABC be callable (not even via super()).
Register a virtual subclass of an ABC.
Decorator for properties with cached return values. The decorator creates a property that stores the return value of the method call in a variable named _[func_name] (where [func_name] is the name of the function).
Examples : |
---|
>>> class Factorializer(object):
...
... n = None
...
... def __init__(self, n):
... self.n = n
...
... @CachedProperty
... def thirty_plus_n_fact(self):
... ret_val = 1
... for i in xrange(2, self.n + 31):
... ret_val *= i
... return ret_val
...
>>> f = Factorializer(3000)
>>> # Takes some time...
>>> var = f.thirty_plus_n_fact
>>> # Should take no time...
>>> for i in xrange(100):
... var = f.thirty_plus_n_fact
...
>>> # Be careful... Remember to invalidate the cache when the appropriate variables are updated...
>>> f.n = 2500
>>> # Takes no time but gives the wrong answer:
>>> var = f.thirty_plus_n_fact
>>> # Invalidate the cache:
>>> f._thirty_plus_n_fact = None
>>> # This should take some time again, but now it will get the right answer
>>> var = f.thirty_plus_n_fact
Encapsulates specifics about how the calculation was/is to be carried out, such as level of theory, basis set, program, etc. Can be subclassed for specific programs which may require special detail setting methods.
Effectively clones details. Used internally for making a details into a ComputationDetails subclass
Mostly for use by templates, this method returns a string of keyword-value pairs in using the given format for each argument in the argument list. format should use the str.format() protocol from the python standard library with the named slots {key} where the keyword name should go and {value} where the value of the detail should go (or, if the value of the detail is a Keyword object, the contents of the value attribute for that Keyword, or, if the value attribute for the keyword is not defined, the _name attribute for the Keyword object in question.
Aliased as keywordify
Mostly for use by templates, this method returns a string of keyword-value pairs in using the given format for each argument in the argument list. format should use the str.format() protocol from the python standard library with the named slots {key} where the keyword name should go and {value} where the value of the detail should go (or, if the value of the detail is a Keyword object, the contents of the value attribute for that Keyword, or, if the value attribute for the keyword is not defined, the _name attribute for the Keyword object in question.
Aliased as keywordify
Raised when a computation can’t be generated either because a compatible input template can’t be found or a valid output parser can’t be found
Superclass for classes that are compatible with specific ComputationDetail objects or any ComputationDetail object more specifically specifice than the details variable.
Abstract base class for all properties
Attributes : |
---|
molecule : Molecule units : CompositeUnit or class with Unit metaclass
Retrieve the value of the property from a tuple of groups matched in a RegexSequence. See RegexSequence.groups()
Retrieve the value of the property from a RegexSequence object that has already been used on a file. By default, this just calls self.from_groups() with seq.groups(flatten) where flatten comes from self.from_groups.flatten.
The new paradigm for obtaining values. Call the callable instance attribute getter with the arguments and keyword arguments passed in.
The value of the molecular property.
Abstract base class for classes that parse the output file for a computation.
Encapsulates a molecular property and the code to parse it from an output file.
..note :: This method ignores property.units
A property whose value is a scalar
By default, just get the last group matched.
Convenience method for getting the typename as a string from the <type ‘Something’> string sent back by str(type(obj))
Shallow copy operation on arbitrary Python objects.
See the module’s __doc__ string for more info.
Deep copy operation on arbitrary Python objects.
See the module’s __doc__ string for more info.
Aliased as is_unit()
Metaclass for defining Abstract Base Classes (ABCs).
Use this metaclass to create an ABC. An ABC can be subclassed directly, and then acts as a mix-in class. You can also register unrelated concrete classes (even built-in classes) and unrelated ABCs as ‘virtual subclasses’ – these and their descendants will be considered subclasses of the registering ABC by the built-in issubclass() function, but the registering ABC won’t show up in their MRO (Method Resolution Order) nor will method implementations defined by the registering ABC be callable (not even via super()).
Register a virtual subclass of an ABC.
Abstract base class for queues of computations to be run.
A decorator indicating abstract properties.
Requires that the metaclass is ABCMeta or derived from it. A class that has a metaclass derived from ABCMeta cannot be instantiated unless all of its abstract properties are overridden. The abstract properties can be called using any of the normal ‘super’ call mechanisms.
Usage:
- class C:
__metaclass__ = ABCMeta @abstractproperty def my_abstract_property(self):
...
This defines a read-only property; you can also define a read-write abstract property using the ‘long’ form of property declaration:
- class C:
- __metaclass__ = ABCMeta def getx(self): ... def setx(self, value): ... x = abstractproperty(getx, setx)
Add computation(s) to the queue.
True if all the computations on the queue are finished
True if the queue has been started (i. e. if any of the computations have been started)
Run the queue. (Abstract method) This runs the whole queue and blocks until the run is complete. See also start
Start the queue in the background and return to execution. Beware that if Python exits, the queue’s processes will be orphaned. This mode of running may not be supported by all queue types.
A decorator indicating abstract methods.
Requires that the metaclass is ABCMeta or derived from it. A class that has a metaclass derived from ABCMeta cannot be instantiated unless all of its abstract methods are overridden. The abstract methods can be called using any of the normal ‘super’ call mechanisms.
Usage:
- class C:
__metaclass__ = ABCMeta @abstractmethod def my_abstract_method(self, ...):
...
A decorator indicating abstract properties.
Requires that the metaclass is ABCMeta or derived from it. A class that has a metaclass derived from ABCMeta cannot be instantiated unless all of its abstract properties are overridden. The abstract properties can be called using any of the normal ‘super’ call mechanisms.
Usage:
- class C:
__metaclass__ = ABCMeta @abstractproperty def my_abstract_property(self):
...
This defines a read-only property; you can also define a read-write abstract property using the ‘long’ form of property declaration:
- class C:
- __metaclass__ = ABCMeta def getx(self): ... def setx(self, value): ... x = abstractproperty(getx, setx)
Run the queue in a non-blocking manner. Calling start multiple times has no effect, but also raises no warning
The simplest possible queue. Runs one job at a time on the local machine.
Metaclass for defining Abstract Base Classes (ABCs).
Use this metaclass to create an ABC. An ABC can be subclassed directly, and then acts as a mix-in class. You can also register unrelated concrete classes (even built-in classes) and unrelated ABCs as ‘virtual subclasses’ – these and their descendants will be considered subclasses of the registering ABC by the built-in issubclass() function, but the registering ABC won’t show up in their MRO (Method Resolution Order) nor will method implementations defined by the registering ABC be callable (not even via super()).
Register a virtual subclass of an ABC.
Base class for all classes encapsulating runs of external programs
Checks to see if an identical input file with an identical name has already been run in the computation’s directory to produce an output file of some sort (if that output file has errors, you probably don’t want to rerun the exact same input file, so this doesn’t do that by default. If you need to do that, call Computation.run() with the force_rerun argument set to True).
True if and only if the calculation has finished running. (regardless of success or failure). Setting completed to True triggers the output parser.
The types of the properties in the self.properties list.
Convert strings to standard form for attributes. Strings with spaces, underscore_joined_strings, Uppercase_Underscore_Strings, and lowerCamelCase strings are all converted to UpperCamelCase.
Examples : |
---|
>>> Computation.standardize_attribute("basis_set")
'BasisSet'
>>> Computation.standardize_attribute("basis set")
'BasisSet'
>>> Computation.standardize_attribute("basis!Set")
'BasisSet'
>>> # Only _ and space serve as CamelCase separators:
>>> Computation.standardize_attribute("basis!set")
'Basisset'
>>> Computation.standardize_attribute("Level___of!*theory")
'LevelOftheory'
>>> # "Accidental" caps are not fixed...
>>> Computation.standardize_attribute("Level___of!*tHEory")
'LevelOftHEory'
>>> #All caps gets translated into title case
>>> Computation.standardize_attribute("Level&$#of__THEORY")
'LevelofTheory'
Alias for can_get_property_for_molecule()
Aliased as has_property(), can_get_property()
Alias for can_get_property_for_molecule()
Raised when a computation can’t be generated either because a compatible input template can’t be found or a valid output parser can’t be found
Abstract base class for all properties
Attributes : |
---|
molecule : Molecule units : CompositeUnit or class with Unit metaclass
Retrieve the value of the property from a tuple of groups matched in a RegexSequence. See RegexSequence.groups()
Retrieve the value of the property from a RegexSequence object that has already been used on a file. By default, this just calls self.from_groups() with seq.groups(flatten) where flatten comes from self.from_groups.flatten.
The new paradigm for obtaining values. Call the callable instance attribute getter with the arguments and keyword arguments passed in.
The value of the molecular property.
Abstract base class for all classes that encapsulate a method of retrieving a (set of) properties of a molecule from a computational chemistry package. An instance of a ResultGetter object should know how to turn a request for a given molecular property into a Computation object (which, in turn, houses MolecularProperty objects for one or more Molecule objects). ResultGetter objects generate Computation objects. Any ResultGetter subclass should always check for an available computation on (exactly) the same molecule that already has the result available.
A decorator indicating abstract methods.
Requires that the metaclass is ABCMeta or derived from it. A class that has a metaclass derived from ABCMeta cannot be instantiated unless all of its abstract methods are overridden. The abstract methods can be called using any of the normal ‘super’ call mechanisms.
Usage:
- class C:
__metaclass__ = ABCMeta @abstractmethod def my_abstract_method(self, ...):
...
Shallow copy operation on arbitrary Python objects.
See the module’s __doc__ string for more info.
Alias a function as something else. Set the documentation of the new method to “Alias for <function>()” and add “Aliased as <alias>()” to the documentation of function. Not inteded to be used as a decorator.
Examples : |
---|
>>> def foo(a, b, c):
... '''Print a test message.'''
... print "testing {0}, {1}, {2}".format(a, b, c)
...
>>> foo(1, 2, 3)
testing 1, 2, 3
>>> bar = function_alias('bar', foo)
>>> bar(4, 5, 6)
testing 4, 5, 6
>>> print bar.__doc__
Alias for `foo()`
>>> print foo.__doc__
Print a test message.
Aliased as `bar()`
>>> baz = function_alias('baz', foo)
>>> baz(7, 8, 9)
testing 7, 8, 9
>>> print foo.__doc__
Print a test message.
Aliased as `baz()`, `bar()`
Inside a class
>>> class FooBar(object):
... def testfunc(self, *args):
... '''Print out the args.'''
... print "testing " + ', '.join(str(a) for a in args)
... another_name = function_alias('another_name', testfunc)
... test_func = function_alias('test_func', testfunc)
...
>>> f = FooBar()
>>> f.test_func(1, 2, 3, 4)
testing 1, 2, 3, 4
>>> print FooBar.test_func.__doc__
Alias for `testfunc()`
>>> print FooBar.testfunc.__doc__
Print out the args.
Aliased as `test_func()`, `another_name()`
Abstract base class for classes that run a computation (or an equivalent task, such as submit a job to a PBS queue). Not all Computation objects need a runner; for instance XML-parsed computations are constructed in an already-run state.
Run in a blocking manner. Default implementation calls wait() on the process returned by start(). Overload it if this doesn’t make sense.
Determine if we will be able to run. Raise a ComputationUnavailableError if running will cause a crash
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of Angstrom
General superclass for all angular units
alias of Degree
alias of Degree
alias of AtomicMassUnit
alias of AtomicUnitOfElectricCharge
alias of Bohr
alias of Hartree
alias of AtomicUnitOfElectricCharge
alias of Bohr
alias of AtomicUnitOfElectricCharge
alias of Hartree
alias of AtomicUnitOfMass
alias of AtomicUnitOfTime
alias of AtomicMassUnit
alias of AttoAMU
alias of Angstrom
alias of AtomicMassUnit
alias of AtomicUnitOfElectricCharge
alias of Bohr
alias of AtomicUnitOfElectricCharge
alias of Hartree
alias of AtomicUnitOfMass
alias of AtomicUnitOfTime
alias of AttoAtomicUnitOfCharge
alias of AttoAtomicUnitOfDistance
alias of AttoAtomicUnitOfEnergy
alias of Bohr
alias of Century
alias of Coulomb
alias of Day
alias of Decade
alias of Degree
alias of ElectronVolt
alias of Gram
alias of Hartree
alias of Hertz
alias of Hour
alias of Joule
alias of Meter
alias of Millennium
alias of Minute
alias of Radian
alias of Second
alias of Wavenumber
alias of Week
alias of Year
alias of AttoAngstrom
alias of AttoAngstrom
alias of AttoBohr
alias of AttoBohr
alias of AttoCentury
alias of AttoCentury
alias of AttoCoulomb
alias of AttoCoulomb
alias of AttoDay
alias of AttoDay
alias of AttoDecade
alias of AttoDecade
alias of AttoDegree
alias of AttoDegree
alias of AttoGram
alias of AttoGram
alias of AttoHartree
alias of AttoHartree
alias of AttoHertz
alias of AttoHertz
alias of AttoHour
alias of AttoHour
alias of AttoJoule
alias of AttoJoule
alias of AttoMeter
alias of AttoMeter
alias of AttoMillennium
alias of AttoMillennium
alias of AttoMinute
alias of AttoMinute
alias of AttoRadian
alias of AttoRadian
alias of AttoSecond
alias of AttoSecond
alias of AttoWavenumber
alias of AttoWavenumber
alias of AttoWeek
alias of AttoWeek
alias of AttoYear
alias of AttoYear
alias of Bohr
alias of AtomicMassUnit
alias of CentiAMU
alias of Angstrom
alias of AtomicMassUnit
alias of AtomicUnitOfElectricCharge
alias of Bohr
alias of AtomicUnitOfElectricCharge
alias of Hartree
alias of AtomicUnitOfMass
alias of AtomicUnitOfTime
alias of CentiAtomicUnitOfCharge
alias of CentiAtomicUnitOfDistance
alias of CentiAtomicUnitOfEnergy
alias of Bohr
alias of Century
alias of Coulomb
alias of Day
alias of Decade
alias of Degree
alias of ElectronVolt
alias of Gram
alias of Hartree
alias of Hertz
alias of Hour
alias of Joule
alias of Meter
alias of Millennium
alias of Minute
alias of Radian
alias of Second
alias of Wavenumber
alias of Week
alias of Year
alias of CentiAngstrom
alias of CentiAngstrom
alias of CentiBohr
alias of CentiBohr
alias of CentiCentury
alias of CentiCentury
alias of CentiCoulomb
alias of CentiCoulomb
alias of CentiDay
alias of CentiDay
alias of CentiDecade
alias of CentiDecade
alias of CentiDegree
alias of CentiDegree
alias of CentiGram
alias of CentiGram
alias of CentiHartree
alias of CentiHartree
alias of CentiHertz
alias of CentiHertz
alias of CentiHour
alias of CentiHour
alias of CentiJoule
alias of CentiJoule
alias of CentiMeter
alias of CentiMeter
alias of CentiMillennium
alias of CentiMillennium
alias of CentiMinute
alias of CentiMinute
alias of CentiRadian
alias of CentiRadian
alias of CentiSecond
alias of CentiSecond
alias of CentiWavenumber
alias of CentiWavenumber
alias of CentiWeek
alias of CentiWeek
alias of CentiYear
alias of CentiYear
alias of Century
A class for composite units, e.g. Joules/Angstrom^2
Analog of Unit.genre. Always returns CompositeUnit
The name of the composite unit, as a product of base units
Reduce the composite unit into the fewest base units possible.
Examples : |
---|
>>> from grendel.util.units import *
>>> (Angstroms**2/Bohr).reduced()
(1.88972612457 Angstrom)
>>> (Degree / (Bohr**2)).reduced()
Degree / Bohr**2
>>> (Degree / (Bohr*Meter)).reduced()
(5.2917721092e-11 Degree / Bohr**2)
Encapsulates specifics about how the calculation was/is to be carried out, such as level of theory, basis set, program, etc. Can be subclassed for specific programs which may require special detail setting methods.
Effectively clones details. Used internally for making a details into a ComputationDetails subclass
Mostly for use by templates, this method returns a string of keyword-value pairs in using the given format for each argument in the argument list. format should use the str.format() protocol from the python standard library with the named slots {key} where the keyword name should go and {value} where the value of the detail should go (or, if the value of the detail is a Keyword object, the contents of the value attribute for that Keyword, or, if the value attribute for the keyword is not defined, the _name attribute for the Keyword object in question.
Aliased as keywordify
Mostly for use by templates, this method returns a string of keyword-value pairs in using the given format for each argument in the argument list. format should use the str.format() protocol from the python standard library with the named slots {key} where the keyword name should go and {value} where the value of the detail should go (or, if the value of the detail is a Keyword object, the contents of the value attribute for that Keyword, or, if the value attribute for the keyword is not defined, the _name attribute for the Keyword object in question.
Aliased as keywordify
alias of Coulomb
alias of Day
alias of AtomicMassUnit
alias of DecaAMU
alias of Angstrom
alias of AtomicMassUnit
alias of AtomicUnitOfElectricCharge
alias of Bohr
alias of AtomicUnitOfElectricCharge
alias of Hartree
alias of AtomicUnitOfMass
alias of AtomicUnitOfTime
alias of DecaAtomicUnitOfCharge
alias of DecaAtomicUnitOfDistance
alias of DecaAtomicUnitOfEnergy
alias of Bohr
alias of Century
alias of Coulomb
alias of Day
alias of Decade
alias of Degree
alias of ElectronVolt
alias of Gram
alias of Hartree
alias of Hertz
alias of Hour
alias of Joule
alias of Meter
alias of Millennium
alias of Minute
alias of Radian
alias of Second
alias of Wavenumber
alias of Week
alias of Year
alias of DecaAngstrom
alias of DecaAngstrom
alias of DecaBohr
alias of DecaBohr
alias of DecaCentury
alias of DecaCentury
alias of DecaCoulomb
alias of DecaCoulomb
alias of DecaDay
alias of DecaDay
alias of DecaDecade
alias of DecaDecade
alias of DecaDegree
alias of DecaDegree
alias of Decade
alias of DecaGram
alias of DecaGram
alias of DecaHartree
alias of DecaHartree
alias of DecaHertz
alias of DecaHertz
alias of DecaHour
alias of DecaHour
alias of DecaJoule
alias of DecaJoule
alias of DecaMeter
alias of DecaMeter
alias of DecaMillennium
alias of DecaMillennium
alias of DecaMinute
alias of DecaMinute
alias of DecaRadian
alias of DecaRadian
alias of DecaSecond
alias of DecaSecond
alias of DecaWavenumber
alias of DecaWavenumber
alias of DecaWeek
alias of DecaWeek
alias of DecaYear
alias of DecaYear
alias of AtomicMassUnit
alias of DeciAMU
alias of Angstrom
alias of AtomicMassUnit
alias of AtomicUnitOfElectricCharge
alias of Bohr
alias of AtomicUnitOfElectricCharge
alias of Hartree
alias of AtomicUnitOfMass
alias of AtomicUnitOfTime
alias of DeciAtomicUnitOfCharge
alias of DeciAtomicUnitOfDistance
alias of DeciAtomicUnitOfEnergy
alias of Bohr
alias of Century
alias of Coulomb
alias of Day
alias of Decade
alias of Degree
alias of ElectronVolt
alias of Gram
alias of Hartree
alias of Hertz
alias of Hour
alias of Joule
alias of Meter
alias of Millennium
alias of Minute
alias of Radian
alias of Second
alias of Wavenumber
alias of Week
alias of Year
alias of DeciAngstrom
alias of DeciAngstrom
alias of DeciBohr
alias of DeciBohr
alias of DeciCentury
alias of DeciCentury
alias of DeciCoulomb
alias of DeciCoulomb
alias of DeciDay
alias of DeciDay
alias of DeciDecade
alias of DeciDecade
alias of DeciDegree
alias of DeciDegree
alias of DeciGram
alias of DeciGram
alias of DeciHartree
alias of DeciHartree
alias of DeciHertz
alias of DeciHertz
alias of DeciHour
alias of DeciHour
alias of DeciJoule
alias of DeciJoule
alias of DeciMeter
alias of DeciMeter
alias of DeciMillennium
alias of DeciMillennium
alias of DeciMinute
alias of DeciMinute
alias of DeciRadian
alias of DeciRadian
alias of DeciSecond
alias of DeciSecond
alias of DeciWavenumber
alias of DeciWavenumber
alias of DeciWeek
alias of DeciWeek
alias of DeciYear
alias of DeciYear
alias of Degree
General superclass for all distance units
alias of Angstrom
alias of Angstrom
General superclass for all units of electric charge
alias of Coulomb
alias of Coulomb
alias of ElectronVolt
The energy of a molecule.
alias of Wavenumber
General superclass for all energy units
alias of Wavenumber
alias of Joule
alias of AtomicMassUnit
alias of ExaAMU
alias of Angstrom
alias of AtomicMassUnit
alias of AtomicUnitOfElectricCharge
alias of Bohr
alias of AtomicUnitOfElectricCharge
alias of Hartree
alias of AtomicUnitOfMass
alias of AtomicUnitOfTime
alias of ExaAtomicUnitOfCharge
alias of ExaAtomicUnitOfDistance
alias of ExaAtomicUnitOfEnergy
alias of Bohr
alias of Century
alias of Coulomb
alias of Day
alias of Decade
alias of Degree
alias of ElectronVolt
alias of Gram
alias of Hartree
alias of Hertz
alias of Hour
alias of Joule
alias of Meter
alias of Millennium
alias of Minute
alias of Radian
alias of Second
alias of Wavenumber
alias of Week
alias of Year
alias of ExaAngstrom
alias of ExaAngstrom
alias of ExaBohr
alias of ExaBohr
alias of ExaCentury
alias of ExaCentury
alias of ExaCoulomb
alias of ExaCoulomb
alias of ExaDay
alias of ExaDay
alias of ExaDecade
alias of ExaDecade
alias of ExaDegree
alias of ExaDegree
alias of ExaGram
alias of ExaGram
alias of ExaHartree
alias of ExaHartree
alias of ExaHertz
alias of ExaHertz
alias of ExaHour
alias of ExaHour
alias of ExaJoule
alias of ExaJoule
alias of ExaMeter
alias of ExaMeter
alias of ExaMillennium
alias of ExaMillennium
alias of ExaMinute
alias of ExaMinute
alias of ExaRadian
alias of ExaRadian
alias of ExaSecond
alias of ExaSecond
alias of ExaWavenumber
alias of ExaWavenumber
alias of ExaWeek
alias of ExaWeek
alias of ExaYear
alias of ExaYear
alias of AtomicMassUnit
alias of FemtoAMU
alias of Angstrom
alias of AtomicMassUnit
alias of AtomicUnitOfElectricCharge
alias of Bohr
alias of AtomicUnitOfElectricCharge
alias of Hartree
alias of AtomicUnitOfMass
alias of AtomicUnitOfTime
alias of FemtoAtomicUnitOfCharge
alias of FemtoAtomicUnitOfDistance
alias of FemtoAtomicUnitOfEnergy
alias of Bohr
alias of Century
alias of Coulomb
alias of Day
alias of Decade
alias of Degree
alias of ElectronVolt
alias of Gram
alias of Hartree
alias of Hertz
alias of Hour
alias of Joule
alias of Meter
alias of Millennium
alias of Minute
alias of Radian
alias of Second
alias of Wavenumber
alias of Week
alias of Year
alias of FemtoAngstrom
alias of FemtoAngstrom
alias of FemtoBohr
alias of FemtoBohr
alias of FemtoCentury
alias of FemtoCentury
alias of FemtoCoulomb
alias of FemtoCoulomb
alias of FemtoDay
alias of FemtoDay
alias of FemtoDecade
alias of FemtoDecade
alias of FemtoDegree
alias of FemtoDegree
alias of FemtoGram
alias of FemtoGram
alias of FemtoHartree
alias of FemtoHartree
alias of FemtoHertz
alias of FemtoHertz
alias of FemtoHour
alias of FemtoHour
alias of FemtoJoule
alias of FemtoJoule
alias of FemtoMeter
alias of FemtoMeter
alias of FemtoMillennium
alias of FemtoMillennium
alias of FemtoMinute
alias of FemtoMinute
alias of FemtoRadian
alias of FemtoRadian
alias of FemtoSecond
alias of FemtoSecond
alias of FemtoWavenumber
alias of FemtoWavenumber
alias of FemtoWeek
alias of FemtoWeek
alias of FemtoYear
alias of FemtoYear
alias of AtomicMassUnit
alias of GigaAMU
alias of Angstrom
alias of AtomicMassUnit
alias of AtomicUnitOfElectricCharge
alias of Bohr
alias of AtomicUnitOfElectricCharge
alias of Hartree
alias of AtomicUnitOfMass
alias of AtomicUnitOfTime
alias of GigaAtomicUnitOfCharge
alias of GigaAtomicUnitOfDistance
alias of GigaAtomicUnitOfEnergy
alias of Bohr
alias of Century
alias of Coulomb
alias of Day
alias of Decade
alias of Degree
alias of ElectronVolt
alias of Gram
alias of Hartree
alias of Hertz
alias of Hour
alias of Joule
alias of Meter
alias of Millennium
alias of Minute
alias of Radian
alias of Second
alias of Wavenumber
alias of Week
alias of Year
alias of GigaAngstrom
alias of GigaAngstrom
alias of GigaBohr
alias of GigaBohr
alias of GigaCentury
alias of GigaCentury
alias of GigaCoulomb
alias of GigaCoulomb
alias of GigaDay
alias of GigaDay
alias of GigaDecade
alias of GigaDecade
alias of GigaDegree
alias of GigaDegree
alias of GigaGram
alias of GigaGram
alias of GigaHartree
alias of GigaHartree
alias of GigaHertz
alias of GigaHertz
alias of GigaHour
alias of GigaHour
alias of GigaJoule
alias of GigaJoule
alias of GigaMeter
alias of GigaMeter
alias of GigaMillennium
alias of GigaMillennium
alias of GigaMinute
alias of GigaMinute
alias of GigaRadian
alias of GigaRadian
alias of GigaSecond
alias of GigaSecond
alias of GigaWavenumber
alias of GigaWavenumber
alias of GigaWeek
alias of GigaWeek
alias of GigaYear
alias of GigaYear
alias of Gram
alias of Hartree
alias of AtomicMassUnit
alias of HectoAMU
alias of Angstrom
alias of AtomicMassUnit
alias of AtomicUnitOfElectricCharge
alias of Bohr
alias of AtomicUnitOfElectricCharge
alias of Hartree
alias of AtomicUnitOfMass
alias of AtomicUnitOfTime
alias of HectoAtomicUnitOfCharge
alias of HectoAtomicUnitOfDistance
alias of HectoAtomicUnitOfEnergy
alias of Bohr
alias of Century
alias of Coulomb
alias of Day
alias of Decade
alias of Degree
alias of ElectronVolt
alias of Gram
alias of Hartree
alias of Hertz
alias of Hour
alias of Joule
alias of Meter
alias of Millennium
alias of Minute
alias of Radian
alias of Second
alias of Wavenumber
alias of Week
alias of Year
alias of HectoAngstrom
alias of HectoAngstrom
alias of HectoBohr
alias of HectoBohr
alias of HectoCentury
alias of HectoCentury
alias of HectoCoulomb
alias of HectoCoulomb
alias of HectoDay
alias of HectoDay
alias of HectoDecade
alias of HectoDecade
alias of HectoDegree
alias of HectoDegree
alias of HectoGram
alias of HectoGram
alias of HectoHartree
alias of HectoHartree
alias of HectoHertz
alias of HectoHertz
alias of HectoHour
alias of HectoHour
alias of HectoJoule
alias of HectoJoule
alias of HectoMeter
alias of HectoMeter
alias of HectoMillennium
alias of HectoMillennium
alias of HectoMinute
alias of HectoMinute
alias of HectoRadian
alias of HectoRadian
alias of HectoSecond
alias of HectoSecond
alias of HectoWavenumber
alias of HectoWavenumber
alias of HectoWeek
alias of HectoWeek
alias of HectoYear
alias of HectoYear
alias of Hertz
alias of Hour
Exception for attempted incompatible unit conversions
alias of Joule
alias of KiloCaloriePerMol
alias of KiloCaloriePerMol
alias of KiloJoulePerMol
alias of KiloCaloriePerMol
alias of KiloCaloriePerMol
alias of AtomicMassUnit
alias of KiloAMU
alias of Angstrom
alias of AtomicMassUnit
alias of AtomicUnitOfElectricCharge
alias of Bohr
alias of AtomicUnitOfElectricCharge
alias of Hartree
alias of AtomicUnitOfMass
alias of AtomicUnitOfTime
alias of KiloAtomicUnitOfCharge
alias of KiloAtomicUnitOfDistance
alias of KiloAtomicUnitOfEnergy
alias of Bohr
alias of KiloCaloriePerMol
alias of KiloCaloriePerMol
alias of KiloCaloriePerMol
alias of Century
alias of Coulomb
alias of Day
alias of Decade
alias of Degree
alias of ElectronVolt
alias of Gram
alias of Hartree
alias of Hertz
alias of Hour
alias of Joule
alias of KiloJoulePerMol
alias of Meter
alias of Millennium
alias of Minute
alias of Radian
alias of Second
alias of Wavenumber
alias of Week
alias of Year
alias of KiloAngstrom
alias of KiloAngstrom
alias of KiloBohr
alias of KiloBohr
alias of KiloCentury
alias of KiloCentury
alias of KiloCoulomb
alias of KiloCoulomb
alias of KiloDay
alias of KiloDay
alias of KiloDecade
alias of KiloDecade
alias of KiloDegree
alias of KiloDegree
alias of KiloGram
alias of KiloGram
alias of KiloHartree
alias of KiloHartree
alias of KiloHertz
alias of KiloHertz
alias of KiloHour
alias of KiloHour
alias of KiloJoule
alias of KiloJoule
alias of KiloJoulePerMol
alias of KiloJoulePerMol
alias of KiloMeter
alias of KiloMeter
alias of KiloMillennium
alias of KiloMillennium
alias of KiloMinute
alias of KiloMinute
alias of KiloRadian
alias of KiloRadian
alias of KiloSecond
alias of KiloSecond
alias of KiloWavenumber
alias of KiloWavenumber
alias of KiloWeek
alias of KiloWeek
alias of KiloYear
alias of KiloYear
General superclass for all units of mass
alias of AtomicMassUnit
alias of Gram
alias of AtomicMassUnit
alias of MegaAMU
alias of Angstrom
alias of AtomicMassUnit
alias of AtomicUnitOfElectricCharge
alias of Bohr
alias of AtomicUnitOfElectricCharge
alias of Hartree
alias of AtomicUnitOfMass
alias of AtomicUnitOfTime
alias of MegaAtomicUnitOfCharge
alias of MegaAtomicUnitOfDistance
alias of MegaAtomicUnitOfEnergy
alias of Bohr
alias of Century
alias of Coulomb
alias of Day
alias of Decade
alias of Degree
alias of ElectronVolt
alias of Gram
alias of Hartree
alias of Hertz
alias of Hour
alias of Joule
alias of Meter
alias of Millennium
alias of Minute
alias of Radian
alias of Second
alias of Wavenumber
alias of Week
alias of Year
alias of MegaAngstrom
alias of MegaAngstrom
alias of MegaBohr
alias of MegaBohr
alias of MegaCentury
alias of MegaCentury
alias of MegaCoulomb
alias of MegaCoulomb
alias of MegaDay
alias of MegaDay
alias of MegaDecade
alias of MegaDecade
alias of MegaDegree
alias of MegaDegree
alias of MegaGram
alias of MegaGram
alias of MegaHartree
alias of MegaHartree
alias of MegaHertz
alias of MegaHertz
alias of MegaHour
alias of MegaHour
alias of MegaJoule
alias of MegaJoule
alias of MegaMeter
alias of MegaMeter
alias of MegaMillennium
alias of MegaMillennium
alias of MegaMinute
alias of MegaMinute
alias of MegaRadian
alias of MegaRadian
alias of MegaSecond
alias of MegaSecond
alias of MegaWavenumber
alias of MegaWavenumber
alias of MegaWeek
alias of MegaWeek
alias of MegaYear
alias of MegaYear
alias of Meter
alias of AtomicMassUnit
alias of MicroAMU
alias of Angstrom
alias of AtomicMassUnit
alias of AtomicUnitOfElectricCharge
alias of Bohr
alias of AtomicUnitOfElectricCharge
alias of Hartree
alias of AtomicUnitOfMass
alias of AtomicUnitOfTime
alias of MicroAtomicUnitOfCharge
alias of MicroAtomicUnitOfDistance
alias of MicroAtomicUnitOfEnergy
alias of Bohr
alias of Century
alias of Coulomb
alias of Day
alias of Decade
alias of Degree
alias of ElectronVolt
alias of Gram
alias of Hartree
alias of Hertz
alias of Hour
alias of Joule
alias of Meter
alias of Millennium
alias of Minute
alias of Radian
alias of Second
alias of Wavenumber
alias of Week
alias of Year
alias of MicroAngstrom
alias of MicroAngstrom
alias of MicroBohr
alias of MicroBohr
alias of MicroCentury
alias of MicroCentury
alias of MicroCoulomb
alias of MicroCoulomb
alias of MicroDay
alias of MicroDay
alias of MicroDecade
alias of MicroDecade
alias of MicroDegree
alias of MicroDegree
alias of MicroGram
alias of MicroGram
alias of MicroHartree
alias of MicroHartree
alias of MicroHertz
alias of MicroHertz
alias of MicroHour
alias of MicroHour
alias of MicroJoule
alias of MicroJoule
alias of MicroMeter
alias of MicroMeter
alias of MicroMillennium
alias of MicroMillennium
alias of MicroMinute
alias of MicroMinute
alias of MicroRadian
alias of MicroRadian
alias of MicroSecond
alias of MicroSecond
alias of MicroWavenumber
alias of MicroWavenumber
alias of MicroWeek
alias of MicroWeek
alias of MicroYear
alias of MicroYear
alias of Millennium
alias of AtomicMassUnit
alias of MilliAMU
alias of Angstrom
alias of AtomicMassUnit
alias of AtomicUnitOfElectricCharge
alias of Bohr
alias of AtomicUnitOfElectricCharge
alias of Hartree
alias of AtomicUnitOfMass
alias of AtomicUnitOfTime
alias of MilliAtomicUnitOfCharge
alias of MilliAtomicUnitOfDistance
alias of MilliAtomicUnitOfEnergy
alias of Bohr
alias of Century
alias of Coulomb
alias of Day
alias of Decade
alias of Degree
alias of ElectronVolt
alias of Gram
alias of Hartree
alias of Hertz
alias of Hour
alias of Joule
alias of Meter
alias of Millennium
alias of Minute
alias of Radian
alias of Second
alias of Wavenumber
alias of Week
alias of Year
alias of MilliAngstrom
alias of MilliAngstrom
alias of MilliBohr
alias of MilliBohr
alias of MilliCentury
alias of MilliCentury
alias of MilliCoulomb
alias of MilliCoulomb
alias of MilliDay
alias of MilliDay
alias of MilliDecade
alias of MilliDecade
alias of MilliDegree
alias of MilliDegree
alias of MilliGram
alias of MilliGram
alias of MilliHartree
alias of MilliHartree
alias of MilliHertz
alias of MilliHertz
alias of MilliHour
alias of MilliHour
alias of MilliJoule
alias of MilliJoule
alias of MilliMeter
alias of MilliMeter
alias of MilliMillennium
alias of MilliMillennium
alias of MilliMinute
alias of MilliMinute
alias of MilliRadian
alias of MilliRadian
alias of MilliSecond
alias of MilliSecond
alias of MilliWavenumber
alias of MilliWavenumber
alias of MilliWeek
alias of MilliWeek
alias of MilliYear
alias of MilliYear
alias of Minute
Abstract base class for all properties
Attributes : |
---|
molecule : Molecule units : CompositeUnit or class with Unit metaclass
Retrieve the value of the property from a tuple of groups matched in a RegexSequence. See RegexSequence.groups()
Retrieve the value of the property from a RegexSequence object that has already been used on a file. By default, this just calls self.from_groups() with seq.groups(flatten) where flatten comes from self.from_groups.flatten.
The new paradigm for obtaining values. Call the callable instance attribute getter with the arguments and keyword arguments passed in.
The value of the molecular property.
The exact same thing as the parent Molecule class (for now, anyway), but used for holding specifications of molecules that can later be replaced by a full molecule class (so things like, for instance, the calculations attribute won’t be filled in, but later if the geometry is found to match, the class using the MoleculeStub in some list can replace the stub with the full Molecule instance upon matching.
alias of AtomicMassUnit
alias of NanoAMU
alias of Angstrom
alias of AtomicMassUnit
alias of AtomicUnitOfElectricCharge
alias of Bohr
alias of AtomicUnitOfElectricCharge
alias of Hartree
alias of AtomicUnitOfMass
alias of AtomicUnitOfTime
alias of NanoAtomicUnitOfCharge
alias of NanoAtomicUnitOfDistance
alias of NanoAtomicUnitOfEnergy
alias of Bohr
alias of Century
alias of Coulomb
alias of Day
alias of Decade
alias of Degree
alias of ElectronVolt
alias of Gram
alias of Hartree
alias of Hertz
alias of Hour
alias of Joule
alias of Meter
alias of Millennium
alias of Minute
alias of Radian
alias of Second
alias of Wavenumber
alias of Week
alias of Year
alias of NanoAngstrom
alias of NanoAngstrom
alias of NanoBohr
alias of NanoBohr
alias of NanoCentury
alias of NanoCentury
alias of NanoCoulomb
alias of NanoCoulomb
alias of NanoDay
alias of NanoDay
alias of NanoDecade
alias of NanoDecade
alias of NanoDegree
alias of NanoDegree
alias of NanoGram
alias of NanoGram
alias of NanoHartree
alias of NanoHartree
alias of NanoHertz
alias of NanoHertz
alias of NanoHour
alias of NanoHour
alias of NanoJoule
alias of NanoJoule
alias of NanoMeter
alias of NanoMeter
alias of NanoMillennium
alias of NanoMillennium
alias of NanoMinute
alias of NanoMinute
alias of NanoRadian
alias of NanoRadian
alias of NanoSecond
alias of NanoSecond
alias of NanoWavenumber
alias of NanoWavenumber
alias of NanoWeek
alias of NanoWeek
alias of NanoYear
alias of NanoYear
alias of AtomicMassUnit
alias of PetaAMU
alias of Angstrom
alias of AtomicMassUnit
alias of AtomicUnitOfElectricCharge
alias of Bohr
alias of AtomicUnitOfElectricCharge
alias of Hartree
alias of AtomicUnitOfMass
alias of AtomicUnitOfTime
alias of PetaAtomicUnitOfCharge
alias of PetaAtomicUnitOfDistance
alias of PetaAtomicUnitOfEnergy
alias of Bohr
alias of Century
alias of Coulomb
alias of Day
alias of Decade
alias of Degree
alias of ElectronVolt
alias of Gram
alias of Hartree
alias of Hertz
alias of Hour
alias of Joule
alias of Meter
alias of Millennium
alias of Minute
alias of Radian
alias of Second
alias of Wavenumber
alias of Week
alias of Year
alias of PetaAngstrom
alias of PetaAngstrom
alias of PetaBohr
alias of PetaBohr
alias of PetaCentury
alias of PetaCentury
alias of PetaCoulomb
alias of PetaCoulomb
alias of PetaDay
alias of PetaDay
alias of PetaDecade
alias of PetaDecade
alias of PetaDegree
alias of PetaDegree
alias of PetaGram
alias of PetaGram
alias of PetaHartree
alias of PetaHartree
alias of PetaHertz
alias of PetaHertz
alias of PetaHour
alias of PetaHour
alias of PetaJoule
alias of PetaJoule
alias of PetaMeter
alias of PetaMeter
alias of PetaMillennium
alias of PetaMillennium
alias of PetaMinute
alias of PetaMinute
alias of PetaRadian
alias of PetaRadian
alias of PetaSecond
alias of PetaSecond
alias of PetaWavenumber
alias of PetaWavenumber
alias of PetaWeek
alias of PetaWeek
alias of PetaYear
alias of PetaYear
alias of AtomicMassUnit
alias of PicoAMU
alias of Angstrom
alias of AtomicMassUnit
alias of AtomicUnitOfElectricCharge
alias of Bohr
alias of AtomicUnitOfElectricCharge
alias of Hartree
alias of AtomicUnitOfMass
alias of AtomicUnitOfTime
alias of PicoAtomicUnitOfCharge
alias of PicoAtomicUnitOfDistance
alias of PicoAtomicUnitOfEnergy
alias of Bohr
alias of Century
alias of Coulomb
alias of Day
alias of Decade
alias of Degree
alias of ElectronVolt
alias of Gram
alias of Hartree
alias of Hertz
alias of Hour
alias of Joule
alias of Meter
alias of Millennium
alias of Minute
alias of Radian
alias of Second
alias of Wavenumber
alias of Week
alias of Year
alias of PicoAngstrom
alias of PicoAngstrom
alias of PicoBohr
alias of PicoBohr
alias of PicoCentury
alias of PicoCentury
alias of PicoCoulomb
alias of PicoCoulomb
alias of PicoDay
alias of PicoDay
alias of PicoDecade
alias of PicoDecade
alias of PicoDegree
alias of PicoDegree
alias of PicoGram
alias of PicoGram
alias of PicoHartree
alias of PicoHartree
alias of PicoHertz
alias of PicoHertz
alias of PicoHour
alias of PicoHour
alias of PicoJoule
alias of PicoJoule
alias of PicoMeter
alias of PicoMeter
alias of PicoMillennium
alias of PicoMillennium
alias of PicoMinute
alias of PicoMinute
alias of PicoRadian
alias of PicoRadian
alias of PicoSecond
alias of PicoSecond
alias of PicoWavenumber
alias of PicoWavenumber
alias of PicoWeek
alias of PicoWeek
alias of PicoYear
alias of PicoYear
alias of Radian
A read-only attribute. See SpecialAttribute for initialization variables standard to all SpecialAttribute subclasses.
Attributes : |
---|
Abstract base class for all classes that encapsulate a method of retrieving a (set of) properties of a molecule from a computational chemistry package. An instance of a ResultGetter object should know how to turn a request for a given molecular property into a Computation object (which, in turn, houses MolecularProperty objects for one or more Molecule objects). ResultGetter objects generate Computation objects. Any ResultGetter subclass should always check for an available computation on (exactly) the same molecule that already has the result available.
alias of Second
alias of AtomicMassUnit
alias of TeraAMU
alias of Angstrom
alias of AtomicMassUnit
alias of AtomicUnitOfElectricCharge
alias of Bohr
alias of AtomicUnitOfElectricCharge
alias of Hartree
alias of AtomicUnitOfMass
alias of AtomicUnitOfTime
alias of TeraAtomicUnitOfCharge
alias of TeraAtomicUnitOfDistance
alias of TeraAtomicUnitOfEnergy
alias of Bohr
alias of Century
alias of Coulomb
alias of Day
alias of Decade
alias of Degree
alias of ElectronVolt
alias of Gram
alias of Hartree
alias of Hertz
alias of Hour
alias of Joule
alias of Meter
alias of Millennium
alias of Minute
alias of Radian
alias of Second
alias of Wavenumber
alias of Week
alias of Year
alias of TeraAngstrom
alias of TeraAngstrom
alias of TeraBohr
alias of TeraBohr
alias of TeraCentury
alias of TeraCentury
alias of TeraCoulomb
alias of TeraCoulomb
alias of TeraDay
alias of TeraDay
alias of TeraDecade
alias of TeraDecade
alias of TeraDegree
alias of TeraDegree
alias of TeraGram
alias of TeraGram
alias of TeraHartree
alias of TeraHartree
alias of TeraHertz
alias of TeraHertz
alias of TeraHour
alias of TeraHour
alias of TeraJoule
alias of TeraJoule
alias of TeraMeter
alias of TeraMeter
alias of TeraMillennium
alias of TeraMillennium
alias of TeraMinute
alias of TeraMinute
alias of TeraRadian
alias of TeraRadian
alias of TeraSecond
alias of TeraSecond
alias of TeraWavenumber
alias of TeraWavenumber
alias of TeraWeek
alias of TeraWeek
alias of TeraYear
alias of TeraYear
General superclass for all time units
alias of Second
alias of Second
Metaclass for a general unit of something.
Abstract base class for things with units. It requires its subclasses to implement the properties ‘value’ and ‘units’. Unitized subclasses are also expected have __mul__, __div__, __truediv__, __pow__, __add__, __sub__, __neg__, __pos__, and __abs__ handle units correctly, when implemented in the given subclass.
For errors encountered in handling unitized objects
Exception for attempted conversion of something that is not a subclass of Unit
A class for encapsulating a physical constant and it’s units.
Attributes : |
---|
alias of Wavenumber
alias of Week
alias of Year
alias of AtomicMassUnit
alias of YoctoAMU
alias of Angstrom
alias of AtomicMassUnit
alias of AtomicUnitOfElectricCharge
alias of Bohr
alias of AtomicUnitOfElectricCharge
alias of Hartree
alias of AtomicUnitOfMass
alias of AtomicUnitOfTime
alias of YoctoAtomicUnitOfCharge
alias of YoctoAtomicUnitOfDistance
alias of YoctoAtomicUnitOfEnergy
alias of Bohr
alias of Century
alias of Coulomb
alias of Day
alias of Decade
alias of Degree
alias of ElectronVolt
alias of Gram
alias of Hartree
alias of Hertz
alias of Hour
alias of Joule
alias of Meter
alias of Millennium
alias of Minute
alias of Radian
alias of Second
alias of Wavenumber
alias of Week
alias of Year
alias of YoctoAngstrom
alias of YoctoAngstrom
alias of YoctoBohr
alias of YoctoBohr
alias of YoctoCentury
alias of YoctoCentury
alias of YoctoCoulomb
alias of YoctoCoulomb
alias of YoctoDay
alias of YoctoDay
alias of YoctoDecade
alias of YoctoDecade
alias of YoctoDegree
alias of YoctoDegree
alias of YoctoGram
alias of YoctoGram
alias of YoctoHartree
alias of YoctoHartree
alias of YoctoHertz
alias of YoctoHertz
alias of YoctoHour
alias of YoctoHour
alias of YoctoJoule
alias of YoctoJoule
alias of YoctoMeter
alias of YoctoMeter
alias of YoctoMillennium
alias of YoctoMillennium
alias of YoctoMinute
alias of YoctoMinute
alias of YoctoRadian
alias of YoctoRadian
alias of YoctoSecond
alias of YoctoSecond
alias of YoctoWavenumber
alias of YoctoWavenumber
alias of YoctoWeek
alias of YoctoWeek
alias of YoctoYear
alias of YoctoYear
alias of AtomicMassUnit
alias of YottaAMU
alias of Angstrom
alias of AtomicMassUnit
alias of AtomicUnitOfElectricCharge
alias of Bohr
alias of AtomicUnitOfElectricCharge
alias of Hartree
alias of AtomicUnitOfMass
alias of AtomicUnitOfTime
alias of YottaAtomicUnitOfCharge
alias of YottaAtomicUnitOfDistance
alias of YottaAtomicUnitOfEnergy
alias of Bohr
alias of Century
alias of Coulomb
alias of Day
alias of Decade
alias of Degree
alias of ElectronVolt
alias of Gram
alias of Hartree
alias of Hertz
alias of Hour
alias of Joule
alias of Meter
alias of Millennium
alias of Minute
alias of Radian
alias of Second
alias of Wavenumber
alias of Week
alias of Year
alias of YottaAngstrom
alias of YottaAngstrom
alias of YottaBohr
alias of YottaBohr
alias of YottaCentury
alias of YottaCentury
alias of YottaCoulomb
alias of YottaCoulomb
alias of YottaDay
alias of YottaDay
alias of YottaDecade
alias of YottaDecade
alias of YottaDegree
alias of YottaDegree
alias of YottaGram
alias of YottaGram
alias of YottaHartree
alias of YottaHartree
alias of YottaHertz
alias of YottaHertz
alias of YottaHour
alias of YottaHour
alias of YottaJoule
alias of YottaJoule
alias of YottaMeter
alias of YottaMeter
alias of YottaMillennium
alias of YottaMillennium
alias of YottaMinute
alias of YottaMinute
alias of YottaRadian
alias of YottaRadian
alias of YottaSecond
alias of YottaSecond
alias of YottaWavenumber
alias of YottaWavenumber
alias of YottaWeek
alias of YottaWeek
alias of YottaYear
alias of YottaYear
alias of AtomicMassUnit
alias of ZeptoAMU
alias of Angstrom
alias of AtomicMassUnit
alias of AtomicUnitOfElectricCharge
alias of Bohr
alias of AtomicUnitOfElectricCharge
alias of Hartree
alias of AtomicUnitOfMass
alias of AtomicUnitOfTime
alias of ZeptoAtomicUnitOfCharge
alias of ZeptoAtomicUnitOfDistance
alias of ZeptoAtomicUnitOfEnergy
alias of Bohr
alias of Century
alias of Coulomb
alias of Day
alias of Decade
alias of Degree
alias of ElectronVolt
alias of Gram
alias of Hartree
alias of Hertz
alias of Hour
alias of Joule
alias of Meter
alias of Millennium
alias of Minute
alias of Radian
alias of Second
alias of Wavenumber
alias of Week
alias of Year
alias of ZeptoAngstrom
alias of ZeptoAngstrom
alias of ZeptoBohr
alias of ZeptoBohr
alias of ZeptoCentury
alias of ZeptoCentury
alias of ZeptoCoulomb
alias of ZeptoCoulomb
alias of ZeptoDay
alias of ZeptoDay
alias of ZeptoDecade
alias of ZeptoDecade
alias of ZeptoDegree
alias of ZeptoDegree
alias of ZeptoGram
alias of ZeptoGram
alias of ZeptoHartree
alias of ZeptoHartree
alias of ZeptoHertz
alias of ZeptoHertz
alias of ZeptoHour
alias of ZeptoHour
alias of ZeptoJoule
alias of ZeptoJoule
alias of ZeptoMeter
alias of ZeptoMeter
alias of ZeptoMillennium
alias of ZeptoMillennium
alias of ZeptoMinute
alias of ZeptoMinute
alias of ZeptoRadian
alias of ZeptoRadian
alias of ZeptoSecond
alias of ZeptoSecond
alias of ZeptoWavenumber
alias of ZeptoWavenumber
alias of ZeptoWeek
alias of ZeptoWeek
alias of ZeptoYear
alias of ZeptoYear
alias of AtomicMassUnit
alias of ZettaAMU
alias of Angstrom
alias of AtomicMassUnit
alias of AtomicUnitOfElectricCharge
alias of Bohr
alias of AtomicUnitOfElectricCharge
alias of Hartree
alias of AtomicUnitOfMass
alias of AtomicUnitOfTime
alias of ZettaAtomicUnitOfCharge
alias of ZettaAtomicUnitOfDistance
alias of ZettaAtomicUnitOfEnergy
alias of Bohr
alias of Century
alias of Coulomb
alias of Day
alias of Decade
alias of Degree
alias of ElectronVolt
alias of Gram
alias of Hartree
alias of Hertz
alias of Hour
alias of Joule
alias of Meter
alias of Millennium
alias of Minute
alias of Radian
alias of Second
alias of Wavenumber
alias of Week
alias of Year
alias of ZettaAngstrom
alias of ZettaAngstrom
alias of ZettaBohr
alias of ZettaBohr
alias of ZettaCentury
alias of ZettaCentury
alias of ZettaCoulomb
alias of ZettaCoulomb
alias of ZettaDay
alias of ZettaDay
alias of ZettaDecade
alias of ZettaDecade
alias of ZettaDegree
alias of ZettaDegree
alias of ZettaGram
alias of ZettaGram
alias of ZettaHartree
alias of ZettaHartree
alias of ZettaHertz
alias of ZettaHertz
alias of ZettaHour
alias of ZettaHour
alias of ZettaJoule
alias of ZettaJoule
alias of ZettaMeter
alias of ZettaMeter
alias of ZettaMillennium
alias of ZettaMillennium
alias of ZettaMinute
alias of ZettaMinute
alias of ZettaRadian
alias of ZettaRadian
alias of ZettaSecond
alias of ZettaSecond
alias of ZettaWavenumber
alias of ZettaWavenumber
alias of ZettaWeek
alias of ZettaWeek
alias of ZettaYear
alias of ZettaYear
Aliased as iscompatible()
Alias for convert_units()
Aliased as convert()
defaultdict(default_factory) –> dict with default factory
The default factory is called without arguments to produce a new value when a key is not present, in __getitem__ only. A defaultdict compares equal to a dict with the same items.
Factory for default value called by __missing__().
Aliased as hasunits()
Alias for has_units()
Aliased as indent()
Alias for isunit()
Alias for compatible_units()
Aliased as is_unit()
A simple way to accept arguments that can be an Iterable or a bunch of arguments that should be treated as a single Iterable. (This method is pretty trivial, but I find myself doing it a whole lot.) The reason you can’t just use list() for this purpose is that if an Iterable is given as the only argument, list(args) will return a list of Iterables rather than a single Iterable.
Examples : |
---|
>>> def test(*args):
... return listify_args(*args)
...
>>> test(1,2,3)
[1, 2, 3]
>>> test([1,2,3])
[1, 2, 3]
>>> test([1,2,3], 4)
[[1, 2, 3], 4]
>>> test("1,2,3", 4)
['1,2,3', 4]
>>> test("1,2,3")
['1,2,3']
Aliased as stripunits()
Alias for strip_units()
alias of CaseInsensativeOpenStruct
A ‘raw’ list, by syntactic analogy to the Python raw string literal.
>>> r[1,2,3]
[1, 2, 3]
>>> r[1, ..., 3]
[1, Ellipsis, 3]
>>> r[...]
[Ellipsis]
>>> r[...,...]
[Ellipsis, Ellipsis]
>>> r[...,...,1:3]
[Ellipsis, Ellipsis, slice(1, 3, None)]
>>> r[...,...,1:3:5]
[Ellipsis, Ellipsis, slice(1, 3, 5)]
>>> r[...,...,1:3:5,'hello']
[Ellipsis, Ellipsis, slice(1, 3, 5), 'hello']
>>> r['hello']
['hello']
Get the name of the calling function as a str
Returns : |
---|
Examples : |
---|
>>> def foo():
... print caller()
...
>>> def bar():
... foo()
...
>>> bar()
bar
>>> def foobar():
... bar()
...
>>> foobar()
bar
A simple way to accept arguments that can be an Iterable or a bunch of arguments that should be treated as a single Iterable. (This method is pretty trivial, but I find myself doing it a whole lot.) The reason you can’t just use list() for this purpose is that if an Iterable is given as the only argument, list(args) will return a list of Iterables rather than a single Iterable.
Examples : |
---|
>>> def test(*args):
... return listify_args(*args)
...
>>> test(1,2,3)
[1, 2, 3]
>>> test([1,2,3])
[1, 2, 3]
>>> test([1,2,3], 4)
[[1, 2, 3], 4]
>>> test("1,2,3", 4)
['1,2,3', 4]
>>> test("1,2,3")
['1,2,3']
Utility function for getting the value of a keyword argument that can be named multiple things. This function also checks to make sure no more than one of the possible names is specified in the keyword dictionary kwarg_dict. If the None of the keywords given are found in kwarg_dict, None is returned.
Utility function for getting the value of a keyword argument that can be named multiple things. This function also checks to make sure no more than one of the possible names is specified in the keyword dictionary kwarg_dict. If the None of the keywords given are found in kwarg_dict, None is returned.
Utility function for getting the value of a keyword argument that can be named multiple things and popping that value off of the kwarg dictionary. If the None of the keywords given are found in kwarg_dict, None is returned.
See Also: |
---|
get_multikwarg
Utility function for getting the value of a keyword argument that can be named multiple things and popping that value off of the kwarg dictionary. If the None of the keywords given are found in kwarg_dict, None is returned.
See Also: |
---|
get_multikwarg
Converts a CamalCase string to a lower_case_string_with_underscores If the divider argument is given, it is used instead of underscores to join words.
Examples : |
---|
Convenience method for getting the typename as a string from the <type ‘Something’> string sent back by str(type(obj))
Alias a function as something else. Set the documentation of the new method to “Alias for <function>()” and add “Aliased as <alias>()” to the documentation of function. Not inteded to be used as a decorator.
Examples : |
---|
>>> def foo(a, b, c):
... '''Print a test message.'''
... print "testing {0}, {1}, {2}".format(a, b, c)
...
>>> foo(1, 2, 3)
testing 1, 2, 3
>>> bar = function_alias('bar', foo)
>>> bar(4, 5, 6)
testing 4, 5, 6
>>> print bar.__doc__
Alias for `foo()`
>>> print foo.__doc__
Print a test message.
Aliased as `bar()`
>>> baz = function_alias('baz', foo)
>>> baz(7, 8, 9)
testing 7, 8, 9
>>> print foo.__doc__
Print a test message.
Aliased as `baz()`, `bar()`
Inside a class
>>> class FooBar(object):
... def testfunc(self, *args):
... '''Print out the args.'''
... print "testing " + ', '.join(str(a) for a in args)
... another_name = function_alias('another_name', testfunc)
... test_func = function_alias('test_func', testfunc)
...
>>> f = FooBar()
>>> f.test_func(1, 2, 3, 4)
testing 1, 2, 3, 4
>>> print FooBar.test_func.__doc__
Alias for `testfunc()`
>>> print FooBar.testfunc.__doc__
Print out the args.
Aliased as `test_func()`, `another_name()`
Alias for indented()
Aliased as indent()
Returns True if a call of callable with args raises an error, and False if not. Note that the callable will get called, so don’t do anything that takes a long time or changes things in a way you don’t want them to be changed. If the optional keyword argument ‘error’ is given as either an Exception subclass or an Iterable, raises_error returns True if the call of callable raises the error given or one of the errors given in the list. (The keyword argument can also be named ‘errors’). Any other keyword arguments are passed through to callable.
Technical note: As per the Python manual, only exceptions that subclass from Exception (and not BaseException directly) will be recognized. According to the python users manual, you should never implement a user exception that subclasses from BaseException directly.
Examples : |
---|
>>> raises_error(int, "5")
False
>>> raises_error(int, "0x5ab7", 0)
False
>>> raises_error(lambda x: int(x), "5")
False
>>> raises_error(int, "abc")
True
>>> raises_error(int, "abc", error = ValueError)
True
>>> raises_error(int, "abc", error = BufferError)
False
>>> raises_error(int, "abc", error = (BufferError, EnvironmentError))
False
>>> raises_error(int, "abc", error = [BufferError, ValueError])
True
>>> raises_error(float, "abc")
True
>>> # Use raises_error to see what errors raises_error raises
... # Raise a type error if the first argument is not a callable (i.e. 17(25) doesn't make sense to Python)
... raises_error(raises_error, 17, 25, error = TypeError)
True
>>> # Raise a TypeError if the error keyword argument is not a subclass of Exception
... raises_error(lambda x: raises_error(int, x, error = "hello world"), 25, error = TypeError)
True
>>> raises_error(lambda x: raises_error(int, x, error = BaseException), 25, error = TypeError)
True
Aliased as shortstr()
Alias for short_str()
Returns the unicode string subscript equivalent of num as a unicode string
Returns the unicode string superscript equivalent of num as a unicode string
Metaclass for a general unit of something.
Aliased as is_unit()
Alias for isunit()
Alias for convert_units()
Aliased as convert()
Aliased as iscompatible()
Alias for compatible_units()
General superclass for all distance units
General superclass for all energy units
alias of Wavenumber
General superclass for all angular units
General superclass for all units of electric charge
General superclass for all units of mass
alias of AtomicMassUnit
General superclass for all time units
alias of Angstrom
alias of YottaAngstrom
alias of YottaAngstrom
alias of Angstrom
alias of ZettaAngstrom
alias of ZettaAngstrom
alias of Angstrom
alias of ExaAngstrom
alias of ExaAngstrom
alias of Angstrom
alias of PetaAngstrom
alias of PetaAngstrom
alias of Angstrom
alias of TeraAngstrom
alias of TeraAngstrom
alias of Angstrom
alias of GigaAngstrom
alias of GigaAngstrom
alias of Angstrom
alias of MegaAngstrom
alias of MegaAngstrom
alias of Angstrom
alias of KiloAngstrom
alias of KiloAngstrom
alias of Angstrom
alias of HectoAngstrom
alias of HectoAngstrom
alias of Angstrom
alias of DecaAngstrom
alias of DecaAngstrom
alias of Angstrom
alias of DeciAngstrom
alias of DeciAngstrom
alias of Angstrom
alias of CentiAngstrom
alias of CentiAngstrom
alias of Angstrom
alias of MilliAngstrom
alias of MilliAngstrom
alias of Angstrom
alias of MicroAngstrom
alias of MicroAngstrom
alias of Angstrom
alias of NanoAngstrom
alias of NanoAngstrom
alias of Angstrom
alias of PicoAngstrom
alias of PicoAngstrom
alias of Angstrom
alias of FemtoAngstrom
alias of FemtoAngstrom
alias of Angstrom
alias of AttoAngstrom
alias of AttoAngstrom
alias of Angstrom
alias of ZeptoAngstrom
alias of ZeptoAngstrom
alias of Angstrom
alias of YoctoAngstrom
alias of YoctoAngstrom
alias of Bohr
alias of Bohr
alias of Bohr
alias of Bohr
alias of Bohr
alias of Bohr
alias of Bohr
alias of Bohr
alias of Bohr
alias of Bohr
alias of Bohr
alias of Bohr
alias of Bohr
alias of Bohr
alias of Bohr
alias of Bohr
alias of Bohr
alias of Bohr
alias of Bohr
alias of Bohr
alias of YottaAtomicUnitOfDistance
alias of ZettaAtomicUnitOfDistance
alias of ExaAtomicUnitOfDistance
alias of PetaAtomicUnitOfDistance
alias of TeraAtomicUnitOfDistance
alias of GigaAtomicUnitOfDistance
alias of MegaAtomicUnitOfDistance
alias of KiloAtomicUnitOfDistance
alias of HectoAtomicUnitOfDistance
alias of DecaAtomicUnitOfDistance
alias of DeciAtomicUnitOfDistance
alias of CentiAtomicUnitOfDistance
alias of MilliAtomicUnitOfDistance
alias of MicroAtomicUnitOfDistance
alias of NanoAtomicUnitOfDistance
alias of PicoAtomicUnitOfDistance
alias of FemtoAtomicUnitOfDistance
alias of AttoAtomicUnitOfDistance
alias of ZeptoAtomicUnitOfDistance
alias of YoctoAtomicUnitOfDistance
alias of Meter
alias of YottaMeter
alias of YottaMeter
alias of Meter
alias of ZettaMeter
alias of ZettaMeter
alias of Meter
alias of Meter
alias of Meter
alias of Meter
alias of Meter
alias of Meter
alias of Meter
alias of HectoMeter
alias of HectoMeter
alias of Meter
alias of Meter
alias of Meter
alias of CentiMeter
alias of CentiMeter
alias of Meter
alias of MilliMeter
alias of MilliMeter
alias of Meter
alias of MicroMeter
alias of MicroMeter
alias of Meter
alias of Meter
alias of Meter
alias of FemtoMeter
alias of FemtoMeter
alias of Meter
alias of Meter
alias of ZeptoMeter
alias of ZeptoMeter
alias of Meter
alias of YoctoMeter
alias of YoctoMeter
alias of Degree
alias of YottaDegree
alias of YottaDegree
alias of Degree
alias of ZettaDegree
alias of ZettaDegree
alias of Degree
alias of Degree
alias of PetaDegree
alias of PetaDegree
alias of Degree
alias of TeraDegree
alias of TeraDegree
alias of Degree
alias of GigaDegree
alias of GigaDegree
alias of Degree
alias of MegaDegree
alias of MegaDegree
alias of Degree
alias of KiloDegree
alias of KiloDegree
alias of Degree
alias of HectoDegree
alias of HectoDegree
alias of Degree
alias of DecaDegree
alias of DecaDegree
alias of Degree
alias of DeciDegree
alias of DeciDegree
alias of Degree
alias of CentiDegree
alias of CentiDegree
alias of Degree
alias of MilliDegree
alias of MilliDegree
alias of Degree
alias of MicroDegree
alias of MicroDegree
alias of Degree
alias of NanoDegree
alias of NanoDegree
alias of Degree
alias of PicoDegree
alias of PicoDegree
alias of Degree
alias of FemtoDegree
alias of FemtoDegree
alias of Degree
alias of AttoDegree
alias of AttoDegree
alias of Degree
alias of ZeptoDegree
alias of ZeptoDegree
alias of Degree
alias of YoctoDegree
alias of YoctoDegree
alias of Radian
alias of YottaRadian
alias of YottaRadian
alias of Radian
alias of ZettaRadian
alias of ZettaRadian
alias of Radian
alias of Radian
alias of PetaRadian
alias of PetaRadian
alias of Radian
alias of TeraRadian
alias of TeraRadian
alias of Radian
alias of GigaRadian
alias of GigaRadian
alias of Radian
alias of MegaRadian
alias of MegaRadian
alias of Radian
alias of KiloRadian
alias of KiloRadian
alias of Radian
alias of HectoRadian
alias of HectoRadian
alias of Radian
alias of DecaRadian
alias of DecaRadian
alias of Radian
alias of DeciRadian
alias of DeciRadian
alias of Radian
alias of CentiRadian
alias of CentiRadian
alias of Radian
alias of MilliRadian
alias of MilliRadian
alias of Radian
alias of MicroRadian
alias of MicroRadian
alias of Radian
alias of NanoRadian
alias of NanoRadian
alias of Radian
alias of PicoRadian
alias of PicoRadian
alias of Radian
alias of FemtoRadian
alias of FemtoRadian
alias of Radian
alias of AttoRadian
alias of AttoRadian
alias of Radian
alias of ZeptoRadian
alias of ZeptoRadian
alias of Radian
alias of YoctoRadian
alias of YoctoRadian
alias of Joule
alias of YottaJoule
alias of YottaJoule
alias of Joule
alias of ZettaJoule
alias of ZettaJoule
alias of Joule
alias of Joule
alias of Joule
alias of Joule
alias of Joule
alias of Joule
alias of Joule
alias of HectoJoule
alias of HectoJoule
alias of Joule
alias of Joule
alias of Joule
alias of CentiJoule
alias of CentiJoule
alias of Joule
alias of MilliJoule
alias of MilliJoule
alias of Joule
alias of MicroJoule
alias of MicroJoule
alias of Joule
alias of Joule
alias of Joule
alias of FemtoJoule
alias of FemtoJoule
alias of Joule
alias of Joule
alias of ZeptoJoule
alias of ZeptoJoule
alias of Joule
alias of YoctoJoule
alias of YoctoJoule
alias of Wavenumber
alias of Wavenumber
alias of Wavenumber
alias of YottaWavenumber
alias of YottaWavenumber
alias of Wavenumber
alias of Wavenumber
alias of ZettaWavenumber
alias of ZettaWavenumber
alias of Wavenumber
alias of Wavenumber
alias of ExaWavenumber
alias of ExaWavenumber
alias of Wavenumber
alias of Wavenumber
alias of PetaWavenumber
alias of PetaWavenumber
alias of Wavenumber
alias of Wavenumber
alias of TeraWavenumber
alias of TeraWavenumber
alias of Wavenumber
alias of Wavenumber
alias of GigaWavenumber
alias of GigaWavenumber
alias of Wavenumber
alias of Wavenumber
alias of MegaWavenumber
alias of MegaWavenumber
alias of Wavenumber
alias of Wavenumber
alias of KiloWavenumber
alias of KiloWavenumber
alias of Wavenumber
alias of Wavenumber
alias of HectoWavenumber
alias of HectoWavenumber
alias of Wavenumber
alias of Wavenumber
alias of DecaWavenumber
alias of DecaWavenumber
alias of Wavenumber
alias of Wavenumber
alias of DeciWavenumber
alias of DeciWavenumber
alias of Wavenumber
alias of Wavenumber
alias of CentiWavenumber
alias of CentiWavenumber
alias of Wavenumber
alias of Wavenumber
alias of MilliWavenumber
alias of MilliWavenumber
alias of Wavenumber
alias of Wavenumber
alias of MicroWavenumber
alias of MicroWavenumber
alias of Wavenumber
alias of Wavenumber
alias of NanoWavenumber
alias of NanoWavenumber
alias of Wavenumber
alias of Wavenumber
alias of PicoWavenumber
alias of PicoWavenumber
alias of Wavenumber
alias of Wavenumber
alias of FemtoWavenumber
alias of FemtoWavenumber
alias of Wavenumber
alias of Wavenumber
alias of AttoWavenumber
alias of AttoWavenumber
alias of Wavenumber
alias of Wavenumber
alias of ZeptoWavenumber
alias of ZeptoWavenumber
alias of Wavenumber
alias of Wavenumber
alias of YoctoWavenumber
alias of YoctoWavenumber
alias of ElectronVolt
alias of ElectronVolt
alias of ElectronVolt
alias of ElectronVolt
alias of ElectronVolt
alias of ElectronVolt
alias of ElectronVolt
alias of ElectronVolt
alias of ElectronVolt
alias of ElectronVolt
alias of ElectronVolt
alias of ElectronVolt
alias of ElectronVolt
alias of ElectronVolt
alias of ElectronVolt
alias of ElectronVolt
alias of ElectronVolt
alias of ElectronVolt
alias of ElectronVolt
alias of ElectronVolt
alias of ElectronVolt
alias of ElectronVolt
alias of ElectronVolt
alias of ElectronVolt
alias of ElectronVolt
alias of ElectronVolt
alias of ElectronVolt
alias of ElectronVolt
alias of ElectronVolt
alias of ElectronVolt
alias of ElectronVolt
alias of ElectronVolt
alias of ElectronVolt
alias of ElectronVolt
alias of ElectronVolt
alias of ElectronVolt
alias of ElectronVolt
alias of ElectronVolt
alias of ElectronVolt
alias of ElectronVolt
alias of ElectronVolt
alias of Hertz
alias of YottaHertz
alias of YottaHertz
alias of Hertz
alias of ZettaHertz
alias of ZettaHertz
alias of Hertz
alias of Hertz
alias of Hertz
alias of Hertz
alias of Hertz
alias of Hertz
alias of Hertz
alias of HectoHertz
alias of HectoHertz
alias of Hertz
alias of Hertz
alias of Hertz
alias of CentiHertz
alias of CentiHertz
alias of Hertz
alias of MilliHertz
alias of MilliHertz
alias of Hertz
alias of MicroHertz
alias of MicroHertz
alias of Hertz
alias of Hertz
alias of Hertz
alias of FemtoHertz
alias of FemtoHertz
alias of Hertz
alias of Hertz
alias of ZeptoHertz
alias of ZeptoHertz
alias of Hertz
alias of YoctoHertz
alias of YoctoHertz
alias of Hartree
alias of YottaHartree
alias of YottaHartree
alias of Hartree
alias of ZettaHartree
alias of ZettaHartree
alias of Hartree
alias of ExaHartree
alias of ExaHartree
alias of Hartree
alias of PetaHartree
alias of PetaHartree
alias of Hartree
alias of TeraHartree
alias of TeraHartree
alias of Hartree
alias of GigaHartree
alias of GigaHartree
alias of Hartree
alias of MegaHartree
alias of MegaHartree
alias of Hartree
alias of KiloHartree
alias of KiloHartree
alias of Hartree
alias of HectoHartree
alias of HectoHartree
alias of Hartree
alias of DecaHartree
alias of DecaHartree
alias of Hartree
alias of DeciHartree
alias of DeciHartree
alias of Hartree
alias of CentiHartree
alias of CentiHartree
alias of Hartree
alias of MilliHartree
alias of MilliHartree
alias of Hartree
alias of MicroHartree
alias of MicroHartree
alias of Hartree
alias of NanoHartree
alias of NanoHartree
alias of Hartree
alias of PicoHartree
alias of PicoHartree
alias of Hartree
alias of FemtoHartree
alias of FemtoHartree
alias of Hartree
alias of AttoHartree
alias of AttoHartree
alias of Hartree
alias of ZeptoHartree
alias of ZeptoHartree
alias of Hartree
alias of YoctoHartree
alias of YoctoHartree
alias of YottaAtomicUnitOfEnergy
alias of ZettaAtomicUnitOfEnergy
alias of ExaAtomicUnitOfEnergy
alias of PetaAtomicUnitOfEnergy
alias of TeraAtomicUnitOfEnergy
alias of GigaAtomicUnitOfEnergy
alias of MegaAtomicUnitOfEnergy
alias of KiloAtomicUnitOfEnergy
alias of HectoAtomicUnitOfEnergy
alias of DecaAtomicUnitOfEnergy
alias of DeciAtomicUnitOfEnergy
alias of CentiAtomicUnitOfEnergy
alias of MilliAtomicUnitOfEnergy
alias of MicroAtomicUnitOfEnergy
alias of NanoAtomicUnitOfEnergy
alias of PicoAtomicUnitOfEnergy
alias of FemtoAtomicUnitOfEnergy
alias of AttoAtomicUnitOfEnergy
alias of ZeptoAtomicUnitOfEnergy
alias of YoctoAtomicUnitOfEnergy
alias of KiloCaloriePerMol
alias of KiloCaloriePerMol
alias of KiloCaloriePerMol
alias of KiloCaloriePerMol
alias of KiloCaloriePerMol
alias of KiloCaloriePerMol
alias of KiloCaloriePerMol
alias of KiloJoulePerMol
alias of KiloJoulePerMol
alias of KiloJoulePerMol
alias of KiloJoulePerMol
alias of Second
alias of YottaSecond
alias of YottaSecond
alias of Second
alias of ZettaSecond
alias of ZettaSecond
alias of Second
alias of Second
alias of PetaSecond
alias of PetaSecond
alias of Second
alias of TeraSecond
alias of TeraSecond
alias of Second
alias of GigaSecond
alias of GigaSecond
alias of Second
alias of MegaSecond
alias of MegaSecond
alias of Second
alias of KiloSecond
alias of KiloSecond
alias of Second
alias of HectoSecond
alias of HectoSecond
alias of Second
alias of DecaSecond
alias of DecaSecond
alias of Second
alias of DeciSecond
alias of DeciSecond
alias of Second
alias of CentiSecond
alias of CentiSecond
alias of Second
alias of MilliSecond
alias of MilliSecond
alias of Second
alias of MicroSecond
alias of MicroSecond
alias of Second
alias of NanoSecond
alias of NanoSecond
alias of Second
alias of PicoSecond
alias of PicoSecond
alias of Second
alias of FemtoSecond
alias of FemtoSecond
alias of Second
alias of AttoSecond
alias of AttoSecond
alias of Second
alias of ZeptoSecond
alias of ZeptoSecond
alias of Second
alias of YoctoSecond
alias of YoctoSecond
alias of AtomicUnitOfTime
alias of AtomicUnitOfTime
alias of AtomicUnitOfTime
alias of AtomicUnitOfTime
alias of AtomicUnitOfTime
alias of AtomicUnitOfTime
alias of AtomicUnitOfTime
alias of AtomicUnitOfTime
alias of AtomicUnitOfTime
alias of AtomicUnitOfTime
alias of AtomicUnitOfTime
alias of AtomicUnitOfTime
alias of AtomicUnitOfTime
alias of AtomicUnitOfTime
alias of AtomicUnitOfTime
alias of AtomicUnitOfTime
alias of AtomicUnitOfTime
alias of AtomicUnitOfTime
alias of AtomicUnitOfTime
alias of AtomicUnitOfTime
alias of AtomicUnitOfTime
alias of AtomicUnitOfTime
alias of AtomicUnitOfTime
alias of AtomicUnitOfTime
alias of AtomicUnitOfTime
alias of AtomicUnitOfTime
alias of AtomicUnitOfTime
alias of AtomicUnitOfTime
alias of AtomicUnitOfTime
alias of AtomicUnitOfTime
alias of AtomicUnitOfTime
alias of AtomicUnitOfTime
alias of AtomicUnitOfTime
alias of AtomicUnitOfTime
alias of AtomicUnitOfTime
alias of AtomicUnitOfTime
alias of AtomicUnitOfTime
alias of AtomicUnitOfTime
alias of AtomicUnitOfTime
alias of AtomicUnitOfTime
alias of AtomicUnitOfTime
alias of Minute
alias of YottaMinute
alias of YottaMinute
alias of Minute
alias of ZettaMinute
alias of ZettaMinute
alias of Minute
alias of Minute
alias of PetaMinute
alias of PetaMinute
alias of Minute
alias of TeraMinute
alias of TeraMinute
alias of Minute
alias of GigaMinute
alias of GigaMinute
alias of Minute
alias of MegaMinute
alias of MegaMinute
alias of Minute
alias of KiloMinute
alias of KiloMinute
alias of Minute
alias of HectoMinute
alias of HectoMinute
alias of Minute
alias of DecaMinute
alias of DecaMinute
alias of Minute
alias of DeciMinute
alias of DeciMinute
alias of Minute
alias of CentiMinute
alias of CentiMinute
alias of Minute
alias of MilliMinute
alias of MilliMinute
alias of Minute
alias of MicroMinute
alias of MicroMinute
alias of Minute
alias of NanoMinute
alias of NanoMinute
alias of Minute
alias of PicoMinute
alias of PicoMinute
alias of Minute
alias of FemtoMinute
alias of FemtoMinute
alias of Minute
alias of AttoMinute
alias of AttoMinute
alias of Minute
alias of ZeptoMinute
alias of ZeptoMinute
alias of Minute
alias of YoctoMinute
alias of YoctoMinute
alias of Hour
alias of Hour
alias of Hour
alias of Hour
alias of Hour
alias of Hour
alias of Hour
alias of Hour
alias of Hour
alias of Hour
alias of Hour
alias of Hour
alias of Hour
alias of Hour
alias of Hour
alias of Hour
alias of Hour
alias of Hour
alias of Hour
alias of Hour
alias of Day
alias of Day
alias of Day
alias of Day
alias of Day
alias of Day
alias of Day
alias of Day
alias of Day
alias of Day
alias of Day
alias of Day
alias of Day
alias of Day
alias of Day
alias of Day
alias of Day
alias of Day
alias of Day
alias of Day
alias of Week
alias of Week
alias of Week
alias of Week
alias of Week
alias of Week
alias of Week
alias of Week
alias of Week
alias of Week
alias of Week
alias of Week
alias of Week
alias of Week
alias of Week
alias of Week
alias of Week
alias of Week
alias of Week
alias of Week
alias of Year
alias of Year
alias of Year
alias of Year
alias of Year
alias of Year
alias of Year
alias of Year
alias of Year
alias of Year
alias of Year
alias of Year
alias of Year
alias of Year
alias of Year
alias of Year
alias of Year
alias of Year
alias of Year
alias of Year
alias of Decade
alias of YottaDecade
alias of YottaDecade
alias of Decade
alias of ZettaDecade
alias of ZettaDecade
alias of Decade
alias of Decade
alias of PetaDecade
alias of PetaDecade
alias of Decade
alias of TeraDecade
alias of TeraDecade
alias of Decade
alias of GigaDecade
alias of GigaDecade
alias of Decade
alias of MegaDecade
alias of MegaDecade
alias of Decade
alias of KiloDecade
alias of KiloDecade
alias of Decade
alias of HectoDecade
alias of HectoDecade
alias of Decade
alias of DecaDecade
alias of DecaDecade
alias of Decade
alias of DeciDecade
alias of DeciDecade
alias of Decade
alias of CentiDecade
alias of CentiDecade
alias of Decade
alias of MilliDecade
alias of MilliDecade
alias of Decade
alias of MicroDecade
alias of MicroDecade
alias of Decade
alias of NanoDecade
alias of NanoDecade
alias of Decade
alias of PicoDecade
alias of PicoDecade
alias of Decade
alias of FemtoDecade
alias of FemtoDecade
alias of Decade
alias of AttoDecade
alias of AttoDecade
alias of Decade
alias of ZeptoDecade
alias of ZeptoDecade
alias of Decade
alias of YoctoDecade
alias of YoctoDecade
alias of Century
alias of YottaCentury
alias of YottaCentury
alias of Century
alias of ZettaCentury
alias of ZettaCentury
alias of Century
alias of ExaCentury
alias of ExaCentury
alias of Century
alias of PetaCentury
alias of PetaCentury
alias of Century
alias of TeraCentury
alias of TeraCentury
alias of Century
alias of GigaCentury
alias of GigaCentury
alias of Century
alias of MegaCentury
alias of MegaCentury
alias of Century
alias of KiloCentury
alias of KiloCentury
alias of Century
alias of HectoCentury
alias of HectoCentury
alias of Century
alias of DecaCentury
alias of DecaCentury
alias of Century
alias of DeciCentury
alias of DeciCentury
alias of Century
alias of CentiCentury
alias of CentiCentury
alias of Century
alias of MilliCentury
alias of MilliCentury
alias of Century
alias of MicroCentury
alias of MicroCentury
alias of Century
alias of NanoCentury
alias of NanoCentury
alias of Century
alias of PicoCentury
alias of PicoCentury
alias of Century
alias of FemtoCentury
alias of FemtoCentury
alias of Century
alias of AttoCentury
alias of AttoCentury
alias of Century
alias of ZeptoCentury
alias of ZeptoCentury
alias of Century
alias of YoctoCentury
alias of YoctoCentury
alias of Millennium
alias of Millennium
alias of Millennium
alias of YottaMillennium
alias of YottaMillennium
alias of Millennium
alias of Millennium
alias of ZettaMillennium
alias of ZettaMillennium
alias of Millennium
alias of Millennium
alias of ExaMillennium
alias of ExaMillennium
alias of Millennium
alias of Millennium
alias of PetaMillennium
alias of PetaMillennium
alias of Millennium
alias of Millennium
alias of TeraMillennium
alias of TeraMillennium
alias of Millennium
alias of Millennium
alias of GigaMillennium
alias of GigaMillennium
alias of Millennium
alias of Millennium
alias of MegaMillennium
alias of MegaMillennium
alias of Millennium
alias of Millennium
alias of KiloMillennium
alias of KiloMillennium
alias of Millennium
alias of Millennium
alias of HectoMillennium
alias of HectoMillennium
alias of Millennium
alias of Millennium
alias of DecaMillennium
alias of DecaMillennium
alias of Millennium
alias of Millennium
alias of DeciMillennium
alias of DeciMillennium
alias of Millennium
alias of Millennium
alias of CentiMillennium
alias of CentiMillennium
alias of Millennium
alias of Millennium
alias of MilliMillennium
alias of MilliMillennium
alias of Millennium
alias of Millennium
alias of MicroMillennium
alias of MicroMillennium
alias of Millennium
alias of Millennium
alias of NanoMillennium
alias of NanoMillennium
alias of Millennium
alias of Millennium
alias of PicoMillennium
alias of PicoMillennium
alias of Millennium
alias of Millennium
alias of FemtoMillennium
alias of FemtoMillennium
alias of Millennium
alias of Millennium
alias of AttoMillennium
alias of AttoMillennium
alias of Millennium
alias of Millennium
alias of ZeptoMillennium
alias of ZeptoMillennium
alias of Millennium
alias of Millennium
alias of YoctoMillennium
alias of YoctoMillennium
alias of Coulomb
alias of YottaCoulomb
alias of YottaCoulomb
alias of Coulomb
alias of ZettaCoulomb
alias of ZettaCoulomb
alias of Coulomb
alias of ExaCoulomb
alias of ExaCoulomb
alias of Coulomb
alias of PetaCoulomb
alias of PetaCoulomb
alias of Coulomb
alias of TeraCoulomb
alias of TeraCoulomb
alias of Coulomb
alias of GigaCoulomb
alias of GigaCoulomb
alias of Coulomb
alias of MegaCoulomb
alias of MegaCoulomb
alias of Coulomb
alias of KiloCoulomb
alias of KiloCoulomb
alias of Coulomb
alias of HectoCoulomb
alias of HectoCoulomb
alias of Coulomb
alias of DecaCoulomb
alias of DecaCoulomb
alias of Coulomb
alias of DeciCoulomb
alias of DeciCoulomb
alias of Coulomb
alias of CentiCoulomb
alias of CentiCoulomb
alias of Coulomb
alias of MilliCoulomb
alias of MilliCoulomb
alias of Coulomb
alias of MicroCoulomb
alias of MicroCoulomb
alias of Coulomb
alias of NanoCoulomb
alias of NanoCoulomb
alias of Coulomb
alias of PicoCoulomb
alias of PicoCoulomb
alias of Coulomb
alias of FemtoCoulomb
alias of FemtoCoulomb
alias of Coulomb
alias of AttoCoulomb
alias of AttoCoulomb
alias of Coulomb
alias of ZeptoCoulomb
alias of ZeptoCoulomb
alias of Coulomb
alias of YoctoCoulomb
alias of YoctoCoulomb
alias of AtomicUnitOfElectricCharge
alias of AtomicUnitOfElectricCharge
alias of AtomicUnitOfElectricCharge
alias of AtomicUnitOfElectricCharge
alias of AtomicUnitOfElectricCharge
alias of AtomicUnitOfElectricCharge
alias of AtomicUnitOfElectricCharge
alias of AtomicUnitOfElectricCharge
alias of AtomicUnitOfElectricCharge
alias of AtomicUnitOfElectricCharge
alias of AtomicUnitOfElectricCharge
alias of AtomicUnitOfElectricCharge
alias of AtomicUnitOfElectricCharge
alias of AtomicUnitOfElectricCharge
alias of AtomicUnitOfElectricCharge
alias of AtomicUnitOfElectricCharge
alias of AtomicUnitOfElectricCharge
alias of AtomicUnitOfElectricCharge
alias of AtomicUnitOfElectricCharge
alias of AtomicUnitOfElectricCharge
alias of AtomicUnitOfElectricCharge
alias of AtomicUnitOfElectricCharge
alias of AtomicUnitOfElectricCharge
alias of AtomicUnitOfElectricCharge
alias of AtomicUnitOfElectricCharge
alias of AtomicUnitOfElectricCharge
alias of AtomicUnitOfElectricCharge
alias of AtomicUnitOfElectricCharge
alias of AtomicUnitOfElectricCharge
alias of AtomicUnitOfElectricCharge
alias of AtomicUnitOfElectricCharge
alias of AtomicUnitOfElectricCharge
alias of AtomicUnitOfElectricCharge
alias of AtomicUnitOfElectricCharge
alias of AtomicUnitOfElectricCharge
alias of AtomicUnitOfElectricCharge
alias of AtomicUnitOfElectricCharge
alias of AtomicUnitOfElectricCharge
alias of AtomicUnitOfElectricCharge
alias of AtomicUnitOfElectricCharge
alias of AtomicUnitOfElectricCharge
alias of AtomicUnitOfElectricCharge
alias of AtomicUnitOfElectricCharge
alias of AtomicUnitOfElectricCharge
alias of YottaAtomicUnitOfCharge
alias of AtomicUnitOfElectricCharge
alias of ZettaAtomicUnitOfCharge
alias of AtomicUnitOfElectricCharge
alias of ExaAtomicUnitOfCharge
alias of AtomicUnitOfElectricCharge
alias of PetaAtomicUnitOfCharge
alias of AtomicUnitOfElectricCharge
alias of TeraAtomicUnitOfCharge
alias of AtomicUnitOfElectricCharge
alias of GigaAtomicUnitOfCharge
alias of AtomicUnitOfElectricCharge
alias of MegaAtomicUnitOfCharge
alias of AtomicUnitOfElectricCharge
alias of KiloAtomicUnitOfCharge
alias of AtomicUnitOfElectricCharge
alias of HectoAtomicUnitOfCharge
alias of AtomicUnitOfElectricCharge
alias of DecaAtomicUnitOfCharge
alias of AtomicUnitOfElectricCharge
alias of DeciAtomicUnitOfCharge
alias of AtomicUnitOfElectricCharge
alias of CentiAtomicUnitOfCharge
alias of AtomicUnitOfElectricCharge
alias of MilliAtomicUnitOfCharge
alias of AtomicUnitOfElectricCharge
alias of MicroAtomicUnitOfCharge
alias of AtomicUnitOfElectricCharge
alias of NanoAtomicUnitOfCharge
alias of AtomicUnitOfElectricCharge
alias of PicoAtomicUnitOfCharge
alias of AtomicUnitOfElectricCharge
alias of FemtoAtomicUnitOfCharge
alias of AtomicUnitOfElectricCharge
alias of AttoAtomicUnitOfCharge
alias of AtomicUnitOfElectricCharge
alias of ZeptoAtomicUnitOfCharge
alias of AtomicUnitOfElectricCharge
alias of YoctoAtomicUnitOfCharge
alias of Gram
alias of Gram
alias of Gram
alias of Gram
alias of Gram
alias of Gram
alias of Gram
alias of Gram
alias of Gram
alias of Gram
alias of Gram
alias of Gram
alias of Gram
alias of Gram
alias of Gram
alias of Gram
alias of Gram
alias of Gram
alias of Gram
alias of Gram
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of AtomicUnitOfMass
alias of AtomicUnitOfMass
alias of AtomicUnitOfMass
alias of AtomicUnitOfMass
alias of AtomicUnitOfMass
alias of AtomicUnitOfMass
alias of AtomicUnitOfMass
alias of AtomicUnitOfMass
alias of AtomicUnitOfMass
alias of AtomicUnitOfMass
alias of AtomicUnitOfMass
alias of AtomicUnitOfMass
alias of AtomicUnitOfMass
alias of AtomicUnitOfMass
alias of AtomicUnitOfMass
alias of AtomicUnitOfMass
alias of AtomicUnitOfMass
alias of AtomicUnitOfMass
alias of AtomicUnitOfMass
alias of AtomicUnitOfMass
alias of AtomicUnitOfMass
alias of AtomicUnitOfMass
alias of AtomicUnitOfMass
alias of AtomicUnitOfMass
alias of AtomicUnitOfMass
alias of AtomicUnitOfMass
alias of AtomicUnitOfMass
alias of AtomicUnitOfMass
alias of AtomicUnitOfMass
alias of AtomicUnitOfMass
alias of AtomicUnitOfMass
alias of AtomicUnitOfMass
alias of AtomicUnitOfMass
alias of AtomicUnitOfMass
alias of AtomicUnitOfMass
alias of AtomicUnitOfMass
alias of AtomicUnitOfMass
alias of AtomicUnitOfMass
alias of AtomicUnitOfMass
alias of AtomicUnitOfMass
alias of AtomicUnitOfMass
A class for composite units, e.g. Joules/Angstrom^2
Analog of Unit.genre. Always returns CompositeUnit
The name of the composite unit, as a product of base units
Reduce the composite unit into the fewest base units possible.
Examples : |
---|
>>> from grendel.util.units import *
>>> (Angstroms**2/Bohr).reduced()
(1.88972612457 Angstrom)
>>> (Degree / (Bohr**2)).reduced()
Degree / Bohr**2
>>> (Degree / (Bohr*Meter)).reduced()
(5.2917721092e-11 Degree / Bohr**2)
Exception for attempted incompatible unit conversions
Exception for attempted conversion of something that is not a subclass of Unit
For errors encountered in handling unitized objects
Alias for has_units()
Aliased as hasunits()
Aliased as stripunits()
Alias for strip_units()
A class for encapsulating a physical constant and it’s units.
Attributes : |
---|
Abstract base class for things with units. It requires its subclasses to implement the properties ‘value’ and ‘units’. Unitized subclasses are also expected have __mul__, __div__, __truediv__, __pow__, __add__, __sub__, __neg__, __pos__, and __abs__ handle units correctly, when implemented in the given subclass.
Raised when a function within the web_getter module cannot find a molecule with the given identifier.
Iterate over all possible partitions of a sequence
Examples : |
---|
This iterates over the brace notation combinations from Allen, et al. Mol. Phys. 89 (1996), 1213-1221 See the explanation of its funtion therein. This is needed for the arbitrary order B tensor formulae.
Examples : |
---|
>>> [tuple(''.join(part) for part in parts) for parts in brace_notation_iter(['AB', 'C', 'D'])]
[('AB', 'C', 'D'), ('AC', 'B', 'D'), ('AD', 'B', 'C'), ('BC', 'A', 'D'), ('BD', 'A', 'C'), ('CD', 'A', 'B')]
chain(*iterables) –> chain object
Return a chain object whose .next() method returns elements from the first iterable until it is exhausted, then elements from the next iterable, until all of the iterables are exhausted.
chain.from_iterable(iterable) –> chain object
Alternate chain() contructor taking a single iterable argument that evaluates lazily.
x.next() -> the next value, or raise StopIteration
combinations_with_replacement(iterable, r) –> combinations_with_replacement object
Return successive r-length combinations of elements in the iterable allowing individual elements to have successive repeats. combinations_with_replacement(‘ABC’, 2) –> AA AB AC BB BC CC
x.next() -> the next value, or raise StopIteration
Iterate over the progressive cumulative sum of the items in the iterable.
Examples : |
---|
>>> [i for i in cummulative_sum(xrange(6))]
[0, 1, 3, 6, 10, 15]
>>> [a for a in cummulative_sum('ABCD', '')]
['A', 'AB', 'ABC', 'ABCD']
>>> [a for a in cummulative_sum(cummulative_sum('ABCD', ''), '')]
['A', 'AAB', 'AABABC', 'AABABCABCD']
>>> [i for i in cummulative_sum(xrange(1,6), 1, op=operator.mul)]
[1, 2, 6, 24, 120]
cycle(iterable) –> cycle object
Return elements from the iterable until it is exhausted. Then repeat the sequence indefinitely.
x.next() -> the next value, or raise StopIteration
Flatten across all levels of iteration.
Examples : |
---|
>>> [f for f in flattened([1,2,3,[4,5,[6]]])]
[1, 2, 3, 4, 5, 6]
>>> [f for f in flattened([1,2,3,[4,5,[6],[[xrange(1,17)]]]])]
[1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]
>>> [f for f in flattened([range(1,4),1,2,3,[4,5,[6],[[xrange(1,17)]]]])]
[1, 2, 3, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]
>>> [f for f in flattened([1, [3, 4], [["hello", ["world"]]], {"yes": True}])]
[1, 3, 4, 'h', 'e', 'l', 'l', 'o', 'w', 'o', 'r', 'l', 'd', 'y', 'e', 's']
>>> [f for f in flattened([1, [3, 4], [["hello", ["world"]]], {"yes": True}], keep_types=str)]
[1, 3, 4, 'hello', 'world', 'yes']
>>> [f for f in flattened([1, [3, 4], [["hello", ["world"]]], {"yes": True}], keep_types=(str, dict))]
[1, 3, 4, 'hello', 'world', {'yes': True}]
>>> [f for f in flattened([1, [3, 4], [["hello", ["world"]]], {"yes": True}], keep_types=(str, dict, list))]
[[1, [3, 4], [['hello', ['world']]], {'yes': True}]]
group(3, ‘ABCDEFG’, ‘x’) –> ABC DEF Gxx
islice(iterable, [start,] stop [, step]) –> islice object
Return an iterator whose next() method returns selected values from an iterable. If start is specified, will skip all preceding elements; otherwise, start defaults to zero. Step defaults to one. If specified as another value, step determines how many values are skipped between successive calls. Works like a slice() on a list but returns an iterator.
x.next() -> the next value, or raise StopIteration
izip_longest(iter1 [,iter2 [...]], [fillvalue=None]) –> izip_longest object
Return an izip_longest object whose .next() method returns a tuple where the i-th element comes from the i-th iterable argument. The .next() method continues until the longest iterable in the argument sequence is exhausted and then it raises StopIteration. When the shorter iterables are exhausted, the fillvalue is substituted in their place. The fillvalue defaults to None or can be specified by a keyword argument.
x.next() -> the next value, or raise StopIteration
OVERVIEW
This function returns a generator that produces all distinct distributions of distinguishable balls among distinguishable boxes, with specified box sizes (capacities). This is a generalization of the most common formulation of the problem, where each box is sufficiently large to accommodate all of the balls.
CONSTRUCTOR INPUTS
n: the number of balls
box_sizes: This argument is a list of length 1 or greater. The length of the list corresponds to the number of boxes. box_sizes[i] is a positive integer that specifies the maximum capacity of the ith box. If box_sizes[i] equals n (or greater), then the ith box can accommodate all n balls and thus effectively has unlimited capacity.
EXAMPLE
Issue the following statement issued at the IPython prompt:
list(labeled_balls_in_labeled_boxes(3,[2,2]))
The output is as follows:
OVERVIEW
This function returns a generator that produces all distinct distributions of distinguishable balls among indistinguishable boxes, with specified box sizes (capacities). This is a generalization of the most common formulation of the problem, where each box is sufficiently large to accommodate all of the balls. It might be asked, ‘In what sense are the boxes indistinguishable if they have different capacities?’ The answer is that the box capacities must be considered when distributing the balls, but once the balls have been distributed, the identities of the boxes no longer matter.
CONSTRUCTOR INPUTS
n: the number of balls
box_sizes: This argument is a list of length 1 or greater. The length of the list corresponds to the number of boxes. box_sizes[i] is a positive integer that specifies the maximum capacity of the ith box. If box_sizes[i] equals n (or greater), then the ith box can accommodate all n balls and thus effectively has unlimited capacity.
NOTE
For labeled_balls_in_unlabeled_boxes, the order of the elements of the box_sizes list is unimportant because the code will sort it into non- increasing order before any other processing is done.
see ordered_partitions_iter
This iterates over the P^k,m operator from Allen, et al. Mol. Phys. 89 (1996), 1213-1221 See the explanation of its funtion therein. This is needed for the arbitrary order B tensor formulae.
Examples : |
---|
>>> [tuple(''.join(part) for part in parts) for parts in ordered_partitions_iter('ABCD', 2)]
[('A', 'BCD'), ('AB', 'CD')]
>>> [tuple(''.join(part) for part in parts) for parts in ordered_partitions_iter('ABCDEF', 3)]
[('A', 'B', 'CDEF'), ('A', 'BC', 'DEF'), ('AB', 'CD', 'EF')]
Iterate over iterable in chunks of sizes given in partitions. If partitions runs out before iterable does, partitions will be cycled (i.e. the next partition size will be the first element of partitions, the following size will be the second, and so on). If there are not enough elements remaining to fill the last partition, the last item yielded will be shorter (just as if a slice running over the end of the list were taken).
Examples : |
---|
>>> [''.join(a) for a in partitioned('ABCDEFG', (1, 3, 2, 1))]
['A', 'BCD', 'EF', 'G']
>>> [''.join(a) for a in partitioned('ABCDEFGHIJ', (1, 3, 2, 1))]
['A', 'BCD', 'EF', 'G', 'H', 'IJ']
>>> [''.join(a) for a in partitioned('ABCDEFGHIJK', (2,))]
['AB', 'CD', 'EF', 'GH', 'IJ', 'K']
>>> [''.join(a) for a in partitioned('ABC', (1, 3, 2, 1))]
['A', 'BC']
>>> [i for i in partitioned('abcdef', (0,3))]
[(), ('a', 'b', 'c'), (), ('d', 'e', 'f'), ()]
>>> [i for i in partitioned('abcdef', (3,1,0,3))]
[('a', 'b', 'c'), ('d',), (), ('e', 'f')]
>>> [i for i in partitioned('abcdef', (3,1,0))]
[('a', 'b', 'c'), ('d',), (), ('e', 'f')]
repeat each element n times before moving on.
Examples : |
---|
>>> [s for s in stutter([1, 2, 3, 4], 3)]
[1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4]
>>> ''.join(a for a in stutter('hello', 2))
'hheelllloo'
tee(iterable, n=2) –> tuple of n independent iterators.
OVERVIEW
This function returns a generator that produces all distinct distributions of indistinguishable balls among labeled boxes with specified box sizes (capacities). This is a generalization of the most common formulation of the problem, where each box is sufficiently large to accommodate all of the balls, and is an important example of a class of combinatorics problems called ‘weak composition’ problems.
CONSTRUCTOR INPUTS
n: the number of balls
box_sizes: This argument is a list of length 1 or greater. The length of the list corresponds to the number of boxes. box_sizes[i] is a positive integer that specifies the maximum capacity of the ith box. If box_sizes[i] equals n (or greater), then the ith box can accommodate all n balls and thus effectively has unlimited capacity.
ACKNOWLEDGMENT
I’d like to thank Chris Rebert for helping me to convert my prototype class-based code into a generator function.
OVERVIEW
This function returns a generator that produces all distinct distributions of indistinguishable balls among indistinguishable boxes, with specified box sizes (capacities). This is a generalization of the most common formulation of the problem, where each box is sufficiently large to accommodate all of the balls. It might be asked, ‘In what sense are the boxes indistinguishable if they have different capacities?’ The answer is that the box capacities must be considered when distributing the balls, but once the balls have been distributed, the identities of the boxes no longer matter.
CONSTRUCTOR INPUTS
n: the number of balls
box_sizes: This argument is a list of length 1 or greater. The length of the list corresponds to the number of boxes. box_sizes[i] is a positive integer that specifies the maximum capacity of the ith box. If box_sizes[i] equals n (or greater), then the ith box can accommodate all n balls and thus effectively has unlimited capacity.
NOTE
For unlabeled_balls_in_unlabeled_boxes, the order of the elements of the box_sizes list is unimportant because the code will sort it into non- increasing order before any other processing is done.
A sequence of regular expressions for parsing a piece of data from a file. The sequence can have optional activation (“start”) and deactivation (“stop”) sequences, and matches are collected from every match of the main regex (or main list of regexes) given. The Ellipsis object may be given in the main sequence (or the start/stop sequences) to indicate that any number of lines may come in between the preceeding and succeding regexes. A RegexSequence.RepeatedRegex object can be used to indicate that a regex can be repeated without invalidating the sequence.
The RegexSequence object is used by passing a file in line by line to the parse_line() method.
A mechanism for allowing a certain part of a pattern to be duplicated an arbitrary number of times in a line.
A super-lightweight class to hold an interlude
Returns the main regex, in order to conform with the Regex class protocol
A regex that may be repeated on multiple consecutive lines without invalidating the sequence. The RepeatedRegex may be repeated an arbitrary (repeats = None, the default) or specified number of times. Currently, the behavior of repeated regexes with exact=False is not stable when multiple (different) RepeatedRegex objects are given consecutively and the number of intervening lines to be matched is fewer than the number of consecutive RepeatedRegex objects minus 1. This is a fairly extreme edge case that is demonstrated in the test suite in test_expected_failures() in the file “test_parsing.py”.
True if reset() would change nothing
Returns a tuple containing all the match groups from all the matches. If the flat argument is True, (default) the groups are flattened across all matches. If flat is False, the groups are only flattened within a given series (this makes no difference for cases where the main regex is a single expression rather than a list of regexes; in this case a flat list of groups is always returned).
The name “groups” is meant to correspond roughly with the naming convention in Python’s re module.
A (possibly nested) list of the matches collected thus far.
Parse a line from a file.
Reset the regex sequence. Do this, for instance, when you’ve finished parsing one file and need to start parsing another. This gets called by the constructor. Most internal uses of this class should already do this when it is supposed to be done.
Abstract base class for regular expressions. For now, anything that responds to ‘match’, ‘search’, and has the attributes ‘flags’ and ‘pattern’ is considered a Regex object. You can’t instantiate a Regex object; the __new__() just returns re.compile() with the same arguments.
Examples : |
---|
>>> import re
>>> isinstance(re.compile(r'test123'), Regex)
True
>>> isinstance(r'test123', Regex)
False
A mechanism for allowing a certain part of a pattern to be duplicated an arbitrary number of times in a line.
A super-lightweight class to hold an interlude
Returns the main regex, in order to conform with the Regex class protocol
alias of RepeatedRegex
A regex that may be repeated on multiple consecutive lines without invalidating the sequence. The RepeatedRegex may be repeated an arbitrary (repeats = None, the default) or specified number of times. Currently, the behavior of repeated regexes with exact=False is not stable when multiple (different) RepeatedRegex objects are given consecutively and the number of intervening lines to be matched is fewer than the number of consecutive RepeatedRegex objects minus 1. This is a fairly extreme edge case that is demonstrated in the test suite in test_expected_failures() in the file “test_parsing.py”.
True if reset() would change nothing
Change to a certain working directory for the execution of a block of code, then change back upon (any kind of) exit.
Generate the factors of an integer.
Examples : |
---|
>>> for i in divisors(12): print i
...
1
2
3
4
6
12
Mostly a wrapper for the NumPy ndarray class. This gives us a place to put tensor-related functionality that we need but is not available in NumPy.
Copy all properties of the tensor except for the data.
Same as numpy.ndarray.flatten, but modified to return a Vector object
Examples : |
---|
>>> t = Tensor([[[1,2],[3,4]],[[5,6],[7,8]]])
>>> t
Tensor([[[ 1., 2.],
[ 3., 4.]],
[[ 5., 6.],
[ 7., 8.]]])
>>> t.flatten()
Vector([ 1., 2., 3., ..., 6., 7., 8.])
List of pointers to IndexRange objects over which the tensor is defined.
Returns True if all elements of self have absolute values less than cutoff, which defaults to Tensor.zero_cutoff
Note
Tensor.zero_cutoff is treated as a pseudo-class attribute for Tensor instances, meaning individual instances can also set a zero_cutoff attribute which will take precidence over the class-level default.
Given any number of Tensor objects that are the same up to a phase factor, return a list of Tensor objects that have been. Copies are only made if necessary. The chosen phase is the one that makes the first non-zero element (in the numpy.nditer(tensor) iterator, using the cutoff keyword argument or Tensor.zero_cutoff if one is not given) positive.
Allows conformance with the Unitized protocol.
Round off near-integer values (within thresh) to integers for each value in the Tensor.
Same as chop, but does not modify the original and instead returns a copy.
A tensor with elements that can be computed as needed.
Warning
Using this class is a very bad idea. It makes development a nightmare. Don’t do it.
Returns True if and only if the tensor has the item without having to compute it. Same as item in self.
Encapsulates a vector. Most functionality gets passed up to Tensor, which in turn passes things up to numpy.ndarray. Special functionality for vectors gets implemented here.
Examples : |
---|
Multiplication >>> from grendel.gmath import Matrix, Vector >>> Matrix([1,2],[3,4]) * Vector([5,6]) Vector([ 17., 39.])
Cartesian components >>> vtwo = Vector(1., 2.) >>> vthree = Vector(1.11, 2.22, 3.33) >>> vtwo[0] 1.0 >>> vtwo.x 1.0 >>> vtwo.y == vtwo[1] True >>> vthree[2] == vthree.z True >>> # Can also set: >>> vtwo.x = -1 >>> vtwo.y = -2 >>> vtwo Vector([-1., -2.]) >>> vthree.x, vthree.z, vthree.y = 1, 3, 2 >>> vthree Vector([ 1., 2., 3.])
Return the column-vector version of self, which is currently implemented as a Matrix object. Note that matrix-vector multiplication will work without getting column first, so don’t use this unless you have a good reason to do so.
Returns cross product of self with other. Wrapper to numpy.cross
Same as normalize(), but does not modify self
Overrides the numpy.ndarray reshape function to make things make sense.
Examples : |
---|
>>> v = Vector([1,2,3,4])
>>> v.reshape((2,2))
Matrix([[ 1., 2.],
[ 3., 4.]])
>>> # `v` is unchanged:
>>> v
Vector([ 1., 2., 3., 4.])
>>> v.reshape((4,1))
Matrix([[ 1.],
[ 2.],
[ 3.],
[ 4.]])
>>> import numpy as np
>>> np.reshape(v, (2,2))
Matrix([[ 1., 2.],
[ 3., 4.]])
The x component of a cartesian vector
Raises : |
---|
The y component of a cartesian vector
Raises : |
---|
The z component of a cartesian vector
Raises : |
---|
Wrapper to numpy.cross which viewcasts the result as a Vector if the first two arguments are Vector objects
Examples : |
---|
>>> cross( Vector(1, 2, 3), Vector(4, 5, 6) )
Vector([-3., 6., -3.])
>>> # Can also be called as a method of Vector
>>> Vector(1, 2, 3).cross( Vector(4, 5, 6) )
Vector([-3., 6., -3.])
Wrapper for Vector.magnitude()
Examples : |
---|
>>> magnitude(Vector(3.0, 4.0))
5.0
Wrapper for Vector.magnitude()
Examples : |
---|
>>> magnitude(Vector(3.0, 4.0))
5.0
Encapsulates a vector. Most functionality gets passed up to Tensor, which in turn passes things up to numpy.ndarray. Special functionality for vectors gets implemented here.
Wrapper to numpy.eigh and numpy.eig for symmetric and non-symmetric matrices, respectively. Note that the eigenvectors are column vectors in the returned matrix.
Number of columns that self has
Number of rows that self has
Returns the Cartesian vector point rotated about axis by angle
Returns the angle between the two vectors, in radians
Allows for the definition of special indices that cover specific ranges and subranges of Tensor axes in einstein summations.
Examples : |
---|
>>> IndexRange.clear_known_ranges() # Don't do this in your program; this is just for the doctest
>>> p = IndexRange('p,q,r,s', 5).with_subranges(
... IndexRange('i,j,k,l', 0, 2),
... IndexRange('a,b,c,d', 2, 5)
... )
>>> p
<IndexRange object covering slice 0:5 represented by indices ['p', 'q', 'r', 's']>
>>> p.subranges[0]
<IndexRange object covering slice 0:2 represented by indices ['i', 'j', 'k', 'l']>
>>> p.subranges[1]
<IndexRange object covering slice 2:5 represented by indices ['a', 'b', 'c', 'd']>
>>> prime = IndexRange["m, m',m''", 10, "m range"].with_subranges(
... IndexRange["n,n',n''", ..., 6, "n range"],
... IndexRange["o,o',o''", 6, ...]
... )
>>> prime
<IndexRange named 'm range' represented by indices ['m', 'm'', 'm''']>
>>> prime.subranges[0]
<IndexRange named 'n range' represented by indices ['n', 'n'', 'n''']>
>>> prime.subranges[1]
<IndexRange object covering slice 6:10 represented by indices ['o', 'o'', 'o''']>
Add a subrange to the list of subranges for self. Note that this returns subrange (with subrange.parent modified) to allow for a ‘pass-through’ like usage (see examples below)
Examples : |
---|
>>> IndexRange.reset_ranges()
>>> p = IndexRange('p,q,r,s', 4, name="orbital space")
>>> # Convenient "pass-through" usage for saving subranges:
>>> i = p.add_subrange(IndexRange('i,j,k,l', 0, 2, name="occupied space"))
>>> a = p.add_subrange(IndexRange('a,b,c,d',2,4))
>>> a
<IndexRange object covering slice 2:4 represented by indices ['a', 'b', 'c', 'd']>
>>> p.subranges[0]
<IndexRange named 'occupied space' represented by indices ['i', 'j', 'k', 'l']>
>>> p.subranges[1]
<IndexRange object covering slice 2:4 represented by indices ['a', 'b', 'c', 'd']>
>>> a.parent
<IndexRange named 'orbital space' represented by indices ['p', 'q', 'r', 's']>
Clears the known ranges. Use with care and only if you’re sure you know what you’re doing!
Clears the known ranges. Use with care and only if you’re sure you know what you’re doing!
Gets the slice of parent_range represented by self (parent_range need not be a direct parent of self, but it should be a parent. See is_subrange())
Examples : |
---|
>>> IndexRange.reset_ranges()
>>> p = IndexRange('p,q,r,s',4)
>>> i = p.add_subrange(IndexRange('i,j,k,l',0,2))
>>> a = p.add_subrange(IndexRange('a,b,c,d',2,4))
>>> a.slice_in(p)
slice(2, 4, None)
Basically the same thing as calling add_subrange() multiple times, except returns self instead of the subrange, allowing for a different syntax (see below)
Examples : |
---|
>>> IndexRange.reset_ranges()
>>> orb = DeclareIndexRange('p,q,r,s', 10, name="Orbital space").with_subranges(
... DeclareIndexRange('i,j,k,l', 0, 3, name="Occupied space").with_subranges(
... DeclareIndexRange("i*,j*,k*,l*", 0, 1, name="Core"),
... DeclareIndexRange("i',j',k',l'", 1, 3)
... ),
... DeclareIndexRange('a,b,c,d', 3, 10, name="Virtual space")
... )
>>> orb
<IndexRange named 'Orbital space' represented by indices ['p', 'q', 'r', 's']>
>>> len(orb.subranges)
2
>>> len(orb.subranges[0].subranges)
2
Alias for IndexRange constructor that more accurately describes what is actually going on.
alias of IndexRangeSet
Returns True if child_range is parent_range or child_range is a child of parent_range (analogous to isinstance from the python standard library)
Returns True if child_range is parent_range or child_range is a child of parent_range (analogous to isinstance from the python standard library)
Metaclass for defining Abstract Base Classes (ABCs).
Use this metaclass to create an ABC. An ABC can be subclassed directly, and then acts as a mix-in class. You can also register unrelated concrete classes (even built-in classes) and unrelated ABCs as ‘virtual subclasses’ – these and their descendants will be considered subclasses of the registering ABC by the built-in issubclass() function, but the registering ABC won’t show up in their MRO (Method Resolution Order) nor will method implementations defined by the registering ABC be callable (not even via super()).
Register a virtual subclass of an ABC.
Abstract base class for things that you are allowed to take derivatives of.
The value of the differentiable property. If this function is not overridden, assume that self can be added and subtracted, as well as multiplied by a float.
An arbitrary finite difference derivative with respect to k FiniteDifferenceVariable instances (not necessarily distinct) of a FiniteDifferenceFunction of an arbitrary number of FiniteDifferenceVariable instances whose output is a Differentiable instance. Ideally, the derivative can be calculated to an arbitrary order of robustness in the displacement, though in practice not all orders may be implemented yet.
Save a little bit of time by prepopulating the single variable displacement formulas dictionary up to max_derivative and max_order. If forward is True, the forward formulas are precomputed instead of the central ones.
A formula for a given finite difference derivative.
The displacement amounts for each of the variables.
Get a value for the displacement corresponding to the (variable, number of deltas) pairs given in the argument pairs
The list of FiniteDifferenceVariable instances on which the function depends.
This class implements rational numbers.
In the two-argument form of the constructor, Fraction(8, 6) will produce a rational number equivalent to 4/3. Both arguments must be Rational. The numerator defaults to 0 and the denominator defaults to 1 so that Fraction(3) == 3 and Fraction() == 0.
Fractions can also be constructed from:
- numeric strings similar to those accepted by the float constructor (for example, ‘-2.3’ or ‘1e10’)
- strings of the form ‘123/456’
- float and Decimal instances
- other Rational instances (including integers)
Converts a finite Decimal instance to a rational number, exactly.
Converts a finite float to a rational number, exactly.
Beware that Fraction.from_float(0.3) != Fraction(3, 10).
Closest Fraction to self with denominator at most max_denominator.
>>> Fraction('3.141592653589793').limit_denominator(10)
Fraction(22, 7)
>>> Fraction('3.141592653589793').limit_denominator(100)
Fraction(311, 99)
>>> Fraction(4321, 8765).limit_denominator(10000)
Fraction(4321, 8765)
A read-only attribute. See SpecialAttribute for initialization variables standard to all SpecialAttribute subclasses.
Attributes : |
---|
Mostly a wrapper for the NumPy ndarray class. This gives us a place to put tensor-related functionality that we need but is not available in NumPy.
Copy all properties of the tensor except for the data.
Same as numpy.ndarray.flatten, but modified to return a Vector object
Examples : |
---|
>>> t = Tensor([[[1,2],[3,4]],[[5,6],[7,8]]])
>>> t
Tensor([[[ 1., 2.],
[ 3., 4.]],
[[ 5., 6.],
[ 7., 8.]]])
>>> t.flatten()
Vector([ 1., 2., 3., ..., 6., 7., 8.])
List of pointers to IndexRange objects over which the tensor is defined.
Returns True if all elements of self have absolute values less than cutoff, which defaults to Tensor.zero_cutoff
Note
Tensor.zero_cutoff is treated as a pseudo-class attribute for Tensor instances, meaning individual instances can also set a zero_cutoff attribute which will take precidence over the class-level default.
Given any number of Tensor objects that are the same up to a phase factor, return a list of Tensor objects that have been. Copies are only made if necessary. The chosen phase is the one that makes the first non-zero element (in the numpy.nditer(tensor) iterator, using the cutoff keyword argument or Tensor.zero_cutoff if one is not given) positive.
Allows conformance with the Unitized protocol.
A decorator indicating abstract methods.
Requires that the metaclass is ABCMeta or derived from it. A class that has a metaclass derived from ABCMeta cannot be instantiated unless all of its abstract methods are overridden. The abstract methods can be called using any of the normal ‘super’ call mechanisms.
Usage:
- class C:
__metaclass__ = ABCMeta @abstractmethod def my_abstract_method(self, ...):
...
A decorator indicating abstract properties.
Requires that the metaclass is ABCMeta or derived from it. A class that has a metaclass derived from ABCMeta cannot be instantiated unless all of its abstract properties are overridden. The abstract properties can be called using any of the normal ‘super’ call mechanisms.
Usage:
- class C:
__metaclass__ = ABCMeta @abstractproperty def my_abstract_property(self):
...
This defines a read-only property; you can also define a read-write abstract property using the ‘long’ form of property declaration:
- class C:
- __metaclass__ = ABCMeta def getx(self): ... def setx(self, value): ... x = abstractproperty(getx, setx)
add(a, b) – Same as a + b.
attrgetter(attr, ...) –> attrgetter object
Return a callable object that fetches the given attribute(s) from its operand. After f = attrgetter(‘name’), the call f(r) returns r.name. After g = attrgetter(‘name’, ‘date’), the call g(r) returns (r.name, r.date). After h = attrgetter(‘name.first’, ‘name.last’), the call h(r) returns (r.name.first, r.name.last).
From Fornberg, Bengt. Mathematics of Computation 51 (1988), p. 699-706 M: “the order of the highest derivative we wish to approximate” N: given “a set of N + 1 grid points” x0: the point at which we wish to take the derivative alpha: alpha_i is the ith grid point
groupby(iterable[, keyfunc]) -> create an iterator which returns (key, sub-iterator) grouped by each value of key(value).
x.next() -> the next value, or raise StopIteration
Aliased as indent()
A simple way to accept arguments that can be an Iterable or a bunch of arguments that should be treated as a single Iterable. (This method is pretty trivial, but I find myself doing it a whole lot.) The reason you can’t just use list() for this purpose is that if an Iterable is given as the only argument, list(args) will return a list of Iterables rather than a single Iterable.
Examples : |
---|
>>> def test(*args):
... return listify_args(*args)
...
>>> test(1,2,3)
[1, 2, 3]
>>> test([1,2,3])
[1, 2, 3]
>>> test([1,2,3], 4)
[[1, 2, 3], 4]
>>> test("1,2,3", 4)
['1,2,3', 4]
>>> test("1,2,3")
['1,2,3']
mul(a, b) – Same as a * b.
Type checking for functions and methods.
Allows the creation of functions with case insensative, alternately named keyword arguments.
Examples : |
---|
>>> @with_flexible_arguments(
... required=[
... ('name', 'greet', 'name_to_greet'),
... ('from_where', 'source')
... ],
... optional=[
... ('greeting', 'hello_phrase', 'salutation'),
... ('message',)
... ]
... )
... def say_hello(name, from_where, greeting='Hello', message=''):
... print(greeting + ', ' + name + ', from ' + from_where + '!' + message)
...
>>> say_hello('moon', 'Earth')
Hello, moon, from Earth!
>>> say_hello('world', source='the moon')
Hello, world, from the moon!
>>> say_hello(source='France', name_to_greet='visitor', salutation='Bonjour')
Bonjour, visitor, from France!
>>> say_hello('earthlings', 'outer space', 'Greetings', message=' We come in peace!')
Greetings, earthlings, from outer space! We come in peace!
Decorator for properties with cached return values. The decorator creates a property that stores the return value of the method call in a variable named _[func_name] (where [func_name] is the name of the function).
Examples : |
---|
>>> class Factorializer(object):
...
... n = None
...
... def __init__(self, n):
... self.n = n
...
... @CachedProperty
... def thirty_plus_n_fact(self):
... ret_val = 1
... for i in xrange(2, self.n + 31):
... ret_val *= i
... return ret_val
...
>>> f = Factorializer(3000)
>>> # Takes some time...
>>> var = f.thirty_plus_n_fact
>>> # Should take no time...
>>> for i in xrange(100):
... var = f.thirty_plus_n_fact
...
>>> # Be careful... Remember to invalidate the cache when the appropriate variables are updated...
>>> f.n = 2500
>>> # Takes no time but gives the wrong answer:
>>> var = f.thirty_plus_n_fact
>>> # Invalidate the cache:
>>> f._thirty_plus_n_fact = None
>>> # This should take some time again, but now it will get the right answer
>>> var = f.thirty_plus_n_fact
Abstract base class for a general coordinate of a Molecule.
Coordinate`s are the components in which `Molecule`s are represented. The most important thing about `Coordinate`s is that they are immutible, like Python’s `str and tuple classes. [#f1]_ Let me say that again a bit louder:
Note
All coordinates are immutable!
Parentage and the molecule attribute: Coordinate instances are typically (though not always) associated with a Representation, accessible through the parent read-only attribute. Coordinate instances that do not have a parent associated with them are called “orphaned” coordinates, and can be identified using the is_orphaned() instance method. Even orphaned coordinates must have a Molecule associated with them in one way or another. This happens in one of three ways:
- If the Coordinate is not orphaned, then parent‘s molecule attribute is used. Note that in this case, the Coordinate protocol requires the Coordinate‘s constituant atoms to have a parent molecule that is exactly the same instance as parent‘s molecule attribute. (If you aren’t doing something weird, this shouldn’t be an issue).
- If the Coordinate is orphaned, it still must be composed of one or more Atom instances, accessible through the atoms attribute. These Atom`s may themselves be orphaned, but if they are not, the first non-orphaned `Atom‘s parent is used. Note that if one Atom is non-orphaned, the Coordinate protocol requires that all of them must not be orphaned (i. e. the Coordinate constructor enforces this when sanity_checking_enabled is True)
- If the Coordinate is orphaned and all of its Atom`s are also orphaned (as is the case, for instance, with `Coordinate instances created for the purpose of finite difference B tensor computation), the Coordinate‘s base_analog attribute may be set to a Coordinate instance whose constituate Atom instances correspond to the derived Coordinate‘s atoms’ base_atom attributes. In this case, the base_analog‘s molecule attribute is used, though it should be utilized for index translation purposes only, since the positions of the atoms in the base molecule will not correspond to the positions of the Coordinate‘s atoms. (The base_analog, in turn, may be an orphaned coordinate of this third type, in which case that coordinate’s base_analog will be used, and so on recursively.)
- If the Coordinate is orphaned and no base_analog is given, then all of the atoms must have a base_atom that either has a parent_molecule or also has a base_atom defined (and so on so that a base_atom eventually has a parent_molecule somewhere up the line). In this case, the Coordinate protocol requires that all the atoms refer to the same Molecule obtained in this manner. Coordinates created in the course of analytic computation of B tensors fall into this catagory.
Indexing schemes: Because all Coordinate`s may be austensibly associated with a `Molecule instance in one way or another, there are two different ways to index various tensor properties of a Coordinate: the Molecule‘s indices (3 * natoms total indices) and the Coordinate‘s indexing scheme (3 * len(coord.atoms) total indices, where coord is a Coordinate instance). The internal indexing scheme makes a lot more sense in many instances, (see the documentation of Coordinate.atoms for a simple example), but for determining properties of the whole molecule, we need to use the Molecule‘s indexing scheme. All of this should be handled seemlessly behind the scenes, but it’s a good distinction to be aware of.
Getting a Coordinate‘s value: Coordinate has a number of methods that can be used to get the value of a Coordinate in a particular scenario. They hierarchically call each other to determine the value of the Coordinate. The basic scheme is as follows:
}
The reason for this relatively complex hierarchy is that there are instances in which I have needed each variety for some reason or another. Nodes with dotted borders must be implemented in the relevant subclasses: SimpleInternalCoordinate subclasses must implement value_for_xyz, InternalCoordinate subclasses must implement value_for_positions, and Coordinate subclasses must implement value_for_molecule_matrix().
Subclassing: |
---|
TODO: write this part
Footnotes
[7] | Since Python doesn’t really have private attributes, you could in theory change some of the attributes of a Coordinate instance after it is created; the designation of “immutible” here merely means that the class is not guarenteed to work if you do. While it’s technically more of a “please don’t” than a “you can’t”, I for one will not be held responsible for your code not working if you do something like that, and the way these private attributes are used and changed is not guarenteed to stay the same between different versions. Bottom line: just don’t do it. If you don’t know what I’m talking about, you’re probably okay. Just don’t access or modify any attributes that start with a single underscore (you should never do this anyway from outside of a class). |
The indices of the atom(s) the Coordinate depends on in the Molecule the Coordinate depends on.
This is guarenteed to work whether or not the Coordinate is orphaned. For each of the various possible Coordinate–Molecule relationships detailed in the Coordinate class documentation, the reason the method works is as follows:
Use this carefully. Don’t ever retrieve an atom’s position by its index in the parent molecule, since that atom may not be the same instance (or even in the same position) as the Coordinate‘s atom.
List of the Atom instances that the Coordinate depends on. In the case of a CartesianCoordinate, for instance, this is trivially one Atom, but in the case of other coordinates it can be much more substantial. In the case of a NormalCoordinate, this is all the atoms in the parent Molecule.
The presence of an atoms list is essential to establish an internal indexing scheme that can be converted to the indexing scheme of the parent molecule. Besides making the B tensor code much more managable, the use of an internal indexing scheme make Coordinate instances much more self-contained, making “orphaned” coordinates much more viable. Consider the following example:
>>> from grendel.util.units import Degrees
>>> from grendel.coordinates.bond_angle import BondAngle
>>> ba = BondAngle(
... Atom('O', [0.0, 0.0, 0.0]),
... Atom('H', [0.0, 1.0, 0.0]),
... Atom('H', [0.0, 0.0, 1.0]),
... units=Degrees
... )
>>> round(ba.value)
90.
If orphaned coordinates where not allowed to exist, we would have to create a Molecule instance containing those three atoms, construct an InternalRepresentation containing the BondAngle instance (which would need to be a valid, complete representation, a non-trivial task in the general case), pair that InternalRepresentation instance with the Molecule instance, get the right Coordinate instance from the InternalRepresentation corresponding to the BondAngle we want, and then get that coordinate’s value. If all of the coordinate’s complicated methods were not implemented in terms of the Coordinate’s own indexing scheme, it would have to have all of this structure in place just to get a value.
Note
Since all Coordinate`s depend on `Atom`s and `Atom`s are not immutible, a `Coordinate`s `value and other properties such as its b_vector can change even if the Coordinate itself cannot. The one way around this is to specify freeze_value as True in the Coordinate‘s constructor. If that is done, the value of the Coordinate will not change over the life of the instance, even if the positions of the constituant atoms does change (so if you use this, make sure you know what you are doing). This behavior is useful, for instance, in the use of CartesianRepresentation`s as “snapshots” of a `Molecule instance to be used for the parsing of a particular RepresentationDependentProperty.
Analogous Coordinate object on the base molecule, if self is a Coordinate on a displaced Molecule, or the Coordinate from which an orphaned displaced Coordinate was created, if the coordinate was created this way.
Every coordinate must define a reasonable default amount for a finite displacement of that kind of coordinate. This should be a class attribute.
Whether or not the Coordinate instance has a parent Representation
Default implementation for coordinates dependent on atoms directly (basically anything but a CartesianCoordinate or some sort of symmetrized cartesian coordinate).
The molecule associated with the Coordinate.
Note
The molecule’s atoms’ positions may not correspond to the positions of the atoms the coordinate describes. See the class documentation for Coordinate for details.
The InternalRepresentation instance which the coordinate self is a part of.
The InternalRepresentation instance which the coordinate self is a part of.
The units in which the coordinate’s value is expressed.
Get the value of the coordinate for the XYZ matrix mat, which is a (self.molecule.natoms) by 3 matrix. In other words, the matrix argument uses the parent Molecule‘s indexing scheme, not the Coordinate‘s own indexing scheme.
Note
For angular coordinates, this always returns a value in Radians. value, value_with_units, and value_for_molecule, however, return values in self.units
Encapsulates the concept of an (energy) derivative with respect to a coordinate. This may later be expanded (in a backwards compatible manner) to include other types of derivatives, e.g. dipole moment derivatives
Attributes : |
---|
The Molecule object to which the coordinate
The order of the derivative. ‘1’ indicates first derivative, ‘2’ indicates second derivative, etc.
A tensor with elements that can be computed as needed.
Warning
Using this class is a very bad idea. It makes development a nightmare. Don’t do it.
Returns True if and only if the tensor has the item without having to compute it. Same as item in self.
Abstract base class for a general coordinate of a Molecule.
Coordinate`s are the components in which `Molecule`s are represented. The most important thing about `Coordinate`s is that they are immutible, like Python’s `str and tuple classes. [#f1]_ Let me say that again a bit louder:
Note
All coordinates are immutable!
Parentage and the molecule attribute: Coordinate instances are typically (though not always) associated with a Representation, accessible through the parent read-only attribute. Coordinate instances that do not have a parent associated with them are called “orphaned” coordinates, and can be identified using the is_orphaned() instance method. Even orphaned coordinates must have a Molecule associated with them in one way or another. This happens in one of three ways:
- If the Coordinate is not orphaned, then parent‘s molecule attribute is used. Note that in this case, the Coordinate protocol requires the Coordinate‘s constituant atoms to have a parent molecule that is exactly the same instance as parent‘s molecule attribute. (If you aren’t doing something weird, this shouldn’t be an issue).
- If the Coordinate is orphaned, it still must be composed of one or more Atom instances, accessible through the atoms attribute. These Atom`s may themselves be orphaned, but if they are not, the first non-orphaned `Atom‘s parent is used. Note that if one Atom is non-orphaned, the Coordinate protocol requires that all of them must not be orphaned (i. e. the Coordinate constructor enforces this when sanity_checking_enabled is True)
- If the Coordinate is orphaned and all of its Atom`s are also orphaned (as is the case, for instance, with `Coordinate instances created for the purpose of finite difference B tensor computation), the Coordinate‘s base_analog attribute may be set to a Coordinate instance whose constituate Atom instances correspond to the derived Coordinate‘s atoms’ base_atom attributes. In this case, the base_analog‘s molecule attribute is used, though it should be utilized for index translation purposes only, since the positions of the atoms in the base molecule will not correspond to the positions of the Coordinate‘s atoms. (The base_analog, in turn, may be an orphaned coordinate of this third type, in which case that coordinate’s base_analog will be used, and so on recursively.)
- If the Coordinate is orphaned and no base_analog is given, then all of the atoms must have a base_atom that either has a parent_molecule or also has a base_atom defined (and so on so that a base_atom eventually has a parent_molecule somewhere up the line). In this case, the Coordinate protocol requires that all the atoms refer to the same Molecule obtained in this manner. Coordinates created in the course of analytic computation of B tensors fall into this catagory.
Indexing schemes: Because all Coordinate`s may be austensibly associated with a `Molecule instance in one way or another, there are two different ways to index various tensor properties of a Coordinate: the Molecule‘s indices (3 * natoms total indices) and the Coordinate‘s indexing scheme (3 * len(coord.atoms) total indices, where coord is a Coordinate instance). The internal indexing scheme makes a lot more sense in many instances, (see the documentation of Coordinate.atoms for a simple example), but for determining properties of the whole molecule, we need to use the Molecule‘s indexing scheme. All of this should be handled seemlessly behind the scenes, but it’s a good distinction to be aware of.
Getting a Coordinate‘s value: Coordinate has a number of methods that can be used to get the value of a Coordinate in a particular scenario. They hierarchically call each other to determine the value of the Coordinate. The basic scheme is as follows:
}
The reason for this relatively complex hierarchy is that there are instances in which I have needed each variety for some reason or another. Nodes with dotted borders must be implemented in the relevant subclasses: SimpleInternalCoordinate subclasses must implement value_for_xyz, InternalCoordinate subclasses must implement value_for_positions, and Coordinate subclasses must implement value_for_molecule_matrix().
Subclassing: |
---|
TODO: write this part
Footnotes
[8] | Since Python doesn’t really have private attributes, you could in theory change some of the attributes of a Coordinate instance after it is created; the designation of “immutible” here merely means that the class is not guarenteed to work if you do. While it’s technically more of a “please don’t” than a “you can’t”, I for one will not be held responsible for your code not working if you do something like that, and the way these private attributes are used and changed is not guarenteed to stay the same between different versions. Bottom line: just don’t do it. If you don’t know what I’m talking about, you’re probably okay. Just don’t access or modify any attributes that start with a single underscore (you should never do this anyway from outside of a class). |
The indices of the atom(s) the Coordinate depends on in the Molecule the Coordinate depends on.
This is guarenteed to work whether or not the Coordinate is orphaned. For each of the various possible Coordinate–Molecule relationships detailed in the Coordinate class documentation, the reason the method works is as follows:
Use this carefully. Don’t ever retrieve an atom’s position by its index in the parent molecule, since that atom may not be the same instance (or even in the same position) as the Coordinate‘s atom.
List of the Atom instances that the Coordinate depends on. In the case of a CartesianCoordinate, for instance, this is trivially one Atom, but in the case of other coordinates it can be much more substantial. In the case of a NormalCoordinate, this is all the atoms in the parent Molecule.
The presence of an atoms list is essential to establish an internal indexing scheme that can be converted to the indexing scheme of the parent molecule. Besides making the B tensor code much more managable, the use of an internal indexing scheme make Coordinate instances much more self-contained, making “orphaned” coordinates much more viable. Consider the following example:
>>> from grendel.util.units import Degrees
>>> from grendel.coordinates.bond_angle import BondAngle
>>> ba = BondAngle(
... Atom('O', [0.0, 0.0, 0.0]),
... Atom('H', [0.0, 1.0, 0.0]),
... Atom('H', [0.0, 0.0, 1.0]),
... units=Degrees
... )
>>> round(ba.value)
90.
If orphaned coordinates where not allowed to exist, we would have to create a Molecule instance containing those three atoms, construct an InternalRepresentation containing the BondAngle instance (which would need to be a valid, complete representation, a non-trivial task in the general case), pair that InternalRepresentation instance with the Molecule instance, get the right Coordinate instance from the InternalRepresentation corresponding to the BondAngle we want, and then get that coordinate’s value. If all of the coordinate’s complicated methods were not implemented in terms of the Coordinate’s own indexing scheme, it would have to have all of this structure in place just to get a value.
Note
Since all Coordinate`s depend on `Atom`s and `Atom`s are not immutible, a `Coordinate`s `value and other properties such as its b_vector can change even if the Coordinate itself cannot. The one way around this is to specify freeze_value as True in the Coordinate‘s constructor. If that is done, the value of the Coordinate will not change over the life of the instance, even if the positions of the constituant atoms does change (so if you use this, make sure you know what you are doing). This behavior is useful, for instance, in the use of CartesianRepresentation`s as “snapshots” of a `Molecule instance to be used for the parsing of a particular RepresentationDependentProperty.
Analogous Coordinate object on the base molecule, if self is a Coordinate on a displaced Molecule, or the Coordinate from which an orphaned displaced Coordinate was created, if the coordinate was created this way.
Every coordinate must define a reasonable default amount for a finite displacement of that kind of coordinate. This should be a class attribute.
Whether or not the Coordinate instance has a parent Representation
Default implementation for coordinates dependent on atoms directly (basically anything but a CartesianCoordinate or some sort of symmetrized cartesian coordinate).
The molecule associated with the Coordinate.
Note
The molecule’s atoms’ positions may not correspond to the positions of the atoms the coordinate describes. See the class documentation for Coordinate for details.
The InternalRepresentation instance which the coordinate self is a part of.
The InternalRepresentation instance which the coordinate self is a part of.
The units in which the coordinate’s value is expressed.
Get the value of the coordinate for the XYZ matrix mat, which is a (self.molecule.natoms) by 3 matrix. In other words, the matrix argument uses the parent Molecule‘s indexing scheme, not the Coordinate‘s own indexing scheme.
Note
For angular coordinates, this always returns a value in Radians. value, value_with_units, and value_for_molecule, however, return values in self.units
A collection of derivatives with indices that are coordinates in a given representation.
An Iterable that is not an instance of basestring
All numbers inherit from this class.
If you just want to check if an argument x is a number, without caring what kind, use isinstance(x, Number).
Superclass of all the representations types.
Attributes : |
|
---|
Make a copy of self that is the same in every way except for the molecule attribute. New Coordinate objects are created using the Coordinate.copy_for_representation() method for each element of self.coords. This is an abstract method that must be implemented by all Representation subclasses.
Apply the Displacement instance disp to the molecule and current representation, generating a new molecule and a new representation (which start as a deepcopy and the return value of Representation.copy_with_molecule, respectively) with the displacement applied. This is an abstract method that must be implemented by all Representation subclasses.
Alias for values_for_matrix()
Alias for values_for_molecule()
Aliased as value_for_matrix()
Aliased as value_for_molecule()
Mostly a wrapper for the NumPy ndarray class. This gives us a place to put tensor-related functionality that we need but is not available in NumPy.
Copy all properties of the tensor except for the data.
Same as numpy.ndarray.flatten, but modified to return a Vector object
Examples : |
---|
>>> t = Tensor([[[1,2],[3,4]],[[5,6],[7,8]]])
>>> t
Tensor([[[ 1., 2.],
[ 3., 4.]],
[[ 5., 6.],
[ 7., 8.]]])
>>> t.flatten()
Vector([ 1., 2., 3., ..., 6., 7., 8.])
List of pointers to IndexRange objects over which the tensor is defined.
Returns True if all elements of self have absolute values less than cutoff, which defaults to Tensor.zero_cutoff
Note
Tensor.zero_cutoff is treated as a pseudo-class attribute for Tensor instances, meaning individual instances can also set a zero_cutoff attribute which will take precidence over the class-level default.
Given any number of Tensor objects that are the same up to a phase factor, return a list of Tensor objects that have been. Copies are only made if necessary. The chosen phase is the one that makes the first non-zero element (in the numpy.nditer(tensor) iterator, using the cutoff keyword argument or Tensor.zero_cutoff if one is not given) positive.
Allows conformance with the Unitized protocol.
Shallow copy operation on arbitrary Python objects.
See the module’s __doc__ string for more info.
Alias for has_units()
Alias for indented()
permutations(iterable[, r]) –> permutations object
Return successive r-length permutations of elements in the iterable.
permutations(range(3), 2) –> (0,1), (0,2), (1,0), (1,2), (2,0), (2,1)
x.next() -> the next value, or raise StopIteration
Alias for short_str()
Type checking for functions and methods.
Encapsulates specifics about how the calculation was/is to be carried out, such as level of theory, basis set, program, etc. Can be subclassed for specific programs which may require special detail setting methods.
Effectively clones details. Used internally for making a details into a ComputationDetails subclass
Mostly for use by templates, this method returns a string of keyword-value pairs in using the given format for each argument in the argument list. format should use the str.format() protocol from the python standard library with the named slots {key} where the keyword name should go and {value} where the value of the detail should go (or, if the value of the detail is a Keyword object, the contents of the value attribute for that Keyword, or, if the value attribute for the keyword is not defined, the _name attribute for the Keyword object in question.
Aliased as keywordify
Mostly for use by templates, this method returns a string of keyword-value pairs in using the given format for each argument in the argument list. format should use the str.format() protocol from the python standard library with the named slots {key} where the keyword name should go and {value} where the value of the detail should go (or, if the value of the detail is a Keyword object, the contents of the value attribute for that Keyword, or, if the value attribute for the keyword is not defined, the _name attribute for the Keyword object in question.
Aliased as keywordify
Abstract base class for a general coordinate of a Molecule.
Coordinate`s are the components in which `Molecule`s are represented. The most important thing about `Coordinate`s is that they are immutible, like Python’s `str and tuple classes. [#f1]_ Let me say that again a bit louder:
Note
All coordinates are immutable!
Parentage and the molecule attribute: Coordinate instances are typically (though not always) associated with a Representation, accessible through the parent read-only attribute. Coordinate instances that do not have a parent associated with them are called “orphaned” coordinates, and can be identified using the is_orphaned() instance method. Even orphaned coordinates must have a Molecule associated with them in one way or another. This happens in one of three ways:
- If the Coordinate is not orphaned, then parent‘s molecule attribute is used. Note that in this case, the Coordinate protocol requires the Coordinate‘s constituant atoms to have a parent molecule that is exactly the same instance as parent‘s molecule attribute. (If you aren’t doing something weird, this shouldn’t be an issue).
- If the Coordinate is orphaned, it still must be composed of one or more Atom instances, accessible through the atoms attribute. These Atom`s may themselves be orphaned, but if they are not, the first non-orphaned `Atom‘s parent is used. Note that if one Atom is non-orphaned, the Coordinate protocol requires that all of them must not be orphaned (i. e. the Coordinate constructor enforces this when sanity_checking_enabled is True)
- If the Coordinate is orphaned and all of its Atom`s are also orphaned (as is the case, for instance, with `Coordinate instances created for the purpose of finite difference B tensor computation), the Coordinate‘s base_analog attribute may be set to a Coordinate instance whose constituate Atom instances correspond to the derived Coordinate‘s atoms’ base_atom attributes. In this case, the base_analog‘s molecule attribute is used, though it should be utilized for index translation purposes only, since the positions of the atoms in the base molecule will not correspond to the positions of the Coordinate‘s atoms. (The base_analog, in turn, may be an orphaned coordinate of this third type, in which case that coordinate’s base_analog will be used, and so on recursively.)
- If the Coordinate is orphaned and no base_analog is given, then all of the atoms must have a base_atom that either has a parent_molecule or also has a base_atom defined (and so on so that a base_atom eventually has a parent_molecule somewhere up the line). In this case, the Coordinate protocol requires that all the atoms refer to the same Molecule obtained in this manner. Coordinates created in the course of analytic computation of B tensors fall into this catagory.
Indexing schemes: Because all Coordinate`s may be austensibly associated with a `Molecule instance in one way or another, there are two different ways to index various tensor properties of a Coordinate: the Molecule‘s indices (3 * natoms total indices) and the Coordinate‘s indexing scheme (3 * len(coord.atoms) total indices, where coord is a Coordinate instance). The internal indexing scheme makes a lot more sense in many instances, (see the documentation of Coordinate.atoms for a simple example), but for determining properties of the whole molecule, we need to use the Molecule‘s indexing scheme. All of this should be handled seemlessly behind the scenes, but it’s a good distinction to be aware of.
Getting a Coordinate‘s value: Coordinate has a number of methods that can be used to get the value of a Coordinate in a particular scenario. They hierarchically call each other to determine the value of the Coordinate. The basic scheme is as follows:
}
The reason for this relatively complex hierarchy is that there are instances in which I have needed each variety for some reason or another. Nodes with dotted borders must be implemented in the relevant subclasses: SimpleInternalCoordinate subclasses must implement value_for_xyz, InternalCoordinate subclasses must implement value_for_positions, and Coordinate subclasses must implement value_for_molecule_matrix().
Subclassing: |
---|
TODO: write this part
Footnotes
[9] | Since Python doesn’t really have private attributes, you could in theory change some of the attributes of a Coordinate instance after it is created; the designation of “immutible” here merely means that the class is not guarenteed to work if you do. While it’s technically more of a “please don’t” than a “you can’t”, I for one will not be held responsible for your code not working if you do something like that, and the way these private attributes are used and changed is not guarenteed to stay the same between different versions. Bottom line: just don’t do it. If you don’t know what I’m talking about, you’re probably okay. Just don’t access or modify any attributes that start with a single underscore (you should never do this anyway from outside of a class). |
The indices of the atom(s) the Coordinate depends on in the Molecule the Coordinate depends on.
This is guarenteed to work whether or not the Coordinate is orphaned. For each of the various possible Coordinate–Molecule relationships detailed in the Coordinate class documentation, the reason the method works is as follows:
Use this carefully. Don’t ever retrieve an atom’s position by its index in the parent molecule, since that atom may not be the same instance (or even in the same position) as the Coordinate‘s atom.
List of the Atom instances that the Coordinate depends on. In the case of a CartesianCoordinate, for instance, this is trivially one Atom, but in the case of other coordinates it can be much more substantial. In the case of a NormalCoordinate, this is all the atoms in the parent Molecule.
The presence of an atoms list is essential to establish an internal indexing scheme that can be converted to the indexing scheme of the parent molecule. Besides making the B tensor code much more managable, the use of an internal indexing scheme make Coordinate instances much more self-contained, making “orphaned” coordinates much more viable. Consider the following example:
>>> from grendel.util.units import Degrees
>>> from grendel.coordinates.bond_angle import BondAngle
>>> ba = BondAngle(
... Atom('O', [0.0, 0.0, 0.0]),
... Atom('H', [0.0, 1.0, 0.0]),
... Atom('H', [0.0, 0.0, 1.0]),
... units=Degrees
... )
>>> round(ba.value)
90.
If orphaned coordinates where not allowed to exist, we would have to create a Molecule instance containing those three atoms, construct an InternalRepresentation containing the BondAngle instance (which would need to be a valid, complete representation, a non-trivial task in the general case), pair that InternalRepresentation instance with the Molecule instance, get the right Coordinate instance from the InternalRepresentation corresponding to the BondAngle we want, and then get that coordinate’s value. If all of the coordinate’s complicated methods were not implemented in terms of the Coordinate’s own indexing scheme, it would have to have all of this structure in place just to get a value.
Note
Since all Coordinate`s depend on `Atom`s and `Atom`s are not immutible, a `Coordinate`s `value and other properties such as its b_vector can change even if the Coordinate itself cannot. The one way around this is to specify freeze_value as True in the Coordinate‘s constructor. If that is done, the value of the Coordinate will not change over the life of the instance, even if the positions of the constituant atoms does change (so if you use this, make sure you know what you are doing). This behavior is useful, for instance, in the use of CartesianRepresentation`s as “snapshots” of a `Molecule instance to be used for the parsing of a particular RepresentationDependentProperty.
Analogous Coordinate object on the base molecule, if self is a Coordinate on a displaced Molecule, or the Coordinate from which an orphaned displaced Coordinate was created, if the coordinate was created this way.
Every coordinate must define a reasonable default amount for a finite displacement of that kind of coordinate. This should be a class attribute.
Whether or not the Coordinate instance has a parent Representation
Default implementation for coordinates dependent on atoms directly (basically anything but a CartesianCoordinate or some sort of symmetrized cartesian coordinate).
The molecule associated with the Coordinate.
Note
The molecule’s atoms’ positions may not correspond to the positions of the atoms the coordinate describes. See the class documentation for Coordinate for details.
The InternalRepresentation instance which the coordinate self is a part of.
The InternalRepresentation instance which the coordinate self is a part of.
The units in which the coordinate’s value is expressed.
Get the value of the coordinate for the XYZ matrix mat, which is a (self.molecule.natoms) by 3 matrix. In other words, the matrix argument uses the parent Molecule‘s indexing scheme, not the Coordinate‘s own indexing scheme.
Note
For angular coordinates, this always returns a value in Radians. value, value_with_units, and value_for_molecule, however, return values in self.units
Abstract base class for things that you are allowed to take derivatives of.
The value of the differentiable property. If this function is not overridden, assume that self can be added and subtracted, as well as multiplied by a float.
Encapsulates a displacement from a base molecule.
Attributes : |
---|
The displaced molecule object resulting from applying self to Molecule
The displaced molecule object resulting from applying self to Molecule
A function (in the finite_difference.FiniteDifferenceFunction sense) that can get values for displacements of some base molecule.
General superclass for all distance units
alias of Angstrom
alias of Angstrom
The displacement amounts for each of the variables.
Get a value for the displacement corresponding to the (variable, number of deltas) pairs given in the argument pairs
The list of FiniteDifferenceVariable instances on which the function depends.
Exception for attempted incompatible unit conversions
Abstract base class for all properties
Attributes : |
---|
molecule : Molecule units : CompositeUnit or class with Unit metaclass
Retrieve the value of the property from a tuple of groups matched in a RegexSequence. See RegexSequence.groups()
Retrieve the value of the property from a RegexSequence object that has already been used on a file. By default, this just calls self.from_groups() with seq.groups(flatten) where flatten comes from self.from_groups.flatten.
The new paradigm for obtaining values. Call the callable instance attribute getter with the arguments and keyword arguments passed in.
The value of the molecular property.
Encapsulates all of the functionality and attributes of a Molecule itself.
Signatures : |
|
---|---|
Parameters : |
Other Parameters: | |
---|---|
Attributes : |
---|
atoms : list of Atom internal_representations : list of InternalRepresentation normal_representation : NormalRepresentation cartesian_representation : CartesianRepresentation description : str
Examples : |
---|
Constructor
>>> Molecule("""
... 5
...
... C 0.000000 0.000000 0.000000
... H 0.000000 0.000000 1.089000
... H 1.026719 0.000000 -0.363000
... H -0.513360 -0.889165 -0.363000
... H -0.513360 0.889165 -0.363000
... """)
Molecule([
Atom('C', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('H', [ 0.00000000, 0.00000000, 1.08900000 ] ),
Atom('H', [ 1.02671900, 0.00000000, -0.36300000 ] ),
Atom('H', [ -0.51336000, -0.88916500, -0.36300000 ] ),
Atom('H', [ -0.51336000, 0.88916500, -0.36300000 ] )
])
>>> Molecule([
... Atom('H', [0,0,0]),
... Atom('H', [0,0,0.75])
... ])
Molecule([
Atom('H', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('H', [ 0.00000000, 0.00000000, 0.75000000 ] )
])
>>> Molecule(['H','C'], Matrix([[0,0,0],[1,0.5,0]]))
Molecule([
Atom('H', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('C', [ 1.00000000, 0.50000000, 0.00000000 ] )
])
>>> mol = Molecule("""
... 5
...
... C 0.000000 0.000000 0.000000
... H 0.000000 0.000000 1.089000
... H 1.026719 0.000000 -0.363000
... H -0.513360 -0.889165 -0.363000
... H -0.513360 0.889165 -0.363000
... """)
>>> mol
Molecule([
Atom('C', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('H', [ 0.00000000, 0.00000000, 1.08900000 ] ),
Atom('H', [ 1.02671900, 0.00000000, -0.36300000 ] ),
Atom('H', [ -0.51336000, -0.88916500, -0.36300000 ] ),
Atom('H', [ -0.51336000, 0.88916500, -0.36300000 ] )
])
Iteration
>>> from __future__ import print_function
>>> for atom in mol:
... print(repr(atom))
...
Atom('C', [ 0.00000000, 0.00000000, 0.00000000 ] )
Atom('H', [ 0.00000000, 0.00000000, 1.08900000 ] )
Atom('H', [ 1.02671900, 0.00000000, -0.36300000 ] )
Atom('H', [ -0.51336000, -0.88916500, -0.36300000 ] )
Atom('H', [ -0.51336000, 0.88916500, -0.36300000 ] )
The first principal axis of rotation, a. The positive phase is always chosen.
Note
This property depends directly on Molecule.principal_axes(), which is cached. See discussion of caching in A_e
The second principal axis of rotation, b. The positive phase is always chosen.
Note
This property depends directly on Molecule.principal_axes(), which is cached. See discussion of caching in A_e
The third principal axis of rotation, c. The positive phase is always chosen.
Note
This property depends directly on Molecule.principal_axes(), which is cached. See discussion of caching in A_e
The current default cartesian representation associated with the molecule. If the molecule has multiple cartesian representations, the first in the list self.cartesian_representations is returned. The setter for this property pushes the cartesian representation onto the front of the list.
Note
The setter does not check for uniqueness (unless it’s exactly the same object as another CartesianRepresentation). Thus, you should check to make sure the CartesianRepresentation you are assigning to the molecule is not already part of the molecule’s list of representations (to the degree of accuracy required for your particular application) before assigning. Repeatedly failing to do this check could cause runaway memory usage.
Returns a Vector giving the center of mass of the molecule in the current Cartesian representation. The units of the returned value are self.cartesian_units.
Note
This result of this method is cached, and the cached value gets flushed in update_cartesian_representation(). If you change an atom’s position (or mass) and forget to call update_cartesian_representation(), you may get some funny results for this method or any methods that depend on it, including recenter(), reorient(), and principal_moments_of_inertia(). You can detect whether caching is causing problems by setting the environment variable GRENDEL_NO_CACHE to 1 and rerunning your tests. If tests that were failing subsequently succeed, you probably forgot to call update_cartesian_representation() somewhere, or you were assuming that it was automatically called somewhere when in fact it was not getting called.
Create a Molecule object using only the name, SMILES, InChIKey, etc.
The easiest way to call Molecule.from_identifier() is to give it a single argument that is one of the following properties: * smiles * stdinchikey * stdinchi * ncicadd_identifier # (for FICTS, FICuS, uuuuu) * hashisy * cas_number * chemspider_id # input must be chemspider_id=1234567 * opsin_name * cir_name (These are resolved in roughly this order.) Visit the NIH CIR documentation for (some) explaination of what these identifiers are: http://cactus.nci.nih.gov/chemical/structure/documentation
Molecule.from_identifier() can be called with any (single) keyword argument in the grendel.util.web_getter.input_identifiers list. In this form, there must be only
This can also be called using an argument that is the value of a property and a second argument that is a list of fields to search for that property in.
Note: Molecule.get() is a very useful alias for this.
Examples : |
---|
TODO
TODO Document this more
Examples : |
---|
>>> Molecule.from_z_matrix("""
... O
... H1 O 1.0
... H2 O 1.0 H1 90.0
... """)
Molecule([
Atom('O', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('H', [ 0.00000000, 0.00000000, 1.00000000 ] ),
Atom('H', [ 0.00000000, -1.00000000, -0.00000000 ] )
])
>>> Molecule.from_z_matrix(
... [
... ['H'],
... ['O', 1, 0.9],
... ['O', 2, 1.4, 1, 105.0],
... ['H', 3, 0.9, 2, 105.0, 1, 120.0]
... ]
... )
Molecule([
Atom('H', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('O', [ 0.00000000, 0.00000000, 0.90000000 ] ),
Atom('O', [ 0.00000000, 1.35229616, 1.26234666 ] ),
Atom('H', [ -0.75286467, 1.46479616, 1.74249095 ] )
])
>>> Molecule.from_z_matrix(
... ['H'],
... ['O', 1, 0.9]
... )
Molecule([
Atom('H', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('O', [ 0.00000000, 0.00000000, 0.90000000 ] )
])
@param string: String containing a z-matrix with labels defined at the end using e.g. a234=8.5 @param args: Passed on to Molecule.from_z_matrix @param kwargs: Passed on to Molecule.from_z_matrix @return: Molecule object corresponding to the z-matrix passed in
Return a list of geometrically separated moieties of the molecule. Note: sub-molecules returned will have charge 0 and multiplicity 1 for now
@param n_vdw_radii: How many Van der Waals radii two atoms may be separated by and still be considered bonded @param default_vdw_radius: Van der Waals radius to use for elements that grendel doesn’t know the VDW radius of. @return: list of moieties as Molecule objects.
Create a Molecule object using only the name, SMILES, InChIKey, etc.
The easiest way to call Molecule.from_identifier() is to give it a single argument that is one of the following properties: * smiles * stdinchikey * stdinchi * ncicadd_identifier # (for FICTS, FICuS, uuuuu) * hashisy * cas_number * chemspider_id # input must be chemspider_id=1234567 * opsin_name * cir_name (These are resolved in roughly this order.) Visit the NIH CIR documentation for (some) explaination of what these identifiers are: http://cactus.nci.nih.gov/chemical/structure/documentation
Molecule.from_identifier() can be called with any (single) keyword argument in the grendel.util.web_getter.input_identifiers list. In this form, there must be only
This can also be called using an argument that is the value of a property and a second argument that is a list of fields to search for that property in.
Note: Molecule.get() is a very useful alias for this.
Examples : |
---|
TODO
Returns True if the elements of self correspond directly to the elements of other (i.e. self.atoms[0].element == other.atoms[0].element and self.atoms[1].element == other.atoms[1].element and ...)
Returns True if all of the elements are the same (including isotope and nuclear spin) and the reoriented() versions of self and other have no atoms whose pairwise position difference has a magnitude greater than tol (which defaults to 1e-8 Angstroms)
Examples : |
---|
>>> mol = Molecule('''
... O 1.5 0.0 0.0
... H 0.2 0.0 0.0
... ''')
>>> m1 = Molecule('''
... O 0.0 1.5 0.0
... H 0.0 0.2 0.0
... ''')
>>> m2 = Molecule('''
... O 0.00000 0.00000 0.200000
... H 0.00000 0.00000 1.500001
... ''')
>>> m3 = Molecule('''
... H 0.0 0.0 0.0
... H 0.0 -1.3 0.0
... ''')
>>> mol.has_same_geometry(m1)
True
>>> m1.has_same_geometry(m2)
False
>>> m1.has_same_geometry(m2, 1e-5)
True
>>> m2.has_same_geometry(mol, 1e-5)
True
>>> m1.has_same_geometry(m3)
False
True if op is a valid symmetry operation on self Each coordinate of the transformed atoms must differ from the original by less than
Returns the index of atom in the atoms array of the molecule
Note
This method returns a cached property Atom.index. If you reorder the atoms in a molecule, be sure and flush this cache by setting atom._index to None for all of the atoms in the reordered molecule.
Raises : |
---|
IndexError : if atom is not found in self
Examples : |
---|
>>> from grendel.chemistry import SampleMolecules, init_sample_molecules
>>> init_sample_molecules()
>>> h2o = SampleMolecules['water']
>>> atom1 = h2o[0]
>>> atom2 = h2o[1]
>>> atom3 = h2o[2]
>>> h2o
Molecule([
Atom('O', [ 0.00000000, 0.00000000, 0.11815400 ] ),
Atom('H', [ 0.00000000, 0.75873400, -0.47261400 ] ),
Atom('H', [ 0.00000000, -0.75873400, -0.47261400 ] )
])
>>> h2o.index(atom2)
1
>>> h2o.index(atom1)
0
>>> # It must be exactly the same instance to avoid raising an index error
>>> h2o.index(Atom('O', [ 0.00000000, 0.00000000, 0.11815400 ] ))
Traceback (most recent call last):
...
IndexError: ...
Returns a tuple of the principal moments of inertia vector and the principal axes matrix.
mol.inertial_system()
Computes the principal moments of inertia and the principal axes.
Note
This funtion mol.recenter() if the molecule is not centered, so any CartesianRepresentations that are not both frozen and referenced elsewhere (e.g. in a RepresentationDependentProperty) will be lost forever.
Note
This method is cached. See discussion of the consequences of caching in Molecule.center_of_mass()
Returns : |
---|
A tuple with types (Vector, Matrix) containing the principal moments of inertia and the principal axes, respectively. These should be aligned (i.e. ret_val[0][1] corresponds to the vector ret_val[1][1])
Examples : |
---|
>>> hnco = Molecule.from_z_matrix("""
... N
... C N 1.2145
... O C 1.1634 N 172.22
... H N 1.0030 C 123.34 O 180.0
... """
... )
>>> i = hnco.inertial_system()
>>> i[0]
Vector([ 0.60187342, 45.48378728, 46.0856607 ])
>>> i[1]
Matrix([[ 0. , 0. , 1. ],
[ 0.09870438, -0.9951168 , 0. ],
[ 0.9951168 , 0.09870438, 0. ]])
>>> j = hnco.inertial_system()
>>> i == j
True
>>> hnco.A_e
28.0085955528 Wavenumber
>>> hnco.B_e
0.370629408869 Wavenumber
>>> hnco.C_e
0.365789031483 Wavenumber
>>> hnco.a
Vector([ 0. , 0.09870438, 0.9951168 ])
>>> hnco.b
Vector([ 0. , -0.9951168 , 0.09870438])
>>> hnco.c
Vector([ 1., 0., 0.])
The first internal representations (of type InternalRepresentation), or None if it does not exist yet.
True if the center of mass is at the origin. This actually computes the vector from the origin to the center of mass and then determines if the magnitude of that vector is less than tol.
Parameters : |
---|
True if the molecule is linear to within tol. All diatomics should return True.
If tol is a ValueWithUnits and tol.units is an AngularUnit, then this method returns True only if all angles in the molecule are within tol of 180 Degrees. If tol.units is a unit-compatible with a moment of inertia (i.e. MassUnit * DistanceUnit**2 ), then this method returns True if the smallest principal moment of inertia is less than tol and the difference between the two largest principal moments of inertia is less than tol. If no units are given (i.e. tol is a float or other float-compatible unit), tol is assumed to have units of AngularUnit.default and the method proceeds as if tol.units was an AngularUnit subclass.
Parameters : |
---|
Examples : |
---|
>>> from grendel.chemistry import SampleMolecules, init_sample_molecules
>>> init_sample_molecules()
>>> SampleMolecules['water'].is_linear()
False
>>> SampleMolecules['CO2'].is_linear()
True
>>> SampleMolecules['Benzene'].is_linear()
False
The principal moments of inertia, as a Vector
Note
This funtion mol.recenter() if the molecule is not centered, so any CartesianRepresentations that are not both frozen and referenced elsewhere (e.g. in a RepresentationDependentProperty) will be lost forever.
Note
This method is cached. See discussion of the consequences of caching in Molecule.center_of_mass()
Examples: >>> hnco = Molecule.from_z_matrix(""" ... N ... C N 1.2145 ... O C 1.1634 N 172.22 ... H N 1.0030 C 123.34 O 180.0 ... """ ... ) >>> hnco.principal_moments_of_inertia() Vector([ 0.60187342, 45.48378728, 46.0856607 ]) >>> hnco.pmi() Vector([ 0.60187342, 45.48378728, 46.0856607 ])
See Also: principal_axes, inertial_system, A_e, B_e, C_e
Aliased as principal_moments_of_inertia()
The molecule’s position as a natoms x 3 Matrix. The ordering of rows is (as expected) the same as the ordering of the Molecule.atoms list attribute. Aliased to xyz_mat and position (the latter to be “consistant-ish” with the naming in Atom.
The principal axes as column vectors in a Matrix. The Vector object mol.principal_axes()[:,i] corresponds to the i`th moment of inertia, `mol.principal_moments_of_inertia()[i].
mol.principal_axes()
Note
This funtion mol.recenter() if the molecule is not centered, so any CartesianRepresentations that are not both frozen and referenced elsewhere (e.g. in a RepresentationDependentProperty) will be lost forever.
Note
This method is cached. See discussion of the consequences of caching in Molecule.center_of_mass()
Examples : |
---|
>>> hnco = Molecule.from_z_matrix("""
... N
... C N 1.2145
... O C 1.1634 N 172.22
... H N 1.0030 C 123.34 O 180.0
... """
... )
>>> hnco.principal_axes()
Matrix([[ 0. , 0. , 1. ],
[ 0.09870438, -0.9951168 , 0. ],
[ 0.9951168 , 0.09870438, 0. ]])
See Also: |
---|
principal_moments_of_inertia, inertial_system, A_e, B_e, C_e
Alias for pmi()
Recenters the molecule about the center of mass This modifies the molecule in place.
Examples : |
---|
>>> m = Molecule([Atom("O", [1.1, 1.3, 1.7])])
>>> m
Molecule([
Atom('O', [ 1.10000000, 1.30000000, 1.70000000 ] )
])
>>> m.recenter()
>>> m
Molecule([
Atom('O', [ 0.00000000, 0.00000000, 0.00000000 ] )
])
>>> m = Molecule(['H','H'], Matrix([[0,0,0],[1,0.0,0]]))
>>> m
Molecule([
Atom('H', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('H', [ 1.00000000, 0.00000000, 0.00000000 ] )
])
>>> m.recenter()
>>> m
Molecule([
Atom('H', [ -0.50000000, 0.00000000, 0.00000000 ] ),
Atom('H', [ 0.50000000, 0.00000000, 0.00000000 ] )
])
Same as recenter, but makes returns a copy. self is not modified.
Examples : |
---|
>>> foo = Molecule([Atom("O", [1.3, 1.7, 2.0])])
>>> bar = foo.recentered()
>>> foo.recenter()
>>> foo
Molecule([
Atom('O', [ 0.00000000, 0.00000000, 0.00000000 ] )
])
>>> foo == bar
True
>>> foo is bar
False
Reorient the molecule to align the x, y, and z axes with the principal axes of rotation.
Parameters : |
---|
Examples : |
---|
>>> from grendel.chemistry import SampleMolecules, init_sample_molecules
>>> init_sample_molecules()
>>> from grendel.gmath import chopped
>>> h2o = SampleMolecules['quantum water']
>>> h2o.principal_axes()
Matrix([[-0. , 0. , 1. ],
[-0.53654222, -0.84387348, 0. ],
[-0.84387348, 0.53654222, 0. ]])
>>> h2o.reorient()
>>> # Use chopped to get rid of very small numerical artifacts...
>>> # using abs to get rid of phase factor
>>> abs(chopped(h2o.principal_axes()))
Matrix([[ 0., 0., 1.],
[ 1., 0., 0.],
[ 0., 1., 0.]])
>>> h2o.reorient("I")
>>> from grendel.gmath import chopped
>>> abs(chopped(h2o.principal_axes()))
Matrix([[ 0., 1., 0.],
[ 0., 0., 1.],
[ 1., 0., 0.]])
>>> h2o.reorient("III")
>>> abs(chopped(h2o.principal_axes()))
Matrix([[ 1., 0., 0.],
[ 0., 1., 0.],
[ 0., 0., 1.]])
Same as reorient, but makes returns a copy. self is not modified.
Examples : |
---|
>>> from grendel.chemistry import SampleMolecules, init_sample_molecules
>>> init_sample_molecules()
>>> from grendel.gmath import chopped
>>> h2o = Molecule([
... Atom('O', [ 0.00000000, 0.00000000, 0.00000000 ] ),
... Atom('H', [ 0.00000000, 0.00000000, 1.00000000 ] ),
... Atom('H', [ 0.00000000, -1.00000000, -0.00000000 ] )
... ])
>>> new = h2o.reoriented()
>>> # Use chopped to get rid of very small numerical artifacts...
>>> chopped(new.principal_axes())
Matrix([[ 0., 0., 1.],
[-1., 0., 0.],
[ 0., 1., 0.]])
>>> new is h2o
False
>>> # original molecule is unchanged...
>>> h2o
Molecule([
Atom('O', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('H', [ 0.00000000, 0.00000000, 1.00000000 ] ),
Atom('H', [ 0.00000000, -1.00000000, -0.00000000 ] )
])
Rotates the molecule about axis (a Vector) by angle
Writes the Molecule to the standard xyz format.
See Molecule.xyz_string() for more details.
See Also: |
---|
xyz_string
The molecule’s position as a natoms x 3 Matrix. The ordering of rows is (as expected) the same as the ordering of the Molecule.atoms list attribute. Aliased to xyz_mat and position (the latter to be “consistant-ish” with the naming in Atom.
The molecule’s position as a natoms x 3 Matrix. The ordering of rows is (as expected) the same as the ordering of the Molecule.atoms list attribute. Aliased to xyz_mat and position (the latter to be “consistant-ish” with the naming in Atom.
The molecule, represented as a string in standard xyz format.
The first line will always be the number of atoms. The second line (which is a comment in the xyz specification) is filled by the description first line of the description attribute.
Parameters : |
---|
Examples : |
---|
>>> from __future__ import print_function
>>> from grendel.chemistry import SampleMolecules, init_sample_molecules
>>> init_sample_molecules()
>>> print(SampleMolecules['water'].xyz_string())
3
CCSD(T)/aug-cc-pVTZ Water
O 0.00000000 0.00000000 0.11815400
H 0.00000000 0.75873400 -0.47261400
H 0.00000000 -0.75873400 -0.47261400
>>> print(Molecule("O 1.0 0.5 1.5").xyz_string("Atom: %2s, x: %3.1f, y: %4.2f, z: %5.3f"))
1
Atom: O, x: 1.0, y: 0.50, z: 1.500
>>> print(Molecule("O 1.0 0.5 1.5").xyz_string("Atom: %2s, x: %3.1f, y: %4.2f, z: %5.3f", False))
Atom: O, x: 1.0, y: 0.50, z: 1.500
A read-only attribute. See SpecialAttribute for initialization variables standard to all SpecialAttribute subclasses.
Attributes : |
---|
Superclass of all the representations types.
Attributes : |
|
---|
Make a copy of self that is the same in every way except for the molecule attribute. New Coordinate objects are created using the Coordinate.copy_for_representation() method for each element of self.coords. This is an abstract method that must be implemented by all Representation subclasses.
Apply the Displacement instance disp to the molecule and current representation, generating a new molecule and a new representation (which start as a deepcopy and the return value of Representation.copy_with_molecule, respectively) with the displacement applied. This is an abstract method that must be implemented by all Representation subclasses.
Alias for values_for_matrix()
Alias for values_for_molecule()
Aliased as value_for_matrix()
Aliased as value_for_molecule()
A property whose value is dependent on a given representation of the molecule.
Aliased as iscompatible()
Shallow copy operation on arbitrary Python objects.
See the module’s __doc__ string for more info.
Alias for has_units()
Aliased as indent()
Type checking for functions and methods.
A representations of a molecule in Cartesian coordinates. Since Atom objects already have Cartesian vectors associated with them, this class mostly consists of helper functions and convenience (accessor) functions that make CartesianRepresentation compatible with the parent Representation class.
Add an atom to the representation by creating a CartesianCoordinate object cooresponding to the atom.
Add a CartesianCoordinate to the representation.
Convenience method for accessing atoms. Returns self.molecule.atoms[number]
Convenience property for referencing the atoms list in the molecule associated with self.
Returns the index of the parameter atom in the representation self.
Parameters : |
---|
Raises : |
---|
Returns the value of the representation as a light vector
Renew the coordinates for an atom to coincide with the atom’s current position
A collection of derivatives with indices that are coordinates in a given representation.
Return the Tensor object corresponding to the `order`th order derivative.
A function (in the finite_difference.FiniteDifferenceFunction sense) that can get values for displacements of some base molecule.
The energy of a molecule.
alias of Wavenumber
An arbitrary finite difference derivative with respect to k FiniteDifferenceVariable instances (not necessarily distinct) of a FiniteDifferenceFunction of an arbitrary number of FiniteDifferenceVariable instances whose output is a Differentiable instance. Ideally, the derivative can be calculated to an arbitrary order of robustness in the displacement, though in practice not all orders may be implemented yet.
Save a little bit of time by prepopulating the single variable displacement formulas dictionary up to max_derivative and max_order. If forward is True, the forward formulas are precomputed instead of the central ones.
An internal coordinate representations of a molecule. TODO: More thoroughly document what this means.
The El’yashevich–Wilson B matrix pseudoinverse, with the Sayvetz conditions used to generate the inverse mass external conditions.
The El’yashevich–Wilson B matrix for the molecule in the representation.
Alias for MolecularPropertyDerivative()
permutations(iterable[, r]) –> permutations object
Return successive r-length permutations of elements in the iterable.
permutations(range(3), 2) –> (0,1), (0,2), (1,0), (1,2), (2,0), (2,1)
x.next() -> the next value, or raise StopIteration
alias of combinations_with_replacement
Type checking for functions and methods.
General superclass for all angular units
alias of Degree
alias of Degree
Decorator for properties with cached return values. The decorator creates a property that stores the return value of the method call in a variable named _[func_name] (where [func_name] is the name of the function).
Examples : |
---|
>>> class Factorializer(object):
...
... n = None
...
... def __init__(self, n):
... self.n = n
...
... @CachedProperty
... def thirty_plus_n_fact(self):
... ret_val = 1
... for i in xrange(2, self.n + 31):
... ret_val *= i
... return ret_val
...
>>> f = Factorializer(3000)
>>> # Takes some time...
>>> var = f.thirty_plus_n_fact
>>> # Should take no time...
>>> for i in xrange(100):
... var = f.thirty_plus_n_fact
...
>>> # Be careful... Remember to invalidate the cache when the appropriate variables are updated...
>>> f.n = 2500
>>> # Takes no time but gives the wrong answer:
>>> var = f.thirty_plus_n_fact
>>> # Invalidate the cache:
>>> f._thirty_plus_n_fact = None
>>> # This should take some time again, but now it will get the right answer
>>> var = f.thirty_plus_n_fact
A representations of a molecule in Cartesian coordinates. Since Atom objects already have Cartesian vectors associated with them, this class mostly consists of helper functions and convenience (accessor) functions that make CartesianRepresentation compatible with the parent Representation class.
Add an atom to the representation by creating a CartesianCoordinate object cooresponding to the atom.
Add a CartesianCoordinate to the representation.
Convenience method for accessing atoms. Returns self.molecule.atoms[number]
Convenience property for referencing the atoms list in the molecule associated with self.
Returns the index of the parameter atom in the representation self.
Parameters : |
---|
Raises : |
---|
Returns the value of the representation as a light vector
Renew the coordinates for an atom to coincide with the atom’s current position
Abstract base class for a general coordinate of a Molecule.
Coordinate`s are the components in which `Molecule`s are represented. The most important thing about `Coordinate`s is that they are immutible, like Python’s `str and tuple classes. [#f1]_ Let me say that again a bit louder:
Note
All coordinates are immutable!
Parentage and the molecule attribute: Coordinate instances are typically (though not always) associated with a Representation, accessible through the parent read-only attribute. Coordinate instances that do not have a parent associated with them are called “orphaned” coordinates, and can be identified using the is_orphaned() instance method. Even orphaned coordinates must have a Molecule associated with them in one way or another. This happens in one of three ways:
- If the Coordinate is not orphaned, then parent‘s molecule attribute is used. Note that in this case, the Coordinate protocol requires the Coordinate‘s constituant atoms to have a parent molecule that is exactly the same instance as parent‘s molecule attribute. (If you aren’t doing something weird, this shouldn’t be an issue).
- If the Coordinate is orphaned, it still must be composed of one or more Atom instances, accessible through the atoms attribute. These Atom`s may themselves be orphaned, but if they are not, the first non-orphaned `Atom‘s parent is used. Note that if one Atom is non-orphaned, the Coordinate protocol requires that all of them must not be orphaned (i. e. the Coordinate constructor enforces this when sanity_checking_enabled is True)
- If the Coordinate is orphaned and all of its Atom`s are also orphaned (as is the case, for instance, with `Coordinate instances created for the purpose of finite difference B tensor computation), the Coordinate‘s base_analog attribute may be set to a Coordinate instance whose constituate Atom instances correspond to the derived Coordinate‘s atoms’ base_atom attributes. In this case, the base_analog‘s molecule attribute is used, though it should be utilized for index translation purposes only, since the positions of the atoms in the base molecule will not correspond to the positions of the Coordinate‘s atoms. (The base_analog, in turn, may be an orphaned coordinate of this third type, in which case that coordinate’s base_analog will be used, and so on recursively.)
- If the Coordinate is orphaned and no base_analog is given, then all of the atoms must have a base_atom that either has a parent_molecule or also has a base_atom defined (and so on so that a base_atom eventually has a parent_molecule somewhere up the line). In this case, the Coordinate protocol requires that all the atoms refer to the same Molecule obtained in this manner. Coordinates created in the course of analytic computation of B tensors fall into this catagory.
Indexing schemes: Because all Coordinate`s may be austensibly associated with a `Molecule instance in one way or another, there are two different ways to index various tensor properties of a Coordinate: the Molecule‘s indices (3 * natoms total indices) and the Coordinate‘s indexing scheme (3 * len(coord.atoms) total indices, where coord is a Coordinate instance). The internal indexing scheme makes a lot more sense in many instances, (see the documentation of Coordinate.atoms for a simple example), but for determining properties of the whole molecule, we need to use the Molecule‘s indexing scheme. All of this should be handled seemlessly behind the scenes, but it’s a good distinction to be aware of.
Getting a Coordinate‘s value: Coordinate has a number of methods that can be used to get the value of a Coordinate in a particular scenario. They hierarchically call each other to determine the value of the Coordinate. The basic scheme is as follows:
}
The reason for this relatively complex hierarchy is that there are instances in which I have needed each variety for some reason or another. Nodes with dotted borders must be implemented in the relevant subclasses: SimpleInternalCoordinate subclasses must implement value_for_xyz, InternalCoordinate subclasses must implement value_for_positions, and Coordinate subclasses must implement value_for_molecule_matrix().
Subclassing: |
---|
TODO: write this part
Footnotes
[10] | Since Python doesn’t really have private attributes, you could in theory change some of the attributes of a Coordinate instance after it is created; the designation of “immutible” here merely means that the class is not guarenteed to work if you do. While it’s technically more of a “please don’t” than a “you can’t”, I for one will not be held responsible for your code not working if you do something like that, and the way these private attributes are used and changed is not guarenteed to stay the same between different versions. Bottom line: just don’t do it. If you don’t know what I’m talking about, you’re probably okay. Just don’t access or modify any attributes that start with a single underscore (you should never do this anyway from outside of a class). |
The indices of the atom(s) the Coordinate depends on in the Molecule the Coordinate depends on.
This is guarenteed to work whether or not the Coordinate is orphaned. For each of the various possible Coordinate–Molecule relationships detailed in the Coordinate class documentation, the reason the method works is as follows:
Use this carefully. Don’t ever retrieve an atom’s position by its index in the parent molecule, since that atom may not be the same instance (or even in the same position) as the Coordinate‘s atom.
List of the Atom instances that the Coordinate depends on. In the case of a CartesianCoordinate, for instance, this is trivially one Atom, but in the case of other coordinates it can be much more substantial. In the case of a NormalCoordinate, this is all the atoms in the parent Molecule.
The presence of an atoms list is essential to establish an internal indexing scheme that can be converted to the indexing scheme of the parent molecule. Besides making the B tensor code much more managable, the use of an internal indexing scheme make Coordinate instances much more self-contained, making “orphaned” coordinates much more viable. Consider the following example:
>>> from grendel.util.units import Degrees
>>> from grendel.coordinates.bond_angle import BondAngle
>>> ba = BondAngle(
... Atom('O', [0.0, 0.0, 0.0]),
... Atom('H', [0.0, 1.0, 0.0]),
... Atom('H', [0.0, 0.0, 1.0]),
... units=Degrees
... )
>>> round(ba.value)
90.
If orphaned coordinates where not allowed to exist, we would have to create a Molecule instance containing those three atoms, construct an InternalRepresentation containing the BondAngle instance (which would need to be a valid, complete representation, a non-trivial task in the general case), pair that InternalRepresentation instance with the Molecule instance, get the right Coordinate instance from the InternalRepresentation corresponding to the BondAngle we want, and then get that coordinate’s value. If all of the coordinate’s complicated methods were not implemented in terms of the Coordinate’s own indexing scheme, it would have to have all of this structure in place just to get a value.
Note
Since all Coordinate`s depend on `Atom`s and `Atom`s are not immutible, a `Coordinate`s `value and other properties such as its b_vector can change even if the Coordinate itself cannot. The one way around this is to specify freeze_value as True in the Coordinate‘s constructor. If that is done, the value of the Coordinate will not change over the life of the instance, even if the positions of the constituant atoms does change (so if you use this, make sure you know what you are doing). This behavior is useful, for instance, in the use of CartesianRepresentation`s as “snapshots” of a `Molecule instance to be used for the parsing of a particular RepresentationDependentProperty.
Analogous Coordinate object on the base molecule, if self is a Coordinate on a displaced Molecule, or the Coordinate from which an orphaned displaced Coordinate was created, if the coordinate was created this way.
Every coordinate must define a reasonable default amount for a finite displacement of that kind of coordinate. This should be a class attribute.
Whether or not the Coordinate instance has a parent Representation
Default implementation for coordinates dependent on atoms directly (basically anything but a CartesianCoordinate or some sort of symmetrized cartesian coordinate).
The molecule associated with the Coordinate.
Note
The molecule’s atoms’ positions may not correspond to the positions of the atoms the coordinate describes. See the class documentation for Coordinate for details.
The InternalRepresentation instance which the coordinate self is a part of.
The InternalRepresentation instance which the coordinate self is a part of.
The units in which the coordinate’s value is expressed.
Get the value of the coordinate for the XYZ matrix mat, which is a (self.molecule.natoms) by 3 matrix. In other words, the matrix argument uses the parent Molecule‘s indexing scheme, not the Coordinate‘s own indexing scheme.
Note
For angular coordinates, this always returns a value in Radians. value, value_with_units, and value_for_molecule, however, return values in self.units
Encapsulates a displacement from a base molecule.
Attributes : |
---|
The displaced molecule object resulting from applying self to Molecule
The displaced molecule object resulting from applying self to Molecule
Exception for attempted incompatible unit conversions
An internal coordinate representations of a molecule. TODO: More thoroughly document what this means.
The El’yashevich–Wilson B matrix pseudoinverse, with the Sayvetz conditions used to generate the inverse mass external conditions.
The El’yashevich–Wilson B matrix for the molecule in the representation.
alias of Iterable
Encapsulates all of the functionality and attributes of a Molecule itself.
Signatures : |
|
---|---|
Parameters : |
Other Parameters: | |
---|---|
Attributes : |
---|
atoms : list of Atom internal_representations : list of InternalRepresentation normal_representation : NormalRepresentation cartesian_representation : CartesianRepresentation description : str
Examples : |
---|
Constructor
>>> Molecule("""
... 5
...
... C 0.000000 0.000000 0.000000
... H 0.000000 0.000000 1.089000
... H 1.026719 0.000000 -0.363000
... H -0.513360 -0.889165 -0.363000
... H -0.513360 0.889165 -0.363000
... """)
Molecule([
Atom('C', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('H', [ 0.00000000, 0.00000000, 1.08900000 ] ),
Atom('H', [ 1.02671900, 0.00000000, -0.36300000 ] ),
Atom('H', [ -0.51336000, -0.88916500, -0.36300000 ] ),
Atom('H', [ -0.51336000, 0.88916500, -0.36300000 ] )
])
>>> Molecule([
... Atom('H', [0,0,0]),
... Atom('H', [0,0,0.75])
... ])
Molecule([
Atom('H', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('H', [ 0.00000000, 0.00000000, 0.75000000 ] )
])
>>> Molecule(['H','C'], Matrix([[0,0,0],[1,0.5,0]]))
Molecule([
Atom('H', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('C', [ 1.00000000, 0.50000000, 0.00000000 ] )
])
>>> mol = Molecule("""
... 5
...
... C 0.000000 0.000000 0.000000
... H 0.000000 0.000000 1.089000
... H 1.026719 0.000000 -0.363000
... H -0.513360 -0.889165 -0.363000
... H -0.513360 0.889165 -0.363000
... """)
>>> mol
Molecule([
Atom('C', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('H', [ 0.00000000, 0.00000000, 1.08900000 ] ),
Atom('H', [ 1.02671900, 0.00000000, -0.36300000 ] ),
Atom('H', [ -0.51336000, -0.88916500, -0.36300000 ] ),
Atom('H', [ -0.51336000, 0.88916500, -0.36300000 ] )
])
Iteration
>>> from __future__ import print_function
>>> for atom in mol:
... print(repr(atom))
...
Atom('C', [ 0.00000000, 0.00000000, 0.00000000 ] )
Atom('H', [ 0.00000000, 0.00000000, 1.08900000 ] )
Atom('H', [ 1.02671900, 0.00000000, -0.36300000 ] )
Atom('H', [ -0.51336000, -0.88916500, -0.36300000 ] )
Atom('H', [ -0.51336000, 0.88916500, -0.36300000 ] )
The first principal axis of rotation, a. The positive phase is always chosen.
Note
This property depends directly on Molecule.principal_axes(), which is cached. See discussion of caching in A_e
The second principal axis of rotation, b. The positive phase is always chosen.
Note
This property depends directly on Molecule.principal_axes(), which is cached. See discussion of caching in A_e
The third principal axis of rotation, c. The positive phase is always chosen.
Note
This property depends directly on Molecule.principal_axes(), which is cached. See discussion of caching in A_e
The current default cartesian representation associated with the molecule. If the molecule has multiple cartesian representations, the first in the list self.cartesian_representations is returned. The setter for this property pushes the cartesian representation onto the front of the list.
Note
The setter does not check for uniqueness (unless it’s exactly the same object as another CartesianRepresentation). Thus, you should check to make sure the CartesianRepresentation you are assigning to the molecule is not already part of the molecule’s list of representations (to the degree of accuracy required for your particular application) before assigning. Repeatedly failing to do this check could cause runaway memory usage.
Returns a Vector giving the center of mass of the molecule in the current Cartesian representation. The units of the returned value are self.cartesian_units.
Note
This result of this method is cached, and the cached value gets flushed in update_cartesian_representation(). If you change an atom’s position (or mass) and forget to call update_cartesian_representation(), you may get some funny results for this method or any methods that depend on it, including recenter(), reorient(), and principal_moments_of_inertia(). You can detect whether caching is causing problems by setting the environment variable GRENDEL_NO_CACHE to 1 and rerunning your tests. If tests that were failing subsequently succeed, you probably forgot to call update_cartesian_representation() somewhere, or you were assuming that it was automatically called somewhere when in fact it was not getting called.
Create a Molecule object using only the name, SMILES, InChIKey, etc.
The easiest way to call Molecule.from_identifier() is to give it a single argument that is one of the following properties: * smiles * stdinchikey * stdinchi * ncicadd_identifier # (for FICTS, FICuS, uuuuu) * hashisy * cas_number * chemspider_id # input must be chemspider_id=1234567 * opsin_name * cir_name (These are resolved in roughly this order.) Visit the NIH CIR documentation for (some) explaination of what these identifiers are: http://cactus.nci.nih.gov/chemical/structure/documentation
Molecule.from_identifier() can be called with any (single) keyword argument in the grendel.util.web_getter.input_identifiers list. In this form, there must be only
This can also be called using an argument that is the value of a property and a second argument that is a list of fields to search for that property in.
Note: Molecule.get() is a very useful alias for this.
Examples : |
---|
TODO
TODO Document this more
Examples : |
---|
>>> Molecule.from_z_matrix("""
... O
... H1 O 1.0
... H2 O 1.0 H1 90.0
... """)
Molecule([
Atom('O', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('H', [ 0.00000000, 0.00000000, 1.00000000 ] ),
Atom('H', [ 0.00000000, -1.00000000, -0.00000000 ] )
])
>>> Molecule.from_z_matrix(
... [
... ['H'],
... ['O', 1, 0.9],
... ['O', 2, 1.4, 1, 105.0],
... ['H', 3, 0.9, 2, 105.0, 1, 120.0]
... ]
... )
Molecule([
Atom('H', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('O', [ 0.00000000, 0.00000000, 0.90000000 ] ),
Atom('O', [ 0.00000000, 1.35229616, 1.26234666 ] ),
Atom('H', [ -0.75286467, 1.46479616, 1.74249095 ] )
])
>>> Molecule.from_z_matrix(
... ['H'],
... ['O', 1, 0.9]
... )
Molecule([
Atom('H', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('O', [ 0.00000000, 0.00000000, 0.90000000 ] )
])
@param string: String containing a z-matrix with labels defined at the end using e.g. a234=8.5 @param args: Passed on to Molecule.from_z_matrix @param kwargs: Passed on to Molecule.from_z_matrix @return: Molecule object corresponding to the z-matrix passed in
Return a list of geometrically separated moieties of the molecule. Note: sub-molecules returned will have charge 0 and multiplicity 1 for now
@param n_vdw_radii: How many Van der Waals radii two atoms may be separated by and still be considered bonded @param default_vdw_radius: Van der Waals radius to use for elements that grendel doesn’t know the VDW radius of. @return: list of moieties as Molecule objects.
Create a Molecule object using only the name, SMILES, InChIKey, etc.
The easiest way to call Molecule.from_identifier() is to give it a single argument that is one of the following properties: * smiles * stdinchikey * stdinchi * ncicadd_identifier # (for FICTS, FICuS, uuuuu) * hashisy * cas_number * chemspider_id # input must be chemspider_id=1234567 * opsin_name * cir_name (These are resolved in roughly this order.) Visit the NIH CIR documentation for (some) explaination of what these identifiers are: http://cactus.nci.nih.gov/chemical/structure/documentation
Molecule.from_identifier() can be called with any (single) keyword argument in the grendel.util.web_getter.input_identifiers list. In this form, there must be only
This can also be called using an argument that is the value of a property and a second argument that is a list of fields to search for that property in.
Note: Molecule.get() is a very useful alias for this.
Examples : |
---|
TODO
Returns True if the elements of self correspond directly to the elements of other (i.e. self.atoms[0].element == other.atoms[0].element and self.atoms[1].element == other.atoms[1].element and ...)
Returns True if all of the elements are the same (including isotope and nuclear spin) and the reoriented() versions of self and other have no atoms whose pairwise position difference has a magnitude greater than tol (which defaults to 1e-8 Angstroms)
Examples : |
---|
>>> mol = Molecule('''
... O 1.5 0.0 0.0
... H 0.2 0.0 0.0
... ''')
>>> m1 = Molecule('''
... O 0.0 1.5 0.0
... H 0.0 0.2 0.0
... ''')
>>> m2 = Molecule('''
... O 0.00000 0.00000 0.200000
... H 0.00000 0.00000 1.500001
... ''')
>>> m3 = Molecule('''
... H 0.0 0.0 0.0
... H 0.0 -1.3 0.0
... ''')
>>> mol.has_same_geometry(m1)
True
>>> m1.has_same_geometry(m2)
False
>>> m1.has_same_geometry(m2, 1e-5)
True
>>> m2.has_same_geometry(mol, 1e-5)
True
>>> m1.has_same_geometry(m3)
False
True if op is a valid symmetry operation on self Each coordinate of the transformed atoms must differ from the original by less than
Returns the index of atom in the atoms array of the molecule
Note
This method returns a cached property Atom.index. If you reorder the atoms in a molecule, be sure and flush this cache by setting atom._index to None for all of the atoms in the reordered molecule.
Raises : |
---|
IndexError : if atom is not found in self
Examples : |
---|
>>> from grendel.chemistry import SampleMolecules, init_sample_molecules
>>> init_sample_molecules()
>>> h2o = SampleMolecules['water']
>>> atom1 = h2o[0]
>>> atom2 = h2o[1]
>>> atom3 = h2o[2]
>>> h2o
Molecule([
Atom('O', [ 0.00000000, 0.00000000, 0.11815400 ] ),
Atom('H', [ 0.00000000, 0.75873400, -0.47261400 ] ),
Atom('H', [ 0.00000000, -0.75873400, -0.47261400 ] )
])
>>> h2o.index(atom2)
1
>>> h2o.index(atom1)
0
>>> # It must be exactly the same instance to avoid raising an index error
>>> h2o.index(Atom('O', [ 0.00000000, 0.00000000, 0.11815400 ] ))
Traceback (most recent call last):
...
IndexError: ...
Returns a tuple of the principal moments of inertia vector and the principal axes matrix.
mol.inertial_system()
Computes the principal moments of inertia and the principal axes.
Note
This funtion mol.recenter() if the molecule is not centered, so any CartesianRepresentations that are not both frozen and referenced elsewhere (e.g. in a RepresentationDependentProperty) will be lost forever.
Note
This method is cached. See discussion of the consequences of caching in Molecule.center_of_mass()
Returns : |
---|
A tuple with types (Vector, Matrix) containing the principal moments of inertia and the principal axes, respectively. These should be aligned (i.e. ret_val[0][1] corresponds to the vector ret_val[1][1])
Examples : |
---|
>>> hnco = Molecule.from_z_matrix("""
... N
... C N 1.2145
... O C 1.1634 N 172.22
... H N 1.0030 C 123.34 O 180.0
... """
... )
>>> i = hnco.inertial_system()
>>> i[0]
Vector([ 0.60187342, 45.48378728, 46.0856607 ])
>>> i[1]
Matrix([[ 0. , 0. , 1. ],
[ 0.09870438, -0.9951168 , 0. ],
[ 0.9951168 , 0.09870438, 0. ]])
>>> j = hnco.inertial_system()
>>> i == j
True
>>> hnco.A_e
28.0085955528 Wavenumber
>>> hnco.B_e
0.370629408869 Wavenumber
>>> hnco.C_e
0.365789031483 Wavenumber
>>> hnco.a
Vector([ 0. , 0.09870438, 0.9951168 ])
>>> hnco.b
Vector([ 0. , -0.9951168 , 0.09870438])
>>> hnco.c
Vector([ 1., 0., 0.])
The first internal representations (of type InternalRepresentation), or None if it does not exist yet.
True if the center of mass is at the origin. This actually computes the vector from the origin to the center of mass and then determines if the magnitude of that vector is less than tol.
Parameters : |
---|
True if the molecule is linear to within tol. All diatomics should return True.
If tol is a ValueWithUnits and tol.units is an AngularUnit, then this method returns True only if all angles in the molecule are within tol of 180 Degrees. If tol.units is a unit-compatible with a moment of inertia (i.e. MassUnit * DistanceUnit**2 ), then this method returns True if the smallest principal moment of inertia is less than tol and the difference between the two largest principal moments of inertia is less than tol. If no units are given (i.e. tol is a float or other float-compatible unit), tol is assumed to have units of AngularUnit.default and the method proceeds as if tol.units was an AngularUnit subclass.
Parameters : |
---|
Examples : |
---|
>>> from grendel.chemistry import SampleMolecules, init_sample_molecules
>>> init_sample_molecules()
>>> SampleMolecules['water'].is_linear()
False
>>> SampleMolecules['CO2'].is_linear()
True
>>> SampleMolecules['Benzene'].is_linear()
False
The principal moments of inertia, as a Vector
Note
This funtion mol.recenter() if the molecule is not centered, so any CartesianRepresentations that are not both frozen and referenced elsewhere (e.g. in a RepresentationDependentProperty) will be lost forever.
Note
This method is cached. See discussion of the consequences of caching in Molecule.center_of_mass()
Examples: >>> hnco = Molecule.from_z_matrix(""" ... N ... C N 1.2145 ... O C 1.1634 N 172.22 ... H N 1.0030 C 123.34 O 180.0 ... """ ... ) >>> hnco.principal_moments_of_inertia() Vector([ 0.60187342, 45.48378728, 46.0856607 ]) >>> hnco.pmi() Vector([ 0.60187342, 45.48378728, 46.0856607 ])
See Also: principal_axes, inertial_system, A_e, B_e, C_e
Aliased as principal_moments_of_inertia()
The molecule’s position as a natoms x 3 Matrix. The ordering of rows is (as expected) the same as the ordering of the Molecule.atoms list attribute. Aliased to xyz_mat and position (the latter to be “consistant-ish” with the naming in Atom.
The principal axes as column vectors in a Matrix. The Vector object mol.principal_axes()[:,i] corresponds to the i`th moment of inertia, `mol.principal_moments_of_inertia()[i].
mol.principal_axes()
Note
This funtion mol.recenter() if the molecule is not centered, so any CartesianRepresentations that are not both frozen and referenced elsewhere (e.g. in a RepresentationDependentProperty) will be lost forever.
Note
This method is cached. See discussion of the consequences of caching in Molecule.center_of_mass()
Examples : |
---|
>>> hnco = Molecule.from_z_matrix("""
... N
... C N 1.2145
... O C 1.1634 N 172.22
... H N 1.0030 C 123.34 O 180.0
... """
... )
>>> hnco.principal_axes()
Matrix([[ 0. , 0. , 1. ],
[ 0.09870438, -0.9951168 , 0. ],
[ 0.9951168 , 0.09870438, 0. ]])
See Also: |
---|
principal_moments_of_inertia, inertial_system, A_e, B_e, C_e
Alias for pmi()
Recenters the molecule about the center of mass This modifies the molecule in place.
Examples : |
---|
>>> m = Molecule([Atom("O", [1.1, 1.3, 1.7])])
>>> m
Molecule([
Atom('O', [ 1.10000000, 1.30000000, 1.70000000 ] )
])
>>> m.recenter()
>>> m
Molecule([
Atom('O', [ 0.00000000, 0.00000000, 0.00000000 ] )
])
>>> m = Molecule(['H','H'], Matrix([[0,0,0],[1,0.0,0]]))
>>> m
Molecule([
Atom('H', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('H', [ 1.00000000, 0.00000000, 0.00000000 ] )
])
>>> m.recenter()
>>> m
Molecule([
Atom('H', [ -0.50000000, 0.00000000, 0.00000000 ] ),
Atom('H', [ 0.50000000, 0.00000000, 0.00000000 ] )
])
Same as recenter, but makes returns a copy. self is not modified.
Examples : |
---|
>>> foo = Molecule([Atom("O", [1.3, 1.7, 2.0])])
>>> bar = foo.recentered()
>>> foo.recenter()
>>> foo
Molecule([
Atom('O', [ 0.00000000, 0.00000000, 0.00000000 ] )
])
>>> foo == bar
True
>>> foo is bar
False
Reorient the molecule to align the x, y, and z axes with the principal axes of rotation.
Parameters : |
---|
Examples : |
---|
>>> from grendel.chemistry import SampleMolecules, init_sample_molecules
>>> init_sample_molecules()
>>> from grendel.gmath import chopped
>>> h2o = SampleMolecules['quantum water']
>>> h2o.principal_axes()
Matrix([[-0. , 0. , 1. ],
[-0.53654222, -0.84387348, 0. ],
[-0.84387348, 0.53654222, 0. ]])
>>> h2o.reorient()
>>> # Use chopped to get rid of very small numerical artifacts...
>>> # using abs to get rid of phase factor
>>> abs(chopped(h2o.principal_axes()))
Matrix([[ 0., 0., 1.],
[ 1., 0., 0.],
[ 0., 1., 0.]])
>>> h2o.reorient("I")
>>> from grendel.gmath import chopped
>>> abs(chopped(h2o.principal_axes()))
Matrix([[ 0., 1., 0.],
[ 0., 0., 1.],
[ 1., 0., 0.]])
>>> h2o.reorient("III")
>>> abs(chopped(h2o.principal_axes()))
Matrix([[ 1., 0., 0.],
[ 0., 1., 0.],
[ 0., 0., 1.]])
Same as reorient, but makes returns a copy. self is not modified.
Examples : |
---|
>>> from grendel.chemistry import SampleMolecules, init_sample_molecules
>>> init_sample_molecules()
>>> from grendel.gmath import chopped
>>> h2o = Molecule([
... Atom('O', [ 0.00000000, 0.00000000, 0.00000000 ] ),
... Atom('H', [ 0.00000000, 0.00000000, 1.00000000 ] ),
... Atom('H', [ 0.00000000, -1.00000000, -0.00000000 ] )
... ])
>>> new = h2o.reoriented()
>>> # Use chopped to get rid of very small numerical artifacts...
>>> chopped(new.principal_axes())
Matrix([[ 0., 0., 1.],
[-1., 0., 0.],
[ 0., 1., 0.]])
>>> new is h2o
False
>>> # original molecule is unchanged...
>>> h2o
Molecule([
Atom('O', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('H', [ 0.00000000, 0.00000000, 1.00000000 ] ),
Atom('H', [ 0.00000000, -1.00000000, -0.00000000 ] )
])
Rotates the molecule about axis (a Vector) by angle
Writes the Molecule to the standard xyz format.
See Molecule.xyz_string() for more details.
See Also: |
---|
xyz_string
The molecule’s position as a natoms x 3 Matrix. The ordering of rows is (as expected) the same as the ordering of the Molecule.atoms list attribute. Aliased to xyz_mat and position (the latter to be “consistant-ish” with the naming in Atom.
The molecule’s position as a natoms x 3 Matrix. The ordering of rows is (as expected) the same as the ordering of the Molecule.atoms list attribute. Aliased to xyz_mat and position (the latter to be “consistant-ish” with the naming in Atom.
The molecule, represented as a string in standard xyz format.
The first line will always be the number of atoms. The second line (which is a comment in the xyz specification) is filled by the description first line of the description attribute.
Parameters : |
---|
Examples : |
---|
>>> from __future__ import print_function
>>> from grendel.chemistry import SampleMolecules, init_sample_molecules
>>> init_sample_molecules()
>>> print(SampleMolecules['water'].xyz_string())
3
CCSD(T)/aug-cc-pVTZ Water
O 0.00000000 0.00000000 0.11815400
H 0.00000000 0.75873400 -0.47261400
H 0.00000000 -0.75873400 -0.47261400
>>> print(Molecule("O 1.0 0.5 1.5").xyz_string("Atom: %2s, x: %3.1f, y: %4.2f, z: %5.3f"))
1
Atom: O, x: 1.0, y: 0.50, z: 1.500
>>> print(Molecule("O 1.0 0.5 1.5").xyz_string("Atom: %2s, x: %3.1f, y: %4.2f, z: %5.3f", False))
Atom: O, x: 1.0, y: 0.50, z: 1.500
All numbers inherit from this class.
If you just want to check if an argument x is a number, without caring what kind, use isinstance(x, Number).
alias of Radian
A read-only attribute. See SpecialAttribute for initialization variables standard to all SpecialAttribute subclasses.
Attributes : |
---|
Superclass of all the representations types.
Attributes : |
|
---|
Make a copy of self that is the same in every way except for the molecule attribute. New Coordinate objects are created using the Coordinate.copy_for_representation() method for each element of self.coords. This is an abstract method that must be implemented by all Representation subclasses.
Apply the Displacement instance disp to the molecule and current representation, generating a new molecule and a new representation (which start as a deepcopy and the return value of Representation.copy_with_molecule, respectively) with the displacement applied. This is an abstract method that must be implemented by all Representation subclasses.
Alias for values_for_matrix()
Alias for values_for_molecule()
Aliased as value_for_matrix()
Aliased as value_for_molecule()
Encapsulates a vector. Most functionality gets passed up to Tensor, which in turn passes things up to numpy.ndarray. Special functionality for vectors gets implemented here.
Examples : |
---|
Multiplication >>> from grendel.gmath import Matrix, Vector >>> Matrix([1,2],[3,4]) * Vector([5,6]) Vector([ 17., 39.])
Cartesian components >>> vtwo = Vector(1., 2.) >>> vthree = Vector(1.11, 2.22, 3.33) >>> vtwo[0] 1.0 >>> vtwo.x 1.0 >>> vtwo.y == vtwo[1] True >>> vthree[2] == vthree.z True >>> # Can also set: >>> vtwo.x = -1 >>> vtwo.y = -2 >>> vtwo Vector([-1., -2.]) >>> vthree.x, vthree.z, vthree.y = 1, 3, 2 >>> vthree Vector([ 1., 2., 3.])
Return the column-vector version of self, which is currently implemented as a Matrix object. Note that matrix-vector multiplication will work without getting column first, so don’t use this unless you have a good reason to do so.
Returns cross product of self with other. Wrapper to numpy.cross
Same as normalize(), but does not modify self
Overrides the numpy.ndarray reshape function to make things make sense.
Examples : |
---|
>>> v = Vector([1,2,3,4])
>>> v.reshape((2,2))
Matrix([[ 1., 2.],
[ 3., 4.]])
>>> # `v` is unchanged:
>>> v
Vector([ 1., 2., 3., 4.])
>>> v.reshape((4,1))
Matrix([[ 1.],
[ 2.],
[ 3.],
[ 4.]])
>>> import numpy as np
>>> np.reshape(v, (2,2))
Matrix([[ 1., 2.],
[ 3., 4.]])
The x component of a cartesian vector
Raises : |
---|
The y component of a cartesian vector
Raises : |
---|
The z component of a cartesian vector
Raises : |
---|
Aliased as iscompatible()
Alias for has_units()
product(*iterables) –> product object
Cartesian product of input iterables. Equivalent to nested for-loops.
For example, product(A, B) returns the same as: ((x,y) for x in A for y in B). The leftmost iterators are in the outermost for-loop, so the output tuples cycle in a manner similar to an odometer (with the rightmost element changing on every iteration).
To compute the product of an iterable with itself, specify the number of repetitions with the optional repeat keyword argument. For example, product(A, repeat=4) means the same as product(A, A, A, A).
product(‘ab’, range(3)) –> (‘a’,0) (‘a’,1) (‘a’,2) (‘b’,0) (‘b’,1) (‘b’,2) product((0,1), (0,1), (0,1)) –> (0,0,0) (0,0,1) (0,1,0) (0,1,1) (1,0,0) ...
x.next() -> the next value, or raise StopIteration
Aliased as stripunits()
Type checking for functions and methods.
Allows the creation of functions with case insensative, alternately named keyword arguments.
Examples : |
---|
>>> @with_flexible_arguments(
... required=[
... ('name', 'greet', 'name_to_greet'),
... ('from_where', 'source')
... ],
... optional=[
... ('greeting', 'hello_phrase', 'salutation'),
... ('message',)
... ]
... )
... def say_hello(name, from_where, greeting='Hello', message=''):
... print(greeting + ', ' + name + ', from ' + from_where + '!' + message)
...
>>> say_hello('moon', 'Earth')
Hello, moon, from Earth!
>>> say_hello('world', source='the moon')
Hello, world, from the moon!
>>> say_hello(source='France', name_to_greet='visitor', salutation='Bonjour')
Bonjour, visitor, from France!
>>> say_hello('earthlings', 'outer space', 'Greetings', message=' We come in peace!')
Greetings, earthlings, from outer space! We come in peace!
Abstract base class for a general coordinate of a Molecule.
Coordinate`s are the components in which `Molecule`s are represented. The most important thing about `Coordinate`s is that they are immutible, like Python’s `str and tuple classes. [#f1]_ Let me say that again a bit louder:
Note
All coordinates are immutable!
Parentage and the molecule attribute: Coordinate instances are typically (though not always) associated with a Representation, accessible through the parent read-only attribute. Coordinate instances that do not have a parent associated with them are called “orphaned” coordinates, and can be identified using the is_orphaned() instance method. Even orphaned coordinates must have a Molecule associated with them in one way or another. This happens in one of three ways:
- If the Coordinate is not orphaned, then parent‘s molecule attribute is used. Note that in this case, the Coordinate protocol requires the Coordinate‘s constituant atoms to have a parent molecule that is exactly the same instance as parent‘s molecule attribute. (If you aren’t doing something weird, this shouldn’t be an issue).
- If the Coordinate is orphaned, it still must be composed of one or more Atom instances, accessible through the atoms attribute. These Atom`s may themselves be orphaned, but if they are not, the first non-orphaned `Atom‘s parent is used. Note that if one Atom is non-orphaned, the Coordinate protocol requires that all of them must not be orphaned (i. e. the Coordinate constructor enforces this when sanity_checking_enabled is True)
- If the Coordinate is orphaned and all of its Atom`s are also orphaned (as is the case, for instance, with `Coordinate instances created for the purpose of finite difference B tensor computation), the Coordinate‘s base_analog attribute may be set to a Coordinate instance whose constituate Atom instances correspond to the derived Coordinate‘s atoms’ base_atom attributes. In this case, the base_analog‘s molecule attribute is used, though it should be utilized for index translation purposes only, since the positions of the atoms in the base molecule will not correspond to the positions of the Coordinate‘s atoms. (The base_analog, in turn, may be an orphaned coordinate of this third type, in which case that coordinate’s base_analog will be used, and so on recursively.)
- If the Coordinate is orphaned and no base_analog is given, then all of the atoms must have a base_atom that either has a parent_molecule or also has a base_atom defined (and so on so that a base_atom eventually has a parent_molecule somewhere up the line). In this case, the Coordinate protocol requires that all the atoms refer to the same Molecule obtained in this manner. Coordinates created in the course of analytic computation of B tensors fall into this catagory.
Indexing schemes: Because all Coordinate`s may be austensibly associated with a `Molecule instance in one way or another, there are two different ways to index various tensor properties of a Coordinate: the Molecule‘s indices (3 * natoms total indices) and the Coordinate‘s indexing scheme (3 * len(coord.atoms) total indices, where coord is a Coordinate instance). The internal indexing scheme makes a lot more sense in many instances, (see the documentation of Coordinate.atoms for a simple example), but for determining properties of the whole molecule, we need to use the Molecule‘s indexing scheme. All of this should be handled seemlessly behind the scenes, but it’s a good distinction to be aware of.
Getting a Coordinate‘s value: Coordinate has a number of methods that can be used to get the value of a Coordinate in a particular scenario. They hierarchically call each other to determine the value of the Coordinate. The basic scheme is as follows:
}
The reason for this relatively complex hierarchy is that there are instances in which I have needed each variety for some reason or another. Nodes with dotted borders must be implemented in the relevant subclasses: SimpleInternalCoordinate subclasses must implement value_for_xyz, InternalCoordinate subclasses must implement value_for_positions, and Coordinate subclasses must implement value_for_molecule_matrix().
Subclassing: |
---|
TODO: write this part
Footnotes
[11] | Since Python doesn’t really have private attributes, you could in theory change some of the attributes of a Coordinate instance after it is created; the designation of “immutible” here merely means that the class is not guarenteed to work if you do. While it’s technically more of a “please don’t” than a “you can’t”, I for one will not be held responsible for your code not working if you do something like that, and the way these private attributes are used and changed is not guarenteed to stay the same between different versions. Bottom line: just don’t do it. If you don’t know what I’m talking about, you’re probably okay. Just don’t access or modify any attributes that start with a single underscore (you should never do this anyway from outside of a class). |
The indices of the atom(s) the Coordinate depends on in the Molecule the Coordinate depends on.
This is guarenteed to work whether or not the Coordinate is orphaned. For each of the various possible Coordinate–Molecule relationships detailed in the Coordinate class documentation, the reason the method works is as follows:
Use this carefully. Don’t ever retrieve an atom’s position by its index in the parent molecule, since that atom may not be the same instance (or even in the same position) as the Coordinate‘s atom.
List of the Atom instances that the Coordinate depends on. In the case of a CartesianCoordinate, for instance, this is trivially one Atom, but in the case of other coordinates it can be much more substantial. In the case of a NormalCoordinate, this is all the atoms in the parent Molecule.
The presence of an atoms list is essential to establish an internal indexing scheme that can be converted to the indexing scheme of the parent molecule. Besides making the B tensor code much more managable, the use of an internal indexing scheme make Coordinate instances much more self-contained, making “orphaned” coordinates much more viable. Consider the following example:
>>> from grendel.util.units import Degrees
>>> from grendel.coordinates.bond_angle import BondAngle
>>> ba = BondAngle(
... Atom('O', [0.0, 0.0, 0.0]),
... Atom('H', [0.0, 1.0, 0.0]),
... Atom('H', [0.0, 0.0, 1.0]),
... units=Degrees
... )
>>> round(ba.value)
90.
If orphaned coordinates where not allowed to exist, we would have to create a Molecule instance containing those three atoms, construct an InternalRepresentation containing the BondAngle instance (which would need to be a valid, complete representation, a non-trivial task in the general case), pair that InternalRepresentation instance with the Molecule instance, get the right Coordinate instance from the InternalRepresentation corresponding to the BondAngle we want, and then get that coordinate’s value. If all of the coordinate’s complicated methods were not implemented in terms of the Coordinate’s own indexing scheme, it would have to have all of this structure in place just to get a value.
Note
Since all Coordinate`s depend on `Atom`s and `Atom`s are not immutible, a `Coordinate`s `value and other properties such as its b_vector can change even if the Coordinate itself cannot. The one way around this is to specify freeze_value as True in the Coordinate‘s constructor. If that is done, the value of the Coordinate will not change over the life of the instance, even if the positions of the constituant atoms does change (so if you use this, make sure you know what you are doing). This behavior is useful, for instance, in the use of CartesianRepresentation`s as “snapshots” of a `Molecule instance to be used for the parsing of a particular RepresentationDependentProperty.
Analogous Coordinate object on the base molecule, if self is a Coordinate on a displaced Molecule, or the Coordinate from which an orphaned displaced Coordinate was created, if the coordinate was created this way.
Every coordinate must define a reasonable default amount for a finite displacement of that kind of coordinate. This should be a class attribute.
Whether or not the Coordinate instance has a parent Representation
Default implementation for coordinates dependent on atoms directly (basically anything but a CartesianCoordinate or some sort of symmetrized cartesian coordinate).
The molecule associated with the Coordinate.
Note
The molecule’s atoms’ positions may not correspond to the positions of the atoms the coordinate describes. See the class documentation for Coordinate for details.
The InternalRepresentation instance which the coordinate self is a part of.
The InternalRepresentation instance which the coordinate self is a part of.
The units in which the coordinate’s value is expressed.
Get the value of the coordinate for the XYZ matrix mat, which is a (self.molecule.natoms) by 3 matrix. In other words, the matrix argument uses the parent Molecule‘s indexing scheme, not the Coordinate‘s own indexing scheme.
Note
For angular coordinates, this always returns a value in Radians. value, value_with_units, and value_for_molecule, however, return values in self.units
A cartesian coordinate compatible with the Coordinate class. CartesianCoordinate objects are immutable. If you need a different cartesian coordinate, create a new CartesianCoordinate objects.
Attributes : |
---|
The atom to which the cartesian coordinate refers.
The direction (x, y, or z) that the coordinate describes. (0 for X, 1 for Y, 2 for Z, which are also class constants)
The index in the parent representation. This allows for the retrieval of the value for the coordinate on a different molecule, for instance.
General superclass for all types internal coordinates. Internal coordinates may only refer to one representation.
Compute the analytic B tensor of a given order and return a tensor indexed by the coordinate’s own indexing scheme.
Retrieve an element of the Coordinate’s B tensor using CartesianCoordinate instances and/or integer indices in the molecule’s indexing scheme.
Fill the coordinate’s own _btensor attribute for a given order. (The _btensor attribute should be retrieved using the get_b_tensor() method, which calls this if the _btensor has not already been computed.) If the b tensor cannot be computed analytically at the given order, this method returns NotImplemented. Otherwise, it computes the B tensor to the given order and returns None. If the optional B argument is given, this Coordinate’s part of the Representation-based TensorCollection that B refers to is filled as well.
Computes the B tensor for order order by finite difference of B tensors of order order-1, taking into account permutational symmetry. If use_parent_indices is False, a Tensor is returned that is indexed by the coordinate’s internal indices rather than the parent molecule’s atom indices. Otherwise, a DerivativeTensor is returned with its representation attribute set to the coordinate’s parent molecule’s cartesian_representation attribute.
Get the coordinate’s b tensor as a Coordinate-based DerivativeCollection. If it has not already done so, the coordinate will fill in the b tensor up to max_order. The returned value uses the Coordinate‘s internal indexing scheme.
Superclass for all types of simple (non-symmetry, non-normal) internal coordinates.
Attributes : |
---|
Returns the number of the atom (as an index in self.molecule) that the i’th atom composing the coordinate self refers to.
Returns the b vector corresponding to a coordinate with atoms in the positions given as arguments (assumed to be Vector or at least LightVector instances). Note that the returned value uses the indexing scheme corresponding to the order of the argument’s passed in, not the indexing scheme corresponding to a Molecule instance somewhere.
Get the value of the coordinate position vectors xyz.
Note
For angular coordinates, this always returns a value in Radians. value, value_with_units, and value_for_molecule, however, return values in self.units
Value for the xyz matrix constructed from the coordinates of the atoms for the coordinate. For instance, for a
Abstract base class for a general coordinate of a Molecule.
Coordinate`s are the components in which `Molecule`s are represented. The most important thing about `Coordinate`s is that they are immutible, like Python’s `str and tuple classes. [#f1]_ Let me say that again a bit louder:
Note
All coordinates are immutable!
Parentage and the molecule attribute: Coordinate instances are typically (though not always) associated with a Representation, accessible through the parent read-only attribute. Coordinate instances that do not have a parent associated with them are called “orphaned” coordinates, and can be identified using the is_orphaned() instance method. Even orphaned coordinates must have a Molecule associated with them in one way or another. This happens in one of three ways:
- If the Coordinate is not orphaned, then parent‘s molecule attribute is used. Note that in this case, the Coordinate protocol requires the Coordinate‘s constituant atoms to have a parent molecule that is exactly the same instance as parent‘s molecule attribute. (If you aren’t doing something weird, this shouldn’t be an issue).
- If the Coordinate is orphaned, it still must be composed of one or more Atom instances, accessible through the atoms attribute. These Atom`s may themselves be orphaned, but if they are not, the first non-orphaned `Atom‘s parent is used. Note that if one Atom is non-orphaned, the Coordinate protocol requires that all of them must not be orphaned (i. e. the Coordinate constructor enforces this when sanity_checking_enabled is True)
- If the Coordinate is orphaned and all of its Atom`s are also orphaned (as is the case, for instance, with `Coordinate instances created for the purpose of finite difference B tensor computation), the Coordinate‘s base_analog attribute may be set to a Coordinate instance whose constituate Atom instances correspond to the derived Coordinate‘s atoms’ base_atom attributes. In this case, the base_analog‘s molecule attribute is used, though it should be utilized for index translation purposes only, since the positions of the atoms in the base molecule will not correspond to the positions of the Coordinate‘s atoms. (The base_analog, in turn, may be an orphaned coordinate of this third type, in which case that coordinate’s base_analog will be used, and so on recursively.)
- If the Coordinate is orphaned and no base_analog is given, then all of the atoms must have a base_atom that either has a parent_molecule or also has a base_atom defined (and so on so that a base_atom eventually has a parent_molecule somewhere up the line). In this case, the Coordinate protocol requires that all the atoms refer to the same Molecule obtained in this manner. Coordinates created in the course of analytic computation of B tensors fall into this catagory.
Indexing schemes: Because all Coordinate`s may be austensibly associated with a `Molecule instance in one way or another, there are two different ways to index various tensor properties of a Coordinate: the Molecule‘s indices (3 * natoms total indices) and the Coordinate‘s indexing scheme (3 * len(coord.atoms) total indices, where coord is a Coordinate instance). The internal indexing scheme makes a lot more sense in many instances, (see the documentation of Coordinate.atoms for a simple example), but for determining properties of the whole molecule, we need to use the Molecule‘s indexing scheme. All of this should be handled seemlessly behind the scenes, but it’s a good distinction to be aware of.
Getting a Coordinate‘s value: Coordinate has a number of methods that can be used to get the value of a Coordinate in a particular scenario. They hierarchically call each other to determine the value of the Coordinate. The basic scheme is as follows:
}
The reason for this relatively complex hierarchy is that there are instances in which I have needed each variety for some reason or another. Nodes with dotted borders must be implemented in the relevant subclasses: SimpleInternalCoordinate subclasses must implement value_for_xyz, InternalCoordinate subclasses must implement value_for_positions, and Coordinate subclasses must implement value_for_molecule_matrix().
Subclassing: |
---|
TODO: write this part
Footnotes
[12] | Since Python doesn’t really have private attributes, you could in theory change some of the attributes of a Coordinate instance after it is created; the designation of “immutible” here merely means that the class is not guarenteed to work if you do. While it’s technically more of a “please don’t” than a “you can’t”, I for one will not be held responsible for your code not working if you do something like that, and the way these private attributes are used and changed is not guarenteed to stay the same between different versions. Bottom line: just don’t do it. If you don’t know what I’m talking about, you’re probably okay. Just don’t access or modify any attributes that start with a single underscore (you should never do this anyway from outside of a class). |
The indices of the atom(s) the Coordinate depends on in the Molecule the Coordinate depends on.
This is guarenteed to work whether or not the Coordinate is orphaned. For each of the various possible Coordinate–Molecule relationships detailed in the Coordinate class documentation, the reason the method works is as follows:
Use this carefully. Don’t ever retrieve an atom’s position by its index in the parent molecule, since that atom may not be the same instance (or even in the same position) as the Coordinate‘s atom.
List of the Atom instances that the Coordinate depends on. In the case of a CartesianCoordinate, for instance, this is trivially one Atom, but in the case of other coordinates it can be much more substantial. In the case of a NormalCoordinate, this is all the atoms in the parent Molecule.
The presence of an atoms list is essential to establish an internal indexing scheme that can be converted to the indexing scheme of the parent molecule. Besides making the B tensor code much more managable, the use of an internal indexing scheme make Coordinate instances much more self-contained, making “orphaned” coordinates much more viable. Consider the following example:
>>> from grendel.util.units import Degrees
>>> from grendel.coordinates.bond_angle import BondAngle
>>> ba = BondAngle(
... Atom('O', [0.0, 0.0, 0.0]),
... Atom('H', [0.0, 1.0, 0.0]),
... Atom('H', [0.0, 0.0, 1.0]),
... units=Degrees
... )
>>> round(ba.value)
90.
If orphaned coordinates where not allowed to exist, we would have to create a Molecule instance containing those three atoms, construct an InternalRepresentation containing the BondAngle instance (which would need to be a valid, complete representation, a non-trivial task in the general case), pair that InternalRepresentation instance with the Molecule instance, get the right Coordinate instance from the InternalRepresentation corresponding to the BondAngle we want, and then get that coordinate’s value. If all of the coordinate’s complicated methods were not implemented in terms of the Coordinate’s own indexing scheme, it would have to have all of this structure in place just to get a value.
Note
Since all Coordinate`s depend on `Atom`s and `Atom`s are not immutible, a `Coordinate`s `value and other properties such as its b_vector can change even if the Coordinate itself cannot. The one way around this is to specify freeze_value as True in the Coordinate‘s constructor. If that is done, the value of the Coordinate will not change over the life of the instance, even if the positions of the constituant atoms does change (so if you use this, make sure you know what you are doing). This behavior is useful, for instance, in the use of CartesianRepresentation`s as “snapshots” of a `Molecule instance to be used for the parsing of a particular RepresentationDependentProperty.
Analogous Coordinate object on the base molecule, if self is a Coordinate on a displaced Molecule, or the Coordinate from which an orphaned displaced Coordinate was created, if the coordinate was created this way.
Every coordinate must define a reasonable default amount for a finite displacement of that kind of coordinate. This should be a class attribute.
Whether or not the Coordinate instance has a parent Representation
Default implementation for coordinates dependent on atoms directly (basically anything but a CartesianCoordinate or some sort of symmetrized cartesian coordinate).
The molecule associated with the Coordinate.
Note
The molecule’s atoms’ positions may not correspond to the positions of the atoms the coordinate describes. See the class documentation for Coordinate for details.
The InternalRepresentation instance which the coordinate self is a part of.
The InternalRepresentation instance which the coordinate self is a part of.
The units in which the coordinate’s value is expressed.
Get the value of the coordinate for the XYZ matrix mat, which is a (self.molecule.natoms) by 3 matrix. In other words, the matrix argument uses the parent Molecule‘s indexing scheme, not the Coordinate‘s own indexing scheme.
Note
For angular coordinates, this always returns a value in Radians. value, value_with_units, and value_for_molecule, however, return values in self.units
A coordinate that is a function of one or more other Coordinate instances
General superclass for all types internal coordinates. Internal coordinates may only refer to one representation.
Compute the analytic B tensor of a given order and return a tensor indexed by the coordinate’s own indexing scheme.
Retrieve an element of the Coordinate’s B tensor using CartesianCoordinate instances and/or integer indices in the molecule’s indexing scheme.
Fill the coordinate’s own _btensor attribute for a given order. (The _btensor attribute should be retrieved using the get_b_tensor() method, which calls this if the _btensor has not already been computed.) If the b tensor cannot be computed analytically at the given order, this method returns NotImplemented. Otherwise, it computes the B tensor to the given order and returns None. If the optional B argument is given, this Coordinate’s part of the Representation-based TensorCollection that B refers to is filled as well.
Computes the B tensor for order order by finite difference of B tensors of order order-1, taking into account permutational symmetry. If use_parent_indices is False, a Tensor is returned that is indexed by the coordinate’s internal indices rather than the parent molecule’s atom indices. Otherwise, a DerivativeTensor is returned with its representation attribute set to the coordinate’s parent molecule’s cartesian_representation attribute.
Get the coordinate’s b tensor as a Coordinate-based DerivativeCollection. If it has not already done so, the coordinate will fill in the b tensor up to max_order. The returned value uses the Coordinate‘s internal indexing scheme.
An internal coordinate representations of a molecule. TODO: More thoroughly document what this means.
The El’yashevich–Wilson B matrix pseudoinverse, with the Sayvetz conditions used to generate the inverse mass external conditions.
The El’yashevich–Wilson B matrix for the molecule in the representation.
alias of Radian
Superclass for all types of simple (non-symmetry, non-normal) internal coordinates.
Attributes : |
---|
Returns the number of the atom (as an index in self.molecule) that the i’th atom composing the coordinate self refers to.
Returns the b vector corresponding to a coordinate with atoms in the positions given as arguments (assumed to be Vector or at least LightVector instances). Note that the returned value uses the indexing scheme corresponding to the order of the argument’s passed in, not the indexing scheme corresponding to a Molecule instance somewhere.
Get the value of the coordinate position vectors xyz.
Note
For angular coordinates, this always returns a value in Radians. value, value_with_units, and value_for_molecule, however, return values in self.units
Value for the xyz matrix constructed from the coordinates of the atoms for the coordinate. For instance, for a
Mostly a wrapper for the NumPy ndarray class. This gives us a place to put tensor-related functionality that we need but is not available in NumPy.
Copy all properties of the tensor except for the data.
Same as numpy.ndarray.flatten, but modified to return a Vector object
Examples : |
---|
>>> t = Tensor([[[1,2],[3,4]],[[5,6],[7,8]]])
>>> t
Tensor([[[ 1., 2.],
[ 3., 4.]],
[[ 5., 6.],
[ 7., 8.]]])
>>> t.flatten()
Vector([ 1., 2., 3., ..., 6., 7., 8.])
List of pointers to IndexRange objects over which the tensor is defined.
Returns True if all elements of self have absolute values less than cutoff, which defaults to Tensor.zero_cutoff
Note
Tensor.zero_cutoff is treated as a pseudo-class attribute for Tensor instances, meaning individual instances can also set a zero_cutoff attribute which will take precidence over the class-level default.
Given any number of Tensor objects that are the same up to a phase factor, return a list of Tensor objects that have been. Copies are only made if necessary. The chosen phase is the one that makes the first non-zero element (in the numpy.nditer(tensor) iterator, using the cutoff keyword argument or Tensor.zero_cutoff if one is not given) positive.
Allows conformance with the Unitized protocol.
A class for encapsulating a physical constant and it’s units.
Attributes : |
---|
Encapsulates a vector. Most functionality gets passed up to Tensor, which in turn passes things up to numpy.ndarray. Special functionality for vectors gets implemented here.
Examples : |
---|
Multiplication >>> from grendel.gmath import Matrix, Vector >>> Matrix([1,2],[3,4]) * Vector([5,6]) Vector([ 17., 39.])
Cartesian components >>> vtwo = Vector(1., 2.) >>> vthree = Vector(1.11, 2.22, 3.33) >>> vtwo[0] 1.0 >>> vtwo.x 1.0 >>> vtwo.y == vtwo[1] True >>> vthree[2] == vthree.z True >>> # Can also set: >>> vtwo.x = -1 >>> vtwo.y = -2 >>> vtwo Vector([-1., -2.]) >>> vthree.x, vthree.z, vthree.y = 1, 3, 2 >>> vthree Vector([ 1., 2., 3.])
Return the column-vector version of self, which is currently implemented as a Matrix object. Note that matrix-vector multiplication will work without getting column first, so don’t use this unless you have a good reason to do so.
Returns cross product of self with other. Wrapper to numpy.cross
Same as normalize(), but does not modify self
Overrides the numpy.ndarray reshape function to make things make sense.
Examples : |
---|
>>> v = Vector([1,2,3,4])
>>> v.reshape((2,2))
Matrix([[ 1., 2.],
[ 3., 4.]])
>>> # `v` is unchanged:
>>> v
Vector([ 1., 2., 3., 4.])
>>> v.reshape((4,1))
Matrix([[ 1.],
[ 2.],
[ 3.],
[ 4.]])
>>> import numpy as np
>>> np.reshape(v, (2,2))
Matrix([[ 1., 2.],
[ 3., 4.]])
The x component of a cartesian vector
Raises : |
---|
The y component of a cartesian vector
Raises : |
---|
The z component of a cartesian vector
Raises : |
---|
group(3, ‘ABCDEFG’, ‘x’) –> ABC DEF Gxx
Return true if the object is an instance method.
Aliased as is_unit()
partial(func, *args, **keywords) - new function with partial application of the given arguments and keywords.
tuple of arguments to future partial calls
function object to use in future partial calls
dictionary of keyword arguments to future partial calls
product(*iterables) –> product object
Cartesian product of input iterables. Equivalent to nested for-loops.
For example, product(A, B) returns the same as: ((x,y) for x in A for y in B). The leftmost iterators are in the outermost for-loop, so the output tuples cycle in a manner similar to an odometer (with the rightmost element changing on every iteration).
To compute the product of an iterable with itself, specify the number of repetitions with the optional repeat keyword argument. For example, product(A, repeat=4) means the same as product(A, A, A, A).
product(‘ab’, range(3)) –> (‘a’,0) (‘a’,1) (‘a’,2) (‘b’,0) (‘b’,1) (‘b’,2) product((0,1), (0,1), (0,1)) –> (0,0,0) (0,0,1) (0,1,0) (0,1,1) (1,0,0) ...
x.next() -> the next value, or raise StopIteration
Aliased as stripunits()
alias of Angstrom
Encapsulates an atom. Molecules are made up of Atoms.
Attributes : |
---|
Creates an orphaned copy of atom and displaces it by disp_vect
The Element object corresponding to self. Updated transparently using the symbol property
The isotope of the element that self is composed of. Defaults to element.principal_isotope
The atom’s mass as a float (in AMU). Automatically retrieved from the element and isotope attributes.
Alias for the parent_molecule attribute.
Alias for self.position. pos is also an alias for self.position
The atomic symbol from the periodic table (as a str object) , with correct capitalization. Updating this property transparently updates the Element object associated with self.
Alias for self.position. pos is also an alias for self.position
General superclass for all distance units
alias of Angstrom
alias of Angstrom
An internal coordinate representations of a molecule. TODO: More thoroughly document what this means.
The El’yashevich–Wilson B matrix pseudoinverse, with the Sayvetz conditions used to generate the inverse mass external conditions.
The El’yashevich–Wilson B matrix for the molecule in the representation.
alias of Iterable
Returns True if the vector is Cartesian (i.e. if the vector is two or three dimensional).
Alias for Tensor.is_zero()
Returns cross product of self with other. Wrapper to numpy.cross
Same as l_normalize(), but does not modify self
Aliased as normalized()
The magnitude of the vector.
Aliased as norm()
Alias for magnitude()
Performs an in-place normalization of self.
Examples : |
---|
>>> Vector(2.0, 0.0, 0.0).normalize()
Vector([ 1., 0., 0.])
>>> Vector(0.5, 0.5, 0.5).normalize()
Vector([ 0.57735027, 0.57735027, 0.57735027])
>>> v = Vector(-0.5, 0.5, -0.5).normalize()
>>> v
Vector([-0.57735027, 0.57735027, -0.57735027])
>>> v.magnitude()
1.0
Alias for l_normalized()
The number of entries in the vector
Encapsulates a vector. Most functionality gets passed up to Tensor, which in turn passes things up to numpy.ndarray. Special functionality for vectors gets implemented here.
Wrapper to numpy.eigh and numpy.eig for symmetric and non-symmetric matrices, respectively. Note that the eigenvectors are column vectors in the returned matrix.
Number of columns that self has
Number of rows that self has
Encapsulates all of the functionality and attributes of a Molecule itself.
Signatures : |
|
---|---|
Parameters : |
Other Parameters: | |
---|---|
Attributes : |
---|
atoms : list of Atom internal_representations : list of InternalRepresentation normal_representation : NormalRepresentation cartesian_representation : CartesianRepresentation description : str
Examples : |
---|
Constructor
>>> Molecule("""
... 5
...
... C 0.000000 0.000000 0.000000
... H 0.000000 0.000000 1.089000
... H 1.026719 0.000000 -0.363000
... H -0.513360 -0.889165 -0.363000
... H -0.513360 0.889165 -0.363000
... """)
Molecule([
Atom('C', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('H', [ 0.00000000, 0.00000000, 1.08900000 ] ),
Atom('H', [ 1.02671900, 0.00000000, -0.36300000 ] ),
Atom('H', [ -0.51336000, -0.88916500, -0.36300000 ] ),
Atom('H', [ -0.51336000, 0.88916500, -0.36300000 ] )
])
>>> Molecule([
... Atom('H', [0,0,0]),
... Atom('H', [0,0,0.75])
... ])
Molecule([
Atom('H', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('H', [ 0.00000000, 0.00000000, 0.75000000 ] )
])
>>> Molecule(['H','C'], Matrix([[0,0,0],[1,0.5,0]]))
Molecule([
Atom('H', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('C', [ 1.00000000, 0.50000000, 0.00000000 ] )
])
>>> mol = Molecule("""
... 5
...
... C 0.000000 0.000000 0.000000
... H 0.000000 0.000000 1.089000
... H 1.026719 0.000000 -0.363000
... H -0.513360 -0.889165 -0.363000
... H -0.513360 0.889165 -0.363000
... """)
>>> mol
Molecule([
Atom('C', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('H', [ 0.00000000, 0.00000000, 1.08900000 ] ),
Atom('H', [ 1.02671900, 0.00000000, -0.36300000 ] ),
Atom('H', [ -0.51336000, -0.88916500, -0.36300000 ] ),
Atom('H', [ -0.51336000, 0.88916500, -0.36300000 ] )
])
Iteration
>>> from __future__ import print_function
>>> for atom in mol:
... print(repr(atom))
...
Atom('C', [ 0.00000000, 0.00000000, 0.00000000 ] )
Atom('H', [ 0.00000000, 0.00000000, 1.08900000 ] )
Atom('H', [ 1.02671900, 0.00000000, -0.36300000 ] )
Atom('H', [ -0.51336000, -0.88916500, -0.36300000 ] )
Atom('H', [ -0.51336000, 0.88916500, -0.36300000 ] )
The first principal axis of rotation, a. The positive phase is always chosen.
Note
This property depends directly on Molecule.principal_axes(), which is cached. See discussion of caching in A_e
The second principal axis of rotation, b. The positive phase is always chosen.
Note
This property depends directly on Molecule.principal_axes(), which is cached. See discussion of caching in A_e
The third principal axis of rotation, c. The positive phase is always chosen.
Note
This property depends directly on Molecule.principal_axes(), which is cached. See discussion of caching in A_e
The current default cartesian representation associated with the molecule. If the molecule has multiple cartesian representations, the first in the list self.cartesian_representations is returned. The setter for this property pushes the cartesian representation onto the front of the list.
Note
The setter does not check for uniqueness (unless it’s exactly the same object as another CartesianRepresentation). Thus, you should check to make sure the CartesianRepresentation you are assigning to the molecule is not already part of the molecule’s list of representations (to the degree of accuracy required for your particular application) before assigning. Repeatedly failing to do this check could cause runaway memory usage.
Returns a Vector giving the center of mass of the molecule in the current Cartesian representation. The units of the returned value are self.cartesian_units.
Note
This result of this method is cached, and the cached value gets flushed in update_cartesian_representation(). If you change an atom’s position (or mass) and forget to call update_cartesian_representation(), you may get some funny results for this method or any methods that depend on it, including recenter(), reorient(), and principal_moments_of_inertia(). You can detect whether caching is causing problems by setting the environment variable GRENDEL_NO_CACHE to 1 and rerunning your tests. If tests that were failing subsequently succeed, you probably forgot to call update_cartesian_representation() somewhere, or you were assuming that it was automatically called somewhere when in fact it was not getting called.
Create a Molecule object using only the name, SMILES, InChIKey, etc.
The easiest way to call Molecule.from_identifier() is to give it a single argument that is one of the following properties: * smiles * stdinchikey * stdinchi * ncicadd_identifier # (for FICTS, FICuS, uuuuu) * hashisy * cas_number * chemspider_id # input must be chemspider_id=1234567 * opsin_name * cir_name (These are resolved in roughly this order.) Visit the NIH CIR documentation for (some) explaination of what these identifiers are: http://cactus.nci.nih.gov/chemical/structure/documentation
Molecule.from_identifier() can be called with any (single) keyword argument in the grendel.util.web_getter.input_identifiers list. In this form, there must be only
This can also be called using an argument that is the value of a property and a second argument that is a list of fields to search for that property in.
Note: Molecule.get() is a very useful alias for this.
Examples : |
---|
TODO
TODO Document this more
Examples : |
---|
>>> Molecule.from_z_matrix("""
... O
... H1 O 1.0
... H2 O 1.0 H1 90.0
... """)
Molecule([
Atom('O', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('H', [ 0.00000000, 0.00000000, 1.00000000 ] ),
Atom('H', [ 0.00000000, -1.00000000, -0.00000000 ] )
])
>>> Molecule.from_z_matrix(
... [
... ['H'],
... ['O', 1, 0.9],
... ['O', 2, 1.4, 1, 105.0],
... ['H', 3, 0.9, 2, 105.0, 1, 120.0]
... ]
... )
Molecule([
Atom('H', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('O', [ 0.00000000, 0.00000000, 0.90000000 ] ),
Atom('O', [ 0.00000000, 1.35229616, 1.26234666 ] ),
Atom('H', [ -0.75286467, 1.46479616, 1.74249095 ] )
])
>>> Molecule.from_z_matrix(
... ['H'],
... ['O', 1, 0.9]
... )
Molecule([
Atom('H', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('O', [ 0.00000000, 0.00000000, 0.90000000 ] )
])
@param string: String containing a z-matrix with labels defined at the end using e.g. a234=8.5 @param args: Passed on to Molecule.from_z_matrix @param kwargs: Passed on to Molecule.from_z_matrix @return: Molecule object corresponding to the z-matrix passed in
Return a list of geometrically separated moieties of the molecule. Note: sub-molecules returned will have charge 0 and multiplicity 1 for now
@param n_vdw_radii: How many Van der Waals radii two atoms may be separated by and still be considered bonded @param default_vdw_radius: Van der Waals radius to use for elements that grendel doesn’t know the VDW radius of. @return: list of moieties as Molecule objects.
Create a Molecule object using only the name, SMILES, InChIKey, etc.
The easiest way to call Molecule.from_identifier() is to give it a single argument that is one of the following properties: * smiles * stdinchikey * stdinchi * ncicadd_identifier # (for FICTS, FICuS, uuuuu) * hashisy * cas_number * chemspider_id # input must be chemspider_id=1234567 * opsin_name * cir_name (These are resolved in roughly this order.) Visit the NIH CIR documentation for (some) explaination of what these identifiers are: http://cactus.nci.nih.gov/chemical/structure/documentation
Molecule.from_identifier() can be called with any (single) keyword argument in the grendel.util.web_getter.input_identifiers list. In this form, there must be only
This can also be called using an argument that is the value of a property and a second argument that is a list of fields to search for that property in.
Note: Molecule.get() is a very useful alias for this.
Examples : |
---|
TODO
Returns True if the elements of self correspond directly to the elements of other (i.e. self.atoms[0].element == other.atoms[0].element and self.atoms[1].element == other.atoms[1].element and ...)
Returns True if all of the elements are the same (including isotope and nuclear spin) and the reoriented() versions of self and other have no atoms whose pairwise position difference has a magnitude greater than tol (which defaults to 1e-8 Angstroms)
Examples : |
---|
>>> mol = Molecule('''
... O 1.5 0.0 0.0
... H 0.2 0.0 0.0
... ''')
>>> m1 = Molecule('''
... O 0.0 1.5 0.0
... H 0.0 0.2 0.0
... ''')
>>> m2 = Molecule('''
... O 0.00000 0.00000 0.200000
... H 0.00000 0.00000 1.500001
... ''')
>>> m3 = Molecule('''
... H 0.0 0.0 0.0
... H 0.0 -1.3 0.0
... ''')
>>> mol.has_same_geometry(m1)
True
>>> m1.has_same_geometry(m2)
False
>>> m1.has_same_geometry(m2, 1e-5)
True
>>> m2.has_same_geometry(mol, 1e-5)
True
>>> m1.has_same_geometry(m3)
False
True if op is a valid symmetry operation on self Each coordinate of the transformed atoms must differ from the original by less than
Returns the index of atom in the atoms array of the molecule
Note
This method returns a cached property Atom.index. If you reorder the atoms in a molecule, be sure and flush this cache by setting atom._index to None for all of the atoms in the reordered molecule.
Raises : |
---|
IndexError : if atom is not found in self
Examples : |
---|
>>> from grendel.chemistry import SampleMolecules, init_sample_molecules
>>> init_sample_molecules()
>>> h2o = SampleMolecules['water']
>>> atom1 = h2o[0]
>>> atom2 = h2o[1]
>>> atom3 = h2o[2]
>>> h2o
Molecule([
Atom('O', [ 0.00000000, 0.00000000, 0.11815400 ] ),
Atom('H', [ 0.00000000, 0.75873400, -0.47261400 ] ),
Atom('H', [ 0.00000000, -0.75873400, -0.47261400 ] )
])
>>> h2o.index(atom2)
1
>>> h2o.index(atom1)
0
>>> # It must be exactly the same instance to avoid raising an index error
>>> h2o.index(Atom('O', [ 0.00000000, 0.00000000, 0.11815400 ] ))
Traceback (most recent call last):
...
IndexError: ...
Returns a tuple of the principal moments of inertia vector and the principal axes matrix.
mol.inertial_system()
Computes the principal moments of inertia and the principal axes.
Note
This funtion mol.recenter() if the molecule is not centered, so any CartesianRepresentations that are not both frozen and referenced elsewhere (e.g. in a RepresentationDependentProperty) will be lost forever.
Note
This method is cached. See discussion of the consequences of caching in Molecule.center_of_mass()
Returns : |
---|
A tuple with types (Vector, Matrix) containing the principal moments of inertia and the principal axes, respectively. These should be aligned (i.e. ret_val[0][1] corresponds to the vector ret_val[1][1])
Examples : |
---|
>>> hnco = Molecule.from_z_matrix("""
... N
... C N 1.2145
... O C 1.1634 N 172.22
... H N 1.0030 C 123.34 O 180.0
... """
... )
>>> i = hnco.inertial_system()
>>> i[0]
Vector([ 0.60187342, 45.48378728, 46.0856607 ])
>>> i[1]
Matrix([[ 0. , 0. , 1. ],
[ 0.09870438, -0.9951168 , 0. ],
[ 0.9951168 , 0.09870438, 0. ]])
>>> j = hnco.inertial_system()
>>> i == j
True
>>> hnco.A_e
28.0085955528 Wavenumber
>>> hnco.B_e
0.370629408869 Wavenumber
>>> hnco.C_e
0.365789031483 Wavenumber
>>> hnco.a
Vector([ 0. , 0.09870438, 0.9951168 ])
>>> hnco.b
Vector([ 0. , -0.9951168 , 0.09870438])
>>> hnco.c
Vector([ 1., 0., 0.])
The first internal representations (of type InternalRepresentation), or None if it does not exist yet.
True if the center of mass is at the origin. This actually computes the vector from the origin to the center of mass and then determines if the magnitude of that vector is less than tol.
Parameters : |
---|
True if the molecule is linear to within tol. All diatomics should return True.
If tol is a ValueWithUnits and tol.units is an AngularUnit, then this method returns True only if all angles in the molecule are within tol of 180 Degrees. If tol.units is a unit-compatible with a moment of inertia (i.e. MassUnit * DistanceUnit**2 ), then this method returns True if the smallest principal moment of inertia is less than tol and the difference between the two largest principal moments of inertia is less than tol. If no units are given (i.e. tol is a float or other float-compatible unit), tol is assumed to have units of AngularUnit.default and the method proceeds as if tol.units was an AngularUnit subclass.
Parameters : |
---|
Examples : |
---|
>>> from grendel.chemistry import SampleMolecules, init_sample_molecules
>>> init_sample_molecules()
>>> SampleMolecules['water'].is_linear()
False
>>> SampleMolecules['CO2'].is_linear()
True
>>> SampleMolecules['Benzene'].is_linear()
False
The principal moments of inertia, as a Vector
Note
This funtion mol.recenter() if the molecule is not centered, so any CartesianRepresentations that are not both frozen and referenced elsewhere (e.g. in a RepresentationDependentProperty) will be lost forever.
Note
This method is cached. See discussion of the consequences of caching in Molecule.center_of_mass()
Examples: >>> hnco = Molecule.from_z_matrix(""" ... N ... C N 1.2145 ... O C 1.1634 N 172.22 ... H N 1.0030 C 123.34 O 180.0 ... """ ... ) >>> hnco.principal_moments_of_inertia() Vector([ 0.60187342, 45.48378728, 46.0856607 ]) >>> hnco.pmi() Vector([ 0.60187342, 45.48378728, 46.0856607 ])
See Also: principal_axes, inertial_system, A_e, B_e, C_e
Aliased as principal_moments_of_inertia()
The molecule’s position as a natoms x 3 Matrix. The ordering of rows is (as expected) the same as the ordering of the Molecule.atoms list attribute. Aliased to xyz_mat and position (the latter to be “consistant-ish” with the naming in Atom.
The principal axes as column vectors in a Matrix. The Vector object mol.principal_axes()[:,i] corresponds to the i`th moment of inertia, `mol.principal_moments_of_inertia()[i].
mol.principal_axes()
Note
This funtion mol.recenter() if the molecule is not centered, so any CartesianRepresentations that are not both frozen and referenced elsewhere (e.g. in a RepresentationDependentProperty) will be lost forever.
Note
This method is cached. See discussion of the consequences of caching in Molecule.center_of_mass()
Examples : |
---|
>>> hnco = Molecule.from_z_matrix("""
... N
... C N 1.2145
... O C 1.1634 N 172.22
... H N 1.0030 C 123.34 O 180.0
... """
... )
>>> hnco.principal_axes()
Matrix([[ 0. , 0. , 1. ],
[ 0.09870438, -0.9951168 , 0. ],
[ 0.9951168 , 0.09870438, 0. ]])
See Also: |
---|
principal_moments_of_inertia, inertial_system, A_e, B_e, C_e
Alias for pmi()
Recenters the molecule about the center of mass This modifies the molecule in place.
Examples : |
---|
>>> m = Molecule([Atom("O", [1.1, 1.3, 1.7])])
>>> m
Molecule([
Atom('O', [ 1.10000000, 1.30000000, 1.70000000 ] )
])
>>> m.recenter()
>>> m
Molecule([
Atom('O', [ 0.00000000, 0.00000000, 0.00000000 ] )
])
>>> m = Molecule(['H','H'], Matrix([[0,0,0],[1,0.0,0]]))
>>> m
Molecule([
Atom('H', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('H', [ 1.00000000, 0.00000000, 0.00000000 ] )
])
>>> m.recenter()
>>> m
Molecule([
Atom('H', [ -0.50000000, 0.00000000, 0.00000000 ] ),
Atom('H', [ 0.50000000, 0.00000000, 0.00000000 ] )
])
Same as recenter, but makes returns a copy. self is not modified.
Examples : |
---|
>>> foo = Molecule([Atom("O", [1.3, 1.7, 2.0])])
>>> bar = foo.recentered()
>>> foo.recenter()
>>> foo
Molecule([
Atom('O', [ 0.00000000, 0.00000000, 0.00000000 ] )
])
>>> foo == bar
True
>>> foo is bar
False
Reorient the molecule to align the x, y, and z axes with the principal axes of rotation.
Parameters : |
---|
Examples : |
---|
>>> from grendel.chemistry import SampleMolecules, init_sample_molecules
>>> init_sample_molecules()
>>> from grendel.gmath import chopped
>>> h2o = SampleMolecules['quantum water']
>>> h2o.principal_axes()
Matrix([[-0. , 0. , 1. ],
[-0.53654222, -0.84387348, 0. ],
[-0.84387348, 0.53654222, 0. ]])
>>> h2o.reorient()
>>> # Use chopped to get rid of very small numerical artifacts...
>>> # using abs to get rid of phase factor
>>> abs(chopped(h2o.principal_axes()))
Matrix([[ 0., 0., 1.],
[ 1., 0., 0.],
[ 0., 1., 0.]])
>>> h2o.reorient("I")
>>> from grendel.gmath import chopped
>>> abs(chopped(h2o.principal_axes()))
Matrix([[ 0., 1., 0.],
[ 0., 0., 1.],
[ 1., 0., 0.]])
>>> h2o.reorient("III")
>>> abs(chopped(h2o.principal_axes()))
Matrix([[ 1., 0., 0.],
[ 0., 1., 0.],
[ 0., 0., 1.]])
Same as reorient, but makes returns a copy. self is not modified.
Examples : |
---|
>>> from grendel.chemistry import SampleMolecules, init_sample_molecules
>>> init_sample_molecules()
>>> from grendel.gmath import chopped
>>> h2o = Molecule([
... Atom('O', [ 0.00000000, 0.00000000, 0.00000000 ] ),
... Atom('H', [ 0.00000000, 0.00000000, 1.00000000 ] ),
... Atom('H', [ 0.00000000, -1.00000000, -0.00000000 ] )
... ])
>>> new = h2o.reoriented()
>>> # Use chopped to get rid of very small numerical artifacts...
>>> chopped(new.principal_axes())
Matrix([[ 0., 0., 1.],
[-1., 0., 0.],
[ 0., 1., 0.]])
>>> new is h2o
False
>>> # original molecule is unchanged...
>>> h2o
Molecule([
Atom('O', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('H', [ 0.00000000, 0.00000000, 1.00000000 ] ),
Atom('H', [ 0.00000000, -1.00000000, -0.00000000 ] )
])
Rotates the molecule about axis (a Vector) by angle
Writes the Molecule to the standard xyz format.
See Molecule.xyz_string() for more details.
See Also: |
---|
xyz_string
The molecule’s position as a natoms x 3 Matrix. The ordering of rows is (as expected) the same as the ordering of the Molecule.atoms list attribute. Aliased to xyz_mat and position (the latter to be “consistant-ish” with the naming in Atom.
The molecule’s position as a natoms x 3 Matrix. The ordering of rows is (as expected) the same as the ordering of the Molecule.atoms list attribute. Aliased to xyz_mat and position (the latter to be “consistant-ish” with the naming in Atom.
The molecule, represented as a string in standard xyz format.
The first line will always be the number of atoms. The second line (which is a comment in the xyz specification) is filled by the description first line of the description attribute.
Parameters : |
---|
Examples : |
---|
>>> from __future__ import print_function
>>> from grendel.chemistry import SampleMolecules, init_sample_molecules
>>> init_sample_molecules()
>>> print(SampleMolecules['water'].xyz_string())
3
CCSD(T)/aug-cc-pVTZ Water
O 0.00000000 0.00000000 0.11815400
H 0.00000000 0.75873400 -0.47261400
H 0.00000000 -0.75873400 -0.47261400
>>> print(Molecule("O 1.0 0.5 1.5").xyz_string("Atom: %2s, x: %3.1f, y: %4.2f, z: %5.3f"))
1
Atom: O, x: 1.0, y: 0.50, z: 1.500
>>> print(Molecule("O 1.0 0.5 1.5").xyz_string("Atom: %2s, x: %3.1f, y: %4.2f, z: %5.3f", False))
Atom: O, x: 1.0, y: 0.50, z: 1.500
Superclass for all types of simple (non-symmetry, non-normal) internal coordinates.
Attributes : |
---|
Returns the number of the atom (as an index in self.molecule) that the i’th atom composing the coordinate self refers to.
Returns the b vector corresponding to a coordinate with atoms in the positions given as arguments (assumed to be Vector or at least LightVector instances). Note that the returned value uses the indexing scheme corresponding to the order of the argument’s passed in, not the indexing scheme corresponding to a Molecule instance somewhere.
Get the value of the coordinate position vectors xyz.
Note
For angular coordinates, this always returns a value in Radians. value, value_with_units, and value_for_molecule, however, return values in self.units
Value for the xyz matrix constructed from the coordinates of the atoms for the coordinate. For instance, for a
Encapsulates a vector. Most functionality gets passed up to Tensor, which in turn passes things up to numpy.ndarray. Special functionality for vectors gets implemented here.
Examples : |
---|
Multiplication >>> from grendel.gmath import Matrix, Vector >>> Matrix([1,2],[3,4]) * Vector([5,6]) Vector([ 17., 39.])
Cartesian components >>> vtwo = Vector(1., 2.) >>> vthree = Vector(1.11, 2.22, 3.33) >>> vtwo[0] 1.0 >>> vtwo.x 1.0 >>> vtwo.y == vtwo[1] True >>> vthree[2] == vthree.z True >>> # Can also set: >>> vtwo.x = -1 >>> vtwo.y = -2 >>> vtwo Vector([-1., -2.]) >>> vthree.x, vthree.z, vthree.y = 1, 3, 2 >>> vthree Vector([ 1., 2., 3.])
Return the column-vector version of self, which is currently implemented as a Matrix object. Note that matrix-vector multiplication will work without getting column first, so don’t use this unless you have a good reason to do so.
Returns cross product of self with other. Wrapper to numpy.cross
Same as normalize(), but does not modify self
Overrides the numpy.ndarray reshape function to make things make sense.
Examples : |
---|
>>> v = Vector([1,2,3,4])
>>> v.reshape((2,2))
Matrix([[ 1., 2.],
[ 3., 4.]])
>>> # `v` is unchanged:
>>> v
Vector([ 1., 2., 3., 4.])
>>> v.reshape((4,1))
Matrix([[ 1.],
[ 2.],
[ 3.],
[ 4.]])
>>> import numpy as np
>>> np.reshape(v, (2,2))
Matrix([[ 1., 2.],
[ 3., 4.]])
The x component of a cartesian vector
Raises : |
---|
The y component of a cartesian vector
Raises : |
---|
The z component of a cartesian vector
Raises : |
---|
Shallow copy operation on arbitrary Python objects.
See the module’s __doc__ string for more info.
TODO Document this
Aliased as is_unit()
Overload a function the Pythonic (at least, Python 2) way.
Types can be specified using the overloaded instance decorator method overload_with (which is aliased as overload, submethod, and subfunction).
Examples : |
---|
>>> @overloaded
... def test():
... raise TypeError
...
>>> @test.overload_with(int, int)
... def test(a, b=5):
... return a+b
...
>>> @test.overload_with(str)
... def test(string, *args, **kwargs):
... return string + (' ' if len(args) else '') + ', '.join(list(args) + kwargs.keys())
...
>>> @test.overload_with(list, func=callable)
... def test(lst, func, *args):
... for item in lst:
... if func(item, *args):
... return item
...
>>> test(1, 3)
4
>>> test(17)
22
>>> test("Hello")
'Hello'
>>> test("Hello", "World")
'Hello World'
>>> test("Hello", "Earth", "Mars", "Jupiter")
'Hello Earth, Mars, Jupiter'
>>> test([1, 2, 3], lambda x: x**2 % 2 == 0)
2
>>> test([1, 2, 3], lambda x, y: x**2 % y == 0, 1)
1
>>> test(3.14159, 3.234)
Traceback (most recent call last):
...
TypeError: invalid function signature test(float, float).
Available signatures are:
test(a: int, b: int=5)
Not valid signature because: argument 'a' is not of the correct type
test(string: str, *args, **kwargs)
Not valid signature because: argument 'string' is not of the correct type
test(lst: list, func: <something for which callable(func) returns True>, *args)
Not valid signature because: argument 'lst' is not of the correct type
>>> # giving multiple values for a keyword argument means there is no match. For instance:
>>> test('Hello', 'World', string='this is wrong')
Traceback (most recent call last):
...
TypeError: invalid function signature test(str, str, string=str).
Available signatures are:
test(a: int, b: int=5)
Not valid signature because: argument 'a' is not of the correct type
test(string: str, *args, **kwargs)
Not valid signature because: got multiple values for keyword argument 'string'
test(lst: list, func: <something for which callable(func) returns True>, *args)
Not valid signature because: argument 'lst' is not of the correct type
>>> # Methods in classes
>>> class Foo(object):
... @overloaded
... def bar(self, *args, **kwargs): pass
...
... @bar.overload_with(a=int, b=int)
... def bar(self, a, b):
... if not hasattr(self, 'total'):
... self.total = 0
... self.total += a + b
... return a + b
...
>>> foo = Foo()
>>> foo.bar(1,2)
3
>>> foo.bar(4,5)
9
>>> foo.total
12
>>> Foo.bar(foo, 7, 8)
15
>>> foo.total
27
A representations of a molecule in Cartesian coordinates. Since Atom objects already have Cartesian vectors associated with them, this class mostly consists of helper functions and convenience (accessor) functions that make CartesianRepresentation compatible with the parent Representation class.
Add an atom to the representation by creating a CartesianCoordinate object cooresponding to the atom.
Add a CartesianCoordinate to the representation.
Convenience method for accessing atoms. Returns self.molecule.atoms[number]
Convenience property for referencing the atoms list in the molecule associated with self.
Returns the index of the parameter atom in the representation self.
Parameters : |
---|
Raises : |
---|
Returns the value of the representation as a light vector
Renew the coordinates for an atom to coincide with the atom’s current position
Superclass of all the representations types.
Attributes : |
|
---|
Make a copy of self that is the same in every way except for the molecule attribute. New Coordinate objects are created using the Coordinate.copy_for_representation() method for each element of self.coords. This is an abstract method that must be implemented by all Representation subclasses.
Apply the Displacement instance disp to the molecule and current representation, generating a new molecule and a new representation (which start as a deepcopy and the return value of Representation.copy_with_molecule, respectively) with the displacement applied. This is an abstract method that must be implemented by all Representation subclasses.
Alias for values_for_matrix()
Alias for values_for_molecule()
Aliased as value_for_matrix()
Aliased as value_for_molecule()
An internal coordinate representations of a molecule. TODO: More thoroughly document what this means.
The El’yashevich–Wilson B matrix pseudoinverse, with the Sayvetz conditions used to generate the inverse mass external conditions.
The El’yashevich–Wilson B matrix for the molecule in the representation.
alias of AtomicMassUnit
alias of Angstrom
alias of AttoJoule
alias of CentiMeter
General superclass for all distance units
alias of Angstrom
alias of Angstrom
alias of Hartree
An internal coordinate representations of a molecule. TODO: More thoroughly document what this means.
The El’yashevich–Wilson B matrix pseudoinverse, with the Sayvetz conditions used to generate the inverse mass external conditions.
The El’yashevich–Wilson B matrix for the molecule in the representation.
alias of Joule
alias of KiloGram
Encapsulates a vector. Most functionality gets passed up to Tensor, which in turn passes things up to numpy.ndarray. Special functionality for vectors gets implemented here.
Wrapper to numpy.eigh and numpy.eig for symmetric and non-symmetric matrices, respectively. Note that the eigenvectors are column vectors in the returned matrix.
Number of columns that self has
Number of rows that self has
Superclass of all the representations types.
Attributes : |
|
---|
Make a copy of self that is the same in every way except for the molecule attribute. New Coordinate objects are created using the Coordinate.copy_for_representation() method for each element of self.coords. This is an abstract method that must be implemented by all Representation subclasses.
Apply the Displacement instance disp to the molecule and current representation, generating a new molecule and a new representation (which start as a deepcopy and the return value of Representation.copy_with_molecule, respectively) with the displacement applied. This is an abstract method that must be implemented by all Representation subclasses.
Alias for values_for_matrix()
Alias for values_for_molecule()
Aliased as value_for_matrix()
Aliased as value_for_molecule()
Encapsulates a vector. Most functionality gets passed up to Tensor, which in turn passes things up to numpy.ndarray. Special functionality for vectors gets implemented here.
Examples : |
---|
Multiplication >>> from grendel.gmath import Matrix, Vector >>> Matrix([1,2],[3,4]) * Vector([5,6]) Vector([ 17., 39.])
Cartesian components >>> vtwo = Vector(1., 2.) >>> vthree = Vector(1.11, 2.22, 3.33) >>> vtwo[0] 1.0 >>> vtwo.x 1.0 >>> vtwo.y == vtwo[1] True >>> vthree[2] == vthree.z True >>> # Can also set: >>> vtwo.x = -1 >>> vtwo.y = -2 >>> vtwo Vector([-1., -2.]) >>> vthree.x, vthree.z, vthree.y = 1, 3, 2 >>> vthree Vector([ 1., 2., 3.])
Return the column-vector version of self, which is currently implemented as a Matrix object. Note that matrix-vector multiplication will work without getting column first, so don’t use this unless you have a good reason to do so.
Returns cross product of self with other. Wrapper to numpy.cross
Same as normalize(), but does not modify self
Overrides the numpy.ndarray reshape function to make things make sense.
Examples : |
---|
>>> v = Vector([1,2,3,4])
>>> v.reshape((2,2))
Matrix([[ 1., 2.],
[ 3., 4.]])
>>> # `v` is unchanged:
>>> v
Vector([ 1., 2., 3., 4.])
>>> v.reshape((4,1))
Matrix([[ 1.],
[ 2.],
[ 3.],
[ 4.]])
>>> import numpy as np
>>> np.reshape(v, (2,2))
Matrix([[ 1., 2.],
[ 3., 4.]])
The x component of a cartesian vector
Raises : |
---|
The y component of a cartesian vector
Raises : |
---|
The z component of a cartesian vector
Raises : |
---|
alias of Wavenumber
Shallow copy operation on arbitrary Python objects.
See the module’s __doc__ string for more info.
Deep copy operation on arbitrary Python objects.
See the module’s __doc__ string for more info.
Because NumPy’s prod function uses 32-bit integer arithmetic with silent handling of overflows, results are wrong if the correct answer would exceed the limits of a signed 32-bit integer. When operating on a sequence of integers, the prod function that we define here uses large integer arithmetic and thus always gives correct results.
product(*iterables) –> product object
Cartesian product of input iterables. Equivalent to nested for-loops.
For example, product(A, B) returns the same as: ((x,y) for x in A for y in B). The leftmost iterators are in the outermost for-loop, so the output tuples cycle in a manner similar to an odometer (with the rightmost element changing on every iteration).
To compute the product of an iterable with itself, specify the number of repetitions with the optional repeat keyword argument. For example, product(A, repeat=4) means the same as product(A, A, A, A).
product(‘ab’, range(3)) –> (‘a’,0) (‘a’,1) (‘a’,2) (‘b’,0) (‘b’,1) (‘b’,2) product((0,1), (0,1), (0,1)) –> (0,0,0) (0,0,1) (0,1,0) (0,1,1) (1,0,0) ...
x.next() -> the next value, or raise StopIteration
Type checking for functions and methods.
Encapsulates an element. Contains attributes that are constant for a given element.
The most abundant isotope. This contains the default mass for the element.
Struct for containing the information about an isotope. For abundance, None means trace abundance
alias of KiloJoulePerMol
alias of AtomicMassUnit
alias of PicoMeter
Encapsulates an atom. Molecules are made up of Atoms.
Attributes : |
---|
Creates an orphaned copy of atom and displaces it by disp_vect
The Element object corresponding to self. Updated transparently using the symbol property
The isotope of the element that self is composed of. Defaults to element.principal_isotope
The atom’s mass as a float (in AMU). Automatically retrieved from the element and isotope attributes.
Alias for the parent_molecule attribute.
Alias for self.position. pos is also an alias for self.position
The atomic symbol from the periodic table (as a str object) , with correct capitalization. Updating this property transparently updates the Element object associated with self.
Alias for self.position. pos is also an alias for self.position
Encapsulates all of the functionality and attributes of a Molecule itself.
Signatures : |
|
---|---|
Parameters : |
Other Parameters: | |
---|---|
Attributes : |
---|
atoms : list of Atom internal_representations : list of InternalRepresentation normal_representation : NormalRepresentation cartesian_representation : CartesianRepresentation description : str
Examples : |
---|
Constructor
>>> Molecule("""
... 5
...
... C 0.000000 0.000000 0.000000
... H 0.000000 0.000000 1.089000
... H 1.026719 0.000000 -0.363000
... H -0.513360 -0.889165 -0.363000
... H -0.513360 0.889165 -0.363000
... """)
Molecule([
Atom('C', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('H', [ 0.00000000, 0.00000000, 1.08900000 ] ),
Atom('H', [ 1.02671900, 0.00000000, -0.36300000 ] ),
Atom('H', [ -0.51336000, -0.88916500, -0.36300000 ] ),
Atom('H', [ -0.51336000, 0.88916500, -0.36300000 ] )
])
>>> Molecule([
... Atom('H', [0,0,0]),
... Atom('H', [0,0,0.75])
... ])
Molecule([
Atom('H', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('H', [ 0.00000000, 0.00000000, 0.75000000 ] )
])
>>> Molecule(['H','C'], Matrix([[0,0,0],[1,0.5,0]]))
Molecule([
Atom('H', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('C', [ 1.00000000, 0.50000000, 0.00000000 ] )
])
>>> mol = Molecule("""
... 5
...
... C 0.000000 0.000000 0.000000
... H 0.000000 0.000000 1.089000
... H 1.026719 0.000000 -0.363000
... H -0.513360 -0.889165 -0.363000
... H -0.513360 0.889165 -0.363000
... """)
>>> mol
Molecule([
Atom('C', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('H', [ 0.00000000, 0.00000000, 1.08900000 ] ),
Atom('H', [ 1.02671900, 0.00000000, -0.36300000 ] ),
Atom('H', [ -0.51336000, -0.88916500, -0.36300000 ] ),
Atom('H', [ -0.51336000, 0.88916500, -0.36300000 ] )
])
Iteration
>>> from __future__ import print_function
>>> for atom in mol:
... print(repr(atom))
...
Atom('C', [ 0.00000000, 0.00000000, 0.00000000 ] )
Atom('H', [ 0.00000000, 0.00000000, 1.08900000 ] )
Atom('H', [ 1.02671900, 0.00000000, -0.36300000 ] )
Atom('H', [ -0.51336000, -0.88916500, -0.36300000 ] )
Atom('H', [ -0.51336000, 0.88916500, -0.36300000 ] )
The first principal axis of rotation, a. The positive phase is always chosen.
Note
This property depends directly on Molecule.principal_axes(), which is cached. See discussion of caching in A_e
The second principal axis of rotation, b. The positive phase is always chosen.
Note
This property depends directly on Molecule.principal_axes(), which is cached. See discussion of caching in A_e
The third principal axis of rotation, c. The positive phase is always chosen.
Note
This property depends directly on Molecule.principal_axes(), which is cached. See discussion of caching in A_e
The current default cartesian representation associated with the molecule. If the molecule has multiple cartesian representations, the first in the list self.cartesian_representations is returned. The setter for this property pushes the cartesian representation onto the front of the list.
Note
The setter does not check for uniqueness (unless it’s exactly the same object as another CartesianRepresentation). Thus, you should check to make sure the CartesianRepresentation you are assigning to the molecule is not already part of the molecule’s list of representations (to the degree of accuracy required for your particular application) before assigning. Repeatedly failing to do this check could cause runaway memory usage.
Returns a Vector giving the center of mass of the molecule in the current Cartesian representation. The units of the returned value are self.cartesian_units.
Note
This result of this method is cached, and the cached value gets flushed in update_cartesian_representation(). If you change an atom’s position (or mass) and forget to call update_cartesian_representation(), you may get some funny results for this method or any methods that depend on it, including recenter(), reorient(), and principal_moments_of_inertia(). You can detect whether caching is causing problems by setting the environment variable GRENDEL_NO_CACHE to 1 and rerunning your tests. If tests that were failing subsequently succeed, you probably forgot to call update_cartesian_representation() somewhere, or you were assuming that it was automatically called somewhere when in fact it was not getting called.
Create a Molecule object using only the name, SMILES, InChIKey, etc.
The easiest way to call Molecule.from_identifier() is to give it a single argument that is one of the following properties: * smiles * stdinchikey * stdinchi * ncicadd_identifier # (for FICTS, FICuS, uuuuu) * hashisy * cas_number * chemspider_id # input must be chemspider_id=1234567 * opsin_name * cir_name (These are resolved in roughly this order.) Visit the NIH CIR documentation for (some) explaination of what these identifiers are: http://cactus.nci.nih.gov/chemical/structure/documentation
Molecule.from_identifier() can be called with any (single) keyword argument in the grendel.util.web_getter.input_identifiers list. In this form, there must be only
This can also be called using an argument that is the value of a property and a second argument that is a list of fields to search for that property in.
Note: Molecule.get() is a very useful alias for this.
Examples : |
---|
TODO
TODO Document this more
Examples : |
---|
>>> Molecule.from_z_matrix("""
... O
... H1 O 1.0
... H2 O 1.0 H1 90.0
... """)
Molecule([
Atom('O', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('H', [ 0.00000000, 0.00000000, 1.00000000 ] ),
Atom('H', [ 0.00000000, -1.00000000, -0.00000000 ] )
])
>>> Molecule.from_z_matrix(
... [
... ['H'],
... ['O', 1, 0.9],
... ['O', 2, 1.4, 1, 105.0],
... ['H', 3, 0.9, 2, 105.0, 1, 120.0]
... ]
... )
Molecule([
Atom('H', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('O', [ 0.00000000, 0.00000000, 0.90000000 ] ),
Atom('O', [ 0.00000000, 1.35229616, 1.26234666 ] ),
Atom('H', [ -0.75286467, 1.46479616, 1.74249095 ] )
])
>>> Molecule.from_z_matrix(
... ['H'],
... ['O', 1, 0.9]
... )
Molecule([
Atom('H', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('O', [ 0.00000000, 0.00000000, 0.90000000 ] )
])
@param string: String containing a z-matrix with labels defined at the end using e.g. a234=8.5 @param args: Passed on to Molecule.from_z_matrix @param kwargs: Passed on to Molecule.from_z_matrix @return: Molecule object corresponding to the z-matrix passed in
Return a list of geometrically separated moieties of the molecule. Note: sub-molecules returned will have charge 0 and multiplicity 1 for now
@param n_vdw_radii: How many Van der Waals radii two atoms may be separated by and still be considered bonded @param default_vdw_radius: Van der Waals radius to use for elements that grendel doesn’t know the VDW radius of. @return: list of moieties as Molecule objects.
Create a Molecule object using only the name, SMILES, InChIKey, etc.
The easiest way to call Molecule.from_identifier() is to give it a single argument that is one of the following properties: * smiles * stdinchikey * stdinchi * ncicadd_identifier # (for FICTS, FICuS, uuuuu) * hashisy * cas_number * chemspider_id # input must be chemspider_id=1234567 * opsin_name * cir_name (These are resolved in roughly this order.) Visit the NIH CIR documentation for (some) explaination of what these identifiers are: http://cactus.nci.nih.gov/chemical/structure/documentation
Molecule.from_identifier() can be called with any (single) keyword argument in the grendel.util.web_getter.input_identifiers list. In this form, there must be only
This can also be called using an argument that is the value of a property and a second argument that is a list of fields to search for that property in.
Note: Molecule.get() is a very useful alias for this.
Examples : |
---|
TODO
Returns True if the elements of self correspond directly to the elements of other (i.e. self.atoms[0].element == other.atoms[0].element and self.atoms[1].element == other.atoms[1].element and ...)
Returns True if all of the elements are the same (including isotope and nuclear spin) and the reoriented() versions of self and other have no atoms whose pairwise position difference has a magnitude greater than tol (which defaults to 1e-8 Angstroms)
Examples : |
---|
>>> mol = Molecule('''
... O 1.5 0.0 0.0
... H 0.2 0.0 0.0
... ''')
>>> m1 = Molecule('''
... O 0.0 1.5 0.0
... H 0.0 0.2 0.0
... ''')
>>> m2 = Molecule('''
... O 0.00000 0.00000 0.200000
... H 0.00000 0.00000 1.500001
... ''')
>>> m3 = Molecule('''
... H 0.0 0.0 0.0
... H 0.0 -1.3 0.0
... ''')
>>> mol.has_same_geometry(m1)
True
>>> m1.has_same_geometry(m2)
False
>>> m1.has_same_geometry(m2, 1e-5)
True
>>> m2.has_same_geometry(mol, 1e-5)
True
>>> m1.has_same_geometry(m3)
False
True if op is a valid symmetry operation on self Each coordinate of the transformed atoms must differ from the original by less than
Returns the index of atom in the atoms array of the molecule
Note
This method returns a cached property Atom.index. If you reorder the atoms in a molecule, be sure and flush this cache by setting atom._index to None for all of the atoms in the reordered molecule.
Raises : |
---|
IndexError : if atom is not found in self
Examples : |
---|
>>> from grendel.chemistry import SampleMolecules, init_sample_molecules
>>> init_sample_molecules()
>>> h2o = SampleMolecules['water']
>>> atom1 = h2o[0]
>>> atom2 = h2o[1]
>>> atom3 = h2o[2]
>>> h2o
Molecule([
Atom('O', [ 0.00000000, 0.00000000, 0.11815400 ] ),
Atom('H', [ 0.00000000, 0.75873400, -0.47261400 ] ),
Atom('H', [ 0.00000000, -0.75873400, -0.47261400 ] )
])
>>> h2o.index(atom2)
1
>>> h2o.index(atom1)
0
>>> # It must be exactly the same instance to avoid raising an index error
>>> h2o.index(Atom('O', [ 0.00000000, 0.00000000, 0.11815400 ] ))
Traceback (most recent call last):
...
IndexError: ...
Returns a tuple of the principal moments of inertia vector and the principal axes matrix.
mol.inertial_system()
Computes the principal moments of inertia and the principal axes.
Note
This funtion mol.recenter() if the molecule is not centered, so any CartesianRepresentations that are not both frozen and referenced elsewhere (e.g. in a RepresentationDependentProperty) will be lost forever.
Note
This method is cached. See discussion of the consequences of caching in Molecule.center_of_mass()
Returns : |
---|
A tuple with types (Vector, Matrix) containing the principal moments of inertia and the principal axes, respectively. These should be aligned (i.e. ret_val[0][1] corresponds to the vector ret_val[1][1])
Examples : |
---|
>>> hnco = Molecule.from_z_matrix("""
... N
... C N 1.2145
... O C 1.1634 N 172.22
... H N 1.0030 C 123.34 O 180.0
... """
... )
>>> i = hnco.inertial_system()
>>> i[0]
Vector([ 0.60187342, 45.48378728, 46.0856607 ])
>>> i[1]
Matrix([[ 0. , 0. , 1. ],
[ 0.09870438, -0.9951168 , 0. ],
[ 0.9951168 , 0.09870438, 0. ]])
>>> j = hnco.inertial_system()
>>> i == j
True
>>> hnco.A_e
28.0085955528 Wavenumber
>>> hnco.B_e
0.370629408869 Wavenumber
>>> hnco.C_e
0.365789031483 Wavenumber
>>> hnco.a
Vector([ 0. , 0.09870438, 0.9951168 ])
>>> hnco.b
Vector([ 0. , -0.9951168 , 0.09870438])
>>> hnco.c
Vector([ 1., 0., 0.])
The first internal representations (of type InternalRepresentation), or None if it does not exist yet.
True if the center of mass is at the origin. This actually computes the vector from the origin to the center of mass and then determines if the magnitude of that vector is less than tol.
Parameters : |
---|
True if the molecule is linear to within tol. All diatomics should return True.
If tol is a ValueWithUnits and tol.units is an AngularUnit, then this method returns True only if all angles in the molecule are within tol of 180 Degrees. If tol.units is a unit-compatible with a moment of inertia (i.e. MassUnit * DistanceUnit**2 ), then this method returns True if the smallest principal moment of inertia is less than tol and the difference between the two largest principal moments of inertia is less than tol. If no units are given (i.e. tol is a float or other float-compatible unit), tol is assumed to have units of AngularUnit.default and the method proceeds as if tol.units was an AngularUnit subclass.
Parameters : |
---|
Examples : |
---|
>>> from grendel.chemistry import SampleMolecules, init_sample_molecules
>>> init_sample_molecules()
>>> SampleMolecules['water'].is_linear()
False
>>> SampleMolecules['CO2'].is_linear()
True
>>> SampleMolecules['Benzene'].is_linear()
False
The principal moments of inertia, as a Vector
Note
This funtion mol.recenter() if the molecule is not centered, so any CartesianRepresentations that are not both frozen and referenced elsewhere (e.g. in a RepresentationDependentProperty) will be lost forever.
Note
This method is cached. See discussion of the consequences of caching in Molecule.center_of_mass()
Examples: >>> hnco = Molecule.from_z_matrix(""" ... N ... C N 1.2145 ... O C 1.1634 N 172.22 ... H N 1.0030 C 123.34 O 180.0 ... """ ... ) >>> hnco.principal_moments_of_inertia() Vector([ 0.60187342, 45.48378728, 46.0856607 ]) >>> hnco.pmi() Vector([ 0.60187342, 45.48378728, 46.0856607 ])
See Also: principal_axes, inertial_system, A_e, B_e, C_e
Aliased as principal_moments_of_inertia()
The molecule’s position as a natoms x 3 Matrix. The ordering of rows is (as expected) the same as the ordering of the Molecule.atoms list attribute. Aliased to xyz_mat and position (the latter to be “consistant-ish” with the naming in Atom.
The principal axes as column vectors in a Matrix. The Vector object mol.principal_axes()[:,i] corresponds to the i`th moment of inertia, `mol.principal_moments_of_inertia()[i].
mol.principal_axes()
Note
This funtion mol.recenter() if the molecule is not centered, so any CartesianRepresentations that are not both frozen and referenced elsewhere (e.g. in a RepresentationDependentProperty) will be lost forever.
Note
This method is cached. See discussion of the consequences of caching in Molecule.center_of_mass()
Examples : |
---|
>>> hnco = Molecule.from_z_matrix("""
... N
... C N 1.2145
... O C 1.1634 N 172.22
... H N 1.0030 C 123.34 O 180.0
... """
... )
>>> hnco.principal_axes()
Matrix([[ 0. , 0. , 1. ],
[ 0.09870438, -0.9951168 , 0. ],
[ 0.9951168 , 0.09870438, 0. ]])
See Also: |
---|
principal_moments_of_inertia, inertial_system, A_e, B_e, C_e
Alias for pmi()
Recenters the molecule about the center of mass This modifies the molecule in place.
Examples : |
---|
>>> m = Molecule([Atom("O", [1.1, 1.3, 1.7])])
>>> m
Molecule([
Atom('O', [ 1.10000000, 1.30000000, 1.70000000 ] )
])
>>> m.recenter()
>>> m
Molecule([
Atom('O', [ 0.00000000, 0.00000000, 0.00000000 ] )
])
>>> m = Molecule(['H','H'], Matrix([[0,0,0],[1,0.0,0]]))
>>> m
Molecule([
Atom('H', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('H', [ 1.00000000, 0.00000000, 0.00000000 ] )
])
>>> m.recenter()
>>> m
Molecule([
Atom('H', [ -0.50000000, 0.00000000, 0.00000000 ] ),
Atom('H', [ 0.50000000, 0.00000000, 0.00000000 ] )
])
Same as recenter, but makes returns a copy. self is not modified.
Examples : |
---|
>>> foo = Molecule([Atom("O", [1.3, 1.7, 2.0])])
>>> bar = foo.recentered()
>>> foo.recenter()
>>> foo
Molecule([
Atom('O', [ 0.00000000, 0.00000000, 0.00000000 ] )
])
>>> foo == bar
True
>>> foo is bar
False
Reorient the molecule to align the x, y, and z axes with the principal axes of rotation.
Parameters : |
---|
Examples : |
---|
>>> from grendel.chemistry import SampleMolecules, init_sample_molecules
>>> init_sample_molecules()
>>> from grendel.gmath import chopped
>>> h2o = SampleMolecules['quantum water']
>>> h2o.principal_axes()
Matrix([[-0. , 0. , 1. ],
[-0.53654222, -0.84387348, 0. ],
[-0.84387348, 0.53654222, 0. ]])
>>> h2o.reorient()
>>> # Use chopped to get rid of very small numerical artifacts...
>>> # using abs to get rid of phase factor
>>> abs(chopped(h2o.principal_axes()))
Matrix([[ 0., 0., 1.],
[ 1., 0., 0.],
[ 0., 1., 0.]])
>>> h2o.reorient("I")
>>> from grendel.gmath import chopped
>>> abs(chopped(h2o.principal_axes()))
Matrix([[ 0., 1., 0.],
[ 0., 0., 1.],
[ 1., 0., 0.]])
>>> h2o.reorient("III")
>>> abs(chopped(h2o.principal_axes()))
Matrix([[ 1., 0., 0.],
[ 0., 1., 0.],
[ 0., 0., 1.]])
Same as reorient, but makes returns a copy. self is not modified.
Examples : |
---|
>>> from grendel.chemistry import SampleMolecules, init_sample_molecules
>>> init_sample_molecules()
>>> from grendel.gmath import chopped
>>> h2o = Molecule([
... Atom('O', [ 0.00000000, 0.00000000, 0.00000000 ] ),
... Atom('H', [ 0.00000000, 0.00000000, 1.00000000 ] ),
... Atom('H', [ 0.00000000, -1.00000000, -0.00000000 ] )
... ])
>>> new = h2o.reoriented()
>>> # Use chopped to get rid of very small numerical artifacts...
>>> chopped(new.principal_axes())
Matrix([[ 0., 0., 1.],
[-1., 0., 0.],
[ 0., 1., 0.]])
>>> new is h2o
False
>>> # original molecule is unchanged...
>>> h2o
Molecule([
Atom('O', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('H', [ 0.00000000, 0.00000000, 1.00000000 ] ),
Atom('H', [ 0.00000000, -1.00000000, -0.00000000 ] )
])
Rotates the molecule about axis (a Vector) by angle
Writes the Molecule to the standard xyz format.
See Molecule.xyz_string() for more details.
See Also: |
---|
xyz_string
The molecule’s position as a natoms x 3 Matrix. The ordering of rows is (as expected) the same as the ordering of the Molecule.atoms list attribute. Aliased to xyz_mat and position (the latter to be “consistant-ish” with the naming in Atom.
The molecule’s position as a natoms x 3 Matrix. The ordering of rows is (as expected) the same as the ordering of the Molecule.atoms list attribute. Aliased to xyz_mat and position (the latter to be “consistant-ish” with the naming in Atom.
The molecule, represented as a string in standard xyz format.
The first line will always be the number of atoms. The second line (which is a comment in the xyz specification) is filled by the description first line of the description attribute.
Parameters : |
---|
Examples : |
---|
>>> from __future__ import print_function
>>> from grendel.chemistry import SampleMolecules, init_sample_molecules
>>> init_sample_molecules()
>>> print(SampleMolecules['water'].xyz_string())
3
CCSD(T)/aug-cc-pVTZ Water
O 0.00000000 0.00000000 0.11815400
H 0.00000000 0.75873400 -0.47261400
H 0.00000000 -0.75873400 -0.47261400
>>> print(Molecule("O 1.0 0.5 1.5").xyz_string("Atom: %2s, x: %3.1f, y: %4.2f, z: %5.3f"))
1
Atom: O, x: 1.0, y: 0.50, z: 1.500
>>> print(Molecule("O 1.0 0.5 1.5").xyz_string("Atom: %2s, x: %3.1f, y: %4.2f, z: %5.3f", False))
Atom: O, x: 1.0, y: 0.50, z: 1.500
Raised if a line of a z-matrix has the wrong number of entries.
Raised if an invalid string in the XYZ format is passed into the Molecule class constructor
Encapsulates an element. Contains attributes that are constant for a given element.
The most abundant isotope. This contains the default mass for the element.
Struct for containing the information about an isotope. For abundance, None means trace abundance
Metaclass for defining Abstract Base Classes (ABCs).
Use this metaclass to create an ABC. An ABC can be subclassed directly, and then acts as a mix-in class. You can also register unrelated concrete classes (even built-in classes) and unrelated ABCs as ‘virtual subclasses’ – these and their descendants will be considered subclasses of the registering ABC by the built-in issubclass() function, but the registering ABC won’t show up in their MRO (Method Resolution Order) nor will method implementations defined by the registering ABC be callable (not even via super()).
Register a virtual subclass of an ABC.
Abstract base class for things that you are allowed to take derivatives of.
The value of the differentiable property. If this function is not overridden, assume that self can be added and subtracted, as well as multiplied by a float.
General superclass for all distance units
alias of Angstrom
alias of Angstrom
The energy of a molecule.
alias of Wavenumber
General superclass for all energy units
alias of Wavenumber
alias of Joule
Exception for attempted incompatible unit conversions
A property whose value is a matrix.
Placeholder implementation to satisfy abstract class requirements. Everything is already taken care of in MatrixProperty.from_sequence
Default implementation for matrix properties; only works if seq is a MatrixRegexSequence
Special subclass of RegexSequence that make parsing matrices easier.
Abstract base class for all properties
Attributes : |
---|
molecule : Molecule units : CompositeUnit or class with Unit metaclass
Retrieve the value of the property from a tuple of groups matched in a RegexSequence. See RegexSequence.groups()
Retrieve the value of the property from a RegexSequence object that has already been used on a file. By default, this just calls self.from_groups() with seq.groups(flatten) where flatten comes from self.from_groups.flatten.
The new paradigm for obtaining values. Call the callable instance attribute getter with the arguments and keyword arguments passed in.
The value of the molecular property.
Encapsulates all of the functionality and attributes of a Molecule itself.
Signatures : |
|
---|---|
Parameters : |
Other Parameters: | |
---|---|
Attributes : |
---|
atoms : list of Atom internal_representations : list of InternalRepresentation normal_representation : NormalRepresentation cartesian_representation : CartesianRepresentation description : str
Examples : |
---|
Constructor
>>> Molecule("""
... 5
...
... C 0.000000 0.000000 0.000000
... H 0.000000 0.000000 1.089000
... H 1.026719 0.000000 -0.363000
... H -0.513360 -0.889165 -0.363000
... H -0.513360 0.889165 -0.363000
... """)
Molecule([
Atom('C', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('H', [ 0.00000000, 0.00000000, 1.08900000 ] ),
Atom('H', [ 1.02671900, 0.00000000, -0.36300000 ] ),
Atom('H', [ -0.51336000, -0.88916500, -0.36300000 ] ),
Atom('H', [ -0.51336000, 0.88916500, -0.36300000 ] )
])
>>> Molecule([
... Atom('H', [0,0,0]),
... Atom('H', [0,0,0.75])
... ])
Molecule([
Atom('H', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('H', [ 0.00000000, 0.00000000, 0.75000000 ] )
])
>>> Molecule(['H','C'], Matrix([[0,0,0],[1,0.5,0]]))
Molecule([
Atom('H', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('C', [ 1.00000000, 0.50000000, 0.00000000 ] )
])
>>> mol = Molecule("""
... 5
...
... C 0.000000 0.000000 0.000000
... H 0.000000 0.000000 1.089000
... H 1.026719 0.000000 -0.363000
... H -0.513360 -0.889165 -0.363000
... H -0.513360 0.889165 -0.363000
... """)
>>> mol
Molecule([
Atom('C', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('H', [ 0.00000000, 0.00000000, 1.08900000 ] ),
Atom('H', [ 1.02671900, 0.00000000, -0.36300000 ] ),
Atom('H', [ -0.51336000, -0.88916500, -0.36300000 ] ),
Atom('H', [ -0.51336000, 0.88916500, -0.36300000 ] )
])
Iteration
>>> from __future__ import print_function
>>> for atom in mol:
... print(repr(atom))
...
Atom('C', [ 0.00000000, 0.00000000, 0.00000000 ] )
Atom('H', [ 0.00000000, 0.00000000, 1.08900000 ] )
Atom('H', [ 1.02671900, 0.00000000, -0.36300000 ] )
Atom('H', [ -0.51336000, -0.88916500, -0.36300000 ] )
Atom('H', [ -0.51336000, 0.88916500, -0.36300000 ] )
The first principal axis of rotation, a. The positive phase is always chosen.
Note
This property depends directly on Molecule.principal_axes(), which is cached. See discussion of caching in A_e
The second principal axis of rotation, b. The positive phase is always chosen.
Note
This property depends directly on Molecule.principal_axes(), which is cached. See discussion of caching in A_e
The third principal axis of rotation, c. The positive phase is always chosen.
Note
This property depends directly on Molecule.principal_axes(), which is cached. See discussion of caching in A_e
The current default cartesian representation associated with the molecule. If the molecule has multiple cartesian representations, the first in the list self.cartesian_representations is returned. The setter for this property pushes the cartesian representation onto the front of the list.
Note
The setter does not check for uniqueness (unless it’s exactly the same object as another CartesianRepresentation). Thus, you should check to make sure the CartesianRepresentation you are assigning to the molecule is not already part of the molecule’s list of representations (to the degree of accuracy required for your particular application) before assigning. Repeatedly failing to do this check could cause runaway memory usage.
Returns a Vector giving the center of mass of the molecule in the current Cartesian representation. The units of the returned value are self.cartesian_units.
Note
This result of this method is cached, and the cached value gets flushed in update_cartesian_representation(). If you change an atom’s position (or mass) and forget to call update_cartesian_representation(), you may get some funny results for this method or any methods that depend on it, including recenter(), reorient(), and principal_moments_of_inertia(). You can detect whether caching is causing problems by setting the environment variable GRENDEL_NO_CACHE to 1 and rerunning your tests. If tests that were failing subsequently succeed, you probably forgot to call update_cartesian_representation() somewhere, or you were assuming that it was automatically called somewhere when in fact it was not getting called.
Create a Molecule object using only the name, SMILES, InChIKey, etc.
The easiest way to call Molecule.from_identifier() is to give it a single argument that is one of the following properties: * smiles * stdinchikey * stdinchi * ncicadd_identifier # (for FICTS, FICuS, uuuuu) * hashisy * cas_number * chemspider_id # input must be chemspider_id=1234567 * opsin_name * cir_name (These are resolved in roughly this order.) Visit the NIH CIR documentation for (some) explaination of what these identifiers are: http://cactus.nci.nih.gov/chemical/structure/documentation
Molecule.from_identifier() can be called with any (single) keyword argument in the grendel.util.web_getter.input_identifiers list. In this form, there must be only
This can also be called using an argument that is the value of a property and a second argument that is a list of fields to search for that property in.
Note: Molecule.get() is a very useful alias for this.
Examples : |
---|
TODO
TODO Document this more
Examples : |
---|
>>> Molecule.from_z_matrix("""
... O
... H1 O 1.0
... H2 O 1.0 H1 90.0
... """)
Molecule([
Atom('O', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('H', [ 0.00000000, 0.00000000, 1.00000000 ] ),
Atom('H', [ 0.00000000, -1.00000000, -0.00000000 ] )
])
>>> Molecule.from_z_matrix(
... [
... ['H'],
... ['O', 1, 0.9],
... ['O', 2, 1.4, 1, 105.0],
... ['H', 3, 0.9, 2, 105.0, 1, 120.0]
... ]
... )
Molecule([
Atom('H', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('O', [ 0.00000000, 0.00000000, 0.90000000 ] ),
Atom('O', [ 0.00000000, 1.35229616, 1.26234666 ] ),
Atom('H', [ -0.75286467, 1.46479616, 1.74249095 ] )
])
>>> Molecule.from_z_matrix(
... ['H'],
... ['O', 1, 0.9]
... )
Molecule([
Atom('H', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('O', [ 0.00000000, 0.00000000, 0.90000000 ] )
])
@param string: String containing a z-matrix with labels defined at the end using e.g. a234=8.5 @param args: Passed on to Molecule.from_z_matrix @param kwargs: Passed on to Molecule.from_z_matrix @return: Molecule object corresponding to the z-matrix passed in
Return a list of geometrically separated moieties of the molecule. Note: sub-molecules returned will have charge 0 and multiplicity 1 for now
@param n_vdw_radii: How many Van der Waals radii two atoms may be separated by and still be considered bonded @param default_vdw_radius: Van der Waals radius to use for elements that grendel doesn’t know the VDW radius of. @return: list of moieties as Molecule objects.
Create a Molecule object using only the name, SMILES, InChIKey, etc.
The easiest way to call Molecule.from_identifier() is to give it a single argument that is one of the following properties: * smiles * stdinchikey * stdinchi * ncicadd_identifier # (for FICTS, FICuS, uuuuu) * hashisy * cas_number * chemspider_id # input must be chemspider_id=1234567 * opsin_name * cir_name (These are resolved in roughly this order.) Visit the NIH CIR documentation for (some) explaination of what these identifiers are: http://cactus.nci.nih.gov/chemical/structure/documentation
Molecule.from_identifier() can be called with any (single) keyword argument in the grendel.util.web_getter.input_identifiers list. In this form, there must be only
This can also be called using an argument that is the value of a property and a second argument that is a list of fields to search for that property in.
Note: Molecule.get() is a very useful alias for this.
Examples : |
---|
TODO
Returns True if the elements of self correspond directly to the elements of other (i.e. self.atoms[0].element == other.atoms[0].element and self.atoms[1].element == other.atoms[1].element and ...)
Returns True if all of the elements are the same (including isotope and nuclear spin) and the reoriented() versions of self and other have no atoms whose pairwise position difference has a magnitude greater than tol (which defaults to 1e-8 Angstroms)
Examples : |
---|
>>> mol = Molecule('''
... O 1.5 0.0 0.0
... H 0.2 0.0 0.0
... ''')
>>> m1 = Molecule('''
... O 0.0 1.5 0.0
... H 0.0 0.2 0.0
... ''')
>>> m2 = Molecule('''
... O 0.00000 0.00000 0.200000
... H 0.00000 0.00000 1.500001
... ''')
>>> m3 = Molecule('''
... H 0.0 0.0 0.0
... H 0.0 -1.3 0.0
... ''')
>>> mol.has_same_geometry(m1)
True
>>> m1.has_same_geometry(m2)
False
>>> m1.has_same_geometry(m2, 1e-5)
True
>>> m2.has_same_geometry(mol, 1e-5)
True
>>> m1.has_same_geometry(m3)
False
True if op is a valid symmetry operation on self Each coordinate of the transformed atoms must differ from the original by less than
Returns the index of atom in the atoms array of the molecule
Note
This method returns a cached property Atom.index. If you reorder the atoms in a molecule, be sure and flush this cache by setting atom._index to None for all of the atoms in the reordered molecule.
Raises : |
---|
IndexError : if atom is not found in self
Examples : |
---|
>>> from grendel.chemistry import SampleMolecules, init_sample_molecules
>>> init_sample_molecules()
>>> h2o = SampleMolecules['water']
>>> atom1 = h2o[0]
>>> atom2 = h2o[1]
>>> atom3 = h2o[2]
>>> h2o
Molecule([
Atom('O', [ 0.00000000, 0.00000000, 0.11815400 ] ),
Atom('H', [ 0.00000000, 0.75873400, -0.47261400 ] ),
Atom('H', [ 0.00000000, -0.75873400, -0.47261400 ] )
])
>>> h2o.index(atom2)
1
>>> h2o.index(atom1)
0
>>> # It must be exactly the same instance to avoid raising an index error
>>> h2o.index(Atom('O', [ 0.00000000, 0.00000000, 0.11815400 ] ))
Traceback (most recent call last):
...
IndexError: ...
Returns a tuple of the principal moments of inertia vector and the principal axes matrix.
mol.inertial_system()
Computes the principal moments of inertia and the principal axes.
Note
This funtion mol.recenter() if the molecule is not centered, so any CartesianRepresentations that are not both frozen and referenced elsewhere (e.g. in a RepresentationDependentProperty) will be lost forever.
Note
This method is cached. See discussion of the consequences of caching in Molecule.center_of_mass()
Returns : |
---|
A tuple with types (Vector, Matrix) containing the principal moments of inertia and the principal axes, respectively. These should be aligned (i.e. ret_val[0][1] corresponds to the vector ret_val[1][1])
Examples : |
---|
>>> hnco = Molecule.from_z_matrix("""
... N
... C N 1.2145
... O C 1.1634 N 172.22
... H N 1.0030 C 123.34 O 180.0
... """
... )
>>> i = hnco.inertial_system()
>>> i[0]
Vector([ 0.60187342, 45.48378728, 46.0856607 ])
>>> i[1]
Matrix([[ 0. , 0. , 1. ],
[ 0.09870438, -0.9951168 , 0. ],
[ 0.9951168 , 0.09870438, 0. ]])
>>> j = hnco.inertial_system()
>>> i == j
True
>>> hnco.A_e
28.0085955528 Wavenumber
>>> hnco.B_e
0.370629408869 Wavenumber
>>> hnco.C_e
0.365789031483 Wavenumber
>>> hnco.a
Vector([ 0. , 0.09870438, 0.9951168 ])
>>> hnco.b
Vector([ 0. , -0.9951168 , 0.09870438])
>>> hnco.c
Vector([ 1., 0., 0.])
The first internal representations (of type InternalRepresentation), or None if it does not exist yet.
True if the center of mass is at the origin. This actually computes the vector from the origin to the center of mass and then determines if the magnitude of that vector is less than tol.
Parameters : |
---|
True if the molecule is linear to within tol. All diatomics should return True.
If tol is a ValueWithUnits and tol.units is an AngularUnit, then this method returns True only if all angles in the molecule are within tol of 180 Degrees. If tol.units is a unit-compatible with a moment of inertia (i.e. MassUnit * DistanceUnit**2 ), then this method returns True if the smallest principal moment of inertia is less than tol and the difference between the two largest principal moments of inertia is less than tol. If no units are given (i.e. tol is a float or other float-compatible unit), tol is assumed to have units of AngularUnit.default and the method proceeds as if tol.units was an AngularUnit subclass.
Parameters : |
---|
Examples : |
---|
>>> from grendel.chemistry import SampleMolecules, init_sample_molecules
>>> init_sample_molecules()
>>> SampleMolecules['water'].is_linear()
False
>>> SampleMolecules['CO2'].is_linear()
True
>>> SampleMolecules['Benzene'].is_linear()
False
The principal moments of inertia, as a Vector
Note
This funtion mol.recenter() if the molecule is not centered, so any CartesianRepresentations that are not both frozen and referenced elsewhere (e.g. in a RepresentationDependentProperty) will be lost forever.
Note
This method is cached. See discussion of the consequences of caching in Molecule.center_of_mass()
Examples: >>> hnco = Molecule.from_z_matrix(""" ... N ... C N 1.2145 ... O C 1.1634 N 172.22 ... H N 1.0030 C 123.34 O 180.0 ... """ ... ) >>> hnco.principal_moments_of_inertia() Vector([ 0.60187342, 45.48378728, 46.0856607 ]) >>> hnco.pmi() Vector([ 0.60187342, 45.48378728, 46.0856607 ])
See Also: principal_axes, inertial_system, A_e, B_e, C_e
Aliased as principal_moments_of_inertia()
The molecule’s position as a natoms x 3 Matrix. The ordering of rows is (as expected) the same as the ordering of the Molecule.atoms list attribute. Aliased to xyz_mat and position (the latter to be “consistant-ish” with the naming in Atom.
The principal axes as column vectors in a Matrix. The Vector object mol.principal_axes()[:,i] corresponds to the i`th moment of inertia, `mol.principal_moments_of_inertia()[i].
mol.principal_axes()
Note
This funtion mol.recenter() if the molecule is not centered, so any CartesianRepresentations that are not both frozen and referenced elsewhere (e.g. in a RepresentationDependentProperty) will be lost forever.
Note
This method is cached. See discussion of the consequences of caching in Molecule.center_of_mass()
Examples : |
---|
>>> hnco = Molecule.from_z_matrix("""
... N
... C N 1.2145
... O C 1.1634 N 172.22
... H N 1.0030 C 123.34 O 180.0
... """
... )
>>> hnco.principal_axes()
Matrix([[ 0. , 0. , 1. ],
[ 0.09870438, -0.9951168 , 0. ],
[ 0.9951168 , 0.09870438, 0. ]])
See Also: |
---|
principal_moments_of_inertia, inertial_system, A_e, B_e, C_e
Alias for pmi()
Recenters the molecule about the center of mass This modifies the molecule in place.
Examples : |
---|
>>> m = Molecule([Atom("O", [1.1, 1.3, 1.7])])
>>> m
Molecule([
Atom('O', [ 1.10000000, 1.30000000, 1.70000000 ] )
])
>>> m.recenter()
>>> m
Molecule([
Atom('O', [ 0.00000000, 0.00000000, 0.00000000 ] )
])
>>> m = Molecule(['H','H'], Matrix([[0,0,0],[1,0.0,0]]))
>>> m
Molecule([
Atom('H', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('H', [ 1.00000000, 0.00000000, 0.00000000 ] )
])
>>> m.recenter()
>>> m
Molecule([
Atom('H', [ -0.50000000, 0.00000000, 0.00000000 ] ),
Atom('H', [ 0.50000000, 0.00000000, 0.00000000 ] )
])
Same as recenter, but makes returns a copy. self is not modified.
Examples : |
---|
>>> foo = Molecule([Atom("O", [1.3, 1.7, 2.0])])
>>> bar = foo.recentered()
>>> foo.recenter()
>>> foo
Molecule([
Atom('O', [ 0.00000000, 0.00000000, 0.00000000 ] )
])
>>> foo == bar
True
>>> foo is bar
False
Reorient the molecule to align the x, y, and z axes with the principal axes of rotation.
Parameters : |
---|
Examples : |
---|
>>> from grendel.chemistry import SampleMolecules, init_sample_molecules
>>> init_sample_molecules()
>>> from grendel.gmath import chopped
>>> h2o = SampleMolecules['quantum water']
>>> h2o.principal_axes()
Matrix([[-0. , 0. , 1. ],
[-0.53654222, -0.84387348, 0. ],
[-0.84387348, 0.53654222, 0. ]])
>>> h2o.reorient()
>>> # Use chopped to get rid of very small numerical artifacts...
>>> # using abs to get rid of phase factor
>>> abs(chopped(h2o.principal_axes()))
Matrix([[ 0., 0., 1.],
[ 1., 0., 0.],
[ 0., 1., 0.]])
>>> h2o.reorient("I")
>>> from grendel.gmath import chopped
>>> abs(chopped(h2o.principal_axes()))
Matrix([[ 0., 1., 0.],
[ 0., 0., 1.],
[ 1., 0., 0.]])
>>> h2o.reorient("III")
>>> abs(chopped(h2o.principal_axes()))
Matrix([[ 1., 0., 0.],
[ 0., 1., 0.],
[ 0., 0., 1.]])
Same as reorient, but makes returns a copy. self is not modified.
Examples : |
---|
>>> from grendel.chemistry import SampleMolecules, init_sample_molecules
>>> init_sample_molecules()
>>> from grendel.gmath import chopped
>>> h2o = Molecule([
... Atom('O', [ 0.00000000, 0.00000000, 0.00000000 ] ),
... Atom('H', [ 0.00000000, 0.00000000, 1.00000000 ] ),
... Atom('H', [ 0.00000000, -1.00000000, -0.00000000 ] )
... ])
>>> new = h2o.reoriented()
>>> # Use chopped to get rid of very small numerical artifacts...
>>> chopped(new.principal_axes())
Matrix([[ 0., 0., 1.],
[-1., 0., 0.],
[ 0., 1., 0.]])
>>> new is h2o
False
>>> # original molecule is unchanged...
>>> h2o
Molecule([
Atom('O', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('H', [ 0.00000000, 0.00000000, 1.00000000 ] ),
Atom('H', [ 0.00000000, -1.00000000, -0.00000000 ] )
])
Rotates the molecule about axis (a Vector) by angle
Writes the Molecule to the standard xyz format.
See Molecule.xyz_string() for more details.
See Also: |
---|
xyz_string
The molecule’s position as a natoms x 3 Matrix. The ordering of rows is (as expected) the same as the ordering of the Molecule.atoms list attribute. Aliased to xyz_mat and position (the latter to be “consistant-ish” with the naming in Atom.
The molecule’s position as a natoms x 3 Matrix. The ordering of rows is (as expected) the same as the ordering of the Molecule.atoms list attribute. Aliased to xyz_mat and position (the latter to be “consistant-ish” with the naming in Atom.
The molecule, represented as a string in standard xyz format.
The first line will always be the number of atoms. The second line (which is a comment in the xyz specification) is filled by the description first line of the description attribute.
Parameters : |
---|
Examples : |
---|
>>> from __future__ import print_function
>>> from grendel.chemistry import SampleMolecules, init_sample_molecules
>>> init_sample_molecules()
>>> print(SampleMolecules['water'].xyz_string())
3
CCSD(T)/aug-cc-pVTZ Water
O 0.00000000 0.00000000 0.11815400
H 0.00000000 0.75873400 -0.47261400
H 0.00000000 -0.75873400 -0.47261400
>>> print(Molecule("O 1.0 0.5 1.5").xyz_string("Atom: %2s, x: %3.1f, y: %4.2f, z: %5.3f"))
1
Atom: O, x: 1.0, y: 0.50, z: 1.500
>>> print(Molecule("O 1.0 0.5 1.5").xyz_string("Atom: %2s, x: %3.1f, y: %4.2f, z: %5.3f", False))
Atom: O, x: 1.0, y: 0.50, z: 1.500
All numbers inherit from this class.
If you just want to check if an argument x is a number, without caring what kind, use isinstance(x, Number).
alias of Wavenumber
Append some attributes to be set after the initialization is performed. Note that these override anything done in the class’s __init__, so don’t do anything stupid.
A property whose value is a scalar
By default, just get the last group matched.
Mostly a wrapper for the NumPy ndarray class. This gives us a place to put tensor-related functionality that we need but is not available in NumPy.
Copy all properties of the tensor except for the data.
Same as numpy.ndarray.flatten, but modified to return a Vector object
Examples : |
---|
>>> t = Tensor([[[1,2],[3,4]],[[5,6],[7,8]]])
>>> t
Tensor([[[ 1., 2.],
[ 3., 4.]],
[[ 5., 6.],
[ 7., 8.]]])
>>> t.flatten()
Vector([ 1., 2., 3., ..., 6., 7., 8.])
List of pointers to IndexRange objects over which the tensor is defined.
Returns True if all elements of self have absolute values less than cutoff, which defaults to Tensor.zero_cutoff
Note
Tensor.zero_cutoff is treated as a pseudo-class attribute for Tensor instances, meaning individual instances can also set a zero_cutoff attribute which will take precidence over the class-level default.
Given any number of Tensor objects that are the same up to a phase factor, return a list of Tensor objects that have been. Copies are only made if necessary. The chosen phase is the one that makes the first non-zero element (in the numpy.nditer(tensor) iterator, using the cutoff keyword argument or Tensor.zero_cutoff if one is not given) positive.
Allows conformance with the Unitized protocol.
A property whose value is an n-dimensional tensor
Abstract base class for things with units. It requires its subclasses to implement the properties ‘value’ and ‘units’. Unitized subclasses are also expected have __mul__, __div__, __truediv__, __pow__, __add__, __sub__, __neg__, __pos__, and __abs__ handle units correctly, when implemented in the given subclass.
Raised when a MolecularProperty is requested but not available for whatever reason.
A class for encapsulating a physical constant and it’s units.
Attributes : |
---|
A property whose value is a vector.
A decorator indicating abstract methods.
Requires that the metaclass is ABCMeta or derived from it. A class that has a metaclass derived from ABCMeta cannot be instantiated unless all of its abstract methods are overridden. The abstract methods can be called using any of the normal ‘super’ call mechanisms.
Usage:
- class C:
__metaclass__ = ABCMeta @abstractmethod def my_abstract_method(self, ...):
...
Convenience method for getting the typename as a string from the <type ‘Something’> string sent back by str(type(obj))
Alias for has_units()
Aliased as is_unit()
partial(func, *args, **keywords) - new function with partial application of the given arguments and keywords.
tuple of arguments to future partial calls
function object to use in future partial calls
dictionary of keyword arguments to future partial calls
Type checking for functions and methods.
Decorator allowing the assignment of attributes to a function.
Convenience error to raise when an argument is not of the right types.
A representations of a molecule in Cartesian coordinates. Since Atom objects already have Cartesian vectors associated with them, this class mostly consists of helper functions and convenience (accessor) functions that make CartesianRepresentation compatible with the parent Representation class.
Add an atom to the representation by creating a CartesianCoordinate object cooresponding to the atom.
Add a CartesianCoordinate to the representation.
Convenience method for accessing atoms. Returns self.molecule.atoms[number]
Convenience property for referencing the atoms list in the molecule associated with self.
Returns the index of the parameter atom in the representation self.
Parameters : |
---|
Raises : |
---|
Returns the value of the representation as a light vector
Renew the coordinates for an atom to coincide with the atom’s current position
Placeholder implementation to satisfy abstract class requirements. Everything is already taken care of in from_sequence
Expects a MatrixRegexSequence which returns a Nx3 matrix
The energy of a molecule.
alias of Wavenumber
alias of _PartiallyConstructed___EnergyDerivative1_0
alias of _PartiallyConstructed___EnergyDerivative2_1
alias of _PartiallyConstructed___EnergyDerivative1_0
alias of _PartiallyConstructed___EnergyDerivative1_0
alias of _PartiallyConstructed___EnergyDerivative2_1
Exception for attempted incompatible unit conversions
An internal coordinate representations of a molecule. TODO: More thoroughly document what this means.
The El’yashevich–Wilson B matrix pseudoinverse, with the Sayvetz conditions used to generate the inverse mass external conditions.
The El’yashevich–Wilson B matrix for the molecule in the representation.
Special subclass of RegexSequence that make parsing matrices easier.
Abstract base class for all properties
Attributes : |
---|
molecule : Molecule units : CompositeUnit or class with Unit metaclass
Retrieve the value of the property from a tuple of groups matched in a RegexSequence. See RegexSequence.groups()
Retrieve the value of the property from a RegexSequence object that has already been used on a file. By default, this just calls self.from_groups() with seq.groups(flatten) where flatten comes from self.from_groups.flatten.
The new paradigm for obtaining values. Call the callable instance attribute getter with the arguments and keyword arguments passed in.
The value of the molecular property.
Factory for creating MolecularProperty subclasses that represent the nth derivative of a MolecularProperty with respect to some set of coordinates.
Several possibilities for representation: If it’s a Representation subclass, then we want that representation of the molecule in question (used when requesting the derivative). If it’s a representation instance, then we want the Derivative with respect to that specific representation (raises an error if it is not compatible). If it’s an arbitrary callable, then the callable is called with the contents of the file and should return a representation, which the (typically parsed-from-a-file) derivative is considered to be with respect to. The default is CartesianRepresentation.
Derivative properties can be automatically or manually transformed to other representations.
Aliased as PropertyDerivative()
Append some attributes to be set after the initialization is performed. Note that these override anything done in the class’s __init__, so don’t do anything stupid.
Alias for MolecularPropertyDerivative()
Superclass of all the representations types.
Attributes : |
|
---|
Make a copy of self that is the same in every way except for the molecule attribute. New Coordinate objects are created using the Coordinate.copy_for_representation() method for each element of self.coords. This is an abstract method that must be implemented by all Representation subclasses.
Apply the Displacement instance disp to the molecule and current representation, generating a new molecule and a new representation (which start as a deepcopy and the return value of Representation.copy_with_molecule, respectively) with the displacement applied. This is an abstract method that must be implemented by all Representation subclasses.
Alias for values_for_matrix()
Alias for values_for_molecule()
Aliased as value_for_matrix()
Aliased as value_for_molecule()
A property whose value is dependent on a given representation of the molecule.
A property whose value is an n-dimensional tensor
Alias a function as something else. Set the documentation of the new method to “Alias for <function>()” and add “Aliased as <alias>()” to the documentation of function. Not inteded to be used as a decorator.
Examples : |
---|
>>> def foo(a, b, c):
... '''Print a test message.'''
... print "testing {0}, {1}, {2}".format(a, b, c)
...
>>> foo(1, 2, 3)
testing 1, 2, 3
>>> bar = function_alias('bar', foo)
>>> bar(4, 5, 6)
testing 4, 5, 6
>>> print bar.__doc__
Alias for `foo()`
>>> print foo.__doc__
Print a test message.
Aliased as `bar()`
>>> baz = function_alias('baz', foo)
>>> baz(7, 8, 9)
testing 7, 8, 9
>>> print foo.__doc__
Print a test message.
Aliased as `baz()`, `bar()`
Inside a class
>>> class FooBar(object):
... def testfunc(self, *args):
... '''Print out the args.'''
... print "testing " + ', '.join(str(a) for a in args)
... another_name = function_alias('another_name', testfunc)
... test_func = function_alias('test_func', testfunc)
...
>>> f = FooBar()
>>> f.test_func(1, 2, 3, 4)
testing 1, 2, 3, 4
>>> print FooBar.test_func.__doc__
Alias for `testfunc()`
>>> print FooBar.testfunc.__doc__
Print out the args.
Aliased as `test_func()`, `another_name()`
Returns True if a call of callable with args raises an error, and False if not. Note that the callable will get called, so don’t do anything that takes a long time or changes things in a way you don’t want them to be changed. If the optional keyword argument ‘error’ is given as either an Exception subclass or an Iterable, raises_error returns True if the call of callable raises the error given or one of the errors given in the list. (The keyword argument can also be named ‘errors’). Any other keyword arguments are passed through to callable.
Technical note: As per the Python manual, only exceptions that subclass from Exception (and not BaseException directly) will be recognized. According to the python users manual, you should never implement a user exception that subclasses from BaseException directly.
Examples : |
---|
>>> raises_error(int, "5")
False
>>> raises_error(int, "0x5ab7", 0)
False
>>> raises_error(lambda x: int(x), "5")
False
>>> raises_error(int, "abc")
True
>>> raises_error(int, "abc", error = ValueError)
True
>>> raises_error(int, "abc", error = BufferError)
False
>>> raises_error(int, "abc", error = (BufferError, EnvironmentError))
False
>>> raises_error(int, "abc", error = [BufferError, ValueError])
True
>>> raises_error(float, "abc")
True
>>> # Use raises_error to see what errors raises_error raises
... # Raise a type error if the first argument is not a callable (i.e. 17(25) doesn't make sense to Python)
... raises_error(raises_error, 17, 25, error = TypeError)
True
>>> # Raise a TypeError if the error keyword argument is not a subclass of Exception
... raises_error(lambda x: raises_error(int, x, error = "hello world"), 25, error = TypeError)
True
>>> raises_error(lambda x: raises_error(int, x, error = BaseException), 25, error = TypeError)
True
Raised when something that’s not allowed in group theory is done.
Encapsulates a point group.
Returns the element that is the same as op in the group self. This allows us to avoid duplication. When self._generate_elements is True, this adds op to self.operations if no operation is found that is the same as op (this should pretty much only be used by the internal PointGroup._close_group() private method. If you come up with another use for it, use it with care!) Otherwise, if an equivalent of op is not found, a GroupTheoryError is raised.
Returns the element that has the matrix mat in the group self. Raises a GroupTheoryError indicating the group is not closed if no such element is found.
Returns the number of (unique) axes of order n in the point group
Adds an element to the conjugacy class (if it has not already been added)
The abstract superclass for elements of point groups.
Attributes : |
---|
True if the axes a1 and a2 are parallel or antiparallel. Note that normalized versions of a1 and a2 are used, so normalizing before passing in will just slow things down. If parallel_only is True (it is False by default), this method only returns True if the two axes are parallel, not anti_parallel.
True if (a1-a2).norm() < SymmetryOperation.same_operation_tolerance (See ~pyobj:grendel.gmath.tensor.Tensor.norm for description of what is meant by norm here)
The Matrix that transforms the molecule according to the symmetry operation self
The Molecule that the operation acts on
A rotation (C_n^m) element of a point group.
Attributes : |
---|
The angle of rotation, in Radians
A reflection (sigma) element of a point group.
Whether or not the reflection is a sigma_d
An inversion (i) element of a point group.
An improper rotation (S_n^m) element of a point group.
Attributes : |
---|
Metaclass for defining Abstract Base Classes (ABCs).
Use this metaclass to create an ABC. An ABC can be subclassed directly, and then acts as a mix-in class. You can also register unrelated concrete classes (even built-in classes) and unrelated ABCs as ‘virtual subclasses’ – these and their descendants will be considered subclasses of the registering ABC by the built-in issubclass() function, but the registering ABC won’t show up in their MRO (Method Resolution Order) nor will method implementations defined by the registering ABC be callable (not even via super()).
Register a virtual subclass of an ABC.
Convenience error to raise when an argument is not of the right types.
A representations of a molecule in Cartesian coordinates. Since Atom objects already have Cartesian vectors associated with them, this class mostly consists of helper functions and convenience (accessor) functions that make CartesianRepresentation compatible with the parent Representation class.
Add an atom to the representation by creating a CartesianCoordinate object cooresponding to the atom.
Add a CartesianCoordinate to the representation.
Convenience method for accessing atoms. Returns self.molecule.atoms[number]
Convenience property for referencing the atoms list in the molecule associated with self.
Returns the index of the parameter atom in the representation self.
Parameters : |
---|
Raises : |
---|
Returns the value of the representation as a light vector
Renew the coordinates for an atom to coincide with the atom’s current position
Base class for all classes encapsulating runs of external programs
Checks to see if an identical input file with an identical name has already been run in the computation’s directory to produce an output file of some sort (if that output file has errors, you probably don’t want to rerun the exact same input file, so this doesn’t do that by default. If you need to do that, call Computation.run() with the force_rerun argument set to True).
True if and only if the calculation has finished running. (regardless of success or failure). Setting completed to True triggers the output parser.
The types of the properties in the self.properties list.
Convert strings to standard form for attributes. Strings with spaces, underscore_joined_strings, Uppercase_Underscore_Strings, and lowerCamelCase strings are all converted to UpperCamelCase.
Examples : |
---|
>>> Computation.standardize_attribute("basis_set")
'BasisSet'
>>> Computation.standardize_attribute("basis set")
'BasisSet'
>>> Computation.standardize_attribute("basis!Set")
'BasisSet'
>>> # Only _ and space serve as CamelCase separators:
>>> Computation.standardize_attribute("basis!set")
'Basisset'
>>> Computation.standardize_attribute("Level___of!*theory")
'LevelOftheory'
>>> # "Accidental" caps are not fixed...
>>> Computation.standardize_attribute("Level___of!*tHEory")
'LevelOftHEory'
>>> #All caps gets translated into title case
>>> Computation.standardize_attribute("Level&$#of__THEORY")
'LevelofTheory'
Encapsulates specifics about how the calculation was/is to be carried out, such as level of theory, basis set, program, etc. Can be subclassed for specific programs which may require special detail setting methods.
Effectively clones details. Used internally for making a details into a ComputationDetails subclass
Mostly for use by templates, this method returns a string of keyword-value pairs in using the given format for each argument in the argument list. format should use the str.format() protocol from the python standard library with the named slots {key} where the keyword name should go and {value} where the value of the detail should go (or, if the value of the detail is a Keyword object, the contents of the value attribute for that Keyword, or, if the value attribute for the keyword is not defined, the _name attribute for the Keyword object in question.
Aliased as keywordify
Mostly for use by templates, this method returns a string of keyword-value pairs in using the given format for each argument in the argument list. format should use the str.format() protocol from the python standard library with the named slots {key} where the keyword name should go and {value} where the value of the detail should go (or, if the value of the detail is a Keyword object, the contents of the value attribute for that Keyword, or, if the value attribute for the keyword is not defined, the _name attribute for the Keyword object in question.
Aliased as keywordify
Thrown when a computation fails for one reason or another
Alias for can_get_property_for_molecule()
Aliased as has_property(), can_get_property()
Alias for can_get_property_for_molecule()
Raised when a computation can’t be generated either because a compatible input template can’t be found or a valid output parser can’t be found
Placeholder implementation to satisfy abstract class requirements. Everything is already taken care of in from_sequence
Expects a MatrixRegexSequence which returns a Nx3 matrix
Abstract base class for things that you are allowed to take derivatives of.
The value of the differentiable property. If this function is not overridden, assume that self can be added and subtracted, as well as multiplied by a float.
General superclass for all distance units
alias of Angstrom
alias of Angstrom
The energy of a molecule.
alias of Wavenumber
alias of _PartiallyConstructed___EnergyDerivative1_0
alias of _PartiallyConstructed___EnergyDerivative2_1
General superclass for all energy units
alias of Wavenumber
alias of Joule
alias of _PartiallyConstructed___EnergyDerivative1_0
alias of _PartiallyConstructed___EnergyDerivative1_0
alias of _PartiallyConstructed___EnergyDerivative2_1
Exception for attempted incompatible unit conversions
Abstract base class for classes that generate input files.
Determine if we will be able to generate an input.
An internal coordinate representations of a molecule. TODO: More thoroughly document what this means.
The El’yashevich–Wilson B matrix pseudoinverse, with the Sayvetz conditions used to generate the inverse mass external conditions.
The El’yashevich–Wilson B matrix for the molecule in the representation.
A property whose value is a matrix.
Placeholder implementation to satisfy abstract class requirements. Everything is already taken care of in MatrixProperty.from_sequence
Default implementation for matrix properties; only works if seq is a MatrixRegexSequence
Special subclass of RegexSequence that make parsing matrices easier.
Abstract base class for all properties
Attributes : |
---|
molecule : Molecule units : CompositeUnit or class with Unit metaclass
Retrieve the value of the property from a tuple of groups matched in a RegexSequence. See RegexSequence.groups()
Retrieve the value of the property from a RegexSequence object that has already been used on a file. By default, this just calls self.from_groups() with seq.groups(flatten) where flatten comes from self.from_groups.flatten.
The new paradigm for obtaining values. Call the callable instance attribute getter with the arguments and keyword arguments passed in.
The value of the molecular property.
Factory for creating MolecularProperty subclasses that represent the nth derivative of a MolecularProperty with respect to some set of coordinates.
Several possibilities for representation: If it’s a Representation subclass, then we want that representation of the molecule in question (used when requesting the derivative). If it’s a representation instance, then we want the Derivative with respect to that specific representation (raises an error if it is not compatible). If it’s an arbitrary callable, then the callable is called with the contents of the file and should return a representation, which the (typically parsed-from-a-file) derivative is considered to be with respect to. The default is CartesianRepresentation.
Derivative properties can be automatically or manually transformed to other representations.
Aliased as PropertyDerivative()
Encapsulates all of the functionality and attributes of a Molecule itself.
Signatures : |
|
---|---|
Parameters : |
Other Parameters: | |
---|---|
Attributes : |
---|
atoms : list of Atom internal_representations : list of InternalRepresentation normal_representation : NormalRepresentation cartesian_representation : CartesianRepresentation description : str
Examples : |
---|
Constructor
>>> Molecule("""
... 5
...
... C 0.000000 0.000000 0.000000
... H 0.000000 0.000000 1.089000
... H 1.026719 0.000000 -0.363000
... H -0.513360 -0.889165 -0.363000
... H -0.513360 0.889165 -0.363000
... """)
Molecule([
Atom('C', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('H', [ 0.00000000, 0.00000000, 1.08900000 ] ),
Atom('H', [ 1.02671900, 0.00000000, -0.36300000 ] ),
Atom('H', [ -0.51336000, -0.88916500, -0.36300000 ] ),
Atom('H', [ -0.51336000, 0.88916500, -0.36300000 ] )
])
>>> Molecule([
... Atom('H', [0,0,0]),
... Atom('H', [0,0,0.75])
... ])
Molecule([
Atom('H', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('H', [ 0.00000000, 0.00000000, 0.75000000 ] )
])
>>> Molecule(['H','C'], Matrix([[0,0,0],[1,0.5,0]]))
Molecule([
Atom('H', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('C', [ 1.00000000, 0.50000000, 0.00000000 ] )
])
>>> mol = Molecule("""
... 5
...
... C 0.000000 0.000000 0.000000
... H 0.000000 0.000000 1.089000
... H 1.026719 0.000000 -0.363000
... H -0.513360 -0.889165 -0.363000
... H -0.513360 0.889165 -0.363000
... """)
>>> mol
Molecule([
Atom('C', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('H', [ 0.00000000, 0.00000000, 1.08900000 ] ),
Atom('H', [ 1.02671900, 0.00000000, -0.36300000 ] ),
Atom('H', [ -0.51336000, -0.88916500, -0.36300000 ] ),
Atom('H', [ -0.51336000, 0.88916500, -0.36300000 ] )
])
Iteration
>>> from __future__ import print_function
>>> for atom in mol:
... print(repr(atom))
...
Atom('C', [ 0.00000000, 0.00000000, 0.00000000 ] )
Atom('H', [ 0.00000000, 0.00000000, 1.08900000 ] )
Atom('H', [ 1.02671900, 0.00000000, -0.36300000 ] )
Atom('H', [ -0.51336000, -0.88916500, -0.36300000 ] )
Atom('H', [ -0.51336000, 0.88916500, -0.36300000 ] )
The first principal axis of rotation, a. The positive phase is always chosen.
Note
This property depends directly on Molecule.principal_axes(), which is cached. See discussion of caching in A_e
The second principal axis of rotation, b. The positive phase is always chosen.
Note
This property depends directly on Molecule.principal_axes(), which is cached. See discussion of caching in A_e
The third principal axis of rotation, c. The positive phase is always chosen.
Note
This property depends directly on Molecule.principal_axes(), which is cached. See discussion of caching in A_e
The current default cartesian representation associated with the molecule. If the molecule has multiple cartesian representations, the first in the list self.cartesian_representations is returned. The setter for this property pushes the cartesian representation onto the front of the list.
Note
The setter does not check for uniqueness (unless it’s exactly the same object as another CartesianRepresentation). Thus, you should check to make sure the CartesianRepresentation you are assigning to the molecule is not already part of the molecule’s list of representations (to the degree of accuracy required for your particular application) before assigning. Repeatedly failing to do this check could cause runaway memory usage.
Returns a Vector giving the center of mass of the molecule in the current Cartesian representation. The units of the returned value are self.cartesian_units.
Note
This result of this method is cached, and the cached value gets flushed in update_cartesian_representation(). If you change an atom’s position (or mass) and forget to call update_cartesian_representation(), you may get some funny results for this method or any methods that depend on it, including recenter(), reorient(), and principal_moments_of_inertia(). You can detect whether caching is causing problems by setting the environment variable GRENDEL_NO_CACHE to 1 and rerunning your tests. If tests that were failing subsequently succeed, you probably forgot to call update_cartesian_representation() somewhere, or you were assuming that it was automatically called somewhere when in fact it was not getting called.
Create a Molecule object using only the name, SMILES, InChIKey, etc.
The easiest way to call Molecule.from_identifier() is to give it a single argument that is one of the following properties: * smiles * stdinchikey * stdinchi * ncicadd_identifier # (for FICTS, FICuS, uuuuu) * hashisy * cas_number * chemspider_id # input must be chemspider_id=1234567 * opsin_name * cir_name (These are resolved in roughly this order.) Visit the NIH CIR documentation for (some) explaination of what these identifiers are: http://cactus.nci.nih.gov/chemical/structure/documentation
Molecule.from_identifier() can be called with any (single) keyword argument in the grendel.util.web_getter.input_identifiers list. In this form, there must be only
This can also be called using an argument that is the value of a property and a second argument that is a list of fields to search for that property in.
Note: Molecule.get() is a very useful alias for this.
Examples : |
---|
TODO
TODO Document this more
Examples : |
---|
>>> Molecule.from_z_matrix("""
... O
... H1 O 1.0
... H2 O 1.0 H1 90.0
... """)
Molecule([
Atom('O', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('H', [ 0.00000000, 0.00000000, 1.00000000 ] ),
Atom('H', [ 0.00000000, -1.00000000, -0.00000000 ] )
])
>>> Molecule.from_z_matrix(
... [
... ['H'],
... ['O', 1, 0.9],
... ['O', 2, 1.4, 1, 105.0],
... ['H', 3, 0.9, 2, 105.0, 1, 120.0]
... ]
... )
Molecule([
Atom('H', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('O', [ 0.00000000, 0.00000000, 0.90000000 ] ),
Atom('O', [ 0.00000000, 1.35229616, 1.26234666 ] ),
Atom('H', [ -0.75286467, 1.46479616, 1.74249095 ] )
])
>>> Molecule.from_z_matrix(
... ['H'],
... ['O', 1, 0.9]
... )
Molecule([
Atom('H', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('O', [ 0.00000000, 0.00000000, 0.90000000 ] )
])
@param string: String containing a z-matrix with labels defined at the end using e.g. a234=8.5 @param args: Passed on to Molecule.from_z_matrix @param kwargs: Passed on to Molecule.from_z_matrix @return: Molecule object corresponding to the z-matrix passed in
Return a list of geometrically separated moieties of the molecule. Note: sub-molecules returned will have charge 0 and multiplicity 1 for now
@param n_vdw_radii: How many Van der Waals radii two atoms may be separated by and still be considered bonded @param default_vdw_radius: Van der Waals radius to use for elements that grendel doesn’t know the VDW radius of. @return: list of moieties as Molecule objects.
Create a Molecule object using only the name, SMILES, InChIKey, etc.
The easiest way to call Molecule.from_identifier() is to give it a single argument that is one of the following properties: * smiles * stdinchikey * stdinchi * ncicadd_identifier # (for FICTS, FICuS, uuuuu) * hashisy * cas_number * chemspider_id # input must be chemspider_id=1234567 * opsin_name * cir_name (These are resolved in roughly this order.) Visit the NIH CIR documentation for (some) explaination of what these identifiers are: http://cactus.nci.nih.gov/chemical/structure/documentation
Molecule.from_identifier() can be called with any (single) keyword argument in the grendel.util.web_getter.input_identifiers list. In this form, there must be only
This can also be called using an argument that is the value of a property and a second argument that is a list of fields to search for that property in.
Note: Molecule.get() is a very useful alias for this.
Examples : |
---|
TODO
Returns True if the elements of self correspond directly to the elements of other (i.e. self.atoms[0].element == other.atoms[0].element and self.atoms[1].element == other.atoms[1].element and ...)
Returns True if all of the elements are the same (including isotope and nuclear spin) and the reoriented() versions of self and other have no atoms whose pairwise position difference has a magnitude greater than tol (which defaults to 1e-8 Angstroms)
Examples : |
---|
>>> mol = Molecule('''
... O 1.5 0.0 0.0
... H 0.2 0.0 0.0
... ''')
>>> m1 = Molecule('''
... O 0.0 1.5 0.0
... H 0.0 0.2 0.0
... ''')
>>> m2 = Molecule('''
... O 0.00000 0.00000 0.200000
... H 0.00000 0.00000 1.500001
... ''')
>>> m3 = Molecule('''
... H 0.0 0.0 0.0
... H 0.0 -1.3 0.0
... ''')
>>> mol.has_same_geometry(m1)
True
>>> m1.has_same_geometry(m2)
False
>>> m1.has_same_geometry(m2, 1e-5)
True
>>> m2.has_same_geometry(mol, 1e-5)
True
>>> m1.has_same_geometry(m3)
False
True if op is a valid symmetry operation on self Each coordinate of the transformed atoms must differ from the original by less than
Returns the index of atom in the atoms array of the molecule
Note
This method returns a cached property Atom.index. If you reorder the atoms in a molecule, be sure and flush this cache by setting atom._index to None for all of the atoms in the reordered molecule.
Raises : |
---|
IndexError : if atom is not found in self
Examples : |
---|
>>> from grendel.chemistry import SampleMolecules, init_sample_molecules
>>> init_sample_molecules()
>>> h2o = SampleMolecules['water']
>>> atom1 = h2o[0]
>>> atom2 = h2o[1]
>>> atom3 = h2o[2]
>>> h2o
Molecule([
Atom('O', [ 0.00000000, 0.00000000, 0.11815400 ] ),
Atom('H', [ 0.00000000, 0.75873400, -0.47261400 ] ),
Atom('H', [ 0.00000000, -0.75873400, -0.47261400 ] )
])
>>> h2o.index(atom2)
1
>>> h2o.index(atom1)
0
>>> # It must be exactly the same instance to avoid raising an index error
>>> h2o.index(Atom('O', [ 0.00000000, 0.00000000, 0.11815400 ] ))
Traceback (most recent call last):
...
IndexError: ...
Returns a tuple of the principal moments of inertia vector and the principal axes matrix.
mol.inertial_system()
Computes the principal moments of inertia and the principal axes.
Note
This funtion mol.recenter() if the molecule is not centered, so any CartesianRepresentations that are not both frozen and referenced elsewhere (e.g. in a RepresentationDependentProperty) will be lost forever.
Note
This method is cached. See discussion of the consequences of caching in Molecule.center_of_mass()
Returns : |
---|
A tuple with types (Vector, Matrix) containing the principal moments of inertia and the principal axes, respectively. These should be aligned (i.e. ret_val[0][1] corresponds to the vector ret_val[1][1])
Examples : |
---|
>>> hnco = Molecule.from_z_matrix("""
... N
... C N 1.2145
... O C 1.1634 N 172.22
... H N 1.0030 C 123.34 O 180.0
... """
... )
>>> i = hnco.inertial_system()
>>> i[0]
Vector([ 0.60187342, 45.48378728, 46.0856607 ])
>>> i[1]
Matrix([[ 0. , 0. , 1. ],
[ 0.09870438, -0.9951168 , 0. ],
[ 0.9951168 , 0.09870438, 0. ]])
>>> j = hnco.inertial_system()
>>> i == j
True
>>> hnco.A_e
28.0085955528 Wavenumber
>>> hnco.B_e
0.370629408869 Wavenumber
>>> hnco.C_e
0.365789031483 Wavenumber
>>> hnco.a
Vector([ 0. , 0.09870438, 0.9951168 ])
>>> hnco.b
Vector([ 0. , -0.9951168 , 0.09870438])
>>> hnco.c
Vector([ 1., 0., 0.])
The first internal representations (of type InternalRepresentation), or None if it does not exist yet.
True if the center of mass is at the origin. This actually computes the vector from the origin to the center of mass and then determines if the magnitude of that vector is less than tol.
Parameters : |
---|
True if the molecule is linear to within tol. All diatomics should return True.
If tol is a ValueWithUnits and tol.units is an AngularUnit, then this method returns True only if all angles in the molecule are within tol of 180 Degrees. If tol.units is a unit-compatible with a moment of inertia (i.e. MassUnit * DistanceUnit**2 ), then this method returns True if the smallest principal moment of inertia is less than tol and the difference between the two largest principal moments of inertia is less than tol. If no units are given (i.e. tol is a float or other float-compatible unit), tol is assumed to have units of AngularUnit.default and the method proceeds as if tol.units was an AngularUnit subclass.
Parameters : |
---|
Examples : |
---|
>>> from grendel.chemistry import SampleMolecules, init_sample_molecules
>>> init_sample_molecules()
>>> SampleMolecules['water'].is_linear()
False
>>> SampleMolecules['CO2'].is_linear()
True
>>> SampleMolecules['Benzene'].is_linear()
False
The principal moments of inertia, as a Vector
Note
This funtion mol.recenter() if the molecule is not centered, so any CartesianRepresentations that are not both frozen and referenced elsewhere (e.g. in a RepresentationDependentProperty) will be lost forever.
Note
This method is cached. See discussion of the consequences of caching in Molecule.center_of_mass()
Examples: >>> hnco = Molecule.from_z_matrix(""" ... N ... C N 1.2145 ... O C 1.1634 N 172.22 ... H N 1.0030 C 123.34 O 180.0 ... """ ... ) >>> hnco.principal_moments_of_inertia() Vector([ 0.60187342, 45.48378728, 46.0856607 ]) >>> hnco.pmi() Vector([ 0.60187342, 45.48378728, 46.0856607 ])
See Also: principal_axes, inertial_system, A_e, B_e, C_e
Aliased as principal_moments_of_inertia()
The molecule’s position as a natoms x 3 Matrix. The ordering of rows is (as expected) the same as the ordering of the Molecule.atoms list attribute. Aliased to xyz_mat and position (the latter to be “consistant-ish” with the naming in Atom.
The principal axes as column vectors in a Matrix. The Vector object mol.principal_axes()[:,i] corresponds to the i`th moment of inertia, `mol.principal_moments_of_inertia()[i].
mol.principal_axes()
Note
This funtion mol.recenter() if the molecule is not centered, so any CartesianRepresentations that are not both frozen and referenced elsewhere (e.g. in a RepresentationDependentProperty) will be lost forever.
Note
This method is cached. See discussion of the consequences of caching in Molecule.center_of_mass()
Examples : |
---|
>>> hnco = Molecule.from_z_matrix("""
... N
... C N 1.2145
... O C 1.1634 N 172.22
... H N 1.0030 C 123.34 O 180.0
... """
... )
>>> hnco.principal_axes()
Matrix([[ 0. , 0. , 1. ],
[ 0.09870438, -0.9951168 , 0. ],
[ 0.9951168 , 0.09870438, 0. ]])
See Also: |
---|
principal_moments_of_inertia, inertial_system, A_e, B_e, C_e
Alias for pmi()
Recenters the molecule about the center of mass This modifies the molecule in place.
Examples : |
---|
>>> m = Molecule([Atom("O", [1.1, 1.3, 1.7])])
>>> m
Molecule([
Atom('O', [ 1.10000000, 1.30000000, 1.70000000 ] )
])
>>> m.recenter()
>>> m
Molecule([
Atom('O', [ 0.00000000, 0.00000000, 0.00000000 ] )
])
>>> m = Molecule(['H','H'], Matrix([[0,0,0],[1,0.0,0]]))
>>> m
Molecule([
Atom('H', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('H', [ 1.00000000, 0.00000000, 0.00000000 ] )
])
>>> m.recenter()
>>> m
Molecule([
Atom('H', [ -0.50000000, 0.00000000, 0.00000000 ] ),
Atom('H', [ 0.50000000, 0.00000000, 0.00000000 ] )
])
Same as recenter, but makes returns a copy. self is not modified.
Examples : |
---|
>>> foo = Molecule([Atom("O", [1.3, 1.7, 2.0])])
>>> bar = foo.recentered()
>>> foo.recenter()
>>> foo
Molecule([
Atom('O', [ 0.00000000, 0.00000000, 0.00000000 ] )
])
>>> foo == bar
True
>>> foo is bar
False
Reorient the molecule to align the x, y, and z axes with the principal axes of rotation.
Parameters : |
---|
Examples : |
---|
>>> from grendel.chemistry import SampleMolecules, init_sample_molecules
>>> init_sample_molecules()
>>> from grendel.gmath import chopped
>>> h2o = SampleMolecules['quantum water']
>>> h2o.principal_axes()
Matrix([[-0. , 0. , 1. ],
[-0.53654222, -0.84387348, 0. ],
[-0.84387348, 0.53654222, 0. ]])
>>> h2o.reorient()
>>> # Use chopped to get rid of very small numerical artifacts...
>>> # using abs to get rid of phase factor
>>> abs(chopped(h2o.principal_axes()))
Matrix([[ 0., 0., 1.],
[ 1., 0., 0.],
[ 0., 1., 0.]])
>>> h2o.reorient("I")
>>> from grendel.gmath import chopped
>>> abs(chopped(h2o.principal_axes()))
Matrix([[ 0., 1., 0.],
[ 0., 0., 1.],
[ 1., 0., 0.]])
>>> h2o.reorient("III")
>>> abs(chopped(h2o.principal_axes()))
Matrix([[ 1., 0., 0.],
[ 0., 1., 0.],
[ 0., 0., 1.]])
Same as reorient, but makes returns a copy. self is not modified.
Examples : |
---|
>>> from grendel.chemistry import SampleMolecules, init_sample_molecules
>>> init_sample_molecules()
>>> from grendel.gmath import chopped
>>> h2o = Molecule([
... Atom('O', [ 0.00000000, 0.00000000, 0.00000000 ] ),
... Atom('H', [ 0.00000000, 0.00000000, 1.00000000 ] ),
... Atom('H', [ 0.00000000, -1.00000000, -0.00000000 ] )
... ])
>>> new = h2o.reoriented()
>>> # Use chopped to get rid of very small numerical artifacts...
>>> chopped(new.principal_axes())
Matrix([[ 0., 0., 1.],
[-1., 0., 0.],
[ 0., 1., 0.]])
>>> new is h2o
False
>>> # original molecule is unchanged...
>>> h2o
Molecule([
Atom('O', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('H', [ 0.00000000, 0.00000000, 1.00000000 ] ),
Atom('H', [ 0.00000000, -1.00000000, -0.00000000 ] )
])
Rotates the molecule about axis (a Vector) by angle
Writes the Molecule to the standard xyz format.
See Molecule.xyz_string() for more details.
See Also: |
---|
xyz_string
The molecule’s position as a natoms x 3 Matrix. The ordering of rows is (as expected) the same as the ordering of the Molecule.atoms list attribute. Aliased to xyz_mat and position (the latter to be “consistant-ish” with the naming in Atom.
The molecule’s position as a natoms x 3 Matrix. The ordering of rows is (as expected) the same as the ordering of the Molecule.atoms list attribute. Aliased to xyz_mat and position (the latter to be “consistant-ish” with the naming in Atom.
The molecule, represented as a string in standard xyz format.
The first line will always be the number of atoms. The second line (which is a comment in the xyz specification) is filled by the description first line of the description attribute.
Parameters : |
---|
Examples : |
---|
>>> from __future__ import print_function
>>> from grendel.chemistry import SampleMolecules, init_sample_molecules
>>> init_sample_molecules()
>>> print(SampleMolecules['water'].xyz_string())
3
CCSD(T)/aug-cc-pVTZ Water
O 0.00000000 0.00000000 0.11815400
H 0.00000000 0.75873400 -0.47261400
H 0.00000000 -0.75873400 -0.47261400
>>> print(Molecule("O 1.0 0.5 1.5").xyz_string("Atom: %2s, x: %3.1f, y: %4.2f, z: %5.3f"))
1
Atom: O, x: 1.0, y: 0.50, z: 1.500
>>> print(Molecule("O 1.0 0.5 1.5").xyz_string("Atom: %2s, x: %3.1f, y: %4.2f, z: %5.3f", False))
Atom: O, x: 1.0, y: 0.50, z: 1.500
All numbers inherit from this class.
If you just want to check if an argument x is a number, without caring what kind, use isinstance(x, Number).
alias of Wavenumber
Abstract base class for classes that parse the output file for a computation.
Container for the various custom classes needed to run a calculation in a given software package.
alias of Computation
alias of ComputationDetails
Load a package with the given name to be used for computations. Optionally, specify specific subclasses to use for certain things.
Append some attributes to be set after the initialization is performed. Note that these override anything done in the class’s __init__, so don’t do anything stupid.
Alias for MolecularPropertyDerivative()
Superclass of all the representations types.
Attributes : |
|
---|
Make a copy of self that is the same in every way except for the molecule attribute. New Coordinate objects are created using the Coordinate.copy_for_representation() method for each element of self.coords. This is an abstract method that must be implemented by all Representation subclasses.
Apply the Displacement instance disp to the molecule and current representation, generating a new molecule and a new representation (which start as a deepcopy and the return value of Representation.copy_with_molecule, respectively) with the displacement applied. This is an abstract method that must be implemented by all Representation subclasses.
Alias for values_for_matrix()
Alias for values_for_molecule()
Aliased as value_for_matrix()
Aliased as value_for_molecule()
A property whose value is dependent on a given representation of the molecule.
Abstract base class for classes that run a computation (or an equivalent task, such as submit a job to a PBS queue). Not all Computation objects need a runner; for instance XML-parsed computations are constructed in an already-run state.
Run in a blocking manner. Default implementation calls wait() on the process returned by start(). Overload it if this doesn’t make sense.
Determine if we will be able to run. Raise a ComputationUnavailableError if running will cause a crash
A property whose value is a scalar
By default, just get the last group matched.
Create and return a temporary file. Arguments: ‘prefix’, ‘suffix’, ‘dir’ – as for mkstemp. ‘mode’ – the mode argument to os.fdopen (default “w+b”). ‘bufsize’ – the buffer size argument to os.fdopen (default -1). The file is created as mkstemp() would do it.
Returns an object with a file-like interface. The file has no name, and will cease to exist when it is closed.
Mostly a wrapper for the NumPy ndarray class. This gives us a place to put tensor-related functionality that we need but is not available in NumPy.
Copy all properties of the tensor except for the data.
Same as numpy.ndarray.flatten, but modified to return a Vector object
Examples : |
---|
>>> t = Tensor([[[1,2],[3,4]],[[5,6],[7,8]]])
>>> t
Tensor([[[ 1., 2.],
[ 3., 4.]],
[[ 5., 6.],
[ 7., 8.]]])
>>> t.flatten()
Vector([ 1., 2., 3., ..., 6., 7., 8.])
List of pointers to IndexRange objects over which the tensor is defined.
Returns True if all elements of self have absolute values less than cutoff, which defaults to Tensor.zero_cutoff
Note
Tensor.zero_cutoff is treated as a pseudo-class attribute for Tensor instances, meaning individual instances can also set a zero_cutoff attribute which will take precidence over the class-level default.
Given any number of Tensor objects that are the same up to a phase factor, return a list of Tensor objects that have been. Copies are only made if necessary. The chosen phase is the one that makes the first non-zero element (in the numpy.nditer(tensor) iterator, using the cutoff keyword argument or Tensor.zero_cutoff if one is not given) positive.
Allows conformance with the Unitized protocol.
A property whose value is an n-dimensional tensor
Abstract base class for things with units. It requires its subclasses to implement the properties ‘value’ and ‘units’. Unitized subclasses are also expected have __mul__, __div__, __truediv__, __pow__, __add__, __sub__, __neg__, __pos__, and __abs__ handle units correctly, when implemented in the given subclass.
Raised when a MolecularProperty is requested but not available for whatever reason.
A class for encapsulating a physical constant and it’s units.
Attributes : |
---|
A property whose value is a vector.
A decorator indicating abstract methods.
Requires that the metaclass is ABCMeta or derived from it. A class that has a metaclass derived from ABCMeta cannot be instantiated unless all of its abstract methods are overridden. The abstract methods can be called using any of the normal ‘super’ call mechanisms.
Usage:
- class C:
__metaclass__ = ABCMeta @abstractmethod def my_abstract_method(self, ...):
...
Execute code with a lock acquired before the block of code and released afterwards
Convenience method for getting the typename as a string from the <type ‘Something’> string sent back by str(type(obj))
Alias a function as something else. Set the documentation of the new method to “Alias for <function>()” and add “Aliased as <alias>()” to the documentation of function. Not inteded to be used as a decorator.
Examples : |
---|
>>> def foo(a, b, c):
... '''Print a test message.'''
... print "testing {0}, {1}, {2}".format(a, b, c)
...
>>> foo(1, 2, 3)
testing 1, 2, 3
>>> bar = function_alias('bar', foo)
>>> bar(4, 5, 6)
testing 4, 5, 6
>>> print bar.__doc__
Alias for `foo()`
>>> print foo.__doc__
Print a test message.
Aliased as `bar()`
>>> baz = function_alias('baz', foo)
>>> baz(7, 8, 9)
testing 7, 8, 9
>>> print foo.__doc__
Print a test message.
Aliased as `baz()`, `bar()`
Inside a class
>>> class FooBar(object):
... def testfunc(self, *args):
... '''Print out the args.'''
... print "testing " + ', '.join(str(a) for a in args)
... another_name = function_alias('another_name', testfunc)
... test_func = function_alias('test_func', testfunc)
...
>>> f = FooBar()
>>> f.test_func(1, 2, 3, 4)
testing 1, 2, 3, 4
>>> print FooBar.test_func.__doc__
Alias for `testfunc()`
>>> print FooBar.testfunc.__doc__
Print out the args.
Aliased as `test_func()`, `another_name()`
group(3, ‘ABCDEFG’, ‘x’) –> ABC DEF Gxx
Alias for has_units()
Alias for indented()
islice(iterable, [start,] stop [, step]) –> islice object
Return an iterator whose next() method returns selected values from an iterable. If start is specified, will skip all preceding elements; otherwise, start defaults to zero. Step defaults to one. If specified as another value, step determines how many values are skipped between successive calls. Works like a slice() on a list but returns an iterator.
x.next() -> the next value, or raise StopIteration
Aliased as is_unit()
partial(func, *args, **keywords) - new function with partial application of the given arguments and keywords.
tuple of arguments to future partial calls
function object to use in future partial calls
dictionary of keyword arguments to future partial calls
Utility function for getting the value of a keyword argument that can be named multiple things and popping that value off of the kwarg dictionary. If the None of the keywords given are found in kwarg_dict, None is returned.
See Also: |
---|
get_multikwarg
Returns True if a call of callable with args raises an error, and False if not. Note that the callable will get called, so don’t do anything that takes a long time or changes things in a way you don’t want them to be changed. If the optional keyword argument ‘error’ is given as either an Exception subclass or an Iterable, raises_error returns True if the call of callable raises the error given or one of the errors given in the list. (The keyword argument can also be named ‘errors’). Any other keyword arguments are passed through to callable.
Technical note: As per the Python manual, only exceptions that subclass from Exception (and not BaseException directly) will be recognized. According to the python users manual, you should never implement a user exception that subclasses from BaseException directly.
Examples : |
---|
>>> raises_error(int, "5")
False
>>> raises_error(int, "0x5ab7", 0)
False
>>> raises_error(lambda x: int(x), "5")
False
>>> raises_error(int, "abc")
True
>>> raises_error(int, "abc", error = ValueError)
True
>>> raises_error(int, "abc", error = BufferError)
False
>>> raises_error(int, "abc", error = (BufferError, EnvironmentError))
False
>>> raises_error(int, "abc", error = [BufferError, ValueError])
True
>>> raises_error(float, "abc")
True
>>> # Use raises_error to see what errors raises_error raises
... # Raise a type error if the first argument is not a callable (i.e. 17(25) doesn't make sense to Python)
... raises_error(raises_error, 17, 25, error = TypeError)
True
>>> # Raise a TypeError if the error keyword argument is not a subclass of Exception
... raises_error(lambda x: raises_error(int, x, error = "hello world"), 25, error = TypeError)
True
>>> raises_error(lambda x: raises_error(int, x, error = BaseException), 25, error = TypeError)
True
Type checking for functions and methods.
Issue a warning, or maybe ignore it or raise an exception.
Decorator allowing the assignment of attributes to a function.
Allows the creation of functions with case insensative, alternately named keyword arguments.
Examples : |
---|
>>> @with_flexible_arguments(
... required=[
... ('name', 'greet', 'name_to_greet'),
... ('from_where', 'source')
... ],
... optional=[
... ('greeting', 'hello_phrase', 'salutation'),
... ('message',)
... ]
... )
... def say_hello(name, from_where, greeting='Hello', message=''):
... print(greeting + ', ' + name + ', from ' + from_where + '!' + message)
...
>>> say_hello('moon', 'Earth')
Hello, moon, from Earth!
>>> say_hello('world', source='the moon')
Hello, world, from the moon!
>>> say_hello(source='France', name_to_greet='visitor', salutation='Bonjour')
Bonjour, visitor, from France!
>>> say_hello('earthlings', 'outer space', 'Greetings', message=' We come in peace!')
Greetings, earthlings, from outer space! We come in peace!
Change to a certain working directory for the execution of a block of code, then change back upon (any kind of) exit.
Encapsulates specifics about how the calculation was/is to be carried out, such as level of theory, basis set, program, etc. Can be subclassed for specific programs which may require special detail setting methods.
Effectively clones details. Used internally for making a details into a ComputationDetails subclass
Mostly for use by templates, this method returns a string of keyword-value pairs in using the given format for each argument in the argument list. format should use the str.format() protocol from the python standard library with the named slots {key} where the keyword name should go and {value} where the value of the detail should go (or, if the value of the detail is a Keyword object, the contents of the value attribute for that Keyword, or, if the value attribute for the keyword is not defined, the _name attribute for the Keyword object in question.
Aliased as keywordify
Mostly for use by templates, this method returns a string of keyword-value pairs in using the given format for each argument in the argument list. format should use the str.format() protocol from the python standard library with the named slots {key} where the keyword name should go and {value} where the value of the detail should go (or, if the value of the detail is a Keyword object, the contents of the value attribute for that Keyword, or, if the value attribute for the keyword is not defined, the _name attribute for the Keyword object in question.
Aliased as keywordify
Simple container for keyword-like objects (“sentinal values”). Can also be used as a container for sub-keywords via instance objects. Sub-keywords are case-insensative. Keywords cannot be assigned values using the value attribute (note that this means you can’t create a sub-keyword called ‘value’).
Warning
Since there is exactly one instance of every unique keyword (with two keywords that differ by capitalization not being unique), storing a value can have some unexpected consequences. For instance:
>>> Hello = Keyword('Hello')
>>> foo = Hello.World
>>> foo.value = "good bye"
>>> # ...some time later...
>>> Hello.WORLD.value = "good night"
>>> foo.value
'good night'
Note
Since value, parent, _parent, parents, _name, and any of the double-underscore methods inherited from object are already attributes of Keyword objects, you can’t make sub-keywords with these names. Everything else is fair game.
Examples : |
---|
>>> Hello = Keyword('Hello')
>>> Hello.World
Hello.World
>>> # Any future changes in case simply refer back to the original
>>> Hello.WoRlD
Hello.World
>>> # But, of course, not for the first level
>>> hEllO.World
Traceback (most recent call last):
...
NameError: name 'hEllO' is not defined
>>> # Multiple levels can be created at once
>>> Hello.there.world
Hello.there.world
>>> Hello.there == Hello.ThErE
True
>>> Hello.there == Hello.ThErE.world
False
>>> Hello.there.WORLD == Hello.ThErE.world
True
>>> Hello.There.World.value = "Hello World"
>>> Hello.THERE.WORLD.value
'Hello World'
Simple container for keyword-like objects (“sentinal values”). Can also be used as a container for sub-keywords via instance objects. Sub-keywords are case-insensative. Keywords cannot be assigned values using the value attribute (note that this means you can’t create a sub-keyword called ‘value’).
Warning
Since there is exactly one instance of every unique keyword (with two keywords that differ by capitalization not being unique), storing a value can have some unexpected consequences. For instance:
>>> Hello = Keyword('Hello')
>>> foo = Hello.World
>>> foo.value = "good bye"
>>> # ...some time later...
>>> Hello.WORLD.value = "good night"
>>> foo.value
'good night'
Note
Since value, parent, _parent, parents, _name, and any of the double-underscore methods inherited from object are already attributes of Keyword objects, you can’t make sub-keywords with these names. Everything else is fair game.
Examples : |
---|
>>> Hello = Keyword('Hello')
>>> Hello.World
Hello.World
>>> # Any future changes in case simply refer back to the original
>>> Hello.WoRlD
Hello.World
>>> # But, of course, not for the first level
>>> hEllO.World
Traceback (most recent call last):
...
NameError: name 'hEllO' is not defined
>>> # Multiple levels can be created at once
>>> Hello.there.world
Hello.there.world
>>> Hello.there == Hello.ThErE
True
>>> Hello.there == Hello.ThErE.world
False
>>> Hello.there.WORLD == Hello.ThErE.world
True
>>> Hello.There.World.value = "Hello World"
>>> Hello.THERE.WORLD.value
'Hello World'
Simple container for keyword-like objects (“sentinal values”). Can also be used as a container for sub-keywords via instance objects. Sub-keywords are case-insensative. Keywords cannot be assigned values using the value attribute (note that this means you can’t create a sub-keyword called ‘value’).
Warning
Since there is exactly one instance of every unique keyword (with two keywords that differ by capitalization not being unique), storing a value can have some unexpected consequences. For instance:
>>> Hello = Keyword('Hello')
>>> foo = Hello.World
>>> foo.value = "good bye"
>>> # ...some time later...
>>> Hello.WORLD.value = "good night"
>>> foo.value
'good night'
Note
Since value, parent, _parent, parents, _name, and any of the double-underscore methods inherited from object are already attributes of Keyword objects, you can’t make sub-keywords with these names. Everything else is fair game.
Examples : |
---|
>>> Hello = Keyword('Hello')
>>> Hello.World
Hello.World
>>> # Any future changes in case simply refer back to the original
>>> Hello.WoRlD
Hello.World
>>> # But, of course, not for the first level
>>> hEllO.World
Traceback (most recent call last):
...
NameError: name 'hEllO' is not defined
>>> # Multiple levels can be created at once
>>> Hello.there.world
Hello.there.world
>>> Hello.there == Hello.ThErE
True
>>> Hello.there == Hello.ThErE.world
False
>>> Hello.there.WORLD == Hello.ThErE.world
True
>>> Hello.There.World.value = "Hello World"
>>> Hello.THERE.WORLD.value
'Hello World'
Metaclass for defining Abstract Base Classes (ABCs).
Use this metaclass to create an ABC. An ABC can be subclassed directly, and then acts as a mix-in class. You can also register unrelated concrete classes (even built-in classes) and unrelated ABCs as ‘virtual subclasses’ – these and their descendants will be considered subclasses of the registering ABC by the built-in issubclass() function, but the registering ABC won’t show up in their MRO (Method Resolution Order) nor will method implementations defined by the registering ABC be callable (not even via super()).
Register a virtual subclass of an ABC.
Base class for all classes encapsulating runs of external programs
Checks to see if an identical input file with an identical name has already been run in the computation’s directory to produce an output file of some sort (if that output file has errors, you probably don’t want to rerun the exact same input file, so this doesn’t do that by default. If you need to do that, call Computation.run() with the force_rerun argument set to True).
True if and only if the calculation has finished running. (regardless of success or failure). Setting completed to True triggers the output parser.
The types of the properties in the self.properties list.
Convert strings to standard form for attributes. Strings with spaces, underscore_joined_strings, Uppercase_Underscore_Strings, and lowerCamelCase strings are all converted to UpperCamelCase.
Examples : |
---|
>>> Computation.standardize_attribute("basis_set")
'BasisSet'
>>> Computation.standardize_attribute("basis set")
'BasisSet'
>>> Computation.standardize_attribute("basis!Set")
'BasisSet'
>>> # Only _ and space serve as CamelCase separators:
>>> Computation.standardize_attribute("basis!set")
'Basisset'
>>> Computation.standardize_attribute("Level___of!*theory")
'LevelOftheory'
>>> # "Accidental" caps are not fixed...
>>> Computation.standardize_attribute("Level___of!*tHEory")
'LevelOftHEory'
>>> #All caps gets translated into title case
>>> Computation.standardize_attribute("Level&$#of__THEORY")
'LevelofTheory'
Alias for can_get_property_for_molecule()
Aliased as has_property(), can_get_property()
Alias for can_get_property_for_molecule()
Raised when a computation can’t be generated either because a compatible input template can’t be found or a valid output parser can’t be found
Abstract base class for all properties
Attributes : |
---|
molecule : Molecule units : CompositeUnit or class with Unit metaclass
Retrieve the value of the property from a tuple of groups matched in a RegexSequence. See RegexSequence.groups()
Retrieve the value of the property from a RegexSequence object that has already been used on a file. By default, this just calls self.from_groups() with seq.groups(flatten) where flatten comes from self.from_groups.flatten.
The new paradigm for obtaining values. Call the callable instance attribute getter with the arguments and keyword arguments passed in.
The value of the molecular property.
Abstract base class for all classes that encapsulate a method of retrieving a (set of) properties of a molecule from a computational chemistry package. An instance of a ResultGetter object should know how to turn a request for a given molecular property into a Computation object (which, in turn, houses MolecularProperty objects for one or more Molecule objects). ResultGetter objects generate Computation objects. Any ResultGetter subclass should always check for an available computation on (exactly) the same molecule that already has the result available.
A decorator indicating abstract methods.
Requires that the metaclass is ABCMeta or derived from it. A class that has a metaclass derived from ABCMeta cannot be instantiated unless all of its abstract methods are overridden. The abstract methods can be called using any of the normal ‘super’ call mechanisms.
Usage:
- class C:
__metaclass__ = ABCMeta @abstractmethod def my_abstract_method(self, ...):
...
Shallow copy operation on arbitrary Python objects.
See the module’s __doc__ string for more info.
Alias a function as something else. Set the documentation of the new method to “Alias for <function>()” and add “Aliased as <alias>()” to the documentation of function. Not inteded to be used as a decorator.
Examples : |
---|
>>> def foo(a, b, c):
... '''Print a test message.'''
... print "testing {0}, {1}, {2}".format(a, b, c)
...
>>> foo(1, 2, 3)
testing 1, 2, 3
>>> bar = function_alias('bar', foo)
>>> bar(4, 5, 6)
testing 4, 5, 6
>>> print bar.__doc__
Alias for `foo()`
>>> print foo.__doc__
Print a test message.
Aliased as `bar()`
>>> baz = function_alias('baz', foo)
>>> baz(7, 8, 9)
testing 7, 8, 9
>>> print foo.__doc__
Print a test message.
Aliased as `baz()`, `bar()`
Inside a class
>>> class FooBar(object):
... def testfunc(self, *args):
... '''Print out the args.'''
... print "testing " + ', '.join(str(a) for a in args)
... another_name = function_alias('another_name', testfunc)
... test_func = function_alias('test_func', testfunc)
...
>>> f = FooBar()
>>> f.test_func(1, 2, 3, 4)
testing 1, 2, 3, 4
>>> print FooBar.test_func.__doc__
Alias for `testfunc()`
>>> print FooBar.testfunc.__doc__
Print out the args.
Aliased as `test_func()`, `another_name()`
Metaclass for defining Abstract Base Classes (ABCs).
Use this metaclass to create an ABC. An ABC can be subclassed directly, and then acts as a mix-in class. You can also register unrelated concrete classes (even built-in classes) and unrelated ABCs as ‘virtual subclasses’ – these and their descendants will be considered subclasses of the registering ABC by the built-in issubclass() function, but the registering ABC won’t show up in their MRO (Method Resolution Order) nor will method implementations defined by the registering ABC be callable (not even via super()).
Register a virtual subclass of an ABC.
Encapsulates specifics about how the calculation was/is to be carried out, such as level of theory, basis set, program, etc. Can be subclassed for specific programs which may require special detail setting methods.
Effectively clones details. Used internally for making a details into a ComputationDetails subclass
Mostly for use by templates, this method returns a string of keyword-value pairs in using the given format for each argument in the argument list. format should use the str.format() protocol from the python standard library with the named slots {key} where the keyword name should go and {value} where the value of the detail should go (or, if the value of the detail is a Keyword object, the contents of the value attribute for that Keyword, or, if the value attribute for the keyword is not defined, the _name attribute for the Keyword object in question.
Aliased as keywordify
Mostly for use by templates, this method returns a string of keyword-value pairs in using the given format for each argument in the argument list. format should use the str.format() protocol from the python standard library with the named slots {key} where the keyword name should go and {value} where the value of the detail should go (or, if the value of the detail is a Keyword object, the contents of the value attribute for that Keyword, or, if the value attribute for the keyword is not defined, the _name attribute for the Keyword object in question.
Aliased as keywordify
Raised when a computation can’t be generated either because a compatible input template can’t be found or a valid output parser can’t be found
Superclass for classes that are compatible with specific ComputationDetail objects or any ComputationDetail object more specifically specifice than the details variable.
Abstract base class for things that you are allowed to take derivatives of.
The value of the differentiable property. If this function is not overridden, assume that self can be added and subtracted, as well as multiplied by a float.
General superclass for all distance units
alias of Angstrom
alias of Angstrom
The energy of a molecule.
alias of Wavenumber
General superclass for all energy units
alias of Wavenumber
alias of Joule
Exception for attempted incompatible unit conversions
Abstract base class for classes that generate input files.
Determine if we will be able to generate an input.
A collection of convenience methods for generating InputGenerator classes
Simple container for keyword-like objects (“sentinal values”). Can also be used as a container for sub-keywords via instance objects. Sub-keywords are case-insensative. Keywords cannot be assigned values using the value attribute (note that this means you can’t create a sub-keyword called ‘value’).
Warning
Since there is exactly one instance of every unique keyword (with two keywords that differ by capitalization not being unique), storing a value can have some unexpected consequences. For instance:
>>> Hello = Keyword('Hello')
>>> foo = Hello.World
>>> foo.value = "good bye"
>>> # ...some time later...
>>> Hello.WORLD.value = "good night"
>>> foo.value
'good night'
Note
Since value, parent, _parent, parents, _name, and any of the double-underscore methods inherited from object are already attributes of Keyword objects, you can’t make sub-keywords with these names. Everything else is fair game.
Examples : |
---|
>>> Hello = Keyword('Hello')
>>> Hello.World
Hello.World
>>> # Any future changes in case simply refer back to the original
>>> Hello.WoRlD
Hello.World
>>> # But, of course, not for the first level
>>> hEllO.World
Traceback (most recent call last):
...
NameError: name 'hEllO' is not defined
>>> # Multiple levels can be created at once
>>> Hello.there.world
Hello.there.world
>>> Hello.there == Hello.ThErE
True
>>> Hello.there == Hello.ThErE.world
False
>>> Hello.there.WORLD == Hello.ThErE.world
True
>>> Hello.There.World.value = "Hello World"
>>> Hello.THERE.WORLD.value
'Hello World'
The keyword immediately preceding self in the heirarchical keyword notation. For instance:
>>> Hello = Keyword('Hello')
>>> Hello.World.parent
Hello
>>> Hello.There.World.parent
Hello.There
list of all parent keywords, ordered from immediate parent to most distant
A property whose value is a matrix.
Placeholder implementation to satisfy abstract class requirements. Everything is already taken care of in MatrixProperty.from_sequence
Default implementation for matrix properties; only works if seq is a MatrixRegexSequence
Special subclass of RegexSequence that make parsing matrices easier.
Abstract base class for all properties
Attributes : |
---|
molecule : Molecule units : CompositeUnit or class with Unit metaclass
Retrieve the value of the property from a tuple of groups matched in a RegexSequence. See RegexSequence.groups()
Retrieve the value of the property from a RegexSequence object that has already been used on a file. By default, this just calls self.from_groups() with seq.groups(flatten) where flatten comes from self.from_groups.flatten.
The new paradigm for obtaining values. Call the callable instance attribute getter with the arguments and keyword arguments passed in.
The value of the molecular property.
Encapsulates all of the functionality and attributes of a Molecule itself.
Signatures : |
|
---|---|
Parameters : |
Other Parameters: | |
---|---|
Attributes : |
---|
atoms : list of Atom internal_representations : list of InternalRepresentation normal_representation : NormalRepresentation cartesian_representation : CartesianRepresentation description : str
Examples : |
---|
Constructor
>>> Molecule("""
... 5
...
... C 0.000000 0.000000 0.000000
... H 0.000000 0.000000 1.089000
... H 1.026719 0.000000 -0.363000
... H -0.513360 -0.889165 -0.363000
... H -0.513360 0.889165 -0.363000
... """)
Molecule([
Atom('C', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('H', [ 0.00000000, 0.00000000, 1.08900000 ] ),
Atom('H', [ 1.02671900, 0.00000000, -0.36300000 ] ),
Atom('H', [ -0.51336000, -0.88916500, -0.36300000 ] ),
Atom('H', [ -0.51336000, 0.88916500, -0.36300000 ] )
])
>>> Molecule([
... Atom('H', [0,0,0]),
... Atom('H', [0,0,0.75])
... ])
Molecule([
Atom('H', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('H', [ 0.00000000, 0.00000000, 0.75000000 ] )
])
>>> Molecule(['H','C'], Matrix([[0,0,0],[1,0.5,0]]))
Molecule([
Atom('H', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('C', [ 1.00000000, 0.50000000, 0.00000000 ] )
])
>>> mol = Molecule("""
... 5
...
... C 0.000000 0.000000 0.000000
... H 0.000000 0.000000 1.089000
... H 1.026719 0.000000 -0.363000
... H -0.513360 -0.889165 -0.363000
... H -0.513360 0.889165 -0.363000
... """)
>>> mol
Molecule([
Atom('C', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('H', [ 0.00000000, 0.00000000, 1.08900000 ] ),
Atom('H', [ 1.02671900, 0.00000000, -0.36300000 ] ),
Atom('H', [ -0.51336000, -0.88916500, -0.36300000 ] ),
Atom('H', [ -0.51336000, 0.88916500, -0.36300000 ] )
])
Iteration
>>> from __future__ import print_function
>>> for atom in mol:
... print(repr(atom))
...
Atom('C', [ 0.00000000, 0.00000000, 0.00000000 ] )
Atom('H', [ 0.00000000, 0.00000000, 1.08900000 ] )
Atom('H', [ 1.02671900, 0.00000000, -0.36300000 ] )
Atom('H', [ -0.51336000, -0.88916500, -0.36300000 ] )
Atom('H', [ -0.51336000, 0.88916500, -0.36300000 ] )
The first principal axis of rotation, a. The positive phase is always chosen.
Note
This property depends directly on Molecule.principal_axes(), which is cached. See discussion of caching in A_e
The second principal axis of rotation, b. The positive phase is always chosen.
Note
This property depends directly on Molecule.principal_axes(), which is cached. See discussion of caching in A_e
The third principal axis of rotation, c. The positive phase is always chosen.
Note
This property depends directly on Molecule.principal_axes(), which is cached. See discussion of caching in A_e
The current default cartesian representation associated with the molecule. If the molecule has multiple cartesian representations, the first in the list self.cartesian_representations is returned. The setter for this property pushes the cartesian representation onto the front of the list.
Note
The setter does not check for uniqueness (unless it’s exactly the same object as another CartesianRepresentation). Thus, you should check to make sure the CartesianRepresentation you are assigning to the molecule is not already part of the molecule’s list of representations (to the degree of accuracy required for your particular application) before assigning. Repeatedly failing to do this check could cause runaway memory usage.
Returns a Vector giving the center of mass of the molecule in the current Cartesian representation. The units of the returned value are self.cartesian_units.
Note
This result of this method is cached, and the cached value gets flushed in update_cartesian_representation(). If you change an atom’s position (or mass) and forget to call update_cartesian_representation(), you may get some funny results for this method or any methods that depend on it, including recenter(), reorient(), and principal_moments_of_inertia(). You can detect whether caching is causing problems by setting the environment variable GRENDEL_NO_CACHE to 1 and rerunning your tests. If tests that were failing subsequently succeed, you probably forgot to call update_cartesian_representation() somewhere, or you were assuming that it was automatically called somewhere when in fact it was not getting called.
Create a Molecule object using only the name, SMILES, InChIKey, etc.
The easiest way to call Molecule.from_identifier() is to give it a single argument that is one of the following properties: * smiles * stdinchikey * stdinchi * ncicadd_identifier # (for FICTS, FICuS, uuuuu) * hashisy * cas_number * chemspider_id # input must be chemspider_id=1234567 * opsin_name * cir_name (These are resolved in roughly this order.) Visit the NIH CIR documentation for (some) explaination of what these identifiers are: http://cactus.nci.nih.gov/chemical/structure/documentation
Molecule.from_identifier() can be called with any (single) keyword argument in the grendel.util.web_getter.input_identifiers list. In this form, there must be only
This can also be called using an argument that is the value of a property and a second argument that is a list of fields to search for that property in.
Note: Molecule.get() is a very useful alias for this.
Examples : |
---|
TODO
TODO Document this more
Examples : |
---|
>>> Molecule.from_z_matrix("""
... O
... H1 O 1.0
... H2 O 1.0 H1 90.0
... """)
Molecule([
Atom('O', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('H', [ 0.00000000, 0.00000000, 1.00000000 ] ),
Atom('H', [ 0.00000000, -1.00000000, -0.00000000 ] )
])
>>> Molecule.from_z_matrix(
... [
... ['H'],
... ['O', 1, 0.9],
... ['O', 2, 1.4, 1, 105.0],
... ['H', 3, 0.9, 2, 105.0, 1, 120.0]
... ]
... )
Molecule([
Atom('H', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('O', [ 0.00000000, 0.00000000, 0.90000000 ] ),
Atom('O', [ 0.00000000, 1.35229616, 1.26234666 ] ),
Atom('H', [ -0.75286467, 1.46479616, 1.74249095 ] )
])
>>> Molecule.from_z_matrix(
... ['H'],
... ['O', 1, 0.9]
... )
Molecule([
Atom('H', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('O', [ 0.00000000, 0.00000000, 0.90000000 ] )
])
@param string: String containing a z-matrix with labels defined at the end using e.g. a234=8.5 @param args: Passed on to Molecule.from_z_matrix @param kwargs: Passed on to Molecule.from_z_matrix @return: Molecule object corresponding to the z-matrix passed in
Return a list of geometrically separated moieties of the molecule. Note: sub-molecules returned will have charge 0 and multiplicity 1 for now
@param n_vdw_radii: How many Van der Waals radii two atoms may be separated by and still be considered bonded @param default_vdw_radius: Van der Waals radius to use for elements that grendel doesn’t know the VDW radius of. @return: list of moieties as Molecule objects.
Create a Molecule object using only the name, SMILES, InChIKey, etc.
The easiest way to call Molecule.from_identifier() is to give it a single argument that is one of the following properties: * smiles * stdinchikey * stdinchi * ncicadd_identifier # (for FICTS, FICuS, uuuuu) * hashisy * cas_number * chemspider_id # input must be chemspider_id=1234567 * opsin_name * cir_name (These are resolved in roughly this order.) Visit the NIH CIR documentation for (some) explaination of what these identifiers are: http://cactus.nci.nih.gov/chemical/structure/documentation
Molecule.from_identifier() can be called with any (single) keyword argument in the grendel.util.web_getter.input_identifiers list. In this form, there must be only
This can also be called using an argument that is the value of a property and a second argument that is a list of fields to search for that property in.
Note: Molecule.get() is a very useful alias for this.
Examples : |
---|
TODO
Returns True if the elements of self correspond directly to the elements of other (i.e. self.atoms[0].element == other.atoms[0].element and self.atoms[1].element == other.atoms[1].element and ...)
Returns True if all of the elements are the same (including isotope and nuclear spin) and the reoriented() versions of self and other have no atoms whose pairwise position difference has a magnitude greater than tol (which defaults to 1e-8 Angstroms)
Examples : |
---|
>>> mol = Molecule('''
... O 1.5 0.0 0.0
... H 0.2 0.0 0.0
... ''')
>>> m1 = Molecule('''
... O 0.0 1.5 0.0
... H 0.0 0.2 0.0
... ''')
>>> m2 = Molecule('''
... O 0.00000 0.00000 0.200000
... H 0.00000 0.00000 1.500001
... ''')
>>> m3 = Molecule('''
... H 0.0 0.0 0.0
... H 0.0 -1.3 0.0
... ''')
>>> mol.has_same_geometry(m1)
True
>>> m1.has_same_geometry(m2)
False
>>> m1.has_same_geometry(m2, 1e-5)
True
>>> m2.has_same_geometry(mol, 1e-5)
True
>>> m1.has_same_geometry(m3)
False
True if op is a valid symmetry operation on self Each coordinate of the transformed atoms must differ from the original by less than
Returns the index of atom in the atoms array of the molecule
Note
This method returns a cached property Atom.index. If you reorder the atoms in a molecule, be sure and flush this cache by setting atom._index to None for all of the atoms in the reordered molecule.
Raises : |
---|
IndexError : if atom is not found in self
Examples : |
---|
>>> from grendel.chemistry import SampleMolecules, init_sample_molecules
>>> init_sample_molecules()
>>> h2o = SampleMolecules['water']
>>> atom1 = h2o[0]
>>> atom2 = h2o[1]
>>> atom3 = h2o[2]
>>> h2o
Molecule([
Atom('O', [ 0.00000000, 0.00000000, 0.11815400 ] ),
Atom('H', [ 0.00000000, 0.75873400, -0.47261400 ] ),
Atom('H', [ 0.00000000, -0.75873400, -0.47261400 ] )
])
>>> h2o.index(atom2)
1
>>> h2o.index(atom1)
0
>>> # It must be exactly the same instance to avoid raising an index error
>>> h2o.index(Atom('O', [ 0.00000000, 0.00000000, 0.11815400 ] ))
Traceback (most recent call last):
...
IndexError: ...
Returns a tuple of the principal moments of inertia vector and the principal axes matrix.
mol.inertial_system()
Computes the principal moments of inertia and the principal axes.
Note
This funtion mol.recenter() if the molecule is not centered, so any CartesianRepresentations that are not both frozen and referenced elsewhere (e.g. in a RepresentationDependentProperty) will be lost forever.
Note
This method is cached. See discussion of the consequences of caching in Molecule.center_of_mass()
Returns : |
---|
A tuple with types (Vector, Matrix) containing the principal moments of inertia and the principal axes, respectively. These should be aligned (i.e. ret_val[0][1] corresponds to the vector ret_val[1][1])
Examples : |
---|
>>> hnco = Molecule.from_z_matrix("""
... N
... C N 1.2145
... O C 1.1634 N 172.22
... H N 1.0030 C 123.34 O 180.0
... """
... )
>>> i = hnco.inertial_system()
>>> i[0]
Vector([ 0.60187342, 45.48378728, 46.0856607 ])
>>> i[1]
Matrix([[ 0. , 0. , 1. ],
[ 0.09870438, -0.9951168 , 0. ],
[ 0.9951168 , 0.09870438, 0. ]])
>>> j = hnco.inertial_system()
>>> i == j
True
>>> hnco.A_e
28.0085955528 Wavenumber
>>> hnco.B_e
0.370629408869 Wavenumber
>>> hnco.C_e
0.365789031483 Wavenumber
>>> hnco.a
Vector([ 0. , 0.09870438, 0.9951168 ])
>>> hnco.b
Vector([ 0. , -0.9951168 , 0.09870438])
>>> hnco.c
Vector([ 1., 0., 0.])
The first internal representations (of type InternalRepresentation), or None if it does not exist yet.
True if the center of mass is at the origin. This actually computes the vector from the origin to the center of mass and then determines if the magnitude of that vector is less than tol.
Parameters : |
---|
True if the molecule is linear to within tol. All diatomics should return True.
If tol is a ValueWithUnits and tol.units is an AngularUnit, then this method returns True only if all angles in the molecule are within tol of 180 Degrees. If tol.units is a unit-compatible with a moment of inertia (i.e. MassUnit * DistanceUnit**2 ), then this method returns True if the smallest principal moment of inertia is less than tol and the difference between the two largest principal moments of inertia is less than tol. If no units are given (i.e. tol is a float or other float-compatible unit), tol is assumed to have units of AngularUnit.default and the method proceeds as if tol.units was an AngularUnit subclass.
Parameters : |
---|
Examples : |
---|
>>> from grendel.chemistry import SampleMolecules, init_sample_molecules
>>> init_sample_molecules()
>>> SampleMolecules['water'].is_linear()
False
>>> SampleMolecules['CO2'].is_linear()
True
>>> SampleMolecules['Benzene'].is_linear()
False
The principal moments of inertia, as a Vector
Note
This funtion mol.recenter() if the molecule is not centered, so any CartesianRepresentations that are not both frozen and referenced elsewhere (e.g. in a RepresentationDependentProperty) will be lost forever.
Note
This method is cached. See discussion of the consequences of caching in Molecule.center_of_mass()
Examples: >>> hnco = Molecule.from_z_matrix(""" ... N ... C N 1.2145 ... O C 1.1634 N 172.22 ... H N 1.0030 C 123.34 O 180.0 ... """ ... ) >>> hnco.principal_moments_of_inertia() Vector([ 0.60187342, 45.48378728, 46.0856607 ]) >>> hnco.pmi() Vector([ 0.60187342, 45.48378728, 46.0856607 ])
See Also: principal_axes, inertial_system, A_e, B_e, C_e
Aliased as principal_moments_of_inertia()
The molecule’s position as a natoms x 3 Matrix. The ordering of rows is (as expected) the same as the ordering of the Molecule.atoms list attribute. Aliased to xyz_mat and position (the latter to be “consistant-ish” with the naming in Atom.
The principal axes as column vectors in a Matrix. The Vector object mol.principal_axes()[:,i] corresponds to the i`th moment of inertia, `mol.principal_moments_of_inertia()[i].
mol.principal_axes()
Note
This funtion mol.recenter() if the molecule is not centered, so any CartesianRepresentations that are not both frozen and referenced elsewhere (e.g. in a RepresentationDependentProperty) will be lost forever.
Note
This method is cached. See discussion of the consequences of caching in Molecule.center_of_mass()
Examples : |
---|
>>> hnco = Molecule.from_z_matrix("""
... N
... C N 1.2145
... O C 1.1634 N 172.22
... H N 1.0030 C 123.34 O 180.0
... """
... )
>>> hnco.principal_axes()
Matrix([[ 0. , 0. , 1. ],
[ 0.09870438, -0.9951168 , 0. ],
[ 0.9951168 , 0.09870438, 0. ]])
See Also: |
---|
principal_moments_of_inertia, inertial_system, A_e, B_e, C_e
Alias for pmi()
Recenters the molecule about the center of mass This modifies the molecule in place.
Examples : |
---|
>>> m = Molecule([Atom("O", [1.1, 1.3, 1.7])])
>>> m
Molecule([
Atom('O', [ 1.10000000, 1.30000000, 1.70000000 ] )
])
>>> m.recenter()
>>> m
Molecule([
Atom('O', [ 0.00000000, 0.00000000, 0.00000000 ] )
])
>>> m = Molecule(['H','H'], Matrix([[0,0,0],[1,0.0,0]]))
>>> m
Molecule([
Atom('H', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('H', [ 1.00000000, 0.00000000, 0.00000000 ] )
])
>>> m.recenter()
>>> m
Molecule([
Atom('H', [ -0.50000000, 0.00000000, 0.00000000 ] ),
Atom('H', [ 0.50000000, 0.00000000, 0.00000000 ] )
])
Same as recenter, but makes returns a copy. self is not modified.
Examples : |
---|
>>> foo = Molecule([Atom("O", [1.3, 1.7, 2.0])])
>>> bar = foo.recentered()
>>> foo.recenter()
>>> foo
Molecule([
Atom('O', [ 0.00000000, 0.00000000, 0.00000000 ] )
])
>>> foo == bar
True
>>> foo is bar
False
Reorient the molecule to align the x, y, and z axes with the principal axes of rotation.
Parameters : |
---|
Examples : |
---|
>>> from grendel.chemistry import SampleMolecules, init_sample_molecules
>>> init_sample_molecules()
>>> from grendel.gmath import chopped
>>> h2o = SampleMolecules['quantum water']
>>> h2o.principal_axes()
Matrix([[-0. , 0. , 1. ],
[-0.53654222, -0.84387348, 0. ],
[-0.84387348, 0.53654222, 0. ]])
>>> h2o.reorient()
>>> # Use chopped to get rid of very small numerical artifacts...
>>> # using abs to get rid of phase factor
>>> abs(chopped(h2o.principal_axes()))
Matrix([[ 0., 0., 1.],
[ 1., 0., 0.],
[ 0., 1., 0.]])
>>> h2o.reorient("I")
>>> from grendel.gmath import chopped
>>> abs(chopped(h2o.principal_axes()))
Matrix([[ 0., 1., 0.],
[ 0., 0., 1.],
[ 1., 0., 0.]])
>>> h2o.reorient("III")
>>> abs(chopped(h2o.principal_axes()))
Matrix([[ 1., 0., 0.],
[ 0., 1., 0.],
[ 0., 0., 1.]])
Same as reorient, but makes returns a copy. self is not modified.
Examples : |
---|
>>> from grendel.chemistry import SampleMolecules, init_sample_molecules
>>> init_sample_molecules()
>>> from grendel.gmath import chopped
>>> h2o = Molecule([
... Atom('O', [ 0.00000000, 0.00000000, 0.00000000 ] ),
... Atom('H', [ 0.00000000, 0.00000000, 1.00000000 ] ),
... Atom('H', [ 0.00000000, -1.00000000, -0.00000000 ] )
... ])
>>> new = h2o.reoriented()
>>> # Use chopped to get rid of very small numerical artifacts...
>>> chopped(new.principal_axes())
Matrix([[ 0., 0., 1.],
[-1., 0., 0.],
[ 0., 1., 0.]])
>>> new is h2o
False
>>> # original molecule is unchanged...
>>> h2o
Molecule([
Atom('O', [ 0.00000000, 0.00000000, 0.00000000 ] ),
Atom('H', [ 0.00000000, 0.00000000, 1.00000000 ] ),
Atom('H', [ 0.00000000, -1.00000000, -0.00000000 ] )
])
Rotates the molecule about axis (a Vector) by angle
Writes the Molecule to the standard xyz format.
See Molecule.xyz_string() for more details.
See Also: |
---|
xyz_string
The molecule’s position as a natoms x 3 Matrix. The ordering of rows is (as expected) the same as the ordering of the Molecule.atoms list attribute. Aliased to xyz_mat and position (the latter to be “consistant-ish” with the naming in Atom.
The molecule’s position as a natoms x 3 Matrix. The ordering of rows is (as expected) the same as the ordering of the Molecule.atoms list attribute. Aliased to xyz_mat and position (the latter to be “consistant-ish” with the naming in Atom.
The molecule, represented as a string in standard xyz format.
The first line will always be the number of atoms. The second line (which is a comment in the xyz specification) is filled by the description first line of the description attribute.
Parameters : |
---|
Examples : |
---|
>>> from __future__ import print_function
>>> from grendel.chemistry import SampleMolecules, init_sample_molecules
>>> init_sample_molecules()
>>> print(SampleMolecules['water'].xyz_string())
3
CCSD(T)/aug-cc-pVTZ Water
O 0.00000000 0.00000000 0.11815400
H 0.00000000 0.75873400 -0.47261400
H 0.00000000 -0.75873400 -0.47261400
>>> print(Molecule("O 1.0 0.5 1.5").xyz_string("Atom: %2s, x: %3.1f, y: %4.2f, z: %5.3f"))
1
Atom: O, x: 1.0, y: 0.50, z: 1.500
>>> print(Molecule("O 1.0 0.5 1.5").xyz_string("Atom: %2s, x: %3.1f, y: %4.2f, z: %5.3f", False))
Atom: O, x: 1.0, y: 0.50, z: 1.500
All numbers inherit from this class.
If you just want to check if an argument x is a number, without caring what kind, use isinstance(x, Number).
alias of Wavenumber
Append some attributes to be set after the initialization is performed. Note that these override anything done in the class’s __init__, so don’t do anything stupid.
Contains the filename of a template that generates the input file for the computation of a molecular property, optionally with a set of specific details for which the template is valid. This class is mostly to mirror the OutputParser and PropertyParser from the output side of things.
A property whose value is a scalar
By default, just get the last group matched.
The simplest form of a generator. Takes a Mako-style template file, passes in the Computation object in as the argument “computation”, and runs the Mako templete engine.
Mostly a wrapper for the NumPy ndarray class. This gives us a place to put tensor-related functionality that we need but is not available in NumPy.
Copy all properties of the tensor except for the data.
Same as numpy.ndarray.flatten, but modified to return a Vector object
Examples : |
---|
>>> t = Tensor([[[1,2],[3,4]],[[5,6],[7,8]]])
>>> t
Tensor([[[ 1., 2.],
[ 3., 4.]],
[[ 5., 6.],
[ 7., 8.]]])
>>> t.flatten()
Vector([ 1., 2., 3., ..., 6., 7., 8.])
List of pointers to IndexRange objects over which the tensor is defined.
Returns True if all elements of self have absolute values less than cutoff, which defaults to Tensor.zero_cutoff
Note
Tensor.zero_cutoff is treated as a pseudo-class attribute for Tensor instances, meaning individual instances can also set a zero_cutoff attribute which will take precidence over the class-level default.
Given any number of Tensor objects that are the same up to a phase factor, return a list of Tensor objects that have been. Copies are only made if necessary. The chosen phase is the one that makes the first non-zero element (in the numpy.nditer(tensor) iterator, using the cutoff keyword argument or Tensor.zero_cutoff if one is not given) positive.
Allows conformance with the Unitized protocol.
A property whose value is an n-dimensional tensor
Abstract base class for things with units. It requires its subclasses to implement the properties ‘value’ and ‘units’. Unitized subclasses are also expected have __mul__, __div__, __truediv__, __pow__, __add__, __sub__, __neg__, __pos__, and __abs__ handle units correctly, when implemented in the given subclass.
Raised when a MolecularProperty is requested but not available for whatever reason.
A class for encapsulating a physical constant and it’s units.
Attributes : |
---|
A property whose value is a vector.
A decorator indicating abstract methods.
Requires that the metaclass is ABCMeta or derived from it. A class that has a metaclass derived from ABCMeta cannot be instantiated unless all of its abstract methods are overridden. The abstract methods can be called using any of the normal ‘super’ call mechanisms.
Usage:
- class C:
__metaclass__ = ABCMeta @abstractmethod def my_abstract_method(self, ...):
...
Converts a CamalCase string to a lower_case_string_with_underscores If the divider argument is given, it is used instead of underscores to join words.
Examples : |
---|
Convenience method for getting the typename as a string from the <type ‘Something’> string sent back by str(type(obj))
Alias for has_units()
Aliased as is_unit()
partial(func, *args, **keywords) - new function with partial application of the given arguments and keywords.
tuple of arguments to future partial calls
function object to use in future partial calls
dictionary of keyword arguments to future partial calls
Type checking for functions and methods.
Issue a warning, or maybe ignore it or raise an exception.
Decorator allowing the assignment of attributes to a function.
Metaclass for defining Abstract Base Classes (ABCs).
Use this metaclass to create an ABC. An ABC can be subclassed directly, and then acts as a mix-in class. You can also register unrelated concrete classes (even built-in classes) and unrelated ABCs as ‘virtual subclasses’ – these and their descendants will be considered subclasses of the registering ABC by the built-in issubclass() function, but the registering ABC won’t show up in their MRO (Method Resolution Order) nor will method implementations defined by the registering ABC be callable (not even via super()).
Register a virtual subclass of an ABC.
Decorator for properties with cached return values. The decorator creates a property that stores the return value of the method call in a variable named _[func_name] (where [func_name] is the name of the function).
Examples : |
---|
>>> class Factorializer(object):
...
... n = None
...
... def __init__(self, n):
... self.n = n
...
... @CachedProperty
... def thirty_plus_n_fact(self):
... ret_val = 1
... for i in xrange(2, self.n + 31):
... ret_val *= i
... return ret_val
...
>>> f = Factorializer(3000)
>>> # Takes some time...
>>> var = f.thirty_plus_n_fact
>>> # Should take no time...
>>> for i in xrange(100):
... var = f.thirty_plus_n_fact
...
>>> # Be careful... Remember to invalidate the cache when the appropriate variables are updated...
>>> f.n = 2500
>>> # Takes no time but gives the wrong answer:
>>> var = f.thirty_plus_n_fact
>>> # Invalidate the cache:
>>> f._thirty_plus_n_fact = None
>>> # This should take some time again, but now it will get the right answer
>>> var = f.thirty_plus_n_fact
Encapsulates specifics about how the calculation was/is to be carried out, such as level of theory, basis set, program, etc. Can be subclassed for specific programs which may require special detail setting methods.
Effectively clones details. Used internally for making a details into a ComputationDetails subclass
Mostly for use by templates, this method returns a string of keyword-value pairs in using the given format for each argument in the argument list. format should use the str.format() protocol from the python standard library with the named slots {key} where the keyword name should go and {value} where the value of the detail should go (or, if the value of the detail is a Keyword object, the contents of the value attribute for that Keyword, or, if the value attribute for the keyword is not defined, the _name attribute for the Keyword object in question.
Aliased as keywordify
Mostly for use by templates, this method returns a string of keyword-value pairs in using the given format for each argument in the argument list. format should use the str.format() protocol from the python standard library with the named slots {key} where the keyword name should go and {value} where the value of the detail should go (or, if the value of the detail is a Keyword object, the contents of the value attribute for that Keyword, or, if the value attribute for the keyword is not defined, the _name attribute for the Keyword object in question.
Aliased as keywordify
Raised when a computation can’t be generated either because a compatible input template can’t be found or a valid output parser can’t be found
Superclass for classes that are compatible with specific ComputationDetail objects or any ComputationDetail object more specifically specifice than the details variable.
Abstract base class for all properties
Attributes : |
---|
molecule : Molecule units : CompositeUnit or class with Unit metaclass
Retrieve the value of the property from a tuple of groups matched in a RegexSequence. See RegexSequence.groups()
Retrieve the value of the property from a RegexSequence object that has already been used on a file. By default, this just calls self.from_groups() with seq.groups(flatten) where flatten comes from self.from_groups.flatten.
The new paradigm for obtaining values. Call the callable instance attribute getter with the arguments and keyword arguments passed in.
The value of the molecular property.
Abstract base class for classes that parse the output file for a computation.
Encapsulates a molecular property and the code to parse it from an output file.
..note :: This method ignores property.units
A property whose value is a scalar
By default, just get the last group matched.
Convenience method for getting the typename as a string from the <type ‘Something’> string sent back by str(type(obj))
Shallow copy operation on arbitrary Python objects.
See the module’s __doc__ string for more info.
Deep copy operation on arbitrary Python objects.
See the module’s __doc__ string for more info.
Aliased as is_unit()
Metaclass for defining Abstract Base Classes (ABCs).
Use this metaclass to create an ABC. An ABC can be subclassed directly, and then acts as a mix-in class. You can also register unrelated concrete classes (even built-in classes) and unrelated ABCs as ‘virtual subclasses’ – these and their descendants will be considered subclasses of the registering ABC by the built-in issubclass() function, but the registering ABC won’t show up in their MRO (Method Resolution Order) nor will method implementations defined by the registering ABC be callable (not even via super()).
Register a virtual subclass of an ABC.
Abstract base class for queues of computations to be run.
A decorator indicating abstract properties.
Requires that the metaclass is ABCMeta or derived from it. A class that has a metaclass derived from ABCMeta cannot be instantiated unless all of its abstract properties are overridden. The abstract properties can be called using any of the normal ‘super’ call mechanisms.
Usage:
- class C:
__metaclass__ = ABCMeta @abstractproperty def my_abstract_property(self):
...
This defines a read-only property; you can also define a read-write abstract property using the ‘long’ form of property declaration:
- class C:
- __metaclass__ = ABCMeta def getx(self): ... def setx(self, value): ... x = abstractproperty(getx, setx)
Add computation(s) to the queue.
True if all the computations on the queue are finished
True if the queue has been started (i. e. if any of the computations have been started)
Run the queue. (Abstract method) This runs the whole queue and blocks until the run is complete. See also start
Start the queue in the background and return to execution. Beware that if Python exits, the queue’s processes will be orphaned. This mode of running may not be supported by all queue types.
A decorator indicating abstract methods.
Requires that the metaclass is ABCMeta or derived from it. A class that has a metaclass derived from ABCMeta cannot be instantiated unless all of its abstract methods are overridden. The abstract methods can be called using any of the normal ‘super’ call mechanisms.
Usage:
- class C:
__metaclass__ = ABCMeta @abstractmethod def my_abstract_method(self, ...):
...
A decorator indicating abstract properties.
Requires that the metaclass is ABCMeta or derived from it. A class that has a metaclass derived from ABCMeta cannot be instantiated unless all of its abstract properties are overridden. The abstract properties can be called using any of the normal ‘super’ call mechanisms.
Usage:
- class C:
__metaclass__ = ABCMeta @abstractproperty def my_abstract_property(self):
...
This defines a read-only property; you can also define a read-write abstract property using the ‘long’ form of property declaration:
- class C:
- __metaclass__ = ABCMeta def getx(self): ... def setx(self, value): ... x = abstractproperty(getx, setx)
Run the queue in a non-blocking manner. Calling start multiple times has no effect, but also raises no warning
The simplest possible queue. Runs one job at a time on the local machine.
Metaclass for defining Abstract Base Classes (ABCs).
Use this metaclass to create an ABC. An ABC can be subclassed directly, and then acts as a mix-in class. You can also register unrelated concrete classes (even built-in classes) and unrelated ABCs as ‘virtual subclasses’ – these and their descendants will be considered subclasses of the registering ABC by the built-in issubclass() function, but the registering ABC won’t show up in their MRO (Method Resolution Order) nor will method implementations defined by the registering ABC be callable (not even via super()).
Register a virtual subclass of an ABC.
Base class for all classes encapsulating runs of external programs
Checks to see if an identical input file with an identical name has already been run in the computation’s directory to produce an output file of some sort (if that output file has errors, you probably don’t want to rerun the exact same input file, so this doesn’t do that by default. If you need to do that, call Computation.run() with the force_rerun argument set to True).
True if and only if the calculation has finished running. (regardless of success or failure). Setting completed to True triggers the output parser.
The types of the properties in the self.properties list.
Convert strings to standard form for attributes. Strings with spaces, underscore_joined_strings, Uppercase_Underscore_Strings, and lowerCamelCase strings are all converted to UpperCamelCase.
Examples : |
---|
>>> Computation.standardize_attribute("basis_set")
'BasisSet'
>>> Computation.standardize_attribute("basis set")
'BasisSet'
>>> Computation.standardize_attribute("basis!Set")
'BasisSet'
>>> # Only _ and space serve as CamelCase separators:
>>> Computation.standardize_attribute("basis!set")
'Basisset'
>>> Computation.standardize_attribute("Level___of!*theory")
'LevelOftheory'
>>> # "Accidental" caps are not fixed...
>>> Computation.standardize_attribute("Level___of!*tHEory")
'LevelOftHEory'
>>> #All caps gets translated into title case
>>> Computation.standardize_attribute("Level&$#of__THEORY")
'LevelofTheory'
Alias for can_get_property_for_molecule()
Aliased as has_property(), can_get_property()
Alias for can_get_property_for_molecule()
Raised when a computation can’t be generated either because a compatible input template can’t be found or a valid output parser can’t be found
Abstract base class for all properties
Attributes : |
---|
molecule : Molecule units : CompositeUnit or class with Unit metaclass
Retrieve the value of the property from a tuple of groups matched in a RegexSequence. See RegexSequence.groups()
Retrieve the value of the property from a RegexSequence object that has already been used on a file. By default, this just calls self.from_groups() with seq.groups(flatten) where flatten comes from self.from_groups.flatten.
The new paradigm for obtaining values. Call the callable instance attribute getter with the arguments and keyword arguments passed in.
The value of the molecular property.
Abstract base class for all classes that encapsulate a method of retrieving a (set of) properties of a molecule from a computational chemistry package. An instance of a ResultGetter object should know how to turn a request for a given molecular property into a Computation object (which, in turn, houses MolecularProperty objects for one or more Molecule objects). ResultGetter objects generate Computation objects. Any ResultGetter subclass should always check for an available computation on (exactly) the same molecule that already has the result available.
A decorator indicating abstract methods.
Requires that the metaclass is ABCMeta or derived from it. A class that has a metaclass derived from ABCMeta cannot be instantiated unless all of its abstract methods are overridden. The abstract methods can be called using any of the normal ‘super’ call mechanisms.
Usage:
- class C:
__metaclass__ = ABCMeta @abstractmethod def my_abstract_method(self, ...):
...
Shallow copy operation on arbitrary Python objects.
See the module’s __doc__ string for more info.
Alias a function as something else. Set the documentation of the new method to “Alias for <function>()” and add “Aliased as <alias>()” to the documentation of function. Not inteded to be used as a decorator.
Examples : |
---|
>>> def foo(a, b, c):
... '''Print a test message.'''
... print "testing {0}, {1}, {2}".format(a, b, c)
...
>>> foo(1, 2, 3)
testing 1, 2, 3
>>> bar = function_alias('bar', foo)
>>> bar(4, 5, 6)
testing 4, 5, 6
>>> print bar.__doc__
Alias for `foo()`
>>> print foo.__doc__
Print a test message.
Aliased as `bar()`
>>> baz = function_alias('baz', foo)
>>> baz(7, 8, 9)
testing 7, 8, 9
>>> print foo.__doc__
Print a test message.
Aliased as `baz()`, `bar()`
Inside a class
>>> class FooBar(object):
... def testfunc(self, *args):
... '''Print out the args.'''
... print "testing " + ', '.join(str(a) for a in args)
... another_name = function_alias('another_name', testfunc)
... test_func = function_alias('test_func', testfunc)
...
>>> f = FooBar()
>>> f.test_func(1, 2, 3, 4)
testing 1, 2, 3, 4
>>> print FooBar.test_func.__doc__
Alias for `testfunc()`
>>> print FooBar.testfunc.__doc__
Print out the args.
Aliased as `test_func()`, `another_name()`
Abstract base class for classes that run a computation (or an equivalent task, such as submit a job to a PBS queue). Not all Computation objects need a runner; for instance XML-parsed computations are constructed in an already-run state.
Run in a blocking manner. Default implementation calls wait() on the process returned by start(). Overload it if this doesn’t make sense.
Determine if we will be able to run. Raise a ComputationUnavailableError if running will cause a crash
alias of AtomicMassUnit
alias of AtomicMassUnit
alias of Angstrom
General superclass for all angular units
alias of Degree
alias of Degree
alias of AtomicMassUnit
alias of AtomicUnitOfElectricCharge
alias of Bohr
alias of Hartree
alias of AtomicUnitOfElectricCharge
alias of Bohr
alias of AtomicUnitOfElectricCharge
alias of Hartree
alias of AtomicUnitOfMass
alias of AtomicUnitOfTime
alias of AtomicMassUnit
alias of AttoAMU
alias of Angstrom
alias of AtomicMassUnit
alias of AtomicUnitOfElectricCharge
alias of Bohr
alias of AtomicUnitOfElectricCharge
alias of Hartree
alias of AtomicUnitOfMass
alias of AtomicUnitOfTime
alias of AttoAtomicUnitOfCharge
alias of AttoAtomicUnitOfDistance
alias of AttoAtomicUnitOfEnergy
alias of Bohr
alias of Century
alias of Coulomb
alias of Day
alias of Decade
alias of Degree
alias of ElectronVolt
alias of Gram
alias of Hartree
alias of Hertz
alias of Hour
alias of Joule
alias of Meter
alias of Millennium
alias of Minute
alias of Radian
alias of Second
alias of Wavenumber
alias of Week
alias of Year
alias of AttoAngstrom
alias of AttoAngstrom
alias of AttoBohr
alias of AttoBohr
alias of AttoCentury
alias of AttoCentury
alias of AttoCoulomb
alias of AttoCoulomb
alias of AttoDay
alias of AttoDay
alias of AttoDecade
alias of AttoDecade
alias of AttoDegree
alias of AttoDegree
alias of AttoGram
alias of AttoGram
alias of AttoHartree
alias of AttoHartree
alias of AttoHertz
alias of AttoHertz
alias of AttoHour
alias of AttoHour
alias of AttoJoule
alias of AttoJoule
alias of AttoMeter
alias of AttoMeter
alias of AttoMillennium
alias of AttoMillennium
alias of AttoMinute
alias of AttoMinute
alias of AttoRadian
alias of AttoRadian
alias of AttoSecond
alias of AttoSecond
alias of AttoWavenumber
alias of AttoWavenumber
alias of AttoWeek
alias of AttoWeek
alias of AttoYear
alias of AttoYear
alias of Bohr
alias of AtomicMassUnit
alias of CentiAMU
alias of Angstrom
alias of AtomicMassUnit
alias of AtomicUnitOfElectricCharge
alias of Bohr
alias of AtomicUnitOfElectricCharge
alias of Hartree
alias of AtomicUnitOfMass
alias of AtomicUnitOfTime
alias of CentiAtomicUnitOfCharge
alias of CentiAtomicUnitOfDistance
alias of CentiAtomicUnitOfEnergy
alias of Bohr
alias of Century
alias of Coulomb
alias of Day
alias of Decade
alias of Degree
alias of ElectronVolt
alias of Gram
alias of Hartree
alias of Hertz
alias of Hour
alias of Joule
alias of Meter
alias of Millennium
alias of Minute
alias of Radian
alias of Second
alias of Wavenumber
alias of Week
alias of Year
alias of CentiAngstrom
alias of CentiAngstrom
alias of CentiBohr
alias of CentiBohr
alias of CentiCentury
alias of CentiCentury
alias of CentiCoulomb
alias of CentiCoulomb
alias of CentiDay
alias of CentiDay
alias of CentiDecade
alias of CentiDecade
alias of CentiDegree
alias of CentiDegree
alias of CentiGram
alias of CentiGram
alias of CentiHartree
alias of CentiHartree
alias of CentiHertz
alias of CentiHertz
alias of CentiHour
alias of CentiHour
alias of CentiJoule
alias of CentiJoule
alias of CentiMeter
alias of CentiMeter
alias of CentiMillennium
alias of CentiMillennium
alias of CentiMinute
alias of CentiMinute
alias of CentiRadian
alias of CentiRadian
alias of CentiSecond
alias of CentiSecond
alias of CentiWavenumber
alias of CentiWavenumber
alias of CentiWeek
alias of CentiWeek
alias of CentiYear
alias of CentiYear
alias of Century
A class for composite units, e.g. Joules/Angstrom^2
Analog of Unit.genre. Always returns CompositeUnit
The name of the composite unit, as a product of base units
Reduce the composite unit into the fewest base units possible.
Examples : |
---|
>>> from grendel.util.units import *
>>> (Angstroms**2/Bohr).reduced()
(1.88972612457 Angstrom)
>>> (Degree / (Bohr**2)).reduced()
Degree / Bohr**2
>>> (Degree / (Bohr*Meter)).reduced()
(5.2917721092e-11 Degree / Bohr**2)
Encapsulates specifics about how the calculation was/is to be carried out, such as level of theory, basis set, program, etc. Can be subclassed for specific programs which may require special detail setting methods.
Effectively clones details. Used internally for making a details into a ComputationDetails subclass
Mostly for use by templates, this method returns a string of keyword-value pairs in using the given format for each argument in the argument list. format should use the str.format() protocol from the python standard library with the named slots {key} where the keyword name should go and {value} where the value of the detail should go (or, if the value of the detail is a Keyword object, the contents of the value attribute for that Keyword, or, if the value attribute for the keyword is not defined, the _name attribute for the Keyword object in question.
Aliased as keywordify
Mostly for use by templates, this method returns a string of keyword-value pairs in using the given format for each argument in the argument list. format should use the str.format() protocol from the python standard library with the named slots {key} where the keyword name should go and {value} where the value of the detail should go (or, if the value of the detail is a Keyword object, the contents of the value attribute for that Keyword, or, if the value attribute for the keyword is not defined, the _name attribute for the Keyword object in question.
Aliased as keywordify
alias of Coulomb
alias of Day
alias of AtomicMassUnit
alias of DecaAMU
alias of Angstrom
alias of AtomicMassUnit
alias of AtomicUnitOfElectricCharge
alias of Bohr
alias of AtomicUnitOfElectricCharge
alias of Hartree
alias of AtomicUnitOfMass
alias of AtomicUnitOfTime
alias of DecaAtomicUnitOfCharge
alias of DecaAtomicUnitOfDistance
alias of DecaAtomicUnitOfEnergy
alias of Bohr
alias of Century
alias of Coulomb
alias of Day
alias of Decade
alias of Degree
alias of ElectronVolt
alias of Gram
alias of Hartree
alias of Hertz
alias of Hour
alias of Joule
alias of Meter
alias of Millennium
alias of Minute
alias of Radian
alias of Second
alias of Wavenumber
alias of Week
alias of Year
alias of DecaAngstrom
alias of DecaAngstrom
alias of DecaBohr
alias of DecaBohr
alias of DecaCentury
alias of DecaCentury
alias of DecaCoulomb
alias of DecaCoulomb
alias of DecaDay
alias of DecaDay
alias of DecaDecade
alias of DecaDecade
alias of DecaDegree
alias of DecaDegree
alias of Decade
alias of DecaGram
alias of DecaGram
alias of DecaHartree
alias of DecaHartree
alias of DecaHertz
alias of DecaHertz
alias of DecaHour
alias of DecaHour
alias of DecaJoule
alias of DecaJoule
alias of DecaMeter
alias of DecaMeter
alias of DecaMillennium
alias of DecaMillennium
alias of DecaMinute
alias of DecaMinute
alias of DecaRadian
alias of DecaRadian
alias of DecaSecond
alias of DecaSecond
alias of DecaWavenumber
alias of DecaWavenumber
alias of DecaWeek
alias of DecaWeek
alias of DecaYear
alias of DecaYear
alias of AtomicMassUnit
alias of DeciAMU
alias of Angstrom
alias of AtomicMassUnit
alias of AtomicUnitOfElectricCharge
alias of Bohr
alias of AtomicUnitOfElectricCharge
alias of Hartree
alias of AtomicUnitOfMass
alias of AtomicUnitOfTime
alias of DeciAtomicUnitOfCharge
alias of DeciAtomicUnitOfDistance
alias of DeciAtomicUnitOfEnergy
alias of Bohr
alias of Century
alias of Coulomb
alias of Day
alias of Decade
alias of Degree
alias of ElectronVolt
alias of Gram
alias of Hartree
alias of Hertz
alias of Hour
alias of Joule
alias of Meter
alias of Millennium
alias of Minute
alias of Radian
alias of Second
alias of Wavenumber
alias of Week
alias of Year
alias of DeciAngstrom
alias of DeciAngstrom
alias of DeciBohr
alias of DeciBohr
alias of DeciCentury
alias of DeciCentury
alias of DeciCoulomb
alias of DeciCoulomb
alias of DeciDay
alias of DeciDay
alias of DeciDecade
alias of DeciDecade
alias of DeciDegree
alias of DeciDegree
alias of DeciGram
alias of DeciGram
alias of DeciHartree
alias of DeciHartree
alias of DeciHertz
alias of DeciHertz
alias of DeciHour
alias of DeciHour
alias of DeciJoule
alias of DeciJoule
alias of DeciMeter
alias of DeciMeter
alias of DeciMillennium
alias of DeciMillennium
alias of DeciMinute
alias of DeciMinute
alias of DeciRadian
alias of DeciRadian
alias of DeciSecond
alias of DeciSecond
alias of DeciWavenumber
alias of DeciWavenumber
alias of DeciWeek
alias of DeciWeek
alias of DeciYear
alias of DeciYear
alias of Degree
General superclass for all distance units
alias of Angstrom
alias of Angstrom
General superclass for all units of electric charge
alias of Coulomb
alias of Coulomb
alias of ElectronVolt
The energy of a molecule.
alias of Wavenumber
General superclass for all energy units
alias of Wavenumber
alias of Joule
alias of AtomicMassUnit
alias of ExaAMU
alias of Angstrom
alias of AtomicMassUnit
alias of AtomicUnitOfElectricCharge
alias of Bohr
alias of AtomicUnitOfElectricCharge
alias of Hartree
alias of AtomicUnitOfMass
alias of AtomicUnitOfTime
alias of ExaAtomicUnitOfCharge
alias of ExaAtomicUnitOfDistance
alias of ExaAtomicUnitOfEnergy
alias of Bohr
alias of Century
alias of Coulomb
alias of Day
alias of Decade
alias of Degree
alias of ElectronVolt
alias of Gram
alias of Hartree
alias of Hertz
alias of Hour
alias of Joule
alias of Meter
alias of Millennium
alias of Minute
alias of Radian
alias of Second
alias of Wavenumber
alias of Week
alias of Year
alias of ExaAngstrom
alias of ExaAngstrom
alias of ExaBohr
alias of ExaBohr
alias of ExaCentury
alias of ExaCentury
alias of ExaCoulomb
alias of ExaCoulomb
alias of ExaDay
alias of ExaDay
alias of ExaDecade
alias of ExaDecade
alias of ExaDegree
alias of ExaDegree
alias of ExaGram
alias of ExaGram
alias of ExaHartree
alias of ExaHartree
alias of ExaHertz
alias of ExaHertz
alias of ExaHour
alias of ExaHour
alias of ExaJoule
alias of ExaJoule
alias of ExaMeter
alias of ExaMeter
alias of ExaMillennium
alias of ExaMillennium
alias of ExaMinute
alias of ExaMinute
alias of ExaRadian
alias of ExaRadian
alias of ExaSecond
alias of ExaSecond
alias of ExaWavenumber
alias of ExaWavenumber
alias of ExaWeek
alias of ExaWeek
alias of ExaYear
alias of ExaYear
alias of AtomicMassUnit
alias of FemtoAMU
alias of Angstrom
alias of AtomicMassUnit
alias of AtomicUnitOfElectricCharge
alias of Bohr
alias of AtomicUnitOfElectricCharge
alias of Hartree
alias of AtomicUnitOfMass
alias of AtomicUnitOfTime
alias of FemtoAtomicUnitOfCharge
alias of FemtoAtomicUnitOfDistance
alias of FemtoAtomicUnitOfEnergy
alias of Bohr
alias of Century
alias of Coulomb
alias of Day
alias of Decade
alias of Degree
alias of ElectronVolt
alias of Gram
alias of Hartree
alias of Hertz
alias of Hour
alias of Joule
alias of Meter
alias of Millennium
alias of Minute
alias of Radian
alias of Second
alias of Wavenumber
alias of Week
alias of Year
alias of FemtoAngstrom
alias of FemtoAngstrom
alias of FemtoBohr
alias of FemtoBohr
alias of FemtoCentury
alias of FemtoCentury
alias of FemtoCoulomb
alias of FemtoCoulomb
alias of FemtoDay
alias of FemtoDay
alias of FemtoDecade
alias of FemtoDecade
alias of FemtoDegree
alias of FemtoDegree
alias of FemtoGram
alias of FemtoGram
alias of FemtoHartree
alias of FemtoHartree
alias of FemtoHertz
alias of FemtoHertz
alias of FemtoHour
alias of FemtoHour
alias of FemtoJoule
alias of FemtoJoule
alias of FemtoMeter
alias of FemtoMeter
alias of FemtoMillennium
alias of FemtoMillennium
alias of FemtoMinute
alias of FemtoMinute
alias of FemtoRadian
alias of FemtoRadian
alias of FemtoSecond
alias of FemtoSecond
alias of FemtoWavenumber
alias of FemtoWavenumber
alias of FemtoWeek
alias of FemtoWeek
alias of FemtoYear
alias of FemtoYear
alias of AtomicMassUnit
alias of GigaAMU
alias of Angstrom
alias of AtomicMassUnit
alias of AtomicUnitOfElectricCharge
alias of Bohr
alias of AtomicUnitOfElectricCharge
alias of Hartree
alias of AtomicUnitOfMass
alias of AtomicUnitOfTime
alias of GigaAtomicUnitOfCharge
alias of GigaAtomicUnitOfDistance
alias of GigaAtomicUnitOfEnergy
alias of Bohr
alias of Century
alias of Coulomb
alias of Day
alias of Decade
alias of Degree
alias of ElectronVolt
alias of Gram
alias of Hartree
alias of Hertz
alias of Hour
alias of Joule
alias of Meter
alias of Millennium
alias of Minute
alias of Radian
alias of Second
alias of Wavenumber
alias of Week
alias of Year
alias of GigaAngstrom
alias of GigaAngstrom
alias of GigaBohr
alias of GigaBohr
alias of GigaCentury
alias of GigaCentury
alias of GigaCoulomb
alias of GigaCoulomb
alias of GigaDay
alias of GigaDay
alias of GigaDecade
alias of GigaDecade
alias of GigaDegree
alias of GigaDegree
alias of GigaGram
alias of GigaGram
alias of GigaHartree
alias of GigaHartree
alias of GigaHertz
alias of GigaHertz
alias of GigaHour
alias of GigaHour
alias of GigaJoule
alias of GigaJoule
alias of GigaMeter
alias of GigaMeter
alias of GigaMillennium
alias of GigaMillennium
alias of GigaMinute
alias of GigaMinute
alias of GigaRadian
alias of GigaRadian
alias of GigaSecond
alias of GigaSecond
alias of GigaWavenumber
alias of GigaWavenumber
alias of GigaWeek
alias of GigaWeek
alias of GigaYear
alias of GigaYear
alias of Gram
alias of Hartree
alias of AtomicMassUnit
alias of HectoAMU
alias of Angstrom
alias of AtomicMassUnit
alias of AtomicUnitOfElectricCharge
alias of Bohr
alias of AtomicUnitOfElectricCharge
alias of Hartree
alias of AtomicUnitOfMass
alias of AtomicUnitOfTime
alias of HectoAtomicUnitOfCharge
alias of HectoAtomicUnitOfDistance
alias of HectoAtomicUnitOfEnergy
alias of Bohr
alias of Century
alias of Coulomb
alias of Day
alias of Decade
alias of Degree
alias of ElectronVolt
alias of Gram
alias of Hartree
alias of Hertz
alias of Hour
alias of Joule
alias of Meter
alias of Millennium
alias of Minute
alias of Radian
alias of Second
alias of Wavenumber
alias of Week
alias of Year
alias of HectoAngstrom
alias of HectoAngstrom
alias of HectoBohr
alias of HectoBohr
alias of HectoCentury
alias of HectoCentury
alias of HectoCoulomb
alias of HectoCoulomb
alias of HectoDay
alias of HectoDay
alias of HectoDecade
alias of HectoDecade
alias of HectoDegree
alias of HectoDegree
alias of HectoGram
alias of HectoGram
alias of HectoHartree
alias of HectoHartree
alias of HectoHertz
alias of HectoHertz
alias of HectoHour
alias of HectoHour
alias of HectoJoule
alias of HectoJoule
alias of HectoMeter
alias of HectoMeter
alias of HectoMillennium
alias of HectoMillennium
alias of HectoMinute
alias of HectoMinute
alias of HectoRadian
alias of HectoRadian
alias of HectoSecond
alias of HectoSecond
alias of HectoWavenumber
alias of HectoWavenumber
alias of HectoWeek
alias of HectoWeek
alias of HectoYear
alias of HectoYear
alias of Hertz
alias of Hour
Exception for attempted incompatible unit conversions
alias of Joule
alias of KiloCaloriePerMol
alias of KiloCaloriePerMol
alias of KiloJoulePerMol
alias of KiloCaloriePerMol
alias of KiloCaloriePerMol
alias of AtomicMassUnit
alias of KiloAMU
alias of Angstrom
alias of AtomicMassUnit
alias of AtomicUnitOfElectricCharge
alias of Bohr
alias of AtomicUnitOfElectricCharge
alias of Hartree
alias of AtomicUnitOfMass
alias of AtomicUnitOfTime
alias of KiloAtomicUnitOfCharge
alias of KiloAtomicUnitOfDistance
alias of KiloAtomicUnitOfEnergy
alias of Bohr
alias of KiloCaloriePerMol
alias of KiloCaloriePerMol
alias of KiloCaloriePerMol
alias of Century
alias of Coulomb
alias of Day
alias of Decade
alias of Degree
alias of ElectronVolt
alias of Gram
alias of Hartree
alias of Hertz
alias of Hour
alias of Joule
alias of KiloJoulePerMol
alias of Meter
alias of Millennium
alias of Minute
alias of Radian
alias of Second
alias of Wavenumber
alias of Week
alias of Year
alias of KiloAngstrom
alias of KiloAngstrom
alias of KiloBohr
alias of KiloBohr
alias of KiloCentury
alias of KiloCentury
alias of KiloCoulomb
alias of KiloCoulomb
alias of KiloDay
alias of KiloDay
alias of KiloDecade
alias of KiloDecade
alias of KiloDegree
alias of KiloDegree
alias of KiloGram
alias of KiloGram
alias of KiloHartree
alias of KiloHartree
alias of KiloHertz
alias of KiloHertz
alias of KiloHour
alias of KiloHour
alias of KiloJoule
alias of KiloJoule
alias of KiloJoulePerMol
alias of KiloJoulePerMol
alias of KiloMeter
alias of KiloMeter
alias of KiloMillennium
alias of KiloMillennium
alias of KiloMinute
alias of KiloMinute
alias of KiloRadian
alias of KiloRadian
alias of KiloSecond
alias of KiloSecond
alias of KiloWavenumber
alias of KiloWavenumber
alias of KiloWeek
alias of KiloWeek
alias of KiloYear
alias of KiloYear
General superclass for all units of mass
alias of AtomicMassUnit
alias of Gram
alias of AtomicMassUnit
alias of MegaAMU
alias of Angstrom
alias of AtomicMassUnit
alias of AtomicUnitOfElectricCharge
alias of Bohr
alias of AtomicUnitOfElectricCharge
alias of Hartree
alias of AtomicUnitOfMass
alias of AtomicUnitOfTime
alias of MegaAtomicUnitOfCharge
alias of MegaAtomicUnitOfDistance
alias of MegaAtomicUnitOfEnergy
alias of Bohr
alias of Century
alias of Coulomb
alias of Day
alias of Decade
alias of Degree
alias of ElectronVolt
alias of Gram
alias of Hartree
alias of Hertz
alias of Hour
alias of Joule
alias of Meter
alias of Millennium
alias of Minute
alias of Radian
alias of Second
alias of Wavenumber
alias of Week
alias of Year
alias of MegaAngstrom
alias of MegaAngstrom
alias of MegaBohr
alias of MegaBohr
alias of MegaCentury
alias of MegaCentury
alias of MegaCoulomb
alias of MegaCoulomb
alias of MegaDay
alias of MegaDay
alias of MegaDecade
alias of MegaDecade
alias of MegaDegree
alias of MegaDegree
alias of MegaGram
alias of MegaGram
alias of MegaHartree
alias of MegaHartree
alias of MegaHertz
alias of MegaHertz
alias of MegaHour
alias of MegaHour
alias of MegaJoule
alias of MegaJoule
alias of MegaMeter
alias of MegaMeter
alias of MegaMillennium
alias of MegaMillennium
alias of MegaMinute
alias of MegaMinute
alias of MegaRadian
alias of MegaRadian
alias of MegaSecond
alias of MegaSecond
alias of MegaWavenumber
alias of MegaWavenumber
alias of MegaWeek
alias of MegaWeek
alias of MegaYear
alias of MegaYear
alias of Meter
alias of AtomicMassUnit
alias of MicroAMU
alias of Angstrom
alias of AtomicMassUnit
alias of AtomicUnitOfElectricCharge
alias of Bohr
alias of AtomicUnitOfElectricCharge
alias of Hartree
alias of AtomicUnitOfMass
alias of AtomicUnitOfTime
alias of MicroAtomicUnitOfCharge
alias of MicroAtomicUnitOfDistance
alias of MicroAtomicUnitOfEnergy
alias of Bohr
alias of Century
alias of Coulomb
alias of Day
alias of Decade
alias of Degree
alias of ElectronVolt
alias of Gram
alias of Hartree
alias of Hertz
alias of Hour
alias of Joule
alias of Meter
alias of Millennium
alias of Minute
alias of Radian
alias of Second
alias of Wavenumber
alias of Week
alias of Year
alias of MicroAngstrom
alias of MicroAngstrom
alias of MicroBohr
alias of MicroBohr
alias of MicroCentury
alias of MicroCentury
alias of MicroCoulomb
alias of MicroCoulomb
alias of MicroDay
alias of MicroDay
alias of MicroDecade
alias of MicroDecade
alias of MicroDegree
alias of MicroDegree
alias of MicroGram
alias of MicroGram
alias of MicroHartree
alias of MicroHartree
alias of MicroHertz
alias of MicroHertz
alias of MicroHour
alias of MicroHour
alias of MicroJoule
alias of MicroJoule
alias of MicroMeter
alias of MicroMeter
alias of MicroMillennium
alias of MicroMillennium
alias of MicroMinute
alias of MicroMinute
alias of MicroRadian
alias of MicroRadian
alias of MicroSecond
alias of MicroSecond
alias of MicroWavenumber
alias of MicroWavenumber
alias of MicroWeek
alias of MicroWeek
alias of MicroYear
alias of MicroYear
alias of Millennium
alias of AtomicMassUnit
alias of MilliAMU
alias of Angstrom
alias of AtomicMassUnit
alias of AtomicUnitOfElectricCharge
alias of Bohr
alias of AtomicUnitOfElectricCharge
alias of Hartree
alias of AtomicUnitOfMass
alias of AtomicUnitOfTime
alias of MilliAtomicUnitOfCharge
alias of MilliAtomicUnitOfDistance
alias of MilliAtomicUnitOfEnergy
alias of Bohr
alias of Century
alias of Coulomb
alias of Day
alias of Decade
alias of Degree
alias of ElectronVolt
alias of Gram
alias of Hartree
alias of Hertz
alias of Hour
alias of Joule
alias of Meter
alias of Millennium
alias of Minute
alias of Radian
alias of Second
alias of Wavenumber
alias of Week
alias of Year
alias of MilliAngstrom
alias of MilliAngstrom
alias of MilliBohr
alias of MilliBohr
alias of MilliCentury
alias of MilliCentury
alias of MilliCoulomb
alias of MilliCoulomb
alias of MilliDay
alias of MilliDay
alias of MilliDecade
alias of MilliDecade
alias of MilliDegree
alias of MilliDegree
alias of MilliGram
alias of MilliGram
alias of MilliHartree
alias of MilliHartree
alias of MilliHertz
alias of MilliHertz
alias of MilliHour
alias of MilliHour
alias of MilliJoule
alias of MilliJoule
alias of MilliMeter
alias of MilliMeter
alias of MilliMillennium
alias of MilliMillennium
alias of MilliMinute
alias of MilliMinute
alias of MilliRadian
alias of MilliRadian
alias of MilliSecond
alias of MilliSecond
alias of MilliWavenumber
alias of MilliWavenumber
alias of MilliWeek
alias of MilliWeek
alias of MilliYear
alias of MilliYear
alias of Minute
Abstract base class for all properties
Attributes : |
---|
molecule : Molecule units : CompositeUnit or class with Unit metaclass
Retrieve the value of the property from a tuple of groups matched in a RegexSequence. See RegexSequence.groups()
Retrieve the value of the property from a RegexSequence object that has already been used on a file. By default, this just calls self.from_groups() with seq.groups(flatten) where flatten comes from self.from_groups.flatten.
The new paradigm for obtaining values. Call the callable instance attribute getter with the arguments and keyword arguments passed in.
The value of the molecular property.
The exact same thing as the parent Molecule class (for now, anyway), but used for holding specifications of molecules that can later be replaced by a full molecule class (so things like, for instance, the calculations attribute won’t be filled in, but later if the geometry is found to match, the class using the MoleculeStub in some list can replace the stub with the full Molecule instance upon matching.
alias of AtomicMassUnit
alias of NanoAMU
alias of Angstrom
alias of AtomicMassUnit
alias of AtomicUnitOfElectricCharge
alias of Bohr
alias of AtomicUnitOfElectricCharge
alias of Hartree
alias of AtomicUnitOfMass
alias of AtomicUnitOfTime
alias of NanoAtomicUnitOfCharge
alias of NanoAtomicUnitOfDistance
alias of NanoAtomicUnitOfEnergy
alias of Bohr
alias of Century
alias of Coulomb
alias of Day
alias of Decade
alias of Degree
alias of ElectronVolt
alias of Gram
alias of Hartree
alias of Hertz
alias of Hour
alias of Joule
alias of Meter
alias of Millennium
alias of Minute
alias of Radian
alias of Second
alias of Wavenumber
alias of Week
alias of Year
alias of NanoAngstrom
alias of NanoAngstrom
alias of NanoBohr
alias of NanoBohr
alias of NanoCentury
alias of NanoCentury
alias of NanoCoulomb
alias of NanoCoulomb
alias of NanoDay
alias of NanoDay
alias of NanoDecade
alias of NanoDecade
alias of NanoDegree
alias of NanoDegree
alias of NanoGram
alias of NanoGram
alias of NanoHartree
alias of NanoHartree
alias of NanoHertz
alias of NanoHertz
alias of NanoHour
alias of NanoHour
alias of NanoJoule
alias of NanoJoule
alias of NanoMeter
alias of NanoMeter
alias of NanoMillennium
alias of NanoMillennium
alias of NanoMinute
alias of NanoMinute
alias of NanoRadian
alias of NanoRadian
alias of NanoSecond
alias of NanoSecond
alias of NanoWavenumber
alias of NanoWavenumber
alias of NanoWeek
alias of NanoWeek
alias of NanoYear
alias of NanoYear
alias of AtomicMassUnit
alias of PetaAMU
alias of Angstrom
alias of AtomicMassUnit
alias of AtomicUnitOfElectricCharge
alias of Bohr
alias of AtomicUnitOfElectricCharge
alias of Hartree
alias of AtomicUnitOfMass
alias of AtomicUnitOfTime
alias of PetaAtomicUnitOfCharge
alias of PetaAtomicUnitOfDistance
alias of PetaAtomicUnitOfEnergy
alias of Bohr
alias of Century
alias of Coulomb
alias of Day
alias of Decade
alias of Degree
alias of ElectronVolt
alias of Gram
alias of Hartree
alias of Hertz
alias of Hour
alias of Joule
alias of Meter
alias of Millennium
alias of Minute
alias of Radian
alias of Second
alias of Wavenumber
alias of Week
alias of Year
alias of PetaAngstrom
alias of PetaAngstrom
alias of PetaBohr
alias of PetaBohr
alias of PetaCentury
alias of PetaCentury
alias of PetaCoulomb
alias of PetaCoulomb
alias of PetaDay
alias of PetaDay
alias of PetaDecade
alias of PetaDecade
alias of PetaDegree
alias of PetaDegree
alias of PetaGram
alias of PetaGram
alias of PetaHartree
alias of PetaHartree
alias of PetaHertz
alias of PetaHertz
alias of PetaHour
alias of PetaHour
alias of PetaJoule
alias of PetaJoule
alias of PetaMeter
alias of PetaMeter
alias of PetaMillennium
alias of PetaMillennium
alias of PetaMinute
alias of PetaMinute
alias of PetaRadian
alias of PetaRadian
alias of PetaSecond
alias of PetaSecond
alias of PetaWavenumber
alias of PetaWavenumber
alias of PetaWeek
alias of PetaWeek
alias of PetaYear
alias of PetaYear
alias of AtomicMassUnit
alias of PicoAMU
alias of Angstrom
alias of AtomicMassUnit
alias of AtomicUnitOfElectricCharge
alias of Bohr
alias of AtomicUnitOfElectricCharge
alias of Hartree
alias of AtomicUnitOfMass
alias of AtomicUnitOfTime
alias of PicoAtomicUnitOfCharge
alias of PicoAtomicUnitOfDistance
alias of PicoAtomicUnitOfEnergy
alias of Bohr
alias of Century
alias of Coulomb
alias of Day
alias of Decade
alias of Degree
alias of ElectronVolt
alias of Gram
alias of Hartree
alias of Hertz
alias of Hour
alias of Joule
alias of Meter
alias of Millennium
alias of Minute
alias of Radian
alias of Second
alias of Wavenumber
alias of Week
alias of Year
alias of PicoAngstrom
alias of PicoAngstrom
alias of PicoBohr
alias of PicoBohr
alias of PicoCentury
alias of PicoCentury
alias of PicoCoulomb
alias of PicoCoulomb
alias of PicoDay
alias of PicoDay
alias of PicoDecade
alias of PicoDecade
alias of PicoDegree
alias of PicoDegree
alias of PicoGram
alias of PicoGram
alias of PicoHartree
alias of PicoHartree
alias of PicoHertz
alias of PicoHertz
alias of PicoHour
alias of PicoHour
alias of PicoJoule
alias of PicoJoule
alias of PicoMeter
alias of PicoMeter
alias of PicoMillennium
alias of PicoMillennium
alias of PicoMinute
alias of PicoMinute
alias of PicoRadian
alias of PicoRadian
alias of PicoSecond
alias of PicoSecond
alias of PicoWavenumber
alias of PicoWavenumber
alias of PicoWeek
alias of PicoWeek
alias of PicoYear
alias of PicoYear
alias of Radian
A read-only attribute. See SpecialAttribute for initialization variables standard to all SpecialAttribute subclasses.
Attributes : |
---|
Abstract base class for all classes that encapsulate a method of retrieving a (set of) properties of a molecule from a computational chemistry package. An instance of a ResultGetter object should know how to turn a request for a given molecular property into a Computation object (which, in turn, houses MolecularProperty objects for one or more Molecule objects). ResultGetter objects generate Computation objects. Any ResultGetter subclass should always check for an available computation on (exactly) the same molecule that already has the result available.
alias of Second
alias of AtomicMassUnit
alias of TeraAMU
alias of Angstrom
alias of AtomicMassUnit
alias of AtomicUnitOfElectricCharge
alias of Bohr
alias of AtomicUnitOfElectricCharge
alias of Hartree
alias of AtomicUnitOfMass
alias of AtomicUnitOfTime
alias of TeraAtomicUnitOfCharge
alias of TeraAtomicUnitOfDistance
alias of TeraAtomicUnitOfEnergy
alias of Bohr
alias of Century
alias of Coulomb
alias of Day
alias of Decade
alias of Degree
alias of ElectronVolt
alias of Gram
alias of Hartree
alias of Hertz
alias of Hour
alias of Joule
alias of Meter
alias of Millennium
alias of Minute
alias of Radian
alias of Second
alias of Wavenumber
alias of Week
alias of Year
alias of TeraAngstrom
alias of TeraAngstrom
alias of TeraBohr
alias of TeraBohr
alias of TeraCentury
alias of TeraCentury
alias of TeraCoulomb
alias of TeraCoulomb
alias of TeraDay
alias of TeraDay
alias of TeraDecade
alias of TeraDecade
alias of TeraDegree
alias of TeraDegree
alias of TeraGram
alias of TeraGram
alias of TeraHartree
alias of TeraHartree
alias of TeraHertz
alias of TeraHertz
alias of TeraHour
alias of TeraHour
alias of TeraJoule
alias of TeraJoule
alias of TeraMeter
alias of TeraMeter
alias of TeraMillennium
alias of TeraMillennium
alias of TeraMinute
alias of TeraMinute
alias of TeraRadian
alias of TeraRadian
alias of TeraSecond
alias of TeraSecond
alias of TeraWavenumber
alias of TeraWavenumber
alias of TeraWeek
alias of TeraWeek
alias of TeraYear
alias of TeraYear
General superclass for all time units
alias of Second
alias of Second
Metaclass for a general unit of something.
Abstract base class for things with units. It requires its subclasses to implement the properties ‘value’ and ‘units’. Unitized subclasses are also expected have __mul__, __div__, __truediv__, __pow__, __add__, __sub__, __neg__, __pos__, and __abs__ handle units correctly, when implemented in the given subclass.
For errors encountered in handling unitized objects
Exception for attempted conversion of something that is not a subclass of Unit
A class for encapsulating a physical constant and it’s units.
Attributes : |
---|
alias of Wavenumber
alias of Week
alias of Year
alias of AtomicMassUnit
alias of YoctoAMU
alias of Angstrom
alias of AtomicMassUnit
alias of AtomicUnitOfElectricCharge
alias of Bohr
alias of AtomicUnitOfElectricCharge
alias of Hartree
alias of AtomicUnitOfMass
alias of AtomicUnitOfTime
alias of YoctoAtomicUnitOfCharge
alias of YoctoAtomicUnitOfDistance
alias of YoctoAtomicUnitOfEnergy
alias of Bohr
alias of Century
alias of Coulomb
alias of Day
alias of Decade
alias of Degree
alias of ElectronVolt
alias of Gram
alias of Hartree
alias of Hertz
alias of Hour
alias of Joule
alias of Meter
alias of Millennium
alias of Minute
alias of Radian
alias of Second
alias of Wavenumber
alias of Week
alias of Year
alias of YoctoAngstrom
alias of YoctoAngstrom
alias of YoctoBohr
alias of YoctoBohr
alias of YoctoCentury
alias of YoctoCentury
alias of YoctoCoulomb
alias of YoctoCoulomb
alias of YoctoDay
alias of YoctoDay
alias of YoctoDecade
alias of YoctoDecade
alias of YoctoDegree
alias of YoctoDegree
alias of YoctoGram
alias of YoctoGram
alias of YoctoHartree
alias of YoctoHartree
alias of YoctoHertz
alias of YoctoHertz
alias of YoctoHour
alias of YoctoHour
alias of YoctoJoule
alias of YoctoJoule
alias of YoctoMeter
alias of YoctoMeter
alias of YoctoMillennium
alias of YoctoMillennium
alias of YoctoMinute
alias of YoctoMinute
alias of YoctoRadian
alias of YoctoRadian
alias of YoctoSecond
alias of YoctoSecond
alias of YoctoWavenumber
alias of YoctoWavenumber
alias of YoctoWeek
alias of YoctoWeek
alias of YoctoYear
alias of YoctoYear
alias of AtomicMassUnit
alias of YottaAMU
alias of Angstrom
alias of AtomicMassUnit
alias of AtomicUnitOfElectricCharge
alias of Bohr
alias of AtomicUnitOfElectricCharge
alias of Hartree
alias of AtomicUnitOfMass
alias of AtomicUnitOfTime
alias of YottaAtomicUnitOfCharge
alias of YottaAtomicUnitOfDistance
alias of YottaAtomicUnitOfEnergy
alias of Bohr
alias of Century
alias of Coulomb
alias of Day
alias of Decade
alias of Degree
alias of ElectronVolt
alias of Gram
alias of Hartree
alias of Hertz
alias of Hour
alias of Joule
alias of Meter
alias of Millennium
alias of Minute
alias of Radian
alias of Second
alias of Wavenumber
alias of Week
alias of Year
alias of YottaAngstrom
alias of YottaAngstrom
alias of YottaBohr
alias of YottaBohr
alias of YottaCentury
alias of YottaCentury
alias of YottaCoulomb
alias of YottaCoulomb
alias of YottaDay
alias of YottaDay
alias of YottaDecade
alias of YottaDecade
alias of YottaDegree
alias of YottaDegree
alias of YottaGram
alias of YottaGram
alias of YottaHartree
alias of YottaHartree
alias of YottaHertz
alias of YottaHertz
alias of YottaHour
alias of YottaHour
alias of YottaJoule
alias of YottaJoule
alias of YottaMeter
alias of YottaMeter
alias of YottaMillennium
alias of YottaMillennium
alias of YottaMinute
alias of YottaMinute
alias of YottaRadian
alias of YottaRadian
alias of YottaSecond
alias of YottaSecond
alias of YottaWavenumber
alias of YottaWavenumber
alias of YottaWeek
alias of YottaWeek
alias of YottaYear
alias of YottaYear
alias of AtomicMassUnit
alias of ZeptoAMU
alias of Angstrom
alias of AtomicMassUnit
alias of AtomicUnitOfElectricCharge
alias of Bohr
alias of AtomicUnitOfElectricCharge
alias of Hartree
alias of AtomicUnitOfMass
alias of AtomicUnitOfTime
alias of ZeptoAtomicUnitOfCharge
alias of ZeptoAtomicUnitOfDistance
alias of ZeptoAtomicUnitOfEnergy
alias of Bohr
alias of Century
alias of Coulomb
alias of Day
alias of Decade
alias of Degree
alias of ElectronVolt
alias of Gram
alias of Hartree
alias of Hertz
alias of Hour
alias of Joule
alias of Meter
alias of Millennium
alias of Minute
alias of Radian
alias of Second
alias of Wavenumber
alias of Week
alias of Year
alias of ZeptoAngstrom
alias of ZeptoAngstrom
alias of ZeptoBohr
alias of ZeptoBohr
alias of ZeptoCentury
alias of ZeptoCentury
alias of ZeptoCoulomb
alias of ZeptoCoulomb
alias of ZeptoDay
alias of ZeptoDay
alias of ZeptoDecade
alias of ZeptoDecade
alias of ZeptoDegree
alias of ZeptoDegree
alias of ZeptoGram
alias of ZeptoGram
alias of ZeptoHartree
alias of ZeptoHartree
alias of ZeptoHertz
alias of ZeptoHertz
alias of ZeptoHour
alias of ZeptoHour
alias of ZeptoJoule
alias of ZeptoJoule
alias of ZeptoMeter
alias of ZeptoMeter
alias of ZeptoMillennium
alias of ZeptoMillennium
alias of ZeptoMinute
alias of ZeptoMinute
alias of ZeptoRadian
alias of ZeptoRadian
alias of ZeptoSecond
alias of ZeptoSecond
alias of ZeptoWavenumber
alias of ZeptoWavenumber
alias of ZeptoWeek
alias of ZeptoWeek
alias of ZeptoYear
alias of ZeptoYear
alias of AtomicMassUnit
alias of ZettaAMU
alias of Angstrom
alias of AtomicMassUnit
alias of AtomicUnitOfElectricCharge
alias of Bohr
alias of AtomicUnitOfElectricCharge
alias of Hartree
alias of AtomicUnitOfMass
alias of AtomicUnitOfTime
alias of ZettaAtomicUnitOfCharge
alias of ZettaAtomicUnitOfDistance
alias of ZettaAtomicUnitOfEnergy
alias of Bohr
alias of Century
alias of Coulomb
alias of Day
alias of Decade
alias of Degree
alias of ElectronVolt
alias of Gram
alias of Hartree
alias of Hertz
alias of Hour
alias of Joule
alias of Meter
alias of Millennium
alias of Minute
alias of Radian
alias of Second
alias of Wavenumber
alias of Week
alias of Year
alias of ZettaAngstrom
alias of ZettaAngstrom
alias of ZettaBohr
alias of ZettaBohr
alias of ZettaCentury
alias of ZettaCentury
alias of ZettaCoulomb
alias of ZettaCoulomb
alias of ZettaDay
alias of ZettaDay
alias of ZettaDecade
alias of ZettaDecade
alias of ZettaDegree
alias of ZettaDegree
alias of ZettaGram
alias of ZettaGram
alias of ZettaHartree
alias of ZettaHartree
alias of ZettaHertz
alias of ZettaHertz
alias of ZettaHour
alias of ZettaHour
alias of ZettaJoule
alias of ZettaJoule
alias of ZettaMeter
alias of ZettaMeter
alias of ZettaMillennium
alias of ZettaMillennium
alias of ZettaMinute
alias of ZettaMinute
alias of ZettaRadian
alias of ZettaRadian
alias of ZettaSecond
alias of ZettaSecond
alias of ZettaWavenumber
alias of ZettaWavenumber
alias of ZettaWeek
alias of ZettaWeek
alias of ZettaYear
alias of ZettaYear
Aliased as iscompatible()
Alias for convert_units()
Aliased as convert()
defaultdict(default_factory) –> dict with default factory
The default factory is called without arguments to produce a new value when a key is not present, in __getitem__ only. A defaultdict compares equal to a dict with the same items.
Factory for default value called by __missing__().
Aliased as hasunits()
Alias for has_units()
Aliased as indent()
Alias for isunit()
Alias for compatible_units()
Aliased as is_unit()
A simple way to accept arguments that can be an Iterable or a bunch of arguments that should be treated as a single Iterable. (This method is pretty trivial, but I find myself doing it a whole lot.) The reason you can’t just use list() for this purpose is that if an Iterable is given as the only argument, list(args) will return a list of Iterables rather than a single Iterable.
Examples : |
---|
>>> def test(*args):
... return listify_args(*args)
...
>>> test(1,2,3)
[1, 2, 3]
>>> test([1,2,3])
[1, 2, 3]
>>> test([1,2,3], 4)
[[1, 2, 3], 4]
>>> test("1,2,3", 4)
['1,2,3', 4]
>>> test("1,2,3")
['1,2,3']
Aliased as stripunits()
Alias for strip_units()
Module with utility functions for use in input files.
Function to compare two integers. Prints util.success() when value computed matches value expected. Performs a system exit on failure. Used in input files in the test suite.
Function to compare two matrices. Prints util.success() when elements of matrix computed match elements of matrix expected to number of digits. Performs a system exit on failure to match symmetry structure, dimensions, or element values. Used in input files in the test suite.
Function to compare two strings. Prints util.success() when string computed exactly matches string expected. Performs a system exit on failure. Used in input files in the test suite.
Function to compare two values. Prints util.success() when value computed matches value expected to number of digits. Performs a system exit on failure. Used in input files in the test suite.
Function to compare two vectors. Prints util.success() when elements of vector computed match elements of vector expected to number of digits. Performs a system exit on failure to match symmetry structure, dimension, or element values. Used in input files in the test suite.
Function to move file out of scratch with correct naming convention.
Arguments:
@arg filename full path to target file @arg prefix computation prefix, usually ‘psi’ @arg namespace context namespace, usually molecule name @arg unit unit number, e.g. 32 @arg move copy or move? (default copy)
Example:
Assume PID is 12345 and SCRATCH is /scratch/parrish/
Function to move file into scratch with correct naming convention.
Arguments:
@arg filename full path to file @arg prefix computation prefix, usually ‘psi’ @arg namespace context namespace, usually molecule name @arg unit unit number, e.g. 32 @arg move copy or move? (default copy)
Example:
Assume PID is 12345 and SCRATCH is /scratch/parrish/
Function to print a ‘label...PASSED’ line to screen. Used by util.compare_values() family when functions pass.
Module (auto-generated from make_dunning.pl script) with commands building BasisFamily objects that encode the Dunning basis set orbital definitions in psi4/lib/basis/NOTES and fitting bases designed for those orbital bases.
Class defining a flexible Table object for storing data.
Function to print text to output file in a banner of minimum width width and minimum three-line height for type = 1 or one-line height for type = 2. If strNotOutfile is True, function returns string rather than printing it to output file.
Function to compute approximate string matches from a list of options.
Module to provide mechanism to store and restore option states in driver.
Class to store the state of a single option. If module given, the option value and has_changed value is stored for global, local to module, and used by module scopes; otherwise (used for BASIS keywords), only global scope is stored. Class can store, print, and restore option values.
>>> OptionState('SCF_TYPE', 'SCF')
>>> print(OptionState('DF_BASIS_MP2'))
Class to contain multiple OptionsState() objects. Used in python driver functions to collect several options before altering them, then restoring before function return.
>>> optstash = OptionsState(
['SCF', 'DFT_FUNCTIONAL'],
['DF_BASIS_SCF'],
['SCF', 'SCF_TYPE'],
['SCF', 'REFERENCE'])
>>> print(optstash)
>>> optstash.restore()
Module with utility functions used by several Python functions.
Function to return a generator of all lettercase permutations of input_string.
Function that given an array seq, returns an array without any duplicate entries. There is no guarantee of which duplicate entry is dropped.
Function to examine file sowout from a sow/reap distributed job for formatted line with electronic energy information about index sownum to be used for construction of quantity computations as directed by master input file with linkage kwarg. When file sowout is missing or incomplete files, function will either return zero (allvital is False) or terminate (allvital is True) since some sow/reap procedures can produce meaningful results (database) from an incomplete set of sown files, while others cannot (gradient, hessian).
Function to return an input file in preprocessed psithon. Captures memory, molecule, options, function, method, and kwargs. Used to write distributed (sow/reap) input files.
Function to pickle to file filename the options dictionary kwargs. Mode lmode =2 pickles appropriate settings for reap mode. Used to capture Python options information for distributed (sow/reap) input files.
Function to return a string of the output of inputparser.process_input() applied to the XYZ format of molecule, passed as either fragmented geometry string mol or molecule instance mol. Used to capture molecule information from database modules and for distributed (sow/reap) input files. For the reverse, see molutil.geometry().
Function to return a string of commands to replicate the current state of user-modified options. Used to capture C++ options information for distributed (sow/reap) input files.
Caution
Some features are not yet implemented. Buy a developer a coffee.
Function to return the full path and filename for psi file fileno (e.g., psi.32) in current namespace pidspace.
Function to extract attribute attr from module if attr is available in any possible lettercase permutation. Returns attribute if available, None if not.
Function to import module in any possible lettercase permutation. Returns module object if available, None if not.
Function to rebuild and return kwargs dictionary with all keys made lowercase. Should be called by every function that could be called directly by the user.
Function to convert psi4.Matrix mat to Python array of arrays. Expects psi4.Matrix to be flat with respect to symmetry.
Function to return a string of commands to replicate the current state of user-modified options. Used to capture C++ options information for distributed (sow/reap) input files.
Caution
Some features are not yet implemented. Buy a developer a coffee.
Module with commands building BasisFamily objects for Pople and other non-Dunning orbital basis sets. Some plausible fitting basis sets are supplied as defaults.
Module to define a class BasisFamily that associates fitting basis sets to an orbital basis and to provide functions to query appropriate fitting bases for any orbital basis distributed with Psi4.
Class to associate with an orbital basis name ornate the gbs file names in which the orbital basis orbital (usually the coded form of ornate) and jfit, jkfit, rifit, and dualfit auxiliary bases can be found.
Function to add basis fit as associated helper basis member dualfit to a BasisFamily object.
Function to add basis fit as associated fitting basis member jfit to a BasisFamily object.
Function to add basis fit as associated fitting basis member jkfit to a BasisFamily object.
Function to return an appropriate DUAL helper basis for the orbital basis name in coded or ornate form. None is returned if no fitting basis is defined or if the orbital basis is not found.
Function to return an appropriate J fitting basis for the orbital basis name in coded or ornate form. None is returned if no fitting basis is defined or if the orbital basis is not found.
Function to return an appropriate JK fitting basis for the orbital basis name in coded or ornate form. None is returned if no fitting basis is defined or if the orbital basis is not found.
Function to validate if the orbital basis name in coded or ornate form is in Psi4’s standard installed bases list. None is returned if the orbital basis is not found.
Function to return an appropriate RI fitting basis for the orbital basis name in coded or ornate form. None is returned if no fitting basis is defined or if the orbital basis is not found.
Function to load into the array basisfamily_list BasisFamily objects for all Psi4’s standard installed bases.