TheoChem-VU / TCutility

Utility functions/classes for the TheoCheM programs
https://theochem-vu.github.io/TCutility/
MIT License
6 stars 0 forks source link

Add geometric parameter function and the new tc geo command #236

Closed YHordijk closed 6 months ago

YHordijk commented 6 months ago

We added the new tc geo command:

usage: tc geo [-h] [-p] xyzfile atom_indices [atom_indices ...]

Calculate geometrical parameters for atoms at the provided indices. For 1 index this program returns the cartesian coordinate for this atom. For 2 indices return bond length
between atoms. For 3 indices return bond angle, with the second index being the central atom. For 4 indices return dihedral angle by calculating the angle between normal
vectors described by atoms at indices 1-2-3 and indices 2-3-4. If the -p/--pyramidal flag is turned on it calculates 360° - ang1 - ang2 - ang3, where ang1, ang2 and ang3 are
the angles described by indices 2-1-3, 3-1-4 and 4-1-2 respectively.

positional arguments:
  xyzfile          The molecule to calculate the parameter for.
  atom_indices     The indices of the atoms to calculate the parameters for. For 1 index return cartesian coordinate. For 2 indices return bond length between atoms. For 3
                   indices return bond angle, with the second index being the central atom. For 4 indices return dihedral angle by calculating the angle between normal vectors
                   described by atoms at indices 1, 2, 3 and indices 2, 3, 4. If the -p/--pyramidal flag is turned on it calculates

options:
  -h, --help       show this help message and exit
  -p, --pyramidal  Instead of calculating dihedral angles, calculate pyramidalisation angle.

Example usage:

>>> tc geo nh3.xyz 1
Coordinate(N1) =  0.000000   0.000000   0.254200 Å
>>> tc geo nh3.xyz 1 2
Distance(N1-H2) =  1.008 Å
>>> tc geo nh3.xyz 2 1 3
Angle(H2-N1-H3) =  109.29°
>>> tc geo nh3.xyz 1 2 3 4
Dihedral(N1-H2-H3-H4) =  35.53°
>>> tc geo nh3.xyz 1 2 3 4 -p
Pyramid(N1-H2-H3-H4) =  32.13°
YHordijk commented 6 months ago

The command line is very nice. There misses a check if the user tries to specify more than 4 identifiers, or less than 1. Can you raise an error if that is the case?

Good suggestion! Now we raise an AssertionError