Skip to content

Commit

Permalink
electronic structure class now can set restricted occupancies via a n…
Browse files Browse the repository at this point in the history
…ew method

added a few api examples for shape and symmetry
updated unittest files in order to erase old methods
  • Loading branch information
efrembernuz committed Oct 21, 2020
1 parent a6031ad commit f148851
Show file tree
Hide file tree
Showing 8 changed files with 365 additions and 23 deletions.
1 change: 1 addition & 0 deletions cosymlib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@ def print_electronic_density_measure(self, group, axis=None, axis2=None, center=
txt2 += 'axis : ' + ' '.join(['{:12.8f}'.format(s) for s in axes_information['axis']])
txt2 += '\n'
txt2 += 'axis2 : ' + ' '.join(['{:12.8f}'.format(s) for s in axes_information['axis2']])
txt2 += '\n'

txt += '\n' + txt2

Expand Down
8 changes: 5 additions & 3 deletions cosymlib/molecule/electronic_structure/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,12 @@ def __init__(self,
for i in range(self._multiplicity-1):
self._beta_occupancy.append(0)

def set_alpha_occupancy(self, occupancy, restricted=False):
def set_occupancy(self, occupancy):
self.set_alpha_occupancy(occupancy)
self.set_beta_occupancy(occupancy)

def set_alpha_occupancy(self, occupancy):
self._alpha_occupancy = occupancy
if restricted:
self.set_beta_occupancy(occupancy)

def set_beta_occupancy(self, occupancy):
self._beta_occupancy = occupancy
Expand Down
130 changes: 130 additions & 0 deletions examples/Symgroup/ethane.xyz
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
8
0
6 0.000000 0.000000 0.000000
6 0.000000 0.000000 1.549348
1 1.024510 0.000000 -0.409437
1 -0.509263 -0.888972 -0.409437
1 -0.518222 0.883780 -0.409437
1 -0.512255 0.887252 1.958785
1 -0.515241 -0.885521 1.958785
1 1.024487 -0.006903 1.958785
8
5
6 0.000000 0.000000 0.000000
6 0.000000 0.000000 1.549683
1 1.024435 0.000000 -0.409551
1 -0.512124 -0.887240 -0.409551
1 -0.512403 0.887079 -0.409551
1 -0.587591 0.839168 1.959233
1 -0.433042 -0.928408 1.959233
1 1.020555 0.089071 1.959233
8
10
6 0.000000 0.000000 0.000000
6 0.000000 0.000000 1.549468
1 1.024512 0.000000 -0.409408
1 -0.515081 -0.885616 -0.409408
1 -0.506590 0.890501 -0.409408
1 -0.658544 0.784822 1.958876
1 -0.347334 -0.963838 1.958876
1 1.007793 0.184333 1.958876
8
15
6 0.000000 0.000000 0.000000
6 0.000000 0.000000 1.548699
1 1.024727 0.000000 -0.409032
1 -0.517836 -0.884257 -0.409032
1 -0.501359 0.893703 -0.409032
1 -0.724592 0.724592 1.957730
1 -0.259099 -0.991430 1.957730
1 0.986458 0.277429 1.957730
8
20
6 0.000000 0.000000 0.000000
6 0.000000 0.000000 1.547466
1 1.025065 0.000000 -0.408436
1 -0.520176 -0.883275 -0.408436
1 -0.497132 0.896447 -0.408436
1 -0.785245 0.658899 1.955901
1 -0.169281 -1.010991 1.955901
1 0.957050 0.367168 1.955901
8
25
6 0.000000 0.000000 0.000000
6 0.000000 0.000000 1.545937
1 1.025506 0.000000 -0.407643
1 -0.522043 -0.882685 -0.407643
1 -0.494004 0.898678 -0.407643
1 -0.840045 0.588206 1.953580
1 -0.078655 -1.022485 1.953580
1 0.920125 0.452805 1.953580
8
30
6 0.000000 0.000000 0.000000
6 0.000000 0.000000 1.544261
1 1.026016 0.000000 -0.406701
1 -0.523300 -0.882534 -0.406701
1 -0.492218 0.900239 -0.406701
1 -0.888556 0.513008 1.950962
1 0.011924 -1.025947 1.950962
1 0.876393 0.533521 1.950962
8
35
6 0.000000 0.000000 0.000000
6 0.000000 0.000000 1.542558
1 1.026550 0.000000 -0.405705
1 -0.523790 -0.882864 -0.405705
1 -0.492030 0.900950 -0.405705
1 -0.930370 0.433839 1.948263
1 0.101600 -1.021510 1.948263
1 0.826689 0.608597 1.948263
8
40
6 0.000000 0.000000 0.000000
6 0.000000 0.000000 1.540938
1 1.027066 0.000000 -0.404741
1 -0.523565 -0.883597 -0.404741
1 -0.493272 0.900859 -0.404741
1 -0.965126 0.351277 1.945679
1 0.189783 -1.009380 1.945679
1 0.771636 0.677822 1.945679
8
45
6 0.000000 0.000000 0.000000
6 0.000000 0.000000 1.539493
1 1.027537 0.000000 -0.403854
1 -0.522699 -0.884657 -0.403854
1 -0.495753 0.900035 -0.403854
1 -0.992525 0.265946 1.943347
1 0.275922 -0.989798 1.943347
1 0.711807 0.741056 1.943347
8
50
6 0.000000 0.000000 0.000000
6 0.000000 0.000000 1.538318
1 1.027936 0.000000 -0.403091
1 -0.521157 -0.886029 -0.403091
1 -0.499489 0.898423 -0.403091
1 -1.012319 0.178499 1.941409
1 0.359382 -0.963066 1.941409
1 0.647910 0.798038 1.941409
8
55
6 0.000000 0.000000 0.000000
6 0.000000 0.000000 1.537462
1 1.028238 0.000000 -0.402506
1 -0.519171 -0.887544 -0.402506
1 -0.503964 0.896266 -0.402506
1 -1.024325 0.089617 1.939969
1 0.439841 -0.929415 1.939969
1 0.580161 0.848932 1.939969
8
60
6 0.000000 0.000000 0.000000
6 0.000000 0.000000 1.536946
1 1.028425 0.000000 -0.402134
1 -0.516804 -0.889141 -0.402134
1 -0.509017 0.893621 -0.402134
1 -1.028425 0.000000 1.939080
1 0.516804 -0.889141 1.939080
1 0.509017 0.893621 1.939080
19 changes: 19 additions & 0 deletions examples/Symgroup/multiple_symmetry.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# This tutorial will show you how to handle a shape measure with lots of structures and later on their plot in what we
# call shape maps.
# Import part
from cosymlib.file_io import get_geometry_from_file_xyz, read_generic_structure_file
from cosymlib import Cosymlib

# This example will show the user how to perform a symmetry calculation on the ethane conformation path between
# the eclipsed and the staggered forms. The first thing to do is to read the xyz file that contains the molecules and
# creates one or multiple Geometry objects which will storage all the structural information

structures = get_geometry_from_file_xyz('../Symgroup/ethane.xyz', read_multiple=True)

# Now we are going to create a Cosymlib object with all these Geometry objects to simplify the printing process

structure_set = Cosymlib(structures)

# Finally, it is as simple as call one of the print functions inside Cosymlib class

structure_set.print_geometric_symmetry_measure('i')
117 changes: 117 additions & 0 deletions examples/shape/crn6.xyz
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
7
crhs_00
24 0.000000 0.000000 0.000000
7 1.416275 -1.908957 0.000000
7 -1.416275 -1.908746 0.000000
7 1.416275 0.922765 1.598276
7 -1.416275 0.922655 1.598086
7 1.416275 1.052185 -1.822437
7 -1.416275 1.052120 -1.822326
7
crhs_05
24 0.000000 0.000000 0.000000
7 1.413259 -1.840215 0.000000
7 -1.413259 -1.887380 0.165125
7 1.413259 0.947617 1.641320
7 -1.413259 1.055566 1.507504
7 1.413259 1.053774 -1.825190
7 -1.413259 0.890797 -1.910320
7
crhs_10
24 0.000000 0.000000 0.000000
7 1.404683 -2.100818 0.000000
7 -1.404683 -2.069937 0.364986
7 1.404683 0.901229 1.560975
7 -1.404683 1.218657 1.452339
7 1.404683 0.948314 -1.642528
7 -1.404683 0.616763 -1.694542
7
crhs_15
24 0.000000 0.000000 0.000000
7 1.391634 -1.889149 0.000000
7 -1.391634 -1.711895 0.458701
7 1.391634 1.040952 1.802982
7 -1.391634 1.472290 1.472289
7 1.391634 0.885430 -1.533610
7 -1.391634 0.488445 -1.822903
7
crhs_20
24 0.000000 0.000000 0.000000
7 1.374597 -2.028172 0.000000
7 -1.374597 -1.773858 0.645632
7 1.374597 0.944141 1.635301
7 -1.374597 1.554311 1.304221
7 1.374597 0.882434 -1.528421
7 -1.374597 0.306475 -1.738105
7
crhs_25
24 0.000000 0.000000 0.000000
7 1.354331 -1.735507 0.000000
7 -1.354331 -1.705775 0.795416
7 1.354331 0.939653 1.627528
7 -1.354331 1.421520 0.995359
7 1.354331 1.011192 -1.751436
7 -1.354331 0.176046 -2.012213
7
crhs_30
24 0.000000 0.000000 0.000000
7 1.328088 -1.814846 0.000000
7 -1.328088 -1.763298 1.018041
7 1.328087 0.885359 1.533487
7 -1.328088 1.532114 0.884566
7 1.328088 1.018976 -1.764918
7 -1.328088 0.000000 -1.818042
7
crhs_35
24 0.000000 0.000000 0.000000
7 1.297653 -1.796152 0.000000
7 -1.297652 -1.674547 1.172531
7 1.297652 0.893537 1.547652
7 -1.297652 1.621065 0.755915
7 1.297653 1.022138 -1.770395
7 -1.297653 -0.156406 -1.787726
7
crhs_40
24 0.000000 0.000000 0.000000
7 1.261198 -1.814356 0.000000
7 -1.261198 -1.390983 1.167174
7 1.261197 1.028859 1.782037
7 -1.261198 1.673314 0.609037
7 1.261198 0.891580 -1.544261
7 -1.261198 -0.357202 -2.025792
7
crhs_45
24 0.000000 0.000000 0.000000
7 1.218056 -1.847766 0.000000
7 -1.218056 -1.303856 1.303856
7 1.218056 1.035335 1.793252
7 -1.218056 1.722614 0.461573
7 1.218056 0.889508 -1.540673
7 -1.218056 -0.536264 -2.001363
7
crhs_50
24 0.000000 0.000000 0.000000
7 1.166902 -1.785799 0.000000
7 -1.166902 -1.345356 1.603333
7 1.166902 0.941238 1.630271
7 -1.166902 1.847867 0.325829
7 1.166902 1.046435 -1.812478
7 -1.166902 -0.611319 -1.679583
7
crhs_55
24 0.000000 0.000000 0.000000
7 1.159771 -1.752041 0.000000
7 -1.159771 -1.002962 1.432379
7 1.159771 0.876012 1.517297
7 -1.159771 1.743547 0.152540
7 1.159771 0.874444 -1.514581
7 -1.159771 -0.740312 -1.587604
7
crhs_60
24 0.000000 0.000000 0.000000
7 1.113410 -1.771131 0.000000
7 -1.113410 -0.879658 1.523612
7 1.113410 0.881670 1.527096
7 -1.113410 1.763543 0.000000
7 1.113410 0.879718 -1.523717
7 -1.113410 -0.885590 -1.533886
31 changes: 31 additions & 0 deletions examples/shape/easy_measure.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# This tutorial will show you how to handle a simple shape measure using a python script. It will not cover the
# reading and wrinting file which is explined in detail in the ----
# Import part:
from cosymlib import Geometry

# In this case we got a fac-[FeCl3Br3]3- slightly distorted from his octahedral shape and we want to know how distorted
# it is with continious shape measure. As we are analyzing shapes and not symmetry, we can avoid chemical part
# (elements and electronic structure).

structure = [[-0.000250, -0.000142, -0.002855],
[ 2.028556, 0.001959, 1.468881],
[-1.015070, -1.758645, 1.467680],
[-1.016235, 1.757020, 1.467903],
[-2.158748, 0.000226, -1.487093],
[ 1.079740, 1.869427, -1.486814],
[ 1.082006, -1.869845, -1.484507]]
symbols = ['Fe', 'Cl', 'Cl', 'Cl', 'Br', 'Br', 'Br']

# The first thing we should do is to create a Geometry or Molecule object. As stated before, as we do not need the
# chemical part, the geometry should be our choice, as it only focus on the structural part.
# The Geometry class, only needs the position of the atoms in order to be created.

fecl3br3 = Geometry(structure, symbols=symbols)

# Now, different approaches can be performed, but as this tutorial try to be as simple as possible, the most striaght
# approach is to just call for the shape measure within the Geometry class. Shape only requires an ideal or a user's
# reference structure for the comparison with the case structure. However, as this molecule has a central atom (Fe3+),
# it is a must to include this information in the function call.

measure = fecl3br3.get_shape_measure('OC-6', central_atom=1)
print('Oh measure: {:.2f}'.format(measure))
29 changes: 29 additions & 0 deletions examples/shape/shape_maps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# This tutorial will show you how to handle a shape measure with lots of structures and later on their plot in what we
# call shape maps.
# Import part
from cosymlib.file_io import get_geometry_from_file_xyz, read_generic_structure_file
from cosymlib import Cosymlib

# In this case we got a scan of the dihedral angle of CrN6 molecule. The Oh and D3h shapes are going to be measure
# to analyse the path of the molecule along both shapes. In this case the structures will be read from an xyz file
# containing all the geometries along the path. This can be done in two ways, using the get_geometry_from_file_xyz
# function, which is specific for the xyz files or a more generic one, the read_generic_structure_file, that allows
# the user to read any kind of file supported by this program. In both cases we must change read_multiple to True,
# if not the function will only read the first structure in file

# structures = read_generic_structure_file('crn6.xyz', read_multiple=True)
structures = get_geometry_from_file_xyz('crn6.xyz', read_multiple=True)

# Creating shape maps is something that can be tedious to both new and veteran users. To avoid such task one can use the
# Cosymlib class, a class that allows the user to print all possible information that the program contains in a fancy
# format and also permits to plot shape maps more user friendly.

structure_set = Cosymlib(structures)

# Once a Cosymlib object is easy to print all the information in one map using the following function.

structure_set.print_minimum_distortion_path_shape('OC-6',
'TPR-6',
central_atom=1,
max_dev=30,
max_gco=105)

0 comments on commit f148851

Please sign in to comment.