diff --git a/examples/USER/plumed/check-plumed.sh b/examples/USER/plumed/check-plumed.sh new file mode 100755 index 0000000000..584b4d3297 --- /dev/null +++ b/examples/USER/plumed/check-plumed.sh @@ -0,0 +1,32 @@ +#!/bin/bash + +# Check PLUMED positions +nlines=`paste plumed.xyz lammps.xyz | awk '{if( $2<$6-0.0001 || $2>$6+0.0001 || $3<$7-0.0001 || $3>$7+0.0001 || $4<$8-0.0002 || $4>$8+0.0002 ) if( $5!="Timestep:" && $1!=2004 ) print $0}' | wc -l` +if [ "$nlines" -gt 0 ] ; then + echo ERROR passing positions from LAMMPS to PLUMED + paste plumed.xyz lammps.xyz | awk '{if( $2<$6-0.0001 || $2>$6+0.0001 || $3<$7-0.0001 || $3>$7+0.0001 || $4<$8-0.0002 || $4>$8+0.0002 ) if( $5!="Timestep:" && $1!=2004 ) print $0, $2-$6, $3-$7, $4-$8}' +fi + +# CHECK PLUMED timestep +tstep=`grep timestep in.peptide-plumed | awk '{print $2}'` +tstep=`echo $tstep \* 0.001 \* 10 | bc -l` +nlines=`wc -l plmd_energy | awk '{print $1}'` + +for ((i=3;i<$nlines;i++)); do + told=`head -n $(($i-1)) plmd_energy | tail -n 1 | awk '{print $1}'` + tnew=`head -n $i plmd_energy | tail -n 1 | awk '{print $1}'` + tdiff=`echo \( $tnew - $told - $tstep \) \> 0 | bc -l` + if [ $tdiff -gt 0 ] ; then + echo ERROR passing timestep from LAMMPS to PLUMED + fi +done + +# Check PLUMED energy +tail -n +2 plmd_energy > plmd_energy2 +nlines=`paste lammps_energy plmd_energy2 | tail -n +2 | awk '{if( $2<$4-0.0001 || $2>$4+0.0001 ) print $0}' | wc -l` +if [ "$nlines" -gt 0 ] ; then + echo ERROR passing potential energy from LAMMPS to PLUMED + paste lammps_energy plmd_energy2 | tail -n +2 | awk '{if( $2<$4-0.0001 || $2>$4+0.0001 ) print $0}' +fi +rm -f plmd_energy2 + diff --git a/examples/USER/plumed/colvar b/examples/USER/plumed/colvar deleted file mode 100644 index b909300108..0000000000 --- a/examples/USER/plumed/colvar +++ /dev/null @@ -1,102 +0,0 @@ -#! FIELDS time d1 d2 h_pot.bias h_pot.force2 - 0.000000 0.993491 0.758366 0.292146 5.842921 - 0.002000 0.995476 0.759311 0.289757 5.795146 - 0.004000 0.997617 0.760436 0.286982 5.739638 - 0.006000 0.999849 0.761714 0.283902 5.678045 - 0.008000 1.002126 0.763111 0.280604 5.612077 - 0.010000 1.004429 0.764614 0.277132 5.542631 - 0.012000 1.006758 0.766228 0.273476 5.469523 - 0.014000 1.009119 0.767975 0.269594 5.391885 - 0.016000 1.011514 0.769873 0.265455 5.309099 - 0.018000 1.013929 0.771911 0.261093 5.221860 - 0.020000 1.016331 0.774032 0.256641 5.132826 - 0.022000 1.018671 0.776135 0.252321 5.046430 - 0.024000 1.020900 0.778094 0.248395 4.967894 - 0.026000 1.022979 0.779791 0.245099 4.901982 - 0.028000 1.024903 0.781143 0.242592 4.851832 - 0.030000 1.026700 0.782129 0.240904 4.818078 - 0.032000 1.028430 0.782795 0.239931 4.798623 - 0.034000 1.030167 0.783248 0.239458 4.789166 - 0.036000 1.031975 0.783621 0.239212 4.784241 - 0.038000 1.033897 0.784047 0.238923 4.778459 - 0.040000 1.035930 0.784627 0.238382 4.767647 - 0.042000 1.038033 0.785407 0.237484 4.749678 - 0.044000 1.040121 0.786369 0.236240 4.724809 - 0.046000 1.042091 0.787439 0.234768 4.695368 - 0.048000 1.043837 0.788511 0.233246 4.664919 - 0.050000 1.045280 0.789471 0.231863 4.637266 - 0.052000 1.046388 0.790226 0.230785 4.615694 - 0.054000 1.047178 0.790712 0.230136 4.602723 - 0.056000 1.047712 0.790891 0.230015 4.600302 - 0.058000 1.048083 0.790742 0.230505 4.610102 - 0.060000 1.048397 0.790252 0.231683 4.633662 - 0.062000 1.048754 0.789414 0.233618 4.672352 - 0.064000 1.049236 0.788230 0.236354 4.727083 - 0.066000 1.049892 0.786723 0.239883 4.797654 - 0.068000 1.050741 0.784954 0.244096 4.881918 - 0.070000 1.051768 0.783036 0.248766 4.975312 - 0.072000 1.052946 0.781120 0.253559 5.071179 - 0.074000 1.054246 0.779374 0.258094 5.161873 - 0.076000 1.055648 0.777949 0.262017 5.240331 - 0.078000 1.057143 0.776950 0.265083 5.301665 - 0.080000 1.058728 0.776406 0.267217 5.344336 - 0.082000 1.060397 0.776265 0.268526 5.370525 - 0.084000 1.062135 0.776403 0.269282 5.385630 - 0.086000 1.063918 0.776650 0.269855 5.397095 - 0.088000 1.065713 0.776818 0.270642 5.412845 - 0.090000 1.067486 0.776746 0.271982 5.439646 - 0.092000 1.069203 0.776331 0.274084 5.481685 - 0.094000 1.070839 0.775547 0.276987 5.539735 - 0.096000 1.072370 0.774448 0.280554 5.611090 - 0.098000 1.073779 0.773153 0.284514 5.690279 - 0.100000 1.075049 0.771810 0.288515 5.770295 - 0.102000 1.076167 0.770572 0.292193 5.843867 - 0.104000 1.077116 0.769571 0.295223 5.904455 - 0.106000 1.077882 0.768908 0.297345 5.946904 - 0.108000 1.078459 0.768648 0.298397 5.967949 - 0.110000 1.078853 0.768806 0.298342 5.966843 - 0.112000 1.079090 0.769340 0.297296 5.945926 - 0.114000 1.079219 0.770158 0.295516 5.910315 - 0.116000 1.079303 0.771141 0.293328 5.866561 - 0.118000 1.079415 0.772170 0.291067 5.821338 - 0.120000 1.079622 0.773135 0.289037 5.780735 - 0.122000 1.079971 0.773942 0.287489 5.749783 - 0.124000 1.080476 0.774515 0.286599 5.731971 - 0.126000 1.081103 0.774812 0.286437 5.728730 - 0.128000 1.081783 0.774828 0.286955 5.739101 - 0.130000 1.082421 0.774602 0.287987 5.759744 - 0.132000 1.082925 0.774217 0.289271 5.785430 - 0.134000 1.083230 0.773787 0.290498 5.809961 - 0.136000 1.083320 0.773437 0.291366 5.827324 - 0.138000 1.083229 0.773283 0.291638 5.832753 - 0.140000 1.083032 0.773417 0.291171 5.823427 - 0.142000 1.082825 0.773886 0.289936 5.798729 - 0.144000 1.082697 0.774694 0.288007 5.760150 - 0.146000 1.082716 0.775795 0.285550 5.710997 - 0.148000 1.082911 0.777098 0.282797 5.655945 - 0.150000 1.083267 0.778482 0.280018 5.600355 - 0.152000 1.083739 0.779816 0.277467 5.549332 - 0.154000 1.084258 0.780984 0.275337 5.506735 - 0.156000 1.084764 0.781917 0.273726 5.474524 - 0.158000 1.085215 0.782595 0.272633 5.452651 - 0.160000 1.085600 0.783050 0.271973 5.439463 - 0.162000 1.085939 0.783349 0.271614 5.432288 - 0.164000 1.086269 0.783582 0.271395 5.427907 - 0.166000 1.086632 0.783845 0.271141 5.422814 - 0.168000 1.087062 0.784236 0.270670 5.413403 - 0.170000 1.087575 0.784841 0.269815 5.396302 - 0.172000 1.088169 0.785721 0.268447 5.368936 - 0.174000 1.088827 0.786902 0.266506 5.330122 - 0.176000 1.089527 0.788366 0.264020 5.280397 - 0.178000 1.090249 0.790062 0.261095 5.221908 - 0.180000 1.090983 0.791909 0.257899 5.157988 - 0.182000 1.091725 0.793812 0.254634 5.092674 - 0.184000 1.092478 0.795671 0.251513 5.030265 - 0.186000 1.093252 0.797384 0.248746 4.974922 - 0.188000 1.094056 0.798864 0.246512 4.930235 - 0.190000 1.094906 0.800048 0.244938 4.898769 - 0.192000 1.095809 0.800909 0.244083 4.881658 - 0.194000 1.096763 0.801455 0.243917 4.878336 - 0.196000 1.097747 0.801731 0.244326 4.886516 - 0.198000 1.098716 0.801809 0.245123 4.902456 - 0.200000 1.099614 0.801777 0.246077 4.921541 diff --git a/examples/USER/plumed/in.peptide-plumed b/examples/USER/plumed/in.peptide-plumed index 40657d987e..2f5e8d026f 100644 --- a/examples/USER/plumed/in.peptide-plumed +++ b/examples/USER/plumed/in.peptide-plumed @@ -35,6 +35,9 @@ fix 4 all shake 0.0001 10 100 b 4 6 8 10 12 14 18 a 31 thermo_style custom step temp etotal pe ke epair ebond f_2 thermo 10 +dump dd all xyz 10 lammps.xyz +variable step equal step +variable pe equal pe +fix 5 all print 10 "$(v_step) $(v_pe)" file lammps_energy - -run 100 +run 101 diff --git a/examples/USER/plumed/p.log b/examples/USER/plumed/p.log deleted file mode 100644 index c2f2163c83..0000000000 --- a/examples/USER/plumed/p.log +++ /dev/null @@ -1,64 +0,0 @@ -PLUMED: PLUMED is starting -PLUMED: Version: 2.5.0-dev (git: a10584333) compiled on Jul 2 2018 at 09:29:02 -PLUMED: Please cite this paper when using PLUMED [1] -PLUMED: For further information see the PLUMED web page at http://www.plumed.org -PLUMED: Root: /data/gt/mycodes/plumed2/ -PLUMED: For installed feature, see /data/gt/mycodes/plumed2//src/config/config.txt -PLUMED: Molecular dynamics engine: LAMMPS -PLUMED: Precision of reals: 8 -PLUMED: Running over 1 node -PLUMED: Number of threads: 1 -PLUMED: Cache line size: 512 -PLUMED: Number of atoms: 2004 -PLUMED: File suffix: -PLUMED: FILE: plumed.dat -PLUMED: Action COM -PLUMED: with label c1 -PLUMED: serial associated to this virtual atom is 2005 -PLUMED: of atoms -PLUMED: 2 4 5 6 -PLUMED: broken molecules will be rebuilt assuming atoms are in the proper order -PLUMED: Action COM -PLUMED: with label c2 -PLUMED: serial associated to this virtual atom is 2006 -PLUMED: of atoms -PLUMED: 80 82 83 84 -PLUMED: broken molecules will be rebuilt assuming atoms are in the proper order -PLUMED: Action DISTANCE -PLUMED: with label d1 -PLUMED: between atoms 2005 37 -PLUMED: using periodic boundary conditions -PLUMED: Action DISTANCE -PLUMED: with label d2 -PLUMED: between atoms 2006 37 -PLUMED: using periodic boundary conditions -PLUMED: Action RESTRAINT -PLUMED: with label h_pot -PLUMED: with arguments d1 d2 -PLUMED: added component to this action: h_pot.bias -PLUMED: at 1.000000 1.000000 -PLUMED: with harmonic force constant 10.000000 10.000000 -PLUMED: and linear force constant 0.000000 0.000000 -PLUMED: added component to this action: h_pot.force2 -PLUMED: Action PRINT -PLUMED: with label @5 -PLUMED: with stride 1 -PLUMED: with arguments d1 d2 h_pot.bias h_pot.force2 -PLUMED: on file colvar -PLUMED: with format %f -PLUMED: END FILE: plumed.dat -PLUMED: Timestep: 0.002000 -PLUMED: KbT has not been set by the MD engine -PLUMED: It should be set by hand where needed -PLUMED: Relevant bibliography: -PLUMED: [1] Tribello, Bonomi, Branduardi, Camilloni, and Bussi, Comput. Phys. Commun. 185, 604 (2014) -PLUMED: Please read and cite where appropriate! -PLUMED: Finished setup -PLUMED: Cycles Total Average Minumum Maximum -PLUMED: 1 0.015035 0.015035 0.015035 0.015035 -PLUMED: 1 Prepare dependencies 101 0.000123 0.000001 0.000001 0.000004 -PLUMED: 2 Sharing data 101 0.006837 0.000068 0.000047 0.000891 -PLUMED: 3 Waiting for data 101 0.000967 0.000010 0.000007 0.000041 -PLUMED: 4 Calculating (forward loop) 101 0.001616 0.000016 0.000011 0.000043 -PLUMED: 5 Applying (backward loop) 101 0.002159 0.000021 0.000018 0.000057 -PLUMED: 6 Update 101 0.001059 0.000010 0.000006 0.000086 diff --git a/examples/USER/plumed/plumed.dat b/examples/USER/plumed/plumed.dat index d316d4b035..27f4d635fb 100644 --- a/examples/USER/plumed/plumed.dat +++ b/examples/USER/plumed/plumed.dat @@ -1,6 +1,6 @@ +UNITS ENERGY=kcal/mol c1: COM ATOMS=2,4,5,6 c2: COM ATOMS=80,82,83,84 -d1: DISTANCE ATOMS=c1,37 -d2: DISTANCE ATOMS=c2,37 -h_pot: RESTRAINT ARG=d1,d2 AT=1.0,1.0 KAPPA=10,10 -PRINT ARG=d1,d2,h_pot.* FILE=colvar +energy: ENERGY +DUMPATOMS ATOMS=1-2004 FILE=plumed.xyz UNITS=A PRECISION=4 STRIDE=10 +PRINT ARG=energy STRIDE=10 FMT=%8.4f FILE=plmd_energy diff --git a/src/USER-PLUMED/fix_plumed.cpp b/src/USER-PLUMED/fix_plumed.cpp index 15753596a5..b6af7c691d 100644 --- a/src/USER-PLUMED/fix_plumed.cpp +++ b/src/USER-PLUMED/fix_plumed.cpp @@ -32,6 +32,9 @@ FixPlumed::FixPlumed(LAMMPS *lmp, int narg, char **arg) : if (!atom->tag_enable) error->all(FLERR,"fix plumed requires atom tags"); // Initialize plumed: p=new PLMD::Plumed; +// Check API version + int api_version; p->cmd("getApiVersion",&api_version); + if( api_version!=6 ) error->all(FLERR,"invalid api version for PLUMED"); // If the -partition option is activated then enable inter-partition communication if (universe->existflag == 1) {