This C-program optimises (minimum or TS) variables (can be a geometry or something else)
by calling a "script" (you have to make it! So it can be linked to any program!).
It can also calculate gradient, hessian matrix, frequencies.
In the commands the upper or lower case doesn't matter. However, it can be important in the variable names.
It has a restart capability.
All commands finish by an 'end'.
You have to separate words (numbers) by at least one blank space.
download a copy of mini mini.tar.gz
uncompress and compile it.
gunzip mini.tar.gz tar xvf mini.tar cd mini make
There are more examples in mini/examples
a small example: optimisation of water with molpro.
data R = 2. bohr 1 A = 109. degree -1 end
The program minimises R (1) end maximises A (-1). You should get the linear transition state.
However, you need a script to link mini to molpro (const, the script name by default).
It must be executable. So you should use this command 'chmod u+x const' in unix.
#!/bin/ksh echo "***,HOH sto-3g RHF ">x.inpm cat geom>>x.inpm echo "zmat,noorient O1 H2,O1,R H3,O1,R,H2,A endz basis=sto-3g int hf ">>x.inpm molpro.run x grep "SCF STATE 1.1 ENERGY" x.outm|awk '{print $5}'>energ grep "NO CONVERGE" x.outm|awk '{print 0}'>>energ echo 1 >> energ
The variables are put in the file 'geom', and the program reads the energy in the file 'energ'.
The first part of the scrip generates an input file for molpro (until the last >> x.inpm). It's mostly the input file of molpro.
molpro.run x : execution of molpro.
extraction of the energy of the output file (x.outm, here) and add a flag (0 or 1) for the convergence.
you get:
data R = 2.000000000000 bohr 1 A = 109.000000000000 degree -1 opt = 1 hess = 0 grad = 0 ene = 2 R = 1.762380589233 bohr 1 A = 179.999982248148 degree -1 energie = -74.852480660000
You can specify some file names. However, the default works fine.
example:
FIChiers const = const_test1 energy = energ res = xxx geom = geom end
The script name is 'const_test1'.
The energy file name is 'energ'. Mini reads the energy in this file.
The result (intermediary) file name is 'xxx'.
The variables file name is 'geom'. Mini writes variables in this file.
The default file name:
fichiers const = const energy = energ res = res geom = geom restart = restart (restart file) gradient = gradient (mini reads the gradient from this file) end
Specify the operation:
test_ene = 0 or 1 (calculate the energy, useful for a script test)
test_opt = 0, 1, 2 (1, 2 : optimisation and 0 no optimisation)
i_ts_min = -1 (a variable number) for 'test_opt = 2': optimise the other variables then this one 'i_ts_min'
test_grad = 0, 1, 2, 3 (0: no gradient; 1: gradient (one displacement); 2: gradient (two displacements); 3: read a gradient)
test_hess = 0, 1, 2, 3, 4 (0: no hessian; 1 or 2: hessian (1 cheaper but 2 more precise); 3: read gradient); 4: read a hessian matrix (see hessian)
test_freq = 0, 1 (frequencies (1), you have to specify test_hess)
restart = 0, 1 (0: full calculation; 1: restart on energy only, so it doesn't work when you read gradient)
example:
controle test_opt = 1 test_ene = 0 test_grad = 0 test_hess = 2 test_freq = 1 end
First the optimisation, then the frequencies calculation with the expensive hessian calculation (four displacements for the out-diagonal elements).
The default:
controle test_ene = 0 test_opt = 1 i_ts_min = -1 test_grad = 0 test_hess = 0 test_freq = 0 restart = 0 end
You have to specify the variables (at least one and up to 12), you want to optimise, with their name (up to 20 characters) = an initial value, the unit (bohr, angs, rad or degree) then 0 (no optimisation), 1 (minimisation) or -1 (maximisation).
It's easy to understand with an example.
example:
data R1 = 2. bohr 1 R2 = 2. bohr 1 A = 109. degree 1 end
Three variables (R1, R2, A) which are all minimised.
You specify the variable by a cartesian coordinates (from some programs)
Between cart and end:
na : atom number prog : name of a program for the format (gamess, molpro, g92) bohr : (t or true) or (f or false) convert : conversion of unit (Bohr -> Åström or the reverse) opt : flags for define the optimisation (0, 1, -1)
Then the cartesian coordinates with the right format.
It's easy to understand with an example.
example:
cart na = 3 prog = gamess bohr = t convert = f opt = 0 0 0 1 0 1 1 0 1 end O 8.0 0.0000000000 0.0000000000 -0.1344680200 H 1.0 1.4326043750 0.0000000000 1.0670525220 H 1.0 -1.4326043750 0.0000000000 1.0670525220
This example defines a cartesian coordinates for 3 atoms (na = 3), with gamess format (prog = gamess). The unit is Bohr (bohr = t), no conversion (convert = f). You allow some possible optimisation (opt = ....)
Then the cartesian coordinates with 'gamess' format.
Define some convergence and displacement parameters for the optimisation or the numerical gradient/hessian.
It's easy to understand with an example.
example and default:
param deriv = 0.01 conv_energie = 1.e-6 conv_deplace = 5.e-4 max_deplace = 0.1 end
deriv : displacement in Bohr or Radian for the first step of the numerical optimisation, the gradient or hessian (mini makes the conversion).
max_deplace : maximum displacement in Bohr or Radian during the optimisation.
conv_energie : convergence criterion on the energy.
conv_deplace : convergence criterion on the displacement in Bohr or Radian.
The optimisation stops when both criterion are met.
Define masses for the frequencies calculation. There are default up to Z=19 (from Handbook of Chemistry and Physics 78th, pp1-10).
You need 3*n variables (xyz) and you define n masses.
example:
masses 15.99491 1.00781 1.00781 end
You define 3 masses (1 oxygen and 2 hydrogens).
Read a hessian matrix (test_hess = 4 in controle).
You MUST read data or cart before.
Useful if you want to change isotopes in a frequencies calculation.
example:
hessian nb_col = 2 0.00000000 0.00000000 0 0.65403626 -0.03064077 1 -0.03064077 0.65403605 2 0.03769920 0.03769921 0.00000000 0 0.03769920 1 0.03769921 2 0.29688227 end
nb_col define the column number.
Then 'nb_col' columns of the matrix (with row of eigenvalue -not used here-)
You enter this block ('nb_col' columns) until the end of the matrix.
fichiers const = const_AB end controle test_opt = 1 test_ene = 0 test_grad = 0 test_hess = 2 test_freq = 1 end data x1 = 0.000000000 bohr 0 y1 = 0.000000000 bohr 0 z1 = 0.000000000 bohr 0 x2 = 0.000000000 bohr 0 y2 = 0.000000000 bohr 0 z2 = 2.970000000 bohr 1 end param deriv = 0.005 conv_energie = 5.e-6 conv_deplace = 5.e-5 max_deplace = 0.1 end masses 15.994915 34.968853 endscript: const_AB
#!/bin/ksh awk '{t[NR]=$3} END { # Req=2.9725 k=0.305573 # #for (i=1;i<7;i++) print t[i] x=t[1]-t[4] y=t[2]-t[5] z=t[3]-t[6] r=sqrt(x*x+y*y+z*z) print 0.5*k*(r-Req)*(r-Req) }' geom >energ echo 1 >>energ
fichiers const = const_h2o_cart end controle test_opt = 1 test_ene = 0 test_grad = 0 test_hess = 2 test_freq = 1 end cart na = 3 prog = gamess bohr = t convert = f opt = 0 0 0 1 0 1 1 0 1 end O 8.0 0.0000000000 0.0000000000 -0.1344680200 H 1.0 1.4326043750 0.0000000000 1.0670525220 H 1.0 -1.4326043750 0.0000000000 1.0670525220 param deriv = 0.01 conv_energie = 1.e-4 conv_deplace = 1.e-3 max_deplace = 0.1 endscript: const_h2o_cart
you can use one of these 2 scripts:
- the first one use nawk unix command (or gawk). I you don't have it, use the
second one.
- the second use another program: cart.
The hessian matrix (3*3) has been calculated in example 3.
first script
#!/bin/ksh
nawk '{t[NR]=$3}
END {
# vector 1 (OH_1)
vx1=t[1]-t[4]
vy1=t[2]-t[5]
vz1=t[3]-t[6]
d1=sqrt(vx1*vx1+vy1*vy1+vz1*vz1)
# vector 1 (OH_2)
vx2=t[1]-t[7]
vy2=t[2]-t[8]
vz2=t[3]-t[9]
d2=sqrt(vx2*vx2+vy2*vy2+vz2*vz2)
#angle HOH
c=(vx1*vx2+vy1*vy2+vz1*vz2)/(d1*d2)
s=sqrt(1.0-c*c)
angle=atan2(s,c)
#print d1" "d2" "angle
#hessian3*3
h11=0.65407272
h22=0.65407580
h33=0.29688606
h12=-0.03064230
h13=0.03770003
h23=0.03769997
#energy (harmonic)
r0=1.8697612
a0=1.7458023
r1=d1-r0
r2=d2-r0
a1=angle-a0
e = 0.5*( r1*r1*h11 + r2*r2*h22 + a1*a1*h33)
e = e + ( r1*r2*h12 + r1*a1*h13 + r2*a1*h23)
print e
}' geom >energ
echo 1 >> energ
second script
#!/bin/ksh
echo " \$lect na=3 prog='g92' convert=.false. \$end" >dat
awk '{t[NR]=$3}
END {
print " 1 8 "t[1]" "t[2]" "t[3]
print " 2 1 "t[4]" "t[5]" "t[6]
print " 2 1 "t[7]" "t[8]" "t[9]}' geom >>dat
echo " \$oper \$end
\$zmat nb=3 \$end
1
2 1
3 1 2
\$fiop
\$fini" >> dat
cart
fichiers const = const_h2o_h33 end controle test_opt = 0 i_ts_min = 0 test_hess = 2 test_freq = 0 end data R1 = 2. bohr 1 R2 = 2. bohr 1 A = 109. degree 1 end param deriv = 0.01 conv_energie = 1.e-6 conv_deplace = 1.e-4 max_deplace = 0.1 endscript: const_h2o_h33
echo "***,HOH sto-3g RHF memory,0.5,m ">x.inpm cat geom>>x.inpm echo "zmat,nosym,noorient O1 H2,O1,R1 H3,O1,R2,H2,A endz basis=sto-3g int hf show[1,f25.15],energy ">>x.inpm molpro.run x grep "ENERGY / AU" x.outm|awk '{print $5}'>energ grep "NO CONVERGE" x.outm|awk '{print 0}'>>energ echo 1 >> energ
Background: Ptiluc ici (in French)