CHARMM Development Project
Posted By: Rohit Write forces in single file - 08/12/20 06:58 AM
Hello everyone,

Below is the script I am using for force calculation. I have the following questions.

1. I want to write the forces of all frames into a single file? How do I do it append does not work?
2. Both "TEST FIRST" and "COOR FORCE COMP" gives the same values but later is faster so which would you recommend?
3. Should I use UPDATe keyword in the loop before "COOR FORCE COMP"?

Code
 NBOND CUTNB @ctl CUTIM @ctl CTOFnb @rc CTONnb @ci -
       atom vatom vdistance                        -
       VSWITCH  SHIFT  CDIE eps 1.0  e14fac 1.0  wmin 1.5

 ! ENERGY

!================================================================                         
!Set up for reading coordinate sets from the trajectory and writing data                      
!================================================================      
OPEN READ UNIT 51 FILE NAME ./prod/diala_recen.dcd
TRAJECTORY QUERY UNIT 51
OPEN UNIT 12 WRITE CARD NAME ./anal/forces/all_forces.dat

calc nstop = ?NFILE             ! last step = number of frames * runs per frame * steps per run

TRAJECTORY FIRSTU 51 NUNIT 1 IREAD BEGIN 0 STOP ?NFILE

SET frame 0
LABEL TimeFrame

TRAJ READ
ENERGY

DEFINE FATOMS SELE SEGID PRT END
! TEST FIRST TOL 0.00000001 UNIT 12 CRYSTAL SELE FATOMS END

COOR FORCE COMP 
WRITE COOR CARD UNIT 12 COMP SELE FATOMS END
* title
*

! CLOSE UNIT 12
increment frame
if frame .LT. 10 GOTO TimeFrame         !!!! small run to check that script runs correctly
! if frame .LT. ?NFILE GOTO TimeFrame

STOP

Thank-you,
Regards,
Rohit
Posted By: lennart Re: Write forces in single file - 08/12/20 08:34 AM
1. WRITE COOR cannot append to an existing file. You can use the CHARMM SYSTEM command to concatenate this file to an existing file, something like SYSTTEM "cat single_focec.dat >> all_forces.dat"
2. Use COOR FORCE COMP. TEST FIRST is a command for testing (and does more than just compute the force, so is slow).
3. The ENERGY command should do an update, which is necessary.
Posted By: Rohit Re: Write forces in single file - 08/18/20 05:46 AM
Thank you for the SYSTEM command suggestion. It's nice to have it in CHARMM.
© CHARMM forums