1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 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 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 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 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319
|
# flake8: noqa
"""Check that reading multi image .con files is consistent."""
import os
from numpy import array
import ase
import ase.io
# Error tolerance.
TOL = 1e-6
# A correct .con file.
CON_FILE = """\
0 Random Number Seed
0 Time
8.123222 5.744000 9.747867
90.000000 90.000000 90.000000
0 0
0 0 0
1
17
51.996100
Cr
Coordinates of Component 1
1.01540277999999962 0.71799999999999997 1.01540277999999984 1 0
3.04620834000000063 2.15399999999999991 1.01540277999999984 1 1
3.04620834000000063 0.71799999999999997 3.04620834000000196 1 2
1.01540277999999962 2.15399999999999991 3.04620834000000196 1 3
1.01540277999999962 3.58999999999999986 1.01540277999999984 1 4
3.04620834000000063 5.02599999999999980 1.01540277999999984 1 5
3.04620834000000063 3.58999999999999986 3.04620834000000196 1 6
1.01540277999999962 5.02599999999999980 3.04620834000000196 1 7
5.07701389999999986 0.71799999999999997 1.01540277999999984 1 8
7.10781945999998488 2.15399999999999991 1.01540277999999984 1 9
7.10781945999998488 0.71799999999999997 3.04620834000000196 1 10
5.07701389999999986 2.15399999999999991 3.04620834000000196 1 11
5.07701389999999986 3.58999999999999986 1.01540277999999984 1 12
7.10781945999998488 5.02599999999999980 1.01540277999999984 1 13
7.10781945999998488 3.58999999999999986 3.04620834000000196 1 14
5.07701389999999986 5.02599999999999980 3.04620834000000196 1 15
3.04618285858587523 2.15398224021542450 4.60622193000079427 0 16
0 Random Number Seed
0 Time
8.123222 5.744000 9.747867
90.000000 90.000000 90.000000
0 0
0 0 0
1
17
51.996100
Cr
Coordinates of Component 1
1.01540277999999962 0.71799999999999997 1.01540277999999984 1 0
3.04620834000000063 2.15399999999999991 1.01540277999999984 1 1
3.04620834000000063 0.71799999999999997 3.04620834000000196 1 2
1.01540277999999962 2.15399999999999991 3.04620834000000196 1 3
1.01540277999999962 3.58999999999999986 1.01540277999999984 1 4
3.04620834000000063 5.02599999999999980 1.01540277999999984 1 5
3.04620834000000063 3.58999999999999986 3.04620834000000196 1 6
1.01540277999999962 5.02599999999999980 3.04620834000000196 1 7
5.07701389999999986 0.71799999999999997 1.01540277999999984 1 8
7.10781945999998488 2.15399999999999991 1.01540277999999984 1 9
7.10781945999998488 0.71799999999999997 3.04620834000000196 1 10
5.07701389999999986 2.15399999999999991 3.04620834000000196 1 11
5.07701389999999986 3.58999999999999986 1.01540277999999984 1 12
7.10781945999998488 5.02599999999999980 1.01540277999999984 1 13
7.10781945999998488 3.58999999999999986 3.04620834000000196 1 14
5.07701389999999986 5.02599999999999980 3.04620834000000196 1 15
3.36369427985916092 2.20887986058760699 4.61557342394151693 0 16
0 Random Number Seed
0 Time
8.123222 5.744000 9.747867
90.000000 90.000000 90.000000
0 0
0 0 0
1
17
51.996100
Cr
Coordinates of Component 1
1.01540277999999962 0.71799999999999997 1.01540277999999984 1 0
3.04620834000000063 2.15399999999999991 1.01540277999999984 1 1
3.04620834000000063 0.71799999999999997 3.04620834000000196 1 2
1.01540277999999962 2.15399999999999991 3.04620834000000196 1 3
1.01540277999999962 3.58999999999999986 1.01540277999999984 1 4
3.04620834000000063 5.02599999999999980 1.01540277999999984 1 5
3.04620834000000063 3.58999999999999986 3.04620834000000196 1 6
1.01540277999999962 5.02599999999999980 3.04620834000000196 1 7
5.07701389999999986 0.71799999999999997 1.01540277999999984 1 8
7.10781945999998488 2.15399999999999991 1.01540277999999984 1 9
7.10781945999998488 0.71799999999999997 3.04620834000000196 1 10
5.07701389999999986 2.15399999999999991 3.04620834000000196 1 11
5.07701389999999986 3.58999999999999986 1.01540277999999984 1 12
7.10781945999998488 5.02599999999999980 1.01540277999999984 1 13
7.10781945999998488 3.58999999999999986 3.04620834000000196 1 14
5.07701389999999986 5.02599999999999980 3.04620834000000196 1 15
3.62116697589668135 2.40183843231018113 4.63674682635805180 0 16
0 Random Number Seed
0 Time
8.123222 5.744000 9.747867
90.000000 90.000000 90.000000
0 0
0 0 0
1
17
51.996100
Cr
Coordinates of Component 1
1.01540277999999962 0.71799999999999997 1.01540277999999984 1 0
3.04620834000000063 2.15399999999999991 1.01540277999999984 1 1
3.04620834000000063 0.71799999999999997 3.04620834000000196 1 2
1.01540277999999962 2.15399999999999991 3.04620834000000196 1 3
1.01540277999999962 3.58999999999999986 1.01540277999999984 1 4
3.04620834000000063 5.02599999999999980 1.01540277999999984 1 5
3.04620834000000063 3.58999999999999986 3.04620834000000196 1 6
1.01540277999999962 5.02599999999999980 3.04620834000000196 1 7
5.07701389999999986 0.71799999999999997 1.01540277999999984 1 8
7.10781945999998488 2.15399999999999991 1.01540277999999984 1 9
7.10781945999998488 0.71799999999999997 3.04620834000000196 1 10
5.07701389999999986 2.15399999999999991 3.04620834000000196 1 11
5.07701389999999986 3.58999999999999986 1.01540277999999984 1 12
7.10781945999998488 5.02599999999999980 1.01540277999999984 1 13
7.10781945999998488 3.58999999999999986 3.04620834000000196 1 14
5.07701389999999986 5.02599999999999980 3.04620834000000196 1 15
3.83933949582109157 2.63825709178043821 4.65669727965894875 0 16
0 Random Number Seed
0 Time
8.123222 5.744000 9.747867
90.000000 90.000000 90.000000
0 0
0 0 0
1
17
51.996100
Cr
Coordinates of Component 1
1.01540277999999962 0.71799999999999997 1.01540277999999984 1 0
3.04620834000000063 2.15399999999999991 1.01540277999999984 1 1
3.04620834000000063 0.71799999999999997 3.04620834000000196 1 2
1.01540277999999962 2.15399999999999991 3.04620834000000196 1 3
1.01540277999999962 3.58999999999999986 1.01540277999999984 1 4
3.04620834000000063 5.02599999999999980 1.01540277999999984 1 5
3.04620834000000063 3.58999999999999986 3.04620834000000196 1 6
1.01540277999999962 5.02599999999999980 3.04620834000000196 1 7
5.07701389999999986 0.71799999999999997 1.01540277999999984 1 8
7.10781945999998488 2.15399999999999991 1.01540277999999984 1 9
7.10781945999998488 0.71799999999999997 3.04620834000000196 1 10
5.07701389999999986 2.15399999999999991 3.04620834000000196 1 11
5.07701389999999986 3.58999999999999986 1.01540277999999984 1 12
7.10781945999998488 5.02599999999999980 1.01540277999999984 1 13
7.10781945999998488 3.58999999999999986 3.04620834000000196 1 14
5.07701389999999986 5.02599999999999980 3.04620834000000196 1 15
4.06162234392075128 2.87141228075409316 4.66819033729618926 0 16
0 Random Number Seed
0 Time
8.123222 5.744000 9.747867
90.000000 90.000000 90.000000
0 0
0 0 0
1
17
51.996100
Cr
Coordinates of Component 1
1.01540277999999962 0.71799999999999997 1.01540277999999984 1 0
3.04620834000000063 2.15399999999999991 1.01540277999999984 1 1
3.04620834000000063 0.71799999999999997 3.04620834000000196 1 2
1.01540277999999962 2.15399999999999991 3.04620834000000196 1 3
1.01540277999999962 3.58999999999999986 1.01540277999999984 1 4
3.04620834000000063 5.02599999999999980 1.01540277999999984 1 5
3.04620834000000063 3.58999999999999986 3.04620834000000196 1 6
1.01540277999999962 5.02599999999999980 3.04620834000000196 1 7
5.07701389999999986 0.71799999999999997 1.01540277999999984 1 8
7.10781945999998488 2.15399999999999991 1.01540277999999984 1 9
7.10781945999998488 0.71799999999999997 3.04620834000000196 1 10
5.07701389999999986 2.15399999999999991 3.04620834000000196 1 11
5.07701389999999986 3.58999999999999986 1.01540277999999984 1 12
7.10781945999998488 5.02599999999999980 1.01540277999999984 1 13
7.10781945999998488 3.58999999999999986 3.04620834000000196 1 14
5.07701389999999986 5.02599999999999980 3.04620834000000196 1 15
4.28380999862949441 3.10482201783771883 4.65660558580467221 0 16
0 Random Number Seed
0 Time
8.123222 5.744000 9.747867
90.000000 90.000000 90.000000
0 0
0 0 0
1
17
51.996100
Cr
Coordinates of Component 1
1.01540277999999962 0.71799999999999997 1.01540277999999984 1 0
3.04620834000000063 2.15399999999999991 1.01540277999999984 1 1
3.04620834000000063 0.71799999999999997 3.04620834000000196 1 2
1.01540277999999962 2.15399999999999991 3.04620834000000196 1 3
1.01540277999999962 3.58999999999999986 1.01540277999999984 1 4
3.04620834000000063 5.02599999999999980 1.01540277999999984 1 5
3.04620834000000063 3.58999999999999986 3.04620834000000196 1 6
1.01540277999999962 5.02599999999999980 3.04620834000000196 1 7
5.07701389999999986 0.71799999999999997 1.01540277999999984 1 8
7.10781945999998488 2.15399999999999991 1.01540277999999984 1 9
7.10781945999998488 0.71799999999999997 3.04620834000000196 1 10
5.07701389999999986 2.15399999999999991 3.04620834000000196 1 11
5.07701389999999986 3.58999999999999986 1.01540277999999984 1 12
7.10781945999998488 5.02599999999999980 1.01540277999999984 1 13
7.10781945999998488 3.58999999999999986 3.04620834000000196 1 14
5.07701389999999986 5.02599999999999980 3.04620834000000196 1 15
4.50188452903429326 3.34154720502221236 4.63664894132718874 0 16
0 Random Number Seed
0 Time
8.123222 5.744000 9.747867
90.000000 90.000000 90.000000
0 0
0 0 0
1
17
51.996100
Cr
Coordinates of Component 1
1.01540277999999962 0.71799999999999997 1.01540277999999984 1 0
3.04620834000000063 2.15399999999999991 1.01540277999999984 1 1
3.04620834000000063 0.71799999999999997 3.04620834000000196 1 2
1.01540277999999962 2.15399999999999991 3.04620834000000196 1 3
1.01540277999999962 3.58999999999999986 1.01540277999999984 1 4
3.04620834000000063 5.02599999999999980 1.01540277999999984 1 5
3.04620834000000063 3.58999999999999986 3.04620834000000196 1 6
1.01540277999999962 5.02599999999999980 3.04620834000000196 1 7
5.07701389999999986 0.71799999999999997 1.01540277999999984 1 8
7.10781945999998488 2.15399999999999991 1.01540277999999984 1 9
7.10781945999998488 0.71799999999999997 3.04620834000000196 1 10
5.07701389999999986 2.15399999999999991 3.04620834000000196 1 11
5.07701389999999986 3.58999999999999986 1.01540277999999984 1 12
7.10781945999998488 5.02599999999999980 1.01540277999999984 1 13
7.10781945999998488 3.58999999999999986 3.04620834000000196 1 14
5.07701389999999986 5.02599999999999980 3.04620834000000196 1 15
4.75928919917819293 3.53496190773495211 4.61566200013953409 0 16
0 Random Number Seed
0 Time
8.123222 5.744000 9.747867
90.000000 90.000000 90.000000
0 0
0 0 0
1
17
51.996100
Cr
Coordinates of Component 1
1.01540277999999962 0.71799999999999997 1.01540277999999984 1 0
3.04620834000000063 2.15399999999999991 1.01540277999999984 1 1
3.04620834000000063 0.71799999999999997 3.04620834000000196 1 2
1.01540277999999962 2.15399999999999991 3.04620834000000196 1 3
1.01540277999999962 3.58999999999999986 1.01540277999999984 1 4
3.04620834000000063 5.02599999999999980 1.01540277999999984 1 5
3.04620834000000063 3.58999999999999986 3.04620834000000196 1 6
1.01540277999999962 5.02599999999999980 3.04620834000000196 1 7
5.07701389999999986 0.71799999999999997 1.01540277999999984 1 8
7.10781945999998488 2.15399999999999991 1.01540277999999984 1 9
7.10781945999998488 0.71799999999999997 3.04620834000000196 1 10
5.07701389999999986 2.15399999999999991 3.04620834000000196 1 11
5.07701389999999986 3.58999999999999986 1.01540277999999984 1 12
7.10781945999998488 5.02599999999999980 1.01540277999999984 1 13
7.10781945999998488 3.58999999999999986 3.04620834000000196 1 14
5.07701389999999986 5.02599999999999980 3.04620834000000196 1 15
5.07701160164306042 3.58998956883621734 4.60626159988447537 0 16
"""
# The corresponding data for the second to last image as an ASE Atoms object.
data = ase.Atoms('Cr17',cell = array([[8.123222, 0, 0],
[0, 5.744000, 0],
[0, 0, 9.747867]]),
positions = array([ [1.01540277999999962, 0.71799999999999997, 1.01540277999999984],
[3.04620834000000063, 2.15399999999999991, 1.01540277999999984],
[3.04620834000000063, 0.71799999999999997, 3.04620834000000196],
[1.01540277999999962, 2.15399999999999991, 3.04620834000000196],
[1.01540277999999962, 3.58999999999999986, 1.01540277999999984],
[3.04620834000000063, 5.02599999999999980, 1.01540277999999984],
[3.04620834000000063, 3.58999999999999986, 3.04620834000000196],
[1.01540277999999962, 5.02599999999999980, 3.04620834000000196],
[5.07701389999999986, 0.71799999999999997, 1.01540277999999984],
[7.10781945999998488, 2.15399999999999991, 1.01540277999999984],
[7.10781945999998488, 0.71799999999999997, 3.04620834000000196],
[5.07701389999999986, 2.15399999999999991, 3.04620834000000196],
[5.07701389999999986, 3.58999999999999986, 1.01540277999999984],
[7.10781945999998488, 5.02599999999999980, 1.01540277999999984],
[7.10781945999998488, 3.58999999999999986, 3.04620834000000196],
[5.07701389999999986, 5.02599999999999980, 3.04620834000000196],
[4.75928919917819293, 3.53496190773495211, 4.61566200013953409]]),
pbc=(True, True, True))
def test_eon():
# First, write a correct .con file and try to read it.
con_file = 'neb.con'
with open(con_file, 'w') as f:
f.write(CON_FILE)
images = ase.io.read(con_file, format='eon', index =':')
box = images[-2]
# Check cell vectors.
assert (abs(box.cell - data.cell)).sum() < TOL # read: cell vector check
# Check atom positions.
# read: position check
assert (abs(box.positions - data.positions)).sum() < TOL
# Now that we know that reading a .con file works, we will write
# one and read it back in.
out_file = 'out.con'
ase.io.write(out_file, data, format='eon')
data2 = ase.io.read(out_file, format='eon')
# Check cell vectors.
# write: cell vector check
assert (abs(data2.cell - data.cell)).sum() < TOL
# Check atom positions.
# write: position check
assert (abs(data2.positions - data.positions)).sum() < TOL
|