1 subroutine etotal(energia)
2 implicit real*8 (a-h,o-z)
7 cMS$ATTRIBUTES C :: proc_proc
12 double precision weights_(n_ene)
14 include 'COMMON.SETUP'
15 include 'COMMON.IOUNITS'
16 double precision energia(0:n_ene)
17 include 'COMMON.LOCAL'
18 include 'COMMON.FFIELD'
19 include 'COMMON.DERIV'
20 include 'COMMON.INTERACT'
21 include 'COMMON.SBRIDGE'
22 include 'COMMON.CHAIN'
25 include 'COMMON.CONTROL'
26 include 'COMMON.TIME1'
27 include 'COMMON.SPLITELE'
29 c print*,"ETOTAL Processor",fg_rank," absolute rank",myrank,
30 c & " nfgtasks",nfgtasks
31 if (nfgtasks.gt.1) then
33 C FG slaves call the following matching MPI_Bcast in ERGASTULUM
34 if (fg_rank.eq.0) then
35 call MPI_Bcast(0,1,MPI_INTEGER,king,FG_COMM,IERROR)
36 c print *,"Processor",myrank," BROADCAST iorder"
37 C FG master sets up the WEIGHTS_ array which will be broadcast to the
38 C FG slaves as WEIGHTS array.
58 C FG Master broadcasts the WEIGHTS_ array
59 call MPI_Bcast(weights_(1),n_ene,
60 & MPI_DOUBLE_PRECISION,king,FG_COMM,IERROR)
62 C FG slaves receive the WEIGHTS array
63 call MPI_Bcast(weights(1),n_ene,
64 & MPI_DOUBLE_PRECISION,king,FG_COMM,IERROR)
85 time_Bcast=time_Bcast+MPI_Wtime()-time00
86 time_Bcastw=time_Bcastw+MPI_Wtime()-time00
87 c call chainbuild_cart
89 c print *,'Processor',myrank,' calling etotal ipot=',ipot
90 c print *,'Processor',myrank,' nnt=',nnt,' nct=',nct
92 c if (modecalc.eq.12.or.modecalc.eq.14) then
93 c call int_from_cart1(.false.)
100 C Compute the side-chain and electrostatic interaction energy
103 goto (101,102,103,104,105,106) ipot
104 C Lennard-Jones potential.
106 cd print '(a)','Exit ELJ'
108 C Lennard-Jones-Kihara potential (shifted).
111 C Berne-Pechukas potential (dilated LJ, angular dependence).
114 C Gay-Berne potential (shifted LJ, angular dependence).
116 C print *,"bylem w egb"
118 C Gay-Berne-Vorobjev potential (shifted LJ, angular dependence).
121 C Soft-sphere potential
122 106 call e_softsphere(evdw)
124 C Calculate electrostatic (H-bonding) energy of the main chain.
128 cmc Sep-06: egb takes care of dynamic ss bonds too
130 c if (dyn_ss) call dyn_set_nss
132 c print *,"Processor",myrank," computed USCSC"
133 c write (iout,*) "SCSC computed OK"
140 time_vec=time_vec+MPI_Wtime()-time01
142 C Introduction of shielding effect first for each peptide group
143 C the shielding factor is set this factor is describing how each
144 C peptide group is shielded by side-chains
145 C the matrix - shield_fac(i) the i index describe the ith between i and i+1
146 C write (iout,*) "shield_mode",shield_mode
147 if (shield_mode.gt.0) then
150 c print *,"Processor",myrank," left VEC_AND_DERIV"
153 if (welec.gt.0d0.or.wvdwpp.gt.0d0.or.wel_loc.gt.0d0.or.
154 & wturn3.gt.0d0.or.wturn4.gt.0d0 .or. wcorr.gt.0.0d0
155 & .or. wcorr4.gt.0.0d0 .or. wcorr5.gt.0.d0
156 & .or. wcorr6.gt.0.0d0 .or. wturn6.gt.0.0d0 ) then
158 if (welec.gt.0d0.or.wel_loc.gt.0d0.or.
159 & wturn3.gt.0d0.or.wturn4.gt.0d0 .or. wcorr.gt.0.0d0
160 & .or. wcorr4.gt.0.0d0 .or. wcorr5.gt.0.d0
161 & .or. wcorr6.gt.0.0d0 .or. wturn6.gt.0.0d0 ) then
163 call eelec(ees,evdw1,eel_loc,eello_turn3,eello_turn4)
172 write (iout,*) "Soft-spheer ELEC potential"
173 c call eelec_soft_sphere(ees,evdw1,eel_loc,eello_turn3,
176 c write (iout,*) "eelec computed OK"
178 c print *,"Processor",myrank," computed UELEC"
180 C Calculate excluded-volume interaction energy between peptide groups
185 call escp(evdw2,evdw2_14)
191 c write (iout,*) "Soft-sphere SCP potential"
192 call escp_soft_sphere(evdw2,evdw2_14)
194 c write (iout,*) "escp computed OK"
197 c Calculate the bond-stretching energy
200 c write (iout,*) "ebond computed OK"
203 C Calculate the disulfide-bridge and other energy and the contributions
204 C from other distance constraints.
205 cd print *,'Calling EHPB'
207 cd print *,'EHPB exitted succesfully.'
209 C Calculate the virtual-bond-angle energy.
211 if (wang.gt.0d0) then
212 call ebend(ebe,ethetacnstr)
217 c write (iout,*) "ebend computed OK"
219 c print *,"Processor",myrank," computed UB"
221 C Calculate the SC local energy.
223 C print *,"TU DOCHODZE?"
225 c write (iout,*) "esc computed OK"
227 c print *,"Processor",myrank," computed USC"
229 C Calculate the virtual-bond torsional energy.
231 cd print *,'nterm=',nterm
233 call etor(etors,edihcnstr)
238 c write (iout,*) "etor computed OK"
240 c print *,"Processor",myrank," computed Utor"
242 C 6/23/01 Calculate double-torsional energy
244 if (wtor_d.gt.0) then
249 c write (iout,*) "etor_d computed OK"
251 c print *,"Processor",myrank," computed Utord"
253 C 21/5/07 Calculate local sicdechain correlation energy
255 if (wsccor.gt.0.0d0) then
256 call eback_sc_corr(esccor)
260 c write (iout,*) "eback_sc_corr computed OK"
262 C print *,"PRZED MULIt"
263 c print *,"Processor",myrank," computed Usccorr"
265 C 12/1/95 Multi-body terms
269 if ((wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 .or. wcorr6.gt.0.0d0
270 & .or. wturn6.gt.0.0d0) .and. ipot.lt.6) then
271 c write (iout,*) "Calling multibody_eello"
273 call multibody_eello(ecorr,ecorr5,ecorr6,eturn6,n_corr,n_corr1)
275 c & 'multibody_eello n_corr=',n_corr,' n_corr1=',n_corr1,
276 c & " ecorr",ecorr," ecorr5",ecorr5," ecorr6",ecorr6," eturn6",eturn6
284 if ((wcorr4.eq.0.0d0 .and. wcorr.gt.0.0d0) .and. ipot.lt.6) then
285 c write (iout,*) "Calling multibody_gb_ecorr"
287 call multibody_hb(ecorr,ecorr5,ecorr6,n_corr,n_corr1)
288 c write (iout,*) "Exited multibody_hb ecorr",ecorr
291 c write (iout,*) "multibody computed OK"
293 c print *,"Processor",myrank," computed Ucorr"
295 C If performing constraint dynamics, call the constraint energy
296 C after the equilibration time
297 if(usampl.and.totT.gt.eq_time) then
304 C 01/27/2015 added by adasko
305 C the energy component below is energy transfer into lipid environment
306 C based on partition function
307 C print *,"przed lipidami"
308 if (wliptran.gt.0) then
309 call Eliptransfer(eliptran)
311 c write (iout,*) "lipid energy computed OK"
313 if (AFMlog.gt.0) then
314 call AFMforce(Eafmforce)
315 else if (selfguide.gt.0) then
316 call AFMvel(Eafmforce)
318 c write (iout,*) "AFMforce computed OK"
321 time_enecalc=time_enecalc+MPI_Wtime()-time00
323 c print *,"Processor",myrank," computed Uconstr"
332 energia(2)=evdw2-evdw2_14
349 energia(8)=eello_turn3
350 energia(9)=eello_turn4
357 energia(19)=edihcnstr
359 energia(20)=Uconst+Uconst_back
362 energia(23)=Eafmforce
363 energia(24)=ethetacnstr
364 c Here are the energies showed per procesor if the are more processors
365 c per molecule then we sum it up in sum_energy subroutine
366 c print *," Processor",myrank," calls SUM_ENERGY"
367 call sum_energy(energia,.true.)
368 c write (iout,*) "sum energy OK"
370 if (dyn_ss) call dyn_set_nss
371 c write (iout,*) "Exiting energy"
373 c print *," Processor",myrank," left SUM_ENERGY"
375 time_sumene=time_sumene+MPI_Wtime()-time00
379 c-------------------------------------------------------------------------------
380 subroutine sum_energy(energia,reduce)
381 implicit real*8 (a-h,o-z)
386 cMS$ATTRIBUTES C :: proc_proc
392 include 'COMMON.SETUP'
393 include 'COMMON.IOUNITS'
394 double precision energia(0:n_ene),enebuff(0:n_ene+1)
395 include 'COMMON.FFIELD'
396 include 'COMMON.DERIV'
397 include 'COMMON.INTERACT'
398 include 'COMMON.SBRIDGE'
399 include 'COMMON.CHAIN'
401 include 'COMMON.CONTROL'
402 include 'COMMON.TIME1'
405 if (nfgtasks.gt.1 .and. reduce) then
407 write (iout,*) "energies before REDUCE"
408 call enerprint(energia)
412 enebuff(i)=energia(i)
415 call MPI_Barrier(FG_COMM,IERR)
416 time_barrier_e=time_barrier_e+MPI_Wtime()-time00
418 call MPI_Reduce(enebuff(0),energia(0),n_ene+1,
419 & MPI_DOUBLE_PRECISION,MPI_SUM,king,FG_COMM,IERR)
421 write (iout,*) "energies after REDUCE"
422 call enerprint(energia)
425 time_Reduce=time_Reduce+MPI_Wtime()-time00
427 if (fg_rank.eq.0) then
431 evdw2=energia(2)+energia(18)
447 eello_turn3=energia(8)
448 eello_turn4=energia(9)
455 edihcnstr=energia(19)
460 Eafmforce=energia(23)
461 ethetacnstr=energia(24)
463 etot=wsc*evdw+wscp*evdw2+welec*ees+wvdwpp*evdw1
464 & +wang*ebe+wtor*etors+wscloc*escloc
465 & +wstrain*ehpb+wcorr*ecorr+wcorr5*ecorr5
466 & +wcorr6*ecorr6+wturn4*eello_turn4+wturn3*eello_turn3
467 & +wturn6*eturn6+wel_loc*eel_loc+edihcnstr+wtor_d*etors_d
468 & +wbond*estr+Uconst+wsccor*esccor+wliptran*eliptran+Eafmforce
471 etot=wsc*evdw+wscp*evdw2+welec*(ees+evdw1)
472 & +wang*ebe+wtor*etors+wscloc*escloc
473 & +wstrain*ehpb+wcorr*ecorr+wcorr5*ecorr5
474 & +wcorr6*ecorr6+wturn4*eello_turn4+wturn3*eello_turn3
475 & +wturn6*eturn6+wel_loc*eel_loc+edihcnstr+wtor_d*etors_d
476 & +wbond*estr+Uconst+wsccor*esccor+wliptran*eliptran
484 if (isnan(etot).ne.0) energia(0)=1.0d+99
486 if (isnan(etot)) energia(0)=1.0d+99
491 idumm=proc_proc(etot,i)
493 call proc_proc(etot,i)
495 if(i.eq.1)energia(0)=1.0d+99
502 c-------------------------------------------------------------------------------
503 subroutine sum_gradient
504 implicit real*8 (a-h,o-z)
509 cMS$ATTRIBUTES C :: proc_proc
515 double precision gradbufc(3,-1:maxres),gradbufx(3,-1:maxres),
516 & glocbuf(4*maxres),gradbufc_sum(3,-1:maxres)
517 & ,gloc_scbuf(3,-1:maxres)
518 include 'COMMON.SETUP'
519 include 'COMMON.IOUNITS'
520 include 'COMMON.FFIELD'
521 include 'COMMON.DERIV'
522 include 'COMMON.INTERACT'
523 include 'COMMON.SBRIDGE'
524 include 'COMMON.CHAIN'
526 include 'COMMON.CONTROL'
527 include 'COMMON.TIME1'
528 include 'COMMON.MAXGRAD'
529 include 'COMMON.SCCOR'
534 write (iout,*) "sum_gradient gvdwc, gvdwx"
536 write (iout,'(i3,3f10.5,5x,3f10.5,5x,f10.5)')
537 & i,(gvdwx(j,i),j=1,3),(gvdwc(j,i),j=1,3)
542 C FG slaves call the following matching MPI_Bcast in ERGASTULUM
543 if (nfgtasks.gt.1 .and. fg_rank.eq.0)
544 & call MPI_Bcast(1,1,MPI_INTEGER,king,FG_COMM,IERROR)
547 C 9/29/08 AL Transform parts of gradients in site coordinates to the gradient
548 C in virtual-bond-vector coordinates
551 c write (iout,*) "gel_loc gel_loc_long and gel_loc_loc"
553 c write (iout,'(i5,3f10.5,2x,3f10.5,2x,f10.5)')
554 c & i,(gel_loc(j,i),j=1,3),(gel_loc_long(j,i),j=1,3),gel_loc_loc(i)
556 c write (iout,*) "gel_loc_tur3 gel_loc_turn4"
558 c write (iout,'(i5,3f10.5,2x,f10.5)')
559 c & i,(gcorr4_turn(j,i),j=1,3),gel_loc_turn4(i)
561 write (iout,*) "gradcorr5 gradcorr5_long gradcorr5_loc"
563 write (iout,'(i3,3f10.5,5x,3f10.5,5x,f10.5)')
564 & i,(gradcorr5(j,i),j=1,3),(gradcorr5_long(j,i),j=1,3),
572 gradbufc(j,i)=wsc*gvdwc(j,i)+
573 & wscp*(gvdwc_scp(j,i)+gvdwc_scpp(j,i))+
574 & welec*gelc_long(j,i)+wvdwpp*gvdwpp(j,i)+
575 & wel_loc*gel_loc_long(j,i)+
576 & wcorr*gradcorr_long(j,i)+
577 & wcorr5*gradcorr5_long(j,i)+
578 & wcorr6*gradcorr6_long(j,i)+
579 & wturn6*gcorr6_turn_long(j,i)+
581 & +wliptran*gliptranc(j,i)
583 & +welec*gshieldc(j,i)
590 gradbufc(j,i)=wsc*gvdwc(j,i)+
591 & wscp*(gvdwc_scp(j,i)+gvdwc_scpp(j,i))+
592 & welec*gelc_long(j,i)+
594 & wel_loc*gel_loc_long(j,i)+
595 & wcorr*gradcorr_long(j,i)+
596 & wcorr5*gradcorr5_long(j,i)+
597 & wcorr6*gradcorr6_long(j,i)+
598 & wturn6*gcorr6_turn_long(j,i)+
600 & +wliptran*gliptranc(j,i)
602 & +welec*gshieldc(j,i)
608 if (nfgtasks.gt.1) then
611 write (iout,*) "gradbufc before allreduce"
613 write (iout,'(i3,3f10.5)') i,(gradbufc(j,i),j=1,3)
619 gradbufc_sum(j,i)=gradbufc(j,i)
622 c call MPI_AllReduce(gradbufc(1,1),gradbufc_sum(1,1),3*nres,
623 c & MPI_DOUBLE_PRECISION,MPI_SUM,FG_COMM,IERR)
624 c time_reduce=time_reduce+MPI_Wtime()-time00
626 c write (iout,*) "gradbufc_sum after allreduce"
628 c write (iout,'(i3,3f10.5)') i,(gradbufc_sum(j,i),j=1,3)
633 c time_allreduce=time_allreduce+MPI_Wtime()-time00
641 write (iout,*) "igrad_start",igrad_start," igrad_end",igrad_end
642 write (iout,*) (i," jgrad_start",jgrad_start(i),
643 & " jgrad_end ",jgrad_end(i),
644 & i=igrad_start,igrad_end)
647 c Obsolete and inefficient code; we can make the effort O(n) and, therefore,
648 c do not parallelize this part.
650 c do i=igrad_start,igrad_end
651 c do j=jgrad_start(i),jgrad_end(i)
653 c gradbufc(k,i)=gradbufc(k,i)+gradbufc_sum(k,j)
658 gradbufc(j,nres-1)=gradbufc_sum(j,nres)
662 gradbufc(j,i)=gradbufc(j,i+1)+gradbufc_sum(j,i+1)
666 write (iout,*) "gradbufc after summing"
668 write (iout,'(i3,3f10.5)') i,(gradbufc(j,i),j=1,3)
675 write (iout,*) "gradbufc"
677 write (iout,'(i3,3f10.5)') i,(gradbufc(j,i),j=1,3)
683 gradbufc_sum(j,i)=gradbufc(j,i)
688 gradbufc(j,nres-1)=gradbufc_sum(j,nres)
692 gradbufc(j,i)=gradbufc(j,i+1)+gradbufc_sum(j,i+1)
697 c gradbufc(k,i)=0.0d0
701 c gradbufc(k,i)=gradbufc(k,i)+gradbufc(k,j)
706 write (iout,*) "gradbufc after summing"
708 write (iout,'(i3,3f10.5)') i,(gradbufc(j,i),j=1,3)
716 gradbufc(k,nres)=0.0d0
721 C print *,gradbufc(1,13)
722 C print *,welec*gelc(1,13)
723 C print *,wel_loc*gel_loc(1,13)
724 C print *,0.5d0*(wscp*gvdwc_scpp(1,13))
725 C print *,welec*gelc_long(1,13)+wvdwpp*gvdwpp(1,13)
726 C print *,wel_loc*gel_loc_long(1,13)
727 C print *,gradafm(1,13),"AFM"
728 gradc(j,i,icg)=gradbufc(j,i)+welec*gelc(j,i)+
729 & wel_loc*gel_loc(j,i)+
730 & 0.5d0*(wscp*gvdwc_scpp(j,i)+
731 & welec*gelc_long(j,i)+wvdwpp*gvdwpp(j,i)+
732 & wel_loc*gel_loc_long(j,i)+
733 & wcorr*gradcorr_long(j,i)+
734 & wcorr5*gradcorr5_long(j,i)+
735 & wcorr6*gradcorr6_long(j,i)+
736 & wturn6*gcorr6_turn_long(j,i))+
738 & wcorr*gradcorr(j,i)+
739 & wturn3*gcorr3_turn(j,i)+
740 & wturn4*gcorr4_turn(j,i)+
741 & wcorr5*gradcorr5(j,i)+
742 & wcorr6*gradcorr6(j,i)+
743 & wturn6*gcorr6_turn(j,i)+
744 & wsccor*gsccorc(j,i)
745 & +wscloc*gscloc(j,i)
746 & +wliptran*gliptranc(j,i)
748 & +welec*gshieldc(j,i)
749 & +welec*gshieldc_loc(j,i)
753 gradc(j,i,icg)=gradbufc(j,i)+welec*gelc(j,i)+
754 & wel_loc*gel_loc(j,i)+
755 & 0.5d0*(wscp*gvdwc_scpp(j,i)+
756 & welec*gelc_long(j,i)
757 & wel_loc*gel_loc_long(j,i)+
758 & wcorr*gcorr_long(j,i)+
759 & wcorr5*gradcorr5_long(j,i)+
760 & wcorr6*gradcorr6_long(j,i)+
761 & wturn6*gcorr6_turn_long(j,i))+
763 & wcorr*gradcorr(j,i)+
764 & wturn3*gcorr3_turn(j,i)+
765 & wturn4*gcorr4_turn(j,i)+
766 & wcorr5*gradcorr5(j,i)+
767 & wcorr6*gradcorr6(j,i)+
768 & wturn6*gcorr6_turn(j,i)+
769 & wsccor*gsccorc(j,i)
770 & +wscloc*gscloc(j,i)
771 & +wliptran*gliptranc(j,i)
773 & +welec*gshieldc(j,i)
774 & +welec*gshieldc_loc(j,i)
778 gradx(j,i,icg)=wsc*gvdwx(j,i)+wscp*gradx_scp(j,i)+
780 & wstrain*ghpbx(j,i)+wcorr*gradxorr(j,i)+
781 & wsccor*gsccorx(j,i)
782 & +wscloc*gsclocx(j,i)
783 & +wliptran*gliptranx(j,i)
784 & +welec*gshieldx(j,i)
788 write (iout,*) "gloc before adding corr"
790 write (iout,*) i,gloc(i,icg)
794 gloc(i,icg)=gloc(i,icg)+wcorr*gcorr_loc(i)
795 & +wcorr5*g_corr5_loc(i)
796 & +wcorr6*g_corr6_loc(i)
797 & +wturn4*gel_loc_turn4(i)
798 & +wturn3*gel_loc_turn3(i)
799 & +wturn6*gel_loc_turn6(i)
800 & +wel_loc*gel_loc_loc(i)
803 write (iout,*) "gloc after adding corr"
805 write (iout,*) i,gloc(i,icg)
809 if (nfgtasks.gt.1) then
812 gradbufc(j,i)=gradc(j,i,icg)
813 gradbufx(j,i)=gradx(j,i,icg)
817 glocbuf(i)=gloc(i,icg)
821 write (iout,*) "gloc_sc before reduce"
824 write (iout,*) i,j,gloc_sc(j,i,icg)
831 gloc_scbuf(j,i)=gloc_sc(j,i,icg)
835 call MPI_Barrier(FG_COMM,IERR)
836 time_barrier_g=time_barrier_g+MPI_Wtime()-time00
838 call MPI_Reduce(gradbufc(1,1),gradc(1,1,icg),3*nres,
839 & MPI_DOUBLE_PRECISION,MPI_SUM,king,FG_COMM,IERR)
840 call MPI_Reduce(gradbufx(1,1),gradx(1,1,icg),3*nres,
841 & MPI_DOUBLE_PRECISION,MPI_SUM,king,FG_COMM,IERR)
842 call MPI_Reduce(glocbuf(1),gloc(1,icg),4*nres,
843 & MPI_DOUBLE_PRECISION,MPI_SUM,king,FG_COMM,IERR)
844 time_reduce=time_reduce+MPI_Wtime()-time00
845 call MPI_Reduce(gloc_scbuf(1,1),gloc_sc(1,1,icg),3*nres,
846 & MPI_DOUBLE_PRECISION,MPI_SUM,king,FG_COMM,IERR)
847 time_reduce=time_reduce+MPI_Wtime()-time00
850 write (iout,*) "gloc_sc after reduce"
853 write (iout,*) i,j,gloc_sc(j,i,icg)
859 write (iout,*) "gloc after reduce"
861 write (iout,*) i,gloc(i,icg)
866 if (gnorm_check) then
868 c Compute the maximum elements of the gradient
878 gcorr3_turn_max=0.0d0
879 gcorr4_turn_max=0.0d0
882 gcorr6_turn_max=0.0d0
892 gvdwc_norm=dsqrt(scalar(gvdwc(1,i),gvdwc(1,i)))
893 if (gvdwc_norm.gt.gvdwc_max) gvdwc_max=gvdwc_norm
894 gvdwc_scp_norm=dsqrt(scalar(gvdwc_scp(1,i),gvdwc_scp(1,i)))
895 if (gvdwc_scp_norm.gt.gvdwc_scp_max)
896 & gvdwc_scp_max=gvdwc_scp_norm
897 gelc_norm=dsqrt(scalar(gelc(1,i),gelc(1,i)))
898 if (gelc_norm.gt.gelc_max) gelc_max=gelc_norm
899 gvdwpp_norm=dsqrt(scalar(gvdwpp(1,i),gvdwpp(1,i)))
900 if (gvdwpp_norm.gt.gvdwpp_max) gvdwpp_max=gvdwpp_norm
901 gradb_norm=dsqrt(scalar(gradb(1,i),gradb(1,i)))
902 if (gradb_norm.gt.gradb_max) gradb_max=gradb_norm
903 ghpbc_norm=dsqrt(scalar(ghpbc(1,i),ghpbc(1,i)))
904 if (ghpbc_norm.gt.ghpbc_max) ghpbc_max=ghpbc_norm
905 gradcorr_norm=dsqrt(scalar(gradcorr(1,i),gradcorr(1,i)))
906 if (gradcorr_norm.gt.gradcorr_max) gradcorr_max=gradcorr_norm
907 gel_loc_norm=dsqrt(scalar(gel_loc(1,i),gel_loc(1,i)))
908 if (gel_loc_norm.gt.gel_loc_max) gel_loc_max=gel_loc_norm
909 gcorr3_turn_norm=dsqrt(scalar(gcorr3_turn(1,i),
911 if (gcorr3_turn_norm.gt.gcorr3_turn_max)
912 & gcorr3_turn_max=gcorr3_turn_norm
913 gcorr4_turn_norm=dsqrt(scalar(gcorr4_turn(1,i),
915 if (gcorr4_turn_norm.gt.gcorr4_turn_max)
916 & gcorr4_turn_max=gcorr4_turn_norm
917 gradcorr5_norm=dsqrt(scalar(gradcorr5(1,i),gradcorr5(1,i)))
918 if (gradcorr5_norm.gt.gradcorr5_max)
919 & gradcorr5_max=gradcorr5_norm
920 gradcorr6_norm=dsqrt(scalar(gradcorr6(1,i),gradcorr6(1,i)))
921 if (gradcorr6_norm.gt.gradcorr6_max) gcorr6_max=gradcorr6_norm
922 gcorr6_turn_norm=dsqrt(scalar(gcorr6_turn(1,i),
924 if (gcorr6_turn_norm.gt.gcorr6_turn_max)
925 & gcorr6_turn_max=gcorr6_turn_norm
926 gsccorr_norm=dsqrt(scalar(gsccorc(1,i),gsccorc(1,i)))
927 if (gsccorr_norm.gt.gsccorr_max) gsccorr_max=gsccorr_norm
928 gscloc_norm=dsqrt(scalar(gscloc(1,i),gscloc(1,i)))
929 if (gscloc_norm.gt.gscloc_max) gscloc_max=gscloc_norm
930 gvdwx_norm=dsqrt(scalar(gvdwx(1,i),gvdwx(1,i)))
931 if (gvdwx_norm.gt.gvdwx_max) gvdwx_max=gvdwx_norm
932 gradx_scp_norm=dsqrt(scalar(gradx_scp(1,i),gradx_scp(1,i)))
933 if (gradx_scp_norm.gt.gradx_scp_max)
934 & gradx_scp_max=gradx_scp_norm
935 ghpbx_norm=dsqrt(scalar(ghpbx(1,i),ghpbx(1,i)))
936 if (ghpbx_norm.gt.ghpbx_max) ghpbx_max=ghpbx_norm
937 gradxorr_norm=dsqrt(scalar(gradxorr(1,i),gradxorr(1,i)))
938 if (gradxorr_norm.gt.gradxorr_max) gradxorr_max=gradxorr_norm
939 gsccorrx_norm=dsqrt(scalar(gsccorx(1,i),gsccorx(1,i)))
940 if (gsccorrx_norm.gt.gsccorrx_max) gsccorrx_max=gsccorrx_norm
941 gsclocx_norm=dsqrt(scalar(gsclocx(1,i),gsclocx(1,i)))
942 if (gsclocx_norm.gt.gsclocx_max) gsclocx_max=gsclocx_norm
946 open(istat,file=statname,position="append")
948 open(istat,file=statname,access="append")
950 write (istat,'(1h#,21f10.2)') gvdwc_max,gvdwc_scp_max,
951 & gelc_max,gvdwpp_max,gradb_max,ghpbc_max,
952 & gradcorr_max,gel_loc_max,gcorr3_turn_max,gcorr4_turn_max,
953 & gradcorr5_max,gradcorr6_max,gcorr6_turn_max,gsccorc_max,
954 & gscloc_max,gvdwx_max,gradx_scp_max,ghpbx_max,gradxorr_max,
955 & gsccorx_max,gsclocx_max
957 if (gvdwc_max.gt.1.0d4) then
958 write (iout,*) "gvdwc gvdwx gradb gradbx"
960 write(iout,'(i5,4(3f10.2,5x))') i,(gvdwc(j,i),gvdwx(j,i),
961 & gradb(j,i),gradbx(j,i),j=1,3)
963 call pdbout(0.0d0,'cipiszcze',iout)
969 write (iout,*) "gradc gradx gloc"
971 write (iout,'(i5,3f10.5,5x,3f10.5,5x,f10.5)')
972 & i,(gradc(j,i,icg),j=1,3),(gradx(j,i,icg),j=1,3),gloc(i,icg)
976 time_sumgradient=time_sumgradient+MPI_Wtime()-time01
980 c-------------------------------------------------------------------------------
981 subroutine rescale_weights(t_bath)
982 implicit real*8 (a-h,o-z)
984 include 'COMMON.IOUNITS'
985 include 'COMMON.FFIELD'
986 include 'COMMON.SBRIDGE'
987 double precision kfac /2.4d0/
988 double precision x,x2,x3,x4,x5,licznik /1.12692801104297249644/
990 c facT=2*temp0/(t_bath+temp0)
991 if (rescale_mode.eq.0) then
997 else if (rescale_mode.eq.1) then
998 facT=kfac/(kfac-1.0d0+t_bath/temp0)
999 facT2=kfac**2/(kfac**2-1.0d0+(t_bath/temp0)**2)
1000 facT3=kfac**3/(kfac**3-1.0d0+(t_bath/temp0)**3)
1001 facT4=kfac**4/(kfac**4-1.0d0+(t_bath/temp0)**4)
1002 facT5=kfac**5/(kfac**5-1.0d0+(t_bath/temp0)**5)
1003 else if (rescale_mode.eq.2) then
1009 facT=licznik/dlog(dexp(x)+dexp(-x))
1010 facT2=licznik/dlog(dexp(x2)+dexp(-x2))
1011 facT3=licznik/dlog(dexp(x3)+dexp(-x3))
1012 facT4=licznik/dlog(dexp(x4)+dexp(-x4))
1013 facT5=licznik/dlog(dexp(x5)+dexp(-x5))
1015 write (iout,*) "Wrong RESCALE_MODE",rescale_mode
1016 write (*,*) "Wrong RESCALE_MODE",rescale_mode
1018 call MPI_Finalize(MPI_COMM_WORLD,IERROR)
1022 welec=weights(3)*fact
1023 wcorr=weights(4)*fact3
1024 wcorr5=weights(5)*fact4
1025 wcorr6=weights(6)*fact5
1026 wel_loc=weights(7)*fact2
1027 wturn3=weights(8)*fact2
1028 wturn4=weights(9)*fact3
1029 wturn6=weights(10)*fact5
1030 wtor=weights(13)*fact
1031 wtor_d=weights(14)*fact2
1032 wsccor=weights(21)*fact
1036 C------------------------------------------------------------------------
1037 subroutine enerprint(energia)
1038 implicit real*8 (a-h,o-z)
1039 include 'DIMENSIONS'
1040 include 'COMMON.IOUNITS'
1041 include 'COMMON.FFIELD'
1042 include 'COMMON.SBRIDGE'
1044 double precision energia(0:n_ene)
1049 evdw2=energia(2)+energia(18)
1061 eello_turn3=energia(8)
1062 eello_turn4=energia(9)
1063 eello_turn6=energia(10)
1069 edihcnstr=energia(19)
1073 eliptran=energia(22)
1074 Eafmforce=energia(23)
1075 ethetacnstr=energia(24)
1077 write (iout,10) evdw,wsc,evdw2,wscp,ees,welec,evdw1,wvdwpp,
1078 & estr,wbond,ebe,wang,
1079 & escloc,wscloc,etors,wtor,etors_d,wtor_d,ehpb,wstrain,
1081 & ecorr5,wcorr5,ecorr6,wcorr6,eel_loc,wel_loc,eello_turn3,wturn3,
1082 & eello_turn4,wturn4,eello_turn6,wturn6,esccor,wsccro,edihcnstr,
1083 & ethetacnstr,ebr*nss,Uconst,eliptran,wliptran,Eafmforc,
1085 10 format (/'Virtual-chain energies:'//
1086 & 'EVDW= ',1pE16.6,' WEIGHT=',1pD16.6,' (SC-SC)'/
1087 & 'EVDW2= ',1pE16.6,' WEIGHT=',1pD16.6,' (SC-p)'/
1088 & 'EES= ',1pE16.6,' WEIGHT=',1pD16.6,' (p-p)'/
1089 & 'EVDWPP=',1pE16.6,' WEIGHT=',1pD16.6,' (p-p VDW)'/
1090 & 'ESTR= ',1pE16.6,' WEIGHT=',1pD16.6,' (stretching)'/
1091 & 'EBE= ',1pE16.6,' WEIGHT=',1pD16.6,' (bending)'/
1092 & 'ESC= ',1pE16.6,' WEIGHT=',1pD16.6,' (SC local)'/
1093 & 'ETORS= ',1pE16.6,' WEIGHT=',1pD16.6,' (torsional)'/
1094 & 'ETORSD=',1pE16.6,' WEIGHT=',1pD16.6,' (double torsional)'/
1095 & 'EHBP= ',1pE16.6,' WEIGHT=',1pD16.6,
1096 & ' (SS bridges & dist. cnstr.)'/
1097 & 'ECORR4=',1pE16.6,' WEIGHT=',1pD16.6,' (multi-body)'/
1098 & 'ECORR5=',1pE16.6,' WEIGHT=',1pD16.6,' (multi-body)'/
1099 & 'ECORR6=',1pE16.6,' WEIGHT=',1pD16.6,' (multi-body)'/
1100 & 'EELLO= ',1pE16.6,' WEIGHT=',1pD16.6,' (electrostatic-local)'/
1101 & 'ETURN3=',1pE16.6,' WEIGHT=',1pD16.6,' (turns, 3rd order)'/
1102 & 'ETURN4=',1pE16.6,' WEIGHT=',1pD16.6,' (turns, 4th order)'/
1103 & 'ETURN6=',1pE16.6,' WEIGHT=',1pD16.6,' (turns, 6th order)'/
1104 & 'ESCCOR=',1pE16.6,' WEIGHT=',1pD16.6,' (backbone-rotamer corr)'/
1105 & 'EDIHC= ',1pE16.6,' (dihedral angle constraints)'/
1106 & 'ETHETC= ',1pE16.6,' (valence angle constraints)'/
1107 & 'ESS= ',1pE16.6,' (disulfide-bridge intrinsic energy)'/
1108 & 'UCONST= ',1pE16.6,' (Constraint energy)'/
1109 & 'ELT=',1pE16.6, ' WEIGHT=',1pD16.6,' (Lipid transfer energy)'/
1110 & 'EAFM= ',1pE16.6,' (atomic-force microscopy)'/
1111 & 'ETOT= ',1pE16.6,' (total)')
1114 write (iout,10) evdw,wsc,evdw2,wscp,ees,welec,
1115 & estr,wbond,ebe,wang,
1116 & escloc,wscloc,etors,wtor,etors_d,wtor_d,ehpb,wstrain,
1118 & ecorr5,wcorr5,ecorr6,wcorr6,eel_loc,wel_loc,eello_turn3,wturn3,
1119 & eello_turn4,wturn4,eello_turn6,wturn6,esccor,wsccro,edihcnstr,
1120 & ethetacnstr,ebr*nss,Uconst,eliptran,wliptran,Eafmforc,
1122 10 format (/'Virtual-chain energies:'//
1123 & 'EVDW= ',1pE16.6,' WEIGHT=',1pD16.6,' (SC-SC)'/
1124 & 'EVDW2= ',1pE16.6,' WEIGHT=',1pD16.6,' (SC-p)'/
1125 & 'EES= ',1pE16.6,' WEIGHT=',1pD16.6,' (p-p)'/
1126 & 'ESTR= ',1pE16.6,' WEIGHT=',1pD16.6,' (stretching)'/
1127 & 'EBE= ',1pE16.6,' WEIGHT=',1pD16.6,' (bending)'/
1128 & 'ESC= ',1pE16.6,' WEIGHT=',1pD16.6,' (SC local)'/
1129 & 'ETORS= ',1pE16.6,' WEIGHT=',1pD16.6,' (torsional)'/
1130 & 'ETORSD=',1pE16.6,' WEIGHT=',1pD16.6,' (double torsional)'/
1131 & 'EHBP= ',1pE16.6,' WEIGHT=',1pD16.6,
1132 & ' (SS bridges & dist. cnstr.)'/
1133 & 'ECORR4=',1pE16.6,' WEIGHT=',1pD16.6,' (multi-body)'/
1134 & 'ECORR5=',1pE16.6,' WEIGHT=',1pD16.6,' (multi-body)'/
1135 & 'ECORR6=',1pE16.6,' WEIGHT=',1pD16.6,' (multi-body)'/
1136 & 'EELLO= ',1pE16.6,' WEIGHT=',1pD16.6,' (electrostatic-local)'/
1137 & 'ETURN3=',1pE16.6,' WEIGHT=',1pD16.6,' (turns, 3rd order)'/
1138 & 'ETURN4=',1pE16.6,' WEIGHT=',1pD16.6,' (turns, 4th order)'/
1139 & 'ETURN6=',1pE16.6,' WEIGHT=',1pD16.6,' (turns, 6th order)'/
1140 & 'ESCCOR=',1pE16.6,' WEIGHT=',1pD16.6,' (backbone-rotamer corr)'/
1141 & 'EDIHC= ',1pE16.6,' (dihedral angle constraints)'/
1142 & 'ETHETC= ',1pE16.6,' (valence angle constraints)'/
1143 & 'ESS= ',1pE16.6,' (disulfide-bridge intrinsic energy)'/
1144 & 'UCONST=',1pE16.6,' (Constraint energy)'/
1145 & 'ELT=',1pE16.6, ' WEIGHT=',1pD16.6,' (Lipid transfer energy)'/
1146 & 'EAFM= ',1pE16.6,' (atomic-force microscopy)'/
1147 & 'ETOT= ',1pE16.6,' (total)')
1151 C-----------------------------------------------------------------------
1152 subroutine elj(evdw)
1154 C This subroutine calculates the interaction energy of nonbonded side chains
1155 C assuming the LJ potential of interaction.
1157 implicit real*8 (a-h,o-z)
1158 include 'DIMENSIONS'
1159 parameter (accur=1.0d-10)
1160 include 'COMMON.GEO'
1161 include 'COMMON.VAR'
1162 include 'COMMON.LOCAL'
1163 include 'COMMON.CHAIN'
1164 include 'COMMON.DERIV'
1165 include 'COMMON.INTERACT'
1166 include 'COMMON.TORSION'
1167 include 'COMMON.SBRIDGE'
1168 include 'COMMON.NAMES'
1169 include 'COMMON.IOUNITS'
1170 include 'COMMON.CONTACTS'
1172 c write(iout,*)'Entering ELJ nnt=',nnt,' nct=',nct,' expon=',expon
1174 do i=iatsc_s,iatsc_e
1175 itypi=iabs(itype(i))
1176 if (itypi.eq.ntyp1) cycle
1177 itypi1=iabs(itype(i+1))
1184 C Calculate SC interaction energy.
1186 do iint=1,nint_gr(i)
1187 cd write (iout,*) 'i=',i,' iint=',iint,' istart=',istart(i,iint),
1188 cd & 'iend=',iend(i,iint)
1189 do j=istart(i,iint),iend(i,iint)
1190 itypj=iabs(itype(j))
1191 if (itypj.eq.ntyp1) cycle
1195 C Change 12/1/95 to calculate four-body interactions
1196 rij=xj*xj+yj*yj+zj*zj
1198 c write (iout,*)'i=',i,' j=',j,' itypi=',itypi,' itypj=',itypj
1199 eps0ij=eps(itypi,itypj)
1201 C have you changed here?
1205 cd sigm=dabs(aa(itypi,itypj)/bb(itypi,itypj))**(1.0D0/6.0D0)
1206 cd epsi=bb(itypi,itypj)**2/aa(itypi,itypj)
1207 cd write (iout,'(2(a3,i3,2x),6(1pd12.4)/2(3(1pd12.4),5x)/)')
1208 cd & restyp(itypi),i,restyp(itypj),j,a(itypi,itypj),
1209 cd & bb(itypi,itypj),1.0D0/dsqrt(rrij),evdwij,epsi,sigm,
1210 cd & (c(k,i),k=1,3),(c(k,j),k=1,3)
1213 C Calculate the components of the gradient in DC and X
1215 fac=-rrij*(e1+evdwij)
1220 gvdwx(k,i)=gvdwx(k,i)-gg(k)
1221 gvdwx(k,j)=gvdwx(k,j)+gg(k)
1222 gvdwc(k,i)=gvdwc(k,i)-gg(k)
1223 gvdwc(k,j)=gvdwc(k,j)+gg(k)
1227 cgrad gvdwc(l,k)=gvdwc(l,k)+gg(l)
1231 C 12/1/95, revised on 5/20/97
1233 C Calculate the contact function. The ith column of the array JCONT will
1234 C contain the numbers of atoms that make contacts with the atom I (of numbers
1235 C greater than I). The arrays FACONT and GACONT will contain the values of
1236 C the contact function and its derivative.
1238 C Uncomment next line, if the correlation interactions include EVDW explicitly.
1239 c if (j.gt.i+1 .and. evdwij.le.0.0D0) then
1240 C Uncomment next line, if the correlation interactions are contact function only
1241 if (j.gt.i+1.and. eps0ij.gt.0.0D0) then
1243 sigij=sigma(itypi,itypj)
1244 r0ij=rs0(itypi,itypj)
1246 C Check whether the SC's are not too far to make a contact.
1249 call gcont(rij,rcut,1.0d0,0.2d0*rcut,fcont,fprimcont)
1250 C Add a new contact, if the SC's are close enough, but not too close (r<sigma).
1252 if (fcont.gt.0.0D0) then
1253 C If the SC-SC distance if close to sigma, apply spline.
1254 cAdam call gcont(-rij,-1.03d0*sigij,2.0d0*sigij,1.0d0,
1255 cAdam & fcont1,fprimcont1)
1256 cAdam fcont1=1.0d0-fcont1
1257 cAdam if (fcont1.gt.0.0d0) then
1258 cAdam fprimcont=fprimcont*fcont1+fcont*fprimcont1
1259 cAdam fcont=fcont*fcont1
1261 C Uncomment following 4 lines to have the geometric average of the epsilon0's
1262 cga eps0ij=1.0d0/dsqrt(eps0ij)
1264 cga gg(k)=gg(k)*eps0ij
1266 cga eps0ij=-evdwij*eps0ij
1267 C Uncomment for AL's type of SC correlation interactions.
1268 cadam eps0ij=-evdwij
1269 num_conti=num_conti+1
1270 jcont(num_conti,i)=j
1271 facont(num_conti,i)=fcont*eps0ij
1272 fprimcont=eps0ij*fprimcont/rij
1274 cAdam gacont(1,num_conti,i)=-fprimcont*xj+fcont*gg(1)
1275 cAdam gacont(2,num_conti,i)=-fprimcont*yj+fcont*gg(2)
1276 cAdam gacont(3,num_conti,i)=-fprimcont*zj+fcont*gg(3)
1277 C Uncomment following 3 lines for Skolnick's type of SC correlation.
1278 gacont(1,num_conti,i)=-fprimcont*xj
1279 gacont(2,num_conti,i)=-fprimcont*yj
1280 gacont(3,num_conti,i)=-fprimcont*zj
1281 cd write (iout,'(2i5,2f10.5)') i,j,rij,facont(num_conti,i)
1282 cd write (iout,'(2i3,3f10.5)')
1283 cd & i,j,(gacont(kk,num_conti,i),kk=1,3)
1289 num_cont(i)=num_conti
1293 gvdwc(j,i)=expon*gvdwc(j,i)
1294 gvdwx(j,i)=expon*gvdwx(j,i)
1297 C******************************************************************************
1301 C To save time, the factor of EXPON has been extracted from ALL components
1302 C of GVDWC and GRADX. Remember to multiply them by this factor before further
1305 C******************************************************************************
1308 C-----------------------------------------------------------------------------
1309 subroutine eljk(evdw)
1311 C This subroutine calculates the interaction energy of nonbonded side chains
1312 C assuming the LJK potential of interaction.
1314 implicit real*8 (a-h,o-z)
1315 include 'DIMENSIONS'
1316 include 'COMMON.GEO'
1317 include 'COMMON.VAR'
1318 include 'COMMON.LOCAL'
1319 include 'COMMON.CHAIN'
1320 include 'COMMON.DERIV'
1321 include 'COMMON.INTERACT'
1322 include 'COMMON.IOUNITS'
1323 include 'COMMON.NAMES'
1326 c print *,'Entering ELJK nnt=',nnt,' nct=',nct,' expon=',expon
1328 do i=iatsc_s,iatsc_e
1329 itypi=iabs(itype(i))
1330 if (itypi.eq.ntyp1) cycle
1331 itypi1=iabs(itype(i+1))
1336 C Calculate SC interaction energy.
1338 do iint=1,nint_gr(i)
1339 do j=istart(i,iint),iend(i,iint)
1340 itypj=iabs(itype(j))
1341 if (itypj.eq.ntyp1) cycle
1345 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
1346 fac_augm=rrij**expon
1347 e_augm=augm(itypi,itypj)*fac_augm
1348 r_inv_ij=dsqrt(rrij)
1350 r_shift_inv=1.0D0/(rij+r0(itypi,itypj)-sigma(itypi,itypj))
1351 fac=r_shift_inv**expon
1352 C have you changed here?
1356 cd sigm=dabs(aa(itypi,itypj)/bb(itypi,itypj))**(1.0D0/6.0D0)
1357 cd epsi=bb(itypi,itypj)**2/aa(itypi,itypj)
1358 cd write (iout,'(2(a3,i3,2x),8(1pd12.4)/2(3(1pd12.4),5x)/)')
1359 cd & restyp(itypi),i,restyp(itypj),j,aa(itypi,itypj),
1360 cd & bb(itypi,itypj),augm(itypi,itypj),epsi,sigm,
1361 cd & sigma(itypi,itypj),1.0D0/dsqrt(rrij),evdwij,
1362 cd & (c(k,i),k=1,3),(c(k,j),k=1,3)
1365 C Calculate the components of the gradient in DC and X
1367 fac=-2.0D0*rrij*e_augm-r_inv_ij*r_shift_inv*(e1+e1+e2)
1372 gvdwx(k,i)=gvdwx(k,i)-gg(k)
1373 gvdwx(k,j)=gvdwx(k,j)+gg(k)
1374 gvdwc(k,i)=gvdwc(k,i)-gg(k)
1375 gvdwc(k,j)=gvdwc(k,j)+gg(k)
1379 cgrad gvdwc(l,k)=gvdwc(l,k)+gg(l)
1387 gvdwc(j,i)=expon*gvdwc(j,i)
1388 gvdwx(j,i)=expon*gvdwx(j,i)
1393 C-----------------------------------------------------------------------------
1394 subroutine ebp(evdw)
1396 C This subroutine calculates the interaction energy of nonbonded side chains
1397 C assuming the Berne-Pechukas potential of interaction.
1399 implicit real*8 (a-h,o-z)
1400 include 'DIMENSIONS'
1401 include 'COMMON.GEO'
1402 include 'COMMON.VAR'
1403 include 'COMMON.LOCAL'
1404 include 'COMMON.CHAIN'
1405 include 'COMMON.DERIV'
1406 include 'COMMON.NAMES'
1407 include 'COMMON.INTERACT'
1408 include 'COMMON.IOUNITS'
1409 include 'COMMON.CALC'
1410 common /srutu/ icall
1411 c double precision rrsave(maxdim)
1414 c print *,'Entering EBP nnt=',nnt,' nct=',nct,' expon=',expon
1416 c if (icall.eq.0) then
1422 do i=iatsc_s,iatsc_e
1423 itypi=iabs(itype(i))
1424 if (itypi.eq.ntyp1) cycle
1425 itypi1=iabs(itype(i+1))
1429 dxi=dc_norm(1,nres+i)
1430 dyi=dc_norm(2,nres+i)
1431 dzi=dc_norm(3,nres+i)
1432 c dsci_inv=dsc_inv(itypi)
1433 dsci_inv=vbld_inv(i+nres)
1435 C Calculate SC interaction energy.
1437 do iint=1,nint_gr(i)
1438 do j=istart(i,iint),iend(i,iint)
1440 itypj=iabs(itype(j))
1441 if (itypj.eq.ntyp1) cycle
1442 c dscj_inv=dsc_inv(itypj)
1443 dscj_inv=vbld_inv(j+nres)
1444 chi1=chi(itypi,itypj)
1445 chi2=chi(itypj,itypi)
1452 alf12=0.5D0*(alf1+alf2)
1453 C For diagnostics only!!!
1466 dxj=dc_norm(1,nres+j)
1467 dyj=dc_norm(2,nres+j)
1468 dzj=dc_norm(3,nres+j)
1469 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
1470 cd if (icall.eq.0) then
1476 C Calculate the angle-dependent terms of energy & contributions to derivatives.
1478 C Calculate whole angle-dependent part of epsilon and contributions
1479 C to its derivatives
1480 C have you changed here?
1481 fac=(rrij*sigsq)**expon2
1484 evdwij=eps1*eps2rt*eps3rt*(e1+e2)
1485 eps2der=evdwij*eps3rt
1486 eps3der=evdwij*eps2rt
1487 evdwij=evdwij*eps2rt*eps3rt
1490 sigm=dabs(aa/bb)**(1.0D0/6.0D0)
1492 cd write (iout,'(2(a3,i3,2x),15(0pf7.3))')
1493 cd & restyp(itypi),i,restyp(itypj),j,
1494 cd & epsi,sigm,chi1,chi2,chip1,chip2,
1495 cd & eps1,eps2rt**2,eps3rt**2,1.0D0/dsqrt(sigsq),
1496 cd & om1,om2,om12,1.0D0/dsqrt(rrij),
1499 C Calculate gradient components.
1500 e1=e1*eps1*eps2rt**2*eps3rt**2
1501 fac=-expon*(e1+evdwij)
1504 C Calculate radial part of the gradient
1508 C Calculate the angular part of the gradient and sum add the contributions
1509 C to the appropriate components of the Cartesian gradient.
1517 C-----------------------------------------------------------------------------
1518 subroutine egb(evdw)
1520 C This subroutine calculates the interaction energy of nonbonded side chains
1521 C assuming the Gay-Berne potential of interaction.
1523 implicit real*8 (a-h,o-z)
1524 include 'DIMENSIONS'
1525 include 'COMMON.GEO'
1526 include 'COMMON.VAR'
1527 include 'COMMON.LOCAL'
1528 include 'COMMON.CHAIN'
1529 include 'COMMON.DERIV'
1530 include 'COMMON.NAMES'
1531 include 'COMMON.INTERACT'
1532 include 'COMMON.IOUNITS'
1533 include 'COMMON.CALC'
1534 include 'COMMON.CONTROL'
1535 include 'COMMON.SPLITELE'
1536 include 'COMMON.SBRIDGE'
1538 integer xshift,yshift,zshift
1541 ccccc energy_dec=.false.
1542 C print *,'Entering EGB nnt=',nnt,' nct=',nct,' expon=',expon
1545 c if (icall.eq.0) lprn=.false.
1547 C the loop over all 27 posible neigbours (for xshift=0,yshift=0,zshift=0
1548 C we have the original box)
1552 do i=iatsc_s,iatsc_e
1553 itypi=iabs(itype(i))
1554 if (itypi.eq.ntyp1) cycle
1555 itypi1=iabs(itype(i+1))
1559 C Return atom into box, boxxsize is size of box in x dimension
1561 c if (xi.gt.((xshift+0.5d0)*boxxsize)) xi=xi-boxxsize
1562 c if (xi.lt.((xshift-0.5d0)*boxxsize)) xi=xi+boxxsize
1563 C Condition for being inside the proper box
1564 c if ((xi.gt.((xshift+0.5d0)*boxxsize)).or.
1565 c & (xi.lt.((xshift-0.5d0)*boxxsize))) then
1569 c if (yi.gt.((yshift+0.5d0)*boxysize)) yi=yi-boxysize
1570 c if (yi.lt.((yshift-0.5d0)*boxysize)) yi=yi+boxysize
1571 C Condition for being inside the proper box
1572 c if ((yi.gt.((yshift+0.5d0)*boxysize)).or.
1573 c & (yi.lt.((yshift-0.5d0)*boxysize))) then
1577 c if (zi.gt.((zshift+0.5d0)*boxzsize)) zi=zi-boxzsize
1578 c if (zi.lt.((zshift-0.5d0)*boxzsize)) zi=zi+boxzsize
1579 C Condition for being inside the proper box
1580 c if ((zi.gt.((zshift+0.5d0)*boxzsize)).or.
1581 c & (zi.lt.((zshift-0.5d0)*boxzsize))) then
1585 if (xi.lt.0) xi=xi+boxxsize
1587 if (yi.lt.0) yi=yi+boxysize
1589 if (zi.lt.0) zi=zi+boxzsize
1590 C define scaling factor for lipids
1592 C if (positi.le.0) positi=positi+boxzsize
1594 C first for peptide groups
1595 c for each residue check if it is in lipid or lipid water border area
1596 if ((zi.gt.bordlipbot)
1597 &.and.(zi.lt.bordliptop)) then
1598 C the energy transfer exist
1599 if (zi.lt.buflipbot) then
1600 C what fraction I am in
1602 & ((zi-bordlipbot)/lipbufthick)
1603 C lipbufthick is thickenes of lipid buffore
1604 sslipi=sscalelip(fracinbuf)
1605 ssgradlipi=-sscagradlip(fracinbuf)/lipbufthick
1606 elseif (zi.gt.bufliptop) then
1607 fracinbuf=1.0d0-((bordliptop-zi)/lipbufthick)
1608 sslipi=sscalelip(fracinbuf)
1609 ssgradlipi=sscagradlip(fracinbuf)/lipbufthick
1619 C xi=xi+xshift*boxxsize
1620 C yi=yi+yshift*boxysize
1621 C zi=zi+zshift*boxzsize
1623 dxi=dc_norm(1,nres+i)
1624 dyi=dc_norm(2,nres+i)
1625 dzi=dc_norm(3,nres+i)
1626 c dsci_inv=dsc_inv(itypi)
1627 dsci_inv=vbld_inv(i+nres)
1628 c write (iout,*) "i",i,dsc_inv(itypi),dsci_inv,1.0d0/vbld(i+nres)
1629 c write (iout,*) "dcnori",dxi*dxi+dyi*dyi+dzi*dzi
1631 C Calculate SC interaction energy.
1633 do iint=1,nint_gr(i)
1634 do j=istart(i,iint),iend(i,iint)
1635 IF (dyn_ss_mask(i).and.dyn_ss_mask(j)) THEN
1637 c write(iout,*) "PRZED ZWYKLE", evdwij
1638 call dyn_ssbond_ene(i,j,evdwij)
1639 c write(iout,*) "PO ZWYKLE", evdwij
1642 if (energy_dec) write (iout,'(a6,2i5,0pf7.3,a3)')
1643 & 'evdw',i,j,evdwij,' ss'
1644 C triple bond artifac removal
1645 do k=j+1,iend(i,iint)
1646 C search over all next residues
1647 if (dyn_ss_mask(k)) then
1648 C check if they are cysteins
1649 C write(iout,*) 'k=',k
1651 c write(iout,*) "PRZED TRI", evdwij
1652 evdwij_przed_tri=evdwij
1653 call triple_ssbond_ene(i,j,k,evdwij)
1654 c if(evdwij_przed_tri.ne.evdwij) then
1655 c write (iout,*) "TRI:", evdwij, evdwij_przed_tri
1658 c write(iout,*) "PO TRI", evdwij
1659 C call the energy function that removes the artifical triple disulfide
1660 C bond the soubroutine is located in ssMD.F
1662 if (energy_dec) write (iout,'(a6,2i5,0pf7.3,a3)')
1663 & 'evdw',i,j,evdwij,'tss'
1664 endif!dyn_ss_mask(k)
1668 itypj=iabs(itype(j))
1669 if (itypj.eq.ntyp1) cycle
1670 c dscj_inv=dsc_inv(itypj)
1671 dscj_inv=vbld_inv(j+nres)
1672 c write (iout,*) "j",j,dsc_inv(itypj),dscj_inv,
1673 c & 1.0d0/vbld(j+nres)
1674 c write (iout,*) "i",i," j", j," itype",itype(i),itype(j)
1675 sig0ij=sigma(itypi,itypj)
1676 chi1=chi(itypi,itypj)
1677 chi2=chi(itypj,itypi)
1684 alf12=0.5D0*(alf1+alf2)
1685 C For diagnostics only!!!
1698 C Return atom J into box the original box
1700 c if (xj.gt.((0.5d0)*boxxsize)) xj=xj-boxxsize
1701 c if (xj.lt.((-0.5d0)*boxxsize)) xj=xj+boxxsize
1702 C Condition for being inside the proper box
1703 c if ((xj.gt.((0.5d0)*boxxsize)).or.
1704 c & (xj.lt.((-0.5d0)*boxxsize))) then
1708 c if (yj.gt.((0.5d0)*boxysize)) yj=yj-boxysize
1709 c if (yj.lt.((-0.5d0)*boxysize)) yj=yj+boxysize
1710 C Condition for being inside the proper box
1711 c if ((yj.gt.((0.5d0)*boxysize)).or.
1712 c & (yj.lt.((-0.5d0)*boxysize))) then
1716 c if (zj.gt.((0.5d0)*boxzsize)) zj=zj-boxzsize
1717 c if (zj.lt.((-0.5d0)*boxzsize)) zj=zj+boxzsize
1718 C Condition for being inside the proper box
1719 c if ((zj.gt.((0.5d0)*boxzsize)).or.
1720 c & (zj.lt.((-0.5d0)*boxzsize))) then
1724 if (xj.lt.0) xj=xj+boxxsize
1726 if (yj.lt.0) yj=yj+boxysize
1728 if (zj.lt.0) zj=zj+boxzsize
1729 if ((zj.gt.bordlipbot)
1730 &.and.(zj.lt.bordliptop)) then
1731 C the energy transfer exist
1732 if (zj.lt.buflipbot) then
1733 C what fraction I am in
1735 & ((zj-bordlipbot)/lipbufthick)
1736 C lipbufthick is thickenes of lipid buffore
1737 sslipj=sscalelip(fracinbuf)
1738 ssgradlipj=-sscagradlip(fracinbuf)/lipbufthick
1739 elseif (zj.gt.bufliptop) then
1740 fracinbuf=1.0d0-((bordliptop-zj)/lipbufthick)
1741 sslipj=sscalelip(fracinbuf)
1742 ssgradlipj=sscagradlip(fracinbuf)/lipbufthick
1751 aa=aa_lip(itypi,itypj)*(sslipi+sslipj)/2.0d0
1752 & +aa_aq(itypi,itypj)*(2.0d0-sslipi-sslipj)/2.0d0
1753 bb=bb_lip(itypi,itypj)*(sslipi+sslipj)/2.0d0
1754 & +bb_aq(itypi,itypj)*(2.0d0-sslipi-sslipj)/2.0d0
1755 C if (aa.ne.aa_aq(itypi,itypj)) write(63,'(2e10.5)')
1756 C &(aa-aa_aq(itypi,itypj)),(bb-bb_aq(itypi,itypj))
1757 C if (ssgradlipj.gt.0.0d0) print *,"??WTF??"
1758 C print *,sslipi,sslipj,bordlipbot,zi,zj
1759 dist_init=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
1767 xj=xj_safe+xshift*boxxsize
1768 yj=yj_safe+yshift*boxysize
1769 zj=zj_safe+zshift*boxzsize
1770 dist_temp=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
1771 if(dist_temp.lt.dist_init) then
1781 if (subchap.eq.1) then
1790 dxj=dc_norm(1,nres+j)
1791 dyj=dc_norm(2,nres+j)
1792 dzj=dc_norm(3,nres+j)
1796 c write (iout,*) "dcnorj",dxi*dxi+dyi*dyi+dzi*dzi
1797 c write (iout,*) "j",j," dc_norm",
1798 c & dc_norm(1,nres+j),dc_norm(2,nres+j),dc_norm(3,nres+j)
1799 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
1801 sss=sscale((1.0d0/rij)/sigma(itypi,itypj))
1802 sssgrad=sscagrad((1.0d0/rij)/sigma(itypi,itypj))
1804 c write (iout,'(a7,4f8.3)')
1805 c & "ssscale",sss,((1.0d0/rij)/sigma(itypi,itypj)),r_cut,rlamb
1806 if (sss.gt.0.0d0) then
1807 C Calculate angle-dependent terms of energy and contributions to their
1811 sig=sig0ij*dsqrt(sigsq)
1812 rij_shift=1.0D0/rij-sig+sig0ij
1813 c for diagnostics; uncomment
1814 c rij_shift=1.2*sig0ij
1815 C I hate to put IF's in the loops, but here don't have another choice!!!!
1816 if (rij_shift.le.0.0D0) then
1818 cd write (iout,'(2(a3,i3,2x),17(0pf7.3))')
1819 cd & restyp(itypi),i,restyp(itypj),j,
1820 cd & rij_shift,1.0D0/rij,sig,sig0ij,sigsq,1-dsqrt(sigsq)
1824 c---------------------------------------------------------------
1825 rij_shift=1.0D0/rij_shift
1826 fac=rij_shift**expon
1827 C here to start with
1832 evdwij=eps1*eps2rt*eps3rt*(e1+e2)
1833 eps2der=evdwij*eps3rt
1834 eps3der=evdwij*eps2rt
1835 C write(63,'(2i3,2e10.3,2f10.5)') i,j,aa,bb, evdwij,
1836 C &((sslipi+sslipj)/2.0d0+
1837 C &(2.0d0-sslipi-sslipj)/2.0d0)
1838 c write (iout,*) "sigsq",sigsq," sig",sig," eps2rt",eps2rt,
1839 c & " eps3rt",eps3rt," eps1",eps1," e1",e1," e2",e2
1840 evdwij=evdwij*eps2rt*eps3rt
1841 evdw=evdw+evdwij*sss
1843 sigm=dabs(aa/bb)**(1.0D0/6.0D0)
1845 write (iout,'(2(a3,i3,2x),17(0pf7.3))')
1846 & restyp(itypi),i,restyp(itypj),j,
1847 & epsi,sigm,chi1,chi2,chip1,chip2,
1848 & eps1,eps2rt**2,eps3rt**2,sig,sig0ij,
1849 & om1,om2,om12,1.0D0/rij,1.0D0/rij_shift,
1853 if (energy_dec) write (iout,'(a6,2i5,0pf7.3)')
1856 C Calculate gradient components.
1857 e1=e1*eps1*eps2rt**2*eps3rt**2
1858 fac=-expon*(e1+evdwij)*rij_shift
1861 c print '(2i4,6f8.4)',i,j,sss,sssgrad*
1862 c & evdwij,fac,sigma(itypi,itypj),expon
1863 fac=fac+evdwij/sss*sssgrad/sigma(itypi,itypj)*rij
1865 C Calculate the radial part of the gradient
1866 gg_lipi(3)=eps1*(eps2rt*eps2rt)
1867 &*(eps3rt*eps3rt)*sss/2.0d0*(faclip*faclip*
1868 & (aa_lip(itypi,itypj)-aa_aq(itypi,itypj))
1869 &+faclip*(bb_lip(itypi,itypj)-bb_aq(itypi,itypj)))
1870 gg_lipj(3)=ssgradlipj*gg_lipi(3)
1871 gg_lipi(3)=gg_lipi(3)*ssgradlipi
1877 C Calculate angular part of the gradient.
1887 c write (iout,*) "Number of loop steps in EGB:",ind
1888 cccc energy_dec=.false.
1891 C-----------------------------------------------------------------------------
1892 subroutine egbv(evdw)
1894 C This subroutine calculates the interaction energy of nonbonded side chains
1895 C assuming the Gay-Berne-Vorobjev potential of interaction.
1897 implicit real*8 (a-h,o-z)
1898 include 'DIMENSIONS'
1899 include 'COMMON.GEO'
1900 include 'COMMON.VAR'
1901 include 'COMMON.LOCAL'
1902 include 'COMMON.CHAIN'
1903 include 'COMMON.DERIV'
1904 include 'COMMON.NAMES'
1905 include 'COMMON.INTERACT'
1906 include 'COMMON.IOUNITS'
1907 include 'COMMON.CALC'
1908 common /srutu/ icall
1911 c print *,'Entering EGB nnt=',nnt,' nct=',nct,' expon=',expon
1914 c if (icall.eq.0) lprn=.true.
1916 do i=iatsc_s,iatsc_e
1917 itypi=iabs(itype(i))
1918 if (itypi.eq.ntyp1) cycle
1919 itypi1=iabs(itype(i+1))
1924 if (xi.lt.0) xi=xi+boxxsize
1926 if (yi.lt.0) yi=yi+boxysize
1928 if (zi.lt.0) zi=zi+boxzsize
1929 C define scaling factor for lipids
1931 C if (positi.le.0) positi=positi+boxzsize
1933 C first for peptide groups
1934 c for each residue check if it is in lipid or lipid water border area
1935 if ((zi.gt.bordlipbot)
1936 &.and.(zi.lt.bordliptop)) then
1937 C the energy transfer exist
1938 if (zi.lt.buflipbot) then
1939 C what fraction I am in
1941 & ((zi-bordlipbot)/lipbufthick)
1942 C lipbufthick is thickenes of lipid buffore
1943 sslipi=sscalelip(fracinbuf)
1944 ssgradlipi=-sscagradlip(fracinbuf)/lipbufthick
1945 elseif (zi.gt.bufliptop) then
1946 fracinbuf=1.0d0-((bordliptop-zi)/lipbufthick)
1947 sslipi=sscalelip(fracinbuf)
1948 ssgradlipi=sscagradlip(fracinbuf)/lipbufthick
1958 dxi=dc_norm(1,nres+i)
1959 dyi=dc_norm(2,nres+i)
1960 dzi=dc_norm(3,nres+i)
1961 c dsci_inv=dsc_inv(itypi)
1962 dsci_inv=vbld_inv(i+nres)
1964 C Calculate SC interaction energy.
1966 do iint=1,nint_gr(i)
1967 do j=istart(i,iint),iend(i,iint)
1969 itypj=iabs(itype(j))
1970 if (itypj.eq.ntyp1) cycle
1971 c dscj_inv=dsc_inv(itypj)
1972 dscj_inv=vbld_inv(j+nres)
1973 sig0ij=sigma(itypi,itypj)
1974 r0ij=r0(itypi,itypj)
1975 chi1=chi(itypi,itypj)
1976 chi2=chi(itypj,itypi)
1983 alf12=0.5D0*(alf1+alf2)
1984 C For diagnostics only!!!
1998 if (xj.lt.0) xj=xj+boxxsize
2000 if (yj.lt.0) yj=yj+boxysize
2002 if (zj.lt.0) zj=zj+boxzsize
2003 if ((zj.gt.bordlipbot)
2004 &.and.(zj.lt.bordliptop)) then
2005 C the energy transfer exist
2006 if (zj.lt.buflipbot) then
2007 C what fraction I am in
2009 & ((zj-bordlipbot)/lipbufthick)
2010 C lipbufthick is thickenes of lipid buffore
2011 sslipj=sscalelip(fracinbuf)
2012 ssgradlipj=-sscagradlip(fracinbuf)/lipbufthick
2013 elseif (zj.gt.bufliptop) then
2014 fracinbuf=1.0d0-((bordliptop-zj)/lipbufthick)
2015 sslipj=sscalelip(fracinbuf)
2016 ssgradlipj=sscagradlip(fracinbuf)/lipbufthick
2025 aa=aa_lip(itypi,itypj)*(sslipi+sslipj)/2.0d0
2026 & +aa_aq(itypi,itypj)*(2.0d0-sslipi-sslipj)/2.0d0
2027 bb=bb_lip(itypi,itypj)*(sslipi+sslipj)/2.0d0
2028 & +bb_aq(itypi,itypj)*(2.0d0-sslipi-sslipj)/2.0d0
2029 C if (aa.ne.aa_aq(itypi,itypj)) write(63,'2e10.5')
2030 C &(aa-aa_aq(itypi,itypj)),(bb-bb_aq(itypi,itypj))
2031 dist_init=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
2039 xj=xj_safe+xshift*boxxsize
2040 yj=yj_safe+yshift*boxysize
2041 zj=zj_safe+zshift*boxzsize
2042 dist_temp=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
2043 if(dist_temp.lt.dist_init) then
2053 if (subchap.eq.1) then
2062 dxj=dc_norm(1,nres+j)
2063 dyj=dc_norm(2,nres+j)
2064 dzj=dc_norm(3,nres+j)
2065 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
2067 C Calculate angle-dependent terms of energy and contributions to their
2071 sig=sig0ij*dsqrt(sigsq)
2072 rij_shift=1.0D0/rij-sig+r0ij
2073 C I hate to put IF's in the loops, but here don't have another choice!!!!
2074 if (rij_shift.le.0.0D0) then
2079 c---------------------------------------------------------------
2080 rij_shift=1.0D0/rij_shift
2081 fac=rij_shift**expon
2084 evdwij=eps1*eps2rt*eps3rt*(e1+e2)
2085 eps2der=evdwij*eps3rt
2086 eps3der=evdwij*eps2rt
2087 fac_augm=rrij**expon
2088 e_augm=augm(itypi,itypj)*fac_augm
2089 evdwij=evdwij*eps2rt*eps3rt
2090 evdw=evdw+evdwij+e_augm
2092 sigm=dabs(aa/bb)**(1.0D0/6.0D0)
2094 write (iout,'(2(a3,i3,2x),17(0pf7.3))')
2095 & restyp(itypi),i,restyp(itypj),j,
2096 & epsi,sigm,sig,(augm(itypi,itypj)/epsi)**(1.0D0/12.0D0),
2097 & chi1,chi2,chip1,chip2,
2098 & eps1,eps2rt**2,eps3rt**2,
2099 & om1,om2,om12,1.0D0/rij,1.0D0/rij_shift,
2102 C Calculate gradient components.
2103 e1=e1*eps1*eps2rt**2*eps3rt**2
2104 fac=-expon*(e1+evdwij)*rij_shift
2106 fac=rij*fac-2*expon*rrij*e_augm
2107 fac=fac+evdwij/sss*sssgrad/sigma(itypi,itypj)*rij
2108 C Calculate the radial part of the gradient
2112 C Calculate angular part of the gradient.
2118 C-----------------------------------------------------------------------------
2119 subroutine sc_angular
2120 C Calculate eps1,eps2,eps3,sigma, and parts of their derivatives in om1,om2,
2121 C om12. Called by ebp, egb, and egbv.
2123 include 'COMMON.CALC'
2124 include 'COMMON.IOUNITS'
2128 om1=dxi*erij(1)+dyi*erij(2)+dzi*erij(3)
2129 om2=dxj*erij(1)+dyj*erij(2)+dzj*erij(3)
2130 om12=dxi*dxj+dyi*dyj+dzi*dzj
2132 C Calculate eps1(om12) and its derivative in om12
2133 faceps1=1.0D0-om12*chiom12
2134 faceps1_inv=1.0D0/faceps1
2135 eps1=dsqrt(faceps1_inv)
2136 C Following variable is eps1*deps1/dom12
2137 eps1_om12=faceps1_inv*chiom12
2142 c write (iout,*) "om12",om12," eps1",eps1
2143 C Calculate sigma(om1,om2,om12) and the derivatives of sigma**2 in om1,om2,
2148 facsig=om1*chiom1+om2*chiom2-2.0D0*om1om2*chiom12
2149 sigsq=1.0D0-facsig*faceps1_inv
2150 sigsq_om1=(chiom1-chiom12*om2)*faceps1_inv
2151 sigsq_om2=(chiom2-chiom12*om1)*faceps1_inv
2152 sigsq_om12=-chi12*(om1om2*faceps1-om12*facsig)*faceps1_inv**2
2158 c write (iout,*) "chiom1",chiom1," chiom2",chiom2," chiom12",chiom12
2159 c write (iout,*) "faceps1",faceps1," faceps1_inv",faceps1_inv,
2161 C Calculate eps2 and its derivatives in om1, om2, and om12.
2164 chipom12=chip12*om12
2165 facp=1.0D0-om12*chipom12
2167 facp1=om1*chipom1+om2*chipom2-2.0D0*om1om2*chipom12
2168 c write (iout,*) "chipom1",chipom1," chipom2",chipom2,
2169 c & " chipom12",chipom12," facp",facp," facp_inv",facp_inv
2170 C Following variable is the square root of eps2
2171 eps2rt=1.0D0-facp1*facp_inv
2172 C Following three variables are the derivatives of the square root of eps
2173 C in om1, om2, and om12.
2174 eps2rt_om1=-4.0D0*(chipom1-chipom12*om2)*facp_inv
2175 eps2rt_om2=-4.0D0*(chipom2-chipom12*om1)*facp_inv
2176 eps2rt_om12=4.0D0*chip12*(om1om2*facp-om12*facp1)*facp_inv**2
2177 C Evaluate the "asymmetric" factor in the VDW constant, eps3
2178 eps3rt=1.0D0-alf1*om1+alf2*om2-alf12*om12
2179 c write (iout,*) "eps2rt",eps2rt," eps3rt",eps3rt
2180 c write (iout,*) "eps2rt_om1",eps2rt_om1," eps2rt_om2",eps2rt_om2,
2181 c & " eps2rt_om12",eps2rt_om12
2182 C Calculate whole angle-dependent part of epsilon and contributions
2183 C to its derivatives
2186 C----------------------------------------------------------------------------
2188 implicit real*8 (a-h,o-z)
2189 include 'DIMENSIONS'
2190 include 'COMMON.CHAIN'
2191 include 'COMMON.DERIV'
2192 include 'COMMON.CALC'
2193 include 'COMMON.IOUNITS'
2194 double precision dcosom1(3),dcosom2(3)
2195 cc print *,'sss=',sss
2196 eom1=eps2der*eps2rt_om1-2.0D0*alf1*eps3der+sigder*sigsq_om1
2197 eom2=eps2der*eps2rt_om2+2.0D0*alf2*eps3der+sigder*sigsq_om2
2198 eom12=evdwij*eps1_om12+eps2der*eps2rt_om12
2199 & -2.0D0*alf12*eps3der+sigder*sigsq_om12
2203 c eom12=evdwij*eps1_om12
2205 c write (iout,*) "eps2der",eps2der," eps3der",eps3der,
2206 c & " sigder",sigder
2207 c write (iout,*) "eps1_om12",eps1_om12," eps2rt_om12",eps2rt_om12
2208 c write (iout,*) "eom1",eom1," eom2",eom2," eom12",eom12
2210 dcosom1(k)=rij*(dc_norm(k,nres+i)-om1*erij(k))
2211 dcosom2(k)=rij*(dc_norm(k,nres+j)-om2*erij(k))
2214 gg(k)=(gg(k)+eom1*dcosom1(k)+eom2*dcosom2(k))*sss
2216 c write (iout,*) "gg",(gg(k),k=1,3)
2218 gvdwx(k,i)=gvdwx(k,i)-gg(k)+gg_lipi(k)
2219 & +(eom12*(dc_norm(k,nres+j)-om12*dc_norm(k,nres+i))
2220 & +eom1*(erij(k)-om1*dc_norm(k,nres+i)))*dsci_inv*sss
2221 gvdwx(k,j)=gvdwx(k,j)+gg(k)+gg_lipj(k)
2222 & +(eom12*(dc_norm(k,nres+i)-om12*dc_norm(k,nres+j))
2223 & +eom2*(erij(k)-om2*dc_norm(k,nres+j)))*dscj_inv*sss
2224 c write (iout,*)(eom12*(dc_norm(k,nres+j)-om12*dc_norm(k,nres+i))
2225 c & +eom1*(erij(k)-om1*dc_norm(k,nres+i)))*dsci_inv
2226 c write (iout,*)(eom12*(dc_norm(k,nres+i)-om12*dc_norm(k,nres+j))
2227 c & +eom2*(erij(k)-om2*dc_norm(k,nres+j)))*dscj_inv
2230 C Calculate the components of the gradient in DC and X
2234 cgrad gvdwc(l,k)=gvdwc(l,k)+gg(l)
2238 gvdwc(l,i)=gvdwc(l,i)-gg(l)+gg_lipi(l)
2239 gvdwc(l,j)=gvdwc(l,j)+gg(l)+gg_lipj(l)
2243 C-----------------------------------------------------------------------
2244 subroutine e_softsphere(evdw)
2246 C This subroutine calculates the interaction energy of nonbonded side chains
2247 C assuming the LJ potential of interaction.
2249 implicit real*8 (a-h,o-z)
2250 include 'DIMENSIONS'
2251 parameter (accur=1.0d-10)
2252 include 'COMMON.GEO'
2253 include 'COMMON.VAR'
2254 include 'COMMON.LOCAL'
2255 include 'COMMON.CHAIN'
2256 include 'COMMON.DERIV'
2257 include 'COMMON.INTERACT'
2258 include 'COMMON.TORSION'
2259 include 'COMMON.SBRIDGE'
2260 include 'COMMON.NAMES'
2261 include 'COMMON.IOUNITS'
2262 include 'COMMON.CONTACTS'
2264 cd print *,'Entering Esoft_sphere nnt=',nnt,' nct=',nct
2266 do i=iatsc_s,iatsc_e
2267 itypi=iabs(itype(i))
2268 if (itypi.eq.ntyp1) cycle
2269 itypi1=iabs(itype(i+1))
2274 C Calculate SC interaction energy.
2276 do iint=1,nint_gr(i)
2277 cd write (iout,*) 'i=',i,' iint=',iint,' istart=',istart(i,iint),
2278 cd & 'iend=',iend(i,iint)
2279 do j=istart(i,iint),iend(i,iint)
2280 itypj=iabs(itype(j))
2281 if (itypj.eq.ntyp1) cycle
2285 rij=xj*xj+yj*yj+zj*zj
2286 c write (iout,*)'i=',i,' j=',j,' itypi=',itypi,' itypj=',itypj
2287 r0ij=r0(itypi,itypj)
2289 c print *,i,j,r0ij,dsqrt(rij)
2290 if (rij.lt.r0ijsq) then
2291 evdwij=0.25d0*(rij-r0ijsq)**2
2299 C Calculate the components of the gradient in DC and X
2305 gvdwx(k,i)=gvdwx(k,i)-gg(k)
2306 gvdwx(k,j)=gvdwx(k,j)+gg(k)
2307 gvdwc(k,i)=gvdwc(k,i)-gg(k)
2308 gvdwc(k,j)=gvdwc(k,j)+gg(k)
2312 cgrad gvdwc(l,k)=gvdwc(l,k)+gg(l)
2320 C--------------------------------------------------------------------------
2321 subroutine eelec_soft_sphere(ees,evdw1,eel_loc,eello_turn3,
2324 C Soft-sphere potential of p-p interaction
2326 implicit real*8 (a-h,o-z)
2327 include 'DIMENSIONS'
2328 include 'COMMON.CONTROL'
2329 include 'COMMON.IOUNITS'
2330 include 'COMMON.GEO'
2331 include 'COMMON.VAR'
2332 include 'COMMON.LOCAL'
2333 include 'COMMON.CHAIN'
2334 include 'COMMON.DERIV'
2335 include 'COMMON.INTERACT'
2336 include 'COMMON.CONTACTS'
2337 include 'COMMON.TORSION'
2338 include 'COMMON.VECTORS'
2339 include 'COMMON.FFIELD'
2341 C write(iout,*) 'In EELEC_soft_sphere'
2348 do i=iatel_s,iatel_e
2349 if (itype(i).eq.ntyp1 .or. itype(i+1).eq.ntyp1) cycle
2353 xmedi=c(1,i)+0.5d0*dxi
2354 ymedi=c(2,i)+0.5d0*dyi
2355 zmedi=c(3,i)+0.5d0*dzi
2356 xmedi=mod(xmedi,boxxsize)
2357 if (xmedi.lt.0) xmedi=xmedi+boxxsize
2358 ymedi=mod(ymedi,boxysize)
2359 if (ymedi.lt.0) ymedi=ymedi+boxysize
2360 zmedi=mod(zmedi,boxzsize)
2361 if (zmedi.lt.0) zmedi=zmedi+boxzsize
2363 c write (iout,*) 'i',i,' ielstart',ielstart(i),' ielend',ielend(i)
2364 do j=ielstart(i),ielend(i)
2365 if (itype(j).eq.ntyp1 .or. itype(j+1).eq.ntyp1) cycle
2369 if (j.eq.i+2 .and. itelj.eq.2) iteli=2
2370 r0ij=rpp(iteli,itelj)
2379 if (xj.lt.0) xj=xj+boxxsize
2381 if (yj.lt.0) yj=yj+boxysize
2383 if (zj.lt.0) zj=zj+boxzsize
2384 dist_init=(xj-xmedi)**2+(yj-ymedi)**2+(zj-zmedi)**2
2392 xj=xj_safe+xshift*boxxsize
2393 yj=yj_safe+yshift*boxysize
2394 zj=zj_safe+zshift*boxzsize
2395 dist_temp=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
2396 if(dist_temp.lt.dist_init) then
2406 if (isubchap.eq.1) then
2415 rij=xj*xj+yj*yj+zj*zj
2416 sss=sscale(sqrt(rij))
2417 sssgrad=sscagrad(sqrt(rij))
2418 if (rij.lt.r0ijsq) then
2419 evdw1ij=0.25d0*(rij-r0ijsq)**2
2425 evdw1=evdw1+evdw1ij*sss
2427 C Calculate contributions to the Cartesian gradient.
2429 ggg(1)=fac*xj*sssgrad
2430 ggg(2)=fac*yj*sssgrad
2431 ggg(3)=fac*zj*sssgrad
2433 gvdwpp(k,i)=gvdwpp(k,i)-ggg(k)
2434 gvdwpp(k,j)=gvdwpp(k,j)+ggg(k)
2437 * Loop over residues i+1 thru j-1.
2441 cgrad gelc(l,k)=gelc(l,k)+ggg(l)
2446 cgrad do i=nnt,nct-1
2448 cgrad gelc(k,i)=gelc(k,i)+0.5d0*gelc(k,i)
2450 cgrad do j=i+1,nct-1
2452 cgrad gelc(k,i)=gelc(k,i)+gelc(k,j)
2458 c------------------------------------------------------------------------------
2459 subroutine vec_and_deriv
2460 implicit real*8 (a-h,o-z)
2461 include 'DIMENSIONS'
2465 include 'COMMON.IOUNITS'
2466 include 'COMMON.GEO'
2467 include 'COMMON.VAR'
2468 include 'COMMON.LOCAL'
2469 include 'COMMON.CHAIN'
2470 include 'COMMON.VECTORS'
2471 include 'COMMON.SETUP'
2472 include 'COMMON.TIME1'
2473 dimension uyder(3,3,2),uzder(3,3,2),vbld_inv_temp(2)
2474 C Compute the local reference systems. For reference system (i), the
2475 C X-axis points from CA(i) to CA(i+1), the Y axis is in the
2476 C CA(i)-CA(i+1)-CA(i+2) plane, and the Z axis is perpendicular to this plane.
2478 do i=ivec_start,ivec_end
2482 if (i.eq.nres-1) then
2483 C Case of the last full residue
2484 C Compute the Z-axis
2485 call vecpr(dc_norm(1,i),dc_norm(1,i-1),uz(1,i))
2486 costh=dcos(pi-theta(nres))
2487 fac=1.0d0/dsqrt(1.0d0-costh*costh)
2491 C Compute the derivatives of uz
2493 uzder(2,1,1)=-dc_norm(3,i-1)
2494 uzder(3,1,1)= dc_norm(2,i-1)
2495 uzder(1,2,1)= dc_norm(3,i-1)
2497 uzder(3,2,1)=-dc_norm(1,i-1)
2498 uzder(1,3,1)=-dc_norm(2,i-1)
2499 uzder(2,3,1)= dc_norm(1,i-1)
2502 uzder(2,1,2)= dc_norm(3,i)
2503 uzder(3,1,2)=-dc_norm(2,i)
2504 uzder(1,2,2)=-dc_norm(3,i)
2506 uzder(3,2,2)= dc_norm(1,i)
2507 uzder(1,3,2)= dc_norm(2,i)
2508 uzder(2,3,2)=-dc_norm(1,i)
2510 C Compute the Y-axis
2513 uy(k,i)=fac*(dc_norm(k,i-1)-costh*dc_norm(k,i))
2515 C Compute the derivatives of uy
2518 uyder(k,j,1)=2*dc_norm(k,i-1)*dc_norm(j,i)
2519 & -dc_norm(k,i)*dc_norm(j,i-1)
2520 uyder(k,j,2)=-dc_norm(j,i)*dc_norm(k,i)
2522 uyder(j,j,1)=uyder(j,j,1)-costh
2523 uyder(j,j,2)=1.0d0+uyder(j,j,2)
2528 uygrad(l,k,j,i)=uyder(l,k,j)
2529 uzgrad(l,k,j,i)=uzder(l,k,j)
2533 call unormderiv(uy(1,i),uyder(1,1,1),facy,uygrad(1,1,1,i))
2534 call unormderiv(uy(1,i),uyder(1,1,2),facy,uygrad(1,1,2,i))
2535 call unormderiv(uz(1,i),uzder(1,1,1),fac,uzgrad(1,1,1,i))
2536 call unormderiv(uz(1,i),uzder(1,1,2),fac,uzgrad(1,1,2,i))
2539 C Compute the Z-axis
2540 call vecpr(dc_norm(1,i),dc_norm(1,i+1),uz(1,i))
2541 costh=dcos(pi-theta(i+2))
2542 fac=1.0d0/dsqrt(1.0d0-costh*costh)
2546 C Compute the derivatives of uz
2548 uzder(2,1,1)=-dc_norm(3,i+1)
2549 uzder(3,1,1)= dc_norm(2,i+1)
2550 uzder(1,2,1)= dc_norm(3,i+1)
2552 uzder(3,2,1)=-dc_norm(1,i+1)
2553 uzder(1,3,1)=-dc_norm(2,i+1)
2554 uzder(2,3,1)= dc_norm(1,i+1)
2557 uzder(2,1,2)= dc_norm(3,i)
2558 uzder(3,1,2)=-dc_norm(2,i)
2559 uzder(1,2,2)=-dc_norm(3,i)
2561 uzder(3,2,2)= dc_norm(1,i)
2562 uzder(1,3,2)= dc_norm(2,i)
2563 uzder(2,3,2)=-dc_norm(1,i)
2565 C Compute the Y-axis
2568 uy(k,i)=facy*(dc_norm(k,i+1)-costh*dc_norm(k,i))
2570 C Compute the derivatives of uy
2573 uyder(k,j,1)=2*dc_norm(k,i+1)*dc_norm(j,i)
2574 & -dc_norm(k,i)*dc_norm(j,i+1)
2575 uyder(k,j,2)=-dc_norm(j,i)*dc_norm(k,i)
2577 uyder(j,j,1)=uyder(j,j,1)-costh
2578 uyder(j,j,2)=1.0d0+uyder(j,j,2)
2583 uygrad(l,k,j,i)=uyder(l,k,j)
2584 uzgrad(l,k,j,i)=uzder(l,k,j)
2588 call unormderiv(uy(1,i),uyder(1,1,1),facy,uygrad(1,1,1,i))
2589 call unormderiv(uy(1,i),uyder(1,1,2),facy,uygrad(1,1,2,i))
2590 call unormderiv(uz(1,i),uzder(1,1,1),fac,uzgrad(1,1,1,i))
2591 call unormderiv(uz(1,i),uzder(1,1,2),fac,uzgrad(1,1,2,i))
2595 vbld_inv_temp(1)=vbld_inv(i+1)
2596 if (i.lt.nres-1) then
2597 vbld_inv_temp(2)=vbld_inv(i+2)
2599 vbld_inv_temp(2)=vbld_inv(i)
2604 uygrad(l,k,j,i)=vbld_inv_temp(j)*uygrad(l,k,j,i)
2605 uzgrad(l,k,j,i)=vbld_inv_temp(j)*uzgrad(l,k,j,i)
2610 #if defined(PARVEC) && defined(MPI)
2611 if (nfgtasks1.gt.1) then
2613 c print *,"Processor",fg_rank1,kolor1," ivec_start",ivec_start,
2614 c & " ivec_displ",(ivec_displ(i),i=0,nfgtasks1-1),
2615 c & " ivec_count",(ivec_count(i),i=0,nfgtasks1-1)
2616 call MPI_Allgatherv(uy(1,ivec_start),ivec_count(fg_rank1),
2617 & MPI_UYZ,uy(1,1),ivec_count(0),ivec_displ(0),MPI_UYZ,
2619 call MPI_Allgatherv(uz(1,ivec_start),ivec_count(fg_rank1),
2620 & MPI_UYZ,uz(1,1),ivec_count(0),ivec_displ(0),MPI_UYZ,
2622 call MPI_Allgatherv(uygrad(1,1,1,ivec_start),
2623 & ivec_count(fg_rank1),MPI_UYZGRAD,uygrad(1,1,1,1),ivec_count(0),
2624 & ivec_displ(0),MPI_UYZGRAD,FG_COMM1,IERR)
2625 call MPI_Allgatherv(uzgrad(1,1,1,ivec_start),
2626 & ivec_count(fg_rank1),MPI_UYZGRAD,uzgrad(1,1,1,1),ivec_count(0),
2627 & ivec_displ(0),MPI_UYZGRAD,FG_COMM1,IERR)
2628 time_gather=time_gather+MPI_Wtime()-time00
2630 c if (fg_rank.eq.0) then
2631 c write (iout,*) "Arrays UY and UZ"
2633 c write (iout,'(i5,3f10.5,5x,3f10.5)') i,(uy(k,i),k=1,3),
2640 C-----------------------------------------------------------------------------
2641 subroutine check_vecgrad
2642 implicit real*8 (a-h,o-z)
2643 include 'DIMENSIONS'
2644 include 'COMMON.IOUNITS'
2645 include 'COMMON.GEO'
2646 include 'COMMON.VAR'
2647 include 'COMMON.LOCAL'
2648 include 'COMMON.CHAIN'
2649 include 'COMMON.VECTORS'
2650 dimension uygradt(3,3,2,maxres),uzgradt(3,3,2,maxres)
2651 dimension uyt(3,maxres),uzt(3,maxres)
2652 dimension uygradn(3,3,2),uzgradn(3,3,2),erij(3)
2653 double precision delta /1.0d-7/
2656 crc write(iout,'(2i5,2(3f10.5,5x))') i,1,dc_norm(:,i)
2657 crc write(iout,'(2i5,2(3f10.5,5x))') i,2,uy(:,i)
2658 crc write(iout,'(2i5,2(3f10.5,5x)/)')i,3,uz(:,i)
2659 cd write(iout,'(2i5,2(3f10.5,5x))') i,1,
2660 cd & (dc_norm(if90,i),if90=1,3)
2661 cd write(iout,'(2i5,2(3f10.5,5x))') i,2,(uy(if90,i),if90=1,3)
2662 cd write(iout,'(2i5,2(3f10.5,5x)/)')i,3,(uz(if90,i),if90=1,3)
2663 cd write(iout,'(a)')
2669 uygradt(l,k,j,i)=uygrad(l,k,j,i)
2670 uzgradt(l,k,j,i)=uzgrad(l,k,j,i)
2683 cd write (iout,*) 'i=',i
2685 erij(k)=dc_norm(k,i)
2689 dc_norm(k,i)=erij(k)
2691 dc_norm(j,i)=dc_norm(j,i)+delta
2692 c fac=dsqrt(scalar(dc_norm(1,i),dc_norm(1,i)))
2694 c dc_norm(k,i)=dc_norm(k,i)/fac
2696 c write (iout,*) (dc_norm(k,i),k=1,3)
2697 c write (iout,*) (erij(k),k=1,3)
2700 uygradn(k,j,1)=(uy(k,i)-uyt(k,i))/delta
2701 uygradn(k,j,2)=(uy(k,i-1)-uyt(k,i-1))/delta
2702 uzgradn(k,j,1)=(uz(k,i)-uzt(k,i))/delta
2703 uzgradn(k,j,2)=(uz(k,i-1)-uzt(k,i-1))/delta
2705 c write (iout,'(i5,3f8.5,3x,3f8.5,5x,3f8.5,3x,3f8.5)')
2706 c & j,(uzgradt(k,j,1,i),k=1,3),(uzgradn(k,j,1),k=1,3),
2707 c & (uzgradt(k,j,2,i-1),k=1,3),(uzgradn(k,j,2),k=1,3)
2710 dc_norm(k,i)=erij(k)
2713 cd write (iout,'(i5,3f8.5,3x,3f8.5,5x,3f8.5,3x,3f8.5)')
2714 cd & k,(uygradt(k,l,1,i),l=1,3),(uygradn(k,l,1),l=1,3),
2715 cd & (uygradt(k,l,2,i-1),l=1,3),(uygradn(k,l,2),l=1,3)
2716 cd write (iout,'(i5,3f8.5,3x,3f8.5,5x,3f8.5,3x,3f8.5)')
2717 cd & k,(uzgradt(k,l,1,i),l=1,3),(uzgradn(k,l,1),l=1,3),
2718 cd & (uzgradt(k,l,2,i-1),l=1,3),(uzgradn(k,l,2),l=1,3)
2719 cd write (iout,'(a)')
2724 C--------------------------------------------------------------------------
2725 subroutine set_matrices
2726 implicit real*8 (a-h,o-z)
2727 include 'DIMENSIONS'
2730 include "COMMON.SETUP"
2732 integer status(MPI_STATUS_SIZE)
2734 include 'COMMON.IOUNITS'
2735 include 'COMMON.GEO'
2736 include 'COMMON.VAR'
2737 include 'COMMON.LOCAL'
2738 include 'COMMON.CHAIN'
2739 include 'COMMON.DERIV'
2740 include 'COMMON.INTERACT'
2741 include 'COMMON.CONTACTS'
2742 include 'COMMON.TORSION'
2743 include 'COMMON.VECTORS'
2744 include 'COMMON.FFIELD'
2745 double precision auxvec(2),auxmat(2,2)
2747 C Compute the virtual-bond-torsional-angle dependent quantities needed
2748 C to calculate the el-loc multibody terms of various order.
2750 c write(iout,*) 'nphi=',nphi,nres
2752 do i=ivec_start+2,ivec_end+2
2757 if (i.gt. nnt+2 .and. i.lt.nct+2) then
2758 iti = itortyp(itype(i-2))
2762 c if (i.gt. iatel_s+1 .and. i.lt.iatel_e+4) then
2763 if (i.gt. nnt+1 .and. i.lt.nct+1) then
2764 iti1 = itortyp(itype(i-1))
2769 b1(1,i-2)=bnew1(1,1,iti)*dsin(theta(i-1)/2.0)
2770 & +bnew1(2,1,iti)*dsin(theta(i-1))
2771 & +bnew1(3,1,iti)*dcos(theta(i-1)/2.0)
2772 gtb1(1,i-2)=bnew1(1,1,iti)*dcos(theta(i-1)/2.0d0)/2.0d0
2773 & +bnew1(2,1,iti)*dcos(theta(i-1))
2774 & -bnew1(3,1,iti)*dsin(theta(i-1)/2.0d0)/2.0d0
2775 c & +bnew1(3,1,iti)*sin(alpha(i))*cos(beta(i))
2776 c &*(cos(theta(i)/2.0)
2777 b2(1,i-2)=bnew2(1,1,iti)*dsin(theta(i-1)/2.0)
2778 & +bnew2(2,1,iti)*dsin(theta(i-1))
2779 & +bnew2(3,1,iti)*dcos(theta(i-1)/2.0)
2780 c & +bnew2(3,1,iti)*sin(alpha(i))*cos(beta(i))
2781 c &*(cos(theta(i)/2.0)
2782 gtb2(1,i-2)=bnew2(1,1,iti)*dcos(theta(i-1)/2.0d0)/2.0d0
2783 & +bnew2(2,1,iti)*dcos(theta(i-1))
2784 & -bnew2(3,1,iti)*dsin(theta(i-1)/2.0d0)/2.0d0
2785 c if (ggb1(1,i).eq.0.0d0) then
2786 c write(iout,*) 'i=',i,ggb1(1,i),
2787 c &bnew1(1,1,iti)*cos(theta(i)/2.0)/2.0,
2788 c &bnew1(2,1,iti)*cos(theta(i)),
2789 c &bnew1(3,1,iti)*sin(theta(i)/2.0)/2.0
2791 b1(2,i-2)=bnew1(1,2,iti)
2793 b2(2,i-2)=bnew2(1,2,iti)
2795 EE(1,1,i-2)=eenew(1,iti)*dcos(theta(i-1))
2796 EE(1,2,i-2)=eeold(1,2,iti)
2797 EE(2,1,i-2)=eeold(2,1,iti)
2798 EE(2,2,i-2)=eeold(2,2,iti)
2799 gtEE(1,1,i-2)=-eenew(1,iti)*dsin(theta(i-1))
2804 c EE(1,2,iti)=0.5d0*eenew(1,iti)
2805 c EE(2,1,iti)=0.5d0*eenew(1,iti)
2806 c b1(2,iti)=bnew1(1,2,iti)*sin(alpha(i))*sin(beta(i))
2807 c b2(2,iti)=bnew2(1,2,iti)*sin(alpha(i))*sin(beta(i))
2808 b1tilde(1,i-2)=b1(1,i-2)
2809 b1tilde(2,i-2)=-b1(2,i-2)
2810 b2tilde(1,i-2)=b2(1,i-2)
2811 b2tilde(2,i-2)=-b2(2,i-2)
2812 c write (iout,*) 'i=',i-2,gtb1(2,i-2),gtb1(1,i-2)
2813 c write(iout,*) 'b1=',b1(1,i-2)
2814 c write (iout,*) 'theta=', theta(i-1)
2817 if (i.gt. nnt+2 .and. i.lt.nct+2) then
2818 iti = itortyp(itype(i-2))
2822 c if (i.gt. iatel_s+1 .and. i.lt.iatel_e+4) then
2823 if (i.gt. nnt+1 .and. i.lt.nct+1) then
2824 iti1 = itortyp(itype(i-1))
2832 b1tilde(1,i-2)=b1(1,i-2)
2833 b1tilde(2,i-2)=-b1(2,i-2)
2834 b2tilde(1,i-2)=b2(1,i-2)
2835 b2tilde(2,i-2)=-b2(2,i-2)
2836 EE(1,2,i-2)=eeold(1,2,iti)
2837 EE(2,1,i-2)=eeold(2,1,iti)
2838 EE(2,2,i-2)=eeold(2,2,iti)
2839 EE(1,1,i-2)=eeold(1,1,iti)
2843 do i=ivec_start+2,ivec_end+2
2847 if (i .lt. nres+1) then
2884 if (i .gt. 3 .and. i .lt. nres+1) then
2885 obrot_der(1,i-2)=-sin1
2886 obrot_der(2,i-2)= cos1
2887 Ugder(1,1,i-2)= sin1
2888 Ugder(1,2,i-2)=-cos1
2889 Ugder(2,1,i-2)=-cos1
2890 Ugder(2,2,i-2)=-sin1
2893 obrot2_der(1,i-2)=-dwasin2
2894 obrot2_der(2,i-2)= dwacos2
2895 Ug2der(1,1,i-2)= dwasin2
2896 Ug2der(1,2,i-2)=-dwacos2
2897 Ug2der(2,1,i-2)=-dwacos2
2898 Ug2der(2,2,i-2)=-dwasin2
2900 obrot_der(1,i-2)=0.0d0
2901 obrot_der(2,i-2)=0.0d0
2902 Ugder(1,1,i-2)=0.0d0
2903 Ugder(1,2,i-2)=0.0d0
2904 Ugder(2,1,i-2)=0.0d0
2905 Ugder(2,2,i-2)=0.0d0
2906 obrot2_der(1,i-2)=0.0d0
2907 obrot2_der(2,i-2)=0.0d0
2908 Ug2der(1,1,i-2)=0.0d0
2909 Ug2der(1,2,i-2)=0.0d0
2910 Ug2der(2,1,i-2)=0.0d0
2911 Ug2der(2,2,i-2)=0.0d0
2913 c if (i.gt. iatel_s+2 .and. i.lt.iatel_e+5) then
2914 if (i.gt. nnt+2 .and. i.lt.nct+2) then
2915 iti = itortyp(itype(i-2))
2919 c if (i.gt. iatel_s+1 .and. i.lt.iatel_e+4) then
2920 if (i.gt. nnt+1 .and. i.lt.nct+1) then
2921 iti1 = itortyp(itype(i-1))
2925 cd write (iout,*) '*******i',i,' iti1',iti
2926 cd write (iout,*) 'b1',b1(:,iti)
2927 cd write (iout,*) 'b2',b2(:,iti)
2928 cd write (iout,*) 'Ug',Ug(:,:,i-2)
2929 c if (i .gt. iatel_s+2) then
2930 if (i .gt. nnt+2) then
2931 call matvec2(Ug(1,1,i-2),b2(1,i-2),Ub2(1,i-2))
2933 call matvec2(Ug(1,1,i-2),gtb2(1,i-2),gUb2(1,i-2))
2934 c write (iout,*) Ug(1,1,i-2),gtb2(1,i-2),gUb2(1,i-2),"chuj"
2936 c write(iout,*) "co jest kurwa", iti, EE(1,1,iti),EE(2,1,iti),
2937 c & EE(1,2,iti),EE(2,2,iti)
2938 call matmat2(EE(1,1,i-2),Ug(1,1,i-2),EUg(1,1,i-2))
2939 call matmat2(gtEE(1,1,i-2),Ug(1,1,i-2),gtEUg(1,1,i-2))
2940 c write(iout,*) "Macierz EUG",
2941 c & eug(1,1,i-2),eug(1,2,i-2),eug(2,1,i-2),
2943 if (wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 .or. wcorr6.gt.0.0d0)
2945 call matmat2(CC(1,1,iti),Ug(1,1,i-2),CUg(1,1,i-2))
2946 call matmat2(DD(1,1,iti),Ug(1,1,i-2),DUg(1,1,i-2))
2947 call matmat2(Dtilde(1,1,iti),Ug2(1,1,i-2),DtUg2(1,1,i-2))
2948 call matvec2(Ctilde(1,1,iti1),obrot(1,i-2),Ctobr(1,i-2))
2949 call matvec2(Dtilde(1,1,iti),obrot2(1,i-2),Dtobr2(1,i-2))
2960 DtUg2(l,k,i-2)=0.0d0
2964 call matvec2(Ugder(1,1,i-2),b2(1,i-2),Ub2der(1,i-2))
2965 call matmat2(EE(1,1,i-2),Ugder(1,1,i-2),EUgder(1,1,i-2))
2967 muder(k,i-2)=Ub2der(k,i-2)
2969 c if (i.gt. iatel_s+1 .and. i.lt.iatel_e+4) then
2970 if (i.gt. nnt+1 .and. i.lt.nct+1) then
2971 if (itype(i-1).le.ntyp) then
2972 iti1 = itortyp(itype(i-1))
2980 mu(k,i-2)=Ub2(k,i-2)+b1(k,i-1)
2982 C write (iout,*) 'mumu',i,b1(1,i-1),Ub2(1,i-2)
2983 c write (iout,*) 'mu ',mu(:,i-2),i-2
2984 cd write (iout,*) 'mu1',mu1(:,i-2)
2985 cd write (iout,*) 'mu2',mu2(:,i-2)
2986 if (wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 .or.wcorr6.gt.0.0d0)
2988 call matmat2(CC(1,1,iti1),Ugder(1,1,i-2),CUgder(1,1,i-2))
2989 call matmat2(DD(1,1,iti),Ugder(1,1,i-2),DUgder(1,1,i-2))
2990 call matmat2(Dtilde(1,1,iti),Ug2der(1,1,i-2),DtUg2der(1,1,i-2))
2991 call matvec2(Ctilde(1,1,iti1),obrot_der(1,i-2),Ctobrder(1,i-2))
2992 call matvec2(Dtilde(1,1,iti),obrot2_der(1,i-2),Dtobr2der(1,i-2))
2993 C Vectors and matrices dependent on a single virtual-bond dihedral.
2994 call matvec2(DD(1,1,iti),b1tilde(1,i-1),auxvec(1))
2995 call matvec2(Ug2(1,1,i-2),auxvec(1),Ug2Db1t(1,i-2))
2996 call matvec2(Ug2der(1,1,i-2),auxvec(1),Ug2Db1tder(1,i-2))
2997 call matvec2(CC(1,1,iti1),Ub2(1,i-2),CUgb2(1,i-2))
2998 call matvec2(CC(1,1,iti1),Ub2der(1,i-2),CUgb2der(1,i-2))
2999 call matmat2(EUg(1,1,i-2),CC(1,1,iti1),EUgC(1,1,i-2))
3000 call matmat2(EUgder(1,1,i-2),CC(1,1,iti1),EUgCder(1,1,i-2))
3001 call matmat2(EUg(1,1,i-2),DD(1,1,iti1),EUgD(1,1,i-2))
3002 call matmat2(EUgder(1,1,i-2),DD(1,1,iti1),EUgDder(1,1,i-2))
3005 C Matrices dependent on two consecutive virtual-bond dihedrals.
3006 C The order of matrices is from left to right.
3007 if (wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 .or.wcorr6.gt.0.0d0)
3009 c do i=max0(ivec_start,2),ivec_end
3011 call matmat2(DtUg2(1,1,i-1),EUg(1,1,i),DtUg2EUg(1,1,i))
3012 call matmat2(DtUg2der(1,1,i-1),EUg(1,1,i),DtUg2EUgder(1,1,1,i))
3013 call matmat2(DtUg2(1,1,i-1),EUgder(1,1,i),DtUg2EUgder(1,1,2,i))
3014 call transpose2(DtUg2(1,1,i-1),auxmat(1,1))
3015 call matmat2(auxmat(1,1),EUg(1,1,i),Ug2DtEUg(1,1,i))
3016 call matmat2(auxmat(1,1),EUgder(1,1,i),Ug2DtEUgder(1,1,2,i))
3017 call transpose2(DtUg2der(1,1,i-1),auxmat(1,1))
3018 call matmat2(auxmat(1,1),EUg(1,1,i),Ug2DtEUgder(1,1,1,i))
3021 #if defined(MPI) && defined(PARMAT)
3023 c if (fg_rank.eq.0) then
3024 write (iout,*) "Arrays UG and UGDER before GATHER"
3026 write (iout,'(i5,4f10.5,5x,4f10.5)') i,
3027 & ((ug(l,k,i),l=1,2),k=1,2),
3028 & ((ugder(l,k,i),l=1,2),k=1,2)
3030 write (iout,*) "Arrays UG2 and UG2DER"
3032 write (iout,'(i5,4f10.5,5x,4f10.5)') i,
3033 & ((ug2(l,k,i),l=1,2),k=1,2),
3034 & ((ug2der(l,k,i),l=1,2),k=1,2)
3036 write (iout,*) "Arrays OBROT OBROT2 OBROTDER and OBROT2DER"
3038 write (iout,'(i5,4f10.5,5x,4f10.5)') i,
3039 & (obrot(k,i),k=1,2),(obrot2(k,i),k=1,2),
3040 & (obrot_der(k,i),k=1,2),(obrot2_der(k,i),k=1,2)
3042 write (iout,*) "Arrays COSTAB SINTAB COSTAB2 and SINTAB2"
3044 write (iout,'(i5,4f10.5,5x,4f10.5)') i,
3045 & costab(i),sintab(i),costab2(i),sintab2(i)
3047 write (iout,*) "Array MUDER"
3049 write (iout,'(i5,2f10.5)') i,muder(1,i),muder(2,i)
3053 if (nfgtasks.gt.1) then
3055 c write(iout,*)"Processor",fg_rank,kolor," ivec_start",ivec_start,
3056 c & " ivec_displ",(ivec_displ(i),i=0,nfgtasks-1),
3057 c & " ivec_count",(ivec_count(i),i=0,nfgtasks-1)
3059 call MPI_Allgatherv(Ub2(1,ivec_start),ivec_count(fg_rank1),
3060 & MPI_MU,Ub2(1,1),ivec_count(0),ivec_displ(0),MPI_MU,
3062 call MPI_Allgatherv(Ub2der(1,ivec_start),ivec_count(fg_rank1),
3063 & MPI_MU,Ub2der(1,1),ivec_count(0),ivec_displ(0),MPI_MU,
3065 call MPI_Allgatherv(mu(1,ivec_start),ivec_count(fg_rank1),
3066 & MPI_MU,mu(1,1),ivec_count(0),ivec_displ(0),MPI_MU,
3068 call MPI_Allgatherv(muder(1,ivec_start),ivec_count(fg_rank1),
3069 & MPI_MU,muder(1,1),ivec_count(0),ivec_displ(0),MPI_MU,
3071 call MPI_Allgatherv(Eug(1,1,ivec_start),ivec_count(fg_rank1),
3072 & MPI_MAT1,Eug(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,
3074 call MPI_Allgatherv(Eugder(1,1,ivec_start),ivec_count(fg_rank1),
3075 & MPI_MAT1,Eugder(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,
3077 call MPI_Allgatherv(costab(ivec_start),ivec_count(fg_rank1),
3078 & MPI_DOUBLE_PRECISION,costab(1),ivec_count(0),ivec_displ(0),
3079 & MPI_DOUBLE_PRECISION,FG_COMM1,IERR)
3080 call MPI_Allgatherv(sintab(ivec_start),ivec_count(fg_rank1),
3081 & MPI_DOUBLE_PRECISION,sintab(1),ivec_count(0),ivec_displ(0),
3082 & MPI_DOUBLE_PRECISION,FG_COMM1,IERR)
3083 call MPI_Allgatherv(costab2(ivec_start),ivec_count(fg_rank1),
3084 & MPI_DOUBLE_PRECISION,costab2(1),ivec_count(0),ivec_displ(0),
3085 & MPI_DOUBLE_PRECISION,FG_COMM1,IERR)
3086 call MPI_Allgatherv(sintab2(ivec_start),ivec_count(fg_rank1),
3087 & MPI_DOUBLE_PRECISION,sintab2(1),ivec_count(0),ivec_displ(0),
3088 & MPI_DOUBLE_PRECISION,FG_COMM1,IERR)
3089 if (wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 .or. wcorr6.gt.0.0d0)
3091 call MPI_Allgatherv(Ctobr(1,ivec_start),ivec_count(fg_rank1),
3092 & MPI_MU,Ctobr(1,1),ivec_count(0),ivec_displ(0),MPI_MU,
3094 call MPI_Allgatherv(Ctobrder(1,ivec_start),ivec_count(fg_rank1),
3095 & MPI_MU,Ctobrder(1,1),ivec_count(0),ivec_displ(0),MPI_MU,
3097 call MPI_Allgatherv(Dtobr2(1,ivec_start),ivec_count(fg_rank1),
3098 & MPI_MU,Dtobr2(1,1),ivec_count(0),ivec_displ(0),MPI_MU,
3100 call MPI_Allgatherv(Dtobr2der(1,ivec_start),ivec_count(fg_rank1),
3101 & MPI_MU,Dtobr2der(1,1),ivec_count(0),ivec_displ(0),MPI_MU,
3103 call MPI_Allgatherv(Ug2Db1t(1,ivec_start),ivec_count(fg_rank1),
3104 & MPI_MU,Ug2Db1t(1,1),ivec_count(0),ivec_displ(0),MPI_MU,
3106 call MPI_Allgatherv(Ug2Db1tder(1,ivec_start),
3107 & ivec_count(fg_rank1),
3108 & MPI_MU,Ug2Db1tder(1,1),ivec_count(0),ivec_displ(0),MPI_MU,
3110 call MPI_Allgatherv(CUgb2(1,ivec_start),ivec_count(fg_rank1),
3111 & MPI_MU,CUgb2(1,1),ivec_count(0),ivec_displ(0),MPI_MU,
3113 call MPI_Allgatherv(CUgb2der(1,ivec_start),ivec_count(fg_rank1),
3114 & MPI_MU,CUgb2der(1,1),ivec_count(0),ivec_displ(0),MPI_MU,
3116 call MPI_Allgatherv(Cug(1,1,ivec_start),ivec_count(fg_rank1),
3117 & MPI_MAT1,Cug(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,
3119 call MPI_Allgatherv(Cugder(1,1,ivec_start),ivec_count(fg_rank1),
3120 & MPI_MAT1,Cugder(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,
3122 call MPI_Allgatherv(Dug(1,1,ivec_start),ivec_count(fg_rank1),
3123 & MPI_MAT1,Dug(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,
3125 call MPI_Allgatherv(Dugder(1,1,ivec_start),ivec_count(fg_rank1),
3126 & MPI_MAT1,Dugder(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,
3128 call MPI_Allgatherv(Dtug2(1,1,ivec_start),ivec_count(fg_rank1),
3129 & MPI_MAT1,Dtug2(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,
3131 call MPI_Allgatherv(Dtug2der(1,1,ivec_start),
3132 & ivec_count(fg_rank1),
3133 & MPI_MAT1,Dtug2der(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,
3135 call MPI_Allgatherv(EugC(1,1,ivec_start),ivec_count(fg_rank1),
3136 & MPI_MAT1,EugC(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,
3138 call MPI_Allgatherv(EugCder(1,1,ivec_start),ivec_count(fg_rank1),
3139 & MPI_MAT1,EugCder(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,
3141 call MPI_Allgatherv(EugD(1,1,ivec_start),ivec_count(fg_rank1),
3142 & MPI_MAT1,EugD(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,
3144 call MPI_Allgatherv(EugDder(1,1,ivec_start),ivec_count(fg_rank1),
3145 & MPI_MAT1,EugDder(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,
3147 call MPI_Allgatherv(DtUg2EUg(1,1,ivec_start),
3148 & ivec_count(fg_rank1),
3149 & MPI_MAT1,DtUg2EUg(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,
3151 call MPI_Allgatherv(Ug2DtEUg(1,1,ivec_start),
3152 & ivec_count(fg_rank1),
3153 & MPI_MAT1,Ug2DtEUg(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,
3155 call MPI_Allgatherv(DtUg2EUgder(1,1,1,ivec_start),
3156 & ivec_count(fg_rank1),
3157 & MPI_MAT2,DtUg2EUgder(1,1,1,1),ivec_count(0),ivec_displ(0),
3158 & MPI_MAT2,FG_COMM1,IERR)
3159 call MPI_Allgatherv(Ug2DtEUgder(1,1,1,ivec_start),
3160 & ivec_count(fg_rank1),
3161 & MPI_MAT2,Ug2DtEUgder(1,1,1,1),ivec_count(0),ivec_displ(0),
3162 & MPI_MAT2,FG_COMM1,IERR)
3165 c Passes matrix info through the ring
3168 if (irecv.lt.0) irecv=nfgtasks1-1
3171 if (inext.ge.nfgtasks1) inext=0
3173 c write (iout,*) "isend",isend," irecv",irecv
3175 lensend=lentyp(isend)
3176 lenrecv=lentyp(irecv)
3177 c write (iout,*) "lensend",lensend," lenrecv",lenrecv
3178 c call MPI_SENDRECV(ug(1,1,ivec_displ(isend)+1),1,
3179 c & MPI_ROTAT1(lensend),inext,2200+isend,
3180 c & ug(1,1,ivec_displ(irecv)+1),1,MPI_ROTAT1(lenrecv),
3181 c & iprev,2200+irecv,FG_COMM,status,IERR)
3182 c write (iout,*) "Gather ROTAT1"
3184 c call MPI_SENDRECV(obrot(1,ivec_displ(isend)+1),1,
3185 c & MPI_ROTAT2(lensend),inext,3300+isend,
3186 c & obrot(1,ivec_displ(irecv)+1),1,MPI_ROTAT2(lenrecv),
3187 c & iprev,3300+irecv,FG_COMM,status,IERR)
3188 c write (iout,*) "Gather ROTAT2"
3190 call MPI_SENDRECV(costab(ivec_displ(isend)+1),1,
3191 & MPI_ROTAT_OLD(lensend),inext,4400+isend,
3192 & costab(ivec_displ(irecv)+1),1,MPI_ROTAT_OLD(lenrecv),
3193 & iprev,4400+irecv,FG_COMM,status,IERR)
3194 c write (iout,*) "Gather ROTAT_OLD"
3196 call MPI_SENDRECV(mu(1,ivec_displ(isend)+1),1,
3197 & MPI_PRECOMP11(lensend),inext,5500+isend,
3198 & mu(1,ivec_displ(irecv)+1),1,MPI_PRECOMP11(lenrecv),
3199 & iprev,5500+irecv,FG_COMM,status,IERR)
3200 c write (iout,*) "Gather PRECOMP11"
3202 call MPI_SENDRECV(Eug(1,1,ivec_displ(isend)+1),1,
3203 & MPI_PRECOMP12(lensend),inext,6600+isend,
3204 & Eug(1,1,ivec_displ(irecv)+1),1,MPI_PRECOMP12(lenrecv),
3205 & iprev,6600+irecv,FG_COMM,status,IERR)
3206 c write (iout,*) "Gather PRECOMP12"
3208 if (wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 .or. wcorr6.gt.0.0d0)
3210 call MPI_SENDRECV(ug2db1t(1,ivec_displ(isend)+1),1,
3211 & MPI_ROTAT2(lensend),inext,7700+isend,
3212 & ug2db1t(1,ivec_displ(irecv)+1),1,MPI_ROTAT2(lenrecv),
3213 & iprev,7700+irecv,FG_COMM,status,IERR)
3214 c write (iout,*) "Gather PRECOMP21"
3216 call MPI_SENDRECV(EUgC(1,1,ivec_displ(isend)+1),1,
3217 & MPI_PRECOMP22(lensend),inext,8800+isend,
3218 & EUgC(1,1,ivec_displ(irecv)+1),1,MPI_PRECOMP22(lenrecv),
3219 & iprev,8800+irecv,FG_COMM,status,IERR)
3220 c write (iout,*) "Gather PRECOMP22"
3222 call MPI_SENDRECV(Ug2DtEUgder(1,1,1,ivec_displ(isend)+1),1,
3223 & MPI_PRECOMP23(lensend),inext,9900+isend,
3224 & Ug2DtEUgder(1,1,1,ivec_displ(irecv)+1),1,
3225 & MPI_PRECOMP23(lenrecv),
3226 & iprev,9900+irecv,FG_COMM,status,IERR)
3227 c write (iout,*) "Gather PRECOMP23"
3232 if (irecv.lt.0) irecv=nfgtasks1-1
3235 time_gather=time_gather+MPI_Wtime()-time00
3238 c if (fg_rank.eq.0) then
3239 write (iout,*) "Arrays UG and UGDER"
3241 write (iout,'(i5,4f10.5,5x,4f10.5)') i,
3242 & ((ug(l,k,i),l=1,2),k=1,2),
3243 & ((ugder(l,k,i),l=1,2),k=1,2)
3245 write (iout,*) "Arrays UG2 and UG2DER"
3247 write (iout,'(i5,4f10.5,5x,4f10.5)') i,
3248 & ((ug2(l,k,i),l=1,2),k=1,2),
3249 & ((ug2der(l,k,i),l=1,2),k=1,2)
3251 write (iout,*) "Arrays OBROT OBROT2 OBROTDER and OBROT2DER"
3253 write (iout,'(i5,4f10.5,5x,4f10.5)') i,
3254 & (obrot(k,i),k=1,2),(obrot2(k,i),k=1,2),
3255 & (obrot_der(k,i),k=1,2),(obrot2_der(k,i),k=1,2)
3257 write (iout,*) "Arrays COSTAB SINTAB COSTAB2 and SINTAB2"
3259 write (iout,'(i5,4f10.5,5x,4f10.5)') i,
3260 & costab(i),sintab(i),costab2(i),sintab2(i)
3262 write (iout,*) "Array MUDER"
3264 write (iout,'(i5,2f10.5)') i,muder(1,i),muder(2,i)
3270 cd iti = itortyp(itype(i))
3273 cd write (iout,'(2f10.5,5x,2f10.5,5x,2f10.5)')
3274 cd & (EE(j,k,iti),k=1,2),(Ug(j,k,i),k=1,2),(EUg(j,k,i),k=1,2)
3279 C--------------------------------------------------------------------------
3280 subroutine eelec(ees,evdw1,eel_loc,eello_turn3,eello_turn4)
3282 C This subroutine calculates the average interaction energy and its gradient
3283 C in the virtual-bond vectors between non-adjacent peptide groups, based on
3284 C the potential described in Liwo et al., Protein Sci., 1993, 2, 1715.
3285 C The potential depends both on the distance of peptide-group centers and on
3286 C the orientation of the CA-CA virtual bonds.
3288 implicit real*8 (a-h,o-z)
3292 include 'DIMENSIONS'
3293 include 'COMMON.CONTROL'
3294 include 'COMMON.SETUP'
3295 include 'COMMON.IOUNITS'
3296 include 'COMMON.GEO'
3297 include 'COMMON.VAR'
3298 include 'COMMON.LOCAL'
3299 include 'COMMON.CHAIN'
3300 include 'COMMON.DERIV'
3301 include 'COMMON.INTERACT'
3302 include 'COMMON.CONTACTS'
3303 include 'COMMON.TORSION'
3304 include 'COMMON.VECTORS'
3305 include 'COMMON.FFIELD'
3306 include 'COMMON.TIME1'
3307 include 'COMMON.SPLITELE'
3308 dimension ggg(3),gggp(3),gggm(3),erij(3),dcosb(3),dcosg(3),
3309 & erder(3,3),uryg(3,3),urzg(3,3),vryg(3,3),vrzg(3,3)
3310 double precision acipa(2,2),agg(3,4),aggi(3,4),aggi1(3,4),
3311 & aggj(3,4),aggj1(3,4),a_temp(2,2),muij(4),gmuij(4)
3312 common /locel/ a_temp,agg,aggi,aggi1,aggj,aggj1,a22,a23,a32,a33,
3313 & dxi,dyi,dzi,dx_normi,dy_normi,dz_normi,xmedi,ymedi,zmedi,
3315 c 4/26/02 - AL scaling factor for 1,4 repulsive VDW interactions
3317 double precision scal_el /1.0d0/
3319 double precision scal_el /0.5d0/
3322 C 13-go grudnia roku pamietnego...
3323 double precision unmat(3,3) /1.0d0,0.0d0,0.0d0,
3324 & 0.0d0,1.0d0,0.0d0,
3325 & 0.0d0,0.0d0,1.0d0/
3326 cd write(iout,*) 'In EELEC'
3328 cd write(iout,*) 'Type',i
3329 cd write(iout,*) 'B1',B1(:,i)
3330 cd write(iout,*) 'B2',B2(:,i)
3331 cd write(iout,*) 'CC',CC(:,:,i)
3332 cd write(iout,*) 'DD',DD(:,:,i)
3333 cd write(iout,*) 'EE',EE(:,:,i)
3335 cd call check_vecgrad
3337 if (icheckgrad.eq.1) then
3339 fac=1.0d0/dsqrt(scalar(dc(1,i),dc(1,i)))
3341 dc_norm(k,i)=dc(k,i)*fac
3343 c write (iout,*) 'i',i,' fac',fac
3346 if (wel_loc.gt.0.0d0 .or. wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0
3347 & .or. wcorr6.gt.0.0d0 .or. wturn3.gt.0.0d0 .or.
3348 & wturn4.gt.0.0d0 .or. wturn6.gt.0.0d0) then
3349 c call vec_and_deriv
3355 time_mat=time_mat+MPI_Wtime()-time01
3359 cd write (iout,*) 'i=',i
3361 cd write (iout,'(i5,2f10.5)') k,uy(k,i),uz(k,i)
3364 cd write (iout,'(f10.5,2x,3f10.5,2x,3f10.5)')
3365 cd & uz(k,i),(uzgrad(k,l,1,i),l=1,3),(uzgrad(k,l,2,i),l=1,3)
3378 cd print '(a)','Enter EELEC'
3379 cd write (iout,*) 'iatel_s=',iatel_s,' iatel_e=',iatel_e
3381 gel_loc_loc(i)=0.0d0
3386 c 9/27/08 AL Split the interaction loop to ensure load balancing of turn terms
3388 C Loop over i,i+2 and i,i+3 pairs of the peptide groups
3390 C 14/01/2014 TURN3,TUNR4 does no go under periodic boundry condition
3391 do i=iturn3_start,iturn3_end
3393 C write(iout,*) "tu jest i",i
3394 if (itype(i).eq.ntyp1 .or. itype(i+1).eq.ntyp1
3395 C changes suggested by Ana to avoid out of bounds
3396 & .or.((i+4).gt.nres)
3398 C end of changes by Ana
3399 & .or. itype(i+2).eq.ntyp1
3400 & .or. itype(i+3).eq.ntyp1) cycle
3402 if(itype(i-1).eq.ntyp1)cycle
3405 if (itype(i+4).eq.ntyp1) cycle
3410 dx_normi=dc_norm(1,i)
3411 dy_normi=dc_norm(2,i)
3412 dz_normi=dc_norm(3,i)
3413 xmedi=c(1,i)+0.5d0*dxi
3414 ymedi=c(2,i)+0.5d0*dyi
3415 zmedi=c(3,i)+0.5d0*dzi
3416 xmedi=mod(xmedi,boxxsize)
3417 if (xmedi.lt.0) xmedi=xmedi+boxxsize
3418 ymedi=mod(ymedi,boxysize)
3419 if (ymedi.lt.0) ymedi=ymedi+boxysize
3420 zmedi=mod(zmedi,boxzsize)
3421 if (zmedi.lt.0) zmedi=zmedi+boxzsize
3423 call eelecij(i,i+2,ees,evdw1,eel_loc)
3424 if (wturn3.gt.0.0d0) call eturn3(i,eello_turn3)
3425 num_cont_hb(i)=num_conti
3427 do i=iturn4_start,iturn4_end
3429 if (itype(i).eq.ntyp1 .or. itype(i+1).eq.ntyp1
3430 C changes suggested by Ana to avoid out of bounds
3431 & .or.((i+5).gt.nres)
3433 C end of changes suggested by Ana
3434 & .or. itype(i+3).eq.ntyp1
3435 & .or. itype(i+4).eq.ntyp1
3436 & .or. itype(i+5).eq.ntyp1
3437 & .or. itype(i).eq.ntyp1
3438 & .or. itype(i-1).eq.ntyp1
3443 dx_normi=dc_norm(1,i)
3444 dy_normi=dc_norm(2,i)
3445 dz_normi=dc_norm(3,i)
3446 xmedi=c(1,i)+0.5d0*dxi
3447 ymedi=c(2,i)+0.5d0*dyi
3448 zmedi=c(3,i)+0.5d0*dzi
3449 C Return atom into box, boxxsize is size of box in x dimension
3451 c if (xmedi.gt.((0.5d0)*boxxsize)) xmedi=xmedi-boxxsize
3452 c if (xmedi.lt.((-0.5d0)*boxxsize)) xmedi=xmedi+boxxsize
3453 C Condition for being inside the proper box
3454 c if ((xmedi.gt.((0.5d0)*boxxsize)).or.
3455 c & (xmedi.lt.((-0.5d0)*boxxsize))) then
3459 c if (ymedi.gt.((0.5d0)*boxysize)) ymedi=ymedi-boxysize
3460 c if (ymedi.lt.((-0.5d0)*boxysize)) ymedi=ymedi+boxysize
3461 C Condition for being inside the proper box
3462 c if ((ymedi.gt.((0.5d0)*boxysize)).or.
3463 c & (ymedi.lt.((-0.5d0)*boxysize))) then
3467 c if (zmedi.gt.((0.5d0)*boxzsize)) zmedi=zmedi-boxzsize
3468 c if (zmedi.lt.((-0.5d0)*boxzsize)) zmedi=zmedi+boxzsize
3469 C Condition for being inside the proper box
3470 c if ((zmedi.gt.((0.5d0)*boxzsize)).or.
3471 c & (zmedi.lt.((-0.5d0)*boxzsize))) then
3474 xmedi=mod(xmedi,boxxsize)
3475 if (xmedi.lt.0) xmedi=xmedi+boxxsize
3476 ymedi=mod(ymedi,boxysize)
3477 if (ymedi.lt.0) ymedi=ymedi+boxysize
3478 zmedi=mod(zmedi,boxzsize)
3479 if (zmedi.lt.0) zmedi=zmedi+boxzsize
3481 num_conti=num_cont_hb(i)
3482 c write(iout,*) "JESTEM W PETLI"
3483 call eelecij(i,i+3,ees,evdw1,eel_loc)
3484 if (wturn4.gt.0.0d0 .and. itype(i+2).ne.ntyp1)
3485 & call eturn4(i,eello_turn4)
3486 num_cont_hb(i)=num_conti
3488 C Loop over all neighbouring boxes
3493 c Loop over all pairs of interacting peptide groups except i,i+2 and i,i+3
3496 do i=iatel_s,iatel_e
3499 if (itype(i).eq.ntyp1 .or. itype(i+1).eq.ntyp1
3500 C changes suggested by Ana to avoid out of bounds
3501 & .or.((i+2).gt.nres)
3503 C end of changes by Ana
3504 & .or. itype(i+2).eq.ntyp1
3505 & .or. itype(i-1).eq.ntyp1
3510 dx_normi=dc_norm(1,i)
3511 dy_normi=dc_norm(2,i)
3512 dz_normi=dc_norm(3,i)
3513 xmedi=c(1,i)+0.5d0*dxi
3514 ymedi=c(2,i)+0.5d0*dyi
3515 zmedi=c(3,i)+0.5d0*dzi
3516 xmedi=mod(xmedi,boxxsize)
3517 if (xmedi.lt.0) xmedi=xmedi+boxxsize
3518 ymedi=mod(ymedi,boxysize)
3519 if (ymedi.lt.0) ymedi=ymedi+boxysize
3520 zmedi=mod(zmedi,boxzsize)
3521 if (zmedi.lt.0) zmedi=zmedi+boxzsize
3522 C xmedi=xmedi+xshift*boxxsize
3523 C ymedi=ymedi+yshift*boxysize
3524 C zmedi=zmedi+zshift*boxzsize
3526 C Return tom into box, boxxsize is size of box in x dimension
3528 c if (xmedi.gt.((xshift+0.5d0)*boxxsize)) xmedi=xmedi-boxxsize
3529 c if (xmedi.lt.((xshift-0.5d0)*boxxsize)) xmedi=xmedi+boxxsize
3530 C Condition for being inside the proper box
3531 c if ((xmedi.gt.((xshift+0.5d0)*boxxsize)).or.
3532 c & (xmedi.lt.((xshift-0.5d0)*boxxsize))) then
3536 c if (ymedi.gt.((yshift+0.5d0)*boxysize)) ymedi=ymedi-boxysize
3537 c if (ymedi.lt.((yshift-0.5d0)*boxysize)) ymedi=ymedi+boxysize
3538 C Condition for being inside the proper box
3539 c if ((ymedi.gt.((yshift+0.5d0)*boxysize)).or.
3540 c & (ymedi.lt.((yshift-0.5d0)*boxysize))) then
3544 c if (zmedi.gt.((zshift+0.5d0)*boxzsize)) zmedi=zmedi-boxzsize
3545 c if (zmedi.lt.((zshift-0.5d0)*boxzsize)) zmedi=zmedi+boxzsize
3546 cC Condition for being inside the proper box
3547 c if ((zmedi.gt.((zshift+0.5d0)*boxzsize)).or.
3548 c & (zmedi.lt.((zshift-0.5d0)*boxzsize))) then
3552 c write (iout,*) 'i',i,' ielstart',ielstart(i),' ielend',ielend(i)
3553 num_conti=num_cont_hb(i)
3555 do j=ielstart(i),ielend(i)
3557 C write (iout,*) i,j
3559 if (itype(j).eq.ntyp1.or. itype(j+1).eq.ntyp1
3560 C changes suggested by Ana to avoid out of bounds
3561 & .or.((j+2).gt.nres)
3563 C end of changes by Ana
3564 & .or.itype(j+2).eq.ntyp1
3565 & .or.itype(j-1).eq.ntyp1
3567 call eelecij(i,j,ees,evdw1,eel_loc)
3569 num_cont_hb(i)=num_conti
3575 c write (iout,*) "Number of loop steps in EELEC:",ind
3577 cd write (iout,'(i3,3f10.5,5x,3f10.5)')
3578 cd & i,(gel_loc(k,i),k=1,3),gel_loc_loc(i)
3580 c 12/7/99 Adam eello_turn3 will be considered as a separate energy term
3581 ccc eel_loc=eel_loc+eello_turn3
3582 cd print *,"Processor",fg_rank," t_eelecij",t_eelecij
3585 C-------------------------------------------------------------------------------
3586 subroutine eelecij(i,j,ees,evdw1,eel_loc)
3587 implicit real*8 (a-h,o-z)
3588 include 'DIMENSIONS'
3592 include 'COMMON.CONTROL'
3593 include 'COMMON.IOUNITS'
3594 include 'COMMON.GEO'
3595 include 'COMMON.VAR'
3596 include 'COMMON.LOCAL'
3597 include 'COMMON.CHAIN'
3598 include 'COMMON.DERIV'
3599 include 'COMMON.INTERACT'
3600 include 'COMMON.CONTACTS'
3601 include 'COMMON.TORSION'
3602 include 'COMMON.VECTORS'
3603 include 'COMMON.FFIELD'
3604 include 'COMMON.TIME1'
3605 include 'COMMON.SPLITELE'
3606 include 'COMMON.SHIELD'
3607 dimension ggg(3),gggp(3),gggm(3),erij(3),dcosb(3),dcosg(3),
3608 & erder(3,3),uryg(3,3),urzg(3,3),vryg(3,3),vrzg(3,3)
3609 double precision acipa(2,2),agg(3,4),aggi(3,4),aggi1(3,4),
3610 & aggj(3,4),aggj1(3,4),a_temp(2,2),muij(4),gmuij1(4),gmuji1(4),
3611 & gmuij2(4),gmuji2(4)
3612 common /locel/ a_temp,agg,aggi,aggi1,aggj,aggj1,a22,a23,a32,a33,
3613 & dxi,dyi,dzi,dx_normi,dy_normi,dz_normi,xmedi,ymedi,zmedi,
3615 c 4/26/02 - AL scaling factor for 1,4 repulsive VDW interactions
3617 double precision scal_el /1.0d0/
3619 double precision scal_el /0.5d0/
3622 C 13-go grudnia roku pamietnego...
3623 double precision unmat(3,3) /1.0d0,0.0d0,0.0d0,
3624 & 0.0d0,1.0d0,0.0d0,
3625 & 0.0d0,0.0d0,1.0d0/
3626 c time00=MPI_Wtime()
3627 cd write (iout,*) "eelecij",i,j
3631 if (j.eq.i+2 .and. itelj.eq.2) iteli=2
3632 aaa=app(iteli,itelj)
3633 bbb=bpp(iteli,itelj)
3634 ael6i=ael6(iteli,itelj)
3635 ael3i=ael3(iteli,itelj)
3639 dx_normj=dc_norm(1,j)
3640 dy_normj=dc_norm(2,j)
3641 dz_normj=dc_norm(3,j)
3642 C xj=c(1,j)+0.5D0*dxj-xmedi
3643 C yj=c(2,j)+0.5D0*dyj-ymedi
3644 C zj=c(3,j)+0.5D0*dzj-zmedi
3649 if (xj.lt.0) xj=xj+boxxsize
3651 if (yj.lt.0) yj=yj+boxysize
3653 if (zj.lt.0) zj=zj+boxzsize
3654 if ((zj.lt.0).or.(xj.lt.0).or.(yj.lt.0)) write (*,*) "CHUJ"
3655 dist_init=(xj-xmedi)**2+(yj-ymedi)**2+(zj-zmedi)**2
3663 xj=xj_safe+xshift*boxxsize
3664 yj=yj_safe+yshift*boxysize
3665 zj=zj_safe+zshift*boxzsize
3666 dist_temp=(xj-xmedi)**2+(yj-ymedi)**2+(zj-zmedi)**2
3667 if(dist_temp.lt.dist_init) then
3677 if (isubchap.eq.1) then
3686 C if ((i+3).lt.j) then !this condition keeps for turn3 and turn4 not subject to PBC
3688 c if (xj.gt.((0.5d0)*boxxsize)) xj=xj-boxxsize
3689 c if (xj.lt.((-0.5d0)*boxxsize)) xj=xj+boxxsize
3690 C Condition for being inside the proper box
3691 c if ((xj.gt.((0.5d0)*boxxsize)).or.
3692 c & (xj.lt.((-0.5d0)*boxxsize))) then
3696 c if (yj.gt.((0.5d0)*boxysize)) yj=yj-boxysize
3697 c if (yj.lt.((-0.5d0)*boxysize)) yj=yj+boxysize
3698 C Condition for being inside the proper box
3699 c if ((yj.gt.((0.5d0)*boxysize)).or.
3700 c & (yj.lt.((-0.5d0)*boxysize))) then
3704 c if (zj.gt.((0.5d0)*boxzsize)) zj=zj-boxzsize
3705 c if (zj.lt.((-0.5d0)*boxzsize)) zj=zj+boxzsize
3706 C Condition for being inside the proper box
3707 c if ((zj.gt.((0.5d0)*boxzsize)).or.
3708 c & (zj.lt.((-0.5d0)*boxzsize))) then
3711 C endif !endPBC condintion
3715 rij=xj*xj+yj*yj+zj*zj
3717 sss=sscale(sqrt(rij))
3718 sssgrad=sscagrad(sqrt(rij))
3719 c if (sss.gt.0.0d0) then
3725 cosa=dx_normi*dx_normj+dy_normi*dy_normj+dz_normi*dz_normj
3726 cosb=(xj*dx_normi+yj*dy_normi+zj*dz_normi)*rmij
3727 cosg=(xj*dx_normj+yj*dy_normj+zj*dz_normj)*rmij
3728 fac=cosa-3.0D0*cosb*cosg
3730 c 4/26/02 - AL scaling down 1,4 repulsive VDW interactions
3731 if (j.eq.i+2) ev1=scal_el*ev1
3736 el1=fac3*(4.0D0+fac*fac-3.0D0*(cosb*cosb+cosg*cosg))
3740 C 12/26/95 - for the evaluation of multi-body H-bonding interactions
3741 ees0ij=4.0D0+fac*fac-3.0D0*(cosb*cosb+cosg*cosg)
3742 if (shield_mode.gt.0) then
3745 el1=el1*fac_shield(i)*fac_shield(j)
3746 el2=el2*fac_shield(i)*fac_shield(j)
3755 evdw1=evdw1+evdwij*sss
3756 cd write(iout,'(2(2i3,2x),7(1pd12.4)/2(3(1pd12.4),5x)/)')
3757 cd & iteli,i,itelj,j,aaa,bbb,ael6i,ael3i,
3758 cd & 1.0D0/dsqrt(rrmij),evdwij,eesij,
3759 cd & xmedi,ymedi,zmedi,xj,yj,zj
3761 if (energy_dec) then
3762 write (iout,'(a6,2i5,0pf7.3,2i5,2e11.3)')
3764 &,iteli,itelj,aaa,evdw1
3765 write (iout,'(a6,2i5,0pf7.3)') 'ees',i,j,eesij
3769 C Calculate contributions to the Cartesian gradient.
3772 facvdw=-6*rrmij*(ev1+evdwij)*sss
3773 facel=-3*rrmij*(el1+eesij)
3780 * Radial derivatives. First process both termini of the fragment (i,j)
3785 if ((fac_shield(i).gt.0).and.(fac_shield(j).gt.0).and.
3786 & (shield_mode.gt.0)) then
3788 do ilist=1,ishield_list(i)
3789 iresshield=shield_list(ilist,i)
3791 rlocshield=grad_shield_side(k,ilist,i)*eesij/fac_shield(i)
3792 gshieldx(k,iresshield)=gshieldx(k,iresshield)+
3794 & +grad_shield_loc(k,ilist,i)*eesij/fac_shield(i)
3795 gshieldc(k,iresshield-1)=gshieldc(k,iresshield-1)+rlocshield
3796 C gshieldc_loc(k,iresshield)=gshieldc_loc(k,iresshield)
3797 C & +grad_shield_loc(k,ilist,i)*eesij/fac_shield(i)
3798 C if (iresshield.gt.i) then
3799 C do ishi=i+1,iresshield-1
3800 C gshieldc(k,ishi)=gshieldc(k,ishi)+rlocshield
3801 C & +grad_shield_loc(k,ilist,i)*eesij/fac_shield(i)
3805 C do ishi=iresshield,i
3806 C gshieldc(k,ishi)=gshieldc(k,ishi)-rlocshield
3807 C & -grad_shield_loc(k,ilist,i)*eesij/fac_shield(i)
3813 do ilist=1,ishield_list(j)
3814 iresshield=shield_list(ilist,j)
3816 rlocshield=grad_shield_side(k,ilist,j)*eesij/fac_shield(j)
3817 gshieldx(k,iresshield)=gshieldx(k,iresshield)+
3819 & +grad_shield_loc(k,ilist,j)*eesij/fac_shield(j)
3820 gshieldc(k,iresshield-1)=gshieldc(k,iresshield-1)+rlocshield
3822 C & +grad_shield_loc(k,ilist,j)*eesij/fac_shield(j)
3823 C gshieldc_loc(k,iresshield)=gshieldc_loc(k,iresshield)
3824 C & +grad_shield_loc(k,ilist,j)*eesij/fac_shield(j)
3825 C if (iresshield.gt.j) then
3826 C do ishi=j+1,iresshield-1
3827 C gshieldc(k,ishi)=gshieldc(k,ishi)+rlocshield
3828 C & +grad_shield_loc(k,ilist,j)*eesij/fac_shield(j)
3832 C do ishi=iresshield,j
3833 C gshieldc(k,ishi)=gshieldc(k,ishi)-rlocshield
3834 C & -grad_shield_loc(k,ilist,j)*eesij/fac_shield(j)
3841 gshieldc(k,i)=gshieldc(k,i)+
3842 & grad_shield(k,i)*eesij/fac_shield(i)
3843 gshieldc(k,j)=gshieldc(k,j)+
3844 & grad_shield(k,j)*eesij/fac_shield(j)
3845 gshieldc(k,i-1)=gshieldc(k,i-1)+
3846 & grad_shield(k,i)*eesij/fac_shield(i)
3847 gshieldc(k,j-1)=gshieldc(k,j-1)+
3848 & grad_shield(k,j)*eesij/fac_shield(j)
3853 c ghalf=0.5D0*ggg(k)
3854 c gelc(k,i)=gelc(k,i)+ghalf
3855 c gelc(k,j)=gelc(k,j)+ghalf
3857 c 9/28/08 AL Gradient compotents will be summed only at the end
3858 C print *,"before", gelc_long(1,i), gelc_long(1,j)
3860 gelc_long(k,j)=gelc_long(k,j)+ggg(k)
3861 C & +grad_shield(k,j)*eesij/fac_shield(j)
3862 gelc_long(k,i)=gelc_long(k,i)-ggg(k)
3863 C & +grad_shield(k,i)*eesij/fac_shield(i)
3864 C gelc_long(k,i-1)=gelc_long(k,i-1)
3865 C & +grad_shield(k,i)*eesij/fac_shield(i)
3866 C gelc_long(k,j-1)=gelc_long(k,j-1)
3867 C & +grad_shield(k,j)*eesij/fac_shield(j)
3869 C print *,"bafter", gelc_long(1,i), gelc_long(1,j)
3872 * Loop over residues i+1 thru j-1.
3876 cgrad gelc(l,k)=gelc(l,k)+ggg(l)
3879 if (sss.gt.0.0) then
3880 ggg(1)=facvdw*xj+sssgrad*rmij*evdwij*xj
3881 ggg(2)=facvdw*yj+sssgrad*rmij*evdwij*yj
3882 ggg(3)=facvdw*zj+sssgrad*rmij*evdwij*zj
3889 c ghalf=0.5D0*ggg(k)
3890 c gvdwpp(k,i)=gvdwpp(k,i)+ghalf
3891 c gvdwpp(k,j)=gvdwpp(k,j)+ghalf
3893 c 9/28/08 AL Gradient compotents will be summed only at the end
3895 gvdwpp(k,j)=gvdwpp(k,j)+ggg(k)
3896 gvdwpp(k,i)=gvdwpp(k,i)-ggg(k)
3899 * Loop over residues i+1 thru j-1.
3903 cgrad gvdwpp(l,k)=gvdwpp(l,k)+ggg(l)
3908 facvdw=(ev1+evdwij)*sss
3911 fac=-3*rrmij*(facvdw+facvdw+facel)
3916 * Radial derivatives. First process both termini of the fragment (i,j)
3919 C+eesij*grad_shield(1,i)+eesij*grad_shield(1,j)
3921 C+eesij*grad_shield(2,i)+eesij*grad_shield(2,j)
3923 C+eesij*grad_shield(3,i)+eesij*grad_shield(3,j)
3925 c ghalf=0.5D0*ggg(k)
3926 c gelc(k,i)=gelc(k,i)+ghalf
3927 c gelc(k,j)=gelc(k,j)+ghalf
3929 c 9/28/08 AL Gradient compotents will be summed only at the end
3931 gelc_long(k,j)=gelc(k,j)+ggg(k)
3932 gelc_long(k,i)=gelc(k,i)-ggg(k)
3935 * Loop over residues i+1 thru j-1.
3939 cgrad gelc(l,k)=gelc(l,k)+ggg(l)
3942 c 9/28/08 AL Gradient compotents will be summed only at the end
3943 ggg(1)=facvdw*xj+sssgrad*rmij*evdwij*xj
3944 ggg(2)=facvdw*yj+sssgrad*rmij*evdwij*yj
3945 ggg(3)=facvdw*zj+sssgrad*rmij*evdwij*zj
3947 gvdwpp(k,j)=gvdwpp(k,j)+ggg(k)
3948 gvdwpp(k,i)=gvdwpp(k,i)-ggg(k)
3954 ecosa=2.0D0*fac3*fac1+fac4
3957 ecosb=(fac3*(fac1*cosg+cosb)+cosg*fac4)
3958 ecosg=(fac3*(fac1*cosb+cosg)+cosb*fac4)
3960 dcosb(k)=rmij*(dc_norm(k,i)-erij(k)*cosb)
3961 dcosg(k)=rmij*(dc_norm(k,j)-erij(k)*cosg)
3963 cd print '(2i3,2(3(1pd14.5),3x))',i,j,(dcosb(k),k=1,3),
3964 cd & (dcosg(k),k=1,3)
3966 ggg(k)=(ecosb*dcosb(k)+ecosg*dcosg(k))*
3967 & fac_shield(i)*fac_shield(j)
3970 c ghalf=0.5D0*ggg(k)
3971 c gelc(k,i)=gelc(k,i)+ghalf
3972 c & +(ecosa*(dc_norm(k,j)-cosa*dc_norm(k,i))
3973 c & + ecosb*(erij(k)-cosb*dc_norm(k,i)))*vbld_inv(i+1)
3974 c gelc(k,j)=gelc(k,j)+ghalf
3975 c & +(ecosa*(dc_norm(k,i)-cosa*dc_norm(k,j))
3976 c & + ecosg*(erij(k)-cosg*dc_norm(k,j)))*vbld_inv(j+1)
3980 cgrad gelc(l,k)=gelc(l,k)+ggg(l)
3983 C print *,"before22", gelc_long(1,i), gelc_long(1,j)
3986 & +((ecosa*(dc_norm(k,j)-cosa*dc_norm(k,i))
3987 & + ecosb*(erij(k)-cosb*dc_norm(k,i)))*vbld_inv(i+1))
3988 & *fac_shield(i)*fac_shield(j)
3990 & +((ecosa*(dc_norm(k,i)-cosa*dc_norm(k,j))
3991 & + ecosg*(erij(k)-cosg*dc_norm(k,j)))*vbld_inv(j+1))
3992 & *fac_shield(i)*fac_shield(j)
3993 gelc_long(k,j)=gelc_long(k,j)+ggg(k)
3994 gelc_long(k,i)=gelc_long(k,i)-ggg(k)
3996 C print *,"before33", gelc_long(1,i), gelc_long(1,j)
4000 IF (wel_loc.gt.0.0d0 .or. wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0
4001 & .or. wcorr6.gt.0.0d0 .or. wturn3.gt.0.0d0
4002 & .or. wturn4.gt.0.0d0 .or. wturn6.gt.0.0d0) THEN
4004 C 9/25/99 Mixed third-order local-electrostatic terms. The local-interaction
4005 C energy of a peptide unit is assumed in the form of a second-order
4006 C Fourier series in the angles lambda1 and lambda2 (see Nishikawa et al.
4007 C Macromolecules, 1974, 7, 797-806 for definition). This correlation terms
4008 C are computed for EVERY pair of non-contiguous peptide groups.
4011 if (j.lt.nres-1) then
4023 muij(kkk)=mu(k,i)*mu(l,j)
4024 c write(iout,*) 'mumu=', mu(k,i),mu(l,j),i,j,k,l
4026 gmuij1(kkk)=gtb1(k,i+1)*mu(l,j)
4027 c write(iout,*) 'k=',k,i,gtb1(k,i+1),gtb1(k,i+1)*mu(l,j)
4028 gmuij2(kkk)=gUb2(k,i)*mu(l,j)
4029 gmuji1(kkk)=mu(k,i)*gtb1(l,j+1)
4030 c write(iout,*) 'l=',l,j,gtb1(l,j+1),gtb1(l,j+1)*mu(k,i)
4031 gmuji2(kkk)=mu(k,i)*gUb2(l,j)
4035 cd write (iout,*) 'EELEC: i',i,' j',j
4036 cd write (iout,*) 'j',j,' j1',j1,' j2',j2
4037 cd write(iout,*) 'muij',muij
4038 ury=scalar(uy(1,i),erij)
4039 urz=scalar(uz(1,i),erij)
4040 vry=scalar(uy(1,j),erij)
4041 vrz=scalar(uz(1,j),erij)
4042 a22=scalar(uy(1,i),uy(1,j))-3*ury*vry
4043 a23=scalar(uy(1,i),uz(1,j))-3*ury*vrz
4044 a32=scalar(uz(1,i),uy(1,j))-3*urz*vry
4045 a33=scalar(uz(1,i),uz(1,j))-3*urz*vrz
4046 fac=dsqrt(-ael6i)*r3ij
4051 cd write (iout,'(4i5,4f10.5)')
4052 cd & i,itortyp(itype(i)),j,itortyp(itype(j)),a22,a23,a32,a33
4053 cd write (iout,'(6f10.5)') (muij(k),k=1,4),fac,eel_loc_ij
4054 cd write (iout,'(2(3f10.5,5x)/2(3f10.5,5x))') uy(:,i),uz(:,i),
4055 cd & uy(:,j),uz(:,j)
4056 cd write (iout,'(4f10.5)')
4057 cd & scalar(uy(1,i),uy(1,j)),scalar(uy(1,i),uz(1,j)),
4058 cd & scalar(uz(1,i),uy(1,j)),scalar(uz(1,i),uz(1,j))
4059 cd write (iout,'(4f10.5)') ury,urz,vry,vrz
4060 cd write (iout,'(9f10.5/)')
4061 cd & fac22,a22,fac23,a23,fac32,a32,fac33,a33,eel_loc_ij
4062 C Derivatives of the elements of A in virtual-bond vectors
4063 call unormderiv(erij(1),unmat(1,1),rmij,erder(1,1))
4065 uryg(k,1)=scalar(erder(1,k),uy(1,i))
4066 uryg(k,2)=scalar(uygrad(1,k,1,i),erij(1))
4067 uryg(k,3)=scalar(uygrad(1,k,2,i),erij(1))
4068 urzg(k,1)=scalar(erder(1,k),uz(1,i))
4069 urzg(k,2)=scalar(uzgrad(1,k,1,i),erij(1))
4070 urzg(k,3)=scalar(uzgrad(1,k,2,i),erij(1))
4071 vryg(k,1)=scalar(erder(1,k),uy(1,j))
4072 vryg(k,2)=scalar(uygrad(1,k,1,j),erij(1))
4073 vryg(k,3)=scalar(uygrad(1,k,2,j),erij(1))
4074 vrzg(k,1)=scalar(erder(1,k),uz(1,j))
4075 vrzg(k,2)=scalar(uzgrad(1,k,1,j),erij(1))
4076 vrzg(k,3)=scalar(uzgrad(1,k,2,j),erij(1))
4078 C Compute radial contributions to the gradient
4096 C Add the contributions coming from er
4099 agg(k,1)=agg(k,1)+fac3*(uryg(k,1)*vry+vryg(k,1)*ury)
4100 agg(k,2)=agg(k,2)+fac3*(uryg(k,1)*vrz+vrzg(k,1)*ury)
4101 agg(k,3)=agg(k,3)+fac3*(urzg(k,1)*vry+vryg(k,1)*urz)
4102 agg(k,4)=agg(k,4)+fac3*(urzg(k,1)*vrz+vrzg(k,1)*urz)
4105 C Derivatives in DC(i)
4106 cgrad ghalf1=0.5d0*agg(k,1)
4107 cgrad ghalf2=0.5d0*agg(k,2)
4108 cgrad ghalf3=0.5d0*agg(k,3)
4109 cgrad ghalf4=0.5d0*agg(k,4)
4110 aggi(k,1)=fac*(scalar(uygrad(1,k,1,i),uy(1,j))
4111 & -3.0d0*uryg(k,2)*vry)!+ghalf1
4112 aggi(k,2)=fac*(scalar(uygrad(1,k,1,i),uz(1,j))
4113 & -3.0d0*uryg(k,2)*vrz)!+ghalf2
4114 aggi(k,3)=fac*(scalar(uzgrad(1,k,1,i),uy(1,j))
4115 & -3.0d0*urzg(k,2)*vry)!+ghalf3
4116 aggi(k,4)=fac*(scalar(uzgrad(1,k,1,i),uz(1,j))
4117 & -3.0d0*urzg(k,2)*vrz)!+ghalf4
4118 C Derivatives in DC(i+1)
4119 aggi1(k,1)=fac*(scalar(uygrad(1,k,2,i),uy(1,j))
4120 & -3.0d0*uryg(k,3)*vry)!+agg(k,1)
4121 aggi1(k,2)=fac*(scalar(uygrad(1,k,2,i),uz(1,j))
4122 & -3.0d0*uryg(k,3)*vrz)!+agg(k,2)
4123 aggi1(k,3)=fac*(scalar(uzgrad(1,k,2,i),uy(1,j))
4124 & -3.0d0*urzg(k,3)*vry)!+agg(k,3)
4125 aggi1(k,4)=fac*(scalar(uzgrad(1,k,2,i),uz(1,j))
4126 & -3.0d0*urzg(k,3)*vrz)!+agg(k,4)
4127 C Derivatives in DC(j)
4128 aggj(k,1)=fac*(scalar(uygrad(1,k,1,j),uy(1,i))
4129 & -3.0d0*vryg(k,2)*ury)!+ghalf1
4130 aggj(k,2)=fac*(scalar(uzgrad(1,k,1,j),uy(1,i))
4131 & -3.0d0*vrzg(k,2)*ury)!+ghalf2
4132 aggj(k,3)=fac*(scalar(uygrad(1,k,1,j),uz(1,i))
4133 & -3.0d0*vryg(k,2)*urz)!+ghalf3
4134 aggj(k,4)=fac*(scalar(uzgrad(1,k,1,j),uz(1,i))
4135 & -3.0d0*vrzg(k,2)*urz)!+ghalf4
4136 C Derivatives in DC(j+1) or DC(nres-1)
4137 aggj1(k,1)=fac*(scalar(uygrad(1,k,2,j),uy(1,i))
4138 & -3.0d0*vryg(k,3)*ury)
4139 aggj1(k,2)=fac*(scalar(uzgrad(1,k,2,j),uy(1,i))
4140 & -3.0d0*vrzg(k,3)*ury)
4141 aggj1(k,3)=fac*(scalar(uygrad(1,k,2,j),uz(1,i))
4142 & -3.0d0*vryg(k,3)*urz)
4143 aggj1(k,4)=fac*(scalar(uzgrad(1,k,2,j),uz(1,i))
4144 & -3.0d0*vrzg(k,3)*urz)
4145 cgrad if (j.eq.nres-1 .and. i.lt.j-2) then
4147 cgrad aggj1(k,l)=aggj1(k,l)+agg(k,l)
4160 aggi(k,l)=-aggi(k,l)
4161 aggi1(k,l)=-aggi1(k,l)
4162 aggj(k,l)=-aggj(k,l)
4163 aggj1(k,l)=-aggj1(k,l)
4166 if (j.lt.nres-1) then
4172 aggi(k,l)=-aggi(k,l)
4173 aggi1(k,l)=-aggi1(k,l)
4174 aggj(k,l)=-aggj(k,l)
4175 aggj1(k,l)=-aggj1(k,l)
4186 aggi(k,l)=-aggi(k,l)
4187 aggi1(k,l)=-aggi1(k,l)
4188 aggj(k,l)=-aggj(k,l)
4189 aggj1(k,l)=-aggj1(k,l)
4194 IF (wel_loc.gt.0.0d0) THEN
4195 C Contribution to the local-electrostatic energy coming from the i-j pair
4196 eel_loc_ij=a22*muij(1)+a23*muij(2)+a32*muij(3)
4198 c write (iout,*) 'i',i,' j',j,itype(i),itype(j),
4199 c & ' eel_loc_ij',eel_loc_ij
4200 C write(iout,*) 'muije=',i,j,muij(1),muij(2),muij(3),muij(4)
4201 C Calculate patrial derivative for theta angle
4203 geel_loc_ij=a22*gmuij1(1)
4207 c write(iout,*) "derivative over thatai"
4208 c write(iout,*) a22*gmuij1(1), a23*gmuij1(2) ,a32*gmuij1(3),
4210 gloc(nphi+i,icg)=gloc(nphi+i,icg)+
4211 & geel_loc_ij*wel_loc
4212 c write(iout,*) "derivative over thatai-1"
4213 c write(iout,*) a22*gmuij2(1), a23*gmuij2(2) ,a32*gmuij2(3),
4220 gloc(nphi+i-1,icg)=gloc(nphi+i-1,icg)+
4221 & geel_loc_ij*wel_loc
4222 c Derivative over j residue
4223 geel_loc_ji=a22*gmuji1(1)
4227 c write(iout,*) "derivative over thataj"
4228 c write(iout,*) a22*gmuji1(1), a23*gmuji1(2) ,a32*gmuji1(3),
4231 gloc(nphi+j,icg)=gloc(nphi+j,icg)+
4232 & geel_loc_ji*wel_loc
4238 c write(iout,*) "derivative over thataj-1"
4239 c write(iout,*) a22*gmuji2(1), a23*gmuji2(2) ,a32*gmuji2(3),
4241 gloc(nphi+j-1,icg)=gloc(nphi+j-1,icg)+
4242 & geel_loc_ji*wel_loc
4244 cd write (iout,*) 'i',i,' j',j,' eel_loc_ij',eel_loc_ij
4246 if (energy_dec) write (iout,'(a6,2i5,0pf7.3)')
4247 & 'eelloc',i,j,eel_loc_ij
4248 c if (eel_loc_ij.ne.0)
4249 c & write (iout,'(a4,2i4,8f9.5)')'chuj',
4250 c & i,j,a22,muij(1),a23,muij(2),a32,muij(3),a33,muij(4)
4252 eel_loc=eel_loc+eel_loc_ij
4253 C Partial derivatives in virtual-bond dihedral angles gamma
4255 & gel_loc_loc(i-1)=gel_loc_loc(i-1)+
4256 & a22*muder(1,i)*mu(1,j)+a23*muder(1,i)*mu(2,j)
4257 & +a32*muder(2,i)*mu(1,j)+a33*muder(2,i)*mu(2,j)
4258 gel_loc_loc(j-1)=gel_loc_loc(j-1)+
4259 & a22*mu(1,i)*muder(1,j)+a23*mu(1,i)*muder(2,j)
4260 & +a32*mu(2,i)*muder(1,j)+a33*mu(2,i)*muder(2,j)
4261 C Derivatives of eello in DC(i+1) thru DC(j-1) or DC(nres-2)
4263 ggg(l)=agg(l,1)*muij(1)+
4264 & agg(l,2)*muij(2)+agg(l,3)*muij(3)+agg(l,4)*muij(4)
4265 gel_loc_long(l,j)=gel_loc_long(l,j)+ggg(l)
4266 gel_loc_long(l,i)=gel_loc_long(l,i)-ggg(l)
4267 cgrad ghalf=0.5d0*ggg(l)
4268 cgrad gel_loc(l,i)=gel_loc(l,i)+ghalf
4269 cgrad gel_loc(l,j)=gel_loc(l,j)+ghalf
4273 cgrad gel_loc(l,k)=gel_loc(l,k)+ggg(l)
4276 C Remaining derivatives of eello
4278 gel_loc(l,i)=gel_loc(l,i)+(aggi(l,1)*muij(1)+
4279 & aggi(l,2)*muij(2)+aggi(l,3)*muij(3)+aggi(l,4)*muij(4))
4280 gel_loc(l,i+1)=gel_loc(l,i+1)+(aggi1(l,1)*muij(1)+
4281 & aggi1(l,2)*muij(2)+aggi1(l,3)*muij(3)+aggi1(l,4)*muij(4))
4282 gel_loc(l,j)=gel_loc(l,j)+(aggj(l,1)*muij(1)+
4283 & aggj(l,2)*muij(2)+aggj(l,3)*muij(3)+aggj(l,4)*muij(4))
4284 gel_loc(l,j1)=gel_loc(l,j1)+(aggj1(l,1)*muij(1)+
4285 & aggj1(l,2)*muij(2)+aggj1(l,3)*muij(3)+aggj1(l,4)*muij(4))
4288 C Change 12/26/95 to calculate four-body contributions to H-bonding energy
4289 c if (j.gt.i+1 .and. num_conti.le.maxconts) then
4290 if (wcorr+wcorr4+wcorr5+wcorr6.gt.0.0d0
4291 & .and. num_conti.le.maxconts) then
4292 c write (iout,*) i,j," entered corr"
4294 C Calculate the contact function. The ith column of the array JCONT will
4295 C contain the numbers of atoms that make contacts with the atom I (of numbers
4296 C greater than I). The arrays FACONT and GACONT will contain the values of
4297 C the contact function and its derivative.
4298 c r0ij=1.02D0*rpp(iteli,itelj)
4299 c r0ij=1.11D0*rpp(iteli,itelj)
4300 r0ij=2.20D0*rpp(iteli,itelj)
4301 c r0ij=1.55D0*rpp(iteli,itelj)
4302 call gcont(rij,r0ij,1.0D0,0.2d0*r0ij,fcont,fprimcont)
4303 if (fcont.gt.0.0D0) then
4304 num_conti=num_conti+1
4305 if (num_conti.gt.maxconts) then
4306 write (iout,*) 'WARNING - max. # of contacts exceeded;',
4307 & ' will skip next contacts for this conf.'
4309 jcont_hb(num_conti,i)=j
4310 cd write (iout,*) "i",i," j",j," num_conti",num_conti,
4311 cd & " jcont_hb",jcont_hb(num_conti,i)
4312 IF (wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 .or.
4313 & wcorr6.gt.0.0d0 .or. wturn6.gt.0.0d0) THEN
4314 C 9/30/99 (AL) - store components necessary to evaluate higher-order loc-el
4316 d_cont(num_conti,i)=rij
4317 cd write (2,'(3e15.5)') rij,r0ij+0.2d0*r0ij,rij
4318 C --- Electrostatic-interaction matrix ---
4319 a_chuj(1,1,num_conti,i)=a22
4320 a_chuj(1,2,num_conti,i)=a23
4321 a_chuj(2,1,num_conti,i)=a32
4322 a_chuj(2,2,num_conti,i)=a33
4323 C --- Gradient of rij
4325 grij_hb_cont(kkk,num_conti,i)=erij(kkk)
4332 a_chuj_der(k,l,m,1,num_conti,i)=agg(m,kkll)
4333 a_chuj_der(k,l,m,2,num_conti,i)=aggi(m,kkll)
4334 a_chuj_der(k,l,m,3,num_conti,i)=aggi1(m,kkll)
4335 a_chuj_der(k,l,m,4,num_conti,i)=aggj(m,kkll)
4336 a_chuj_der(k,l,m,5,num_conti,i)=aggj1(m,kkll)
4341 IF (wcorr4.eq.0.0d0 .and. wcorr.gt.0.0d0) THEN
4342 C Calculate contact energies
4344 wij=cosa-3.0D0*cosb*cosg
4347 c fac3=dsqrt(-ael6i)/r0ij**3
4348 fac3=dsqrt(-ael6i)*r3ij
4349 c ees0pij=dsqrt(4.0D0+cosa4+wij*wij-3.0D0*cosbg1*cosbg1)
4350 ees0tmp=4.0D0+cosa4+wij*wij-3.0D0*cosbg1*cosbg1
4351 if (ees0tmp.gt.0) then
4352 ees0pij=dsqrt(ees0tmp)
4356 c ees0mij=dsqrt(4.0D0-cosa4+wij*wij-3.0D0*cosbg2*cosbg2)
4357 ees0tmp=4.0D0-cosa4+wij*wij-3.0D0*cosbg2*cosbg2
4358 if (ees0tmp.gt.0) then
4359 ees0mij=dsqrt(ees0tmp)
4364 ees0p(num_conti,i)=0.5D0*fac3*(ees0pij+ees0mij)
4365 ees0m(num_conti,i)=0.5D0*fac3*(ees0pij-ees0mij)
4366 C Diagnostics. Comment out or remove after debugging!
4367 c ees0p(num_conti,i)=0.5D0*fac3*ees0pij
4368 c ees0m(num_conti,i)=0.5D0*fac3*ees0mij
4369 c ees0m(num_conti,i)=0.0D0
4371 c write (iout,*) 'i=',i,' j=',j,' rij=',rij,' r0ij=',r0ij,
4372 c & ' ees0ij=',ees0p(num_conti,i),ees0m(num_conti,i),' fcont=',fcont
4373 C Angular derivatives of the contact function
4374 ees0pij1=fac3/ees0pij
4375 ees0mij1=fac3/ees0mij
4376 fac3p=-3.0D0*fac3*rrmij
4377 ees0pijp=0.5D0*fac3p*(ees0pij+ees0mij)
4378 ees0mijp=0.5D0*fac3p*(ees0pij-ees0mij)
4380 ecosa1= ees0pij1*( 1.0D0+0.5D0*wij)
4381 ecosb1=-1.5D0*ees0pij1*(wij*cosg+cosbg1)
4382 ecosg1=-1.5D0*ees0pij1*(wij*cosb+cosbg1)
4383 ecosa2= ees0mij1*(-1.0D0+0.5D0*wij)
4384 ecosb2=-1.5D0*ees0mij1*(wij*cosg+cosbg2)
4385 ecosg2=-1.5D0*ees0mij1*(wij*cosb-cosbg2)
4386 ecosap=ecosa1+ecosa2
4387 ecosbp=ecosb1+ecosb2
4388 ecosgp=ecosg1+ecosg2
4389 ecosam=ecosa1-ecosa2
4390 ecosbm=ecosb1-ecosb2
4391 ecosgm=ecosg1-ecosg2
4400 facont_hb(num_conti,i)=fcont
4401 fprimcont=fprimcont/rij
4402 cd facont_hb(num_conti,i)=1.0D0
4403 C Following line is for diagnostics.
4406 dcosb(k)=rmij*(dc_norm(k,i)-erij(k)*cosb)
4407 dcosg(k)=rmij*(dc_norm(k,j)-erij(k)*cosg)
4410 gggp(k)=ecosbp*dcosb(k)+ecosgp*dcosg(k)
4411 gggm(k)=ecosbm*dcosb(k)+ecosgm*dcosg(k)
4413 gggp(1)=gggp(1)+ees0pijp*xj
4414 gggp(2)=gggp(2)+ees0pijp*yj
4415 gggp(3)=gggp(3)+ees0pijp*zj
4416 gggm(1)=gggm(1)+ees0mijp*xj
4417 gggm(2)=gggm(2)+ees0mijp*yj
4418 gggm(3)=gggm(3)+ees0mijp*zj
4419 C Derivatives due to the contact function
4420 gacont_hbr(1,num_conti,i)=fprimcont*xj
4421 gacont_hbr(2,num_conti,i)=fprimcont*yj
4422 gacont_hbr(3,num_conti,i)=fprimcont*zj
4425 c 10/24/08 cgrad and ! comments indicate the parts of the code removed
4426 c following the change of gradient-summation algorithm.
4428 cgrad ghalfp=0.5D0*gggp(k)
4429 cgrad ghalfm=0.5D0*gggm(k)
4430 gacontp_hb1(k,num_conti,i)=!ghalfp
4431 & +(ecosap*(dc_norm(k,j)-cosa*dc_norm(k,i))
4432 & + ecosbp*(erij(k)-cosb*dc_norm(k,i)))*vbld_inv(i+1)
4433 gacontp_hb2(k,num_conti,i)=!ghalfp
4434 & +(ecosap*(dc_norm(k,i)-cosa*dc_norm(k,j))
4435 & + ecosgp*(erij(k)-cosg*dc_norm(k,j)))*vbld_inv(j+1)
4436 gacontp_hb3(k,num_conti,i)=gggp(k)
4437 gacontm_hb1(k,num_conti,i)=!ghalfm
4438 & +(ecosam*(dc_norm(k,j)-cosa*dc_norm(k,i))
4439 & + ecosbm*(erij(k)-cosb*dc_norm(k,i)))*vbld_inv(i+1)
4440 gacontm_hb2(k,num_conti,i)=!ghalfm
4441 & +(ecosam*(dc_norm(k,i)-cosa*dc_norm(k,j))
4442 & + ecosgm*(erij(k)-cosg*dc_norm(k,j)))*vbld_inv(j+1)
4443 gacontm_hb3(k,num_conti,i)=gggm(k)
4445 C Diagnostics. Comment out or remove after debugging!
4447 cdiag gacontp_hb1(k,num_conti,i)=0.0D0
4448 cdiag gacontp_hb2(k,num_conti,i)=0.0D0
4449 cdiag gacontp_hb3(k,num_conti,i)=0.0D0
4450 cdiag gacontm_hb1(k,num_conti,i)=0.0D0
4451 cdiag gacontm_hb2(k,num_conti,i)=0.0D0
4452 cdiag gacontm_hb3(k,num_conti,i)=0.0D0
4455 endif ! num_conti.le.maxconts
4458 if (wturn3.gt.0.0d0 .or. wturn4.gt.0.0d0) then
4461 ghalf=0.5d0*agg(l,k)
4462 aggi(l,k)=aggi(l,k)+ghalf
4463 aggi1(l,k)=aggi1(l,k)+agg(l,k)
4464 aggj(l,k)=aggj(l,k)+ghalf
4467 if (j.eq.nres-1 .and. i.lt.j-2) then
4470 aggj1(l,k)=aggj1(l,k)+agg(l,k)
4475 c t_eelecij=t_eelecij+MPI_Wtime()-time00
4478 C-----------------------------------------------------------------------------
4479 subroutine eturn3(i,eello_turn3)
4480 C Third- and fourth-order contributions from turns
4481 implicit real*8 (a-h,o-z)
4482 include 'DIMENSIONS'
4483 include 'COMMON.IOUNITS'
4484 include 'COMMON.GEO'
4485 include 'COMMON.VAR'
4486 include 'COMMON.LOCAL'
4487 include 'COMMON.CHAIN'
4488 include 'COMMON.DERIV'
4489 include 'COMMON.INTERACT'
4490 include 'COMMON.CONTACTS'
4491 include 'COMMON.TORSION'
4492 include 'COMMON.VECTORS'
4493 include 'COMMON.FFIELD'
4494 include 'COMMON.CONTROL'
4496 double precision auxmat(2,2),auxmat1(2,2),auxmat2(2,2),pizda(2,2),
4497 & e1t(2,2),e2t(2,2),e3t(2,2),e1tder(2,2),e2tder(2,2),e3tder(2,2),
4498 & e1a(2,2),ae3(2,2),ae3e2(2,2),auxvec(2),auxvec1(2),gpizda1(2,2),
4499 & gpizda2(2,2),auxgmat1(2,2),auxgmatt1(2,2),
4500 & auxgmat2(2,2),auxgmatt2(2,2)
4501 double precision agg(3,4),aggi(3,4),aggi1(3,4),
4502 & aggj(3,4),aggj1(3,4),a_temp(2,2),auxmat3(2,2)
4503 common /locel/ a_temp,agg,aggi,aggi1,aggj,aggj1,a22,a23,a32,a33,
4504 & dxi,dyi,dzi,dx_normi,dy_normi,dz_normi,xmedi,ymedi,zmedi,
4507 c write (iout,*) "eturn3",i,j,j1,j2
4512 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
4514 C Third-order contributions
4521 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
4522 cd call checkint_turn3(i,a_temp,eello_turn3_num)
4523 call matmat2(EUg(1,1,i+1),EUg(1,1,i+2),auxmat(1,1))
4524 c auxalary matices for theta gradient
4525 c auxalary matrix for i+1 and constant i+2
4526 call matmat2(gtEUg(1,1,i+1),EUg(1,1,i+2),auxgmat1(1,1))
4527 c auxalary matrix for i+2 and constant i+1
4528 call matmat2(EUg(1,1,i+1),gtEUg(1,1,i+2),auxgmat2(1,1))
4529 call transpose2(auxmat(1,1),auxmat1(1,1))
4530 call transpose2(auxgmat1(1,1),auxgmatt1(1,1))
4531 call transpose2(auxgmat2(1,1),auxgmatt2(1,1))
4532 call matmat2(a_temp(1,1),auxmat1(1,1),pizda(1,1))
4533 call matmat2(a_temp(1,1),auxgmatt1(1,1),gpizda1(1,1))
4534 call matmat2(a_temp(1,1),auxgmatt2(1,1),gpizda2(1,1))
4535 eello_turn3=eello_turn3+0.5d0*(pizda(1,1)+pizda(2,2))
4536 C Derivatives in theta
4537 gloc(nphi+i,icg)=gloc(nphi+i,icg)
4538 & +0.5d0*(gpizda1(1,1)+gpizda1(2,2))*wturn3
4539 gloc(nphi+i+1,icg)=gloc(nphi+i+1,icg)
4540 & +0.5d0*(gpizda2(1,1)+gpizda2(2,2))*wturn3
4542 if (energy_dec) write (iout,'(a6,2i5,0pf7.3)')
4543 & 'eturn3',i,j,0.5d0*(pizda(1,1)+pizda(2,2))
4544 cd write (2,*) 'i,',i,' j',j,'eello_turn3',
4545 cd & 0.5d0*(pizda(1,1)+pizda(2,2)),
4546 cd & ' eello_turn3_num',4*eello_turn3_num
4547 C Derivatives in gamma(i)
4548 call matmat2(EUgder(1,1,i+1),EUg(1,1,i+2),auxmat2(1,1))
4549 call transpose2(auxmat2(1,1),auxmat3(1,1))
4550 call matmat2(a_temp(1,1),auxmat3(1,1),pizda(1,1))
4551 gel_loc_turn3(i)=gel_loc_turn3(i)+0.5d0*(pizda(1,1)+pizda(2,2))
4552 C Derivatives in gamma(i+1)
4553 call matmat2(EUg(1,1,i+1),EUgder(1,1,i+2),auxmat2(1,1))
4554 call transpose2(auxmat2(1,1),auxmat3(1,1))
4555 call matmat2(a_temp(1,1),auxmat3(1,1),pizda(1,1))
4556 gel_loc_turn3(i+1)=gel_loc_turn3(i+1)
4557 & +0.5d0*(pizda(1,1)+pizda(2,2))
4558 C Cartesian derivatives
4560 c ghalf1=0.5d0*agg(l,1)
4561 c ghalf2=0.5d0*agg(l,2)
4562 c ghalf3=0.5d0*agg(l,3)
4563 c ghalf4=0.5d0*agg(l,4)
4564 a_temp(1,1)=aggi(l,1)!+ghalf1
4565 a_temp(1,2)=aggi(l,2)!+ghalf2
4566 a_temp(2,1)=aggi(l,3)!+ghalf3
4567 a_temp(2,2)=aggi(l,4)!+ghalf4
4568 call matmat2(a_temp(1,1),auxmat1(1,1),pizda(1,1))
4569 gcorr3_turn(l,i)=gcorr3_turn(l,i)
4570 & +0.5d0*(pizda(1,1)+pizda(2,2))
4571 a_temp(1,1)=aggi1(l,1)!+agg(l,1)
4572 a_temp(1,2)=aggi1(l,2)!+agg(l,2)
4573 a_temp(2,1)=aggi1(l,3)!+agg(l,3)
4574 a_temp(2,2)=aggi1(l,4)!+agg(l,4)
4575 call matmat2(a_temp(1,1),auxmat1(1,1),pizda(1,1))
4576 gcorr3_turn(l,i+1)=gcorr3_turn(l,i+1)
4577 & +0.5d0*(pizda(1,1)+pizda(2,2))
4578 a_temp(1,1)=aggj(l,1)!+ghalf1
4579 a_temp(1,2)=aggj(l,2)!+ghalf2
4580 a_temp(2,1)=aggj(l,3)!+ghalf3
4581 a_temp(2,2)=aggj(l,4)!+ghalf4
4582 call matmat2(a_temp(1,1),auxmat1(1,1),pizda(1,1))
4583 gcorr3_turn(l,j)=gcorr3_turn(l,j)
4584 & +0.5d0*(pizda(1,1)+pizda(2,2))
4585 a_temp(1,1)=aggj1(l,1)
4586 a_temp(1,2)=aggj1(l,2)
4587 a_temp(2,1)=aggj1(l,3)
4588 a_temp(2,2)=aggj1(l,4)
4589 call matmat2(a_temp(1,1),auxmat1(1,1),pizda(1,1))
4590 gcorr3_turn(l,j1)=gcorr3_turn(l,j1)
4591 & +0.5d0*(pizda(1,1)+pizda(2,2))
4595 C-------------------------------------------------------------------------------
4596 subroutine eturn4(i,eello_turn4)
4597 C Third- and fourth-order contributions from turns
4598 implicit real*8 (a-h,o-z)
4599 include 'DIMENSIONS'
4600 include 'COMMON.IOUNITS'
4601 include 'COMMON.GEO'
4602 include 'COMMON.VAR'
4603 include 'COMMON.LOCAL'
4604 include 'COMMON.CHAIN'
4605 include 'COMMON.DERIV'
4606 include 'COMMON.INTERACT'
4607 include 'COMMON.CONTACTS'
4608 include 'COMMON.TORSION'
4609 include 'COMMON.VECTORS'
4610 include 'COMMON.FFIELD'
4611 include 'COMMON.CONTROL'
4613 double precision auxmat(2,2),auxmat1(2,2),auxmat2(2,2),pizda(2,2),
4614 & e1t(2,2),e2t(2,2),e3t(2,2),e1tder(2,2),e2tder(2,2),e3tder(2,2),
4615 & e1a(2,2),ae3(2,2),ae3e2(2,2),auxvec(2),auxvec1(2),auxgvec(2),
4616 & auxgEvec1(2),auxgEvec2(2),auxgEvec3(2),
4617 & gte1t(2,2),gte2t(2,2),gte3t(2,2),
4618 & gte1a(2,2),gtae3(2,2),gtae3e2(2,2), ae3gte2(2,2),
4619 & gtEpizda1(2,2),gtEpizda2(2,2),gtEpizda3(2,2)
4620 double precision agg(3,4),aggi(3,4),aggi1(3,4),
4621 & aggj(3,4),aggj1(3,4),a_temp(2,2),auxmat3(2,2)
4622 common /locel/ a_temp,agg,aggi,aggi1,aggj,aggj1,a22,a23,a32,a33,
4623 & dxi,dyi,dzi,dx_normi,dy_normi,dz_normi,xmedi,ymedi,zmedi,
4626 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
4628 C Fourth-order contributions
4636 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
4637 cd call checkint_turn4(i,a_temp,eello_turn4_num)
4638 c write (iout,*) "eturn4 i",i," j",j," j1",j1," j2",j2
4639 c write(iout,*)"WCHODZE W PROGRAM"
4644 iti1=itortyp(itype(i+1))
4645 iti2=itortyp(itype(i+2))
4646 iti3=itortyp(itype(i+3))
4647 c write(iout,*) "iti1",iti1," iti2",iti2," iti3",iti3
4648 call transpose2(EUg(1,1,i+1),e1t(1,1))
4649 call transpose2(Eug(1,1,i+2),e2t(1,1))
4650 call transpose2(Eug(1,1,i+3),e3t(1,1))
4651 C Ematrix derivative in theta
4652 call transpose2(gtEUg(1,1,i+1),gte1t(1,1))
4653 call transpose2(gtEug(1,1,i+2),gte2t(1,1))
4654 call transpose2(gtEug(1,1,i+3),gte3t(1,1))
4655 call matmat2(e1t(1,1),a_temp(1,1),e1a(1,1))
4656 c eta1 in derivative theta
4657 call matmat2(gte1t(1,1),a_temp(1,1),gte1a(1,1))
4658 call matvec2(e1a(1,1),Ub2(1,i+3),auxvec(1))
4659 c auxgvec is derivative of Ub2 so i+3 theta
4660 call matvec2(e1a(1,1),gUb2(1,i+3),auxgvec(1))
4661 c auxalary matrix of E i+1
4662 call matvec2(gte1a(1,1),Ub2(1,i+3),auxgEvec1(1))
4665 s1=scalar2(b1(1,i+2),auxvec(1))
4666 c derivative of theta i+2 with constant i+3
4667 gs23=scalar2(gtb1(1,i+2),auxvec(1))
4668 c derivative of theta i+2 with constant i+2
4669 gs32=scalar2(b1(1,i+2),auxgvec(1))
4670 c derivative of E matix in theta of i+1
4671 gsE13=scalar2(b1(1,i+2),auxgEvec1(1))
4673 call matmat2(a_temp(1,1),e3t(1,1),ae3(1,1))
4674 c ea31 in derivative theta
4675 call matmat2(a_temp(1,1),gte3t(1,1),gtae3(1,1))
4676 call matvec2(ae3(1,1),Ub2(1,i+2),auxvec(1))
4677 c auxilary matrix auxgvec of Ub2 with constant E matirx
4678 call matvec2(ae3(1,1),gUb2(1,i+2),auxgvec(1))
4679 c auxilary matrix auxgEvec1 of E matix with Ub2 constant
4680 call matvec2(gtae3(1,1),Ub2(1,i+2),auxgEvec3(1))
4684 s2=scalar2(b1(1,i+1),auxvec(1))
4685 c derivative of theta i+1 with constant i+3
4686 gs13=scalar2(gtb1(1,i+1),auxvec(1))
4687 c derivative of theta i+2 with constant i+1
4688 gs21=scalar2(b1(1,i+1),auxgvec(1))
4689 c derivative of theta i+3 with constant i+1
4690 gsE31=scalar2(b1(1,i+1),auxgEvec3(1))
4691 c write(iout,*) gs1,gs2,'i=',i,auxgvec(1),gUb2(1,i+2),gtb1(1,i+2),
4693 call matmat2(ae3(1,1),e2t(1,1),ae3e2(1,1))
4694 c two derivatives over diffetent matrices
4695 c gtae3e2 is derivative over i+3
4696 call matmat2(gtae3(1,1),e2t(1,1),gtae3e2(1,1))
4697 c ae3gte2 is derivative over i+2
4698 call matmat2(ae3(1,1),gte2t(1,1),ae3gte2(1,1))
4699 call matmat2(ae3e2(1,1),e1t(1,1),pizda(1,1))
4700 c three possible derivative over theta E matices
4702 call matmat2(ae3e2(1,1),gte1t(1,1),gtEpizda1(1,1))
4704 call matmat2(ae3gte2(1,1),e1t(1,1),gtEpizda2(1,1))
4706 call matmat2(gtae3e2(1,1),e1t(1,1),gtEpizda3(1,1))
4707 s3=0.5d0*(pizda(1,1)+pizda(2,2))
4709 gsEE1=0.5d0*(gtEpizda1(1,1)+gtEpizda1(2,2))
4710 gsEE2=0.5d0*(gtEpizda2(1,1)+gtEpizda2(2,2))
4711 gsEE3=0.5d0*(gtEpizda3(1,1)+gtEpizda3(2,2))
4713 eello_turn4=eello_turn4-(s1+s2+s3)
4714 c write(iout,*)'chujOWO', auxvec(1),b1(1,iti2)
4715 if (energy_dec) write (iout,'(a6,2i5,0pf7.3,3f7.3)')
4716 & 'eturn4',i,j,-(s1+s2+s3),s1,s2,s3
4717 cd write (2,*) 'i,',i,' j',j,'eello_turn4',-(s1+s2+s3),
4718 cd & ' eello_turn4_num',8*eello_turn4_num
4720 gloc(nphi+i,icg)=gloc(nphi+i,icg)
4721 & -(gs13+gsE13+gsEE1)*wturn4
4722 gloc(nphi+i+1,icg)= gloc(nphi+i+1,icg)
4723 & -(gs23+gs21+gsEE2)*wturn4
4724 gloc(nphi+i+2,icg)= gloc(nphi+i+2,icg)
4725 & -(gs32+gsE31+gsEE3)*wturn4
4726 c gloc(nphi+i+1,icg)=gloc(nphi+i+1,icg)-
4729 if (energy_dec) write (iout,'(a6,2i5,0pf7.3)')
4730 & 'eturn4',i,j,-(s1+s2+s3)
4731 c write (iout,*) 'i,',i,' j',j,'eello_turn4',-(s1+s2+s3),
4732 c & ' eello_turn4_num',8*eello_turn4_num
4733 C Derivatives in gamma(i)
4734 call transpose2(EUgder(1,1,i+1),e1tder(1,1))
4735 call matmat2(e1tder(1,1),a_temp(1,1),auxmat(1,1))
4736 call matvec2(auxmat(1,1),Ub2(1,i+3),auxvec(1))
4737 s1=scalar2(b1(1,i+2),auxvec(1))
4738 call matmat2(ae3e2(1,1),e1tder(1,1),pizda(1,1))
4739 s3=0.5d0*(pizda(1,1)+pizda(2,2))
4740 gel_loc_turn4(i)=gel_loc_turn4(i)-(s1+s3)
4741 C Derivatives in gamma(i+1)
4742 call transpose2(EUgder(1,1,i+2),e2tder(1,1))
4743 call matvec2(ae3(1,1),Ub2der(1,i+2),auxvec(1))
4744 s2=scalar2(b1(1,i+1),auxvec(1))
4745 call matmat2(ae3(1,1),e2tder(1,1),auxmat(1,1))
4746 call matmat2(auxmat(1,1),e1t(1,1),pizda(1,1))
4747 s3=0.5d0*(pizda(1,1)+pizda(2,2))
4748 gel_loc_turn4(i+1)=gel_loc_turn4(i+1)-(s2+s3)
4749 C Derivatives in gamma(i+2)
4750 call transpose2(EUgder(1,1,i+3),e3tder(1,1))
4751 call matvec2(e1a(1,1),Ub2der(1,i+3),auxvec(1))
4752 s1=scalar2(b1(1,i+2),auxvec(1))
4753 call matmat2(a_temp(1,1),e3tder(1,1),auxmat(1,1))
4754 call matvec2(auxmat(1,1),Ub2(1,i+2),auxvec(1))
4755 s2=scalar2(b1(1,i+1),auxvec(1))
4756 call matmat2(auxmat(1,1),e2t(1,1),auxmat3(1,1))
4757 call matmat2(auxmat3(1,1),e1t(1,1),pizda(1,1))
4758 s3=0.5d0*(pizda(1,1)+pizda(2,2))
4759 gel_loc_turn4(i+2)=gel_loc_turn4(i+2)-(s1+s2+s3)
4760 C Cartesian derivatives
4761 C Derivatives of this turn contributions in DC(i+2)
4762 if (j.lt.nres-1) then
4764 a_temp(1,1)=agg(l,1)
4765 a_temp(1,2)=agg(l,2)
4766 a_temp(2,1)=agg(l,3)
4767 a_temp(2,2)=agg(l,4)
4768 call matmat2(e1t(1,1),a_temp(1,1),e1a(1,1))
4769 call matvec2(e1a(1,1),Ub2(1,i+3),auxvec(1))
4770 s1=scalar2(b1(1,i+2),auxvec(1))
4771 call matmat2(a_temp(1,1),e3t(1,1),ae3(1,1))
4772 call matvec2(ae3(1,1),Ub2(1,i+2),auxvec(1))
4773 s2=scalar2(b1(1,i+1),auxvec(1))
4774 call matmat2(ae3(1,1),e2t(1,1),ae3e2(1,1))
4775 call matmat2(ae3e2(1,1),e1t(1,1),pizda(1,1))
4776 s3=0.5d0*(pizda(1,1)+pizda(2,2))
4778 gcorr4_turn(l,i+2)=gcorr4_turn(l,i+2)-(s1+s2+s3)
4781 C Remaining derivatives of this turn contribution
4783 a_temp(1,1)=aggi(l,1)
4784 a_temp(1,2)=aggi(l,2)
4785 a_temp(2,1)=aggi(l,3)
4786 a_temp(2,2)=aggi(l,4)
4787 call matmat2(e1t(1,1),a_temp(1,1),e1a(1,1))
4788 call matvec2(e1a(1,1),Ub2(1,i+3),auxvec(1))
4789 s1=scalar2(b1(1,i+2),auxvec(1))
4790 call matmat2(a_temp(1,1),e3t(1,1),ae3(1,1))
4791 call matvec2(ae3(1,1),Ub2(1,i+2),auxvec(1))
4792 s2=scalar2(b1(1,i+1),auxvec(1))
4793 call matmat2(ae3(1,1),e2t(1,1),ae3e2(1,1))
4794 call matmat2(ae3e2(1,1),e1t(1,1),pizda(1,1))
4795 s3=0.5d0*(pizda(1,1)+pizda(2,2))
4796 gcorr4_turn(l,i)=gcorr4_turn(l,i)-(s1+s2+s3)
4797 a_temp(1,1)=aggi1(l,1)
4798 a_temp(1,2)=aggi1(l,2)
4799 a_temp(2,1)=aggi1(l,3)
4800 a_temp(2,2)=aggi1(l,4)
4801 call matmat2(e1t(1,1),a_temp(1,1),e1a(1,1))
4802 call matvec2(e1a(1,1),Ub2(1,i+3),auxvec(1))
4803 s1=scalar2(b1(1,i+2),auxvec(1))
4804 call matmat2(a_temp(1,1),e3t(1,1),ae3(1,1))
4805 call matvec2(ae3(1,1),Ub2(1,i+2),auxvec(1))
4806 s2=scalar2(b1(1,i+1),auxvec(1))
4807 call matmat2(ae3(1,1),e2t(1,1),ae3e2(1,1))
4808 call matmat2(ae3e2(1,1),e1t(1,1),pizda(1,1))
4809 s3=0.5d0*(pizda(1,1)+pizda(2,2))
4810 gcorr4_turn(l,i+1)=gcorr4_turn(l,i+1)-(s1+s2+s3)
4811 a_temp(1,1)=aggj(l,1)
4812 a_temp(1,2)=aggj(l,2)
4813 a_temp(2,1)=aggj(l,3)
4814 a_temp(2,2)=aggj(l,4)
4815 call matmat2(e1t(1,1),a_temp(1,1),e1a(1,1))
4816 call matvec2(e1a(1,1),Ub2(1,i+3),auxvec(1))
4817 s1=scalar2(b1(1,i+2),auxvec(1))
4818 call matmat2(a_temp(1,1),e3t(1,1),ae3(1,1))
4819 call matvec2(ae3(1,1),Ub2(1,i+2),auxvec(1))
4820 s2=scalar2(b1(1,i+1),auxvec(1))
4821 call matmat2(ae3(1,1),e2t(1,1),ae3e2(1,1))
4822 call matmat2(ae3e2(1,1),e1t(1,1),pizda(1,1))
4823 s3=0.5d0*(pizda(1,1)+pizda(2,2))
4824 gcorr4_turn(l,j)=gcorr4_turn(l,j)-(s1+s2+s3)
4825 a_temp(1,1)=aggj1(l,1)
4826 a_temp(1,2)=aggj1(l,2)
4827 a_temp(2,1)=aggj1(l,3)
4828 a_temp(2,2)=aggj1(l,4)
4829 call matmat2(e1t(1,1),a_temp(1,1),e1a(1,1))
4830 call matvec2(e1a(1,1),Ub2(1,i+3),auxvec(1))
4831 s1=scalar2(b1(1,i+2),auxvec(1))
4832 call matmat2(a_temp(1,1),e3t(1,1),ae3(1,1))
4833 call matvec2(ae3(1,1),Ub2(1,i+2),auxvec(1))
4834 s2=scalar2(b1(1,i+1),auxvec(1))
4835 call matmat2(ae3(1,1),e2t(1,1),ae3e2(1,1))
4836 call matmat2(ae3e2(1,1),e1t(1,1),pizda(1,1))
4837 s3=0.5d0*(pizda(1,1)+pizda(2,2))
4838 c write (iout,*) "s1",s1," s2",s2," s3",s3," s1+s2+s3",s1+s2+s3
4839 gcorr4_turn(l,j1)=gcorr4_turn(l,j1)-(s1+s2+s3)
4843 C-----------------------------------------------------------------------------
4844 subroutine vecpr(u,v,w)
4845 implicit real*8(a-h,o-z)
4846 dimension u(3),v(3),w(3)
4847 w(1)=u(2)*v(3)-u(3)*v(2)
4848 w(2)=-u(1)*v(3)+u(3)*v(1)
4849 w(3)=u(1)*v(2)-u(2)*v(1)
4852 C-----------------------------------------------------------------------------
4853 subroutine unormderiv(u,ugrad,unorm,ungrad)
4854 C This subroutine computes the derivatives of a normalized vector u, given
4855 C the derivatives computed without normalization conditions, ugrad. Returns
4858 double precision u(3),ugrad(3,3),unorm,ungrad(3,3)
4859 double precision vec(3)
4860 double precision scalar
4862 c write (2,*) 'ugrad',ugrad
4865 vec(i)=scalar(ugrad(1,i),u(1))
4867 c write (2,*) 'vec',vec
4870 ungrad(j,i)=(ugrad(j,i)-u(j)*vec(i))*unorm
4873 c write (2,*) 'ungrad',ungrad
4876 C-----------------------------------------------------------------------------
4877 subroutine escp_soft_sphere(evdw2,evdw2_14)
4879 C This subroutine calculates the excluded-volume interaction energy between
4880 C peptide-group centers and side chains and its gradient in virtual-bond and
4881 C side-chain vectors.
4883 implicit real*8 (a-h,o-z)
4884 include 'DIMENSIONS'
4885 include 'COMMON.GEO'
4886 include 'COMMON.VAR'
4887 include 'COMMON.LOCAL'
4888 include 'COMMON.CHAIN'
4889 include 'COMMON.DERIV'
4890 include 'COMMON.INTERACT'
4891 include 'COMMON.FFIELD'
4892 include 'COMMON.IOUNITS'
4893 include 'COMMON.CONTROL'
4898 cd print '(a)','Enter ESCP'
4899 cd write (iout,*) 'iatscp_s=',iatscp_s,' iatscp_e=',iatscp_e
4903 do i=iatscp_s,iatscp_e
4904 if (itype(i).eq.ntyp1 .or. itype(i+1).eq.ntyp1) cycle
4906 xi=0.5D0*(c(1,i)+c(1,i+1))
4907 yi=0.5D0*(c(2,i)+c(2,i+1))
4908 zi=0.5D0*(c(3,i)+c(3,i+1))
4909 C Return atom into box, boxxsize is size of box in x dimension
4911 c if (xi.gt.((xshift+0.5d0)*boxxsize)) xi=xi-boxxsize
4912 c if (xi.lt.((xshift-0.5d0)*boxxsize)) xi=xi+boxxsize
4913 C Condition for being inside the proper box
4914 c if ((xi.gt.((xshift+0.5d0)*boxxsize)).or.
4915 c & (xi.lt.((xshift-0.5d0)*boxxsize))) then
4919 c if (yi.gt.((yshift+0.5d0)*boxysize)) yi=yi-boxysize
4920 c if (yi.lt.((yshift-0.5d0)*boxysize)) yi=yi+boxysize
4921 C Condition for being inside the proper box
4922 c if ((yi.gt.((yshift+0.5d0)*boxysize)).or.
4923 c & (yi.lt.((yshift-0.5d0)*boxysize))) then
4927 c if (zi.gt.((zshift+0.5d0)*boxzsize)) zi=zi-boxzsize
4928 c if (zi.lt.((zshift-0.5d0)*boxzsize)) zi=zi+boxzsize
4929 cC Condition for being inside the proper box
4930 c if ((zi.gt.((zshift+0.5d0)*boxzsize)).or.
4931 c & (zi.lt.((zshift-0.5d0)*boxzsize))) then
4935 if (xi.lt.0) xi=xi+boxxsize
4937 if (yi.lt.0) yi=yi+boxysize
4939 if (zi.lt.0) zi=zi+boxzsize
4940 C xi=xi+xshift*boxxsize
4941 C yi=yi+yshift*boxysize
4942 C zi=zi+zshift*boxzsize
4943 do iint=1,nscp_gr(i)
4945 do j=iscpstart(i,iint),iscpend(i,iint)
4946 if (itype(j).eq.ntyp1) cycle
4947 itypj=iabs(itype(j))
4948 C Uncomment following three lines for SC-p interactions
4952 C Uncomment following three lines for Ca-p interactions
4957 c if (xj.gt.((0.5d0)*boxxsize)) xj=xj-boxxsize
4958 c if (xj.lt.((-0.5d0)*boxxsize)) xj=xj+boxxsize
4959 C Condition for being inside the proper box
4960 c if ((xj.gt.((0.5d0)*boxxsize)).or.
4961 c & (xj.lt.((-0.5d0)*boxxsize))) then
4965 c if (yj.gt.((0.5d0)*boxysize)) yj=yj-boxysize
4966 c if (yj.lt.((-0.5d0)*boxysize)) yj=yj+boxysize
4967 cC Condition for being inside the proper box
4968 c if ((yj.gt.((0.5d0)*boxysize)).or.
4969 c & (yj.lt.((-0.5d0)*boxysize))) then
4973 c if (zj.gt.((0.5d0)*boxzsize)) zj=zj-boxzsize
4974 c if (zj.lt.((-0.5d0)*boxzsize)) zj=zj+boxzsize
4975 C Condition for being inside the proper box
4976 c if ((zj.gt.((0.5d0)*boxzsize)).or.
4977 c & (zj.lt.((-0.5d0)*boxzsize))) then
4980 if (xj.lt.0) xj=xj+boxxsize
4982 if (yj.lt.0) yj=yj+boxysize
4984 if (zj.lt.0) zj=zj+boxzsize
4985 dist_init=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
4993 xj=xj_safe+xshift*boxxsize
4994 yj=yj_safe+yshift*boxysize
4995 zj=zj_safe+zshift*boxzsize
4996 dist_temp=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
4997 if(dist_temp.lt.dist_init) then
5007 if (subchap.eq.1) then
5020 rij=xj*xj+yj*yj+zj*zj
5024 if (rij.lt.r0ijsq) then
5025 evdwij=0.25d0*(rij-r0ijsq)**2
5033 C Calculate contributions to the gradient in the virtual-bond and SC vectors.
5038 cgrad if (j.lt.i) then
5039 cd write (iout,*) 'j<i'
5040 C Uncomment following three lines for SC-p interactions
5042 c gradx_scp(k,j)=gradx_scp(k,j)+ggg(k)
5045 cd write (iout,*) 'j>i'
5047 cgrad ggg(k)=-ggg(k)
5048 C Uncomment following line for SC-p interactions
5049 c gradx_scp(k,j)=gradx_scp(k,j)-ggg(k)
5053 cgrad gvdwc_scp(k,i)=gvdwc_scp(k,i)-0.5D0*ggg(k)
5055 cgrad kstart=min0(i+1,j)
5056 cgrad kend=max0(i-1,j-1)
5057 cd write (iout,*) 'i=',i,' j=',j,' kstart=',kstart,' kend=',kend
5058 cd write (iout,*) ggg(1),ggg(2),ggg(3)
5059 cgrad do k=kstart,kend
5061 cgrad gvdwc_scp(l,k)=gvdwc_scp(l,k)-ggg(l)
5065 gvdwc_scpp(k,i)=gvdwc_scpp(k,i)-ggg(k)
5066 gvdwc_scp(k,j)=gvdwc_scp(k,j)+ggg(k)
5077 C-----------------------------------------------------------------------------
5078 subroutine escp(evdw2,evdw2_14)
5080 C This subroutine calculates the excluded-volume interaction energy between
5081 C peptide-group centers and side chains and its gradient in virtual-bond and
5082 C side-chain vectors.
5084 implicit real*8 (a-h,o-z)
5085 include 'DIMENSIONS'
5086 include 'COMMON.GEO'
5087 include 'COMMON.VAR'
5088 include 'COMMON.LOCAL'
5089 include 'COMMON.CHAIN'
5090 include 'COMMON.DERIV'
5091 include 'COMMON.INTERACT'
5092 include 'COMMON.FFIELD'
5093 include 'COMMON.IOUNITS'
5094 include 'COMMON.CONTROL'
5095 include 'COMMON.SPLITELE'
5099 c print *,boxxsize,boxysize,boxzsize,'wymiary pudla'
5100 cd print '(a)','Enter ESCP'
5101 cd write (iout,*) 'iatscp_s=',iatscp_s,' iatscp_e=',iatscp_e
5105 do i=iatscp_s,iatscp_e
5106 if (itype(i).eq.ntyp1 .or. itype(i+1).eq.ntyp1) cycle
5108 xi=0.5D0*(c(1,i)+c(1,i+1))
5109 yi=0.5D0*(c(2,i)+c(2,i+1))
5110 zi=0.5D0*(c(3,i)+c(3,i+1))
5112 if (xi.lt.0) xi=xi+boxxsize
5114 if (yi.lt.0) yi=yi+boxysize
5116 if (zi.lt.0) zi=zi+boxzsize
5117 c xi=xi+xshift*boxxsize
5118 c yi=yi+yshift*boxysize
5119 c zi=zi+zshift*boxzsize
5120 c print *,xi,yi,zi,'polozenie i'
5121 C Return atom into box, boxxsize is size of box in x dimension
5123 c if (xi.gt.((xshift+0.5d0)*boxxsize)) xi=xi-boxxsize
5124 c if (xi.lt.((xshift-0.5d0)*boxxsize)) xi=xi+boxxsize
5125 C Condition for being inside the proper box
5126 c if ((xi.gt.((xshift+0.5d0)*boxxsize)).or.
5127 c & (xi.lt.((xshift-0.5d0)*boxxsize))) then
5131 c print *,xi,boxxsize,"pierwszy"
5133 c if (yi.gt.((yshift+0.5d0)*boxysize)) yi=yi-boxysize
5134 c if (yi.lt.((yshift-0.5d0)*boxysize)) yi=yi+boxysize
5135 C Condition for being inside the proper box
5136 c if ((yi.gt.((yshift+0.5d0)*boxysize)).or.
5137 c & (yi.lt.((yshift-0.5d0)*boxysize))) then
5141 c if (zi.gt.((zshift+0.5d0)*boxzsize)) zi=zi-boxzsize
5142 c if (zi.lt.((zshift-0.5d0)*boxzsize)) zi=zi+boxzsize
5143 C Condition for being inside the proper box
5144 c if ((zi.gt.((zshift+0.5d0)*boxzsize)).or.
5145 c & (zi.lt.((zshift-0.5d0)*boxzsize))) then
5148 do iint=1,nscp_gr(i)
5150 do j=iscpstart(i,iint),iscpend(i,iint)
5151 itypj=iabs(itype(j))
5152 if (itypj.eq.ntyp1) cycle
5153 C Uncomment following three lines for SC-p interactions
5157 C Uncomment following three lines for Ca-p interactions
5162 if (xj.lt.0) xj=xj+boxxsize
5164 if (yj.lt.0) yj=yj+boxysize
5166 if (zj.lt.0) zj=zj+boxzsize
5168 c if (xj.gt.((0.5d0)*boxxsize)) xj=xj-boxxsize
5169 c if (xj.lt.((-0.5d0)*boxxsize)) xj=xj+boxxsize
5170 C Condition for being inside the proper box
5171 c if ((xj.gt.((0.5d0)*boxxsize)).or.
5172 c & (xj.lt.((-0.5d0)*boxxsize))) then
5176 c if (yj.gt.((0.5d0)*boxysize)) yj=yj-boxysize
5177 c if (yj.lt.((-0.5d0)*boxysize)) yj=yj+boxysize
5178 cC Condition for being inside the proper box
5179 c if ((yj.gt.((0.5d0)*boxysize)).or.
5180 c & (yj.lt.((-0.5d0)*boxysize))) then
5184 c if (zj.gt.((0.5d0)*boxzsize)) zj=zj-boxzsize
5185 c if (zj.lt.((-0.5d0)*boxzsize)) zj=zj+boxzsize
5186 C Condition for being inside the proper box
5187 c if ((zj.gt.((0.5d0)*boxzsize)).or.
5188 c & (zj.lt.((-0.5d0)*boxzsize))) then
5191 CHERE IS THE CALCULATION WHICH MIRROR IMAGE IS THE CLOSEST ONE
5192 dist_init=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
5200 xj=xj_safe+xshift*boxxsize
5201 yj=yj_safe+yshift*boxysize
5202 zj=zj_safe+zshift*boxzsize
5203 dist_temp=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
5204 if(dist_temp.lt.dist_init) then
5214 if (subchap.eq.1) then
5223 c print *,xj,yj,zj,'polozenie j'
5224 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
5226 sss=sscale(1.0d0/(dsqrt(rrij)))
5227 c print *,r_cut,1.0d0/dsqrt(rrij),sss,'tu patrz'
5228 c if (sss.eq.0) print *,'czasem jest OK'
5229 if (sss.le.0.0d0) cycle
5230 sssgrad=sscagrad(1.0d0/(dsqrt(rrij)))
5232 e1=fac*fac*aad(itypj,iteli)
5233 e2=fac*bad(itypj,iteli)
5234 if (iabs(j-i) .le. 2) then
5237 evdw2_14=evdw2_14+(e1+e2)*sss
5240 evdw2=evdw2+evdwij*sss
5241 if (energy_dec) write (iout,'(a6,2i5,0pf7.3,2i3,3e11.3)')
5242 & 'evdw2',i,j,evdwij,iteli,itypj,fac,aad(itypj,iteli),
5245 C Calculate contributions to the gradient in the virtual-bond and SC vectors.
5247 fac=-(evdwij+e1)*rrij*sss
5248 fac=fac+(evdwij)*sssgrad*dsqrt(rrij)/expon
5252 cgrad if (j.lt.i) then
5253 cd write (iout,*) 'j<i'
5254 C Uncomment following three lines for SC-p interactions
5256 c gradx_scp(k,j)=gradx_scp(k,j)+ggg(k)
5259 cd write (iout,*) 'j>i'
5261 cgrad ggg(k)=-ggg(k)
5262 C Uncomment following line for SC-p interactions
5263 ccgrad gradx_scp(k,j)=gradx_scp(k,j)-ggg(k)
5264 c gradx_scp(k,j)=gradx_scp(k,j)+ggg(k)
5268 cgrad gvdwc_scp(k,i)=gvdwc_scp(k,i)-0.5D0*ggg(k)
5270 cgrad kstart=min0(i+1,j)
5271 cgrad kend=max0(i-1,j-1)
5272 cd write (iout,*) 'i=',i,' j=',j,' kstart=',kstart,' kend=',kend
5273 cd write (iout,*) ggg(1),ggg(2),ggg(3)
5274 cgrad do k=kstart,kend
5276 cgrad gvdwc_scp(l,k)=gvdwc_scp(l,k)-ggg(l)
5280 gvdwc_scpp(k,i)=gvdwc_scpp(k,i)-ggg(k)
5281 gvdwc_scp(k,j)=gvdwc_scp(k,j)+ggg(k)
5283 c endif !endif for sscale cutoff
5293 gvdwc_scp(j,i)=expon*gvdwc_scp(j,i)
5294 gvdwc_scpp(j,i)=expon*gvdwc_scpp(j,i)
5295 gradx_scp(j,i)=expon*gradx_scp(j,i)
5298 C******************************************************************************
5302 C To save time the factor EXPON has been extracted from ALL components
5303 C of GVDWC and GRADX. Remember to multiply them by this factor before further
5306 C******************************************************************************
5309 C--------------------------------------------------------------------------
5310 subroutine edis(ehpb)
5312 C Evaluate bridge-strain energy and its gradient in virtual-bond and SC vectors.
5314 implicit real*8 (a-h,o-z)
5315 include 'DIMENSIONS'
5316 include 'COMMON.SBRIDGE'
5317 include 'COMMON.CHAIN'
5318 include 'COMMON.DERIV'
5319 include 'COMMON.VAR'
5320 include 'COMMON.INTERACT'
5321 include 'COMMON.IOUNITS'
5322 include 'COMMON.CONTROL'
5328 C write (iout,*) ,"link_end",link_end,constr_dist
5329 cd write(iout,*)'edis: nhpb=',nhpb,' fbr=',fbr
5330 cd write(iout,*)'link_start=',link_start,' link_end=',link_end
5331 if (link_end.eq.0) return
5332 do i=link_start,link_end
5333 C If ihpb(i) and jhpb(i) > NRES, this is a SC-SC distance, otherwise a
5334 C CA-CA distance used in regularization of structure.
5337 C iii and jjj point to the residues for which the distance is assigned.
5338 if (ii.gt.nres) then
5345 c write (iout,*) "i",i," ii",ii," iii",iii," jj",jj," jjj",jjj,
5346 c & dhpb(i),dhpb1(i),forcon(i)
5347 C 24/11/03 AL: SS bridges handled separately because of introducing a specific
5348 C distance and angle dependent SS bond potential.
5349 C if (ii.gt.nres .and. iabs(itype(iii)).eq.1 .and.
5350 C & iabs(itype(jjj)).eq.1) then
5351 cmc if (ii.gt.nres .and. itype(iii).eq.1 .and. itype(jjj).eq.1) then
5352 C 18/07/06 MC: Use the convention that the first nss pairs are SS bonds
5353 if (.not.dyn_ss .and. i.le.nss) then
5354 C 15/02/13 CC dynamic SSbond - additional check
5355 if (ii.gt.nres .and. iabs(itype(iii)).eq.1 .and.
5356 & iabs(itype(jjj)).eq.1) then
5357 call ssbond_ene(iii,jjj,eij)
5360 cd write (iout,*) "eij",eij
5361 cd & ' waga=',waga,' fac=',fac
5362 else if (ii.gt.nres .and. jj.gt.nres) then
5363 c Restraints from contact prediction
5365 if (constr_dist.eq.11) then
5366 ehpb=ehpb+fordepth(i)**4.0d0
5367 & *rlornmr1(dd,dhpb(i),dhpb1(i),forcon(i))
5368 fac=fordepth(i)**4.0d0
5369 & *rlornmr1prim(dd,dhpb(i),dhpb1(i),forcon(i))/dd
5370 if (energy_dec) write (iout,'(a6,2i5,3f8.3)') "edisl",ii,jj,
5371 & ehpb,fordepth(i),dd
5373 if (dhpb1(i).gt.0.0d0) then
5374 ehpb=ehpb+2*forcon(i)*gnmr1(dd,dhpb(i),dhpb1(i))
5375 fac=forcon(i)*gnmr1prim(dd,dhpb(i),dhpb1(i))/dd
5376 c write (iout,*) "beta nmr",
5377 c & dd,2*forcon(i)*gnmr1(dd,dhpb(i),dhpb1(i))
5381 C Get the force constant corresponding to this distance.
5383 C Calculate the contribution to energy.
5384 ehpb=ehpb+waga*rdis*rdis
5385 c write (iout,*) "beta reg",dd,waga*rdis*rdis
5387 C Evaluate gradient.
5393 ggg(j)=fac*(c(j,jj)-c(j,ii))
5396 ghpbx(j,iii)=ghpbx(j,iii)-ggg(j)
5397 ghpbx(j,jjj)=ghpbx(j,jjj)+ggg(j)
5400 ghpbc(k,jjj)=ghpbc(k,jjj)+ggg(k)
5401 ghpbc(k,iii)=ghpbc(k,iii)-ggg(k)
5404 C Calculate the distance between the two points and its difference from the
5407 if (constr_dist.eq.11) then
5408 ehpb=ehpb+fordepth(i)**4.0d0
5409 & *rlornmr1(dd,dhpb(i),dhpb1(i),forcon(i))
5410 fac=fordepth(i)**4.0d0
5411 & *rlornmr1prim(dd,dhpb(i),dhpb1(i),forcon(i))/dd
5412 if (energy_dec) write (iout,'(a6,2i5,3f8.3)') "edisl",ii,jj,
5413 & ehpb,fordepth(i),dd
5415 if (dhpb1(i).gt.0.0d0) then
5416 ehpb=ehpb+2*forcon(i)*gnmr1(dd,dhpb(i),dhpb1(i))
5417 fac=forcon(i)*gnmr1prim(dd,dhpb(i),dhpb1(i))/dd
5418 c write (iout,*) "alph nmr",
5419 c & dd,2*forcon(i)*gnmr1(dd,dhpb(i),dhpb1(i))
5422 C Get the force constant corresponding to this distance.
5424 C Calculate the contribution to energy.
5425 ehpb=ehpb+waga*rdis*rdis
5426 c write (iout,*) "alpha reg",dd,waga*rdis*rdis
5428 C Evaluate gradient.
5434 ggg(j)=fac*(c(j,jj)-c(j,ii))
5436 cd print '(i3,3(1pe14.5))',i,(ggg(j),j=1,3)
5437 C If this is a SC-SC distance, we need to calculate the contributions to the
5438 C Cartesian gradient in the SC vectors (ghpbx).
5441 ghpbx(j,iii)=ghpbx(j,iii)-ggg(j)
5442 ghpbx(j,jjj)=ghpbx(j,jjj)+ggg(j)
5445 cgrad do j=iii,jjj-1
5447 cgrad ghpbc(k,j)=ghpbc(k,j)+ggg(k)
5451 ghpbc(k,jjj)=ghpbc(k,jjj)+ggg(k)
5452 ghpbc(k,iii)=ghpbc(k,iii)-ggg(k)
5456 if (constr_dist.ne.11) ehpb=0.5D0*ehpb
5459 C--------------------------------------------------------------------------
5460 subroutine ssbond_ene(i,j,eij)
5462 C Calculate the distance and angle dependent SS-bond potential energy
5463 C using a free-energy function derived based on RHF/6-31G** ab initio
5464 C calculations of diethyl disulfide.
5466 C A. Liwo and U. Kozlowska, 11/24/03
5468 implicit real*8 (a-h,o-z)
5469 include 'DIMENSIONS'
5470 include 'COMMON.SBRIDGE'
5471 include 'COMMON.CHAIN'
5472 include 'COMMON.DERIV'
5473 include 'COMMON.LOCAL'
5474 include 'COMMON.INTERACT'
5475 include 'COMMON.VAR'
5476 include 'COMMON.IOUNITS'
5477 double precision erij(3),dcosom1(3),dcosom2(3),gg(3)
5478 itypi=iabs(itype(i))
5482 dxi=dc_norm(1,nres+i)
5483 dyi=dc_norm(2,nres+i)
5484 dzi=dc_norm(3,nres+i)
5485 c dsci_inv=dsc_inv(itypi)
5486 dsci_inv=vbld_inv(nres+i)
5487 itypj=iabs(itype(j))
5488 c dscj_inv=dsc_inv(itypj)
5489 dscj_inv=vbld_inv(nres+j)
5493 dxj=dc_norm(1,nres+j)
5494 dyj=dc_norm(2,nres+j)
5495 dzj=dc_norm(3,nres+j)
5496 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
5501 om1=dxi*erij(1)+dyi*erij(2)+dzi*erij(3)
5502 om2=dxj*erij(1)+dyj*erij(2)+dzj*erij(3)
5503 om12=dxi*dxj+dyi*dyj+dzi*dzj
5505 dcosom1(k)=rij*(dc_norm(k,nres+i)-om1*erij(k))
5506 dcosom2(k)=rij*(dc_norm(k,nres+j)-om2*erij(k))
5512 deltat12=om2-om1+2.0d0
5514 eij=akcm*deltad*deltad+akth*(deltat1*deltat1+deltat2*deltat2)
5515 & +akct*deltad*deltat12
5516 & +v1ss*cosphi+v2ss*cosphi*cosphi+v3ss*cosphi*cosphi*cosphi+ebr
5517 c write(iout,*) i,j,"rij",rij,"d0cm",d0cm," akcm",akcm," akth",akth,
5518 c & " akct",akct," deltad",deltad," deltat",deltat1,deltat2,
5519 c & " deltat12",deltat12," eij",eij
5520 ed=2*akcm*deltad+akct*deltat12
5522 pom2=v1ss+2*v2ss*cosphi+3*v3ss*cosphi*cosphi
5523 eom1=-2*akth*deltat1-pom1-om2*pom2
5524 eom2= 2*akth*deltat2+pom1-om1*pom2
5527 ggk=ed*erij(k)+eom1*dcosom1(k)+eom2*dcosom2(k)
5528 ghpbx(k,i)=ghpbx(k,i)-ggk
5529 & +(eom12*(dc_norm(k,nres+j)-om12*dc_norm(k,nres+i))
5530 & +eom1*(erij(k)-om1*dc_norm(k,nres+i)))*dsci_inv
5531 ghpbx(k,j)=ghpbx(k,j)+ggk
5532 & +(eom12*(dc_norm(k,nres+i)-om12*dc_norm(k,nres+j))
5533 & +eom2*(erij(k)-om2*dc_norm(k,nres+j)))*dscj_inv
5534 ghpbc(k,i)=ghpbc(k,i)-ggk
5535 ghpbc(k,j)=ghpbc(k,j)+ggk
5538 C Calculate the components of the gradient in DC and X
5542 cgrad ghpbc(l,k)=ghpbc(l,k)+gg(l)
5547 C--------------------------------------------------------------------------
5548 subroutine ebond(estr)
5550 c Evaluate the energy of stretching of the CA-CA and CA-SC virtual bonds
5552 implicit real*8 (a-h,o-z)
5553 include 'DIMENSIONS'
5554 include 'COMMON.LOCAL'
5555 include 'COMMON.GEO'
5556 include 'COMMON.INTERACT'
5557 include 'COMMON.DERIV'
5558 include 'COMMON.VAR'
5559 include 'COMMON.CHAIN'
5560 include 'COMMON.IOUNITS'
5561 include 'COMMON.NAMES'
5562 include 'COMMON.FFIELD'
5563 include 'COMMON.CONTROL'
5564 include 'COMMON.SETUP'
5565 double precision u(3),ud(3)
5568 do i=ibondp_start,ibondp_end
5569 if (itype(i-1).eq.ntyp1 .and. itype(i).eq.ntyp1) cycle
5570 c estr1=estr1+gnmr1(vbld(i),-1.0d0,distchainmax)
5572 c gradb(j,i-1)=gnmr1prim(vbld(i),-1.0d0,distchainmax)
5573 c & *dc(j,i-1)/vbld(i)
5575 c if (energy_dec) write(iout,*)
5576 c & "estr1",i,gnmr1(vbld(i),-1.0d0,distchainmax)
5578 C Checking if it involves dummy (NH3+ or COO-) group
5579 if (itype(i-1).eq.ntyp1 .or. itype(i).eq.ntyp1) then
5580 C YES vbldpDUM is the equlibrium length of spring for Dummy atom
5581 diff = vbld(i)-vbldpDUM
5583 C NO vbldp0 is the equlibrium lenght of spring for peptide group
5584 diff = vbld(i)-vbldp0
5586 if (energy_dec) write (iout,'(a7,i5,4f7.3)')
5587 & "estr bb",i,vbld(i),vbldp0,diff,AKP*diff*diff
5590 gradb(j,i-1)=AKP*diff*dc(j,i-1)/vbld(i)
5592 c write (iout,'(i5,3f10.5)') i,(gradb(j,i-1),j=1,3)
5595 estr=0.5d0*AKP*estr+estr1
5597 c 09/18/07 AL: multimodal bond potential based on AM1 CA-SC PMF's included
5599 do i=ibond_start,ibond_end
5601 if (iti.ne.10 .and. iti.ne.ntyp1) then
5604 diff=vbld(i+nres)-vbldsc0(1,iti)
5605 if (energy_dec) write (iout,*)
5606 & "estr sc",i,iti,vbld(i+nres),vbldsc0(1,iti),diff,
5607 & AKSC(1,iti),AKSC(1,iti)*diff*diff
5608 estr=estr+0.5d0*AKSC(1,iti)*diff*diff
5610 gradbx(j,i)=AKSC(1,iti)*diff*dc(j,i+nres)/vbld(i+nres)
5614 diff=vbld(i+nres)-vbldsc0(j,iti)
5615 ud(j)=aksc(j,iti)*diff
5616 u(j)=abond0(j,iti)+0.5d0*ud(j)*diff
5630 uprod2=uprod2*u(k)*u(k)
5634 usumsqder=usumsqder+ud(j)*uprod2
5636 estr=estr+uprod/usum
5638 gradbx(j,i)=usumsqder/(usum*usum)*dc(j,i+nres)/vbld(i+nres)
5646 C--------------------------------------------------------------------------
5647 subroutine ebend(etheta,ethetacnstr)
5649 C Evaluate the virtual-bond-angle energy given the virtual-bond dihedral
5650 C angles gamma and its derivatives in consecutive thetas and gammas.
5652 implicit real*8 (a-h,o-z)
5653 include 'DIMENSIONS'
5654 include 'COMMON.LOCAL'
5655 include 'COMMON.GEO'
5656 include 'COMMON.INTERACT'
5657 include 'COMMON.DERIV'
5658 include 'COMMON.VAR'
5659 include 'COMMON.CHAIN'
5660 include 'COMMON.IOUNITS'
5661 include 'COMMON.NAMES'
5662 include 'COMMON.FFIELD'
5663 include 'COMMON.CONTROL'
5664 include 'COMMON.TORCNSTR'
5665 common /calcthet/ term1,term2,termm,diffak,ratak,
5666 & ak,aktc,termpre,termexp,sigc,sig0i,time11,time12,sigcsq,
5667 & delthe0,sig0inv,sigtc,sigsqtc,delthec,it
5668 double precision y(2),z(2)
5670 c time11=dexp(-2*time)
5673 c write (*,'(a,i2)') 'EBEND ICG=',icg
5674 do i=ithet_start,ithet_end
5675 c write (iout,*) "ebend: i=",i
5677 if ((itype(i-1).eq.ntyp1).or.itype(i-2).eq.ntyp1
5678 & .or.itype(i).eq.ntyp1) cycle
5679 C Zero the energy function and its derivative at 0 or pi.
5680 call splinthet(theta(i),0.5d0*delta,ss,ssd)
5682 ichir1=isign(1,itype(i-2))
5683 ichir2=isign(1,itype(i))
5684 if (itype(i-2).eq.10) ichir1=isign(1,itype(i-1))
5685 if (itype(i).eq.10) ichir2=isign(1,itype(i-1))
5686 if (itype(i-1).eq.10) then
5687 itype1=isign(10,itype(i-2))
5688 ichir11=isign(1,itype(i-2))
5689 ichir12=isign(1,itype(i-2))
5690 itype2=isign(10,itype(i))
5691 ichir21=isign(1,itype(i))
5692 ichir22=isign(1,itype(i))
5695 if (i.gt.3 .and. itype(i-3).ne.ntyp1) then
5698 if (phii.ne.phii) phii=150.0
5708 if (i.lt.nres .and. itype(i+1).ne.ntyp1) then
5711 if (phii1.ne.phii1) phii1=150.0
5723 C Calculate the "mean" value of theta from the part of the distribution
5724 C dependent on the adjacent virtual-bond-valence angles (gamma1 & gamma2).
5725 C In following comments this theta will be referred to as t_c.
5726 thet_pred_mean=0.0d0
5728 athetk=athet(k,it,ichir1,ichir2)
5729 bthetk=bthet(k,it,ichir1,ichir2)
5731 athetk=athet(k,itype1,ichir11,ichir12)
5732 bthetk=bthet(k,itype2,ichir21,ichir22)
5734 thet_pred_mean=thet_pred_mean+athetk*y(k)+bthetk*z(k)
5735 c write(iout,*) 'chuj tu', y(k),z(k)
5737 dthett=thet_pred_mean*ssd
5738 thet_pred_mean=thet_pred_mean*ss+a0thet(it)
5739 C Derivatives of the "mean" values in gamma1 and gamma2.
5740 dthetg1=(-athet(1,it,ichir1,ichir2)*y(2)
5741 &+athet(2,it,ichir1,ichir2)*y(1))*ss
5742 dthetg2=(-bthet(1,it,ichir1,ichir2)*z(2)
5743 & +bthet(2,it,ichir1,ichir2)*z(1))*ss
5745 dthetg1=(-athet(1,itype1,ichir11,ichir12)*y(2)
5746 &+athet(2,itype1,ichir11,ichir12)*y(1))*ss
5747 dthetg2=(-bthet(1,itype2,ichir21,ichir22)*z(2)
5748 & +bthet(2,itype2,ichir21,ichir22)*z(1))*ss
5750 if (theta(i).gt.pi-delta) then
5751 call theteng(pi-delta,thet_pred_mean,theta0(it),f0,fprim0,
5753 call mixder(pi-delta,thet_pred_mean,theta0(it),fprim_tc0)
5754 call theteng(pi,thet_pred_mean,theta0(it),f1,fprim1,E_tc1)
5755 call spline1(theta(i),pi-delta,delta,f0,f1,fprim0,ethetai,
5757 call spline2(theta(i),pi-delta,delta,E_tc0,E_tc1,fprim_tc0,
5759 else if (theta(i).lt.delta) then
5760 call theteng(delta,thet_pred_mean,theta0(it),f0,fprim0,E_tc0)
5761 call theteng(0.0d0,thet_pred_mean,theta0(it),f1,fprim1,E_tc1)
5762 call spline1(theta(i),delta,-delta,f0,f1,fprim0,ethetai,
5764 call mixder(delta,thet_pred_mean,theta0(it),fprim_tc0)
5765 call spline2(theta(i),delta,-delta,E_tc0,E_tc1,fprim_tc0,
5768 call theteng(theta(i),thet_pred_mean,theta0(it),ethetai,
5771 etheta=etheta+ethetai
5772 if (energy_dec) write (iout,'(a6,i5,0pf7.3,f7.3,i5)')
5773 & 'ebend',i,ethetai,theta(i),itype(i)
5774 if (i.gt.3) gloc(i-3,icg)=gloc(i-3,icg)+wang*E_tc*dthetg1
5775 if (i.lt.nres) gloc(i-2,icg)=gloc(i-2,icg)+wang*E_tc*dthetg2
5776 gloc(nphi+i-2,icg)=wang*(E_theta+E_tc*dthett)+gloc(nphi+i-2,icg)
5778 c write (iout,*) "Exit loop"
5781 c write (iout,*) ithetaconstr_start,ithetaconstr_end,"TU"
5783 do i=max0(ithetaconstr_start,1),ithetaconstr_end
5784 itheta=itheta_constr(i)
5785 thetiii=theta(itheta)
5786 difi=pinorm(thetiii-theta_constr0(i))
5787 if (difi.gt.theta_drange(i)) then
5788 difi=difi-theta_drange(i)
5789 ethetacnstr=ethetcnstr+0.25d0*for_thet_constr(i)*difi**4
5790 gloc(itheta+nphi-2,icg)=gloc(itheta+nphi-2,icg)
5791 & +for_thet_constr(i)*difi**3
5792 else if (difi.lt.-drange(i)) then
5794 ethetacnstr=ethetcnstr+0.25d0*for_thet_constr(i)*difi**4
5795 gloc(itheta+nphi-2,icg)=gloc(itheta+nphi-2,icg)
5796 & +for_thet_constr(i)*difi**3
5800 if (energy_dec) then
5801 write (iout,'(a6,2i5,4f8.3,2e14.5)') "ethetc",
5802 & i,itheta,rad2deg*thetiii,
5803 & rad2deg*theta_constr0(i), rad2deg*theta_drange(i),
5804 & rad2deg*difi,0.25d0*for_thet_constr(i)*difi**4,
5805 & gloc(itheta+nphi-2,icg)
5808 c write (iout,*) "Exit ebend"
5811 C Ufff.... We've done all this!!!
5814 C---------------------------------------------------------------------------
5815 subroutine theteng(thetai,thet_pred_mean,theta0i,ethetai,E_theta,
5817 implicit real*8 (a-h,o-z)
5818 include 'DIMENSIONS'
5819 include 'COMMON.LOCAL'
5820 include 'COMMON.IOUNITS'
5821 common /calcthet/ term1,term2,termm,diffak,ratak,
5822 & ak,aktc,termpre,termexp,sigc,sig0i,time11,time12,sigcsq,
5823 & delthe0,sig0inv,sigtc,sigsqtc,delthec,it
5824 C Calculate the contributions to both Gaussian lobes.
5825 C 6/6/97 - Deform the Gaussians using the factor of 1/(1+time)
5826 C The "polynomial part" of the "standard deviation" of this part of
5827 C the distributioni.
5828 ccc write (iout,*) thetai,thet_pred_mean
5831 sig=sig*thet_pred_mean+polthet(j,it)
5833 C Derivative of the "interior part" of the "standard deviation of the"
5834 C gamma-dependent Gaussian lobe in t_c.
5835 sigtc=3*polthet(3,it)
5837 sigtc=sigtc*thet_pred_mean+j*polthet(j,it)
5840 C Set the parameters of both Gaussian lobes of the distribution.
5841 C "Standard deviation" of the gamma-dependent Gaussian lobe (sigtc)
5842 fac=sig*sig+sigc0(it)
5845 C Following variable (sigsqtc) is -(1/2)d[sigma(t_c)**(-2))]/dt_c
5846 sigsqtc=-4.0D0*sigcsq*sigtc
5847 c print *,i,sig,sigtc,sigsqtc
5848 C Following variable (sigtc) is d[sigma(t_c)]/dt_c
5849 sigtc=-sigtc/(fac*fac)
5850 C Following variable is sigma(t_c)**(-2)
5851 sigcsq=sigcsq*sigcsq
5853 sig0inv=1.0D0/sig0i**2
5854 delthec=thetai-thet_pred_mean
5855 delthe0=thetai-theta0i
5856 term1=-0.5D0*sigcsq*delthec*delthec
5857 term2=-0.5D0*sig0inv*delthe0*delthe0
5858 C write (iout,*)'term1',term1,term2,sigcsq,delthec,sig0inv,delthe0
5859 C Following fuzzy logic is to avoid underflows in dexp and subsequent INFs and
5860 C NaNs in taking the logarithm. We extract the largest exponent which is added
5861 C to the energy (this being the log of the distribution) at the end of energy
5862 C term evaluation for this virtual-bond angle.
5863 if (term1.gt.term2) then
5865 term2=dexp(term2-termm)
5869 term1=dexp(term1-termm)
5872 C The ratio between the gamma-independent and gamma-dependent lobes of
5873 C the distribution is a Gaussian function of thet_pred_mean too.
5874 diffak=gthet(2,it)-thet_pred_mean
5875 ratak=diffak/gthet(3,it)**2
5876 ak=dexp(gthet(1,it)-0.5D0*diffak*ratak)
5877 C Let's differentiate it in thet_pred_mean NOW.
5879 C Now put together the distribution terms to make complete distribution.
5880 termexp=term1+ak*term2
5881 termpre=sigc+ak*sig0i
5882 C Contribution of the bending energy from this theta is just the -log of
5883 C the sum of the contributions from the two lobes and the pre-exponential
5884 C factor. Simple enough, isn't it?
5885 ethetai=(-dlog(termexp)-termm+dlog(termpre))
5886 C write (iout,*) 'termexp',termexp,termm,termpre,i
5887 C NOW the derivatives!!!
5888 C 6/6/97 Take into account the deformation.
5889 E_theta=(delthec*sigcsq*term1
5890 & +ak*delthe0*sig0inv*term2)/termexp
5891 E_tc=((sigtc+aktc*sig0i)/termpre
5892 & -((delthec*sigcsq+delthec*delthec*sigsqtc)*term1+
5893 & aktc*term2)/termexp)
5896 c-----------------------------------------------------------------------------
5897 subroutine mixder(thetai,thet_pred_mean,theta0i,E_tc_t)
5898 implicit real*8 (a-h,o-z)
5899 include 'DIMENSIONS'
5900 include 'COMMON.LOCAL'
5901 include 'COMMON.IOUNITS'
5902 common /calcthet/ term1,term2,termm,diffak,ratak,
5903 & ak,aktc,termpre,termexp,sigc,sig0i,time11,time12,sigcsq,
5904 & delthe0,sig0inv,sigtc,sigsqtc,delthec,it
5905 delthec=thetai-thet_pred_mean
5906 delthe0=thetai-theta0i
5907 C "Thank you" to MAPLE (probably spared one day of hand-differentiation).
5908 t3 = thetai-thet_pred_mean
5912 t14 = t12+t6*sigsqtc
5914 t21 = thetai-theta0i
5920 E_tc_t = -((sigcsq+2.D0*t3*sigsqtc)*t9-t14*sigcsq*t3*t16*t9
5921 & -aktc*sig0inv*t27)/t32+(t14*t9+aktc*t26)/t40
5922 & *(-t12*t9-ak*sig0inv*t27)
5926 C--------------------------------------------------------------------------
5927 subroutine ebend(etheta,ethetacnstr)
5929 C Evaluate the virtual-bond-angle energy given the virtual-bond dihedral
5930 C angles gamma and its derivatives in consecutive thetas and gammas.
5931 C ab initio-derived potentials from
5932 c Kozlowska et al., J. Phys.: Condens. Matter 19 (2007) 285203
5934 implicit real*8 (a-h,o-z)
5935 include 'DIMENSIONS'
5936 include 'COMMON.LOCAL'
5937 include 'COMMON.GEO'
5938 include 'COMMON.INTERACT'
5939 include 'COMMON.DERIV'
5940 include 'COMMON.VAR'
5941 include 'COMMON.CHAIN'
5942 include 'COMMON.IOUNITS'
5943 include 'COMMON.NAMES'
5944 include 'COMMON.FFIELD'
5945 include 'COMMON.CONTROL'
5946 include 'COMMON.TORCNSTR'
5947 double precision coskt(mmaxtheterm),sinkt(mmaxtheterm),
5948 & cosph1(maxsingle),sinph1(maxsingle),cosph2(maxsingle),
5949 & sinph2(maxsingle),cosph1ph2(maxdouble,maxdouble),
5950 & sinph1ph2(maxdouble,maxdouble)
5951 logical lprn /.false./, lprn1 /.false./
5953 do i=ithet_start,ithet_end
5955 c print *,i,itype(i-1),itype(i),itype(i-2)
5956 if ((itype(i-1).eq.ntyp1).or.itype(i-2).eq.ntyp1
5957 & .or.itype(i).eq.ntyp1) cycle
5958 C print *,i,theta(i)
5959 if (iabs(itype(i+1)).eq.20) iblock=2
5960 if (iabs(itype(i+1)).ne.20) iblock=1
5964 theti2=0.5d0*theta(i)
5965 ityp2=ithetyp((itype(i-1)))
5967 coskt(k)=dcos(k*theti2)
5968 sinkt(k)=dsin(k*theti2)
5980 if (i.gt.3 .and. itype(i-3).ne.ntyp1) then
5983 if (phii.ne.phii) phii=150.0
5987 ityp1=ithetyp((itype(i-2)))
5988 C propagation of chirality for glycine type
5990 cosph1(k)=dcos(k*phii)
5991 sinph1(k)=dsin(k*phii)
5996 ityp1=ithetyp((itype(i-2)))
6002 if (i.lt.nres .and. itype(i+1).ne.ntyp1) then
6005 if (phii1.ne.phii1) phii1=150.0
6010 ityp3=ithetyp((itype(i)))
6012 cosph2(k)=dcos(k*phii1)
6013 sinph2(k)=dsin(k*phii1)
6017 ityp3=ithetyp((itype(i)))
6023 ethetai=aa0thet(ityp1,ityp2,ityp3,iblock)
6026 ccl=cosph1(l)*cosph2(k-l)
6027 ssl=sinph1(l)*sinph2(k-l)
6028 scl=sinph1(l)*cosph2(k-l)
6029 csl=cosph1(l)*sinph2(k-l)
6030 cosph1ph2(l,k)=ccl-ssl
6031 cosph1ph2(k,l)=ccl+ssl
6032 sinph1ph2(l,k)=scl+csl
6033 sinph1ph2(k,l)=scl-csl
6037 write (iout,*) "i",i," ityp1",ityp1," ityp2",ityp2,
6038 & " ityp3",ityp3," theti2",theti2," phii",phii," phii1",phii1
6039 write (iout,*) "coskt and sinkt"
6041 write (iout,*) k,coskt(k),sinkt(k)
6045 ethetai=ethetai+aathet(k,ityp1,ityp2,ityp3,iblock)*sinkt(k)
6046 dethetai=dethetai+0.5d0*k*aathet(k,ityp1,ityp2,ityp3,iblock)
6049 & write (iout,*) "k",k,"
6050 & aathet",aathet(k,ityp1,ityp2,ityp3,iblock),
6051 & " ethetai",ethetai
6054 write (iout,*) "cosph and sinph"
6056 write (iout,*) k,cosph1(k),sinph1(k),cosph2(k),sinph2(k)
6058 write (iout,*) "cosph1ph2 and sinph2ph2"
6061 write (iout,*) l,k,cosph1ph2(l,k),cosph1ph2(k,l),
6062 & sinph1ph2(l,k),sinph1ph2(k,l)
6065 write(iout,*) "ethetai",ethetai
6070 aux=bbthet(k,m,ityp1,ityp2,ityp3,iblock)*cosph1(k)
6071 & +ccthet(k,m,ityp1,ityp2,ityp3,iblock)*sinph1(k)
6072 & +ddthet(k,m,ityp1,ityp2,ityp3,iblock)*cosph2(k)
6073 & +eethet(k,m,ityp1,ityp2,ityp3,iblock)*sinph2(k)
6074 ethetai=ethetai+sinkt(m)*aux
6075 dethetai=dethetai+0.5d0*m*aux*coskt(m)
6076 dephii=dephii+k*sinkt(m)*(
6077 & ccthet(k,m,ityp1,ityp2,ityp3,iblock)*cosph1(k)-
6078 & bbthet(k,m,ityp1,ityp2,ityp3,iblock)*sinph1(k))
6079 dephii1=dephii1+k*sinkt(m)*(
6080 & eethet(k,m,ityp1,ityp2,ityp3,iblock)*cosph2(k)-
6081 & ddthet(k,m,ityp1,ityp2,ityp3,iblock)*sinph2(k))
6083 & write (iout,*) "m",m," k",k," bbthet",
6084 & bbthet(k,m,ityp1,ityp2,ityp3,iblock)," ccthet",
6085 & ccthet(k,m,ityp1,ityp2,ityp3,iblock)," ddthet",
6086 & ddthet(k,m,ityp1,ityp2,ityp3,iblock)," eethet",
6087 & eethet(k,m,ityp1,ityp2,ityp3,iblock)," ethetai",ethetai
6088 C print *,"tu",cosph1(k),sinph1(k),cosph2(k),sinph2(k)
6091 C print *,"cosph1", (cosph1(k), k=1,nsingle)
6092 C print *,"cosph2", (cosph2(k), k=1,nsingle)
6093 C print *,"sinph1", (sinph1(k), k=1,nsingle)
6094 C print *,"sinph2", (sinph2(k), k=1,nsingle)
6096 & write(iout,*) "ethetai",ethetai
6097 C print *,"tu",cosph1(k),sinph1(k),cosph2(k),sinph2(k)
6101 aux=ffthet(l,k,m,ityp1,ityp2,ityp3,iblock)*cosph1ph2(l,k)+
6102 & ffthet(k,l,m,ityp1,ityp2,ityp3,iblock)*cosph1ph2(k,l)+
6103 & ggthet(l,k,m,ityp1,ityp2,ityp3,iblock)*sinph1ph2(l,k)+
6104 & ggthet(k,l,m,ityp1,ityp2,ityp3,iblock)*sinph1ph2(k,l)
6105 ethetai=ethetai+sinkt(m)*aux
6106 dethetai=dethetai+0.5d0*m*coskt(m)*aux
6107 dephii=dephii+l*sinkt(m)*(
6108 & -ffthet(l,k,m,ityp1,ityp2,ityp3,iblock)*sinph1ph2(l,k)-
6109 & ffthet(k,l,m,ityp1,ityp2,ityp3,iblock)*sinph1ph2(k,l)+
6110 & ggthet(l,k,m,ityp1,ityp2,ityp3,iblock)*cosph1ph2(l,k)+
6111 & ggthet(k,l,m,ityp1,ityp2,ityp3,iblock)*cosph1ph2(k,l))
6112 dephii1=dephii1+(k-l)*sinkt(m)*(
6113 & -ffthet(l,k,m,ityp1,ityp2,ityp3,iblock)*sinph1ph2(l,k)+
6114 & ffthet(k,l,m,ityp1,ityp2,ityp3,iblock)*sinph1ph2(k,l)+
6115 & ggthet(l,k,m,ityp1,ityp2,ityp3,iblock)*cosph1ph2(l,k)-
6116 & ggthet(k,l,m,ityp1,ityp2,ityp3,iblock)*cosph1ph2(k,l))
6118 write (iout,*) "m",m," k",k," l",l," ffthet",
6119 & ffthet(l,k,m,ityp1,ityp2,ityp3,iblock),
6120 & ffthet(k,l,m,ityp1,ityp2,ityp3,iblock)," ggthet",
6121 & ggthet(l,k,m,ityp1,ityp2,ityp3,iblock),
6122 & ggthet(k,l,m,ityp1,ityp2,ityp3,iblock),
6123 & " ethetai",ethetai
6124 write (iout,*) cosph1ph2(l,k)*sinkt(m),
6125 & cosph1ph2(k,l)*sinkt(m),
6126 & sinph1ph2(l,k)*sinkt(m),sinph1ph2(k,l)*sinkt(m)
6135 & write (iout,'(i2,3f8.1,9h ethetai ,f10.5)')
6136 & i,theta(i)*rad2deg,phii*rad2deg,
6137 & phii1*rad2deg,ethetai
6139 etheta=etheta+ethetai
6140 if (i.gt.3) gloc(i-3,icg)=gloc(i-3,icg)+wang*dephii
6141 if (i.lt.nres) gloc(i-2,icg)=gloc(i-2,icg)+wang*dephii1
6142 gloc(nphi+i-2,icg)=gloc(nphi+i-2,icg)+wang*dethetai
6146 C print *,ithetaconstr_start,ithetaconstr_end,"TU"
6147 do i=max0(ithetaconstr_start,1),ithetaconstr_end
6148 itheta=itheta_constr(i)
6149 thetiii=theta(itheta)
6150 difi=pinorm(thetiii-theta_constr0(i))
6151 if (difi.gt.theta_drange(i)) then
6152 difi=difi-theta_drange(i)
6153 ethetacnstr=ethetacnstr+0.25d0*for_thet_constr(i)*difi**4
6154 gloc(itheta+nphi-2,icg)=gloc(itheta+nphi-2,icg)
6155 & +for_thet_constr(i)*difi**3
6156 else if (difi.lt.-drange(i)) then
6158 ethetacnstr=ethetacnstr+0.25d0*for_thet_constr(i)*difi**4
6159 gloc(itheta+nphi-2,icg)=gloc(itheta+nphi-2,icg)
6160 & +for_thet_constr(i)*difi**3
6164 if (energy_dec) then
6165 write (iout,'(a6,2i5,4f8.3,2e14.5)') "ethetc",
6166 & i,itheta,rad2deg*thetiii,
6167 & rad2deg*theta_constr0(i), rad2deg*theta_drange(i),
6168 & rad2deg*difi,0.25d0*for_thet_constr(i)*difi**4,
6169 & gloc(itheta+nphi-2,icg)
6177 c-----------------------------------------------------------------------------
6178 subroutine esc(escloc)
6179 C Calculate the local energy of a side chain and its derivatives in the
6180 C corresponding virtual-bond valence angles THETA and the spherical angles
6182 implicit real*8 (a-h,o-z)
6183 include 'DIMENSIONS'
6184 include 'COMMON.GEO'
6185 include 'COMMON.LOCAL'
6186 include 'COMMON.VAR'
6187 include 'COMMON.INTERACT'
6188 include 'COMMON.DERIV'
6189 include 'COMMON.CHAIN'
6190 include 'COMMON.IOUNITS'
6191 include 'COMMON.NAMES'
6192 include 'COMMON.FFIELD'
6193 include 'COMMON.CONTROL'
6194 double precision x(3),dersc(3),xemp(3),dersc0(3),dersc1(3),
6195 & ddersc0(3),ddummy(3),xtemp(3),temp(3)
6196 common /sccalc/ time11,time12,time112,theti,it,nlobit
6199 c write (iout,'(a)') 'ESC'
6200 do i=loc_start,loc_end
6202 if (it.eq.ntyp1) cycle
6203 if (it.eq.10) goto 1
6204 nlobit=nlob(iabs(it))
6205 c print *,'i=',i,' it=',it,' nlobit=',nlobit
6206 c write (iout,*) 'i=',i,' ssa=',ssa,' ssad=',ssad
6207 theti=theta(i+1)-pipol
6212 if (x(2).gt.pi-delta) then
6216 call enesc(xtemp,escloci0,dersc0,ddersc0,.true.)
6218 call enesc(xtemp,escloci1,dersc1,ddummy,.false.)
6219 call spline1(x(2),pi-delta,delta,escloci0,escloci1,dersc0(2),
6221 call spline2(x(2),pi-delta,delta,dersc0(1),dersc1(1),
6222 & ddersc0(1),dersc(1))
6223 call spline2(x(2),pi-delta,delta,dersc0(3),dersc1(3),
6224 & ddersc0(3),dersc(3))
6226 call enesc_bound(xtemp,esclocbi0,dersc0,dersc12,.true.)
6228 call enesc_bound(xtemp,esclocbi1,dersc1,chuju,.false.)
6229 call spline1(x(2),pi-delta,delta,esclocbi0,esclocbi1,
6230 & dersc0(2),esclocbi,dersc02)
6231 call spline2(x(2),pi-delta,delta,dersc0(1),dersc1(1),
6233 call splinthet(x(2),0.5d0*delta,ss,ssd)
6238 dersc(k)=ss*dersc(k)+(1.0d0-ss)*dersc0(k)
6240 dersc(2)=dersc(2)+ssd*(escloci-esclocbi)
6241 c write (iout,*) 'i=',i,x(2)*rad2deg,escloci0,escloci,
6243 escloci=ss*escloci+(1.0d0-ss)*esclocbi
6245 c write (iout,*) escloci
6246 else if (x(2).lt.delta) then
6250 call enesc(xtemp,escloci0,dersc0,ddersc0,.true.)
6252 call enesc(xtemp,escloci1,dersc1,ddummy,.false.)
6253 call spline1(x(2),delta,-delta,escloci0,escloci1,dersc0(2),
6255 call spline2(x(2),delta,-delta,dersc0(1),dersc1(1),
6256 & ddersc0(1),dersc(1))
6257 call spline2(x(2),delta,-delta,dersc0(3),dersc1(3),
6258 & ddersc0(3),dersc(3))
6260 call enesc_bound(xtemp,esclocbi0,dersc0,dersc12,.true.)
6262 call enesc_bound(xtemp,esclocbi1,dersc1,chuju,.false.)
6263 call spline1(x(2),delta,-delta,esclocbi0,esclocbi1,
6264 & dersc0(2),esclocbi,dersc02)
6265 call spline2(x(2),delta,-delta,dersc0(1),dersc1(1),
6270 call splinthet(x(2),0.5d0*delta,ss,ssd)
6272 dersc(k)=ss*dersc(k)+(1.0d0-ss)*dersc0(k)
6274 dersc(2)=dersc(2)+ssd*(escloci-esclocbi)
6275 c write (iout,*) 'i=',i,x(2)*rad2deg,escloci0,escloci,
6277 escloci=ss*escloci+(1.0d0-ss)*esclocbi
6278 c write (iout,*) escloci
6280 call enesc(x,escloci,dersc,ddummy,.false.)
6283 escloc=escloc+escloci
6284 if (energy_dec) write (iout,'(a6,i5,0pf7.3)')
6285 & 'escloc',i,escloci
6286 c write (iout,*) 'i=',i,' escloci=',escloci,' dersc=',dersc
6288 gloc(nphi+i-1,icg)=gloc(nphi+i-1,icg)+
6290 gloc(ialph(i,1),icg)=wscloc*dersc(2)
6291 gloc(ialph(i,1)+nside,icg)=wscloc*dersc(3)
6296 C---------------------------------------------------------------------------
6297 subroutine enesc(x,escloci,dersc,ddersc,mixed)
6298 implicit real*8 (a-h,o-z)
6299 include 'DIMENSIONS'
6300 include 'COMMON.GEO'
6301 include 'COMMON.LOCAL'
6302 include 'COMMON.IOUNITS'
6303 common /sccalc/ time11,time12,time112,theti,it,nlobit
6304 double precision x(3),z(3),Ax(3,maxlob,-1:1),dersc(3),ddersc(3)
6305 double precision contr(maxlob,-1:1)
6307 c write (iout,*) 'it=',it,' nlobit=',nlobit
6311 if (mixed) ddersc(j)=0.0d0
6315 C Because of periodicity of the dependence of the SC energy in omega we have
6316 C to add up the contributions from x(3)-2*pi, x(3), and x(3+2*pi).
6317 C To avoid underflows, first compute & store the exponents.
6325 z(k)=x(k)-censc(k,j,it)
6330 Axk=Axk+gaussc(l,k,j,it)*z(l)
6336 expfac=expfac+Ax(k,j,iii)*z(k)
6344 C As in the case of ebend, we want to avoid underflows in exponentiation and
6345 C subsequent NaNs and INFs in energy calculation.
6346 C Find the largest exponent
6350 if (emin.gt.contr(j,iii)) emin=contr(j,iii)
6354 cd print *,'it=',it,' emin=',emin
6356 C Compute the contribution to SC energy and derivatives
6361 adexp=bsc(j,iabs(it))-0.5D0*contr(j,iii)+emin
6362 if(adexp.ne.adexp) adexp=1.0
6365 expfac=dexp(bsc(j,iabs(it))-0.5D0*contr(j,iii)+emin)
6367 cd print *,'j=',j,' expfac=',expfac
6368 escloc_i=escloc_i+expfac
6370 dersc(k)=dersc(k)+Ax(k,j,iii)*expfac
6374 ddersc(k)=ddersc(k)+(-Ax(2,j,iii)*Ax(k,j,iii)
6375 & +gaussc(k,2,j,it))*expfac
6382 dersc(1)=dersc(1)/cos(theti)**2
6383 ddersc(1)=ddersc(1)/cos(theti)**2
6386 escloci=-(dlog(escloc_i)-emin)
6388 dersc(j)=dersc(j)/escloc_i
6392 ddersc(j)=(ddersc(j)/escloc_i+dersc(2)*dersc(j))
6397 C------------------------------------------------------------------------------
6398 subroutine enesc_bound(x,escloci,dersc,dersc12,mixed)
6399 implicit real*8 (a-h,o-z)
6400 include 'DIMENSIONS'
6401 include 'COMMON.GEO'
6402 include 'COMMON.LOCAL'
6403 include 'COMMON.IOUNITS'
6404 common /sccalc/ time11,time12,time112,theti,it,nlobit
6405 double precision x(3),z(3),Ax(3,maxlob),dersc(3)
6406 double precision contr(maxlob)
6417 z(k)=x(k)-censc(k,j,it)
6423 Axk=Axk+gaussc(l,k,j,it)*z(l)
6429 expfac=expfac+Ax(k,j)*z(k)
6434 C As in the case of ebend, we want to avoid underflows in exponentiation and
6435 C subsequent NaNs and INFs in energy calculation.
6436 C Find the largest exponent
6439 if (emin.gt.contr(j)) emin=contr(j)
6443 C Compute the contribution to SC energy and derivatives
6447 expfac=dexp(bsc(j,iabs(it))-0.5D0*contr(j)+emin)
6448 escloc_i=escloc_i+expfac
6450 dersc(k)=dersc(k)+Ax(k,j)*expfac
6452 if (mixed) dersc12=dersc12+(-Ax(2,j)*Ax(1,j)
6453 & +gaussc(1,2,j,it))*expfac
6457 dersc(1)=dersc(1)/cos(theti)**2
6458 dersc12=dersc12/cos(theti)**2
6459 escloci=-(dlog(escloc_i)-emin)
6461 dersc(j)=dersc(j)/escloc_i
6463 if (mixed) dersc12=(dersc12/escloc_i+dersc(2)*dersc(1))
6467 c----------------------------------------------------------------------------------
6468 subroutine esc(escloc)
6469 C Calculate the local energy of a side chain and its derivatives in the
6470 C corresponding virtual-bond valence angles THETA and the spherical angles
6471 C ALPHA and OMEGA derived from AM1 all-atom calculations.
6472 C added by Urszula Kozlowska. 07/11/2007
6474 implicit real*8 (a-h,o-z)
6475 include 'DIMENSIONS'
6476 include 'COMMON.GEO'
6477 include 'COMMON.LOCAL'
6478 include 'COMMON.VAR'
6479 include 'COMMON.SCROT'
6480 include 'COMMON.INTERACT'
6481 include 'COMMON.DERIV'
6482 include 'COMMON.CHAIN'
6483 include 'COMMON.IOUNITS'
6484 include 'COMMON.NAMES'
6485 include 'COMMON.FFIELD'
6486 include 'COMMON.CONTROL'
6487 include 'COMMON.VECTORS'
6488 double precision x_prime(3),y_prime(3),z_prime(3)
6489 & , sumene,dsc_i,dp2_i,x(65),
6490 & xx,yy,zz,sumene1,sumene2,sumene3,sumene4,s1,s1_6,s2,s2_6,
6491 & de_dxx,de_dyy,de_dzz,de_dt
6492 double precision s1_t,s1_6_t,s2_t,s2_6_t
6494 & dXX_Ci1(3),dYY_Ci1(3),dZZ_Ci1(3),dXX_Ci(3),
6495 & dYY_Ci(3),dZZ_Ci(3),dXX_XYZ(3),dYY_XYZ(3),dZZ_XYZ(3),
6496 & dt_dCi(3),dt_dCi1(3)
6497 common /sccalc/ time11,time12,time112,theti,it,nlobit
6500 do i=loc_start,loc_end
6501 if (itype(i).eq.ntyp1) cycle
6502 costtab(i+1) =dcos(theta(i+1))
6503 sinttab(i+1) =dsqrt(1-costtab(i+1)*costtab(i+1))
6504 cost2tab(i+1)=dsqrt(0.5d0*(1.0d0+costtab(i+1)))
6505 sint2tab(i+1)=dsqrt(0.5d0*(1.0d0-costtab(i+1)))
6506 cosfac2=0.5d0/(1.0d0+costtab(i+1))
6507 cosfac=dsqrt(cosfac2)
6508 sinfac2=0.5d0/(1.0d0-costtab(i+1))
6509 sinfac=dsqrt(sinfac2)
6511 if (it.eq.10) goto 1
6513 C Compute the axes of tghe local cartesian coordinates system; store in
6514 c x_prime, y_prime and z_prime
6521 C write(2,*) "dc_norm", dc_norm(1,i+nres),dc_norm(2,i+nres),
6522 C & dc_norm(3,i+nres)
6524 x_prime(j) = (dc_norm(j,i) - dc_norm(j,i-1))*cosfac
6525 y_prime(j) = (dc_norm(j,i) + dc_norm(j,i-1))*sinfac
6528 z_prime(j) = -uz(j,i-1)*dsign(1.0d0,dfloat(itype(i)))
6531 c write (2,*) "x_prime",(x_prime(j),j=1,3)
6532 c write (2,*) "y_prime",(y_prime(j),j=1,3)
6533 c write (2,*) "z_prime",(z_prime(j),j=1,3)
6534 c write (2,*) "xx",scalar(x_prime(1),x_prime(1)),
6535 c & " xy",scalar(x_prime(1),y_prime(1)),
6536 c & " xz",scalar(x_prime(1),z_prime(1)),
6537 c & " yy",scalar(y_prime(1),y_prime(1)),
6538 c & " yz",scalar(y_prime(1),z_prime(1)),
6539 c & " zz",scalar(z_prime(1),z_prime(1))
6541 C Transform the unit vector of the ith side-chain centroid, dC_norm(*,i),
6542 C to local coordinate system. Store in xx, yy, zz.
6548 xx = xx + x_prime(j)*dc_norm(j,i+nres)
6549 yy = yy + y_prime(j)*dc_norm(j,i+nres)
6550 zz = zz + z_prime(j)*dc_norm(j,i+nres)
6557 C Compute the energy of the ith side cbain
6559 c write (2,*) "xx",xx," yy",yy," zz",zz
6562 x(j) = sc_parmin(j,it)
6565 Cc diagnostics - remove later
6567 yy1 = dsin(alph(2))*dcos(omeg(2))
6568 zz1 = -dsign(1.0,dfloat(itype(i)))*dsin(alph(2))*dsin(omeg(2))
6569 write(2,'(3f8.1,3f9.3,1x,3f9.3)')
6570 & alph(2)*rad2deg,omeg(2)*rad2deg,theta(3)*rad2deg,xx,yy,zz,
6572 C," --- ", xx_w,yy_w,zz_w
6575 sumene1= x(1)+ x(2)*xx+ x(3)*yy+ x(4)*zz+ x(5)*xx**2
6576 & + x(6)*yy**2+ x(7)*zz**2+ x(8)*xx*zz+ x(9)*xx*yy
6578 sumene2= x(11) + x(12)*xx + x(13)*yy + x(14)*zz + x(15)*xx**2
6579 & + x(16)*yy**2 + x(17)*zz**2 + x(18)*xx*zz + x(19)*xx*yy
6581 sumene3= x(21) +x(22)*xx +x(23)*yy +x(24)*zz +x(25)*xx**2
6582 & +x(26)*yy**2 +x(27)*zz**2 +x(28)*xx*zz +x(29)*xx*yy
6583 & +x(30)*yy*zz +x(31)*xx**3 +x(32)*yy**3 +x(33)*zz**3
6584 & +x(34)*(xx**2)*yy +x(35)*(xx**2)*zz +x(36)*(yy**2)*xx
6585 & +x(37)*(yy**2)*zz +x(38)*(zz**2)*xx +x(39)*(zz**2)*yy
6587 sumene4= x(41) +x(42)*xx +x(43)*yy +x(44)*zz +x(45)*xx**2
6588 & +x(46)*yy**2 +x(47)*zz**2 +x(48)*xx*zz +x(49)*xx*yy
6589 & +x(50)*yy*zz +x(51)*xx**3 +x(52)*yy**3 +x(53)*zz**3
6590 & +x(54)*(xx**2)*yy +x(55)*(xx**2)*zz +x(56)*(yy**2)*xx
6591 & +x(57)*(yy**2)*zz +x(58)*(zz**2)*xx +x(59)*(zz**2)*yy
6593 dsc_i = 0.743d0+x(61)
6595 dscp1=dsqrt(dsc_i**2+dp2_i**2-2*dsc_i*dp2_i
6596 & *(xx*cost2tab(i+1)+yy*sint2tab(i+1)))
6597 dscp2=dsqrt(dsc_i**2+dp2_i**2-2*dsc_i*dp2_i
6598 & *(xx*cost2tab(i+1)-yy*sint2tab(i+1)))
6599 s1=(1+x(63))/(0.1d0 + dscp1)
6600 s1_6=(1+x(64))/(0.1d0 + dscp1**6)
6601 s2=(1+x(65))/(0.1d0 + dscp2)
6602 s2_6=(1+x(65))/(0.1d0 + dscp2**6)
6603 sumene = ( sumene3*sint2tab(i+1) + sumene1)*(s1+s1_6)
6604 & + (sumene4*cost2tab(i+1) +sumene2)*(s2+s2_6)
6605 c write(2,'(i2," sumene",7f9.3)') i,sumene1,sumene2,sumene3,
6607 c & dscp1,dscp2,sumene
6608 c sumene = enesc(x,xx,yy,zz,cost2tab(i+1),sint2tab(i+1))
6609 escloc = escloc + sumene
6610 c write (2,*) "i",i," escloc",sumene,escloc,it,itype(i)
6615 C This section to check the numerical derivatives of the energy of ith side
6616 C chain in xx, yy, zz, and theta. Use the -DDEBUG compiler option or insert
6617 C #define DEBUG in the code to turn it on.
6619 write (2,*) "sumene =",sumene
6623 write (2,*) xx,yy,zz
6624 sumenep = enesc(x,xx,yy,zz,cost2tab(i+1),sint2tab(i+1))
6625 de_dxx_num=(sumenep-sumene)/aincr
6627 write (2,*) "xx+ sumene from enesc=",sumenep
6630 write (2,*) xx,yy,zz
6631 sumenep = enesc(x,xx,yy,zz,cost2tab(i+1),sint2tab(i+1))
6632 de_dyy_num=(sumenep-sumene)/aincr
6634 write (2,*) "yy+ sumene from enesc=",sumenep
6637 write (2,*) xx,yy,zz
6638 sumenep = enesc(x,xx,yy,zz,cost2tab(i+1),sint2tab(i+1))
6639 de_dzz_num=(sumenep-sumene)/aincr
6641 write (2,*) "zz+ sumene from enesc=",sumenep
6642 costsave=cost2tab(i+1)
6643 sintsave=sint2tab(i+1)
6644 cost2tab(i+1)=dcos(0.5d0*(theta(i+1)+aincr))
6645 sint2tab(i+1)=dsin(0.5d0*(theta(i+1)+aincr))
6646 sumenep = enesc(x,xx,yy,zz,cost2tab(i+1),sint2tab(i+1))
6647 de_dt_num=(sumenep-sumene)/aincr
6648 write (2,*) " t+ sumene from enesc=",sumenep
6649 cost2tab(i+1)=costsave
6650 sint2tab(i+1)=sintsave
6651 C End of diagnostics section.
6654 C Compute the gradient of esc
6656 c zz=zz*dsign(1.0,dfloat(itype(i)))
6657 pom_s1=(1.0d0+x(63))/(0.1d0 + dscp1)**2
6658 pom_s16=6*(1.0d0+x(64))/(0.1d0 + dscp1**6)**2
6659 pom_s2=(1.0d0+x(65))/(0.1d0 + dscp2)**2
6660 pom_s26=6*(1.0d0+x(65))/(0.1d0 + dscp2**6)**2
6661 pom_dx=dsc_i*dp2_i*cost2tab(i+1)
6662 pom_dy=dsc_i*dp2_i*sint2tab(i+1)
6663 pom_dt1=-0.5d0*dsc_i*dp2_i*(xx*sint2tab(i+1)-yy*cost2tab(i+1))
6664 pom_dt2=-0.5d0*dsc_i*dp2_i*(xx*sint2tab(i+1)+yy*cost2tab(i+1))
6665 pom1=(sumene3*sint2tab(i+1)+sumene1)
6666 & *(pom_s1/dscp1+pom_s16*dscp1**4)
6667 pom2=(sumene4*cost2tab(i+1)+sumene2)
6668 & *(pom_s2/dscp2+pom_s26*dscp2**4)
6669 sumene1x=x(2)+2*x(5)*xx+x(8)*zz+ x(9)*yy
6670 sumene3x=x(22)+2*x(25)*xx+x(28)*zz+x(29)*yy+3*x(31)*xx**2
6671 & +2*x(34)*xx*yy +2*x(35)*xx*zz +x(36)*(yy**2) +x(38)*(zz**2)
6673 sumene2x=x(12)+2*x(15)*xx+x(18)*zz+ x(19)*yy
6674 sumene4x=x(42)+2*x(45)*xx +x(48)*zz +x(49)*yy +3*x(51)*xx**2
6675 & +2*x(54)*xx*yy+2*x(55)*xx*zz+x(56)*(yy**2)+x(58)*(zz**2)
6677 de_dxx =(sumene1x+sumene3x*sint2tab(i+1))*(s1+s1_6)
6678 & +(sumene2x+sumene4x*cost2tab(i+1))*(s2+s2_6)
6679 & +(pom1+pom2)*pom_dx
6681 write(2,*), "de_dxx = ", de_dxx,de_dxx_num,itype(i)
6684 sumene1y=x(3) + 2*x(6)*yy + x(9)*xx + x(10)*zz
6685 sumene3y=x(23) +2*x(26)*yy +x(29)*xx +x(30)*zz +3*x(32)*yy**2
6686 & +x(34)*(xx**2) +2*x(36)*yy*xx +2*x(37)*yy*zz +x(39)*(zz**2)
6688 sumene2y=x(13) + 2*x(16)*yy + x(19)*xx + x(20)*zz
6689 sumene4y=x(43)+2*x(46)*yy+x(49)*xx +x(50)*zz
6690 & +3*x(52)*yy**2+x(54)*xx**2+2*x(56)*yy*xx +2*x(57)*yy*zz
6691 & +x(59)*zz**2 +x(60)*xx*zz
6692 de_dyy =(sumene1y+sumene3y*sint2tab(i+1))*(s1+s1_6)
6693 & +(sumene2y+sumene4y*cost2tab(i+1))*(s2+s2_6)
6694 & +(pom1-pom2)*pom_dy
6696 write(2,*), "de_dyy = ", de_dyy,de_dyy_num,itype(i)
6699 de_dzz =(x(24) +2*x(27)*zz +x(28)*xx +x(30)*yy
6700 & +3*x(33)*zz**2 +x(35)*xx**2 +x(37)*yy**2 +2*x(38)*zz*xx
6701 & +2*x(39)*zz*yy +x(40)*xx*yy)*sint2tab(i+1)*(s1+s1_6)
6702 & +(x(4) + 2*x(7)*zz+ x(8)*xx + x(10)*yy)*(s1+s1_6)
6703 & +(x(44)+2*x(47)*zz +x(48)*xx +x(50)*yy +3*x(53)*zz**2
6704 & +x(55)*xx**2 +x(57)*(yy**2)+2*x(58)*zz*xx +2*x(59)*zz*yy
6705 & +x(60)*xx*yy)*cost2tab(i+1)*(s2+s2_6)
6706 & + ( x(14) + 2*x(17)*zz+ x(18)*xx + x(20)*yy)*(s2+s2_6)
6708 write(2,*), "de_dzz = ", de_dzz,de_dzz_num,itype(i)
6711 de_dt = 0.5d0*sumene3*cost2tab(i+1)*(s1+s1_6)
6712 & -0.5d0*sumene4*sint2tab(i+1)*(s2+s2_6)
6713 & +pom1*pom_dt1+pom2*pom_dt2
6715 write(2,*), "de_dt = ", de_dt,de_dt_num,itype(i)
6720 cossc=scalar(dc_norm(1,i),dc_norm(1,i+nres))
6721 cossc1=scalar(dc_norm(1,i-1),dc_norm(1,i+nres))
6722 cosfac2xx=cosfac2*xx
6723 sinfac2yy=sinfac2*yy
6725 dt_dCi(k) = -(dc_norm(k,i-1)+costtab(i+1)*dc_norm(k,i))*
6727 dt_dCi1(k)= -(dc_norm(k,i)+costtab(i+1)*dc_norm(k,i-1))*
6729 pom=(dC_norm(k,i+nres)-cossc*dC_norm(k,i))*vbld_inv(i+1)
6730 pom1=(dC_norm(k,i+nres)-cossc1*dC_norm(k,i-1))*vbld_inv(i)
6731 c write (iout,*) "i",i," k",k," pom",pom," pom1",pom1,
6732 c & " dt_dCi",dt_dCi(k)," dt_dCi1",dt_dCi1(k)
6733 c write (iout,*) "dC_norm",(dC_norm(j,i),j=1,3),
6734 c & (dC_norm(j,i-1),j=1,3)," vbld_inv",vbld_inv(i+1),vbld_inv(i)
6735 dXX_Ci(k)=pom*cosfac-dt_dCi(k)*cosfac2xx
6736 dXX_Ci1(k)=-pom1*cosfac-dt_dCi1(k)*cosfac2xx
6737 dYY_Ci(k)=pom*sinfac+dt_dCi(k)*sinfac2yy
6738 dYY_Ci1(k)=pom1*sinfac+dt_dCi1(k)*sinfac2yy
6742 dZZ_Ci(k)=dZZ_Ci(k)-uzgrad(j,k,2,i-1)
6743 & *dsign(1.0d0,dfloat(itype(i)))*dC_norm(j,i+nres)
6744 dZZ_Ci1(k)=dZZ_Ci1(k)-uzgrad(j,k,1,i-1)
6745 & *dsign(1.0d0,dfloat(itype(i)))*dC_norm(j,i+nres)
6748 dXX_XYZ(k)=vbld_inv(i+nres)*(x_prime(k)-xx*dC_norm(k,i+nres))
6749 dYY_XYZ(k)=vbld_inv(i+nres)*(y_prime(k)-yy*dC_norm(k,i+nres))
6750 dZZ_XYZ(k)=vbld_inv(i+nres)*
6751 & (z_prime(k)-zz*dC_norm(k,i+nres))
6753 dt_dCi(k) = -dt_dCi(k)/sinttab(i+1)
6754 dt_dCi1(k)= -dt_dCi1(k)/sinttab(i+1)
6758 dXX_Ctab(k,i)=dXX_Ci(k)
6759 dXX_C1tab(k,i)=dXX_Ci1(k)
6760 dYY_Ctab(k,i)=dYY_Ci(k)
6761 dYY_C1tab(k,i)=dYY_Ci1(k)
6762 dZZ_Ctab(k,i)=dZZ_Ci(k)
6763 dZZ_C1tab(k,i)=dZZ_Ci1(k)
6764 dXX_XYZtab(k,i)=dXX_XYZ(k)
6765 dYY_XYZtab(k,i)=dYY_XYZ(k)
6766 dZZ_XYZtab(k,i)=dZZ_XYZ(k)
6770 c write (iout,*) "k",k," dxx_ci1",dxx_ci1(k)," dyy_ci1",
6771 c & dyy_ci1(k)," dzz_ci1",dzz_ci1(k)
6772 c write (iout,*) "k",k," dxx_ci",dxx_ci(k)," dyy_ci",
6773 c & dyy_ci(k)," dzz_ci",dzz_ci(k)
6774 c write (iout,*) "k",k," dt_dci",dt_dci(k)," dt_dci",
6776 c write (iout,*) "k",k," dxx_XYZ",dxx_XYZ(k)," dyy_XYZ",
6777 c & dyy_XYZ(k)," dzz_XYZ",dzz_XYZ(k)
6778 gscloc(k,i-1)=gscloc(k,i-1)+de_dxx*dxx_ci1(k)
6779 & +de_dyy*dyy_ci1(k)+de_dzz*dzz_ci1(k)+de_dt*dt_dCi1(k)
6780 gscloc(k,i)=gscloc(k,i)+de_dxx*dxx_Ci(k)
6781 & +de_dyy*dyy_Ci(k)+de_dzz*dzz_Ci(k)+de_dt*dt_dCi(k)
6782 gsclocx(k,i)= de_dxx*dxx_XYZ(k)
6783 & +de_dyy*dyy_XYZ(k)+de_dzz*dzz_XYZ(k)
6785 c write(iout,*) "ENERGY GRAD = ", (gscloc(k,i-1),k=1,3),
6786 c & (gscloc(k,i),k=1,3),(gsclocx(k,i),k=1,3)
6788 C to check gradient call subroutine check_grad
6794 c------------------------------------------------------------------------------
6795 double precision function enesc(x,xx,yy,zz,cost2,sint2)
6797 double precision x(65),xx,yy,zz,cost2,sint2,sumene1,sumene2,
6798 & sumene3,sumene4,sumene,dsc_i,dp2_i,dscp1,dscp2,s1,s1_6,s2,s2_6
6799 sumene1= x(1)+ x(2)*xx+ x(3)*yy+ x(4)*zz+ x(5)*xx**2
6800 & + x(6)*yy**2+ x(7)*zz**2+ x(8)*xx*zz+ x(9)*xx*yy
6802 sumene2= x(11) + x(12)*xx + x(13)*yy + x(14)*zz + x(15)*xx**2
6803 & + x(16)*yy**2 + x(17)*zz**2 + x(18)*xx*zz + x(19)*xx*yy
6805 sumene3= x(21) +x(22)*xx +x(23)*yy +x(24)*zz +x(25)*xx**2
6806 & +x(26)*yy**2 +x(27)*zz**2 +x(28)*xx*zz +x(29)*xx*yy
6807 & +x(30)*yy*zz +x(31)*xx**3 +x(32)*yy**3 +x(33)*zz**3
6808 & +x(34)*(xx**2)*yy +x(35)*(xx**2)*zz +x(36)*(yy**2)*xx
6809 & +x(37)*(yy**2)*zz +x(38)*(zz**2)*xx +x(39)*(zz**2)*yy
6811 sumene4= x(41) +x(42)*xx +x(43)*yy +x(44)*zz +x(45)*xx**2
6812 & +x(46)*yy**2 +x(47)*zz**2 +x(48)*xx*zz +x(49)*xx*yy
6813 & +x(50)*yy*zz +x(51)*xx**3 +x(52)*yy**3 +x(53)*zz**3
6814 & +x(54)*(xx**2)*yy +x(55)*(xx**2)*zz +x(56)*(yy**2)*xx
6815 & +x(57)*(yy**2)*zz +x(58)*(zz**2)*xx +x(59)*(zz**2)*yy
6817 dsc_i = 0.743d0+x(61)
6819 dscp1=dsqrt(dsc_i**2+dp2_i**2-2*dsc_i*dp2_i
6820 & *(xx*cost2+yy*sint2))
6821 dscp2=dsqrt(dsc_i**2+dp2_i**2-2*dsc_i*dp2_i
6822 & *(xx*cost2-yy*sint2))
6823 s1=(1+x(63))/(0.1d0 + dscp1)
6824 s1_6=(1+x(64))/(0.1d0 + dscp1**6)
6825 s2=(1+x(65))/(0.1d0 + dscp2)
6826 s2_6=(1+x(65))/(0.1d0 + dscp2**6)
6827 sumene = ( sumene3*sint2 + sumene1)*(s1+s1_6)
6828 & + (sumene4*cost2 +sumene2)*(s2+s2_6)
6833 c------------------------------------------------------------------------------
6834 subroutine gcont(rij,r0ij,eps0ij,delta,fcont,fprimcont)
6836 C This procedure calculates two-body contact function g(rij) and its derivative:
6839 C g(rij) = esp0ij*(-0.9375*x+0.625*x**3-0.1875*x**5) ! -1 =< x =< 1
6842 C where x=(rij-r0ij)/delta
6844 C rij - interbody distance, r0ij - contact distance, eps0ij - contact energy
6847 double precision rij,r0ij,eps0ij,fcont,fprimcont
6848 double precision x,x2,x4,delta
6852 if (x.lt.-1.0D0) then
6855 else if (x.le.1.0D0) then
6858 fcont=eps0ij*(x*(-0.9375D0+0.6250D0*x2-0.1875D0*x4)+0.5D0)
6859 fprimcont=eps0ij * (-0.9375D0+1.8750D0*x2-0.9375D0*x4)/delta
6866 c------------------------------------------------------------------------------
6867 subroutine splinthet(theti,delta,ss,ssder)
6868 implicit real*8 (a-h,o-z)
6869 include 'DIMENSIONS'
6870 include 'COMMON.VAR'
6871 include 'COMMON.GEO'
6874 if (theti.gt.pipol) then
6875 call gcont(theti,thetup,1.0d0,delta,ss,ssder)
6877 call gcont(-theti,-thetlow,1.0d0,delta,ss,ssder)
6882 c------------------------------------------------------------------------------
6883 subroutine spline1(x,x0,delta,f0,f1,fprim0,f,fprim)
6885 double precision x,x0,delta,f0,f1,fprim0,f,fprim
6886 double precision ksi,ksi2,ksi3,a1,a2,a3
6887 a1=fprim0*delta/(f1-f0)
6893 f=f0+(f1-f0)*ksi*(a1+ksi*(a2+a3*ksi))
6894 fprim=(f1-f0)/delta*(a1+ksi*(2*a2+3*ksi*a3))
6897 c------------------------------------------------------------------------------
6898 subroutine spline2(x,x0,delta,f0x,f1x,fprim0x,fx)
6900 double precision x,x0,delta,f0x,f1x,fprim0x,fx
6901 double precision ksi,ksi2,ksi3,a1,a2,a3
6906 a2=3*(f1x-f0x)-2*fprim0x*delta
6907 a3=fprim0x*delta-2*(f1x-f0x)
6908 fx=f0x+a1*ksi+a2*ksi2+a3*ksi3
6911 C-----------------------------------------------------------------------------
6913 C-----------------------------------------------------------------------------
6914 subroutine etor(etors,edihcnstr)
6915 implicit real*8 (a-h,o-z)
6916 include 'DIMENSIONS'
6917 include 'COMMON.VAR'
6918 include 'COMMON.GEO'
6919 include 'COMMON.LOCAL'
6920 include 'COMMON.TORSION'
6921 include 'COMMON.INTERACT'
6922 include 'COMMON.DERIV'
6923 include 'COMMON.CHAIN'
6924 include 'COMMON.NAMES'
6925 include 'COMMON.IOUNITS'
6926 include 'COMMON.FFIELD'
6927 include 'COMMON.TORCNSTR'
6928 include 'COMMON.CONTROL'
6930 C Set lprn=.true. for debugging
6934 do i=iphi_start,iphi_end
6936 if (itype(i-2).eq.ntyp1.or. itype(i-1).eq.ntyp1
6937 & .or. itype(i).eq.ntyp1 .or. itype(i-3).eq.ntyp1) cycle
6938 itori=itortyp(itype(i-2))
6939 itori1=itortyp(itype(i-1))
6942 C Proline-Proline pair is a special case...
6943 if (itori.eq.3 .and. itori1.eq.3) then
6944 if (phii.gt.-dwapi3) then
6946 fac=1.0D0/(1.0D0-cosphi)
6947 etorsi=v1(1,3,3)*fac
6948 etorsi=etorsi+etorsi
6949 etors=etors+etorsi-v1(1,3,3)
6950 if (energy_dec) etors_ii=etors_ii+etorsi-v1(1,3,3)
6951 gloci=gloci-3*fac*etorsi*dsin(3*phii)
6954 v1ij=v1(j+1,itori,itori1)
6955 v2ij=v2(j+1,itori,itori1)
6958 etors=etors+v1ij*cosphi+v2ij*sinphi+dabs(v1ij)+dabs(v2ij)
6959 if (energy_dec) etors_ii=etors_ii+
6960 & v2ij*sinphi+dabs(v1ij)+dabs(v2ij)
6961 gloci=gloci+j*(v2ij*cosphi-v1ij*sinphi)
6965 v1ij=v1(j,itori,itori1)
6966 v2ij=v2(j,itori,itori1)
6969 etors=etors+v1ij*cosphi+v2ij*sinphi+dabs(v1ij)+dabs(v2ij)
6970 if (energy_dec) etors_ii=etors_ii+
6971 & v1ij*cosphi+v2ij*sinphi+dabs(v1ij)+dabs(v2ij)
6972 gloci=gloci+j*(v2ij*cosphi-v1ij*sinphi)
6975 if (energy_dec) write (iout,'(a6,i5,0pf7.3)')
6978 & write (iout,'(2(a3,2x,i3,2x),2i3,6f8.3/26x,6f8.3/)')
6979 & restyp(itype(i-2)),i-2,restyp(itype(i-1)),i-1,itori,itori1,
6980 & (v1(j,itori,itori1),j=1,6),(v2(j,itori,itori1),j=1,6)
6981 gloc(i-3,icg)=gloc(i-3,icg)+wtor*gloci
6982 c write (iout,*) 'i=',i,' gloc=',gloc(i-3,icg)
6984 ! 6/20/98 - dihedral angle constraints
6987 itori=idih_constr(i)
6990 if (difi.gt.drange(i)) then
6992 edihcnstr=edihcnstr+0.25d0*ftors(i)*difi**4
6993 gloc(itori-3,icg)=gloc(itori-3,icg)+ftors(i)*difi**3
6994 else if (difi.lt.-drange(i)) then
6996 edihcnstr=edihcnstr+0.25d0*ftors(i)**difi**4
6997 gloc(itori-3,icg)=gloc(itori-3,icg)+ftors(i)*difi**3
6999 ! write (iout,'(2i5,2f8.3,2e14.5)') i,itori,rad2deg*phii,
7000 ! & rad2deg*difi,0.25d0*ftors*difi**4,gloc(itori-3,icg)
7002 ! write (iout,*) 'edihcnstr',edihcnstr
7005 c------------------------------------------------------------------------------
7006 subroutine etor_d(etors_d)
7010 c----------------------------------------------------------------------------
7012 subroutine etor(etors,edihcnstr)
7013 implicit real*8 (a-h,o-z)
7014 include 'DIMENSIONS'
7015 include 'COMMON.VAR'
7016 include 'COMMON.GEO'
7017 include 'COMMON.LOCAL'
7018 include 'COMMON.TORSION'
7019 include 'COMMON.INTERACT'
7020 include 'COMMON.DERIV'
7021 include 'COMMON.CHAIN'
7022 include 'COMMON.NAMES'
7023 include 'COMMON.IOUNITS'
7024 include 'COMMON.FFIELD'
7025 include 'COMMON.TORCNSTR'
7026 include 'COMMON.CONTROL'
7028 C Set lprn=.true. for debugging
7032 do i=iphi_start,iphi_end
7033 C ANY TWO ARE DUMMY ATOMS in row CYCLE
7034 c if (((itype(i-3).eq.ntyp1).and.(itype(i-2).eq.ntyp1)).or.
7035 c & ((itype(i-2).eq.ntyp1).and.(itype(i-1).eq.ntyp1)) .or.
7036 c & ((itype(i-1).eq.ntyp1).and.(itype(i).eq.ntyp1))) cycle
7037 if (itype(i-2).eq.ntyp1.or. itype(i-1).eq.ntyp1
7038 & .or. itype(i).eq.ntyp1 .or. itype(i-3).eq.ntyp1) cycle
7039 C In current verion the ALL DUMMY ATOM POTENTIALS ARE OFF
7040 C For introducing the NH3+ and COO- group please check the etor_d for reference
7043 if (iabs(itype(i)).eq.20) then
7048 itori=itortyp(itype(i-2))
7049 itori1=itortyp(itype(i-1))
7052 C Regular cosine and sine terms
7053 do j=1,nterm(itori,itori1,iblock)
7054 v1ij=v1(j,itori,itori1,iblock)
7055 v2ij=v2(j,itori,itori1,iblock)
7058 etors=etors+v1ij*cosphi+v2ij*sinphi
7059 if (energy_dec) etors_ii=etors_ii+
7060 & v1ij*cosphi+v2ij*sinphi
7061 gloci=gloci+j*(v2ij*cosphi-v1ij*sinphi)
7065 C E = SUM ----------------------------------- - v1
7066 C [v2 cos(phi/2)+v3 sin(phi/2)]^2 + 1
7068 cosphi=dcos(0.5d0*phii)
7069 sinphi=dsin(0.5d0*phii)
7070 do j=1,nlor(itori,itori1,iblock)
7071 vl1ij=vlor1(j,itori,itori1)
7072 vl2ij=vlor2(j,itori,itori1)
7073 vl3ij=vlor3(j,itori,itori1)
7074 pom=vl2ij*cosphi+vl3ij*sinphi
7075 pom1=1.0d0/(pom*pom+1.0d0)
7076 etors=etors+vl1ij*pom1
7077 if (energy_dec) etors_ii=etors_ii+
7080 gloci=gloci+vl1ij*(vl3ij*cosphi-vl2ij*sinphi)*pom
7082 C Subtract the constant term
7083 etors=etors-v0(itori,itori1,iblock)
7084 if (energy_dec) write (iout,'(a6,i5,0pf7.3)')
7085 & 'etor',i,etors_ii-v0(itori,itori1,iblock)
7087 & write (iout,'(2(a3,2x,i3,2x),2i3,6f8.3/26x,6f8.3/)')
7088 & restyp(itype(i-2)),i-2,restyp(itype(i-1)),i-1,itori,itori1,
7089 & (v1(j,itori,itori1,iblock),j=1,6),
7090 & (v2(j,itori,itori1,iblock),j=1,6)
7091 gloc(i-3,icg)=gloc(i-3,icg)+wtor*gloci
7092 c write (iout,*) 'i=',i,' gloc=',gloc(i-3,icg)
7094 ! 6/20/98 - dihedral angle constraints
7096 c do i=1,ndih_constr
7097 do i=idihconstr_start,idihconstr_end
7098 itori=idih_constr(i)
7100 difi=pinorm(phii-phi0(i))
7101 if (difi.gt.drange(i)) then
7103 edihcnstr=edihcnstr+0.25d0*ftors(i)*difi**4
7104 gloc(itori-3,icg)=gloc(itori-3,icg)+ftors(i)*difi**3
7105 else if (difi.lt.-drange(i)) then
7107 edihcnstr=edihcnstr+0.25d0*ftors(i)*difi**4
7108 gloc(itori-3,icg)=gloc(itori-3,icg)+ftors(i)*difi**3
7112 if (energy_dec) then
7113 write (iout,'(a6,2i5,4f8.3,2e14.5)') "edihc",
7114 & i,itori,rad2deg*phii,
7115 & rad2deg*phi0(i), rad2deg*drange(i),
7116 & rad2deg*difi,0.25d0*ftors(i)*difi**4,gloc(itori-3,icg)
7119 cd write (iout,*) 'edihcnstr',edihcnstr
7122 c----------------------------------------------------------------------------
7123 subroutine etor_d(etors_d)
7124 C 6/23/01 Compute double torsional energy
7125 implicit real*8 (a-h,o-z)
7126 include 'DIMENSIONS'
7127 include 'COMMON.VAR'
7128 include 'COMMON.GEO'
7129 include 'COMMON.LOCAL'
7130 include 'COMMON.TORSION'
7131 include 'COMMON.INTERACT'
7132 include 'COMMON.DERIV'
7133 include 'COMMON.CHAIN'
7134 include 'COMMON.NAMES'
7135 include 'COMMON.IOUNITS'
7136 include 'COMMON.FFIELD'
7137 include 'COMMON.TORCNSTR'
7139 C Set lprn=.true. for debugging
7143 c write(iout,*) "a tu??"
7144 do i=iphid_start,iphid_end
7145 C ANY TWO ARE DUMMY ATOMS in row CYCLE
7146 C if (((itype(i-3).eq.ntyp1).and.(itype(i-2).eq.ntyp1)).or.
7147 C & ((itype(i-2).eq.ntyp1).and.(itype(i-1).eq.ntyp1)).or.
7148 C & ((itype(i-1).eq.ntyp1).and.(itype(i).eq.ntyp1)) .or.
7149 C & ((itype(i).eq.ntyp1).and.(itype(i+1).eq.ntyp1))) cycle
7150 if ((itype(i-2).eq.ntyp1).or.itype(i-3).eq.ntyp1.or.
7151 & (itype(i-1).eq.ntyp1).or.(itype(i).eq.ntyp1).or.
7152 & (itype(i+1).eq.ntyp1)) cycle
7153 C In current verion the ALL DUMMY ATOM POTENTIALS ARE OFF
7154 itori=itortyp(itype(i-2))
7155 itori1=itortyp(itype(i-1))
7156 itori2=itortyp(itype(i))
7162 if (iabs(itype(i+1)).eq.20) iblock=2
7163 C Iblock=2 Proline type
7164 C ADASKO: WHEN PARAMETERS FOR THIS TYPE OF BLOCKING GROUP IS READY UNCOMMENT
7165 C CHECK WEATHER THERE IS NECCESITY FOR iblock=3 for COO-
7166 C if (itype(i+1).eq.ntyp1) iblock=3
7167 C The problem of NH3+ group can be resolved by adding new parameters please note if there
7168 C IS or IS NOT need for this
7169 C IF Yes uncomment below and add to parmread.F appropriate changes and to v1cij and so on
7170 C is (itype(i-3).eq.ntyp1) ntblock=2
7171 C ntblock is N-terminal blocking group
7173 C Regular cosine and sine terms
7174 do j=1,ntermd_1(itori,itori1,itori2,iblock)
7175 C Example of changes for NH3+ blocking group
7176 C do j=1,ntermd_1(itori,itori1,itori2,iblock,ntblock)
7177 C v1cij=v1c(1,j,itori,itori1,itori2,iblock,ntblock)
7178 v1cij=v1c(1,j,itori,itori1,itori2,iblock)
7179 v1sij=v1s(1,j,itori,itori1,itori2,iblock)
7180 v2cij=v1c(2,j,itori,itori1,itori2,iblock)
7181 v2sij=v1s(2,j,itori,itori1,itori2,iblock)
7182 cosphi1=dcos(j*phii)
7183 sinphi1=dsin(j*phii)
7184 cosphi2=dcos(j*phii1)
7185 sinphi2=dsin(j*phii1)
7186 etors_d=etors_d+v1cij*cosphi1+v1sij*sinphi1+
7187 & v2cij*cosphi2+v2sij*sinphi2
7188 gloci1=gloci1+j*(v1sij*cosphi1-v1cij*sinphi1)
7189 gloci2=gloci2+j*(v2sij*cosphi2-v2cij*sinphi2)
7191 do k=2,ntermd_2(itori,itori1,itori2,iblock)
7193 v1cdij = v2c(k,l,itori,itori1,itori2,iblock)
7194 v2cdij = v2c(l,k,itori,itori1,itori2,iblock)
7195 v1sdij = v2s(k,l,itori,itori1,itori2,iblock)
7196 v2sdij = v2s(l,k,itori,itori1,itori2,iblock)
7197 cosphi1p2=dcos(l*phii+(k-l)*phii1)
7198 cosphi1m2=dcos(l*phii-(k-l)*phii1)
7199 sinphi1p2=dsin(l*phii+(k-l)*phii1)
7200 sinphi1m2=dsin(l*phii-(k-l)*phii1)
7201 etors_d=etors_d+v1cdij*cosphi1p2+v2cdij*cosphi1m2+
7202 & v1sdij*sinphi1p2+v2sdij*sinphi1m2
7203 gloci1=gloci1+l*(v1sdij*cosphi1p2+v2sdij*cosphi1m2
7204 & -v1cdij*sinphi1p2-v2cdij*sinphi1m2)
7205 gloci2=gloci2+(k-l)*(v1sdij*cosphi1p2-v2sdij*cosphi1m2
7206 & -v1cdij*sinphi1p2+v2cdij*sinphi1m2)
7209 gloc(i-3,icg)=gloc(i-3,icg)+wtor_d*gloci1
7210 gloc(i-2,icg)=gloc(i-2,icg)+wtor_d*gloci2
7215 c------------------------------------------------------------------------------
7216 subroutine eback_sc_corr(esccor)
7217 c 7/21/2007 Correlations between the backbone-local and side-chain-local
7218 c conformational states; temporarily implemented as differences
7219 c between UNRES torsional potentials (dependent on three types of
7220 c residues) and the torsional potentials dependent on all 20 types
7221 c of residues computed from AM1 energy surfaces of terminally-blocked
7222 c amino-acid residues.
7223 implicit real*8 (a-h,o-z)
7224 include 'DIMENSIONS'
7225 include 'COMMON.VAR'
7226 include 'COMMON.GEO'
7227 include 'COMMON.LOCAL'
7228 include 'COMMON.TORSION'
7229 include 'COMMON.SCCOR'
7230 include 'COMMON.INTERACT'
7231 include 'COMMON.DERIV'
7232 include 'COMMON.CHAIN'
7233 include 'COMMON.NAMES'
7234 include 'COMMON.IOUNITS'
7235 include 'COMMON.FFIELD'
7236 include 'COMMON.CONTROL'
7238 C Set lprn=.true. for debugging
7241 c write (iout,*) "EBACK_SC_COR",itau_start,itau_end
7243 do i=itau_start,itau_end
7244 if ((itype(i-2).eq.ntyp1).or.(itype(i-1).eq.ntyp1)) cycle
7246 isccori=isccortyp(itype(i-2))
7247 isccori1=isccortyp(itype(i-1))
7248 c write (iout,*) "EBACK_SC_COR",i,nterm_sccor(isccori,isccori1)
7250 do intertyp=1,3 !intertyp
7251 cc Added 09 May 2012 (Adasko)
7252 cc Intertyp means interaction type of backbone mainchain correlation:
7253 c 1 = SC...Ca...Ca...Ca
7254 c 2 = Ca...Ca...Ca...SC
7255 c 3 = SC...Ca...Ca...SCi
7257 if (((intertyp.eq.3).and.((itype(i-2).eq.10).or.
7258 & (itype(i-1).eq.10).or.(itype(i-2).eq.ntyp1).or.
7259 & (itype(i-1).eq.ntyp1)))
7260 & .or. ((intertyp.eq.1).and.((itype(i-2).eq.10)
7261 & .or.(itype(i-2).eq.ntyp1).or.(itype(i-1).eq.ntyp1)
7262 & .or.(itype(i).eq.ntyp1)))
7263 & .or.((intertyp.eq.2).and.((itype(i-1).eq.10).or.
7264 & (itype(i-1).eq.ntyp1).or.(itype(i-2).eq.ntyp1).or.
7265 & (itype(i-3).eq.ntyp1)))) cycle
7266 if ((intertyp.eq.2).and.(i.eq.4).and.(itype(1).eq.ntyp1)) cycle
7267 if ((intertyp.eq.1).and.(i.eq.nres).and.(itype(nres).eq.ntyp1))
7269 do j=1,nterm_sccor(isccori,isccori1)
7270 v1ij=v1sccor(j,intertyp,isccori,isccori1)
7271 v2ij=v2sccor(j,intertyp,isccori,isccori1)
7272 cosphi=dcos(j*tauangle(intertyp,i))
7273 sinphi=dsin(j*tauangle(intertyp,i))
7274 esccor=esccor+v1ij*cosphi+v2ij*sinphi
7275 gloci=gloci+j*(v2ij*cosphi-v1ij*sinphi)
7277 c write (iout,*) "EBACK_SC_COR",i,v1ij*cosphi+v2ij*sinphi,intertyp
7278 gloc_sc(intertyp,i-3,icg)=gloc_sc(intertyp,i-3,icg)+wsccor*gloci
7280 & write (iout,'(2(a3,2x,i3,2x),2i3,6f8.3/26x,6f8.3/)')
7281 & restyp(itype(i-2)),i-2,restyp(itype(i-1)),i-1,isccori,isccori1,
7282 & (v1sccor(j,intertyp,isccori,isccori1),j=1,6)
7283 & ,(v2sccor(j,intertyp,isccori,isccori1),j=1,6)
7284 gsccor_loc(i-3)=gsccor_loc(i-3)+gloci
7290 c----------------------------------------------------------------------------
7291 subroutine multibody(ecorr)
7292 C This subroutine calculates multi-body contributions to energy following
7293 C the idea of Skolnick et al. If side chains I and J make a contact and
7294 C at the same time side chains I+1 and J+1 make a contact, an extra
7295 C contribution equal to sqrt(eps(i,j)*eps(i+1,j+1)) is added.
7296 implicit real*8 (a-h,o-z)
7297 include 'DIMENSIONS'
7298 include 'COMMON.IOUNITS'
7299 include 'COMMON.DERIV'
7300 include 'COMMON.INTERACT'
7301 include 'COMMON.CONTACTS'
7302 double precision gx(3),gx1(3)
7305 C Set lprn=.true. for debugging
7309 write (iout,'(a)') 'Contact function values:'
7311 write (iout,'(i2,20(1x,i2,f10.5))')
7312 & i,(jcont(j,i),facont(j,i),j=1,num_cont(i))
7327 num_conti=num_cont(i)
7328 num_conti1=num_cont(i1)
7333 if (j1.eq.j+ishift .or. j1.eq.j-ishift) then
7334 cd write(iout,*)'i=',i,' j=',j,' i1=',i1,' j1=',j1,
7335 cd & ' ishift=',ishift
7336 C Contacts I--J and I+ISHIFT--J+-ISHIFT1 occur simultaneously.
7337 C The system gains extra energy.
7338 ecorr=ecorr+esccorr(i,j,i1,j1,jj,kk)
7339 endif ! j1==j+-ishift
7348 c------------------------------------------------------------------------------
7349 double precision function esccorr(i,j,k,l,jj,kk)
7350 implicit real*8 (a-h,o-z)
7351 include 'DIMENSIONS'
7352 include 'COMMON.IOUNITS'
7353 include 'COMMON.DERIV'
7354 include 'COMMON.INTERACT'
7355 include 'COMMON.CONTACTS'
7356 double precision gx(3),gx1(3)
7361 cd write (iout,'(4i5,3f10.5)') i,j,k,l,eij,ekl,-eij*ekl
7362 C Calculate the multi-body contribution to energy.
7363 C Calculate multi-body contributions to the gradient.
7364 cd write (iout,'(2(2i3,3f10.5))')i,j,(gacont(m,jj,i),m=1,3),
7365 cd & k,l,(gacont(m,kk,k),m=1,3)
7367 gx(m) =ekl*gacont(m,jj,i)
7368 gx1(m)=eij*gacont(m,kk,k)
7369 gradxorr(m,i)=gradxorr(m,i)-gx(m)
7370 gradxorr(m,j)=gradxorr(m,j)+gx(m)
7371 gradxorr(m,k)=gradxorr(m,k)-gx1(m)
7372 gradxorr(m,l)=gradxorr(m,l)+gx1(m)
7376 gradcorr(ll,m)=gradcorr(ll,m)+gx(ll)
7381 gradcorr(ll,m)=gradcorr(ll,m)+gx1(ll)
7387 c------------------------------------------------------------------------------
7388 subroutine multibody_hb(ecorr,ecorr5,ecorr6,n_corr,n_corr1)
7389 C This subroutine calculates multi-body contributions to hydrogen-bonding
7390 implicit real*8 (a-h,o-z)
7391 include 'DIMENSIONS'
7392 include 'COMMON.IOUNITS'
7395 parameter (max_cont=maxconts)
7396 parameter (max_dim=26)
7397 integer source,CorrelType,CorrelID,CorrelType1,CorrelID1,Error
7398 double precision zapas(max_dim,maxconts,max_fg_procs),
7399 & zapas_recv(max_dim,maxconts,max_fg_procs)
7400 common /przechowalnia/ zapas
7401 integer status(MPI_STATUS_SIZE),req(maxconts*2),
7402 & status_array(MPI_STATUS_SIZE,maxconts*2)
7404 include 'COMMON.SETUP'
7405 include 'COMMON.FFIELD'
7406 include 'COMMON.DERIV'
7407 include 'COMMON.INTERACT'
7408 include 'COMMON.CONTACTS'
7409 include 'COMMON.CONTROL'
7410 include 'COMMON.LOCAL'
7411 double precision gx(3),gx1(3),time00
7414 C Set lprn=.true. for debugging
7419 if (nfgtasks.le.1) goto 30
7421 write (iout,'(a)') 'Contact function values before RECEIVE:'
7423 write (iout,'(2i3,50(1x,i3,f5.2))')
7424 & i,num_cont_hb(i),(jcont_hb(j,i),facont_hb(j,i),
7425 & j=1,num_cont_hb(i))
7429 do i=1,ntask_cont_from
7432 do i=1,ntask_cont_to
7435 c write (iout,*) "ntask_cont_from",ntask_cont_from," ntask_cont_to",
7437 C Make the list of contacts to send to send to other procesors
7438 c write (iout,*) "limits",max0(iturn4_end-1,iatel_s),iturn3_end
7440 do i=iturn3_start,iturn3_end
7441 c write (iout,*) "make contact list turn3",i," num_cont",
7443 call add_hb_contact(i,i+2,iturn3_sent_local(1,i))
7445 do i=iturn4_start,iturn4_end
7446 c write (iout,*) "make contact list turn4",i," num_cont",
7448 call add_hb_contact(i,i+3,iturn4_sent_local(1,i))
7452 c write (iout,*) "make contact list longrange",i,ii," num_cont",
7454 do j=1,num_cont_hb(i)
7457 iproc=iint_sent_local(k,jjc,ii)
7458 c write (iout,*) "i",i," j",j," k",k," jjc",jjc," iproc",iproc
7459 if (iproc.gt.0) then
7460 ncont_sent(iproc)=ncont_sent(iproc)+1
7461 nn=ncont_sent(iproc)
7463 zapas(2,nn,iproc)=jjc
7464 zapas(3,nn,iproc)=facont_hb(j,i)
7465 zapas(4,nn,iproc)=ees0p(j,i)
7466 zapas(5,nn,iproc)=ees0m(j,i)
7467 zapas(6,nn,iproc)=gacont_hbr(1,j,i)
7468 zapas(7,nn,iproc)=gacont_hbr(2,j,i)
7469 zapas(8,nn,iproc)=gacont_hbr(3,j,i)
7470 zapas(9,nn,iproc)=gacontm_hb1(1,j,i)
7471 zapas(10,nn,iproc)=gacontm_hb1(2,j,i)
7472 zapas(11,nn,iproc)=gacontm_hb1(3,j,i)
7473 zapas(12,nn,iproc)=gacontp_hb1(1,j,i)
7474 zapas(13,nn,iproc)=gacontp_hb1(2,j,i)
7475 zapas(14,nn,iproc)=gacontp_hb1(3,j,i)
7476 zapas(15,nn,iproc)=gacontm_hb2(1,j,i)
7477 zapas(16,nn,iproc)=gacontm_hb2(2,j,i)
7478 zapas(17,nn,iproc)=gacontm_hb2(3,j,i)
7479 zapas(18,nn,iproc)=gacontp_hb2(1,j,i)
7480 zapas(19,nn,iproc)=gacontp_hb2(2,j,i)
7481 zapas(20,nn,iproc)=gacontp_hb2(3,j,i)
7482 zapas(21,nn,iproc)=gacontm_hb3(1,j,i)
7483 zapas(22,nn,iproc)=gacontm_hb3(2,j,i)
7484 zapas(23,nn,iproc)=gacontm_hb3(3,j,i)
7485 zapas(24,nn,iproc)=gacontp_hb3(1,j,i)
7486 zapas(25,nn,iproc)=gacontp_hb3(2,j,i)
7487 zapas(26,nn,iproc)=gacontp_hb3(3,j,i)
7494 & "Numbers of contacts to be sent to other processors",
7495 & (ncont_sent(i),i=1,ntask_cont_to)
7496 write (iout,*) "Contacts sent"
7497 do ii=1,ntask_cont_to
7499 iproc=itask_cont_to(ii)
7500 write (iout,*) nn," contacts to processor",iproc,
7501 & " of CONT_TO_COMM group"
7503 write(iout,'(2f5.0,4f10.5)')(zapas(j,i,ii),j=1,5)
7511 CorrelID1=nfgtasks+fg_rank+1
7513 C Receive the numbers of needed contacts from other processors
7514 do ii=1,ntask_cont_from
7515 iproc=itask_cont_from(ii)
7517 call MPI_Irecv(ncont_recv(ii),1,MPI_INTEGER,iproc,CorrelType,
7518 & FG_COMM,req(ireq),IERR)
7520 c write (iout,*) "IRECV ended"
7522 C Send the number of contacts needed by other processors
7523 do ii=1,ntask_cont_to
7524 iproc=itask_cont_to(ii)
7526 call MPI_Isend(ncont_sent(ii),1,MPI_INTEGER,iproc,CorrelType,
7527 & FG_COMM,req(ireq),IERR)
7529 c write (iout,*) "ISEND ended"
7530 c write (iout,*) "number of requests (nn)",ireq
7533 & call MPI_Waitall(ireq,req,status_array,ierr)
7535 c & "Numbers of contacts to be received from other processors",
7536 c & (ncont_recv(i),i=1,ntask_cont_from)
7540 do ii=1,ntask_cont_from
7541 iproc=itask_cont_from(ii)
7543 c write (iout,*) "Receiving",nn," contacts from processor",iproc,
7544 c & " of CONT_TO_COMM group"
7548 call MPI_Irecv(zapas_recv(1,1,ii),nn*max_dim,
7549 & MPI_DOUBLE_PRECISION,iproc,CorrelType1,FG_COMM,req(ireq),IERR)
7550 c write (iout,*) "ireq,req",ireq,req(ireq)
7553 C Send the contacts to processors that need them
7554 do ii=1,ntask_cont_to
7555 iproc=itask_cont_to(ii)
7557 c write (iout,*) nn," contacts to processor",iproc,
7558 c & " of CONT_TO_COMM group"
7561 call MPI_Isend(zapas(1,1,ii),nn*max_dim,MPI_DOUBLE_PRECISION,
7562 & iproc,CorrelType1,FG_COMM,req(ireq),IERR)
7563 c write (iout,*) "ireq,req",ireq,req(ireq)
7565 c write(iout,'(2f5.0,4f10.5)')(zapas(j,i,ii),j=1,5)
7569 c write (iout,*) "number of requests (contacts)",ireq
7570 c write (iout,*) "req",(req(i),i=1,4)
7573 & call MPI_Waitall(ireq,req,status_array,ierr)
7574 do iii=1,ntask_cont_from
7575 iproc=itask_cont_from(iii)
7578 write (iout,*) "Received",nn," contacts from processor",iproc,
7579 & " of CONT_FROM_COMM group"
7582 write(iout,'(2f5.0,4f10.5)')(zapas_recv(j,i,iii),j=1,5)
7587 ii=zapas_recv(1,i,iii)
7588 c Flag the received contacts to prevent double-counting
7589 jj=-zapas_recv(2,i,iii)
7590 c write (iout,*) "iii",iii," i",i," ii",ii," jj",jj
7592 nnn=num_cont_hb(ii)+1
7595 facont_hb(nnn,ii)=zapas_recv(3,i,iii)
7596 ees0p(nnn,ii)=zapas_recv(4,i,iii)
7597 ees0m(nnn,ii)=zapas_recv(5,i,iii)
7598 gacont_hbr(1,nnn,ii)=zapas_recv(6,i,iii)
7599 gacont_hbr(2,nnn,ii)=zapas_recv(7,i,iii)
7600 gacont_hbr(3,nnn,ii)=zapas_recv(8,i,iii)
7601 gacontm_hb1(1,nnn,ii)=zapas_recv(9,i,iii)
7602 gacontm_hb1(2,nnn,ii)=zapas_recv(10,i,iii)
7603 gacontm_hb1(3,nnn,ii)=zapas_recv(11,i,iii)
7604 gacontp_hb1(1,nnn,ii)=zapas_recv(12,i,iii)
7605 gacontp_hb1(2,nnn,ii)=zapas_recv(13,i,iii)
7606 gacontp_hb1(3,nnn,ii)=zapas_recv(14,i,iii)
7607 gacontm_hb2(1,nnn,ii)=zapas_recv(15,i,iii)
7608 gacontm_hb2(2,nnn,ii)=zapas_recv(16,i,iii)
7609 gacontm_hb2(3,nnn,ii)=zapas_recv(17,i,iii)
7610 gacontp_hb2(1,nnn,ii)=zapas_recv(18,i,iii)
7611 gacontp_hb2(2,nnn,ii)=zapas_recv(19,i,iii)
7612 gacontp_hb2(3,nnn,ii)=zapas_recv(20,i,iii)
7613 gacontm_hb3(1,nnn,ii)=zapas_recv(21,i,iii)
7614 gacontm_hb3(2,nnn,ii)=zapas_recv(22,i,iii)
7615 gacontm_hb3(3,nnn,ii)=zapas_recv(23,i,iii)
7616 gacontp_hb3(1,nnn,ii)=zapas_recv(24,i,iii)
7617 gacontp_hb3(2,nnn,ii)=zapas_recv(25,i,iii)
7618 gacontp_hb3(3,nnn,ii)=zapas_recv(26,i,iii)
7623 write (iout,'(a)') 'Contact function values after receive:'
7625 write (iout,'(2i3,50(1x,i3,f5.2))')
7626 & i,num_cont_hb(i),(jcont_hb(j,i),facont_hb(j,i),
7627 & j=1,num_cont_hb(i))
7634 write (iout,'(a)') 'Contact function values:'
7636 write (iout,'(2i3,50(1x,i3,f5.2))')
7637 & i,num_cont_hb(i),(jcont_hb(j,i),facont_hb(j,i),
7638 & j=1,num_cont_hb(i))
7642 C Remove the loop below after debugging !!!
7649 C Calculate the local-electrostatic correlation terms
7650 do i=min0(iatel_s,iturn4_start),max0(iatel_e,iturn3_end)
7652 num_conti=num_cont_hb(i)
7653 num_conti1=num_cont_hb(i+1)
7660 c write (iout,*) 'i=',i,' j=',j,' i1=',i1,' j1=',j1,
7661 c & ' jj=',jj,' kk=',kk
7663 if ((j.gt.0 .and. j1.gt.0 .or. j.gt.0 .and. j1.lt.0
7664 & .or. j.lt.0 .and. j1.gt.0) .and.
7665 & (jp1.eq.jp+1 .or. jp1.eq.jp-1)) then
7666 C Contacts I-J and (I+1)-(J+1) or (I+1)-(J-1) occur simultaneously.
7667 C The system gains extra energy.
7668 ecorr=ecorr+ehbcorr(i,jp,i+1,jp1,jj,kk,0.72D0,0.32D0)
7669 if (energy_dec) write (iout,'(a6,2i5,0pf7.3)')
7670 & 'ecorrh',i,j,ehbcorr(i,j,i+1,j1,jj,kk,0.72D0,0.32D0)
7672 else if (j1.eq.j) then
7673 C Contacts I-J and I-(J+1) occur simultaneously.
7674 C The system loses extra energy.
7675 c ecorr=ecorr+ehbcorr(i,j,i+1,j,jj,kk,0.60D0,-0.40D0)
7680 c write (iout,*) 'i=',i,' j=',j,' i1=',i1,' j1=',j1,
7681 c & ' jj=',jj,' kk=',kk
7684 C Contacts I-J and (I+1)-J occur simultaneously.
7685 C The system loses extra energy.
7686 c ecorr=ecorr+ehbcorr(i,j,i,j+1,jj,kk,0.60D0,-0.40D0)
7693 c------------------------------------------------------------------------------
7694 subroutine add_hb_contact(ii,jj,itask)
7695 implicit real*8 (a-h,o-z)
7696 include "DIMENSIONS"
7697 include "COMMON.IOUNITS"
7700 parameter (max_cont=maxconts)
7701 parameter (max_dim=26)
7702 include "COMMON.CONTACTS"
7703 double precision zapas(max_dim,maxconts,max_fg_procs),
7704 & zapas_recv(max_dim,maxconts,max_fg_procs)
7705 common /przechowalnia/ zapas
7706 integer i,j,ii,jj,iproc,itask(4),nn
7707 c write (iout,*) "itask",itask
7710 if (iproc.gt.0) then
7711 do j=1,num_cont_hb(ii)
7713 c write (iout,*) "i",ii," j",jj," jjc",jjc
7715 ncont_sent(iproc)=ncont_sent(iproc)+1
7716 nn=ncont_sent(iproc)
7717 zapas(1,nn,iproc)=ii
7718 zapas(2,nn,iproc)=jjc
7719 zapas(3,nn,iproc)=facont_hb(j,ii)
7720 zapas(4,nn,iproc)=ees0p(j,ii)
7721 zapas(5,nn,iproc)=ees0m(j,ii)
7722 zapas(6,nn,iproc)=gacont_hbr(1,j,ii)
7723 zapas(7,nn,iproc)=gacont_hbr(2,j,ii)
7724 zapas(8,nn,iproc)=gacont_hbr(3,j,ii)
7725 zapas(9,nn,iproc)=gacontm_hb1(1,j,ii)
7726 zapas(10,nn,iproc)=gacontm_hb1(2,j,ii)
7727 zapas(11,nn,iproc)=gacontm_hb1(3,j,ii)
7728 zapas(12,nn,iproc)=gacontp_hb1(1,j,ii)
7729 zapas(13,nn,iproc)=gacontp_hb1(2,j,ii)
7730 zapas(14,nn,iproc)=gacontp_hb1(3,j,ii)
7731 zapas(15,nn,iproc)=gacontm_hb2(1,j,ii)
7732 zapas(16,nn,iproc)=gacontm_hb2(2,j,ii)
7733 zapas(17,nn,iproc)=gacontm_hb2(3,j,ii)
7734 zapas(18,nn,iproc)=gacontp_hb2(1,j,ii)
7735 zapas(19,nn,iproc)=gacontp_hb2(2,j,ii)
7736 zapas(20,nn,iproc)=gacontp_hb2(3,j,ii)
7737 zapas(21,nn,iproc)=gacontm_hb3(1,j,ii)
7738 zapas(22,nn,iproc)=gacontm_hb3(2,j,ii)
7739 zapas(23,nn,iproc)=gacontm_hb3(3,j,ii)
7740 zapas(24,nn,iproc)=gacontp_hb3(1,j,ii)
7741 zapas(25,nn,iproc)=gacontp_hb3(2,j,ii)
7742 zapas(26,nn,iproc)=gacontp_hb3(3,j,ii)
7750 c------------------------------------------------------------------------------
7751 subroutine multibody_eello(ecorr,ecorr5,ecorr6,eturn6,n_corr,
7753 C This subroutine calculates multi-body contributions to hydrogen-bonding
7754 implicit real*8 (a-h,o-z)
7755 include 'DIMENSIONS'
7756 include 'COMMON.IOUNITS'
7759 parameter (max_cont=maxconts)
7760 parameter (max_dim=70)
7761 integer source,CorrelType,CorrelID,CorrelType1,CorrelID1,Error
7762 double precision zapas(max_dim,maxconts,max_fg_procs),
7763 & zapas_recv(max_dim,maxconts,max_fg_procs)
7764 common /przechowalnia/ zapas
7765 integer status(MPI_STATUS_SIZE),req(maxconts*2),
7766 & status_array(MPI_STATUS_SIZE,maxconts*2)
7768 include 'COMMON.SETUP'
7769 include 'COMMON.FFIELD'
7770 include 'COMMON.DERIV'
7771 include 'COMMON.LOCAL'
7772 include 'COMMON.INTERACT'
7773 include 'COMMON.CONTACTS'
7774 include 'COMMON.CHAIN'
7775 include 'COMMON.CONTROL'
7776 include 'COMMON.TORSION'
7777 double precision gx(3),gx1(3)
7778 integer num_cont_hb_old(maxres)
7780 double precision eello4,eello5,eelo6,eello_turn6
7781 external eello4,eello5,eello6,eello_turn6
7782 C Set lprn=.true. for debugging
7785 c write (iout,*) "MULTIBODY_EELLO"
7789 num_cont_hb_old(i)=num_cont_hb(i)
7793 if (nfgtasks.le.1) goto 30
7795 write (iout,'(a)') 'Contact function values before RECEIVE:'
7797 write (iout,'(2i3,50(1x,i3,f5.2))')
7798 & i,num_cont_hb(i),(jcont_hb(j,i),facont_hb(j,i),
7799 & j=1,num_cont_hb(i))
7803 do i=1,ntask_cont_from
7806 do i=1,ntask_cont_to
7809 c write (iout,*) "ntask_cont_from",ntask_cont_from," ntask_cont_to",
7811 C Make the list of contacts to send to send to other procesors
7812 do i=iturn3_start,iturn3_end
7813 c write (iout,*) "make contact list turn3",i," num_cont",
7815 call add_hb_contact_eello(i,i+2,iturn3_sent_local(1,i))
7817 do i=iturn4_start,iturn4_end
7818 c write (iout,*) "make contact list turn4",i," num_cont",
7820 call add_hb_contact_eello(i,i+3,iturn4_sent_local(1,i))
7824 c write (iout,*) "make contact list longrange",i,ii," num_cont",
7826 do j=1,num_cont_hb(i)
7829 iproc=iint_sent_local(k,jjc,ii)
7830 c write (iout,*) "i",i," j",j," k",k," jjc",jjc," iproc",iproc
7831 if (iproc.ne.0) then
7832 ncont_sent(iproc)=ncont_sent(iproc)+1
7833 nn=ncont_sent(iproc)
7835 zapas(2,nn,iproc)=jjc
7836 zapas(3,nn,iproc)=d_cont(j,i)
7840 zapas(ind,nn,iproc)=grij_hb_cont(kk,j,i)
7845 zapas(ind,nn,iproc)=a_chuj(ll,kk,j,i)
7853 zapas(ind,nn,iproc)=a_chuj_der(mm,ll,kk,jj,j,i)
7864 & "Numbers of contacts to be sent to other processors",
7865 & (ncont_sent(i),i=1,ntask_cont_to)
7866 write (iout,*) "Contacts sent"
7867 do ii=1,ntask_cont_to
7869 iproc=itask_cont_to(ii)
7870 write (iout,*) nn," contacts to processor",iproc,
7871 & " of CONT_TO_COMM group"
7873 write(iout,'(2f5.0,10f10.5)')(zapas(j,i,ii),j=1,10)
7881 CorrelID1=nfgtasks+fg_rank+1
7883 C Receive the numbers of needed contacts from other processors
7884 do ii=1,ntask_cont_from
7885 iproc=itask_cont_from(ii)
7887 call MPI_Irecv(ncont_recv(ii),1,MPI_INTEGER,iproc,CorrelType,
7888 & FG_COMM,req(ireq),IERR)
7890 c write (iout,*) "IRECV ended"
7892 C Send the number of contacts needed by other processors
7893 do ii=1,ntask_cont_to
7894 iproc=itask_cont_to(ii)
7896 call MPI_Isend(ncont_sent(ii),1,MPI_INTEGER,iproc,CorrelType,
7897 & FG_COMM,req(ireq),IERR)
7899 c write (iout,*) "ISEND ended"
7900 c write (iout,*) "number of requests (nn)",ireq
7903 & call MPI_Waitall(ireq,req,status_array,ierr)
7905 c & "Numbers of contacts to be received from other processors",
7906 c & (ncont_recv(i),i=1,ntask_cont_from)
7910 do ii=1,ntask_cont_from
7911 iproc=itask_cont_from(ii)
7913 c write (iout,*) "Receiving",nn," contacts from processor",iproc,
7914 c & " of CONT_TO_COMM group"
7918 call MPI_Irecv(zapas_recv(1,1,ii),nn*max_dim,
7919 & MPI_DOUBLE_PRECISION,iproc,CorrelType1,FG_COMM,req(ireq),IERR)
7920 c write (iout,*) "ireq,req",ireq,req(ireq)
7923 C Send the contacts to processors that need them
7924 do ii=1,ntask_cont_to
7925 iproc=itask_cont_to(ii)
7927 c write (iout,*) nn," contacts to processor",iproc,
7928 c & " of CONT_TO_COMM group"
7931 call MPI_Isend(zapas(1,1,ii),nn*max_dim,MPI_DOUBLE_PRECISION,
7932 & iproc,CorrelType1,FG_COMM,req(ireq),IERR)
7933 c write (iout,*) "ireq,req",ireq,req(ireq)
7935 c write(iout,'(2f5.0,4f10.5)')(zapas(j,i,ii),j=1,5)
7939 c write (iout,*) "number of requests (contacts)",ireq
7940 c write (iout,*) "req",(req(i),i=1,4)
7943 & call MPI_Waitall(ireq,req,status_array,ierr)
7944 do iii=1,ntask_cont_from
7945 iproc=itask_cont_from(iii)
7948 write (iout,*) "Received",nn," contacts from processor",iproc,
7949 & " of CONT_FROM_COMM group"
7952 write(iout,'(2f5.0,10f10.5)')(zapas_recv(j,i,iii),j=1,10)
7957 ii=zapas_recv(1,i,iii)
7958 c Flag the received contacts to prevent double-counting
7959 jj=-zapas_recv(2,i,iii)
7960 c write (iout,*) "iii",iii," i",i," ii",ii," jj",jj
7962 nnn=num_cont_hb(ii)+1
7965 d_cont(nnn,ii)=zapas_recv(3,i,iii)
7969 grij_hb_cont(kk,nnn,ii)=zapas_recv(ind,i,iii)
7974 a_chuj(ll,kk,nnn,ii)=zapas_recv(ind,i,iii)
7982 a_chuj_der(mm,ll,kk,jj,nnn,ii)=zapas_recv(ind,i,iii)
7991 write (iout,'(a)') 'Contact function values after receive:'
7993 write (iout,'(2i3,50(1x,i3,5f6.3))')
7994 & i,num_cont_hb(i),(jcont_hb(j,i),d_cont(j,i),
7995 & ((a_chuj(ll,kk,j,i),ll=1,2),kk=1,2),j=1,num_cont_hb(i))
8002 write (iout,'(a)') 'Contact function values:'
8004 write (iout,'(2i3,50(1x,i3,5f6.3))')
8005 & i,num_cont_hb(i),(jcont_hb(j,i),d_cont(j,i),
8006 & ((a_chuj(ll,kk,j,i),ll=1,2),kk=1,2),j=1,num_cont_hb(i))
8008 write (iout,*) "itortyp"
8010 write (iout,*) i,itype(i),itortyp(itype(i))
8017 C Remove the loop below after debugging !!!
8024 C Calculate the dipole-dipole interaction energies
8025 if (wcorr6.gt.0.0d0 .or. wturn6.gt.0.0d0) then
8026 do i=iatel_s,iatel_e+1
8027 num_conti=num_cont_hb(i)
8036 C Calculate the local-electrostatic correlation terms
8037 c write (iout,*) "gradcorr5 in eello5 before loop"
8039 c write (iout,'(i5,3f10.5)')
8040 c & iii,(gradcorr5(jjj,iii),jjj=1,3)
8042 do i=min0(iatel_s,iturn4_start),max0(iatel_e+1,iturn3_end+1)
8043 c write (iout,*) "corr loop i",i
8045 num_conti=num_cont_hb(i)
8046 num_conti1=num_cont_hb(i+1)
8054 write (iout,*) 'i=',i,' j=',j,' i1=',i1,' j1=',j1,
8055 & ' jj=',jj,' kk=',kk
8058 c if (j1.eq.j+1 .or. j1.eq.j-1) then
8059 if ((j.gt.0 .and. j1.gt.0 .or. j.gt.0 .and. j1.lt.0
8060 & .or. j.lt.0 .and. j1.gt.0) .and.
8061 & (jp1.eq.jp+1 .or. jp1.eq.jp-1)) then
8062 C Contacts I-J and (I+1)-(J+1) or (I+1)-(J-1) occur simultaneously.
8063 C The system gains extra energy.
8065 sqd1=dsqrt(d_cont(jj,i))
8066 sqd2=dsqrt(d_cont(kk,i1))
8067 sred_geom = sqd1*sqd2
8068 IF (sred_geom.lt.cutoff_corr) THEN
8069 call gcont(sred_geom,r0_corr,1.0D0,delt_corr,
8071 cd write (iout,*) 'i=',i,' j=',jp,' i1=',i1,' j1=',jp1,
8072 cd & ' jj=',jj,' kk=',kk
8073 fac_prim1=0.5d0*sqd2/sqd1*fprimcont
8074 fac_prim2=0.5d0*sqd1/sqd2*fprimcont
8076 g_contij(l,1)=fac_prim1*grij_hb_cont(l,jj,i)
8077 g_contij(l,2)=fac_prim2*grij_hb_cont(l,kk,i1)
8080 cd write (iout,*) 'sred_geom=',sred_geom,
8081 cd & ' ekont=',ekont,' fprim=',fprimcont,
8082 cd & ' fac_prim1',fac_prim1,' fac_prim2',fac_prim2
8083 cd write (iout,*) "g_contij",g_contij
8084 cd write (iout,*) "grij_hb_cont i",grij_hb_cont(:,jj,i)
8085 cd write (iout,*) "grij_hb_cont i1",grij_hb_cont(:,jj,i1)
8086 call calc_eello(i,jp,i+1,jp1,jj,kk)
8087 if (wcorr4.gt.0.0d0)
8088 & ecorr=ecorr+eello4(i,jp,i+1,jp1,jj,kk)
8089 if (energy_dec.and.wcorr4.gt.0.0d0)
8090 1 write (iout,'(a6,4i5,0pf7.3)')
8091 2 'ecorr4',i,j,i+1,j1,eello4(i,jp,i+1,jp1,jj,kk)
8092 c write (iout,*) "gradcorr5 before eello5"
8094 c write (iout,'(i5,3f10.5)')
8095 c & iii,(gradcorr5(jjj,iii),jjj=1,3)
8097 c write (iout,*) "ecorr4"
8099 c write (iout,*) "eello5:",i,jp,i+1,jp1,jj,kk,
8100 c & itype(jp),itype(i+1),itype(jp1),
8101 c & itortyp(itype(jp)),itortyp(itype(i+1)),itortyp(itype(jp1))
8103 if (wcorr5.gt.0.0d0)
8104 & ecorr5=ecorr5+eello5(i,jp,i+1,jp1,jj,kk)
8105 c write (iout,*) "gradcorr5 after eello5"
8107 c write (iout,'(i5,3f10.5)')
8108 c & iii,(gradcorr5(jjj,iii),jjj=1,3)
8110 if (energy_dec.and.wcorr5.gt.0.0d0)
8111 1 write (iout,'(a6,4i5,0pf7.3)')
8112 2 'ecorr5',i,j,i+1,j1,eello5(i,jp,i+1,jp1,jj,kk)
8113 cd write(2,*)'wcorr6',wcorr6,' wturn6',wturn6
8114 cd write(2,*)'ijkl',i,jp,i+1,jp1
8115 c write (iout,*) "ecorr5"
8117 if (wcorr6.gt.0.0d0 .and. (jp.ne.i+4 .or. jp1.ne.i+3
8118 & .or. wturn6.eq.0.0d0))then
8119 cd write (iout,*) '******ecorr6: i,j,i+1,j1',i,j,i+1,j1
8120 ecorr6=ecorr6+eello6(i,jp,i+1,jp1,jj,kk)
8121 if (energy_dec) write (iout,'(a6,4i5,0pf7.3)')
8122 1 'ecorr6',i,j,i+1,j1,eello6(i,jp,i+1,jp1,jj,kk)
8123 c write (iout,*) "ecorr6"
8125 cd write (iout,*) 'ecorr',ecorr,' ecorr5=',ecorr5,
8126 cd & 'ecorr6=',ecorr6
8127 cd write (iout,'(4e15.5)') sred_geom,
8128 cd & dabs(eello4(i,jp,i+1,jp1,jj,kk)),
8129 cd & dabs(eello5(i,jp,i+1,jp1,jj,kk)),
8130 cd & dabs(eello6(i,jp,i+1,jp1,jj,kk))
8131 else if (wturn6.gt.0.0d0
8132 & .and. (jp.eq.i+4 .and. jp1.eq.i+3)) then
8133 cd write (iout,*) '******eturn6: i,j,i+1,j1',i,jip,i+1,jp1
8134 eturn6=eturn6+eello_turn6(i,jj,kk)
8135 if (energy_dec) write (iout,'(a6,4i5,0pf7.3)')
8136 1 'eturn6',i,j,i+1,j1,eello_turn6(i,jj,kk)
8137 cd write (2,*) 'multibody_eello:eturn6',eturn6
8138 c write (iout,*) "ecorr4"
8144 if (energy_dec) call flush(iout)
8149 num_cont_hb(i)=num_cont_hb_old(i)
8151 c write (iout,*) "gradcorr5 in eello5"
8153 c write (iout,'(i5,3f10.5)')
8154 c & iii,(gradcorr5(jjj,iii),jjj=1,3)
8158 c------------------------------------------------------------------------------
8159 subroutine add_hb_contact_eello(ii,jj,itask)
8160 implicit real*8 (a-h,o-z)
8161 include "DIMENSIONS"
8162 include "COMMON.IOUNITS"
8165 parameter (max_cont=maxconts)
8166 parameter (max_dim=70)
8167 include "COMMON.CONTACTS"
8168 double precision zapas(max_dim,maxconts,max_fg_procs),
8169 & zapas_recv(max_dim,maxconts,max_fg_procs)
8170 common /przechowalnia/ zapas
8171 integer i,j,ii,jj,iproc,itask(4),nn
8172 c write (iout,*) "itask",itask
8175 if (iproc.gt.0) then
8176 do j=1,num_cont_hb(ii)
8178 c write (iout,*) "send turns i",ii," j",jj," jjc",jjc
8180 ncont_sent(iproc)=ncont_sent(iproc)+1
8181 nn=ncont_sent(iproc)
8182 zapas(1,nn,iproc)=ii
8183 zapas(2,nn,iproc)=jjc
8184 zapas(3,nn,iproc)=d_cont(j,ii)
8188 zapas(ind,nn,iproc)=grij_hb_cont(kk,j,ii)
8193 zapas(ind,nn,iproc)=a_chuj(ll,kk,j,ii)
8201 zapas(ind,nn,iproc)=a_chuj_der(mm,ll,kk,jj,j,ii)
8213 c------------------------------------------------------------------------------
8214 double precision function ehbcorr(i,j,k,l,jj,kk,coeffp,coeffm)
8215 implicit real*8 (a-h,o-z)
8216 include 'DIMENSIONS'
8217 include 'COMMON.IOUNITS'
8218 include 'COMMON.DERIV'
8219 include 'COMMON.INTERACT'
8220 include 'COMMON.CONTACTS'
8221 double precision gx(3),gx1(3)
8231 ees=-(coeffp*ees0pij*ees0pkl+coeffm*ees0mij*ees0mkl)
8232 cd ees=-(coeffp*ees0pkl+coeffm*ees0mkl)
8233 C Following 4 lines for diagnostics.
8238 c write (iout,'(2(a,2i3,a,f10.5,a,2f10.5),a,f10.5,a,$)')
8239 c & 'Contacts ',i,j,
8240 c & ' eij',eij,' eesij',ees0pij,ees0mij,' and ',k,l
8241 c & ,' fcont ',ekl,' eeskl',ees0pkl,ees0mkl,' energy=',ekont*ees,
8243 C Calculate the multi-body contribution to energy.
8244 c ecorr=ecorr+ekont*ees
8245 C Calculate multi-body contributions to the gradient.
8246 coeffpees0pij=coeffp*ees0pij
8247 coeffmees0mij=coeffm*ees0mij
8248 coeffpees0pkl=coeffp*ees0pkl
8249 coeffmees0mkl=coeffm*ees0mkl
8251 cgrad ghalfi=ees*ekl*gacont_hbr(ll,jj,i)
8252 gradcorr(ll,i)=gradcorr(ll,i)!+0.5d0*ghalfi
8253 & -ekont*(coeffpees0pkl*gacontp_hb1(ll,jj,i)+
8254 & coeffmees0mkl*gacontm_hb1(ll,jj,i))
8255 gradcorr(ll,j)=gradcorr(ll,j)!+0.5d0*ghalfi
8256 & -ekont*(coeffpees0pkl*gacontp_hb2(ll,jj,i)+
8257 & coeffmees0mkl*gacontm_hb2(ll,jj,i))
8258 cgrad ghalfk=ees*eij*gacont_hbr(ll,kk,k)
8259 gradcorr(ll,k)=gradcorr(ll,k)!+0.5d0*ghalfk
8260 & -ekont*(coeffpees0pij*gacontp_hb1(ll,kk,k)+
8261 & coeffmees0mij*gacontm_hb1(ll,kk,k))
8262 gradcorr(ll,l)=gradcorr(ll,l)!+0.5d0*ghalfk
8263 & -ekont*(coeffpees0pij*gacontp_hb2(ll,kk,k)+
8264 & coeffmees0mij*gacontm_hb2(ll,kk,k))
8265 gradlongij=ees*ekl*gacont_hbr(ll,jj,i)-
8266 & ekont*(coeffpees0pkl*gacontp_hb3(ll,jj,i)+
8267 & coeffmees0mkl*gacontm_hb3(ll,jj,i))
8268 gradcorr_long(ll,j)=gradcorr_long(ll,j)+gradlongij
8269 gradcorr_long(ll,i)=gradcorr_long(ll,i)-gradlongij
8270 gradlongkl=ees*eij*gacont_hbr(ll,kk,k)-
8271 & ekont*(coeffpees0pij*gacontp_hb3(ll,kk,k)+
8272 & coeffmees0mij*gacontm_hb3(ll,kk,k))
8273 gradcorr_long(ll,l)=gradcorr_long(ll,l)+gradlongkl
8274 gradcorr_long(ll,k)=gradcorr_long(ll,k)-gradlongkl
8275 c write (iout,'(2f10.5,2x,$)') gradlongij,gradlongkl
8280 cgrad gradcorr(ll,m)=gradcorr(ll,m)+
8281 cgrad & ees*ekl*gacont_hbr(ll,jj,i)-
8282 cgrad & ekont*(coeffp*ees0pkl*gacontp_hb3(ll,jj,i)+
8283 cgrad & coeffm*ees0mkl*gacontm_hb3(ll,jj,i))
8288 cgrad gradcorr(ll,m)=gradcorr(ll,m)+
8289 cgrad & ees*eij*gacont_hbr(ll,kk,k)-
8290 cgrad & ekont*(coeffp*ees0pij*gacontp_hb3(ll,kk,k)+
8291 cgrad & coeffm*ees0mij*gacontm_hb3(ll,kk,k))
8294 c write (iout,*) "ehbcorr",ekont*ees
8299 C---------------------------------------------------------------------------
8300 subroutine dipole(i,j,jj)
8301 implicit real*8 (a-h,o-z)
8302 include 'DIMENSIONS'
8303 include 'COMMON.IOUNITS'
8304 include 'COMMON.CHAIN'
8305 include 'COMMON.FFIELD'
8306 include 'COMMON.DERIV'
8307 include 'COMMON.INTERACT'
8308 include 'COMMON.CONTACTS'
8309 include 'COMMON.TORSION'
8310 include 'COMMON.VAR'
8311 include 'COMMON.GEO'
8312 dimension dipi(2,2),dipj(2,2),dipderi(2),dipderj(2),auxvec(2),
8314 iti1 = itortyp(itype(i+1))
8315 if (j.lt.nres-1) then
8316 itj1 = itortyp(itype(j+1))
8321 dipi(iii,1)=Ub2(iii,i)
8322 dipderi(iii)=Ub2der(iii,i)
8323 dipi(iii,2)=b1(iii,i+1)
8324 dipj(iii,1)=Ub2(iii,j)
8325 dipderj(iii)=Ub2der(iii,j)
8326 dipj(iii,2)=b1(iii,j+1)
8330 call matvec2(a_chuj(1,1,jj,i),dipj(1,iii),auxvec(1))
8333 dip(kkk,jj,i)=scalar2(dipi(1,jjj),auxvec(1))
8340 call matvec2(a_chuj_der(1,1,lll,kkk,jj,i),dipj(1,iii),
8344 dipderx(lll,kkk,mmm,jj,i)=scalar2(dipi(1,jjj),auxvec(1))
8349 call transpose2(a_chuj(1,1,jj,i),auxmat(1,1))
8350 call matvec2(auxmat(1,1),dipderi(1),auxvec(1))
8352 dipderg(iii,jj,i)=scalar2(auxvec(1),dipj(1,iii))
8354 call matvec2(a_chuj(1,1,jj,i),dipderj(1),auxvec(1))
8356 dipderg(iii+2,jj,i)=scalar2(auxvec(1),dipi(1,iii))
8361 C---------------------------------------------------------------------------
8362 subroutine calc_eello(i,j,k,l,jj,kk)
8364 C This subroutine computes matrices and vectors needed to calculate
8365 C the fourth-, fifth-, and sixth-order local-electrostatic terms.
8367 implicit real*8 (a-h,o-z)
8368 include 'DIMENSIONS'
8369 include 'COMMON.IOUNITS'
8370 include 'COMMON.CHAIN'
8371 include 'COMMON.DERIV'
8372 include 'COMMON.INTERACT'
8373 include 'COMMON.CONTACTS'
8374 include 'COMMON.TORSION'
8375 include 'COMMON.VAR'
8376 include 'COMMON.GEO'
8377 include 'COMMON.FFIELD'
8378 double precision aa1(2,2),aa2(2,2),aa1t(2,2),aa2t(2,2),
8379 & aa1tder(2,2,3,5),aa2tder(2,2,3,5),auxmat(2,2)
8382 cd write (iout,*) 'calc_eello: i=',i,' j=',j,' k=',k,' l=',l,
8383 cd & ' jj=',jj,' kk=',kk
8384 cd if (i.ne.2 .or. j.ne.4 .or. k.ne.3 .or. l.ne.5) return
8385 cd write (iout,*) "a_chujij",((a_chuj(iii,jjj,jj,i),iii=1,2),jjj=1,2)
8386 cd write (iout,*) "a_chujkl",((a_chuj(iii,jjj,kk,k),iii=1,2),jjj=1,2)
8389 aa1(iii,jjj)=a_chuj(iii,jjj,jj,i)
8390 aa2(iii,jjj)=a_chuj(iii,jjj,kk,k)
8393 call transpose2(aa1(1,1),aa1t(1,1))
8394 call transpose2(aa2(1,1),aa2t(1,1))
8397 call transpose2(a_chuj_der(1,1,lll,kkk,jj,i),
8398 & aa1tder(1,1,lll,kkk))
8399 call transpose2(a_chuj_der(1,1,lll,kkk,kk,k),
8400 & aa2tder(1,1,lll,kkk))
8404 C parallel orientation of the two CA-CA-CA frames.
8406 iti=itortyp(itype(i))
8410 itk1=itortyp(itype(k+1))
8411 itj=itortyp(itype(j))
8412 if (l.lt.nres-1) then
8413 itl1=itortyp(itype(l+1))
8417 C A1 kernel(j+1) A2T
8419 cd write (iout,'(3f10.5,5x,3f10.5)')
8420 cd & (EUg(iii,jjj,k),jjj=1,2),(EUg(iii,jjj,l),jjj=1,2)
8422 call kernel(aa1(1,1),aa2t(1,1),a_chuj_der(1,1,1,1,jj,i),
8423 & aa2tder(1,1,1,1),1,.false.,EUg(1,1,l),EUgder(1,1,l),
8424 & AEA(1,1,1),AEAderg(1,1,1),AEAderx(1,1,1,1,1,1))
8425 C Following matrices are needed only for 6-th order cumulants
8426 IF (wcorr6.gt.0.0d0) THEN
8427 call kernel(aa1(1,1),aa2t(1,1),a_chuj_der(1,1,1,1,jj,i),
8428 & aa2tder(1,1,1,1),1,.false.,EUgC(1,1,l),EUgCder(1,1,l),
8429 & AECA(1,1,1),AECAderg(1,1,1),AECAderx(1,1,1,1,1,1))
8430 call kernel(aa1(1,1),aa2t(1,1),a_chuj_der(1,1,1,1,jj,i),
8431 & aa2tder(1,1,1,1),2,.false.,Ug2DtEUg(1,1,l),
8432 & Ug2DtEUgder(1,1,1,l),ADtEA(1,1,1),ADtEAderg(1,1,1,1),
8433 & ADtEAderx(1,1,1,1,1,1))
8435 call kernel(aa1(1,1),aa2t(1,1),a_chuj_der(1,1,1,1,jj,i),
8436 & aa2tder(1,1,1,1),2,.false.,DtUg2EUg(1,1,l),
8437 & DtUg2EUgder(1,1,1,l),ADtEA1(1,1,1),ADtEA1derg(1,1,1,1),
8438 & ADtEA1derx(1,1,1,1,1,1))
8440 C End 6-th order cumulants
8443 cd write (2,*) 'In calc_eello6'
8445 cd write (2,*) 'iii=',iii
8447 cd write (2,*) 'kkk=',kkk
8449 cd write (2,'(3(2f10.5),5x)')
8450 cd & ((ADtEA1derx(jjj,mmm,lll,kkk,iii,1),mmm=1,2),lll=1,3)
8455 call transpose2(EUgder(1,1,k),auxmat(1,1))
8456 call matmat2(auxmat(1,1),AEA(1,1,1),EAEAderg(1,1,1,1))
8457 call transpose2(EUg(1,1,k),auxmat(1,1))
8458 call matmat2(auxmat(1,1),AEA(1,1,1),EAEA(1,1,1))
8459 call matmat2(auxmat(1,1),AEAderg(1,1,1),EAEAderg(1,1,2,1))
8463 call matmat2(auxmat(1,1),AEAderx(1,1,lll,kkk,iii,1),
8464 & EAEAderx(1,1,lll,kkk,iii,1))
8468 C A1T kernel(i+1) A2
8469 call kernel(aa1t(1,1),aa2(1,1),aa1tder(1,1,1,1),
8470 & a_chuj_der(1,1,1,1,kk,k),1,.false.,EUg(1,1,k),EUgder(1,1,k),
8471 & AEA(1,1,2),AEAderg(1,1,2),AEAderx(1,1,1,1,1,2))
8472 C Following matrices are needed only for 6-th order cumulants
8473 IF (wcorr6.gt.0.0d0) THEN
8474 call kernel(aa1t(1,1),aa2(1,1),aa1tder(1,1,1,1),
8475 & a_chuj_der(1,1,1,1,kk,k),1,.false.,EUgC(1,1,k),EUgCder(1,1,k),
8476 & AECA(1,1,2),AECAderg(1,1,2),AECAderx(1,1,1,1,1,2))
8477 call kernel(aa1t(1,1),aa2(1,1),aa1tder(1,1,1,1),
8478 & a_chuj_der(1,1,1,1,kk,k),2,.false.,Ug2DtEUg(1,1,k),
8479 & Ug2DtEUgder(1,1,1,k),ADtEA(1,1,2),ADtEAderg(1,1,1,2),
8480 & ADtEAderx(1,1,1,1,1,2))
8481 call kernel(aa1t(1,1),aa2(1,1),aa1tder(1,1,1,1),
8482 & a_chuj_der(1,1,1,1,kk,k),2,.false.,DtUg2EUg(1,1,k),
8483 & DtUg2EUgder(1,1,1,k),ADtEA1(1,1,2),ADtEA1derg(1,1,1,2),
8484 & ADtEA1derx(1,1,1,1,1,2))
8486 C End 6-th order cumulants
8487 call transpose2(EUgder(1,1,l),auxmat(1,1))
8488 call matmat2(auxmat(1,1),AEA(1,1,2),EAEAderg(1,1,1,2))
8489 call transpose2(EUg(1,1,l),auxmat(1,1))
8490 call matmat2(auxmat(1,1),AEA(1,1,2),EAEA(1,1,2))
8491 call matmat2(auxmat(1,1),AEAderg(1,1,2),EAEAderg(1,1,2,2))
8495 call matmat2(auxmat(1,1),AEAderx(1,1,lll,kkk,iii,2),
8496 & EAEAderx(1,1,lll,kkk,iii,2))
8501 C Calculate the vectors and their derivatives in virtual-bond dihedral angles.
8502 C They are needed only when the fifth- or the sixth-order cumulants are
8504 IF (wcorr5.gt.0.0d0 .or. wcorr6.gt.0.0d0) THEN
8505 call transpose2(AEA(1,1,1),auxmat(1,1))
8506 call matvec2(auxmat(1,1),b1(1,i),AEAb1(1,1,1))
8507 call matvec2(auxmat(1,1),Ub2(1,i),AEAb2(1,1,1))
8508 call matvec2(auxmat(1,1),Ub2der(1,i),AEAb2derg(1,2,1,1))
8509 call transpose2(AEAderg(1,1,1),auxmat(1,1))
8510 call matvec2(auxmat(1,1),b1(1,i),AEAb1derg(1,1,1))
8511 call matvec2(auxmat(1,1),Ub2(1,i),AEAb2derg(1,1,1,1))
8512 call matvec2(AEA(1,1,1),b1(1,k+1),AEAb1(1,2,1))
8513 call matvec2(AEAderg(1,1,1),b1(1,k+1),AEAb1derg(1,2,1))
8514 call matvec2(AEA(1,1,1),Ub2(1,k+1),AEAb2(1,2,1))
8515 call matvec2(AEAderg(1,1,1),Ub2(1,k+1),AEAb2derg(1,1,2,1))
8516 call matvec2(AEA(1,1,1),Ub2der(1,k+1),AEAb2derg(1,2,2,1))
8517 call transpose2(AEA(1,1,2),auxmat(1,1))
8518 call matvec2(auxmat(1,1),b1(1,j),AEAb1(1,1,2))
8519 call matvec2(auxmat(1,1),Ub2(1,j),AEAb2(1,1,2))
8520 call matvec2(auxmat(1,1),Ub2der(1,j),AEAb2derg(1,2,1,2))
8521 call transpose2(AEAderg(1,1,2),auxmat(1,1))
8522 call matvec2(auxmat(1,1),b1(1,j),AEAb1derg(1,1,2))
8523 call matvec2(auxmat(1,1),Ub2(1,j),AEAb2derg(1,1,1,2))
8524 call matvec2(AEA(1,1,2),b1(1,l+1),AEAb1(1,2,2))
8525 call matvec2(AEAderg(1,1,2),b1(1,l+1),AEAb1derg(1,2,2))
8526 call matvec2(AEA(1,1,2),Ub2(1,l+1),AEAb2(1,2,2))
8527 call matvec2(AEAderg(1,1,2),Ub2(1,l+1),AEAb2derg(1,1,2,2))
8528 call matvec2(AEA(1,1,2),Ub2der(1,l+1),AEAb2derg(1,2,2,2))
8529 C Calculate the Cartesian derivatives of the vectors.
8533 call transpose2(AEAderx(1,1,lll,kkk,iii,1),auxmat(1,1))
8534 call matvec2(auxmat(1,1),b1(1,i),
8535 & AEAb1derx(1,lll,kkk,iii,1,1))
8536 call matvec2(auxmat(1,1),Ub2(1,i),
8537 & AEAb2derx(1,lll,kkk,iii,1,1))
8538 call matvec2(AEAderx(1,1,lll,kkk,iii,1),b1(1,k+1),
8539 & AEAb1derx(1,lll,kkk,iii,2,1))
8540 call matvec2(AEAderx(1,1,lll,kkk,iii,1),Ub2(1,k+1),
8541 & AEAb2derx(1,lll,kkk,iii,2,1))
8542 call transpose2(AEAderx(1,1,lll,kkk,iii,2),auxmat(1,1))
8543 call matvec2(auxmat(1,1),b1(1,j),
8544 & AEAb1derx(1,lll,kkk,iii,1,2))
8545 call matvec2(auxmat(1,1),Ub2(1,j),
8546 & AEAb2derx(1,lll,kkk,iii,1,2))
8547 call matvec2(AEAderx(1,1,lll,kkk,iii,2),b1(1,l+1),
8548 & AEAb1derx(1,lll,kkk,iii,2,2))
8549 call matvec2(AEAderx(1,1,lll,kkk,iii,2),Ub2(1,l+1),
8550 & AEAb2derx(1,lll,kkk,iii,2,2))
8557 C Antiparallel orientation of the two CA-CA-CA frames.
8559 iti=itortyp(itype(i))
8563 itk1=itortyp(itype(k+1))
8564 itl=itortyp(itype(l))
8565 itj=itortyp(itype(j))
8566 if (j.lt.nres-1) then
8567 itj1=itortyp(itype(j+1))
8571 C A2 kernel(j-1)T A1T
8572 call kernel(aa1(1,1),aa2t(1,1),a_chuj_der(1,1,1,1,jj,i),
8573 & aa2tder(1,1,1,1),1,.true.,EUg(1,1,j),EUgder(1,1,j),
8574 & AEA(1,1,1),AEAderg(1,1,1),AEAderx(1,1,1,1,1,1))
8575 C Following matrices are needed only for 6-th order cumulants
8576 IF (wcorr6.gt.0.0d0 .or. (wturn6.gt.0.0d0 .and.
8577 & j.eq.i+4 .and. l.eq.i+3)) THEN
8578 call kernel(aa1(1,1),aa2t(1,1),a_chuj_der(1,1,1,1,jj,i),
8579 & aa2tder(1,1,1,1),1,.true.,EUgC(1,1,j),EUgCder(1,1,j),
8580 & AECA(1,1,1),AECAderg(1,1,1),AECAderx(1,1,1,1,1,1))
8581 call kernel(aa2(1,1),aa2t(1,1),a_chuj_der(1,1,1,1,jj,i),
8582 & aa2tder(1,1,1,1),2,.true.,Ug2DtEUg(1,1,j),
8583 & Ug2DtEUgder(1,1,1,j),ADtEA(1,1,1),ADtEAderg(1,1,1,1),
8584 & ADtEAderx(1,1,1,1,1,1))
8585 call kernel(aa1(1,1),aa2t(1,1),a_chuj_der(1,1,1,1,jj,i),
8586 & aa2tder(1,1,1,1),2,.true.,DtUg2EUg(1,1,j),
8587 & DtUg2EUgder(1,1,1,j),ADtEA1(1,1,1),ADtEA1derg(1,1,1,1),
8588 & ADtEA1derx(1,1,1,1,1,1))
8590 C End 6-th order cumulants
8591 call transpose2(EUgder(1,1,k),auxmat(1,1))
8592 call matmat2(auxmat(1,1),AEA(1,1,1),EAEAderg(1,1,1,1))
8593 call transpose2(EUg(1,1,k),auxmat(1,1))
8594 call matmat2(auxmat(1,1),AEA(1,1,1),EAEA(1,1,1))
8595 call matmat2(auxmat(1,1),AEAderg(1,1,1),EAEAderg(1,1,2,1))
8599 call matmat2(auxmat(1,1),AEAderx(1,1,lll,kkk,iii,1),
8600 & EAEAderx(1,1,lll,kkk,iii,1))
8604 C A2T kernel(i+1)T A1
8605 call kernel(aa2t(1,1),aa1(1,1),aa2tder(1,1,1,1),
8606 & a_chuj_der(1,1,1,1,jj,i),1,.true.,EUg(1,1,k),EUgder(1,1,k),
8607 & AEA(1,1,2),AEAderg(1,1,2),AEAderx(1,1,1,1,1,2))
8608 C Following matrices are needed only for 6-th order cumulants
8609 IF (wcorr6.gt.0.0d0 .or. (wturn6.gt.0.0d0 .and.
8610 & j.eq.i+4 .and. l.eq.i+3)) THEN
8611 call kernel(aa2t(1,1),aa1(1,1),aa2tder(1,1,1,1),
8612 & a_chuj_der(1,1,1,1,jj,i),1,.true.,EUgC(1,1,k),EUgCder(1,1,k),
8613 & AECA(1,1,2),AECAderg(1,1,2),AECAderx(1,1,1,1,1,2))
8614 call kernel(aa2t(1,1),aa1(1,1),aa2tder(1,1,1,1),
8615 & a_chuj_der(1,1,1,1,jj,i),2,.true.,Ug2DtEUg(1,1,k),
8616 & Ug2DtEUgder(1,1,1,k),ADtEA(1,1,2),ADtEAderg(1,1,1,2),
8617 & ADtEAderx(1,1,1,1,1,2))
8618 call kernel(aa2t(1,1),aa1(1,1),aa2tder(1,1,1,1),
8619 & a_chuj_der(1,1,1,1,jj,i),2,.true.,DtUg2EUg(1,1,k),
8620 & DtUg2EUgder(1,1,1,k),ADtEA1(1,1,2),ADtEA1derg(1,1,1,2),
8621 & ADtEA1derx(1,1,1,1,1,2))
8623 C End 6-th order cumulants
8624 call transpose2(EUgder(1,1,j),auxmat(1,1))
8625 call matmat2(auxmat(1,1),AEA(1,1,1),EAEAderg(1,1,2,2))
8626 call transpose2(EUg(1,1,j),auxmat(1,1))
8627 call matmat2(auxmat(1,1),AEA(1,1,2),EAEA(1,1,2))
8628 call matmat2(auxmat(1,1),AEAderg(1,1,2),EAEAderg(1,1,2,2))
8632 call matmat2(auxmat(1,1),AEAderx(1,1,lll,kkk,iii,2),
8633 & EAEAderx(1,1,lll,kkk,iii,2))
8638 C Calculate the vectors and their derivatives in virtual-bond dihedral angles.
8639 C They are needed only when the fifth- or the sixth-order cumulants are
8641 IF (wcorr5.gt.0.0d0 .or. wcorr6.gt.0.0d0 .or.
8642 & (wturn6.gt.0.0d0 .and. j.eq.i+4 .and. l.eq.i+3)) THEN
8643 call transpose2(AEA(1,1,1),auxmat(1,1))
8644 call matvec2(auxmat(1,1),b1(1,i),AEAb1(1,1,1))
8645 call matvec2(auxmat(1,1),Ub2(1,i),AEAb2(1,1,1))
8646 call matvec2(auxmat(1,1),Ub2der(1,i),AEAb2derg(1,2,1,1))
8647 call transpose2(AEAderg(1,1,1),auxmat(1,1))
8648 call matvec2(auxmat(1,1),b1(1,i),AEAb1derg(1,1,1))
8649 call matvec2(auxmat(1,1),Ub2(1,i),AEAb2derg(1,1,1,1))
8650 call matvec2(AEA(1,1,1),b1(1,k+1),AEAb1(1,2,1))
8651 call matvec2(AEAderg(1,1,1),b1(1,k+1),AEAb1derg(1,2,1))
8652 call matvec2(AEA(1,1,1),Ub2(1,k+1),AEAb2(1,2,1))
8653 call matvec2(AEAderg(1,1,1),Ub2(1,k+1),AEAb2derg(1,1,2,1))
8654 call matvec2(AEA(1,1,1),Ub2der(1,k+1),AEAb2derg(1,2,2,1))
8655 call transpose2(AEA(1,1,2),auxmat(1,1))
8656 call matvec2(auxmat(1,1),b1(1,j+1),AEAb1(1,1,2))
8657 call matvec2(auxmat(1,1),Ub2(1,l),AEAb2(1,1,2))
8658 call matvec2(auxmat(1,1),Ub2der(1,l),AEAb2derg(1,2,1,2))
8659 call transpose2(AEAderg(1,1,2),auxmat(1,1))
8660 call matvec2(auxmat(1,1),b1(1,l),AEAb1(1,1,2))
8661 call matvec2(auxmat(1,1),Ub2(1,l),AEAb2derg(1,1,1,2))
8662 call matvec2(AEA(1,1,2),b1(1,j+1),AEAb1(1,2,2))
8663 call matvec2(AEAderg(1,1,2),b1(1,j+1),AEAb1derg(1,2,2))
8664 call matvec2(AEA(1,1,2),Ub2(1,j),AEAb2(1,2,2))
8665 call matvec2(AEAderg(1,1,2),Ub2(1,j),AEAb2derg(1,1,2,2))
8666 call matvec2(AEA(1,1,2),Ub2der(1,j),AEAb2derg(1,2,2,2))
8667 C Calculate the Cartesian derivatives of the vectors.
8671 call transpose2(AEAderx(1,1,lll,kkk,iii,1),auxmat(1,1))
8672 call matvec2(auxmat(1,1),b1(1,i),
8673 & AEAb1derx(1,lll,kkk,iii,1,1))
8674 call matvec2(auxmat(1,1),Ub2(1,i),
8675 & AEAb2derx(1,lll,kkk,iii,1,1))
8676 call matvec2(AEAderx(1,1,lll,kkk,iii,1),b1(1,k+1),
8677 & AEAb1derx(1,lll,kkk,iii,2,1))
8678 call matvec2(AEAderx(1,1,lll,kkk,iii,1),Ub2(1,k+1),
8679 & AEAb2derx(1,lll,kkk,iii,2,1))
8680 call transpose2(AEAderx(1,1,lll,kkk,iii,2),auxmat(1,1))
8681 call matvec2(auxmat(1,1),b1(1,l),
8682 & AEAb1derx(1,lll,kkk,iii,1,2))
8683 call matvec2(auxmat(1,1),Ub2(1,l),
8684 & AEAb2derx(1,lll,kkk,iii,1,2))
8685 call matvec2(AEAderx(1,1,lll,kkk,iii,2),b1(1,j+1),
8686 & AEAb1derx(1,lll,kkk,iii,2,2))
8687 call matvec2(AEAderx(1,1,lll,kkk,iii,2),Ub2(1,j),
8688 & AEAb2derx(1,lll,kkk,iii,2,2))
8697 C---------------------------------------------------------------------------
8698 subroutine kernel(aa1,aa2t,aa1derx,aa2tderx,nderg,transp,
8699 & KK,KKderg,AKA,AKAderg,AKAderx)
8703 double precision aa1(2,2),aa2t(2,2),aa1derx(2,2,3,5),
8704 & aa2tderx(2,2,3,5),KK(2,2),KKderg(2,2,nderg),AKA(2,2),
8705 & AKAderg(2,2,nderg),AKAderx(2,2,3,5,2)
8710 call prodmat3(aa1(1,1),aa2t(1,1),KK(1,1),transp,AKA(1,1))
8712 call prodmat3(aa1(1,1),aa2t(1,1),KKderg(1,1,iii),transp,
8715 cd if (lprn) write (2,*) 'In kernel'
8717 cd if (lprn) write (2,*) 'kkk=',kkk
8719 call prodmat3(aa1derx(1,1,lll,kkk),aa2t(1,1),
8720 & KK(1,1),transp,AKAderx(1,1,lll,kkk,1))
8722 cd write (2,*) 'lll=',lll
8723 cd write (2,*) 'iii=1'
8725 cd write (2,'(3(2f10.5),5x)')
8726 cd & (AKAderx(jjj,mmm,lll,kkk,1),mmm=1,2)
8729 call prodmat3(aa1(1,1),aa2tderx(1,1,lll,kkk),
8730 & KK(1,1),transp,AKAderx(1,1,lll,kkk,2))
8732 cd write (2,*) 'lll=',lll
8733 cd write (2,*) 'iii=2'
8735 cd write (2,'(3(2f10.5),5x)')
8736 cd & (AKAderx(jjj,mmm,lll,kkk,2),mmm=1,2)
8743 C---------------------------------------------------------------------------
8744 double precision function eello4(i,j,k,l,jj,kk)
8745 implicit real*8 (a-h,o-z)
8746 include 'DIMENSIONS'
8747 include 'COMMON.IOUNITS'
8748 include 'COMMON.CHAIN'
8749 include 'COMMON.DERIV'
8750 include 'COMMON.INTERACT'
8751 include 'COMMON.CONTACTS'
8752 include 'COMMON.TORSION'
8753 include 'COMMON.VAR'
8754 include 'COMMON.GEO'
8755 double precision pizda(2,2),ggg1(3),ggg2(3)
8756 cd if (i.ne.1 .or. j.ne.5 .or. k.ne.2 .or.l.ne.4) then
8760 cd print *,'eello4:',i,j,k,l,jj,kk
8761 cd write (2,*) 'i',i,' j',j,' k',k,' l',l
8762 cd call checkint4(i,j,k,l,jj,kk,eel4_num)
8763 cold eij=facont_hb(jj,i)
8764 cold ekl=facont_hb(kk,k)
8766 eel4=-EAEA(1,1,1)-EAEA(2,2,1)
8767 cd eel41=-EAEA(1,1,2)-EAEA(2,2,2)
8768 gcorr_loc(k-1)=gcorr_loc(k-1)
8769 & -ekont*(EAEAderg(1,1,1,1)+EAEAderg(2,2,1,1))
8771 gcorr_loc(l-1)=gcorr_loc(l-1)
8772 & -ekont*(EAEAderg(1,1,2,1)+EAEAderg(2,2,2,1))
8774 gcorr_loc(j-1)=gcorr_loc(j-1)
8775 & -ekont*(EAEAderg(1,1,2,1)+EAEAderg(2,2,2,1))
8780 derx(lll,kkk,iii)=-EAEAderx(1,1,lll,kkk,iii,1)
8781 & -EAEAderx(2,2,lll,kkk,iii,1)
8782 cd derx(lll,kkk,iii)=0.0d0
8786 cd gcorr_loc(l-1)=0.0d0
8787 cd gcorr_loc(j-1)=0.0d0
8788 cd gcorr_loc(k-1)=0.0d0
8790 cd write (iout,*)'Contacts have occurred for peptide groups',
8791 cd & i,j,' fcont:',eij,' eij',' and ',k,l,
8792 cd & ' fcont ',ekl,' eel4=',eel4,' eel4_num',16*eel4_num
8793 if (j.lt.nres-1) then
8800 if (l.lt.nres-1) then
8808 cgrad ggg1(ll)=eel4*g_contij(ll,1)
8809 cgrad ggg2(ll)=eel4*g_contij(ll,2)
8810 glongij=eel4*g_contij(ll,1)+ekont*derx(ll,1,1)
8811 glongkl=eel4*g_contij(ll,2)+ekont*derx(ll,1,2)
8812 cgrad ghalf=0.5d0*ggg1(ll)
8813 gradcorr(ll,i)=gradcorr(ll,i)+ekont*derx(ll,2,1)
8814 gradcorr(ll,i+1)=gradcorr(ll,i+1)+ekont*derx(ll,3,1)
8815 gradcorr(ll,j)=gradcorr(ll,j)+ekont*derx(ll,4,1)
8816 gradcorr(ll,j1)=gradcorr(ll,j1)+ekont*derx(ll,5,1)
8817 gradcorr_long(ll,j)=gradcorr_long(ll,j)+glongij
8818 gradcorr_long(ll,i)=gradcorr_long(ll,i)-glongij
8819 cgrad ghalf=0.5d0*ggg2(ll)
8820 gradcorr(ll,k)=gradcorr(ll,k)+ekont*derx(ll,2,2)
8821 gradcorr(ll,k+1)=gradcorr(ll,k+1)+ekont*derx(ll,3,2)
8822 gradcorr(ll,l)=gradcorr(ll,l)+ekont*derx(ll,4,2)
8823 gradcorr(ll,l1)=gradcorr(ll,l1)+ekont*derx(ll,5,2)
8824 gradcorr_long(ll,l)=gradcorr_long(ll,l)+glongkl
8825 gradcorr_long(ll,k)=gradcorr_long(ll,k)-glongkl
8829 cgrad gradcorr(ll,m)=gradcorr(ll,m)+ggg1(ll)
8834 cgrad gradcorr(ll,m)=gradcorr(ll,m)+ggg2(ll)
8839 cgrad gradcorr(ll,m)=gradcorr(ll,m)+ekont*derx(ll,1,1)
8844 cgrad gradcorr(ll,m)=gradcorr(ll,m)+ekont*derx(ll,1,2)
8848 cd write (2,*) iii,gcorr_loc(iii)
8851 cd write (2,*) 'ekont',ekont
8852 cd write (iout,*) 'eello4',ekont*eel4
8855 C---------------------------------------------------------------------------
8856 double precision function eello5(i,j,k,l,jj,kk)
8857 implicit real*8 (a-h,o-z)
8858 include 'DIMENSIONS'
8859 include 'COMMON.IOUNITS'
8860 include 'COMMON.CHAIN'
8861 include 'COMMON.DERIV'
8862 include 'COMMON.INTERACT'
8863 include 'COMMON.CONTACTS'
8864 include 'COMMON.TORSION'
8865 include 'COMMON.VAR'
8866 include 'COMMON.GEO'
8867 double precision pizda(2,2),auxmat(2,2),auxmat1(2,2),vv(2)
8868 double precision ggg1(3),ggg2(3)
8869 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
8874 C /l\ / \ \ / \ / \ / C
8875 C / \ / \ \ / \ / \ / C
8876 C j| o |l1 | o | o| o | | o |o C
8877 C \ |/k\| |/ \| / |/ \| |/ \| C
8878 C \i/ \ / \ / / \ / \ C
8880 C (I) (II) (III) (IV) C
8882 C eello5_1 eello5_2 eello5_3 eello5_4 C
8884 C Antiparallel chains C
8887 C /j\ / \ \ / \ / \ / C
8888 C / \ / \ \ / \ / \ / C
8889 C j1| o |l | o | o| o | | o |o C
8890 C \ |/k\| |/ \| / |/ \| |/ \| C
8891 C \i/ \ / \ / / \ / \ C
8893 C (I) (II) (III) (IV) C
8895 C eello5_1 eello5_2 eello5_3 eello5_4 C
8897 C o denotes a local interaction, vertical lines an electrostatic interaction. C
8899 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
8900 cd if (i.ne.2 .or. j.ne.6 .or. k.ne.3 .or. l.ne.5) then
8905 cd & 'EELLO5: Contacts have occurred for peptide groups',i,j,
8907 c itk=itortyp(itype(k))
8908 c itl=itortyp(itype(l))
8909 c itj=itortyp(itype(j))
8914 cd call checkint5(i,j,k,l,jj,kk,eel5_1_num,eel5_2_num,
8915 cd & eel5_3_num,eel5_4_num)
8919 derx(lll,kkk,iii)=0.0d0
8923 cd eij=facont_hb(jj,i)
8924 cd ekl=facont_hb(kk,k)
8926 cd write (iout,*)'Contacts have occurred for peptide groups',
8927 cd & i,j,' fcont:',eij,' eij',' and ',k,l
8929 C Contribution from the graph I.
8930 cd write (2,*) 'AEA ',AEA(1,1,1),AEA(2,1,1),AEA(1,2,1),AEA(2,2,1)
8931 cd write (2,*) 'AEAb2',AEAb2(1,1,1),AEAb2(2,1,1)
8932 call transpose2(EUg(1,1,k),auxmat(1,1))
8933 call matmat2(AEA(1,1,1),auxmat(1,1),pizda(1,1))
8934 vv(1)=pizda(1,1)-pizda(2,2)
8935 vv(2)=pizda(1,2)+pizda(2,1)
8936 eello5_1=scalar2(AEAb2(1,1,1),Ub2(1,k))
8937 & +0.5d0*scalar2(vv(1),Dtobr2(1,i))
8938 C Explicit gradient in virtual-dihedral angles.
8939 if (i.gt.1) g_corr5_loc(i-1)=g_corr5_loc(i-1)
8940 & +ekont*(scalar2(AEAb2derg(1,2,1,1),Ub2(1,k))
8941 & +0.5d0*scalar2(vv(1),Dtobr2der(1,i)))
8942 call transpose2(EUgder(1,1,k),auxmat1(1,1))
8943 call matmat2(AEA(1,1,1),auxmat1(1,1),pizda(1,1))
8944 vv(1)=pizda(1,1)-pizda(2,2)
8945 vv(2)=pizda(1,2)+pizda(2,1)
8946 g_corr5_loc(k-1)=g_corr5_loc(k-1)
8947 & +ekont*(scalar2(AEAb2(1,1,1),Ub2der(1,k))
8948 & +0.5d0*scalar2(vv(1),Dtobr2(1,i)))
8949 call matmat2(AEAderg(1,1,1),auxmat(1,1),pizda(1,1))
8950 vv(1)=pizda(1,1)-pizda(2,2)
8951 vv(2)=pizda(1,2)+pizda(2,1)
8953 if (l.lt.nres-1) g_corr5_loc(l-1)=g_corr5_loc(l-1)
8954 & +ekont*(scalar2(AEAb2derg(1,1,1,1),Ub2(1,k))
8955 & +0.5d0*scalar2(vv(1),Dtobr2(1,i)))
8957 if (j.lt.nres-1) g_corr5_loc(j-1)=g_corr5_loc(j-1)
8958 & +ekont*(scalar2(AEAb2derg(1,1,1,1),Ub2(1,k))
8959 & +0.5d0*scalar2(vv(1),Dtobr2(1,i)))
8961 C Cartesian gradient
8965 call matmat2(AEAderx(1,1,lll,kkk,iii,1),auxmat(1,1),
8967 vv(1)=pizda(1,1)-pizda(2,2)
8968 vv(2)=pizda(1,2)+pizda(2,1)
8969 derx(lll,kkk,iii)=derx(lll,kkk,iii)
8970 & +scalar2(AEAb2derx(1,lll,kkk,iii,1,1),Ub2(1,k))
8971 & +0.5d0*scalar2(vv(1),Dtobr2(1,i))
8977 C Contribution from graph II
8978 call transpose2(EE(1,1,k),auxmat(1,1))
8979 call matmat2(auxmat(1,1),AEA(1,1,1),pizda(1,1))
8980 vv(1)=pizda(1,1)+pizda(2,2)
8981 vv(2)=pizda(2,1)-pizda(1,2)
8982 eello5_2=scalar2(AEAb1(1,2,1),b1(1,k))
8983 & -0.5d0*scalar2(vv(1),Ctobr(1,k))
8984 C Explicit gradient in virtual-dihedral angles.
8985 g_corr5_loc(k-1)=g_corr5_loc(k-1)
8986 & -0.5d0*ekont*scalar2(vv(1),Ctobrder(1,k))
8987 call matmat2(auxmat(1,1),AEAderg(1,1,1),pizda(1,1))
8988 vv(1)=pizda(1,1)+pizda(2,2)
8989 vv(2)=pizda(2,1)-pizda(1,2)
8991 g_corr5_loc(l-1)=g_corr5_loc(l-1)
8992 & +ekont*(scalar2(AEAb1derg(1,2,1),b1(1,k))
8993 & -0.5d0*scalar2(vv(1),Ctobr(1,k)))
8995 g_corr5_loc(j-1)=g_corr5_loc(j-1)
8996 & +ekont*(scalar2(AEAb1derg(1,2,1),b1(1,k))
8997 & -0.5d0*scalar2(vv(1),Ctobr(1,k)))
8999 C Cartesian gradient
9003 call matmat2(auxmat(1,1),AEAderx(1,1,lll,kkk,iii,1),
9005 vv(1)=pizda(1,1)+pizda(2,2)
9006 vv(2)=pizda(2,1)-pizda(1,2)
9007 derx(lll,kkk,iii)=derx(lll,kkk,iii)
9008 & +scalar2(AEAb1derx(1,lll,kkk,iii,2,1),b1(1,k))
9009 & -0.5d0*scalar2(vv(1),Ctobr(1,k))
9017 C Parallel orientation
9018 C Contribution from graph III
9019 call transpose2(EUg(1,1,l),auxmat(1,1))
9020 call matmat2(AEA(1,1,2),auxmat(1,1),pizda(1,1))
9021 vv(1)=pizda(1,1)-pizda(2,2)
9022 vv(2)=pizda(1,2)+pizda(2,1)
9023 eello5_3=scalar2(AEAb2(1,1,2),Ub2(1,l))
9024 & +0.5d0*scalar2(vv(1),Dtobr2(1,j))
9025 C Explicit gradient in virtual-dihedral angles.
9026 g_corr5_loc(j-1)=g_corr5_loc(j-1)
9027 & +ekont*(scalar2(AEAb2derg(1,2,1,2),Ub2(1,l))
9028 & +0.5d0*scalar2(vv(1),Dtobr2der(1,j)))
9029 call matmat2(AEAderg(1,1,2),auxmat(1,1),pizda(1,1))
9030 vv(1)=pizda(1,1)-pizda(2,2)
9031 vv(2)=pizda(1,2)+pizda(2,1)
9032 g_corr5_loc(k-1)=g_corr5_loc(k-1)
9033 & +ekont*(scalar2(AEAb2derg(1,1,1,2),Ub2(1,l))
9034 & +0.5d0*scalar2(vv(1),Dtobr2(1,j)))
9035 call transpose2(EUgder(1,1,l),auxmat1(1,1))
9036 call matmat2(AEA(1,1,2),auxmat1(1,1),pizda(1,1))
9037 vv(1)=pizda(1,1)-pizda(2,2)
9038 vv(2)=pizda(1,2)+pizda(2,1)
9039 g_corr5_loc(l-1)=g_corr5_loc(l-1)
9040 & +ekont*(scalar2(AEAb2(1,1,2),Ub2der(1,l))
9041 & +0.5d0*scalar2(vv(1),Dtobr2(1,j)))
9042 C Cartesian gradient
9046 call matmat2(AEAderx(1,1,lll,kkk,iii,2),auxmat(1,1),
9048 vv(1)=pizda(1,1)-pizda(2,2)
9049 vv(2)=pizda(1,2)+pizda(2,1)
9050 derx(lll,kkk,iii)=derx(lll,kkk,iii)
9051 & +scalar2(AEAb2derx(1,lll,kkk,iii,1,2),Ub2(1,l))
9052 & +0.5d0*scalar2(vv(1),Dtobr2(1,j))
9057 C Contribution from graph IV
9059 call transpose2(EE(1,1,l),auxmat(1,1))
9060 call matmat2(auxmat(1,1),AEA(1,1,2),pizda(1,1))
9061 vv(1)=pizda(1,1)+pizda(2,2)
9062 vv(2)=pizda(2,1)-pizda(1,2)
9063 eello5_4=scalar2(AEAb1(1,2,2),b1(1,l))
9064 & -0.5d0*scalar2(vv(1),Ctobr(1,l))
9065 C Explicit gradient in virtual-dihedral angles.
9066 g_corr5_loc(l-1)=g_corr5_loc(l-1)
9067 & -0.5d0*ekont*scalar2(vv(1),Ctobrder(1,l))
9068 call matmat2(auxmat(1,1),AEAderg(1,1,2),pizda(1,1))
9069 vv(1)=pizda(1,1)+pizda(2,2)
9070 vv(2)=pizda(2,1)-pizda(1,2)
9071 g_corr5_loc(k-1)=g_corr5_loc(k-1)
9072 & +ekont*(scalar2(AEAb1derg(1,2,2),b1(1,l))
9073 & -0.5d0*scalar2(vv(1),Ctobr(1,l)))
9074 C Cartesian gradient
9078 call matmat2(auxmat(1,1),AEAderx(1,1,lll,kkk,iii,2),
9080 vv(1)=pizda(1,1)+pizda(2,2)
9081 vv(2)=pizda(2,1)-pizda(1,2)
9082 derx(lll,kkk,iii)=derx(lll,kkk,iii)
9083 & +scalar2(AEAb1derx(1,lll,kkk,iii,2,2),b1(1,l))
9084 & -0.5d0*scalar2(vv(1),Ctobr(1,l))
9089 C Antiparallel orientation
9090 C Contribution from graph III
9092 call transpose2(EUg(1,1,j),auxmat(1,1))
9093 call matmat2(AEA(1,1,2),auxmat(1,1),pizda(1,1))
9094 vv(1)=pizda(1,1)-pizda(2,2)
9095 vv(2)=pizda(1,2)+pizda(2,1)
9096 eello5_3=scalar2(AEAb2(1,1,2),Ub2(1,j))
9097 & +0.5d0*scalar2(vv(1),Dtobr2(1,l))
9098 C Explicit gradient in virtual-dihedral angles.
9099 g_corr5_loc(l-1)=g_corr5_loc(l-1)
9100 & +ekont*(scalar2(AEAb2derg(1,2,1,2),Ub2(1,j))
9101 & +0.5d0*scalar2(vv(1),Dtobr2der(1,l)))
9102 call matmat2(AEAderg(1,1,2),auxmat(1,1),pizda(1,1))
9103 vv(1)=pizda(1,1)-pizda(2,2)
9104 vv(2)=pizda(1,2)+pizda(2,1)
9105 g_corr5_loc(k-1)=g_corr5_loc(k-1)
9106 & +ekont*(scalar2(AEAb2derg(1,1,1,2),Ub2(1,j))
9107 & +0.5d0*scalar2(vv(1),Dtobr2(1,l)))
9108 call transpose2(EUgder(1,1,j),auxmat1(1,1))
9109 call matmat2(AEA(1,1,2),auxmat1(1,1),pizda(1,1))
9110 vv(1)=pizda(1,1)-pizda(2,2)
9111 vv(2)=pizda(1,2)+pizda(2,1)
9112 g_corr5_loc(j-1)=g_corr5_loc(j-1)
9113 & +ekont*(scalar2(AEAb2(1,1,2),Ub2der(1,j))
9114 & +0.5d0*scalar2(vv(1),Dtobr2(1,l)))
9115 C Cartesian gradient
9119 call matmat2(AEAderx(1,1,lll,kkk,iii,2),auxmat(1,1),
9121 vv(1)=pizda(1,1)-pizda(2,2)
9122 vv(2)=pizda(1,2)+pizda(2,1)
9123 derx(lll,kkk,3-iii)=derx(lll,kkk,3-iii)
9124 & +scalar2(AEAb2derx(1,lll,kkk,iii,1,2),Ub2(1,j))
9125 & +0.5d0*scalar2(vv(1),Dtobr2(1,l))
9130 C Contribution from graph IV
9132 call transpose2(EE(1,1,j),auxmat(1,1))
9133 call matmat2(auxmat(1,1),AEA(1,1,2),pizda(1,1))
9134 vv(1)=pizda(1,1)+pizda(2,2)
9135 vv(2)=pizda(2,1)-pizda(1,2)
9136 eello5_4=scalar2(AEAb1(1,2,2),b1(1,j))
9137 & -0.5d0*scalar2(vv(1),Ctobr(1,j))
9138 C Explicit gradient in virtual-dihedral angles.
9139 g_corr5_loc(j-1)=g_corr5_loc(j-1)
9140 & -0.5d0*ekont*scalar2(vv(1),Ctobrder(1,j))
9141 call matmat2(auxmat(1,1),AEAderg(1,1,2),pizda(1,1))
9142 vv(1)=pizda(1,1)+pizda(2,2)
9143 vv(2)=pizda(2,1)-pizda(1,2)
9144 g_corr5_loc(k-1)=g_corr5_loc(k-1)
9145 & +ekont*(scalar2(AEAb1derg(1,2,2),b1(1,j))
9146 & -0.5d0*scalar2(vv(1),Ctobr(1,j)))
9147 C Cartesian gradient
9151 call matmat2(auxmat(1,1),AEAderx(1,1,lll,kkk,iii,2),
9153 vv(1)=pizda(1,1)+pizda(2,2)
9154 vv(2)=pizda(2,1)-pizda(1,2)
9155 derx(lll,kkk,3-iii)=derx(lll,kkk,3-iii)
9156 & +scalar2(AEAb1derx(1,lll,kkk,iii,2,2),b1(1,j))
9157 & -0.5d0*scalar2(vv(1),Ctobr(1,j))
9163 eel5=eello5_1+eello5_2+eello5_3+eello5_4
9164 cd if (i.eq.2 .and. j.eq.8 .and. k.eq.3 .and. l.eq.7) then
9165 cd write (2,*) 'ijkl',i,j,k,l
9166 cd write (2,*) 'eello5_1',eello5_1,' eello5_2',eello5_2,
9167 cd & ' eello5_3',eello5_3,' eello5_4',eello5_4
9169 cd write(iout,*) 'eello5_1',eello5_1,' eel5_1_num',16*eel5_1_num
9170 cd write(iout,*) 'eello5_2',eello5_2,' eel5_2_num',16*eel5_2_num
9171 cd write(iout,*) 'eello5_3',eello5_3,' eel5_3_num',16*eel5_3_num
9172 cd write(iout,*) 'eello5_4',eello5_4,' eel5_4_num',16*eel5_4_num
9173 if (j.lt.nres-1) then
9180 if (l.lt.nres-1) then
9190 cd write (2,*) 'eij',eij,' ekl',ekl,' ekont',ekont
9191 C 2/11/08 AL Gradients over DC's connecting interacting sites will be
9192 C summed up outside the subrouine as for the other subroutines
9193 C handling long-range interactions. The old code is commented out
9194 C with "cgrad" to keep track of changes.
9196 cgrad ggg1(ll)=eel5*g_contij(ll,1)
9197 cgrad ggg2(ll)=eel5*g_contij(ll,2)
9198 gradcorr5ij=eel5*g_contij(ll,1)+ekont*derx(ll,1,1)
9199 gradcorr5kl=eel5*g_contij(ll,2)+ekont*derx(ll,1,2)
9200 c write (iout,'(a,3i3,a,5f8.3,2i3,a,5f8.3,a,f8.3)')
9201 c & "ecorr5",ll,i,j," derx",derx(ll,2,1),derx(ll,3,1),derx(ll,4,1),
9202 c & derx(ll,5,1),k,l," derx",derx(ll,2,2),derx(ll,3,2),
9203 c & derx(ll,4,2),derx(ll,5,2)," ekont",ekont
9204 c write (iout,'(a,3i3,a,3f8.3,2i3,a,3f8.3)')
9205 c & "ecorr5",ll,i,j," gradcorr5",g_contij(ll,1),derx(ll,1,1),
9207 c & k,l," gradcorr5",g_contij(ll,2),derx(ll,1,2),gradcorr5kl
9208 cold ghalf=0.5d0*eel5*ekl*gacont_hbr(ll,jj,i)
9209 cgrad ghalf=0.5d0*ggg1(ll)
9211 gradcorr5(ll,i)=gradcorr5(ll,i)+ekont*derx(ll,2,1)
9212 gradcorr5(ll,i+1)=gradcorr5(ll,i+1)+ekont*derx(ll,3,1)
9213 gradcorr5(ll,j)=gradcorr5(ll,j)+ekont*derx(ll,4,1)
9214 gradcorr5(ll,j1)=gradcorr5(ll,j1)+ekont*derx(ll,5,1)
9215 gradcorr5_long(ll,j)=gradcorr5_long(ll,j)+gradcorr5ij
9216 gradcorr5_long(ll,i)=gradcorr5_long(ll,i)-gradcorr5ij
9217 cold ghalf=0.5d0*eel5*eij*gacont_hbr(ll,kk,k)
9218 cgrad ghalf=0.5d0*ggg2(ll)
9220 gradcorr5(ll,k)=gradcorr5(ll,k)+ekont*derx(ll,2,2)
9221 gradcorr5(ll,k+1)=gradcorr5(ll,k+1)+ekont*derx(ll,3,2)
9222 gradcorr5(ll,l)=gradcorr5(ll,l)+ekont*derx(ll,4,2)
9223 gradcorr5(ll,l1)=gradcorr5(ll,l1)+ekont*derx(ll,5,2)
9224 gradcorr5_long(ll,l)=gradcorr5_long(ll,l)+gradcorr5kl
9225 gradcorr5_long(ll,k)=gradcorr5_long(ll,k)-gradcorr5kl
9230 cold gradcorr5(ll,m)=gradcorr5(ll,m)+eel5*ekl*gacont_hbr(ll,jj,i)
9231 cgrad gradcorr5(ll,m)=gradcorr5(ll,m)+ggg1(ll)
9236 cold gradcorr5(ll,m)=gradcorr5(ll,m)+eel5*eij*gacont_hbr(ll,kk,k)
9237 cgrad gradcorr5(ll,m)=gradcorr5(ll,m)+ggg2(ll)
9243 cgrad gradcorr5(ll,m)=gradcorr5(ll,m)+ekont*derx(ll,1,1)
9248 cgrad gradcorr5(ll,m)=gradcorr5(ll,m)+ekont*derx(ll,1,2)
9252 cd write (2,*) iii,g_corr5_loc(iii)
9255 cd write (2,*) 'ekont',ekont
9256 cd write (iout,*) 'eello5',ekont*eel5
9259 c--------------------------------------------------------------------------
9260 double precision function eello6(i,j,k,l,jj,kk)
9261 implicit real*8 (a-h,o-z)
9262 include 'DIMENSIONS'
9263 include 'COMMON.IOUNITS'
9264 include 'COMMON.CHAIN'
9265 include 'COMMON.DERIV'
9266 include 'COMMON.INTERACT'
9267 include 'COMMON.CONTACTS'
9268 include 'COMMON.TORSION'
9269 include 'COMMON.VAR'
9270 include 'COMMON.GEO'
9271 include 'COMMON.FFIELD'
9272 double precision ggg1(3),ggg2(3)
9273 cd if (i.ne.1 .or. j.ne.3 .or. k.ne.2 .or. l.ne.4) then
9278 cd & 'EELLO6: Contacts have occurred for peptide groups',i,j,
9286 cd call checkint6(i,j,k,l,jj,kk,eel6_1_num,eel6_2_num,
9287 cd & eel6_3_num,eel6_4_num,eel6_5_num,eel6_6_num)
9291 derx(lll,kkk,iii)=0.0d0
9295 cd eij=facont_hb(jj,i)
9296 cd ekl=facont_hb(kk,k)
9302 eello6_1=eello6_graph1(i,j,k,l,1,.false.)
9303 eello6_2=eello6_graph1(j,i,l,k,2,.false.)
9304 eello6_3=eello6_graph2(i,j,k,l,jj,kk,.false.)
9305 eello6_4=eello6_graph4(i,j,k,l,jj,kk,1,.false.)
9306 eello6_5=eello6_graph4(j,i,l,k,jj,kk,2,.false.)
9307 eello6_6=eello6_graph3(i,j,k,l,jj,kk,.false.)
9309 eello6_1=eello6_graph1(i,j,k,l,1,.false.)
9310 eello6_2=eello6_graph1(l,k,j,i,2,.true.)
9311 eello6_3=eello6_graph2(i,l,k,j,jj,kk,.true.)
9312 eello6_4=eello6_graph4(i,j,k,l,jj,kk,1,.false.)
9313 if (wturn6.eq.0.0d0 .or. j.ne.i+4) then
9314 eello6_5=eello6_graph4(l,k,j,i,kk,jj,2,.true.)
9318 eello6_6=eello6_graph3(i,l,k,j,jj,kk,.true.)
9320 C If turn contributions are considered, they will be handled separately.
9321 eel6=eello6_1+eello6_2+eello6_3+eello6_4+eello6_5+eello6_6
9322 cd write(iout,*) 'eello6_1',eello6_1!,' eel6_1_num',16*eel6_1_num
9323 cd write(iout,*) 'eello6_2',eello6_2!,' eel6_2_num',16*eel6_2_num
9324 cd write(iout,*) 'eello6_3',eello6_3!,' eel6_3_num',16*eel6_3_num
9325 cd write(iout,*) 'eello6_4',eello6_4!,' eel6_4_num',16*eel6_4_num
9326 cd write(iout,*) 'eello6_5',eello6_5!,' eel6_5_num',16*eel6_5_num
9327 cd write(iout,*) 'eello6_6',eello6_6!,' eel6_6_num',16*eel6_6_num
9329 if (j.lt.nres-1) then
9336 if (l.lt.nres-1) then
9344 cgrad ggg1(ll)=eel6*g_contij(ll,1)
9345 cgrad ggg2(ll)=eel6*g_contij(ll,2)
9346 cold ghalf=0.5d0*eel6*ekl*gacont_hbr(ll,jj,i)
9347 cgrad ghalf=0.5d0*ggg1(ll)
9349 gradcorr6ij=eel6*g_contij(ll,1)+ekont*derx(ll,1,1)
9350 gradcorr6kl=eel6*g_contij(ll,2)+ekont*derx(ll,1,2)
9351 gradcorr6(ll,i)=gradcorr6(ll,i)+ekont*derx(ll,2,1)
9352 gradcorr6(ll,i+1)=gradcorr6(ll,i+1)+ekont*derx(ll,3,1)
9353 gradcorr6(ll,j)=gradcorr6(ll,j)+ekont*derx(ll,4,1)
9354 gradcorr6(ll,j1)=gradcorr6(ll,j1)+ekont*derx(ll,5,1)
9355 gradcorr6_long(ll,j)=gradcorr6_long(ll,j)+gradcorr6ij
9356 gradcorr6_long(ll,i)=gradcorr6_long(ll,i)-gradcorr6ij
9357 cgrad ghalf=0.5d0*ggg2(ll)
9358 cold ghalf=0.5d0*eel6*eij*gacont_hbr(ll,kk,k)
9360 gradcorr6(ll,k)=gradcorr6(ll,k)+ekont*derx(ll,2,2)
9361 gradcorr6(ll,k+1)=gradcorr6(ll,k+1)+ekont*derx(ll,3,2)
9362 gradcorr6(ll,l)=gradcorr6(ll,l)+ekont*derx(ll,4,2)
9363 gradcorr6(ll,l1)=gradcorr6(ll,l1)+ekont*derx(ll,5,2)
9364 gradcorr6_long(ll,l)=gradcorr6_long(ll,l)+gradcorr6kl
9365 gradcorr6_long(ll,k)=gradcorr6_long(ll,k)-gradcorr6kl
9370 cold gradcorr6(ll,m)=gradcorr6(ll,m)+eel6*ekl*gacont_hbr(ll,jj,i)
9371 cgrad gradcorr6(ll,m)=gradcorr6(ll,m)+ggg1(ll)
9376 cold gradcorr6(ll,m)=gradcorr6(ll,m)+eel6*eij*gacont_hbr(ll,kk,k)
9377 cgrad gradcorr6(ll,m)=gradcorr6(ll,m)+ggg2(ll)
9383 cgrad gradcorr6(ll,m)=gradcorr6(ll,m)+ekont*derx(ll,1,1)
9388 cgrad gradcorr6(ll,m)=gradcorr6(ll,m)+ekont*derx(ll,1,2)
9392 cd write (2,*) iii,g_corr6_loc(iii)
9395 cd write (2,*) 'ekont',ekont
9396 cd write (iout,*) 'eello6',ekont*eel6
9399 c--------------------------------------------------------------------------
9400 double precision function eello6_graph1(i,j,k,l,imat,swap)
9401 implicit real*8 (a-h,o-z)
9402 include 'DIMENSIONS'
9403 include 'COMMON.IOUNITS'
9404 include 'COMMON.CHAIN'
9405 include 'COMMON.DERIV'
9406 include 'COMMON.INTERACT'
9407 include 'COMMON.CONTACTS'
9408 include 'COMMON.TORSION'
9409 include 'COMMON.VAR'
9410 include 'COMMON.GEO'
9411 double precision vv(2),vv1(2),pizda(2,2),auxmat(2,2),pizda1(2,2)
9415 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
9417 C Parallel Antiparallel C
9423 C \ j|/k\| / \ |/k\|l / C
9428 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
9429 c itk=itortyp(itype(k))
9430 s1= scalar2(AEAb1(1,2,imat),CUgb2(1,i))
9431 s2=-scalar2(AEAb2(1,1,imat),Ug2Db1t(1,k))
9432 s3= scalar2(AEAb2(1,1,imat),CUgb2(1,k))
9433 call transpose2(EUgC(1,1,k),auxmat(1,1))
9434 call matmat2(AEA(1,1,imat),auxmat(1,1),pizda1(1,1))
9435 vv1(1)=pizda1(1,1)-pizda1(2,2)
9436 vv1(2)=pizda1(1,2)+pizda1(2,1)
9437 s4=0.5d0*scalar2(vv1(1),Dtobr2(1,i))
9438 vv(1)=AEAb1(1,2,imat)*b1(1,k)-AEAb1(2,2,imat)*b1(2,k)
9439 vv(2)=AEAb1(1,2,imat)*b1(2,k)+AEAb1(2,2,imat)*b1(1,k)
9440 s5=scalar2(vv(1),Dtobr2(1,i))
9441 cd write (2,*) 's1',s1,' s2',s2,' s3',s3,' s4', s4,' s5',s5
9442 eello6_graph1=-0.5d0*(s1+s2+s3+s4+s5)
9443 if (i.gt.1) g_corr6_loc(i-1)=g_corr6_loc(i-1)
9444 & -0.5d0*ekont*(scalar2(AEAb1(1,2,imat),CUgb2der(1,i))
9445 & -scalar2(AEAb2derg(1,2,1,imat),Ug2Db1t(1,k))
9446 & +scalar2(AEAb2derg(1,2,1,imat),CUgb2(1,k))
9447 & +0.5d0*scalar2(vv1(1),Dtobr2der(1,i))
9448 & +scalar2(vv(1),Dtobr2der(1,i)))
9449 call matmat2(AEAderg(1,1,imat),auxmat(1,1),pizda1(1,1))
9450 vv1(1)=pizda1(1,1)-pizda1(2,2)
9451 vv1(2)=pizda1(1,2)+pizda1(2,1)
9452 vv(1)=AEAb1derg(1,2,imat)*b1(1,k)-AEAb1derg(2,2,imat)*b1(2,k)
9453 vv(2)=AEAb1derg(1,2,imat)*b1(2,k)+AEAb1derg(2,2,imat)*b1(1,k)
9455 g_corr6_loc(l-1)=g_corr6_loc(l-1)
9456 & +ekont*(-0.5d0*(scalar2(AEAb1derg(1,2,imat),CUgb2(1,i))
9457 & -scalar2(AEAb2derg(1,1,1,imat),Ug2Db1t(1,k))
9458 & +scalar2(AEAb2derg(1,1,1,imat),CUgb2(1,k))
9459 & +0.5d0*scalar2(vv1(1),Dtobr2(1,i))+scalar2(vv(1),Dtobr2(1,i))))
9461 g_corr6_loc(j-1)=g_corr6_loc(j-1)
9462 & +ekont*(-0.5d0*(scalar2(AEAb1derg(1,2,imat),CUgb2(1,i))
9463 & -scalar2(AEAb2derg(1,1,1,imat),Ug2Db1t(1,k))
9464 & +scalar2(AEAb2derg(1,1,1,imat),CUgb2(1,k))
9465 & +0.5d0*scalar2(vv1(1),Dtobr2(1,i))+scalar2(vv(1),Dtobr2(1,i))))
9467 call transpose2(EUgCder(1,1,k),auxmat(1,1))
9468 call matmat2(AEA(1,1,imat),auxmat(1,1),pizda1(1,1))
9469 vv1(1)=pizda1(1,1)-pizda1(2,2)
9470 vv1(2)=pizda1(1,2)+pizda1(2,1)
9471 if (k.gt.1) g_corr6_loc(k-1)=g_corr6_loc(k-1)
9472 & +ekont*(-0.5d0*(-scalar2(AEAb2(1,1,imat),Ug2Db1tder(1,k))
9473 & +scalar2(AEAb2(1,1,imat),CUgb2der(1,k))
9474 & +0.5d0*scalar2(vv1(1),Dtobr2(1,i))))
9483 s1= scalar2(AEAb1derx(1,lll,kkk,iii,2,imat),CUgb2(1,i))
9484 s2=-scalar2(AEAb2derx(1,lll,kkk,iii,1,imat),Ug2Db1t(1,k))
9485 s3= scalar2(AEAb2derx(1,lll,kkk,iii,1,imat),CUgb2(1,k))
9486 call transpose2(EUgC(1,1,k),auxmat(1,1))
9487 call matmat2(AEAderx(1,1,lll,kkk,iii,imat),auxmat(1,1),
9489 vv1(1)=pizda1(1,1)-pizda1(2,2)
9490 vv1(2)=pizda1(1,2)+pizda1(2,1)
9491 s4=0.5d0*scalar2(vv1(1),Dtobr2(1,i))
9492 vv(1)=AEAb1derx(1,lll,kkk,iii,2,imat)*b1(1,k)
9493 & -AEAb1derx(2,lll,kkk,iii,2,imat)*b1(2,k)
9494 vv(2)=AEAb1derx(1,lll,kkk,iii,2,imat)*b1(2,k)
9495 & +AEAb1derx(2,lll,kkk,iii,2,imat)*b1(1,k)
9496 s5=scalar2(vv(1),Dtobr2(1,i))
9497 derx(lll,kkk,ind)=derx(lll,kkk,ind)-0.5d0*(s1+s2+s3+s4+s5)
9503 c----------------------------------------------------------------------------
9504 double precision function eello6_graph2(i,j,k,l,jj,kk,swap)
9505 implicit real*8 (a-h,o-z)
9506 include 'DIMENSIONS'
9507 include 'COMMON.IOUNITS'
9508 include 'COMMON.CHAIN'
9509 include 'COMMON.DERIV'
9510 include 'COMMON.INTERACT'
9511 include 'COMMON.CONTACTS'
9512 include 'COMMON.TORSION'
9513 include 'COMMON.VAR'
9514 include 'COMMON.GEO'
9516 double precision vv(2),pizda(2,2),auxmat(2,2),auxvec(2),
9517 & auxvec1(2),auxvec2(2),auxmat1(2,2)
9520 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
9522 C Parallel Antiparallel C
9528 C \ j|/k\| \ |/k\|l C
9533 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
9534 cd write (2,*) 'eello6_graph2: i,',i,' j',j,' k',k,' l',l
9535 C AL 7/4/01 s1 would occur in the sixth-order moment,
9536 C but not in a cluster cumulant
9538 s1=dip(1,jj,i)*dip(1,kk,k)
9540 call matvec2(ADtEA1(1,1,1),Ub2(1,k),auxvec(1))
9541 s2=-0.5d0*scalar2(Ub2(1,i),auxvec(1))
9542 call matvec2(ADtEA(1,1,2),Ub2(1,l),auxvec1(1))
9543 s3=-0.5d0*scalar2(Ub2(1,j),auxvec1(1))
9544 call transpose2(EUg(1,1,k),auxmat(1,1))
9545 call matmat2(ADtEA1(1,1,1),auxmat(1,1),pizda(1,1))
9546 vv(1)=pizda(1,1)-pizda(2,2)
9547 vv(2)=pizda(1,2)+pizda(2,1)
9548 s4=-0.25d0*scalar2(vv(1),Dtobr2(1,i))
9549 cd write (2,*) 'eello6_graph2:','s1',s1,' s2',s2,' s3',s3,' s4',s4
9551 eello6_graph2=-(s1+s2+s3+s4)
9553 eello6_graph2=-(s2+s3+s4)
9556 C Derivatives in gamma(i-1)
9559 s1=dipderg(1,jj,i)*dip(1,kk,k)
9561 s2=-0.5d0*scalar2(Ub2der(1,i),auxvec(1))
9562 call matvec2(ADtEAderg(1,1,1,2),Ub2(1,l),auxvec2(1))
9563 s3=-0.5d0*scalar2(Ub2(1,j),auxvec2(1))
9564 s4=-0.25d0*scalar2(vv(1),Dtobr2der(1,i))
9566 g_corr6_loc(i-1)=g_corr6_loc(i-1)-ekont*(s1+s2+s3+s4)
9568 g_corr6_loc(i-1)=g_corr6_loc(i-1)-ekont*(s2+s3+s4)
9570 c g_corr6_loc(i-1)=g_corr6_loc(i-1)-s3
9572 C Derivatives in gamma(k-1)
9574 s1=dip(1,jj,i)*dipderg(1,kk,k)
9576 call matvec2(ADtEA1(1,1,1),Ub2der(1,k),auxvec2(1))
9577 s2=-0.5d0*scalar2(Ub2(1,i),auxvec2(1))
9578 call matvec2(ADtEAderg(1,1,2,2),Ub2(1,l),auxvec2(1))
9579 s3=-0.5d0*scalar2(Ub2(1,j),auxvec2(1))
9580 call transpose2(EUgder(1,1,k),auxmat1(1,1))
9581 call matmat2(ADtEA1(1,1,1),auxmat1(1,1),pizda(1,1))
9582 vv(1)=pizda(1,1)-pizda(2,2)
9583 vv(2)=pizda(1,2)+pizda(2,1)
9584 s4=-0.25d0*scalar2(vv(1),Dtobr2(1,i))
9586 g_corr6_loc(k-1)=g_corr6_loc(k-1)-ekont*(s1+s2+s3+s4)
9588 g_corr6_loc(k-1)=g_corr6_loc(k-1)-ekont*(s2+s3+s4)
9590 c g_corr6_loc(k-1)=g_corr6_loc(k-1)-s3
9591 C Derivatives in gamma(j-1) or gamma(l-1)
9594 s1=dipderg(3,jj,i)*dip(1,kk,k)
9596 call matvec2(ADtEA1derg(1,1,1,1),Ub2(1,k),auxvec2(1))
9597 s2=-0.5d0*scalar2(Ub2(1,i),auxvec2(1))
9598 s3=-0.5d0*scalar2(Ub2der(1,j),auxvec1(1))
9599 call matmat2(ADtEA1derg(1,1,1,1),auxmat(1,1),pizda(1,1))
9600 vv(1)=pizda(1,1)-pizda(2,2)
9601 vv(2)=pizda(1,2)+pizda(2,1)
9602 s4=-0.25d0*scalar2(vv(1),Dtobr2(1,i))
9605 g_corr6_loc(l-1)=g_corr6_loc(l-1)-ekont*s1
9607 g_corr6_loc(j-1)=g_corr6_loc(j-1)-ekont*s1
9610 g_corr6_loc(j-1)=g_corr6_loc(j-1)-ekont*(s2+s3+s4)
9611 c g_corr6_loc(j-1)=g_corr6_loc(j-1)-s3
9613 C Derivatives in gamma(l-1) or gamma(j-1)
9616 s1=dip(1,jj,i)*dipderg(3,kk,k)
9618 call matvec2(ADtEA1derg(1,1,2,1),Ub2(1,k),auxvec2(1))
9619 s2=-0.5d0*scalar2(Ub2(1,i),auxvec2(1))
9620 call matvec2(ADtEA(1,1,2),Ub2der(1,l),auxvec2(1))
9621 s3=-0.5d0*scalar2(Ub2(1,j),auxvec2(1))
9622 call matmat2(ADtEA1derg(1,1,2,1),auxmat(1,1),pizda(1,1))
9623 vv(1)=pizda(1,1)-pizda(2,2)
9624 vv(2)=pizda(1,2)+pizda(2,1)
9625 s4=-0.25d0*scalar2(vv(1),Dtobr2(1,i))
9628 g_corr6_loc(j-1)=g_corr6_loc(j-1)-ekont*s1
9630 g_corr6_loc(l-1)=g_corr6_loc(l-1)-ekont*s1
9633 g_corr6_loc(l-1)=g_corr6_loc(l-1)-ekont*(s2+s3+s4)
9634 c g_corr6_loc(l-1)=g_corr6_loc(l-1)-s3
9636 C Cartesian derivatives.
9638 write (2,*) 'In eello6_graph2'
9640 write (2,*) 'iii=',iii
9642 write (2,*) 'kkk=',kkk
9644 write (2,'(3(2f10.5),5x)')
9645 & ((ADtEA1derx(jjj,mmm,lll,kkk,iii,1),mmm=1,2),lll=1,3)
9655 s1=dipderx(lll,kkk,1,jj,i)*dip(1,kk,k)
9657 s1=dip(1,jj,i)*dipderx(lll,kkk,1,kk,k)
9660 call matvec2(ADtEA1derx(1,1,lll,kkk,iii,1),Ub2(1,k),
9662 s2=-0.5d0*scalar2(Ub2(1,i),auxvec(1))
9663 call matvec2(ADtEAderx(1,1,lll,kkk,iii,2),Ub2(1,l),
9665 s3=-0.5d0*scalar2(Ub2(1,j),auxvec(1))
9666 call transpose2(EUg(1,1,k),auxmat(1,1))
9667 call matmat2(ADtEA1derx(1,1,lll,kkk,iii,1),auxmat(1,1),
9669 vv(1)=pizda(1,1)-pizda(2,2)
9670 vv(2)=pizda(1,2)+pizda(2,1)
9671 s4=-0.25d0*scalar2(vv(1),Dtobr2(1,i))
9672 cd write (2,*) 's1',s1,' s2',s2,' s3',s3,' s4',s4
9674 derx(lll,kkk,iii)=derx(lll,kkk,iii)-(s1+s2+s4)
9676 derx(lll,kkk,iii)=derx(lll,kkk,iii)-(s2+s4)
9679 derx(lll,kkk,3-iii)=derx(lll,kkk,3-iii)-s3
9681 derx(lll,kkk,iii)=derx(lll,kkk,iii)-s3
9688 c----------------------------------------------------------------------------
9689 double precision function eello6_graph3(i,j,k,l,jj,kk,swap)
9690 implicit real*8 (a-h,o-z)
9691 include 'DIMENSIONS'
9692 include 'COMMON.IOUNITS'
9693 include 'COMMON.CHAIN'
9694 include 'COMMON.DERIV'
9695 include 'COMMON.INTERACT'
9696 include 'COMMON.CONTACTS'
9697 include 'COMMON.TORSION'
9698 include 'COMMON.VAR'
9699 include 'COMMON.GEO'
9700 double precision vv(2),pizda(2,2),auxmat(2,2),auxvec(2)
9702 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
9704 C Parallel Antiparallel C
9710 C j|/k\| / |/k\|l / C
9715 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
9717 C 4/7/01 AL Component s1 was removed, because it pertains to the respective
9718 C energy moment and not to the cluster cumulant.
9719 c iti=itortyp(itype(i))
9720 c if (j.lt.nres-1) then
9721 c itj1=itortyp(itype(j+1))
9725 c itk=itortyp(itype(k))
9726 c itk1=itortyp(itype(k+1))
9727 c if (l.lt.nres-1) then
9728 c itl1=itortyp(itype(l+1))
9733 s1=dip(4,jj,i)*dip(4,kk,k)
9735 call matvec2(AECA(1,1,1),b1(1,k+1),auxvec(1))
9736 s2=0.5d0*scalar2(b1(1,k),auxvec(1))
9737 call matvec2(AECA(1,1,2),b1(1,l+1),auxvec(1))
9738 s3=0.5d0*scalar2(b1(1,j+1),auxvec(1))
9739 call transpose2(EE(1,1,k),auxmat(1,1))
9740 call matmat2(auxmat(1,1),AECA(1,1,1),pizda(1,1))
9741 vv(1)=pizda(1,1)+pizda(2,2)
9742 vv(2)=pizda(2,1)-pizda(1,2)
9743 s4=-0.25d0*scalar2(vv(1),Ctobr(1,k))
9744 cd write (2,*) 'eello6_graph3:','s1',s1,' s2',s2,' s3',s3,' s4',s4,
9745 cd & "sum",-(s2+s3+s4)
9747 eello6_graph3=-(s1+s2+s3+s4)
9749 eello6_graph3=-(s2+s3+s4)
9752 C Derivatives in gamma(k-1)
9753 call matvec2(AECAderg(1,1,2),b1(1,l+1),auxvec(1))
9754 s3=0.5d0*scalar2(b1(1,j+1),auxvec(1))
9755 s4=-0.25d0*scalar2(vv(1),Ctobrder(1,k))
9756 g_corr6_loc(k-1)=g_corr6_loc(k-1)-ekont*(s3+s4)
9757 C Derivatives in gamma(l-1)
9758 call matvec2(AECAderg(1,1,1),b1(1,k+1),auxvec(1))
9759 s2=0.5d0*scalar2(b1(1,k),auxvec(1))
9760 call matmat2(auxmat(1,1),AECAderg(1,1,1),pizda(1,1))
9761 vv(1)=pizda(1,1)+pizda(2,2)
9762 vv(2)=pizda(2,1)-pizda(1,2)
9763 s4=-0.25d0*scalar2(vv(1),Ctobr(1,k))
9764 g_corr6_loc(l-1)=g_corr6_loc(l-1)-ekont*(s2+s4)
9765 C Cartesian derivatives.
9771 s1=dipderx(lll,kkk,4,jj,i)*dip(4,kk,k)
9773 s1=dip(4,jj,i)*dipderx(lll,kkk,4,kk,k)
9776 call matvec2(AECAderx(1,1,lll,kkk,iii,1),b1(1,k+1),
9778 s2=0.5d0*scalar2(b1(1,k),auxvec(1))
9779 call matvec2(AECAderx(1,1,lll,kkk,iii,2),b1(1,l+1),
9781 s3=0.5d0*scalar2(b1(1,j+1),auxvec(1))
9782 call matmat2(auxmat(1,1),AECAderx(1,1,lll,kkk,iii,1),
9784 vv(1)=pizda(1,1)+pizda(2,2)
9785 vv(2)=pizda(2,1)-pizda(1,2)
9786 s4=-0.25d0*scalar2(vv(1),Ctobr(1,k))
9788 derx(lll,kkk,iii)=derx(lll,kkk,iii)-(s1+s2+s4)
9790 derx(lll,kkk,iii)=derx(lll,kkk,iii)-(s2+s4)
9793 derx(lll,kkk,3-iii)=derx(lll,kkk,3-iii)-s3
9795 derx(lll,kkk,iii)=derx(lll,kkk,iii)-s3
9797 c derx(lll,kkk,iii)=derx(lll,kkk,iii)-s4
9803 c----------------------------------------------------------------------------
9804 double precision function eello6_graph4(i,j,k,l,jj,kk,imat,swap)
9805 implicit real*8 (a-h,o-z)
9806 include 'DIMENSIONS'
9807 include 'COMMON.IOUNITS'
9808 include 'COMMON.CHAIN'
9809 include 'COMMON.DERIV'
9810 include 'COMMON.INTERACT'
9811 include 'COMMON.CONTACTS'
9812 include 'COMMON.TORSION'
9813 include 'COMMON.VAR'
9814 include 'COMMON.GEO'
9815 include 'COMMON.FFIELD'
9816 double precision vv(2),pizda(2,2),auxmat(2,2),auxvec(2),
9817 & auxvec1(2),auxmat1(2,2)
9819 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
9821 C Parallel Antiparallel C
9827 C \ j|/k\| \ |/k\|l C
9832 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
9834 C 4/7/01 AL Component s1 was removed, because it pertains to the respective
9835 C energy moment and not to the cluster cumulant.
9836 cd write (2,*) 'eello_graph4: wturn6',wturn6
9837 c iti=itortyp(itype(i))
9838 c itj=itortyp(itype(j))
9839 c if (j.lt.nres-1) then
9840 c itj1=itortyp(itype(j+1))
9844 c itk=itortyp(itype(k))
9845 c if (k.lt.nres-1) then
9846 c itk1=itortyp(itype(k+1))
9850 c itl=itortyp(itype(l))
9851 c if (l.lt.nres-1) then
9852 c itl1=itortyp(itype(l+1))
9856 cd write (2,*) 'eello6_graph4:','i',i,' j',j,' k',k,' l',l
9857 cd write (2,*) 'iti',iti,' itj',itj,' itj1',itj1,' itk',itk,
9858 cd & ' itl',itl,' itl1',itl1
9861 s1=dip(3,jj,i)*dip(3,kk,k)
9863 s1=dip(2,jj,j)*dip(2,kk,l)
9866 call matvec2(AECA(1,1,imat),Ub2(1,k),auxvec(1))
9867 s2=0.5d0*scalar2(Ub2(1,i),auxvec(1))
9869 call matvec2(ADtEA1(1,1,3-imat),b1(1,j+1),auxvec1(1))
9870 s3=-0.5d0*scalar2(b1(1,j),auxvec1(1))
9872 call matvec2(ADtEA1(1,1,3-imat),b1(1,l+1),auxvec1(1))
9873 s3=-0.5d0*scalar2(b1(1,l),auxvec1(1))
9875 call transpose2(EUg(1,1,k),auxmat(1,1))
9876 call matmat2(AECA(1,1,imat),auxmat(1,1),pizda(1,1))
9877 vv(1)=pizda(1,1)-pizda(2,2)
9878 vv(2)=pizda(2,1)+pizda(1,2)
9879 s4=0.25d0*scalar2(vv(1),Dtobr2(1,i))
9880 cd write (2,*) 'eello6_graph4:','s1',s1,' s2',s2,' s3',s3,' s4',s4
9882 eello6_graph4=-(s1+s2+s3+s4)
9884 eello6_graph4=-(s2+s3+s4)
9886 C Derivatives in gamma(i-1)
9890 s1=dipderg(2,jj,i)*dip(3,kk,k)
9892 s1=dipderg(4,jj,j)*dip(2,kk,l)
9895 s2=0.5d0*scalar2(Ub2der(1,i),auxvec(1))
9897 call matvec2(ADtEA1derg(1,1,1,3-imat),b1(1,j+1),auxvec1(1))
9898 s3=-0.5d0*scalar2(b1(1,j),auxvec1(1))
9900 call matvec2(ADtEA1derg(1,1,1,3-imat),b1(1,l+1),auxvec1(1))
9901 s3=-0.5d0*scalar2(b1(1,l),auxvec1(1))
9903 s4=0.25d0*scalar2(vv(1),Dtobr2der(1,i))
9904 if (wturn6.gt.0.0d0 .and. k.eq.l+4 .and. i.eq.j+2) then
9905 cd write (2,*) 'turn6 derivatives'
9907 gel_loc_turn6(i-1)=gel_loc_turn6(i-1)-ekont*(s1+s2+s3+s4)
9909 gel_loc_turn6(i-1)=gel_loc_turn6(i-1)-ekont*(s2+s3+s4)
9913 g_corr6_loc(i-1)=g_corr6_loc(i-1)-ekont*(s1+s2+s3+s4)
9915 g_corr6_loc(i-1)=g_corr6_loc(i-1)-ekont*(s2+s3+s4)
9919 C Derivatives in gamma(k-1)
9922 s1=dip(3,jj,i)*dipderg(2,kk,k)
9924 s1=dip(2,jj,j)*dipderg(4,kk,l)
9927 call matvec2(AECA(1,1,imat),Ub2der(1,k),auxvec1(1))
9928 s2=0.5d0*scalar2(Ub2(1,i),auxvec1(1))
9930 call matvec2(ADtEA1derg(1,1,2,3-imat),b1(1,j+1),auxvec1(1))
9931 s3=-0.5d0*scalar2(b1(1,j),auxvec1(1))
9933 call matvec2(ADtEA1derg(1,1,2,3-imat),b1(1,l+1),auxvec1(1))
9934 s3=-0.5d0*scalar2(b1(1,l),auxvec1(1))
9936 call transpose2(EUgder(1,1,k),auxmat1(1,1))
9937 call matmat2(AECA(1,1,imat),auxmat1(1,1),pizda(1,1))
9938 vv(1)=pizda(1,1)-pizda(2,2)
9939 vv(2)=pizda(2,1)+pizda(1,2)
9940 s4=0.25d0*scalar2(vv(1),Dtobr2(1,i))
9941 if (wturn6.gt.0.0d0 .and. k.eq.l+4 .and. i.eq.j+2) then
9943 gel_loc_turn6(k-1)=gel_loc_turn6(k-1)-ekont*(s1+s2+s3+s4)
9945 gel_loc_turn6(k-1)=gel_loc_turn6(k-1)-ekont*(s2+s3+s4)
9949 g_corr6_loc(k-1)=g_corr6_loc(k-1)-ekont*(s1+s2+s3+s4)
9951 g_corr6_loc(k-1)=g_corr6_loc(k-1)-ekont*(s2+s3+s4)
9954 C Derivatives in gamma(j-1) or gamma(l-1)
9955 if (l.eq.j+1 .and. l.gt.1) then
9956 call matvec2(AECAderg(1,1,imat),Ub2(1,k),auxvec(1))
9957 s2=0.5d0*scalar2(Ub2(1,i),auxvec(1))
9958 call matmat2(AECAderg(1,1,imat),auxmat(1,1),pizda(1,1))
9959 vv(1)=pizda(1,1)-pizda(2,2)
9960 vv(2)=pizda(2,1)+pizda(1,2)
9961 s4=0.25d0*scalar2(vv(1),Dtobr2(1,i))
9962 g_corr6_loc(l-1)=g_corr6_loc(l-1)-ekont*(s2+s4)
9963 else if (j.gt.1) then
9964 call matvec2(AECAderg(1,1,imat),Ub2(1,k),auxvec(1))
9965 s2=0.5d0*scalar2(Ub2(1,i),auxvec(1))
9966 call matmat2(AECAderg(1,1,imat),auxmat(1,1),pizda(1,1))
9967 vv(1)=pizda(1,1)-pizda(2,2)
9968 vv(2)=pizda(2,1)+pizda(1,2)
9969 s4=0.25d0*scalar2(vv(1),Dtobr2(1,i))
9970 if (wturn6.gt.0.0d0 .and. k.eq.l+4 .and. i.eq.j+2) then
9971 gel_loc_turn6(j-1)=gel_loc_turn6(j-1)-ekont*(s2+s4)
9973 g_corr6_loc(j-1)=g_corr6_loc(j-1)-ekont*(s2+s4)
9976 C Cartesian derivatives.
9983 s1=dipderx(lll,kkk,3,jj,i)*dip(3,kk,k)
9985 s1=dipderx(lll,kkk,2,jj,j)*dip(2,kk,l)
9989 s1=dip(3,jj,i)*dipderx(lll,kkk,3,kk,k)
9991 s1=dip(2,jj,j)*dipderx(lll,kkk,2,kk,l)
9995 call matvec2(AECAderx(1,1,lll,kkk,iii,imat),Ub2(1,k),
9997 s2=0.5d0*scalar2(Ub2(1,i),auxvec(1))
9999 call matvec2(ADtEA1derx(1,1,lll,kkk,iii,3-imat),
10000 & b1(1,j+1),auxvec(1))
10001 s3=-0.5d0*scalar2(b1(1,j),auxvec(1))
10003 call matvec2(ADtEA1derx(1,1,lll,kkk,iii,3-imat),
10004 & b1(1,l+1),auxvec(1))
10005 s3=-0.5d0*scalar2(b1(1,l),auxvec(1))
10007 call matmat2(AECAderx(1,1,lll,kkk,iii,imat),auxmat(1,1),
10009 vv(1)=pizda(1,1)-pizda(2,2)
10010 vv(2)=pizda(2,1)+pizda(1,2)
10011 s4=0.25d0*scalar2(vv(1),Dtobr2(1,i))
10013 if (wturn6.gt.0.0d0 .and. k.eq.l+4 .and. i.eq.j+2) then
10015 derx_turn(lll,kkk,3-iii)=derx_turn(lll,kkk,3-iii)
10018 derx_turn(lll,kkk,3-iii)=derx_turn(lll,kkk,3-iii)
10021 derx_turn(lll,kkk,iii)=derx_turn(lll,kkk,iii)-s3
10024 derx(lll,kkk,3-iii)=derx(lll,kkk,3-iii)-(s1+s2+s4)
10026 derx(lll,kkk,3-iii)=derx(lll,kkk,3-iii)-(s2+s4)
10028 derx(lll,kkk,iii)=derx(lll,kkk,iii)-s3
10032 derx(lll,kkk,iii)=derx(lll,kkk,iii)-(s1+s2+s4)
10034 derx(lll,kkk,iii)=derx(lll,kkk,iii)-(s2+s4)
10037 derx(lll,kkk,iii)=derx(lll,kkk,iii)-s3
10039 derx(lll,kkk,3-iii)=derx(lll,kkk,3-iii)-s3
10047 c----------------------------------------------------------------------------
10048 double precision function eello_turn6(i,jj,kk)
10049 implicit real*8 (a-h,o-z)
10050 include 'DIMENSIONS'
10051 include 'COMMON.IOUNITS'
10052 include 'COMMON.CHAIN'
10053 include 'COMMON.DERIV'
10054 include 'COMMON.INTERACT'
10055 include 'COMMON.CONTACTS'
10056 include 'COMMON.TORSION'
10057 include 'COMMON.VAR'
10058 include 'COMMON.GEO'
10059 double precision vtemp1(2),vtemp2(2),vtemp3(2),vtemp4(2),
10060 & atemp(2,2),auxmat(2,2),achuj_temp(2,2),gtemp(2,2),gvec(2),
10062 double precision vtemp1d(2),vtemp2d(2),vtemp3d(2),vtemp4d(2),
10063 & atempd(2,2),auxmatd(2,2),achuj_tempd(2,2),gtempd(2,2),gvecd(2)
10064 C 4/7/01 AL Components s1, s8, and s13 were removed, because they pertain to
10065 C the respective energy moment and not to the cluster cumulant.
10074 iti=itortyp(itype(i))
10075 itk=itortyp(itype(k))
10076 itk1=itortyp(itype(k+1))
10077 itl=itortyp(itype(l))
10078 itj=itortyp(itype(j))
10079 cd write (2,*) 'itk',itk,' itk1',itk1,' itl',itl,' itj',itj
10080 cd write (2,*) 'i',i,' k',k,' j',j,' l',l
10081 cd if (i.ne.1 .or. j.ne.3 .or. k.ne.2 .or. l.ne.4) then
10086 cd & 'EELLO6: Contacts have occurred for peptide groups',i,j,
10088 cd call checkint_turn6(i,jj,kk,eel_turn6_num)
10092 derx_turn(lll,kkk,iii)=0.0d0
10099 eello6_5=eello6_graph4(l,k,j,i,kk,jj,2,.true.)
10101 cd write (2,*) 'eello6_5',eello6_5
10103 call transpose2(AEA(1,1,1),auxmat(1,1))
10104 call matmat2(EUg(1,1,i+1),auxmat(1,1),auxmat(1,1))
10105 ss1=scalar2(Ub2(1,i+2),b1(1,l))
10106 s1 = (auxmat(1,1)+auxmat(2,2))*ss1
10108 call matvec2(EUg(1,1,i+2),b1(1,l),vtemp1(1))
10109 call matvec2(AEA(1,1,1),vtemp1(1),vtemp1(1))
10110 s2 = scalar2(b1(1,k),vtemp1(1))
10112 call transpose2(AEA(1,1,2),atemp(1,1))
10113 call matmat2(atemp(1,1),EUg(1,1,i+4),atemp(1,1))
10114 call matvec2(Ug2(1,1,i+2),dd(1,1,itk1),vtemp2(1))
10115 s8 = -(atemp(1,1)+atemp(2,2))*scalar2(cc(1,1,itl),vtemp2(1))
10117 call matmat2(EUg(1,1,i+3),AEA(1,1,2),auxmat(1,1))
10118 call matvec2(auxmat(1,1),Ub2(1,i+4),vtemp3(1))
10119 s12 = scalar2(Ub2(1,i+2),vtemp3(1))
10121 call transpose2(a_chuj(1,1,kk,i+1),achuj_temp(1,1))
10122 call matmat2(achuj_temp(1,1),EUg(1,1,i+2),gtemp(1,1))
10123 call matmat2(gtemp(1,1),EUg(1,1,i+3),gtemp(1,1))
10124 call matvec2(a_chuj(1,1,jj,i),Ub2(1,i+4),vtemp4(1))
10125 ss13 = scalar2(b1(1,k),vtemp4(1))
10126 s13 = (gtemp(1,1)+gtemp(2,2))*ss13
10128 c write (2,*) 's1,s2,s8,s12,s13',s1,s2,s8,s12,s13
10134 eel_turn6 = eello6_5 - 0.5d0*(s1+s2+s12+s8+s13)
10135 C Derivatives in gamma(i+2)
10139 call transpose2(AEA(1,1,1),auxmatd(1,1))
10140 call matmat2(EUgder(1,1,i+1),auxmatd(1,1),auxmatd(1,1))
10141 s1d = (auxmatd(1,1)+auxmatd(2,2))*ss1
10142 call transpose2(AEAderg(1,1,2),atempd(1,1))
10143 call matmat2(atempd(1,1),EUg(1,1,i+4),atempd(1,1))
10144 s8d = -(atempd(1,1)+atempd(2,2))*scalar2(cc(1,1,itl),vtemp2(1))
10146 call matmat2(EUg(1,1,i+3),AEAderg(1,1,2),auxmatd(1,1))
10147 call matvec2(auxmatd(1,1),Ub2(1,i+4),vtemp3d(1))
10148 s12d = scalar2(Ub2(1,i+2),vtemp3d(1))
10154 gel_loc_turn6(i)=gel_loc_turn6(i)-0.5d0*ekont*(s1d+s8d+s12d)
10155 C Derivatives in gamma(i+3)
10157 call transpose2(AEA(1,1,1),auxmatd(1,1))
10158 call matmat2(EUg(1,1,i+1),auxmatd(1,1),auxmatd(1,1))
10159 ss1d=scalar2(Ub2der(1,i+2),b1(1,l))
10160 s1d = (auxmatd(1,1)+auxmatd(2,2))*ss1d
10162 call matvec2(EUgder(1,1,i+2),b1(1,l),vtemp1d(1))
10163 call matvec2(AEA(1,1,1),vtemp1d(1),vtemp1d(1))
10164 s2d = scalar2(b1(1,k),vtemp1d(1))
10166 call matvec2(Ug2der(1,1,i+2),dd(1,1,itk1),vtemp2d(1))
10167 s8d = -(atemp(1,1)+atemp(2,2))*scalar2(cc(1,1,itl),vtemp2d(1))
10169 s12d = scalar2(Ub2der(1,i+2),vtemp3(1))
10171 call matmat2(achuj_temp(1,1),EUgder(1,1,i+2),gtempd(1,1))
10172 call matmat2(gtempd(1,1),EUg(1,1,i+3),gtempd(1,1))
10173 s13d = (gtempd(1,1)+gtempd(2,2))*ss13
10181 gel_loc_turn6(i+1)=gel_loc_turn6(i+1)
10182 & -0.5d0*ekont*(s1d+s2d+s8d+s12d+s13d)
10184 gel_loc_turn6(i+1)=gel_loc_turn6(i+1)
10185 & -0.5d0*ekont*(s2d+s12d)
10187 C Derivatives in gamma(i+4)
10188 call matmat2(EUgder(1,1,i+3),AEA(1,1,2),auxmatd(1,1))
10189 call matvec2(auxmatd(1,1),Ub2(1,i+4),vtemp3d(1))
10190 s12d = scalar2(Ub2(1,i+2),vtemp3d(1))
10192 call matmat2(achuj_temp(1,1),EUg(1,1,i+2),gtempd(1,1))
10193 call matmat2(gtempd(1,1),EUgder(1,1,i+3),gtempd(1,1))
10194 s13d = (gtempd(1,1)+gtempd(2,2))*ss13
10202 gel_loc_turn6(i+2)=gel_loc_turn6(i+2)-0.5d0*ekont*(s12d+s13d)
10204 gel_loc_turn6(i+2)=gel_loc_turn6(i+2)-0.5d0*ekont*(s12d)
10206 C Derivatives in gamma(i+5)
10208 call transpose2(AEAderg(1,1,1),auxmatd(1,1))
10209 call matmat2(EUg(1,1,i+1),auxmatd(1,1),auxmatd(1,1))
10210 s1d = (auxmatd(1,1)+auxmatd(2,2))*ss1
10212 call matvec2(EUg(1,1,i+2),b1(1,l),vtemp1d(1))
10213 call matvec2(AEAderg(1,1,1),vtemp1d(1),vtemp1d(1))
10214 s2d = scalar2(b1(1,k),vtemp1d(1))
10216 call transpose2(AEA(1,1,2),atempd(1,1))
10217 call matmat2(atempd(1,1),EUgder(1,1,i+4),atempd(1,1))
10218 s8d = -(atempd(1,1)+atempd(2,2))*scalar2(cc(1,1,itl),vtemp2(1))
10220 call matvec2(auxmat(1,1),Ub2der(1,i+4),vtemp3d(1))
10221 s12d = scalar2(Ub2(1,i+2),vtemp3d(1))
10223 call matvec2(a_chuj(1,1,jj,i),Ub2der(1,i+4),vtemp4d(1))
10224 ss13d = scalar2(b1(1,k),vtemp4d(1))
10225 s13d = (gtemp(1,1)+gtemp(2,2))*ss13d
10233 gel_loc_turn6(i+3)=gel_loc_turn6(i+3)
10234 & -0.5d0*ekont*(s1d+s2d+s8d+s12d+s13d)
10236 gel_loc_turn6(i+3)=gel_loc_turn6(i+3)
10237 & -0.5d0*ekont*(s2d+s12d)
10239 C Cartesian derivatives
10244 call transpose2(AEAderx(1,1,lll,kkk,iii,1),auxmatd(1,1))
10245 call matmat2(EUg(1,1,i+1),auxmatd(1,1),auxmatd(1,1))
10246 s1d = (auxmatd(1,1)+auxmatd(2,2))*ss1
10248 call matvec2(EUg(1,1,i+2),b1(1,l),vtemp1(1))
10249 call matvec2(AEAderx(1,1,lll,kkk,iii,1),vtemp1(1),
10251 s2d = scalar2(b1(1,k),vtemp1d(1))
10253 call transpose2(AEAderx(1,1,lll,kkk,iii,2),atempd(1,1))
10254 call matmat2(atempd(1,1),EUg(1,1,i+4),atempd(1,1))
10255 s8d = -(atempd(1,1)+atempd(2,2))*
10256 & scalar2(cc(1,1,itl),vtemp2(1))
10258 call matmat2(EUg(1,1,i+3),AEAderx(1,1,lll,kkk,iii,2),
10260 call matvec2(auxmatd(1,1),Ub2(1,i+4),vtemp3d(1))
10261 s12d = scalar2(Ub2(1,i+2),vtemp3d(1))
10268 derx_turn(lll,kkk,iii) = derx_turn(lll,kkk,iii)
10269 & - 0.5d0*(s1d+s2d)
10271 derx_turn(lll,kkk,iii) = derx_turn(lll,kkk,iii)
10275 derx_turn(lll,kkk,3-iii) = derx_turn(lll,kkk,3-iii)
10276 & - 0.5d0*(s8d+s12d)
10278 derx_turn(lll,kkk,3-iii) = derx_turn(lll,kkk,3-iii)
10287 call transpose2(a_chuj_der(1,1,lll,kkk,kk,i+1),
10288 & achuj_tempd(1,1))
10289 call matmat2(achuj_tempd(1,1),EUg(1,1,i+2),gtempd(1,1))
10290 call matmat2(gtempd(1,1),EUg(1,1,i+3),gtempd(1,1))
10291 s13d=(gtempd(1,1)+gtempd(2,2))*ss13
10292 derx_turn(lll,kkk,2) = derx_turn(lll,kkk,2)-0.5d0*s13d
10293 call matvec2(a_chuj_der(1,1,lll,kkk,jj,i),Ub2(1,i+4),
10295 ss13d = scalar2(b1(1,k),vtemp4d(1))
10296 s13d = (gtemp(1,1)+gtemp(2,2))*ss13d
10297 derx_turn(lll,kkk,1) = derx_turn(lll,kkk,1)-0.5d0*s13d
10301 cd write(iout,*) 'eel6_turn6',eel_turn6,' eel_turn6_num',
10302 cd & 16*eel_turn6_num
10304 if (j.lt.nres-1) then
10311 if (l.lt.nres-1) then
10319 cgrad ggg1(ll)=eel_turn6*g_contij(ll,1)
10320 cgrad ggg2(ll)=eel_turn6*g_contij(ll,2)
10321 cgrad ghalf=0.5d0*ggg1(ll)
10323 gturn6ij=eel_turn6*g_contij(ll,1)+ekont*derx_turn(ll,1,1)
10324 gturn6kl=eel_turn6*g_contij(ll,2)+ekont*derx_turn(ll,1,2)
10325 gcorr6_turn(ll,i)=gcorr6_turn(ll,i)!+ghalf
10326 & +ekont*derx_turn(ll,2,1)
10327 gcorr6_turn(ll,i+1)=gcorr6_turn(ll,i+1)+ekont*derx_turn(ll,3,1)
10328 gcorr6_turn(ll,j)=gcorr6_turn(ll,j)!+ghalf
10329 & +ekont*derx_turn(ll,4,1)
10330 gcorr6_turn(ll,j1)=gcorr6_turn(ll,j1)+ekont*derx_turn(ll,5,1)
10331 gcorr6_turn_long(ll,j)=gcorr6_turn_long(ll,j)+gturn6ij
10332 gcorr6_turn_long(ll,i)=gcorr6_turn_long(ll,i)-gturn6ij
10333 cgrad ghalf=0.5d0*ggg2(ll)
10335 gcorr6_turn(ll,k)=gcorr6_turn(ll,k)!+ghalf
10336 & +ekont*derx_turn(ll,2,2)
10337 gcorr6_turn(ll,k+1)=gcorr6_turn(ll,k+1)+ekont*derx_turn(ll,3,2)
10338 gcorr6_turn(ll,l)=gcorr6_turn(ll,l)!+ghalf
10339 & +ekont*derx_turn(ll,4,2)
10340 gcorr6_turn(ll,l1)=gcorr6_turn(ll,l1)+ekont*derx_turn(ll,5,2)
10341 gcorr6_turn_long(ll,l)=gcorr6_turn_long(ll,l)+gturn6kl
10342 gcorr6_turn_long(ll,k)=gcorr6_turn_long(ll,k)-gturn6kl
10347 cgrad gcorr6_turn(ll,m)=gcorr6_turn(ll,m)+ggg1(ll)
10352 cgrad gcorr6_turn(ll,m)=gcorr6_turn(ll,m)+ggg2(ll)
10358 cgrad gcorr6_turn(ll,m)=gcorr6_turn(ll,m)+ekont*derx_turn(ll,1,1)
10363 cgrad gcorr6_turn(ll,m)=gcorr6_turn(ll,m)+ekont*derx_turn(ll,1,2)
10367 cd write (2,*) iii,g_corr6_loc(iii)
10369 eello_turn6=ekont*eel_turn6
10370 cd write (2,*) 'ekont',ekont
10371 cd write (2,*) 'eel_turn6',ekont*eel_turn6
10375 C-----------------------------------------------------------------------------
10376 double precision function scalar(u,v)
10377 !DIR$ INLINEALWAYS scalar
10379 cDEC$ ATTRIBUTES FORCEINLINE::scalar
10382 double precision u(3),v(3)
10383 cd double precision sc
10391 scalar=u(1)*v(1)+u(2)*v(2)+u(3)*v(3)
10394 crc-------------------------------------------------
10395 SUBROUTINE MATVEC2(A1,V1,V2)
10396 !DIR$ INLINEALWAYS MATVEC2
10398 cDEC$ ATTRIBUTES FORCEINLINE::MATVEC2
10400 implicit real*8 (a-h,o-z)
10401 include 'DIMENSIONS'
10402 DIMENSION A1(2,2),V1(2),V2(2)
10406 c 3 VI=VI+A1(I,K)*V1(K)
10410 vaux1=a1(1,1)*v1(1)+a1(1,2)*v1(2)
10411 vaux2=a1(2,1)*v1(1)+a1(2,2)*v1(2)
10416 C---------------------------------------
10417 SUBROUTINE MATMAT2(A1,A2,A3)
10419 cDEC$ ATTRIBUTES FORCEINLINE::MATMAT2
10421 implicit real*8 (a-h,o-z)
10422 include 'DIMENSIONS'
10423 DIMENSION A1(2,2),A2(2,2),A3(2,2)
10424 c DIMENSION AI3(2,2)
10428 c A3IJ=A3IJ+A1(I,K)*A2(K,J)
10434 ai3_11=a1(1,1)*a2(1,1)+a1(1,2)*a2(2,1)
10435 ai3_12=a1(1,1)*a2(1,2)+a1(1,2)*a2(2,2)
10436 ai3_21=a1(2,1)*a2(1,1)+a1(2,2)*a2(2,1)
10437 ai3_22=a1(2,1)*a2(1,2)+a1(2,2)*a2(2,2)
10445 c-------------------------------------------------------------------------
10446 double precision function scalar2(u,v)
10447 !DIR$ INLINEALWAYS scalar2
10449 double precision u(2),v(2)
10450 double precision sc
10452 scalar2=u(1)*v(1)+u(2)*v(2)
10456 C-----------------------------------------------------------------------------
10458 subroutine transpose2(a,at)
10459 !DIR$ INLINEALWAYS transpose2
10461 cDEC$ ATTRIBUTES FORCEINLINE::transpose2
10464 double precision a(2,2),at(2,2)
10471 c--------------------------------------------------------------------------
10472 subroutine transpose(n,a,at)
10475 double precision a(n,n),at(n,n)
10483 C---------------------------------------------------------------------------
10484 subroutine prodmat3(a1,a2,kk,transp,prod)
10485 !DIR$ INLINEALWAYS prodmat3
10487 cDEC$ ATTRIBUTES FORCEINLINE::prodmat3
10491 double precision a1(2,2),a2(2,2),a2t(2,2),kk(2,2),prod(2,2)
10493 crc double precision auxmat(2,2),prod_(2,2)
10496 crc call transpose2(kk(1,1),auxmat(1,1))
10497 crc call matmat2(a1(1,1),auxmat(1,1),auxmat(1,1))
10498 crc call matmat2(auxmat(1,1),a2(1,1),prod_(1,1))
10500 prod(1,1)=(a1(1,1)*kk(1,1)+a1(1,2)*kk(1,2))*a2(1,1)
10501 & +(a1(1,1)*kk(2,1)+a1(1,2)*kk(2,2))*a2(2,1)
10502 prod(1,2)=(a1(1,1)*kk(1,1)+a1(1,2)*kk(1,2))*a2(1,2)
10503 & +(a1(1,1)*kk(2,1)+a1(1,2)*kk(2,2))*a2(2,2)
10504 prod(2,1)=(a1(2,1)*kk(1,1)+a1(2,2)*kk(1,2))*a2(1,1)
10505 & +(a1(2,1)*kk(2,1)+a1(2,2)*kk(2,2))*a2(2,1)
10506 prod(2,2)=(a1(2,1)*kk(1,1)+a1(2,2)*kk(1,2))*a2(1,2)
10507 & +(a1(2,1)*kk(2,1)+a1(2,2)*kk(2,2))*a2(2,2)
10510 crc call matmat2(a1(1,1),kk(1,1),auxmat(1,1))
10511 crc call matmat2(auxmat(1,1),a2(1,1),prod_(1,1))
10513 prod(1,1)=(a1(1,1)*kk(1,1)+a1(1,2)*kk(2,1))*a2(1,1)
10514 & +(a1(1,1)*kk(1,2)+a1(1,2)*kk(2,2))*a2(2,1)
10515 prod(1,2)=(a1(1,1)*kk(1,1)+a1(1,2)*kk(2,1))*a2(1,2)
10516 & +(a1(1,1)*kk(1,2)+a1(1,2)*kk(2,2))*a2(2,2)
10517 prod(2,1)=(a1(2,1)*kk(1,1)+a1(2,2)*kk(2,1))*a2(1,1)
10518 & +(a1(2,1)*kk(1,2)+a1(2,2)*kk(2,2))*a2(2,1)
10519 prod(2,2)=(a1(2,1)*kk(1,1)+a1(2,2)*kk(2,1))*a2(1,2)
10520 & +(a1(2,1)*kk(1,2)+a1(2,2)*kk(2,2))*a2(2,2)
10523 c call transpose2(a2(1,1),a2t(1,1))
10526 crc print *,((prod_(i,j),i=1,2),j=1,2)
10527 crc print *,((prod(i,j),i=1,2),j=1,2)
10531 CCC----------------------------------------------
10532 subroutine Eliptransfer(eliptran)
10533 implicit real*8 (a-h,o-z)
10534 include 'DIMENSIONS'
10535 include 'COMMON.GEO'
10536 include 'COMMON.VAR'
10537 include 'COMMON.LOCAL'
10538 include 'COMMON.CHAIN'
10539 include 'COMMON.DERIV'
10540 include 'COMMON.NAMES'
10541 include 'COMMON.INTERACT'
10542 include 'COMMON.IOUNITS'
10543 include 'COMMON.CALC'
10544 include 'COMMON.CONTROL'
10545 include 'COMMON.SPLITELE'
10546 include 'COMMON.SBRIDGE'
10547 C this is done by Adasko
10548 C print *,"wchodze"
10549 C structure of box:
10551 C--bordliptop-- buffore starts
10552 C--bufliptop--- here true lipid starts
10554 C--buflipbot--- lipid ends buffore starts
10555 C--bordlipbot--buffore ends
10557 do i=ilip_start,ilip_end
10559 if (itype(i).eq.ntyp1) cycle
10561 positi=(mod(((c(3,i)+c(3,i+1))/2.0d0),boxzsize))
10562 if (positi.le.0) positi=positi+boxzsize
10564 C first for peptide groups
10565 c for each residue check if it is in lipid or lipid water border area
10566 if ((positi.gt.bordlipbot)
10567 &.and.(positi.lt.bordliptop)) then
10568 C the energy transfer exist
10569 if (positi.lt.buflipbot) then
10570 C what fraction I am in
10572 & ((positi-bordlipbot)/lipbufthick)
10573 C lipbufthick is thickenes of lipid buffore
10574 sslip=sscalelip(fracinbuf)
10575 ssgradlip=-sscagradlip(fracinbuf)/lipbufthick
10576 eliptran=eliptran+sslip*pepliptran
10577 gliptranc(3,i)=gliptranc(3,i)+ssgradlip*pepliptran/2.0d0
10578 gliptranc(3,i-1)=gliptranc(3,i-1)+ssgradlip*pepliptran/2.0d0
10579 C gliptranc(3,i-2)=gliptranc(3,i)+ssgradlip*pepliptran
10581 C print *,"doing sccale for lower part"
10582 C print *,i,sslip,fracinbuf,ssgradlip
10583 elseif (positi.gt.bufliptop) then
10584 fracinbuf=1.0d0-((bordliptop-positi)/lipbufthick)
10585 sslip=sscalelip(fracinbuf)
10586 ssgradlip=sscagradlip(fracinbuf)/lipbufthick
10587 eliptran=eliptran+sslip*pepliptran
10588 gliptranc(3,i)=gliptranc(3,i)+ssgradlip*pepliptran/2.0d0
10589 gliptranc(3,i-1)=gliptranc(3,i-1)+ssgradlip*pepliptran/2.0d0
10590 C gliptranc(3,i-2)=gliptranc(3,i)+ssgradlip*pepliptran
10591 C print *, "doing sscalefor top part"
10592 C print *,i,sslip,fracinbuf,ssgradlip
10594 eliptran=eliptran+pepliptran
10595 C print *,"I am in true lipid"
10598 C eliptran=elpitran+0.0 ! I am in water
10601 C print *, "nic nie bylo w lipidzie?"
10602 C now multiply all by the peptide group transfer factor
10603 C eliptran=eliptran*pepliptran
10604 C now the same for side chains
10606 do i=ilip_start,ilip_end
10607 if (itype(i).eq.ntyp1) cycle
10608 positi=(mod(c(3,i+nres),boxzsize))
10609 if (positi.le.0) positi=positi+boxzsize
10610 C print *,mod(c(3,i+nres),boxzsize),bordlipbot,bordliptop
10611 c for each residue check if it is in lipid or lipid water border area
10612 C respos=mod(c(3,i+nres),boxzsize)
10613 C print *,positi,bordlipbot,buflipbot
10614 if ((positi.gt.bordlipbot)
10615 & .and.(positi.lt.bordliptop)) then
10616 C the energy transfer exist
10617 if (positi.lt.buflipbot) then
10619 & ((positi-bordlipbot)/lipbufthick)
10620 C lipbufthick is thickenes of lipid buffore
10621 sslip=sscalelip(fracinbuf)
10622 ssgradlip=-sscagradlip(fracinbuf)/lipbufthick
10623 eliptran=eliptran+sslip*liptranene(itype(i))
10624 gliptranx(3,i)=gliptranx(3,i)
10625 &+ssgradlip*liptranene(itype(i))
10626 gliptranc(3,i-1)= gliptranc(3,i-1)
10627 &+ssgradlip*liptranene(itype(i))
10628 C print *,"doing sccale for lower part"
10629 elseif (positi.gt.bufliptop) then
10631 &((bordliptop-positi)/lipbufthick)
10632 sslip=sscalelip(fracinbuf)
10633 ssgradlip=sscagradlip(fracinbuf)/lipbufthick
10634 eliptran=eliptran+sslip*liptranene(itype(i))
10635 gliptranx(3,i)=gliptranx(3,i)
10636 &+ssgradlip*liptranene(itype(i))
10637 gliptranc(3,i-1)= gliptranc(3,i-1)
10638 &+ssgradlip*liptranene(itype(i))
10639 C print *, "doing sscalefor top part",sslip,fracinbuf
10641 eliptran=eliptran+liptranene(itype(i))
10642 C print *,"I am in true lipid"
10644 endif ! if in lipid or buffor
10646 C eliptran=elpitran+0.0 ! I am in water
10650 C---------------------------------------------------------
10651 C AFM soubroutine for constant force
10652 subroutine AFMforce(Eafmforce)
10653 implicit real*8 (a-h,o-z)
10654 include 'DIMENSIONS'
10655 include 'COMMON.GEO'
10656 include 'COMMON.VAR'
10657 include 'COMMON.LOCAL'
10658 include 'COMMON.CHAIN'
10659 include 'COMMON.DERIV'
10660 include 'COMMON.NAMES'
10661 include 'COMMON.INTERACT'
10662 include 'COMMON.IOUNITS'
10663 include 'COMMON.CALC'
10664 include 'COMMON.CONTROL'
10665 include 'COMMON.SPLITELE'
10666 include 'COMMON.SBRIDGE'
10671 diffafm(i)=c(i,afmend)-c(i,afmbeg)
10672 dist=dist+diffafm(i)**2
10675 Eafmforce=-forceAFMconst*(dist-distafminit)
10677 gradafm(i,afmend-1)=-forceAFMconst*diffafm(i)/dist
10678 gradafm(i,afmbeg-1)=forceAFMconst*diffafm(i)/dist
10680 C print *,'AFM',Eafmforce
10683 C---------------------------------------------------------
10684 C AFM subroutine with pseudoconstant velocity
10685 subroutine AFMvel(Eafmforce)
10686 implicit real*8 (a-h,o-z)
10687 include 'DIMENSIONS'
10688 include 'COMMON.GEO'
10689 include 'COMMON.VAR'
10690 include 'COMMON.LOCAL'
10691 include 'COMMON.CHAIN'
10692 include 'COMMON.DERIV'
10693 include 'COMMON.NAMES'
10694 include 'COMMON.INTERACT'
10695 include 'COMMON.IOUNITS'
10696 include 'COMMON.CALC'
10697 include 'COMMON.CONTROL'
10698 include 'COMMON.SPLITELE'
10699 include 'COMMON.SBRIDGE'
10701 C Only for check grad COMMENT if not used for checkgrad
10703 C--------------------------------------------------------
10704 C print *,"wchodze"
10708 diffafm(i)=c(i,afmend)-c(i,afmbeg)
10709 dist=dist+diffafm(i)**2
10712 Eafmforce=0.5d0*forceAFMconst
10713 & *(distafminit+totTafm*velAFMconst-dist)**2
10714 C Eafmforce=-forceAFMconst*(dist-distafminit)
10716 gradafm(i,afmend-1)=-forceAFMconst*
10717 &(distafminit+totTafm*velAFMconst-dist)
10719 gradafm(i,afmbeg-1)=forceAFMconst*
10720 &(distafminit+totTafm*velAFMconst-dist)
10723 C print *,'AFM',Eafmforce,totTafm*velAFMconst,dist
10726 C-----------------------------------------------------------
10727 C first for shielding is setting of function of side-chains
10728 subroutine set_shield_fac
10729 implicit real*8 (a-h,o-z)
10730 include 'DIMENSIONS'
10731 include 'COMMON.CHAIN'
10732 include 'COMMON.DERIV'
10733 include 'COMMON.IOUNITS'
10734 include 'COMMON.SHIELD'
10735 include 'COMMON.INTERACT'
10736 C this is the squar root 77 devided by 81 the epislion in lipid (in protein)
10737 double precision div77_81/0.974996043d0/,
10738 &div4_81/0.2222222222d0/,sh_frac_dist_grad(3)
10740 C the vector between center of side_chain and peptide group
10741 double precision pep_side(3),long,side_calf(3),
10742 &pept_group(3),costhet_grad(3),cosphi_grad_long(3),
10743 &cosphi_grad_loc(3),pep_side_norm(3),side_calf_norm(3)
10744 C the line belowe needs to be changed for FGPROC>1
10746 if ((itype(i).eq.ntyp1).and.itype(i+1).eq.ntyp1) cycle
10748 Cif there two consequtive dummy atoms there is no peptide group between them
10749 C the line below has to be changed for FGPROC>1
10752 if ((itype(k).eq.ntyp1).or.(itype(k).eq.10)) cycle
10756 C first lets set vector conecting the ithe side-chain with kth side-chain
10757 pep_side(j)=c(j,k+nres)-(c(j,i)+c(j,i+1))/2.0d0
10758 C pep_side(j)=2.0d0
10759 C and vector conecting the side-chain with its proper calfa
10760 side_calf(j)=c(j,k+nres)-c(j,k)
10761 C side_calf(j)=2.0d0
10762 pept_group(j)=c(j,i)-c(j,i+1)
10763 C lets have their lenght
10764 dist_pep_side=pep_side(j)**2+dist_pep_side
10765 dist_side_calf=dist_side_calf+side_calf(j)**2
10766 dist_pept_group=dist_pept_group+pept_group(j)**2
10768 dist_pep_side=dsqrt(dist_pep_side)
10769 dist_pept_group=dsqrt(dist_pept_group)
10770 dist_side_calf=dsqrt(dist_side_calf)
10772 pep_side_norm(j)=pep_side(j)/dist_pep_side
10773 side_calf_norm(j)=dist_side_calf
10775 C now sscale fraction
10776 sh_frac_dist=-(dist_pep_side-rpp(1,1)-buff_shield)/buff_shield
10777 C print *,buff_shield,"buff"
10779 if (sh_frac_dist.le.0.0) cycle
10780 C If we reach here it means that this side chain reaches the shielding sphere
10781 C Lets add him to the list for gradient
10782 ishield_list(i)=ishield_list(i)+1
10783 C ishield_list is a list of non 0 side-chain that contribute to factor gradient
10784 C this list is essential otherwise problem would be O3
10785 shield_list(ishield_list(i),i)=k
10786 C Lets have the sscale value
10787 if (sh_frac_dist.gt.1.0) then
10788 scale_fac_dist=1.0d0
10790 sh_frac_dist_grad(j)=0.0d0
10793 scale_fac_dist=-sh_frac_dist*sh_frac_dist
10794 & *(2.0*sh_frac_dist-3.0d0)
10795 fac_help_scale=6.0*(sh_frac_dist-sh_frac_dist**2)
10796 & /dist_pep_side/buff_shield*0.5
10797 C remember for the final gradient multiply sh_frac_dist_grad(j)
10798 C for side_chain by factor -2 !
10800 sh_frac_dist_grad(j)=fac_help_scale*pep_side(j)
10801 C print *,"jestem",scale_fac_dist,fac_help_scale,
10802 C & sh_frac_dist_grad(j)
10805 C if ((i.eq.3).and.(k.eq.2)) then
10806 C print *,i,sh_frac_dist,dist_pep,fac_help_scale,scale_fac_dist
10810 C this is what is now we have the distance scaling now volume...
10811 short=short_r_sidechain(itype(k))
10812 long=long_r_sidechain(itype(k))
10813 costhet=1.0d0/dsqrt(1.0+short**2/dist_pep_side**2)
10816 costhet_fac=costhet**3*short**2*(-0.5)/dist_pep_side**4
10817 C costhet_fac=0.0d0
10819 costhet_grad(j)=costhet_fac*pep_side(j)
10821 C remember for the final gradient multiply costhet_grad(j)
10822 C for side_chain by factor -2 !
10823 C fac alfa is angle between CB_k,CA_k, CA_i,CA_i+1
10824 C pep_side0pept_group is vector multiplication
10825 pep_side0pept_group=0.0
10827 pep_side0pept_group=pep_side0pept_group+pep_side(j)*side_calf(j)
10829 cosalfa=(pep_side0pept_group/
10830 & (dist_pep_side*dist_side_calf))
10831 fac_alfa_sin=1.0-cosalfa**2
10832 fac_alfa_sin=dsqrt(fac_alfa_sin)
10833 rkprim=fac_alfa_sin*(long-short)+short
10835 cosphi=1.0d0/dsqrt(1.0+rkprim**2/dist_pep_side**2)
10836 cosphi_fac=cosphi**3*rkprim**2*(-0.5)/dist_pep_side**4
10839 cosphi_grad_long(j)=cosphi_fac*pep_side(j)
10840 &+cosphi**3*0.5/dist_pep_side**2*(-rkprim)
10841 &*(long-short)/fac_alfa_sin*cosalfa/
10842 &((dist_pep_side*dist_side_calf))*
10843 &((side_calf(j))-cosalfa*
10844 &((pep_side(j)/dist_pep_side)*dist_side_calf))
10846 cosphi_grad_loc(j)=cosphi**3*0.5/dist_pep_side**2*(-rkprim)
10847 &*(long-short)/fac_alfa_sin*cosalfa
10848 &/((dist_pep_side*dist_side_calf))*
10850 &cosalfa*side_calf(j)/dist_side_calf*dist_pep_side)
10853 VofOverlap=VSolvSphere/2.0d0*(1.0-costhet)*(1.0-cosphi)
10855 C now the gradient...
10856 C grad_shield is gradient of Calfa for peptide groups
10858 grad_shield(j,i)=grad_shield(j,i)
10859 C gradient po skalowaniu
10860 & +(sh_frac_dist_grad(j)
10861 C gradient po costhet
10862 &-scale_fac_dist*costhet_grad(j)/(1.0-costhet)
10863 &-scale_fac_dist*(cosphi_grad_long(j))
10864 &/(1.0-cosphi) )*div77_81
10866 C grad_shield_side is Cbeta sidechain gradient
10867 grad_shield_side(j,ishield_list(i),i)=
10868 & (sh_frac_dist_grad(j)*(-2.0d0)
10869 & +scale_fac_dist*costhet_grad(j)*2.0d0/(1.0-costhet)
10870 & +scale_fac_dist*(cosphi_grad_long(j))
10871 & *2.0d0/(1.0-cosphi))
10872 & *div77_81*VofOverlap
10874 grad_shield_loc(j,ishield_list(i),i)=
10875 & scale_fac_dist*cosphi_grad_loc(j)
10876 & *2.0d0/(1.0-cosphi)
10877 & *div77_81*VofOverlap
10879 VolumeTotal=VolumeTotal+VofOverlap*scale_fac_dist
10881 fac_shield(i)=VolumeTotal*div77_81+div4_81
10882 C write(2,*) "TOTAL VOLUME",i,VolumeTotal,fac_shield(i)