-
Notifications
You must be signed in to change notification settings - Fork 8
/
atoms.py
1356 lines (1194 loc) · 47.1 KB
/
atoms.py
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
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
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
"""For parsing and storing atom information"""
import json
import os
import re
import numpy as np
from AaronTools import addlogger
from AaronTools.const import (
CONNECTIVITY,
EIJ,
ELEMENTS,
MASS,
RADII,
RIJ,
SATURATION,
TMETAL,
VDW_RADII,
COLORS,
)
warn_LJ = set([])
copying_times = {}
class BondOrder:
bonds = {}
warn_atoms = set([])
warn_str = (
"\n"
+ " Could not get bond order for: "
+ " {} {}"
+ " using bond order of 1"
)
# warn(s.format(a1.element, a2.element))
def __init__(self):
if BondOrder.bonds:
return
with open(
os.path.join(
os.path.dirname(__file__), "calculated_bond_lengths.json"
)
) as f:
BondOrder.bonds = json.load(f)
@classmethod
def key(cls, a1, a2):
if isinstance(a1, Atom):
a1 = a1.element
if isinstance(a2, Atom):
a2 = a2.element
return " ".join(sorted([a1, a2]))
@classmethod
def get(cls, a1, a2, dist=None):
"""determines bond order between two atoms based on bond length"""
try:
bonds = cls.bonds[cls.key(a1, a2)]
except KeyError:
if a1.element == "H" or a2.element == "H":
return 1
else:
BondOrder.warn_atoms.add((a1.element, a2.element))
return 1
if dist is None:
dist = a1.dist(a2)
closest = 0, None # (bond order, length diff)
for order, length in bonds.items():
diff = abs(length - dist)
if closest[1] is None or diff < closest[1]:
closest = order, diff
return float(closest[0])
@addlogger
class Atom:
"""
Attributes:
* element str
* coords np.array(float)
* flag bool true if frozen, false if relaxed
* name str form of \d+(\.\d+)*
* tags set
* charge float
* connected set(Atom)
* constraint set(Atom) for determining constrained bonds
* _rank
* _radii float for calculating if bonded
* _connectivity int max connections without hypervalence
* _saturation int max connections without hypervalence or charges
"""
LOG = None
_bo = BondOrder()
_do_not_copy = {
"_hashed",
"constraint",
"connected",
"element",
"_connectivity",
"_saturation",
"_vdw",
"_radii",
"_mass",
"element",
"coords",
"name",
"tags",
"charge",
"mass",
}
def __init__(
self, element="", coords=None, flag=False, name="", tags=None, charge=None, mass=None
):
"""
:param str element: element symbol
:param np.ndarray coords: position
:param bool flag: whether atom is frozen
:param str name: atom name
:param list tags: misc. data
:param float charge: partial charge of atom
:param float mass: mass of atom
"""
super().__setattr__("_hashed", False)
if coords is None:
coords = []
# for BqO to have a ghost atom with oxygen basis functions
ele = str(element).strip()
element = ele.capitalize()
if "-" in ele:
element = "-".join(e.capitalize() for e in ele.split("-"))
if element.isdigit():
element = ELEMENTS[int(element)]
if element != "" and element not in ELEMENTS and not element.endswith("Bq"):
raise ValueError("Unknown element detected: %s" % element)
if tags is None:
tags = set()
elif hasattr(tags, "__iter__") and not isinstance(tags, str):
tags = set(tags)
else:
tags = set([tags])
if charge is not None:
charge = float(charge)
self.__dict__.update({
"element": element,
"coords": np.array(coords, dtype=float),
"_mass": mass,
"name": str(name).strip(),
"flag": bool(flag),
"tags": tags,
"charge": charge,
"connected": set(),
"constraint": set(),
"_rank": None,
})
if self.element:
self.reset()
# utilities
def __float__(self):
"""
converts self.name from a string to a floating point number
"""
rv = self.name.split(".")
if len(rv) == 0:
return float(0)
if len(rv) == 1:
return float(rv[0])
rv = "{}.{}".format(rv[0], rv[1])
return float(rv)
def __lt__(self, other):
"""
sorts by canonical smiles rank, then by neighbor ID, then by name
more connections first
then, more non-H bonds first
then, higher atomic number first
then, higher number of attached hydrogens first
then, lower sorting name first
"""
if (
self._rank is not None
and other._rank is not None
and self._rank != other._rank
):
return self._rank > other._rank
if self._rank is None or other._rank is None:
# if the ranks are the same, we have little reason to
# believe the invariants will differ
a = self.get_invariant()
b = other.get_invariant()
if a != b:
return a > b
# print("using names")
a = self.name.split(".")
b = other.name.split(".")
while len(a) < len(b):
a += ["0"]
while len(b) < len(a):
b += ["0"]
for i, j in zip(a, b):
try:
if int(i) != int(j):
return int(i) < int(j)
except ValueError:
pass
return True
def __str__(self):
s = ""
s += "{:>4s} ".format(self.name)
s += "{:<3s} ".format(self.element)
for c in self.coords:
s += " {: 10.6f}".format(c)
return s
def __repr__(self):
s = ""
s += "{:>3s} ".format(self.element)
for c in self.coords:
s += " {: 13.8f}".format(c)
s += " {: 2d}".format(-1 if self.flag else 0)
s += " {:>4s}".format(self.name)
s += " ({:d})".format(self._rank) if self._rank is not None else ""
return s
@property
def _radii(self):
"""Sets atomic radii"""
if self.is_ghost or self.is_dummy:
return 0
try:
return float(RADII[self.element])
except KeyError:
self.LOG.warning("Radii not found for element: %s" % self.element)
return 1.5
def __setattr__(self, attr, val):
if self._hashed and attr in {"element", "coords"}:
raise RuntimeError(
"Atom %s's Geometry has been hashed and can no longer be changed\n"
% self.name
+ "setattr was called to set %s to %s" % (attr, val)
)
super().__setattr__(attr, val)
@property
def _vdw(self):
"""Sets atomic radii"""
if self.is_ghost or self.is_dummy:
return 0
try:
return float(VDW_RADII[self.element])
except KeyError:
self.LOG.warning(
"VDW Radii not found for element: %s" % self.element
)
return 0
@property
def _connectivity(self):
if self.is_ghost or self.is_dummy:
return 1000
try:
return int(CONNECTIVITY[self.element])
except KeyError:
return None
@property
def _saturation(self):
"""
Sets theoretical maximum connectivity without the atom having a formal charge.
If # connections > self._saturation, then atom is hyper-valent or has a non-zero formal charge
"""
if self.is_ghost or self.is_dummy:
return 0
try:
return int(SATURATION[self.element])
except KeyError:
return
@property
def is_dummy(self):
return re.match("X$", self.element) is not None
@property
def is_ghost(self):
return re.match("([A-Z][a-z]?-Bq|Bq)", self.element) is not None
def reset(self):
pass
def add_tag(self, *args):
for a in args:
if hasattr(a, "__iter__") and not isinstance(a, str):
self.tags = self.tags.union(set(a))
else:
self.tags.add(a)
return
def get_invariant(self):
"""
gets initial invariant, which is formulated using:
#. number of non-hydrogen connections (\d{1}): nconn
#. sum of bond order of non-hydrogen bonds * 10 (\d{2}): nB
#. atomic number (\d{3}): z
#. sign of charge (\d{1}) (not used)
#. absolute charge (\d{1}) (not used)
#. number of attached hydrogens (\d{1}): nH
"""
heavy = set([x for x in self.connected if x.element != "H"])
# number of non-hydrogen connections:
nconn = len(heavy)
# number of bonds with heavy atoms
nB = 0
for h in heavy:
nB += BondOrder.get(h, self)
# number of connected hydrogens
nH = len(self.connected - heavy)
# atomic number
z = ELEMENTS.index(self.element)
return "{:01d}{:03d}{:03d}{:01d}".format(
int(nconn), int(nB * 10), int(z), int(nH)
)
def get_neighbor_id(self):
"""
gets initial invariant based on self's element and the element of
the atoms connected to self
"""
# atomic number
z = ELEMENTS.index(self.element)
heavy = [
ELEMENTS.index(x.element)
for x in self.connected
if x.element != "H"
]
# number of non-hydrogen connections
# number of bonds with heavy atoms and their element
t = []
for h in sorted(set(heavy)):
t.extend([h, heavy.count(h)])
# number of connected hydrogens
nH = len(self.connected) - len(heavy)
fmt = "%03i%02i" + (len(set(heavy)) * "%03i%02i") + "%02i"
s = fmt % (z, len(heavy), *t, nH)
return s
def copy(self):
"""
creates and returns a copy of self
"""
rv = Atom(element=self.element, coords=self.coords.copy(), name=self.name, tags=self.tags.copy(), charge=self.charge, mass=self.mass)
# from time import perf_counter
for key, val in self.__dict__.items():
if key in Atom._do_not_copy:
continue
# copying_times.setdefault(key, 0)
# start = perf_counter()
try:
rv.__dict__[key] = val.copy()
# stop = perf_counter()
# copying_times[key] += (stop - start)
except AttributeError:
rv.__dict__[key] = val
# stop = perf_counter()
# copying_times[key] += (stop - start)
# ignore chimerax objects so seqcrow doesn't print a
# warning when a geometry is copied
mod = val.__class__.__module__
if "chimerax" in mod:
continue
if mod != "builtins":
self.LOG.warning(
"No copy method for {}: in-place changes may occur".format(
type(val)
)
)
return rv
# measurement
def is_connected(self, other, tolerance=None):
"""
determines if distance between atoms is small enough to be bonded
same as dist_is_connected but automatically calculates the distance between the atoms
:param float tolerance: buffer for consideration of what is "small enough"; default is 0.3. Cutoff for what constitutes small enough is the sum of the atoms' radii and the tolerance value
:returns: True if distance is small enough to be bonded, False otherwise
:rtype: boolean
"""
return self.dist_is_connected(other, self.dist(other), tolerance)
def dist_is_connected(self, other, dist_to_other, tolerance):
"""
determines if distance between atoms is small enough to be bonded
used to optimize connected checks when distances can be quickly precalculated,
like with scipy.spatial.distance_matrix
:param Atom other: atom to measure the distance between
:param float tolerance: buffer for consideration of what is "small enough"; d
efault is 0.3. Cutoff for what constitutes small enough is the sum of the atoms' radii and the tolerance value
:param float dist_to_other: distance between the atoms in Angstroms
:returns: True if distance is small enough to be bonded, False otherwise
:rtype: boolean
"""
if tolerance is None:
tolerance = 0.3
rad1 = self._radii
rad2 = other._radii
if rad1 is None:
rad1 = 1.5
if rad2 is None:
rad2 = 1.5
cutoff = rad1 + rad2 + tolerance
return dist_to_other < cutoff
def add_bond_to(self, other):
"""add self and other to eachother's connected attribute"""
self.connected.add(other)
other.connected.add(self)
def bond(self, other):
"""
retrieves bond vectors
:returns: the vector self-->other
:rtype: np.array
"""
if isinstance(other, np.ndarray):
return other - np.array(self.coords)
return np.array(other.coords) - np.array(self.coords)
def dist(self, other):
"""
retrieves distance between Atoms
:returns: the distance between self and other
:rtype: float
"""
return np.linalg.norm(self.bond(other))
def angle(self, a1, a3):
"""
determines angle between three Atoms
:returns: the a1-self-a3 angle
:rtype: float
"""
v1 = self.bond(a1)
v2 = self.bond(a3)
dot = np.dot(v1, v2)
# numpy is still unhappy with this sometimes
# every now and again, the changeElement cls test will "fail" b/c
# numpy throws a warning here
if abs(dot / (self.dist(a1) * self.dist(a3))) >= 1:
return 0
else:
return np.arccos(dot / (self.dist(a1) * self.dist(a3)))
@property
def mass(self):
"""
retrieves mass of an Atom
:returns: atomic mass
:rtype: float
"""
if self._mass is not None:
return self._mass
if self.element in MASS:
return MASS[self.element]
elif not (self.is_dummy or self.is_ghost):
self.LOG.warning("no mass for %s" % self.element)
return 0
@mass.setter
def mass(self, value):
"""
manually sets the mass of an atom; when retrieving mass values, there is a default value based on the element of the Atom, so this is only necessary if you want an instance of Atom of a differing mass to its typical value.
:param float value: mass in AMU to set the Atom to;
"""
self._mass = value
def rij(self, other):
try:
rv = RIJ[self.element + other.element]
except KeyError:
try:
rv = RIJ[other.element + self.element]
except KeyError:
warn_LJ.add("".join(sorted([self.element, other.element])))
return 0
return rv
def eij(self, other):
try:
rv = EIJ[self.element + other.element]
except KeyError:
try:
rv = EIJ[other.element + self.element]
except KeyError:
warn_LJ.add("".join(sorted([self.element, other.element])))
return 0
return rv
def bond_order(self, other):
return BondOrder.get(self, other)
@classmethod
def get_shape(cls, shape_name):
"""
returns dummy atoms in an idealized vsepr geometry
shape_name can be:
* point
* linear 1
* linear 2
* bent 2 tetrahedral
* bent 2 planar
* trigonal planar
* bent 3 tetrahedral
* t shaped
* tetrahedral
* sawhorse
* seesaw
* square planar
* trigonal pyramidal
* trigonal bipyramidal
* square pyramidal
* pentagonal
* hexagonal
* trigonal prismatic
* pentagonal pyramidal
* octahedral
* capped octahedral
* hexagonal pyramidal
* pentagonal bipyramidal
* capped trigonal prismatic
* heptagonal
* hexagonal bipyramidal
* heptagonal pyramidal
* octagonal
* square antiprismatic
* trigonal dodecahedral
* capped cube
* biaugmented trigonal prismatic
* cubic
* elongated trigonal bipyramidal
* capped square antiprismatic
* enneagonal
* heptagonal bipyramidal
* hula-hoop
* triangular cupola
* tridiminished icosahedral
* muffin
* octagonal pyramidal
* tricapped trigonal prismatic
"""
if shape_name == "point":
return cls.linear_shape()[0:1]
elif shape_name == "linear 1":
return cls.linear_shape()[0:2]
elif shape_name == "linear 2":
return cls.linear_shape()
elif shape_name == "bent 2 tetrahedral":
return cls.tetrahedral_shape()[0:3]
elif shape_name == "bent 2 planar":
return cls.trigonal_planar_shape()[0:3]
elif shape_name == "trigonal planar":
return cls.trigonal_planar_shape()
elif shape_name == "bent 3 tetrahedral":
return cls.tetrahedral_shape()[0:4]
elif shape_name == "t shaped":
return cls.octahedral_shape()[0:4]
elif shape_name == "tetrahedral":
return cls.tetrahedral_shape()
elif shape_name == "sawhorse":
return np.concatenate((
cls.trigonal_bipyramidal_shape()[0:3,],
cls.trigonal_bipyramidal_shape()[-2:,],
))
elif shape_name == "seesaw":
return np.concatenate((
cls.octahedral_shape()[0:3],
cls.octahedral_shape()[-2:],
))
elif shape_name == "square planar":
return cls.octahedral_shape()[0:5]
elif shape_name == "trigonal pyramidal":
return cls.trigonal_bipyramidal_shape()[0:5]
elif shape_name == "trigonal bipyramidal":
return cls.trigonal_bipyramidal_shape()
elif shape_name == "square pyramidal":
return cls.octahedral_shape()[0:6]
elif shape_name == "pentagonal":
return cls.pentagonal_bipyramidal_shape()[0:6]
elif shape_name == "hexagonal":
return cls.hexagonal_bipyramidal_shape()[0:7]
elif shape_name == "trigonal prismatic":
return cls.trigonal_prismatic_shape()
elif shape_name == "pentagonal pyramidal":
return cls.pentagonal_bipyramidal_shape()[0:7]
elif shape_name == "octahedral":
return cls.octahedral_shape()
elif shape_name == "capped octahedral":
return cls.capped_octahedral_shape()
elif shape_name == "hexagonal pyramidal":
return cls.hexagonal_bipyramidal_shape()[0:8]
elif shape_name == "pentagonal bipyramidal":
return cls.pentagonal_bipyramidal_shape()
elif shape_name == "capped trigonal prismatic":
return cls.capped_trigonal_prismatic_shape()
elif shape_name == "heptagonal":
return cls.heptagonal_bipyramidal_shape()[0:8]
elif shape_name == "hexagonal bipyramidal":
return cls.hexagonal_bipyramidal_shape()
elif shape_name == "heptagonal pyramidal":
return cls.heptagonal_bipyramidal_shape()[0:9]
elif shape_name == "octagonal":
return cls.octagonal_pyramidal_shape()[0:9]
elif shape_name == "square antiprismatic":
return cls.square_antiprismatic_shape()
elif shape_name == "trigonal dodecahedral":
return cls.trigonal_dodecahedral_shape()
elif shape_name == "capped cube":
return cls.capped_cube_shape()
elif shape_name == "biaugmented trigonal prismatic":
return cls.biaugmented_trigonal_prismatic_shape()
elif shape_name == "cubic":
return cls.cubic_shape()
elif shape_name == "elongated trigonal bipyramidal":
return cls.elongated_trigonal_bipyramidal_shape()
elif shape_name == "capped square antiprismatic":
return cls.capped_square_antiprismatic_shape()
elif shape_name == "enneagonal":
return cls.enneagonal_shape()
elif shape_name == "heptagonal bipyramidal":
return cls.heptagonal_bipyramidal_shape()
elif shape_name == "hula-hoop":
return cls.hula_hoop_shape()
elif shape_name == "triangular cupola":
return cls.triangular_cupola_shape()
elif shape_name == "tridiminished icosahedral":
return cls.tridiminished_icosahedral_shape()
elif shape_name == "muffin":
return cls.muffin_shape()
elif shape_name == "octagonal pyramidal":
return cls.octagonal_pyramidal_shape()
elif shape_name == "tricapped trigonal prismatic":
return cls.tricapped_trigonal_prismatic_shape()
else:
raise RuntimeError(
"no shape method is defined for %s" % shape_name
)
@classmethod
def linear_shape(cls):
"""returns a list of 3 dummy atoms in a linear shape"""
center = np.zeros(3)
pos1 = np.array([1.0, 0.0, 0.0])
pos2 = np.array([-1.0, 0.0, 0.0])
return np.array([center, pos1, pos2])
@classmethod
def trigonal_planar_shape(cls):
"""returns a list of 4 dummy atoms in a trigonal planar shape"""
positions = cls.trigonal_bipyramidal_shape()
return positions[:-2,]
@classmethod
def tetrahedral_shape(cls):
"""returns a list of 5 dummy atoms in a tetrahedral shape"""
center = np.zeros(3)
pos1 = np.array([0.57735, -0.81650, 0.0])
pos2 = np.array([0.57735, 0.81650, 0.0])
pos3 = np.array([-0.57735, 0.0, 0.81650])
pos4 = np.array([-0.57735, 0.0, -0.81650])
return np.array([center, pos1, pos2, pos3, pos4])
@classmethod
def trigonal_bipyramidal_shape(cls):
"""returns a list of 6 dummy atoms in a trigonal bipyramidal shape"""
center = np.zeros(3)
pos1 = np.array([1.0, 0.0, 0.0])
pos2 = np.array([-0.5, 0.86603, 0.0])
pos3 = np.array([-0.5, -0.86603, 0.0])
pos4 = np.array([0.0, 0.0, 1.0])
pos5 = np.array([0.0, 0.0, -1.0])
return np.array([center, pos1, pos2, pos3, pos4, pos5])
@classmethod
def octahedral_shape(cls):
"""returns a list of 7 dummy atoms in an octahedral shape"""
center = np.zeros(3)
pos1 = np.array([1.0, 0.0, 0.0])
pos2 = np.array([0.0, 1.0, 0.0])
pos3 = np.array([-1.0, 0.0, 0.0])
pos4 = np.array([0.0, -1.0, 0.0])
pos5 = np.array([0.0, 0.0, 1.0])
pos6 = np.array([0.0, 0.0, -1.0])
return np.array([center, pos1, pos2, pos3, pos4, pos5, pos6])
@classmethod
def trigonal_prismatic_shape(cls):
"""returns a list of 7 dummy atoms in a trigonal prismatic shape"""
center = np.zeros(3)
pos1 = np.array([-0.6547, -0.3780, 0.6547])
pos2 = np.array([-0.6547, -0.3780, -0.6547])
pos3 = np.array([0.6547, -0.3780, 0.6547])
pos4 = np.array([0.6547, -0.3780, -0.6547])
pos5 = np.array([0.0, 0.7559, 0.6547])
pos6 = np.array([0.0, 0.7559, -0.6547])
return np.array([center, pos1, pos2, pos3, pos4, pos5, pos6])
@classmethod
def capped_octahedral_shape(cls):
"""returns a list of 8 dummy atoms in a capped ocrahedral shape"""
center = np.zeros(3)
pos1 = np.array([0.0, 0.0, 1.0])
pos2 = np.array([0.9777, 0.0, 0.2101])
pos3 = np.array([0.1698, 0.9628, 0.2101])
pos4 = np.array([-0.9187, 0.3344, 0.2102])
pos5 = np.array([-0.4888, -0.8467, 0.2102])
pos6 = np.array([0.3628, -0.6284, -0.6881])
pos7 = np.array([-0.2601, 0.4505, -0.8540])
return np.array(
[center, pos1, pos2, pos3, pos4, pos5, pos6, pos7]
)
@classmethod
def capped_trigonal_prismatic_shape(cls):
"""returns a list of 8 dummy atoms in a capped trigonal prismatic shape"""
center = np.zeros(3)
pos1 = np.array([0.0, 0.0, 1.0])
pos2 = np.array([0.6869, 0.6869, 0.2374])
pos3 = np.array([-0.6869, 0.6869, 0.2374])
pos4 = np.array([0.6869, -0.6869, 0.2374])
pos5 = np.array([-0.6869, -0.6869, 0.2374])
pos6 = np.array([0.6175, 0.0, -0.7866])
pos7 = np.array([-0.6175, 0.0, -0.7866])
return np.array(
[center, pos1, pos2, pos3, pos4, pos5, pos6, pos7]
)
@classmethod
def pentagonal_bipyramidal_shape(cls):
"""returns a list of 8 dummy atoms in a pentagonal bipyramidal shape"""
center = np.zeros(3)
pos1 = np.array([1.0, 0.0, 0.0])
pos2 = np.array([0.3090, 0.9511, 0.0])
pos3 = np.array([-0.8090, 0.5878, 0.0])
pos4 = np.array([-0.8090, -0.5878, 0.0])
pos5 = np.array([0.3090, -0.9511, 0.0])
pos6 = np.array([0.0, 0.0, 1.0])
pos7 = np.array([0.0, 0.0, -1.0])
return np.array(
[center, pos1, pos2, pos3, pos4, pos5, pos6, pos7]
)
@classmethod
def biaugmented_trigonal_prismatic_shape(cls):
"""returns a list of 9 dummy atoms in a biaugmented trigonal prismatic shape"""
center = np.zeros(3)
pos1 = np.array([-0.6547, -0.3780, 0.6547])
pos2 = np.array([-0.6547, -0.3780, -0.6547])
pos3 = np.array([0.6547, -0.3780, 0.6547])
pos4 = np.array([0.6547, -0.3780, -0.6547])
pos5 = np.array([0.0, 0.7559, 0.6547])
pos6 = np.array([0.0, 0.7559, -0.6547])
pos7 = np.array([0.0, -1.0, 0.0])
pos8 = np.array([-0.8660, 0.5, 0.0])
return np.array(
[center, pos1, pos2, pos3, pos4, pos5, pos6, pos7, pos8]
)
@classmethod
def cubic_shape(cls):
"""returns a list of 9 dummy atoms in a cubic shape"""
center = np.zeros(3)
pos1 = np.array([0.5775, 0.5774, 0.5774])
pos2 = np.array([0.5775, 0.5774, -0.5774])
pos3 = np.array([0.5775, -0.5774, 0.5774])
pos4 = np.array([-0.5775, 0.5774, 0.5774])
pos5 = np.array([0.5775, -0.5774, -0.5774])
pos6 = np.array([-0.5775, 0.5774, -0.5774])
pos7 = np.array([-0.5775, -0.5774, 0.5774])
pos8 = np.array([-0.5775, -0.5774, -0.5774])
return np.array(
[center, pos1, pos2, pos3, pos4, pos5, pos6, pos7, pos8]
)
@classmethod
def elongated_trigonal_bipyramidal_shape(cls):
"""returns a list of 9 dummy atoms in an elongated trigonal bipyramidal shape"""
center = np.zeros(3)
pos1 = np.array([0.6547, 0.0, 0.7559])
pos2 = np.array([-0.6547, 0.0, 0.7559])
pos3 = np.array([0.6547, 0.6547, -0.3780])
pos4 = np.array([-0.6547, 0.6547, -0.3780])
pos5 = np.array([0.6547, -0.6547, -0.3780])
pos6 = np.array([-0.6547, -0.6547, -0.3780])
pos7 = np.array([1.0, 0.0, 0.0])
pos8 = np.array([-1.0, 0.0, 0.0])
return np.array(
[center, pos1, pos2, pos3, pos4, pos5, pos6, pos7, pos8]
)
@classmethod
def hexagonal_bipyramidal_shape(cls):
"""returns a list of 9 dummy atoms in a hexagonal bipyramidal shape"""
center = np.zeros(3)
pos1 = np.array([0.0, -1.0, 0.0])
pos2 = np.array([0.8660, -0.5, 0.0])
pos3 = np.array([0.8660, 0.5, 0.0])
pos4 = np.array([0.0, 1.0, 0.0])
pos5 = np.array([-0.8660, 0.5, 0.0])
pos6 = np.array([-0.8660, -0.5, 0.0])
pos7 = np.array([0.0, 0.0, 1.0])
pos8 = np.array([0.0, 0.0, -1.0])
return np.array(
[center, pos1, pos2, pos3, pos4, pos5, pos6, pos7, pos8]
)
@classmethod
def square_antiprismatic_shape(cls):
"""returns a list of 9 dummy atoms in a square antiprismatic shape"""
center = np.zeros(3)
pos1 = np.array([0.0, 0.0, 1.0])
pos2 = np.array([0.9653, 0.0, 0.2612])
pos3 = np.array([-0.5655, 0.7823, 0.2612])
pos4 = np.array([-0.8825, -0.3912, 0.2612])
pos5 = np.array([0.1999, -0.9444, 0.2612])
pos6 = np.array([0.3998, 0.7827, -0.4776])
pos7 = np.array([-0.5998, 0.1620, -0.7836])
pos8 = np.array([0.4826, -0.3912, -0.7836])
return np.array(
[center, pos1, pos2, pos3, pos4, pos5, pos6, pos7, pos8]
)
@classmethod
def trigonal_dodecahedral_shape(cls):
"""returns a list of 9 dummy atoms in a trigonal dodecahedral shape"""
center = np.zeros(3)
pos1 = np.array([-0.5997, 0.0, 0.8002])
pos2 = np.array([0.0, -0.9364, 0.3509])
pos3 = np.array([0.5998, 0.0, 0.8002])
pos4 = np.array([0.0, 0.9364, 0.3509])
pos5 = np.array([-0.9364, 0.0, -0.3509])
pos6 = np.array([0.0, -0.5997, -0.8002])
pos7 = np.array([0.9365, 0.0, -0.3509])
pos8 = np.array([0.0, 0.5997, -0.8002])
return np.array(
[center, pos1, pos2, pos3, pos4, pos5, pos6, pos7, pos8]
)
@classmethod
def heptagonal_bipyramidal_shape(cls):
"""returns a list of 10 dummy atoms in a heptagonal bipyramidal shape"""
center = np.zeros(3)
pos1 = np.array([1.0, 0.0, 0.0])
pos2 = np.array([0.6235, 0.7818, 0.0])
pos3 = np.array([-0.2225, 0.9749, 0.0])
pos4 = np.array([-0.9010, 0.4339, 0.0])
pos5 = np.array([-0.9010, -0.4339, 0.0])
pos6 = np.array([-0.2225, -0.9749, 0.0])
pos7 = np.array([0.6235, -0.7818, 0.0])
pos8 = np.array([0.0, 0.0, 1.0])
pos9 = np.array([0.0, 0.0, -1.0])
return np.array(
[center, pos1, pos2, pos3, pos4, pos5, pos6, pos7, pos8, pos9]
)
@classmethod
def capped_cube_shape(cls):
"""returns a list of 10 dummy atoms in a capped cube shape"""
center = np.zeros(3)
pos1 = np.array([0.6418, 0.6418, 0.4196])
pos2 = np.array([0.6418, -0.6418, 0.4196])
pos3 = np.array([-0.6418, 0.6418, 0.4196])
pos4 = np.array([-0.6418, -0.6418, 0.4196])
pos5 = np.array([0.5387, 0.5387, -0.6478])
pos6 = np.array([0.5387, -0.5387, -0.6478])
pos7 = np.array([-0.5387, 0.5387, -0.6478])
pos8 = np.array([-0.5387, -0.5387, -0.6478])
pos9 = np.array([0.0, 0.0, 1.0])
return np.array(
[center, pos1, pos2, pos3, pos4, pos5, pos6, pos7, pos8, pos9]
)
@classmethod
def capped_square_antiprismatic_shape(cls):
"""returns a list of 10 dummy atoms in a capped square antiprismatic shape"""
center = np.zeros(3)
pos1 = np.array([0.9322, 0.0, 0.3619])
pos2 = np.array([-0.9322, 0.0, 0.3619])
pos3 = np.array([0.0, 0.9322, 0.3619])
pos4 = np.array([0.0, -0.9322, 0.3619])
pos5 = np.array([0.5606, 0.5606, -0.6095])
pos6 = np.array([-0.5606, 0.5606, -0.6095])
pos7 = np.array([-0.5606, -0.5606, -0.6095])
pos8 = np.array([0.5606, -0.5606, -0.6095])
pos9 = np.array([0.0, 0.0, 1.0])
return np.array(
[center, pos1, pos2, pos3, pos4, pos5, pos6, pos7, pos8, pos9]
)
@classmethod
def enneagonal_shape(cls):
"""returns a list of 10 dummy atoms in an enneagonal shape"""
center = np.zeros(3)
pos1 = np.array([1.0, 0.0, 0.0])
pos2 = np.array([0.7660, 0.6428, 0.0])
pos3 = np.array([0.1736, 0.9848, 0.0])
pos4 = np.array([-0.5, 0.8660, 0.0])
pos5 = np.array([-0.9397, 0.3420, 0.0])
pos6 = np.array([-0.9397, -0.3420, 0.0])
pos7 = np.array([-0.5, -0.8660, 0.0])
pos8 = np.array([0.1736, -0.9848, 0.0])
pos9 = np.array([0.7660, -0.6428, 0.0])
return np.array(
[center, pos1, pos2, pos3, pos4, pos5, pos6, pos7, pos8, pos9]
)
@classmethod
def hula_hoop_shape(cls):
"""returns a list of 10 dummy atoms in a hula hoop shape"""
center = np.zeros(3)
pos1 = np.array([1.0, 0.0, 0.0])
pos2 = np.array([0.5, 0.8660, 0.0])
pos3 = np.array([-0.5, 0.8660, 0.0])
pos4 = np.array([-1.0, 0.0, 0.0])
pos5 = np.array([-0.5, -0.8660, 0.0])
pos6 = np.array([0.5, -0.8660, 0.0])
pos7 = np.array([0.0, 0.0, 1.0])
pos8 = np.array([0.5, 0.0, -0.8660])
pos9 = np.array([-0.5, 0.0, -0.8660])
return np.array(
[center, pos1, pos2, pos3, pos4, pos5, pos6, pos7, pos8, pos9]
)
@classmethod
def triangular_cupola_shape(cls):
""" returns a list of 10 dummy atoms in a triangular cupola shape"""
center = np.zeros(3)
pos1 = np.array([1.0, 0.0, 0.0])
pos2 = np.array([0.5, 0.8660, 0.0])
pos3 = np.array([-0.5, 0.8660, 0.0])
pos4 = np.array([-1.0, 0.0, 0.0])
pos5 = np.array([0.5, -0.8660, 0.0])
pos6 = np.array([-0.5, -0.8660, 0.0])
pos7 = np.array([0.5, 0.2887, -0.8165])
pos8 = np.array([-0.5, 0.2887, -0.8165])
pos9 = np.array([0.0, -0.5774, -0.8165])
return np.array(
[center, pos1, pos2, pos3, pos4, pos5, pos6, pos7, pos8, pos9]