User Tools

Site Tools


exercises:2016_uzh_cmest:first_simulation_run

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:2016_uzh_cmest:first_simulation_run [2016/09/22 14:35] – [Part II: Computation of the LJ energy curve] tmuellerexercises:2016_uzh_cmest:first_simulation_run [2020/08/21 10:15] (current) – external edit 127.0.0.1
Line 7: Line 7:
  
 To get you started, we will do a simple exercise using Molecular Mechanics (that is: a classical approach). The point is to get familiar with the options, organizing and editing the input file and analyze the output. To get you started, we will do a simple exercise using Molecular Mechanics (that is: a classical approach). The point is to get familiar with the options, organizing and editing the input file and analyze the output.
 +
 ====== Computation of the Lennard Jones curve ====== ====== Computation of the Lennard Jones curve ======
  
Line 17: Line 18:
 Additonal parameters for Neon (Ne) and combination rules to obtain new parameters are provided in  Part III and IV. Additonal parameters for Neon (Ne) and combination rules to obtain new parameters are provided in  Part III and IV.
  
-You are expected to hand in the respective plots plus answers to the questions. The format can be either a proper PDF or directly in the email with the plots attached (as pictures in pngjpg, or pdf format). +You are expected to hand in the respective plots by email, either as one PDF or as one file per plot (PNGJPEG, or PDF format).
 ===== Part I:  Single Point (Energy) calculation ===== ===== Part I:  Single Point (Energy) calculation =====
  
Line 79: Line 79:
 &END FORCE_EVAL &END FORCE_EVAL
 </code> </code>
 +
 +<note tip>Instructions starting with an ampersand ''&'' start a //section// and **must** be terminated with an ''&END SECTION-NAME''. Other instructions are called //keywords//. The indentation is ignored but recommended for readability.</note>
  
 === 2. Step === === 2. Step ===
Line 102: Line 104:
   **** **  *******  **  PROGRAM STARTED IN          /data/students/studentXX/ex1   **** **  *******  **  PROGRAM STARTED IN          /data/students/studentXX/ex1
 [...] [...]
-  ENERGY| Total FORCE_EVAL ( FIST ) energy (a.u.):           0.003617048870059+  ENERGY| Total FORCE_EVAL ( FIST ) energy (a.u.):          -0.000518941408898
 [...] [...]
  
Line 116: Line 118:
  
 If you get the closing banner you know that CP2K finished. If you get the closing banner you know that CP2K finished.
- 
-<note warning>Always check the number of warnings by looking at the <code>The number of warnings for this run is : ...</code> line. If that number is not zero you **must** check the rest of the output for warnings and act accordingly.</note> 
  
 The following line tells you the result: The following line tells you the result:
Line 130: Line 130:
 To convert from //Kelvin// to //Hartree// you have to multiply with the Boltzmann constant $ k_\text{b} = 3.1668154 \cdot 10^{-6} \frac{E_\text{H}}{\text{K}} $ . To convert from //Kelvin// to //Hartree// you have to multiply with the Boltzmann constant $ k_\text{b} = 3.1668154 \cdot 10^{-6} \frac{E_\text{H}}{\text{K}} $ .
  
 +<note warning>Always check the number of warnings by looking at the line: <code>The number of warnings for this run is : ...</code>  If that number is not zero you **must** check the rest of the output for warnings and act accordingly, otherwise you may work with wrong results.</note>
 ===== Part II: Computation of the LJ energy curve ===== ===== Part II: Computation of the LJ energy curve =====
    
Line 250: Line 251:
 Plot again the energy curve. Plot again the energy curve.
  
 +====== Tips & Tricks ======
 +
 +===== Parsing the output =====
 +
 +Many times you will have to get some value out of a simulation output, in this case, the energy.
 +This can achieved in a number of ways:
 +
 +  * Using the ''grep'' command:<code>
 +$ grep "Total FORCE_EVAL" energy.out
 +</code>which gives you:<code>
 + ENERGY| Total FORCE_EVAL ( FIST ) energy (a.u.):             -0.000250281091139
 +</code>
 +  * Using the ''awk'' tool:<code>
 +$ awk '/Total FORCE_EVAL/ { print $9; }' energy.out
 +</code>which returns:<code>
 +-0.000250281091139
 +</code>''awk'' reads a given file line-by-line and splits a line into multiple fields (using whitespace as delimiter). The command above tells ''awk'' to look for the string ''Total FORCE_EVAL'' in a line and if found, print field number 9 of it, effectively returning the energy.
 +
 +===== Generating input files =====
 +
 +Many times you will have to run the same simulation with different parameters (here the distance).
 +
 +A simple way to generate the different input files is using shell scripting in combination with ''sed'' (the stream editor):
 +
 +<code>
 +for d in $(seq 2 0.1 4); do
 +  sed -e "s|4 0 0|${d} 0 0|" energy.inp > energy_${d}A.inp
 +  cp2k.sopt -i energy_${d}A.inp -o energy_${d}A.out
 +  awk '/Total FORCE_EVAL/ { print $9; }' energy_${d}A.out
 +done
 +</code>
 +
 +  * The command ''seq 2 0.1 4'' generates the numbers ''2.0'', ''2.1'', ''2.2'', ... , ''4.0'' (try it out!)
 +  * With ''for d in $(seq 2 0.1 4); do'' we use the shell to run all commands which follow once for every number (stored in ''$d'')
 +  * ''sed -e "s|4 0 0|$d 0 0|" energy.inp'' looks for ''4 0 0'' in the file ''energy.inp'' (the original file from above) and replaces ''4 0 0'' by ''$d 0 0'' (that is: ''2.0'', ''2.1'', ''2.2'', ...)
 +  * ... and using ''> energy_${d}A.out'' we redirect the output of the ''sed'' command to new files ''energy_2.0A.out'', ''energy_2.1A.out'', etc.
 +  * Then we run ''cp2k.sopt'' as shown before on those new input files and write the output to new output files as well
 +  * Using ''awk'' we extract the energy from the output file
exercises/2016_uzh_cmest/first_simulation_run.1474554950.txt.gz · Last modified: 2020/08/21 10:15 (external edit)