2 c------------------------------------------------
3 c The driver for molecular dynamics subroutines
4 c------------------------------------------------
5 implicit real*8 (a-h,o-z)
11 include 'COMMON.SETUP'
12 include 'COMMON.CONTROL'
15 include 'COMMON.LAGRANGE'
17 include 'COMMON.LANGEVIN'
19 include 'COMMON.LANGEVIN.lang0'
21 include 'COMMON.CHAIN'
22 include 'COMMON.DERIV'
24 include 'COMMON.LOCAL'
25 include 'COMMON.INTERACT'
26 include 'COMMON.IOUNITS'
27 include 'COMMON.NAMES'
28 include 'COMMON.TIME1'
29 include 'COMMON.HAIRPIN'
30 double precision cm(3),L(3),vcm(3)
32 double precision v_work(maxres6),v_transf(maxres6)
42 if (ilen(tmpdir).gt.0)
43 & call copy_to_tmp(pref_orig(:ilen(pref_orig))//"_"
44 & //liczba(:ilen(liczba))//'.rst')
46 if (ilen(tmpdir).gt.0)
47 & call copy_to_tmp(pref_orig(:ilen(pref_orig))//"_"//'.rst')
54 write (iout,'(20(1h=),a20,20(1h=))') "MD calculation started"
60 c Determine the inverse of the inertia matrix.
61 call setup_MD_matrices
65 t_MDsetup = MPI_Wtime()-tt0
67 t_MDsetup = tcpu()-tt0
70 c Entering the MD loop
76 if (lang.eq.2 .or. lang.eq.3) then
80 call sd_verlet_p_setup
82 call sd_verlet_ciccotti_setup
86 pfric0_mat(i,j,0)=pfric_mat(i,j)
87 afric0_mat(i,j,0)=afric_mat(i,j)
88 vfric0_mat(i,j,0)=vfric_mat(i,j)
89 prand0_mat(i,j,0)=prand_mat(i,j)
90 vrand0_mat1(i,j,0)=vrand_mat1(i,j)
91 vrand0_mat2(i,j,0)=vrand_mat2(i,j)
100 & "LANG=2 or 3 NOT SUPPORTED. Recompile without -DLANG0"
102 call MPI_Abort(MPI_COMM_WORLD,IERROR,ERRCODE)
106 else if (lang.eq.1 .or. lang.eq.4) then
110 t_langsetup=MPI_Wtime()-tt0
113 t_langsetup=tcpu()-tt0
116 do itime=1,n_timestep
118 if (large.and. mod(itime,ntwe).eq.0)
119 & write (iout,*) "itime",itime
121 if (lang.gt.0 .and. surfarea .and.
122 & mod(itime,reset_fricmat).eq.0) then
123 if (lang.eq.2 .or. lang.eq.3) then
127 call sd_verlet_p_setup
129 call sd_verlet_ciccotti_setup
133 pfric0_mat(i,j,0)=pfric_mat(i,j)
134 afric0_mat(i,j,0)=afric_mat(i,j)
135 vfric0_mat(i,j,0)=vfric_mat(i,j)
136 prand0_mat(i,j,0)=prand_mat(i,j)
137 vrand0_mat1(i,j,0)=vrand_mat1(i,j)
138 vrand0_mat2(i,j,0)=vrand_mat2(i,j)
143 flag_stoch(i)=.false.
146 else if (lang.eq.1 .or. lang.eq.4) then
149 write (iout,'(a,i10)')
150 & "Friction matrix reset based on surface area, itime",itime
152 if (reset_vel .and. tbf .and. lang.eq.0
153 & .and. mod(itime,count_reset_vel).eq.0) then
155 write(iout,'(a,f20.2)')
156 & "Velocities reset to random values, time",totT
159 d_t_old(j,i)=d_t(j,i)
163 if (reset_moment .and. mod(itime,count_reset_moment).eq.0) then
167 d_t(j,0)=d_t(j,0)-vcm(j)
170 kinetic_T=2.0d0/(dimen3*Rb)*EK
171 scalfac=dsqrt(T_bath/kinetic_T)
172 write(iout,'(a,f20.2)') "Momenta zeroed out, time",totT
175 d_t_old(j,i)=scalfac*d_t(j,i)
181 c Time-reversible RESPA algorithm
182 c (Tuckerman et al., J. Chem. Phys., 97, 1990, 1992)
183 call RESPA_step(itime)
185 c Variable time step algorithm.
186 call velverlet_step(itime)
190 call brown_step(itime)
192 print *,"Brown dynamics not here!"
194 call MPI_Abort(MPI_COMM_WORLD,IERROR,ERRCODE)
200 if (mod(itime,ntwe).eq.0) then
202 C call enerprint(potEcomp)
203 C print *,itime,'AFM',Eafmforc,etot
217 if (itype(i).ne.10 .and. itype(i).ne.ntyp1) then
220 v_work(ind)=d_t(j,i+nres)
225 write (66,'(80f10.5)')
226 & ((d_t(j,i),j=1,3),i=0,nres-1),((d_t(j,i+nres),j=1,3),i=1,nres)
230 v_transf(i)=v_transf(i)+gvec(j,i)*v_work(j)
232 v_transf(i)= v_transf(i)*dsqrt(geigen(i))
234 write (67,'(80f10.5)') (v_transf(i),i=1,ind)
237 if (mod(itime,ntwx).eq.0) then
238 c write(iout,*) 'time=',itime
239 C call check_ecartint
241 write (tytul,'("time",f8.2)') totT
243 call hairpin(.true.,nharp,iharp)
244 call secondary2(.true.)
245 call pdbout(potE,tytul,ipdb)
250 if (rstcount.eq.1000.or.itime.eq.n_timestep) then
251 open(irest2,file=rest2name,status='unknown')
252 write(irest2,*) totT,EK,potE,totE,t_bath
254 write (irest2,'(3e15.5)') (d_t(j,i),j=1,3)
257 write (irest2,'(3e15.5)') (dc(j,i),j=1,3)
268 write (iout,'(//35(1h=),a10,35(1h=)/10(/a40,1pe15.5))')
270 & 'MD calculations setup:',t_MDsetup,
271 & 'Energy & gradient evaluation:',t_enegrad,
272 & 'Stochastic MD setup:',t_langsetup,
273 & 'Stochastic MD step setup:',t_sdsetup,
275 write (iout,'(/28(1h=),a25,27(1h=))')
276 & ' End of MD calculation '
278 write (iout,*) "time for etotal",t_etotal," elong",t_elong,
280 write (iout,*) "time_fric",time_fric," time_stoch",time_stoch,
281 & " time_fricmatmult",time_fricmatmult," time_fsample ",
286 c-------------------------------------------------------------------------------
287 subroutine velverlet_step(itime)
288 c-------------------------------------------------------------------------------
289 c Perform a single velocity Verlet step; the time step can be rescaled if
290 c increments in accelerations exceed the threshold
291 c-------------------------------------------------------------------------------
292 implicit real*8 (a-h,o-z)
296 integer ierror,ierrcode
298 include 'COMMON.SETUP'
299 include 'COMMON.CONTROL'
302 include 'COMMON.LAGRANGE'
304 include 'COMMON.LANGEVIN'
306 include 'COMMON.LANGEVIN.lang0'
308 include 'COMMON.CHAIN'
309 include 'COMMON.DERIV'
311 include 'COMMON.LOCAL'
312 include 'COMMON.INTERACT'
313 include 'COMMON.IOUNITS'
314 include 'COMMON.NAMES'
315 include 'COMMON.TIME1'
316 include 'COMMON.MUCA'
317 double precision vcm(3),incr(3)
318 double precision cm(3),L(3)
319 integer ilen,count,rstcount
322 integer maxcount_scale /20/
324 double precision stochforcvec(MAXRES6)
325 common /stochcalc/ stochforcvec
333 else if (lang.eq.2 .or. lang.eq.3) then
335 call stochastic_force(stochforcvec)
338 & "LANG=2 or 3 NOT SUPPORTED. Recompile without -DLANG0"
340 call MPI_Abort(MPI_COMM_WORLD,IERROR,ERRCODE)
347 icount_scale=icount_scale+1
348 if (icount_scale.gt.maxcount_scale) then
350 & "ERROR: too many attempts at scaling down the time step. ",
351 & "amax=",amax,"epdrift=",epdrift,
352 & "damax=",damax,"edriftmax=",edriftmax,
356 call MPI_Abort(MPI_COMM_WORLD,IERROR,IERRCODE)
360 c First step of the velocity Verlet algorithm
365 else if (lang.eq.3) then
367 call sd_verlet1_ciccotti
369 else if (lang.eq.1) then
374 c Build the chain from the newly calculated coordinates
376 if (rattle) call rattle1
378 if (large.and. mod(itime,ntwe).eq.0) then
379 write (iout,*) "Cartesian and internal coordinates: step 1"
384 write (iout,'(i3,3f10.5,3x,3f10.5)') i,(dc(j,i),j=1,3),
385 & (dc(j,i+nres),j=1,3)
387 write (iout,*) "Accelerations"
389 write (iout,'(i3,3f10.5,3x,3f10.5)') i,(d_a(j,i),j=1,3),
390 & (d_a(j,i+nres),j=1,3)
392 write (iout,*) "Velocities, step 1"
394 write (iout,'(i3,3f10.5,3x,3f10.5)') i,(d_t(j,i),j=1,3),
395 & (d_t(j,i+nres),j=1,3)
404 c Calculate energy and forces
406 call etotal(potEcomp)
407 ! AL 4/17/17: Reduce the steps if NaNs occurred.
408 if (potEcomp(0).gt.0.99e20 .or. isnan(potEcomp(0)).gt.0) then
413 if (large.and. mod(itime,ntwe).eq.0)
414 & call enerprint(potEcomp)
417 t_etotal=t_etotal+MPI_Wtime()-tt0
419 t_etotal=t_etotal+tcpu()-tt0
422 potE=potEcomp(0)-potEcomp(20)
424 c Get the new accelerations
427 t_enegrad=t_enegrad+MPI_Wtime()-tt0
429 t_enegrad=t_enegrad+tcpu()-tt0
431 c Determine maximum acceleration and scale down the timestep if needed
433 amax=amax/(itime_scal+1)**2
434 call predict_edrift(epdrift)
435 if (amax/(itime_scal+1).gt.damax .or. epdrift.gt.edriftmax) then
436 c Maximum acceleration or maximum predicted energy drift exceeded, rescale the time step
438 ifac_time=dmax1(dlog(amax/damax),dlog(epdrift/edriftmax))
440 itime_scal=itime_scal+ifac_time
441 c fac_time=dmin1(damax/amax,0.5d0)
442 fac_time=0.5d0**ifac_time
443 d_time=d_time*fac_time
444 if (lang.eq.2 .or. lang.eq.3) then
446 c write (iout,*) "Calling sd_verlet_setup: 1"
447 c Rescale the stochastic forces and recalculate or restore
448 c the matrices of tinker integrator
449 if (itime_scal.gt.maxflag_stoch) then
450 if (large) write (iout,'(a,i5,a)')
451 & "Calculate matrices for stochastic step;",
452 & " itime_scal ",itime_scal
454 call sd_verlet_p_setup
456 call sd_verlet_ciccotti_setup
458 write (iout,'(2a,i3,a,i3,1h.)')
459 & "Warning: cannot store matrices for stochastic",
460 & " integration because the index",itime_scal,
461 & " is greater than",maxflag_stoch
462 write (iout,'(2a)')"Increase MAXFLAG_STOCH or use direct",
463 & " integration Langevin algorithm for better efficiency."
464 else if (flag_stoch(itime_scal)) then
465 if (large) write (iout,'(a,i5,a,l1)')
466 & "Restore matrices for stochastic step; itime_scal ",
467 & itime_scal," flag ",flag_stoch(itime_scal)
470 pfric_mat(i,j)=pfric0_mat(i,j,itime_scal)
471 afric_mat(i,j)=afric0_mat(i,j,itime_scal)
472 vfric_mat(i,j)=vfric0_mat(i,j,itime_scal)
473 prand_mat(i,j)=prand0_mat(i,j,itime_scal)
474 vrand_mat1(i,j)=vrand0_mat1(i,j,itime_scal)
475 vrand_mat2(i,j)=vrand0_mat2(i,j,itime_scal)
479 if (large) write (iout,'(2a,i5,a,l1)')
480 & "Calculate & store matrices for stochastic step;",
481 & " itime_scal ",itime_scal," flag ",flag_stoch(itime_scal)
483 call sd_verlet_p_setup
485 call sd_verlet_ciccotti_setup
487 flag_stoch(ifac_time)=.true.
490 pfric0_mat(i,j,itime_scal)=pfric_mat(i,j)
491 afric0_mat(i,j,itime_scal)=afric_mat(i,j)
492 vfric0_mat(i,j,itime_scal)=vfric_mat(i,j)
493 prand0_mat(i,j,itime_scal)=prand_mat(i,j)
494 vrand0_mat1(i,j,itime_scal)=vrand_mat1(i,j)
495 vrand0_mat2(i,j,itime_scal)=vrand_mat2(i,j)
499 fac_time=1.0d0/dsqrt(fac_time)
501 stochforcvec(i)=fac_time*stochforcvec(i)
504 else if (lang.eq.1) then
505 c Rescale the accelerations due to stochastic forces
506 fac_time=1.0d0/dsqrt(fac_time)
508 d_as_work(i)=d_as_work(i)*fac_time
511 if (large) write (iout,'(a,i10,a,f8.6,a,i3,a,i3)')
512 & "itime",itime," Timestep scaled down to ",
513 & d_time," ifac_time",ifac_time," itime_scal",itime_scal
515 c Second step of the velocity Verlet algorithm
520 else if (lang.eq.3) then
522 call sd_verlet2_ciccotti
524 else if (lang.eq.1) then
529 if (rattle) call rattle2
532 C print *,totTafm,"TU?"
533 if (d_time.ne.d_time0) then
536 if (lang.eq.2 .or. lang.eq.3) then
537 if (large) write (iout,'(a)')
538 & "Restore original matrices for stochastic step"
539 c write (iout,*) "Calling sd_verlet_setup: 2"
540 c Restore the matrices of tinker integrator if the time step has been restored
543 pfric_mat(i,j)=pfric0_mat(i,j,0)
544 afric_mat(i,j)=afric0_mat(i,j,0)
545 vfric_mat(i,j)=vfric0_mat(i,j,0)
546 prand_mat(i,j)=prand0_mat(i,j,0)
547 vrand_mat1(i,j)=vrand0_mat1(i,j,0)
548 vrand_mat2(i,j)=vrand0_mat2(i,j,0)
557 c Calculate the kinetic and the total energy and the kinetic temperature
562 c write (iout,*) "step",itime," EK",EK," EK1",EK1
564 c Couple the system to Berendsen bath if needed
565 if (tbf .and. lang.eq.0) then
568 kinetic_T=2.0d0/(dimen3*Rb)*EK
569 c Backup the coordinates, velocities, and accelerations
573 d_t_old(j,i)=d_t(j,i)
574 d_a_old(j,i)=d_a(j,i)
578 if (mod(itime,ntwe).eq.0 .and. large) then
579 write (iout,*) "Velocities, step 2"
581 write (iout,'(i3,3f10.5,3x,3f10.5)') i,(d_t(j,i),j=1,3),
582 & (d_t(j,i+nres),j=1,3)
588 c-------------------------------------------------------------------------------
589 subroutine RESPA_step(itime)
590 c-------------------------------------------------------------------------------
591 c Perform a single RESPA step.
592 c-------------------------------------------------------------------------------
593 implicit real*8 (a-h,o-z)
597 integer IERROR,ERRCODE
599 include 'COMMON.SETUP'
600 include 'COMMON.CONTROL'
603 include 'COMMON.LAGRANGE'
605 include 'COMMON.LANGEVIN'
607 include 'COMMON.LANGEVIN.lang0'
609 include 'COMMON.CHAIN'
610 include 'COMMON.DERIV'
612 include 'COMMON.LOCAL'
613 include 'COMMON.INTERACT'
614 include 'COMMON.IOUNITS'
615 include 'COMMON.NAMES'
616 include 'COMMON.TIME1'
618 common /shortcheck/ lprint_short
619 double precision energia_short(0:n_ene),
620 & energia_long(0:n_ene)
621 double precision cm(3),L(3),vcm(3),incr(3)
622 double precision dc_old0(3,0:maxres2),d_t_old0(3,0:maxres2),
623 & d_a_old0(3,0:maxres2)
624 logical PRINT_AMTS_MSG /.false./
625 integer ilen,count,rstcount
628 integer maxcount_scale /10/
630 double precision stochforcvec(MAXRES6)
631 common /stochcalc/ stochforcvec
634 common /cipiszcze/ itt
637 if (large.and. mod(itime,ntwe).eq.0) then
638 write (iout,*) "***************** RESPA itime",itime
639 write (iout,*) "Cartesian and internal coordinates: step 0"
644 write (iout,*) "Accelerations from long-range forces"
646 write (iout,'(i3,3f10.5,3x,3f10.5)') i,(d_a(j,i),j=1,3),
647 & (d_a(j,i+nres),j=1,3)
649 write (iout,*) "Velocities, step 0"
651 write (iout,'(i3,3f10.5,3x,3f10.5)') i,(d_t(j,i),j=1,3),
652 & (d_t(j,i+nres),j=1,3)
657 c Perform the initial RESPA step (increment velocities)
658 c write (iout,*) "*********************** RESPA ini"
661 if (mod(itime,ntwe).eq.0 .and. large) then
662 write (iout,*) "Velocities, end"
664 write (iout,'(i3,3f10.5,3x,3f10.5)') i,(d_t(j,i),j=1,3),
665 & (d_t(j,i+nres),j=1,3)
669 c Compute the short-range forces
675 C 7/2/2009 commented out
677 c call etotal_short(energia_short)
680 C 7/2/2009 Copy accelerations due to short-lange forces from previous MD step
683 d_a(j,i)=d_a_short(j,i)
687 if (large.and. mod(itime,ntwe).eq.0) then
688 write (iout,*) "energia_short",energia_short(0)
689 write (iout,*) "Accelerations from short-range forces"
691 write (iout,'(i3,3f10.5,3x,3f10.5)') i,(d_a(j,i),j=1,3),
692 & (d_a(j,i+nres),j=1,3)
697 t_enegrad=t_enegrad+MPI_Wtime()-tt0
699 t_enegrad=t_enegrad+tcpu()-tt0
704 d_t_old(j,i)=d_t(j,i)
705 d_a_old(j,i)=d_a(j,i)
708 c 6/30/08 A-MTS: attempt at increasing the split number
711 dc_old0(j,i)=dc_old(j,i)
712 d_t_old0(j,i)=d_t_old(j,i)
713 d_a_old0(j,i)=d_a_old(j,i)
716 if (ntime_split.gt.ntime_split0) ntime_split=ntime_split/2
717 if (ntime_split.lt.ntime_split0) ntime_split=ntime_split0
724 c write (iout,*) "itime",itime," ntime_split",ntime_split
725 c Split the time step
726 d_time=d_time0/ntime_split
727 c Perform the short-range RESPA steps (velocity Verlet increments of
728 c positions and velocities using short-range forces)
729 c write (iout,*) "*********************** RESPA split"
730 do itsplit=1,ntime_split
733 else if (lang.eq.2 .or. lang.eq.3) then
735 call stochastic_force(stochforcvec)
738 & "LANG=2 or 3 NOT SUPPORTED. Recompile without -DLANG0"
740 call MPI_Abort(MPI_COMM_WORLD,IERROR,ERRCODE)
745 c First step of the velocity Verlet algorithm
750 else if (lang.eq.3) then
752 call sd_verlet1_ciccotti
754 else if (lang.eq.1) then
759 c Build the chain from the newly calculated coordinates
761 if (rattle) call rattle1
763 if (large.and. mod(itime,ntwe).eq.0) then
764 write (iout,*) "***** ITSPLIT",itsplit
765 write (iout,*) "Cartesian and internal coordinates: step 1"
770 write (iout,*) "Velocities, step 1"
772 write (iout,'(i3,3f10.5,3x,3f10.5)') i,(d_t(j,i),j=1,3),
773 & (d_t(j,i+nres),j=1,3)
782 c Calculate energy and forces
783 c if (large.and. mod(itime,ntwe).eq.0) lprint_short=.true.
785 call etotal_short(energia_short)
786 ! AL 4/17/17: Exit itime_split loop when energy goes infinite
787 if (energia_short(0).gt.0.99e20 .or. isnan(energia_short(0)) )
789 if (PRINT_AMTS_MSG) write (iout,*)
790 & "Infinities/NaNs in energia_short",
791 & energia_short(0),"; increasing ntime_split to",ntime_split
792 ntime_split=ntime_split*2
793 if (ntime_split.gt.maxtime_split) then
795 write (iout,*) "Cannot rescue the run; aborting job.",
796 & " Retry with a smaller time step"
798 call MPI_Abort(MPI_COMM_WORLD,IERROR,ERRCODE)
800 write (iout,*) "Cannot rescue the run; terminating.",
801 & " Retry with a smaller time step"
807 if (large.and. mod(itime,ntwe).eq.0)
808 & call enerprint(energia_short)
811 t_eshort=t_eshort+MPI_Wtime()-tt0
813 t_eshort=t_eshort+tcpu()-tt0
817 c Get the new accelerations
819 C 7/2/2009 Copy accelerations due to short-lange forces to an auxiliary array
822 d_a_short(j,i)=d_a(j,i)
826 if (large.and. mod(itime,ntwe).eq.0) then
827 write (iout,*)"energia_short",energia_short(0)
828 write (iout,*) "Accelerations from short-range forces"
830 write (iout,'(i3,3f10.5,3x,3f10.5)') i,(d_a(j,i),j=1,3),
831 & (d_a(j,i+nres),j=1,3)
836 c Determine maximum acceleration and scale down the timestep if needed
838 amax=amax/ntime_split**2
839 call predict_edrift(epdrift)
840 if (ntwe.gt.0 .and. large .and. mod(itime,ntwe).eq.0)
841 & write (iout,*) "amax",amax," damax",damax,
842 & " epdrift",epdrift," epdriftmax",epdriftmax
843 c Exit loop and try with increased split number if the change of
844 c acceleration is too big
845 if (amax.gt.damax .or. epdrift.gt.edriftmax) then
846 if (ntime_split.lt.maxtime_split) then
848 ntime_split=ntime_split*2
851 dc_old(j,i)=dc_old0(j,i)
852 d_t_old(j,i)=d_t_old0(j,i)
853 d_a_old(j,i)=d_a_old0(j,i)
856 if (PRINT_AMTS_MSG) then
857 write (iout,*) "acceleration/energy drift too large",amax,
858 & epdrift," split increased to ",ntime_split," itime",itime,
864 & "Uh-hu. Bumpy landscape. Maximum splitting number",
866 & " already reached!!! Trying to carry on!"
870 t_enegrad=t_enegrad+MPI_Wtime()-tt0
872 t_enegrad=t_enegrad+tcpu()-tt0
874 c Second step of the velocity Verlet algorithm
879 else if (lang.eq.3) then
881 call sd_verlet2_ciccotti
883 else if (lang.eq.1) then
888 if (rattle) call rattle2
889 c Backup the coordinates, velocities, and accelerations
893 d_t_old(j,i)=d_t(j,i)
894 d_a_old(j,i)=d_a(j,i)
901 c Restore the time step
903 c Compute long-range forces
910 call etotal_long(energia_long)
911 ! AL 4/17/2017 Handling NaNs
912 if (energia_long(0).gt.0.99e20 .or. isnan(energia_long(0))) then
915 & "Infinitied/NaNs in energia_long, Aborting MPI job."
916 call enerprint(energia_long)
918 call MPI_Abort(MPI_COMM_WORLD,IERROR,ERRCODE)
920 write (iout,*) "Infinitied/NaNs in energia_long, terminating."
921 call enerprint(energia_long)
926 c lprint_short=.false.
927 if (large.and. mod(itime,ntwe).eq.0)
928 & call enerprint(energia_long)
931 t_elong=t_elong+MPI_Wtime()-tt0
933 t_elong=t_elong+tcpu()-tt0
939 t_enegrad=t_enegrad+MPI_Wtime()-tt0
941 t_enegrad=t_enegrad+tcpu()-tt0
943 c Compute accelerations from long-range forces
945 if (large.and. mod(itime,ntwe).eq.0) then
946 write (iout,*) "energia_long",energia_long(0)
947 write (iout,*) "Cartesian and internal coordinates: step 2"
952 write (iout,*) "Accelerations from long-range forces"
954 write (iout,'(i3,3f10.5,3x,3f10.5)') i,(d_a(j,i),j=1,3),
955 & (d_a(j,i+nres),j=1,3)
957 write (iout,*) "Velocities, step 2"
959 write (iout,'(i3,3f10.5,3x,3f10.5)') i,(d_t(j,i),j=1,3),
960 & (d_t(j,i+nres),j=1,3)
964 c Compute the final RESPA step (increment velocities)
965 c write (iout,*) "*********************** RESPA fin"
967 c Compute the complete potential energy
969 potEcomp(i)=energia_short(i)+energia_long(i)
971 potE=potEcomp(0)-potEcomp(20)
973 if (large.and. mod(itime,ntwe).eq.0) then
974 call enerprint(potEcomp)
975 write (iout,*) "potE",potD
978 c potE=energia_short(0)+energia_long(0)
981 c Calculate the kinetic and the total energy and the kinetic temperature
984 c Couple the system to Berendsen bath if needed
985 if (tbf .and. lang.eq.0) then
988 kinetic_T=2.0d0/(dimen3*Rb)*EK
989 c Backup the coordinates, velocities, and accelerations
991 if (mod(itime,ntwe).eq.0 .and. large) then
992 write (iout,*) "Velocities, end"
994 write (iout,'(i3,3f10.5,3x,3f10.5)') i,(d_t(j,i),j=1,3),
995 & (d_t(j,i+nres),j=1,3)
1001 c---------------------------------------------------------------------
1002 subroutine RESPA_vel
1003 c First and last RESPA step (incrementing velocities using long-range
1005 implicit real*8 (a-h,o-z)
1006 include 'DIMENSIONS'
1007 include 'COMMON.CONTROL'
1008 include 'COMMON.VAR'
1010 include 'COMMON.LAGRANGE'
1011 include 'COMMON.CHAIN'
1012 include 'COMMON.DERIV'
1013 include 'COMMON.GEO'
1014 include 'COMMON.LOCAL'
1015 include 'COMMON.INTERACT'
1016 include 'COMMON.IOUNITS'
1017 include 'COMMON.NAMES'
1019 d_t(j,0)=d_t(j,0)+0.5d0*d_a(j,0)*d_time
1023 d_t(j,i)=d_t(j,i)+0.5d0*d_a(j,i)*d_time
1027 if (itype(i).ne.10 .and. itype(i).ne.ntyp1) then
1030 d_t(j,inres)=d_t(j,inres)+0.5d0*d_a(j,inres)*d_time
1036 c-----------------------------------------------------------------
1038 c Applying velocity Verlet algorithm - step 1 to coordinates
1039 implicit real*8 (a-h,o-z)
1040 include 'DIMENSIONS'
1041 include 'COMMON.CONTROL'
1042 include 'COMMON.VAR'
1044 include 'COMMON.LAGRANGE'
1045 include 'COMMON.CHAIN'
1046 include 'COMMON.DERIV'
1047 include 'COMMON.GEO'
1048 include 'COMMON.LOCAL'
1049 include 'COMMON.INTERACT'
1050 include 'COMMON.IOUNITS'
1051 include 'COMMON.NAMES'
1052 double precision adt,adt2
1055 write (iout,*) "VELVERLET1 START: DC"
1057 write (iout,'(i3,3f10.5,5x,3f10.5)') i,(dc(j,i),j=1,3),
1058 & (dc(j,i+nres),j=1,3)
1062 adt=d_a_old(j,0)*d_time
1064 dc(j,0)=dc_old(j,0)+(d_t_old(j,0)+adt2)*d_time
1065 d_t_new(j,0)=d_t_old(j,0)+adt2
1066 d_t(j,0)=d_t_old(j,0)+adt
1072 adt=d_a_old(j,i)*d_time
1074 dc(j,i)=dc_old(j,i)+(d_t_old(j,i)+adt2)*d_time
1075 d_t_new(j,i)=d_t_old(j,i)+adt2
1076 d_t(j,i)=d_t_old(j,i)+adt
1081 if (itype(i).ne.10 .and. itype(i).ne.ntyp1) then
1084 adt=d_a_old(j,inres)*d_time
1086 dc(j,inres)=dc_old(j,inres)+(d_t_old(j,inres)+adt2)*d_time
1087 d_t_new(j,inres)=d_t_old(j,inres)+adt2
1088 d_t(j,inres)=d_t_old(j,inres)+adt
1093 write (iout,*) "VELVERLET1 END: DC"
1095 write (iout,'(i3,3f10.5,5x,3f10.5)') i,(dc(j,i),j=1,3),
1096 & (dc(j,i+nres),j=1,3)
1101 c---------------------------------------------------------------------
1103 c Step 2 of the velocity Verlet algorithm: update velocities
1104 implicit real*8 (a-h,o-z)
1105 include 'DIMENSIONS'
1106 include 'COMMON.CONTROL'
1107 include 'COMMON.VAR'
1109 include 'COMMON.LAGRANGE'
1110 include 'COMMON.CHAIN'
1111 include 'COMMON.DERIV'
1112 include 'COMMON.GEO'
1113 include 'COMMON.LOCAL'
1114 include 'COMMON.INTERACT'
1115 include 'COMMON.IOUNITS'
1116 include 'COMMON.NAMES'
1118 d_t(j,0)=d_t_new(j,0)+0.5d0*d_a(j,0)*d_time
1122 d_t(j,i)=d_t_new(j,i)+0.5d0*d_a(j,i)*d_time
1126 if (itype(i).ne.10 .and. itype(i).ne.ntyp1) then
1129 d_t(j,inres)=d_t_new(j,inres)+0.5d0*d_a(j,inres)*d_time
1135 c-----------------------------------------------------------------
1136 subroutine sddir_precalc
1137 c Applying velocity Verlet algorithm - step 1 to coordinates
1138 implicit real*8 (a-h,o-z)
1139 include 'DIMENSIONS'
1143 include 'COMMON.CONTROL'
1144 include 'COMMON.VAR'
1146 include 'COMMON.LAGRANGE'
1148 include 'COMMON.LANGEVIN'
1150 include 'COMMON.LANGEVIN.lang0'
1152 include 'COMMON.CHAIN'
1153 include 'COMMON.DERIV'
1154 include 'COMMON.GEO'
1155 include 'COMMON.LOCAL'
1156 include 'COMMON.INTERACT'
1157 include 'COMMON.IOUNITS'
1158 include 'COMMON.NAMES'
1159 include 'COMMON.TIME1'
1160 double precision stochforcvec(MAXRES6)
1161 common /stochcalc/ stochforcvec
1163 c Compute friction and stochastic forces
1172 time_fric=time_fric+MPI_Wtime()-time00
1175 time_fric=time_fric+tcpu()-time00
1178 call stochastic_force(stochforcvec)
1180 time_stoch=time_stoch+MPI_Wtime()-time00
1182 time_stoch=time_stoch+tcpu()-time00
1185 c Compute the acceleration due to friction forces (d_af_work) and stochastic
1186 c forces (d_as_work)
1188 call ginv_mult(fric_work, d_af_work)
1189 call ginv_mult(stochforcvec, d_as_work)
1192 c---------------------------------------------------------------------
1193 subroutine sddir_verlet1
1194 c Applying velocity Verlet algorithm - step 1 to velocities
1195 implicit real*8 (a-h,o-z)
1196 include 'DIMENSIONS'
1197 include 'COMMON.CONTROL'
1198 include 'COMMON.VAR'
1200 include 'COMMON.LAGRANGE'
1202 include 'COMMON.LANGEVIN'
1204 include 'COMMON.LANGEVIN.lang0'
1206 include 'COMMON.CHAIN'
1207 include 'COMMON.DERIV'
1208 include 'COMMON.GEO'
1209 include 'COMMON.LOCAL'
1210 include 'COMMON.INTERACT'
1211 include 'COMMON.IOUNITS'
1212 include 'COMMON.NAMES'
1213 c Revised 3/31/05 AL: correlation between random contributions to
1214 c position and velocity increments included.
1215 double precision sqrt13 /0.57735026918962576451d0/ ! 1/sqrt(3)
1216 double precision adt,adt2
1218 c Add the contribution from BOTH friction and stochastic force to the
1219 c coordinates, but ONLY the contribution from the friction forces to velocities
1222 adt=(d_a_old(j,0)+d_af_work(j))*d_time
1223 adt2=0.5d0*adt+sqrt13*d_as_work(j)*d_time
1224 dc(j,0)=dc_old(j,0)+(d_t_old(j,0)+adt2)*d_time
1225 d_t_new(j,0)=d_t_old(j,0)+0.5d0*adt
1226 d_t(j,0)=d_t_old(j,0)+adt
1231 adt=(d_a_old(j,i)+d_af_work(ind+j))*d_time
1232 adt2=0.5d0*adt+sqrt13*d_as_work(ind+j)*d_time
1233 dc(j,i)=dc_old(j,i)+(d_t_old(j,i)+adt2)*d_time
1234 d_t_new(j,i)=d_t_old(j,i)+0.5d0*adt
1235 d_t(j,i)=d_t_old(j,i)+adt
1240 if (itype(i).ne.10 .and. itype(i).ne.ntyp1) then
1243 adt=(d_a_old(j,inres)+d_af_work(ind+j))*d_time
1244 adt2=0.5d0*adt+sqrt13*d_as_work(ind+j)*d_time
1245 dc(j,inres)=dc_old(j,inres)+(d_t_old(j,inres)+adt2)*d_time
1246 d_t_new(j,inres)=d_t_old(j,inres)+0.5d0*adt
1247 d_t(j,inres)=d_t_old(j,inres)+adt
1254 c---------------------------------------------------------------------
1255 subroutine sddir_verlet2
1256 c Calculating the adjusted velocities for accelerations
1257 implicit real*8 (a-h,o-z)
1258 include 'DIMENSIONS'
1259 include 'COMMON.CONTROL'
1260 include 'COMMON.VAR'
1262 include 'COMMON.LAGRANGE'
1264 include 'COMMON.LANGEVIN'
1266 include 'COMMON.LANGEVIN.lang0'
1268 include 'COMMON.CHAIN'
1269 include 'COMMON.DERIV'
1270 include 'COMMON.GEO'
1271 include 'COMMON.LOCAL'
1272 include 'COMMON.INTERACT'
1273 include 'COMMON.IOUNITS'
1274 include 'COMMON.NAMES'
1275 double precision stochforcvec(MAXRES6),d_as_work1(MAXRES6)
1276 double precision cos60 /0.5d0/, sin60 /0.86602540378443864676d0/
1277 c Revised 3/31/05 AL: correlation between random contributions to
1278 c position and velocity increments included.
1279 c The correlation coefficients are calculated at low-friction limit.
1280 c Also, friction forces are now not calculated with new velocities.
1282 c call friction_force
1283 call stochastic_force(stochforcvec)
1285 c Compute the acceleration due to friction forces (d_af_work) and stochastic
1286 c forces (d_as_work)
1288 call ginv_mult(stochforcvec, d_as_work1)
1294 d_t(j,0)=d_t_new(j,0)+(0.5d0*(d_a(j,0)+d_af_work(j))
1295 & +sin60*d_as_work(j)+cos60*d_as_work1(j))*d_time
1300 d_t(j,i)=d_t_new(j,i)+(0.5d0*(d_a(j,i)+d_af_work(ind+j))
1301 & +sin60*d_as_work(ind+j)+cos60*d_as_work1(ind+j))*d_time
1306 if (itype(i).ne.10 .and. itype(i).ne.ntyp1) then
1309 d_t(j,inres)=d_t_new(j,inres)+(0.5d0*(d_a(j,inres)
1310 & +d_af_work(ind+j))+sin60*d_as_work(ind+j)
1311 & +cos60*d_as_work1(ind+j))*d_time
1318 c---------------------------------------------------------------------
1319 subroutine max_accel
1321 c Find the maximum difference in the accelerations of the the sites
1322 c at the beginning and the end of the time step.
1324 implicit real*8 (a-h,o-z)
1325 include 'DIMENSIONS'
1326 include 'COMMON.CONTROL'
1327 include 'COMMON.VAR'
1329 include 'COMMON.LAGRANGE'
1330 include 'COMMON.CHAIN'
1331 include 'COMMON.DERIV'
1332 include 'COMMON.GEO'
1333 include 'COMMON.LOCAL'
1334 include 'COMMON.INTERACT'
1335 include 'COMMON.IOUNITS'
1336 double precision aux(3),accel(3),accel_old(3),dacc
1338 c aux(j)=d_a(j,0)-d_a_old(j,0)
1339 accel_old(j)=d_a_old(j,0)
1346 c 7/3/08 changed to asymmetric difference
1348 c accel(j)=aux(j)+0.5d0*(d_a(j,i)-d_a_old(j,i))
1349 accel_old(j)=accel_old(j)+0.5d0*d_a_old(j,i)
1350 accel(j)=accel(j)+0.5d0*d_a(j,i)
1351 c if (dabs(accel(j)).gt.amax) amax=dabs(accel(j))
1352 if (dabs(accel(j)).gt.dabs(accel_old(j))) then
1353 dacc=dabs(accel(j)-accel_old(j))
1354 c write (iout,*) i,dacc
1355 if (dacc.gt.amax) amax=dacc
1363 accel_old(j)=d_a_old(j,0)
1368 accel_old(j)=accel_old(j)+d_a_old(j,1)
1369 accel(j)=accel(j)+d_a(j,1)
1373 if (itype(i).ne.10 .and. itype(i).ne.ntyp1) then
1375 c accel(j)=accel(j)+d_a(j,i+nres)-d_a_old(j,i+nres)
1376 accel_old(j)=accel_old(j)+d_a_old(j,i+nres)
1377 accel(j)=accel(j)+d_a(j,i+nres)
1381 c if (dabs(accel(j)).gt.amax) amax=dabs(accel(j))
1382 if (dabs(accel(j)).gt.dabs(accel_old(j))) then
1383 dacc=dabs(accel(j)-accel_old(j))
1384 c write (iout,*) "side-chain",i,dacc
1385 if (dacc.gt.amax) amax=dacc
1389 accel_old(j)=accel_old(j)+d_a_old(j,i)
1390 accel(j)=accel(j)+d_a(j,i)
1391 c aux(j)=aux(j)+d_a(j,i)-d_a_old(j,i)
1396 c---------------------------------------------------------------------
1397 subroutine predict_edrift(epdrift)
1399 c Predict the drift of the potential energy
1401 implicit real*8 (a-h,o-z)
1402 include 'DIMENSIONS'
1403 include 'COMMON.CONTROL'
1404 include 'COMMON.VAR'
1406 include 'COMMON.LAGRANGE'
1407 include 'COMMON.CHAIN'
1408 include 'COMMON.DERIV'
1409 include 'COMMON.GEO'
1410 include 'COMMON.LOCAL'
1411 include 'COMMON.INTERACT'
1412 include 'COMMON.IOUNITS'
1413 include 'COMMON.MUCA'
1414 double precision epdrift,epdriftij
1415 c Drift of the potential energy
1421 epdriftij=dabs((d_a(j,i)-d_a_old(j,i))*gcart(j,i))
1422 if (lmuca) epdriftij=epdriftij*factor
1423 c write (iout,*) "back",i,j,epdriftij
1424 if (epdriftij.gt.epdrift) epdrift=epdriftij
1428 if (itype(i).ne.10 .and. itype(i).ne.ntyp1) then
1431 & dabs((d_a(j,i+nres)-d_a_old(j,i+nres))*gxcart(j,i))
1432 if (lmuca) epdriftij=epdriftij*factor
1433 c write (iout,*) "side",i,j,epdriftij
1434 if (epdriftij.gt.epdrift) epdrift=epdriftij
1438 epdrift=0.5d0*epdrift*d_time*d_time
1439 c write (iout,*) "epdrift",epdrift
1442 c-----------------------------------------------------------------------
1443 subroutine verlet_bath
1445 c Coupling to the thermostat by using the Berendsen algorithm
1447 implicit real*8 (a-h,o-z)
1448 include 'DIMENSIONS'
1449 include 'COMMON.CONTROL'
1450 include 'COMMON.VAR'
1452 include 'COMMON.LAGRANGE'
1453 include 'COMMON.CHAIN'
1454 include 'COMMON.DERIV'
1455 include 'COMMON.GEO'
1456 include 'COMMON.LOCAL'
1457 include 'COMMON.INTERACT'
1458 include 'COMMON.IOUNITS'
1459 include 'COMMON.NAMES'
1460 double precision T_half,fact
1462 T_half=2.0d0/(dimen3*Rb)*EK
1463 fact=dsqrt(1.0d0+(d_time/tau_bath)*(t_bath/T_half-1.0d0))
1464 c write(iout,*) "T_half", T_half
1465 c write(iout,*) "EK", EK
1466 c write(iout,*) "fact", fact
1468 d_t(j,0)=fact*d_t(j,0)
1472 d_t(j,i)=fact*d_t(j,i)
1476 if (itype(i).ne.10 .and. itype(i).ne.ntyp1) then
1479 d_t(j,inres)=fact*d_t(j,inres)
1485 c---------------------------------------------------------
1487 c Set up the initial conditions of a MD simulation
1488 implicit real*8 (a-h,o-z)
1489 include 'DIMENSIONS'
1493 integer IERROR,ERRCODE
1495 include 'COMMON.SETUP'
1496 include 'COMMON.CONTROL'
1497 include 'COMMON.VAR'
1499 include 'COMMON.QRESTR'
1500 include 'COMMON.LAGRANGE'
1502 include 'COMMON.LANGEVIN'
1504 include 'COMMON.LANGEVIN.lang0'
1506 include 'COMMON.CHAIN'
1507 include 'COMMON.DERIV'
1508 include 'COMMON.GEO'
1509 include 'COMMON.LOCAL'
1510 include 'COMMON.INTERACT'
1511 include 'COMMON.IOUNITS'
1512 include 'COMMON.NAMES'
1513 include 'COMMON.REMD'
1514 real*8 energia_long(0:n_ene),
1515 & energia_short(0:n_ene),vcm(3),incr(3)
1516 double precision cm(3),L(3),xv,sigv,lowb,highb
1517 double precision varia(maxvar),energia(0:n_ene)
1524 write (iout,*) "init_MD INDPDB",indpdb
1526 c write(iout,*) "d_time", d_time
1527 c Compute the standard deviations of stochastic forces for Langevin dynamics
1528 c if the friction coefficients do not depend on surface area
1529 if (lang.gt.0 .and. .not.surfarea) then
1531 stdforcp(i)=stdfp*dsqrt(gamp)
1534 if (itype(i).ne.ntyp1) stdforcsc(i)=stdfsc(iabs(itype(i)))
1535 & *dsqrt(gamsc(iabs(itype(i))))
1538 c Open the pdb file for snapshotshots
1541 if (ilen(tmpdir).gt.0)
1542 & call copy_to_tmp(pref_orig(:ilen(pref_orig))//"_MD"//
1543 & liczba(:ilen(liczba))//".pdb")
1545 & file=prefix(:ilen(prefix))//"_MD"//liczba(:ilen(liczba))
1549 if (ilen(tmpdir).gt.0 .and. (me.eq.king .or. .not.traj1file))
1550 & call copy_to_tmp(pref_orig(:ilen(pref_orig))//"_MD"//
1551 & liczba(:ilen(liczba))//".x")
1552 cartname=prefix(:ilen(prefix))//"_MD"//liczba(:ilen(liczba))
1555 if (ilen(tmpdir).gt.0 .and. (me.eq.king .or. .not.traj1file))
1556 & call copy_to_tmp(pref_orig(:ilen(pref_orig))//"_MD"//
1557 & liczba(:ilen(liczba))//".cx")
1558 cartname=prefix(:ilen(prefix))//"_MD"//liczba(:ilen(liczba))
1564 if (ilen(tmpdir).gt.0)
1565 & call copy_to_tmp(pref_orig(:ilen(pref_orig))//"_MD.pdb")
1566 open(ipdb,file=prefix(:ilen(prefix))//"_MD.pdb")
1568 if (ilen(tmpdir).gt.0)
1569 & call copy_to_tmp(pref_orig(:ilen(pref_orig))//"_MD.cx")
1570 cartname=prefix(:ilen(prefix))//"_MD.cx"
1574 write (qstr,'(256(1h ))')
1577 iq = qinfrag(i,iset)*10
1578 iw = wfrag(i,iset)/100
1580 if(me.eq.king.or..not.out1file)
1581 & write (iout,*) "Frag",qinfrag(i,iset),wfrag(i,iset),iq,iw
1582 write (qstr(ipos:ipos+6),'(2h_f,i1,1h_,i1,1h_,i1)') i,iq,iw
1587 iq = qinpair(i,iset)*10
1588 iw = wpair(i,iset)/100
1590 if(me.eq.king.or..not.out1file)
1591 & write (iout,*) "Pair",i,qinpair(i,iset),wpair(i,iset),iq,iw
1592 write (qstr(ipos:ipos+6),'(2h_p,i1,1h_,i1,1h_,i1)') i,iq,iw
1596 c pdbname=pdbname(:ilen(pdbname)-4)//qstr(:ipos-1)//'.pdb'
1598 c cartname=cartname(:ilen(cartname)-2)//qstr(:ipos-1)//'.x'
1600 c cartname=cartname(:ilen(cartname)-3)//qstr(:ipos-1)//'.cx'
1602 c statname=statname(:ilen(statname)-5)//qstr(:ipos-1)//'.stat'
1605 write (iout,*) "REST ",rest
1607 if (restart1file) then
1609 & inquire(file=mremd_rst_name,exist=file_exist)
1611 write (*,*) me," Before broadcast: file_exist",file_exist
1612 call MPI_Bcast(file_exist,1,MPI_LOGICAL,king,CG_COMM,
1614 write (*,*) me," After broadcast: file_exist",file_exist
1615 c inquire(file=mremd_rst_name,exist=file_exist)
1617 if(me.eq.king.or..not.out1file)
1618 & write(iout,*) "Initial state read by master and distributed"
1620 if (ilen(tmpdir).gt.0)
1621 & call copy_to_tmp(pref_orig(:ilen(pref_orig))//'_'
1622 & //liczba(:ilen(liczba))//'.rst')
1623 inquire(file=rest2name,exist=file_exist)
1626 if(.not.restart1file) then
1627 if(me.eq.king.or..not.out1file)
1628 & write(iout,*) "Initial state will be read from file ",
1629 & rest2name(:ilen(rest2name))
1632 call rescale_weights(t_bath)
1635 if(me.eq.king.or..not.out1file)then
1636 if (restart1file) then
1637 write(iout,*) "File ",mremd_rst_name(:ilen(mremd_rst_name)),
1640 write(iout,*) "File ",rest2name(:ilen(rest2name)),
1643 write(iout,*) "Initial velocities randomly generated"
1650 c Generate initial velocities
1651 if(me.eq.king.or..not.out1file)
1652 & write(iout,*) "Initial velocities randomly generated"
1655 CtotTafm is the variable for AFM time which eclipsed during
1658 c rest2name = prefix(:ilen(prefix))//'.rst'
1659 if(me.eq.king.or..not.out1file)then
1660 write (iout,*) "Initial velocities"
1662 write (iout,'(i3,3f10.5,3x,3f10.5)') i,(d_t(j,i),j=1,3),
1663 & (d_t(j,i+nres),j=1,3)
1665 c Zeroing the total angular momentum of the system
1666 write(iout,*) "Calling the zero-angular
1667 & momentum subroutine"
1670 c Getting the potential energy and forces and velocities and accelerations
1672 write (iout,*) "velocity of the center of the mass:"
1673 write (iout,*) (vcm(j),j=1,3)
1676 d_t(j,0)=d_t(j,0)-vcm(j)
1678 c Removing the velocity of the center of mass
1680 if(me.eq.king.or..not.out1file)then
1681 write (iout,*) "vcm right after adjustment:"
1682 write (iout,*) (vcm(j),j=1,3)
1685 write (iout,*) "init_MD before initial structure REST ",rest
1687 if (iranconf.ne.0) then
1688 c 8/22/17 AL Loop to produce a low-energy random conformation
1692 print *, 'Calling OVERLAP_SC'
1693 call overlap_sc(fail)
1697 call sc_move(2,nres-1,10,1d10,nft_sc,etot)
1698 print *,'SC_move',nft_sc,etot
1699 if(me.eq.king.or..not.out1file)
1700 & write(iout,*) 'SC_move',nft_sc,etot
1704 if (me.eq.king.or..not.out1file) write(iout,*)
1705 & 'Minimizing random structure: Calling MINIM_DC'
1706 call minim_dc(etot,iretcode,nfun)
1708 call geom_to_var(nvar,varia)
1709 if (me.eq.king.or..not.out1file) write (iout,*)
1710 & 'Minimizing random structure: Calling MINIMIZE.'
1711 call minimize(etot,varia,iretcode,nfun)
1712 call var_to_geom(nvar,varia)
1714 if (me.eq.king.or..not.out1file)
1715 & write(iout,*) 'SUMSL return code is',iretcode,' eval ',nfun
1716 if (isnan(etot) .or. etot.gt.1.0d4) then
1717 write (iout,*) "Energy too large",etot,
1718 & " trying another random conformation"
1721 call gen_rand_conf(itmp,*30)
1723 30 write (iout,*) 'Failed to generate random conformation',
1724 & ', itrial=',itrial
1725 write (*,*) 'Processor:',me,
1726 & ' Failed to generate random conformation',
1736 write (iout,'(a,i3,a)') 'Processor:',me,
1737 & ' error in generating random conformation.'
1738 write (*,'(a,i3,a)') 'Processor:',me,
1739 & ' error in generating random conformation.'
1742 call MPI_Abort(mpi_comm_world,error_msg,ierrcode)
1751 write (iout,'(a,i3,a)') 'Processor:',me,
1752 & ' failed to generate a low-energy random conformation.'
1753 write (*,'(a,i3,a)') 'Processor:',me,
1754 & ' failed to generate a low-energy random conformation.'
1757 call MPI_Abort(mpi_comm_world,error_msg,ierrcode)
1762 else if (preminim) then
1763 if (start_from_model) then
1764 i_model=iran_num(1,constr_homology)
1765 write (iout,*) 'starting from model ',i_model
1768 c(j,i)=chomo(j,i,i_model)
1771 call int_from_cart(.true.,.false.)
1772 call sc_loc_geom(.false.)
1775 dc(j,i)=c(j,i+1)-c(j,i)
1776 dc_norm(j,i)=dc(j,i)*vbld_inv(i+1)
1781 dc(j,i+nres)=c(j,i+nres)-c(j,i)
1782 dc_norm(j,i+nres)=dc(j,i+nres)*vbld_inv(i+nres)
1786 ! Remove SC overlaps if requested
1788 write (iout,*) 'Calling OVERLAP_SC'
1789 call overlap_sc(fail)
1791 ! Search for better SC rotamers if requested
1793 call sc_move(2,nres-1,10,1d10,nft_sc,etot)
1794 print *,'SC_move',nft_sc,etot
1795 if (me.eq.king.or..not.out1file)
1796 & write(iout,*) 'SC_move',nft_sc,etot
1798 call etotal(energia(0))
1799 C 8/22/17 AL Minimize initial structure
1801 if (me.eq.king.or..not.out1file) write(iout,*)
1802 & 'Minimizing initial PDB structure: Calling MINIM_DC'
1803 call minim_dc(etot,iretcode,nfun)
1805 call geom_to_var(nvar,varia)
1806 if(me.eq.king.or..not.out1file) write (iout,*)
1807 & 'Minimizing initial PDB structure: Calling MINIMIZE.'
1808 call minimize(etot,varia,iretcode,nfun)
1809 call var_to_geom(nvar,varia)
1811 if (me.eq.king.or..not.out1file)
1812 & write(iout,*) 'SUMSL return code is',iretcode,' eval ',nfun
1813 if(me.eq.king.or..not.out1file)
1814 & write(iout,*) 'SUMSL return code is',iretcode,' eval ',nfun
1817 call chainbuild_cart
1822 kinetic_T=2.0d0/(dimen3*Rb)*EK
1823 if(me.eq.king.or..not.out1file)then
1833 call etotal(potEcomp)
1834 if (large) call enerprint(potEcomp)
1837 t_etotal=t_etotal+MPI_Wtime()-tt0
1839 t_etotal=t_etotal+tcpu()-tt0
1846 if (amax*d_time .gt. dvmax) then
1847 d_time=d_time*dvmax/amax
1848 if(me.eq.king.or..not.out1file) write (iout,*)
1849 & "Time step reduced to",d_time,
1850 & " because of too large initial acceleration."
1852 if(me.eq.king.or..not.out1file)then
1853 write(iout,*) "Potential energy and its components"
1854 call enerprint(potEcomp)
1855 write(iout,*) (potEcomp(i),i=0,n_ene)
1857 potE=potEcomp(0)-potEcomp(20)
1860 if (ntwe.ne.0) call statout(itime)
1861 if(me.eq.king.or..not.out1file)
1862 & write (iout,'(/a/3(a25,1pe14.5/))') "Initial:",
1863 & " Kinetic energy",EK," Potential energy",potE,
1864 & " Total energy",totE," Maximum acceleration ",
1867 write (iout,*) "Initial coordinates"
1869 write (iout,'(i3,3f10.5,3x,3f10.5)') i,(c(j,i),j=1,3),
1870 & (c(j,i+nres),j=1,3)
1872 write (iout,*) "Initial dC"
1874 write (iout,'(i3,3f10.5,3x,3f10.5)') i,(dc(j,i),j=1,3),
1875 & (dc(j,i+nres),j=1,3)
1877 write (iout,*) "Initial velocities"
1878 write (iout,"(13x,' backbone ',23x,' side chain')")
1880 write (iout,'(i3,3f10.5,3x,3f10.5)') i,(d_t(j,i),j=1,3),
1881 & (d_t(j,i+nres),j=1,3)
1883 write (iout,*) "Initial accelerations"
1885 c write (iout,'(i3,3f10.5,3x,3f10.5)') i,(d_a(j,i),j=1,3),
1886 write (iout,'(i3,3f15.10,3x,3f15.10)') i,(d_a(j,i),j=1,3),
1887 & (d_a(j,i+nres),j=1,3)
1893 d_t_old(j,i)=d_t(j,i)
1894 d_a_old(j,i)=d_a(j,i)
1896 c write (iout,*) "dc_old",i,(dc_old(j,i),j=1,3)
1905 call etotal_short(energia_short)
1906 if (large) call enerprint(potEcomp)
1909 t_eshort=t_eshort+MPI_Wtime()-tt0
1911 t_eshort=t_eshort+tcpu()-tt0
1916 if(.not.out1file .and. large) then
1917 write (iout,*) "energia_long",energia_long(0),
1918 & " energia_short",energia_short(0),
1919 & " total",energia_long(0)+energia_short(0)
1920 write (iout,*) "Initial fast-force accelerations"
1922 write (iout,'(i3,3f10.5,3x,3f10.5)') i,(d_a(j,i),j=1,3),
1923 & (d_a(j,i+nres),j=1,3)
1926 C 7/2/2009 Copy accelerations due to short-lange forces to an auxiliary array
1929 d_a_short(j,i)=d_a(j,i)
1938 call etotal_long(energia_long)
1939 if (large) call enerprint(potEcomp)
1942 t_elong=t_elong+MPI_Wtime()-tt0
1944 t_elong=t_elong+tcpu()-tt0
1949 if(.not.out1file .and. large) then
1950 write (iout,*) "energia_long",energia_long(0)
1951 write (iout,*) "Initial slow-force accelerations"
1953 write (iout,'(i3,3f10.5,3x,3f10.5)') i,(d_a(j,i),j=1,3),
1954 & (d_a(j,i+nres),j=1,3)
1958 t_enegrad=t_enegrad+MPI_Wtime()-tt0
1960 t_enegrad=t_enegrad+tcpu()-tt0
1965 c-----------------------------------------------------------
1966 subroutine random_vel
1967 implicit real*8 (a-h,o-z)
1968 include 'DIMENSIONS'
1969 include 'COMMON.CONTROL'
1970 include 'COMMON.VAR'
1972 include 'COMMON.LAGRANGE'
1974 include 'COMMON.LANGEVIN'
1976 include 'COMMON.LANGEVIN.lang0'
1978 include 'COMMON.CHAIN'
1979 include 'COMMON.DERIV'
1980 include 'COMMON.GEO'
1981 include 'COMMON.LOCAL'
1982 include 'COMMON.INTERACT'
1983 include 'COMMON.IOUNITS'
1984 include 'COMMON.NAMES'
1985 include 'COMMON.TIME1'
1986 double precision xv,sigv,lowb,highb,vec_afm(3)
1987 c Generate random velocities from Gaussian distribution of mean 0 and std of KT/m
1988 c First generate velocities in the eigenspace of the G matrix
1989 c write (iout,*) "Calling random_vel dimen dimen3",dimen,dimen3
1996 sigv=dsqrt((Rb*t_bath)/geigen(i))
1999 d_t_work_new(ii)=anorm_distr(xv,sigv,lowb,highb)
2001 c write (iout,*) "i",i," ii",ii," geigen",geigen(i),
2002 c & " d_t_work_new",d_t_work_new(ii)
2005 C if (SELFGUIDE.gt.0) then
2008 C vec_afm(j)=c(j,afmend)-c(j,afmbeg)
2009 C distance=distance+vec_afm(j)**2
2011 C distance=dsqrt(distance)
2013 C d_t_work_new(j+(afmbeg-1)*3)=-velAFMconst*vec_afm(j)/distance
2014 C d_t_work_new(j+(afmend-1)*3)=velAFMconst*vec_afm(j)/distance
2015 C write(iout,*) "myvel",d_t_work_new(j+(afmbeg-1)*3),
2016 C & d_t_work_new(j+(afmend-1)*3)
2027 c Ek1=Ek1+0.5d0*geigen(i)*d_t_work_new(ii)**2
2030 c write (iout,*) "Ek from eigenvectors",Ek1
2032 c Transform velocities to UNRES coordinate space
2038 d_t_work(ind)=d_t_work(ind)
2039 & +Gvec(i,j)*d_t_work_new((j-1)*3+k+1)
2041 c write (iout,*) "i",i," ind",ind," d_t_work",d_t_work(ind)
2045 c Transfer to the d_t vector
2047 d_t(j,0)=d_t_work(j)
2053 d_t(j,i)=d_t_work(ind)
2057 if (itype(i).ne.10 .and. itype(i).ne.ntyp1) then
2060 d_t(j,i+nres)=d_t_work(ind)
2065 c write (iout,*) "Kinetic energy",Ek,EK1," kinetic temperature",
2066 c & 2.0d0/(dimen3*Rb)*EK,2.0d0/(dimen3*Rb)*EK1
2071 c-----------------------------------------------------------
2072 subroutine sd_verlet_p_setup
2073 c Sets up the parameters of stochastic Verlet algorithm
2074 implicit real*8 (a-h,o-z)
2075 include 'DIMENSIONS'
2079 include 'COMMON.CONTROL'
2080 include 'COMMON.VAR'
2083 include 'COMMON.LANGEVIN'
2085 include 'COMMON.LANGEVIN.lang0'
2087 include 'COMMON.CHAIN'
2088 include 'COMMON.DERIV'
2089 include 'COMMON.GEO'
2090 include 'COMMON.LOCAL'
2091 include 'COMMON.INTERACT'
2092 include 'COMMON.IOUNITS'
2093 include 'COMMON.NAMES'
2094 include 'COMMON.TIME1'
2095 double precision emgdt(MAXRES6),
2096 & pterm,vterm,rho,rhoc,vsig,
2097 & pfric_vec(MAXRES6),vfric_vec(MAXRES6),
2098 & afric_vec(MAXRES6),prand_vec(MAXRES6),
2099 & vrand_vec1(MAXRES6),vrand_vec2(MAXRES6)
2100 logical lprn /.false./
2101 double precision zero /1.0d-8/, gdt_radius /0.05d0/
2102 double precision ktm
2109 c AL 8/17/04 Code adapted from tinker
2111 c Get the frictional and random terms for stochastic dynamics in the
2112 c eigenspace of mass-scaled UNRES friction matrix
2115 gdt = fricgam(i) * d_time
2117 c Stochastic dynamics reduces to simple MD for zero friction
2119 if (gdt .le. zero) then
2120 pfric_vec(i) = 1.0d0
2121 vfric_vec(i) = d_time
2122 afric_vec(i) = 0.5d0 * d_time * d_time
2123 prand_vec(i) = 0.0d0
2124 vrand_vec1(i) = 0.0d0
2125 vrand_vec2(i) = 0.0d0
2127 c Analytical expressions when friction coefficient is large
2130 if (gdt .ge. gdt_radius) then
2133 vfric_vec(i) = (1.0d0-egdt) / fricgam(i)
2134 afric_vec(i) = (d_time-vfric_vec(i)) / fricgam(i)
2135 pterm = 2.0d0*gdt - 3.0d0 + (4.0d0-egdt)*egdt
2136 vterm = 1.0d0 - egdt**2
2137 rho = (1.0d0-egdt)**2 / sqrt(pterm*vterm)
2139 c Use series expansions when friction coefficient is small
2150 afric_vec(i) = (gdt2/2.0d0 - gdt3/6.0d0 + gdt4/24.0d0
2151 & - gdt5/120.0d0 + gdt6/720.0d0
2152 & - gdt7/5040.0d0 + gdt8/40320.0d0
2153 & - gdt9/362880.0d0) / fricgam(i)**2
2154 vfric_vec(i) = d_time - fricgam(i)*afric_vec(i)
2155 pfric_vec(i) = 1.0d0 - fricgam(i)*vfric_vec(i)
2156 pterm = 2.0d0*gdt3/3.0d0 - gdt4/2.0d0
2157 & + 7.0d0*gdt5/30.0d0 - gdt6/12.0d0
2158 & + 31.0d0*gdt7/1260.0d0 - gdt8/160.0d0
2159 & + 127.0d0*gdt9/90720.0d0
2160 vterm = 2.0d0*gdt - 2.0d0*gdt2 + 4.0d0*gdt3/3.0d0
2161 & - 2.0d0*gdt4/3.0d0 + 4.0d0*gdt5/15.0d0
2162 & - 4.0d0*gdt6/45.0d0 + 8.0d0*gdt7/315.0d0
2163 & - 2.0d0*gdt8/315.0d0 + 4.0d0*gdt9/2835.0d0
2164 rho = sqrt(3.0d0) * (0.5d0 - 3.0d0*gdt/16.0d0
2165 & - 17.0d0*gdt2/1280.0d0
2166 & + 17.0d0*gdt3/6144.0d0
2167 & + 40967.0d0*gdt4/34406400.0d0
2168 & - 57203.0d0*gdt5/275251200.0d0
2169 & - 1429487.0d0*gdt6/13212057600.0d0)
2172 c Compute the scaling factors of random terms for the nonzero friction case
2174 ktm = 0.5d0*d_time/fricgam(i)
2175 psig = dsqrt(ktm*pterm) / fricgam(i)
2176 vsig = dsqrt(ktm*vterm)
2177 rhoc = dsqrt(1.0d0 - rho*rho)
2179 vrand_vec1(i) = vsig * rho
2180 vrand_vec2(i) = vsig * rhoc
2185 & "pfric_vec, vfric_vec, afric_vec, prand_vec, vrand_vec1,",
2188 write (iout,'(i5,6e15.5)') i,pfric_vec(i),vfric_vec(i),
2189 & afric_vec(i),prand_vec(i),vrand_vec1(i),vrand_vec2(i)
2193 c Transform from the eigenspace of mass-scaled friction matrix to UNRES variables
2196 call eigtransf(dimen,maxres2,mt3,mt2,pfric_vec,pfric_mat)
2197 call eigtransf(dimen,maxres2,mt3,mt2,vfric_vec,vfric_mat)
2198 call eigtransf(dimen,maxres2,mt3,mt2,afric_vec,afric_mat)
2199 call eigtransf(dimen,maxres2,mt3,mt1,prand_vec,prand_mat)
2200 call eigtransf(dimen,maxres2,mt3,mt1,vrand_vec1,vrand_mat1)
2201 call eigtransf(dimen,maxres2,mt3,mt1,vrand_vec2,vrand_mat2)
2204 t_sdsetup=t_sdsetup+MPI_Wtime()
2206 t_sdsetup=t_sdsetup+tcpu()-tt0
2210 c-------------------------------------------------------------
2211 subroutine eigtransf1(n,ndim,ab,d,c)
2214 double precision ab(ndim,ndim,n),c(ndim,n),d(ndim)
2220 c(i,j)=c(i,j)+ab(k,j,i)*d(k)
2226 c-------------------------------------------------------------
2227 subroutine eigtransf(n,ndim,a,b,d,c)
2230 double precision a(ndim,n),b(ndim,n),c(ndim,n),d(ndim)
2236 c(i,j)=c(i,j)+a(i,k)*b(k,j)*d(k)
2242 c-------------------------------------------------------------
2243 subroutine sd_verlet1
2244 c Applying stochastic velocity Verlet algorithm - step 1 to velocities
2245 implicit real*8 (a-h,o-z)
2246 include 'DIMENSIONS'
2247 include 'COMMON.CONTROL'
2248 include 'COMMON.VAR'
2250 include 'COMMON.LAGRANGE'
2252 include 'COMMON.LANGEVIN'
2254 include 'COMMON.LANGEVIN.lang0'
2256 include 'COMMON.CHAIN'
2257 include 'COMMON.DERIV'
2258 include 'COMMON.GEO'
2259 include 'COMMON.LOCAL'
2260 include 'COMMON.INTERACT'
2261 include 'COMMON.IOUNITS'
2262 include 'COMMON.NAMES'
2263 double precision stochforcvec(MAXRES6)
2264 common /stochcalc/ stochforcvec
2265 logical lprn /.false./
2267 c write (iout,*) "dc_old"
2269 c write (iout,'(i5,3f10.5,5x,3f10.5)')
2270 c & i,(dc_old(j,i),j=1,3),(dc_old(j,i+nres),j=1,3)
2273 dc_work(j)=dc_old(j,0)
2274 d_t_work(j)=d_t_old(j,0)
2275 d_a_work(j)=d_a_old(j,0)
2280 dc_work(ind+j)=dc_old(j,i)
2281 d_t_work(ind+j)=d_t_old(j,i)
2282 d_a_work(ind+j)=d_a_old(j,i)
2287 if (itype(i).ne.10 .and. itype(i).ne.ntyp1) then
2289 dc_work(ind+j)=dc_old(j,i+nres)
2290 d_t_work(ind+j)=d_t_old(j,i+nres)
2291 d_a_work(ind+j)=d_a_old(j,i+nres)
2299 & "pfric_mat, vfric_mat, afric_mat, prand_mat, vrand_mat1,",
2303 write (iout,'(2i5,6e15.5)') i,j,pfric_mat(i,j),
2304 & vfric_mat(i,j),afric_mat(i,j),
2305 & prand_mat(i,j),vrand_mat1(i,j),vrand_mat2(i,j)
2313 dc_work(i)=dc_work(i)+vfric_mat(i,j)*d_t_work(j)
2314 & +afric_mat(i,j)*d_a_work(j)+prand_mat(i,j)*stochforcvec(j)
2315 ddt1=ddt1+pfric_mat(i,j)*d_t_work(j)
2316 ddt2=ddt2+vfric_mat(i,j)*d_a_work(j)
2318 d_t_work_new(i)=ddt1+0.5d0*ddt2
2319 d_t_work(i)=ddt1+ddt2
2324 d_t(j,0)=d_t_work(j)
2329 dc(j,i)=dc_work(ind+j)
2330 d_t(j,i)=d_t_work(ind+j)
2335 if (itype(i).ne.10) then
2338 dc(j,inres)=dc_work(ind+j)
2339 d_t(j,inres)=d_t_work(ind+j)
2346 c--------------------------------------------------------------------------
2347 subroutine sd_verlet2
2348 c Calculating the adjusted velocities for accelerations
2349 implicit real*8 (a-h,o-z)
2350 include 'DIMENSIONS'
2351 include 'COMMON.CONTROL'
2352 include 'COMMON.VAR'
2354 include 'COMMON.LAGRANGE'
2356 include 'COMMON.LANGEVIN'
2358 include 'COMMON.LANGEVIN.lang0'
2360 include 'COMMON.CHAIN'
2361 include 'COMMON.DERIV'
2362 include 'COMMON.GEO'
2363 include 'COMMON.LOCAL'
2364 include 'COMMON.INTERACT'
2365 include 'COMMON.IOUNITS'
2366 include 'COMMON.NAMES'
2367 double precision stochforcvec(MAXRES6),stochforcvecV(MAXRES6)
2368 common /stochcalc/ stochforcvec
2370 c Compute the stochastic forces which contribute to velocity change
2372 call stochastic_force(stochforcvecV)
2379 ddt1=ddt1+vfric_mat(i,j)*d_a_work(j)
2380 ddt2=ddt2+vrand_mat1(i,j)*stochforcvec(j)+
2381 & vrand_mat2(i,j)*stochforcvecV(j)
2383 d_t_work(i)=d_t_work_new(i)+0.5d0*ddt1+ddt2
2387 d_t(j,0)=d_t_work(j)
2392 d_t(j,i)=d_t_work(ind+j)
2397 if (itype(i).ne.10 .and. itype(i).ne.ntyp1) then
2400 d_t(j,inres)=d_t_work(ind+j)
2407 c-----------------------------------------------------------
2408 subroutine sd_verlet_ciccotti_setup
2409 c Sets up the parameters of stochastic velocity Verlet algorithmi; Ciccotti's
2411 implicit real*8 (a-h,o-z)
2412 include 'DIMENSIONS'
2416 include 'COMMON.CONTROL'
2417 include 'COMMON.VAR'
2419 include 'COMMON.LAGRANGE'
2421 include 'COMMON.LANGEVIN'
2423 include 'COMMON.LANGEVIN.lang0'
2425 include 'COMMON.CHAIN'
2426 include 'COMMON.DERIV'
2427 include 'COMMON.GEO'
2428 include 'COMMON.LOCAL'
2429 include 'COMMON.INTERACT'
2430 include 'COMMON.IOUNITS'
2431 include 'COMMON.NAMES'
2432 include 'COMMON.TIME1'
2433 double precision emgdt(MAXRES6),
2434 & pterm,vterm,rho,rhoc,vsig,
2435 & pfric_vec(MAXRES6),vfric_vec(MAXRES6),
2436 & afric_vec(MAXRES6),prand_vec(MAXRES6),
2437 & vrand_vec1(MAXRES6),vrand_vec2(MAXRES6)
2438 logical lprn /.false./
2439 double precision zero /1.0d-8/, gdt_radius /0.05d0/
2440 double precision ktm
2447 c AL 8/17/04 Code adapted from tinker
2449 c Get the frictional and random terms for stochastic dynamics in the
2450 c eigenspace of mass-scaled UNRES friction matrix
2453 write (iout,*) "i",i," fricgam",fricgam(i)
2454 gdt = fricgam(i) * d_time
2456 c Stochastic dynamics reduces to simple MD for zero friction
2458 if (gdt .le. zero) then
2459 pfric_vec(i) = 1.0d0
2460 vfric_vec(i) = d_time
2461 afric_vec(i) = 0.5d0*d_time*d_time
2462 prand_vec(i) = afric_vec(i)
2463 vrand_vec2(i) = vfric_vec(i)
2465 c Analytical expressions when friction coefficient is large
2470 vfric_vec(i) = dexp(-0.5d0*gdt)*d_time
2471 afric_vec(i) = 0.5d0*dexp(-0.25d0*gdt)*d_time*d_time
2472 prand_vec(i) = afric_vec(i)
2473 vrand_vec2(i) = vfric_vec(i)
2475 c Compute the scaling factors of random terms for the nonzero friction case
2477 c ktm = 0.5d0*d_time/fricgam(i)
2478 c psig = dsqrt(ktm*pterm) / fricgam(i)
2479 c vsig = dsqrt(ktm*vterm)
2480 c prand_vec(i) = psig*afric_vec(i)
2481 c vrand_vec2(i) = vsig*vfric_vec(i)
2486 & "pfric_vec, vfric_vec, afric_vec, prand_vec, vrand_vec1,",
2489 write (iout,'(i5,6e15.5)') i,pfric_vec(i),vfric_vec(i),
2490 & afric_vec(i),prand_vec(i),vrand_vec1(i),vrand_vec2(i)
2494 c Transform from the eigenspace of mass-scaled friction matrix to UNRES variables
2496 call eigtransf(dimen,maxres2,mt3,mt2,pfric_vec,pfric_mat)
2497 call eigtransf(dimen,maxres2,mt3,mt2,vfric_vec,vfric_mat)
2498 call eigtransf(dimen,maxres2,mt3,mt2,afric_vec,afric_mat)
2499 call eigtransf(dimen,maxres2,mt3,mt1,prand_vec,prand_mat)
2500 call eigtransf(dimen,maxres2,mt3,mt1,vrand_vec2,vrand_mat2)
2502 t_sdsetup=t_sdsetup+MPI_Wtime()
2504 t_sdsetup=t_sdsetup+tcpu()-tt0
2508 c-------------------------------------------------------------
2509 subroutine sd_verlet1_ciccotti
2510 c Applying stochastic velocity Verlet algorithm - step 1 to velocities
2511 implicit real*8 (a-h,o-z)
2512 include 'DIMENSIONS'
2516 include 'COMMON.CONTROL'
2517 include 'COMMON.VAR'
2519 include 'COMMON.LAGRANGE'
2521 include 'COMMON.LANGEVIN'
2523 include 'COMMON.LANGEVIN.lang0'
2525 include 'COMMON.CHAIN'
2526 include 'COMMON.DERIV'
2527 include 'COMMON.GEO'
2528 include 'COMMON.LOCAL'
2529 include 'COMMON.INTERACT'
2530 include 'COMMON.IOUNITS'
2531 include 'COMMON.NAMES'
2532 double precision stochforcvec(MAXRES6)
2533 common /stochcalc/ stochforcvec
2534 logical lprn /.false./
2536 c write (iout,*) "dc_old"
2538 c write (iout,'(i5,3f10.5,5x,3f10.5)')
2539 c & i,(dc_old(j,i),j=1,3),(dc_old(j,i+nres),j=1,3)
2542 dc_work(j)=dc_old(j,0)
2543 d_t_work(j)=d_t_old(j,0)
2544 d_a_work(j)=d_a_old(j,0)
2549 dc_work(ind+j)=dc_old(j,i)
2550 d_t_work(ind+j)=d_t_old(j,i)
2551 d_a_work(ind+j)=d_a_old(j,i)
2556 if (itype(i).ne.10 .and. itype(i).ne.ntyp1) then
2558 dc_work(ind+j)=dc_old(j,i+nres)
2559 d_t_work(ind+j)=d_t_old(j,i+nres)
2560 d_a_work(ind+j)=d_a_old(j,i+nres)
2569 & "pfric_mat, vfric_mat, afric_mat, prand_mat, vrand_mat1,",
2573 write (iout,'(2i5,6e15.5)') i,j,pfric_mat(i,j),
2574 & vfric_mat(i,j),afric_mat(i,j),
2575 & prand_mat(i,j),vrand_mat1(i,j),vrand_mat2(i,j)
2583 dc_work(i)=dc_work(i)+vfric_mat(i,j)*d_t_work(j)
2584 & +afric_mat(i,j)*d_a_work(j)+prand_mat(i,j)*stochforcvec(j)
2585 ddt1=ddt1+pfric_mat(i,j)*d_t_work(j)
2586 ddt2=ddt2+vfric_mat(i,j)*d_a_work(j)
2588 d_t_work_new(i)=ddt1+0.5d0*ddt2
2589 d_t_work(i)=ddt1+ddt2
2594 d_t(j,0)=d_t_work(j)
2599 dc(j,i)=dc_work(ind+j)
2600 d_t(j,i)=d_t_work(ind+j)
2605 if (itype(i).ne.10 .and. itype(i).ne.ntyp1) then
2608 dc(j,inres)=dc_work(ind+j)
2609 d_t(j,inres)=d_t_work(ind+j)
2616 c--------------------------------------------------------------------------
2617 subroutine sd_verlet2_ciccotti
2618 c Calculating the adjusted velocities for accelerations
2619 implicit real*8 (a-h,o-z)
2620 include 'DIMENSIONS'
2621 include 'COMMON.CONTROL'
2622 include 'COMMON.VAR'
2624 iclude 'COMMON.LAGRANGE'
2626 include 'COMMON.LANGEVIN'
2628 include 'COMMON.LANGEVIN.lang0'
2630 include 'COMMON.CHAIN'
2631 include 'COMMON.DERIV'
2632 include 'COMMON.GEO'
2633 include 'COMMON.LOCAL'
2634 include 'COMMON.INTERACT'
2635 include 'COMMON.IOUNITS'
2636 include 'COMMON.NAMES'
2637 double precision stochforcvec(MAXRES6),stochforcvecV(MAXRES6)
2638 common /stochcalc/ stochforcvec
2640 c Compute the stochastic forces which contribute to velocity change
2642 call stochastic_force(stochforcvecV)
2649 ddt1=ddt1+vfric_mat(i,j)*d_a_work(j)
2650 c ddt2=ddt2+vrand_mat2(i,j)*stochforcvecV(j)
2651 ddt2=ddt2+vrand_mat2(i,j)*stochforcvec(j)
2653 d_t_work(i)=d_t_work_new(i)+0.5d0*ddt1+ddt2
2657 d_t(j,0)=d_t_work(j)
2662 d_t(j,i)=d_t_work(ind+j)
2667 if (itype(i).ne.10 .and. itype(i).ne.ntyp1) then
2670 d_t(j,inres)=d_t_work(ind+j)