Wednesday, November 27, 2013

Gaussian transition state scan input file


#P HF/6-31G(d) opt=Z-Matrix

HCN to CNH isomerization pathway, HF/6-31G(d)

0 1
N1
C2  1  r2
H3  2  r3  1  a3

r2=1.2
r3=1.1
a3=170.0 S  16  -10.0

Monday, November 25, 2013

gnuplot: some scripts and tips



script:
COLVAR gnuplot script.
set xrange [0:1]
set yrange [0:10]
plot "COLVAR" u ($1/120*20*0.0242*6/1000):2 t "CV  C1" w l, \
     "COLVAR" u ($1/120*20*0.0242*6/1000):3 t "    C2" w l, \
     "COLVAR" u ($1/120*20*0.0242*6/1000):4 t "    F1" w l, \
     "COLVAR" u ($1/120*20*0.0242*6/1000):5 t "an  F2" w l, \
     "COLVAR" u ($1/120*20*0.0242*6/1000):6 t "    H1" w l, \
     "COLVAR" u ($1/120*20*0.0242*6/1000):7 t "    H2" w l, \
     "COLVAR" u ($1/120*20*0.0242*6/1000):8 t "    H3" w l, \
     "COLVAR" u ($1/120*20*0.0242*6/1000):9 t "    H4" w l, \
     "COLVAR" u ($1/120*20*0.0242*6/1000):10 t "    H5" w l
set output "colvar.jpg"
set terminal jpeg
replot
-----------------------------------------------------------------------------------------
KS energy script file
set xrange [0:29.1]
set yrange [0:160]
plot "ENERGIES" u ($1*0.0242*6/1000):($4+55.9)*2625.50/4.18 notitle w l
set output "1000k-ch3oh-o2-no4-Eksvstime-ps-v2.jpg"
set terminal jpeg
replot
---------------------------------------------------------------------------------------
multiple script file

set output "h-so2-Eksvstime-sprint-ps.jpg"
set terminal jpeg


set multiplot layout 3,1
#set tmargin 0.2
#set bmargin 0.8
set lmargin 5
#set rmargin 5

set xrange [0:4.35]
set yrange [0:320]
set ytic 0,50,300
set format x " "
plot "ENERGIES" u ($1-10500)*6*0.0242/1000:(($4+42.54)*2625.50) notitle w l



set xrange [0:4.35]
set yrange [0:80]
set ytic 0,20,60
set format x " "
plot "ENERGIES" u ($1-10500)*6*0.0242/1000:($2*2625.50) notitle w l



set xrange [0:4.35]
set yrange [0:3.0]
set ytic 0,1.0,2.5
set key center bottom
set key spacing .6
set key font ",6"
set format x " %g "
plot "COLVAR" u ($1/120*20-10500)*6*0.0242/1000:2 t "SPRINT S1" w l, \
     "COLVAR" u ($1/120*20-10500)*6*0.0242/1000:3 t "       O1" w l, \
     "COLVAR" u ($1/120*20-10500)*6*0.0242/1000:4 t "       O2" w l, \
     "COLVAR" u ($1/120*20-10500)*6*0.0242/1000:5 t "       H1" w l

unset multiplot
set output

Friday, November 22, 2013

metadynamic and well-tempered metadynamics

well tempered mtd
------------------------------------------------------------------
# CPMD units are a.u.: energy = hartree, distance = bohr, time = 0.024 fs
HILLS  HEIGHT 0.00009 W_STRIDE 50
WELLTEMPERED SIMTEMP 300 BIASFACTOR 10
PRINT W_STRIDE 20

g1->
1 2 3 4 5 6 8 9 10 11 12
g1<- p="">
POSITION LIST SIGMA 0.35 DIR Z

ENDMETA


MTD
-------------------------------------------------------------------
# CPMD units are a.u.: energy = hartree, distance = bohr, time = 0.024 fs
HILLS RESTART HEIGHT 0.009 W_STRIDE 300
PRINT W_STRIDE 20

all->
 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
all<- div="">

