Skip to content
Snippets Groups Projects
Commit 09737fea authored by Davide Branduardi's avatar Davide Branduardi
Browse files

The quantum espresso patch (Only PW)

parent d65302b6
No related branches found
No related tags found
No related merge requests found
...@@ -69,6 +69,11 @@ command ...@@ -69,6 +69,11 @@ command
Now you can patch/unpatch your MD code, automatically linking PLUMED, as if it Now you can patch/unpatch your MD code, automatically linking PLUMED, as if it
was an officially released interface. was an officially released interface.
Note that the created diff file is executed as a bash script. This is
particularly useful whenever your code, as a result of a configure, creates a
makefile which can be remarkably different according to the architecture.
In this case you can fiddle with some awk and sed to add the needed paths to
PLUMED libraries.
\section language Language dependence \section language Language dependence
...@@ -152,6 +157,11 @@ The various calls that can be used pass data and calculate the forces due to the ...@@ -152,6 +157,11 @@ The various calls that can be used pass data and calculate the forces due to the
plumed_cmd(plumedmain,"setStep",&step); // Pass a pointer to the current timestep to plumed plumed_cmd(plumedmain,"setStep",&step); // Pass a pointer to the current timestep to plumed
/ *** The way that you pass positions will depend on how they are stored in your code. If the x, y and z position are all stored in a single array you may use: / *** The way that you pass positions will depend on how they are stored in your code. If the x, y and z position are all stored in a single array you may use:
plumed_cmd(plumedmain,"setPositions",&pos[0][0]); // Pass a pointer to the first element in the atomic positions array to plumed plumed_cmd(plumedmain,"setPositions",&pos[0][0]); // Pass a pointer to the first element in the atomic positions array to plumed
// assuming they
// are stored in
// a
// x1,y1,z1,x2,y2,z2 ...
// kind of ordering
/ *** Othersize if you pass the three separate vectors of x, y and z positions using: / *** Othersize if you pass the three separate vectors of x, y and z positions using:
plumed_cmd(plumedmain,"setPositionX",&x[0]); // Pass a pointer to the first element in the array of x component of the atomic positions to plumed plumed_cmd(plumedmain,"setPositionX",&x[0]); // Pass a pointer to the first element in the array of x component of the atomic positions to plumed
plumed_cmd(plumedmain,"setPositionY",&y[0]); // Pass a pointer to the first element in the array of y component of the atomic positions to plumed plumed_cmd(plumedmain,"setPositionY",&y[0]); // Pass a pointer to the first element in the array of y component of the atomic positions to plumed
......
...@@ -12,7 +12,7 @@ Actions (choose one): ...@@ -12,7 +12,7 @@ Actions (choose one):
-l, --list-engines -l, --list-engines
print a list of available MD engines print a list of available MD engines
-s, --save -s, --save
save (*) save, this needs *.preplumed files (*)
-n NEWENGINE, --new NEWENGINE -n NEWENGINE, --new NEWENGINE
create a new patch named NEWENGINE (*) create a new patch named NEWENGINE (*)
Options: Options:
......
# this is not patchable and is needed to place the right calls in the right place no mattder what
cp make.sys make.sys.preplumed
PWD=`pwd`
echo "include ${PWD}/Plumed.inc ">make.sys
awk '{if($1=="LIBS" && $2=="="){print $0" ${PLUMED_SHARED_LOAD} "}else{print }}' make.sys.preplumed >>make.sys
exit
patch -u -l -b -F 5 --suffix=.preplumed "./PW/src/plugin_initialization.f90" << \EOF_EOF
--- ./PW/src/plugin_initialization.f90.preplumed
+++ ./PW/src/plugin_initialization.f90
@@ -13,9 +13,50 @@
USE kinds, ONLY : DP
USE io_files, ONLY : tmp_dir
!
USE plugin_flags
!
+ USE ions_base, ONLY : amass, ityp, nat
+ !
+ USE dynamics_module, ONLY : dt
+ USE constants, ONLY : au_ps
+ !
+ !
IMPLICIT NONE
!
+ INTEGER :: na
+ INTEGER :: plumedavailable
+ REAL*8 :: energyUnits,lengthUnits,timeUnits
+ !
+ IF(use_plumed) then
+
+ CALL plumed_f_installed(plumedavailable)
+
+ IF(plumedavailable<=0)THEN
+ write(stdout,*)"YOU ARE LOOKING FOR PLUMED BUT LOOKS LIKE IT IS NOT AVAILABLE: DO YOU HAVE IT IN YOUR LD_LIBRARY_PATH?"
+ STOP
+ ELSE
+ IF (ionode) THEN
+
+ write(stdout,*)" CREATING PLUMED FROM THE PROGRAM"
+ call plumed_f_gcreate()
+ CALL plumed_f_gcmd("setRealPrecision"//char(0),8)
+ energyUnits=1312.75 ! Ry to kjoule mol
+ lengthUnits=0.0529177249 ! bohr to nm
+ timeUnits=au_ps ! internal time to ps
+ call plumed_f_gcmd("setMDEnergyUnits"//char(0),energyUnits)
+ call plumed_f_gcmd("setMDLengthUnits"//char(0),lengthUnits)
+ call plumed_f_gcmd("setMDTimeUnits"//char(0),timeUnits)
+ call plumed_f_gcmd("setPlumedDat"//char(0),"plumed.dat"//char(0))
+ call plumed_f_gcmd("setLogFile"//char(0),"PLUMED.OUT"//char(0))
+ call plumed_f_gcmd("setNatoms"//char(0),nat)
+ call plumed_f_gcmd("setMDEngine"//char(0),"qespresso");
+ call plumed_f_gcmd("setTimestep"//char(0),dt);
+ call plumed_f_gcmd("init"//char(0),0);
+
+ ENDIF
+ ENDIF
+ ENDIF
+ !
!
END SUBROUTINE plugin_initialization
EOF_EOF
patch -u -l -b -F 5 --suffix=.preplumed "./PW/src/plugin_forces.f90" << \EOF_EOF
--- ./PW/src/plugin_forces.f90.preplumed
+++ ./PW/src/plugin_forces.f90
@@ -16,9 +16,38 @@
USE kinds, ONLY : DP
USE io_files, ONLY : outdir
!
USE plugin_flags
!
+ USE cell_base, ONLY : alat, at
+ USE ions_base, ONLY : tau, nat,amass
+ USE force_mod, ONLY : force
+ USE control_flags, ONLY : istep
+ USE ener, ONLY : etot
+ !
IMPLICIT NONE
!
+ INTEGER:: i,j
+ REAL(DP) :: at_plumed(3,3)
+ REAL(DP), ALLOCATABLE :: tau_plumed(:,:)
+ !
+ IF(use_plumed) then
+ IF(ionode)THEN
+ at_plumed=alat*at; ! the cell, rescaled properly
+ allocate(tau_plumed(3,nat))
+ tau_plumed=alat*tau
+
+ CALL plumed_f_gcmd("setMasses"//char(0),amass)
+ CALL plumed_f_gcmd("setForces"//char(0),force)
+ CALL plumed_f_gcmd("setStep"//char(0),istep)
+ CALL plumed_f_gcmd("setPositions"//char(0),tau_plumed)
+ CALL plumed_f_gcmd("setBox"//char(0),at_plumed)
+ CALL plumed_f_gcmd("setEnergy"//char(0),etot)
+ CALL plumed_f_gcmd("calc"//char(0),0)
+
+ deallocate(tau_plumed)
+ ENDIF
+ CALL mp_bcast(force, ionode_id, intra_image_comm)
+ ENDIF
+ !
!
END SUBROUTINE plugin_forces
EOF_EOF
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment