Action: PRINT
| Module | generic |
|---|---|
| Description | Usage |
| Print quantities to a file. | |
| This action outputs data to a file. You can read more about how PLUMED manages output files here |
Details and examples
Print quantities to a file.
This command can be used to output quantities to a file. The following demonstrates a very simple example:
d: DISTANCECalculate the distance/s between pairs of atoms. More details ATOMSthe pair of atom that we are calculating the distance between=1,2 PRINTPrint quantities to a file. More details ARGthe labels of the values that you would like to print to the file=d FILEthe name of the file on which to output these quantities=colvar
This command outputs the distance between atom 1 and 2 to a file called colvar every step of trajectory. If you want to output the distance less frequently you can use the STRIDE keyword as illustrated below:
d: DISTANCECalculate the distance/s between pairs of atoms. More details ATOMSthe pair of atom that we are calculating the distance between=1,2 PRINTPrint quantities to a file. More details ARGthe labels of the values that you would like to print to the file=d FILEthe name of the file on which to output these quantities=colvar STRIDE the frequency with which the quantities of interest should be output=10
With the input above the distance is only output on every 10th step. Notice this distance will only be calculated on every step as this quantity is not used on every other step.
You can also control the format of the numbers that are output by using the FMT keyword as shown below:
d: DISTANCECalculate the distance/s between pairs of atoms. More details ATOMSthe pair of atom that we are calculating the distance between=1,2 PRINTPrint quantities to a file. More details ARGthe labels of the values that you would like to print to the file=d FILEthe name of the file on which to output these quantities=colvar FMT the format that should be used to output real numbers=%10.6f
The FMT key takes a C format specifiers in input, which is what determines the appearance of the numbers output.
You can also use the PRINT command to output objects that have a rank that is greater than zero. For example, the following input calculates a vector of three distances. These three distances are then output to the output colvar file every step.
d: DISTANCECalculate the distance/s between pairs of atoms. More details ATOMS1the pair of atom that we are calculating the distance between=1,2 ATOMS2the pair of atom that we are calculating the distance between=3,4 ATOMS3the pair of atom that we are calculating the distance between=5,6 PRINTPrint quantities to a file. More details ARGthe labels of the values that you would like to print to the file=d FILEthe name of the file on which to output these quantities=colvar
Alterantively, we can output a matrix by using an input like the one shown below:
d: DISTANCE_MATRIXCalculate a matrix of distances between atoms. This action has hidden defaults. More details GROUPthe atoms for which you would like to calculate the adjacency matrix=1-4 PRINTPrint quantities to a file. More details ARGthe labels of the values that you would like to print to the file=d FILEthe name of the file on which to output these quantities=colvar
The output colvar file here will contain the 16 elements of the matrix on each line output. You can
also use PRINT to output functions on grids. However, you are probably better using DUMPGRID or
DUMPCUBE to output functions on grids.
The PRINT directive can be used multiple times in the input so you can print files with different strides or print different quantities to different files as illustrated in the example input below:
# compute distance: distance: DISTANCECalculate the distance/s between pairs of atoms. More details ATOMSthe pair of atom that we are calculating the distance between=2,5 # compute total energy (potential) energy: ENERGYCalculate the total potential energy of the simulation box. More details # print distance on a file PRINTPrint quantities to a file. More details ARGthe labels of the values that you would like to print to the file=distance STRIDE the frequency with which the quantities of interest should be output=10 FILEthe name of the file on which to output these quantities=COLVAR # print both variables on another file PRINTPrint quantities to a file. More details ARGthe labels of the values that you would like to print to the file=distance,energy STRIDE the frequency with which the quantities of interest should be output=1000 FILEthe name of the file on which to output these quantities=COLVAR_ALL
The input above instructs plumed to print the distance between atoms 3 and 5 on a file called COLVAR every 10 steps, and the distance and total energy on a file called COLVAR_ALL every 1000 steps.
You can control the buffering of output using the FLUSH keyword. Furthermore, whether the output file is
appended or backed up depends on whetehr or not the RESTART action is present on the file. If you add RESTART=yes on the
line containing the PRINT directive the file will be appended also.
Printing happens in the so-called "update" phase. This implies that printing
is affected by the presence of UPDATE_IF actions. One can thus decide to start
and stop printing at preassigned values of time using the UPDATE_FROM and UPDATE_UNTIL keywords.
Keep into account that even on steps when the action is not updated (and thus the file is not printed)
the argument will be activated. In other words, if you use UPDATE_FROM to start printing at a given time,
the collective variables this PRINT statement depends on will be computed also before that time.
PRINT and RESTART
If you run a calculation with the following input:
d: DISTANCECalculate the distance/s between pairs of atoms. More details ATOMSthe pair of atom that we are calculating the distance between=1,2 PRINTPrint quantities to a file. More details ARGthe labels of the values that you would like to print to the file=d FILEthe name of the file on which to output these quantities=colvar
and a file called colvar is already present in the directory where the calculation is running, the existing file is backed up
and renamed to bck.0.colvar so that new data can be output to a new file called colvar. If you would like to append to the
existing file you can use the RESTART command as shown below:
d: DISTANCECalculate the distance/s between pairs of atoms. More details ATOMSthe pair of atom that we are calculating the distance between=1,2 PRINTPrint quantities to a file. More details ARGthe labels of the values that you would like to print to the file=d FILEthe name of the file on which to output these quantities=colvar RESTARTallows per-action setting of restart (YES/NO/AUTO)=YES
You can achieve the same result by using the RESTART action as shown below:
RESTARTActivate restart. More details d: DISTANCECalculate the distance/s between pairs of atoms. More details ATOMSthe pair of atom that we are calculating the distance between=1,2 PRINTPrint quantities to a file. More details ARGthe labels of the values that you would like to print to the file=d FILEthe name of the file on which to output these quantities=colvar
However, the advantage of using the RESTART keyword is that you can apped to some files and back up others as illustrated below:
d1: DISTANCECalculate the distance/s between pairs of atoms. More details ATOMSthe pair of atom that we are calculating the distance between=1,2 PRINTPrint quantities to a file. More details ARGthe labels of the values that you would like to print to the file=d1 FILEthe name of the file on which to output these quantities=colvar1 d2: DISTANCECalculate the distance/s between pairs of atoms. More details ATOMSthe pair of atom that we are calculating the distance between=3,4 PRINTPrint quantities to a file. More details ARGthe labels of the values that you would like to print to the file=d2 FILEthe name of the file on which to output these quantities=colvar2 RESTARTallows per-action setting of restart (YES/NO/AUTO)=YES
If you use the input above the file colvar1 is backed up, while new data will be appended to the file colvar2. If you use the
RESTART action instead data will be appended to both colvar files.
Switching printing on and off
You can use the UPDATE_FROM and UPDATE_UNTIL flags to make the PRINT command only output data at certain points during the trajectory. To see how this works consider the following example:
d: DISTANCECalculate the distance/s between pairs of atoms. More details ATOMSthe pair of atom that we are calculating the distance between=1,2 PRINTPrint quantities to a file. More details ARGthe labels of the values that you would like to print to the file=d FILEthe name of the file on which to output these quantities=colvar UPDATE_FROMOnly update this action from this time=100 UPDATE_UNTILOnly update this action until this time=500 STRIDE the frequency with which the quantities of interest should be output=1
During the first 100 ps of the simulation with this input the distance between atoms 1 and 2 is not output to the file called colvar. The distance is instead first output after the first 100 ps of trajectory have elapsed. Furthermore, output of the distance stops once the trajectory is longer than 500 ps. In other words, the distance is only output during the 400 ps time interval after the first 100 ps of the simulation.
Input
The arguments that serve as the input for this action are specified using one or more of the keywords in the following table.
| Keyword | Type | Description |
|---|---|---|
| ARG | scalar/vector/matrix | the labels of the values that you would like to print to the file |
Full list of keywords
The following table describes the keywords and options that can be used with this action
| Keyword | Type | Default | Description |
|---|---|---|---|
| ARG | input | none | the labels of the values that you would like to print to the file |
| STRIDE | compulsory | 1 | the frequency with which the quantities of interest should be output |
| FMT | compulsory | %f | the format that should be used to output real numbers |
| FILE | optional | not used | the name of the file on which to output these quantities |
| RESTART | optional | not used | allows per-action setting of restart (YES/NO/AUTO) |
| UPDATE_FROM | optional | not used | Only update this action from this time |
| UPDATE_UNTIL | optional | not used | Only update this action until this time |