User Tools

Site Tools


exercises:2015_pitt:aimd

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
exercises:2015_pitt:aimd [2015/03/03 08:28] – [Ab initio molecular dynamics] vondeleexercises:2015_pitt:aimd [2020/08/21 10:15] (current) – external edit 127.0.0.1
Line 4: Line 4:
  
 The first goal is to setup a simulation in production mode by reducing output, and enabling restarting. The first goal is to setup a simulation in production mode by reducing output, and enabling restarting.
-The second goal to understand the produced .ener file.+The second goal to understand the produced .ener file and do some basic analysis of the trajectory with VMD.
  
-====== AIMD of water ======+====== AIMD of bulk liquid water ======
  
-<note>For the sake of running this exercise quickly, we'll use the DZVP-GTH basis found in the HFX_BASIS file. This basis is smaller than what can be recommended, rather use TZV2P-GTH, TZV2P-MOLOPT-GTH, or cc-TZV2P or better basis sets for production runs.</note>+<note>For the sake of running this exercise quickly, we'll use the DZVP-GTH basis found in the HFX_BASIS file. This basis is smaller than what can be recommended for a subtle substance such as liquid water, rather use TZV2P-GTH, TZV2P-MOLOPT-GTH, or cc-TZV2P or better basis sets for production runs.</note> 
 + 
 +Topics: 
 +  * MD section (timestep) 
 +  * Thermostat (NVE, NVT, NPT) 
 + 
 +===== 1st task: prepapre inputs for MD =====
  
 Start from the ''mode1.inp'' input file of [[gga|the previous exercise]], rename the file to ''water.inp''. You'll also need a new file ''HFX_BASIS'' from the ''cp2k/data'' directory. Start from the ''mode1.inp'' input file of [[gga|the previous exercise]], rename the file to ''water.inp''. You'll also need a new file ''HFX_BASIS'' from the ''cp2k/data'' directory.
  
 Change keywords to : Change keywords to :
-  * ''PROJECT water'' +  * ''PROJECT WATER'' 
   * ''RUN_TYPE MD''   * ''RUN_TYPE MD''
   * ''BASIS_SET_FILE_NAME HFX_BASIS''   * ''BASIS_SET_FILE_NAME HFX_BASIS''
Line 23: Line 29:
 Insert the following blocks in their respective sections: Insert the following blocks in their respective sections:
  
 +Reduce output, and limit job time to 5min.
 <code> <code>
 &GLOBAL &GLOBAL
Line 32: Line 39:
 </code> </code>
  
 +! do not write the wfn restart file every step, for large systems this is slow
 <code> <code>
     &SCF     &SCF
Line 42: Line 50:
 </code> </code>
  
 +! tune the output, switch off unneeded keywords
 +! only sample output of others.
 +<code>
 +    &PRINT
 +       ! at the end of the SCF procedure generate cube files of the density
 +       &E_DENSITY_CUBE OFF
 +       &END E_DENSITY_CUBE
 +       ! compute eigenvalues and homo-lumo gap each 10nd MD step
 +       &MO_CUBES
 +          ! compute 4 unoccupied orbital energies
 +          NLUMO 4
 +          NHOMO 4
 +          ! but don't write the cube files
 +          WRITE_CUBE .FALSE.
 +          ! do this every 10th MD step.
 +          &EACH
 +            MD 10
 +          &END
 +       &END
 +    &END
 +</code>
 +
 +make sure trajectories and restart files are dumped as needed.
 +
 +<code>
 +&MOTION
 +  &PRINT
 +   &TRAJECTORY
 +     &EACH
 +       MD 1
 +     &END EACH
 +   &END TRAJECTORY
 +   &VELOCITIES OFF
 +   &END VELOCITIES
 +   &FORCES OFF
 +   &END FORCES
 +   &RESTART_HISTORY
 +     &EACH
 +       MD 500
 +     &END EACH
 +   &END RESTART_HISTORY
 +   &RESTART
 +     BACKUP_COPIES 3
 +     &EACH
 +       MD 1
 +     &END EACH
 +   &END RESTART
 +  &END PRINT
 +&END MOTION
 +</code>
 +
 +Now, run the input and check for successful completion of the job (look for the timing report or the ''ENDED AT'' line in the output).
 +
 +During MD CP2K has generated various files named ''WATER-1.restart'', ''WATER-pos-1.xyz'', ''WATER-1.ener''. These are a restart file for the MD (open this file in an editor to see that this is actually a regular input file), the trajectory of the MD, and a file summarizing the energies (potential, kinetic and conserved quantity). Before we analyze these files, we'll resubmit a job for the continuation of the MD.
 +
 +modify the input to enable restarting:
 +<code>
 +&EXT_RESTART
 +  RESTART_FILE_NAME WATER-1.restart
 +&END
 +</code>
 +If time permits, increase the WALLTIME (and the corresponding time limit in the job script), and run a longer job.
 +
 +<note tip>as soon as the job runs significantly longer than the time needed to perform the first few steps, restarting the job doesn't influence the efficiency. Your batch job system might have a convenient way to have chains of jobs, i.e. a simple way to enforce dependencies and automatic continuation. Look at the -w option of ''bsub'', or --dependency of ''sbatch''</note>
 +
 +
 +====== Analysis ======
 +
 +While running the MD simulations, it is useful to check that all is fine. Here, we do some basic analysis, to look at the structure and dynamics of the liquid. 
 +
 +===== 2nd task: visualize the .ener file =====
 +
 +A first quick check can be performed using the file ''WATER-1.ener'' which contains basic information
 +<code>
 +#     Step Nr.          Time[fs]        Kin.[a.u.]          Temp[K]            Pot.[a.u.]        Cons Qty[a.u.]        UsedTime[s]
 +                    0.000000         0.273612846       300.000000000     -1102.629448594     -1102.355835748         0.000000000
 +                    0.500000         0.279633819       306.601634956     -1102.634728486     -1102.356032711        70.082937483
 +                    1.000000         0.278176228       305.003473822     -1102.643688340     -1102.356285321        11.608515253
 +                    1.500000         0.280393422       307.434493169     -1102.653080703     -1102.356547289        11.607597935
 +                    2.000000         0.282889483       310.171274373     -1102.655862600     -1102.356593452        11.617385623
 +                    2.500000         0.294372846       322.762089451     -1102.653391721     -1102.356505399        11.665471402
 +</code>
 +
 +This can be easily visualized with gnuplot, for example for the conserved quantity (plotting the second vs the sixth column) : 
 +<code>
 +gnuplot> plot './WATER-1.ener' u 2:6 w lp
 +</code>
 +
 +To judge if this is actually well conserved, compare to the potential energy:
 +<code>
 +gnuplot> plot './WATER-1.ener' u 2:5 w lp
 +gnuplot> replot './WATER-1.ener' u 2:6 w lp
 +</code>
 +
 +If the constant of motion is not well conserved, try to
 +  * Make ''EPS_SCF'' tighter (to reduce drift)
 +  * Make ''TIMESTEP'' shorter (to reduce fluctuations)
 +  * Play with ''EXTRAPOLATION_ORDER'' (to reduce drift and or instabilities)
 +
 +To judge if a system is well equilibrated is not easy. At least the temperature and the potential energy of the system must oscillate around an average and be free of long term drift. As a rule of thumb, discard 1/3 of the trajectory, use 2/3 for data analysis.
 +
 +===== 3rd task: visualize/analyze the trajectory file =====
 +
 +We will use vmd to analyze the trajectory file. Note that the generated trajectory is only a few 100s of fs, typically, 10s of ps are needed for even for basic properties. 
 +
 +Start vmd
 +
 +<code>
 +vmd WATER-pos-1.xyz
 +</code>
 +
 +==== g(r) ====
 +
 +In the menu go to :  
 +
 +Extensions/Analysis/Radial Pair Distribution Function g(r)
 +Utilities/Set unit cell size dimensions
 +
 +1st, set the unit cell as needed. Now improve the Graphics/Representations to also show neighboring unit cells and visualize hydrogen bonds.
 +
 +2nd, compute the O-O pair distribution function (Selections=''name O'') and similar for the O-H pair distribution function (including their integrals).
 +
 +How many neighbors does a given water molecule have on average (3, 3-4, 4, 4-5, 5)?
 +
 +==== IR spectrum ====
 +
 +Based on the time evolution of the dipole of the system, the IR spectral density can be estimated. To estimate the dipole from AIMD, wannier centers need to be computed. This is out of scope of the current tutorial (TODO: find link). We employ a simple approximation, namely classical point charges for the water molecules. In this context the approximation is reasonable.
 +
 +Create the following file
 +<code - charges.dat>
 +O -1.2
 +H +0.6
 +</code>
 +
 +Go to Extensions/Analysis/Spectral density calculator.
 +Select the proper molecule (WATER-pos-1.xyz), adjust the timestep (0.5fs), and the maximum frequency (6000 cm^-1).
 +Utilities/Load name<->charge map from file.
 +Compute spectrum.
 +
 +Where do you expect the OH stretch to be ? Is this reproduced ?
 +
 +<note> Lower frequencies need longer trajectories for reasonable estimates, at the very least 10 times the period of the signal </note>
 +
 +====== AIMD of simle ions in water solution ======
 +===== 4th task: simple ions in solution =====
 +
 +<note> This task is optional, and can be performed at the end of the tutorial if time is available. </note>
 +
 +Introduce an ion in your system, and equilibrate this system. Study its dynamics and solvation structure.
 +
 +The easiest way to do so is to replace one or more water molecules (depending on the size of the ion) by the ion in question. Obviously, the configuration produced in this way is far from equilibrium, and must be run for a while before it is representative. 
  
 +Entertaining is to turn one H2O into H+, do you see Eigen and Zundel states and [[wp>Grotthuss_mechanism |the Grotthuss mechanism]] ?
  
 ====== Required files ====== ====== Required files ======
Line 240: Line 400:
   H        -4.1388543582       -6.3621998573        2.1513804320   H        -4.1388543582       -6.3621998573        2.1513804320
   H        -4.3955669691       -5.3216936959        1.0405948547   H        -4.3955669691       -5.3216936959        1.0405948547
 +</code>
 +The following file should be the result of your edits to ''mode1.inp'' and your final ''water.inp''. Only use this if you're stuck following the instructions.
 +<code - water_cheating.inp>
 +&GLOBAL
 +  ! the project name is made part of most output files... useful to keep order 
 +  PROJECT WATER
 +  ! various runtypes (energy, geo_opt, etc.) available.
 +  RUN_TYPE MD             
 +  ! limit the runs to 5min
 +  WALLTIME 1800
 +  ! reduce the amount of IO
 +  IOLEVEL  LOW 
 +&END GLOBAL
 +
 +&FORCE_EVAL
 +  ! the electronic structure part of CP2K is named Quickstep
 +  METHOD Quickstep
 +  &DFT
 +    ! basis sets and pseudopotential files can be found in cp2k/data
 +    BASIS_SET_FILE_NAME HFX_BASIS
 +    POTENTIAL_FILE_NAME GTH_POTENTIALS            
 +
 +    ! Charge and multiplicity
 +    CHARGE 0
 +    MULTIPLICITY 1
 +
 +    &MGRID
 +       ! PW cutoff ... depends on the element (basis) too small cutoffs lead to the eggbox effect.
 +       ! certain calculations (e.g. geometry optimization, vibrational frequencies,
 +       ! NPT and cell optimizations, need higher cutoffs)
 +       CUTOFF [Ry] 400 
 +    &END
 +
 +    &QS
 +       ! use the GPW method (i.e. pseudopotential based calculations with the Gaussian and Plane Waves scheme).
 +       METHOD GPW 
 +       ! default threshold for numerics ~ roughly numerical accuracy of the total energy per electron,
 +       ! sets reasonable values for all other thresholds.
 +       EPS_DEFAULT 1.0E-10 
 +       ! used for MD, the method used to generate the initial guess.
 +       EXTRAPOLATION ASPC 
 +    &END
 +
 +    &POISSON
 +       PERIODIC XYZ ! the default, gas phase systems should have 'NONE' and a wavelet solver
 +    &END
 +
 +    &PRINT
 +       ! at the end of the SCF procedure generate cube files of the density
 +       &E_DENSITY_CUBE OFF
 +       &END E_DENSITY_CUBE
 +       ! compute eigenvalues and homo-lumo gap each 10nd MD step
 +       &MO_CUBES
 +          NLUMO 4
 +          NHOMO 4
 +          WRITE_CUBE .FALSE.
 +          &EACH
 +            MD 10
 +          &END
 +       &END
 +    &END
 +
 +    ! use the OT METHOD for robust and efficient SCF, suitable for all non-metallic systems.
 +    &SCF                              
 +      SCF_GUESS ATOMIC ! can be used to RESTART an interrupted calculation
 +      MAX_SCF 30
 +      EPS_SCF 1.0E-6 ! accuracy of the SCF procedure typically 1.0E-6 - 1.0E-7
 +      &OT
 +        ! an accurate preconditioner suitable also for larger systems
 +        PRECONDITIONER FULL_SINGLE_INVERSE
 +        ! the most robust choice (DIIS might sometimes be faster, but not as stable).
 +        MINIMIZER DIIS
 +      &END OT
 +      &OUTER_SCF ! repeat the inner SCF cycle 10 times
 +        MAX_SCF 10
 +        EPS_SCF 1.0E-6 ! must match the above
 +      &END
 +      ! do not store the wfn during MD
 +      &PRINT
 +        &RESTART OFF
 +        &END
 +      &END
 +    &END SCF
 +
 +    ! specify the exchange and correlation treatment
 +    &XC
 +      ! use a PBE functional 
 +      &XC_FUNCTIONAL 
 +         &PBE
 +         &END
 +      &END XC_FUNCTIONAL
 +      ! adding Grimme's D3 correction (by default without C9 terms) 
 +      &VDW_POTENTIAL
 +         POTENTIAL_TYPE PAIR_POTENTIAL 
 +         &PAIR_POTENTIAL
 +            PARAMETER_FILE_NAME dftd3.dat
 +            TYPE DFTD3
 +            REFERENCE_FUNCTIONAL PBE
 +            R_CUTOFF [angstrom] 16
 +         &END
 +      &END VDW_POTENTIAL
 +    &END XC
 +  &END DFT
 + 
 +  ! description of the system
 +  &SUBSYS
 +    &CELL 
 +      ! unit cells that are orthorhombic are more efficient with CP2K
 +      ABC [angstrom] 12.42 12.42 12.42
 +    &END CELL
 +
 +    ! atom coordinates can be in the &COORD section,
 +    ! or provided as an external file.
 +    &TOPOLOGY
 +      COORD_FILE_NAME water.xyz
 +      COORD_FILE_FORMAT XYZ
 +    &END
 +
 +    ! MOLOPT basis sets are fairly costly,
 +    ! but in the 'DZVP-MOLOPT-SR-GTH' available for all elements
 +    ! their contracted nature makes them suitable
 +    ! for condensed and gas phase systems alike.
 +    &KIND H                              
 +      BASIS_SET DZVP-GTH
 +      POTENTIAL GTH-PBE-q1             
 +    &END KIND
 +    &KIND O
 +      BASIS_SET DZVP-GTH
 +      POTENTIAL GTH-PBE-q6
 +    &END KIND
 +  &END SUBSYS
 +&END FORCE_EVAL
 +
 +! how to propagate the system, selection via RUN_TYPE in the &GLOBAL section
 +&MOTION
 + &GEO_OPT
 +   OPTIMIZER BFGS ! Good choice for 'small' systems (use LBFGS for large systems)
 +   MAX_ITER  100
 +   MAX_DR    [bohr] 0.003 ! adjust target as needed
 +   &BFGS
 +   &END
 + &END
 + &MD
 +   ENSEMBLE NVT  ! sampling the canonical ensemble, accurate properties might need NVE
 +   TEMPERATURE [K] 300
 +   TIMESTEP [fs] 0.5
 +   STEPS 1000
 +   # GLE thermostat as generated at http://epfl-cosmo.github.io/gle4md 
 +   # GLE provides an effective NVT sampling.
 +   &THERMOSTAT
 +     REGION MASSIVE
 +     TYPE GLE
 +     &GLE
 +       NDIM 5
 +       A_SCALE [ps^-1] 1.00
 +       A_LIST    1.859575861256e+2   2.726385349840e-1   1.152610045461e+1  -3.641457826260e+1   2.317337581602e+2
 +       A_LIST   -2.780952471206e-1   8.595159180871e-5   7.218904801765e-1  -1.984453934386e-1   4.240925758342e-1
 +       A_LIST   -1.482580813121e+1  -7.218904801765e-1   1.359090212128e+0   5.149889628035e+0  -9.994926845099e+0
 +       A_LIST   -1.037218912688e+1   1.984453934386e-1  -5.149889628035e+0   2.666191089117e+1   1.150771549531e+1
 +       A_LIST    2.180134636042e+2  -4.240925758342e-1   9.994926845099e+0  -1.150771549531e+1   3.095839456559e+2
 +     &END GLE
 +   &END THERMOSTAT
 + &END
 +  &PRINT
 +   &TRAJECTORY
 +     &EACH
 +       MD 1
 +     &END EACH
 +   &END TRAJECTORY
 +   &VELOCITIES OFF
 +   &END VELOCITIES
 +   &FORCES OFF
 +   &END FORCES
 +   &RESTART_HISTORY
 +     &EACH
 +       MD 500
 +     &END EACH
 +   &END RESTART_HISTORY
 +   &RESTART
 +     BACKUP_COPIES 3
 +     &EACH
 +       MD 1
 +     &END EACH
 +   &END RESTART
 +  &END PRINT
 +&END
 +&EXT_RESTART
 +  RESTART_FILE_NAME WATER-1.restart
 +&END
 </code> </code>
  
exercises/2015_pitt/aimd.1425371291.txt.gz · Last modified: 2020/08/21 10:14 (external edit)