CHARMM Development Project
Posted By: Rohit speed up energy calculation in loop - 04/25/19 09:00 AM
Hi
Below is script for interaction energy calculation. I call this script from bash script.
Code:
!================================================================
! Crystal definition and cutoffs
!================================================================
set ci  10.   ! inner switching cutoff
set rc  12.   ! cutoff
set ctl 14.   ! list-cutoff
set xo  14.   ! cutoff for crystal

!================================================================
!non bonded cut-offs
!================================================================
 NBOND CUTNB @ctl CUTIM @ctl CTOFnb @rc CTONnb @ci -
       atom vatom vdistance                        -
       VSWITCH  SHIFT  CDIE eps 1.0  e14fac 1.0  wmin 1.5

set res1 1

LABEL innerloop
!============================================================
! Write data to file
!============================================================
OPEN UNIT 28 WRITE FORM NAME ./solv_inter_ene/@i/inter_ene_solv_@res1.@i.dat

!============================================================
! Read TRAJ
!============================================================
OPEN READ UNIT 51 FILE NAME ./recen/@i/unfold_1le0.joball.@i.recen.dcd
! OPEN READ UNIT 51 FILE NAME ./extract/unfold_1le0.joball.@i.extract.dcd
TRAJECTORY QUERY UNIT 51
traj iread 51 nskip 1 begin 0 stop ?NSTEP skip 

SET frame 0
LABEL TimeFrame
TRAJ READ

!============================================================
! Example inter Select resid <residue_number> END Select resid <residue_number> show end
! interaction each residue w.r.t solution
!============================================================
inter SELECT resid @res1 END SELECT .NOT. segid PRT END

!==================================================
! writing output
!==================================================
write title unit 28
* @frame ?ener ?vdw ?elec
*

increment frame
!if frame .LT. 15 GOTO TimeFrame         !!!! small run to check that script runs correctly
if frame .LT. ?NFILE GOTO TimeFrame

close unit 28

increment res1
if res1 .LT. 13 GOTO innerloop
STOP


This calculation takes 20 mins for 1 Amino Acid with all solvent. I have 12 amino acids so it will take 240 mins for 1 trajectory. I have 96 trajectories.

Is there any better way (faster way) of doing this analysis. am i doing something wrong.
Posted By: lennart Re: speed up energy calculation in loop - 04/25/19 12:13 PM
A couple of things that you can consider:
Reduce the number of time frames you analyze (ie, increase nskip)
Do the loop over amino acids inside the trajectory-reading loop (ie, read a frame and then analyze the interactions for all 12 aa before reading the next frame)
CONS FIX sele .not. segid prt end after you have read one frame
then CONS FIX sele none end before you read the next frame:
label tloop
cons fix sele none end
traj read
cons fix sele .not. segid prt end
intere ...
write title unit 101
intere ...
write title unit 102
.
.
intere ...
write title unit 112
goto tloop

And you can of course do all 96 trajectories at the same time if you have enough cores.

I would add ".and. segid PRT" to the first intere-selection, just in case there are solvent molecules with the same resid as one of the amino acids.
© CHARMM forums