# chemcoord.Zmat¶

class chemcoord.Zmat(frame, metadata=None, _metadata=None)[source]

The main class for dealing with internal Coordinates.

Rotational direction:

Chemcoord uses the IUPAC definition. Note that this does not include the automatic choosing of the canonical equivalence class representation. An angle of -30° could be represented by 270°. Use iupacify() to choose also the IUPAC conform angle representation.

Mathematical Operations:

The general rule is that mathematical operations using the binary operators + - * / and the unary operators + - abs are only applied to the ['bond', 'angle', 'dihedral'] columns.

Addition/Subtraction/Multiplication/Division: The most common case is to add another Zmat instance. In this case it is tested, if the used references are the same. Afterwards the addition in the ['bond', 'angle', 'dihedral'] columns is performed. If you add a scalar to a Zmat it is added elementwise onto the ['bond', 'angle', 'dihedral'] columns. If you add a 3-dimensional vector, list, tuple... the first element of this vector is added elementwise to the 'bond' column of the Zmat instance and so on. The third possibility is to add a matrix with shape=(len(Zmat), 3) which is again added elementwise. The same rules are true for subtraction, division and multiplication.

Indexing:

The indexing behaves like Indexing and Selecting data in Pandas. You can slice with loc(), iloc(), and Zmat[...]. The only question is about the return type. If the information in the columns is enough to draw a molecule, an instance of the own class (e.g. Zmat) is returned. If the information in the columns is enough to draw a molecule, an instance of the own class (e.g. Zmat) is returned. If the information in the columns is not enough to draw a molecule, there are two cases to consider:

This means that:

molecule.loc[:, ['atom', 'b', 'bond', 'a', 'angle', 'd', 'dihedral']] returns a Zmat.

molecule.loc[:, ['atom', 'bond']] returns a pandas.DataFrame.

molecule.loc[:, 'atom'] returns a pandas.Series.

Comparison:

Comparison for equality with == is supported. It behaves exactly like the equality comparison of DataFrames in pandas. Amongst other things this means that the index has to be the same and the comparison of floating point numbers is exact and not numerical.

Chemical Methods

 __init__(frame[, metadata, _metadata]) How to initialize a Zmat instance. add_data([new_cols]) Adds a column with the requested data. change_numbering([new_index]) Change numbering to a new index. has_same_sumformula(other) Determines if other has the same sumformula get_cartesian() Return the molecule in cartesian coordinates. get_grad_cartesian([as_function, chain, ...]) Return the gradient for the transformation to a Cartesian. to_xyz(*args, **kwargs) Deprecated, use get_cartesian() get_total_mass() Returns the total mass in g/mol. get_electron_number([charge]) Return the number of electrons. subs(*args, **kwargs) Substitute a symbolic expression in ['bond', 'angle', 'dihedral'] iupacify() Give the IUPAC conform representation. minimize_dihedrals() Give a representation of the dihedral with minimized absolute value.

Selection of data

 loc Label based indexing for obtaining elements. safe_loc Label based indexing for obtaining elements and assigning values safely. unsafe_loc Label based indexing for obtaining elements and assigning values unsafely. iloc Integer position based indexing for obtaining elements. safe_iloc Integer position based indexing for obtaining elements and assigning values safely. unsafe_iloc Integer position based indexing for obtaining elements and assigning values unsafely.

Pandas DataFrame Wrapper

 copy() index Returns the index. columns Returns the columns. Zmat.sort_index([axis, level, ascending, ...]) Sort object by labels (along an axis) insert(loc, column, value[, ...]) Insert column into molecule at specified location. sort_values(by[, axis, ascending, kind, ...]) Sort by the values along either axis

IO

 to_zmat([buf, upper_triangle, ...]) Write zmat-file write(*args, **kwargs) Deprecated, use to_zmat() read_zmat(inputfile[, implicit_index]) Reads a zmat file. to_string([buf, format_abs_ref_as, ...]) Render a DataFrame to a console-friendly tabular output. to_latex([buf, upper_triangle]) Render a DataFrame to a tabular environment table.

Attributes

 columns Returns the columns. index Returns the index. shape Returns the shape. dtypes Returns the dtypes.