SPRINT LIST NN 6 MM 12 R_0 10  5.0 5.0 5.0 4.2 5.0 5.0 4.2 5.0 4.2 4.2 INDEX 1 SIGMA 1.5
SPRINT LIST NN 6 MM 12 R_0 10  5.0 5.0 5.0 4.2 5.0 5.0 4.2 5.0 4.2 4.2 INDEX 2 SIGMA 1.5
SPRINT LIST NN 6 MM 12 R_0 10  5.0 5.0 5.0 4.2 5.0 5.0 4.2 5.0 4.2 4.2 INDEX 3 SIGMA 1.5
SPRINT LIST NN 6 MM 12 R_0 10  5.0 5.0 5.0 4.2 5.0 5.0 4.2 5.0 4.2 4.2 INDEX 4 SIGMA 1.5
SPRINT LIST NN 6 MM 12 R_0 10  5.0 5.0 5.0 4.2 5.0 5.0 4.2 5.0 4.2 4.2 INDEX 5 SIGMA 1.5
SPRINT LIST NN 6 MM 12 R_0 10  5.0 5.0 5.0 4.2 5.0 5.0 4.2 5.0 4.2 4.2 INDEX 6 SIGMA 1.5
SPRINT LIST NN 6 MM 12 R_0 10  5.0 5.0 5.0 4.2 5.0 5.0 4.2 5.0 4.2 4.2 INDEX 7 SIGMA 1.5
SPRINT LIST NN 6 MM 12 R_0 10  5.0 5.0 5.0 4.2 5.0 5.0 4.2 5.0 4.2 4.2 INDEX 8 SIGMA 1.5
SPRINT LIST NN 6 MM 12 R_0 10  5.0 5.0 5.0 4.2 5.0 5.0 4.2 5.0 4.2 4.2 INDEX 9 SIGMA 1.5
SPRINT LIST NN 6 MM 12 R_0 10  5.0 5.0 5.0 4.2 5.0 5.0 4.2 5.0 4.2 4.2 INDEX 10 SIGMA 1.5
SPRINT LIST NN 6 MM 12 R_0 10  5.0 5.0 5.0 4.2 5.0 5.0 4.2 5.0 4.2 4.2 INDEX 11 SIGMA 1.5
SPRINT LIST NN 6 MM 12 R_0 10  5.0 5.0 5.0 4.2 5.0 5.0 4.2 5.0 4.2 4.2 INDEX 12 SIGMA 1.5
SPRINT LIST NN 6 MM 12 R_0 10  5.0 5.0 5.0 4.2 5.0 5.0 4.2 5.0 4.2 4.2 INDEX 13 SIGMA 1.5
SPRINT LIST NN 6 MM 12 R_0 10  5.0 5.0 5.0 4.2 5.0 5.0 4.2 5.0 4.2 4.2 INDEX 14 SIGMA 1.5
SPRINT LIST NN 6 MM 12 R_0 10  5.0 5.0 5.0 4.2 5.0 5.0 4.2 5.0 4.2 4.2 INDEX 15 SIGMA 1.5
SPRINT LIST NN 6 MM 12 R_0 10  5.0 5.0 5.0 4.2 5.0 5.0 4.2 5.0 4.2 4.2 INDEX 16 SIGMA 1.5
SPRINT LIST NN 6 MM 12 R_0 10  5.0 5.0 5.0 4.2 5.0 5.0 4.2 5.0 4.2 4.2 INDEX 17 SIGMA 1.5
SPRINT LIST NN 6 MM 12 R_0 10  5.0 5.0 5.0 4.2 5.0 5.0 4.2 5.0 4.2 4.2 INDEX 18 SIGMA 1.5
SPRINT LIST NN 6 MM 12 R_0 10  5.0 5.0 5.0 4.2 5.0 5.0 4.2 5.0 4.2 4.2 INDEX 19 SIGMA 1.5
SPRINT LIST NN 6 MM 12 R_0 10  5.0 5.0 5.0 4.2 5.0 5.0 4.2 5.0 4.2 4.2 INDEX 20 SIGMA 1.5
SPRINT LIST NN 6 MM 12 R_0 10  5.0 5.0 5.0 4.2 5.0 5.0 4.2 5.0 4.2 4.2 INDEX 21 SIGMA 1.5
SPRINT LIST NN 6 MM 12 R_0 10  5.0 5.0 5.0 4.2 5.0 5.0 4.2 5.0 4.2 4.2 INDEX 22 SIGMA 1.5
SPRINT LIST NN 6 MM 12 R_0 10  5.0 5.0 5.0 4.2 5.0 5.0 4.2 5.0 4.2 4.2 INDEX 23 SIGMA 1.5
SPRINT LIST NN 6 MM 12 R_0 10  5.0 5.0 5.0 4.2 5.0 5.0 4.2 5.0 4.2 4.2 INDEX 24 SIGMA 1.5
SPRINT LIST NN 6 MM 12 R_0 10  5.0 5.0 5.0 4.2 5.0 5.0 4.2 5.0 4.2 4.2 INDEX 25 SIGMA 1.5
SPRINT LIST NN 6 MM 12 R_0 10  5.0 5.0 5.0 4.2 5.0 5.0 4.2 5.0 4.2 4.2 INDEX 26 SIGMA 1.5
SPRINT LIST NN 6 MM 12 R_0 10  5.0 5.0 5.0 4.2 5.0 5.0 4.2 5.0 4.2 4.2 INDEX 27 SIGMA 1.5



RGYR LIST SIGMA 1.5
NOHILLS CV 28

UWALL CV 28 LIMIT 8.00 KAPPA 0.5 EXP 2

ENDMETA

Thursday, November 21, 2013

Gaussian some input files for transition states

pbs file
#!/bin/bash
#PBS -N test
#PBS -l nodes=1:ppn=8
#PBS -l walltime=8:00:00
#PBS -j oe
### this will send and email when your job's status changes

### Specify the app to run here                           ###
###                                                       ###
cd $PBS_O_WORKDIR
export g09root="/codes/G09"
export GAUSS_SCRDIR=$PBS_O_WORKDIR
#GAUSS_SCRDIR="/GAUSS_SCRATCH"
#export g09root GAUSS_SCRDIR
. $g09root/g09/bsd/g09.profile



## AND NOW WE DO A CALCUATION
##     g09 test.com
       g09 nofre.com
##   g09 opt.com
### include any post processing here                      ###
###                                                       ###
#

exit 0

-----------------------------------------------------------------------------------------------------
qst2

%chk=ts-ch3oh-o2.chk
%nprocshared=8
%mem=16gb
# HF/6-31G* opt(qst2)

reactants

0,3
 C     -3.177481      1.256011     -0.187008
 O     -2.284301      2.342144     -0.515577
 O      0.492876     -1.214734     -0.800401
 O      0.426581     -1.291085      0.456829
 H     -4.238756      1.523717     -0.259563
 H     -2.955856      1.011776      0.884952
 H     -2.897823      0.467761     -0.819904
 H     -2.002079      2.824345      0.282715

products

0,3
 C    -1.645926    -0.498130    -1.077528
 O    -0.653966    -0.919073    -0.210084
 O    -0.966639     2.622203    -0.355541
 O    -1.547804     2.285127     0.638756
 H    -1.389444     1.733866    -1.118653
 H    -2.380255     0.183607    -0.458397
 H    -1.835573    -1.384190    -1.610873
 H    -0.680901    -0.013826     0.290209

----------------------------------------------------------------------------------------------------------
qst3

%chk=ts-ch3oh-o2.chk
%nprocshared=8
%mem=16gb
# HF/6-31G* opt(qst3)

reactants

0,3
 C     -1.831936     -0.455294     -1.000156
 O     -0.493883     -0.890046     -0.235749
 O     -0.766284      1.611589     -0.147007
 O     -1.805811      1.258415      0.542778
 H     -1.655954      0.534975     -1.543149
 H     -2.343630     -0.276478     -0.109751
 H     -2.120258     -1.175328     -1.691490
 H     -0.381442     -0.063029      0.144704

products

0,3
 C     -1.900815     -0.845392     -0.927500
 O     -0.665315     -0.785582     -0.219485
 O     -1.001482      1.767697     -0.378953
 O     -1.532152      1.101734      0.691260
 H     -0.132511      1.357497     -0.774537
 H     -2.655260      0.101360     -0.672792
 H     -1.549617     -1.018987     -1.970438
 H     -0.674073      0.069990      0.341985

transition state

0,3
 C     -1.645926     -0.498130     -1.077528
 O     -0.653966     -0.919073     -0.210084
 O     -0.966639      1.622203     -0.355541
 O     -1.612905      1.247369      0.750135
 H     -1.389444      0.733866     -1.118653
 H     -2.380255      0.183607     -0.458397
 H     -1.835573     -1.384190     -1.610873
 H     -0.680901     -0.013826      0.290209

------------------------------------------------------------------------------------------------
direct ts opt file

%chk=ts-ch3oh-o2.chk
%nprocshared=8
%mem=16gb
# BLYP/6-311+G** opt(calcall,ts,noeigen,maxcycle=1000, Cartesian) freq scf=maxcycle=1000 nosymm 

this is a test for ts

0,3
 C    -1.645926    -0.498130    -1.077528
 O    -0.653966    -0.919073    -0.210084
 O    -0.966639     1.622203    -0.355541
 O    -1.547804     1.285127     0.638756
 H    -1.389444     0.733866    -1.118653
 H    -2.380255     0.183607    -0.458397
 H    -1.835573    -1.384190    -1.610873
 H    -0.680901    -0.013826     0.290209

Wednesday, November 20, 2013

perl and bash scripts

killjobs.sh
for ((i=1082042;i<1082096 br="" i="">do
qdel $i.login1
done

echo "all jobs done!"
---------------------------------------------------------------------------

makefile.sh
i=0

for ((i=0;i<20 br="" i="">do
mkdir ch3oh-o2$i
cat inputpart1 o2part$i inputpart2 >> input-o2-$i
cat inputpart1-pro o2part$i inputpart2 >> input-o2-$i-pro
mv input-o2-$i ch3oh-o2$i/input
mv input-o2-$i-pro ch3oh-o2$i/input-pro
cp cpmdrun.pbs plumed.dat plumed-pro.dat ch3oh-o2$i
done

#for ((i=0;i<10 br="" i="">#do
#cd ch3oh-oxy$i
#qsub cpmdrun.pbs
#cd ..
#done

rm o2part*
echo "all jobs done!"
--------------------------------------------------------------------------------------------
read-o2.pl

#! /usr/bin/perl -w
my @line=0;
my $i=0;
open FILE1, "20noatomo2methanol.xyz" or die $!;
@line=;
for ($i=0;$i<20 br="" i="">open FILE2, "> o2part$i";
print FILE2 $line[2*$i];
print FILE2 $line[2*$i+1];
close FILE2;
}
close FILE1;
------------------------------------------------------------------------------------------------------


use-findall.sh

i=0
mkdir all-fourfiles
for ((i=0;i<4 br="" i="">do
./find-1214161820.pl ch3oh-o2$i/production/TRAJEC.xyz
mv requiredTimestepsCordinates.xyz all-fourfiles/coordinate$i.xyz
done


echo "all jobs done!"
------------------------------------------------------------------------------------------------------

sum_wham.sh

#!/bin/bash


metafile=wham_metafile
fesout=fes.out

rm -rf $metafile $fesout
points=1000  #there are 500 points/COLVAR, we'll not count the 1st 50 for equilibration.

## important note!  Umbrella sampling uses a potential like
##  V = 1/2 kappa (CV - CV(0))^2 but UWALL/LWALL don't have the 1/2 in there. So if you are using
##  UWALL/LWALL to do your umbrella sampling, then you need to multiply your K value by 2!

for file in shortp? longp? longp??; do


tail -n $points $file/COLVAR | awk '{print $1,$2}' > $file/whamcv;

## get kappa value - multiply by 2
kappa=`grep UMBRELLA $file/plumed.dat  | head -n 1 | awk '{print $5}'`
## get umbrella center
PV=`grep UMBRELLA $file/plumed.dat  | head -n 1 | awk '{print $7}'`
echo $file/whamcv $PV $kappa >> wham_metafile
done;

first=`sort -n -k2 wham_metafile | awk '{print $2}' | head -n 1 `
last=`sort -n -k2 wham_metafile | awk '{print $2}' | tail -n 1 `
num=`wc -l wham_metafile | awk '{print $1}'`
tol=$1


wham $first $last $num 0.0001 300 0 $metafile $fesout$tol

--------------------------------------------------------------------------------------------------
read-operate.pl ! to generate the z direction small changes




#! /usr/bin/perl -w
use warnings;
use strict;

my $i=0;

my @total;
my @data1;
my @data2;
my @data3;
my @data4;
my @data5;
my @data6;

open FILE, 'cgeo.xyz' or die "without such a file, $!";
while () {
$total[$i]=$_;
$i++;
}

#print $total[0];

@data1=split /\s+ /, $total[0];
@data2=split /\s+ /, $total[1];
@data3=split /\s+ /, $total[2];
@data4=split /\s+ /, $total[3];
@data5=split /\s+ /, $total[4];
@data6=split /\s+ /, $total[5];

#my $test=pop @data1;

#print scalar $data1[1];
#print scalar @data1;

for($i=1;$i<61 file="" i="">

$data1[3]=$data1[3]+0.0529;
$data2[3]=$data2[3]+0.0529;
$data3[3]=$data3[3]+0.0529;
$data4[3]=$data4[3]+0.0529;
$data5[3]=$data5[3]+0.0529;
$data6[3]=$data6[3]+0.0529;
open DATA, ">clongp$i";
print DATA "@data1\n";
print DATA "@data2\n";
print DATA "@data3\n";
print DATA "@data4\n";
print DATA "@data5\n";
print DATA "@data6\n";
close (DATA);
}

@data1=split /\s+ /, $total[0];
@data2=split /\s+ /, $total[1];
@data3=split /\s+ /, $total[2];
@data4=split /\s+ /, $total[3];
@data5=split /\s+ /, $total[4];
@data6=split /\s+ /, $total[5];

for($i=1;$i<11 file="" i="">

$data1[3]=$data1[3]-0.0529;
$data2[3]=$data2[3]-0.0529;
$data3[3]=$data3[3]-0.0529;
$data4[3]=$data4[3]-0.0529;
$data5[3]=$data5[3]-0.0529;
$data6[3]=$data6[3]-0.0529;
open DATA, ">clongp-$i";
print DATA "@data1\n";
print DATA "@data2\n";
print DATA "@data3\n";
print DATA "@data4\n";
print DATA "@data5\n";
print DATA "@data6\n";

close (DATA);
}




#print @total;
#print "@data1";
$i=0;
open FILEH, 'hgeo.xyz' or die "without such a file, $!";
while () {
$total[$i]=$_;
$i++;
}

#print $total[0];

@data1=split /\s+ /, $total[0];
@data2=split /\s+ /, $total[1];
@data3=split /\s+ /, $total[2];
@data4=split /\s+ /, $total[3];
@data5=split /\s+ /, $total[4];
@data6=split /\s+ /, $total[5];

#my $test=pop @data1;

#print scalar $data1[1];
#print scalar @data1;

for($i=1;$i<61 br="" i="">$data1[3]=$data1[3]+0.0529;
$data2[3]=$data2[3]+0.0529;
$data3[3]=$data3[3]+0.0529;
$data4[3]=$data4[3]+0.0529;
$data5[3]=$data5[3]+0.0529;
$data6[3]=$data6[3]+0.0529;
open DATA, ">hlongp$i";
print DATA "@data1\n";
print DATA "@data2\n";
print DATA "@data3\n";
print DATA "@data4\n";
print DATA "@data5\n";
print DATA "@data6\n";
close (DATA);
}

@data1=split /\s+ /, $total[0];
@data2=split /\s+ /, $total[1];
@data3=split /\s+ /, $total[2];
@data4=split /\s+ /, $total[3];
@data5=split /\s+ /, $total[4];
@data6=split /\s+ /, $total[5];

for($i=1;$i<11 br="" i="">$data1[3]=$data1[3]-0.0529;
$data2[3]=$data2[3]-0.0529;
$data3[3]=$data3[3]-0.0529;
$data4[3]=$data4[3]-0.0529;
$data5[3]=$data5[3]-0.0529;
$data6[3]=$data6[3]-0.0529;
open DATA, ">hlongp-$i";
print DATA "@data1\n";
print DATA "@data2\n";
print DATA "@data3\n";
print DATA "@data4\n";
print DATA "@data5\n";
print DATA "@data6\n";

close (DATA);
}


perl and bash scripts ---II

read-water.pl
#! /usr/bin/perl -w
my @line=0;
my $i=0;
open FILE1, "10waterch3och3noatom.xyz" or die $!;
@line=;
for ($i=0;$i<10 br="" i="">open FILE2, "> water-opart$i";
open FILE3, "> water-hpart$i";
print FILE2 $line[3*$i];
print FILE3 $line[3*$i+1];
print FILE3 $line[3*$i+2];
close FILE2;
close FILE3;
}
close FILE1;
------------------------------------------------------------------------------------------------------

std.pl

#! /usr/bin/perl -w -l

my @eksenergy=0;
my $tempnumber=0;
my $nobias_average_energy=0;
my $product_average_energy=0;
my $temptotal=0;
my $count=0;
my $energy_std=0;
my $selected_range_start=0;
my $selected_range_end=35000;

open ENERGYFILE, 'eks.dat' or die 'can not find the file!';
while (){
$eksenergy[$tempnumber]=$_;
$tempnumber++;
}

close ENERGYFILE;
print 'total numbers are ', $tempnumber;

for ($count=$selected_range_start;$count<$selected_range_end; $count++){
$temptotal=$eksenergy[$count]+$temptotal;
}

$nobias_average_energy=$temptotal/($selected_range_end-$selected_range_start);

$temptotal=0;

for ($count=$selected_range_start;$count<$selected_range_end;$count++){
$temptotal=($eksenergy[$count]-$nobias_average_energy)**2+$temptotal
}

$energy_std=($temptotal/($selected_range_end-$selected_range_start))**(1/2);

print 'the STD is ', $energy_std*627.509;

print 'the average is ', $nobias_average_energy*627.509;
-----------------------------------------------------------------------------------------------------------

decide-h3.pl

#! /usr/bin/perl -w
my @line=0;
my $i=0;
open FILE1, "COLVAR" or die $!;
@line=;
for ($i=0;$i<500 br="" i="">open FILE2, "> hpart$i";
print FILE2 $line[$i];
close FILE2;
}
close FILE1;
-----------------------------------------------------------------------------------------------------------

 find-1214161820.pl

#! /usr/bin/perl -w

my @fileContent=0; # array to store contents of a file

my @tempStore=0;  # temporary array to store data

my @requiredCoordinates=qw(120001 140001 160001 180001 200001); # get the required time-step coordinates in a TRAJECTORY file.

my $moleculeNumberOfAtoms=8; # the number of one system: methanol and oxygen

my $numberOfSeparation=2; # the separation lines between two coordinate file

my $tempNumber=0; # the temporary number used in program

my $tempNumberTwo=0; # the temporary number used in program

my $coordInterval=50; # every 50 time step we choose one trajectory

open INPUTFILE, "@ARGV" or die "can not open TRAJEC.xyz $!"; # open the trajectroy file. If no files, returen a warning.

@fileContent=; # open the TRAJEC.xyz file and store it into fileContent array

open OUTPUTFILE, ">>requiredTimestepsCordinates.xyz"; # open a new file to store the required coordinates.

for ($tempNumber=0;$tempNumber<5 array="" br="" elements="" five="" in="" nbsp="" read="" requiredcoordinates="" tempnumber="">
for ($tempNumberTwo=0;$tempNumberTwo<($moleculeNumberOfAtoms+$numberOfSeparation);$tempNumberTwo++) { # read 10 lines from coordinate file
     ## you can not skip the N.O. 0 element since all arrays have first elment with index 0.
print OUTPUTFILE $fileContent[($requiredCoordinates[$tempNumber]-1)/50*($moleculeNumberOfAtoms+$numberOfSeparation)+ $tempNumberTwo]; #

}

}

close INPUTFILE;

close OUTPUTFILE;



some of my perl code and bash script------I

clean.sh
rm log.file HILLS* TRAJEC* COLVAR* RESTART.1 GEO_OPT.xyz HESSIAN *.out  LATEST ENERGIES GEOMETRY* input.out name*
--------------------------------------------------------------------------------------------------------------
average.pl

#! /usr/bin/perl -w
use warnings;
use strict;

my $m=0;
my $n =35000;
my $pn = 68000;
my @eks=0;
my $ksind=0;
my $reactave=0;
my $prodave=0;
my $temp=0;

open KSFILE, 'eks.dat';

while (){
$eks[$ksind]=$_+55.9;
$ksind +=1;
}

print "$eks[34999] \n";

print "the average of reactant";

for ($m=0;$m<$n;$m++){
$temp=$eks[$m]+$temp;
}
$reactave=$temp/$n*2625.5/4.18;

print "$reactave \n";
print "the average of product";

$temp=0;
$m=0;
for ($m=$pn;$m<$pn+4000;$m++){
$temp=$eks[$m]+$temp;
}
$prodave=$temp/4000*2625.5/4.18;
my $diff;
$diff= $prodave - $ reactave;

print "$prodave \n";

print "the energy difference betwen produc and reactant is ";
print "$diff \n";


--------------------------------------------------------------------------------------------
combine.sh
awk '{print $4}' ENERGIES > eks.dat
cp ~/to-gscratch/ch3oh/ch3oh-o2/01172013/nonpbc-10o2/ch3oh-oxy1/backup/ENERGIES nonpbc-energy
awk '{print $4}' nonpbc-energy > nonpbc-eks.dat
cat nonpbc-eks.dat eks.dat > eks-total.dat
---------------------------------------------------------------------------------------------
generate-zpe.pl
#! /usr/bin/perl
#!/usr/local/bin/perl
#
# change all occurances of a string in a file to another string
#
## first open a file to read all the lines

use strict;
use warnings;

my @all=0;
my @freq;
my $zpe=0;
my $m=0;
my $n=0;
my @temp;
my $newfile= "raw-freq";
my $targetfile = "freq.out";

open(MYFILE, $targetfile) or die("can not open the file freq.out");
open (OUTFILE,">", $newfile);

while () {
   next unless /PURIFICATION OF DYNAMICAL MATRIX/;
   $all[$m]= $_;
   while ()
    {
        $m +=1;
        $all[$m]= $_;
        last if /BIG MEMORY ALLOCATIONS/;
    }
  
}
##print @all;
##print $m;
##print $all[5];
##print $all[$m-3];

while ($n<$m-7){
@temp=split (' ', $all[$n+5]);
##print @temp;
$n +=1;
##print $n, @temp;
push (@freq,@temp);
}

foreach (@freq) {
if ($_ < 0) {
next;
}

else {
print OUTFILE "$_ \n";
$zpe=0.5*$_*4.556E-6 + $zpe;
##print "$zpe \n";
}

}

print "$zpe \n";
print OUTFILE "the ZPE is \n";
print OUTFILE $zpe;

close(MYFILE);
close (OUTFILE);




Tuesday, November 19, 2013

how to calculate a error bar

first, compute the average (i.e., the estimator) for your measurements, by evaluating the following formula:

average = (sample1 + sample2 + ... + sampleN) / N

Replace "sample1," sample2," ... "sampleN" by the measurements, and "N" by the total number of measurements in the experiment.

Second, compute the standard deviation by evaluating the following formula:

stdDev = sqrt(((sample1 - average)**2 + ... + (sampleN - average)**2)/N) or
stdDev = sqrt(((sample1 - average)**2 + ... + (sampleN - average)**2)/(N-1)) if two DOFs depend on each other.

Finally, compute the beginning and end points of the error bars, by evaluating the following formulas:

barBegin = average - stdDev

barEnd = average + stdDev

If you want to use gnuplot, following command is used.
plot "yourfile.txt" using 1:2:3 with yerrorbars !here 1, 2, 3 are steps, mean,
and stdev, respectively
 
or you can use
plot "yourfile.txt" using 1:($2-$3):($2-$3):($2+$3):($2+$3) with candlesticks!
this will generate a candlesticks.
 
  










Friday, November 15, 2013

one example to use CPMD to obtain the TS state

However, it may have some problems to get converged. Maybe the energy cutoff?
The initial guess structure?

&CPMD
  OPTIMIZE GEOMETRY XYZ
  INITIALIZE WAVEFUNCTIONS ATOMS
  RANDOMIZE COORDINATES
   0.1D0
  RESTFILE
    4
  STORE
    100
  LBFGS
  PRFO MODE
    10
  PRFO CORE=4
    1 2 9 10
  CONVERGENCE
    5.0D-7 5.0D-5
  CONVERGENCE RELAX
    15
  SPLINE POINTS QFUNCTION
    2001
  ISOLATED MOLECULE
  CENTER MOLECULE OFF
  MEMORY BIG
  LSD
&END

&DFT
  FUNCTIONAL PBE
  GC-CUTOFF
    5.0D-5
&END

&SYSTEM
  SYMMETRY
    0
  POISSON SOLVER TUCKERMAN
  ANGSTROM
  CELL
    10.0D0  1.0D0  1.0D0  0.0D0  0.0D0  0.0D0
  CUTOFF
    25.0D0
  MULTIPLICITY
    1
&END

&ATOMS
*N.uspp_ascii FORMATTED
   LMAX=P
    2
     4.525338176055      4.920747785642      4.949904563339
     5.765416638683      5.048851794396      5.079925564279
*H.uspp_ascii FORMATTED
   LMAX=S
    6
     4.265466440716      2.788011128505      4.858413782037
     2.878604693260      3.791408955331      4.306112314885
     4.333398001463      3.598265838244      3.267273093363
     6.467823612522      3.016976904998      5.093103687689
     6.554809448253      3.823511424486      3.501228774397
     7.703325625270      4.291321957329      4.803526469019
*C.uspp_ascii FORMATTED
   LMAX=P
    2
     3.972567677301      3.700817361171      4.307476081948
     6.672717274443      3.979768413937      4.589493362517
&END

Tuesday, November 12, 2013

Plumed utility usage: sum_hills and HILLS file

parallel.f90  serial.f90  sum_hills.f90 files are avaialble.
I use module to link library. In the following part, s denotes step. It seems that gcc is better.
s1: module load  gcc_4.4.7-ompi_1.6.5 (module list, module load, module avail, module unload)
s2:  mpif90 -O3 sum_hills.f90 parallel.f90 -o sum_hills_mpi.x
You should have sum_hills_mpi.x generated.s3. ldd sum_hills_mpi.x
Output:
        linux-vdso.so.1 =>  (0x00007fff205fd000)
        libmpi_f90.so.1 => /sw/openmpi-1.6.5_gcc-4.4.7/lib/libmpi_f90.so.1 (0x00002b18668f0000)
        libmpi_f77.so.1 => /sw/openmpi-1.6.5_gcc-4.4.7/lib/libmpi_f77.so.1 (0x00002b1866af5000)
        libmpi.so.1 => /sw/openmpi-1.6.5_gcc-4.4.7/lib/libmpi.so.1 (0x00002b1866d28000)
        libdl.so.2 => /lib64/libdl.so.2 (0x00002b18670d9000)
        libgfortran.so.3 => /usr/lib64/libgfortran.so.3 (0x00002b18672de000)
        libm.so.6 => /lib64/libm.so.6 (0x00002b18675d0000)
        libnuma.so.1 => /usr/lib64/libnuma.so.1 (0x00002b1867853000)
        librt.so.1 => /lib64/librt.so.1 (0x00002b1867a59000)
        libnsl.so.1 => /lib64/libnsl.so.1 (0x00002b1867c62000)
        libutil.so.1 => /lib64/libutil.so.1 (0x00002b1867e7a000)
        libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00002b186807e000)
        libpthread.so.0 => /lib64/libpthread.so.0 (0x00002b186828c000)
        libc.so.6 => /lib64/libc.so.6 (0x00002b18684a8000)
        /lib64/ld-linux-x86-64.so.2 (0x00002b18666d2000)
s4: gfortran -O3 sum_hills.f90 serial.f90 -o sum_hills.x   !OK. now serial version.
s5:  copy two *.x files to your bin directory.
s6. sum_hills.x -file HILLS -out fes.dat -ndim 3 -ndw 1 2 -kt 0.6 -ngrid 100 100 100
       -ndim: the dimensionality number.
       -ndw: the list of CVs in the desired order to plot the FES.
       -kt: KT specified by -kt (kT must be given in the energy units that were used
by in the code)

HILLS file
  first column      second     third               fourth
   time step          CV            SIGMA      Bias potential