mirror of
https://github.com/nwchemgit/nwchem.git
synced 2026-07-27 13:45:27 -04:00
Make more examples Python 3 compatible
This commit is contained in:
parent
bb3fb8f0f0
commit
87c3f19104
12 changed files with 74 additions and 59 deletions
|
|
@ -19,6 +19,8 @@ end
|
|||
print none
|
||||
|
||||
python noprint
|
||||
from __future__ import print_function
|
||||
|
||||
from mathutil import *
|
||||
|
||||
# It should only be necessary to modify these three lines for
|
||||
|
|
@ -38,12 +40,12 @@ python noprint
|
|||
return task_energy(theory)
|
||||
|
||||
def printexp(z):
|
||||
print "\n Exponents:"
|
||||
print("\n Exponents:")
|
||||
for i in range(len(z)):
|
||||
print " %14.8f" % (z[i]*z[i]),
|
||||
if ((i+1)%5) == 0:
|
||||
print ""
|
||||
print " "
|
||||
print("")
|
||||
print(" ")
|
||||
|
||||
z = array('d',exponents)
|
||||
for i in range(len(z)):
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ set int:acc_std 1e-25
|
|||
print none
|
||||
|
||||
python noprint
|
||||
from __future__ import print_function
|
||||
from mathutil import *
|
||||
|
||||
# It should only be necessary to modify these three lines for
|
||||
|
|
@ -62,12 +63,12 @@ python noprint
|
|||
return task_energy(theory)
|
||||
|
||||
def printexp(z):
|
||||
print "\n Exponents:"
|
||||
print("\n Exponents:")
|
||||
for i in range(len(z)):
|
||||
print " %14.8f" % (z[i]*z[i]),
|
||||
if ((i+1)%5) == 0:
|
||||
print ""
|
||||
print " "
|
||||
print("")
|
||||
print(" ")
|
||||
|
||||
z = array('d',exponents)
|
||||
for i in range(len(z)):
|
||||
|
|
|
|||
|
|
@ -24,6 +24,8 @@ set int:acc_std 1e-25
|
|||
print none
|
||||
|
||||
python noprint
|
||||
from __future__ import print_function
|
||||
|
||||
from mathutil import *
|
||||
|
||||
# It should only be necessary to modify these three lines for
|
||||
|
|
@ -74,12 +76,12 @@ python noprint
|
|||
return task_energy(theory)
|
||||
|
||||
def printexp(z):
|
||||
print "\n Exponents:"
|
||||
print("\n Exponents:")
|
||||
for i in range(len(z)):
|
||||
print " %14.8f" % (z[i]*z[i]),
|
||||
print(" %14.8f" % (z[i]*z[i]),)
|
||||
if ((i+1)%5) == 0:
|
||||
print ""
|
||||
print " "
|
||||
print("")
|
||||
print(" ")
|
||||
|
||||
z = array('d',exponents)
|
||||
for i in range(len(z)):
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ set int:acc_std 1e-25
|
|||
print none
|
||||
|
||||
python
|
||||
from __future__ import print_function
|
||||
from mathutil import *
|
||||
|
||||
n = 6
|
||||
|
|
@ -56,13 +57,13 @@ python
|
|||
|
||||
def printexp(z):
|
||||
exponents = make_exp(z)
|
||||
print '\n alpha %f beta %f' % (z[0]*z[0],z[1]*z[1])
|
||||
print ' Exponents:'
|
||||
print('\n alpha %f beta %f' % (z[0]*z[0],z[1]*z[1]))
|
||||
print(' Exponents:')
|
||||
for i in range(n):
|
||||
print " %14.8f" % exponents[i],
|
||||
print(" %14.8f" % exponents[i],)
|
||||
if ((i+1)%5) == 0:
|
||||
print ""
|
||||
print " "
|
||||
print("")
|
||||
print(" ")
|
||||
|
||||
z = zerovector(2)
|
||||
z[0] = sqrt(alpha - 0.001)
|
||||
|
|
@ -73,13 +74,13 @@ python
|
|||
(value,z) = quasinr(energy, z, 1e-4, 1e-9, printexp)
|
||||
(alpha, beta) = make_alpha_beta(z)
|
||||
results[n] = (alpha, beta, value)
|
||||
print '\n\n Results\n'
|
||||
print ' n alpha beta energy error '
|
||||
print ' --- --------- --------- ------------ -----------'
|
||||
print('\n\n Results\n')
|
||||
print(' n alpha beta energy error ')
|
||||
print(' --- --------- --------- ------------ -----------')
|
||||
(alpha, beta, limit) = results[20]
|
||||
for n in range(2,21):
|
||||
(alpha, beta, value) = results[n]
|
||||
print '%4i %10.6f %10.6f %12.6f %12.6f' % (n, alpha, beta, value, value-limit)
|
||||
print('%4i %10.6f %10.6f %12.6f %12.6f' % (n, alpha, beta, value, value-limit))
|
||||
end
|
||||
|
||||
task python
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ mp2; tight; freeze core atomic; end
|
|||
#print low
|
||||
|
||||
python noprint
|
||||
from __future__ import print_function
|
||||
supermolecule = 'geometry noprint; N 13.356 -4.360 16.307;H 12.631 -4.575 16.716;N 11.384 -5.455 18.225;C 10.267 -4.749 18.620 ; end\n'
|
||||
fragment1 = 'geometry noprint; N 13.356 -4.360 16.307;H 12.631 -4.575 16.716;bqN 11.384 -5.455 18.225;bqC 10.267 -4.749 18.620; end\n'
|
||||
fragment2 = 'geometry noprint; bqN 13.356 -4.360 16.307;bqH 12.631 -4.575 16.716;N 11.384 -5.455 18.225;C 10.267 -4.749 18.620; end\n'
|
||||
|
|
@ -31,7 +32,7 @@ def bsse_energy():
|
|||
|
||||
e = bsse_energy()
|
||||
if (ga_nodeid() == 0):
|
||||
print ' BSSE energy (hartrees) = %10.7f ' % (e)
|
||||
print(' BSSE energy (hartrees) = %10.7f ' % (e))
|
||||
end
|
||||
|
||||
task python
|
||||
|
|
|
|||
|
|
@ -38,6 +38,8 @@ set int:acc_std 1e-25
|
|||
print none
|
||||
|
||||
python
|
||||
from __future__ import print_function
|
||||
|
||||
from mathutil import *
|
||||
|
||||
run_type = "scf"
|
||||
|
|
@ -129,13 +131,13 @@ python
|
|||
def printexp(z):
|
||||
function_type = ["s", "p", "d", "f", "g", "h", "i"]
|
||||
exponents = make_exp(z)
|
||||
print ' Exponents:'
|
||||
print(' Exponents:')
|
||||
for j in range(0,l+1):
|
||||
print "%s - functions" % (function_type[j])
|
||||
print("%s - functions" % (function_type[j]))
|
||||
for i in range(0,n[j]):
|
||||
print " %14.8f" % exponents[i][j]
|
||||
print ""
|
||||
print " "
|
||||
print(" %14.8f" % exponents[i][j])
|
||||
print("")
|
||||
print(" ")
|
||||
|
||||
# Setup list of variables to be optimized
|
||||
|
||||
|
|
@ -174,14 +176,14 @@ python
|
|||
|
||||
# Print the final results
|
||||
|
||||
print '\n\n Results\n'
|
||||
print ' l n exp0 beta gamma '
|
||||
print ' --- --- --------- --------- --------- '
|
||||
print('\n\n Results\n')
|
||||
print(' l n exp0 beta gamma ')
|
||||
print(' --- --- --------- --------- --------- ')
|
||||
for j in range(0,l+1):
|
||||
(exp0_n, beta_n, gamma_n) = get_exp0_beta_gamma(z,j)
|
||||
print '%4i %4i %12.6f %10.6f %10.6f' % (j, n[j], exp0_n, beta_n, gamma_n)
|
||||
print '\n Final energy difference = %12.6f' % value
|
||||
print '\n Energy without Coulomb fitting = %12.6f' % reference
|
||||
print('%4i %4i %12.6f %10.6f %10.6f' % (j, n[j], exp0_n, beta_n, gamma_n))
|
||||
print('\n Final energy difference = %12.6f' % value)
|
||||
print('\n Energy without Coulomb fitting = %12.6f' % reference)
|
||||
printexp(z)
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ set int:acc_std 1e-25
|
|||
print none
|
||||
|
||||
python
|
||||
from __future__ import print_function
|
||||
from mathutil import *
|
||||
|
||||
run_type = "scf"
|
||||
|
|
@ -129,13 +130,13 @@ python
|
|||
def printexp(z):
|
||||
function_type = ["s", "p", "d", "f", "g", "h", "i"]
|
||||
exponents = make_exp(z)
|
||||
print ' Exponents:'
|
||||
print(' Exponents:')
|
||||
for j in range(0,l+1):
|
||||
print "%s - functions" % (function_type[j])
|
||||
print("%s - functions" % (function_type[j]))
|
||||
for i in range(0,n[j]):
|
||||
print " %14.8f" % exponents[i][j]
|
||||
print ""
|
||||
print " "
|
||||
print(" %14.8f" % exponents[i][j])
|
||||
print("")
|
||||
print(" ")
|
||||
|
||||
# Setup list of variables to be optimized
|
||||
|
||||
|
|
@ -174,14 +175,14 @@ python
|
|||
|
||||
# Print the final results
|
||||
|
||||
print '\n\n Results\n'
|
||||
print ' l n exp0 beta gamma '
|
||||
print ' --- --- --------- --------- --------- '
|
||||
print('\n\n Results\n')
|
||||
print(' l n exp0 beta gamma ')
|
||||
print(' --- --- --------- --------- --------- ')
|
||||
for j in range(0,l+1):
|
||||
(exp0_n, beta_n, gamma_n) = get_exp0_beta_gamma(z,j)
|
||||
print '%4i %4i %12.6f %10.6f %10.6f' % (j, n[j], exp0_n, beta_n, gamma_n)
|
||||
print '\n Final energy difference = %12.6f' % value
|
||||
print '\n Energy without Coulomb fitting = %12.6f' % reference
|
||||
print('%4i %4i %12.6f %10.6f %10.6f' % (j, n[j], exp0_n, beta_n, gamma_n))
|
||||
print('\n Final energy difference = %12.6f' % value)
|
||||
print('\n Energy without Coulomb fitting = %12.6f' % reference)
|
||||
printexp(z)
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ set int:acc_std 1e-25
|
|||
print none
|
||||
|
||||
python
|
||||
from __future__ import print_function
|
||||
from mathutil import *
|
||||
|
||||
run_type = "scf"
|
||||
|
|
@ -127,13 +128,13 @@ python
|
|||
def printexp(z):
|
||||
function_type = ["s", "p", "d", "f", "g", "h", "i"]
|
||||
exponents = make_exp(z)
|
||||
print ' Exponents:'
|
||||
print(' Exponents:')
|
||||
for j in range(0,l+1):
|
||||
print "%s - functions" % (function_type[j])
|
||||
print("%s - functions" % (function_type[j]))
|
||||
for i in range(0,n[j]):
|
||||
print " %14.8f" % exponents[i][j]
|
||||
print ""
|
||||
print " "
|
||||
print(" %14.8f" % exponents[i][j])
|
||||
print("")
|
||||
print(" ")
|
||||
|
||||
# Setup list of variables to be optimized
|
||||
|
||||
|
|
@ -170,14 +171,14 @@ python
|
|||
|
||||
# Print the final results
|
||||
|
||||
print '\n\n Results\n'
|
||||
print ' l n exp0 beta gamma '
|
||||
print ' --- --- --------- --------- --------- '
|
||||
print('\n\n Results\n')
|
||||
print(' l n exp0 beta gamma ')
|
||||
print(' --- --- --------- --------- --------- ')
|
||||
for j in range(0,l+1):
|
||||
(exp0_n, beta_n, gamma_n) = get_exp0_beta_gamma(z,j)
|
||||
print '%4i %4i %12.6f %10.6f %10.6f' % (j, n[j], exp0_n, beta_n, gamma_n)
|
||||
print '\n Final energy difference = %12.6f' % value
|
||||
print '\n Energy without Coulomb fitting = %12.6f' % reference
|
||||
print('%4i %4i %12.6f %10.6f %10.6f' % (j, n[j], exp0_n, beta_n, gamma_n))
|
||||
print('\n Final energy difference = %12.6f' % value)
|
||||
print('\n Energy without Coulomb fitting = %12.6f' % reference)
|
||||
printexp(z)
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ scf; print none; end
|
|||
driver; print low; end
|
||||
|
||||
python
|
||||
from __future__ import print_function
|
||||
import Gnuplot, time, signal, os
|
||||
from math import *
|
||||
from nwgeom import *
|
||||
|
|
@ -70,8 +71,8 @@ python
|
|||
cn = bond_length(1,2)
|
||||
nh = bond_length(2,3)
|
||||
ch = bond_length(1,3)
|
||||
print ' angle=%6.1f => cn=%5.3f ch=%5.3f nh=%5.3f energy=%10.6f ' % \
|
||||
(angle,cn,ch,nh,energy)
|
||||
print(' angle=%6.1f => cn=%5.3f ch=%5.3f nh=%5.3f energy=%10.6f ' % \
|
||||
(angle,cn,ch,nh,energy))
|
||||
angle = angle + 180
|
||||
edata = edata + [[angle,energy]]
|
||||
cndata = cndata + [[angle,cn]]
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ mp2; freeze atomic; end
|
|||
print none
|
||||
|
||||
python
|
||||
from __future__ import print_function
|
||||
energies = {}
|
||||
|
||||
c2h4 = '''
|
||||
|
|
@ -43,7 +44,7 @@ python
|
|||
energies[basis] = 2*energy(basis, ch4) - \
|
||||
2*energy(basis, h2) - \
|
||||
energy(basis, c2h4)
|
||||
if (ga_nodeid() == 0): print basis, ' %8.6f' % energies[basis]
|
||||
if (ga_nodeid() == 0): print(basis, ' %8.6f' % energies[basis])
|
||||
end
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ end
|
|||
print none
|
||||
|
||||
python
|
||||
from __future__ import print_function
|
||||
import Gnuplot, time, signal
|
||||
from math import *
|
||||
|
||||
|
|
@ -86,7 +87,7 @@ python
|
|||
input_parse(geometry % (angle+90))
|
||||
(energy,gradient) = task_optimize('scf')
|
||||
r = get_bond_length()
|
||||
print ' angle=%6.2f bond=%6.3f energy=%10.6f ' % (angle,r,energy)
|
||||
print(' angle=%6.2f bond=%6.3f energy=%10.6f ' % (angle,r,energy))
|
||||
energies = energies + [[angle,energy]]
|
||||
bonds = bonds + [[angle,r]]
|
||||
energies.sort()
|
||||
|
|
@ -95,7 +96,7 @@ python
|
|||
g.plot(energies)
|
||||
gr.plot(bonds)
|
||||
|
||||
print ' Done!'
|
||||
print(' Done!')
|
||||
|
||||
time.sleep(90) # time to look at the plot
|
||||
end
|
||||
|
|
|
|||
|
|
@ -11,13 +11,14 @@ end
|
|||
print none
|
||||
|
||||
python
|
||||
from __future__ import print_function
|
||||
from nwgeom import *
|
||||
basis = 'basis noprint; H library 3-21g; O library 3-21g; O d; %f 1.0; end'
|
||||
|
||||
results = scan_input(basis, [0.5], [0.6], 20, 'scf', task_energy)
|
||||
|
||||
for (p,e) in results:
|
||||
print ' Exponent = %7.4f Energy = %10.6f ' % (p[0], e)
|
||||
print(' Exponent = %7.4f Energy = %10.6f ' % (p[0], e))
|
||||
end
|
||||
|
||||
task python
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue