Utilities
sym_ops
- API Internal API Internal API Overview Module Organization Utilities
rotation_matrix
rotation_matrix(axis, theta)
Create rotation matrix about an axis by theta in radians.
Parameters:
-
axis–Cartesian vector defining rotation axis, shape(3,).
-
theta–Angle of rotation in radians.
Returns:
-
ndarray–Matrix defining rotation on column vector, shape (3,3).
Source code in molsympy/core/sym_ops.py
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | |
reflection_matrix
reflection_matrix(axis)
Create reflection matrix about a plane defined by its normal vector.
Parameters:
-
axis–Cartesian vector defining the plane normal vector, shape(3,).
Returns:
-
ndarray–Matrix defining reflection on column vector, shape (3,3).
Source code in molsympy/core/sym_ops.py
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | |
inversion_matrix
inversion_matrix()
Create cartesian inversion matrix.
Returns:
-
ndarray–Matrix defining inversion, shape(3,3).
Source code in molsympy/core/sym_ops.py
55 56 57 58 59 60 61 62 63 64 65 | |
Cn
Cn(axis, n)
Wrapper around rotation_matrix for producing a C_n rotation about axis.
Parameters:
-
axis–Cartesian vector defining rotation axis, shape(3,).
-
n–Defines rotation angle by theta = 2 pi / n.
Returns:
-
ndarray–Matrix defining proper rotation on column vector, shape(3,3).
Source code in molsympy/core/sym_ops.py
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | |
Sn
Sn(axis, n)
Improper rotation S_n about an axis.
Parameters:
-
axis–Cartesian vector defining rotation axis, shape(3,).
-
n–Defines rotation angle by theta = 2 pi / n.
Returns:
-
ndarray–Matrix defining improper rotation on column vector, shape (3,3).
Source code in molsympy/core/sym_ops.py
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | |
vec_norm_axis
vec_norm_axis(v)
Compute Euclidean norm (Numba-compatible).
Source code in molsympy/core/sym_ops.py
106 107 108 109 110 | |
vec_norm
vec_norm(v)
Compute Euclidean norm (Numba-compatible).
Source code in molsympy/core/sym_ops.py
112 113 114 115 116 | |
normalize
normalize(a)
Normalize vector a to unit length, return zero vector shape(n, ) if the input vector is of zero length.
Parameters:
-
a–Vector of arbitrary magnitude, shape(n,).
Returns:
-
ndarray–Normalized vector shape(n,) or zero vector shape(n, ) if the magnitude of
ais less than the global tolerance.
Source code in molsympy/core/sym_ops.py
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 | |
float_isclose
float_isclose(a: float, b: float, rtol: float = 1e-05, atol: float = 1e-08) -> bool
Compare two floats (Numba-compatible).
Source code in molsympy/core/sym_ops.py
138 139 140 141 | |
inertia_isclose
inertia_isclose(a: float, b: float, rtol: float = 1e-05, atol: float = 1e-08) -> bool
Compare two inertia (Numba-compatible).
Source code in molsympy/core/sym_ops.py
143 144 145 146 147 148 149 | |
issame_axis
issame_axis(a, b, tol=NUMERICAL_TOL)
Return True if vectors a and b are colinear within the global tolerance.
Paremeters
a: np.ndarray
Vector a, shape(n,).
b: np.ndarray
Vector b, shape(n,).
tol: float
Tolerance for error, default is global_tol.
Returns:
-
bool–True if vectors are collinear, False if not collinear or if either vector has zero length.
Source code in molsympy/core/sym_ops.py
151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 | |
isfactor
isfactor(n, a)
Return True if a divides n.
Parameters:
-
n–Dividend.
-
a–Divisor.
Returns:
-
bool–True if
adividesnwith remainder 0.
Source code in molsympy/core/sym_ops.py
177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 | |
reduce
reduce(n, i)
Divide n and i by their greatest common divisor g.
Parameters:
-
n– -
i–
Returns:
-
tuple–Tuple of n/g and i/g.
Source code in molsympy/core/sym_ops.py
196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 | |
_gcd
_gcd(A, B)
Euclid algorithm for finding the greatest common divisor between A and B.
Parameters:
-
A– -
B–
Returns:
-
int–Greatest common divisor between A and B.
Source code in molsympy/core/sym_ops.py
214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 | |
unique_sorted
unique_sorted(arr)
Return the sorted unique elements of a 1D array.
Parameters:
-
arr(ndarray) –Input 1D array of comparable elements.
Returns:
-
ndarray–Sorted array containing the unique elements of
arr.
Notes
This is a Numba-compatible alternative to np.unique, implemented
using sorting followed by linear duplicate removal.
Equality is tested using exact comparison (!=), so this function
is best suited for integer or discretized floating-point data.
Source code in molsympy/core/sym_ops.py
239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 | |
canonical
canonical(v)
Returns canonical form of vector. Ensures that the first non-zero element is positive.
Parameters:
-
v((ndarray, shape(3))) –Vector to canonicalize
Returns:
-
(ndarray, shape(3))–Canonical vector
Source code in molsympy/core/sym_ops.py
281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 | |
generate_cyclic_axes
generate_cyclic_axes(static_axis: ndarray, saxis: ndarray, n: int, num_elem_generate: int = -1)
Generate a set of axes by rotating a reference axis around a fixed axis.
Parameters:
-
static_axis((ndarray, shape(3))) –Unit vector defining the rotation axis (e.g., principal symmetry axis).
-
saxis((ndarray, shape(3))) –Reference axis to be rotated about
static_axis. -
n(int) –Order of the rotation symmetry (Cn). Defines the angular step 2π/n. If
nis even, it is internally doubled to ensure full coverage of distinct orientations. -
num_elem_generate(int, default:-1) –Number of rotated axes to generate. If <= 0, defaults to
n.
Returns:
-
(ndarray, shape(num_elem_generate, 3))–Array of rotated axes. The first row is
saxis, and subsequent rows are obtained by successive rotations aboutstatic_axis.
Notes
This function is typically used to generate symmetry-equivalent axes (e.g., C2 axes perpendicular to a principal axis in dihedral groups).
Source code in molsympy/core/sym_ops.py
306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 | |
axes_are_orthogonal
axes_are_orthogonal(axes: ndarray, tol: float = NUMERICAL_TOL) -> bool
Return True if axes are all orthogonal to each other.
Source code in molsympy/core/sym_ops.py
391 392 393 394 395 396 397 398 399 400 401 402 | |
constants
Shared numerical constants for the core package.
- API Internal API Internal API Overview Module Organization Utilities
NUMERICAL_TOL
module-attribute
NUMERICAL_TOL: float = 1e-08
IH_C2_C3_ANGLE
module-attribute
IH_C2_C3_ANGLE: float = 0.36486382647383764
Angle (radians) between a C2 axis and the nearest C3 axis in an icosahedron. Derived from the golden ratio phi = (1+sqrt(5))/2: theta = arccos(phi^2 / sqrt(1 + phi^4)) = arctan(1/phi^2) ~= 0.3649 rad ~= 20.9 deg Used in find_point_group to identify the secondary axis for Ih/I molecules.
IH_ANGLE_TOL
module-attribute
IH_ANGLE_TOL: float = 0.0001
Angular tolerance for the IH_C2_C3_ANGLE comparison.