Skip to content

Commit

Permalink
Update docstring of Cosymlib class
Browse files Browse the repository at this point in the history
  • Loading branch information
abelcarreras committed Dec 21, 2020
1 parent 263b3ef commit 32ddd1b
Showing 1 changed file with 93 additions and 17 deletions.
110 changes: 93 additions & 17 deletions cosymlib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,14 @@ def _get_symgroup_arguments(locals):

class Cosymlib:
"""
Main class of cosymlib program that can perform all the jobs
Main cosymlib class
:param structures: list of Geometry or Molecule type objects
:param ignore_atoms_labels: If True ignore atomic element labels is symmetry calculations
:param ignore_connectivity: If True ignore connectivity in symmetry calculations
:param connectivity: List of pairs if atom indices that are considered connected
:param connectivity_thresh: Connectivity threshold (Ionic radius is used as reference)
"""

def __init__(self,
Expand Down Expand Up @@ -61,34 +68,54 @@ def __init__(self,
molecule.geometry.set_connectivity(None)

def get_n_atoms(self):
"""
Returns the number of atoms if all structures contains the same number of atoms,
else raise exception.
:return: number of atoms
"""
n_atoms_unique_list = np.unique([mol.geometry.get_n_atoms() for mol in self._molecules])
if len(n_atoms_unique_list) > 1:
raise Exception('Not all structures have same number of atoms')

return n_atoms_unique_list[0]

def get_geometries(self):
"""
Returns the geometry of all structures
:return: list of Geometry objects
"""
return [mol.geometry for mol in self._molecules]

def print_info(self):
"""
Prints general information about the structures
:return:
"""
print('\033[1m{:20} {:^5}\033[0m'.format('name', 'atoms'))
for molecule in self._molecules:
print('{:20} : {:5}'.format(molecule.name, molecule.geometry.get_n_atoms()))
print('Total structures: {}'.format(len(self._molecules)))

@property
def molecules(self):
"""
Returns the molecules
:return: List of Molecule objects
"""
return self._molecules

def print_shape_measure(self, shape_reference, central_atom=0, fix_permutation=False, output=sys.stdout):
"""
Method that prints to file shape's measure
Prints the shape measure of all structures in format
:param shape_reference: reference label, list of labels, 'all' or polyhedra list
:param central_atom: position of the central atom in molecule if exist
:param output_name: custom name without extension
:return: shape's measure in the output_name.tab file
:param shape_reference: reference label
:param central_atom: position of the central atom
:param output: defines the output pipe (default: standard output) #TODO: search proper name for "output pipe"
:return:
"""

if shape_reference == 'all':
Expand Down Expand Up @@ -144,13 +171,13 @@ def print_shape_measure(self, shape_reference, central_atom=0, fix_permutation=F

def print_shape_structure(self, shape_reference, central_atom=0, fix_permutation=False, output=sys.stdout):
"""
Method that prints to file shape's structure
Prints the nearest shape structure in format
:param shape_reference: reference polyhedra label which user will compare with his polyhedra.
:param central_atom: position of the central atom in molecule if exist
:param fix_permutation: True or False
:param output: custom name without extension
:return: shape's structure in the output_name.out file
:param shape_reference: reference label
:param central_atom: position of the central atom
:param fix_permutation: Do not permute atoms during shape calculations
:param output: defines the output pipe (default: standard output) #TODO: search proper name for "output pipe"
:return:
"""

if shape_reference == 'all':
Expand Down Expand Up @@ -188,6 +215,16 @@ def print_shape_structure(self, shape_reference, central_atom=0, fix_permutation

# TODO: Change name of all symgroup named functions
def print_geometric_measure_info(self, label, multi=1, central_atom=0, center=None, output=sys.stdout):
"""
Prints geometric symmetry measure verbose
:param label: symmetry group
:param multi: number of axis
:param central_atom: position of the central atom
:param center: center of symmetry. By default center is optimized
:param output: defines the output pipe (default: standard output) #TODO: search proper name for "output pipe"
:return:
"""
kwargs = _get_symgroup_arguments(locals())
sep_line = '..................................................\n'

Expand Down Expand Up @@ -226,8 +263,16 @@ def print_geometric_measure_info(self, label, multi=1, central_atom=0, center=No

output.write(txt)

def print_geometric_symmetry_measure(self, label, central_atom=0, center=None,
output=sys.stdout):
def print_geometric_symmetry_measure(self, label, central_atom=0, center=None, output=sys.stdout):
"""
Prints geometric symmetry measure in format
:param label: symmetry group
:param central_atom: position of the central atom
:param center: center of symmetry. By default center is optimized
:param output: defines the output pipe (default: standard output) #TODO: search proper name for "output pipe"
:return:
"""
kwargs = _get_symgroup_arguments(locals())

txt = 'Evaluating symmetry operation : {}\n \n'.format(label)
Expand All @@ -243,8 +288,16 @@ def print_geometric_symmetry_measure(self, label, central_atom=0, center=None,

output.write(txt)

def print_symmetry_nearest_structure(self, label, central_atom=0, center=None,
output=sys.stdout):
def print_symmetry_nearest_structure(self, label, central_atom=0, center=None, output=sys.stdout):
"""
Prints the nearest structure to ideal symmetric structure
:param label: symmetry group
:param central_atom: position of the central atom
:param center: center of symmetry. By default center is optimized
:param output: defines the output pipe (default: standard output) #TODO: search proper name for "output pipe"
:return:
"""
kwargs = _get_symgroup_arguments(locals())

for idm, molecule in enumerate(self._molecules):
Expand Down Expand Up @@ -464,6 +517,15 @@ def print_wnfsym_irreducible_repr(self, group, axis=None, axis2=None, center=Non
output.write(txt)

def plot_mo_diagram(self, group, axis=None, axis2=None, center=None):
"""
Plots Molecular orbitals diagram
:param group:
:param axis:
:param axis2:
:param center:
:return:
"""

for molecule in self._molecules:

Expand Down Expand Up @@ -544,6 +606,15 @@ def plot_sym_energy_evolution(self, group, axis=None, axis2=None, center=None):
plt.show()

def get_shape_measure(self, label, kind, central_atom=0, fix_permutation=False):
"""
Get shape measure
:param label: reference label
:param kind:
:param central_atom: position of the central atom
:param fix_permutation: do not permute atoms during shape calculations
:return: the shape measure
"""
get_measure = 'get_shape_' + kind
return [getattr(molecule.geometry, get_measure)(label, central_atom=central_atom,
fix_permutation=fix_permutation)
Expand Down Expand Up @@ -653,4 +724,9 @@ def print_minimum_distortion_path_shape(self, shape_label1, shape_label2, centra
plt.show()

def get_point_group(self, tol=0.01):
"""
:param tol:
:return:
"""
return [molecule.geometry.get_pointgroup(tol) for molecule in self._molecules]

0 comments on commit 32ddd1b

Please sign in to comment.