| 1 |
import numpy as np |
| 2 |
import pytest |
| 3 |
|
| 4 |
from pymbd import ang |
| 5 |
from pymbd.fortran import with_mpi, with_scalapack |
| 6 |
|
| 7 |
|
| 8 |
def pytest_collection_modifyitems(config, items): |
| 9 |
if with_scalapack: |
| 10 |
skip = pytest.mark.skip(reason="doesn't support ScaLAPACK") |
| 11 |
for item in items: |
| 12 |
if 'no_scalapack' in item.keywords: |
| 13 |
item.add_marker(skip) |
| 14 |
|
| 15 |
|
| 16 |
if with_mpi: |
| 17 |
from mpi4py import MPI |
| 18 |
|
| 19 |
if with_mpi: |
| 20 |
from functools import wraps |
| 21 |
|
| 22 |
import _pytest._io.terminalwriter |
| 23 |
|
| 24 |
rank = MPI.COMM_WORLD.Get_rank() |
| 25 |
_write_out = _pytest._io.terminalwriter.TerminalWriter.write |
| 26 |
|
| 27 |
@wraps(_write_out) |
| 28 |
def write_wrapper(*args, **kwargs): |
| 29 |
if rank == 0: |
| 30 |
_write_out(*args, **kwargs) |
| 31 |
|
| 32 |
_pytest._io.terminalwriter.TerminalWriter.write = write_wrapper |
| 33 |
|
| 34 |
|
| 35 |
# fmt: off |
| 36 |
@pytest.fixture |
| 37 |
def benzene_dimer(): |
| 38 |
return [ |
| 39 |
(np.array([ |
| 40 |
(-1.047, -1.421, 0.000), (-1.454, -0.855, 1.206), |
| 41 |
(-1.454, -0.855, -1.206), (-2.266, 0.277, 1.206), |
| 42 |
(-2.671, 0.845, 0.000), (-2.266, 0.277, -1.206), |
| 43 |
(-1.133, -1.292, -2.142), (-2.582, 0.716, -2.143), |
| 44 |
(-3.303, 1.723, 0.000), (-2.582, 0.716, 2.143), |
| 45 |
(-1.133, -1.292, 2.142), (-0.406, -2.291, 0.000)]) * ang, |
| 46 |
6 * ['C'] + 6 * ['H'], |
| 47 |
[0.825, 0.821, 0.821, 0.815, 0.814, 0.815, |
| 48 |
0.624, 0.611, 0.610, 0.611, 0.624, 0.643]), |
| 49 |
(np.array([ |
| 50 |
(1.047, 1.421, 0.000), (1.454, 0.855, -1.206), |
| 51 |
(1.454, 0.855, 1.206), (2.266, -0.277, -1.206), |
| 52 |
(2.671, -0.845, 0.000), (2.266, -0.277, 1.206), |
| 53 |
(0.406, 2.291, 0.000), (1.133, 1.292, 2.142), |
| 54 |
(2.582, -0.716, 2.143), (3.303, -1.723, 0.000), |
| 55 |
(2.582, -0.716, -2.143), (1.133, 1.292, -2.142)]) * ang, |
| 56 |
6 * ['C'] + 6 * ['H'], |
| 57 |
[0.825, 0.821, 0.821, 0.815, 0.814, 0.815, |
| 58 |
0.643, 0.624, 0.611, 0.610, 0.611, 0.624])] |
| 59 |
|
| 60 |
|
| 61 |
@pytest.fixture |
| 62 |
def ethylcarbamate(): |
| 63 |
return [ |
| 64 |
(np.array([ |
| 65 |
(4.083, 5.700, 2.856), (0.568, 0.095, 4.217), (0.470, 4.774, 3.551), |
| 66 |
(4.181, 1.022, 3.522), (5.572, 5.587, 1.892), (-0.920, 0.209, 5.181), |
| 67 |
(3.663, 3.255, 2.585), (0.988, 2.541, 4.488), (3.834, 4.011, 0.979), |
| 68 |
(0.816, 1.785, 6.094), (2.223, 1.314, 1.108), (2.428, 4.481, 5.965), |
| 69 |
(1.177, 0.092, 0.406), (3.474, 5.703, 6.667), (4.911, 5.036, 2.573), |
| 70 |
(-0.260, 0.759, 4.500), (4.358, 3.787, 1.918), (0.293, 2.009, 5.155), |
| 71 |
(0.205, 1.729, 1.101), (4.446, 4.067, 5.972), (1.285, 0.947, 0.957), |
| 72 |
(3.366, 4.848, 6.116), (0.485, 2.901, 1.709), (4.165, 2.895, 5.364), |
| 73 |
(4.066, 1.426, 0.670), (0.585, 4.369, 6.403)]) * ang, |
| 74 |
np.array([ |
| 75 |
(5.008, 0.018, -0.070), |
| 76 |
(1.630, 6.759, 0.064), |
| 77 |
(-1.987, -0.981, 7.079)]) * ang, |
| 78 |
(2, 2, 2), |
| 79 |
list('HHHHHHHHHHHHHHCCCCCCNNOOOO'), |
| 80 |
[0.703, 0.703, 0.726, 0.726, 0.731, 0.731, |
| 81 |
0.727, 0.727, 0.754, 0.754, 0.750, 0.750, |
| 82 |
0.755, 0.755, 0.809, 0.809, 0.827, 0.827, |
| 83 |
0.834, 0.834, 0.840, 0.840, 0.886, 0.886, |
| 84 |
0.892, 0.892]), |
| 85 |
(np.array([ |
| 86 |
(4.088, 5.753, 2.783), (5.625, 5.562, 1.906), (3.652, 3.273, 2.592), |
| 87 |
(3.854, 3.998, 0.981), (5.422, 4.834, 3.521), (6.213, 0.125, 0.386), |
| 88 |
(7.201, 1.360, 1.112), (4.913, 5.058, 2.573), (4.366, 3.792, 1.934), |
| 89 |
(5.167, 1.729, 1.084), (6.291, 0.963, 0.938), (4.042, 1.399, 0.752), |
| 90 |
(5.490, 2.915, 1.682)]) * ang, |
| 91 |
None, |
| 92 |
None, |
| 93 |
list('HHHHHHHCCCNOO'), |
| 94 |
[0.581, 0.607, 0.642, 0.646, 0.607, 0.596, |
| 95 |
0.597, 0.762, 0.799, 0.845, 0.824, 0.974, |
| 96 |
0.896]), |
| 97 |
] |
| 98 |
|
| 99 |
|
| 100 |
@pytest.fixture |
| 101 |
def argon_crystal(): |
| 102 |
return ( |
| 103 |
np.array([(0.3, 0.1, 0.2), (4.1, -0.2, -0.1)]) * ang, |
| 104 |
np.array([(8.1, 0.1, -0.2), (0.3, 3.9, -0.1), (-0.1, 0.2, 4.2)]) * ang, |
| 105 |
(4, 4, 4), |
| 106 |
['Ar', 'Ar'], |
| 107 |
[1.0, 1.0], |
| 108 |
) |
| 109 |
|
| 110 |
|
| 111 |
@pytest.fixture |
| 112 |
def peptide_meoh(): |
| 113 |
return [ |
| 114 |
(np.array([ |
| 115 |
(2.137, 0.252, 0.453), (2.857, 0.879, 0.544), |
| 116 |
(2.656, -1.053, 0.687), (1.823, -1.742, 0.582), |
| 117 |
(3.422, -1.322, -0.039), (3.064, -1.154, 1.693)]) * ang, |
| 118 |
list('OHCHHH'), |
| 119 |
[0.9114, 0.5960, 0.7523, 0.5886, 0.5850, 0.5850]), |
| 120 |
(np.array([ |
| 121 |
(-0.849, -0.339, 2.491), (0.184, -0.011, 2.416), |
| 122 |
(-0.882, -1.342, 2.912), (-1.390, 0.316, 3.168), |
| 123 |
(-1.564, -0.353, 1.159), (-2.749, -0.651, 1.056), |
| 124 |
(-0.801, -0.027, 0.088), (0.161, 0.240, 0.218), |
| 125 |
(-1.385, -0.002, -1.234), (-1.891, -0.942, -1.440), |
| 126 |
(-2.119, 0.796, -1.330), (-0.594, 0.149, -1.963)]) * ang, |
| 127 |
list('CHHHCONHCHHH'), |
| 128 |
[0.7657, 0.6027, 0.6062, 0.6077, 0.8343, 0.9815, |
| 129 |
0.8325, 0.5931, 0.7592, 0.6286, 0.6133, 0.5698]), |
| 130 |
(np.array([ |
| 131 |
(-0.849, -0.339, 2.491), (0.184, -0.011, 2.416), |
| 132 |
(-0.882, -1.342, 2.912), (-1.390, 0.316, 3.168), |
| 133 |
(-1.564, -0.353, 1.159), (-2.749, -0.651, 1.056), |
| 134 |
(-0.801, -0.027, 0.088), (0.161, 0.240, 0.218), |
| 135 |
(-1.385, -0.002, -1.234), (-1.891, -0.942, -1.440), |
| 136 |
(-2.119, 0.796, -1.330), (-0.594, 0.149, -1.963), |
| 137 |
(2.137, 0.252, 0.453), (2.857, 0.879, 0.544), |
| 138 |
(2.656, -1.053, 0.687), (1.823, -1.742, 0.582), |
| 139 |
(3.422, -1.322, -0.039), (3.064, -1.154, 1.693)]) * ang, |
| 140 |
list('CHHHCONHCHHHOHCHHH'), |
| 141 |
[0.7767, 0.6594, 0.6193, 0.6167, 0.8414, 0.9898, |
| 142 |
0.8462, 0.7213, 0.7668, 0.6367, 0.6211, 0.5915, |
| 143 |
0.8615, 0.5511, 0.7415, 0.6022, 0.5701, 0.5759]) |
| 144 |
] |
| 145 |
|
| 146 |
|
| 147 |
@pytest.fixture |
| 148 |
def bulk_lithium(): |
| 149 |
return ( |
| 150 |
np.array([(0.0, 0.0, 0.0)]) * ang, |
| 151 |
np.array([ |
| 152 |
(-1.7385, 1.7385, 1.7385), (1.7385, -1.7385, 1.7385), |
| 153 |
(1.7385, 1.7385, -1.7385)]) * ang, |
| 154 |
(4, 4, 4), |
| 155 |
['Li'], |
| 156 |
[1.0], |
| 157 |
) |