| 1 |
# -*- coding: utf-8 -*- |
| 2 |
# |
| 3 |
# Copyright (c) 2017, the cclib development team |
| 4 |
# |
| 5 |
# This file is part of cclib (http://cclib.github.io) and is distributed under |
| 6 |
# the terms of the BSD 3-Clause License. |
| 7 |
|
| 8 |
"""Functions used across multiple data tests.""" |
| 9 |
|
| 10 |
import itertools |
| 11 |
|
| 12 |
import numpy |
| 13 |
|
| 14 |
|
| 15 |
def get_minimum_carbon_separation(data): |
| 16 |
"""Returns minimum carbon distance for any coordinates. |
| 17 |
|
| 18 |
Note that atomcoords is 3D, and we will take the minimum |
| 19 |
over all coordinates and combinations of carbon atoms. |
| 20 |
""" |
| 21 |
|
| 22 |
icarbons = numpy.arange(data.natom)[data.atomnos == 6] |
| 23 |
mindist = 999 |
| 24 |
for i, j in itertools.combinations(icarbons, 2): |
| 25 |
vectors = data.atomcoords[:, i] - data.atomcoords[:, j] |
| 26 |
distances = numpy.linalg.norm(vectors, axis=1) |
| 27 |
mindist = min(mindist, min(distances)) |
| 28 |
return mindist |