Skip to content

Commit

Permalink
Update docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
abelcarreras committed Dec 28, 2020
1 parent 3426523 commit fed7b4c
Show file tree
Hide file tree
Showing 6 changed files with 125 additions and 38 deletions.
16 changes: 9 additions & 7 deletions cosymlib/molecule/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,19 @@ def wrapper(*args, **kwargs):

class Molecule:
"""
Molecule class 2
Main molecule class
:param geometry: The geometry
:type geometry: Geometry
:param electronic_structure: The electronic structure
:type electronic_structure: ElectronicStructure
:param name: Molecule name
:type name: str
"""
def __init__(self, geometry,
electronic_structure=None,
name=None):
"""
:param geometry:
:param electronic_structure:
:param name:
"""

if not geometry:
raise Exception('No geometry found in the input file, check out input file for possible errors')
Expand Down
19 changes: 19 additions & 0 deletions cosymlib/molecule/electronic_structure/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,23 @@
class ElectronicStructure:
"""
Main Electronic structure class
:param charge: The charge
:type charge: int
:param multiplicity: The multiplicity
:type multiplicity: int
:param basis: The basis set
:type basis: list
:param orbital_coefficients: Molecular orbital coefficients
:type orbital_coefficients: list
:param mo_energies: Molecular orbital energies
:type mo_energies: list
:param alpha_electrons: Number of alpha electrons
:type alpha_electrons: int
:param beta_electrons: Number of beta electrons
:type beta_electrons: int
"""
def __init__(self,
charge=0,
multiplicity=1,
Expand Down
25 changes: 24 additions & 1 deletion cosymlib/molecule/geometry/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,30 @@ def wrapper(*args, **kwargs):

class Geometry:
"""
Geometry class
Main geometry class
:param positions: Cartesian coordinates
:type positions: list
:param symbols: Atomic elements symbols
:type symbols: list
:param name: Geometry name
:type name: str
:param connectivity: Connectivity list
:type connectivity: list
:param connectivity_thresh: Connectivity threshold
:type connectivity_thresh: float
:example:
.. code-block:: python
water = Geometry(positions=[[0.0, 0.0, 0.0],
[0.0, 1.0, 0.0],
[0.0, 0.0, 1.0],
symbols=['O', 'H', 'H'],
name='water molecule',
connectivity=[[1, 2], [1, 3]])
"""
def __init__(self,
Expand Down
48 changes: 32 additions & 16 deletions cosymlib/shape/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class Shape:
Shape main class
:param structure: a geometry, molecule or array type object
:type structure: list
"""
def __init__(self, structure):

Expand All @@ -48,10 +49,14 @@ def measure(self, reference, central_atom=0, fix_permutation=False):
"""
Get shape measure
:param reference: reference shape label or Geometry object
:param central_atom: central atom position
:param fix_permutation: do not permute atoms during shape calculations
:return: the measure
:param reference: Reference shape label or Geometry object
:type reference: str
:param central_atom: Central atom position
:type central_atom: int
:param fix_permutation: Do not permute atoms during shape calculations
:type fix_permutation: bool
:return: The measure
:rtype: float
"""
key = _get_key(central_atom, reference, fix_permutation=fix_permutation)
if key not in self._measures:
Expand All @@ -75,10 +80,14 @@ def structure(self, reference, central_atom=0, fix_permutation=False):
"""
Get the nearest structure to reference
:param reference: reference shape label or Geometry object
:param central_atom: central atom position
:param fix_permutation: do not permute atoms during shape calculations
:return: the structure
:param reference: Reference shape label or Geometry object
:type reference: str, Geometry
:param central_atom: Central atom position
:type central_atom: int, Geometry
:param fix_permutation: Do not permute atoms during shape calculations
:type fix_permutation: bool
:return: The structure
:rtype: Structure
"""
key = _get_key(central_atom, reference, fix_permutation=fix_permutation)
if key not in self._structures:
Expand Down Expand Up @@ -107,10 +116,14 @@ def path_deviation(self, shape_label1, shape_label2, central_atom=0):
"""
Get the path deviation
:param shape_label1: first shape reference label or Geometry object
:param shape_label2: second shape reference label or Geometry object
:param central_atom: central atom position
:return: the path deviation
:param shape_label1: First shape reference label or Geometry object
:type shape_label1: str, Geometry
:param shape_label2: Second shape reference label or Geometry object
:type shape_label2: str, Geometry
:param central_atom: Central atom position
:type central_atom: int
:return: The path deviation
:rtype: float
"""
# TODO: Someone improve the description of this function

Expand All @@ -133,10 +146,13 @@ def generalized_coordinate(self, shape_label1, shape_label2, central_atom=0):
"""
Get the generalized coordinate
:param shape_label1: first shape reference label or Geometry object
:param shape_label2: second shape reference label or Geometry object
:param central_atom: central atom position
:return:
:param shape_label1: First shape reference label or Geometry object
:type shape_label1: str, Geometry
:param shape_label2: Second shape reference label or Geometry object
:type shape_label2: str, Geometry
:param central_atom: Central atom position
:type central_atom: int
:return: The generalized coordinate
"""

key = _get_key(central_atom, shape_label1, reference_2=shape_label2)
Expand Down
50 changes: 36 additions & 14 deletions cosymlib/symmetry/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,19 @@ class Symmetry:
Symmetry main class
:param structure: a geometry, molecule or array type object
:type structure: Geometry, Molecule, np.array
:param central_atom: central atom position
:param center: center of symmetry. By default center is optimized
:type central_atom: int
:param center: center of symmetry in Cartesian coordinates. By default center is optimized
:type center: list
:param connect_thresh: Connectivity threshold (Ionic radius is used as reference)
:param multi: number of symmetry axis to find
:param axis: main symmetry axis (If None, then optimize)
:type connect_thresh: float
:param multi: Number of symmetry axis to find
:type multi: int
:param axis: Main symmetry axis (If None, then optimize)
:type axis: list
:param axis2: secondary symmetry axis (If None, then optimize)
:type axis2: list
"""

def __init__(self,
Expand Down Expand Up @@ -84,7 +91,7 @@ def set_parameters(self, parameters_dict):
Set symmetry calculation related parameters
:param parameters_dict: parameters in dictionary
:return:
:type parameters_dict: dict
"""
for name, value in parameters_dict.items():
setattr(self, '_' + name, value)
Expand Down Expand Up @@ -146,17 +153,21 @@ def measure(self, label):
"""
Get symmetry measure
:param label: point group label
:return: the measure
:param label: Point group label
:type label: str
:return: The measure
:rtype: float
"""
return self._get_symgroup_results(label).csm

def nearest_structure(self, label):
"""
Get nearest structure
:param label: point group label
:return: the structure
:param label: Point group label
:type label: str
:return: The structure
:rtype: Structure
"""
# TODO: Improve this docstring

Expand All @@ -166,8 +177,10 @@ def optimum_axis(self, label):
"""
Get the optimum main symmetry axis
:param label: point group label
:return:
:param label: Point group label
:type label: str
:return: The axis
:rtype: list
"""
return self._get_symgroup_results(label).optimum_axis

Expand All @@ -176,7 +189,8 @@ def optimum_permutation(self, label):
Get the optimum atoms permutation
:param label: point group label
:return:
:return: The permutation
:rtype: list
"""
return self._get_symgroup_results(label).optimum_permutation

Expand All @@ -185,7 +199,9 @@ def reference_axis(self, label):
Get reference axis
:param label: point group label
:return:
:type label: str
:return: The axis
:rtype: list
"""
return self._get_symgroup_results(label).reference_axis

Expand All @@ -194,8 +210,11 @@ def cms_multi(self, label, multi=1):
Get symmetry measure of the optimum N axis
:param label: point group label
:type label: str
:param multi: number of axis
:return: list of measures
:type multi: int
:return: The measures
:rtype: list
"""
self._multi = multi
return self._get_symgroup_results(label).cms_multi
Expand All @@ -205,8 +224,11 @@ def axis_multi(self, label, multi=1):
Get the optimum N axis
:param label: point group label
:type label: str
:param multi: number of axis
:return: list of axis
:type multi: int
:return: List of axis
:rtype: list
"""
self._multi = multi
return self._get_symgroup_results(label).axis_multi
Expand Down
5 changes: 5 additions & 0 deletions docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,8 @@ Geometry
.. automodule:: cosymlib.molecule.geometry
:members: Geometry

Electronic structure
--------------------
.. automodule:: cosymlib.molecule.electronic_structure
:members: ElectronicStructure

0 comments on commit fed7b4c

Please sign in to comment.