Psithon Table Usage

Hello Everyone !

I just made an input file in which I am storing my results into the Table and then printing it out . Why psi4 outputs me an error saying Invalid syntax ?

This is my input file :

ch3cl_acetone scan

import numpy as np
memory 24 GB

molecule ch3cl_acetone {
0 1
C 3.32807382 -0.46979835 -1.50619015
H 3.78060806 -0.17635241 -0.58206773
H 3.52366548 -1.50632347 -1.68579964
H 3.73662824 0.11382040 -2.30454624
Cl 7 R1 6 180 8 95.83232

0 1
C -1.45820104 0.54178831 -0.57092078
O -0.25653349 0.28377346 -0.81624384
C -2.40629683 0.98953016 -1.69885766
C -1.95815240 0.50281340 0.88514570
H -3.11460164 1.69186797 -1.31165499
H -1.83852894 1.44962882 -2.48042585
H -2.92450180 0.13818706 -2.08818853
H -2.70944886 1.25184320 1.02445827
H -2.37256634 -0.46125415 1.09427448
H -1.13981081 0.69077117 1.54838692
X 7 1.22977 5 A2 1 -67.57633

}

R1_vals=np.arange(2,5,.2)
print R1_vals
A2_vals=range(90,180,10)

table=Table(rows=[“R”,“A”], cols=[“E(Electrostatics)”,"E(Exchange),“E(Induction)”,“E(Dispersion)”,“E(Total Energy)”])

set basis = aug-cc-pvtz

for R in R1_vals:
ch3cl_acetone.R1=R
for A in A2_vals:
ch3cl_acetone.A2=A
energy(‘sapt2+3’,molecule=ch3cl_acetone)
Eelst = get_variable(‘SAPT2+3 ELST ENERGY’)
Eexch = get_variable(‘SAPT2+3 EXCH ENERGY’)
Eind = get_variable(‘SAPT2+3 IND ENERGY’)
Edisp = get_variable(‘SAPT2+3 DISP ENERGY’)
ET = get_variable(‘SAPT2+3 TOTAL ENERGY’)
table[R][A] = [Eelst, Eexch, Eind,Edisp,ET]

print table

This is my error :

Traceback (most recent call last):
File “/home2/shreyac/psi4conda/bin/psi4”, line 248, in
exec(content)

SyntaxError: invalid syntax (, line 49)

-Thank you

because your chlorine is bonded to atom 7 when atom 7 hasn’t been defined yet. strategic commenting can help :slight_smile:

play around with the Table class if you like, but it isn’t very powerful and there are other python modules that can do tables slicker.

1 Like

I don’t think my error is because of ordering/numbering because when I comment my code starting from Eelst = get_variable(‘SAPT2+3 ELST ENERGY’) to the end (including print table) , my job runs and does not who any error .

what are the other python modules that you are saying that I can use ?
but why is this code not working ?

-Thank you

RuntimeError: 
Fatal Error: Error on geometry input line Cl 7 R1 6 180 8 95.83232
Atom 7 has not been defined yet.

Among other errors, perhaps you didn’t correct the quotes after copying. Below runs

[2.  2.2]
         R          AE(Electrostatics)      E(Exchange)     E(Induction)    E(Dispersion)  E(Total Energy)
       2.0        3.3   -0.0034082770     0.0046062474     0.0527740754    -0.0025875491     0.0513844967
       2.2        3.3   -0.0036015988     0.0044937697     0.0644926007    -0.0026033314     0.0627814402
# ch3cl_acetone scan
import numpy as np
memory 24 GB

#molecule ch3cl_acetone {
#0 1
#C 3.32807382 -0.46979835 -1.50619015
#H 3.78060806 -0.17635241 -0.58206773
#H 3.52366548 -1.50632347 -1.68579964
#H 3.73662824 0.11382040 -2.30454624
#Cl 7 R1 6 180 8 95.83232
#0 1
#C -1.45820104 0.54178831 -0.57092078
#O -0.25653349 0.28377346 -0.81624384
#C -2.40629683 0.98953016 -1.69885766
#C -1.95815240 0.50281340 0.88514570
#H -3.11460164 1.69186797 -1.31165499
#H -1.83852894 1.44962882 -2.48042585
#H -2.92450180 0.13818706 -2.08818853
#H -2.70944886 1.25184320 1.02445827
#H -2.37256634 -0.46125415 1.09427448
#H -1.13981081 0.69077117 1.54838692
#X 7 1.22977 5 A2 1 -67.57633
#
#}

molecule dimer {
0 1
C   0.000000  -0.667578  -2.124659
C   0.000000   0.667578  -2.124659
H   0.923621  -1.232253  -2.126185
H  -0.923621  -1.232253  -2.126185
H  -0.923621   1.232253  -2.126185
H   0.923621   1.232253  -2.126185
--
0 1
C   R1   0.000000   2.900503
C   0.000000   0.000000   1.693240
H   0.000000   0.000000   0.627352
H   0.000000   0.000000   3.963929
units angstrom
}

R1_vals = np.arange(2,2.4,.2)
print(R1_vals)
A2_vals=range(90,180,10)

table=Table(rows=['R','A'], cols=['E(Electrostatics)','E(Exchange)','E(Induction)','E(Dispersion)','E(Total Energy)'])

set basis = aug-cc-pvdz

for R in R1_vals:
    dimer.R1=R
    A = 3.3
    energy('sapt0', molecule=dimer)
    Eelst = get_variable('SAPT0 ELST ENERGY')
    Eexch = get_variable('SAPT0 EXCH ENERGY')
    Eind = get_variable('SAPT0 IND ENERGY')
    Edisp = get_variable('SAPT0 DISP ENERGY')
    ET = get_variable('SAPT0 TOTAL ENERGY')
    table[R][A] = [Eelst, Eexch, Eind,Edisp,ET]

print(table)
1 Like

Thank you so much for your help :smiley: !