A matrix where the entry A[i, j, :] is the vector self.cartesian_pos[j] - self.cartesian_pos[i]. For periodic systems the distance of an atom from itself is the smallest displacement of an atom from one of it's periodic copies, and the distance of two different atoms
(self)
| 145 | return cartesian_positions |
| 146 | |
| 147 | def get_displacement_tensor(self): |
| 148 | """A matrix where the entry A[i, j, :] is the vector |
| 149 | self.cartesian_pos[j] - self.cartesian_pos[i]. |
| 150 | |
| 151 | For periodic systems the distance of an atom from itself is the |
| 152 | smallest displacement of an atom from one of it's periodic copies, and |
| 153 | the distance of two different atoms is the distance of two closest |
| 154 | copies. |
| 155 | |
| 156 | Returns: |
| 157 | np.array: 3D matrix containing the pairwise distance vectors. |
| 158 | """ |
| 159 | if self._displacement_tensor is None: |
| 160 | D, D_len = ase.geometry.geometry.get_distances( |
| 161 | self.get_positions(), cell=self.get_cell(), pbc=self.get_pbc() |
| 162 | ) |
| 163 | |
| 164 | # Figure out the smallest basis vector and set it as |
| 165 | # displacement for diagonal |
| 166 | if self.get_pbc().any(): |
| 167 | cell = self.get_cell() |
| 168 | basis_lengths = np.linalg.norm(cell, axis=1) |
| 169 | min_index = np.argmin(basis_lengths) |
| 170 | min_basis = cell[min_index] |
| 171 | diag_indices = np.diag_indices(len(D)) |
| 172 | D[diag_indices] = min_basis |
| 173 | diag_indices = np.diag_indices(len(D_len)) |
| 174 | D_len[diag_indices] = basis_lengths[min_index] |
| 175 | |
| 176 | self._displacement_tensor = D |
| 177 | self._distance_matrix = D_len |
| 178 | |
| 179 | return self._displacement_tensor |
| 180 | |
| 181 | def get_distance_matrix(self): |
| 182 | """Calculates the distance matrix A defined as: |
no outgoing calls