This repository was archived by the owner on Apr 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmolecularInfo.py
More file actions
1853 lines (1655 loc) · 83.7 KB
/
molecularInfo.py
File metadata and controls
1853 lines (1655 loc) · 83.7 KB
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
import numpy as np
import sys
from numpy import linalg as la
import time
import Plot
import copy
global massH
global massO
global massD
massH=1.00782503223
massD=2.0141017778
massO=15.99491561957
massConversionFactor=1.000000000000000000/6.02213670000e23/9.10938970000e-28#1822.88839 g/mol -> a.u.
ang2bohr=1.88973
bohr2ang=1.000/ang2bohr
rad2deg=180.000/np.pi
au2wn=219474.63
global Water
Water={'H2O', 'water', 'HOH', 'h2o'}
global Hydronium
hydronium = {'H3O+'}
global WaterDimer
WaterDimer = {'water dimer', 'H4O2'}
global ProtonatedWaterDimer
ProtonatedWaterDimer = {'H5O2+','HHOHOHH','H5O2+','h5o2plus','h5o2'}
global DeprotonatedWaterDimer
DeprotonatedWaterDimer = {'HOHOH','H3O2-', 'h3o2-', 'h3o2', 'H3O2'}
global ProtonatedWaterTrimer
ProtonatedWaterTrimer = {'H7O3+','O3H7+', 'H7O3plus','H7O3', 'O3H7'}
global ProtonatedWaterTetramer
ProtonatedWaterTetramer = {'H9O4+','O4H9+', 'H9O4plus','H9O4', 'O4H9'}
surfaceOptions= {'OHStretchAnti','StretchAntiIn','SharedProton','LocalOHStretch','Z-displacement','EckRotZ-displacement'}
class molecule (object):
def __init__(self,moleculeName):
self.name=moleculeName
if self.name in DeprotonatedWaterDimer:
self.nAtoms=5
self.names=['H','O','H','O','H']
elif self.name in hydronium:
self.nAtoms = 4
self.names = ['H', 'H','H','O']
elif self.name in ProtonatedWaterDimer:
self.natoms=7
self.names=['O','O','H','H','H','H','H']
elif self.name in ProtonatedWaterTrimer:
self.nAtoms = 10
self.names=['O','O','O','H','H','H','H','H','H','H']
elif self.name in ProtonatedWaterTetramer:
self.nAtoms = 13
self.names = ['O', 'O', 'O', 'O','H', 'H', 'H', 'H', 'H', 'H', 'H','H','H']
elif self.name in Water:
self.nAtoms = 3
self.names = ['O','H','H']
if self.name in ProtonatedWaterDimer:
self.potential=self.getPES()
self.dipole=self.getDIPOLE()
self.isotope='notDeuterated'
self.nVibs=3*self.nAtoms-6
# if self.name in hydronium:
# self.nVibs+=1
def set_isotope(self,keyword):
print('resetting isotope to ', keyword)
if self.name in ProtonatedWaterTrimer:
self.isotope = keyword
if self.isotope == 'DeuteratedOnce_eigen':
self.names = ['O','O','O','H','H','H','H','H','H','D']
elif self.isotope == 'DeuteratedOnce_fw':
self.names = ['O','O','O','D','H','H','H','H','H','H']
elif self.isotope == 'notDeuterated':
self.names = ['O','O','O','H','H','H','H','H','H','H']
elif self.isotope == 'fullyDeuterated':
self.names = ['O','O','O','D','D','D','D','D','D','D']
elif self.isotope == 'notDeuteratedOnce_eigen':
self.names = ['O','O','O','D','D','D','D','D','D','H']
elif self.isotope == 'notDeuteratedOnce_fw':
self.names = ['O','O','O','H','D','D','D','D','D','D']
elif self.isotope == 'DeuteratedOnce_hydronium':
self.names = ['O','O','O','H','H','H','H','D','H','H']
elif self.isotope == 'notDeuteratedOnce_hydronium':
self.names = ['O','O','O','D','D','D','D','H','D','D']
elif self.name in ProtonatedWaterTetramer:
self.isotope = keyword
if self.isotope == 'DeuteratedOnce_eigen':
self.names = ['O', 'O', 'O', 'O','H', 'H', 'H', 'H', 'H', 'H', 'D','H','H']
elif self.isotope == 'DeuteratedOnce_fw':
self.names = ['O', 'O', 'O', 'O','D', 'H', 'H', 'H', 'H', 'H', 'H','H','H']
elif self.isotope == 'notDeuterated':
self.names = ['O', 'O', 'O', 'O','H', 'H', 'H', 'H', 'H', 'H', 'H','H','H']
elif self.isotope == 'fullyDeuterated':
self.names = ['O', 'O', 'O', 'O','D', 'D', 'D', 'D', 'D', 'D', 'D','D','D']
elif self.isotope == 'notDeuteratedOnce_eigen':
self.names = ['O', 'O', 'O', 'O','D', 'D', 'D', 'D', 'D', 'D', 'H','D','D']
elif self.isotope == 'notDeuteratedOnce_fw':
self.names = ['O', 'O', 'O', 'O','H', 'D', 'D', 'D', 'D', 'D', 'D','D','D']
def setNodalSurface(self,surfaceName,side):
self.surfaceName=surfaceName
if not self.surfaceName in surfaceOptions:
print("HAT IS NOT A SURFACE! you have likely made a typo.")
self.side=side
self.state=1
def getEquilibriumEnergy(self):
if self.name in DeprotonatedWaterDimer:
equilibriumCoords = np.array([[0.2981678882048853, -2.4557992072743176E-002, -5.5485232545510215E-002],
[-2.354423404994569, 0.000000000000000, 0.000000000000000],
[-2.858918674095194, 1.111268022307282, -1.352651141853729],
[2.354423404994569, 0.000000000000000, 0.000000000000000],
[2.671741580470489, 1.136107563104921, 1.382886181959795]])
equilibriumE = self.V([equilibriumCoords])
# print 'equilibrium position',equilibriumCoords*bohr2ang, 'and energy:',equilibriumE*au2wn,'1/cm'
elif self.name in hydronium:
equilibriumE = 3.404489490321794E-006
elif self.name in ProtonatedWaterTrimer:
equilibriumE = -9.129961286575450E-002
elif self.name in ProtonatedWaterTetramer:
equilibriumE = -0.12214685901476255
return equilibriumE
def rotateBackToFrame(self,coordz,a,b,c,dips=None): #use the rotation matrices that I always use to reshape each coordinate back to its reference frame
print(coordz[1])
print('RotatingWalkers')
numWalkers = coordz.shape[0]
#translation back to Origin
o3 = coordz[:,a-1].reshape(numWalkers,1,3)
trCoordz = copy.deepcopy(coordz-o3)
if dips is not None:
dips = dips-o3[:,0,:]
#Rotation of O2 to x axis
o2 = trCoordz[:,b-1,:].reshape(numWalkers,1,3)
z = o2[:, 0, 2]
y = o2[:, 0, 1]
x = o2[:, 0, 0]
theta = np.arctan2(-1 * z, y)
alpha = np.arctan2((-1 * (
y * np.cos(theta) - np.sin(theta) * z)), x)
stheta = np.sin(theta)
ctheta = np.cos(theta)
salpha = np.sin(alpha)
calpha = np.cos(alpha)
r1 = np.zeros((len(trCoordz),3,3))
r1[:,0,:]=np.tile([1,0,0],len(trCoordz)).reshape(len(trCoordz),3)
r1[:,1,:]=np.column_stack((np.zeros(len(trCoordz)),ctheta,-1*stheta))
r1[:,2,:]=np.column_stack((np.zeros(len(trCoordz)),stheta,ctheta))
r2 = np.zeros((len(trCoordz),3,3))
r2[:, 0, :] = np.column_stack((calpha,-1*salpha,np.zeros(len(trCoordz))))
r2[:, 1, :] = np.column_stack((salpha,calpha,np.zeros(len(trCoordz))))
r2[:, 2, :] = np.tile([0, 0, 1], len(trCoordz)).reshape(len(trCoordz),3)
rotM = np.matmul(r2, r1)
#print(trCoordz.shape)
xaxtrCoordz = np.matmul(rotM,trCoordz.transpose(0,2,1)).transpose(0,2,1)
if dips is not None:
for i in range(len(dips)):
dips[i] = np.dot(rotM[i],dips[i])
#print(xaxtrCoordz[0])
#Rotation of O1 to xyplane
o1 = xaxtrCoordz[:,c-1,:]
z = o1[:,2]
y = o1[:,1]
#x= o1[:,0]
beta = np.arctan2(-1 * z, y)
cbeta = np.cos(beta)
sbeta = np.sin(beta)
r = np.zeros((len(trCoordz),3,3))
r[:,0,:]=np.tile([1,0,0],len(trCoordz)).reshape(len(trCoordz),3)
r[:,1,:]=np.column_stack((np.zeros(len(trCoordz)),cbeta,-1*sbeta))
r[:,2,:]=np.column_stack((np.zeros(len(trCoordz)),sbeta,cbeta))
# mas = np.where(np.around(la.det(r),10)!=1.0)
# print(mas)
finalCoords = np.matmul(r, xaxtrCoordz.transpose(0, 2, 1)).transpose(0, 2, 1)
if dips is not None:
for i in range(len(dips)):
dips[i] = np.dot(r[i], dips[i])
# print(finalCoords[0])
# if dips is not None:
# return np.round(finalCoords,19), dips
# else:
# return np.round(finalCoords,19)
if dips is not None:
return finalCoords, dips
else:
return finalCoords
def bL(self,xx,atm1,atm2):
#Rotation of O1 to xyplane
atmO = xx[:,atm1,:]
atmT = xx[:, atm2, :]
lens = la.norm(atmO-atmT,axis=1)
return lens
def ba(self,xx,atm1,atm2,atm3): #left center right
#Rotation of O1 to xyplane
atmO = xx[:,atm1,:]
atmT = xx[:, atm2, :]
atmH = xx[:, atm3, :]
left = atmO - atmT
right = atmH - atmT
return np.arccos((left*right).sum(axis=1) / (la.norm(left,axis=1)*la.norm(right,axis=1)))
def SymInternals(self,x,rotato=True,weights=0):
#print('called SymInternals')
#print('returning values in bohr [or radians]')
if self.name in DeprotonatedWaterDimer:
internals= self.SymInternalsH3O2minus(x)
#self.internalNames=internalNames
return internals#,internalNames
elif self.name in Water:
internals = self.symInternalsH2O
return internals
elif self.name in ProtonatedWaterTrimer:
internals = self.SymInternalsH7O3plus(x)
return internals
elif self.name in ProtonatedWaterTetramer:
internals = self.SymInternalsH9O4plus(x)
return internals
elif self.name in hydronium:
internals = self.SymInternalsH3O(x)
return internals
else:
# print('woefully unprepared to handle the calculation of the SymInternals for ', self.molecule)
crash
def xyzTrimerSharedHydrogens(self,atmnm,xx):
if atmnm == 9:
outerW = 1
if atmnm == 10:
outerW = 2
mp = (xx[:,3-1]+xx[:,outerW-1])/ 2
# print(mp.shape)
xaxis = np.divide((xx[:,outerW-1] - mp),la.norm(xx[:,outerW-1,] - mp,axis=1).reshape(-1,1))
# print(xaxis.shape)
# print(xx[:,1-1].shape)
zaxis = np.cross(xx[:,1-1]-xx[:,3-1],xx[:,2-1]-xx[:,3-1],axis=1)
yaxis = np.cross(zaxis,xaxis,axis=1)
xcomp = ((xx[:,atmnm-1] - mp)*xaxis).sum(axis=1)
ycomp = ((xx[:,atmnm-1] - mp)*yaxis).sum(axis=1)
zcomp = ((xx[:,atmnm-1] - mp)*zaxis).sum(axis=1)
return xcomp, ycomp, zcomp
def getBisectingVector(self,left, middle, right):
bisector1 = la.norm(left - middle, axis=1).reshape(-1, 1) * (right - middle) # |b|*a + |a|*b
bisector2 = la.norm(right - middle, axis=1).reshape(-1, 1) * (left - middle)
normedbisector = la.norm(bisector1 + bisector2, axis=1).reshape(-1, 1)
bisector = (bisector1 + bisector2) / normedbisector
return bisector
# def xyzFreeHydronium(self,xx):
# xaxis = self.getBisectingVector(xx[:,9-1,:], xx[:,3 - 1,:],xx[:,10 - 1,:])
# crs = np.cross(xx[:,9-1]-xx[:,3-1],xx[:,10-1]-xx[:,3-1],axis=1)
# zaxis = crs/((la.norm(crs,axis=1))[:,np.newaxis])
# yaxis = np.cross(zaxis,xaxis,axis=1)
# xcomp = ((xx[:,8-1] - xx[:,3-1])*xaxis).sum(axis=1)
# ycomp = ((xx[:,8-1] - xx[:,3-1])*yaxis).sum(axis=1)
# zcomp = ((xx[:,8-1] - xx[:,3-1])*zaxis).sum(axis=1)
# rdistOH = la.norm(np.column_stack((xcomp,ycomp,zcomp)), axis=1)
# thetaOH = np.arccos(zcomp / rdistOH)
# phiOH = np.arctan2(ycomp,xcomp)
# phiOH[phiOH <= 0]+=(2.*np.pi)
# return rdistOH, thetaOH, phiOH
def spcoords_Water(self,xx,hAtom,hL,hR):
#For H8, hAtom = 8, hL = 9, hR = 10
hAtom-=1
hL-=1
hR-=1
##################### Doesn't work
# xaxis = np.tile(np.array([1., 0., 0.]), len(xx)).reshape(-1, 3)
# # yaxis = np.tile(np.array([0., 1., 0.]), len(xx)).reshape(-1, 3)
# zaxis = np.tile(np.array([0., 0., 1.]), len(xx)).reshape(-1, 3)
# zaxis[len(zaxis)/2:]*=-1.0
# yaxis = np.cross(zaxis,xaxis,axis=1)
# zaxis[len(zaxis)/2:]*=-1.0
#
# xcomp = ((xx[:,hAtom] - xx[:,3-1])*xaxis).sum(axis=1)
# ycomp = ((xx[:,hAtom] - xx[:,3-1])*yaxis).sum(axis=1)
# zcomp = ((xx[:,hAtom] - xx[:,3-1])*zaxis).sum(axis=1)
# rdistOH = la.norm(np.column_stack((xcomp,ycomp,zcomp)), axis=1)
# # rOHR = la.norm(xx[:,hAtom]-xx[:,3-1],axis=1)
# thetaOH = np.arccos(zcomp / rdistOH)
# ycomp[len(ycomp)/2:]*=-1.0
# phiOH = np.arctan2(ycomp,xcomp)
# # phiOH[phiOH <= 0]+=(2.*np.pi)
########################
xaxis = self.getBisectingVector(xx[:, hL, :], xx[:, 3 - 1, :], xx[:, hR, :])
crs = np.cross(xx[:, hL] - xx[:, 3 - 1], xx[:, hR] - xx[:, 3 - 1], axis=1)
zaxis = crs / ((la.norm(crs, axis=1))[:, np.newaxis])
zaxis[len(zaxis) / 2:] *= -1.0
yaxis = np.cross(zaxis, xaxis, axis=1)
zaxis[len(zaxis) / 2:] *= -1.0
xcomp = ((xx[:, hAtom] - xx[:, 3 - 1]) * xaxis).sum(axis=1)
ycomp = ((xx[:, hAtom] - xx[:, 3 - 1]) * yaxis).sum(axis=1)
zcomp = ((xx[:, hAtom] - xx[:, 3 - 1]) * zaxis).sum(axis=1)
rdistOH = la.norm(np.column_stack((xcomp, ycomp, zcomp)), axis=1)
# rOHR = la.norm(xx[:,hAtom]-xx[:,3-1],axis=1)
thetaOH = np.arccos(zcomp / rdistOH)
phiOH = np.arctan2(ycomp, xcomp)
phiOH[phiOH <= 0] += (2. * np.pi)
return rdistOH, thetaOH, phiOH
def spcoords_Water_sp(self,xx,hAtom):
#For H8, hAtom = 8, hL = 9, hR = 10
if hAtom == 9:
oxx = 1
oxx2 = 2
elif hAtom == 10:
oxx = 2
oxx2 = 1
oxx -= 1
oxx2 -= 1
hAtom -= 1
xaxis = xx[:,oxx]-xx[:,3-1]
xaxis/=la.norm(xaxis,axis=1)[:,np.newaxis]
# crs = np.cross(xaxis,xx[:,oxx2]-xx[:,3-1],axis=1)
crs = np.cross(xx[:,2-1]- xx[:, 3 - 1],xx[:,1-1]- xx[:, 3 - 1] , axis=1)
zaxis = crs/la.norm(crs,axis=1)[:,np.newaxis]
zaxis[len(zaxis)/2:]*=-1.0
yaxis = np.cross(zaxis,xaxis,axis=1)
zaxis[len(zaxis) / 2:] *= -1.0
xcomp = ((xx[:,hAtom] - xx[:,3-1])*xaxis).sum(axis=1)
ycomp = ((xx[:,hAtom] - xx[:,3-1])*yaxis).sum(axis=1)
zcomp = ((xx[:,hAtom] - xx[:,3-1])*zaxis).sum(axis=1)
rdistOH = la.norm(np.column_stack((xcomp,ycomp,zcomp)), axis=1)
thetaOH = np.arccos(zcomp / rdistOH)
phiOH = np.arctan2(ycomp,xcomp)
# phiOH[phiOH <= 0]+=(2.*np.pi)
return rdistOH, thetaOH, phiOH
def spcoords_Water_tetramer(self,xx,hAtom):
#For H8, hAtom = 8, hL = 9, hR = 10
if hAtom == 11:
oxx = 1
oxx2 = 3
oxN = 2
elif hAtom == 12:
oxx = 2
oxx2 = 1
oxN = 3
elif hAtom == 13:
oxx = 3
oxx2 = 2
oxN = 1
oxx -= 1
oxx2 -= 1
oxN -= 1
hAtom -= 1
xaxis = xx[:,oxN]-np.insert(xx[:,4-1,:-1],2,0,axis=-1)
xaxis/=la.norm(xaxis,axis=1)[:,np.newaxis]
crs = np.cross(xx[:,oxx]-xx[:,4-1],xx[:,oxx2]-xx[:,4-1],axis=1)
zaxis = crs/la.norm(crs,axis=1)[:,np.newaxis]
yaxis = np.cross(zaxis,xaxis,axis=1)
xcomp = ((xx[:,hAtom] - xx[:,4-1])*xaxis).sum(axis=1)
ycomp = ((xx[:,hAtom] - xx[:,4-1])*yaxis).sum(axis=1)
zcomp = ((xx[:,hAtom] - xx[:,4-1])*zaxis).sum(axis=1)
rdistOH = la.norm(np.column_stack((xcomp,ycomp,zcomp)), axis=1)
thetaOH = np.arccos(zcomp / rdistOH)
phiOH = np.arctan2(ycomp,xcomp)
# phiOH[phiOH <= 0]+=(2.*np.pi)
return rdistOH, thetaOH, phiOH
def finalTrimerEuler(self,xx,O1, h1, h2):
X = np.divide((xx[:, O1 - 1, :] - xx[:,3-1]) , la.norm(xx[:, O1 - 1, :] - xx[:,3-1], axis=1)[:,np.newaxis])
crs = np.cross(xx[:, 1 - 1] - xx[:, 3 - 1], xx[:, 2 - 1] - xx[:, 3 - 1], axis=1)
Z = crs / la.norm(crs,axis=1)[:,np.newaxis]
if len(Z) != 2:
Z[len(Z) / 2:] *= -1.0
Y = np.cross(Z, X, axis=1)
if len(Z) != 2:
Z[len(Z) / 2:] *= -1.0
x,y,z=self.H9GetHOHAxis(xx[:, O1 - 1], xx[:, h1 - 1], xx[:, h2 - 1])
exx = np.copy(x)
x = np.copy(y)
y = np.copy(z)
z = np.copy(exx)
print('lets get weird')
exX = np.copy(X)
X = np.copy(Z)
Z = np.copy(Y)
Y = np.copy(exX)
Theta,tanPhi,tanChi=self.eulerMatrix(x,y,z,X,Y,Z)
return Theta,tanPhi, tanChi
def H9getOOOAxis(self,xx,oW):
# oW = xx[:,outerW-1,:] # Coordinates of outer water Oxygen
center = xx[:, 4 - 1, :]
xaxis = np.divide((oW - center), la.norm(oW - center, axis=1).reshape(-1,1)) # Normalized coordinates of xaxis definition. aka vector with only x component, where x = 1
# zaxis
dummy = center.copy()
dummy[:, -1] = 0.0
OA = oW-center
BA = dummy-center
un = OA / la.norm(OA, axis=1)[:, None] # unit vector pointing along OO axis
OB = oW-dummy
s = (un*OB).sum(axis=1)
OC = s[:, None] * un
AC = OA - OC
ze = AC - BA
zaxis = ze / la.norm(ze, axis=1)[:, None]
zdotx= (zaxis*xaxis).sum(axis=1)
yaxis=np.cross(zaxis,xaxis,axis=1)
return xaxis, yaxis, zaxis
def H9GetHOHAxis(self,o,h1,h2):
xaxis = self.getBisectingVector(h1, o, h2) # bisector of HOH angle
h1on = (h1 - o) / la.norm(h1 - o, axis=1).reshape([-1, 1])
h2on = (h2 - o) / la.norm(h2 - o, axis=1).reshape([-1, 1])
zaxis = np.cross(h2on, h1on, axis=1)
yaxis = np.cross(zaxis,xaxis,axis=1)
return xaxis, yaxis, zaxis
def calcD(self,xx,O, H1, H2, H3):
# calc the unit vectors from O to Hi
# unit vectors are called "a"
#O -= 1
#H1 -= 1
#H2 -= 1
#H3 -= 1
# print('calculating the xxition of D')
# print(xx)
O = xx[:, O]
# Every walker's xyz coordinate for O
H1 = xx[:, H1]
H2 = xx[:, H2]
H3 = xx[:, H3]
#test = H1-O
aOH1 = np.divide((H1 - O), la.norm(H1 - O, axis=1)[:, np.newaxis]) # broadcasting silliness
aOH2 = np.divide((H2 - O), la.norm(H2 - O, axis=1)[:, np.newaxis])
aOH3 = np.divide((H3 - O), la.norm(H3 - O, axis=1)[:, np.newaxis])
# point in space along OH bonds that is 1 unit away from the O
aH1 = O + aOH1
aH2 = O + aOH2
aH3 = O + aOH3
# midpoint between unit vecs
# maH1H2 = (aH1 + aH2) / 2.0
# maH2H3 = (aH2 + aH3) / 2.0
# maH1H3 = (aH1 + aH3) / 2.0
# vectors between the points along the OH bonds that are 1 unit vector away from the O
vaH1H2 = aH2 - aH1
vaH2H3 = aH3 - aH2
# vaH1H3 = aH3 - aH1
# calculate vector
# line = np.zeros((xx.shape[0], 3))
# for i in range(xx.shape[0]):
# line[i] = np.cross(vaH1H2[i], vaH2H3[i].T)
# add normalized vector to O
line = np.cross(vaH1H2, vaH2H3, axis=1)
D = O + (line / la.norm(line, axis=1)[:, np.newaxis])
return D
def umbrellaDi(self,xx,O,H1,H2,H3):
#xx*=bohr2ang
"""O,H1,H2,H3 are indices. """
# calculate d, the trisector point of the umbrella
D = self.calcD(xx,O, H1, H2, H3)
addedX = np.concatenate((xx, D[:, np.newaxis, :]), axis=1) # Change D index
#Dihedrals
# a = 11
# b = 12
# c = 13
# di1 = self.fwiki_dihedral(addedX,b-1,c-1)
# di2 = self.fwiki_dihedral(addedX,a-1,b-1)
# di3 = self.fwiki_dihedral(addedX,c-1,a-1)
####/Dihedrals
di1 = np.zeros(len(xx))
di2 = np.zeros(len(xx))
di3 = np.zeros(len(xx))
getXYZ=False
if getXYZ:
wf = open('test_umb.xyz','w+')
trim = ["O","O","O","O","H","H","H","H","H","H","H","H","H","F"]
for wI, walker in enumerate(addedX):
wf.write("14\n")
wf.write("0.0 0.0 0.0 0.0 0.0\n")
for aI, atm in enumerate(walker):
wf.write("%s %5.12f %5.12f %5.12f\n" % (trim[aI], atm[0], atm[1], atm[2]))
wf.write("\n")
wf.close()
umbrell = self.ba(addedX, H2, O, -1) # 4 11 0 now O H1 0
return umbrell,di1,di2,di3
def getfinalOOAxes(self,atmnm,xx):
if atmnm == 11:
outerW = 2
at2 = 1
at3 = 3
elif atmnm == 12:
outerW = 3
at2 = 2
at3 = 1
elif atmnm == 13:
outerW = 1
at2 = 3
at3 = 2
oW = xx[:, outerW - 1, :] # Coordinates of outer water Oxygen
center = xx[:, 4 - 1, :]
dummy = np.copy(center)
dummy[:, -1] = 0.0
ZBig = np.cross(xx[:,at2-1]-dummy,xx[:,at3-1]-dummy,axis=1)
ZBig /= la.norm(ZBig,axis=1)[:,None]
xaxisp = np.divide((center - oW), la.norm(center - oW, axis=1).reshape(-1,1)) # Normalized coordinates of xpaxis definition. aka vector with only x component, where x = 1
oaHat=np.copy(xaxisp)
OB=dummy-oW
s=(oaHat*OB).sum(axis=1)
OC=oaHat*s[:,np.newaxis]
if np.all(np.around(OC,12)==np.around(OB,12)):
ze = np.copy(ZBig)
else:
ze=OC-OB
#at this point, my x axis points the 'wrong' direction. I will flip the sign
xaxis=np.divide((oW-center), la.norm(oW-center, axis=1).reshape(-1,1))
zaxis = ze / la.norm(ze, axis=1)[:, None]
sgn = np.where((ZBig * zaxis).sum(axis=1) < 0)[0]
zaxis[sgn] = np.negative(zaxis[sgn])
zaxis[len(zaxis)/2:] = np.negative(zaxis[len(zaxis)/2:])
yaxis = np.cross(zaxis, xaxis, axis=1)
zaxis[len(zaxis)/2:] = np.negative(zaxis[len(zaxis)/2:])
return xaxis,yaxis,zaxis
def eulerMatrix(self,x,y,z,X,Y,Z):
#Using the
#[X] [. . .][x]
#[Y] = [. . .][y]
#[Z] [. . .][z]
zdot=(z * Z).sum(axis=1) / (la.norm(z, axis=1) * la.norm(Z, axis=1))
Yzdot=(Y * z).sum(axis=1)/(la.norm(Y,axis=1) * la.norm(z,axis=1))
Xzdot=(X*z).sum(axis=1)/(la.norm(X,axis=1) * la.norm(z,axis=1))
yZdot=(y*Z).sum(axis=1) / (la.norm(y,axis=1) * la.norm(Z,axis=1))
xZdot=(x*Z).sum(axis=1) / (la.norm(x,axis=1) * la.norm(Z,axis=1))
Theta = np.arccos(zdot)
tanPhi = np.arctan2(Yzdot,Xzdot)
# tanPhi = np.absolute(tanPhi)
tanChi = np.arctan2(yZdot,-xZdot) #negative baked in
# tanChi = np.absolute(tanChi)
return Theta, tanPhi, tanChi
def HDihedral(self,xx):
if xx.shape[1] == 13:
d=self.calcD(xx, 4-1, 11-1, 12-1, 13-1)
a = 11
b = 12
c = 13
elif xx.shape[1] == 10:
d = self.calcD(xx, 3 - 1, 8 - 1, 10- 1, 9- 1)
a = 8
b = 10
c = 9
addedX = np.concatenate((xx, d[:, np.newaxis, :]), axis=1)
di1 = self.fwiki_dihedral(addedX,b-1,c-1)
di2 = self.fwiki_dihedral(addedX,a-1,b-1)
di3 = self.fwiki_dihedral(addedX,c-1,a-1)
return di1,di2,di3
def fwiki_dihedral(self,xx,b1A,b2A):
# https://stackoverflow.com/questions/20305272/dihedral-torsion-angle-from-four-points-in-cartesian-coordinates-in-python
b1=xx[:,b1A]-xx[:,-1]
b2=xx[:,b2A]-xx[:,-1]
if xx.shape[1] == 13+1:
b3=xx[:,4-1]-xx[:,-1]
elif xx.shape[1] == 10+1:
b3 = xx[:, 3-1] - xx[:, -1]
crossterm1 = np.cross(np.cross(b1,b2,axis=1),np.cross(b2,b3,axis=1),axis=1)
term1 = (crossterm1*(b2/la.norm(b2,axis=1)[:,np.newaxis])).sum(axis=1)
term2 = (np.cross(b1,b2,axis=1)*np.cross(b2,b3,axis=1)).sum(axis=1)
dh = np.arctan2(term1,term2)
return dh
def getHydroniumAxes(self,xx, group1,group2):
#group1 = list of indices that correspond to X axis, origin, and somewhere on xy plane for outer atoms
#group2 = list of indices that correspond to X axis, origin, and somewhere on xy plane for inner atoms
outerX = group1[0]-1
outerC = group1[1]-1
outerXY = group1[2]-1
innerX = group2[0]-1
innerC = group2[1]-1
innerXY = group2[2]-1
#For tetramer, this was 1-1-2-1 , then cross 1,2 with 3,2
X = (xx[:, outerX] - xx[:, outerC]) / la.norm(xx[:, outerX] - xx[:, outerC], axis=1)[:, np.newaxis]
cr = np.cross(xx[:, outerX] - xx[:, outerC], xx[:, outerXY] - xx[:, outerC])
Z = cr / la.norm(cr, axis=1)[:, np.newaxis]
Y = np.cross(Z, X)
# For tetramer, this was 13-1-11-1 , then cross 13,11 with 12,11
x = (xx[:, innerX] - xx[:, innerC]) / la.norm(xx[:, innerX] - xx[:, innerC], axis=1)[:, np.newaxis]
cr2 = np.cross(xx[:, innerX] - xx[:, innerC], xx[:, innerXY] - xx[:, innerC])
z = cr2 / la.norm(cr2, axis=1)[:, np.newaxis]
y = np.cross(z, x)
return X,Y,Z,x,y,z
def extractEulers(self,rotMs):
"""To get out euler angles from rotation matrices"""
# [x] [. . .][X]
# [y] = [. . .][Y]
# [z] [. . .][Z]
#be careful with which euler matrix you're using, body fixed space fixed stuff- DOESNT MATTER
zdot=rotMs[:,-1,-1]
Yzdot = rotMs[:,2,1]
Xzdot = rotMs[:,2,0]
yZdot = rotMs[:,1,2]
xZdot = rotMs[:,0,2]
Theta = np.arccos(zdot)
tanPhi = np.arctan2(Yzdot, Xzdot)
tanChi = np.arctan2(yZdot, xZdot) # negative not baked in
# tanChi[tanChi < 0]+=(2*np.pi)
tanPhi[tanPhi < 0]+=(2*np.pi)
return Theta,tanPhi,tanChi
def finalPlaneShareEuler(self,xx):
atmnm=11
h1 = 8
h2 = 7
o = 2
X,Y,Z = self.getfinalOOAxes(atmnm,xx)
x,y,z = self.H9GetHOHAxis(xx[:,o-1],xx[:,h1-1],xx[:,h2-1])
exx = np.copy(x)
x = np.copy(y)
y = np.copy(z)
z = np.copy(exx)
print('lets get weird')
exX = np.copy(X)
X = np.copy(Z)
Z = np.copy(Y)
Y = np.copy(exX)
th11,phi11,xi11 = self.eulerMatrix(x,y,z,X,Y,Z)
atmnm=12
h1 = 9
h2 = 10
o = 3
X,Y,Z = self.getfinalOOAxes(atmnm,xx)
x,y,z = self.H9GetHOHAxis(xx[:,o-1],xx[:,h1-1],xx[:,h2-1])
exx = np.copy(x)
x = np.copy(y)
y = np.copy(z)
z = np.copy(exx)
# print('lets get weird')
exX = np.copy(X)
X = np.copy(Z)
Z = np.copy(Y)
Y = np.copy(exX)
th12,phi12,xi12 = self.eulerMatrix(x,y,z,X,Y,Z)
atmnm=13
h1 = 6
h2 = 5
o = 1
X,Y,Z = self.getfinalOOAxes(atmnm,xx)
x,y,z = self.H9GetHOHAxis(xx[:,o-1],xx[:,h1-1],xx[:,h2-1])
exx = np.copy(x)
x = np.copy(y)
y = np.copy(z)
z = np.copy(exx)
# print('lets get weird')
exX = np.copy(X)
X = np.copy(Z)
Z = np.copy(Y)
Y = np.copy(exX)
th13,phi13,xi13 = self.eulerMatrix(x,y,z,X,Y,Z)
print('eckarting...')
# ocom, eVecs,kil=self.eckartRotate(xx,planar=True,lst=[1-1,2-1,3-1,4-1],dip=True)
ocom, eVecs,kil=self.eckartRotate(xx,planar=True,lst=[1-1,2-1,3-1],dip=True)
print('got matrix')
xx-=ocom[:,np.newaxis,:]
print('done')
print('b4')
xx = np.einsum('knj,kij->kni', eVecs.transpose(0, 2, 1), xx).transpose(0, 2, 1)
print('af')
#calculate center of mass of central hydronium
lst = [4-1,11-1,12-1,13-1]
mass = self.get_mass()
mass = mass[lst]
hyd = xx[:, lst]
ocomH = np.dot(mass, hyd) / np.sum(mass)
del hyd
del mass
oh11 = xx[:,11-1]-xx[:,4-1]
oh12 = xx[:,12-1]-xx[:,4-1]
oh13 = xx[:,13-1]-xx[:,4-1]
roh11 = la.norm(oh11, axis=1)
roh12 = la.norm(oh12, axis=1)
roh13 = la.norm(oh13, axis=1)
thH11 = np.arccos(oh11[:, -1] / roh11) #z/r
thH12 = np.arccos(oh12[:, -1] / roh12)
thH13 = np.arccos(oh13[:, -1] / roh13)
phH11= np.arctan2(oh11[:, 1], oh11[:, 0]) # y / x
phH12 = np.arctan2(oh12[:, 1], oh12[:, 0])
phH13 = np.arctan2(oh13[:, 1], oh13[:, 0])
return ocomH[:, 0], ocomH[:, 1], ocomH[:,2], roh11,roh12,roh13,thH11,thH12,thH13,phH11,phH12,phH13,th11, phi11, xi11, th12, phi12, xi12, th13, phi13, xi13
def SymInternalsH9O4plus(self,x):
print('Commence getting internal coordinates for tetramer')
start = time.time()
#good defs
all = self.finalPlaneShareEuler(x)
xyzO4 = all[0:3]
rOHHyd = all[3:6]
thHyd = all[6:9]
phHyd = all[9:12]
thphixi1=all[12:15]
thphixi2=all[15:18]
thphixi3=all[18:21]
print('done hydronium XYZ')
print('time it took to get xyzs,eulers: ',str(time.time()-start))
third = time.time()
rOH5 = self.bL(x,5-1,1-1)
rOH6 = self.bL(x,6-1,1-1)
HOH516 = self.ba(x,5-1,1-1,6-1)
rOH7 = self.bL(x,7-1,2-1)
rOH8 = self.bL(x,8-1,2-1)
HOH728 = self.ba(x,7-1,2-1,8-1)
rOH9 = self.bL(x,9-1,3-1)
rOH10 = self.bL(x,10-1,3-1)
HOH9310 = self.ba(x,9-1,3-1,10-1)
rO1O2 = self.bL(x,2-1,1-1)
rO1O3 = self.bL(x,1-1,3-1)
rO2O3 = self.bL(x,2-1,3-1)
print('time for rOO/rOH', str(time.time() - third))
print('Done with all internals')
internal = np.array(
(rOHHyd[0], rOHHyd[1], rOHHyd[2], thHyd[0], thHyd[1], thHyd[2], phHyd[0], phHyd[1], phHyd[2],
thphixi1[0], thphixi1[1], thphixi1[2], thphixi2[0], thphixi2[1], thphixi2[2], thphixi3[0], thphixi3[1],
thphixi3[2], rOH5, rOH6, HOH516, rOH7, rOH8, HOH728, rOH9, rOH10, HOH9310, rO1O2, rO1O3, rO2O3,
xyzO4[0], xyzO4[1], xyzO4[2])).T
self.internalName = ['rOH11', 'rOH12', 'rOH13', 'thH11','thH12','thH13','phH11','phH12','phH13',
'theta728','phi728', 'Chi728','theta1039', 'phi1039', 'Chi1039', 'theta651', 'phi651',
'Chi651', 'rOH5', 'rOH6','HOH516', 'rOH7', 'rOH8', 'HOH728','rOH9', 'rOH10', 'HOH9310', 'rO1O2', 'rO1O3', 'rO2O3',
'xo4', 'yo4', 'zo4']
print('internal shape: ',np.shape(internal))
print('internal[0] shape: ',np.shape(internal[0]))
return internal
def SymInternalsH3O(self,xx):
r1 = self.bL(xx,4-1,1-1)
r2 = self.bL(xx,4-1,2-1)
r3 = self.bL(xx,4-1,3-1)
hoh1 = self.ba(xx,1-1,4-1,2-1)
hoh2 = self.ba(xx,2-1,4-1,3-1)
hoh3 = self.ba(xx,3-1,4-1,1-1)
brel,c,d,e = self.umbrellaDi(xx,4-1,1-1,2-1,3-1)
dh1 = 2*hoh1 - hoh2 - hoh3
dh2 = hoh2-hoh3
# self.internalName = ['rOH1','rOH2','rOH3','hoh1','hoh2','hoh3','brel']
# internals = np.array((r1,r2,r3,hoh1,hoh2,hoh3,brel)).T
self.internalName = ['rOH1','rOH2','rOH3','brel','dh1','dh2']
internals = np.array((r1,r2,r3,brel,dh1,dh2)).T
# print(r1[0]*bohr2ang)
# print(r2[0] * bohr2ang)
# print(r3[0] * bohr2ang)
# print(np.degrees(brel[0]))
# print(np.degrees(dh1[0]))
# print(np.degrees(dh2[0]))
return internals
def setInternalName(self):
if self.name in DeprotonatedWaterDimer:
self.internalName=[]
elif self.name in ProtonatedWaterTrimer:
self.internalName = ['rOH8', 'thH8', 'phiH8', 'rOH9', 'thH9', 'phiH9', 'rOH10', 'thH10', 'phiH10',
'th_627', 'phi_627', 'xi_627', 'th_514', 'phi_514', 'xi_514', 'rOH_41',
'rOH_51', 'aHOH_451', 'rOH_26', 'rOH_27', 'aHOH_267', 'rOO_1', 'rOO_2', 'aOOO']
elif self.name in ProtonatedWaterTetramer:
self.internalName = ['rOH11', 'rOH12', 'rOH13', 'thH11', 'thH12', 'thH13', 'phH11', 'phH12', 'phH13',
'theta728', 'phi728', 'Chi728', 'theta1039', 'phi1039', 'Chi1039', 'theta651',
'phi651',
'Chi651', 'rOH5', 'rOH6', 'HOH516', 'rOH7', 'rOH8', 'HOH728', 'rOH9', 'rOH10',
'HOH9310', 'rO1O2', 'rO1O3', 'rO2O3',
'xo4', 'yo4', 'zo4']
else:
self.internalName = ['rOH1', 'rOH2', 'rOH3', 'brel', 'dh1', 'dh2']
def sphericalTrimer(self,xx):
com, eckVecs, killList = self.eckartRotate(xx,planar=True,lst=[1-1,2-1,3-1],dip=True)
xx -= com[:, np.newaxis, :]
xx = np.einsum('knj,kij->kni', eckVecs.transpose(0, 2, 1), xx).transpose(0, 2, 1)
oh8 = xx[:,8-1]-xx[:,3-1]
oh9 = xx[:, 9 - 1] - xx[:, 3 - 1]
oh10 = xx[:, 10 - 1] - xx[:, 3 - 1]
roh8 = la.norm(oh8,axis=1)
roh9 = la.norm(oh9,axis=1)
roh10 = la.norm(oh10,axis=1)
thH8 = np.arccos(oh8[:,-1]/roh8) #z / r
# thH8 = np.absolute(thH8-np.pi/2.)+np.pi/2.
thH9 = np.arccos(oh9[:, -1] / roh9)
# thH9 = np.absolute(thH9-np.pi/2.)+np.pi/2.
thH10 = np.arccos(oh10[:, -1] / roh10)
# thH10 = np.absolute(thH10-np.pi/2.)+np.pi/2.
# phH8 = np.arctan2(oh8[:,1],oh8[:,0]) #y / x
# self.ba(x, 1 - 1, 3 - 1, 2 - 1)
hoh1 = self.ba(xx,8-1,3-1,9-1)
hoh2 = self.ba(xx,8-1,3-1,10-1)
phH8 = hoh1-hoh2
phH9 = np.arctan2(oh9[:,1],oh9[:,0])
phH10 = np.arctan2(oh10[:,1],oh10[:,0])
return roh8, roh9, roh10, thH8,thH9,thH10,phH8,phH9,phH10
def cartTrimer(self,xx):
com, eckVecs, killList = self.eckartRotate(xx,planar=True,lst=[1-1,2-1,3-1],dip=True)
xx -= com[:, np.newaxis, :]
xx = np.einsum('knj,kij->kni', eckVecs.transpose(0, 2, 1), xx).transpose(0, 2, 1)
oh8 = xx[:,8-1]-xx[:,3-1]
oh9 = xx[:, 9 - 1] - xx[:, 3 - 1]
oh10 = xx[:, 10 - 1] - xx[:, 3 - 1]
return oh8[:,0],oh9[:,0],oh10[:,0],oh8[:,1],oh9[:,1],oh10[:,1],oh8[:, 2], oh9[:, 2], oh10[:, 2],
def SymInternalsH7O3plus(self,x):
print('Commence getting internal coordinates for trimer')
#Hydronium
rOH8,rOH9,rOH10,thH8,thH9,thH10,phH8,phH9,phH10 = self.sphericalTrimer(x)
print('hydronium')
thphixi1= self.finalTrimerEuler(x,2,7,6)
print('done with Euler1')
thphixi2 = self.finalTrimerEuler(x,1,4,5)
print('done with Euler2')
rOH1 = self.bL(x,1-1,4-1)
rOH2 = self.bL(x,1-1,5-1)
aHOH1= self.ba(x,5-1,1-1,4-1)
rOH3 = self.bL(x,2-1,6-1)
rOH4 = self.bL(x,2-1,7-1)
aHOH2= self.ba(x,6-1,2-1,7-1)
rOO1 = self.bL(x,1-1,3-1)
rOO2 = self.bL(x,2-1,3-1)
aOOO = self.ba(x,1-1,3-1,2-1)
print('first O1H4 bond length: ', rOH1[0]*bohr2ang)
print('first Angle: ',np.degrees(aOOO[0]))
internal = np.array((rOH8, thH8, phH8, rOH9, thH9, phH9, rOH10, thH10, phH10,
thphixi1[0], thphixi1[1], thphixi1[2], thphixi2[0], thphixi2[1], thphixi2[2],
rOH1, rOH2, aHOH1, rOH3, rOH4, aHOH2, rOO1, rOO2, aOOO)).T
self.internalName = ['rOH8', 'thH8', 'phiH8','rOH9', 'thH9', 'phiH9','rOH10', 'thH10', 'phiH10',
'th_627', 'phi_627','xi_627', 'th_514', 'phi_514', 'xi_514', 'rOH_41',
'rOH_51', 'aHOH_451', 'rOH_26','rOH_27', 'aHOH_267','rOO_1', 'rOO_2', 'aOOO']
return internal
def SymInternalsH3O2minus(self,x): #get an array of all the internal coordinates associated with H3O2 minus
#print('calculating the internals...ver 1...')
#internals used in jpc a paper
#print('called symInternalsVer1. Please only provide eckart rotated molecules. Thank you.')
# print('The first walker is: \n', x[0] )
rOH1=self.bondlength(x,atom1=1,atom2=2)
rOH2=self.bondlength(x,atom1=3,atom2=4)
rOO=self.bondlength(x,atom1=1,atom2=3)
aHOO1=self.bondAngle(x,atom1=2, atom2=1, atom3=3)
aHOO2=self.bondAngle(x,atom1=4, atom2=3, atom3=1)
tHOOH,tRange=self.calcTorsion(x)
HdispX,HdispY, HdispZ = self.calcCartesianSharedProtonDisplacement(x)
#rn=self.calcRn(x)
#NOW SYMETRIZE
rOH_s=np.sqrt(0.5)*(rOH1+rOH2) #symetric
rOH_a=np.sqrt(0.5)*(rOH1-rOH2) #asym stretch
#rOH_ai=0.5*(rOH1-rOH2+rOH3-rOH4) # in phase anti sym
#rOH_ao=0.5*(rOH1-rOH2-rOH3+rOH4) #out of phase anti sym
aHOO_s=np.sqrt(0.5)*(aHOO1+aHOO2) #symetric
aHOO_a=np.sqrt(0.5)*(aHOO1-aHOO2) #asymetric
#rearrange these
if rOH1.size<2:
internal = np.array( [rOH_s, rOH_a, rOO, aHOO_s, aHOO_a,tHOOH, HdispX,HdispY,HdispZ])
#internal = np.array( [rOH_s, rOH_a, rOO, aHOO_s, aHOO_a,tHOOH, rn,HdispY,HdispZ])
else:
internal = np.array(zip(rOH_s, rOH_a, rOO, aHOO_s, aHOO_a,tHOOH, HdispX,HdispY,HdispZ))
#internal = np.array(zip(rOH_s, rOH_a, rOO, aHOO_s, aHOO_a,tHOOH, rn,HdispY,HdispZ))
self.internalName=['rOH_s', 'rOH_a', 'rOO', 'rHOO_s', 'rHOO_a', 'tHOOH','HdispX','HdispY','HdispZ']
#self.internalName=['rOH_s', 'rOH_a', 'rOO', 'rHOO_s', 'rHOO_a', 'tHOOH','rn','HdispY','HdispZ']
self.internalConversion=[bohr2ang,bohr2ang,bohr2ang,rad2deg,rad2deg,rad2deg,bohr2ang,bohr2ang,bohr2ang]
return internal
def pullTrimerRefPos(self,yz=False,dip=False): #Eckart reference for the trimer is in an xyz file. Need just a 3xNatom array of reference structures. I can hard code this in
#This one is good.
# myBetterRef = np.array(
# [
# [3.15544362E-30 , 4.06869143E+00, -7.59761292E-01],
# [-4.98270994E-16, -4.06869143E+00 ,-7.59761292E-01],
# [-1.97215226E-30, 0.00000000E+00, 1.58929880E+00],
# [ 1.47532198E+00, 5.00324669E+00, -1.29932702E+00],
# [ -1.47532198E+00, 5.00324669E+00, -1.29932702E+00],
# [ -1.47532198E+00, -5.00324669E+00 ,-1.29932702E+00],
# [ 1.47532198E+00, -5.00324669E+00, -1.29932702E+00],
# [ -3.94430453E-30, -2.22044605E-16, 3.41400471E+00],
# [ 7.88860905E-31, 1.69178407E+00, 6.12546816E-01],
# [ -2.07183794E-16, -1.69178407E+00, 6.12546816E-01]])
# myBetterRef = np.array(
# [
# [-2.34906009e+00, 4.06869143e+00, 0.00000000e+00],
# [ 4.69812018e+00, 0.00000000e+00, 0.00000000e+00],
# [ 0.00000000e+00, 0.00000000e+00, 0.00000000e+00],
# [-2.88862583e+00, 5.00324669e+00, 1.47532198e+00],
# [-2.88862583e+00, 5.00324669e+00, -1.47532198e+00],
# [ 5.77725164e+00, -2.46900000e-09, -1.47532198e+00],
# [ 5.77725164e+00, -2.46900000e-09, 1.47532198e+00],
# [-9.12352955e-01, -1.58024167e+00, 0.00000000e+00],
# [-9.76751990e-01, 1.69178407e+00, 0.00000000e+00],
# [ 1.95350397e+00, -3.53000000e-09, 0.00000000e+00]])
myBetterRef = np.array(
[
[-2.34906009e+00, 4.06869143e+00, 0.00000000e+00],
[ 4.69812018e+00, 0.00000000e+00, 0.00000000e+00],
[ 0.00000000e+00, 0.00000000e+00, 0.00000000e+00],
[-2.88862583e+00, 5.00324669e+00, 1.47532198e+00],
[-2.88862583e+00, 5.00324669e+00, -1.47532198e+00],
[ 5.77725164e+00, -2.46900000e-09, 1.47532198e+00],
[ 5.77725164e+00, -2.46900000e-09, -1.47532198e+00],#6 and 7 better alinged with walkers themselves rather than my printout.
[-9.12352955e-01, -1.58024167e+00, 0.00000000e+00],
[-9.76751990e-01, 1.69178407e+00, 0.00000000e+00],
[1.95350397e+00, -3.53000000e-09, 0.00000000e+00]
])
# myBetterRef = np.array(
# [
# [0.00000000E+00 , 4.09812725E+00 ,-7.66773992E-01 ],
# [-5.01875842E-16, -4.09812725E+00 ,-7.66773992E-01],
# [1.23259516E-31, 0.00000000E+00, 1.59928088E+00],
# [0.00000000E+00, 5.76624514E+00, -1.83972876E-02 ],
# [-1.97215226E-31, 4.32405303E+00, -2.58026572E+00],
# [-7.06161366E-16, -5.76624514E+00, -1.83972876E-02], #7
# [-5.29543770E-16, -4.32405303E+00, -2.58026572E+00], # 6
# [2.95822839E-31, 0.00000000E+00, 3.42362148E+00],
# [9.86076132E-32, 1.68937343E+00, 6.23920678E-01],
# [-2.06888576E-16, -1.68937343E+00, 6.23920678E-01],
# ] #TOTALLY PLANAR
# )
if dip:
print("Principal Axis Eckart")
myBetterRef = self.rotateBackToFrame(np.array([myBetterRef,myBetterRef]),3,8,2)[0]
else:
myBetterRef = self.rotateBackToFrame(np.array([myBetterRef, myBetterRef]), 3, 2, 1)[0]
# fll = open("newEckart_trimer_allH.xyz","w+")
# self.printCoordsToFile(np.array([myBetterRef,myBetterRef]),fll)
# print(myBetterRef)
if yz:
# print('yz - ref structure turned')
rotM = np.array([[0.,0.,1.],
[0, 1, 0],
[-1.,0,0.]
])
# print('yz - ref structure turned (rotation about x axis)'
# rotM = np.array([[1.,0.,0.],
# [0, 0., -1.],
# [0.,1.,0.]])
myBetterRef= np.dot(rotM,myBetterRef.T).T