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'
28 include 'COMMON.TORCNSTR'
30 c print*,"ETOTAL Processor",fg_rank," absolute rank",myrank,
31 c & " nfgtasks",nfgtasks
32 if (nfgtasks.gt.1) then
34 C FG slaves call the following matching MPI_Bcast in ERGASTULUM
35 if (fg_rank.eq.0) then
36 call MPI_Bcast(0,1,MPI_INTEGER,king,FG_COMM,IERROR)
37 c print *,"Processor",myrank," BROADCAST iorder"
38 C FG master sets up the WEIGHTS_ array which will be broadcast to the
39 C FG slaves as WEIGHTS array.
61 C FG Master broadcasts the WEIGHTS_ array
62 call MPI_Bcast(weights_(1),n_ene,
63 & MPI_DOUBLE_PRECISION,king,FG_COMM,IERROR)
65 C FG slaves receive the WEIGHTS array
66 call MPI_Bcast(weights(1),n_ene,
67 & MPI_DOUBLE_PRECISION,king,FG_COMM,IERROR)
90 time_Bcast=time_Bcast+MPI_Wtime()-time00
91 time_Bcastw=time_Bcastw+MPI_Wtime()-time00
92 c call chainbuild_cart
94 c print *,'Processor',myrank,' calling etotal ipot=',ipot
95 c print *,'Processor',myrank,' nnt=',nnt,' nct=',nct
97 c if (modecalc.eq.12.or.modecalc.eq.14) then
98 c call int_from_cart1(.false.)
105 C Compute the side-chain and electrostatic interaction energy
108 goto (101,102,103,104,105,106) ipot
109 C Lennard-Jones potential.
111 cd print '(a)','Exit ELJ'
113 C Lennard-Jones-Kihara potential (shifted).
116 C Berne-Pechukas potential (dilated LJ, angular dependence).
119 C Gay-Berne potential (shifted LJ, angular dependence).
121 C print *,"bylem w egb"
123 C Gay-Berne-Vorobjev potential (shifted LJ, angular dependence).
126 C Soft-sphere potential
127 106 call e_softsphere(evdw)
129 C Calculate electrostatic (H-bonding) energy of the main chain.
133 cmc Sep-06: egb takes care of dynamic ss bonds too
135 c if (dyn_ss) call dyn_set_nss
137 c print *,"Processor",myrank," computed USCSC"
143 time_vec=time_vec+MPI_Wtime()-time01
145 C Introduction of shielding effect first for each peptide group
146 C the shielding factor is set this factor is describing how each
147 C peptide group is shielded by side-chains
148 C the matrix - shield_fac(i) the i index describe the ith between i and i+1
149 C write (iout,*) "shield_mode",shield_mode
150 if (shield_mode.eq.1) then
152 else if (shield_mode.eq.2) then
155 c print *,"Processor",myrank," left VEC_AND_DERIV"
158 if (welec.gt.0d0.or.wvdwpp.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 if (welec.gt.0d0.or.wel_loc.gt.0d0.or.
164 & wturn3.gt.0d0.or.wturn4.gt.0d0 .or. wcorr.gt.0.0d0
165 & .or. wcorr4.gt.0.0d0 .or. wcorr5.gt.0.d0
166 & .or. wcorr6.gt.0.0d0 .or. wturn6.gt.0.0d0 ) then
168 call eelec(ees,evdw1,eel_loc,eello_turn3,eello_turn4)
177 write (iout,*) "Soft-spheer ELEC potential"
178 c call eelec_soft_sphere(ees,evdw1,eel_loc,eello_turn3,
182 c time_enecalc=time_enecalc+MPI_Wtime()-time00
184 c print *,"Processor",myrank," computed UELEC"
186 C Calculate excluded-volume interaction energy between peptide groups
191 call escp(evdw2,evdw2_14)
197 c write (iout,*) "Soft-sphere SCP potential"
198 call escp_soft_sphere(evdw2,evdw2_14)
201 c Calculate the bond-stretching energy
205 C Calculate the disulfide-bridge and other energy and the contributions
206 C from other distance constraints.
207 cd write (iout,*) 'Calling EHPB'
209 cd print *,'EHPB exitted succesfully.'
211 C Calculate the virtual-bond-angle energy.
213 if (wang.gt.0d0) then
214 if (tor_mode.eq.0) then
217 C ebend kcc is Kubo cumulant clustered rigorous attemp to derive the
225 if (with_theta_constr) call etheta_constr(ethetacnstr)
226 c print *,"Processor",myrank," computed UB"
228 C Calculate the SC local energy.
230 C print *,"TU DOCHODZE?"
232 c print *,"Processor",myrank," computed USC"
234 C Calculate the virtual-bond torsional energy.
236 cd print *,'nterm=',nterm
237 C print *,"tor",tor_mode
238 if (wtor.gt.0.0d0) then
239 if (tor_mode.eq.0) then
242 C etor kcc is Kubo cumulant clustered rigorous attemp to derive the
250 if (ndih_constr.gt.0) call etor_constr(edihcnstr)
251 c print *,"Processor",myrank," computed Utor"
253 C 6/23/01 Calculate double-torsional energy
255 if ((wtor_d.gt.0.0d0).and.(tor_mode.eq.0)) then
260 c print *,"Processor",myrank," computed Utord"
262 C 21/5/07 Calculate local sicdechain correlation energy
264 if (wsccor.gt.0.0d0) then
265 call eback_sc_corr(esccor)
269 C print *,"PRZED MULIt"
270 c print *,"Processor",myrank," computed Usccorr"
272 C 12/1/95 Multi-body terms
276 if ((wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 .or. wcorr6.gt.0.0d0
277 & .or. wturn6.gt.0.0d0) .and. ipot.lt.6) then
278 call multibody_eello(ecorr,ecorr5,ecorr6,eturn6,n_corr,n_corr1)
279 c write(2,*)'MULTIBODY_EELLO n_corr=',n_corr,' n_corr1=',n_corr1,
280 c &" ecorr",ecorr," ecorr5",ecorr5," ecorr6",ecorr6," eturn6",eturn6
288 if ((wcorr4.eq.0.0d0 .and. wcorr.gt.0.0d0) .and. ipot.lt.6) then
289 c write (iout,*) "Before MULTIBODY_HB ecorr",ecorr,ecorr5,ecorr6,
292 call multibody_hb(ecorr,ecorr5,ecorr6,n_corr,n_corr1)
293 c write (iout,*) "MULTIBODY_HB ecorr",ecorr,ecorr5,ecorr6,n_corr,
297 c print *,"Processor",myrank," computed Ucorr"
298 c write (iout,*) "nsaxs",nsaxs," saxs_mode",saxs_mode
299 if (nsaxs.gt.0 .and. saxs_mode.eq.0) then
300 call e_saxs(Esaxs_constr)
301 c write (iout,*) "From Esaxs: Esaxs_constr",Esaxs_constr
302 else if (nsaxs.gt.0 .and. saxs_mode.gt.0) then
303 call e_saxsC(Esaxs_constr)
304 c write (iout,*) "From EsaxsC: Esaxs_constr",Esaxs_constr
309 C If performing constraint dynamics, call the constraint energy
310 C after the equilibration time
311 c if(usampl.and.totT.gt.eq_time) then
312 c write (iout,*) "usampl",usampl
316 call Econstr_back_qlike
324 C 01/27/2015 added by adasko
325 C the energy component below is energy transfer into lipid environment
326 C based on partition function
327 C print *,"przed lipidami"
328 if (wliptran.gt.0) then
329 call Eliptransfer(eliptran)
331 C print *,"za lipidami"
332 if (AFMlog.gt.0) then
333 call AFMforce(Eafmforce)
334 else if (selfguide.gt.0) then
335 call AFMvel(Eafmforce)
337 if (TUBElog.eq.1) then
338 C print *,"just before call"
340 elseif (TUBElog.eq.2) then
341 call calctube2(Etube)
347 time_enecalc=time_enecalc+MPI_Wtime()-time00
349 c print *,"Processor",myrank," computed Uconstr"
358 energia(2)=evdw2-evdw2_14
375 energia(8)=eello_turn3
376 energia(9)=eello_turn4
383 energia(19)=edihcnstr
385 energia(20)=Uconst+Uconst_back
388 energia(23)=Eafmforce
389 energia(24)=ethetacnstr
391 energia(26)=Esaxs_constr
392 c write (iout,*) "esaxs_constr",energia(26)
393 c Here are the energies showed per procesor if the are more processors
394 c per molecule then we sum it up in sum_energy subroutine
395 c print *," Processor",myrank," calls SUM_ENERGY"
396 call sum_energy(energia,.true.)
397 c write (iout,*) "After sum_energy: esaxs_constr",energia(26)
398 if (dyn_ss) call dyn_set_nss
399 c print *," Processor",myrank," left SUM_ENERGY"
401 time_sumene=time_sumene+MPI_Wtime()-time00
405 c-------------------------------------------------------------------------------
406 subroutine sum_energy(energia,reduce)
407 implicit real*8 (a-h,o-z)
412 cMS$ATTRIBUTES C :: proc_proc
418 include 'COMMON.SETUP'
419 include 'COMMON.IOUNITS'
420 double precision energia(0:n_ene),enebuff(0:n_ene+1)
421 include 'COMMON.FFIELD'
422 include 'COMMON.DERIV'
423 include 'COMMON.INTERACT'
424 include 'COMMON.SBRIDGE'
425 include 'COMMON.CHAIN'
427 include 'COMMON.CONTROL'
428 include 'COMMON.TIME1'
431 if (nfgtasks.gt.1 .and. reduce) then
433 write (iout,*) "energies before REDUCE"
434 call enerprint(energia)
438 enebuff(i)=energia(i)
441 call MPI_Barrier(FG_COMM,IERR)
442 time_barrier_e=time_barrier_e+MPI_Wtime()-time00
444 call MPI_Reduce(enebuff(0),energia(0),n_ene+1,
445 & MPI_DOUBLE_PRECISION,MPI_SUM,king,FG_COMM,IERR)
447 write (iout,*) "energies after REDUCE"
448 call enerprint(energia)
451 time_Reduce=time_Reduce+MPI_Wtime()-time00
453 if (fg_rank.eq.0) then
457 evdw2=energia(2)+energia(18)
473 eello_turn3=energia(8)
474 eello_turn4=energia(9)
481 edihcnstr=energia(19)
486 Eafmforce=energia(23)
487 ethetacnstr=energia(24)
489 esaxs_constr=energia(26)
491 etot=wsc*evdw+wscp*evdw2+welec*ees+wvdwpp*evdw1
492 & +wang*ebe+wtor*etors+wscloc*escloc
493 & +wstrain*ehpb+wcorr*ecorr+wcorr5*ecorr5
494 & +wcorr6*ecorr6+wturn4*eello_turn4+wturn3*eello_turn3
495 & +wturn6*eturn6+wel_loc*eel_loc+edihcnstr+wtor_d*etors_d
496 & +wbond*estr+wumb*Uconst+wsccor*esccor+wliptran*eliptran+Eafmforce
497 & +ethetacnstr+wtube*Etube+wsaxs*esaxs_constr
499 etot=wsc*evdw+wscp*evdw2+welec*(ees+evdw1)
500 & +wang*ebe+wtor*etors+wscloc*escloc
501 & +wstrain*ehpb+wcorr*ecorr+wcorr5*ecorr5
502 & +wcorr6*ecorr6+wturn4*eello_turn4+wturn3*eello_turn3
503 & +wturn6*eturn6+wel_loc*eel_loc+edihcnstr+wtor_d*etors_d
504 & +wbond*estr+wumb*Uconst+wsccor*esccor+wliptran*eliptran
506 & +ethetacnstr+wtube*Etube+wsaxs*esaxs_constr
512 if (isnan(etot).ne.0) energia(0)=1.0d+99
514 if (isnan(etot)) energia(0)=1.0d+99
519 idumm=proc_proc(etot,i)
521 call proc_proc(etot,i)
523 if(i.eq.1)energia(0)=1.0d+99
530 c-------------------------------------------------------------------------------
531 subroutine sum_gradient
532 implicit real*8 (a-h,o-z)
537 cMS$ATTRIBUTES C :: proc_proc
543 double precision gradbufc(3,-1:maxres),gradbufx(3,-1:maxres),
544 & glocbuf(4*maxres),gradbufc_sum(3,-1:maxres)
545 & ,gloc_scbuf(3,-1:maxres)
546 include 'COMMON.SETUP'
547 include 'COMMON.IOUNITS'
548 include 'COMMON.FFIELD'
549 include 'COMMON.DERIV'
550 include 'COMMON.INTERACT'
551 include 'COMMON.SBRIDGE'
552 include 'COMMON.CHAIN'
554 include 'COMMON.CONTROL'
555 include 'COMMON.TIME1'
556 include 'COMMON.MAXGRAD'
557 include 'COMMON.SCCOR'
562 write (iout,*) "sum_gradient gvdwc, gvdwx"
564 write (iout,'(i3,3f10.5,5x,3f10.5,5x,f10.5)')
565 & i,(gvdwx(j,i),j=1,3),(gvdwc(j,i),j=1,3)
570 write (iout,*) "sum_gradient gsaxsc, gsaxsx"
572 write (iout,'(i3,3e15.5,5x,3e15.5)')
573 & i,(gsaxsc(j,i),j=1,3),(gsaxsx(j,i),j=1,3)
578 C FG slaves call the following matching MPI_Bcast in ERGASTULUM
579 if (nfgtasks.gt.1 .and. fg_rank.eq.0)
580 & call MPI_Bcast(1,1,MPI_INTEGER,king,FG_COMM,IERROR)
583 C 9/29/08 AL Transform parts of gradients in site coordinates to the gradient
584 C in virtual-bond-vector coordinates
587 c write (iout,*) "gel_loc gel_loc_long and gel_loc_loc"
589 c write (iout,'(i5,3f10.5,2x,3f10.5,2x,f10.5)')
590 c & i,(gel_loc(j,i),j=1,3),(gel_loc_long(j,i),j=1,3),gel_loc_loc(i)
592 c write (iout,*) "gel_loc_tur3 gel_loc_turn4"
594 c write (iout,'(i5,3f10.5,2x,f10.5)')
595 c & i,(gcorr4_turn(j,i),j=1,3),gel_loc_turn4(i)
597 write (iout,*) "gradcorr5 gradcorr5_long gradcorr5_loc"
599 write (iout,'(i3,3f10.5,5x,3f10.5,5x,f10.5)')
600 & i,(gradcorr5(j,i),j=1,3),(gradcorr5_long(j,i),j=1,3),
606 write (iout,*) "gsaxsc"
608 write (iout,'(i3,3f10.5)') i,(wsaxs*gsaxsc(j,i),j=1,3)
615 gradbufc(j,i)=wsc*gvdwc(j,i)+
616 & wscp*(gvdwc_scp(j,i)+gvdwc_scpp(j,i))+
617 & welec*gelc_long(j,i)+wvdwpp*gvdwpp(j,i)+
618 & wel_loc*gel_loc_long(j,i)+
619 & wcorr*gradcorr_long(j,i)+
620 & wcorr5*gradcorr5_long(j,i)+
621 & wcorr6*gradcorr6_long(j,i)+
622 & wturn6*gcorr6_turn_long(j,i)+
624 & +wliptran*gliptranc(j,i)
626 & +welec*gshieldc(j,i)
627 & +wcorr*gshieldc_ec(j,i)
628 & +wturn3*gshieldc_t3(j,i)
629 & +wturn4*gshieldc_t4(j,i)
630 & +wel_loc*gshieldc_ll(j,i)
631 & +wtube*gg_tube(j,i)
641 gradbufc(j,i)=wsc*gvdwc(j,i)+
642 & wscp*(gvdwc_scp(j,i)+gvdwc_scpp(j,i))+
643 & welec*gelc_long(j,i)+
645 & wel_loc*gel_loc_long(j,i)+
646 & wcorr*gradcorr_long(j,i)+
647 & wcorr5*gradcorr5_long(j,i)+
648 & wcorr6*gradcorr6_long(j,i)+
649 & wturn6*gcorr6_turn_long(j,i)+
651 & +wliptran*gliptranc(j,i)
653 & +welec*gshieldc(j,i)
654 & +wcorr*gshieldc_ec(j,i)
655 & +wturn4*gshieldc_t4(j,i)
656 & +wel_loc*gshieldc_ll(j,i)
657 & +wtube*gg_tube(j,i)
666 write (iout,*) "gradc from gradbufc"
668 write (iout,'(i3,3f10.5)') i,(gradc(j,i,icg),j=1,3)
673 if (nfgtasks.gt.1) then
676 write (iout,*) "gradbufc before allreduce"
678 write (iout,'(i3,3f10.5)') i,(gradbufc(j,i),j=1,3)
684 gradbufc_sum(j,i)=gradbufc(j,i)
687 c call MPI_AllReduce(gradbufc(1,1),gradbufc_sum(1,1),3*nres,
688 c & MPI_DOUBLE_PRECISION,MPI_SUM,FG_COMM,IERR)
689 c time_reduce=time_reduce+MPI_Wtime()-time00
691 c write (iout,*) "gradbufc_sum after allreduce"
693 c write (iout,'(i3,3f10.5)') i,(gradbufc_sum(j,i),j=1,3)
698 c time_allreduce=time_allreduce+MPI_Wtime()-time00
706 write (iout,*) "igrad_start",igrad_start," igrad_end",igrad_end
707 write (iout,*) (i," jgrad_start",jgrad_start(i),
708 & " jgrad_end ",jgrad_end(i),
709 & i=igrad_start,igrad_end)
712 c Obsolete and inefficient code; we can make the effort O(n) and, therefore,
713 c do not parallelize this part.
715 c do i=igrad_start,igrad_end
716 c do j=jgrad_start(i),jgrad_end(i)
718 c gradbufc(k,i)=gradbufc(k,i)+gradbufc_sum(k,j)
723 gradbufc(j,nres-1)=gradbufc_sum(j,nres)
727 gradbufc(j,i)=gradbufc(j,i+1)+gradbufc_sum(j,i+1)
731 write (iout,*) "gradbufc after summing"
733 write (iout,'(i3,3f10.5)') i,(gradbufc(j,i),j=1,3)
740 write (iout,*) "gradbufc"
742 write (iout,'(i3,3f10.5)') i,(gradbufc(j,i),j=1,3)
748 gradbufc_sum(j,i)=gradbufc(j,i)
753 gradbufc(j,nres-1)=gradbufc_sum(j,nres)
757 gradbufc(j,i)=gradbufc(j,i+1)+gradbufc_sum(j,i+1)
762 c gradbufc(k,i)=0.0d0
766 c gradbufc(k,i)=gradbufc(k,i)+gradbufc(k,j)
771 write (iout,*) "gradbufc after summing"
773 write (iout,'(i3,3f10.5)') i,(gradbufc(j,i),j=1,3)
781 gradbufc(k,nres)=0.0d0
786 C print *,gradbufc(1,13)
787 C print *,welec*gelc(1,13)
788 C print *,wel_loc*gel_loc(1,13)
789 C print *,0.5d0*(wscp*gvdwc_scpp(1,13))
790 C print *,welec*gelc_long(1,13)+wvdwpp*gvdwpp(1,13)
791 C print *,wel_loc*gel_loc_long(1,13)
792 C print *,gradafm(1,13),"AFM"
793 gradc(j,i,icg)=gradbufc(j,i)+welec*gelc(j,i)+
794 & wel_loc*gel_loc(j,i)+
795 & 0.5d0*(wscp*gvdwc_scpp(j,i)+
796 & welec*gelc_long(j,i)+wvdwpp*gvdwpp(j,i)+
797 & wel_loc*gel_loc_long(j,i)+
798 & wcorr*gradcorr_long(j,i)+
799 & wcorr5*gradcorr5_long(j,i)+
800 & wcorr6*gradcorr6_long(j,i)+
801 & wturn6*gcorr6_turn_long(j,i))+
803 & wcorr*gradcorr(j,i)+
804 & wturn3*gcorr3_turn(j,i)+
805 & wturn4*gcorr4_turn(j,i)+
806 & wcorr5*gradcorr5(j,i)+
807 & wcorr6*gradcorr6(j,i)+
808 & wturn6*gcorr6_turn(j,i)+
809 & wsccor*gsccorc(j,i)
810 & +wscloc*gscloc(j,i)
811 & +wliptran*gliptranc(j,i)
813 & +welec*gshieldc(j,i)
814 & +welec*gshieldc_loc(j,i)
815 & +wcorr*gshieldc_ec(j,i)
816 & +wcorr*gshieldc_loc_ec(j,i)
817 & +wturn3*gshieldc_t3(j,i)
818 & +wturn3*gshieldc_loc_t3(j,i)
819 & +wturn4*gshieldc_t4(j,i)
820 & +wturn4*gshieldc_loc_t4(j,i)
821 & +wel_loc*gshieldc_ll(j,i)
822 & +wel_loc*gshieldc_loc_ll(j,i)
823 & +wtube*gg_tube(j,i)
826 gradc(j,i,icg)=gradbufc(j,i)+welec*gelc(j,i)+
827 & wel_loc*gel_loc(j,i)+
828 & 0.5d0*(wscp*gvdwc_scpp(j,i)+
829 & welec*gelc_long(j,i)+
830 & wel_loc*gel_loc_long(j,i)+
831 & wcorr*gcorr_long(j,i)+
832 & wcorr5*gradcorr5_long(j,i)+
833 & wcorr6*gradcorr6_long(j,i)+
834 & wturn6*gcorr6_turn_long(j,i))+
836 & wcorr*gradcorr(j,i)+
837 & wturn3*gcorr3_turn(j,i)+
838 & wturn4*gcorr4_turn(j,i)+
839 & wcorr5*gradcorr5(j,i)+
840 & wcorr6*gradcorr6(j,i)+
841 & wturn6*gcorr6_turn(j,i)+
842 & wsccor*gsccorc(j,i)
843 & +wscloc*gscloc(j,i)
844 & +wliptran*gliptranc(j,i)
846 & +welec*gshieldc(j,i)
847 & +welec*gshieldc_loc(j,i)
848 & +wcorr*gshieldc_ec(j,i)
849 & +wcorr*gshieldc_loc_ec(j,i)
850 & +wturn3*gshieldc_t3(j,i)
851 & +wturn3*gshieldc_loc_t3(j,i)
852 & +wturn4*gshieldc_t4(j,i)
853 & +wturn4*gshieldc_loc_t4(j,i)
854 & +wel_loc*gshieldc_ll(j,i)
855 & +wel_loc*gshieldc_loc_ll(j,i)
856 & +wtube*gg_tube(j,i)
860 gradx(j,i,icg)=wsc*gvdwx(j,i)+wscp*gradx_scp(j,i)+
862 & wstrain*ghpbx(j,i)+wcorr*gradxorr(j,i)+
863 & wsccor*gsccorx(j,i)
864 & +wscloc*gsclocx(j,i)
865 & +wliptran*gliptranx(j,i)
866 & +welec*gshieldx(j,i)
867 & +wcorr*gshieldx_ec(j,i)
868 & +wturn3*gshieldx_t3(j,i)
869 & +wturn4*gshieldx_t4(j,i)
870 & +wel_loc*gshieldx_ll(j,i)
871 & +wtube*gg_tube_sc(j,i)
879 write (iout,*) "gradc gradx gloc after adding"
881 write (iout,'(i5,3f10.5,5x,3f10.5,5x,f10.5)')
882 & i,(gradc(j,i,icg),j=1,3),(gradx(j,i,icg),j=1,3),gloc(i,icg)
886 write (iout,*) "gloc before adding corr"
888 write (iout,*) i,gloc(i,icg)
892 gloc(i,icg)=gloc(i,icg)+wcorr*gcorr_loc(i)
893 & +wcorr5*g_corr5_loc(i)
894 & +wcorr6*g_corr6_loc(i)
895 & +wturn4*gel_loc_turn4(i)
896 & +wturn3*gel_loc_turn3(i)
897 & +wturn6*gel_loc_turn6(i)
898 & +wel_loc*gel_loc_loc(i)
901 write (iout,*) "gloc after adding corr"
903 write (iout,*) i,gloc(i,icg)
907 if (nfgtasks.gt.1) then
910 gradbufc(j,i)=gradc(j,i,icg)
911 gradbufx(j,i)=gradx(j,i,icg)
915 glocbuf(i)=gloc(i,icg)
919 write (iout,*) "gloc_sc before reduce"
922 write (iout,*) i,j,gloc_sc(j,i,icg)
929 gloc_scbuf(j,i)=gloc_sc(j,i,icg)
933 call MPI_Barrier(FG_COMM,IERR)
934 time_barrier_g=time_barrier_g+MPI_Wtime()-time00
936 call MPI_Reduce(gradbufc(1,1),gradc(1,1,icg),3*nres,
937 & MPI_DOUBLE_PRECISION,MPI_SUM,king,FG_COMM,IERR)
938 call MPI_Reduce(gradbufx(1,1),gradx(1,1,icg),3*nres,
939 & MPI_DOUBLE_PRECISION,MPI_SUM,king,FG_COMM,IERR)
940 call MPI_Reduce(glocbuf(1),gloc(1,icg),4*nres,
941 & MPI_DOUBLE_PRECISION,MPI_SUM,king,FG_COMM,IERR)
942 time_reduce=time_reduce+MPI_Wtime()-time00
943 call MPI_Reduce(gloc_scbuf(1,1),gloc_sc(1,1,icg),3*nres,
944 & MPI_DOUBLE_PRECISION,MPI_SUM,king,FG_COMM,IERR)
945 time_reduce=time_reduce+MPI_Wtime()-time00
947 write (iout,*) "gradc after reduce"
950 write (iout,*) i,j,gradc(j,i,icg)
955 write (iout,*) "gloc_sc after reduce"
958 write (iout,*) i,j,gloc_sc(j,i,icg)
963 write (iout,*) "gloc after reduce"
965 write (iout,*) i,gloc(i,icg)
970 if (gnorm_check) then
972 c Compute the maximum elements of the gradient
982 gcorr3_turn_max=0.0d0
983 gcorr4_turn_max=0.0d0
986 gcorr6_turn_max=0.0d0
996 gvdwc_norm=dsqrt(scalar(gvdwc(1,i),gvdwc(1,i)))
997 if (gvdwc_norm.gt.gvdwc_max) gvdwc_max=gvdwc_norm
998 gvdwc_scp_norm=dsqrt(scalar(gvdwc_scp(1,i),gvdwc_scp(1,i)))
999 if (gvdwc_scp_norm.gt.gvdwc_scp_max)
1000 & gvdwc_scp_max=gvdwc_scp_norm
1001 gelc_norm=dsqrt(scalar(gelc(1,i),gelc(1,i)))
1002 if (gelc_norm.gt.gelc_max) gelc_max=gelc_norm
1003 gvdwpp_norm=dsqrt(scalar(gvdwpp(1,i),gvdwpp(1,i)))
1004 if (gvdwpp_norm.gt.gvdwpp_max) gvdwpp_max=gvdwpp_norm
1005 gradb_norm=dsqrt(scalar(gradb(1,i),gradb(1,i)))
1006 if (gradb_norm.gt.gradb_max) gradb_max=gradb_norm
1007 ghpbc_norm=dsqrt(scalar(ghpbc(1,i),ghpbc(1,i)))
1008 if (ghpbc_norm.gt.ghpbc_max) ghpbc_max=ghpbc_norm
1009 gradcorr_norm=dsqrt(scalar(gradcorr(1,i),gradcorr(1,i)))
1010 if (gradcorr_norm.gt.gradcorr_max) gradcorr_max=gradcorr_norm
1011 gel_loc_norm=dsqrt(scalar(gel_loc(1,i),gel_loc(1,i)))
1012 if (gel_loc_norm.gt.gel_loc_max) gel_loc_max=gel_loc_norm
1013 gcorr3_turn_norm=dsqrt(scalar(gcorr3_turn(1,i),
1014 & gcorr3_turn(1,i)))
1015 if (gcorr3_turn_norm.gt.gcorr3_turn_max)
1016 & gcorr3_turn_max=gcorr3_turn_norm
1017 gcorr4_turn_norm=dsqrt(scalar(gcorr4_turn(1,i),
1018 & gcorr4_turn(1,i)))
1019 if (gcorr4_turn_norm.gt.gcorr4_turn_max)
1020 & gcorr4_turn_max=gcorr4_turn_norm
1021 gradcorr5_norm=dsqrt(scalar(gradcorr5(1,i),gradcorr5(1,i)))
1022 if (gradcorr5_norm.gt.gradcorr5_max)
1023 & gradcorr5_max=gradcorr5_norm
1024 gradcorr6_norm=dsqrt(scalar(gradcorr6(1,i),gradcorr6(1,i)))
1025 if (gradcorr6_norm.gt.gradcorr6_max) gcorr6_max=gradcorr6_norm
1026 gcorr6_turn_norm=dsqrt(scalar(gcorr6_turn(1,i),
1027 & gcorr6_turn(1,i)))
1028 if (gcorr6_turn_norm.gt.gcorr6_turn_max)
1029 & gcorr6_turn_max=gcorr6_turn_norm
1030 gsccorr_norm=dsqrt(scalar(gsccorc(1,i),gsccorc(1,i)))
1031 if (gsccorr_norm.gt.gsccorr_max) gsccorr_max=gsccorr_norm
1032 gscloc_norm=dsqrt(scalar(gscloc(1,i),gscloc(1,i)))
1033 if (gscloc_norm.gt.gscloc_max) gscloc_max=gscloc_norm
1034 gvdwx_norm=dsqrt(scalar(gvdwx(1,i),gvdwx(1,i)))
1035 if (gvdwx_norm.gt.gvdwx_max) gvdwx_max=gvdwx_norm
1036 gradx_scp_norm=dsqrt(scalar(gradx_scp(1,i),gradx_scp(1,i)))
1037 if (gradx_scp_norm.gt.gradx_scp_max)
1038 & gradx_scp_max=gradx_scp_norm
1039 ghpbx_norm=dsqrt(scalar(ghpbx(1,i),ghpbx(1,i)))
1040 if (ghpbx_norm.gt.ghpbx_max) ghpbx_max=ghpbx_norm
1041 gradxorr_norm=dsqrt(scalar(gradxorr(1,i),gradxorr(1,i)))
1042 if (gradxorr_norm.gt.gradxorr_max) gradxorr_max=gradxorr_norm
1043 gsccorrx_norm=dsqrt(scalar(gsccorx(1,i),gsccorx(1,i)))
1044 if (gsccorrx_norm.gt.gsccorrx_max) gsccorrx_max=gsccorrx_norm
1045 gsclocx_norm=dsqrt(scalar(gsclocx(1,i),gsclocx(1,i)))
1046 if (gsclocx_norm.gt.gsclocx_max) gsclocx_max=gsclocx_norm
1049 #if (defined AIX || defined CRAY)
1050 open(istat,file=statname,position="append")
1052 open(istat,file=statname,access="append")
1054 write (istat,'(1h#,21f10.2)') gvdwc_max,gvdwc_scp_max,
1055 & gelc_max,gvdwpp_max,gradb_max,ghpbc_max,
1056 & gradcorr_max,gel_loc_max,gcorr3_turn_max,gcorr4_turn_max,
1057 & gradcorr5_max,gradcorr6_max,gcorr6_turn_max,gsccorc_max,
1058 & gscloc_max,gvdwx_max,gradx_scp_max,ghpbx_max,gradxorr_max,
1059 & gsccorx_max,gsclocx_max
1061 if (gvdwc_max.gt.1.0d4) then
1062 write (iout,*) "gvdwc gvdwx gradb gradbx"
1064 write(iout,'(i5,4(3f10.2,5x))') i,(gvdwc(j,i),gvdwx(j,i),
1065 & gradb(j,i),gradbx(j,i),j=1,3)
1067 call pdbout(0.0d0,'cipiszcze',iout)
1073 write (iout,*) "gradc gradx gloc"
1075 write (iout,'(i5,3f10.5,5x,3f10.5,5x,f10.5)')
1076 & i,(gradc(j,i,icg),j=1,3),(gradx(j,i,icg),j=1,3),gloc(i,icg)
1080 time_sumgradient=time_sumgradient+MPI_Wtime()-time01
1084 c-------------------------------------------------------------------------------
1085 subroutine rescale_weights(t_bath)
1086 implicit real*8 (a-h,o-z)
1087 include 'DIMENSIONS'
1088 include 'COMMON.IOUNITS'
1089 include 'COMMON.FFIELD'
1090 include 'COMMON.SBRIDGE'
1091 include 'COMMON.CONTROL'
1092 double precision kfac /2.4d0/
1093 double precision x,x2,x3,x4,x5,licznik /1.12692801104297249644/
1095 c facT=2*temp0/(t_bath+temp0)
1096 if (rescale_mode.eq.0) then
1102 else if (rescale_mode.eq.1) then
1103 facT=kfac/(kfac-1.0d0+t_bath/temp0)
1104 facT2=kfac**2/(kfac**2-1.0d0+(t_bath/temp0)**2)
1105 facT3=kfac**3/(kfac**3-1.0d0+(t_bath/temp0)**3)
1106 facT4=kfac**4/(kfac**4-1.0d0+(t_bath/temp0)**4)
1107 facT5=kfac**5/(kfac**5-1.0d0+(t_bath/temp0)**5)
1108 else if (rescale_mode.eq.2) then
1114 facT=licznik/dlog(dexp(x)+dexp(-x))
1115 facT2=licznik/dlog(dexp(x2)+dexp(-x2))
1116 facT3=licznik/dlog(dexp(x3)+dexp(-x3))
1117 facT4=licznik/dlog(dexp(x4)+dexp(-x4))
1118 facT5=licznik/dlog(dexp(x5)+dexp(-x5))
1120 write (iout,*) "Wrong RESCALE_MODE",rescale_mode
1121 write (*,*) "Wrong RESCALE_MODE",rescale_mode
1123 call MPI_Finalize(MPI_COMM_WORLD,IERROR)
1127 if (shield_mode.gt.0) then
1128 wscp=weights(2)*fact
1130 wvdwpp=weights(16)*fact
1132 welec=weights(3)*fact
1133 wcorr=weights(4)*fact3
1134 wcorr5=weights(5)*fact4
1135 wcorr6=weights(6)*fact5
1136 wel_loc=weights(7)*fact2
1137 wturn3=weights(8)*fact2
1138 wturn4=weights(9)*fact3
1139 wturn6=weights(10)*fact5
1140 wtor=weights(13)*fact
1141 wtor_d=weights(14)*fact2
1142 wsccor=weights(21)*fact
1143 if (scale_umb) wumb=t_bath/temp0
1144 c write (iout,*) "scale_umb",scale_umb
1145 c write (iout,*) "t_bath",t_bath," temp0",temp0," wumb",wumb
1149 C------------------------------------------------------------------------
1150 subroutine enerprint(energia)
1151 implicit real*8 (a-h,o-z)
1152 include 'DIMENSIONS'
1153 include 'COMMON.IOUNITS'
1154 include 'COMMON.FFIELD'
1155 include 'COMMON.SBRIDGE'
1157 double precision energia(0:n_ene)
1162 evdw2=energia(2)+energia(18)
1174 eello_turn3=energia(8)
1175 eello_turn4=energia(9)
1176 eello_turn6=energia(10)
1182 edihcnstr=energia(19)
1186 eliptran=energia(22)
1187 Eafmforce=energia(23)
1188 ethetacnstr=energia(24)
1192 write (iout,10) evdw,wsc,evdw2,wscp,ees,welec,evdw1,wvdwpp,
1193 & estr,wbond,ebe,wang,
1194 & escloc,wscloc,etors,wtor,etors_d,wtor_d,ehpb,wstrain,
1196 & ecorr5,wcorr5,ecorr6,wcorr6,eel_loc,wel_loc,eello_turn3,wturn3,
1197 & eello_turn4,wturn4,eello_turn6,wturn6,esccor,wsccor,edihcnstr,
1198 & ethetacnstr,ebr*nss,Uconst,wumb,eliptran,wliptran,Eafmforc,
1199 & etube,wtube,esaxs,wsaxs,
1201 10 format (/'Virtual-chain energies:'//
1202 & 'EVDW= ',1pE16.6,' WEIGHT=',1pD16.6,' (SC-SC)'/
1203 & 'EVDW2= ',1pE16.6,' WEIGHT=',1pD16.6,' (SC-p)'/
1204 & 'EES= ',1pE16.6,' WEIGHT=',1pD16.6,' (p-p)'/
1205 & 'EVDWPP=',1pE16.6,' WEIGHT=',1pD16.6,' (p-p VDW)'/
1206 & 'ESTR= ',1pE16.6,' WEIGHT=',1pD16.6,' (stretching)'/
1207 & 'EBE= ',1pE16.6,' WEIGHT=',1pD16.6,' (bending)'/
1208 & 'ESC= ',1pE16.6,' WEIGHT=',1pD16.6,' (SC local)'/
1209 & 'ETORS= ',1pE16.6,' WEIGHT=',1pD16.6,' (torsional)'/
1210 & 'ETORSD=',1pE16.6,' WEIGHT=',1pD16.6,' (double torsional)'/
1211 & 'EHBP= ',1pE16.6,' WEIGHT=',1pD16.6,
1212 & ' (SS bridges & dist. cnstr.)'/
1213 & 'ECORR4=',1pE16.6,' WEIGHT=',1pD16.6,' (multi-body)'/
1214 & 'ECORR5=',1pE16.6,' WEIGHT=',1pD16.6,' (multi-body)'/
1215 & 'ECORR6=',1pE16.6,' WEIGHT=',1pD16.6,' (multi-body)'/
1216 & 'EELLO= ',1pE16.6,' WEIGHT=',1pD16.6,' (electrostatic-local)'/
1217 & 'ETURN3=',1pE16.6,' WEIGHT=',1pD16.6,' (turns, 3rd order)'/
1218 & 'ETURN4=',1pE16.6,' WEIGHT=',1pD16.6,' (turns, 4th order)'/
1219 & 'ETURN6=',1pE16.6,' WEIGHT=',1pD16.6,' (turns, 6th order)'/
1220 & 'ESCCOR=',1pE16.6,' WEIGHT=',1pD16.6,' (backbone-rotamer corr)'/
1221 & 'EDIHC= ',1pE16.6,' (virtual-bond dihedral angle restraints)'/
1222 & 'ETHETC=',1pE16.6,' (virtual-bond angle restraints)'/
1223 & 'ESS= ',1pE16.6,' (disulfide-bridge intrinsic energy)'/
1224 & 'UCONST=',1pE16.6,' WEIGHT=',1pD16.6' (umbrella restraints)'/
1225 & 'ELT= ',1pE16.6,' WEIGHT=',1pD16.6,' (Lipid transfer)'/
1226 & 'EAFM= ',1pE16.6,' (atomic-force microscopy)'/
1227 & 'ETUBE= ',1pE16.6,' WEIGHT=',1pD16.6,' (tube confinment)'/
1228 & 'E_SAXS=',1pE16.6,' WEIGHT=',1pD16.6,' (SAXS restraints)'/
1229 & 'ETOT= ',1pE16.6,' (total)')
1232 write (iout,10) evdw,wsc,evdw2,wscp,ees,welec,
1233 & estr,wbond,ebe,wang,
1234 & escloc,wscloc,etors,wtor,etors_d,wtor_d,ehpb,wstrain,
1236 & ecorr5,wcorr5,ecorr6,wcorr6,eel_loc,wel_loc,eello_turn3,wturn3,
1237 & eello_turn4,wturn4,eello_turn6,wturn6,esccor,wsccro,edihcnstr,
1238 & ethetacnstr,ebr*nss,Uconst,wumb,eliptran,wliptran,Eafmforc,
1239 & etube,wtube,esaxs,wsaxs,
1241 10 format (/'Virtual-chain energies:'//
1242 & 'EVDW= ',1pE16.6,' WEIGHT=',1pD16.6,' (SC-SC)'/
1243 & 'EVDW2= ',1pE16.6,' WEIGHT=',1pD16.6,' (SC-p)'/
1244 & 'EES= ',1pE16.6,' WEIGHT=',1pD16.6,' (p-p)'/
1245 & 'ESTR= ',1pE16.6,' WEIGHT=',1pD16.6,' (stretching)'/
1246 & 'EBE= ',1pE16.6,' WEIGHT=',1pD16.6,' (bending)'/
1247 & 'ESC= ',1pE16.6,' WEIGHT=',1pD16.6,' (SC local)'/
1248 & 'ETORS= ',1pE16.6,' WEIGHT=',1pD16.6,' (torsional)'/
1249 & 'ETORSD=',1pE16.6,' WEIGHT=',1pD16.6,' (double torsional)'/
1250 & 'EHBP= ',1pE16.6,' WEIGHT=',1pD16.6,
1251 & ' (SS bridges & dist. restr.)'/
1252 & 'ECORR4=',1pE16.6,' WEIGHT=',1pD16.6,' (multi-body)'/
1253 & 'ECORR5=',1pE16.6,' WEIGHT=',1pD16.6,' (multi-body)'/
1254 & 'ECORR6=',1pE16.6,' WEIGHT=',1pD16.6,' (multi-body)'/
1255 & 'EELLO= ',1pE16.6,' WEIGHT=',1pD16.6,' (electrostatic-local)'/
1256 & 'ETURN3=',1pE16.6,' WEIGHT=',1pD16.6,' (turns, 3rd order)'/
1257 & 'ETURN4=',1pE16.6,' WEIGHT=',1pD16.6,' (turns, 4th order)'/
1258 & 'ETURN6=',1pE16.6,' WEIGHT=',1pD16.6,' (turns, 6th order)'/
1259 & 'ESCCOR=',1pE16.6,' WEIGHT=',1pD16.6,' (backbone-rotamer corr)'/
1260 & 'EDIHC= ',1pE16.6,' (virtual-bond dihedral angle restraints)'/
1261 & 'ETHETC=',1pE16.6,' (virtual-bond angle restraints)'/
1262 & 'ESS= ',1pE16.6,' (disulfide-bridge intrinsic energy)'/
1263 & 'UCONST=',1pE16.6,' WEIGHT=',1pD16.6' (umbrella restraints)'/
1264 & 'ELT= ',1pE16.6,' WEIGHT=',1pD16.6,' (Lipid transfer)'/
1265 & 'EAFM= ',1pE16.6,' (atomic-force microscopy)'/
1266 & 'ETUBE= ',1pE16.6,' WEIGHT=',1pD16.6,' (tube confinment)'/
1267 & 'E_SAXS=',1pE16.6,' WEIGHT=',1pD16.6,' (SAXS restraints)'/
1268 & 'ETOT= ',1pE16.6,' (total)')
1272 C-----------------------------------------------------------------------
1273 subroutine elj(evdw)
1275 C This subroutine calculates the interaction energy of nonbonded side chains
1276 C assuming the LJ potential of interaction.
1278 implicit real*8 (a-h,o-z)
1279 include 'DIMENSIONS'
1280 parameter (accur=1.0d-10)
1281 include 'COMMON.GEO'
1282 include 'COMMON.VAR'
1283 include 'COMMON.LOCAL'
1284 include 'COMMON.CHAIN'
1285 include 'COMMON.DERIV'
1286 include 'COMMON.INTERACT'
1287 include 'COMMON.TORSION'
1288 include 'COMMON.SBRIDGE'
1289 include 'COMMON.NAMES'
1290 include 'COMMON.IOUNITS'
1291 include 'COMMON.CONTACTS'
1293 c write(iout,*)'Entering ELJ nnt=',nnt,' nct=',nct,' expon=',expon
1295 do i=iatsc_s,iatsc_e
1296 itypi=iabs(itype(i))
1297 if (itypi.eq.ntyp1) cycle
1298 itypi1=iabs(itype(i+1))
1305 C Calculate SC interaction energy.
1307 do iint=1,nint_gr(i)
1308 cd write (iout,*) 'i=',i,' iint=',iint,' istart=',istart(i,iint),
1309 cd & 'iend=',iend(i,iint)
1310 do j=istart(i,iint),iend(i,iint)
1311 itypj=iabs(itype(j))
1312 if (itypj.eq.ntyp1) cycle
1316 C Change 12/1/95 to calculate four-body interactions
1317 rij=xj*xj+yj*yj+zj*zj
1319 c write (iout,*)'i=',i,' j=',j,' itypi=',itypi,' itypj=',itypj
1320 eps0ij=eps(itypi,itypj)
1322 C have you changed here?
1326 cd sigm=dabs(aa(itypi,itypj)/bb(itypi,itypj))**(1.0D0/6.0D0)
1327 cd epsi=bb(itypi,itypj)**2/aa(itypi,itypj)
1328 cd write (iout,'(2(a3,i3,2x),6(1pd12.4)/2(3(1pd12.4),5x)/)')
1329 cd & restyp(itypi),i,restyp(itypj),j,a(itypi,itypj),
1330 cd & bb(itypi,itypj),1.0D0/dsqrt(rrij),evdwij,epsi,sigm,
1331 cd & (c(k,i),k=1,3),(c(k,j),k=1,3)
1334 C Calculate the components of the gradient in DC and X
1336 fac=-rrij*(e1+evdwij)
1341 gvdwx(k,i)=gvdwx(k,i)-gg(k)
1342 gvdwx(k,j)=gvdwx(k,j)+gg(k)
1343 gvdwc(k,i)=gvdwc(k,i)-gg(k)
1344 gvdwc(k,j)=gvdwc(k,j)+gg(k)
1348 cgrad gvdwc(l,k)=gvdwc(l,k)+gg(l)
1352 C 12/1/95, revised on 5/20/97
1354 C Calculate the contact function. The ith column of the array JCONT will
1355 C contain the numbers of atoms that make contacts with the atom I (of numbers
1356 C greater than I). The arrays FACONT and GACONT will contain the values of
1357 C the contact function and its derivative.
1359 C Uncomment next line, if the correlation interactions include EVDW explicitly.
1360 c if (j.gt.i+1 .and. evdwij.le.0.0D0) then
1361 C Uncomment next line, if the correlation interactions are contact function only
1362 if (j.gt.i+1.and. eps0ij.gt.0.0D0) then
1364 sigij=sigma(itypi,itypj)
1365 r0ij=rs0(itypi,itypj)
1367 C Check whether the SC's are not too far to make a contact.
1370 call gcont(rij,rcut,1.0d0,0.2d0*rcut,fcont,fprimcont)
1371 C Add a new contact, if the SC's are close enough, but not too close (r<sigma).
1373 if (fcont.gt.0.0D0) then
1374 C If the SC-SC distance if close to sigma, apply spline.
1375 cAdam call gcont(-rij,-1.03d0*sigij,2.0d0*sigij,1.0d0,
1376 cAdam & fcont1,fprimcont1)
1377 cAdam fcont1=1.0d0-fcont1
1378 cAdam if (fcont1.gt.0.0d0) then
1379 cAdam fprimcont=fprimcont*fcont1+fcont*fprimcont1
1380 cAdam fcont=fcont*fcont1
1382 C Uncomment following 4 lines to have the geometric average of the epsilon0's
1383 cga eps0ij=1.0d0/dsqrt(eps0ij)
1385 cga gg(k)=gg(k)*eps0ij
1387 cga eps0ij=-evdwij*eps0ij
1388 C Uncomment for AL's type of SC correlation interactions.
1389 cadam eps0ij=-evdwij
1390 num_conti=num_conti+1
1391 jcont(num_conti,i)=j
1392 facont(num_conti,i)=fcont*eps0ij
1393 fprimcont=eps0ij*fprimcont/rij
1395 cAdam gacont(1,num_conti,i)=-fprimcont*xj+fcont*gg(1)
1396 cAdam gacont(2,num_conti,i)=-fprimcont*yj+fcont*gg(2)
1397 cAdam gacont(3,num_conti,i)=-fprimcont*zj+fcont*gg(3)
1398 C Uncomment following 3 lines for Skolnick's type of SC correlation.
1399 gacont(1,num_conti,i)=-fprimcont*xj
1400 gacont(2,num_conti,i)=-fprimcont*yj
1401 gacont(3,num_conti,i)=-fprimcont*zj
1402 cd write (iout,'(2i5,2f10.5)') i,j,rij,facont(num_conti,i)
1403 cd write (iout,'(2i3,3f10.5)')
1404 cd & i,j,(gacont(kk,num_conti,i),kk=1,3)
1410 num_cont(i)=num_conti
1414 gvdwc(j,i)=expon*gvdwc(j,i)
1415 gvdwx(j,i)=expon*gvdwx(j,i)
1418 C******************************************************************************
1422 C To save time, the factor of EXPON has been extracted from ALL components
1423 C of GVDWC and GRADX. Remember to multiply them by this factor before further
1426 C******************************************************************************
1429 C-----------------------------------------------------------------------------
1430 subroutine eljk(evdw)
1432 C This subroutine calculates the interaction energy of nonbonded side chains
1433 C assuming the LJK potential of interaction.
1435 implicit real*8 (a-h,o-z)
1436 include 'DIMENSIONS'
1437 include 'COMMON.GEO'
1438 include 'COMMON.VAR'
1439 include 'COMMON.LOCAL'
1440 include 'COMMON.CHAIN'
1441 include 'COMMON.DERIV'
1442 include 'COMMON.INTERACT'
1443 include 'COMMON.IOUNITS'
1444 include 'COMMON.NAMES'
1447 c print *,'Entering ELJK nnt=',nnt,' nct=',nct,' expon=',expon
1449 do i=iatsc_s,iatsc_e
1450 itypi=iabs(itype(i))
1451 if (itypi.eq.ntyp1) cycle
1452 itypi1=iabs(itype(i+1))
1457 C Calculate SC interaction energy.
1459 do iint=1,nint_gr(i)
1460 do j=istart(i,iint),iend(i,iint)
1461 itypj=iabs(itype(j))
1462 if (itypj.eq.ntyp1) cycle
1466 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
1467 fac_augm=rrij**expon
1468 e_augm=augm(itypi,itypj)*fac_augm
1469 r_inv_ij=dsqrt(rrij)
1471 r_shift_inv=1.0D0/(rij+r0(itypi,itypj)-sigma(itypi,itypj))
1472 fac=r_shift_inv**expon
1473 C have you changed here?
1477 cd sigm=dabs(aa(itypi,itypj)/bb(itypi,itypj))**(1.0D0/6.0D0)
1478 cd epsi=bb(itypi,itypj)**2/aa(itypi,itypj)
1479 cd write (iout,'(2(a3,i3,2x),8(1pd12.4)/2(3(1pd12.4),5x)/)')
1480 cd & restyp(itypi),i,restyp(itypj),j,aa(itypi,itypj),
1481 cd & bb(itypi,itypj),augm(itypi,itypj),epsi,sigm,
1482 cd & sigma(itypi,itypj),1.0D0/dsqrt(rrij),evdwij,
1483 cd & (c(k,i),k=1,3),(c(k,j),k=1,3)
1486 C Calculate the components of the gradient in DC and X
1488 fac=-2.0D0*rrij*e_augm-r_inv_ij*r_shift_inv*(e1+e1+e2)
1493 gvdwx(k,i)=gvdwx(k,i)-gg(k)
1494 gvdwx(k,j)=gvdwx(k,j)+gg(k)
1495 gvdwc(k,i)=gvdwc(k,i)-gg(k)
1496 gvdwc(k,j)=gvdwc(k,j)+gg(k)
1500 cgrad gvdwc(l,k)=gvdwc(l,k)+gg(l)
1508 gvdwc(j,i)=expon*gvdwc(j,i)
1509 gvdwx(j,i)=expon*gvdwx(j,i)
1514 C-----------------------------------------------------------------------------
1515 subroutine ebp(evdw)
1517 C This subroutine calculates the interaction energy of nonbonded side chains
1518 C assuming the Berne-Pechukas potential of interaction.
1520 implicit real*8 (a-h,o-z)
1521 include 'DIMENSIONS'
1522 include 'COMMON.GEO'
1523 include 'COMMON.VAR'
1524 include 'COMMON.LOCAL'
1525 include 'COMMON.CHAIN'
1526 include 'COMMON.DERIV'
1527 include 'COMMON.NAMES'
1528 include 'COMMON.INTERACT'
1529 include 'COMMON.IOUNITS'
1530 include 'COMMON.CALC'
1531 common /srutu/ icall
1532 c double precision rrsave(maxdim)
1535 c print *,'Entering EBP nnt=',nnt,' nct=',nct,' expon=',expon
1537 c if (icall.eq.0) then
1543 do i=iatsc_s,iatsc_e
1544 itypi=iabs(itype(i))
1545 if (itypi.eq.ntyp1) cycle
1546 itypi1=iabs(itype(i+1))
1550 dxi=dc_norm(1,nres+i)
1551 dyi=dc_norm(2,nres+i)
1552 dzi=dc_norm(3,nres+i)
1553 c dsci_inv=dsc_inv(itypi)
1554 dsci_inv=vbld_inv(i+nres)
1556 C Calculate SC interaction energy.
1558 do iint=1,nint_gr(i)
1559 do j=istart(i,iint),iend(i,iint)
1561 itypj=iabs(itype(j))
1562 if (itypj.eq.ntyp1) cycle
1563 c dscj_inv=dsc_inv(itypj)
1564 dscj_inv=vbld_inv(j+nres)
1565 chi1=chi(itypi,itypj)
1566 chi2=chi(itypj,itypi)
1573 alf12=0.5D0*(alf1+alf2)
1574 C For diagnostics only!!!
1587 dxj=dc_norm(1,nres+j)
1588 dyj=dc_norm(2,nres+j)
1589 dzj=dc_norm(3,nres+j)
1590 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
1591 cd if (icall.eq.0) then
1597 C Calculate the angle-dependent terms of energy & contributions to derivatives.
1599 C Calculate whole angle-dependent part of epsilon and contributions
1600 C to its derivatives
1601 C have you changed here?
1602 fac=(rrij*sigsq)**expon2
1605 evdwij=eps1*eps2rt*eps3rt*(e1+e2)
1606 eps2der=evdwij*eps3rt
1607 eps3der=evdwij*eps2rt
1608 evdwij=evdwij*eps2rt*eps3rt
1611 sigm=dabs(aa/bb)**(1.0D0/6.0D0)
1613 cd write (iout,'(2(a3,i3,2x),15(0pf7.3))')
1614 cd & restyp(itypi),i,restyp(itypj),j,
1615 cd & epsi,sigm,chi1,chi2,chip1,chip2,
1616 cd & eps1,eps2rt**2,eps3rt**2,1.0D0/dsqrt(sigsq),
1617 cd & om1,om2,om12,1.0D0/dsqrt(rrij),
1620 C Calculate gradient components.
1621 e1=e1*eps1*eps2rt**2*eps3rt**2
1622 fac=-expon*(e1+evdwij)
1625 C Calculate radial part of the gradient
1629 C Calculate the angular part of the gradient and sum add the contributions
1630 C to the appropriate components of the Cartesian gradient.
1638 C-----------------------------------------------------------------------------
1639 subroutine egb(evdw)
1641 C This subroutine calculates the interaction energy of nonbonded side chains
1642 C assuming the Gay-Berne potential of interaction.
1644 implicit real*8 (a-h,o-z)
1645 include 'DIMENSIONS'
1646 include 'COMMON.GEO'
1647 include 'COMMON.VAR'
1648 include 'COMMON.LOCAL'
1649 include 'COMMON.CHAIN'
1650 include 'COMMON.DERIV'
1651 include 'COMMON.NAMES'
1652 include 'COMMON.INTERACT'
1653 include 'COMMON.IOUNITS'
1654 include 'COMMON.CALC'
1655 include 'COMMON.CONTROL'
1656 include 'COMMON.SPLITELE'
1657 include 'COMMON.SBRIDGE'
1659 integer xshift,yshift,zshift
1662 ccccc energy_dec=.false.
1663 C print *,'Entering EGB nnt=',nnt,' nct=',nct,' expon=',expon
1666 c if (icall.eq.0) lprn=.false.
1668 C the loop over all 27 posible neigbours (for xshift=0,yshift=0,zshift=0
1669 C we have the original box)
1673 do i=iatsc_s,iatsc_e
1674 itypi=iabs(itype(i))
1675 if (itypi.eq.ntyp1) cycle
1676 itypi1=iabs(itype(i+1))
1680 C Return atom into box, boxxsize is size of box in x dimension
1682 c if (xi.gt.((xshift+0.5d0)*boxxsize)) xi=xi-boxxsize
1683 c if (xi.lt.((xshift-0.5d0)*boxxsize)) xi=xi+boxxsize
1684 C Condition for being inside the proper box
1685 c if ((xi.gt.((xshift+0.5d0)*boxxsize)).or.
1686 c & (xi.lt.((xshift-0.5d0)*boxxsize))) then
1690 c if (yi.gt.((yshift+0.5d0)*boxysize)) yi=yi-boxysize
1691 c if (yi.lt.((yshift-0.5d0)*boxysize)) yi=yi+boxysize
1692 C Condition for being inside the proper box
1693 c if ((yi.gt.((yshift+0.5d0)*boxysize)).or.
1694 c & (yi.lt.((yshift-0.5d0)*boxysize))) then
1698 c if (zi.gt.((zshift+0.5d0)*boxzsize)) zi=zi-boxzsize
1699 c if (zi.lt.((zshift-0.5d0)*boxzsize)) zi=zi+boxzsize
1700 C Condition for being inside the proper box
1701 c if ((zi.gt.((zshift+0.5d0)*boxzsize)).or.
1702 c & (zi.lt.((zshift-0.5d0)*boxzsize))) then
1706 if (xi.lt.0) xi=xi+boxxsize
1708 if (yi.lt.0) yi=yi+boxysize
1710 if (zi.lt.0) zi=zi+boxzsize
1711 C define scaling factor for lipids
1713 C if (positi.le.0) positi=positi+boxzsize
1715 C first for peptide groups
1716 c for each residue check if it is in lipid or lipid water border area
1717 if ((zi.gt.bordlipbot)
1718 &.and.(zi.lt.bordliptop)) then
1719 C the energy transfer exist
1720 if (zi.lt.buflipbot) then
1721 C what fraction I am in
1723 & ((zi-bordlipbot)/lipbufthick)
1724 C lipbufthick is thickenes of lipid buffore
1725 sslipi=sscalelip(fracinbuf)
1726 ssgradlipi=-sscagradlip(fracinbuf)/lipbufthick
1727 elseif (zi.gt.bufliptop) then
1728 fracinbuf=1.0d0-((bordliptop-zi)/lipbufthick)
1729 sslipi=sscalelip(fracinbuf)
1730 ssgradlipi=sscagradlip(fracinbuf)/lipbufthick
1740 C xi=xi+xshift*boxxsize
1741 C yi=yi+yshift*boxysize
1742 C zi=zi+zshift*boxzsize
1744 dxi=dc_norm(1,nres+i)
1745 dyi=dc_norm(2,nres+i)
1746 dzi=dc_norm(3,nres+i)
1747 c dsci_inv=dsc_inv(itypi)
1748 dsci_inv=vbld_inv(i+nres)
1749 c write (iout,*) "i",i,dsc_inv(itypi),dsci_inv,1.0d0/vbld(i+nres)
1750 c write (iout,*) "dcnori",dxi*dxi+dyi*dyi+dzi*dzi
1752 C Calculate SC interaction energy.
1754 do iint=1,nint_gr(i)
1755 do j=istart(i,iint),iend(i,iint)
1756 IF (dyn_ss_mask(i).and.dyn_ss_mask(j)) THEN
1758 c write(iout,*) "PRZED ZWYKLE", evdwij
1759 call dyn_ssbond_ene(i,j,evdwij)
1760 c write(iout,*) "PO ZWYKLE", evdwij
1763 if (energy_dec) write (iout,'(a6,2i5,0pf7.3,a3)')
1764 & 'evdw',i,j,evdwij,' ss'
1765 C triple bond artifac removal
1766 do k=j+1,iend(i,iint)
1767 C search over all next residues
1768 if (dyn_ss_mask(k)) then
1769 C check if they are cysteins
1770 C write(iout,*) 'k=',k
1772 c write(iout,*) "PRZED TRI", evdwij
1773 evdwij_przed_tri=evdwij
1774 call triple_ssbond_ene(i,j,k,evdwij)
1775 c if(evdwij_przed_tri.ne.evdwij) then
1776 c write (iout,*) "TRI:", evdwij, evdwij_przed_tri
1779 c write(iout,*) "PO TRI", evdwij
1780 C call the energy function that removes the artifical triple disulfide
1781 C bond the soubroutine is located in ssMD.F
1783 if (energy_dec) write (iout,'(a6,2i5,0pf7.3,a3)')
1784 & 'evdw',i,j,evdwij,'tss'
1785 endif!dyn_ss_mask(k)
1789 itypj=iabs(itype(j))
1790 if (itypj.eq.ntyp1) cycle
1791 c dscj_inv=dsc_inv(itypj)
1792 dscj_inv=vbld_inv(j+nres)
1793 c write (iout,*) "j",j,dsc_inv(itypj),dscj_inv,
1794 c & 1.0d0/vbld(j+nres)
1795 c write (iout,*) "i",i," j", j," itype",itype(i),itype(j)
1796 sig0ij=sigma(itypi,itypj)
1797 chi1=chi(itypi,itypj)
1798 chi2=chi(itypj,itypi)
1805 alf12=0.5D0*(alf1+alf2)
1806 C For diagnostics only!!!
1819 C Return atom J into box the original box
1821 c if (xj.gt.((0.5d0)*boxxsize)) xj=xj-boxxsize
1822 c if (xj.lt.((-0.5d0)*boxxsize)) xj=xj+boxxsize
1823 C Condition for being inside the proper box
1824 c if ((xj.gt.((0.5d0)*boxxsize)).or.
1825 c & (xj.lt.((-0.5d0)*boxxsize))) then
1829 c if (yj.gt.((0.5d0)*boxysize)) yj=yj-boxysize
1830 c if (yj.lt.((-0.5d0)*boxysize)) yj=yj+boxysize
1831 C Condition for being inside the proper box
1832 c if ((yj.gt.((0.5d0)*boxysize)).or.
1833 c & (yj.lt.((-0.5d0)*boxysize))) then
1837 c if (zj.gt.((0.5d0)*boxzsize)) zj=zj-boxzsize
1838 c if (zj.lt.((-0.5d0)*boxzsize)) zj=zj+boxzsize
1839 C Condition for being inside the proper box
1840 c if ((zj.gt.((0.5d0)*boxzsize)).or.
1841 c & (zj.lt.((-0.5d0)*boxzsize))) then
1845 if (xj.lt.0) xj=xj+boxxsize
1847 if (yj.lt.0) yj=yj+boxysize
1849 if (zj.lt.0) zj=zj+boxzsize
1850 if ((zj.gt.bordlipbot)
1851 &.and.(zj.lt.bordliptop)) then
1852 C the energy transfer exist
1853 if (zj.lt.buflipbot) then
1854 C what fraction I am in
1856 & ((zj-bordlipbot)/lipbufthick)
1857 C lipbufthick is thickenes of lipid buffore
1858 sslipj=sscalelip(fracinbuf)
1859 ssgradlipj=-sscagradlip(fracinbuf)/lipbufthick
1860 elseif (zj.gt.bufliptop) then
1861 fracinbuf=1.0d0-((bordliptop-zj)/lipbufthick)
1862 sslipj=sscalelip(fracinbuf)
1863 ssgradlipj=sscagradlip(fracinbuf)/lipbufthick
1872 aa=aa_lip(itypi,itypj)*(sslipi+sslipj)/2.0d0
1873 & +aa_aq(itypi,itypj)*(2.0d0-sslipi-sslipj)/2.0d0
1874 bb=bb_lip(itypi,itypj)*(sslipi+sslipj)/2.0d0
1875 & +bb_aq(itypi,itypj)*(2.0d0-sslipi-sslipj)/2.0d0
1876 C write(iout,*) "tu,", i,j,aa_lip(itypi,itypj),bb_lip(itypi,itypj)
1877 C if (aa.ne.aa_aq(itypi,itypj)) write(63,'(2e10.5)')
1878 C &(aa-aa_aq(itypi,itypj)),(bb-bb_aq(itypi,itypj))
1879 C if (ssgradlipj.gt.0.0d0) print *,"??WTF??"
1880 C print *,sslipi,sslipj,bordlipbot,zi,zj
1881 dist_init=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
1889 xj=xj_safe+xshift*boxxsize
1890 yj=yj_safe+yshift*boxysize
1891 zj=zj_safe+zshift*boxzsize
1892 dist_temp=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
1893 if(dist_temp.lt.dist_init) then
1903 if (subchap.eq.1) then
1912 dxj=dc_norm(1,nres+j)
1913 dyj=dc_norm(2,nres+j)
1914 dzj=dc_norm(3,nres+j)
1918 c write (iout,*) "dcnorj",dxi*dxi+dyi*dyi+dzi*dzi
1919 c write (iout,*) "j",j," dc_norm",
1920 c & dc_norm(1,nres+j),dc_norm(2,nres+j),dc_norm(3,nres+j)
1921 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
1923 sss=sscale((1.0d0/rij)/sigma(itypi,itypj))
1924 sssgrad=sscagrad((1.0d0/rij)/sigma(itypi,itypj))
1926 c write (iout,'(a7,4f8.3)')
1927 c & "ssscale",sss,((1.0d0/rij)/sigma(itypi,itypj)),r_cut,rlamb
1928 if (sss.gt.0.0d0) then
1929 C Calculate angle-dependent terms of energy and contributions to their
1933 sig=sig0ij*dsqrt(sigsq)
1934 rij_shift=1.0D0/rij-sig+sig0ij
1935 c for diagnostics; uncomment
1936 c rij_shift=1.2*sig0ij
1937 C I hate to put IF's in the loops, but here don't have another choice!!!!
1938 if (rij_shift.le.0.0D0) then
1940 cd write (iout,'(2(a3,i3,2x),17(0pf7.3))')
1941 cd & restyp(itypi),i,restyp(itypj),j,
1942 cd & rij_shift,1.0D0/rij,sig,sig0ij,sigsq,1-dsqrt(sigsq)
1946 c---------------------------------------------------------------
1947 rij_shift=1.0D0/rij_shift
1948 fac=rij_shift**expon
1949 C here to start with
1954 evdwij=eps1*eps2rt*eps3rt*(e1+e2)
1955 eps2der=evdwij*eps3rt
1956 eps3der=evdwij*eps2rt
1957 C write(63,'(2i3,2e10.3,2f10.5)') i,j,aa,bb, evdwij,
1958 C &((sslipi+sslipj)/2.0d0+
1959 C &(2.0d0-sslipi-sslipj)/2.0d0)
1960 c write (iout,*) "sigsq",sigsq," sig",sig," eps2rt",eps2rt,
1961 c & " eps3rt",eps3rt," eps1",eps1," e1",e1," e2",e2
1962 evdwij=evdwij*eps2rt*eps3rt
1963 evdw=evdw+evdwij*sss
1965 sigm=dabs(aa/bb)**(1.0D0/6.0D0)
1967 write (iout,'(2(a3,i3,2x),17(0pf7.3))')
1968 & restyp(itypi),i,restyp(itypj),j,
1969 & epsi,sigm,chi1,chi2,chip1,chip2,
1970 & eps1,eps2rt**2,eps3rt**2,sig,sig0ij,
1971 & om1,om2,om12,1.0D0/rij,1.0D0/rij_shift,
1975 if (energy_dec) write (iout,'(a6,2i5,0pf7.3)')
1978 C Calculate gradient components.
1979 e1=e1*eps1*eps2rt**2*eps3rt**2
1980 fac=-expon*(e1+evdwij)*rij_shift
1983 c print '(2i4,6f8.4)',i,j,sss,sssgrad*
1984 c & evdwij,fac,sigma(itypi,itypj),expon
1985 fac=fac+evdwij/sss*sssgrad/sigma(itypi,itypj)*rij
1987 C Calculate the radial part of the gradient
1988 gg_lipi(3)=eps1*(eps2rt*eps2rt)
1989 &*(eps3rt*eps3rt)*sss/2.0d0*(faclip*faclip*
1990 & (aa_lip(itypi,itypj)-aa_aq(itypi,itypj))
1991 &+faclip*(bb_lip(itypi,itypj)-bb_aq(itypi,itypj)))
1992 gg_lipj(3)=ssgradlipj*gg_lipi(3)
1993 gg_lipi(3)=gg_lipi(3)*ssgradlipi
1999 C Calculate angular part of the gradient.
2009 c write (iout,*) "Number of loop steps in EGB:",ind
2010 cccc energy_dec=.false.
2013 C-----------------------------------------------------------------------------
2014 subroutine egbv(evdw)
2016 C This subroutine calculates the interaction energy of nonbonded side chains
2017 C assuming the Gay-Berne-Vorobjev potential of interaction.
2019 implicit real*8 (a-h,o-z)
2020 include 'DIMENSIONS'
2021 include 'COMMON.GEO'
2022 include 'COMMON.VAR'
2023 include 'COMMON.LOCAL'
2024 include 'COMMON.CHAIN'
2025 include 'COMMON.DERIV'
2026 include 'COMMON.NAMES'
2027 include 'COMMON.INTERACT'
2028 include 'COMMON.IOUNITS'
2029 include 'COMMON.CALC'
2030 integer xshift,yshift,zshift
2031 common /srutu/ icall
2034 c print *,'Entering EGB nnt=',nnt,' nct=',nct,' expon=',expon
2037 c if (icall.eq.0) lprn=.true.
2039 do i=iatsc_s,iatsc_e
2040 itypi=iabs(itype(i))
2041 if (itypi.eq.ntyp1) cycle
2042 itypi1=iabs(itype(i+1))
2047 if (xi.lt.0) xi=xi+boxxsize
2049 if (yi.lt.0) yi=yi+boxysize
2051 if (zi.lt.0) zi=zi+boxzsize
2052 C define scaling factor for lipids
2054 C if (positi.le.0) positi=positi+boxzsize
2056 C first for peptide groups
2057 c for each residue check if it is in lipid or lipid water border area
2058 if ((zi.gt.bordlipbot)
2059 &.and.(zi.lt.bordliptop)) then
2060 C the energy transfer exist
2061 if (zi.lt.buflipbot) then
2062 C what fraction I am in
2064 & ((zi-bordlipbot)/lipbufthick)
2065 C lipbufthick is thickenes of lipid buffore
2066 sslipi=sscalelip(fracinbuf)
2067 ssgradlipi=-sscagradlip(fracinbuf)/lipbufthick
2068 elseif (zi.gt.bufliptop) then
2069 fracinbuf=1.0d0-((bordliptop-zi)/lipbufthick)
2070 sslipi=sscalelip(fracinbuf)
2071 ssgradlipi=sscagradlip(fracinbuf)/lipbufthick
2081 dxi=dc_norm(1,nres+i)
2082 dyi=dc_norm(2,nres+i)
2083 dzi=dc_norm(3,nres+i)
2084 c dsci_inv=dsc_inv(itypi)
2085 dsci_inv=vbld_inv(i+nres)
2087 C Calculate SC interaction energy.
2089 do iint=1,nint_gr(i)
2090 do j=istart(i,iint),iend(i,iint)
2092 itypj=iabs(itype(j))
2093 if (itypj.eq.ntyp1) cycle
2094 c dscj_inv=dsc_inv(itypj)
2095 dscj_inv=vbld_inv(j+nres)
2096 sig0ij=sigma(itypi,itypj)
2097 r0ij=r0(itypi,itypj)
2098 chi1=chi(itypi,itypj)
2099 chi2=chi(itypj,itypi)
2106 alf12=0.5D0*(alf1+alf2)
2107 C For diagnostics only!!!
2121 if (xj.lt.0) xj=xj+boxxsize
2123 if (yj.lt.0) yj=yj+boxysize
2125 if (zj.lt.0) zj=zj+boxzsize
2126 if ((zj.gt.bordlipbot)
2127 &.and.(zj.lt.bordliptop)) then
2128 C the energy transfer exist
2129 if (zj.lt.buflipbot) then
2130 C what fraction I am in
2132 & ((zj-bordlipbot)/lipbufthick)
2133 C lipbufthick is thickenes of lipid buffore
2134 sslipj=sscalelip(fracinbuf)
2135 ssgradlipj=-sscagradlip(fracinbuf)/lipbufthick
2136 elseif (zj.gt.bufliptop) then
2137 fracinbuf=1.0d0-((bordliptop-zj)/lipbufthick)
2138 sslipj=sscalelip(fracinbuf)
2139 ssgradlipj=sscagradlip(fracinbuf)/lipbufthick
2148 aa=aa_lip(itypi,itypj)*(sslipi+sslipj)/2.0d0
2149 & +aa_aq(itypi,itypj)*(2.0d0-sslipi-sslipj)/2.0d0
2150 bb=bb_lip(itypi,itypj)*(sslipi+sslipj)/2.0d0
2151 & +bb_aq(itypi,itypj)*(2.0d0-sslipi-sslipj)/2.0d0
2152 C if (aa.ne.aa_aq(itypi,itypj)) write(63,'2e10.5')
2153 C &(aa-aa_aq(itypi,itypj)),(bb-bb_aq(itypi,itypj))
2154 C write(iout,*) "tu,", i,j,aa,bb,aa_lip(itypi,itypj),sslipi,sslipj
2155 dist_init=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
2163 xj=xj_safe+xshift*boxxsize
2164 yj=yj_safe+yshift*boxysize
2165 zj=zj_safe+zshift*boxzsize
2166 dist_temp=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
2167 if(dist_temp.lt.dist_init) then
2177 if (subchap.eq.1) then
2186 dxj=dc_norm(1,nres+j)
2187 dyj=dc_norm(2,nres+j)
2188 dzj=dc_norm(3,nres+j)
2189 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
2191 C Calculate angle-dependent terms of energy and contributions to their
2195 sig=sig0ij*dsqrt(sigsq)
2196 rij_shift=1.0D0/rij-sig+r0ij
2197 C I hate to put IF's in the loops, but here don't have another choice!!!!
2198 if (rij_shift.le.0.0D0) then
2203 c---------------------------------------------------------------
2204 rij_shift=1.0D0/rij_shift
2205 fac=rij_shift**expon
2208 evdwij=eps1*eps2rt*eps3rt*(e1+e2)
2209 eps2der=evdwij*eps3rt
2210 eps3der=evdwij*eps2rt
2211 fac_augm=rrij**expon
2212 e_augm=augm(itypi,itypj)*fac_augm
2213 evdwij=evdwij*eps2rt*eps3rt
2214 evdw=evdw+evdwij+e_augm
2216 sigm=dabs(aa/bb)**(1.0D0/6.0D0)
2218 write (iout,'(2(a3,i3,2x),17(0pf7.3))')
2219 & restyp(itypi),i,restyp(itypj),j,
2220 & epsi,sigm,sig,(augm(itypi,itypj)/epsi)**(1.0D0/12.0D0),
2221 & chi1,chi2,chip1,chip2,
2222 & eps1,eps2rt**2,eps3rt**2,
2223 & om1,om2,om12,1.0D0/rij,1.0D0/rij_shift,
2226 C Calculate gradient components.
2227 e1=e1*eps1*eps2rt**2*eps3rt**2
2228 fac=-expon*(e1+evdwij)*rij_shift
2230 fac=rij*fac-2*expon*rrij*e_augm
2231 fac=fac+evdwij/sss*sssgrad/sigma(itypi,itypj)*rij
2232 C Calculate the radial part of the gradient
2236 C Calculate angular part of the gradient.
2242 C-----------------------------------------------------------------------------
2243 subroutine sc_angular
2244 C Calculate eps1,eps2,eps3,sigma, and parts of their derivatives in om1,om2,
2245 C om12. Called by ebp, egb, and egbv.
2247 include 'COMMON.CALC'
2248 include 'COMMON.IOUNITS'
2252 om1=dxi*erij(1)+dyi*erij(2)+dzi*erij(3)
2253 om2=dxj*erij(1)+dyj*erij(2)+dzj*erij(3)
2254 om12=dxi*dxj+dyi*dyj+dzi*dzj
2256 C Calculate eps1(om12) and its derivative in om12
2257 faceps1=1.0D0-om12*chiom12
2258 faceps1_inv=1.0D0/faceps1
2259 eps1=dsqrt(faceps1_inv)
2260 C Following variable is eps1*deps1/dom12
2261 eps1_om12=faceps1_inv*chiom12
2266 c write (iout,*) "om12",om12," eps1",eps1
2267 C Calculate sigma(om1,om2,om12) and the derivatives of sigma**2 in om1,om2,
2272 facsig=om1*chiom1+om2*chiom2-2.0D0*om1om2*chiom12
2273 sigsq=1.0D0-facsig*faceps1_inv
2274 sigsq_om1=(chiom1-chiom12*om2)*faceps1_inv
2275 sigsq_om2=(chiom2-chiom12*om1)*faceps1_inv
2276 sigsq_om12=-chi12*(om1om2*faceps1-om12*facsig)*faceps1_inv**2
2282 c write (iout,*) "chiom1",chiom1," chiom2",chiom2," chiom12",chiom12
2283 c write (iout,*) "faceps1",faceps1," faceps1_inv",faceps1_inv,
2285 C Calculate eps2 and its derivatives in om1, om2, and om12.
2288 chipom12=chip12*om12
2289 facp=1.0D0-om12*chipom12
2291 facp1=om1*chipom1+om2*chipom2-2.0D0*om1om2*chipom12
2292 c write (iout,*) "chipom1",chipom1," chipom2",chipom2,
2293 c & " chipom12",chipom12," facp",facp," facp_inv",facp_inv
2294 C Following variable is the square root of eps2
2295 eps2rt=1.0D0-facp1*facp_inv
2296 C Following three variables are the derivatives of the square root of eps
2297 C in om1, om2, and om12.
2298 eps2rt_om1=-4.0D0*(chipom1-chipom12*om2)*facp_inv
2299 eps2rt_om2=-4.0D0*(chipom2-chipom12*om1)*facp_inv
2300 eps2rt_om12=4.0D0*chip12*(om1om2*facp-om12*facp1)*facp_inv**2
2301 C Evaluate the "asymmetric" factor in the VDW constant, eps3
2302 eps3rt=1.0D0-alf1*om1+alf2*om2-alf12*om12
2303 c write (iout,*) "eps2rt",eps2rt," eps3rt",eps3rt
2304 c write (iout,*) "eps2rt_om1",eps2rt_om1," eps2rt_om2",eps2rt_om2,
2305 c & " eps2rt_om12",eps2rt_om12
2306 C Calculate whole angle-dependent part of epsilon and contributions
2307 C to its derivatives
2310 C----------------------------------------------------------------------------
2312 implicit real*8 (a-h,o-z)
2313 include 'DIMENSIONS'
2314 include 'COMMON.CHAIN'
2315 include 'COMMON.DERIV'
2316 include 'COMMON.CALC'
2317 include 'COMMON.IOUNITS'
2318 double precision dcosom1(3),dcosom2(3)
2319 cc print *,'sss=',sss
2320 eom1=eps2der*eps2rt_om1-2.0D0*alf1*eps3der+sigder*sigsq_om1
2321 eom2=eps2der*eps2rt_om2+2.0D0*alf2*eps3der+sigder*sigsq_om2
2322 eom12=evdwij*eps1_om12+eps2der*eps2rt_om12
2323 & -2.0D0*alf12*eps3der+sigder*sigsq_om12
2327 c eom12=evdwij*eps1_om12
2329 c write (iout,*) "eps2der",eps2der," eps3der",eps3der,
2330 c & " sigder",sigder
2331 c write (iout,*) "eps1_om12",eps1_om12," eps2rt_om12",eps2rt_om12
2332 c write (iout,*) "eom1",eom1," eom2",eom2," eom12",eom12
2334 dcosom1(k)=rij*(dc_norm(k,nres+i)-om1*erij(k))
2335 dcosom2(k)=rij*(dc_norm(k,nres+j)-om2*erij(k))
2338 gg(k)=(gg(k)+eom1*dcosom1(k)+eom2*dcosom2(k))*sss
2340 c write (iout,*) "gg",(gg(k),k=1,3)
2342 gvdwx(k,i)=gvdwx(k,i)-gg(k)+gg_lipi(k)
2343 & +(eom12*(dc_norm(k,nres+j)-om12*dc_norm(k,nres+i))
2344 & +eom1*(erij(k)-om1*dc_norm(k,nres+i)))*dsci_inv*sss
2345 gvdwx(k,j)=gvdwx(k,j)+gg(k)+gg_lipj(k)
2346 & +(eom12*(dc_norm(k,nres+i)-om12*dc_norm(k,nres+j))
2347 & +eom2*(erij(k)-om2*dc_norm(k,nres+j)))*dscj_inv*sss
2348 c write (iout,*)(eom12*(dc_norm(k,nres+j)-om12*dc_norm(k,nres+i))
2349 c & +eom1*(erij(k)-om1*dc_norm(k,nres+i)))*dsci_inv
2350 c write (iout,*)(eom12*(dc_norm(k,nres+i)-om12*dc_norm(k,nres+j))
2351 c & +eom2*(erij(k)-om2*dc_norm(k,nres+j)))*dscj_inv
2354 C Calculate the components of the gradient in DC and X
2358 cgrad gvdwc(l,k)=gvdwc(l,k)+gg(l)
2362 gvdwc(l,i)=gvdwc(l,i)-gg(l)+gg_lipi(l)
2363 gvdwc(l,j)=gvdwc(l,j)+gg(l)+gg_lipj(l)
2367 C-----------------------------------------------------------------------
2368 subroutine e_softsphere(evdw)
2370 C This subroutine calculates the interaction energy of nonbonded side chains
2371 C assuming the LJ potential of interaction.
2373 implicit real*8 (a-h,o-z)
2374 include 'DIMENSIONS'
2375 parameter (accur=1.0d-10)
2376 include 'COMMON.GEO'
2377 include 'COMMON.VAR'
2378 include 'COMMON.LOCAL'
2379 include 'COMMON.CHAIN'
2380 include 'COMMON.DERIV'
2381 include 'COMMON.INTERACT'
2382 include 'COMMON.TORSION'
2383 include 'COMMON.SBRIDGE'
2384 include 'COMMON.NAMES'
2385 include 'COMMON.IOUNITS'
2386 include 'COMMON.CONTACTS'
2388 cd print *,'Entering Esoft_sphere nnt=',nnt,' nct=',nct
2390 do i=iatsc_s,iatsc_e
2391 itypi=iabs(itype(i))
2392 if (itypi.eq.ntyp1) cycle
2393 itypi1=iabs(itype(i+1))
2398 C Calculate SC interaction energy.
2400 do iint=1,nint_gr(i)
2401 cd write (iout,*) 'i=',i,' iint=',iint,' istart=',istart(i,iint),
2402 cd & 'iend=',iend(i,iint)
2403 do j=istart(i,iint),iend(i,iint)
2404 itypj=iabs(itype(j))
2405 if (itypj.eq.ntyp1) cycle
2409 rij=xj*xj+yj*yj+zj*zj
2410 c write (iout,*)'i=',i,' j=',j,' itypi=',itypi,' itypj=',itypj
2411 r0ij=r0(itypi,itypj)
2413 c print *,i,j,r0ij,dsqrt(rij)
2414 if (rij.lt.r0ijsq) then
2415 evdwij=0.25d0*(rij-r0ijsq)**2
2423 C Calculate the components of the gradient in DC and X
2429 gvdwx(k,i)=gvdwx(k,i)-gg(k)
2430 gvdwx(k,j)=gvdwx(k,j)+gg(k)
2431 gvdwc(k,i)=gvdwc(k,i)-gg(k)
2432 gvdwc(k,j)=gvdwc(k,j)+gg(k)
2436 cgrad gvdwc(l,k)=gvdwc(l,k)+gg(l)
2444 C--------------------------------------------------------------------------
2445 subroutine eelec_soft_sphere(ees,evdw1,eel_loc,eello_turn3,
2448 C Soft-sphere potential of p-p interaction
2450 implicit real*8 (a-h,o-z)
2451 include 'DIMENSIONS'
2452 include 'COMMON.CONTROL'
2453 include 'COMMON.IOUNITS'
2454 include 'COMMON.GEO'
2455 include 'COMMON.VAR'
2456 include 'COMMON.LOCAL'
2457 include 'COMMON.CHAIN'
2458 include 'COMMON.DERIV'
2459 include 'COMMON.INTERACT'
2460 include 'COMMON.CONTACTS'
2461 include 'COMMON.TORSION'
2462 include 'COMMON.VECTORS'
2463 include 'COMMON.FFIELD'
2465 integer xshift,yshift,zshift
2466 C write(iout,*) 'In EELEC_soft_sphere'
2473 do i=iatel_s,iatel_e
2474 if (itype(i).eq.ntyp1 .or. itype(i+1).eq.ntyp1) cycle
2478 xmedi=c(1,i)+0.5d0*dxi
2479 ymedi=c(2,i)+0.5d0*dyi
2480 zmedi=c(3,i)+0.5d0*dzi
2481 xmedi=mod(xmedi,boxxsize)
2482 if (xmedi.lt.0) xmedi=xmedi+boxxsize
2483 ymedi=mod(ymedi,boxysize)
2484 if (ymedi.lt.0) ymedi=ymedi+boxysize
2485 zmedi=mod(zmedi,boxzsize)
2486 if (zmedi.lt.0) zmedi=zmedi+boxzsize
2488 c write (iout,*) 'i',i,' ielstart',ielstart(i),' ielend',ielend(i)
2489 do j=ielstart(i),ielend(i)
2490 if (itype(j).eq.ntyp1 .or. itype(j+1).eq.ntyp1) cycle
2494 if (j.eq.i+2 .and. itelj.eq.2) iteli=2
2495 r0ij=rpp(iteli,itelj)
2504 if (xj.lt.0) xj=xj+boxxsize
2506 if (yj.lt.0) yj=yj+boxysize
2508 if (zj.lt.0) zj=zj+boxzsize
2509 dist_init=(xj-xmedi)**2+(yj-ymedi)**2+(zj-zmedi)**2
2517 xj=xj_safe+xshift*boxxsize
2518 yj=yj_safe+yshift*boxysize
2519 zj=zj_safe+zshift*boxzsize
2520 dist_temp=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
2521 if(dist_temp.lt.dist_init) then
2531 if (isubchap.eq.1) then
2540 rij=xj*xj+yj*yj+zj*zj
2541 sss=sscale(sqrt(rij))
2542 sssgrad=sscagrad(sqrt(rij))
2543 if (rij.lt.r0ijsq) then
2544 evdw1ij=0.25d0*(rij-r0ijsq)**2
2550 evdw1=evdw1+evdw1ij*sss
2552 C Calculate contributions to the Cartesian gradient.
2554 ggg(1)=fac*xj*sssgrad
2555 ggg(2)=fac*yj*sssgrad
2556 ggg(3)=fac*zj*sssgrad
2558 gvdwpp(k,i)=gvdwpp(k,i)-ggg(k)
2559 gvdwpp(k,j)=gvdwpp(k,j)+ggg(k)
2562 * Loop over residues i+1 thru j-1.
2566 cgrad gelc(l,k)=gelc(l,k)+ggg(l)
2571 cgrad do i=nnt,nct-1
2573 cgrad gelc(k,i)=gelc(k,i)+0.5d0*gelc(k,i)
2575 cgrad do j=i+1,nct-1
2577 cgrad gelc(k,i)=gelc(k,i)+gelc(k,j)
2583 c------------------------------------------------------------------------------
2584 subroutine vec_and_deriv
2585 implicit real*8 (a-h,o-z)
2586 include 'DIMENSIONS'
2590 include 'COMMON.IOUNITS'
2591 include 'COMMON.GEO'
2592 include 'COMMON.VAR'
2593 include 'COMMON.LOCAL'
2594 include 'COMMON.CHAIN'
2595 include 'COMMON.VECTORS'
2596 include 'COMMON.SETUP'
2597 include 'COMMON.TIME1'
2598 dimension uyder(3,3,2),uzder(3,3,2),vbld_inv_temp(2)
2599 C Compute the local reference systems. For reference system (i), the
2600 C X-axis points from CA(i) to CA(i+1), the Y axis is in the
2601 C CA(i)-CA(i+1)-CA(i+2) plane, and the Z axis is perpendicular to this plane.
2603 do i=ivec_start,ivec_end
2607 if (i.eq.nres-1) then
2608 C Case of the last full residue
2609 C Compute the Z-axis
2610 call vecpr(dc_norm(1,i),dc_norm(1,i-1),uz(1,i))
2611 costh=dcos(pi-theta(nres))
2612 fac=1.0d0/dsqrt(1.0d0-costh*costh)
2616 C Compute the derivatives of uz
2618 uzder(2,1,1)=-dc_norm(3,i-1)
2619 uzder(3,1,1)= dc_norm(2,i-1)
2620 uzder(1,2,1)= dc_norm(3,i-1)
2622 uzder(3,2,1)=-dc_norm(1,i-1)
2623 uzder(1,3,1)=-dc_norm(2,i-1)
2624 uzder(2,3,1)= dc_norm(1,i-1)
2627 uzder(2,1,2)= dc_norm(3,i)
2628 uzder(3,1,2)=-dc_norm(2,i)
2629 uzder(1,2,2)=-dc_norm(3,i)
2631 uzder(3,2,2)= dc_norm(1,i)
2632 uzder(1,3,2)= dc_norm(2,i)
2633 uzder(2,3,2)=-dc_norm(1,i)
2635 C Compute the Y-axis
2638 uy(k,i)=fac*(dc_norm(k,i-1)-costh*dc_norm(k,i))
2640 C Compute the derivatives of uy
2643 uyder(k,j,1)=2*dc_norm(k,i-1)*dc_norm(j,i)
2644 & -dc_norm(k,i)*dc_norm(j,i-1)
2645 uyder(k,j,2)=-dc_norm(j,i)*dc_norm(k,i)
2647 uyder(j,j,1)=uyder(j,j,1)-costh
2648 uyder(j,j,2)=1.0d0+uyder(j,j,2)
2653 uygrad(l,k,j,i)=uyder(l,k,j)
2654 uzgrad(l,k,j,i)=uzder(l,k,j)
2658 call unormderiv(uy(1,i),uyder(1,1,1),facy,uygrad(1,1,1,i))
2659 call unormderiv(uy(1,i),uyder(1,1,2),facy,uygrad(1,1,2,i))
2660 call unormderiv(uz(1,i),uzder(1,1,1),fac,uzgrad(1,1,1,i))
2661 call unormderiv(uz(1,i),uzder(1,1,2),fac,uzgrad(1,1,2,i))
2664 C Compute the Z-axis
2665 call vecpr(dc_norm(1,i),dc_norm(1,i+1),uz(1,i))
2666 costh=dcos(pi-theta(i+2))
2667 fac=1.0d0/dsqrt(1.0d0-costh*costh)
2671 C Compute the derivatives of uz
2673 uzder(2,1,1)=-dc_norm(3,i+1)
2674 uzder(3,1,1)= dc_norm(2,i+1)
2675 uzder(1,2,1)= dc_norm(3,i+1)
2677 uzder(3,2,1)=-dc_norm(1,i+1)
2678 uzder(1,3,1)=-dc_norm(2,i+1)
2679 uzder(2,3,1)= dc_norm(1,i+1)
2682 uzder(2,1,2)= dc_norm(3,i)
2683 uzder(3,1,2)=-dc_norm(2,i)
2684 uzder(1,2,2)=-dc_norm(3,i)
2686 uzder(3,2,2)= dc_norm(1,i)
2687 uzder(1,3,2)= dc_norm(2,i)
2688 uzder(2,3,2)=-dc_norm(1,i)
2690 C Compute the Y-axis
2693 uy(k,i)=facy*(dc_norm(k,i+1)-costh*dc_norm(k,i))
2695 C Compute the derivatives of uy
2698 uyder(k,j,1)=2*dc_norm(k,i+1)*dc_norm(j,i)
2699 & -dc_norm(k,i)*dc_norm(j,i+1)
2700 uyder(k,j,2)=-dc_norm(j,i)*dc_norm(k,i)
2702 uyder(j,j,1)=uyder(j,j,1)-costh
2703 uyder(j,j,2)=1.0d0+uyder(j,j,2)
2708 uygrad(l,k,j,i)=uyder(l,k,j)
2709 uzgrad(l,k,j,i)=uzder(l,k,j)
2713 call unormderiv(uy(1,i),uyder(1,1,1),facy,uygrad(1,1,1,i))
2714 call unormderiv(uy(1,i),uyder(1,1,2),facy,uygrad(1,1,2,i))
2715 call unormderiv(uz(1,i),uzder(1,1,1),fac,uzgrad(1,1,1,i))
2716 call unormderiv(uz(1,i),uzder(1,1,2),fac,uzgrad(1,1,2,i))
2720 vbld_inv_temp(1)=vbld_inv(i+1)
2721 if (i.lt.nres-1) then
2722 vbld_inv_temp(2)=vbld_inv(i+2)
2724 vbld_inv_temp(2)=vbld_inv(i)
2729 uygrad(l,k,j,i)=vbld_inv_temp(j)*uygrad(l,k,j,i)
2730 uzgrad(l,k,j,i)=vbld_inv_temp(j)*uzgrad(l,k,j,i)
2735 #if defined(PARVEC) && defined(MPI)
2736 if (nfgtasks1.gt.1) then
2738 c print *,"Processor",fg_rank1,kolor1," ivec_start",ivec_start,
2739 c & " ivec_displ",(ivec_displ(i),i=0,nfgtasks1-1),
2740 c & " ivec_count",(ivec_count(i),i=0,nfgtasks1-1)
2741 call MPI_Allgatherv(uy(1,ivec_start),ivec_count(fg_rank1),
2742 & MPI_UYZ,uy(1,1),ivec_count(0),ivec_displ(0),MPI_UYZ,
2744 call MPI_Allgatherv(uz(1,ivec_start),ivec_count(fg_rank1),
2745 & MPI_UYZ,uz(1,1),ivec_count(0),ivec_displ(0),MPI_UYZ,
2747 call MPI_Allgatherv(uygrad(1,1,1,ivec_start),
2748 & ivec_count(fg_rank1),MPI_UYZGRAD,uygrad(1,1,1,1),ivec_count(0),
2749 & ivec_displ(0),MPI_UYZGRAD,FG_COMM1,IERR)
2750 call MPI_Allgatherv(uzgrad(1,1,1,ivec_start),
2751 & ivec_count(fg_rank1),MPI_UYZGRAD,uzgrad(1,1,1,1),ivec_count(0),
2752 & ivec_displ(0),MPI_UYZGRAD,FG_COMM1,IERR)
2753 time_gather=time_gather+MPI_Wtime()-time00
2757 if (fg_rank.eq.0) then
2758 write (iout,*) "Arrays UY and UZ"
2760 write (iout,'(i5,3f10.5,5x,3f10.5)') i,(uy(k,i),k=1,3),
2767 C-----------------------------------------------------------------------------
2768 subroutine check_vecgrad
2769 implicit real*8 (a-h,o-z)
2770 include 'DIMENSIONS'
2771 include 'COMMON.IOUNITS'
2772 include 'COMMON.GEO'
2773 include 'COMMON.VAR'
2774 include 'COMMON.LOCAL'
2775 include 'COMMON.CHAIN'
2776 include 'COMMON.VECTORS'
2777 dimension uygradt(3,3,2,maxres),uzgradt(3,3,2,maxres)
2778 dimension uyt(3,maxres),uzt(3,maxres)
2779 dimension uygradn(3,3,2),uzgradn(3,3,2),erij(3)
2780 double precision delta /1.0d-7/
2783 crc write(iout,'(2i5,2(3f10.5,5x))') i,1,dc_norm(:,i)
2784 crc write(iout,'(2i5,2(3f10.5,5x))') i,2,uy(:,i)
2785 crc write(iout,'(2i5,2(3f10.5,5x)/)')i,3,uz(:,i)
2786 cd write(iout,'(2i5,2(3f10.5,5x))') i,1,
2787 cd & (dc_norm(if90,i),if90=1,3)
2788 cd write(iout,'(2i5,2(3f10.5,5x))') i,2,(uy(if90,i),if90=1,3)
2789 cd write(iout,'(2i5,2(3f10.5,5x)/)')i,3,(uz(if90,i),if90=1,3)
2790 cd write(iout,'(a)')
2796 uygradt(l,k,j,i)=uygrad(l,k,j,i)
2797 uzgradt(l,k,j,i)=uzgrad(l,k,j,i)
2810 cd write (iout,*) 'i=',i
2812 erij(k)=dc_norm(k,i)
2816 dc_norm(k,i)=erij(k)
2818 dc_norm(j,i)=dc_norm(j,i)+delta
2819 c fac=dsqrt(scalar(dc_norm(1,i),dc_norm(1,i)))
2821 c dc_norm(k,i)=dc_norm(k,i)/fac
2823 c write (iout,*) (dc_norm(k,i),k=1,3)
2824 c write (iout,*) (erij(k),k=1,3)
2827 uygradn(k,j,1)=(uy(k,i)-uyt(k,i))/delta
2828 uygradn(k,j,2)=(uy(k,i-1)-uyt(k,i-1))/delta
2829 uzgradn(k,j,1)=(uz(k,i)-uzt(k,i))/delta
2830 uzgradn(k,j,2)=(uz(k,i-1)-uzt(k,i-1))/delta
2832 c write (iout,'(i5,3f8.5,3x,3f8.5,5x,3f8.5,3x,3f8.5)')
2833 c & j,(uzgradt(k,j,1,i),k=1,3),(uzgradn(k,j,1),k=1,3),
2834 c & (uzgradt(k,j,2,i-1),k=1,3),(uzgradn(k,j,2),k=1,3)
2837 dc_norm(k,i)=erij(k)
2840 cd write (iout,'(i5,3f8.5,3x,3f8.5,5x,3f8.5,3x,3f8.5)')
2841 cd & k,(uygradt(k,l,1,i),l=1,3),(uygradn(k,l,1),l=1,3),
2842 cd & (uygradt(k,l,2,i-1),l=1,3),(uygradn(k,l,2),l=1,3)
2843 cd write (iout,'(i5,3f8.5,3x,3f8.5,5x,3f8.5,3x,3f8.5)')
2844 cd & k,(uzgradt(k,l,1,i),l=1,3),(uzgradn(k,l,1),l=1,3),
2845 cd & (uzgradt(k,l,2,i-1),l=1,3),(uzgradn(k,l,2),l=1,3)
2846 cd write (iout,'(a)')
2851 C--------------------------------------------------------------------------
2852 subroutine set_matrices
2853 implicit real*8 (a-h,o-z)
2854 include 'DIMENSIONS'
2857 include "COMMON.SETUP"
2859 integer status(MPI_STATUS_SIZE)
2861 include 'COMMON.IOUNITS'
2862 include 'COMMON.GEO'
2863 include 'COMMON.VAR'
2864 include 'COMMON.LOCAL'
2865 include 'COMMON.CHAIN'
2866 include 'COMMON.DERIV'
2867 include 'COMMON.INTERACT'
2868 include 'COMMON.CONTACTS'
2869 include 'COMMON.TORSION'
2870 include 'COMMON.VECTORS'
2871 include 'COMMON.FFIELD'
2872 double precision auxvec(2),auxmat(2,2)
2874 C Compute the virtual-bond-torsional-angle dependent quantities needed
2875 C to calculate the el-loc multibody terms of various order.
2877 c write(iout,*) 'nphi=',nphi,nres
2878 c write(iout,*) "itype2loc",itype2loc
2880 do i=ivec_start+2,ivec_end+2
2884 if (i.gt. nnt+2 .and. i.lt.nct+2) then
2885 iti = itype2loc(itype(i-2))
2889 c if (i.gt. iatel_s+1 .and. i.lt.iatel_e+4) then
2890 if (i.gt. nnt+1 .and. i.lt.nct+1) then
2891 iti1 = itype2loc(itype(i-1))
2897 cost1=dcos(theta(i-1))
2898 sint1=dsin(theta(i-1))
2900 sint1cub=sint1sq*sint1
2901 sint1cost1=2*sint1*cost1
2902 c write (iout,*) "bnew1",i,iti
2903 c write (iout,*) (bnew1(k,1,iti),k=1,3)
2904 c write (iout,*) (bnew1(k,2,iti),k=1,3)
2905 c write (iout,*) "bnew2",i,iti
2906 c write (iout,*) (bnew2(k,1,iti),k=1,3)
2907 c write (iout,*) (bnew2(k,2,iti),k=1,3)
2909 b1k=bnew1(1,k,iti)+(bnew1(2,k,iti)+bnew1(3,k,iti)*cost1)*cost1
2911 gtb1(k,i-2)=cost1*b1k-sint1sq*
2912 & (bnew1(2,k,iti)+2*bnew1(3,k,iti)*cost1)
2913 b2k=bnew2(1,k,iti)+(bnew2(2,k,iti)+bnew2(3,k,iti)*cost1)*cost1
2915 gtb2(k,i-2)=cost1*b2k-sint1sq*
2916 & (bnew2(2,k,iti)+2*bnew2(3,k,iti)*cost1)
2919 aux=ccnew(1,k,iti)+(ccnew(2,k,iti)+ccnew(3,k,iti)*cost1)*cost1
2920 cc(1,k,i-2)=sint1sq*aux
2921 gtcc(1,k,i-2)=sint1cost1*aux-sint1cub*
2922 & (ccnew(2,k,iti)+2*ccnew(3,k,iti)*cost1)
2923 aux=ddnew(1,k,iti)+(ddnew(2,k,iti)+ddnew(3,k,iti)*cost1)*cost1
2924 dd(1,k,i-2)=sint1sq*aux
2925 gtdd(1,k,i-2)=sint1cost1*aux-sint1cub*
2926 & (ddnew(2,k,iti)+2*ddnew(3,k,iti)*cost1)
2928 cc(2,1,i-2)=cc(1,2,i-2)
2929 cc(2,2,i-2)=-cc(1,1,i-2)
2930 gtcc(2,1,i-2)=gtcc(1,2,i-2)
2931 gtcc(2,2,i-2)=-gtcc(1,1,i-2)
2932 dd(2,1,i-2)=dd(1,2,i-2)
2933 dd(2,2,i-2)=-dd(1,1,i-2)
2934 gtdd(2,1,i-2)=gtdd(1,2,i-2)
2935 gtdd(2,2,i-2)=-gtdd(1,1,i-2)
2938 aux=eenew(1,l,k,iti)+eenew(2,l,k,iti)*cost1
2939 EE(l,k,i-2)=sint1sq*aux
2940 gtEE(l,k,i-2)=sint1cost1*aux-sint1cub*eenew(2,l,k,iti)
2943 EE(1,1,i-2)=EE(1,1,i-2)+e0new(1,iti)*cost1
2944 EE(1,2,i-2)=EE(1,2,i-2)+e0new(2,iti)+e0new(3,iti)*cost1
2945 EE(2,1,i-2)=EE(2,1,i-2)+e0new(2,iti)*cost1+e0new(3,iti)
2946 EE(2,2,i-2)=EE(2,2,i-2)-e0new(1,iti)
2947 gtEE(1,1,i-2)=gtEE(1,1,i-2)-e0new(1,iti)*sint1
2948 gtEE(1,2,i-2)=gtEE(1,2,i-2)-e0new(3,iti)*sint1
2949 gtEE(2,1,i-2)=gtEE(2,1,i-2)-e0new(2,iti)*sint1
2950 c b1tilde(1,i-2)=b1(1,i-2)
2951 c b1tilde(2,i-2)=-b1(2,i-2)
2952 c b2tilde(1,i-2)=b2(1,i-2)
2953 c b2tilde(2,i-2)=-b2(2,i-2)
2955 write (iout,*) 'i=',i-2,gtb1(2,i-2),gtb1(1,i-2)
2956 write(iout,*) 'b1=',(b1(k,i-2),k=1,2)
2957 write(iout,*) 'b2=',(b2(k,i-2),k=1,2)
2958 write (iout,*) 'theta=', theta(i-1)
2961 if (i.gt. nnt+2 .and. i.lt.nct+2) then
2962 iti = itype2loc(itype(i-2))
2966 c write (iout,*) "i",i-1," itype",itype(i-2)," iti",iti
2967 c if (i.gt. iatel_s+1 .and. i.lt.iatel_e+4) then
2968 if (i.gt. nnt+1 .and. i.lt.nct+1) then
2969 iti1 = itype2loc(itype(i-1))
2979 CC(k,l,i-2)=ccold(k,l,iti)
2980 DD(k,l,i-2)=ddold(k,l,iti)
2981 EE(k,l,i-2)=eeold(k,l,iti)
2985 b1tilde(1,i-2)= b1(1,i-2)
2986 b1tilde(2,i-2)=-b1(2,i-2)
2987 b2tilde(1,i-2)= b2(1,i-2)
2988 b2tilde(2,i-2)=-b2(2,i-2)
2990 Ctilde(1,1,i-2)= CC(1,1,i-2)
2991 Ctilde(1,2,i-2)= CC(1,2,i-2)
2992 Ctilde(2,1,i-2)=-CC(2,1,i-2)
2993 Ctilde(2,2,i-2)=-CC(2,2,i-2)
2995 Dtilde(1,1,i-2)= DD(1,1,i-2)
2996 Dtilde(1,2,i-2)= DD(1,2,i-2)
2997 Dtilde(2,1,i-2)=-DD(2,1,i-2)
2998 Dtilde(2,2,i-2)=-DD(2,2,i-2)
3000 write(iout,*) "i",i," iti",iti
3001 write(iout,*) 'b1=',(b1(k,i-2),k=1,2)
3002 write(iout,*) 'b2=',(b2(k,i-2),k=1,2)
3006 do i=ivec_start+2,ivec_end+2
3010 if (i .lt. nres+1) then
3047 if (i .gt. 3 .and. i .lt. nres+1) then
3048 obrot_der(1,i-2)=-sin1
3049 obrot_der(2,i-2)= cos1
3050 Ugder(1,1,i-2)= sin1
3051 Ugder(1,2,i-2)=-cos1
3052 Ugder(2,1,i-2)=-cos1
3053 Ugder(2,2,i-2)=-sin1
3056 obrot2_der(1,i-2)=-dwasin2
3057 obrot2_der(2,i-2)= dwacos2
3058 Ug2der(1,1,i-2)= dwasin2
3059 Ug2der(1,2,i-2)=-dwacos2
3060 Ug2der(2,1,i-2)=-dwacos2
3061 Ug2der(2,2,i-2)=-dwasin2
3063 obrot_der(1,i-2)=0.0d0
3064 obrot_der(2,i-2)=0.0d0
3065 Ugder(1,1,i-2)=0.0d0
3066 Ugder(1,2,i-2)=0.0d0
3067 Ugder(2,1,i-2)=0.0d0
3068 Ugder(2,2,i-2)=0.0d0
3069 obrot2_der(1,i-2)=0.0d0
3070 obrot2_der(2,i-2)=0.0d0
3071 Ug2der(1,1,i-2)=0.0d0
3072 Ug2der(1,2,i-2)=0.0d0
3073 Ug2der(2,1,i-2)=0.0d0
3074 Ug2der(2,2,i-2)=0.0d0
3076 c if (i.gt. iatel_s+2 .and. i.lt.iatel_e+5) then
3077 if (i.gt. nnt+2 .and. i.lt.nct+2) then
3078 iti = itype2loc(itype(i-2))
3082 c if (i.gt. iatel_s+1 .and. i.lt.iatel_e+4) then
3083 if (i.gt. nnt+1 .and. i.lt.nct+1) then
3084 iti1 = itype2loc(itype(i-1))
3088 cd write (iout,*) '*******i',i,' iti1',iti
3089 cd write (iout,*) 'b1',b1(:,iti)
3090 cd write (iout,*) 'b2',b2(:,iti)
3091 cd write (iout,*) 'Ug',Ug(:,:,i-2)
3092 c if (i .gt. iatel_s+2) then
3093 if (i .gt. nnt+2) then
3094 call matvec2(Ug(1,1,i-2),b2(1,i-2),Ub2(1,i-2))
3096 call matvec2(Ug(1,1,i-2),gtb2(1,i-2),gUb2(1,i-2))
3097 c write (iout,*) Ug(1,1,i-2),gtb2(1,i-2),gUb2(1,i-2),"chuj"
3099 c write(iout,*) "co jest kurwa", iti, EE(1,1,i),EE(2,1,i),
3100 c & EE(1,2,iti),EE(2,2,i)
3101 call matmat2(EE(1,1,i-2),Ug(1,1,i-2),EUg(1,1,i-2))
3102 call matmat2(gtEE(1,1,i-2),Ug(1,1,i-2),gtEUg(1,1,i-2))
3103 c write(iout,*) "Macierz EUG",
3104 c & eug(1,1,i-2),eug(1,2,i-2),eug(2,1,i-2),
3106 if (wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 .or. wcorr6.gt.0.0d0)
3108 call matmat2(CC(1,1,i-2),Ug(1,1,i-2),CUg(1,1,i-2))
3109 call matmat2(DD(1,1,i-2),Ug(1,1,i-2),DUg(1,1,i-2))
3110 call matmat2(Dtilde(1,1,i-2),Ug2(1,1,i-2),DtUg2(1,1,i-2))
3111 call matvec2(Ctilde(1,1,i-1),obrot(1,i-2),Ctobr(1,i-2))
3112 call matvec2(Dtilde(1,1,i-2),obrot2(1,i-2),Dtobr2(1,i-2))
3123 DtUg2(l,k,i-2)=0.0d0
3127 call matvec2(Ugder(1,1,i-2),b2(1,i-2),Ub2der(1,i-2))
3128 call matmat2(EE(1,1,i-2),Ugder(1,1,i-2),EUgder(1,1,i-2))
3130 muder(k,i-2)=Ub2der(k,i-2)
3132 c if (i.gt. iatel_s+1 .and. i.lt.iatel_e+4) then
3133 if (i.gt. nnt+1 .and. i.lt.nct+1) then
3134 if (itype(i-1).le.ntyp) then
3135 iti1 = itype2loc(itype(i-1))
3143 mu(k,i-2)=Ub2(k,i-2)+b1(k,i-1)
3144 c mu(k,i-2)=b1(k,i-1)
3145 c mu(k,i-2)=Ub2(k,i-2)
3148 write (iout,'(2hmu,i3,3f8.1,12f10.5)') i-2,rad2deg*theta(i-1),
3149 & rad2deg*theta(i),rad2deg*phi(i),mu(1,i-2),mu(2,i-2),
3150 & -b2(1,i-2),b2(2,i-2),b1(1,i-2),b1(2,i-2),
3151 & dsqrt(b2(1,i-1)**2+b2(2,i-1)**2)
3152 & +dsqrt(b1(1,i-1)**2+b1(2,i-1)**2),
3153 & ((ee(l,k,i-2),l=1,2),k=1,2)
3155 cd write (iout,*) 'mu1',mu1(:,i-2)
3156 cd write (iout,*) 'mu2',mu2(:,i-2)
3157 cd write (iout,*) 'mu',i-2,mu(:,i-2)
3158 if (wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 .or.wcorr6.gt.0.0d0)
3160 call matmat2(CC(1,1,i-1),Ugder(1,1,i-2),CUgder(1,1,i-2))
3161 call matmat2(DD(1,1,i-2),Ugder(1,1,i-2),DUgder(1,1,i-2))
3162 call matmat2(Dtilde(1,1,i-2),Ug2der(1,1,i-2),DtUg2der(1,1,i-2))
3163 call matvec2(Ctilde(1,1,i-1),obrot_der(1,i-2),Ctobrder(1,i-2))
3164 call matvec2(Dtilde(1,1,i-2),obrot2_der(1,i-2),Dtobr2der(1,i-2))
3165 C Vectors and matrices dependent on a single virtual-bond dihedral.
3166 call matvec2(DD(1,1,i-2),b1tilde(1,i-1),auxvec(1))
3167 call matvec2(Ug2(1,1,i-2),auxvec(1),Ug2Db1t(1,i-2))
3168 call matvec2(Ug2der(1,1,i-2),auxvec(1),Ug2Db1tder(1,i-2))
3169 call matvec2(CC(1,1,i-1),Ub2(1,i-2),CUgb2(1,i-2))
3170 call matvec2(CC(1,1,i-1),Ub2der(1,i-2),CUgb2der(1,i-2))
3171 call matmat2(EUg(1,1,i-2),CC(1,1,i-1),EUgC(1,1,i-2))
3172 call matmat2(EUgder(1,1,i-2),CC(1,1,i-1),EUgCder(1,1,i-2))
3173 call matmat2(EUg(1,1,i-2),DD(1,1,i-1),EUgD(1,1,i-2))
3174 call matmat2(EUgder(1,1,i-2),DD(1,1,i-1),EUgDder(1,1,i-2))
3177 C Matrices dependent on two consecutive virtual-bond dihedrals.
3178 C The order of matrices is from left to right.
3179 if (wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 .or.wcorr6.gt.0.0d0)
3181 c do i=max0(ivec_start,2),ivec_end
3183 call matmat2(DtUg2(1,1,i-1),EUg(1,1,i),DtUg2EUg(1,1,i))
3184 call matmat2(DtUg2der(1,1,i-1),EUg(1,1,i),DtUg2EUgder(1,1,1,i))
3185 call matmat2(DtUg2(1,1,i-1),EUgder(1,1,i),DtUg2EUgder(1,1,2,i))
3186 call transpose2(DtUg2(1,1,i-1),auxmat(1,1))
3187 call matmat2(auxmat(1,1),EUg(1,1,i),Ug2DtEUg(1,1,i))
3188 call matmat2(auxmat(1,1),EUgder(1,1,i),Ug2DtEUgder(1,1,2,i))
3189 call transpose2(DtUg2der(1,1,i-1),auxmat(1,1))
3190 call matmat2(auxmat(1,1),EUg(1,1,i),Ug2DtEUgder(1,1,1,i))
3193 #if defined(MPI) && defined(PARMAT)
3195 c if (fg_rank.eq.0) then
3196 write (iout,*) "Arrays UG and UGDER before GATHER"
3198 write (iout,'(i5,4f10.5,5x,4f10.5)') i,
3199 & ((ug(l,k,i),l=1,2),k=1,2),
3200 & ((ugder(l,k,i),l=1,2),k=1,2)
3202 write (iout,*) "Arrays UG2 and UG2DER"
3204 write (iout,'(i5,4f10.5,5x,4f10.5)') i,
3205 & ((ug2(l,k,i),l=1,2),k=1,2),
3206 & ((ug2der(l,k,i),l=1,2),k=1,2)
3208 write (iout,*) "Arrays OBROT OBROT2 OBROTDER and OBROT2DER"
3210 write (iout,'(i5,4f10.5,5x,4f10.5)') i,
3211 & (obrot(k,i),k=1,2),(obrot2(k,i),k=1,2),
3212 & (obrot_der(k,i),k=1,2),(obrot2_der(k,i),k=1,2)
3214 write (iout,*) "Arrays COSTAB SINTAB COSTAB2 and SINTAB2"
3216 write (iout,'(i5,4f10.5,5x,4f10.5)') i,
3217 & costab(i),sintab(i),costab2(i),sintab2(i)
3219 write (iout,*) "Array MUDER"
3221 write (iout,'(i5,2f10.5)') i,muder(1,i),muder(2,i)
3225 if (nfgtasks.gt.1) then
3227 c write(iout,*)"Processor",fg_rank,kolor," ivec_start",ivec_start,
3228 c & " ivec_displ",(ivec_displ(i),i=0,nfgtasks-1),
3229 c & " ivec_count",(ivec_count(i),i=0,nfgtasks-1)
3231 call MPI_Allgatherv(Ub2(1,ivec_start),ivec_count(fg_rank1),
3232 & MPI_MU,Ub2(1,1),ivec_count(0),ivec_displ(0),MPI_MU,
3234 call MPI_Allgatherv(Ub2der(1,ivec_start),ivec_count(fg_rank1),
3235 & MPI_MU,Ub2der(1,1),ivec_count(0),ivec_displ(0),MPI_MU,
3237 call MPI_Allgatherv(mu(1,ivec_start),ivec_count(fg_rank1),
3238 & MPI_MU,mu(1,1),ivec_count(0),ivec_displ(0),MPI_MU,
3240 call MPI_Allgatherv(muder(1,ivec_start),ivec_count(fg_rank1),
3241 & MPI_MU,muder(1,1),ivec_count(0),ivec_displ(0),MPI_MU,
3243 call MPI_Allgatherv(Eug(1,1,ivec_start),ivec_count(fg_rank1),
3244 & MPI_MAT1,Eug(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,
3246 call MPI_Allgatherv(Eugder(1,1,ivec_start),ivec_count(fg_rank1),
3247 & MPI_MAT1,Eugder(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,
3249 call MPI_Allgatherv(costab(ivec_start),ivec_count(fg_rank1),
3250 & MPI_DOUBLE_PRECISION,costab(1),ivec_count(0),ivec_displ(0),
3251 & MPI_DOUBLE_PRECISION,FG_COMM1,IERR)
3252 call MPI_Allgatherv(sintab(ivec_start),ivec_count(fg_rank1),
3253 & MPI_DOUBLE_PRECISION,sintab(1),ivec_count(0),ivec_displ(0),
3254 & MPI_DOUBLE_PRECISION,FG_COMM1,IERR)
3255 call MPI_Allgatherv(costab2(ivec_start),ivec_count(fg_rank1),
3256 & MPI_DOUBLE_PRECISION,costab2(1),ivec_count(0),ivec_displ(0),
3257 & MPI_DOUBLE_PRECISION,FG_COMM1,IERR)
3258 call MPI_Allgatherv(sintab2(ivec_start),ivec_count(fg_rank1),
3259 & MPI_DOUBLE_PRECISION,sintab2(1),ivec_count(0),ivec_displ(0),
3260 & MPI_DOUBLE_PRECISION,FG_COMM1,IERR)
3261 if (wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 .or. wcorr6.gt.0.0d0)
3263 call MPI_Allgatherv(Ctobr(1,ivec_start),ivec_count(fg_rank1),
3264 & MPI_MU,Ctobr(1,1),ivec_count(0),ivec_displ(0),MPI_MU,
3266 call MPI_Allgatherv(Ctobrder(1,ivec_start),ivec_count(fg_rank1),
3267 & MPI_MU,Ctobrder(1,1),ivec_count(0),ivec_displ(0),MPI_MU,
3269 call MPI_Allgatherv(Dtobr2(1,ivec_start),ivec_count(fg_rank1),
3270 & MPI_MU,Dtobr2(1,1),ivec_count(0),ivec_displ(0),MPI_MU,
3272 call MPI_Allgatherv(Dtobr2der(1,ivec_start),ivec_count(fg_rank1),
3273 & MPI_MU,Dtobr2der(1,1),ivec_count(0),ivec_displ(0),MPI_MU,
3275 call MPI_Allgatherv(Ug2Db1t(1,ivec_start),ivec_count(fg_rank1),
3276 & MPI_MU,Ug2Db1t(1,1),ivec_count(0),ivec_displ(0),MPI_MU,
3278 call MPI_Allgatherv(Ug2Db1tder(1,ivec_start),
3279 & ivec_count(fg_rank1),
3280 & MPI_MU,Ug2Db1tder(1,1),ivec_count(0),ivec_displ(0),MPI_MU,
3282 call MPI_Allgatherv(CUgb2(1,ivec_start),ivec_count(fg_rank1),
3283 & MPI_MU,CUgb2(1,1),ivec_count(0),ivec_displ(0),MPI_MU,
3285 call MPI_Allgatherv(CUgb2der(1,ivec_start),ivec_count(fg_rank1),
3286 & MPI_MU,CUgb2der(1,1),ivec_count(0),ivec_displ(0),MPI_MU,
3288 call MPI_Allgatherv(Cug(1,1,ivec_start),ivec_count(fg_rank1),
3289 & MPI_MAT1,Cug(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,
3291 call MPI_Allgatherv(Cugder(1,1,ivec_start),ivec_count(fg_rank1),
3292 & MPI_MAT1,Cugder(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,
3294 call MPI_Allgatherv(Dug(1,1,ivec_start),ivec_count(fg_rank1),
3295 & MPI_MAT1,Dug(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,
3297 call MPI_Allgatherv(Dugder(1,1,ivec_start),ivec_count(fg_rank1),
3298 & MPI_MAT1,Dugder(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,
3300 call MPI_Allgatherv(Dtug2(1,1,ivec_start),ivec_count(fg_rank1),
3301 & MPI_MAT1,Dtug2(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,
3303 call MPI_Allgatherv(Dtug2der(1,1,ivec_start),
3304 & ivec_count(fg_rank1),
3305 & MPI_MAT1,Dtug2der(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,
3307 call MPI_Allgatherv(EugC(1,1,ivec_start),ivec_count(fg_rank1),
3308 & MPI_MAT1,EugC(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,
3310 call MPI_Allgatherv(EugCder(1,1,ivec_start),ivec_count(fg_rank1),
3311 & MPI_MAT1,EugCder(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,
3313 call MPI_Allgatherv(EugD(1,1,ivec_start),ivec_count(fg_rank1),
3314 & MPI_MAT1,EugD(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,
3316 call MPI_Allgatherv(EugDder(1,1,ivec_start),ivec_count(fg_rank1),
3317 & MPI_MAT1,EugDder(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,
3319 call MPI_Allgatherv(DtUg2EUg(1,1,ivec_start),
3320 & ivec_count(fg_rank1),
3321 & MPI_MAT1,DtUg2EUg(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,
3323 call MPI_Allgatherv(Ug2DtEUg(1,1,ivec_start),
3324 & ivec_count(fg_rank1),
3325 & MPI_MAT1,Ug2DtEUg(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,
3327 call MPI_Allgatherv(DtUg2EUgder(1,1,1,ivec_start),
3328 & ivec_count(fg_rank1),
3329 & MPI_MAT2,DtUg2EUgder(1,1,1,1),ivec_count(0),ivec_displ(0),
3330 & MPI_MAT2,FG_COMM1,IERR)
3331 call MPI_Allgatherv(Ug2DtEUgder(1,1,1,ivec_start),
3332 & ivec_count(fg_rank1),
3333 & MPI_MAT2,Ug2DtEUgder(1,1,1,1),ivec_count(0),ivec_displ(0),
3334 & MPI_MAT2,FG_COMM1,IERR)
3337 c Passes matrix info through the ring
3340 if (irecv.lt.0) irecv=nfgtasks1-1
3343 if (inext.ge.nfgtasks1) inext=0
3345 c write (iout,*) "isend",isend," irecv",irecv
3347 lensend=lentyp(isend)
3348 lenrecv=lentyp(irecv)
3349 c write (iout,*) "lensend",lensend," lenrecv",lenrecv
3350 c call MPI_SENDRECV(ug(1,1,ivec_displ(isend)+1),1,
3351 c & MPI_ROTAT1(lensend),inext,2200+isend,
3352 c & ug(1,1,ivec_displ(irecv)+1),1,MPI_ROTAT1(lenrecv),
3353 c & iprev,2200+irecv,FG_COMM,status,IERR)
3354 c write (iout,*) "Gather ROTAT1"
3356 c call MPI_SENDRECV(obrot(1,ivec_displ(isend)+1),1,
3357 c & MPI_ROTAT2(lensend),inext,3300+isend,
3358 c & obrot(1,ivec_displ(irecv)+1),1,MPI_ROTAT2(lenrecv),
3359 c & iprev,3300+irecv,FG_COMM,status,IERR)
3360 c write (iout,*) "Gather ROTAT2"
3362 call MPI_SENDRECV(costab(ivec_displ(isend)+1),1,
3363 & MPI_ROTAT_OLD(lensend),inext,4400+isend,
3364 & costab(ivec_displ(irecv)+1),1,MPI_ROTAT_OLD(lenrecv),
3365 & iprev,4400+irecv,FG_COMM,status,IERR)
3366 c write (iout,*) "Gather ROTAT_OLD"
3368 call MPI_SENDRECV(mu(1,ivec_displ(isend)+1),1,
3369 & MPI_PRECOMP11(lensend),inext,5500+isend,
3370 & mu(1,ivec_displ(irecv)+1),1,MPI_PRECOMP11(lenrecv),
3371 & iprev,5500+irecv,FG_COMM,status,IERR)
3372 c write (iout,*) "Gather PRECOMP11"
3374 call MPI_SENDRECV(Eug(1,1,ivec_displ(isend)+1),1,
3375 & MPI_PRECOMP12(lensend),inext,6600+isend,
3376 & Eug(1,1,ivec_displ(irecv)+1),1,MPI_PRECOMP12(lenrecv),
3377 & iprev,6600+irecv,FG_COMM,status,IERR)
3378 c write (iout,*) "Gather PRECOMP12"
3380 if (wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 .or. wcorr6.gt.0.0d0)
3382 call MPI_SENDRECV(ug2db1t(1,ivec_displ(isend)+1),1,
3383 & MPI_ROTAT2(lensend),inext,7700+isend,
3384 & ug2db1t(1,ivec_displ(irecv)+1),1,MPI_ROTAT2(lenrecv),
3385 & iprev,7700+irecv,FG_COMM,status,IERR)
3386 c write (iout,*) "Gather PRECOMP21"
3388 call MPI_SENDRECV(EUgC(1,1,ivec_displ(isend)+1),1,
3389 & MPI_PRECOMP22(lensend),inext,8800+isend,
3390 & EUgC(1,1,ivec_displ(irecv)+1),1,MPI_PRECOMP22(lenrecv),
3391 & iprev,8800+irecv,FG_COMM,status,IERR)
3392 c write (iout,*) "Gather PRECOMP22"
3394 call MPI_SENDRECV(Ug2DtEUgder(1,1,1,ivec_displ(isend)+1),1,
3395 & MPI_PRECOMP23(lensend),inext,9900+isend,
3396 & Ug2DtEUgder(1,1,1,ivec_displ(irecv)+1),1,
3397 & MPI_PRECOMP23(lenrecv),
3398 & iprev,9900+irecv,FG_COMM,status,IERR)
3399 c write (iout,*) "Gather PRECOMP23"
3404 if (irecv.lt.0) irecv=nfgtasks1-1
3407 time_gather=time_gather+MPI_Wtime()-time00
3410 c if (fg_rank.eq.0) then
3411 write (iout,*) "Arrays UG and UGDER"
3413 write (iout,'(i5,4f10.5,5x,4f10.5)') i,
3414 & ((ug(l,k,i),l=1,2),k=1,2),
3415 & ((ugder(l,k,i),l=1,2),k=1,2)
3417 write (iout,*) "Arrays UG2 and UG2DER"
3419 write (iout,'(i5,4f10.5,5x,4f10.5)') i,
3420 & ((ug2(l,k,i),l=1,2),k=1,2),
3421 & ((ug2der(l,k,i),l=1,2),k=1,2)
3423 write (iout,*) "Arrays OBROT OBROT2 OBROTDER and OBROT2DER"
3425 write (iout,'(i5,4f10.5,5x,4f10.5)') i,
3426 & (obrot(k,i),k=1,2),(obrot2(k,i),k=1,2),
3427 & (obrot_der(k,i),k=1,2),(obrot2_der(k,i),k=1,2)
3429 write (iout,*) "Arrays COSTAB SINTAB COSTAB2 and SINTAB2"
3431 write (iout,'(i5,4f10.5,5x,4f10.5)') i,
3432 & costab(i),sintab(i),costab2(i),sintab2(i)
3434 write (iout,*) "Array MUDER"
3436 write (iout,'(i5,2f10.5)') i,muder(1,i),muder(2,i)
3442 cd iti = itype2loc(itype(i))
3445 cd write (iout,'(2f10.5,5x,2f10.5,5x,2f10.5)')
3446 cd & (EE(j,k,i),k=1,2),(Ug(j,k,i),k=1,2),(EUg(j,k,i),k=1,2)
3451 C--------------------------------------------------------------------------
3452 subroutine eelec(ees,evdw1,eel_loc,eello_turn3,eello_turn4)
3454 C This subroutine calculates the average interaction energy and its gradient
3455 C in the virtual-bond vectors between non-adjacent peptide groups, based on
3456 C the potential described in Liwo et al., Protein Sci., 1993, 2, 1715.
3457 C The potential depends both on the distance of peptide-group centers and on
3458 C the orientation of the CA-CA virtual bonds.
3460 implicit real*8 (a-h,o-z)
3464 include 'DIMENSIONS'
3465 include 'COMMON.CONTROL'
3466 include 'COMMON.SETUP'
3467 include 'COMMON.IOUNITS'
3468 include 'COMMON.GEO'
3469 include 'COMMON.VAR'
3470 include 'COMMON.LOCAL'
3471 include 'COMMON.CHAIN'
3472 include 'COMMON.DERIV'
3473 include 'COMMON.INTERACT'
3474 include 'COMMON.CONTACTS'
3475 include 'COMMON.TORSION'
3476 include 'COMMON.VECTORS'
3477 include 'COMMON.FFIELD'
3478 include 'COMMON.TIME1'
3479 include 'COMMON.SPLITELE'
3480 dimension ggg(3),gggp(3),gggm(3),erij(3),dcosb(3),dcosg(3),
3481 & erder(3,3),uryg(3,3),urzg(3,3),vryg(3,3),vrzg(3,3)
3482 double precision acipa(2,2),agg(3,4),aggi(3,4),aggi1(3,4),
3483 & aggj(3,4),aggj1(3,4),a_temp(2,2),muij(4),gmuij(4)
3484 common /locel/ a_temp,agg,aggi,aggi1,aggj,aggj1,a22,a23,a32,a33,
3485 & dxi,dyi,dzi,dx_normi,dy_normi,dz_normi,xmedi,ymedi,zmedi,
3487 c 4/26/02 - AL scaling factor for 1,4 repulsive VDW interactions
3489 double precision scal_el /1.0d0/
3491 double precision scal_el /0.5d0/
3494 C 13-go grudnia roku pamietnego...
3495 double precision unmat(3,3) /1.0d0,0.0d0,0.0d0,
3496 & 0.0d0,1.0d0,0.0d0,
3497 & 0.0d0,0.0d0,1.0d0/
3498 cd write(iout,*) 'In EELEC'
3500 cd write(iout,*) 'Type',i
3501 cd write(iout,*) 'B1',B1(:,i)
3502 cd write(iout,*) 'B2',B2(:,i)
3503 cd write(iout,*) 'CC',CC(:,:,i)
3504 cd write(iout,*) 'DD',DD(:,:,i)
3505 cd write(iout,*) 'EE',EE(:,:,i)
3507 cd call check_vecgrad
3509 if (icheckgrad.eq.1) then
3511 fac=1.0d0/dsqrt(scalar(dc(1,i),dc(1,i)))
3513 dc_norm(k,i)=dc(k,i)*fac
3515 c write (iout,*) 'i',i,' fac',fac
3518 if (wel_loc.gt.0.0d0 .or. wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0
3519 & .or. wcorr6.gt.0.0d0 .or. wturn3.gt.0.0d0 .or.
3520 & wturn4.gt.0.0d0 .or. wturn6.gt.0.0d0) then
3521 c call vec_and_deriv
3527 time_mat=time_mat+MPI_Wtime()-time01
3531 cd write (iout,*) 'i=',i
3533 cd write (iout,'(i5,2f10.5)') k,uy(k,i),uz(k,i)
3536 cd write (iout,'(f10.5,2x,3f10.5,2x,3f10.5)')
3537 cd & uz(k,i),(uzgrad(k,l,1,i),l=1,3),(uzgrad(k,l,2,i),l=1,3)
3550 cd print '(a)','Enter EELEC'
3551 cd write (iout,*) 'iatel_s=',iatel_s,' iatel_e=',iatel_e
3553 gel_loc_loc(i)=0.0d0
3558 c 9/27/08 AL Split the interaction loop to ensure load balancing of turn terms
3560 C Loop over i,i+2 and i,i+3 pairs of the peptide groups
3562 C 14/01/2014 TURN3,TUNR4 does no go under periodic boundry condition
3563 do i=iturn3_start,iturn3_end
3565 C write(iout,*) "tu jest i",i
3566 if (itype(i).eq.ntyp1 .or. itype(i+1).eq.ntyp1
3567 C changes suggested by Ana to avoid out of bounds
3568 C Adam: Unnecessary: handled by iturn3_end and iturn3_start
3569 c & .or.((i+4).gt.nres)
3570 c & .or.((i-1).le.0)
3571 C end of changes by Ana
3572 & .or. itype(i+2).eq.ntyp1
3573 & .or. itype(i+3).eq.ntyp1) cycle
3574 C Adam: Instructions below will switch off existing interactions
3576 c if(itype(i-1).eq.ntyp1)cycle
3578 c if(i.LT.nres-3)then
3579 c if (itype(i+4).eq.ntyp1) cycle
3584 dx_normi=dc_norm(1,i)
3585 dy_normi=dc_norm(2,i)
3586 dz_normi=dc_norm(3,i)
3587 xmedi=c(1,i)+0.5d0*dxi
3588 ymedi=c(2,i)+0.5d0*dyi
3589 zmedi=c(3,i)+0.5d0*dzi
3590 xmedi=mod(xmedi,boxxsize)
3591 if (xmedi.lt.0) xmedi=xmedi+boxxsize
3592 ymedi=mod(ymedi,boxysize)
3593 if (ymedi.lt.0) ymedi=ymedi+boxysize
3594 zmedi=mod(zmedi,boxzsize)
3595 if (zmedi.lt.0) zmedi=zmedi+boxzsize
3597 call eelecij(i,i+2,ees,evdw1,eel_loc)
3598 if (wturn3.gt.0.0d0) call eturn3(i,eello_turn3)
3599 num_cont_hb(i)=num_conti
3601 do i=iturn4_start,iturn4_end
3603 if (itype(i).eq.ntyp1 .or. itype(i+1).eq.ntyp1
3604 C changes suggested by Ana to avoid out of bounds
3605 c & .or.((i+5).gt.nres)
3606 c & .or.((i-1).le.0)
3607 C end of changes suggested by Ana
3608 & .or. itype(i+3).eq.ntyp1
3609 & .or. itype(i+4).eq.ntyp1
3610 c & .or. itype(i+5).eq.ntyp1
3611 c & .or. itype(i).eq.ntyp1
3612 c & .or. itype(i-1).eq.ntyp1
3617 dx_normi=dc_norm(1,i)
3618 dy_normi=dc_norm(2,i)
3619 dz_normi=dc_norm(3,i)
3620 xmedi=c(1,i)+0.5d0*dxi
3621 ymedi=c(2,i)+0.5d0*dyi
3622 zmedi=c(3,i)+0.5d0*dzi
3623 C Return atom into box, boxxsize is size of box in x dimension
3625 c if (xmedi.gt.((0.5d0)*boxxsize)) xmedi=xmedi-boxxsize
3626 c if (xmedi.lt.((-0.5d0)*boxxsize)) xmedi=xmedi+boxxsize
3627 C Condition for being inside the proper box
3628 c if ((xmedi.gt.((0.5d0)*boxxsize)).or.
3629 c & (xmedi.lt.((-0.5d0)*boxxsize))) then
3633 c if (ymedi.gt.((0.5d0)*boxysize)) ymedi=ymedi-boxysize
3634 c if (ymedi.lt.((-0.5d0)*boxysize)) ymedi=ymedi+boxysize
3635 C Condition for being inside the proper box
3636 c if ((ymedi.gt.((0.5d0)*boxysize)).or.
3637 c & (ymedi.lt.((-0.5d0)*boxysize))) then
3641 c if (zmedi.gt.((0.5d0)*boxzsize)) zmedi=zmedi-boxzsize
3642 c if (zmedi.lt.((-0.5d0)*boxzsize)) zmedi=zmedi+boxzsize
3643 C Condition for being inside the proper box
3644 c if ((zmedi.gt.((0.5d0)*boxzsize)).or.
3645 c & (zmedi.lt.((-0.5d0)*boxzsize))) then
3648 xmedi=mod(xmedi,boxxsize)
3649 if (xmedi.lt.0) xmedi=xmedi+boxxsize
3650 ymedi=mod(ymedi,boxysize)
3651 if (ymedi.lt.0) ymedi=ymedi+boxysize
3652 zmedi=mod(zmedi,boxzsize)
3653 if (zmedi.lt.0) zmedi=zmedi+boxzsize
3655 num_conti=num_cont_hb(i)
3656 c write(iout,*) "JESTEM W PETLI"
3657 call eelecij(i,i+3,ees,evdw1,eel_loc)
3658 if (wturn4.gt.0.0d0 .and. itype(i+2).ne.ntyp1)
3659 & call eturn4(i,eello_turn4)
3660 num_cont_hb(i)=num_conti
3662 C Loop over all neighbouring boxes
3667 c Loop over all pairs of interacting peptide groups except i,i+2 and i,i+3
3670 do i=iatel_s,iatel_e
3673 if (itype(i).eq.ntyp1 .or. itype(i+1).eq.ntyp1
3674 C changes suggested by Ana to avoid out of bounds
3675 c & .or.((i+2).gt.nres)
3676 c & .or.((i-1).le.0)
3677 C end of changes by Ana
3678 c & .or. itype(i+2).eq.ntyp1
3679 c & .or. itype(i-1).eq.ntyp1
3684 dx_normi=dc_norm(1,i)
3685 dy_normi=dc_norm(2,i)
3686 dz_normi=dc_norm(3,i)
3687 xmedi=c(1,i)+0.5d0*dxi
3688 ymedi=c(2,i)+0.5d0*dyi
3689 zmedi=c(3,i)+0.5d0*dzi
3690 xmedi=mod(xmedi,boxxsize)
3691 if (xmedi.lt.0) xmedi=xmedi+boxxsize
3692 ymedi=mod(ymedi,boxysize)
3693 if (ymedi.lt.0) ymedi=ymedi+boxysize
3694 zmedi=mod(zmedi,boxzsize)
3695 if (zmedi.lt.0) zmedi=zmedi+boxzsize
3696 C xmedi=xmedi+xshift*boxxsize
3697 C ymedi=ymedi+yshift*boxysize
3698 C zmedi=zmedi+zshift*boxzsize
3700 C Return tom into box, boxxsize is size of box in x dimension
3702 c if (xmedi.gt.((xshift+0.5d0)*boxxsize)) xmedi=xmedi-boxxsize
3703 c if (xmedi.lt.((xshift-0.5d0)*boxxsize)) xmedi=xmedi+boxxsize
3704 C Condition for being inside the proper box
3705 c if ((xmedi.gt.((xshift+0.5d0)*boxxsize)).or.
3706 c & (xmedi.lt.((xshift-0.5d0)*boxxsize))) then
3710 c if (ymedi.gt.((yshift+0.5d0)*boxysize)) ymedi=ymedi-boxysize
3711 c if (ymedi.lt.((yshift-0.5d0)*boxysize)) ymedi=ymedi+boxysize
3712 C Condition for being inside the proper box
3713 c if ((ymedi.gt.((yshift+0.5d0)*boxysize)).or.
3714 c & (ymedi.lt.((yshift-0.5d0)*boxysize))) then
3718 c if (zmedi.gt.((zshift+0.5d0)*boxzsize)) zmedi=zmedi-boxzsize
3719 c if (zmedi.lt.((zshift-0.5d0)*boxzsize)) zmedi=zmedi+boxzsize
3720 cC Condition for being inside the proper box
3721 c if ((zmedi.gt.((zshift+0.5d0)*boxzsize)).or.
3722 c & (zmedi.lt.((zshift-0.5d0)*boxzsize))) then
3726 c write (iout,*) 'i',i,' ielstart',ielstart(i),' ielend',ielend(i)
3727 num_conti=num_cont_hb(i)
3729 do j=ielstart(i),ielend(i)
3731 C write (iout,*) i,j
3733 if (itype(j).eq.ntyp1.or. itype(j+1).eq.ntyp1
3734 C changes suggested by Ana to avoid out of bounds
3735 c & .or.((j+2).gt.nres)
3736 c & .or.((j-1).le.0)
3737 C end of changes by Ana
3738 c & .or.itype(j+2).eq.ntyp1
3739 c & .or.itype(j-1).eq.ntyp1
3741 call eelecij(i,j,ees,evdw1,eel_loc)
3743 num_cont_hb(i)=num_conti
3749 c write (iout,*) "Number of loop steps in EELEC:",ind
3751 cd write (iout,'(i3,3f10.5,5x,3f10.5)')
3752 cd & i,(gel_loc(k,i),k=1,3),gel_loc_loc(i)
3754 c 12/7/99 Adam eello_turn3 will be considered as a separate energy term
3755 ccc eel_loc=eel_loc+eello_turn3
3756 cd print *,"Processor",fg_rank," t_eelecij",t_eelecij
3759 C-------------------------------------------------------------------------------
3760 subroutine eelecij(i,j,ees,evdw1,eel_loc)
3761 implicit real*8 (a-h,o-z)
3762 include 'DIMENSIONS'
3766 include 'COMMON.CONTROL'
3767 include 'COMMON.IOUNITS'
3768 include 'COMMON.GEO'
3769 include 'COMMON.VAR'
3770 include 'COMMON.LOCAL'
3771 include 'COMMON.CHAIN'
3772 include 'COMMON.DERIV'
3773 include 'COMMON.INTERACT'
3774 include 'COMMON.CONTACTS'
3775 include 'COMMON.TORSION'
3776 include 'COMMON.VECTORS'
3777 include 'COMMON.FFIELD'
3778 include 'COMMON.TIME1'
3779 include 'COMMON.SPLITELE'
3780 include 'COMMON.SHIELD'
3781 dimension ggg(3),gggp(3),gggm(3),erij(3),dcosb(3),dcosg(3),
3782 & erder(3,3),uryg(3,3),urzg(3,3),vryg(3,3),vrzg(3,3)
3783 double precision acipa(2,2),agg(3,4),aggi(3,4),aggi1(3,4),
3784 & aggj(3,4),aggj1(3,4),a_temp(2,2),muij(4),gmuij1(4),gmuji1(4),
3785 & gmuij2(4),gmuji2(4)
3786 common /locel/ a_temp,agg,aggi,aggi1,aggj,aggj1,a22,a23,a32,a33,
3787 & dxi,dyi,dzi,dx_normi,dy_normi,dz_normi,xmedi,ymedi,zmedi,
3789 c 4/26/02 - AL scaling factor for 1,4 repulsive VDW interactions
3791 double precision scal_el /1.0d0/
3793 double precision scal_el /0.5d0/
3796 C 13-go grudnia roku pamietnego...
3797 double precision unmat(3,3) /1.0d0,0.0d0,0.0d0,
3798 & 0.0d0,1.0d0,0.0d0,
3799 & 0.0d0,0.0d0,1.0d0/
3800 integer xshift,yshift,zshift
3801 c time00=MPI_Wtime()
3802 cd write (iout,*) "eelecij",i,j
3806 if (j.eq.i+2 .and. itelj.eq.2) iteli=2
3807 aaa=app(iteli,itelj)
3808 bbb=bpp(iteli,itelj)
3809 ael6i=ael6(iteli,itelj)
3810 ael3i=ael3(iteli,itelj)
3814 dx_normj=dc_norm(1,j)
3815 dy_normj=dc_norm(2,j)
3816 dz_normj=dc_norm(3,j)
3817 C xj=c(1,j)+0.5D0*dxj-xmedi
3818 C yj=c(2,j)+0.5D0*dyj-ymedi
3819 C zj=c(3,j)+0.5D0*dzj-zmedi
3824 if (xj.lt.0) xj=xj+boxxsize
3826 if (yj.lt.0) yj=yj+boxysize
3828 if (zj.lt.0) zj=zj+boxzsize
3829 if ((zj.lt.0).or.(xj.lt.0).or.(yj.lt.0)) write (*,*) "CHUJ"
3830 dist_init=(xj-xmedi)**2+(yj-ymedi)**2+(zj-zmedi)**2
3838 xj=xj_safe+xshift*boxxsize
3839 yj=yj_safe+yshift*boxysize
3840 zj=zj_safe+zshift*boxzsize
3841 dist_temp=(xj-xmedi)**2+(yj-ymedi)**2+(zj-zmedi)**2
3842 if(dist_temp.lt.dist_init) then
3852 if (isubchap.eq.1) then
3861 C if ((i+3).lt.j) then !this condition keeps for turn3 and turn4 not subject to PBC
3863 c if (xj.gt.((0.5d0)*boxxsize)) xj=xj-boxxsize
3864 c if (xj.lt.((-0.5d0)*boxxsize)) xj=xj+boxxsize
3865 C Condition for being inside the proper box
3866 c if ((xj.gt.((0.5d0)*boxxsize)).or.
3867 c & (xj.lt.((-0.5d0)*boxxsize))) then
3871 c if (yj.gt.((0.5d0)*boxysize)) yj=yj-boxysize
3872 c if (yj.lt.((-0.5d0)*boxysize)) yj=yj+boxysize
3873 C Condition for being inside the proper box
3874 c if ((yj.gt.((0.5d0)*boxysize)).or.
3875 c & (yj.lt.((-0.5d0)*boxysize))) then
3879 c if (zj.gt.((0.5d0)*boxzsize)) zj=zj-boxzsize
3880 c if (zj.lt.((-0.5d0)*boxzsize)) zj=zj+boxzsize
3881 C Condition for being inside the proper box
3882 c if ((zj.gt.((0.5d0)*boxzsize)).or.
3883 c & (zj.lt.((-0.5d0)*boxzsize))) then
3886 C endif !endPBC condintion
3890 rij=xj*xj+yj*yj+zj*zj
3892 sss=sscale(sqrt(rij))
3893 sssgrad=sscagrad(sqrt(rij))
3894 c if (sss.gt.0.0d0) then
3900 cosa=dx_normi*dx_normj+dy_normi*dy_normj+dz_normi*dz_normj
3901 cosb=(xj*dx_normi+yj*dy_normi+zj*dz_normi)*rmij
3902 cosg=(xj*dx_normj+yj*dy_normj+zj*dz_normj)*rmij
3903 fac=cosa-3.0D0*cosb*cosg
3905 c 4/26/02 - AL scaling down 1,4 repulsive VDW interactions
3906 if (j.eq.i+2) ev1=scal_el*ev1
3911 el1=fac3*(4.0D0+fac*fac-3.0D0*(cosb*cosb+cosg*cosg))
3915 C 12/26/95 - for the evaluation of multi-body H-bonding interactions
3916 ees0ij=4.0D0+fac*fac-3.0D0*(cosb*cosb+cosg*cosg)
3917 if (shield_mode.gt.0) then
3920 el1=el1*fac_shield(i)**2*fac_shield(j)**2
3921 el2=el2*fac_shield(i)**2*fac_shield(j)**2
3930 evdw1=evdw1+evdwij*sss
3931 cd write(iout,'(2(2i3,2x),7(1pd12.4)/2(3(1pd12.4),5x)/)')
3932 cd & iteli,i,itelj,j,aaa,bbb,ael6i,ael3i,
3933 cd & 1.0D0/dsqrt(rrmij),evdwij,eesij,
3934 cd & xmedi,ymedi,zmedi,xj,yj,zj
3936 if (energy_dec) then
3937 write (iout,'(a6,2i5,0pf7.3,2i5,3e11.3)')
3939 &,iteli,itelj,aaa,evdw1,sss
3940 write (iout,'(a6,2i5,0pf7.3,2f8.3)') 'ees',i,j,eesij,
3941 &fac_shield(i),fac_shield(j)
3945 C Calculate contributions to the Cartesian gradient.
3948 facvdw=-6*rrmij*(ev1+evdwij)*sss
3949 facel=-3*rrmij*(el1+eesij)
3956 * Radial derivatives. First process both termini of the fragment (i,j)
3961 if ((fac_shield(i).gt.0).and.(fac_shield(j).gt.0).and.
3962 & (shield_mode.gt.0)) then
3964 do ilist=1,ishield_list(i)
3965 iresshield=shield_list(ilist,i)
3967 rlocshield=grad_shield_side(k,ilist,i)*eesij/fac_shield(i)
3969 gshieldx(k,iresshield)=gshieldx(k,iresshield)+
3971 & +grad_shield_loc(k,ilist,i)*eesij/fac_shield(i)*2.0
3972 gshieldc(k,iresshield-1)=gshieldc(k,iresshield-1)+rlocshield
3973 C gshieldc_loc(k,iresshield)=gshieldc_loc(k,iresshield)
3974 C & +grad_shield_loc(k,ilist,i)*eesij/fac_shield(i)
3975 C if (iresshield.gt.i) then
3976 C do ishi=i+1,iresshield-1
3977 C gshieldc(k,ishi)=gshieldc(k,ishi)+rlocshield
3978 C & +grad_shield_loc(k,ilist,i)*eesij/fac_shield(i)
3982 C do ishi=iresshield,i
3983 C gshieldc(k,ishi)=gshieldc(k,ishi)-rlocshield
3984 C & -grad_shield_loc(k,ilist,i)*eesij/fac_shield(i)
3990 do ilist=1,ishield_list(j)
3991 iresshield=shield_list(ilist,j)
3993 rlocshield=grad_shield_side(k,ilist,j)*eesij/fac_shield(j)
3995 gshieldx(k,iresshield)=gshieldx(k,iresshield)+
3997 & +grad_shield_loc(k,ilist,j)*eesij/fac_shield(j)*2.0
3998 gshieldc(k,iresshield-1)=gshieldc(k,iresshield-1)+rlocshield
4000 C & +grad_shield_loc(k,ilist,j)*eesij/fac_shield(j)
4001 C gshieldc_loc(k,iresshield)=gshieldc_loc(k,iresshield)
4002 C & +grad_shield_loc(k,ilist,j)*eesij/fac_shield(j)
4003 C if (iresshield.gt.j) then
4004 C do ishi=j+1,iresshield-1
4005 C gshieldc(k,ishi)=gshieldc(k,ishi)+rlocshield
4006 C & +grad_shield_loc(k,ilist,j)*eesij/fac_shield(j)
4010 C do ishi=iresshield,j
4011 C gshieldc(k,ishi)=gshieldc(k,ishi)-rlocshield
4012 C & -grad_shield_loc(k,ilist,j)*eesij/fac_shield(j)
4019 gshieldc(k,i)=gshieldc(k,i)+
4020 & grad_shield(k,i)*eesij/fac_shield(i)*2.0
4021 gshieldc(k,j)=gshieldc(k,j)+
4022 & grad_shield(k,j)*eesij/fac_shield(j)*2.0
4023 gshieldc(k,i-1)=gshieldc(k,i-1)+
4024 & grad_shield(k,i)*eesij/fac_shield(i)*2.0
4025 gshieldc(k,j-1)=gshieldc(k,j-1)+
4026 & grad_shield(k,j)*eesij/fac_shield(j)*2.0
4031 c ghalf=0.5D0*ggg(k)
4032 c gelc(k,i)=gelc(k,i)+ghalf
4033 c gelc(k,j)=gelc(k,j)+ghalf
4035 c 9/28/08 AL Gradient compotents will be summed only at the end
4036 C print *,"before", gelc_long(1,i), gelc_long(1,j)
4038 gelc_long(k,j)=gelc_long(k,j)+ggg(k)
4039 C & +grad_shield(k,j)*eesij/fac_shield(j)
4040 gelc_long(k,i)=gelc_long(k,i)-ggg(k)
4041 C & +grad_shield(k,i)*eesij/fac_shield(i)
4042 C gelc_long(k,i-1)=gelc_long(k,i-1)
4043 C & +grad_shield(k,i)*eesij/fac_shield(i)
4044 C gelc_long(k,j-1)=gelc_long(k,j-1)
4045 C & +grad_shield(k,j)*eesij/fac_shield(j)
4047 C print *,"bafter", gelc_long(1,i), gelc_long(1,j)
4050 * Loop over residues i+1 thru j-1.
4054 cgrad gelc(l,k)=gelc(l,k)+ggg(l)
4057 if (sss.gt.0.0) then
4058 ggg(1)=facvdw*xj+sssgrad*rmij*evdwij*xj
4059 ggg(2)=facvdw*yj+sssgrad*rmij*evdwij*yj
4060 ggg(3)=facvdw*zj+sssgrad*rmij*evdwij*zj
4067 c ghalf=0.5D0*ggg(k)
4068 c gvdwpp(k,i)=gvdwpp(k,i)+ghalf
4069 c gvdwpp(k,j)=gvdwpp(k,j)+ghalf
4071 c 9/28/08 AL Gradient compotents will be summed only at the end
4073 gvdwpp(k,j)=gvdwpp(k,j)+ggg(k)
4074 gvdwpp(k,i)=gvdwpp(k,i)-ggg(k)
4077 * Loop over residues i+1 thru j-1.
4081 cgrad gvdwpp(l,k)=gvdwpp(l,k)+ggg(l)
4086 facvdw=(ev1+evdwij)*sss
4089 fac=-3*rrmij*(facvdw+facvdw+facel)
4094 * Radial derivatives. First process both termini of the fragment (i,j)
4097 C+eesij*grad_shield(1,i)+eesij*grad_shield(1,j)
4099 C+eesij*grad_shield(2,i)+eesij*grad_shield(2,j)
4101 C+eesij*grad_shield(3,i)+eesij*grad_shield(3,j)
4103 c ghalf=0.5D0*ggg(k)
4104 c gelc(k,i)=gelc(k,i)+ghalf
4105 c gelc(k,j)=gelc(k,j)+ghalf
4107 c 9/28/08 AL Gradient compotents will be summed only at the end
4109 gelc_long(k,j)=gelc(k,j)+ggg(k)
4110 gelc_long(k,i)=gelc(k,i)-ggg(k)
4113 * Loop over residues i+1 thru j-1.
4117 cgrad gelc(l,k)=gelc(l,k)+ggg(l)
4120 c 9/28/08 AL Gradient compotents will be summed only at the end
4121 ggg(1)=facvdw*xj+sssgrad*rmij*evdwij*xj
4122 ggg(2)=facvdw*yj+sssgrad*rmij*evdwij*yj
4123 ggg(3)=facvdw*zj+sssgrad*rmij*evdwij*zj
4125 gvdwpp(k,j)=gvdwpp(k,j)+ggg(k)
4126 gvdwpp(k,i)=gvdwpp(k,i)-ggg(k)
4132 ecosa=2.0D0*fac3*fac1+fac4
4135 ecosb=(fac3*(fac1*cosg+cosb)+cosg*fac4)
4136 ecosg=(fac3*(fac1*cosb+cosg)+cosb*fac4)
4138 dcosb(k)=rmij*(dc_norm(k,i)-erij(k)*cosb)
4139 dcosg(k)=rmij*(dc_norm(k,j)-erij(k)*cosg)
4141 cd print '(2i3,2(3(1pd14.5),3x))',i,j,(dcosb(k),k=1,3),
4142 cd & (dcosg(k),k=1,3)
4144 ggg(k)=(ecosb*dcosb(k)+ecosg*dcosg(k))*
4145 & fac_shield(i)**2*fac_shield(j)**2
4148 c ghalf=0.5D0*ggg(k)
4149 c gelc(k,i)=gelc(k,i)+ghalf
4150 c & +(ecosa*(dc_norm(k,j)-cosa*dc_norm(k,i))
4151 c & + ecosb*(erij(k)-cosb*dc_norm(k,i)))*vbld_inv(i+1)
4152 c gelc(k,j)=gelc(k,j)+ghalf
4153 c & +(ecosa*(dc_norm(k,i)-cosa*dc_norm(k,j))
4154 c & + ecosg*(erij(k)-cosg*dc_norm(k,j)))*vbld_inv(j+1)
4158 cgrad gelc(l,k)=gelc(l,k)+ggg(l)
4161 C print *,"before22", gelc_long(1,i), gelc_long(1,j)
4164 & +((ecosa*(dc_norm(k,j)-cosa*dc_norm(k,i))
4165 & + ecosb*(erij(k)-cosb*dc_norm(k,i)))*vbld_inv(i+1))
4166 & *fac_shield(i)**2*fac_shield(j)**2
4168 & +((ecosa*(dc_norm(k,i)-cosa*dc_norm(k,j))
4169 & + ecosg*(erij(k)-cosg*dc_norm(k,j)))*vbld_inv(j+1))
4170 & *fac_shield(i)**2*fac_shield(j)**2
4171 gelc_long(k,j)=gelc_long(k,j)+ggg(k)
4172 gelc_long(k,i)=gelc_long(k,i)-ggg(k)
4174 C print *,"before33", gelc_long(1,i), gelc_long(1,j)
4178 IF (wel_loc.gt.0.0d0 .or. wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0
4179 & .or. wcorr6.gt.0.0d0 .or. wturn3.gt.0.0d0
4180 & .or. wturn4.gt.0.0d0 .or. wturn6.gt.0.0d0) THEN
4182 C 9/25/99 Mixed third-order local-electrostatic terms. The local-interaction
4183 C energy of a peptide unit is assumed in the form of a second-order
4184 C Fourier series in the angles lambda1 and lambda2 (see Nishikawa et al.
4185 C Macromolecules, 1974, 7, 797-806 for definition). This correlation terms
4186 C are computed for EVERY pair of non-contiguous peptide groups.
4189 if (j.lt.nres-1) then
4201 muij(kkk)=mu(k,i)*mu(l,j)
4202 c write(iout,*) 'mumu=', mu(k,i),mu(l,j),i,j,k,l
4204 gmuij1(kkk)=gtb1(k,i+1)*mu(l,j)
4205 c write(iout,*) 'k=',k,i,gtb1(k,i+1),gtb1(k,i+1)*mu(l,j)
4206 gmuij2(kkk)=gUb2(k,i)*mu(l,j)
4207 gmuji1(kkk)=mu(k,i)*gtb1(l,j+1)
4208 c write(iout,*) 'l=',l,j,gtb1(l,j+1),gtb1(l,j+1)*mu(k,i)
4209 gmuji2(kkk)=mu(k,i)*gUb2(l,j)
4214 write (iout,*) 'EELEC: i',i,' j',j
4215 write (iout,*) 'j',j,' j1',j1,' j2',j2
4216 write(iout,*) 'muij',muij
4218 ury=scalar(uy(1,i),erij)
4219 urz=scalar(uz(1,i),erij)
4220 vry=scalar(uy(1,j),erij)
4221 vrz=scalar(uz(1,j),erij)
4222 a22=scalar(uy(1,i),uy(1,j))-3*ury*vry
4223 a23=scalar(uy(1,i),uz(1,j))-3*ury*vrz
4224 a32=scalar(uz(1,i),uy(1,j))-3*urz*vry
4225 a33=scalar(uz(1,i),uz(1,j))-3*urz*vrz
4226 fac=dsqrt(-ael6i)*r3ij
4228 write (iout,*) "ury",ury," urz",urz," vry",vry," vrz",vrz
4229 write (iout,*) "uyvy",scalar(uy(1,i),uy(1,j)),
4230 & "uyvz",scalar(uy(1,i),uz(1,j)),
4231 & "uzvy",scalar(uz(1,i),uy(1,j)),
4232 & "uzvz",scalar(uz(1,i),uz(1,j))
4233 write (iout,*) "a22",a22," a23",a23," a32",a32," a33",a33
4234 write (iout,*) "fac",fac
4241 write (iout,*) "a22",a22," a23",a23," a32",a32," a33",a33
4244 cd write (iout,'(4i5,4f10.5)')
4245 cd & i,itortyp(itype(i)),j,itortyp(itype(j)),a22,a23,a32,a33
4246 cd write (iout,'(6f10.5)') (muij(k),k=1,4),fac,eel_loc_ij
4247 cd write (iout,'(2(3f10.5,5x)/2(3f10.5,5x))') uy(:,i),uz(:,i),
4248 cd & uy(:,j),uz(:,j)
4249 cd write (iout,'(4f10.5)')
4250 cd & scalar(uy(1,i),uy(1,j)),scalar(uy(1,i),uz(1,j)),
4251 cd & scalar(uz(1,i),uy(1,j)),scalar(uz(1,i),uz(1,j))
4252 cd write (iout,'(4f10.5)') ury,urz,vry,vrz
4253 cd write (iout,'(9f10.5/)')
4254 cd & fac22,a22,fac23,a23,fac32,a32,fac33,a33,eel_loc_ij
4255 C Derivatives of the elements of A in virtual-bond vectors
4256 call unormderiv(erij(1),unmat(1,1),rmij,erder(1,1))
4258 uryg(k,1)=scalar(erder(1,k),uy(1,i))
4259 uryg(k,2)=scalar(uygrad(1,k,1,i),erij(1))
4260 uryg(k,3)=scalar(uygrad(1,k,2,i),erij(1))
4261 urzg(k,1)=scalar(erder(1,k),uz(1,i))
4262 urzg(k,2)=scalar(uzgrad(1,k,1,i),erij(1))
4263 urzg(k,3)=scalar(uzgrad(1,k,2,i),erij(1))
4264 vryg(k,1)=scalar(erder(1,k),uy(1,j))
4265 vryg(k,2)=scalar(uygrad(1,k,1,j),erij(1))
4266 vryg(k,3)=scalar(uygrad(1,k,2,j),erij(1))
4267 vrzg(k,1)=scalar(erder(1,k),uz(1,j))
4268 vrzg(k,2)=scalar(uzgrad(1,k,1,j),erij(1))
4269 vrzg(k,3)=scalar(uzgrad(1,k,2,j),erij(1))
4271 C Compute radial contributions to the gradient
4289 C Add the contributions coming from er
4292 agg(k,1)=agg(k,1)+fac3*(uryg(k,1)*vry+vryg(k,1)*ury)
4293 agg(k,2)=agg(k,2)+fac3*(uryg(k,1)*vrz+vrzg(k,1)*ury)
4294 agg(k,3)=agg(k,3)+fac3*(urzg(k,1)*vry+vryg(k,1)*urz)
4295 agg(k,4)=agg(k,4)+fac3*(urzg(k,1)*vrz+vrzg(k,1)*urz)
4298 C Derivatives in DC(i)
4299 cgrad ghalf1=0.5d0*agg(k,1)
4300 cgrad ghalf2=0.5d0*agg(k,2)
4301 cgrad ghalf3=0.5d0*agg(k,3)
4302 cgrad ghalf4=0.5d0*agg(k,4)
4303 aggi(k,1)=fac*(scalar(uygrad(1,k,1,i),uy(1,j))
4304 & -3.0d0*uryg(k,2)*vry)!+ghalf1
4305 aggi(k,2)=fac*(scalar(uygrad(1,k,1,i),uz(1,j))
4306 & -3.0d0*uryg(k,2)*vrz)!+ghalf2
4307 aggi(k,3)=fac*(scalar(uzgrad(1,k,1,i),uy(1,j))
4308 & -3.0d0*urzg(k,2)*vry)!+ghalf3
4309 aggi(k,4)=fac*(scalar(uzgrad(1,k,1,i),uz(1,j))
4310 & -3.0d0*urzg(k,2)*vrz)!+ghalf4
4311 C Derivatives in DC(i+1)
4312 aggi1(k,1)=fac*(scalar(uygrad(1,k,2,i),uy(1,j))
4313 & -3.0d0*uryg(k,3)*vry)!+agg(k,1)
4314 aggi1(k,2)=fac*(scalar(uygrad(1,k,2,i),uz(1,j))
4315 & -3.0d0*uryg(k,3)*vrz)!+agg(k,2)
4316 aggi1(k,3)=fac*(scalar(uzgrad(1,k,2,i),uy(1,j))
4317 & -3.0d0*urzg(k,3)*vry)!+agg(k,3)
4318 aggi1(k,4)=fac*(scalar(uzgrad(1,k,2,i),uz(1,j))
4319 & -3.0d0*urzg(k,3)*vrz)!+agg(k,4)
4320 C Derivatives in DC(j)
4321 aggj(k,1)=fac*(scalar(uygrad(1,k,1,j),uy(1,i))
4322 & -3.0d0*vryg(k,2)*ury)!+ghalf1
4323 aggj(k,2)=fac*(scalar(uzgrad(1,k,1,j),uy(1,i))
4324 & -3.0d0*vrzg(k,2)*ury)!+ghalf2
4325 aggj(k,3)=fac*(scalar(uygrad(1,k,1,j),uz(1,i))
4326 & -3.0d0*vryg(k,2)*urz)!+ghalf3
4327 aggj(k,4)=fac*(scalar(uzgrad(1,k,1,j),uz(1,i))
4328 & -3.0d0*vrzg(k,2)*urz)!+ghalf4
4329 C Derivatives in DC(j+1) or DC(nres-1)
4330 aggj1(k,1)=fac*(scalar(uygrad(1,k,2,j),uy(1,i))
4331 & -3.0d0*vryg(k,3)*ury)
4332 aggj1(k,2)=fac*(scalar(uzgrad(1,k,2,j),uy(1,i))
4333 & -3.0d0*vrzg(k,3)*ury)
4334 aggj1(k,3)=fac*(scalar(uygrad(1,k,2,j),uz(1,i))
4335 & -3.0d0*vryg(k,3)*urz)
4336 aggj1(k,4)=fac*(scalar(uzgrad(1,k,2,j),uz(1,i))
4337 & -3.0d0*vrzg(k,3)*urz)
4338 cgrad if (j.eq.nres-1 .and. i.lt.j-2) then
4340 cgrad aggj1(k,l)=aggj1(k,l)+agg(k,l)
4353 aggi(k,l)=-aggi(k,l)
4354 aggi1(k,l)=-aggi1(k,l)
4355 aggj(k,l)=-aggj(k,l)
4356 aggj1(k,l)=-aggj1(k,l)
4359 if (j.lt.nres-1) then
4365 aggi(k,l)=-aggi(k,l)
4366 aggi1(k,l)=-aggi1(k,l)
4367 aggj(k,l)=-aggj(k,l)
4368 aggj1(k,l)=-aggj1(k,l)
4379 aggi(k,l)=-aggi(k,l)
4380 aggi1(k,l)=-aggi1(k,l)
4381 aggj(k,l)=-aggj(k,l)
4382 aggj1(k,l)=-aggj1(k,l)
4387 IF (wel_loc.gt.0.0d0) THEN
4388 C Contribution to the local-electrostatic energy coming from the i-j pair
4389 eel_loc_ij=a22*muij(1)+a23*muij(2)+a32*muij(3)
4392 write (iout,*) "muij",muij," a22",a22," a23",a23," a32",a32,
4394 write (iout,*) "ij",i,j," eel_loc_ij",eel_loc_ij,
4395 & " wel_loc",wel_loc
4397 if (shield_mode.eq.0) then
4404 eel_loc_ij=eel_loc_ij
4405 & *fac_shield(i)*fac_shield(j)
4406 c if (energy_dec) write (iout,'(a6,2i5,0pf7.3)')
4407 c & 'eelloc',i,j,eel_loc_ij
4408 C Now derivative over eel_loc
4409 if ((fac_shield(i).gt.0).and.(fac_shield(j).gt.0).and.
4410 & (shield_mode.gt.0)) then
4413 do ilist=1,ishield_list(i)
4414 iresshield=shield_list(ilist,i)
4416 rlocshield=grad_shield_side(k,ilist,i)*eel_loc_ij
4419 gshieldx_ll(k,iresshield)=gshieldx_ll(k,iresshield)+
4421 & +grad_shield_loc(k,ilist,i)*eel_loc_ij/fac_shield(i)
4422 gshieldc_ll(k,iresshield-1)=gshieldc_ll(k,iresshield-1)
4426 do ilist=1,ishield_list(j)
4427 iresshield=shield_list(ilist,j)
4429 rlocshield=grad_shield_side(k,ilist,j)*eel_loc_ij
4432 gshieldx_ll(k,iresshield)=gshieldx_ll(k,iresshield)+
4434 & +grad_shield_loc(k,ilist,j)*eel_loc_ij/fac_shield(j)
4435 gshieldc_ll(k,iresshield-1)=gshieldc_ll(k,iresshield-1)
4442 gshieldc_ll(k,i)=gshieldc_ll(k,i)+
4443 & grad_shield(k,i)*eel_loc_ij/fac_shield(i)
4444 gshieldc_ll(k,j)=gshieldc_ll(k,j)+
4445 & grad_shield(k,j)*eel_loc_ij/fac_shield(j)
4446 gshieldc_ll(k,i-1)=gshieldc_ll(k,i-1)+
4447 & grad_shield(k,i)*eel_loc_ij/fac_shield(i)
4448 gshieldc_ll(k,j-1)=gshieldc_ll(k,j-1)+
4449 & grad_shield(k,j)*eel_loc_ij/fac_shield(j)
4454 c write (iout,*) 'i',i,' j',j,itype(i),itype(j),
4455 c & ' eel_loc_ij',eel_loc_ij
4456 C write(iout,*) 'muije=',i,j,muij(1),muij(2),muij(3),muij(4)
4457 C Calculate patrial derivative for theta angle
4459 geel_loc_ij=(a22*gmuij1(1)
4463 & *fac_shield(i)*fac_shield(j)
4464 c write(iout,*) "derivative over thatai"
4465 c write(iout,*) a22*gmuij1(1), a23*gmuij1(2) ,a32*gmuij1(3),
4467 gloc(nphi+i,icg)=gloc(nphi+i,icg)+
4468 & geel_loc_ij*wel_loc
4469 c write(iout,*) "derivative over thatai-1"
4470 c write(iout,*) a22*gmuij2(1), a23*gmuij2(2) ,a32*gmuij2(3),
4477 gloc(nphi+i-1,icg)=gloc(nphi+i-1,icg)+
4478 & geel_loc_ij*wel_loc
4479 & *fac_shield(i)*fac_shield(j)
4481 c Derivative over j residue
4482 geel_loc_ji=a22*gmuji1(1)
4486 c write(iout,*) "derivative over thataj"
4487 c write(iout,*) a22*gmuji1(1), a23*gmuji1(2) ,a32*gmuji1(3),
4490 gloc(nphi+j,icg)=gloc(nphi+j,icg)+
4491 & geel_loc_ji*wel_loc
4492 & *fac_shield(i)*fac_shield(j)
4499 c write(iout,*) "derivative over thataj-1"
4500 c write(iout,*) a22*gmuji2(1), a23*gmuji2(2) ,a32*gmuji2(3),
4502 gloc(nphi+j-1,icg)=gloc(nphi+j-1,icg)+
4503 & geel_loc_ji*wel_loc
4504 & *fac_shield(i)*fac_shield(j)
4506 cd write (iout,*) 'i',i,' j',j,' eel_loc_ij',eel_loc_ij
4508 if (energy_dec) write (iout,'(a6,2i5,0pf7.3)')
4509 & 'eelloc',i,j,eel_loc_ij
4510 c if (eel_loc_ij.ne.0)
4511 c & write (iout,'(a4,2i4,8f9.5)')'chuj',
4512 c & i,j,a22,muij(1),a23,muij(2),a32,muij(3),a33,muij(4)
4514 eel_loc=eel_loc+eel_loc_ij
4515 C Partial derivatives in virtual-bond dihedral angles gamma
4517 & gel_loc_loc(i-1)=gel_loc_loc(i-1)+
4518 & (a22*muder(1,i)*mu(1,j)+a23*muder(1,i)*mu(2,j)
4519 & +a32*muder(2,i)*mu(1,j)+a33*muder(2,i)*mu(2,j))
4520 & *fac_shield(i)*fac_shield(j)
4522 gel_loc_loc(j-1)=gel_loc_loc(j-1)+
4523 & (a22*mu(1,i)*muder(1,j)+a23*mu(1,i)*muder(2,j)
4524 & +a32*mu(2,i)*muder(1,j)+a33*mu(2,i)*muder(2,j))
4525 & *fac_shield(i)*fac_shield(j)
4526 C Derivatives of eello in DC(i+1) thru DC(j-1) or DC(nres-2)
4528 ggg(l)=(agg(l,1)*muij(1)+
4529 & agg(l,2)*muij(2)+agg(l,3)*muij(3)+agg(l,4)*muij(4))
4530 & *fac_shield(i)*fac_shield(j)
4531 gel_loc_long(l,j)=gel_loc_long(l,j)+ggg(l)
4532 gel_loc_long(l,i)=gel_loc_long(l,i)-ggg(l)
4533 cgrad ghalf=0.5d0*ggg(l)
4534 cgrad gel_loc(l,i)=gel_loc(l,i)+ghalf
4535 cgrad gel_loc(l,j)=gel_loc(l,j)+ghalf
4539 cgrad gel_loc(l,k)=gel_loc(l,k)+ggg(l)
4542 C Remaining derivatives of eello
4544 gel_loc(l,i)=gel_loc(l,i)+(aggi(l,1)*muij(1)+
4545 & aggi(l,2)*muij(2)+aggi(l,3)*muij(3)+aggi(l,4)*muij(4))
4546 & *fac_shield(i)*fac_shield(j)
4548 gel_loc(l,i+1)=gel_loc(l,i+1)+(aggi1(l,1)*muij(1)+
4549 & aggi1(l,2)*muij(2)+aggi1(l,3)*muij(3)+aggi1(l,4)*muij(4))
4550 & *fac_shield(i)*fac_shield(j)
4552 gel_loc(l,j)=gel_loc(l,j)+(aggj(l,1)*muij(1)+
4553 & aggj(l,2)*muij(2)+aggj(l,3)*muij(3)+aggj(l,4)*muij(4))
4554 & *fac_shield(i)*fac_shield(j)
4556 gel_loc(l,j1)=gel_loc(l,j1)+(aggj1(l,1)*muij(1)+
4557 & aggj1(l,2)*muij(2)+aggj1(l,3)*muij(3)+aggj1(l,4)*muij(4))
4558 & *fac_shield(i)*fac_shield(j)
4562 C Change 12/26/95 to calculate four-body contributions to H-bonding energy
4563 c if (j.gt.i+1 .and. num_conti.le.maxconts) then
4564 if (wcorr+wcorr4+wcorr5+wcorr6.gt.0.0d0
4565 & .and. num_conti.le.maxconts) then
4566 c write (iout,*) i,j," entered corr"
4568 C Calculate the contact function. The ith column of the array JCONT will
4569 C contain the numbers of atoms that make contacts with the atom I (of numbers
4570 C greater than I). The arrays FACONT and GACONT will contain the values of
4571 C the contact function and its derivative.
4572 c r0ij=1.02D0*rpp(iteli,itelj)
4573 c r0ij=1.11D0*rpp(iteli,itelj)
4574 r0ij=2.20D0*rpp(iteli,itelj)
4575 c r0ij=1.55D0*rpp(iteli,itelj)
4576 call gcont(rij,r0ij,1.0D0,0.2d0*r0ij,fcont,fprimcont)
4577 if (fcont.gt.0.0D0) then
4578 num_conti=num_conti+1
4579 if (num_conti.gt.maxconts) then
4580 write (iout,*) 'WARNING - max. # of contacts exceeded;',
4581 & ' will skip next contacts for this conf.'
4583 jcont_hb(num_conti,i)=j
4584 cd write (iout,*) "i",i," j",j," num_conti",num_conti,
4585 cd & " jcont_hb",jcont_hb(num_conti,i)
4586 IF (wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 .or.
4587 & wcorr6.gt.0.0d0 .or. wturn6.gt.0.0d0) THEN
4588 C 9/30/99 (AL) - store components necessary to evaluate higher-order loc-el
4590 d_cont(num_conti,i)=rij
4591 cd write (2,'(3e15.5)') rij,r0ij+0.2d0*r0ij,rij
4592 C --- Electrostatic-interaction matrix ---
4593 a_chuj(1,1,num_conti,i)=a22
4594 a_chuj(1,2,num_conti,i)=a23
4595 a_chuj(2,1,num_conti,i)=a32
4596 a_chuj(2,2,num_conti,i)=a33
4597 C --- Gradient of rij
4599 grij_hb_cont(kkk,num_conti,i)=erij(kkk)
4606 a_chuj_der(k,l,m,1,num_conti,i)=agg(m,kkll)
4607 a_chuj_der(k,l,m,2,num_conti,i)=aggi(m,kkll)
4608 a_chuj_der(k,l,m,3,num_conti,i)=aggi1(m,kkll)
4609 a_chuj_der(k,l,m,4,num_conti,i)=aggj(m,kkll)
4610 a_chuj_der(k,l,m,5,num_conti,i)=aggj1(m,kkll)
4615 IF (wcorr4.eq.0.0d0 .and. wcorr.gt.0.0d0) THEN
4616 C Calculate contact energies
4618 wij=cosa-3.0D0*cosb*cosg
4621 c fac3=dsqrt(-ael6i)/r0ij**3
4622 fac3=dsqrt(-ael6i)*r3ij
4623 c ees0pij=dsqrt(4.0D0+cosa4+wij*wij-3.0D0*cosbg1*cosbg1)
4624 ees0tmp=4.0D0+cosa4+wij*wij-3.0D0*cosbg1*cosbg1
4625 if (ees0tmp.gt.0) then
4626 ees0pij=dsqrt(ees0tmp)
4630 c ees0mij=dsqrt(4.0D0-cosa4+wij*wij-3.0D0*cosbg2*cosbg2)
4631 ees0tmp=4.0D0-cosa4+wij*wij-3.0D0*cosbg2*cosbg2
4632 if (ees0tmp.gt.0) then
4633 ees0mij=dsqrt(ees0tmp)
4638 if (shield_mode.eq.0) then
4642 ees0plist(num_conti,i)=j
4643 C fac_shield(i)=0.4d0
4644 C fac_shield(j)=0.6d0
4646 ees0p(num_conti,i)=0.5D0*fac3*(ees0pij+ees0mij)
4647 & *fac_shield(i)*fac_shield(j)
4648 ees0m(num_conti,i)=0.5D0*fac3*(ees0pij-ees0mij)
4649 & *fac_shield(i)*fac_shield(j)
4650 C Diagnostics. Comment out or remove after debugging!
4651 c ees0p(num_conti,i)=0.5D0*fac3*ees0pij
4652 c ees0m(num_conti,i)=0.5D0*fac3*ees0mij
4653 c ees0m(num_conti,i)=0.0D0
4655 c write (iout,*) 'i=',i,' j=',j,' rij=',rij,' r0ij=',r0ij,
4656 c & ' ees0ij=',ees0p(num_conti,i),ees0m(num_conti,i),' fcont=',fcont
4657 C Angular derivatives of the contact function
4658 ees0pij1=fac3/ees0pij
4659 ees0mij1=fac3/ees0mij
4660 fac3p=-3.0D0*fac3*rrmij
4661 ees0pijp=0.5D0*fac3p*(ees0pij+ees0mij)
4662 ees0mijp=0.5D0*fac3p*(ees0pij-ees0mij)
4664 ecosa1= ees0pij1*( 1.0D0+0.5D0*wij)
4665 ecosb1=-1.5D0*ees0pij1*(wij*cosg+cosbg1)
4666 ecosg1=-1.5D0*ees0pij1*(wij*cosb+cosbg1)
4667 ecosa2= ees0mij1*(-1.0D0+0.5D0*wij)
4668 ecosb2=-1.5D0*ees0mij1*(wij*cosg+cosbg2)
4669 ecosg2=-1.5D0*ees0mij1*(wij*cosb-cosbg2)
4670 ecosap=ecosa1+ecosa2
4671 ecosbp=ecosb1+ecosb2
4672 ecosgp=ecosg1+ecosg2
4673 ecosam=ecosa1-ecosa2
4674 ecosbm=ecosb1-ecosb2
4675 ecosgm=ecosg1-ecosg2
4684 facont_hb(num_conti,i)=fcont
4685 fprimcont=fprimcont/rij
4686 cd facont_hb(num_conti,i)=1.0D0
4687 C Following line is for diagnostics.
4690 dcosb(k)=rmij*(dc_norm(k,i)-erij(k)*cosb)
4691 dcosg(k)=rmij*(dc_norm(k,j)-erij(k)*cosg)
4694 gggp(k)=ecosbp*dcosb(k)+ecosgp*dcosg(k)
4695 gggm(k)=ecosbm*dcosb(k)+ecosgm*dcosg(k)
4697 gggp(1)=gggp(1)+ees0pijp*xj
4698 gggp(2)=gggp(2)+ees0pijp*yj
4699 gggp(3)=gggp(3)+ees0pijp*zj
4700 gggm(1)=gggm(1)+ees0mijp*xj
4701 gggm(2)=gggm(2)+ees0mijp*yj
4702 gggm(3)=gggm(3)+ees0mijp*zj
4703 C Derivatives due to the contact function
4704 gacont_hbr(1,num_conti,i)=fprimcont*xj
4705 gacont_hbr(2,num_conti,i)=fprimcont*yj
4706 gacont_hbr(3,num_conti,i)=fprimcont*zj
4709 c 10/24/08 cgrad and ! comments indicate the parts of the code removed
4710 c following the change of gradient-summation algorithm.
4712 cgrad ghalfp=0.5D0*gggp(k)
4713 cgrad ghalfm=0.5D0*gggm(k)
4714 gacontp_hb1(k,num_conti,i)=!ghalfp
4715 & +(ecosap*(dc_norm(k,j)-cosa*dc_norm(k,i))
4716 & + ecosbp*(erij(k)-cosb*dc_norm(k,i)))*vbld_inv(i+1)
4717 & *fac_shield(i)*fac_shield(j)
4719 gacontp_hb2(k,num_conti,i)=!ghalfp
4720 & +(ecosap*(dc_norm(k,i)-cosa*dc_norm(k,j))
4721 & + ecosgp*(erij(k)-cosg*dc_norm(k,j)))*vbld_inv(j+1)
4722 & *fac_shield(i)*fac_shield(j)
4724 gacontp_hb3(k,num_conti,i)=gggp(k)
4725 & *fac_shield(i)*fac_shield(j)
4727 gacontm_hb1(k,num_conti,i)=!ghalfm
4728 & +(ecosam*(dc_norm(k,j)-cosa*dc_norm(k,i))
4729 & + ecosbm*(erij(k)-cosb*dc_norm(k,i)))*vbld_inv(i+1)
4730 & *fac_shield(i)*fac_shield(j)
4732 gacontm_hb2(k,num_conti,i)=!ghalfm
4733 & +(ecosam*(dc_norm(k,i)-cosa*dc_norm(k,j))
4734 & + ecosgm*(erij(k)-cosg*dc_norm(k,j)))*vbld_inv(j+1)
4735 & *fac_shield(i)*fac_shield(j)
4737 gacontm_hb3(k,num_conti,i)=gggm(k)
4738 & *fac_shield(i)*fac_shield(j)
4741 C Diagnostics. Comment out or remove after debugging!
4743 cdiag gacontp_hb1(k,num_conti,i)=0.0D0
4744 cdiag gacontp_hb2(k,num_conti,i)=0.0D0
4745 cdiag gacontp_hb3(k,num_conti,i)=0.0D0
4746 cdiag gacontm_hb1(k,num_conti,i)=0.0D0
4747 cdiag gacontm_hb2(k,num_conti,i)=0.0D0
4748 cdiag gacontm_hb3(k,num_conti,i)=0.0D0
4751 endif ! num_conti.le.maxconts
4754 if (wturn3.gt.0.0d0 .or. wturn4.gt.0.0d0) then
4757 ghalf=0.5d0*agg(l,k)
4758 aggi(l,k)=aggi(l,k)+ghalf
4759 aggi1(l,k)=aggi1(l,k)+agg(l,k)
4760 aggj(l,k)=aggj(l,k)+ghalf
4763 if (j.eq.nres-1 .and. i.lt.j-2) then
4766 aggj1(l,k)=aggj1(l,k)+agg(l,k)
4771 c t_eelecij=t_eelecij+MPI_Wtime()-time00
4774 C-----------------------------------------------------------------------------
4775 subroutine eturn3(i,eello_turn3)
4776 C Third- and fourth-order contributions from turns
4777 implicit real*8 (a-h,o-z)
4778 include 'DIMENSIONS'
4779 include 'COMMON.IOUNITS'
4780 include 'COMMON.GEO'
4781 include 'COMMON.VAR'
4782 include 'COMMON.LOCAL'
4783 include 'COMMON.CHAIN'
4784 include 'COMMON.DERIV'
4785 include 'COMMON.INTERACT'
4786 include 'COMMON.CONTACTS'
4787 include 'COMMON.TORSION'
4788 include 'COMMON.VECTORS'
4789 include 'COMMON.FFIELD'
4790 include 'COMMON.CONTROL'
4791 include 'COMMON.SHIELD'
4793 double precision auxmat(2,2),auxmat1(2,2),auxmat2(2,2),pizda(2,2),
4794 & e1t(2,2),e2t(2,2),e3t(2,2),e1tder(2,2),e2tder(2,2),e3tder(2,2),
4795 & e1a(2,2),ae3(2,2),ae3e2(2,2),auxvec(2),auxvec1(2),gpizda1(2,2),
4796 & gpizda2(2,2),auxgmat1(2,2),auxgmatt1(2,2),
4797 & auxgmat2(2,2),auxgmatt2(2,2)
4798 double precision agg(3,4),aggi(3,4),aggi1(3,4),
4799 & aggj(3,4),aggj1(3,4),a_temp(2,2),auxmat3(2,2)
4800 common /locel/ a_temp,agg,aggi,aggi1,aggj,aggj1,a22,a23,a32,a33,
4801 & dxi,dyi,dzi,dx_normi,dy_normi,dz_normi,xmedi,ymedi,zmedi,
4804 c write (iout,*) "eturn3",i,j,j1,j2
4809 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
4811 C Third-order contributions
4818 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
4819 cd call checkint_turn3(i,a_temp,eello_turn3_num)
4820 call matmat2(EUg(1,1,i+1),EUg(1,1,i+2),auxmat(1,1))
4821 c auxalary matices for theta gradient
4822 c auxalary matrix for i+1 and constant i+2
4823 call matmat2(gtEUg(1,1,i+1),EUg(1,1,i+2),auxgmat1(1,1))
4824 c auxalary matrix for i+2 and constant i+1
4825 call matmat2(EUg(1,1,i+1),gtEUg(1,1,i+2),auxgmat2(1,1))
4826 call transpose2(auxmat(1,1),auxmat1(1,1))
4827 call transpose2(auxgmat1(1,1),auxgmatt1(1,1))
4828 call transpose2(auxgmat2(1,1),auxgmatt2(1,1))
4829 call matmat2(a_temp(1,1),auxmat1(1,1),pizda(1,1))
4830 call matmat2(a_temp(1,1),auxgmatt1(1,1),gpizda1(1,1))
4831 call matmat2(a_temp(1,1),auxgmatt2(1,1),gpizda2(1,1))
4832 if (shield_mode.eq.0) then
4839 eello_turn3=eello_turn3+0.5d0*(pizda(1,1)+pizda(2,2))
4840 & *fac_shield(i)*fac_shield(j)
4841 eello_t3=0.5d0*(pizda(1,1)+pizda(2,2))
4842 & *fac_shield(i)*fac_shield(j)
4843 if (energy_dec) write (iout,'(6heturn3,2i5,0pf7.3)') i,i+2,
4846 C Derivatives in theta
4847 gloc(nphi+i,icg)=gloc(nphi+i,icg)
4848 & +0.5d0*(gpizda1(1,1)+gpizda1(2,2))*wturn3
4849 & *fac_shield(i)*fac_shield(j)
4850 gloc(nphi+i+1,icg)=gloc(nphi+i+1,icg)
4851 & +0.5d0*(gpizda2(1,1)+gpizda2(2,2))*wturn3
4852 & *fac_shield(i)*fac_shield(j)
4855 C Derivatives in shield mode
4856 if ((fac_shield(i).gt.0).and.(fac_shield(j).gt.0).and.
4857 & (shield_mode.gt.0)) then
4860 do ilist=1,ishield_list(i)
4861 iresshield=shield_list(ilist,i)
4863 rlocshield=grad_shield_side(k,ilist,i)*eello_t3/fac_shield(i)
4865 gshieldx_t3(k,iresshield)=gshieldx_t3(k,iresshield)+
4867 & +grad_shield_loc(k,ilist,i)*eello_t3/fac_shield(i)
4868 gshieldc_t3(k,iresshield-1)=gshieldc_t3(k,iresshield-1)
4872 do ilist=1,ishield_list(j)
4873 iresshield=shield_list(ilist,j)
4875 rlocshield=grad_shield_side(k,ilist,j)*eello_t3/fac_shield(j)
4877 gshieldx_t3(k,iresshield)=gshieldx_t3(k,iresshield)+
4879 & +grad_shield_loc(k,ilist,j)*eello_t3/fac_shield(j)
4880 gshieldc_t3(k,iresshield-1)=gshieldc_t3(k,iresshield-1)
4887 gshieldc_t3(k,i)=gshieldc_t3(k,i)+
4888 & grad_shield(k,i)*eello_t3/fac_shield(i)
4889 gshieldc_t3(k,j)=gshieldc_t3(k,j)+
4890 & grad_shield(k,j)*eello_t3/fac_shield(j)
4891 gshieldc_t3(k,i-1)=gshieldc_t3(k,i-1)+
4892 & grad_shield(k,i)*eello_t3/fac_shield(i)
4893 gshieldc_t3(k,j-1)=gshieldc_t3(k,j-1)+
4894 & grad_shield(k,j)*eello_t3/fac_shield(j)
4898 C if (energy_dec) write (iout,'(a6,2i5,0pf7.3)')
4899 cd write (2,*) 'i,',i,' j',j,'eello_turn3',
4900 cd & 0.5d0*(pizda(1,1)+pizda(2,2)),
4901 cd & ' eello_turn3_num',4*eello_turn3_num
4902 C Derivatives in gamma(i)
4903 call matmat2(EUgder(1,1,i+1),EUg(1,1,i+2),auxmat2(1,1))
4904 call transpose2(auxmat2(1,1),auxmat3(1,1))
4905 call matmat2(a_temp(1,1),auxmat3(1,1),pizda(1,1))
4906 gel_loc_turn3(i)=gel_loc_turn3(i)+0.5d0*(pizda(1,1)+pizda(2,2))
4907 & *fac_shield(i)*fac_shield(j)
4908 C Derivatives in gamma(i+1)
4909 call matmat2(EUg(1,1,i+1),EUgder(1,1,i+2),auxmat2(1,1))
4910 call transpose2(auxmat2(1,1),auxmat3(1,1))
4911 call matmat2(a_temp(1,1),auxmat3(1,1),pizda(1,1))
4912 gel_loc_turn3(i+1)=gel_loc_turn3(i+1)
4913 & +0.5d0*(pizda(1,1)+pizda(2,2))
4914 & *fac_shield(i)*fac_shield(j)
4915 C Cartesian derivatives
4917 c ghalf1=0.5d0*agg(l,1)
4918 c ghalf2=0.5d0*agg(l,2)
4919 c ghalf3=0.5d0*agg(l,3)
4920 c ghalf4=0.5d0*agg(l,4)
4921 a_temp(1,1)=aggi(l,1)!+ghalf1
4922 a_temp(1,2)=aggi(l,2)!+ghalf2
4923 a_temp(2,1)=aggi(l,3)!+ghalf3
4924 a_temp(2,2)=aggi(l,4)!+ghalf4
4925 call matmat2(a_temp(1,1),auxmat1(1,1),pizda(1,1))
4926 gcorr3_turn(l,i)=gcorr3_turn(l,i)
4927 & +0.5d0*(pizda(1,1)+pizda(2,2))
4928 & *fac_shield(i)*fac_shield(j)
4930 a_temp(1,1)=aggi1(l,1)!+agg(l,1)
4931 a_temp(1,2)=aggi1(l,2)!+agg(l,2)
4932 a_temp(2,1)=aggi1(l,3)!+agg(l,3)
4933 a_temp(2,2)=aggi1(l,4)!+agg(l,4)
4934 call matmat2(a_temp(1,1),auxmat1(1,1),pizda(1,1))
4935 gcorr3_turn(l,i+1)=gcorr3_turn(l,i+1)
4936 & +0.5d0*(pizda(1,1)+pizda(2,2))
4937 & *fac_shield(i)*fac_shield(j)
4938 a_temp(1,1)=aggj(l,1)!+ghalf1
4939 a_temp(1,2)=aggj(l,2)!+ghalf2
4940 a_temp(2,1)=aggj(l,3)!+ghalf3
4941 a_temp(2,2)=aggj(l,4)!+ghalf4
4942 call matmat2(a_temp(1,1),auxmat1(1,1),pizda(1,1))
4943 gcorr3_turn(l,j)=gcorr3_turn(l,j)
4944 & +0.5d0*(pizda(1,1)+pizda(2,2))
4945 & *fac_shield(i)*fac_shield(j)
4946 a_temp(1,1)=aggj1(l,1)
4947 a_temp(1,2)=aggj1(l,2)
4948 a_temp(2,1)=aggj1(l,3)
4949 a_temp(2,2)=aggj1(l,4)
4950 call matmat2(a_temp(1,1),auxmat1(1,1),pizda(1,1))
4951 gcorr3_turn(l,j1)=gcorr3_turn(l,j1)
4952 & +0.5d0*(pizda(1,1)+pizda(2,2))
4953 & *fac_shield(i)*fac_shield(j)
4957 C-------------------------------------------------------------------------------
4958 subroutine eturn4(i,eello_turn4)
4959 C Third- and fourth-order contributions from turns
4960 implicit real*8 (a-h,o-z)
4961 include 'DIMENSIONS'
4962 include 'COMMON.IOUNITS'
4963 include 'COMMON.GEO'
4964 include 'COMMON.VAR'
4965 include 'COMMON.LOCAL'
4966 include 'COMMON.CHAIN'
4967 include 'COMMON.DERIV'
4968 include 'COMMON.INTERACT'
4969 include 'COMMON.CONTACTS'
4970 include 'COMMON.TORSION'
4971 include 'COMMON.VECTORS'
4972 include 'COMMON.FFIELD'
4973 include 'COMMON.CONTROL'
4974 include 'COMMON.SHIELD'
4976 double precision auxmat(2,2),auxmat1(2,2),auxmat2(2,2),pizda(2,2),
4977 & e1t(2,2),e2t(2,2),e3t(2,2),e1tder(2,2),e2tder(2,2),e3tder(2,2),
4978 & e1a(2,2),ae3(2,2),ae3e2(2,2),auxvec(2),auxvec1(2),auxgvec(2),
4979 & auxgEvec1(2),auxgEvec2(2),auxgEvec3(2),
4980 & gte1t(2,2),gte2t(2,2),gte3t(2,2),
4981 & gte1a(2,2),gtae3(2,2),gtae3e2(2,2), ae3gte2(2,2),
4982 & gtEpizda1(2,2),gtEpizda2(2,2),gtEpizda3(2,2)
4983 double precision agg(3,4),aggi(3,4),aggi1(3,4),
4984 & aggj(3,4),aggj1(3,4),a_temp(2,2),auxmat3(2,2)
4985 common /locel/ a_temp,agg,aggi,aggi1,aggj,aggj1,a22,a23,a32,a33,
4986 & dxi,dyi,dzi,dx_normi,dy_normi,dz_normi,xmedi,ymedi,zmedi,
4989 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
4991 C Fourth-order contributions
4999 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
5000 cd call checkint_turn4(i,a_temp,eello_turn4_num)
5001 c write (iout,*) "eturn4 i",i," j",j," j1",j1," j2",j2
5002 c write(iout,*)"WCHODZE W PROGRAM"
5007 iti1=itype2loc(itype(i+1))
5008 iti2=itype2loc(itype(i+2))
5009 iti3=itype2loc(itype(i+3))
5010 c write(iout,*) "iti1",iti1," iti2",iti2," iti3",iti3
5011 call transpose2(EUg(1,1,i+1),e1t(1,1))
5012 call transpose2(Eug(1,1,i+2),e2t(1,1))
5013 call transpose2(Eug(1,1,i+3),e3t(1,1))
5014 C Ematrix derivative in theta
5015 call transpose2(gtEUg(1,1,i+1),gte1t(1,1))
5016 call transpose2(gtEug(1,1,i+2),gte2t(1,1))
5017 call transpose2(gtEug(1,1,i+3),gte3t(1,1))
5018 call matmat2(e1t(1,1),a_temp(1,1),e1a(1,1))
5019 c eta1 in derivative theta
5020 call matmat2(gte1t(1,1),a_temp(1,1),gte1a(1,1))
5021 call matvec2(e1a(1,1),Ub2(1,i+3),auxvec(1))
5022 c auxgvec is derivative of Ub2 so i+3 theta
5023 call matvec2(e1a(1,1),gUb2(1,i+3),auxgvec(1))
5024 c auxalary matrix of E i+1
5025 call matvec2(gte1a(1,1),Ub2(1,i+3),auxgEvec1(1))
5028 s1=scalar2(b1(1,i+2),auxvec(1))
5029 c derivative of theta i+2 with constant i+3
5030 gs23=scalar2(gtb1(1,i+2),auxvec(1))
5031 c derivative of theta i+2 with constant i+2
5032 gs32=scalar2(b1(1,i+2),auxgvec(1))
5033 c derivative of E matix in theta of i+1
5034 gsE13=scalar2(b1(1,i+2),auxgEvec1(1))
5036 call matmat2(a_temp(1,1),e3t(1,1),ae3(1,1))
5037 c ea31 in derivative theta
5038 call matmat2(a_temp(1,1),gte3t(1,1),gtae3(1,1))
5039 call matvec2(ae3(1,1),Ub2(1,i+2),auxvec(1))
5040 c auxilary matrix auxgvec of Ub2 with constant E matirx
5041 call matvec2(ae3(1,1),gUb2(1,i+2),auxgvec(1))
5042 c auxilary matrix auxgEvec1 of E matix with Ub2 constant
5043 call matvec2(gtae3(1,1),Ub2(1,i+2),auxgEvec3(1))
5047 s2=scalar2(b1(1,i+1),auxvec(1))
5048 c derivative of theta i+1 with constant i+3
5049 gs13=scalar2(gtb1(1,i+1),auxvec(1))
5050 c derivative of theta i+2 with constant i+1
5051 gs21=scalar2(b1(1,i+1),auxgvec(1))
5052 c derivative of theta i+3 with constant i+1
5053 gsE31=scalar2(b1(1,i+1),auxgEvec3(1))
5054 c write(iout,*) gs1,gs2,'i=',i,auxgvec(1),gUb2(1,i+2),gtb1(1,i+2),
5056 call matmat2(ae3(1,1),e2t(1,1),ae3e2(1,1))
5057 c two derivatives over diffetent matrices
5058 c gtae3e2 is derivative over i+3
5059 call matmat2(gtae3(1,1),e2t(1,1),gtae3e2(1,1))
5060 c ae3gte2 is derivative over i+2
5061 call matmat2(ae3(1,1),gte2t(1,1),ae3gte2(1,1))
5062 call matmat2(ae3e2(1,1),e1t(1,1),pizda(1,1))
5063 c three possible derivative over theta E matices
5065 call matmat2(ae3e2(1,1),gte1t(1,1),gtEpizda1(1,1))
5067 call matmat2(ae3gte2(1,1),e1t(1,1),gtEpizda2(1,1))
5069 call matmat2(gtae3e2(1,1),e1t(1,1),gtEpizda3(1,1))
5070 s3=0.5d0*(pizda(1,1)+pizda(2,2))
5072 gsEE1=0.5d0*(gtEpizda1(1,1)+gtEpizda1(2,2))
5073 gsEE2=0.5d0*(gtEpizda2(1,1)+gtEpizda2(2,2))
5074 gsEE3=0.5d0*(gtEpizda3(1,1)+gtEpizda3(2,2))
5075 if (shield_mode.eq.0) then
5082 eello_turn4=eello_turn4-(s1+s2+s3)
5083 & *fac_shield(i)*fac_shield(j)
5084 eello_t4=-(s1+s2+s3)
5085 & *fac_shield(i)*fac_shield(j)
5086 c write(iout,*)'chujOWO', auxvec(1),b1(1,iti2)
5087 if (energy_dec) write (iout,'(a6,2i5,0pf7.3,3f7.3)')
5088 & 'eturn4',i,j,-(s1+s2+s3),s1,s2,s3
5089 C Now derivative over shield:
5090 if ((fac_shield(i).gt.0).and.(fac_shield(j).gt.0).and.
5091 & (shield_mode.gt.0)) then
5094 do ilist=1,ishield_list(i)
5095 iresshield=shield_list(ilist,i)
5097 rlocshield=grad_shield_side(k,ilist,i)*eello_t4/fac_shield(i)
5099 gshieldx_t4(k,iresshield)=gshieldx_t4(k,iresshield)+
5101 & +grad_shield_loc(k,ilist,i)*eello_t4/fac_shield(i)
5102 gshieldc_t4(k,iresshield-1)=gshieldc_t4(k,iresshield-1)
5106 do ilist=1,ishield_list(j)
5107 iresshield=shield_list(ilist,j)
5109 rlocshield=grad_shield_side(k,ilist,j)*eello_t4/fac_shield(j)
5111 gshieldx_t4(k,iresshield)=gshieldx_t4(k,iresshield)+
5113 & +grad_shield_loc(k,ilist,j)*eello_t4/fac_shield(j)
5114 gshieldc_t4(k,iresshield-1)=gshieldc_t4(k,iresshield-1)
5121 gshieldc_t4(k,i)=gshieldc_t4(k,i)+
5122 & grad_shield(k,i)*eello_t4/fac_shield(i)
5123 gshieldc_t4(k,j)=gshieldc_t4(k,j)+
5124 & grad_shield(k,j)*eello_t4/fac_shield(j)
5125 gshieldc_t4(k,i-1)=gshieldc_t4(k,i-1)+
5126 & grad_shield(k,i)*eello_t4/fac_shield(i)
5127 gshieldc_t4(k,j-1)=gshieldc_t4(k,j-1)+
5128 & grad_shield(k,j)*eello_t4/fac_shield(j)
5137 cd write (2,*) 'i,',i,' j',j,'eello_turn4',-(s1+s2+s3),
5138 cd & ' eello_turn4_num',8*eello_turn4_num
5140 gloc(nphi+i,icg)=gloc(nphi+i,icg)
5141 & -(gs13+gsE13+gsEE1)*wturn4
5142 & *fac_shield(i)*fac_shield(j)
5143 gloc(nphi+i+1,icg)= gloc(nphi+i+1,icg)
5144 & -(gs23+gs21+gsEE2)*wturn4
5145 & *fac_shield(i)*fac_shield(j)
5147 gloc(nphi+i+2,icg)= gloc(nphi+i+2,icg)
5148 & -(gs32+gsE31+gsEE3)*wturn4
5149 & *fac_shield(i)*fac_shield(j)
5151 c gloc(nphi+i+1,icg)=gloc(nphi+i+1,icg)-
5154 if (energy_dec) write (iout,'(a6,2i5,0pf7.3)')
5155 & 'eturn4',i,j,-(s1+s2+s3)
5156 c write (iout,*) 'i,',i,' j',j,'eello_turn4',-(s1+s2+s3),
5157 c & ' eello_turn4_num',8*eello_turn4_num
5158 C Derivatives in gamma(i)
5159 call transpose2(EUgder(1,1,i+1),e1tder(1,1))
5160 call matmat2(e1tder(1,1),a_temp(1,1),auxmat(1,1))
5161 call matvec2(auxmat(1,1),Ub2(1,i+3),auxvec(1))
5162 s1=scalar2(b1(1,i+2),auxvec(1))
5163 call matmat2(ae3e2(1,1),e1tder(1,1),pizda(1,1))
5164 s3=0.5d0*(pizda(1,1)+pizda(2,2))
5165 gel_loc_turn4(i)=gel_loc_turn4(i)-(s1+s3)
5166 & *fac_shield(i)*fac_shield(j)
5167 C Derivatives in gamma(i+1)
5168 call transpose2(EUgder(1,1,i+2),e2tder(1,1))
5169 call matvec2(ae3(1,1),Ub2der(1,i+2),auxvec(1))
5170 s2=scalar2(b1(1,i+1),auxvec(1))
5171 call matmat2(ae3(1,1),e2tder(1,1),auxmat(1,1))
5172 call matmat2(auxmat(1,1),e1t(1,1),pizda(1,1))
5173 s3=0.5d0*(pizda(1,1)+pizda(2,2))
5174 gel_loc_turn4(i+1)=gel_loc_turn4(i+1)-(s2+s3)
5175 & *fac_shield(i)*fac_shield(j)
5176 C Derivatives in gamma(i+2)
5177 call transpose2(EUgder(1,1,i+3),e3tder(1,1))
5178 call matvec2(e1a(1,1),Ub2der(1,i+3),auxvec(1))
5179 s1=scalar2(b1(1,i+2),auxvec(1))
5180 call matmat2(a_temp(1,1),e3tder(1,1),auxmat(1,1))
5181 call matvec2(auxmat(1,1),Ub2(1,i+2),auxvec(1))
5182 s2=scalar2(b1(1,i+1),auxvec(1))
5183 call matmat2(auxmat(1,1),e2t(1,1),auxmat3(1,1))
5184 call matmat2(auxmat3(1,1),e1t(1,1),pizda(1,1))
5185 s3=0.5d0*(pizda(1,1)+pizda(2,2))
5186 gel_loc_turn4(i+2)=gel_loc_turn4(i+2)-(s1+s2+s3)
5187 & *fac_shield(i)*fac_shield(j)
5188 C Cartesian derivatives
5189 C Derivatives of this turn contributions in DC(i+2)
5190 if (j.lt.nres-1) then
5192 a_temp(1,1)=agg(l,1)
5193 a_temp(1,2)=agg(l,2)
5194 a_temp(2,1)=agg(l,3)
5195 a_temp(2,2)=agg(l,4)
5196 call matmat2(e1t(1,1),a_temp(1,1),e1a(1,1))
5197 call matvec2(e1a(1,1),Ub2(1,i+3),auxvec(1))
5198 s1=scalar2(b1(1,i+2),auxvec(1))
5199 call matmat2(a_temp(1,1),e3t(1,1),ae3(1,1))
5200 call matvec2(ae3(1,1),Ub2(1,i+2),auxvec(1))
5201 s2=scalar2(b1(1,i+1),auxvec(1))
5202 call matmat2(ae3(1,1),e2t(1,1),ae3e2(1,1))
5203 call matmat2(ae3e2(1,1),e1t(1,1),pizda(1,1))
5204 s3=0.5d0*(pizda(1,1)+pizda(2,2))
5206 gcorr4_turn(l,i+2)=gcorr4_turn(l,i+2)-(s1+s2+s3)
5207 & *fac_shield(i)*fac_shield(j)
5210 C Remaining derivatives of this turn contribution
5212 a_temp(1,1)=aggi(l,1)
5213 a_temp(1,2)=aggi(l,2)
5214 a_temp(2,1)=aggi(l,3)
5215 a_temp(2,2)=aggi(l,4)
5216 call matmat2(e1t(1,1),a_temp(1,1),e1a(1,1))
5217 call matvec2(e1a(1,1),Ub2(1,i+3),auxvec(1))
5218 s1=scalar2(b1(1,i+2),auxvec(1))
5219 call matmat2(a_temp(1,1),e3t(1,1),ae3(1,1))
5220 call matvec2(ae3(1,1),Ub2(1,i+2),auxvec(1))
5221 s2=scalar2(b1(1,i+1),auxvec(1))
5222 call matmat2(ae3(1,1),e2t(1,1),ae3e2(1,1))
5223 call matmat2(ae3e2(1,1),e1t(1,1),pizda(1,1))
5224 s3=0.5d0*(pizda(1,1)+pizda(2,2))
5225 gcorr4_turn(l,i)=gcorr4_turn(l,i)-(s1+s2+s3)
5226 & *fac_shield(i)*fac_shield(j)
5227 a_temp(1,1)=aggi1(l,1)
5228 a_temp(1,2)=aggi1(l,2)
5229 a_temp(2,1)=aggi1(l,3)
5230 a_temp(2,2)=aggi1(l,4)
5231 call matmat2(e1t(1,1),a_temp(1,1),e1a(1,1))
5232 call matvec2(e1a(1,1),Ub2(1,i+3),auxvec(1))
5233 s1=scalar2(b1(1,i+2),auxvec(1))
5234 call matmat2(a_temp(1,1),e3t(1,1),ae3(1,1))
5235 call matvec2(ae3(1,1),Ub2(1,i+2),auxvec(1))
5236 s2=scalar2(b1(1,i+1),auxvec(1))
5237 call matmat2(ae3(1,1),e2t(1,1),ae3e2(1,1))
5238 call matmat2(ae3e2(1,1),e1t(1,1),pizda(1,1))
5239 s3=0.5d0*(pizda(1,1)+pizda(2,2))
5240 gcorr4_turn(l,i+1)=gcorr4_turn(l,i+1)-(s1+s2+s3)
5241 & *fac_shield(i)*fac_shield(j)
5242 a_temp(1,1)=aggj(l,1)
5243 a_temp(1,2)=aggj(l,2)
5244 a_temp(2,1)=aggj(l,3)
5245 a_temp(2,2)=aggj(l,4)
5246 call matmat2(e1t(1,1),a_temp(1,1),e1a(1,1))
5247 call matvec2(e1a(1,1),Ub2(1,i+3),auxvec(1))
5248 s1=scalar2(b1(1,i+2),auxvec(1))
5249 call matmat2(a_temp(1,1),e3t(1,1),ae3(1,1))
5250 call matvec2(ae3(1,1),Ub2(1,i+2),auxvec(1))
5251 s2=scalar2(b1(1,i+1),auxvec(1))
5252 call matmat2(ae3(1,1),e2t(1,1),ae3e2(1,1))
5253 call matmat2(ae3e2(1,1),e1t(1,1),pizda(1,1))
5254 s3=0.5d0*(pizda(1,1)+pizda(2,2))
5255 gcorr4_turn(l,j)=gcorr4_turn(l,j)-(s1+s2+s3)
5256 & *fac_shield(i)*fac_shield(j)
5257 a_temp(1,1)=aggj1(l,1)
5258 a_temp(1,2)=aggj1(l,2)
5259 a_temp(2,1)=aggj1(l,3)
5260 a_temp(2,2)=aggj1(l,4)
5261 call matmat2(e1t(1,1),a_temp(1,1),e1a(1,1))
5262 call matvec2(e1a(1,1),Ub2(1,i+3),auxvec(1))
5263 s1=scalar2(b1(1,i+2),auxvec(1))
5264 call matmat2(a_temp(1,1),e3t(1,1),ae3(1,1))
5265 call matvec2(ae3(1,1),Ub2(1,i+2),auxvec(1))
5266 s2=scalar2(b1(1,i+1),auxvec(1))
5267 call matmat2(ae3(1,1),e2t(1,1),ae3e2(1,1))
5268 call matmat2(ae3e2(1,1),e1t(1,1),pizda(1,1))
5269 s3=0.5d0*(pizda(1,1)+pizda(2,2))
5270 c write (iout,*) "s1",s1," s2",s2," s3",s3," s1+s2+s3",s1+s2+s3
5271 gcorr4_turn(l,j1)=gcorr4_turn(l,j1)-(s1+s2+s3)
5272 & *fac_shield(i)*fac_shield(j)
5276 C-----------------------------------------------------------------------------
5277 subroutine vecpr(u,v,w)
5278 implicit real*8(a-h,o-z)
5279 dimension u(3),v(3),w(3)
5280 w(1)=u(2)*v(3)-u(3)*v(2)
5281 w(2)=-u(1)*v(3)+u(3)*v(1)
5282 w(3)=u(1)*v(2)-u(2)*v(1)
5285 C-----------------------------------------------------------------------------
5286 subroutine unormderiv(u,ugrad,unorm,ungrad)
5287 C This subroutine computes the derivatives of a normalized vector u, given
5288 C the derivatives computed without normalization conditions, ugrad. Returns
5291 double precision u(3),ugrad(3,3),unorm,ungrad(3,3)
5292 double precision vec(3)
5293 double precision scalar
5295 c write (2,*) 'ugrad',ugrad
5298 vec(i)=scalar(ugrad(1,i),u(1))
5300 c write (2,*) 'vec',vec
5303 ungrad(j,i)=(ugrad(j,i)-u(j)*vec(i))*unorm
5306 c write (2,*) 'ungrad',ungrad
5309 C-----------------------------------------------------------------------------
5310 subroutine escp_soft_sphere(evdw2,evdw2_14)
5312 C This subroutine calculates the excluded-volume interaction energy between
5313 C peptide-group centers and side chains and its gradient in virtual-bond and
5314 C side-chain vectors.
5316 implicit real*8 (a-h,o-z)
5317 include 'DIMENSIONS'
5318 include 'COMMON.GEO'
5319 include 'COMMON.VAR'
5320 include 'COMMON.LOCAL'
5321 include 'COMMON.CHAIN'
5322 include 'COMMON.DERIV'
5323 include 'COMMON.INTERACT'
5324 include 'COMMON.FFIELD'
5325 include 'COMMON.IOUNITS'
5326 include 'COMMON.CONTROL'
5328 integer xshift,yshift,zshift
5332 cd print '(a)','Enter ESCP'
5333 cd write (iout,*) 'iatscp_s=',iatscp_s,' iatscp_e=',iatscp_e
5337 do i=iatscp_s,iatscp_e
5338 if (itype(i).eq.ntyp1 .or. itype(i+1).eq.ntyp1) cycle
5340 xi=0.5D0*(c(1,i)+c(1,i+1))
5341 yi=0.5D0*(c(2,i)+c(2,i+1))
5342 zi=0.5D0*(c(3,i)+c(3,i+1))
5343 C Return atom into box, boxxsize is size of box in x dimension
5345 c if (xi.gt.((xshift+0.5d0)*boxxsize)) xi=xi-boxxsize
5346 c if (xi.lt.((xshift-0.5d0)*boxxsize)) xi=xi+boxxsize
5347 C Condition for being inside the proper box
5348 c if ((xi.gt.((xshift+0.5d0)*boxxsize)).or.
5349 c & (xi.lt.((xshift-0.5d0)*boxxsize))) then
5353 c if (yi.gt.((yshift+0.5d0)*boxysize)) yi=yi-boxysize
5354 c if (yi.lt.((yshift-0.5d0)*boxysize)) yi=yi+boxysize
5355 C Condition for being inside the proper box
5356 c if ((yi.gt.((yshift+0.5d0)*boxysize)).or.
5357 c & (yi.lt.((yshift-0.5d0)*boxysize))) then
5361 c if (zi.gt.((zshift+0.5d0)*boxzsize)) zi=zi-boxzsize
5362 c if (zi.lt.((zshift-0.5d0)*boxzsize)) zi=zi+boxzsize
5363 cC Condition for being inside the proper box
5364 c if ((zi.gt.((zshift+0.5d0)*boxzsize)).or.
5365 c & (zi.lt.((zshift-0.5d0)*boxzsize))) then
5369 if (xi.lt.0) xi=xi+boxxsize
5371 if (yi.lt.0) yi=yi+boxysize
5373 if (zi.lt.0) zi=zi+boxzsize
5374 C xi=xi+xshift*boxxsize
5375 C yi=yi+yshift*boxysize
5376 C zi=zi+zshift*boxzsize
5377 do iint=1,nscp_gr(i)
5379 do j=iscpstart(i,iint),iscpend(i,iint)
5380 if (itype(j).eq.ntyp1) cycle
5381 itypj=iabs(itype(j))
5382 C Uncomment following three lines for SC-p interactions
5386 C Uncomment following three lines for Ca-p interactions
5391 c if (xj.gt.((0.5d0)*boxxsize)) xj=xj-boxxsize
5392 c if (xj.lt.((-0.5d0)*boxxsize)) xj=xj+boxxsize
5393 C Condition for being inside the proper box
5394 c if ((xj.gt.((0.5d0)*boxxsize)).or.
5395 c & (xj.lt.((-0.5d0)*boxxsize))) then
5399 c if (yj.gt.((0.5d0)*boxysize)) yj=yj-boxysize
5400 c if (yj.lt.((-0.5d0)*boxysize)) yj=yj+boxysize
5401 cC Condition for being inside the proper box
5402 c if ((yj.gt.((0.5d0)*boxysize)).or.
5403 c & (yj.lt.((-0.5d0)*boxysize))) then
5407 c if (zj.gt.((0.5d0)*boxzsize)) zj=zj-boxzsize
5408 c if (zj.lt.((-0.5d0)*boxzsize)) zj=zj+boxzsize
5409 C Condition for being inside the proper box
5410 c if ((zj.gt.((0.5d0)*boxzsize)).or.
5411 c & (zj.lt.((-0.5d0)*boxzsize))) then
5414 if (xj.lt.0) xj=xj+boxxsize
5416 if (yj.lt.0) yj=yj+boxysize
5418 if (zj.lt.0) zj=zj+boxzsize
5419 dist_init=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
5427 xj=xj_safe+xshift*boxxsize
5428 yj=yj_safe+yshift*boxysize
5429 zj=zj_safe+zshift*boxzsize
5430 dist_temp=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
5431 if(dist_temp.lt.dist_init) then
5441 if (subchap.eq.1) then
5454 rij=xj*xj+yj*yj+zj*zj
5458 if (rij.lt.r0ijsq) then
5459 evdwij=0.25d0*(rij-r0ijsq)**2
5467 C Calculate contributions to the gradient in the virtual-bond and SC vectors.
5472 cgrad if (j.lt.i) then
5473 cd write (iout,*) 'j<i'
5474 C Uncomment following three lines for SC-p interactions
5476 c gradx_scp(k,j)=gradx_scp(k,j)+ggg(k)
5479 cd write (iout,*) 'j>i'
5481 cgrad ggg(k)=-ggg(k)
5482 C Uncomment following line for SC-p interactions
5483 c gradx_scp(k,j)=gradx_scp(k,j)-ggg(k)
5487 cgrad gvdwc_scp(k,i)=gvdwc_scp(k,i)-0.5D0*ggg(k)
5489 cgrad kstart=min0(i+1,j)
5490 cgrad kend=max0(i-1,j-1)
5491 cd write (iout,*) 'i=',i,' j=',j,' kstart=',kstart,' kend=',kend
5492 cd write (iout,*) ggg(1),ggg(2),ggg(3)
5493 cgrad do k=kstart,kend
5495 cgrad gvdwc_scp(l,k)=gvdwc_scp(l,k)-ggg(l)
5499 gvdwc_scpp(k,i)=gvdwc_scpp(k,i)-ggg(k)
5500 gvdwc_scp(k,j)=gvdwc_scp(k,j)+ggg(k)
5511 C-----------------------------------------------------------------------------
5512 subroutine escp(evdw2,evdw2_14)
5514 C This subroutine calculates the excluded-volume interaction energy between
5515 C peptide-group centers and side chains and its gradient in virtual-bond and
5516 C side-chain vectors.
5518 implicit real*8 (a-h,o-z)
5519 include 'DIMENSIONS'
5520 include 'COMMON.GEO'
5521 include 'COMMON.VAR'
5522 include 'COMMON.LOCAL'
5523 include 'COMMON.CHAIN'
5524 include 'COMMON.DERIV'
5525 include 'COMMON.INTERACT'
5526 include 'COMMON.FFIELD'
5527 include 'COMMON.IOUNITS'
5528 include 'COMMON.CONTROL'
5529 include 'COMMON.SPLITELE'
5530 integer xshift,yshift,zshift
5534 c print *,boxxsize,boxysize,boxzsize,'wymiary pudla'
5535 cd print '(a)','Enter ESCP'
5536 cd write (iout,*) 'iatscp_s=',iatscp_s,' iatscp_e=',iatscp_e
5540 if (energy_dec) write (iout,*) "escp:",r_cut,rlamb
5541 do i=iatscp_s,iatscp_e
5542 if (itype(i).eq.ntyp1 .or. itype(i+1).eq.ntyp1) cycle
5544 xi=0.5D0*(c(1,i)+c(1,i+1))
5545 yi=0.5D0*(c(2,i)+c(2,i+1))
5546 zi=0.5D0*(c(3,i)+c(3,i+1))
5548 if (xi.lt.0) xi=xi+boxxsize
5550 if (yi.lt.0) yi=yi+boxysize
5552 if (zi.lt.0) zi=zi+boxzsize
5553 c xi=xi+xshift*boxxsize
5554 c yi=yi+yshift*boxysize
5555 c zi=zi+zshift*boxzsize
5556 c print *,xi,yi,zi,'polozenie i'
5557 C Return atom into box, boxxsize is size of box in x dimension
5559 c if (xi.gt.((xshift+0.5d0)*boxxsize)) xi=xi-boxxsize
5560 c if (xi.lt.((xshift-0.5d0)*boxxsize)) xi=xi+boxxsize
5561 C Condition for being inside the proper box
5562 c if ((xi.gt.((xshift+0.5d0)*boxxsize)).or.
5563 c & (xi.lt.((xshift-0.5d0)*boxxsize))) then
5567 c print *,xi,boxxsize,"pierwszy"
5569 c if (yi.gt.((yshift+0.5d0)*boxysize)) yi=yi-boxysize
5570 c if (yi.lt.((yshift-0.5d0)*boxysize)) yi=yi+boxysize
5571 C Condition for being inside the proper box
5572 c if ((yi.gt.((yshift+0.5d0)*boxysize)).or.
5573 c & (yi.lt.((yshift-0.5d0)*boxysize))) then
5577 c if (zi.gt.((zshift+0.5d0)*boxzsize)) zi=zi-boxzsize
5578 c if (zi.lt.((zshift-0.5d0)*boxzsize)) zi=zi+boxzsize
5579 C Condition for being inside the proper box
5580 c if ((zi.gt.((zshift+0.5d0)*boxzsize)).or.
5581 c & (zi.lt.((zshift-0.5d0)*boxzsize))) then
5584 do iint=1,nscp_gr(i)
5586 do j=iscpstart(i,iint),iscpend(i,iint)
5587 itypj=iabs(itype(j))
5588 if (itypj.eq.ntyp1) cycle
5589 C Uncomment following three lines for SC-p interactions
5593 C Uncomment following three lines for Ca-p interactions
5598 if (xj.lt.0) xj=xj+boxxsize
5600 if (yj.lt.0) yj=yj+boxysize
5602 if (zj.lt.0) zj=zj+boxzsize
5604 c if (xj.gt.((0.5d0)*boxxsize)) xj=xj-boxxsize
5605 c if (xj.lt.((-0.5d0)*boxxsize)) xj=xj+boxxsize
5606 C Condition for being inside the proper box
5607 c if ((xj.gt.((0.5d0)*boxxsize)).or.
5608 c & (xj.lt.((-0.5d0)*boxxsize))) then
5612 c if (yj.gt.((0.5d0)*boxysize)) yj=yj-boxysize
5613 c if (yj.lt.((-0.5d0)*boxysize)) yj=yj+boxysize
5614 cC Condition for being inside the proper box
5615 c if ((yj.gt.((0.5d0)*boxysize)).or.
5616 c & (yj.lt.((-0.5d0)*boxysize))) then
5620 c if (zj.gt.((0.5d0)*boxzsize)) zj=zj-boxzsize
5621 c if (zj.lt.((-0.5d0)*boxzsize)) zj=zj+boxzsize
5622 C Condition for being inside the proper box
5623 c if ((zj.gt.((0.5d0)*boxzsize)).or.
5624 c & (zj.lt.((-0.5d0)*boxzsize))) then
5627 CHERE IS THE CALCULATION WHICH MIRROR IMAGE IS THE CLOSEST ONE
5628 dist_init=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
5636 xj=xj_safe+xshift*boxxsize
5637 yj=yj_safe+yshift*boxysize
5638 zj=zj_safe+zshift*boxzsize
5639 dist_temp=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
5640 if(dist_temp.lt.dist_init) then
5650 if (subchap.eq.1) then
5659 c print *,xj,yj,zj,'polozenie j'
5660 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
5662 sss=sscale(1.0d0/(dsqrt(rrij)))
5663 c print *,r_cut,1.0d0/dsqrt(rrij),sss,'tu patrz'
5664 c if (sss.eq.0) print *,'czasem jest OK'
5665 if (sss.le.0.0d0) cycle
5666 sssgrad=sscagrad(1.0d0/(dsqrt(rrij)))
5668 e1=fac*fac*aad(itypj,iteli)
5669 e2=fac*bad(itypj,iteli)
5670 if (iabs(j-i) .le. 2) then
5673 evdw2_14=evdw2_14+(e1+e2)*sss
5676 evdw2=evdw2+evdwij*sss
5677 if (energy_dec) write (iout,'(a6,2i5,0pf7.3,2i3,3e11.3)')
5678 & 'evdw2',i,j,evdwij,iteli,itypj,fac,aad(itypj,iteli),
5681 C Calculate contributions to the gradient in the virtual-bond and SC vectors.
5683 fac=-(evdwij+e1)*rrij*sss
5684 fac=fac+(evdwij)*sssgrad*dsqrt(rrij)/expon
5688 cgrad if (j.lt.i) then
5689 cd write (iout,*) 'j<i'
5690 C Uncomment following three lines for SC-p interactions
5692 c gradx_scp(k,j)=gradx_scp(k,j)+ggg(k)
5695 cd write (iout,*) 'j>i'
5697 cgrad ggg(k)=-ggg(k)
5698 C Uncomment following line for SC-p interactions
5699 ccgrad gradx_scp(k,j)=gradx_scp(k,j)-ggg(k)
5700 c gradx_scp(k,j)=gradx_scp(k,j)+ggg(k)
5704 cgrad gvdwc_scp(k,i)=gvdwc_scp(k,i)-0.5D0*ggg(k)
5706 cgrad kstart=min0(i+1,j)
5707 cgrad kend=max0(i-1,j-1)
5708 cd write (iout,*) 'i=',i,' j=',j,' kstart=',kstart,' kend=',kend
5709 cd write (iout,*) ggg(1),ggg(2),ggg(3)
5710 cgrad do k=kstart,kend
5712 cgrad gvdwc_scp(l,k)=gvdwc_scp(l,k)-ggg(l)
5716 gvdwc_scpp(k,i)=gvdwc_scpp(k,i)-ggg(k)
5717 gvdwc_scp(k,j)=gvdwc_scp(k,j)+ggg(k)
5719 c endif !endif for sscale cutoff
5729 gvdwc_scp(j,i)=expon*gvdwc_scp(j,i)
5730 gvdwc_scpp(j,i)=expon*gvdwc_scpp(j,i)
5731 gradx_scp(j,i)=expon*gradx_scp(j,i)
5734 C******************************************************************************
5738 C To save time the factor EXPON has been extracted from ALL components
5739 C of GVDWC and GRADX. Remember to multiply them by this factor before further
5742 C******************************************************************************
5745 C--------------------------------------------------------------------------
5746 subroutine edis(ehpb)
5748 C Evaluate bridge-strain energy and its gradient in virtual-bond and SC vectors.
5750 implicit real*8 (a-h,o-z)
5751 include 'DIMENSIONS'
5752 include 'COMMON.SBRIDGE'
5753 include 'COMMON.CHAIN'
5754 include 'COMMON.DERIV'
5755 include 'COMMON.VAR'
5756 include 'COMMON.INTERACT'
5757 include 'COMMON.IOUNITS'
5758 include 'COMMON.CONTROL'
5764 C write (iout,*) ,"link_end",link_end,constr_dist
5765 cd write(iout,*)'edis: nhpb=',nhpb,' fbr=',fbr
5766 c write(iout,*)'link_start=',link_start,' link_end=',link_end,
5767 c & " constr_dist",constr_dist
5768 if (link_end.eq.0) return
5769 do i=link_start,link_end
5770 C If ihpb(i) and jhpb(i) > NRES, this is a SC-SC distance, otherwise a
5771 C CA-CA distance used in regularization of structure.
5774 C iii and jjj point to the residues for which the distance is assigned.
5775 if (ii.gt.nres) then
5782 c write (iout,*) "i",i," ii",ii," iii",iii," jj",jj," jjj",jjj,
5783 c & dhpb(i),dhpb1(i),forcon(i)
5784 C 24/11/03 AL: SS bridges handled separately because of introducing a specific
5785 C distance and angle dependent SS bond potential.
5786 C if (ii.gt.nres .and. iabs(itype(iii)).eq.1 .and.
5787 C & iabs(itype(jjj)).eq.1) then
5788 cmc if (ii.gt.nres .and. itype(iii).eq.1 .and. itype(jjj).eq.1) then
5789 C 18/07/06 MC: Use the convention that the first nss pairs are SS bonds
5790 if (.not.dyn_ss .and. i.le.nss) then
5791 C 15/02/13 CC dynamic SSbond - additional check
5792 if (ii.gt.nres .and. iabs(itype(iii)).eq.1 .and.
5793 & iabs(itype(jjj)).eq.1) then
5794 call ssbond_ene(iii,jjj,eij)
5797 cd write (iout,*) "eij",eij
5798 cd & ' waga=',waga,' fac=',fac
5799 ! else if (ii.gt.nres .and. jj.gt.nres) then
5801 C Calculate the distance between the two points and its difference from the
5804 if (irestr_type(i).eq.11) then
5805 ehpb=ehpb+fordepth(i)!**4.0d0
5806 & *rlornmr1(dd,dhpb(i),dhpb1(i),forcon(i))
5807 fac=fordepth(i)!**4.0d0
5808 & *rlornmr1prim(dd,dhpb(i),dhpb1(i),forcon(i))/dd
5809 if (energy_dec) write (iout,'(a6,2i5,6f10.3,i5)')
5810 & "edisL",ii,jj,dd,dhpb(i),dhpb1(i),forcon(i),fordepth(i),
5811 & ehpb,irestr_type(i)
5812 else if (irestr_type(i).eq.10) then
5813 c AL 6//19/2018 cross-link restraints
5814 xdis = 0.5d0*(dd/forcon(i))**2
5815 expdis = dexp(-xdis)
5816 c aux=(dhpb(i)+dhpb1(i)*xdis)*expdis+fordepth(i)
5817 aux=(dhpb(i)+dhpb1(i)*xdis*xdis)*expdis+fordepth(i)
5818 c write (iout,*)"HERE: xdis",xdis," expdis",expdis," aux",aux,
5819 c & " wboltzd",wboltzd
5820 ehpb=ehpb-wboltzd*xlscore(i)*dlog(aux)
5821 c fac=-wboltzd*(dhpb1(i)*(1.0d0-xdis)-dhpb(i))
5822 fac=-wboltzd*xlscore(i)*(dhpb1(i)*(2.0d0-xdis)*xdis-dhpb(i))
5823 & *expdis/(aux*forcon(i)**2)
5824 if (energy_dec) write(iout,'(a6,2i5,6f10.3,i5)')
5825 & "edisX",ii,jj,dd,dhpb(i),dhpb1(i),forcon(i),fordepth(i),
5826 & -wboltzd*xlscore(i)*dlog(aux),irestr_type(i)
5827 else if (irestr_type(i).eq.2) then
5828 c Quartic restraints
5829 ehpb=ehpb+forcon(i)*gnmr1(dd,dhpb(i),dhpb1(i))
5830 if (energy_dec) write(iout,'(a6,2i5,5f10.3,i5)')
5831 & "edisQ",ii,jj,dd,dhpb(i),dhpb1(i),forcon(i),
5832 & forcon(i)*gnmr1(dd,dhpb(i),dhpb1(i)),irestr_type(i)
5833 fac=forcon(i)*gnmr1prim(dd,dhpb(i),dhpb1(i))/dd
5835 c Quadratic restraints
5837 C Get the force constant corresponding to this distance.
5839 C Calculate the contribution to energy.
5840 ehpb=ehpb+0.5d0*waga*rdis*rdis
5841 if (energy_dec) write(iout,'(a6,2i5,5f10.3,i5)')
5842 & "edisS",ii,jj,dd,dhpb(i),dhpb1(i),forcon(i),
5843 & 0.5d0*waga*rdis*rdis,irestr_type(i)
5845 C Evaluate gradient.
5849 c Calculate Cartesian gradient
5851 ggg(j)=fac*(c(j,jj)-c(j,ii))
5853 cd print '(i3,3(1pe14.5))',i,(ggg(j),j=1,3)
5854 C If this is a SC-SC distance, we need to calculate the contributions to the
5855 C Cartesian gradient in the SC vectors (ghpbx).
5858 ghpbx(j,iii)=ghpbx(j,iii)-ggg(j)
5859 ghpbx(j,jjj)=ghpbx(j,jjj)+ggg(j)
5863 ghpbc(k,jjj)=ghpbc(k,jjj)+ggg(k)
5864 ghpbc(k,iii)=ghpbc(k,iii)-ggg(k)
5870 C--------------------------------------------------------------------------
5871 subroutine ssbond_ene(i,j,eij)
5873 C Calculate the distance and angle dependent SS-bond potential energy
5874 C using a free-energy function derived based on RHF/6-31G** ab initio
5875 C calculations of diethyl disulfide.
5877 C A. Liwo and U. Kozlowska, 11/24/03
5879 implicit real*8 (a-h,o-z)
5880 include 'DIMENSIONS'
5881 include 'COMMON.SBRIDGE'
5882 include 'COMMON.CHAIN'
5883 include 'COMMON.DERIV'
5884 include 'COMMON.LOCAL'
5885 include 'COMMON.INTERACT'
5886 include 'COMMON.VAR'
5887 include 'COMMON.IOUNITS'
5888 double precision erij(3),dcosom1(3),dcosom2(3),gg(3)
5889 itypi=iabs(itype(i))
5893 dxi=dc_norm(1,nres+i)
5894 dyi=dc_norm(2,nres+i)
5895 dzi=dc_norm(3,nres+i)
5896 c dsci_inv=dsc_inv(itypi)
5897 dsci_inv=vbld_inv(nres+i)
5898 itypj=iabs(itype(j))
5899 c dscj_inv=dsc_inv(itypj)
5900 dscj_inv=vbld_inv(nres+j)
5904 dxj=dc_norm(1,nres+j)
5905 dyj=dc_norm(2,nres+j)
5906 dzj=dc_norm(3,nres+j)
5907 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
5912 om1=dxi*erij(1)+dyi*erij(2)+dzi*erij(3)
5913 om2=dxj*erij(1)+dyj*erij(2)+dzj*erij(3)
5914 om12=dxi*dxj+dyi*dyj+dzi*dzj
5916 dcosom1(k)=rij*(dc_norm(k,nres+i)-om1*erij(k))
5917 dcosom2(k)=rij*(dc_norm(k,nres+j)-om2*erij(k))
5923 deltat12=om2-om1+2.0d0
5925 eij=akcm*deltad*deltad+akth*(deltat1*deltat1+deltat2*deltat2)
5926 & +akct*deltad*deltat12
5927 & +v1ss*cosphi+v2ss*cosphi*cosphi+v3ss*cosphi*cosphi*cosphi+ebr
5928 c write(iout,*) i,j,"rij",rij,"d0cm",d0cm," akcm",akcm," akth",akth,
5929 c & " akct",akct," deltad",deltad," deltat",deltat1,deltat2,
5930 c & " deltat12",deltat12," eij",eij
5931 ed=2*akcm*deltad+akct*deltat12
5933 pom2=v1ss+2*v2ss*cosphi+3*v3ss*cosphi*cosphi
5934 eom1=-2*akth*deltat1-pom1-om2*pom2
5935 eom2= 2*akth*deltat2+pom1-om1*pom2
5938 ggk=ed*erij(k)+eom1*dcosom1(k)+eom2*dcosom2(k)
5939 ghpbx(k,i)=ghpbx(k,i)-ggk
5940 & +(eom12*(dc_norm(k,nres+j)-om12*dc_norm(k,nres+i))
5941 & +eom1*(erij(k)-om1*dc_norm(k,nres+i)))*dsci_inv
5942 ghpbx(k,j)=ghpbx(k,j)+ggk
5943 & +(eom12*(dc_norm(k,nres+i)-om12*dc_norm(k,nres+j))
5944 & +eom2*(erij(k)-om2*dc_norm(k,nres+j)))*dscj_inv
5945 ghpbc(k,i)=ghpbc(k,i)-ggk
5946 ghpbc(k,j)=ghpbc(k,j)+ggk
5949 C Calculate the components of the gradient in DC and X
5953 cgrad ghpbc(l,k)=ghpbc(l,k)+gg(l)
5958 C--------------------------------------------------------------------------
5959 subroutine ebond(estr)
5961 c Evaluate the energy of stretching of the CA-CA and CA-SC virtual bonds
5963 implicit real*8 (a-h,o-z)
5964 include 'DIMENSIONS'
5965 include 'COMMON.LOCAL'
5966 include 'COMMON.GEO'
5967 include 'COMMON.INTERACT'
5968 include 'COMMON.DERIV'
5969 include 'COMMON.VAR'
5970 include 'COMMON.CHAIN'
5971 include 'COMMON.IOUNITS'
5972 include 'COMMON.NAMES'
5973 include 'COMMON.FFIELD'
5974 include 'COMMON.CONTROL'
5975 include 'COMMON.SETUP'
5976 double precision u(3),ud(3)
5979 do i=ibondp_start,ibondp_end
5980 if (itype(i-1).eq.ntyp1 .and. itype(i).eq.ntyp1) cycle
5981 c estr1=estr1+gnmr1(vbld(i),-1.0d0,distchainmax)
5983 c gradb(j,i-1)=gnmr1prim(vbld(i),-1.0d0,distchainmax)
5984 c & *dc(j,i-1)/vbld(i)
5986 c if (energy_dec) write(iout,*)
5987 c & "estr1",i,gnmr1(vbld(i),-1.0d0,distchainmax)
5989 C Checking if it involves dummy (NH3+ or COO-) group
5990 if (itype(i-1).eq.ntyp1 .or. itype(i).eq.ntyp1) then
5991 C YES vbldpDUM is the equlibrium length of spring for Dummy atom
5992 diff = vbld(i)-vbldpDUM
5993 if (energy_dec) write(iout,*) "dum_bond",i,diff
5995 C NO vbldp0 is the equlibrium lenght of spring for peptide group
5996 diff = vbld(i)-vbldp0
5998 if (energy_dec) write (iout,'(a7,i5,4f7.3)')
5999 & "estr bb",i,vbld(i),vbldp0,diff,AKP*diff*diff
6002 gradb(j,i-1)=AKP*diff*dc(j,i-1)/vbld(i)
6004 c write (iout,'(i5,3f10.5)') i,(gradb(j,i-1),j=1,3)
6008 estr=0.5d0*AKP*estr+estr1
6010 c 09/18/07 AL: multimodal bond potential based on AM1 CA-SC PMF's included
6012 do i=ibond_start,ibond_end
6014 if (iti.ne.10 .and. iti.ne.ntyp1) then
6017 diff=vbld(i+nres)-vbldsc0(1,iti)
6018 if (energy_dec) write (iout,*)
6019 & "estr sc",i,iti,vbld(i+nres),vbldsc0(1,iti),diff,
6020 & AKSC(1,iti),AKSC(1,iti)*diff*diff
6021 estr=estr+0.5d0*AKSC(1,iti)*diff*diff
6023 gradbx(j,i)=AKSC(1,iti)*diff*dc(j,i+nres)/vbld(i+nres)
6027 diff=vbld(i+nres)-vbldsc0(j,iti)
6028 ud(j)=aksc(j,iti)*diff
6029 u(j)=abond0(j,iti)+0.5d0*ud(j)*diff
6043 uprod2=uprod2*u(k)*u(k)
6047 usumsqder=usumsqder+ud(j)*uprod2
6049 estr=estr+uprod/usum
6051 gradbx(j,i)=usumsqder/(usum*usum)*dc(j,i+nres)/vbld(i+nres)
6059 C--------------------------------------------------------------------------
6060 subroutine ebend(etheta)
6062 C Evaluate the virtual-bond-angle energy given the virtual-bond dihedral
6063 C angles gamma and its derivatives in consecutive thetas and gammas.
6065 implicit real*8 (a-h,o-z)
6066 include 'DIMENSIONS'
6067 include 'COMMON.LOCAL'
6068 include 'COMMON.GEO'
6069 include 'COMMON.INTERACT'
6070 include 'COMMON.DERIV'
6071 include 'COMMON.VAR'
6072 include 'COMMON.CHAIN'
6073 include 'COMMON.IOUNITS'
6074 include 'COMMON.NAMES'
6075 include 'COMMON.FFIELD'
6076 include 'COMMON.CONTROL'
6077 include 'COMMON.TORCNSTR'
6078 common /calcthet/ term1,term2,termm,diffak,ratak,
6079 & ak,aktc,termpre,termexp,sigc,sig0i,time11,time12,sigcsq,
6080 & delthe0,sig0inv,sigtc,sigsqtc,delthec,it
6081 double precision y(2),z(2)
6083 c time11=dexp(-2*time)
6086 c write (*,'(a,i2)') 'EBEND ICG=',icg
6087 do i=ithet_start,ithet_end
6088 if ((itype(i-1).eq.ntyp1).or.itype(i-2).eq.ntyp1
6089 & .or.itype(i).eq.ntyp1) cycle
6090 C Zero the energy function and its derivative at 0 or pi.
6091 call splinthet(theta(i),0.5d0*delta,ss,ssd)
6093 ichir1=isign(1,itype(i-2))
6094 ichir2=isign(1,itype(i))
6095 if (itype(i-2).eq.10) ichir1=isign(1,itype(i-1))
6096 if (itype(i).eq.10) ichir2=isign(1,itype(i-1))
6097 if (itype(i-1).eq.10) then
6098 itype1=isign(10,itype(i-2))
6099 ichir11=isign(1,itype(i-2))
6100 ichir12=isign(1,itype(i-2))
6101 itype2=isign(10,itype(i))
6102 ichir21=isign(1,itype(i))
6103 ichir22=isign(1,itype(i))
6106 if (i.gt.3 .and. itype(i-3).ne.ntyp1) then
6109 if (phii.ne.phii) phii=150.0
6119 if (i.lt.nres .and. itype(i+1).ne.ntyp1) then
6122 if (phii1.ne.phii1) phii1=150.0
6134 C Calculate the "mean" value of theta from the part of the distribution
6135 C dependent on the adjacent virtual-bond-valence angles (gamma1 & gamma2).
6136 C In following comments this theta will be referred to as t_c.
6137 thet_pred_mean=0.0d0
6139 athetk=athet(k,it,ichir1,ichir2)
6140 bthetk=bthet(k,it,ichir1,ichir2)
6142 athetk=athet(k,itype1,ichir11,ichir12)
6143 bthetk=bthet(k,itype2,ichir21,ichir22)
6145 thet_pred_mean=thet_pred_mean+athetk*y(k)+bthetk*z(k)
6146 c write(iout,*) 'chuj tu', y(k),z(k)
6148 dthett=thet_pred_mean*ssd
6149 thet_pred_mean=thet_pred_mean*ss+a0thet(it)
6150 C Derivatives of the "mean" values in gamma1 and gamma2.
6151 dthetg1=(-athet(1,it,ichir1,ichir2)*y(2)
6152 &+athet(2,it,ichir1,ichir2)*y(1))*ss
6153 dthetg2=(-bthet(1,it,ichir1,ichir2)*z(2)
6154 & +bthet(2,it,ichir1,ichir2)*z(1))*ss
6156 dthetg1=(-athet(1,itype1,ichir11,ichir12)*y(2)
6157 &+athet(2,itype1,ichir11,ichir12)*y(1))*ss
6158 dthetg2=(-bthet(1,itype2,ichir21,ichir22)*z(2)
6159 & +bthet(2,itype2,ichir21,ichir22)*z(1))*ss
6161 if (theta(i).gt.pi-delta) then
6162 call theteng(pi-delta,thet_pred_mean,theta0(it),f0,fprim0,
6164 call mixder(pi-delta,thet_pred_mean,theta0(it),fprim_tc0)
6165 call theteng(pi,thet_pred_mean,theta0(it),f1,fprim1,E_tc1)
6166 call spline1(theta(i),pi-delta,delta,f0,f1,fprim0,ethetai,
6168 call spline2(theta(i),pi-delta,delta,E_tc0,E_tc1,fprim_tc0,
6170 else if (theta(i).lt.delta) then
6171 call theteng(delta,thet_pred_mean,theta0(it),f0,fprim0,E_tc0)
6172 call theteng(0.0d0,thet_pred_mean,theta0(it),f1,fprim1,E_tc1)
6173 call spline1(theta(i),delta,-delta,f0,f1,fprim0,ethetai,
6175 call mixder(delta,thet_pred_mean,theta0(it),fprim_tc0)
6176 call spline2(theta(i),delta,-delta,E_tc0,E_tc1,fprim_tc0,
6179 call theteng(theta(i),thet_pred_mean,theta0(it),ethetai,
6182 etheta=etheta+ethetai
6183 if (energy_dec) write (iout,'(a6,i5,0pf7.3,f7.3,i5)')
6184 & 'ebend',i,ethetai,theta(i),itype(i)
6185 if (i.gt.3) gloc(i-3,icg)=gloc(i-3,icg)+wang*E_tc*dthetg1
6186 if (i.lt.nres) gloc(i-2,icg)=gloc(i-2,icg)+wang*E_tc*dthetg2
6187 gloc(nphi+i-2,icg)=wang*(E_theta+E_tc*dthett)+gloc(nphi+i-2,icg)
6190 C Ufff.... We've done all this!!!
6193 C---------------------------------------------------------------------------
6194 subroutine theteng(thetai,thet_pred_mean,theta0i,ethetai,E_theta,
6196 implicit real*8 (a-h,o-z)
6197 include 'DIMENSIONS'
6198 include 'COMMON.LOCAL'
6199 include 'COMMON.IOUNITS'
6200 common /calcthet/ term1,term2,termm,diffak,ratak,
6201 & ak,aktc,termpre,termexp,sigc,sig0i,time11,time12,sigcsq,
6202 & delthe0,sig0inv,sigtc,sigsqtc,delthec,it
6203 C Calculate the contributions to both Gaussian lobes.
6204 C 6/6/97 - Deform the Gaussians using the factor of 1/(1+time)
6205 C The "polynomial part" of the "standard deviation" of this part of
6206 C the distributioni.
6207 ccc write (iout,*) thetai,thet_pred_mean
6210 sig=sig*thet_pred_mean+polthet(j,it)
6212 C Derivative of the "interior part" of the "standard deviation of the"
6213 C gamma-dependent Gaussian lobe in t_c.
6214 sigtc=3*polthet(3,it)
6216 sigtc=sigtc*thet_pred_mean+j*polthet(j,it)
6219 C Set the parameters of both Gaussian lobes of the distribution.
6220 C "Standard deviation" of the gamma-dependent Gaussian lobe (sigtc)
6221 fac=sig*sig+sigc0(it)
6224 C Following variable (sigsqtc) is -(1/2)d[sigma(t_c)**(-2))]/dt_c
6225 sigsqtc=-4.0D0*sigcsq*sigtc
6226 c print *,i,sig,sigtc,sigsqtc
6227 C Following variable (sigtc) is d[sigma(t_c)]/dt_c
6228 sigtc=-sigtc/(fac*fac)
6229 C Following variable is sigma(t_c)**(-2)
6230 sigcsq=sigcsq*sigcsq
6232 sig0inv=1.0D0/sig0i**2
6233 delthec=thetai-thet_pred_mean
6234 delthe0=thetai-theta0i
6235 term1=-0.5D0*sigcsq*delthec*delthec
6236 term2=-0.5D0*sig0inv*delthe0*delthe0
6237 C write (iout,*)'term1',term1,term2,sigcsq,delthec,sig0inv,delthe0
6238 C Following fuzzy logic is to avoid underflows in dexp and subsequent INFs and
6239 C NaNs in taking the logarithm. We extract the largest exponent which is added
6240 C to the energy (this being the log of the distribution) at the end of energy
6241 C term evaluation for this virtual-bond angle.
6242 if (term1.gt.term2) then
6244 term2=dexp(term2-termm)
6248 term1=dexp(term1-termm)
6251 C The ratio between the gamma-independent and gamma-dependent lobes of
6252 C the distribution is a Gaussian function of thet_pred_mean too.
6253 diffak=gthet(2,it)-thet_pred_mean
6254 ratak=diffak/gthet(3,it)**2
6255 ak=dexp(gthet(1,it)-0.5D0*diffak*ratak)
6256 C Let's differentiate it in thet_pred_mean NOW.
6258 C Now put together the distribution terms to make complete distribution.
6259 termexp=term1+ak*term2
6260 termpre=sigc+ak*sig0i
6261 C Contribution of the bending energy from this theta is just the -log of
6262 C the sum of the contributions from the two lobes and the pre-exponential
6263 C factor. Simple enough, isn't it?
6264 ethetai=(-dlog(termexp)-termm+dlog(termpre))
6265 C write (iout,*) 'termexp',termexp,termm,termpre,i
6266 C NOW the derivatives!!!
6267 C 6/6/97 Take into account the deformation.
6268 E_theta=(delthec*sigcsq*term1
6269 & +ak*delthe0*sig0inv*term2)/termexp
6270 E_tc=((sigtc+aktc*sig0i)/termpre
6271 & -((delthec*sigcsq+delthec*delthec*sigsqtc)*term1+
6272 & aktc*term2)/termexp)
6275 c-----------------------------------------------------------------------------
6276 subroutine mixder(thetai,thet_pred_mean,theta0i,E_tc_t)
6277 implicit real*8 (a-h,o-z)
6278 include 'DIMENSIONS'
6279 include 'COMMON.LOCAL'
6280 include 'COMMON.IOUNITS'
6281 common /calcthet/ term1,term2,termm,diffak,ratak,
6282 & ak,aktc,termpre,termexp,sigc,sig0i,time11,time12,sigcsq,
6283 & delthe0,sig0inv,sigtc,sigsqtc,delthec,it
6284 delthec=thetai-thet_pred_mean
6285 delthe0=thetai-theta0i
6286 C "Thank you" to MAPLE (probably spared one day of hand-differentiation).
6287 t3 = thetai-thet_pred_mean
6291 t14 = t12+t6*sigsqtc
6293 t21 = thetai-theta0i
6299 E_tc_t = -((sigcsq+2.D0*t3*sigsqtc)*t9-t14*sigcsq*t3*t16*t9
6300 & -aktc*sig0inv*t27)/t32+(t14*t9+aktc*t26)/t40
6301 & *(-t12*t9-ak*sig0inv*t27)
6305 C--------------------------------------------------------------------------
6306 subroutine ebend(etheta)
6308 C Evaluate the virtual-bond-angle energy given the virtual-bond dihedral
6309 C angles gamma and its derivatives in consecutive thetas and gammas.
6310 C ab initio-derived potentials from
6311 c Kozlowska et al., J. Phys.: Condens. Matter 19 (2007) 285203
6313 implicit real*8 (a-h,o-z)
6314 include 'DIMENSIONS'
6315 include 'COMMON.LOCAL'
6316 include 'COMMON.GEO'
6317 include 'COMMON.INTERACT'
6318 include 'COMMON.DERIV'
6319 include 'COMMON.VAR'
6320 include 'COMMON.CHAIN'
6321 include 'COMMON.IOUNITS'
6322 include 'COMMON.NAMES'
6323 include 'COMMON.FFIELD'
6324 include 'COMMON.CONTROL'
6325 include 'COMMON.TORCNSTR'
6326 double precision coskt(mmaxtheterm),sinkt(mmaxtheterm),
6327 & cosph1(maxsingle),sinph1(maxsingle),cosph2(maxsingle),
6328 & sinph2(maxsingle),cosph1ph2(maxdouble,maxdouble),
6329 & sinph1ph2(maxdouble,maxdouble)
6330 logical lprn /.false./, lprn1 /.false./
6332 do i=ithet_start,ithet_end
6333 c print *,i,itype(i-1),itype(i),itype(i-2)
6334 if ((itype(i-1).eq.ntyp1).or.itype(i-2).eq.ntyp1
6335 & .or.itype(i).eq.ntyp1) cycle
6336 C print *,i,theta(i)
6337 if (iabs(itype(i+1)).eq.20) iblock=2
6338 if (iabs(itype(i+1)).ne.20) iblock=1
6342 theti2=0.5d0*theta(i)
6343 ityp2=ithetyp((itype(i-1)))
6345 coskt(k)=dcos(k*theti2)
6346 sinkt(k)=dsin(k*theti2)
6349 if (i.gt.3 .and. itype(i-3).ne.ntyp1) then
6352 if (phii.ne.phii) phii=150.0
6356 ityp1=ithetyp((itype(i-2)))
6357 C propagation of chirality for glycine type
6359 cosph1(k)=dcos(k*phii)
6360 sinph1(k)=dsin(k*phii)
6365 ityp1=ithetyp((itype(i-2)))
6370 if (i.lt.nres .and. itype(i+1).ne.ntyp1) then
6373 if (phii1.ne.phii1) phii1=150.0
6378 ityp3=ithetyp((itype(i)))
6380 cosph2(k)=dcos(k*phii1)
6381 sinph2(k)=dsin(k*phii1)
6385 ityp3=ithetyp((itype(i)))
6391 ethetai=aa0thet(ityp1,ityp2,ityp3,iblock)
6394 ccl=cosph1(l)*cosph2(k-l)
6395 ssl=sinph1(l)*sinph2(k-l)
6396 scl=sinph1(l)*cosph2(k-l)
6397 csl=cosph1(l)*sinph2(k-l)
6398 cosph1ph2(l,k)=ccl-ssl
6399 cosph1ph2(k,l)=ccl+ssl
6400 sinph1ph2(l,k)=scl+csl
6401 sinph1ph2(k,l)=scl-csl
6405 write (iout,*) "i",i," ityp1",ityp1," ityp2",ityp2,
6406 & " ityp3",ityp3," theti2",theti2," phii",phii," phii1",phii1
6407 write (iout,*) "coskt and sinkt"
6409 write (iout,*) k,coskt(k),sinkt(k)
6413 ethetai=ethetai+aathet(k,ityp1,ityp2,ityp3,iblock)*sinkt(k)
6414 dethetai=dethetai+0.5d0*k*aathet(k,ityp1,ityp2,ityp3,iblock)
6417 & write (iout,*) "k",k,"
6418 & aathet",aathet(k,ityp1,ityp2,ityp3,iblock),
6419 & " ethetai",ethetai
6422 write (iout,*) "cosph and sinph"
6424 write (iout,*) k,cosph1(k),sinph1(k),cosph2(k),sinph2(k)
6426 write (iout,*) "cosph1ph2 and sinph2ph2"
6429 write (iout,*) l,k,cosph1ph2(l,k),cosph1ph2(k,l),
6430 & sinph1ph2(l,k),sinph1ph2(k,l)
6433 write(iout,*) "ethetai",ethetai
6438 aux=bbthet(k,m,ityp1,ityp2,ityp3,iblock)*cosph1(k)
6439 & +ccthet(k,m,ityp1,ityp2,ityp3,iblock)*sinph1(k)
6440 & +ddthet(k,m,ityp1,ityp2,ityp3,iblock)*cosph2(k)
6441 & +eethet(k,m,ityp1,ityp2,ityp3,iblock)*sinph2(k)
6442 ethetai=ethetai+sinkt(m)*aux
6443 dethetai=dethetai+0.5d0*m*aux*coskt(m)
6444 dephii=dephii+k*sinkt(m)*(
6445 & ccthet(k,m,ityp1,ityp2,ityp3,iblock)*cosph1(k)-
6446 & bbthet(k,m,ityp1,ityp2,ityp3,iblock)*sinph1(k))
6447 dephii1=dephii1+k*sinkt(m)*(
6448 & eethet(k,m,ityp1,ityp2,ityp3,iblock)*cosph2(k)-
6449 & ddthet(k,m,ityp1,ityp2,ityp3,iblock)*sinph2(k))
6451 & write (iout,*) "m",m," k",k," bbthet",
6452 & bbthet(k,m,ityp1,ityp2,ityp3,iblock)," ccthet",
6453 & ccthet(k,m,ityp1,ityp2,ityp3,iblock)," ddthet",
6454 & ddthet(k,m,ityp1,ityp2,ityp3,iblock)," eethet",
6455 & eethet(k,m,ityp1,ityp2,ityp3,iblock)," ethetai",ethetai
6456 C print *,"tu",cosph1(k),sinph1(k),cosph2(k),sinph2(k)
6459 C print *,"cosph1", (cosph1(k), k=1,nsingle)
6460 C print *,"cosph2", (cosph2(k), k=1,nsingle)
6461 C print *,"sinph1", (sinph1(k), k=1,nsingle)
6462 C print *,"sinph2", (sinph2(k), k=1,nsingle)
6464 & write(iout,*) "ethetai",ethetai
6465 C print *,"tu",cosph1(k),sinph1(k),cosph2(k),sinph2(k)
6469 aux=ffthet(l,k,m,ityp1,ityp2,ityp3,iblock)*cosph1ph2(l,k)+
6470 & ffthet(k,l,m,ityp1,ityp2,ityp3,iblock)*cosph1ph2(k,l)+
6471 & ggthet(l,k,m,ityp1,ityp2,ityp3,iblock)*sinph1ph2(l,k)+
6472 & ggthet(k,l,m,ityp1,ityp2,ityp3,iblock)*sinph1ph2(k,l)
6473 ethetai=ethetai+sinkt(m)*aux
6474 dethetai=dethetai+0.5d0*m*coskt(m)*aux
6475 dephii=dephii+l*sinkt(m)*(
6476 & -ffthet(l,k,m,ityp1,ityp2,ityp3,iblock)*sinph1ph2(l,k)-
6477 & ffthet(k,l,m,ityp1,ityp2,ityp3,iblock)*sinph1ph2(k,l)+
6478 & ggthet(l,k,m,ityp1,ityp2,ityp3,iblock)*cosph1ph2(l,k)+
6479 & ggthet(k,l,m,ityp1,ityp2,ityp3,iblock)*cosph1ph2(k,l))
6480 dephii1=dephii1+(k-l)*sinkt(m)*(
6481 & -ffthet(l,k,m,ityp1,ityp2,ityp3,iblock)*sinph1ph2(l,k)+
6482 & ffthet(k,l,m,ityp1,ityp2,ityp3,iblock)*sinph1ph2(k,l)+
6483 & ggthet(l,k,m,ityp1,ityp2,ityp3,iblock)*cosph1ph2(l,k)-
6484 & ggthet(k,l,m,ityp1,ityp2,ityp3,iblock)*cosph1ph2(k,l))
6486 write (iout,*) "m",m," k",k," l",l," ffthet",
6487 & ffthet(l,k,m,ityp1,ityp2,ityp3,iblock),
6488 & ffthet(k,l,m,ityp1,ityp2,ityp3,iblock)," ggthet",
6489 & ggthet(l,k,m,ityp1,ityp2,ityp3,iblock),
6490 & ggthet(k,l,m,ityp1,ityp2,ityp3,iblock),
6491 & " ethetai",ethetai
6492 write (iout,*) cosph1ph2(l,k)*sinkt(m),
6493 & cosph1ph2(k,l)*sinkt(m),
6494 & sinph1ph2(l,k)*sinkt(m),sinph1ph2(k,l)*sinkt(m)
6503 & write (iout,'(i2,3f8.1,9h ethetai ,f10.5)')
6504 & i,theta(i)*rad2deg,phii*rad2deg,
6505 & phii1*rad2deg,ethetai
6507 etheta=etheta+ethetai
6508 if (i.gt.3) gloc(i-3,icg)=gloc(i-3,icg)+wang*dephii
6509 if (i.lt.nres) gloc(i-2,icg)=gloc(i-2,icg)+wang*dephii1
6510 gloc(nphi+i-2,icg)=gloc(nphi+i-2,icg)+wang*dethetai
6517 c-----------------------------------------------------------------------------
6518 subroutine esc(escloc)
6519 C Calculate the local energy of a side chain and its derivatives in the
6520 C corresponding virtual-bond valence angles THETA and the spherical angles
6522 implicit real*8 (a-h,o-z)
6523 include 'DIMENSIONS'
6524 include 'COMMON.GEO'
6525 include 'COMMON.LOCAL'
6526 include 'COMMON.VAR'
6527 include 'COMMON.INTERACT'
6528 include 'COMMON.DERIV'
6529 include 'COMMON.CHAIN'
6530 include 'COMMON.IOUNITS'
6531 include 'COMMON.NAMES'
6532 include 'COMMON.FFIELD'
6533 include 'COMMON.CONTROL'
6534 double precision x(3),dersc(3),xemp(3),dersc0(3),dersc1(3),
6535 & ddersc0(3),ddummy(3),xtemp(3),temp(3)
6536 common /sccalc/ time11,time12,time112,theti,it,nlobit
6539 c write (iout,'(a)') 'ESC'
6540 do i=loc_start,loc_end
6542 if (it.eq.ntyp1) cycle
6543 if (it.eq.10) goto 1
6544 nlobit=nlob(iabs(it))
6545 c print *,'i=',i,' it=',it,' nlobit=',nlobit
6546 c write (iout,*) 'i=',i,' ssa=',ssa,' ssad=',ssad
6547 theti=theta(i+1)-pipol
6552 if (x(2).gt.pi-delta) then
6556 call enesc(xtemp,escloci0,dersc0,ddersc0,.true.)
6558 call enesc(xtemp,escloci1,dersc1,ddummy,.false.)
6559 call spline1(x(2),pi-delta,delta,escloci0,escloci1,dersc0(2),
6561 call spline2(x(2),pi-delta,delta,dersc0(1),dersc1(1),
6562 & ddersc0(1),dersc(1))
6563 call spline2(x(2),pi-delta,delta,dersc0(3),dersc1(3),
6564 & ddersc0(3),dersc(3))
6566 call enesc_bound(xtemp,esclocbi0,dersc0,dersc12,.true.)
6568 call enesc_bound(xtemp,esclocbi1,dersc1,chuju,.false.)
6569 call spline1(x(2),pi-delta,delta,esclocbi0,esclocbi1,
6570 & dersc0(2),esclocbi,dersc02)
6571 call spline2(x(2),pi-delta,delta,dersc0(1),dersc1(1),
6573 call splinthet(x(2),0.5d0*delta,ss,ssd)
6578 dersc(k)=ss*dersc(k)+(1.0d0-ss)*dersc0(k)
6580 dersc(2)=dersc(2)+ssd*(escloci-esclocbi)
6581 c write (iout,*) 'i=',i,x(2)*rad2deg,escloci0,escloci,
6583 escloci=ss*escloci+(1.0d0-ss)*esclocbi
6585 c write (iout,*) escloci
6586 else if (x(2).lt.delta) then
6590 call enesc(xtemp,escloci0,dersc0,ddersc0,.true.)
6592 call enesc(xtemp,escloci1,dersc1,ddummy,.false.)
6593 call spline1(x(2),delta,-delta,escloci0,escloci1,dersc0(2),
6595 call spline2(x(2),delta,-delta,dersc0(1),dersc1(1),
6596 & ddersc0(1),dersc(1))
6597 call spline2(x(2),delta,-delta,dersc0(3),dersc1(3),
6598 & ddersc0(3),dersc(3))
6600 call enesc_bound(xtemp,esclocbi0,dersc0,dersc12,.true.)
6602 call enesc_bound(xtemp,esclocbi1,dersc1,chuju,.false.)
6603 call spline1(x(2),delta,-delta,esclocbi0,esclocbi1,
6604 & dersc0(2),esclocbi,dersc02)
6605 call spline2(x(2),delta,-delta,dersc0(1),dersc1(1),
6610 call splinthet(x(2),0.5d0*delta,ss,ssd)
6612 dersc(k)=ss*dersc(k)+(1.0d0-ss)*dersc0(k)
6614 dersc(2)=dersc(2)+ssd*(escloci-esclocbi)
6615 c write (iout,*) 'i=',i,x(2)*rad2deg,escloci0,escloci,
6617 escloci=ss*escloci+(1.0d0-ss)*esclocbi
6618 c write (iout,*) escloci
6620 call enesc(x,escloci,dersc,ddummy,.false.)
6623 escloc=escloc+escloci
6624 if (energy_dec) write (iout,'(a6,i5,0pf7.3)')
6625 & 'escloc',i,escloci
6626 c write (iout,*) 'i=',i,' escloci=',escloci,' dersc=',dersc
6628 gloc(nphi+i-1,icg)=gloc(nphi+i-1,icg)+
6630 gloc(ialph(i,1),icg)=wscloc*dersc(2)
6631 gloc(ialph(i,1)+nside,icg)=wscloc*dersc(3)
6636 C---------------------------------------------------------------------------
6637 subroutine enesc(x,escloci,dersc,ddersc,mixed)
6638 implicit real*8 (a-h,o-z)
6639 include 'DIMENSIONS'
6640 include 'COMMON.GEO'
6641 include 'COMMON.LOCAL'
6642 include 'COMMON.IOUNITS'
6643 common /sccalc/ time11,time12,time112,theti,it,nlobit
6644 double precision x(3),z(3),Ax(3,maxlob,-1:1),dersc(3),ddersc(3)
6645 double precision contr(maxlob,-1:1)
6647 c write (iout,*) 'it=',it,' nlobit=',nlobit
6651 if (mixed) ddersc(j)=0.0d0
6655 C Because of periodicity of the dependence of the SC energy in omega we have
6656 C to add up the contributions from x(3)-2*pi, x(3), and x(3+2*pi).
6657 C To avoid underflows, first compute & store the exponents.
6665 z(k)=x(k)-censc(k,j,it)
6670 Axk=Axk+gaussc(l,k,j,it)*z(l)
6676 expfac=expfac+Ax(k,j,iii)*z(k)
6684 C As in the case of ebend, we want to avoid underflows in exponentiation and
6685 C subsequent NaNs and INFs in energy calculation.
6686 C Find the largest exponent
6690 if (emin.gt.contr(j,iii)) emin=contr(j,iii)
6694 cd print *,'it=',it,' emin=',emin
6696 C Compute the contribution to SC energy and derivatives
6701 adexp=bsc(j,iabs(it))-0.5D0*contr(j,iii)+emin
6702 if(adexp.ne.adexp) adexp=1.0
6705 expfac=dexp(bsc(j,iabs(it))-0.5D0*contr(j,iii)+emin)
6707 cd print *,'j=',j,' expfac=',expfac
6708 escloc_i=escloc_i+expfac
6710 dersc(k)=dersc(k)+Ax(k,j,iii)*expfac
6714 ddersc(k)=ddersc(k)+(-Ax(2,j,iii)*Ax(k,j,iii)
6715 & +gaussc(k,2,j,it))*expfac
6722 dersc(1)=dersc(1)/cos(theti)**2
6723 ddersc(1)=ddersc(1)/cos(theti)**2
6726 escloci=-(dlog(escloc_i)-emin)
6728 dersc(j)=dersc(j)/escloc_i
6732 ddersc(j)=(ddersc(j)/escloc_i+dersc(2)*dersc(j))
6737 C------------------------------------------------------------------------------
6738 subroutine enesc_bound(x,escloci,dersc,dersc12,mixed)
6739 implicit real*8 (a-h,o-z)
6740 include 'DIMENSIONS'
6741 include 'COMMON.GEO'
6742 include 'COMMON.LOCAL'
6743 include 'COMMON.IOUNITS'
6744 common /sccalc/ time11,time12,time112,theti,it,nlobit
6745 double precision x(3),z(3),Ax(3,maxlob),dersc(3)
6746 double precision contr(maxlob)
6757 z(k)=x(k)-censc(k,j,it)
6763 Axk=Axk+gaussc(l,k,j,it)*z(l)
6769 expfac=expfac+Ax(k,j)*z(k)
6774 C As in the case of ebend, we want to avoid underflows in exponentiation and
6775 C subsequent NaNs and INFs in energy calculation.
6776 C Find the largest exponent
6779 if (emin.gt.contr(j)) emin=contr(j)
6783 C Compute the contribution to SC energy and derivatives
6787 expfac=dexp(bsc(j,iabs(it))-0.5D0*contr(j)+emin)
6788 escloc_i=escloc_i+expfac
6790 dersc(k)=dersc(k)+Ax(k,j)*expfac
6792 if (mixed) dersc12=dersc12+(-Ax(2,j)*Ax(1,j)
6793 & +gaussc(1,2,j,it))*expfac
6797 dersc(1)=dersc(1)/cos(theti)**2
6798 dersc12=dersc12/cos(theti)**2
6799 escloci=-(dlog(escloc_i)-emin)
6801 dersc(j)=dersc(j)/escloc_i
6803 if (mixed) dersc12=(dersc12/escloc_i+dersc(2)*dersc(1))
6807 c----------------------------------------------------------------------------------
6808 subroutine esc(escloc)
6809 C Calculate the local energy of a side chain and its derivatives in the
6810 C corresponding virtual-bond valence angles THETA and the spherical angles
6811 C ALPHA and OMEGA derived from AM1 all-atom calculations.
6812 C added by Urszula Kozlowska. 07/11/2007
6814 implicit real*8 (a-h,o-z)
6815 include 'DIMENSIONS'
6816 include 'COMMON.GEO'
6817 include 'COMMON.LOCAL'
6818 include 'COMMON.VAR'
6819 include 'COMMON.SCROT'
6820 include 'COMMON.INTERACT'
6821 include 'COMMON.DERIV'
6822 include 'COMMON.CHAIN'
6823 include 'COMMON.IOUNITS'
6824 include 'COMMON.NAMES'
6825 include 'COMMON.FFIELD'
6826 include 'COMMON.CONTROL'
6827 include 'COMMON.VECTORS'
6828 double precision x_prime(3),y_prime(3),z_prime(3)
6829 & , sumene,dsc_i,dp2_i,x(65),
6830 & xx,yy,zz,sumene1,sumene2,sumene3,sumene4,s1,s1_6,s2,s2_6,
6831 & de_dxx,de_dyy,de_dzz,de_dt
6832 double precision s1_t,s1_6_t,s2_t,s2_6_t
6834 & dXX_Ci1(3),dYY_Ci1(3),dZZ_Ci1(3),dXX_Ci(3),
6835 & dYY_Ci(3),dZZ_Ci(3),dXX_XYZ(3),dYY_XYZ(3),dZZ_XYZ(3),
6836 & dt_dCi(3),dt_dCi1(3)
6837 common /sccalc/ time11,time12,time112,theti,it,nlobit
6840 do i=loc_start,loc_end
6841 if (itype(i).eq.ntyp1) cycle
6842 costtab(i+1) =dcos(theta(i+1))
6843 sinttab(i+1) =dsqrt(1-costtab(i+1)*costtab(i+1))
6844 cost2tab(i+1)=dsqrt(0.5d0*(1.0d0+costtab(i+1)))
6845 sint2tab(i+1)=dsqrt(0.5d0*(1.0d0-costtab(i+1)))
6846 cosfac2=0.5d0/(1.0d0+costtab(i+1))
6847 cosfac=dsqrt(cosfac2)
6848 sinfac2=0.5d0/(1.0d0-costtab(i+1))
6849 sinfac=dsqrt(sinfac2)
6851 if (it.eq.10) goto 1
6853 C Compute the axes of tghe local cartesian coordinates system; store in
6854 c x_prime, y_prime and z_prime
6861 C write(2,*) "dc_norm", dc_norm(1,i+nres),dc_norm(2,i+nres),
6862 C & dc_norm(3,i+nres)
6864 x_prime(j) = (dc_norm(j,i) - dc_norm(j,i-1))*cosfac
6865 y_prime(j) = (dc_norm(j,i) + dc_norm(j,i-1))*sinfac
6868 z_prime(j) = -uz(j,i-1)*dsign(1.0d0,dfloat(itype(i)))
6871 c write (2,*) "x_prime",(x_prime(j),j=1,3)
6872 c write (2,*) "y_prime",(y_prime(j),j=1,3)
6873 c write (2,*) "z_prime",(z_prime(j),j=1,3)
6874 c write (2,*) "xx",scalar(x_prime(1),x_prime(1)),
6875 c & " xy",scalar(x_prime(1),y_prime(1)),
6876 c & " xz",scalar(x_prime(1),z_prime(1)),
6877 c & " yy",scalar(y_prime(1),y_prime(1)),
6878 c & " yz",scalar(y_prime(1),z_prime(1)),
6879 c & " zz",scalar(z_prime(1),z_prime(1))
6881 C Transform the unit vector of the ith side-chain centroid, dC_norm(*,i),
6882 C to local coordinate system. Store in xx, yy, zz.
6888 xx = xx + x_prime(j)*dc_norm(j,i+nres)
6889 yy = yy + y_prime(j)*dc_norm(j,i+nres)
6890 zz = zz + z_prime(j)*dc_norm(j,i+nres)
6897 C Compute the energy of the ith side cbain
6899 c write (2,*) "xx",xx," yy",yy," zz",zz
6902 x(j) = sc_parmin(j,it)
6905 Cc diagnostics - remove later
6907 yy1 = dsin(alph(2))*dcos(omeg(2))
6908 zz1 = -dsign(1.0,dfloat(itype(i)))*dsin(alph(2))*dsin(omeg(2))
6909 write(2,'(3f8.1,3f9.3,1x,3f9.3)')
6910 & alph(2)*rad2deg,omeg(2)*rad2deg,theta(3)*rad2deg,xx,yy,zz,
6912 C," --- ", xx_w,yy_w,zz_w
6915 sumene1= x(1)+ x(2)*xx+ x(3)*yy+ x(4)*zz+ x(5)*xx**2
6916 & + x(6)*yy**2+ x(7)*zz**2+ x(8)*xx*zz+ x(9)*xx*yy
6918 sumene2= x(11) + x(12)*xx + x(13)*yy + x(14)*zz + x(15)*xx**2
6919 & + x(16)*yy**2 + x(17)*zz**2 + x(18)*xx*zz + x(19)*xx*yy
6921 sumene3= x(21) +x(22)*xx +x(23)*yy +x(24)*zz +x(25)*xx**2
6922 & +x(26)*yy**2 +x(27)*zz**2 +x(28)*xx*zz +x(29)*xx*yy
6923 & +x(30)*yy*zz +x(31)*xx**3 +x(32)*yy**3 +x(33)*zz**3
6924 & +x(34)*(xx**2)*yy +x(35)*(xx**2)*zz +x(36)*(yy**2)*xx
6925 & +x(37)*(yy**2)*zz +x(38)*(zz**2)*xx +x(39)*(zz**2)*yy
6927 sumene4= x(41) +x(42)*xx +x(43)*yy +x(44)*zz +x(45)*xx**2
6928 & +x(46)*yy**2 +x(47)*zz**2 +x(48)*xx*zz +x(49)*xx*yy
6929 & +x(50)*yy*zz +x(51)*xx**3 +x(52)*yy**3 +x(53)*zz**3
6930 & +x(54)*(xx**2)*yy +x(55)*(xx**2)*zz +x(56)*(yy**2)*xx
6931 & +x(57)*(yy**2)*zz +x(58)*(zz**2)*xx +x(59)*(zz**2)*yy
6933 dsc_i = 0.743d0+x(61)
6935 dscp1=dsqrt(dsc_i**2+dp2_i**2-2*dsc_i*dp2_i
6936 & *(xx*cost2tab(i+1)+yy*sint2tab(i+1)))
6937 dscp2=dsqrt(dsc_i**2+dp2_i**2-2*dsc_i*dp2_i
6938 & *(xx*cost2tab(i+1)-yy*sint2tab(i+1)))
6939 s1=(1+x(63))/(0.1d0 + dscp1)
6940 s1_6=(1+x(64))/(0.1d0 + dscp1**6)
6941 s2=(1+x(65))/(0.1d0 + dscp2)
6942 s2_6=(1+x(65))/(0.1d0 + dscp2**6)
6943 sumene = ( sumene3*sint2tab(i+1) + sumene1)*(s1+s1_6)
6944 & + (sumene4*cost2tab(i+1) +sumene2)*(s2+s2_6)
6945 c write(2,'(i2," sumene",7f9.3)') i,sumene1,sumene2,sumene3,
6947 c & dscp1,dscp2,sumene
6948 c sumene = enesc(x,xx,yy,zz,cost2tab(i+1),sint2tab(i+1))
6949 escloc = escloc + sumene
6950 c write (2,*) "i",i," escloc",sumene,escloc,it,itype(i)
6955 C This section to check the numerical derivatives of the energy of ith side
6956 C chain in xx, yy, zz, and theta. Use the -DDEBUG compiler option or insert
6957 C #define DEBUG in the code to turn it on.
6959 write (2,*) "sumene =",sumene
6963 write (2,*) xx,yy,zz
6964 sumenep = enesc(x,xx,yy,zz,cost2tab(i+1),sint2tab(i+1))
6965 de_dxx_num=(sumenep-sumene)/aincr
6967 write (2,*) "xx+ sumene from enesc=",sumenep
6970 write (2,*) xx,yy,zz
6971 sumenep = enesc(x,xx,yy,zz,cost2tab(i+1),sint2tab(i+1))
6972 de_dyy_num=(sumenep-sumene)/aincr
6974 write (2,*) "yy+ sumene from enesc=",sumenep
6977 write (2,*) xx,yy,zz
6978 sumenep = enesc(x,xx,yy,zz,cost2tab(i+1),sint2tab(i+1))
6979 de_dzz_num=(sumenep-sumene)/aincr
6981 write (2,*) "zz+ sumene from enesc=",sumenep
6982 costsave=cost2tab(i+1)
6983 sintsave=sint2tab(i+1)
6984 cost2tab(i+1)=dcos(0.5d0*(theta(i+1)+aincr))
6985 sint2tab(i+1)=dsin(0.5d0*(theta(i+1)+aincr))
6986 sumenep = enesc(x,xx,yy,zz,cost2tab(i+1),sint2tab(i+1))
6987 de_dt_num=(sumenep-sumene)/aincr
6988 write (2,*) " t+ sumene from enesc=",sumenep
6989 cost2tab(i+1)=costsave
6990 sint2tab(i+1)=sintsave
6991 C End of diagnostics section.
6994 C Compute the gradient of esc
6996 c zz=zz*dsign(1.0,dfloat(itype(i)))
6997 pom_s1=(1.0d0+x(63))/(0.1d0 + dscp1)**2
6998 pom_s16=6*(1.0d0+x(64))/(0.1d0 + dscp1**6)**2
6999 pom_s2=(1.0d0+x(65))/(0.1d0 + dscp2)**2
7000 pom_s26=6*(1.0d0+x(65))/(0.1d0 + dscp2**6)**2
7001 pom_dx=dsc_i*dp2_i*cost2tab(i+1)
7002 pom_dy=dsc_i*dp2_i*sint2tab(i+1)
7003 pom_dt1=-0.5d0*dsc_i*dp2_i*(xx*sint2tab(i+1)-yy*cost2tab(i+1))
7004 pom_dt2=-0.5d0*dsc_i*dp2_i*(xx*sint2tab(i+1)+yy*cost2tab(i+1))
7005 pom1=(sumene3*sint2tab(i+1)+sumene1)
7006 & *(pom_s1/dscp1+pom_s16*dscp1**4)
7007 pom2=(sumene4*cost2tab(i+1)+sumene2)
7008 & *(pom_s2/dscp2+pom_s26*dscp2**4)
7009 sumene1x=x(2)+2*x(5)*xx+x(8)*zz+ x(9)*yy
7010 sumene3x=x(22)+2*x(25)*xx+x(28)*zz+x(29)*yy+3*x(31)*xx**2
7011 & +2*x(34)*xx*yy +2*x(35)*xx*zz +x(36)*(yy**2) +x(38)*(zz**2)
7013 sumene2x=x(12)+2*x(15)*xx+x(18)*zz+ x(19)*yy
7014 sumene4x=x(42)+2*x(45)*xx +x(48)*zz +x(49)*yy +3*x(51)*xx**2
7015 & +2*x(54)*xx*yy+2*x(55)*xx*zz+x(56)*(yy**2)+x(58)*(zz**2)
7017 de_dxx =(sumene1x+sumene3x*sint2tab(i+1))*(s1+s1_6)
7018 & +(sumene2x+sumene4x*cost2tab(i+1))*(s2+s2_6)
7019 & +(pom1+pom2)*pom_dx
7021 write(2,*), "de_dxx = ", de_dxx,de_dxx_num,itype(i)
7024 sumene1y=x(3) + 2*x(6)*yy + x(9)*xx + x(10)*zz
7025 sumene3y=x(23) +2*x(26)*yy +x(29)*xx +x(30)*zz +3*x(32)*yy**2
7026 & +x(34)*(xx**2) +2*x(36)*yy*xx +2*x(37)*yy*zz +x(39)*(zz**2)
7028 sumene2y=x(13) + 2*x(16)*yy + x(19)*xx + x(20)*zz
7029 sumene4y=x(43)+2*x(46)*yy+x(49)*xx +x(50)*zz
7030 & +3*x(52)*yy**2+x(54)*xx**2+2*x(56)*yy*xx +2*x(57)*yy*zz
7031 & +x(59)*zz**2 +x(60)*xx*zz
7032 de_dyy =(sumene1y+sumene3y*sint2tab(i+1))*(s1+s1_6)
7033 & +(sumene2y+sumene4y*cost2tab(i+1))*(s2+s2_6)
7034 & +(pom1-pom2)*pom_dy
7036 write(2,*), "de_dyy = ", de_dyy,de_dyy_num,itype(i)
7039 de_dzz =(x(24) +2*x(27)*zz +x(28)*xx +x(30)*yy
7040 & +3*x(33)*zz**2 +x(35)*xx**2 +x(37)*yy**2 +2*x(38)*zz*xx
7041 & +2*x(39)*zz*yy +x(40)*xx*yy)*sint2tab(i+1)*(s1+s1_6)
7042 & +(x(4) + 2*x(7)*zz+ x(8)*xx + x(10)*yy)*(s1+s1_6)
7043 & +(x(44)+2*x(47)*zz +x(48)*xx +x(50)*yy +3*x(53)*zz**2
7044 & +x(55)*xx**2 +x(57)*(yy**2)+2*x(58)*zz*xx +2*x(59)*zz*yy
7045 & +x(60)*xx*yy)*cost2tab(i+1)*(s2+s2_6)
7046 & + ( x(14) + 2*x(17)*zz+ x(18)*xx + x(20)*yy)*(s2+s2_6)
7048 write(2,*), "de_dzz = ", de_dzz,de_dzz_num,itype(i)
7051 de_dt = 0.5d0*sumene3*cost2tab(i+1)*(s1+s1_6)
7052 & -0.5d0*sumene4*sint2tab(i+1)*(s2+s2_6)
7053 & +pom1*pom_dt1+pom2*pom_dt2
7055 write(2,*), "de_dt = ", de_dt,de_dt_num,itype(i)
7060 cossc=scalar(dc_norm(1,i),dc_norm(1,i+nres))
7061 cossc1=scalar(dc_norm(1,i-1),dc_norm(1,i+nres))
7062 cosfac2xx=cosfac2*xx
7063 sinfac2yy=sinfac2*yy
7065 dt_dCi(k) = -(dc_norm(k,i-1)+costtab(i+1)*dc_norm(k,i))*
7067 dt_dCi1(k)= -(dc_norm(k,i)+costtab(i+1)*dc_norm(k,i-1))*
7069 pom=(dC_norm(k,i+nres)-cossc*dC_norm(k,i))*vbld_inv(i+1)
7070 pom1=(dC_norm(k,i+nres)-cossc1*dC_norm(k,i-1))*vbld_inv(i)
7071 c write (iout,*) "i",i," k",k," pom",pom," pom1",pom1,
7072 c & " dt_dCi",dt_dCi(k)," dt_dCi1",dt_dCi1(k)
7073 c write (iout,*) "dC_norm",(dC_norm(j,i),j=1,3),
7074 c & (dC_norm(j,i-1),j=1,3)," vbld_inv",vbld_inv(i+1),vbld_inv(i)
7075 dXX_Ci(k)=pom*cosfac-dt_dCi(k)*cosfac2xx
7076 dXX_Ci1(k)=-pom1*cosfac-dt_dCi1(k)*cosfac2xx
7077 dYY_Ci(k)=pom*sinfac+dt_dCi(k)*sinfac2yy
7078 dYY_Ci1(k)=pom1*sinfac+dt_dCi1(k)*sinfac2yy
7082 dZZ_Ci(k)=dZZ_Ci(k)-uzgrad(j,k,2,i-1)
7083 & *dsign(1.0d0,dfloat(itype(i)))*dC_norm(j,i+nres)
7084 dZZ_Ci1(k)=dZZ_Ci1(k)-uzgrad(j,k,1,i-1)
7085 & *dsign(1.0d0,dfloat(itype(i)))*dC_norm(j,i+nres)
7088 dXX_XYZ(k)=vbld_inv(i+nres)*(x_prime(k)-xx*dC_norm(k,i+nres))
7089 dYY_XYZ(k)=vbld_inv(i+nres)*(y_prime(k)-yy*dC_norm(k,i+nres))
7090 dZZ_XYZ(k)=vbld_inv(i+nres)*
7091 & (z_prime(k)-zz*dC_norm(k,i+nres))
7093 dt_dCi(k) = -dt_dCi(k)/sinttab(i+1)
7094 dt_dCi1(k)= -dt_dCi1(k)/sinttab(i+1)
7098 dXX_Ctab(k,i)=dXX_Ci(k)
7099 dXX_C1tab(k,i)=dXX_Ci1(k)
7100 dYY_Ctab(k,i)=dYY_Ci(k)
7101 dYY_C1tab(k,i)=dYY_Ci1(k)
7102 dZZ_Ctab(k,i)=dZZ_Ci(k)
7103 dZZ_C1tab(k,i)=dZZ_Ci1(k)
7104 dXX_XYZtab(k,i)=dXX_XYZ(k)
7105 dYY_XYZtab(k,i)=dYY_XYZ(k)
7106 dZZ_XYZtab(k,i)=dZZ_XYZ(k)
7110 c write (iout,*) "k",k," dxx_ci1",dxx_ci1(k)," dyy_ci1",
7111 c & dyy_ci1(k)," dzz_ci1",dzz_ci1(k)
7112 c write (iout,*) "k",k," dxx_ci",dxx_ci(k)," dyy_ci",
7113 c & dyy_ci(k)," dzz_ci",dzz_ci(k)
7114 c write (iout,*) "k",k," dt_dci",dt_dci(k)," dt_dci",
7116 c write (iout,*) "k",k," dxx_XYZ",dxx_XYZ(k)," dyy_XYZ",
7117 c & dyy_XYZ(k)," dzz_XYZ",dzz_XYZ(k)
7118 gscloc(k,i-1)=gscloc(k,i-1)+de_dxx*dxx_ci1(k)
7119 & +de_dyy*dyy_ci1(k)+de_dzz*dzz_ci1(k)+de_dt*dt_dCi1(k)
7120 gscloc(k,i)=gscloc(k,i)+de_dxx*dxx_Ci(k)
7121 & +de_dyy*dyy_Ci(k)+de_dzz*dzz_Ci(k)+de_dt*dt_dCi(k)
7122 gsclocx(k,i)= de_dxx*dxx_XYZ(k)
7123 & +de_dyy*dyy_XYZ(k)+de_dzz*dzz_XYZ(k)
7125 c write(iout,*) "ENERGY GRAD = ", (gscloc(k,i-1),k=1,3),
7126 c & (gscloc(k,i),k=1,3),(gsclocx(k,i),k=1,3)
7128 C to check gradient call subroutine check_grad
7134 c------------------------------------------------------------------------------
7135 double precision function enesc(x,xx,yy,zz,cost2,sint2)
7137 double precision x(65),xx,yy,zz,cost2,sint2,sumene1,sumene2,
7138 & sumene3,sumene4,sumene,dsc_i,dp2_i,dscp1,dscp2,s1,s1_6,s2,s2_6
7139 sumene1= x(1)+ x(2)*xx+ x(3)*yy+ x(4)*zz+ x(5)*xx**2
7140 & + x(6)*yy**2+ x(7)*zz**2+ x(8)*xx*zz+ x(9)*xx*yy
7142 sumene2= x(11) + x(12)*xx + x(13)*yy + x(14)*zz + x(15)*xx**2
7143 & + x(16)*yy**2 + x(17)*zz**2 + x(18)*xx*zz + x(19)*xx*yy
7145 sumene3= x(21) +x(22)*xx +x(23)*yy +x(24)*zz +x(25)*xx**2
7146 & +x(26)*yy**2 +x(27)*zz**2 +x(28)*xx*zz +x(29)*xx*yy
7147 & +x(30)*yy*zz +x(31)*xx**3 +x(32)*yy**3 +x(33)*zz**3
7148 & +x(34)*(xx**2)*yy +x(35)*(xx**2)*zz +x(36)*(yy**2)*xx
7149 & +x(37)*(yy**2)*zz +x(38)*(zz**2)*xx +x(39)*(zz**2)*yy
7151 sumene4= x(41) +x(42)*xx +x(43)*yy +x(44)*zz +x(45)*xx**2
7152 & +x(46)*yy**2 +x(47)*zz**2 +x(48)*xx*zz +x(49)*xx*yy
7153 & +x(50)*yy*zz +x(51)*xx**3 +x(52)*yy**3 +x(53)*zz**3
7154 & +x(54)*(xx**2)*yy +x(55)*(xx**2)*zz +x(56)*(yy**2)*xx
7155 & +x(57)*(yy**2)*zz +x(58)*(zz**2)*xx +x(59)*(zz**2)*yy
7157 dsc_i = 0.743d0+x(61)
7159 dscp1=dsqrt(dsc_i**2+dp2_i**2-2*dsc_i*dp2_i
7160 & *(xx*cost2+yy*sint2))
7161 dscp2=dsqrt(dsc_i**2+dp2_i**2-2*dsc_i*dp2_i
7162 & *(xx*cost2-yy*sint2))
7163 s1=(1+x(63))/(0.1d0 + dscp1)
7164 s1_6=(1+x(64))/(0.1d0 + dscp1**6)
7165 s2=(1+x(65))/(0.1d0 + dscp2)
7166 s2_6=(1+x(65))/(0.1d0 + dscp2**6)
7167 sumene = ( sumene3*sint2 + sumene1)*(s1+s1_6)
7168 & + (sumene4*cost2 +sumene2)*(s2+s2_6)
7173 c------------------------------------------------------------------------------
7174 subroutine gcont(rij,r0ij,eps0ij,delta,fcont,fprimcont)
7176 C This procedure calculates two-body contact function g(rij) and its derivative:
7179 C g(rij) = esp0ij*(-0.9375*x+0.625*x**3-0.1875*x**5) ! -1 =< x =< 1
7182 C where x=(rij-r0ij)/delta
7184 C rij - interbody distance, r0ij - contact distance, eps0ij - contact energy
7187 double precision rij,r0ij,eps0ij,fcont,fprimcont
7188 double precision x,x2,x4,delta
7192 if (x.lt.-1.0D0) then
7195 else if (x.le.1.0D0) then
7198 fcont=eps0ij*(x*(-0.9375D0+0.6250D0*x2-0.1875D0*x4)+0.5D0)
7199 fprimcont=eps0ij * (-0.9375D0+1.8750D0*x2-0.9375D0*x4)/delta
7206 c------------------------------------------------------------------------------
7207 subroutine splinthet(theti,delta,ss,ssder)
7208 implicit real*8 (a-h,o-z)
7209 include 'DIMENSIONS'
7210 include 'COMMON.VAR'
7211 include 'COMMON.GEO'
7214 if (theti.gt.pipol) then
7215 call gcont(theti,thetup,1.0d0,delta,ss,ssder)
7217 call gcont(-theti,-thetlow,1.0d0,delta,ss,ssder)
7222 c------------------------------------------------------------------------------
7223 subroutine spline1(x,x0,delta,f0,f1,fprim0,f,fprim)
7225 double precision x,x0,delta,f0,f1,fprim0,f,fprim
7226 double precision ksi,ksi2,ksi3,a1,a2,a3
7227 a1=fprim0*delta/(f1-f0)
7233 f=f0+(f1-f0)*ksi*(a1+ksi*(a2+a3*ksi))
7234 fprim=(f1-f0)/delta*(a1+ksi*(2*a2+3*ksi*a3))
7237 c------------------------------------------------------------------------------
7238 subroutine spline2(x,x0,delta,f0x,f1x,fprim0x,fx)
7240 double precision x,x0,delta,f0x,f1x,fprim0x,fx
7241 double precision ksi,ksi2,ksi3,a1,a2,a3
7246 a2=3*(f1x-f0x)-2*fprim0x*delta
7247 a3=fprim0x*delta-2*(f1x-f0x)
7248 fx=f0x+a1*ksi+a2*ksi2+a3*ksi3
7251 C-----------------------------------------------------------------------------
7253 C-----------------------------------------------------------------------------
7254 subroutine etor(etors)
7255 implicit real*8 (a-h,o-z)
7256 include 'DIMENSIONS'
7257 include 'COMMON.VAR'
7258 include 'COMMON.GEO'
7259 include 'COMMON.LOCAL'
7260 include 'COMMON.TORSION'
7261 include 'COMMON.INTERACT'
7262 include 'COMMON.DERIV'
7263 include 'COMMON.CHAIN'
7264 include 'COMMON.NAMES'
7265 include 'COMMON.IOUNITS'
7266 include 'COMMON.FFIELD'
7267 include 'COMMON.TORCNSTR'
7268 include 'COMMON.CONTROL'
7270 C Set lprn=.true. for debugging
7274 do i=iphi_start,iphi_end
7276 if (itype(i-2).eq.ntyp1.or. itype(i-1).eq.ntyp1
7277 & .or. itype(i).eq.ntyp1 .or. itype(i-3).eq.ntyp1) cycle
7278 itori=itortyp(itype(i-2))
7279 itori1=itortyp(itype(i-1))
7282 C Proline-Proline pair is a special case...
7283 if (itori.eq.3 .and. itori1.eq.3) then
7284 if (phii.gt.-dwapi3) then
7286 fac=1.0D0/(1.0D0-cosphi)
7287 etorsi=v1(1,3,3)*fac
7288 etorsi=etorsi+etorsi
7289 etors=etors+etorsi-v1(1,3,3)
7290 if (energy_dec) etors_ii=etors_ii+etorsi-v1(1,3,3)
7291 gloci=gloci-3*fac*etorsi*dsin(3*phii)
7294 v1ij=v1(j+1,itori,itori1)
7295 v2ij=v2(j+1,itori,itori1)
7298 etors=etors+v1ij*cosphi+v2ij*sinphi+dabs(v1ij)+dabs(v2ij)
7299 if (energy_dec) etors_ii=etors_ii+
7300 & v2ij*sinphi+dabs(v1ij)+dabs(v2ij)
7301 gloci=gloci+j*(v2ij*cosphi-v1ij*sinphi)
7305 v1ij=v1(j,itori,itori1)
7306 v2ij=v2(j,itori,itori1)
7309 etors=etors+v1ij*cosphi+v2ij*sinphi+dabs(v1ij)+dabs(v2ij)
7310 if (energy_dec) etors_ii=etors_ii+
7311 & v1ij*cosphi+v2ij*sinphi+dabs(v1ij)+dabs(v2ij)
7312 gloci=gloci+j*(v2ij*cosphi-v1ij*sinphi)
7315 if (energy_dec) write (iout,'(a6,i5,0pf7.3)')
7318 & write (iout,'(2(a3,2x,i3,2x),2i3,6f8.3/26x,6f8.3/)')
7319 & restyp(itype(i-2)),i-2,restyp(itype(i-1)),i-1,itori,itori1,
7320 & (v1(j,itori,itori1),j=1,6),(v2(j,itori,itori1),j=1,6)
7321 gloc(i-3,icg)=gloc(i-3,icg)+wtor*gloci
7322 c write (iout,*) 'i=',i,' gloc=',gloc(i-3,icg)
7326 c------------------------------------------------------------------------------
7327 subroutine etor_d(etors_d)
7331 c----------------------------------------------------------------------------
7333 subroutine etor(etors)
7334 implicit real*8 (a-h,o-z)
7335 include 'DIMENSIONS'
7336 include 'COMMON.VAR'
7337 include 'COMMON.GEO'
7338 include 'COMMON.LOCAL'
7339 include 'COMMON.TORSION'
7340 include 'COMMON.INTERACT'
7341 include 'COMMON.DERIV'
7342 include 'COMMON.CHAIN'
7343 include 'COMMON.NAMES'
7344 include 'COMMON.IOUNITS'
7345 include 'COMMON.FFIELD'
7346 include 'COMMON.TORCNSTR'
7347 include 'COMMON.CONTROL'
7349 C Set lprn=.true. for debugging
7353 do i=iphi_start,iphi_end
7354 C ANY TWO ARE DUMMY ATOMS in row CYCLE
7355 c if (((itype(i-3).eq.ntyp1).and.(itype(i-2).eq.ntyp1)).or.
7356 c & ((itype(i-2).eq.ntyp1).and.(itype(i-1).eq.ntyp1)) .or.
7357 c & ((itype(i-1).eq.ntyp1).and.(itype(i).eq.ntyp1))) cycle
7358 if (itype(i-2).eq.ntyp1.or. itype(i-1).eq.ntyp1
7359 & .or. itype(i).eq.ntyp1 .or. itype(i-3).eq.ntyp1) cycle
7360 C In current verion the ALL DUMMY ATOM POTENTIALS ARE OFF
7361 C For introducing the NH3+ and COO- group please check the etor_d for reference
7364 if (iabs(itype(i)).eq.20) then
7369 itori=itortyp(itype(i-2))
7370 itori1=itortyp(itype(i-1))
7373 C Regular cosine and sine terms
7374 do j=1,nterm(itori,itori1,iblock)
7375 v1ij=v1(j,itori,itori1,iblock)
7376 v2ij=v2(j,itori,itori1,iblock)
7379 etors=etors+v1ij*cosphi+v2ij*sinphi
7380 if (energy_dec) etors_ii=etors_ii+
7381 & v1ij*cosphi+v2ij*sinphi
7382 gloci=gloci+j*(v2ij*cosphi-v1ij*sinphi)
7386 C E = SUM ----------------------------------- - v1
7387 C [v2 cos(phi/2)+v3 sin(phi/2)]^2 + 1
7389 cosphi=dcos(0.5d0*phii)
7390 sinphi=dsin(0.5d0*phii)
7391 do j=1,nlor(itori,itori1,iblock)
7392 vl1ij=vlor1(j,itori,itori1)
7393 vl2ij=vlor2(j,itori,itori1)
7394 vl3ij=vlor3(j,itori,itori1)
7395 pom=vl2ij*cosphi+vl3ij*sinphi
7396 pom1=1.0d0/(pom*pom+1.0d0)
7397 etors=etors+vl1ij*pom1
7398 if (energy_dec) etors_ii=etors_ii+
7401 gloci=gloci+vl1ij*(vl3ij*cosphi-vl2ij*sinphi)*pom
7403 C Subtract the constant term
7404 etors=etors-v0(itori,itori1,iblock)
7405 if (energy_dec) write (iout,'(a6,i5,0pf7.3)')
7406 & 'etor',i,etors_ii-v0(itori,itori1,iblock)
7408 & write (iout,'(2(a3,2x,i3,2x),2i3,6f8.3/26x,6f8.3/)')
7409 & restyp(itype(i-2)),i-2,restyp(itype(i-1)),i-1,itori,itori1,
7410 & (v1(j,itori,itori1,iblock),j=1,6),
7411 & (v2(j,itori,itori1,iblock),j=1,6)
7412 gloc(i-3,icg)=gloc(i-3,icg)+wtor*gloci
7413 c write (iout,*) 'i=',i,' gloc=',gloc(i-3,icg)
7417 c----------------------------------------------------------------------------
7418 subroutine etor_d(etors_d)
7419 C 6/23/01 Compute double torsional energy
7420 implicit real*8 (a-h,o-z)
7421 include 'DIMENSIONS'
7422 include 'COMMON.VAR'
7423 include 'COMMON.GEO'
7424 include 'COMMON.LOCAL'
7425 include 'COMMON.TORSION'
7426 include 'COMMON.INTERACT'
7427 include 'COMMON.DERIV'
7428 include 'COMMON.CHAIN'
7429 include 'COMMON.NAMES'
7430 include 'COMMON.IOUNITS'
7431 include 'COMMON.FFIELD'
7432 include 'COMMON.TORCNSTR'
7434 C Set lprn=.true. for debugging
7438 c write(iout,*) "a tu??"
7439 do i=iphid_start,iphid_end
7440 C ANY TWO ARE DUMMY ATOMS in row CYCLE
7441 C if (((itype(i-3).eq.ntyp1).and.(itype(i-2).eq.ntyp1)).or.
7442 C & ((itype(i-2).eq.ntyp1).and.(itype(i-1).eq.ntyp1)).or.
7443 C & ((itype(i-1).eq.ntyp1).and.(itype(i).eq.ntyp1)) .or.
7444 C & ((itype(i).eq.ntyp1).and.(itype(i+1).eq.ntyp1))) cycle
7445 if ((itype(i-2).eq.ntyp1).or.itype(i-3).eq.ntyp1.or.
7446 & (itype(i-1).eq.ntyp1).or.(itype(i).eq.ntyp1).or.
7447 & (itype(i+1).eq.ntyp1)) cycle
7448 C In current verion the ALL DUMMY ATOM POTENTIALS ARE OFF
7449 itori=itortyp(itype(i-2))
7450 itori1=itortyp(itype(i-1))
7451 itori2=itortyp(itype(i))
7457 if (iabs(itype(i+1)).eq.20) iblock=2
7458 C Iblock=2 Proline type
7459 C ADASKO: WHEN PARAMETERS FOR THIS TYPE OF BLOCKING GROUP IS READY UNCOMMENT
7460 C CHECK WEATHER THERE IS NECCESITY FOR iblock=3 for COO-
7461 C if (itype(i+1).eq.ntyp1) iblock=3
7462 C The problem of NH3+ group can be resolved by adding new parameters please note if there
7463 C IS or IS NOT need for this
7464 C IF Yes uncomment below and add to parmread.F appropriate changes and to v1cij and so on
7465 C is (itype(i-3).eq.ntyp1) ntblock=2
7466 C ntblock is N-terminal blocking group
7468 C Regular cosine and sine terms
7469 do j=1,ntermd_1(itori,itori1,itori2,iblock)
7470 C Example of changes for NH3+ blocking group
7471 C do j=1,ntermd_1(itori,itori1,itori2,iblock,ntblock)
7472 C v1cij=v1c(1,j,itori,itori1,itori2,iblock,ntblock)
7473 v1cij=v1c(1,j,itori,itori1,itori2,iblock)
7474 v1sij=v1s(1,j,itori,itori1,itori2,iblock)
7475 v2cij=v1c(2,j,itori,itori1,itori2,iblock)
7476 v2sij=v1s(2,j,itori,itori1,itori2,iblock)
7477 cosphi1=dcos(j*phii)
7478 sinphi1=dsin(j*phii)
7479 cosphi2=dcos(j*phii1)
7480 sinphi2=dsin(j*phii1)
7481 etors_d=etors_d+v1cij*cosphi1+v1sij*sinphi1+
7482 & v2cij*cosphi2+v2sij*sinphi2
7483 gloci1=gloci1+j*(v1sij*cosphi1-v1cij*sinphi1)
7484 gloci2=gloci2+j*(v2sij*cosphi2-v2cij*sinphi2)
7486 do k=2,ntermd_2(itori,itori1,itori2,iblock)
7488 v1cdij = v2c(k,l,itori,itori1,itori2,iblock)
7489 v2cdij = v2c(l,k,itori,itori1,itori2,iblock)
7490 v1sdij = v2s(k,l,itori,itori1,itori2,iblock)
7491 v2sdij = v2s(l,k,itori,itori1,itori2,iblock)
7492 cosphi1p2=dcos(l*phii+(k-l)*phii1)
7493 cosphi1m2=dcos(l*phii-(k-l)*phii1)
7494 sinphi1p2=dsin(l*phii+(k-l)*phii1)
7495 sinphi1m2=dsin(l*phii-(k-l)*phii1)
7496 etors_d=etors_d+v1cdij*cosphi1p2+v2cdij*cosphi1m2+
7497 & v1sdij*sinphi1p2+v2sdij*sinphi1m2
7498 gloci1=gloci1+l*(v1sdij*cosphi1p2+v2sdij*cosphi1m2
7499 & -v1cdij*sinphi1p2-v2cdij*sinphi1m2)
7500 gloci2=gloci2+(k-l)*(v1sdij*cosphi1p2-v2sdij*cosphi1m2
7501 & -v1cdij*sinphi1p2+v2cdij*sinphi1m2)
7504 gloc(i-3,icg)=gloc(i-3,icg)+wtor_d*gloci1
7505 gloc(i-2,icg)=gloc(i-2,icg)+wtor_d*gloci2
7510 C----------------------------------------------------------------------------------
7511 C The rigorous attempt to derive energy function
7512 subroutine etor_kcc(etors)
7513 implicit real*8 (a-h,o-z)
7514 include 'DIMENSIONS'
7515 include 'COMMON.VAR'
7516 include 'COMMON.GEO'
7517 include 'COMMON.LOCAL'
7518 include 'COMMON.TORSION'
7519 include 'COMMON.INTERACT'
7520 include 'COMMON.DERIV'
7521 include 'COMMON.CHAIN'
7522 include 'COMMON.NAMES'
7523 include 'COMMON.IOUNITS'
7524 include 'COMMON.FFIELD'
7525 include 'COMMON.TORCNSTR'
7526 include 'COMMON.CONTROL'
7527 double precision c1(0:maxval_kcc),c2(0:maxval_kcc)
7529 c double precision thybt1(maxtermkcc),thybt2(maxtermkcc)
7530 C Set lprn=.true. for debugging
7533 C print *,"wchodze kcc"
7534 if (lprn) write (iout,*) "etor_kcc tor_mode",tor_mode
7536 do i=iphi_start,iphi_end
7537 C ANY TWO ARE DUMMY ATOMS in row CYCLE
7538 c if (((itype(i-3).eq.ntyp1).and.(itype(i-2).eq.ntyp1)).or.
7539 c & ((itype(i-2).eq.ntyp1).and.(itype(i-1).eq.ntyp1)) .or.
7540 c & ((itype(i-1).eq.ntyp1).and.(itype(i).eq.ntyp1))) cycle
7541 if (itype(i-2).eq.ntyp1.or. itype(i-1).eq.ntyp1
7542 & .or. itype(i).eq.ntyp1 .or. itype(i-3).eq.ntyp1) cycle
7543 itori=itortyp(itype(i-2))
7544 itori1=itortyp(itype(i-1))
7549 C to avoid multiple devision by 2
7550 c theti22=0.5d0*theta(i)
7551 C theta 12 is the theta_1 /2
7552 C theta 22 is theta_2 /2
7553 c theti12=0.5d0*theta(i-1)
7554 C and appropriate sinus function
7555 sinthet1=dsin(theta(i-1))
7556 sinthet2=dsin(theta(i))
7557 costhet1=dcos(theta(i-1))
7558 costhet2=dcos(theta(i))
7559 C to speed up lets store its mutliplication
7560 sint1t2=sinthet2*sinthet1
7562 C \sum_{i=1}^n (sin(theta_1) * sin(theta_2))^n * (c_n* cos(n*gamma)
7563 C +d_n*sin(n*gamma)) *
7564 C \sum_{i=1}^m (1+a_m*Tb_m(cos(theta_1 /2))+b_m*Tb_m(cos(theta_2 /2)))
7565 C we have two sum 1) Non-Chebyshev which is with n and gamma
7566 nval=nterm_kcc_Tb(itori,itori1)
7572 c1(j)=c1(j-1)*costhet1
7573 c2(j)=c2(j-1)*costhet2
7576 do j=1,nterm_kcc(itori,itori1)
7580 sint1t2n=sint1t2n*sint1t2
7586 sumvalc=sumvalc+v1_kcc(l,k,j,itori1,itori)*c1(k)*c2(l)
7587 gradvalct1=gradvalct1+
7588 & (k-1)*v1_kcc(l,k,j,itori1,itori)*c1(k-1)*c2(l)
7589 gradvalct2=gradvalct2+
7590 & (l-1)*v1_kcc(l,k,j,itori1,itori)*c1(k)*c2(l-1)
7593 gradvalct1=-gradvalct1*sinthet1
7594 gradvalct2=-gradvalct2*sinthet2
7600 sumvals=sumvals+v2_kcc(l,k,j,itori1,itori)*c1(k)*c2(l)
7601 gradvalst1=gradvalst1+
7602 & (k-1)*v2_kcc(l,k,j,itori1,itori)*c1(k-1)*c2(l)
7603 gradvalst2=gradvalst2+
7604 & (l-1)*v2_kcc(l,k,j,itori1,itori)*c1(k)*c2(l-1)
7607 gradvalst1=-gradvalst1*sinthet1
7608 gradvalst2=-gradvalst2*sinthet2
7609 if (lprn) write (iout,*)j,"sumvalc",sumvalc," sumvals",sumvals
7610 etori=etori+sint1t2n*(sumvalc*cosphi+sumvals*sinphi)
7611 C glocig is the gradient local i site in gamma
7612 glocig=glocig+j*sint1t2n*(sumvals*cosphi-sumvalc*sinphi)
7613 C now gradient over theta_1
7614 glocit1=glocit1+sint1t2n*(gradvalct1*cosphi+gradvalst1*sinphi)
7615 & +j*sint1t2n1*costhet1*sinthet2*(sumvalc*cosphi+sumvals*sinphi)
7616 glocit2=glocit2+sint1t2n*(gradvalct2*cosphi+gradvalst2*sinphi)
7617 & +j*sint1t2n1*sinthet1*costhet2*(sumvalc*cosphi+sumvals*sinphi)
7620 C derivative over gamma
7621 gloc(i-3,icg)=gloc(i-3,icg)+wtor*glocig
7622 C derivative over theta1
7623 gloc(nphi+i-3,icg)=gloc(nphi+i-3,icg)+wtor*glocit1
7624 C now derivative over theta2
7625 gloc(nphi+i-2,icg)=gloc(nphi+i-2,icg)+wtor*glocit2
7627 write (iout,*) i-2,i-1,itype(i-2),itype(i-1),itori,itori1,
7628 & theta(i-1)*rad2deg,theta(i)*rad2deg,phii*rad2deg,etori
7629 write (iout,*) "c1",(c1(k),k=0,nval),
7630 & " c2",(c2(k),k=0,nval)
7635 c---------------------------------------------------------------------------------------------
7636 subroutine etor_constr(edihcnstr)
7637 implicit real*8 (a-h,o-z)
7638 include 'DIMENSIONS'
7639 include 'COMMON.VAR'
7640 include 'COMMON.GEO'
7641 include 'COMMON.LOCAL'
7642 include 'COMMON.TORSION'
7643 include 'COMMON.INTERACT'
7644 include 'COMMON.DERIV'
7645 include 'COMMON.CHAIN'
7646 include 'COMMON.NAMES'
7647 include 'COMMON.IOUNITS'
7648 include 'COMMON.FFIELD'
7649 include 'COMMON.TORCNSTR'
7650 include 'COMMON.BOUNDS'
7651 include 'COMMON.CONTROL'
7652 ! 6/20/98 - dihedral angle constraints
7654 c do i=1,ndih_constr
7655 if (raw_psipred) then
7656 do i=idihconstr_start,idihconstr_end
7657 itori=idih_constr(i)
7659 gaudih_i=vpsipred(1,i)
7663 cos_i=(1.0d0-dcos(phii-phibound(j,i)))/s**2
7664 dexpcos_i=dexp(-cos_i*cos_i)
7665 gaudih_i=gaudih_i+vpsipred(j+1,i)*dexpcos_i
7666 gauder_i=gauder_i-2*vpsipred(j+1,i)*dsin(phii-phibound(j,i))
7667 & *cos_i*dexpcos_i/s**2
7669 edihcnstr=edihcnstr-wdihc*dlog(gaudih_i)
7670 gloc(itori-3,icg)=gloc(itori-3,icg)-wdihc*gauder_i/gaudih_i
7672 & write (iout,'(2i5,f8.3,f8.5,2(f8.5,2f8.3),f10.5)')
7673 & i,itori,phii*rad2deg,vpsipred(1,i),vpsipred(2,i),
7674 & phibound(1,i)*rad2deg,sdihed(1,i)*rad2deg,vpsipred(3,i),
7675 & phibound(2,i)*rad2deg,sdihed(2,i)*rad2deg,
7676 & -wdihc*dlog(gaudih_i)
7680 do i=idihconstr_start,idihconstr_end
7681 itori=idih_constr(i)
7683 difi=pinorm(phii-phi0(i))
7684 if (difi.gt.drange(i)) then
7686 edihcnstr=edihcnstr+0.25d0*ftors(i)*difi**4
7687 gloc(itori-3,icg)=gloc(itori-3,icg)+ftors(i)*difi**3
7688 else if (difi.lt.-drange(i)) then
7690 edihcnstr=edihcnstr+0.25d0*ftors(i)*difi**4
7691 gloc(itori-3,icg)=gloc(itori-3,icg)+ftors(i)*difi**3
7701 c----------------------------------------------------------------------------
7702 C The rigorous attempt to derive energy function
7703 subroutine ebend_kcc(etheta)
7705 implicit real*8 (a-h,o-z)
7706 include 'DIMENSIONS'
7707 include 'COMMON.VAR'
7708 include 'COMMON.GEO'
7709 include 'COMMON.LOCAL'
7710 include 'COMMON.TORSION'
7711 include 'COMMON.INTERACT'
7712 include 'COMMON.DERIV'
7713 include 'COMMON.CHAIN'
7714 include 'COMMON.NAMES'
7715 include 'COMMON.IOUNITS'
7716 include 'COMMON.FFIELD'
7717 include 'COMMON.TORCNSTR'
7718 include 'COMMON.CONTROL'
7720 double precision thybt1(maxang_kcc)
7721 C Set lprn=.true. for debugging
7724 C print *,"wchodze kcc"
7725 if (lprn) write (iout,*) "ebend_kcc tor_mode",tor_mode
7727 do i=ithet_start,ithet_end
7728 c print *,i,itype(i-1),itype(i),itype(i-2)
7729 if ((itype(i-1).eq.ntyp1).or.itype(i-2).eq.ntyp1
7730 & .or.itype(i).eq.ntyp1) cycle
7731 iti=iabs(itortyp(itype(i-1)))
7732 sinthet=dsin(theta(i))
7733 costhet=dcos(theta(i))
7734 do j=1,nbend_kcc_Tb(iti)
7735 thybt1(j)=v1bend_chyb(j,iti)
7737 sumth1thyb=v1bend_chyb(0,iti)+
7738 & tschebyshev(1,nbend_kcc_Tb(iti),thybt1(1),costhet)
7739 if (lprn) write (iout,*) i-1,itype(i-1),iti,theta(i)*rad2deg,
7741 ihelp=nbend_kcc_Tb(iti)-1
7742 gradthybt1=gradtschebyshev(0,ihelp,thybt1(1),costhet)
7743 etheta=etheta+sumth1thyb
7744 C print *,sumth1thyb,gradthybt1,sinthet*(-0.5d0)
7745 gloc(nphi+i-2,icg)=gloc(nphi+i-2,icg)-wang*gradthybt1*sinthet
7749 c-------------------------------------------------------------------------------------
7750 subroutine etheta_constr(ethetacnstr)
7752 implicit real*8 (a-h,o-z)
7753 include 'DIMENSIONS'
7754 include 'COMMON.VAR'
7755 include 'COMMON.GEO'
7756 include 'COMMON.LOCAL'
7757 include 'COMMON.TORSION'
7758 include 'COMMON.INTERACT'
7759 include 'COMMON.DERIV'
7760 include 'COMMON.CHAIN'
7761 include 'COMMON.NAMES'
7762 include 'COMMON.IOUNITS'
7763 include 'COMMON.FFIELD'
7764 include 'COMMON.TORCNSTR'
7765 include 'COMMON.CONTROL'
7767 C print *,ithetaconstr_start,ithetaconstr_end,"TU"
7768 do i=ithetaconstr_start,ithetaconstr_end
7769 itheta=itheta_constr(i)
7770 thetiii=theta(itheta)
7771 difi=pinorm(thetiii-theta_constr0(i))
7772 if (difi.gt.theta_drange(i)) then
7773 difi=difi-theta_drange(i)
7774 ethetacnstr=ethetacnstr+0.25d0*for_thet_constr(i)*difi**4
7775 gloc(itheta+nphi-2,icg)=gloc(itheta+nphi-2,icg)
7776 & +for_thet_constr(i)*difi**3
7777 else if (difi.lt.-drange(i)) then
7779 ethetacnstr=ethetacnstr+0.25d0*for_thet_constr(i)*difi**4
7780 gloc(itheta+nphi-2,icg)=gloc(itheta+nphi-2,icg)
7781 & +for_thet_constr(i)*difi**3
7785 if (energy_dec) then
7786 write (iout,'(a6,2i5,4f8.3,2e14.5)') "ethetc",
7787 & i,itheta,rad2deg*thetiii,
7788 & rad2deg*theta_constr0(i), rad2deg*theta_drange(i),
7789 & rad2deg*difi,0.25d0*for_thet_constr(i)*difi**4,
7790 & gloc(itheta+nphi-2,icg)
7795 c------------------------------------------------------------------------------
7796 subroutine eback_sc_corr(esccor)
7797 c 7/21/2007 Correlations between the backbone-local and side-chain-local
7798 c conformational states; temporarily implemented as differences
7799 c between UNRES torsional potentials (dependent on three types of
7800 c residues) and the torsional potentials dependent on all 20 types
7801 c of residues computed from AM1 energy surfaces of terminally-blocked
7802 c amino-acid residues.
7803 implicit real*8 (a-h,o-z)
7804 include 'DIMENSIONS'
7805 include 'COMMON.VAR'
7806 include 'COMMON.GEO'
7807 include 'COMMON.LOCAL'
7808 include 'COMMON.TORSION'
7809 include 'COMMON.SCCOR'
7810 include 'COMMON.INTERACT'
7811 include 'COMMON.DERIV'
7812 include 'COMMON.CHAIN'
7813 include 'COMMON.NAMES'
7814 include 'COMMON.IOUNITS'
7815 include 'COMMON.FFIELD'
7816 include 'COMMON.CONTROL'
7818 C Set lprn=.true. for debugging
7821 c write (iout,*) "EBACK_SC_COR",itau_start,itau_end
7823 do i=itau_start,itau_end
7824 if ((itype(i-2).eq.ntyp1).or.(itype(i-1).eq.ntyp1)) cycle
7826 isccori=isccortyp(itype(i-2))
7827 isccori1=isccortyp(itype(i-1))
7828 c write (iout,*) "EBACK_SC_COR",i,nterm_sccor(isccori,isccori1)
7830 do intertyp=1,3 !intertyp
7831 cc Added 09 May 2012 (Adasko)
7832 cc Intertyp means interaction type of backbone mainchain correlation:
7833 c 1 = SC...Ca...Ca...Ca
7834 c 2 = Ca...Ca...Ca...SC
7835 c 3 = SC...Ca...Ca...SCi
7837 if (((intertyp.eq.3).and.((itype(i-2).eq.10).or.
7838 & (itype(i-1).eq.10).or.(itype(i-2).eq.ntyp1).or.
7839 & (itype(i-1).eq.ntyp1)))
7840 & .or. ((intertyp.eq.1).and.((itype(i-2).eq.10)
7841 & .or.(itype(i-2).eq.ntyp1).or.(itype(i-1).eq.ntyp1)
7842 & .or.(itype(i).eq.ntyp1)))
7843 & .or.((intertyp.eq.2).and.((itype(i-1).eq.10).or.
7844 & (itype(i-1).eq.ntyp1).or.(itype(i-2).eq.ntyp1).or.
7845 & (itype(i-3).eq.ntyp1)))) cycle
7846 if ((intertyp.eq.2).and.(i.eq.4).and.(itype(1).eq.ntyp1)) cycle
7847 if ((intertyp.eq.1).and.(i.eq.nres).and.(itype(nres).eq.ntyp1))
7849 do j=1,nterm_sccor(isccori,isccori1)
7850 v1ij=v1sccor(j,intertyp,isccori,isccori1)
7851 v2ij=v2sccor(j,intertyp,isccori,isccori1)
7852 cosphi=dcos(j*tauangle(intertyp,i))
7853 sinphi=dsin(j*tauangle(intertyp,i))
7854 esccor=esccor+v1ij*cosphi+v2ij*sinphi
7855 gloci=gloci+j*(v2ij*cosphi-v1ij*sinphi)
7857 c write (iout,*) "EBACK_SC_COR",i,v1ij*cosphi+v2ij*sinphi,intertyp
7858 gloc_sc(intertyp,i-3,icg)=gloc_sc(intertyp,i-3,icg)+wsccor*gloci
7860 & write (iout,'(2(a3,2x,i3,2x),2i3,6f8.3/26x,6f8.3/)')
7861 & restyp(itype(i-2)),i-2,restyp(itype(i-1)),i-1,isccori,isccori1,
7862 & (v1sccor(j,intertyp,isccori,isccori1),j=1,6)
7863 & ,(v2sccor(j,intertyp,isccori,isccori1),j=1,6)
7864 gsccor_loc(i-3)=gsccor_loc(i-3)+gloci
7870 c----------------------------------------------------------------------------
7871 subroutine multibody(ecorr)
7872 C This subroutine calculates multi-body contributions to energy following
7873 C the idea of Skolnick et al. If side chains I and J make a contact and
7874 C at the same time side chains I+1 and J+1 make a contact, an extra
7875 C contribution equal to sqrt(eps(i,j)*eps(i+1,j+1)) is added.
7876 implicit real*8 (a-h,o-z)
7877 include 'DIMENSIONS'
7878 include 'COMMON.IOUNITS'
7879 include 'COMMON.DERIV'
7880 include 'COMMON.INTERACT'
7881 include 'COMMON.CONTACTS'
7882 double precision gx(3),gx1(3)
7885 C Set lprn=.true. for debugging
7889 write (iout,'(a)') 'Contact function values:'
7891 write (iout,'(i2,20(1x,i2,f10.5))')
7892 & i,(jcont(j,i),facont(j,i),j=1,num_cont(i))
7907 num_conti=num_cont(i)
7908 num_conti1=num_cont(i1)
7913 if (j1.eq.j+ishift .or. j1.eq.j-ishift) then
7914 cd write(iout,*)'i=',i,' j=',j,' i1=',i1,' j1=',j1,
7915 cd & ' ishift=',ishift
7916 C Contacts I--J and I+ISHIFT--J+-ISHIFT1 occur simultaneously.
7917 C The system gains extra energy.
7918 ecorr=ecorr+esccorr(i,j,i1,j1,jj,kk)
7919 endif ! j1==j+-ishift
7928 c------------------------------------------------------------------------------
7929 double precision function esccorr(i,j,k,l,jj,kk)
7930 implicit real*8 (a-h,o-z)
7931 include 'DIMENSIONS'
7932 include 'COMMON.IOUNITS'
7933 include 'COMMON.DERIV'
7934 include 'COMMON.INTERACT'
7935 include 'COMMON.CONTACTS'
7936 include 'COMMON.SHIELD'
7937 double precision gx(3),gx1(3)
7942 cd write (iout,'(4i5,3f10.5)') i,j,k,l,eij,ekl,-eij*ekl
7943 C Calculate the multi-body contribution to energy.
7944 C Calculate multi-body contributions to the gradient.
7945 cd write (iout,'(2(2i3,3f10.5))')i,j,(gacont(m,jj,i),m=1,3),
7946 cd & k,l,(gacont(m,kk,k),m=1,3)
7948 gx(m) =ekl*gacont(m,jj,i)
7949 gx1(m)=eij*gacont(m,kk,k)
7950 gradxorr(m,i)=gradxorr(m,i)-gx(m)
7951 gradxorr(m,j)=gradxorr(m,j)+gx(m)
7952 gradxorr(m,k)=gradxorr(m,k)-gx1(m)
7953 gradxorr(m,l)=gradxorr(m,l)+gx1(m)
7957 gradcorr(ll,m)=gradcorr(ll,m)+gx(ll)
7962 gradcorr(ll,m)=gradcorr(ll,m)+gx1(ll)
7968 c------------------------------------------------------------------------------
7969 subroutine multibody_hb(ecorr,ecorr5,ecorr6,n_corr,n_corr1)
7970 C This subroutine calculates multi-body contributions to hydrogen-bonding
7971 implicit real*8 (a-h,o-z)
7972 include 'DIMENSIONS'
7973 include 'COMMON.IOUNITS'
7976 parameter (max_cont=maxconts)
7977 parameter (max_dim=26)
7978 integer source,CorrelType,CorrelID,CorrelType1,CorrelID1,Error
7979 double precision zapas(max_dim,maxconts,max_fg_procs),
7980 & zapas_recv(max_dim,maxconts,max_fg_procs)
7981 common /przechowalnia/ zapas
7982 integer status(MPI_STATUS_SIZE),req(maxconts*2),
7983 & status_array(MPI_STATUS_SIZE,maxconts*2)
7985 include 'COMMON.SETUP'
7986 include 'COMMON.FFIELD'
7987 include 'COMMON.DERIV'
7988 include 'COMMON.INTERACT'
7989 include 'COMMON.CONTACTS'
7990 include 'COMMON.CONTROL'
7991 include 'COMMON.LOCAL'
7992 double precision gx(3),gx1(3),time00
7995 C Set lprn=.true. for debugging
8000 if (nfgtasks.le.1) goto 30
8002 write (iout,'(a)') 'Contact function values before RECEIVE:'
8004 write (iout,'(2i3,50(1x,i2,f5.2))')
8005 & i,num_cont_hb(i),(jcont_hb(j,i),facont_hb(j,i),
8006 & j=1,num_cont_hb(i))
8010 do i=1,ntask_cont_from
8013 do i=1,ntask_cont_to
8016 c write (iout,*) "ntask_cont_from",ntask_cont_from," ntask_cont_to",
8018 C Make the list of contacts to send to send to other procesors
8019 c write (iout,*) "limits",max0(iturn4_end-1,iatel_s),iturn3_end
8021 do i=iturn3_start,iturn3_end
8022 c write (iout,*) "make contact list turn3",i," num_cont",
8024 call add_hb_contact(i,i+2,iturn3_sent_local(1,i))
8026 do i=iturn4_start,iturn4_end
8027 c write (iout,*) "make contact list turn4",i," num_cont",
8029 call add_hb_contact(i,i+3,iturn4_sent_local(1,i))
8033 c write (iout,*) "make contact list longrange",i,ii," num_cont",
8035 do j=1,num_cont_hb(i)
8038 iproc=iint_sent_local(k,jjc,ii)
8039 c write (iout,*) "i",i," j",j," k",k," jjc",jjc," iproc",iproc
8040 if (iproc.gt.0) then
8041 ncont_sent(iproc)=ncont_sent(iproc)+1
8042 nn=ncont_sent(iproc)
8044 zapas(2,nn,iproc)=jjc
8045 zapas(3,nn,iproc)=facont_hb(j,i)
8046 zapas(4,nn,iproc)=ees0p(j,i)
8047 zapas(5,nn,iproc)=ees0m(j,i)
8048 zapas(6,nn,iproc)=gacont_hbr(1,j,i)
8049 zapas(7,nn,iproc)=gacont_hbr(2,j,i)
8050 zapas(8,nn,iproc)=gacont_hbr(3,j,i)
8051 zapas(9,nn,iproc)=gacontm_hb1(1,j,i)
8052 zapas(10,nn,iproc)=gacontm_hb1(2,j,i)
8053 zapas(11,nn,iproc)=gacontm_hb1(3,j,i)
8054 zapas(12,nn,iproc)=gacontp_hb1(1,j,i)
8055 zapas(13,nn,iproc)=gacontp_hb1(2,j,i)
8056 zapas(14,nn,iproc)=gacontp_hb1(3,j,i)
8057 zapas(15,nn,iproc)=gacontm_hb2(1,j,i)
8058 zapas(16,nn,iproc)=gacontm_hb2(2,j,i)
8059 zapas(17,nn,iproc)=gacontm_hb2(3,j,i)
8060 zapas(18,nn,iproc)=gacontp_hb2(1,j,i)
8061 zapas(19,nn,iproc)=gacontp_hb2(2,j,i)
8062 zapas(20,nn,iproc)=gacontp_hb2(3,j,i)
8063 zapas(21,nn,iproc)=gacontm_hb3(1,j,i)
8064 zapas(22,nn,iproc)=gacontm_hb3(2,j,i)
8065 zapas(23,nn,iproc)=gacontm_hb3(3,j,i)
8066 zapas(24,nn,iproc)=gacontp_hb3(1,j,i)
8067 zapas(25,nn,iproc)=gacontp_hb3(2,j,i)
8068 zapas(26,nn,iproc)=gacontp_hb3(3,j,i)
8075 & "Numbers of contacts to be sent to other processors",
8076 & (ncont_sent(i),i=1,ntask_cont_to)
8077 write (iout,*) "Contacts sent"
8078 do ii=1,ntask_cont_to
8080 iproc=itask_cont_to(ii)
8081 write (iout,*) nn," contacts to processor",iproc,
8082 & " of CONT_TO_COMM group"
8084 write(iout,'(2f5.0,4f10.5)')(zapas(j,i,ii),j=1,5)
8092 CorrelID1=nfgtasks+fg_rank+1
8094 C Receive the numbers of needed contacts from other processors
8095 do ii=1,ntask_cont_from
8096 iproc=itask_cont_from(ii)
8098 call MPI_Irecv(ncont_recv(ii),1,MPI_INTEGER,iproc,CorrelType,
8099 & FG_COMM,req(ireq),IERR)
8101 c write (iout,*) "IRECV ended"
8103 C Send the number of contacts needed by other processors
8104 do ii=1,ntask_cont_to
8105 iproc=itask_cont_to(ii)
8107 call MPI_Isend(ncont_sent(ii),1,MPI_INTEGER,iproc,CorrelType,
8108 & FG_COMM,req(ireq),IERR)
8110 c write (iout,*) "ISEND ended"
8111 c write (iout,*) "number of requests (nn)",ireq
8114 & call MPI_Waitall(ireq,req,status_array,ierr)
8116 c & "Numbers of contacts to be received from other processors",
8117 c & (ncont_recv(i),i=1,ntask_cont_from)
8121 do ii=1,ntask_cont_from
8122 iproc=itask_cont_from(ii)
8124 c write (iout,*) "Receiving",nn," contacts from processor",iproc,
8125 c & " of CONT_TO_COMM group"
8129 call MPI_Irecv(zapas_recv(1,1,ii),nn*max_dim,
8130 & MPI_DOUBLE_PRECISION,iproc,CorrelType1,FG_COMM,req(ireq),IERR)
8131 c write (iout,*) "ireq,req",ireq,req(ireq)
8134 C Send the contacts to processors that need them
8135 do ii=1,ntask_cont_to
8136 iproc=itask_cont_to(ii)
8138 c write (iout,*) nn," contacts to processor",iproc,
8139 c & " of CONT_TO_COMM group"
8142 call MPI_Isend(zapas(1,1,ii),nn*max_dim,MPI_DOUBLE_PRECISION,
8143 & iproc,CorrelType1,FG_COMM,req(ireq),IERR)
8144 c write (iout,*) "ireq,req",ireq,req(ireq)
8146 c write(iout,'(2f5.0,4f10.5)')(zapas(j,i,ii),j=1,5)
8150 c write (iout,*) "number of requests (contacts)",ireq
8151 c write (iout,*) "req",(req(i),i=1,4)
8154 & call MPI_Waitall(ireq,req,status_array,ierr)
8155 do iii=1,ntask_cont_from
8156 iproc=itask_cont_from(iii)
8159 write (iout,*) "Received",nn," contacts from processor",iproc,
8160 & " of CONT_FROM_COMM group"
8163 write(iout,'(2f5.0,4f10.5)')(zapas_recv(j,i,iii),j=1,5)
8168 ii=zapas_recv(1,i,iii)
8169 c Flag the received contacts to prevent double-counting
8170 jj=-zapas_recv(2,i,iii)
8171 c write (iout,*) "iii",iii," i",i," ii",ii," jj",jj
8173 nnn=num_cont_hb(ii)+1
8176 facont_hb(nnn,ii)=zapas_recv(3,i,iii)
8177 ees0p(nnn,ii)=zapas_recv(4,i,iii)
8178 ees0m(nnn,ii)=zapas_recv(5,i,iii)
8179 gacont_hbr(1,nnn,ii)=zapas_recv(6,i,iii)
8180 gacont_hbr(2,nnn,ii)=zapas_recv(7,i,iii)
8181 gacont_hbr(3,nnn,ii)=zapas_recv(8,i,iii)
8182 gacontm_hb1(1,nnn,ii)=zapas_recv(9,i,iii)
8183 gacontm_hb1(2,nnn,ii)=zapas_recv(10,i,iii)
8184 gacontm_hb1(3,nnn,ii)=zapas_recv(11,i,iii)
8185 gacontp_hb1(1,nnn,ii)=zapas_recv(12,i,iii)
8186 gacontp_hb1(2,nnn,ii)=zapas_recv(13,i,iii)
8187 gacontp_hb1(3,nnn,ii)=zapas_recv(14,i,iii)
8188 gacontm_hb2(1,nnn,ii)=zapas_recv(15,i,iii)
8189 gacontm_hb2(2,nnn,ii)=zapas_recv(16,i,iii)
8190 gacontm_hb2(3,nnn,ii)=zapas_recv(17,i,iii)
8191 gacontp_hb2(1,nnn,ii)=zapas_recv(18,i,iii)
8192 gacontp_hb2(2,nnn,ii)=zapas_recv(19,i,iii)
8193 gacontp_hb2(3,nnn,ii)=zapas_recv(20,i,iii)
8194 gacontm_hb3(1,nnn,ii)=zapas_recv(21,i,iii)
8195 gacontm_hb3(2,nnn,ii)=zapas_recv(22,i,iii)
8196 gacontm_hb3(3,nnn,ii)=zapas_recv(23,i,iii)
8197 gacontp_hb3(1,nnn,ii)=zapas_recv(24,i,iii)
8198 gacontp_hb3(2,nnn,ii)=zapas_recv(25,i,iii)
8199 gacontp_hb3(3,nnn,ii)=zapas_recv(26,i,iii)
8203 write (iout,'(a)') 'Contact function values after receive:'
8205 write (iout,'(2i3,50(1x,i3,f5.2))')
8206 & i,num_cont_hb(i),(jcont_hb(j,i),facont_hb(j,i),
8207 & j=1,num_cont_hb(i))
8214 write (iout,'(a)') 'Contact function values:'
8216 write (iout,'(2i3,50(1x,i3,f5.2))')
8217 & i,num_cont_hb(i),(jcont_hb(j,i),facont_hb(j,i),
8218 & j=1,num_cont_hb(i))
8223 C Remove the loop below after debugging !!!
8230 C Calculate the local-electrostatic correlation terms
8231 do i=min0(iatel_s,iturn4_start),max0(iatel_e,iturn3_end)
8233 num_conti=num_cont_hb(i)
8234 num_conti1=num_cont_hb(i+1)
8241 c write (iout,*) 'i=',i,' j=',j,' i1=',i1,' j1=',j1,
8242 c & ' jj=',jj,' kk=',kk
8244 if ((j.gt.0 .and. j1.gt.0 .or. j.gt.0 .and. j1.lt.0
8245 & .or. j.lt.0 .and. j1.gt.0) .and.
8246 & (jp1.eq.jp+1 .or. jp1.eq.jp-1)) then
8247 C Contacts I-J and (I+1)-(J+1) or (I+1)-(J-1) occur simultaneously.
8248 C The system gains extra energy.
8249 ecorr=ecorr+ehbcorr(i,jp,i+1,jp1,jj,kk,0.72D0,0.32D0)
8250 if (energy_dec) write (iout,'(a6,2i5,0pf7.3)')
8251 & 'ecorrh',i,j,ehbcorr(i,j,i+1,j1,jj,kk,0.72D0,0.32D0)
8253 else if (j1.eq.j) then
8254 C Contacts I-J and I-(J+1) occur simultaneously.
8255 C The system loses extra energy.
8256 c ecorr=ecorr+ehbcorr(i,j,i+1,j,jj,kk,0.60D0,-0.40D0)
8261 c write (iout,*) 'i=',i,' j=',j,' i1=',i1,' j1=',j1,
8262 c & ' jj=',jj,' kk=',kk
8264 C Contacts I-J and (I+1)-J occur simultaneously.
8265 C The system loses extra energy.
8266 c ecorr=ecorr+ehbcorr(i,j,i,j+1,jj,kk,0.60D0,-0.40D0)
8273 c------------------------------------------------------------------------------
8274 subroutine add_hb_contact(ii,jj,itask)
8275 implicit real*8 (a-h,o-z)
8276 include "DIMENSIONS"
8277 include "COMMON.IOUNITS"
8280 parameter (max_cont=maxconts)
8281 parameter (max_dim=26)
8282 include "COMMON.CONTACTS"
8283 double precision zapas(max_dim,maxconts,max_fg_procs),
8284 & zapas_recv(max_dim,maxconts,max_fg_procs)
8285 common /przechowalnia/ zapas
8286 integer i,j,ii,jj,iproc,itask(4),nn
8287 c write (iout,*) "itask",itask
8290 if (iproc.gt.0) then
8291 do j=1,num_cont_hb(ii)
8293 c write (iout,*) "i",ii," j",jj," jjc",jjc
8295 ncont_sent(iproc)=ncont_sent(iproc)+1
8296 nn=ncont_sent(iproc)
8297 zapas(1,nn,iproc)=ii
8298 zapas(2,nn,iproc)=jjc
8299 zapas(3,nn,iproc)=facont_hb(j,ii)
8300 zapas(4,nn,iproc)=ees0p(j,ii)
8301 zapas(5,nn,iproc)=ees0m(j,ii)
8302 zapas(6,nn,iproc)=gacont_hbr(1,j,ii)
8303 zapas(7,nn,iproc)=gacont_hbr(2,j,ii)
8304 zapas(8,nn,iproc)=gacont_hbr(3,j,ii)
8305 zapas(9,nn,iproc)=gacontm_hb1(1,j,ii)
8306 zapas(10,nn,iproc)=gacontm_hb1(2,j,ii)
8307 zapas(11,nn,iproc)=gacontm_hb1(3,j,ii)
8308 zapas(12,nn,iproc)=gacontp_hb1(1,j,ii)
8309 zapas(13,nn,iproc)=gacontp_hb1(2,j,ii)
8310 zapas(14,nn,iproc)=gacontp_hb1(3,j,ii)
8311 zapas(15,nn,iproc)=gacontm_hb2(1,j,ii)
8312 zapas(16,nn,iproc)=gacontm_hb2(2,j,ii)
8313 zapas(17,nn,iproc)=gacontm_hb2(3,j,ii)
8314 zapas(18,nn,iproc)=gacontp_hb2(1,j,ii)
8315 zapas(19,nn,iproc)=gacontp_hb2(2,j,ii)
8316 zapas(20,nn,iproc)=gacontp_hb2(3,j,ii)
8317 zapas(21,nn,iproc)=gacontm_hb3(1,j,ii)
8318 zapas(22,nn,iproc)=gacontm_hb3(2,j,ii)
8319 zapas(23,nn,iproc)=gacontm_hb3(3,j,ii)
8320 zapas(24,nn,iproc)=gacontp_hb3(1,j,ii)
8321 zapas(25,nn,iproc)=gacontp_hb3(2,j,ii)
8322 zapas(26,nn,iproc)=gacontp_hb3(3,j,ii)
8330 c------------------------------------------------------------------------------
8331 subroutine multibody_eello(ecorr,ecorr5,ecorr6,eturn6,n_corr,
8333 C This subroutine calculates multi-body contributions to hydrogen-bonding
8334 implicit real*8 (a-h,o-z)
8335 include 'DIMENSIONS'
8336 include 'COMMON.IOUNITS'
8339 parameter (max_cont=maxconts)
8340 parameter (max_dim=70)
8341 integer source,CorrelType,CorrelID,CorrelType1,CorrelID1,Error
8342 double precision zapas(max_dim,maxconts,max_fg_procs),
8343 & zapas_recv(max_dim,maxconts,max_fg_procs)
8344 common /przechowalnia/ zapas
8345 integer status(MPI_STATUS_SIZE),req(maxconts*2),
8346 & status_array(MPI_STATUS_SIZE,maxconts*2)
8348 include 'COMMON.SETUP'
8349 include 'COMMON.FFIELD'
8350 include 'COMMON.DERIV'
8351 include 'COMMON.LOCAL'
8352 include 'COMMON.INTERACT'
8353 include 'COMMON.CONTACTS'
8354 include 'COMMON.CHAIN'
8355 include 'COMMON.CONTROL'
8356 include 'COMMON.SHIELD'
8357 double precision gx(3),gx1(3)
8358 integer num_cont_hb_old(maxres)
8360 double precision eello4,eello5,eelo6,eello_turn6
8361 external eello4,eello5,eello6,eello_turn6
8362 C Set lprn=.true. for debugging
8367 num_cont_hb_old(i)=num_cont_hb(i)
8371 if (nfgtasks.le.1) goto 30
8373 write (iout,'(a)') 'Contact function values before RECEIVE:'
8375 write (iout,'(2i3,50(1x,i2,f5.2))')
8376 & i,num_cont_hb(i),(jcont_hb(j,i),facont_hb(j,i),
8377 & j=1,num_cont_hb(i))
8380 do i=1,ntask_cont_from
8383 do i=1,ntask_cont_to
8386 c write (iout,*) "ntask_cont_from",ntask_cont_from," ntask_cont_to",
8388 C Make the list of contacts to send to send to other procesors
8389 do i=iturn3_start,iturn3_end
8390 c write (iout,*) "make contact list turn3",i," num_cont",
8392 call add_hb_contact_eello(i,i+2,iturn3_sent_local(1,i))
8394 do i=iturn4_start,iturn4_end
8395 c write (iout,*) "make contact list turn4",i," num_cont",
8397 call add_hb_contact_eello(i,i+3,iturn4_sent_local(1,i))
8401 c write (iout,*) "make contact list longrange",i,ii," num_cont",
8403 do j=1,num_cont_hb(i)
8406 iproc=iint_sent_local(k,jjc,ii)
8407 c write (iout,*) "i",i," j",j," k",k," jjc",jjc," iproc",iproc
8408 if (iproc.ne.0) then
8409 ncont_sent(iproc)=ncont_sent(iproc)+1
8410 nn=ncont_sent(iproc)
8412 zapas(2,nn,iproc)=jjc
8413 zapas(3,nn,iproc)=d_cont(j,i)
8417 zapas(ind,nn,iproc)=grij_hb_cont(kk,j,i)
8422 zapas(ind,nn,iproc)=a_chuj(ll,kk,j,i)
8430 zapas(ind,nn,iproc)=a_chuj_der(mm,ll,kk,jj,j,i)
8441 & "Numbers of contacts to be sent to other processors",
8442 & (ncont_sent(i),i=1,ntask_cont_to)
8443 write (iout,*) "Contacts sent"
8444 do ii=1,ntask_cont_to
8446 iproc=itask_cont_to(ii)
8447 write (iout,*) nn," contacts to processor",iproc,
8448 & " of CONT_TO_COMM group"
8450 write(iout,'(2f5.0,10f10.5)')(zapas(j,i,ii),j=1,10)
8458 CorrelID1=nfgtasks+fg_rank+1
8460 C Receive the numbers of needed contacts from other processors
8461 do ii=1,ntask_cont_from
8462 iproc=itask_cont_from(ii)
8464 call MPI_Irecv(ncont_recv(ii),1,MPI_INTEGER,iproc,CorrelType,
8465 & FG_COMM,req(ireq),IERR)
8467 c write (iout,*) "IRECV ended"
8469 C Send the number of contacts needed by other processors
8470 do ii=1,ntask_cont_to
8471 iproc=itask_cont_to(ii)
8473 call MPI_Isend(ncont_sent(ii),1,MPI_INTEGER,iproc,CorrelType,
8474 & FG_COMM,req(ireq),IERR)
8476 c write (iout,*) "ISEND ended"
8477 c write (iout,*) "number of requests (nn)",ireq
8480 & call MPI_Waitall(ireq,req,status_array,ierr)
8482 c & "Numbers of contacts to be received from other processors",
8483 c & (ncont_recv(i),i=1,ntask_cont_from)
8487 do ii=1,ntask_cont_from
8488 iproc=itask_cont_from(ii)
8490 c write (iout,*) "Receiving",nn," contacts from processor",iproc,
8491 c & " of CONT_TO_COMM group"
8495 call MPI_Irecv(zapas_recv(1,1,ii),nn*max_dim,
8496 & MPI_DOUBLE_PRECISION,iproc,CorrelType1,FG_COMM,req(ireq),IERR)
8497 c write (iout,*) "ireq,req",ireq,req(ireq)
8500 C Send the contacts to processors that need them
8501 do ii=1,ntask_cont_to
8502 iproc=itask_cont_to(ii)
8504 c write (iout,*) nn," contacts to processor",iproc,
8505 c & " of CONT_TO_COMM group"
8508 call MPI_Isend(zapas(1,1,ii),nn*max_dim,MPI_DOUBLE_PRECISION,
8509 & iproc,CorrelType1,FG_COMM,req(ireq),IERR)
8510 c write (iout,*) "ireq,req",ireq,req(ireq)
8512 c write(iout,'(2f5.0,4f10.5)')(zapas(j,i,ii),j=1,5)
8516 c write (iout,*) "number of requests (contacts)",ireq
8517 c write (iout,*) "req",(req(i),i=1,4)
8520 & call MPI_Waitall(ireq,req,status_array,ierr)
8521 do iii=1,ntask_cont_from
8522 iproc=itask_cont_from(iii)
8525 write (iout,*) "Received",nn," contacts from processor",iproc,
8526 & " of CONT_FROM_COMM group"
8529 write(iout,'(2f5.0,10f10.5)')(zapas_recv(j,i,iii),j=1,10)
8534 ii=zapas_recv(1,i,iii)
8535 c Flag the received contacts to prevent double-counting
8536 jj=-zapas_recv(2,i,iii)
8537 c write (iout,*) "iii",iii," i",i," ii",ii," jj",jj
8539 nnn=num_cont_hb(ii)+1
8542 d_cont(nnn,ii)=zapas_recv(3,i,iii)
8546 grij_hb_cont(kk,nnn,ii)=zapas_recv(ind,i,iii)
8551 a_chuj(ll,kk,nnn,ii)=zapas_recv(ind,i,iii)
8559 a_chuj_der(mm,ll,kk,jj,nnn,ii)=zapas_recv(ind,i,iii)
8567 write (iout,'(a)') 'Contact function values after receive:'
8569 write (iout,'(2i3,50(1x,i3,5f6.3))')
8570 & i,num_cont_hb(i),(jcont_hb(j,i),d_cont(j,i),
8571 & ((a_chuj(ll,kk,j,i),ll=1,2),kk=1,2),j=1,num_cont_hb(i))
8578 write (iout,'(a)') 'Contact function values:'
8580 write (iout,'(2i3,50(1x,i2,5f6.3))')
8581 & i,num_cont_hb(i),(jcont_hb(j,i),d_cont(j,i),
8582 & ((a_chuj(ll,kk,j,i),ll=1,2),kk=1,2),j=1,num_cont_hb(i))
8588 C Remove the loop below after debugging !!!
8595 C Calculate the dipole-dipole interaction energies
8596 if (wcorr6.gt.0.0d0 .or. wturn6.gt.0.0d0) then
8597 do i=iatel_s,iatel_e+1
8598 num_conti=num_cont_hb(i)
8607 C Calculate the local-electrostatic correlation terms
8608 c write (iout,*) "gradcorr5 in eello5 before loop"
8610 c write (iout,'(i5,3f10.5)')
8611 c & iii,(gradcorr5(jjj,iii),jjj=1,3)
8613 do i=min0(iatel_s,iturn4_start),max0(iatel_e+1,iturn3_end+1)
8614 c write (iout,*) "corr loop i",i
8616 num_conti=num_cont_hb(i)
8617 num_conti1=num_cont_hb(i+1)
8624 c write (iout,*) 'i=',i,' j=',j,' i1=',i1,' j1=',j1,
8625 c & ' jj=',jj,' kk=',kk
8626 c if (j1.eq.j+1 .or. j1.eq.j-1) then
8627 if ((j.gt.0 .and. j1.gt.0 .or. j.gt.0 .and. j1.lt.0
8628 & .or. j.lt.0 .and. j1.gt.0) .and.
8629 & (jp1.eq.jp+1 .or. jp1.eq.jp-1)) then
8630 C Contacts I-J and (I+1)-(J+1) or (I+1)-(J-1) occur simultaneously.
8631 C The system gains extra energy.
8633 sqd1=dsqrt(d_cont(jj,i))
8634 sqd2=dsqrt(d_cont(kk,i1))
8635 sred_geom = sqd1*sqd2
8636 IF (sred_geom.lt.cutoff_corr) THEN
8637 call gcont(sred_geom,r0_corr,1.0D0,delt_corr,
8639 cd write (iout,*) 'i=',i,' j=',jp,' i1=',i1,' j1=',jp1,
8640 cd & ' jj=',jj,' kk=',kk
8641 fac_prim1=0.5d0*sqd2/sqd1*fprimcont
8642 fac_prim2=0.5d0*sqd1/sqd2*fprimcont
8644 g_contij(l,1)=fac_prim1*grij_hb_cont(l,jj,i)
8645 g_contij(l,2)=fac_prim2*grij_hb_cont(l,kk,i1)
8648 cd write (iout,*) 'sred_geom=',sred_geom,
8649 cd & ' ekont=',ekont,' fprim=',fprimcont,
8650 cd & ' fac_prim1',fac_prim1,' fac_prim2',fac_prim2
8651 cd write (iout,*) "g_contij",g_contij
8652 cd write (iout,*) "grij_hb_cont i",grij_hb_cont(:,jj,i)
8653 cd write (iout,*) "grij_hb_cont i1",grij_hb_cont(:,jj,i1)
8654 call calc_eello(i,jp,i+1,jp1,jj,kk)
8655 if (wcorr4.gt.0.0d0)
8656 & ecorr=ecorr+eello4(i,jp,i+1,jp1,jj,kk)
8657 CC & *fac_shield(i)**2*fac_shield(j)**2
8658 if (energy_dec.and.wcorr4.gt.0.0d0)
8659 1 write (iout,'(a6,4i5,0pf7.3)')
8660 2 'ecorr4',i,j,i+1,j1,eello4(i,jp,i+1,jp1,jj,kk)
8661 c write (iout,*) "gradcorr5 before eello5"
8663 c write (iout,'(i5,3f10.5)')
8664 c & iii,(gradcorr5(jjj,iii),jjj=1,3)
8666 if (wcorr5.gt.0.0d0)
8667 & ecorr5=ecorr5+eello5(i,jp,i+1,jp1,jj,kk)
8668 c write (iout,*) "gradcorr5 after eello5"
8670 c write (iout,'(i5,3f10.5)')
8671 c & iii,(gradcorr5(jjj,iii),jjj=1,3)
8673 if (energy_dec.and.wcorr5.gt.0.0d0)
8674 1 write (iout,'(a6,4i5,0pf7.3)')
8675 2 'ecorr5',i,j,i+1,j1,eello5(i,jp,i+1,jp1,jj,kk)
8676 cd write(2,*)'wcorr6',wcorr6,' wturn6',wturn6
8677 cd write(2,*)'ijkl',i,jp,i+1,jp1
8678 if (wcorr6.gt.0.0d0 .and. (jp.ne.i+4 .or. jp1.ne.i+3
8679 & .or. wturn6.eq.0.0d0))then
8680 cd write (iout,*) '******ecorr6: i,j,i+1,j1',i,j,i+1,j1
8681 ecorr6=ecorr6+eello6(i,jp,i+1,jp1,jj,kk)
8682 if (energy_dec) write (iout,'(a6,4i5,0pf7.3)')
8683 1 'ecorr6',i,j,i+1,j1,eello6(i,jp,i+1,jp1,jj,kk)
8684 cd write (iout,*) 'ecorr',ecorr,' ecorr5=',ecorr5,
8685 cd & 'ecorr6=',ecorr6
8686 cd write (iout,'(4e15.5)') sred_geom,
8687 cd & dabs(eello4(i,jp,i+1,jp1,jj,kk)),
8688 cd & dabs(eello5(i,jp,i+1,jp1,jj,kk)),
8689 cd & dabs(eello6(i,jp,i+1,jp1,jj,kk))
8690 else if (wturn6.gt.0.0d0
8691 & .and. (jp.eq.i+4 .and. jp1.eq.i+3)) then
8692 cd write (iout,*) '******eturn6: i,j,i+1,j1',i,jip,i+1,jp1
8693 eturn6=eturn6+eello_turn6(i,jj,kk)
8694 if (energy_dec) write (iout,'(a6,4i5,0pf7.3)')
8695 1 'eturn6',i,j,i+1,j1,eello_turn6(i,jj,kk)
8696 cd write (2,*) 'multibody_eello:eturn6',eturn6
8705 num_cont_hb(i)=num_cont_hb_old(i)
8707 c write (iout,*) "gradcorr5 in eello5"
8709 c write (iout,'(i5,3f10.5)')
8710 c & iii,(gradcorr5(jjj,iii),jjj=1,3)
8714 c------------------------------------------------------------------------------
8715 subroutine add_hb_contact_eello(ii,jj,itask)
8716 implicit real*8 (a-h,o-z)
8717 include "DIMENSIONS"
8718 include "COMMON.IOUNITS"
8721 parameter (max_cont=maxconts)
8722 parameter (max_dim=70)
8723 include "COMMON.CONTACTS"
8724 double precision zapas(max_dim,maxconts,max_fg_procs),
8725 & zapas_recv(max_dim,maxconts,max_fg_procs)
8726 common /przechowalnia/ zapas
8727 integer i,j,ii,jj,iproc,itask(4),nn
8728 c write (iout,*) "itask",itask
8731 if (iproc.gt.0) then
8732 do j=1,num_cont_hb(ii)
8734 c write (iout,*) "send turns i",ii," j",jj," jjc",jjc
8736 ncont_sent(iproc)=ncont_sent(iproc)+1
8737 nn=ncont_sent(iproc)
8738 zapas(1,nn,iproc)=ii
8739 zapas(2,nn,iproc)=jjc
8740 zapas(3,nn,iproc)=d_cont(j,ii)
8744 zapas(ind,nn,iproc)=grij_hb_cont(kk,j,ii)
8749 zapas(ind,nn,iproc)=a_chuj(ll,kk,j,ii)
8757 zapas(ind,nn,iproc)=a_chuj_der(mm,ll,kk,jj,j,ii)
8769 c------------------------------------------------------------------------------
8770 double precision function ehbcorr(i,j,k,l,jj,kk,coeffp,coeffm)
8771 implicit real*8 (a-h,o-z)
8772 include 'DIMENSIONS'
8773 include 'COMMON.IOUNITS'
8774 include 'COMMON.DERIV'
8775 include 'COMMON.INTERACT'
8776 include 'COMMON.CONTACTS'
8777 include 'COMMON.SHIELD'
8778 include 'COMMON.CONTROL'
8779 double precision gx(3),gx1(3)
8782 C print *,"wchodze",fac_shield(i),shield_mode
8790 ees=-(coeffp*ees0pij*ees0pkl+coeffm*ees0mij*ees0mkl)
8792 C & fac_shield(i)**2*fac_shield(j)**2
8793 cd ees=-(coeffp*ees0pkl+coeffm*ees0mkl)
8794 C Following 4 lines for diagnostics.
8799 c write (iout,'(2(a,2i3,a,f10.5,a,2f10.5),a,f10.5,a,$)')
8800 c & 'Contacts ',i,j,
8801 c & ' eij',eij,' eesij',ees0pij,ees0mij,' and ',k,l
8802 c & ,' fcont ',ekl,' eeskl',ees0pkl,ees0mkl,' energy=',ekont*ees,
8804 C Calculate the multi-body contribution to energy.
8805 C ecorr=ecorr+ekont*ees
8806 C Calculate multi-body contributions to the gradient.
8807 coeffpees0pij=coeffp*ees0pij
8808 coeffmees0mij=coeffm*ees0mij
8809 coeffpees0pkl=coeffp*ees0pkl
8810 coeffmees0mkl=coeffm*ees0mkl
8812 cgrad ghalfi=ees*ekl*gacont_hbr(ll,jj,i)
8813 gradcorr(ll,i)=gradcorr(ll,i)!+0.5d0*ghalfi
8814 & -ekont*(coeffpees0pkl*gacontp_hb1(ll,jj,i)+
8815 & coeffmees0mkl*gacontm_hb1(ll,jj,i))
8816 gradcorr(ll,j)=gradcorr(ll,j)!+0.5d0*ghalfi
8817 & -ekont*(coeffpees0pkl*gacontp_hb2(ll,jj,i)+
8818 & coeffmees0mkl*gacontm_hb2(ll,jj,i))
8819 cgrad ghalfk=ees*eij*gacont_hbr(ll,kk,k)
8820 gradcorr(ll,k)=gradcorr(ll,k)!+0.5d0*ghalfk
8821 & -ekont*(coeffpees0pij*gacontp_hb1(ll,kk,k)+
8822 & coeffmees0mij*gacontm_hb1(ll,kk,k))
8823 gradcorr(ll,l)=gradcorr(ll,l)!+0.5d0*ghalfk
8824 & -ekont*(coeffpees0pij*gacontp_hb2(ll,kk,k)+
8825 & coeffmees0mij*gacontm_hb2(ll,kk,k))
8826 gradlongij=ees*ekl*gacont_hbr(ll,jj,i)-
8827 & ekont*(coeffpees0pkl*gacontp_hb3(ll,jj,i)+
8828 & coeffmees0mkl*gacontm_hb3(ll,jj,i))
8829 gradcorr_long(ll,j)=gradcorr_long(ll,j)+gradlongij
8830 gradcorr_long(ll,i)=gradcorr_long(ll,i)-gradlongij
8831 gradlongkl=ees*eij*gacont_hbr(ll,kk,k)-
8832 & ekont*(coeffpees0pij*gacontp_hb3(ll,kk,k)+
8833 & coeffmees0mij*gacontm_hb3(ll,kk,k))
8834 gradcorr_long(ll,l)=gradcorr_long(ll,l)+gradlongkl
8835 gradcorr_long(ll,k)=gradcorr_long(ll,k)-gradlongkl
8836 c write (iout,'(2f10.5,2x,$)') gradlongij,gradlongkl
8841 cgrad gradcorr(ll,m)=gradcorr(ll,m)+
8842 cgrad & ees*ekl*gacont_hbr(ll,jj,i)-
8843 cgrad & ekont*(coeffp*ees0pkl*gacontp_hb3(ll,jj,i)+
8844 cgrad & coeffm*ees0mkl*gacontm_hb3(ll,jj,i))
8849 cgrad gradcorr(ll,m)=gradcorr(ll,m)+
8850 cgrad & ees*eij*gacont_hbr(ll,kk,k)-
8851 cgrad & ekont*(coeffp*ees0pij*gacontp_hb3(ll,kk,k)+
8852 cgrad & coeffm*ees0mij*gacontm_hb3(ll,kk,k))
8855 c write (iout,*) "ehbcorr",ekont*ees
8856 C print *,ekont,ees,i,k
8858 C now gradient over shielding
8860 if (shield_mode.gt.0) then
8863 C print *,i,j,fac_shield(i),fac_shield(j),
8864 C &fac_shield(k),fac_shield(l)
8865 if ((fac_shield(i).gt.0).and.(fac_shield(j).gt.0).and.
8866 & (fac_shield(k).gt.0).and.(fac_shield(l).gt.0)) then
8867 do ilist=1,ishield_list(i)
8868 iresshield=shield_list(ilist,i)
8870 rlocshield=grad_shield_side(m,ilist,i)*ehbcorr/fac_shield(i)
8872 gshieldx_ec(m,iresshield)=gshieldx_ec(m,iresshield)+
8874 & +grad_shield_loc(m,ilist,i)*ehbcorr/fac_shield(i)
8875 gshieldc_ec(m,iresshield-1)=gshieldc_ec(m,iresshield-1)
8879 do ilist=1,ishield_list(j)
8880 iresshield=shield_list(ilist,j)
8882 rlocshield=grad_shield_side(m,ilist,j)*ehbcorr/fac_shield(j)
8884 gshieldx_ec(m,iresshield)=gshieldx_ec(m,iresshield)+
8886 & +grad_shield_loc(m,ilist,j)*ehbcorr/fac_shield(j)
8887 gshieldc_ec(m,iresshield-1)=gshieldc_ec(m,iresshield-1)
8892 do ilist=1,ishield_list(k)
8893 iresshield=shield_list(ilist,k)
8895 rlocshield=grad_shield_side(m,ilist,k)*ehbcorr/fac_shield(k)
8897 gshieldx_ec(m,iresshield)=gshieldx_ec(m,iresshield)+
8899 & +grad_shield_loc(m,ilist,k)*ehbcorr/fac_shield(k)
8900 gshieldc_ec(m,iresshield-1)=gshieldc_ec(m,iresshield-1)
8904 do ilist=1,ishield_list(l)
8905 iresshield=shield_list(ilist,l)
8907 rlocshield=grad_shield_side(m,ilist,l)*ehbcorr/fac_shield(l)
8909 gshieldx_ec(m,iresshield)=gshieldx_ec(m,iresshield)+
8911 & +grad_shield_loc(m,ilist,l)*ehbcorr/fac_shield(l)
8912 gshieldc_ec(m,iresshield-1)=gshieldc_ec(m,iresshield-1)
8916 C print *,gshieldx(m,iresshield)
8918 gshieldc_ec(m,i)=gshieldc_ec(m,i)+
8919 & grad_shield(m,i)*ehbcorr/fac_shield(i)
8920 gshieldc_ec(m,j)=gshieldc_ec(m,j)+
8921 & grad_shield(m,j)*ehbcorr/fac_shield(j)
8922 gshieldc_ec(m,i-1)=gshieldc_ec(m,i-1)+
8923 & grad_shield(m,i)*ehbcorr/fac_shield(i)
8924 gshieldc_ec(m,j-1)=gshieldc_ec(m,j-1)+
8925 & grad_shield(m,j)*ehbcorr/fac_shield(j)
8927 gshieldc_ec(m,k)=gshieldc_ec(m,k)+
8928 & grad_shield(m,k)*ehbcorr/fac_shield(k)
8929 gshieldc_ec(m,l)=gshieldc_ec(m,l)+
8930 & grad_shield(m,l)*ehbcorr/fac_shield(l)
8931 gshieldc_ec(m,k-1)=gshieldc_ec(m,k-1)+
8932 & grad_shield(m,k)*ehbcorr/fac_shield(k)
8933 gshieldc_ec(m,l-1)=gshieldc_ec(m,l-1)+
8934 & grad_shield(m,l)*ehbcorr/fac_shield(l)
8942 C---------------------------------------------------------------------------
8943 subroutine dipole(i,j,jj)
8944 implicit real*8 (a-h,o-z)
8945 include 'DIMENSIONS'
8946 include 'COMMON.IOUNITS'
8947 include 'COMMON.CHAIN'
8948 include 'COMMON.FFIELD'
8949 include 'COMMON.DERIV'
8950 include 'COMMON.INTERACT'
8951 include 'COMMON.CONTACTS'
8952 include 'COMMON.TORSION'
8953 include 'COMMON.VAR'
8954 include 'COMMON.GEO'
8955 dimension dipi(2,2),dipj(2,2),dipderi(2),dipderj(2),auxvec(2),
8957 iti1 = itortyp(itype(i+1))
8958 if (j.lt.nres-1) then
8959 itj1 = itype2loc(itype(j+1))
8964 dipi(iii,1)=Ub2(iii,i)
8965 dipderi(iii)=Ub2der(iii,i)
8966 dipi(iii,2)=b1(iii,i+1)
8967 dipj(iii,1)=Ub2(iii,j)
8968 dipderj(iii)=Ub2der(iii,j)
8969 dipj(iii,2)=b1(iii,j+1)
8973 call matvec2(a_chuj(1,1,jj,i),dipj(1,iii),auxvec(1))
8976 dip(kkk,jj,i)=scalar2(dipi(1,jjj),auxvec(1))
8983 call matvec2(a_chuj_der(1,1,lll,kkk,jj,i),dipj(1,iii),
8987 dipderx(lll,kkk,mmm,jj,i)=scalar2(dipi(1,jjj),auxvec(1))
8992 call transpose2(a_chuj(1,1,jj,i),auxmat(1,1))
8993 call matvec2(auxmat(1,1),dipderi(1),auxvec(1))
8995 dipderg(iii,jj,i)=scalar2(auxvec(1),dipj(1,iii))
8997 call matvec2(a_chuj(1,1,jj,i),dipderj(1),auxvec(1))
8999 dipderg(iii+2,jj,i)=scalar2(auxvec(1),dipi(1,iii))
9004 C---------------------------------------------------------------------------
9005 subroutine calc_eello(i,j,k,l,jj,kk)
9007 C This subroutine computes matrices and vectors needed to calculate
9008 C the fourth-, fifth-, and sixth-order local-electrostatic terms.
9010 implicit real*8 (a-h,o-z)
9011 include 'DIMENSIONS'
9012 include 'COMMON.IOUNITS'
9013 include 'COMMON.CHAIN'
9014 include 'COMMON.DERIV'
9015 include 'COMMON.INTERACT'
9016 include 'COMMON.CONTACTS'
9017 include 'COMMON.TORSION'
9018 include 'COMMON.VAR'
9019 include 'COMMON.GEO'
9020 include 'COMMON.FFIELD'
9021 double precision aa1(2,2),aa2(2,2),aa1t(2,2),aa2t(2,2),
9022 & aa1tder(2,2,3,5),aa2tder(2,2,3,5),auxmat(2,2)
9025 cd write (iout,*) 'calc_eello: i=',i,' j=',j,' k=',k,' l=',l,
9026 cd & ' jj=',jj,' kk=',kk
9027 cd if (i.ne.2 .or. j.ne.4 .or. k.ne.3 .or. l.ne.5) return
9028 cd write (iout,*) "a_chujij",((a_chuj(iii,jjj,jj,i),iii=1,2),jjj=1,2)
9029 cd write (iout,*) "a_chujkl",((a_chuj(iii,jjj,kk,k),iii=1,2),jjj=1,2)
9032 aa1(iii,jjj)=a_chuj(iii,jjj,jj,i)
9033 aa2(iii,jjj)=a_chuj(iii,jjj,kk,k)
9036 call transpose2(aa1(1,1),aa1t(1,1))
9037 call transpose2(aa2(1,1),aa2t(1,1))
9040 call transpose2(a_chuj_der(1,1,lll,kkk,jj,i),
9041 & aa1tder(1,1,lll,kkk))
9042 call transpose2(a_chuj_der(1,1,lll,kkk,kk,k),
9043 & aa2tder(1,1,lll,kkk))
9047 C parallel orientation of the two CA-CA-CA frames.
9049 iti=itype2loc(itype(i))
9053 itk1=itype2loc(itype(k+1))
9054 itj=itype2loc(itype(j))
9055 if (l.lt.nres-1) then
9056 itl1=itype2loc(itype(l+1))
9060 C A1 kernel(j+1) A2T
9062 cd write (iout,'(3f10.5,5x,3f10.5)')
9063 cd & (EUg(iii,jjj,k),jjj=1,2),(EUg(iii,jjj,l),jjj=1,2)
9065 call kernel(aa1(1,1),aa2t(1,1),a_chuj_der(1,1,1,1,jj,i),
9066 & aa2tder(1,1,1,1),1,.false.,EUg(1,1,l),EUgder(1,1,l),
9067 & AEA(1,1,1),AEAderg(1,1,1),AEAderx(1,1,1,1,1,1))
9068 C Following matrices are needed only for 6-th order cumulants
9069 IF (wcorr6.gt.0.0d0) THEN
9070 call kernel(aa1(1,1),aa2t(1,1),a_chuj_der(1,1,1,1,jj,i),
9071 & aa2tder(1,1,1,1),1,.false.,EUgC(1,1,l),EUgCder(1,1,l),
9072 & AECA(1,1,1),AECAderg(1,1,1),AECAderx(1,1,1,1,1,1))
9073 call kernel(aa1(1,1),aa2t(1,1),a_chuj_der(1,1,1,1,jj,i),
9074 & aa2tder(1,1,1,1),2,.false.,Ug2DtEUg(1,1,l),
9075 & Ug2DtEUgder(1,1,1,l),ADtEA(1,1,1),ADtEAderg(1,1,1,1),
9076 & ADtEAderx(1,1,1,1,1,1))
9078 call kernel(aa1(1,1),aa2t(1,1),a_chuj_der(1,1,1,1,jj,i),
9079 & aa2tder(1,1,1,1),2,.false.,DtUg2EUg(1,1,l),
9080 & DtUg2EUgder(1,1,1,l),ADtEA1(1,1,1),ADtEA1derg(1,1,1,1),
9081 & ADtEA1derx(1,1,1,1,1,1))
9083 C End 6-th order cumulants
9086 cd write (2,*) 'In calc_eello6'
9088 cd write (2,*) 'iii=',iii
9090 cd write (2,*) 'kkk=',kkk
9092 cd write (2,'(3(2f10.5),5x)')
9093 cd & ((ADtEA1derx(jjj,mmm,lll,kkk,iii,1),mmm=1,2),lll=1,3)
9098 call transpose2(EUgder(1,1,k),auxmat(1,1))
9099 call matmat2(auxmat(1,1),AEA(1,1,1),EAEAderg(1,1,1,1))
9100 call transpose2(EUg(1,1,k),auxmat(1,1))
9101 call matmat2(auxmat(1,1),AEA(1,1,1),EAEA(1,1,1))
9102 call matmat2(auxmat(1,1),AEAderg(1,1,1),EAEAderg(1,1,2,1))
9103 C AL 4/16/16: Derivatives of the quantitied related to matrices C, D, and E
9104 c in theta; to be sriten later.
9106 c call transpose2(gtEE(1,1,k),auxmat(1,1))
9107 c call matmat2(auxmat(1,1),AEA(1,1,1),EAEAdert(1,1,1,1))
9108 c call transpose2(EUg(1,1,k),auxmat(1,1))
9109 c call matmat2(auxmat(1,1),AEAdert(1,1,1),EAEAdert(1,1,2,1))
9114 call matmat2(auxmat(1,1),AEAderx(1,1,lll,kkk,iii,1),
9115 & EAEAderx(1,1,lll,kkk,iii,1))
9119 C A1T kernel(i+1) A2
9120 call kernel(aa1t(1,1),aa2(1,1),aa1tder(1,1,1,1),
9121 & a_chuj_der(1,1,1,1,kk,k),1,.false.,EUg(1,1,k),EUgder(1,1,k),
9122 & AEA(1,1,2),AEAderg(1,1,2),AEAderx(1,1,1,1,1,2))
9123 C Following matrices are needed only for 6-th order cumulants
9124 IF (wcorr6.gt.0.0d0) THEN
9125 call kernel(aa1t(1,1),aa2(1,1),aa1tder(1,1,1,1),
9126 & a_chuj_der(1,1,1,1,kk,k),1,.false.,EUgC(1,1,k),EUgCder(1,1,k),
9127 & AECA(1,1,2),AECAderg(1,1,2),AECAderx(1,1,1,1,1,2))
9128 call kernel(aa1t(1,1),aa2(1,1),aa1tder(1,1,1,1),
9129 & a_chuj_der(1,1,1,1,kk,k),2,.false.,Ug2DtEUg(1,1,k),
9130 & Ug2DtEUgder(1,1,1,k),ADtEA(1,1,2),ADtEAderg(1,1,1,2),
9131 & ADtEAderx(1,1,1,1,1,2))
9132 call kernel(aa1t(1,1),aa2(1,1),aa1tder(1,1,1,1),
9133 & a_chuj_der(1,1,1,1,kk,k),2,.false.,DtUg2EUg(1,1,k),
9134 & DtUg2EUgder(1,1,1,k),ADtEA1(1,1,2),ADtEA1derg(1,1,1,2),
9135 & ADtEA1derx(1,1,1,1,1,2))
9137 C End 6-th order cumulants
9138 call transpose2(EUgder(1,1,l),auxmat(1,1))
9139 call matmat2(auxmat(1,1),AEA(1,1,2),EAEAderg(1,1,1,2))
9140 call transpose2(EUg(1,1,l),auxmat(1,1))
9141 call matmat2(auxmat(1,1),AEA(1,1,2),EAEA(1,1,2))
9142 call matmat2(auxmat(1,1),AEAderg(1,1,2),EAEAderg(1,1,2,2))
9146 call matmat2(auxmat(1,1),AEAderx(1,1,lll,kkk,iii,2),
9147 & EAEAderx(1,1,lll,kkk,iii,2))
9152 C Calculate the vectors and their derivatives in virtual-bond dihedral angles.
9153 C They are needed only when the fifth- or the sixth-order cumulants are
9155 IF (wcorr5.gt.0.0d0 .or. wcorr6.gt.0.0d0) THEN
9156 call transpose2(AEA(1,1,1),auxmat(1,1))
9157 call matvec2(auxmat(1,1),b1(1,i),AEAb1(1,1,1))
9158 call matvec2(auxmat(1,1),Ub2(1,i),AEAb2(1,1,1))
9159 call matvec2(auxmat(1,1),Ub2der(1,i),AEAb2derg(1,2,1,1))
9160 call transpose2(AEAderg(1,1,1),auxmat(1,1))
9161 call matvec2(auxmat(1,1),b1(1,i),AEAb1derg(1,1,1))
9162 call matvec2(auxmat(1,1),Ub2(1,i),AEAb2derg(1,1,1,1))
9163 call matvec2(AEA(1,1,1),b1(1,k+1),AEAb1(1,2,1))
9164 call matvec2(AEAderg(1,1,1),b1(1,k+1),AEAb1derg(1,2,1))
9165 call matvec2(AEA(1,1,1),Ub2(1,k+1),AEAb2(1,2,1))
9166 call matvec2(AEAderg(1,1,1),Ub2(1,k+1),AEAb2derg(1,1,2,1))
9167 call matvec2(AEA(1,1,1),Ub2der(1,k+1),AEAb2derg(1,2,2,1))
9168 call transpose2(AEA(1,1,2),auxmat(1,1))
9169 call matvec2(auxmat(1,1),b1(1,j),AEAb1(1,1,2))
9170 call matvec2(auxmat(1,1),Ub2(1,j),AEAb2(1,1,2))
9171 call matvec2(auxmat(1,1),Ub2der(1,j),AEAb2derg(1,2,1,2))
9172 call transpose2(AEAderg(1,1,2),auxmat(1,1))
9173 call matvec2(auxmat(1,1),b1(1,j),AEAb1derg(1,1,2))
9174 call matvec2(auxmat(1,1),Ub2(1,j),AEAb2derg(1,1,1,2))
9175 call matvec2(AEA(1,1,2),b1(1,l+1),AEAb1(1,2,2))
9176 call matvec2(AEAderg(1,1,2),b1(1,l+1),AEAb1derg(1,2,2))
9177 call matvec2(AEA(1,1,2),Ub2(1,l+1),AEAb2(1,2,2))
9178 call matvec2(AEAderg(1,1,2),Ub2(1,l+1),AEAb2derg(1,1,2,2))
9179 call matvec2(AEA(1,1,2),Ub2der(1,l+1),AEAb2derg(1,2,2,2))
9180 C Calculate the Cartesian derivatives of the vectors.
9184 call transpose2(AEAderx(1,1,lll,kkk,iii,1),auxmat(1,1))
9185 call matvec2(auxmat(1,1),b1(1,i),
9186 & AEAb1derx(1,lll,kkk,iii,1,1))
9187 call matvec2(auxmat(1,1),Ub2(1,i),
9188 & AEAb2derx(1,lll,kkk,iii,1,1))
9189 call matvec2(AEAderx(1,1,lll,kkk,iii,1),b1(1,k+1),
9190 & AEAb1derx(1,lll,kkk,iii,2,1))
9191 call matvec2(AEAderx(1,1,lll,kkk,iii,1),Ub2(1,k+1),
9192 & AEAb2derx(1,lll,kkk,iii,2,1))
9193 call transpose2(AEAderx(1,1,lll,kkk,iii,2),auxmat(1,1))
9194 call matvec2(auxmat(1,1),b1(1,j),
9195 & AEAb1derx(1,lll,kkk,iii,1,2))
9196 call matvec2(auxmat(1,1),Ub2(1,j),
9197 & AEAb2derx(1,lll,kkk,iii,1,2))
9198 call matvec2(AEAderx(1,1,lll,kkk,iii,2),b1(1,l+1),
9199 & AEAb1derx(1,lll,kkk,iii,2,2))
9200 call matvec2(AEAderx(1,1,lll,kkk,iii,2),Ub2(1,l+1),
9201 & AEAb2derx(1,lll,kkk,iii,2,2))
9208 C Antiparallel orientation of the two CA-CA-CA frames.
9210 iti=itype2loc(itype(i))
9214 itk1=itype2loc(itype(k+1))
9215 itl=itype2loc(itype(l))
9216 itj=itype2loc(itype(j))
9217 if (j.lt.nres-1) then
9218 itj1=itype2loc(itype(j+1))
9222 C A2 kernel(j-1)T A1T
9223 call kernel(aa1(1,1),aa2t(1,1),a_chuj_der(1,1,1,1,jj,i),
9224 & aa2tder(1,1,1,1),1,.true.,EUg(1,1,j),EUgder(1,1,j),
9225 & AEA(1,1,1),AEAderg(1,1,1),AEAderx(1,1,1,1,1,1))
9226 C Following matrices are needed only for 6-th order cumulants
9227 IF (wcorr6.gt.0.0d0 .or. (wturn6.gt.0.0d0 .and.
9228 & j.eq.i+4 .and. l.eq.i+3)) THEN
9229 call kernel(aa1(1,1),aa2t(1,1),a_chuj_der(1,1,1,1,jj,i),
9230 & aa2tder(1,1,1,1),1,.true.,EUgC(1,1,j),EUgCder(1,1,j),
9231 & AECA(1,1,1),AECAderg(1,1,1),AECAderx(1,1,1,1,1,1))
9232 call kernel(aa2(1,1),aa2t(1,1),a_chuj_der(1,1,1,1,jj,i),
9233 & aa2tder(1,1,1,1),2,.true.,Ug2DtEUg(1,1,j),
9234 & Ug2DtEUgder(1,1,1,j),ADtEA(1,1,1),ADtEAderg(1,1,1,1),
9235 & ADtEAderx(1,1,1,1,1,1))
9236 call kernel(aa1(1,1),aa2t(1,1),a_chuj_der(1,1,1,1,jj,i),
9237 & aa2tder(1,1,1,1),2,.true.,DtUg2EUg(1,1,j),
9238 & DtUg2EUgder(1,1,1,j),ADtEA1(1,1,1),ADtEA1derg(1,1,1,1),
9239 & ADtEA1derx(1,1,1,1,1,1))
9241 C End 6-th order cumulants
9242 call transpose2(EUgder(1,1,k),auxmat(1,1))
9243 call matmat2(auxmat(1,1),AEA(1,1,1),EAEAderg(1,1,1,1))
9244 call transpose2(EUg(1,1,k),auxmat(1,1))
9245 call matmat2(auxmat(1,1),AEA(1,1,1),EAEA(1,1,1))
9246 call matmat2(auxmat(1,1),AEAderg(1,1,1),EAEAderg(1,1,2,1))
9250 call matmat2(auxmat(1,1),AEAderx(1,1,lll,kkk,iii,1),
9251 & EAEAderx(1,1,lll,kkk,iii,1))
9255 C A2T kernel(i+1)T A1
9256 call kernel(aa2t(1,1),aa1(1,1),aa2tder(1,1,1,1),
9257 & a_chuj_der(1,1,1,1,jj,i),1,.true.,EUg(1,1,k),EUgder(1,1,k),
9258 & AEA(1,1,2),AEAderg(1,1,2),AEAderx(1,1,1,1,1,2))
9259 C Following matrices are needed only for 6-th order cumulants
9260 IF (wcorr6.gt.0.0d0 .or. (wturn6.gt.0.0d0 .and.
9261 & j.eq.i+4 .and. l.eq.i+3)) THEN
9262 call kernel(aa2t(1,1),aa1(1,1),aa2tder(1,1,1,1),
9263 & a_chuj_der(1,1,1,1,jj,i),1,.true.,EUgC(1,1,k),EUgCder(1,1,k),
9264 & AECA(1,1,2),AECAderg(1,1,2),AECAderx(1,1,1,1,1,2))
9265 call kernel(aa2t(1,1),aa1(1,1),aa2tder(1,1,1,1),
9266 & a_chuj_der(1,1,1,1,jj,i),2,.true.,Ug2DtEUg(1,1,k),
9267 & Ug2DtEUgder(1,1,1,k),ADtEA(1,1,2),ADtEAderg(1,1,1,2),
9268 & ADtEAderx(1,1,1,1,1,2))
9269 call kernel(aa2t(1,1),aa1(1,1),aa2tder(1,1,1,1),
9270 & a_chuj_der(1,1,1,1,jj,i),2,.true.,DtUg2EUg(1,1,k),
9271 & DtUg2EUgder(1,1,1,k),ADtEA1(1,1,2),ADtEA1derg(1,1,1,2),
9272 & ADtEA1derx(1,1,1,1,1,2))
9274 C End 6-th order cumulants
9275 call transpose2(EUgder(1,1,j),auxmat(1,1))
9276 call matmat2(auxmat(1,1),AEA(1,1,1),EAEAderg(1,1,2,2))
9277 call transpose2(EUg(1,1,j),auxmat(1,1))
9278 call matmat2(auxmat(1,1),AEA(1,1,2),EAEA(1,1,2))
9279 call matmat2(auxmat(1,1),AEAderg(1,1,2),EAEAderg(1,1,2,2))
9283 call matmat2(auxmat(1,1),AEAderx(1,1,lll,kkk,iii,2),
9284 & EAEAderx(1,1,lll,kkk,iii,2))
9289 C Calculate the vectors and their derivatives in virtual-bond dihedral angles.
9290 C They are needed only when the fifth- or the sixth-order cumulants are
9292 IF (wcorr5.gt.0.0d0 .or. wcorr6.gt.0.0d0 .or.
9293 & (wturn6.gt.0.0d0 .and. j.eq.i+4 .and. l.eq.i+3)) THEN
9294 call transpose2(AEA(1,1,1),auxmat(1,1))
9295 call matvec2(auxmat(1,1),b1(1,i),AEAb1(1,1,1))
9296 call matvec2(auxmat(1,1),Ub2(1,i),AEAb2(1,1,1))
9297 call matvec2(auxmat(1,1),Ub2der(1,i),AEAb2derg(1,2,1,1))
9298 call transpose2(AEAderg(1,1,1),auxmat(1,1))
9299 call matvec2(auxmat(1,1),b1(1,i),AEAb1derg(1,1,1))
9300 call matvec2(auxmat(1,1),Ub2(1,i),AEAb2derg(1,1,1,1))
9301 call matvec2(AEA(1,1,1),b1(1,k+1),AEAb1(1,2,1))
9302 call matvec2(AEAderg(1,1,1),b1(1,k+1),AEAb1derg(1,2,1))
9303 call matvec2(AEA(1,1,1),Ub2(1,k+1),AEAb2(1,2,1))
9304 call matvec2(AEAderg(1,1,1),Ub2(1,k+1),AEAb2derg(1,1,2,1))
9305 call matvec2(AEA(1,1,1),Ub2der(1,k+1),AEAb2derg(1,2,2,1))
9306 call transpose2(AEA(1,1,2),auxmat(1,1))
9307 call matvec2(auxmat(1,1),b1(1,j+1),AEAb1(1,1,2))
9308 call matvec2(auxmat(1,1),Ub2(1,l),AEAb2(1,1,2))
9309 call matvec2(auxmat(1,1),Ub2der(1,l),AEAb2derg(1,2,1,2))
9310 call transpose2(AEAderg(1,1,2),auxmat(1,1))
9311 call matvec2(auxmat(1,1),b1(1,l),AEAb1(1,1,2))
9312 call matvec2(auxmat(1,1),Ub2(1,l),AEAb2derg(1,1,1,2))
9313 call matvec2(AEA(1,1,2),b1(1,j+1),AEAb1(1,2,2))
9314 call matvec2(AEAderg(1,1,2),b1(1,j+1),AEAb1derg(1,2,2))
9315 call matvec2(AEA(1,1,2),Ub2(1,j),AEAb2(1,2,2))
9316 call matvec2(AEAderg(1,1,2),Ub2(1,j),AEAb2derg(1,1,2,2))
9317 call matvec2(AEA(1,1,2),Ub2der(1,j),AEAb2derg(1,2,2,2))
9318 C Calculate the Cartesian derivatives of the vectors.
9322 call transpose2(AEAderx(1,1,lll,kkk,iii,1),auxmat(1,1))
9323 call matvec2(auxmat(1,1),b1(1,i),
9324 & AEAb1derx(1,lll,kkk,iii,1,1))
9325 call matvec2(auxmat(1,1),Ub2(1,i),
9326 & AEAb2derx(1,lll,kkk,iii,1,1))
9327 call matvec2(AEAderx(1,1,lll,kkk,iii,1),b1(1,k+1),
9328 & AEAb1derx(1,lll,kkk,iii,2,1))
9329 call matvec2(AEAderx(1,1,lll,kkk,iii,1),Ub2(1,k+1),
9330 & AEAb2derx(1,lll,kkk,iii,2,1))
9331 call transpose2(AEAderx(1,1,lll,kkk,iii,2),auxmat(1,1))
9332 call matvec2(auxmat(1,1),b1(1,l),
9333 & AEAb1derx(1,lll,kkk,iii,1,2))
9334 call matvec2(auxmat(1,1),Ub2(1,l),
9335 & AEAb2derx(1,lll,kkk,iii,1,2))
9336 call matvec2(AEAderx(1,1,lll,kkk,iii,2),b1(1,j+1),
9337 & AEAb1derx(1,lll,kkk,iii,2,2))
9338 call matvec2(AEAderx(1,1,lll,kkk,iii,2),Ub2(1,j),
9339 & AEAb2derx(1,lll,kkk,iii,2,2))
9348 C---------------------------------------------------------------------------
9349 subroutine kernel(aa1,aa2t,aa1derx,aa2tderx,nderg,transp,
9350 & KK,KKderg,AKA,AKAderg,AKAderx)
9354 double precision aa1(2,2),aa2t(2,2),aa1derx(2,2,3,5),
9355 & aa2tderx(2,2,3,5),KK(2,2),KKderg(2,2,nderg),AKA(2,2),
9356 & AKAderg(2,2,nderg),AKAderx(2,2,3,5,2)
9361 call prodmat3(aa1(1,1),aa2t(1,1),KK(1,1),transp,AKA(1,1))
9363 call prodmat3(aa1(1,1),aa2t(1,1),KKderg(1,1,iii),transp,
9366 cd if (lprn) write (2,*) 'In kernel'
9368 cd if (lprn) write (2,*) 'kkk=',kkk
9370 call prodmat3(aa1derx(1,1,lll,kkk),aa2t(1,1),
9371 & KK(1,1),transp,AKAderx(1,1,lll,kkk,1))
9373 cd write (2,*) 'lll=',lll
9374 cd write (2,*) 'iii=1'
9376 cd write (2,'(3(2f10.5),5x)')
9377 cd & (AKAderx(jjj,mmm,lll,kkk,1),mmm=1,2)
9380 call prodmat3(aa1(1,1),aa2tderx(1,1,lll,kkk),
9381 & KK(1,1),transp,AKAderx(1,1,lll,kkk,2))
9383 cd write (2,*) 'lll=',lll
9384 cd write (2,*) 'iii=2'
9386 cd write (2,'(3(2f10.5),5x)')
9387 cd & (AKAderx(jjj,mmm,lll,kkk,2),mmm=1,2)
9394 C---------------------------------------------------------------------------
9395 double precision function eello4(i,j,k,l,jj,kk)
9396 implicit real*8 (a-h,o-z)
9397 include 'DIMENSIONS'
9398 include 'COMMON.IOUNITS'
9399 include 'COMMON.CHAIN'
9400 include 'COMMON.DERIV'
9401 include 'COMMON.INTERACT'
9402 include 'COMMON.CONTACTS'
9403 include 'COMMON.TORSION'
9404 include 'COMMON.VAR'
9405 include 'COMMON.GEO'
9406 double precision pizda(2,2),ggg1(3),ggg2(3)
9407 cd if (i.ne.1 .or. j.ne.5 .or. k.ne.2 .or.l.ne.4) then
9411 cd print *,'eello4:',i,j,k,l,jj,kk
9412 cd write (2,*) 'i',i,' j',j,' k',k,' l',l
9413 cd call checkint4(i,j,k,l,jj,kk,eel4_num)
9414 cold eij=facont_hb(jj,i)
9415 cold ekl=facont_hb(kk,k)
9417 eel4=-EAEA(1,1,1)-EAEA(2,2,1)
9418 cd eel41=-EAEA(1,1,2)-EAEA(2,2,2)
9419 gcorr_loc(k-1)=gcorr_loc(k-1)
9420 & -ekont*(EAEAderg(1,1,1,1)+EAEAderg(2,2,1,1))
9422 gcorr_loc(l-1)=gcorr_loc(l-1)
9423 & -ekont*(EAEAderg(1,1,2,1)+EAEAderg(2,2,2,1))
9424 C Al 4/16/16: Derivatives in theta, to be added later.
9426 c gcorr_loc(nphi+l-1)=gcorr_loc(nphi+l-1)
9427 c & -ekont*(EAEAdert(1,1,2,1)+EAEAdert(2,2,2,1))
9430 gcorr_loc(j-1)=gcorr_loc(j-1)
9431 & -ekont*(EAEAderg(1,1,2,1)+EAEAderg(2,2,2,1))
9433 c gcorr_loc(nphi+j-1)=gcorr_loc(nphi+j-1)
9434 c & -ekont*(EAEAdert(1,1,2,1)+EAEAdert(2,2,2,1))
9440 derx(lll,kkk,iii)=-EAEAderx(1,1,lll,kkk,iii,1)
9441 & -EAEAderx(2,2,lll,kkk,iii,1)
9442 cd derx(lll,kkk,iii)=0.0d0
9446 cd gcorr_loc(l-1)=0.0d0
9447 cd gcorr_loc(j-1)=0.0d0
9448 cd gcorr_loc(k-1)=0.0d0
9450 cd write (iout,*)'Contacts have occurred for peptide groups',
9451 cd & i,j,' fcont:',eij,' eij',' and ',k,l,
9452 cd & ' fcont ',ekl,' eel4=',eel4,' eel4_num',16*eel4_num
9453 if (j.lt.nres-1) then
9460 if (l.lt.nres-1) then
9468 cgrad ggg1(ll)=eel4*g_contij(ll,1)
9469 cgrad ggg2(ll)=eel4*g_contij(ll,2)
9470 glongij=eel4*g_contij(ll,1)+ekont*derx(ll,1,1)
9471 glongkl=eel4*g_contij(ll,2)+ekont*derx(ll,1,2)
9472 cgrad ghalf=0.5d0*ggg1(ll)
9473 gradcorr(ll,i)=gradcorr(ll,i)+ekont*derx(ll,2,1)
9474 gradcorr(ll,i+1)=gradcorr(ll,i+1)+ekont*derx(ll,3,1)
9475 gradcorr(ll,j)=gradcorr(ll,j)+ekont*derx(ll,4,1)
9476 gradcorr(ll,j1)=gradcorr(ll,j1)+ekont*derx(ll,5,1)
9477 gradcorr_long(ll,j)=gradcorr_long(ll,j)+glongij
9478 gradcorr_long(ll,i)=gradcorr_long(ll,i)-glongij
9479 cgrad ghalf=0.5d0*ggg2(ll)
9480 gradcorr(ll,k)=gradcorr(ll,k)+ekont*derx(ll,2,2)
9481 gradcorr(ll,k+1)=gradcorr(ll,k+1)+ekont*derx(ll,3,2)
9482 gradcorr(ll,l)=gradcorr(ll,l)+ekont*derx(ll,4,2)
9483 gradcorr(ll,l1)=gradcorr(ll,l1)+ekont*derx(ll,5,2)
9484 gradcorr_long(ll,l)=gradcorr_long(ll,l)+glongkl
9485 gradcorr_long(ll,k)=gradcorr_long(ll,k)-glongkl
9489 cgrad gradcorr(ll,m)=gradcorr(ll,m)+ggg1(ll)
9494 cgrad gradcorr(ll,m)=gradcorr(ll,m)+ggg2(ll)
9499 cgrad gradcorr(ll,m)=gradcorr(ll,m)+ekont*derx(ll,1,1)
9504 cgrad gradcorr(ll,m)=gradcorr(ll,m)+ekont*derx(ll,1,2)
9508 cd write (2,*) iii,gcorr_loc(iii)
9511 cd write (2,*) 'ekont',ekont
9512 cd write (iout,*) 'eello4',ekont*eel4
9515 C---------------------------------------------------------------------------
9516 double precision function eello5(i,j,k,l,jj,kk)
9517 implicit real*8 (a-h,o-z)
9518 include 'DIMENSIONS'
9519 include 'COMMON.IOUNITS'
9520 include 'COMMON.CHAIN'
9521 include 'COMMON.DERIV'
9522 include 'COMMON.INTERACT'
9523 include 'COMMON.CONTACTS'
9524 include 'COMMON.TORSION'
9525 include 'COMMON.VAR'
9526 include 'COMMON.GEO'
9527 double precision pizda(2,2),auxmat(2,2),auxmat1(2,2),vv(2)
9528 double precision ggg1(3),ggg2(3)
9529 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
9534 C /l\ / \ \ / \ / \ / C
9535 C / \ / \ \ / \ / \ / C
9536 C j| o |l1 | o | o| o | | o |o C
9537 C \ |/k\| |/ \| / |/ \| |/ \| C
9538 C \i/ \ / \ / / \ / \ C
9540 C (I) (II) (III) (IV) C
9542 C eello5_1 eello5_2 eello5_3 eello5_4 C
9544 C Antiparallel chains C
9547 C /j\ / \ \ / \ / \ / C
9548 C / \ / \ \ / \ / \ / C
9549 C j1| o |l | o | o| o | | o |o C
9550 C \ |/k\| |/ \| / |/ \| |/ \| C
9551 C \i/ \ / \ / / \ / \ C
9553 C (I) (II) (III) (IV) C
9555 C eello5_1 eello5_2 eello5_3 eello5_4 C
9557 C o denotes a local interaction, vertical lines an electrostatic interaction. C
9559 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
9560 cd if (i.ne.2 .or. j.ne.6 .or. k.ne.3 .or. l.ne.5) then
9565 cd & 'EELLO5: Contacts have occurred for peptide groups',i,j,
9567 itk=itype2loc(itype(k))
9568 itl=itype2loc(itype(l))
9569 itj=itype2loc(itype(j))
9574 cd call checkint5(i,j,k,l,jj,kk,eel5_1_num,eel5_2_num,
9575 cd & eel5_3_num,eel5_4_num)
9579 derx(lll,kkk,iii)=0.0d0
9583 cd eij=facont_hb(jj,i)
9584 cd ekl=facont_hb(kk,k)
9586 cd write (iout,*)'Contacts have occurred for peptide groups',
9587 cd & i,j,' fcont:',eij,' eij',' and ',k,l
9589 C Contribution from the graph I.
9590 cd write (2,*) 'AEA ',AEA(1,1,1),AEA(2,1,1),AEA(1,2,1),AEA(2,2,1)
9591 cd write (2,*) 'AEAb2',AEAb2(1,1,1),AEAb2(2,1,1)
9592 call transpose2(EUg(1,1,k),auxmat(1,1))
9593 call matmat2(AEA(1,1,1),auxmat(1,1),pizda(1,1))
9594 vv(1)=pizda(1,1)-pizda(2,2)
9595 vv(2)=pizda(1,2)+pizda(2,1)
9596 eello5_1=scalar2(AEAb2(1,1,1),Ub2(1,k))
9597 & +0.5d0*scalar2(vv(1),Dtobr2(1,i))
9598 C Explicit gradient in virtual-dihedral angles.
9599 if (i.gt.1) g_corr5_loc(i-1)=g_corr5_loc(i-1)
9600 & +ekont*(scalar2(AEAb2derg(1,2,1,1),Ub2(1,k))
9601 & +0.5d0*scalar2(vv(1),Dtobr2der(1,i)))
9602 call transpose2(EUgder(1,1,k),auxmat1(1,1))
9603 call matmat2(AEA(1,1,1),auxmat1(1,1),pizda(1,1))
9604 vv(1)=pizda(1,1)-pizda(2,2)
9605 vv(2)=pizda(1,2)+pizda(2,1)
9606 g_corr5_loc(k-1)=g_corr5_loc(k-1)
9607 & +ekont*(scalar2(AEAb2(1,1,1),Ub2der(1,k))
9608 & +0.5d0*scalar2(vv(1),Dtobr2(1,i)))
9609 call matmat2(AEAderg(1,1,1),auxmat(1,1),pizda(1,1))
9610 vv(1)=pizda(1,1)-pizda(2,2)
9611 vv(2)=pizda(1,2)+pizda(2,1)
9613 if (l.lt.nres-1) g_corr5_loc(l-1)=g_corr5_loc(l-1)
9614 & +ekont*(scalar2(AEAb2derg(1,1,1,1),Ub2(1,k))
9615 & +0.5d0*scalar2(vv(1),Dtobr2(1,i)))
9617 if (j.lt.nres-1) g_corr5_loc(j-1)=g_corr5_loc(j-1)
9618 & +ekont*(scalar2(AEAb2derg(1,1,1,1),Ub2(1,k))
9619 & +0.5d0*scalar2(vv(1),Dtobr2(1,i)))
9621 C Cartesian gradient
9625 call matmat2(AEAderx(1,1,lll,kkk,iii,1),auxmat(1,1),
9627 vv(1)=pizda(1,1)-pizda(2,2)
9628 vv(2)=pizda(1,2)+pizda(2,1)
9629 derx(lll,kkk,iii)=derx(lll,kkk,iii)
9630 & +scalar2(AEAb2derx(1,lll,kkk,iii,1,1),Ub2(1,k))
9631 & +0.5d0*scalar2(vv(1),Dtobr2(1,i))
9637 C Contribution from graph II
9638 call transpose2(EE(1,1,k),auxmat(1,1))
9639 call matmat2(auxmat(1,1),AEA(1,1,1),pizda(1,1))
9640 vv(1)=pizda(1,1)+pizda(2,2)
9641 vv(2)=pizda(2,1)-pizda(1,2)
9642 eello5_2=scalar2(AEAb1(1,2,1),b1(1,k))
9643 & -0.5d0*scalar2(vv(1),Ctobr(1,k))
9644 C Explicit gradient in virtual-dihedral angles.
9645 g_corr5_loc(k-1)=g_corr5_loc(k-1)
9646 & -0.5d0*ekont*scalar2(vv(1),Ctobrder(1,k))
9647 call matmat2(auxmat(1,1),AEAderg(1,1,1),pizda(1,1))
9648 vv(1)=pizda(1,1)+pizda(2,2)
9649 vv(2)=pizda(2,1)-pizda(1,2)
9651 g_corr5_loc(l-1)=g_corr5_loc(l-1)
9652 & +ekont*(scalar2(AEAb1derg(1,2,1),b1(1,k))
9653 & -0.5d0*scalar2(vv(1),Ctobr(1,k)))
9655 g_corr5_loc(j-1)=g_corr5_loc(j-1)
9656 & +ekont*(scalar2(AEAb1derg(1,2,1),b1(1,k))
9657 & -0.5d0*scalar2(vv(1),Ctobr(1,k)))
9659 C Cartesian gradient
9663 call matmat2(auxmat(1,1),AEAderx(1,1,lll,kkk,iii,1),
9665 vv(1)=pizda(1,1)+pizda(2,2)
9666 vv(2)=pizda(2,1)-pizda(1,2)
9667 derx(lll,kkk,iii)=derx(lll,kkk,iii)
9668 & +scalar2(AEAb1derx(1,lll,kkk,iii,2,1),b1(1,k))
9669 & -0.5d0*scalar2(vv(1),Ctobr(1,k))
9677 C Parallel orientation
9678 C Contribution from graph III
9679 call transpose2(EUg(1,1,l),auxmat(1,1))
9680 call matmat2(AEA(1,1,2),auxmat(1,1),pizda(1,1))
9681 vv(1)=pizda(1,1)-pizda(2,2)
9682 vv(2)=pizda(1,2)+pizda(2,1)
9683 eello5_3=scalar2(AEAb2(1,1,2),Ub2(1,l))
9684 & +0.5d0*scalar2(vv(1),Dtobr2(1,j))
9685 C Explicit gradient in virtual-dihedral angles.
9686 g_corr5_loc(j-1)=g_corr5_loc(j-1)
9687 & +ekont*(scalar2(AEAb2derg(1,2,1,2),Ub2(1,l))
9688 & +0.5d0*scalar2(vv(1),Dtobr2der(1,j)))
9689 call matmat2(AEAderg(1,1,2),auxmat(1,1),pizda(1,1))
9690 vv(1)=pizda(1,1)-pizda(2,2)
9691 vv(2)=pizda(1,2)+pizda(2,1)
9692 g_corr5_loc(k-1)=g_corr5_loc(k-1)
9693 & +ekont*(scalar2(AEAb2derg(1,1,1,2),Ub2(1,l))
9694 & +0.5d0*scalar2(vv(1),Dtobr2(1,j)))
9695 call transpose2(EUgder(1,1,l),auxmat1(1,1))
9696 call matmat2(AEA(1,1,2),auxmat1(1,1),pizda(1,1))
9697 vv(1)=pizda(1,1)-pizda(2,2)
9698 vv(2)=pizda(1,2)+pizda(2,1)
9699 g_corr5_loc(l-1)=g_corr5_loc(l-1)
9700 & +ekont*(scalar2(AEAb2(1,1,2),Ub2der(1,l))
9701 & +0.5d0*scalar2(vv(1),Dtobr2(1,j)))
9702 C Cartesian gradient
9706 call matmat2(AEAderx(1,1,lll,kkk,iii,2),auxmat(1,1),
9708 vv(1)=pizda(1,1)-pizda(2,2)
9709 vv(2)=pizda(1,2)+pizda(2,1)
9710 derx(lll,kkk,iii)=derx(lll,kkk,iii)
9711 & +scalar2(AEAb2derx(1,lll,kkk,iii,1,2),Ub2(1,l))
9712 & +0.5d0*scalar2(vv(1),Dtobr2(1,j))
9717 C Contribution from graph IV
9719 call transpose2(EE(1,1,l),auxmat(1,1))
9720 call matmat2(auxmat(1,1),AEA(1,1,2),pizda(1,1))
9721 vv(1)=pizda(1,1)+pizda(2,2)
9722 vv(2)=pizda(2,1)-pizda(1,2)
9723 eello5_4=scalar2(AEAb1(1,2,2),b1(1,l))
9724 & -0.5d0*scalar2(vv(1),Ctobr(1,l))
9725 C Explicit gradient in virtual-dihedral angles.
9726 g_corr5_loc(l-1)=g_corr5_loc(l-1)
9727 & -0.5d0*ekont*scalar2(vv(1),Ctobrder(1,l))
9728 call matmat2(auxmat(1,1),AEAderg(1,1,2),pizda(1,1))
9729 vv(1)=pizda(1,1)+pizda(2,2)
9730 vv(2)=pizda(2,1)-pizda(1,2)
9731 g_corr5_loc(k-1)=g_corr5_loc(k-1)
9732 & +ekont*(scalar2(AEAb1derg(1,2,2),b1(1,l))
9733 & -0.5d0*scalar2(vv(1),Ctobr(1,l)))
9734 C Cartesian gradient
9738 call matmat2(auxmat(1,1),AEAderx(1,1,lll,kkk,iii,2),
9740 vv(1)=pizda(1,1)+pizda(2,2)
9741 vv(2)=pizda(2,1)-pizda(1,2)
9742 derx(lll,kkk,iii)=derx(lll,kkk,iii)
9743 & +scalar2(AEAb1derx(1,lll,kkk,iii,2,2),b1(1,l))
9744 & -0.5d0*scalar2(vv(1),Ctobr(1,l))
9749 C Antiparallel orientation
9750 C Contribution from graph III
9752 call transpose2(EUg(1,1,j),auxmat(1,1))
9753 call matmat2(AEA(1,1,2),auxmat(1,1),pizda(1,1))
9754 vv(1)=pizda(1,1)-pizda(2,2)
9755 vv(2)=pizda(1,2)+pizda(2,1)
9756 eello5_3=scalar2(AEAb2(1,1,2),Ub2(1,j))
9757 & +0.5d0*scalar2(vv(1),Dtobr2(1,l))
9758 C Explicit gradient in virtual-dihedral angles.
9759 g_corr5_loc(l-1)=g_corr5_loc(l-1)
9760 & +ekont*(scalar2(AEAb2derg(1,2,1,2),Ub2(1,j))
9761 & +0.5d0*scalar2(vv(1),Dtobr2der(1,l)))
9762 call matmat2(AEAderg(1,1,2),auxmat(1,1),pizda(1,1))
9763 vv(1)=pizda(1,1)-pizda(2,2)
9764 vv(2)=pizda(1,2)+pizda(2,1)
9765 g_corr5_loc(k-1)=g_corr5_loc(k-1)
9766 & +ekont*(scalar2(AEAb2derg(1,1,1,2),Ub2(1,j))
9767 & +0.5d0*scalar2(vv(1),Dtobr2(1,l)))
9768 call transpose2(EUgder(1,1,j),auxmat1(1,1))
9769 call matmat2(AEA(1,1,2),auxmat1(1,1),pizda(1,1))
9770 vv(1)=pizda(1,1)-pizda(2,2)
9771 vv(2)=pizda(1,2)+pizda(2,1)
9772 g_corr5_loc(j-1)=g_corr5_loc(j-1)
9773 & +ekont*(scalar2(AEAb2(1,1,2),Ub2der(1,j))
9774 & +0.5d0*scalar2(vv(1),Dtobr2(1,l)))
9775 C Cartesian gradient
9779 call matmat2(AEAderx(1,1,lll,kkk,iii,2),auxmat(1,1),
9781 vv(1)=pizda(1,1)-pizda(2,2)
9782 vv(2)=pizda(1,2)+pizda(2,1)
9783 derx(lll,kkk,3-iii)=derx(lll,kkk,3-iii)
9784 & +scalar2(AEAb2derx(1,lll,kkk,iii,1,2),Ub2(1,j))
9785 & +0.5d0*scalar2(vv(1),Dtobr2(1,l))
9790 C Contribution from graph IV
9792 call transpose2(EE(1,1,j),auxmat(1,1))
9793 call matmat2(auxmat(1,1),AEA(1,1,2),pizda(1,1))
9794 vv(1)=pizda(1,1)+pizda(2,2)
9795 vv(2)=pizda(2,1)-pizda(1,2)
9796 eello5_4=scalar2(AEAb1(1,2,2),b1(1,j))
9797 & -0.5d0*scalar2(vv(1),Ctobr(1,j))
9798 C Explicit gradient in virtual-dihedral angles.
9799 g_corr5_loc(j-1)=g_corr5_loc(j-1)
9800 & -0.5d0*ekont*scalar2(vv(1),Ctobrder(1,j))
9801 call matmat2(auxmat(1,1),AEAderg(1,1,2),pizda(1,1))
9802 vv(1)=pizda(1,1)+pizda(2,2)
9803 vv(2)=pizda(2,1)-pizda(1,2)
9804 g_corr5_loc(k-1)=g_corr5_loc(k-1)
9805 & +ekont*(scalar2(AEAb1derg(1,2,2),b1(1,j))
9806 & -0.5d0*scalar2(vv(1),Ctobr(1,j)))
9807 C Cartesian gradient
9811 call matmat2(auxmat(1,1),AEAderx(1,1,lll,kkk,iii,2),
9813 vv(1)=pizda(1,1)+pizda(2,2)
9814 vv(2)=pizda(2,1)-pizda(1,2)
9815 derx(lll,kkk,3-iii)=derx(lll,kkk,3-iii)
9816 & +scalar2(AEAb1derx(1,lll,kkk,iii,2,2),b1(1,j))
9817 & -0.5d0*scalar2(vv(1),Ctobr(1,j))
9823 eel5=eello5_1+eello5_2+eello5_3+eello5_4
9824 cd if (i.eq.2 .and. j.eq.8 .and. k.eq.3 .and. l.eq.7) then
9825 cd write (2,*) 'ijkl',i,j,k,l
9826 cd write (2,*) 'eello5_1',eello5_1,' eello5_2',eello5_2,
9827 cd & ' eello5_3',eello5_3,' eello5_4',eello5_4
9829 cd write(iout,*) 'eello5_1',eello5_1,' eel5_1_num',16*eel5_1_num
9830 cd write(iout,*) 'eello5_2',eello5_2,' eel5_2_num',16*eel5_2_num
9831 cd write(iout,*) 'eello5_3',eello5_3,' eel5_3_num',16*eel5_3_num
9832 cd write(iout,*) 'eello5_4',eello5_4,' eel5_4_num',16*eel5_4_num
9833 if (j.lt.nres-1) then
9840 if (l.lt.nres-1) then
9850 cd write (2,*) 'eij',eij,' ekl',ekl,' ekont',ekont
9851 C 2/11/08 AL Gradients over DC's connecting interacting sites will be
9852 C summed up outside the subrouine as for the other subroutines
9853 C handling long-range interactions. The old code is commented out
9854 C with "cgrad" to keep track of changes.
9856 cgrad ggg1(ll)=eel5*g_contij(ll,1)
9857 cgrad ggg2(ll)=eel5*g_contij(ll,2)
9858 gradcorr5ij=eel5*g_contij(ll,1)+ekont*derx(ll,1,1)
9859 gradcorr5kl=eel5*g_contij(ll,2)+ekont*derx(ll,1,2)
9860 c write (iout,'(a,3i3,a,5f8.3,2i3,a,5f8.3,a,f8.3)')
9861 c & "ecorr5",ll,i,j," derx",derx(ll,2,1),derx(ll,3,1),derx(ll,4,1),
9862 c & derx(ll,5,1),k,l," derx",derx(ll,2,2),derx(ll,3,2),
9863 c & derx(ll,4,2),derx(ll,5,2)," ekont",ekont
9864 c write (iout,'(a,3i3,a,3f8.3,2i3,a,3f8.3)')
9865 c & "ecorr5",ll,i,j," gradcorr5",g_contij(ll,1),derx(ll,1,1),
9867 c & k,l," gradcorr5",g_contij(ll,2),derx(ll,1,2),gradcorr5kl
9868 cold ghalf=0.5d0*eel5*ekl*gacont_hbr(ll,jj,i)
9869 cgrad ghalf=0.5d0*ggg1(ll)
9871 gradcorr5(ll,i)=gradcorr5(ll,i)+ekont*derx(ll,2,1)
9872 gradcorr5(ll,i+1)=gradcorr5(ll,i+1)+ekont*derx(ll,3,1)
9873 gradcorr5(ll,j)=gradcorr5(ll,j)+ekont*derx(ll,4,1)
9874 gradcorr5(ll,j1)=gradcorr5(ll,j1)+ekont*derx(ll,5,1)
9875 gradcorr5_long(ll,j)=gradcorr5_long(ll,j)+gradcorr5ij
9876 gradcorr5_long(ll,i)=gradcorr5_long(ll,i)-gradcorr5ij
9877 cold ghalf=0.5d0*eel5*eij*gacont_hbr(ll,kk,k)
9878 cgrad ghalf=0.5d0*ggg2(ll)
9880 gradcorr5(ll,k)=gradcorr5(ll,k)+ekont*derx(ll,2,2)
9881 gradcorr5(ll,k+1)=gradcorr5(ll,k+1)+ekont*derx(ll,3,2)
9882 gradcorr5(ll,l)=gradcorr5(ll,l)+ekont*derx(ll,4,2)
9883 gradcorr5(ll,l1)=gradcorr5(ll,l1)+ekont*derx(ll,5,2)
9884 gradcorr5_long(ll,l)=gradcorr5_long(ll,l)+gradcorr5kl
9885 gradcorr5_long(ll,k)=gradcorr5_long(ll,k)-gradcorr5kl
9890 cold gradcorr5(ll,m)=gradcorr5(ll,m)+eel5*ekl*gacont_hbr(ll,jj,i)
9891 cgrad gradcorr5(ll,m)=gradcorr5(ll,m)+ggg1(ll)
9896 cold gradcorr5(ll,m)=gradcorr5(ll,m)+eel5*eij*gacont_hbr(ll,kk,k)
9897 cgrad gradcorr5(ll,m)=gradcorr5(ll,m)+ggg2(ll)
9903 cgrad gradcorr5(ll,m)=gradcorr5(ll,m)+ekont*derx(ll,1,1)
9908 cgrad gradcorr5(ll,m)=gradcorr5(ll,m)+ekont*derx(ll,1,2)
9912 cd write (2,*) iii,g_corr5_loc(iii)
9915 cd write (2,*) 'ekont',ekont
9916 cd write (iout,*) 'eello5',ekont*eel5
9919 c--------------------------------------------------------------------------
9920 double precision function eello6(i,j,k,l,jj,kk)
9921 implicit real*8 (a-h,o-z)
9922 include 'DIMENSIONS'
9923 include 'COMMON.IOUNITS'
9924 include 'COMMON.CHAIN'
9925 include 'COMMON.DERIV'
9926 include 'COMMON.INTERACT'
9927 include 'COMMON.CONTACTS'
9928 include 'COMMON.TORSION'
9929 include 'COMMON.VAR'
9930 include 'COMMON.GEO'
9931 include 'COMMON.FFIELD'
9932 double precision ggg1(3),ggg2(3)
9933 cd if (i.ne.1 .or. j.ne.3 .or. k.ne.2 .or. l.ne.4) then
9938 cd & 'EELLO6: Contacts have occurred for peptide groups',i,j,
9946 cd call checkint6(i,j,k,l,jj,kk,eel6_1_num,eel6_2_num,
9947 cd & eel6_3_num,eel6_4_num,eel6_5_num,eel6_6_num)
9951 derx(lll,kkk,iii)=0.0d0
9955 cd eij=facont_hb(jj,i)
9956 cd ekl=facont_hb(kk,k)
9962 eello6_1=eello6_graph1(i,j,k,l,1,.false.)
9963 eello6_2=eello6_graph1(j,i,l,k,2,.false.)
9964 eello6_3=eello6_graph2(i,j,k,l,jj,kk,.false.)
9965 eello6_4=eello6_graph4(i,j,k,l,jj,kk,1,.false.)
9966 eello6_5=eello6_graph4(j,i,l,k,jj,kk,2,.false.)
9967 eello6_6=eello6_graph3(i,j,k,l,jj,kk,.false.)
9969 eello6_1=eello6_graph1(i,j,k,l,1,.false.)
9970 eello6_2=eello6_graph1(l,k,j,i,2,.true.)
9971 eello6_3=eello6_graph2(i,l,k,j,jj,kk,.true.)
9972 eello6_4=eello6_graph4(i,j,k,l,jj,kk,1,.false.)
9973 if (wturn6.eq.0.0d0 .or. j.ne.i+4) then
9974 eello6_5=eello6_graph4(l,k,j,i,kk,jj,2,.true.)
9978 eello6_6=eello6_graph3(i,l,k,j,jj,kk,.true.)
9980 C If turn contributions are considered, they will be handled separately.
9981 eel6=eello6_1+eello6_2+eello6_3+eello6_4+eello6_5+eello6_6
9982 cd write(iout,*) 'eello6_1',eello6_1!,' eel6_1_num',16*eel6_1_num
9983 cd write(iout,*) 'eello6_2',eello6_2!,' eel6_2_num',16*eel6_2_num
9984 cd write(iout,*) 'eello6_3',eello6_3!,' eel6_3_num',16*eel6_3_num
9985 cd write(iout,*) 'eello6_4',eello6_4!,' eel6_4_num',16*eel6_4_num
9986 cd write(iout,*) 'eello6_5',eello6_5!,' eel6_5_num',16*eel6_5_num
9987 cd write(iout,*) 'eello6_6',eello6_6!,' eel6_6_num',16*eel6_6_num
9989 if (j.lt.nres-1) then
9996 if (l.lt.nres-1) then
10004 cgrad ggg1(ll)=eel6*g_contij(ll,1)
10005 cgrad ggg2(ll)=eel6*g_contij(ll,2)
10006 cold ghalf=0.5d0*eel6*ekl*gacont_hbr(ll,jj,i)
10007 cgrad ghalf=0.5d0*ggg1(ll)
10009 gradcorr6ij=eel6*g_contij(ll,1)+ekont*derx(ll,1,1)
10010 gradcorr6kl=eel6*g_contij(ll,2)+ekont*derx(ll,1,2)
10011 gradcorr6(ll,i)=gradcorr6(ll,i)+ekont*derx(ll,2,1)
10012 gradcorr6(ll,i+1)=gradcorr6(ll,i+1)+ekont*derx(ll,3,1)
10013 gradcorr6(ll,j)=gradcorr6(ll,j)+ekont*derx(ll,4,1)
10014 gradcorr6(ll,j1)=gradcorr6(ll,j1)+ekont*derx(ll,5,1)
10015 gradcorr6_long(ll,j)=gradcorr6_long(ll,j)+gradcorr6ij
10016 gradcorr6_long(ll,i)=gradcorr6_long(ll,i)-gradcorr6ij
10017 cgrad ghalf=0.5d0*ggg2(ll)
10018 cold ghalf=0.5d0*eel6*eij*gacont_hbr(ll,kk,k)
10020 gradcorr6(ll,k)=gradcorr6(ll,k)+ekont*derx(ll,2,2)
10021 gradcorr6(ll,k+1)=gradcorr6(ll,k+1)+ekont*derx(ll,3,2)
10022 gradcorr6(ll,l)=gradcorr6(ll,l)+ekont*derx(ll,4,2)
10023 gradcorr6(ll,l1)=gradcorr6(ll,l1)+ekont*derx(ll,5,2)
10024 gradcorr6_long(ll,l)=gradcorr6_long(ll,l)+gradcorr6kl
10025 gradcorr6_long(ll,k)=gradcorr6_long(ll,k)-gradcorr6kl
10030 cold gradcorr6(ll,m)=gradcorr6(ll,m)+eel6*ekl*gacont_hbr(ll,jj,i)
10031 cgrad gradcorr6(ll,m)=gradcorr6(ll,m)+ggg1(ll)
10036 cold gradcorr6(ll,m)=gradcorr6(ll,m)+eel6*eij*gacont_hbr(ll,kk,k)
10037 cgrad gradcorr6(ll,m)=gradcorr6(ll,m)+ggg2(ll)
10043 cgrad gradcorr6(ll,m)=gradcorr6(ll,m)+ekont*derx(ll,1,1)
10048 cgrad gradcorr6(ll,m)=gradcorr6(ll,m)+ekont*derx(ll,1,2)
10052 cd write (2,*) iii,g_corr6_loc(iii)
10055 cd write (2,*) 'ekont',ekont
10056 cd write (iout,*) 'eello6',ekont*eel6
10059 c--------------------------------------------------------------------------
10060 double precision function eello6_graph1(i,j,k,l,imat,swap)
10061 implicit real*8 (a-h,o-z)
10062 include 'DIMENSIONS'
10063 include 'COMMON.IOUNITS'
10064 include 'COMMON.CHAIN'
10065 include 'COMMON.DERIV'
10066 include 'COMMON.INTERACT'
10067 include 'COMMON.CONTACTS'
10068 include 'COMMON.TORSION'
10069 include 'COMMON.VAR'
10070 include 'COMMON.GEO'
10071 double precision vv(2),vv1(2),pizda(2,2),auxmat(2,2),pizda1(2,2)
10074 common /kutas/ lprn
10075 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
10077 C Parallel Antiparallel C
10083 C \ j|/k\| / \ |/k\|l / C
10084 C \ / \ / \ / \ / C
10088 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
10089 itk=itype2loc(itype(k))
10090 s1= scalar2(AEAb1(1,2,imat),CUgb2(1,i))
10091 s2=-scalar2(AEAb2(1,1,imat),Ug2Db1t(1,k))
10092 s3= scalar2(AEAb2(1,1,imat),CUgb2(1,k))
10093 call transpose2(EUgC(1,1,k),auxmat(1,1))
10094 call matmat2(AEA(1,1,imat),auxmat(1,1),pizda1(1,1))
10095 vv1(1)=pizda1(1,1)-pizda1(2,2)
10096 vv1(2)=pizda1(1,2)+pizda1(2,1)
10097 s4=0.5d0*scalar2(vv1(1),Dtobr2(1,i))
10098 vv(1)=AEAb1(1,2,imat)*b1(1,k)-AEAb1(2,2,imat)*b1(2,k)
10099 vv(2)=AEAb1(1,2,imat)*b1(2,k)+AEAb1(2,2,imat)*b1(1,k)
10100 s5=scalar2(vv(1),Dtobr2(1,i))
10101 cd write (2,*) 's1',s1,' s2',s2,' s3',s3,' s4', s4,' s5',s5
10102 eello6_graph1=-0.5d0*(s1+s2+s3+s4+s5)
10103 if (i.gt.1) g_corr6_loc(i-1)=g_corr6_loc(i-1)
10104 & -0.5d0*ekont*(scalar2(AEAb1(1,2,imat),CUgb2der(1,i))
10105 & -scalar2(AEAb2derg(1,2,1,imat),Ug2Db1t(1,k))
10106 & +scalar2(AEAb2derg(1,2,1,imat),CUgb2(1,k))
10107 & +0.5d0*scalar2(vv1(1),Dtobr2der(1,i))
10108 & +scalar2(vv(1),Dtobr2der(1,i)))
10109 call matmat2(AEAderg(1,1,imat),auxmat(1,1),pizda1(1,1))
10110 vv1(1)=pizda1(1,1)-pizda1(2,2)
10111 vv1(2)=pizda1(1,2)+pizda1(2,1)
10112 vv(1)=AEAb1derg(1,2,imat)*b1(1,k)-AEAb1derg(2,2,imat)*b1(2,k)
10113 vv(2)=AEAb1derg(1,2,imat)*b1(2,k)+AEAb1derg(2,2,imat)*b1(1,k)
10115 g_corr6_loc(l-1)=g_corr6_loc(l-1)
10116 & +ekont*(-0.5d0*(scalar2(AEAb1derg(1,2,imat),CUgb2(1,i))
10117 & -scalar2(AEAb2derg(1,1,1,imat),Ug2Db1t(1,k))
10118 & +scalar2(AEAb2derg(1,1,1,imat),CUgb2(1,k))
10119 & +0.5d0*scalar2(vv1(1),Dtobr2(1,i))+scalar2(vv(1),Dtobr2(1,i))))
10121 g_corr6_loc(j-1)=g_corr6_loc(j-1)
10122 & +ekont*(-0.5d0*(scalar2(AEAb1derg(1,2,imat),CUgb2(1,i))
10123 & -scalar2(AEAb2derg(1,1,1,imat),Ug2Db1t(1,k))
10124 & +scalar2(AEAb2derg(1,1,1,imat),CUgb2(1,k))
10125 & +0.5d0*scalar2(vv1(1),Dtobr2(1,i))+scalar2(vv(1),Dtobr2(1,i))))
10127 call transpose2(EUgCder(1,1,k),auxmat(1,1))
10128 call matmat2(AEA(1,1,imat),auxmat(1,1),pizda1(1,1))
10129 vv1(1)=pizda1(1,1)-pizda1(2,2)
10130 vv1(2)=pizda1(1,2)+pizda1(2,1)
10131 if (k.gt.1) g_corr6_loc(k-1)=g_corr6_loc(k-1)
10132 & +ekont*(-0.5d0*(-scalar2(AEAb2(1,1,imat),Ug2Db1tder(1,k))
10133 & +scalar2(AEAb2(1,1,imat),CUgb2der(1,k))
10134 & +0.5d0*scalar2(vv1(1),Dtobr2(1,i))))
10143 s1= scalar2(AEAb1derx(1,lll,kkk,iii,2,imat),CUgb2(1,i))
10144 s2=-scalar2(AEAb2derx(1,lll,kkk,iii,1,imat),Ug2Db1t(1,k))
10145 s3= scalar2(AEAb2derx(1,lll,kkk,iii,1,imat),CUgb2(1,k))
10146 call transpose2(EUgC(1,1,k),auxmat(1,1))
10147 call matmat2(AEAderx(1,1,lll,kkk,iii,imat),auxmat(1,1),
10149 vv1(1)=pizda1(1,1)-pizda1(2,2)
10150 vv1(2)=pizda1(1,2)+pizda1(2,1)
10151 s4=0.5d0*scalar2(vv1(1),Dtobr2(1,i))
10152 vv(1)=AEAb1derx(1,lll,kkk,iii,2,imat)*b1(1,k)
10153 & -AEAb1derx(2,lll,kkk,iii,2,imat)*b1(2,k)
10154 vv(2)=AEAb1derx(1,lll,kkk,iii,2,imat)*b1(2,k)
10155 & +AEAb1derx(2,lll,kkk,iii,2,imat)*b1(1,k)
10156 s5=scalar2(vv(1),Dtobr2(1,i))
10157 derx(lll,kkk,ind)=derx(lll,kkk,ind)-0.5d0*(s1+s2+s3+s4+s5)
10163 c----------------------------------------------------------------------------
10164 double precision function eello6_graph2(i,j,k,l,jj,kk,swap)
10165 implicit real*8 (a-h,o-z)
10166 include 'DIMENSIONS'
10167 include 'COMMON.IOUNITS'
10168 include 'COMMON.CHAIN'
10169 include 'COMMON.DERIV'
10170 include 'COMMON.INTERACT'
10171 include 'COMMON.CONTACTS'
10172 include 'COMMON.TORSION'
10173 include 'COMMON.VAR'
10174 include 'COMMON.GEO'
10176 double precision vv(2),pizda(2,2),auxmat(2,2),auxvec(2),
10177 & auxvec1(2),auxvec2(2),auxmat1(2,2)
10179 common /kutas/ lprn
10180 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
10182 C Parallel Antiparallel C
10188 C \ j|/k\| \ |/k\|l C
10193 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
10194 cd write (2,*) 'eello6_graph2: i,',i,' j',j,' k',k,' l',l
10195 C AL 7/4/01 s1 would occur in the sixth-order moment,
10196 C but not in a cluster cumulant
10198 s1=dip(1,jj,i)*dip(1,kk,k)
10200 call matvec2(ADtEA1(1,1,1),Ub2(1,k),auxvec(1))
10201 s2=-0.5d0*scalar2(Ub2(1,i),auxvec(1))
10202 call matvec2(ADtEA(1,1,2),Ub2(1,l),auxvec1(1))
10203 s3=-0.5d0*scalar2(Ub2(1,j),auxvec1(1))
10204 call transpose2(EUg(1,1,k),auxmat(1,1))
10205 call matmat2(ADtEA1(1,1,1),auxmat(1,1),pizda(1,1))
10206 vv(1)=pizda(1,1)-pizda(2,2)
10207 vv(2)=pizda(1,2)+pizda(2,1)
10208 s4=-0.25d0*scalar2(vv(1),Dtobr2(1,i))
10209 cd write (2,*) 'eello6_graph2:','s1',s1,' s2',s2,' s3',s3,' s4',s4
10211 eello6_graph2=-(s1+s2+s3+s4)
10213 eello6_graph2=-(s2+s3+s4)
10215 c eello6_graph2=-s3
10216 C Derivatives in gamma(i-1)
10219 s1=dipderg(1,jj,i)*dip(1,kk,k)
10221 s2=-0.5d0*scalar2(Ub2der(1,i),auxvec(1))
10222 call matvec2(ADtEAderg(1,1,1,2),Ub2(1,l),auxvec2(1))
10223 s3=-0.5d0*scalar2(Ub2(1,j),auxvec2(1))
10224 s4=-0.25d0*scalar2(vv(1),Dtobr2der(1,i))
10226 g_corr6_loc(i-1)=g_corr6_loc(i-1)-ekont*(s1+s2+s3+s4)
10228 g_corr6_loc(i-1)=g_corr6_loc(i-1)-ekont*(s2+s3+s4)
10230 c g_corr6_loc(i-1)=g_corr6_loc(i-1)-s3
10232 C Derivatives in gamma(k-1)
10234 s1=dip(1,jj,i)*dipderg(1,kk,k)
10236 call matvec2(ADtEA1(1,1,1),Ub2der(1,k),auxvec2(1))
10237 s2=-0.5d0*scalar2(Ub2(1,i),auxvec2(1))
10238 call matvec2(ADtEAderg(1,1,2,2),Ub2(1,l),auxvec2(1))
10239 s3=-0.5d0*scalar2(Ub2(1,j),auxvec2(1))
10240 call transpose2(EUgder(1,1,k),auxmat1(1,1))
10241 call matmat2(ADtEA1(1,1,1),auxmat1(1,1),pizda(1,1))
10242 vv(1)=pizda(1,1)-pizda(2,2)
10243 vv(2)=pizda(1,2)+pizda(2,1)
10244 s4=-0.25d0*scalar2(vv(1),Dtobr2(1,i))
10246 g_corr6_loc(k-1)=g_corr6_loc(k-1)-ekont*(s1+s2+s3+s4)
10248 g_corr6_loc(k-1)=g_corr6_loc(k-1)-ekont*(s2+s3+s4)
10250 c g_corr6_loc(k-1)=g_corr6_loc(k-1)-s3
10251 C Derivatives in gamma(j-1) or gamma(l-1)
10254 s1=dipderg(3,jj,i)*dip(1,kk,k)
10256 call matvec2(ADtEA1derg(1,1,1,1),Ub2(1,k),auxvec2(1))
10257 s2=-0.5d0*scalar2(Ub2(1,i),auxvec2(1))
10258 s3=-0.5d0*scalar2(Ub2der(1,j),auxvec1(1))
10259 call matmat2(ADtEA1derg(1,1,1,1),auxmat(1,1),pizda(1,1))
10260 vv(1)=pizda(1,1)-pizda(2,2)
10261 vv(2)=pizda(1,2)+pizda(2,1)
10262 s4=-0.25d0*scalar2(vv(1),Dtobr2(1,i))
10265 g_corr6_loc(l-1)=g_corr6_loc(l-1)-ekont*s1
10267 g_corr6_loc(j-1)=g_corr6_loc(j-1)-ekont*s1
10270 g_corr6_loc(j-1)=g_corr6_loc(j-1)-ekont*(s2+s3+s4)
10271 c g_corr6_loc(j-1)=g_corr6_loc(j-1)-s3
10273 C Derivatives in gamma(l-1) or gamma(j-1)
10276 s1=dip(1,jj,i)*dipderg(3,kk,k)
10278 call matvec2(ADtEA1derg(1,1,2,1),Ub2(1,k),auxvec2(1))
10279 s2=-0.5d0*scalar2(Ub2(1,i),auxvec2(1))
10280 call matvec2(ADtEA(1,1,2),Ub2der(1,l),auxvec2(1))
10281 s3=-0.5d0*scalar2(Ub2(1,j),auxvec2(1))
10282 call matmat2(ADtEA1derg(1,1,2,1),auxmat(1,1),pizda(1,1))
10283 vv(1)=pizda(1,1)-pizda(2,2)
10284 vv(2)=pizda(1,2)+pizda(2,1)
10285 s4=-0.25d0*scalar2(vv(1),Dtobr2(1,i))
10288 g_corr6_loc(j-1)=g_corr6_loc(j-1)-ekont*s1
10290 g_corr6_loc(l-1)=g_corr6_loc(l-1)-ekont*s1
10293 g_corr6_loc(l-1)=g_corr6_loc(l-1)-ekont*(s2+s3+s4)
10294 c g_corr6_loc(l-1)=g_corr6_loc(l-1)-s3
10296 C Cartesian derivatives.
10298 write (2,*) 'In eello6_graph2'
10300 write (2,*) 'iii=',iii
10302 write (2,*) 'kkk=',kkk
10304 write (2,'(3(2f10.5),5x)')
10305 & ((ADtEA1derx(jjj,mmm,lll,kkk,iii,1),mmm=1,2),lll=1,3)
10315 s1=dipderx(lll,kkk,1,jj,i)*dip(1,kk,k)
10317 s1=dip(1,jj,i)*dipderx(lll,kkk,1,kk,k)
10320 call matvec2(ADtEA1derx(1,1,lll,kkk,iii,1),Ub2(1,k),
10322 s2=-0.5d0*scalar2(Ub2(1,i),auxvec(1))
10323 call matvec2(ADtEAderx(1,1,lll,kkk,iii,2),Ub2(1,l),
10325 s3=-0.5d0*scalar2(Ub2(1,j),auxvec(1))
10326 call transpose2(EUg(1,1,k),auxmat(1,1))
10327 call matmat2(ADtEA1derx(1,1,lll,kkk,iii,1),auxmat(1,1),
10329 vv(1)=pizda(1,1)-pizda(2,2)
10330 vv(2)=pizda(1,2)+pizda(2,1)
10331 s4=-0.25d0*scalar2(vv(1),Dtobr2(1,i))
10332 cd write (2,*) 's1',s1,' s2',s2,' s3',s3,' s4',s4
10334 derx(lll,kkk,iii)=derx(lll,kkk,iii)-(s1+s2+s4)
10336 derx(lll,kkk,iii)=derx(lll,kkk,iii)-(s2+s4)
10339 derx(lll,kkk,3-iii)=derx(lll,kkk,3-iii)-s3
10341 derx(lll,kkk,iii)=derx(lll,kkk,iii)-s3
10348 c----------------------------------------------------------------------------
10349 double precision function eello6_graph3(i,j,k,l,jj,kk,swap)
10350 implicit real*8 (a-h,o-z)
10351 include 'DIMENSIONS'
10352 include 'COMMON.IOUNITS'
10353 include 'COMMON.CHAIN'
10354 include 'COMMON.DERIV'
10355 include 'COMMON.INTERACT'
10356 include 'COMMON.CONTACTS'
10357 include 'COMMON.TORSION'
10358 include 'COMMON.VAR'
10359 include 'COMMON.GEO'
10360 double precision vv(2),pizda(2,2),auxmat(2,2),auxvec(2)
10362 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
10364 C Parallel Antiparallel C
10369 C /| o |o o| o |\ C
10370 C j|/k\| / |/k\|l / C
10375 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
10377 C 4/7/01 AL Component s1 was removed, because it pertains to the respective
10378 C energy moment and not to the cluster cumulant.
10379 iti=itortyp(itype(i))
10380 if (j.lt.nres-1) then
10381 itj1=itype2loc(itype(j+1))
10385 itk=itype2loc(itype(k))
10386 itk1=itype2loc(itype(k+1))
10387 if (l.lt.nres-1) then
10388 itl1=itype2loc(itype(l+1))
10393 s1=dip(4,jj,i)*dip(4,kk,k)
10395 call matvec2(AECA(1,1,1),b1(1,k+1),auxvec(1))
10396 s2=0.5d0*scalar2(b1(1,k),auxvec(1))
10397 call matvec2(AECA(1,1,2),b1(1,l+1),auxvec(1))
10398 s3=0.5d0*scalar2(b1(1,j+1),auxvec(1))
10399 call transpose2(EE(1,1,k),auxmat(1,1))
10400 call matmat2(auxmat(1,1),AECA(1,1,1),pizda(1,1))
10401 vv(1)=pizda(1,1)+pizda(2,2)
10402 vv(2)=pizda(2,1)-pizda(1,2)
10403 s4=-0.25d0*scalar2(vv(1),Ctobr(1,k))
10404 cd write (2,*) 'eello6_graph3:','s1',s1,' s2',s2,' s3',s3,' s4',s4,
10405 cd & "sum",-(s2+s3+s4)
10407 eello6_graph3=-(s1+s2+s3+s4)
10409 eello6_graph3=-(s2+s3+s4)
10411 c eello6_graph3=-s4
10412 C Derivatives in gamma(k-1)
10413 call matvec2(AECAderg(1,1,2),b1(1,l+1),auxvec(1))
10414 s3=0.5d0*scalar2(b1(1,j+1),auxvec(1))
10415 s4=-0.25d0*scalar2(vv(1),Ctobrder(1,k))
10416 g_corr6_loc(k-1)=g_corr6_loc(k-1)-ekont*(s3+s4)
10417 C Derivatives in gamma(l-1)
10418 call matvec2(AECAderg(1,1,1),b1(1,k+1),auxvec(1))
10419 s2=0.5d0*scalar2(b1(1,k),auxvec(1))
10420 call matmat2(auxmat(1,1),AECAderg(1,1,1),pizda(1,1))
10421 vv(1)=pizda(1,1)+pizda(2,2)
10422 vv(2)=pizda(2,1)-pizda(1,2)
10423 s4=-0.25d0*scalar2(vv(1),Ctobr(1,k))
10424 g_corr6_loc(l-1)=g_corr6_loc(l-1)-ekont*(s2+s4)
10425 C Cartesian derivatives.
10431 s1=dipderx(lll,kkk,4,jj,i)*dip(4,kk,k)
10433 s1=dip(4,jj,i)*dipderx(lll,kkk,4,kk,k)
10436 call matvec2(AECAderx(1,1,lll,kkk,iii,1),b1(1,k+1),
10438 s2=0.5d0*scalar2(b1(1,k),auxvec(1))
10439 call matvec2(AECAderx(1,1,lll,kkk,iii,2),b1(1,l+1),
10441 s3=0.5d0*scalar2(b1(1,j+1),auxvec(1))
10442 call matmat2(auxmat(1,1),AECAderx(1,1,lll,kkk,iii,1),
10444 vv(1)=pizda(1,1)+pizda(2,2)
10445 vv(2)=pizda(2,1)-pizda(1,2)
10446 s4=-0.25d0*scalar2(vv(1),Ctobr(1,k))
10448 derx(lll,kkk,iii)=derx(lll,kkk,iii)-(s1+s2+s4)
10450 derx(lll,kkk,iii)=derx(lll,kkk,iii)-(s2+s4)
10453 derx(lll,kkk,3-iii)=derx(lll,kkk,3-iii)-s3
10455 derx(lll,kkk,iii)=derx(lll,kkk,iii)-s3
10457 c derx(lll,kkk,iii)=derx(lll,kkk,iii)-s4
10463 c----------------------------------------------------------------------------
10464 double precision function eello6_graph4(i,j,k,l,jj,kk,imat,swap)
10465 implicit real*8 (a-h,o-z)
10466 include 'DIMENSIONS'
10467 include 'COMMON.IOUNITS'
10468 include 'COMMON.CHAIN'
10469 include 'COMMON.DERIV'
10470 include 'COMMON.INTERACT'
10471 include 'COMMON.CONTACTS'
10472 include 'COMMON.TORSION'
10473 include 'COMMON.VAR'
10474 include 'COMMON.GEO'
10475 include 'COMMON.FFIELD'
10476 double precision vv(2),pizda(2,2),auxmat(2,2),auxvec(2),
10477 & auxvec1(2),auxmat1(2,2)
10479 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
10481 C Parallel Antiparallel C
10486 C /| o |o o| o |\ C
10487 C \ j|/k\| \ |/k\|l C
10492 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
10494 C 4/7/01 AL Component s1 was removed, because it pertains to the respective
10495 C energy moment and not to the cluster cumulant.
10496 cd write (2,*) 'eello_graph4: wturn6',wturn6
10497 iti=itype2loc(itype(i))
10498 itj=itype2loc(itype(j))
10499 if (j.lt.nres-1) then
10500 itj1=itype2loc(itype(j+1))
10504 itk=itype2loc(itype(k))
10505 if (k.lt.nres-1) then
10506 itk1=itype2loc(itype(k+1))
10510 itl=itype2loc(itype(l))
10511 if (l.lt.nres-1) then
10512 itl1=itype2loc(itype(l+1))
10516 cd write (2,*) 'eello6_graph4:','i',i,' j',j,' k',k,' l',l
10517 cd write (2,*) 'iti',iti,' itj',itj,' itj1',itj1,' itk',itk,
10518 cd & ' itl',itl,' itl1',itl1
10520 if (imat.eq.1) then
10521 s1=dip(3,jj,i)*dip(3,kk,k)
10523 s1=dip(2,jj,j)*dip(2,kk,l)
10526 call matvec2(AECA(1,1,imat),Ub2(1,k),auxvec(1))
10527 s2=0.5d0*scalar2(Ub2(1,i),auxvec(1))
10529 call matvec2(ADtEA1(1,1,3-imat),b1(1,j+1),auxvec1(1))
10530 s3=-0.5d0*scalar2(b1(1,j),auxvec1(1))
10532 call matvec2(ADtEA1(1,1,3-imat),b1(1,l+1),auxvec1(1))
10533 s3=-0.5d0*scalar2(b1(1,l),auxvec1(1))
10535 call transpose2(EUg(1,1,k),auxmat(1,1))
10536 call matmat2(AECA(1,1,imat),auxmat(1,1),pizda(1,1))
10537 vv(1)=pizda(1,1)-pizda(2,2)
10538 vv(2)=pizda(2,1)+pizda(1,2)
10539 s4=0.25d0*scalar2(vv(1),Dtobr2(1,i))
10540 cd write (2,*) 'eello6_graph4:','s1',s1,' s2',s2,' s3',s3,' s4',s4
10542 eello6_graph4=-(s1+s2+s3+s4)
10544 eello6_graph4=-(s2+s3+s4)
10546 C Derivatives in gamma(i-1)
10549 if (imat.eq.1) then
10550 s1=dipderg(2,jj,i)*dip(3,kk,k)
10552 s1=dipderg(4,jj,j)*dip(2,kk,l)
10555 s2=0.5d0*scalar2(Ub2der(1,i),auxvec(1))
10557 call matvec2(ADtEA1derg(1,1,1,3-imat),b1(1,j+1),auxvec1(1))
10558 s3=-0.5d0*scalar2(b1(1,j),auxvec1(1))
10560 call matvec2(ADtEA1derg(1,1,1,3-imat),b1(1,l+1),auxvec1(1))
10561 s3=-0.5d0*scalar2(b1(1,l),auxvec1(1))
10563 s4=0.25d0*scalar2(vv(1),Dtobr2der(1,i))
10564 if (wturn6.gt.0.0d0 .and. k.eq.l+4 .and. i.eq.j+2) then
10565 cd write (2,*) 'turn6 derivatives'
10567 gel_loc_turn6(i-1)=gel_loc_turn6(i-1)-ekont*(s1+s2+s3+s4)
10569 gel_loc_turn6(i-1)=gel_loc_turn6(i-1)-ekont*(s2+s3+s4)
10573 g_corr6_loc(i-1)=g_corr6_loc(i-1)-ekont*(s1+s2+s3+s4)
10575 g_corr6_loc(i-1)=g_corr6_loc(i-1)-ekont*(s2+s3+s4)
10579 C Derivatives in gamma(k-1)
10581 if (imat.eq.1) then
10582 s1=dip(3,jj,i)*dipderg(2,kk,k)
10584 s1=dip(2,jj,j)*dipderg(4,kk,l)
10587 call matvec2(AECA(1,1,imat),Ub2der(1,k),auxvec1(1))
10588 s2=0.5d0*scalar2(Ub2(1,i),auxvec1(1))
10590 call matvec2(ADtEA1derg(1,1,2,3-imat),b1(1,j+1),auxvec1(1))
10591 s3=-0.5d0*scalar2(b1(1,j),auxvec1(1))
10593 call matvec2(ADtEA1derg(1,1,2,3-imat),b1(1,l+1),auxvec1(1))
10594 s3=-0.5d0*scalar2(b1(1,l),auxvec1(1))
10596 call transpose2(EUgder(1,1,k),auxmat1(1,1))
10597 call matmat2(AECA(1,1,imat),auxmat1(1,1),pizda(1,1))
10598 vv(1)=pizda(1,1)-pizda(2,2)
10599 vv(2)=pizda(2,1)+pizda(1,2)
10600 s4=0.25d0*scalar2(vv(1),Dtobr2(1,i))
10601 if (wturn6.gt.0.0d0 .and. k.eq.l+4 .and. i.eq.j+2) then
10603 gel_loc_turn6(k-1)=gel_loc_turn6(k-1)-ekont*(s1+s2+s3+s4)
10605 gel_loc_turn6(k-1)=gel_loc_turn6(k-1)-ekont*(s2+s3+s4)
10609 g_corr6_loc(k-1)=g_corr6_loc(k-1)-ekont*(s1+s2+s3+s4)
10611 g_corr6_loc(k-1)=g_corr6_loc(k-1)-ekont*(s2+s3+s4)
10614 C Derivatives in gamma(j-1) or gamma(l-1)
10615 if (l.eq.j+1 .and. l.gt.1) then
10616 call matvec2(AECAderg(1,1,imat),Ub2(1,k),auxvec(1))
10617 s2=0.5d0*scalar2(Ub2(1,i),auxvec(1))
10618 call matmat2(AECAderg(1,1,imat),auxmat(1,1),pizda(1,1))
10619 vv(1)=pizda(1,1)-pizda(2,2)
10620 vv(2)=pizda(2,1)+pizda(1,2)
10621 s4=0.25d0*scalar2(vv(1),Dtobr2(1,i))
10622 g_corr6_loc(l-1)=g_corr6_loc(l-1)-ekont*(s2+s4)
10623 else if (j.gt.1) then
10624 call matvec2(AECAderg(1,1,imat),Ub2(1,k),auxvec(1))
10625 s2=0.5d0*scalar2(Ub2(1,i),auxvec(1))
10626 call matmat2(AECAderg(1,1,imat),auxmat(1,1),pizda(1,1))
10627 vv(1)=pizda(1,1)-pizda(2,2)
10628 vv(2)=pizda(2,1)+pizda(1,2)
10629 s4=0.25d0*scalar2(vv(1),Dtobr2(1,i))
10630 if (wturn6.gt.0.0d0 .and. k.eq.l+4 .and. i.eq.j+2) then
10631 gel_loc_turn6(j-1)=gel_loc_turn6(j-1)-ekont*(s2+s4)
10633 g_corr6_loc(j-1)=g_corr6_loc(j-1)-ekont*(s2+s4)
10636 C Cartesian derivatives.
10642 if (imat.eq.1) then
10643 s1=dipderx(lll,kkk,3,jj,i)*dip(3,kk,k)
10645 s1=dipderx(lll,kkk,2,jj,j)*dip(2,kk,l)
10648 if (imat.eq.1) then
10649 s1=dip(3,jj,i)*dipderx(lll,kkk,3,kk,k)
10651 s1=dip(2,jj,j)*dipderx(lll,kkk,2,kk,l)
10655 call matvec2(AECAderx(1,1,lll,kkk,iii,imat),Ub2(1,k),
10657 s2=0.5d0*scalar2(Ub2(1,i),auxvec(1))
10659 call matvec2(ADtEA1derx(1,1,lll,kkk,iii,3-imat),
10660 & b1(1,j+1),auxvec(1))
10661 s3=-0.5d0*scalar2(b1(1,j),auxvec(1))
10663 call matvec2(ADtEA1derx(1,1,lll,kkk,iii,3-imat),
10664 & b1(1,l+1),auxvec(1))
10665 s3=-0.5d0*scalar2(b1(1,l),auxvec(1))
10667 call matmat2(AECAderx(1,1,lll,kkk,iii,imat),auxmat(1,1),
10669 vv(1)=pizda(1,1)-pizda(2,2)
10670 vv(2)=pizda(2,1)+pizda(1,2)
10671 s4=0.25d0*scalar2(vv(1),Dtobr2(1,i))
10673 if (wturn6.gt.0.0d0 .and. k.eq.l+4 .and. i.eq.j+2) then
10675 derx_turn(lll,kkk,3-iii)=derx_turn(lll,kkk,3-iii)
10678 derx_turn(lll,kkk,3-iii)=derx_turn(lll,kkk,3-iii)
10681 derx_turn(lll,kkk,iii)=derx_turn(lll,kkk,iii)-s3
10684 derx(lll,kkk,3-iii)=derx(lll,kkk,3-iii)-(s1+s2+s4)
10686 derx(lll,kkk,3-iii)=derx(lll,kkk,3-iii)-(s2+s4)
10688 derx(lll,kkk,iii)=derx(lll,kkk,iii)-s3
10692 derx(lll,kkk,iii)=derx(lll,kkk,iii)-(s1+s2+s4)
10694 derx(lll,kkk,iii)=derx(lll,kkk,iii)-(s2+s4)
10697 derx(lll,kkk,iii)=derx(lll,kkk,iii)-s3
10699 derx(lll,kkk,3-iii)=derx(lll,kkk,3-iii)-s3
10707 c----------------------------------------------------------------------------
10708 double precision function eello_turn6(i,jj,kk)
10709 implicit real*8 (a-h,o-z)
10710 include 'DIMENSIONS'
10711 include 'COMMON.IOUNITS'
10712 include 'COMMON.CHAIN'
10713 include 'COMMON.DERIV'
10714 include 'COMMON.INTERACT'
10715 include 'COMMON.CONTACTS'
10716 include 'COMMON.TORSION'
10717 include 'COMMON.VAR'
10718 include 'COMMON.GEO'
10719 double precision vtemp1(2),vtemp2(2),vtemp3(2),vtemp4(2),
10720 & atemp(2,2),auxmat(2,2),achuj_temp(2,2),gtemp(2,2),gvec(2),
10722 double precision vtemp1d(2),vtemp2d(2),vtemp3d(2),vtemp4d(2),
10723 & atempd(2,2),auxmatd(2,2),achuj_tempd(2,2),gtempd(2,2),gvecd(2)
10724 C 4/7/01 AL Components s1, s8, and s13 were removed, because they pertain to
10725 C the respective energy moment and not to the cluster cumulant.
10734 iti=itype2loc(itype(i))
10735 itk=itype2loc(itype(k))
10736 itk1=itype2loc(itype(k+1))
10737 itl=itype2loc(itype(l))
10738 itj=itype2loc(itype(j))
10739 cd write (2,*) 'itk',itk,' itk1',itk1,' itl',itl,' itj',itj
10740 cd write (2,*) 'i',i,' k',k,' j',j,' l',l
10741 cd if (i.ne.1 .or. j.ne.3 .or. k.ne.2 .or. l.ne.4) then
10746 cd & 'EELLO6: Contacts have occurred for peptide groups',i,j,
10748 cd call checkint_turn6(i,jj,kk,eel_turn6_num)
10752 derx_turn(lll,kkk,iii)=0.0d0
10759 eello6_5=eello6_graph4(l,k,j,i,kk,jj,2,.true.)
10761 cd write (2,*) 'eello6_5',eello6_5
10763 call transpose2(AEA(1,1,1),auxmat(1,1))
10764 call matmat2(EUg(1,1,i+1),auxmat(1,1),auxmat(1,1))
10765 ss1=scalar2(Ub2(1,i+2),b1(1,l))
10766 s1 = (auxmat(1,1)+auxmat(2,2))*ss1
10768 call matvec2(EUg(1,1,i+2),b1(1,l),vtemp1(1))
10769 call matvec2(AEA(1,1,1),vtemp1(1),vtemp1(1))
10770 s2 = scalar2(b1(1,k),vtemp1(1))
10772 call transpose2(AEA(1,1,2),atemp(1,1))
10773 call matmat2(atemp(1,1),EUg(1,1,i+4),atemp(1,1))
10774 call matvec2(Ug2(1,1,i+2),dd(1,1,k+1),vtemp2(1))
10775 s8 = -(atemp(1,1)+atemp(2,2))*scalar2(cc(1,1,l),vtemp2(1))
10777 call matmat2(EUg(1,1,i+3),AEA(1,1,2),auxmat(1,1))
10778 call matvec2(auxmat(1,1),Ub2(1,i+4),vtemp3(1))
10779 s12 = scalar2(Ub2(1,i+2),vtemp3(1))
10781 call transpose2(a_chuj(1,1,kk,i+1),achuj_temp(1,1))
10782 call matmat2(achuj_temp(1,1),EUg(1,1,i+2),gtemp(1,1))
10783 call matmat2(gtemp(1,1),EUg(1,1,i+3),gtemp(1,1))
10784 call matvec2(a_chuj(1,1,jj,i),Ub2(1,i+4),vtemp4(1))
10785 ss13 = scalar2(b1(1,k),vtemp4(1))
10786 s13 = (gtemp(1,1)+gtemp(2,2))*ss13
10788 c write (2,*) 's1,s2,s8,s12,s13',s1,s2,s8,s12,s13
10794 eel_turn6 = eello6_5 - 0.5d0*(s1+s2+s12+s8+s13)
10795 C Derivatives in gamma(i+2)
10799 call transpose2(AEA(1,1,1),auxmatd(1,1))
10800 call matmat2(EUgder(1,1,i+1),auxmatd(1,1),auxmatd(1,1))
10801 s1d = (auxmatd(1,1)+auxmatd(2,2))*ss1
10802 call transpose2(AEAderg(1,1,2),atempd(1,1))
10803 call matmat2(atempd(1,1),EUg(1,1,i+4),atempd(1,1))
10804 s8d = -(atempd(1,1)+atempd(2,2))*scalar2(cc(1,1,l),vtemp2(1))
10806 call matmat2(EUg(1,1,i+3),AEAderg(1,1,2),auxmatd(1,1))
10807 call matvec2(auxmatd(1,1),Ub2(1,i+4),vtemp3d(1))
10808 s12d = scalar2(Ub2(1,i+2),vtemp3d(1))
10814 gel_loc_turn6(i)=gel_loc_turn6(i)-0.5d0*ekont*(s1d+s8d+s12d)
10815 C Derivatives in gamma(i+3)
10817 call transpose2(AEA(1,1,1),auxmatd(1,1))
10818 call matmat2(EUg(1,1,i+1),auxmatd(1,1),auxmatd(1,1))
10819 ss1d=scalar2(Ub2der(1,i+2),b1(1,l))
10820 s1d = (auxmatd(1,1)+auxmatd(2,2))*ss1d
10822 call matvec2(EUgder(1,1,i+2),b1(1,l),vtemp1d(1))
10823 call matvec2(AEA(1,1,1),vtemp1d(1),vtemp1d(1))
10824 s2d = scalar2(b1(1,k),vtemp1d(1))
10826 call matvec2(Ug2der(1,1,i+2),dd(1,1,k+1),vtemp2d(1))
10827 s8d = -(atemp(1,1)+atemp(2,2))*scalar2(cc(1,1,l),vtemp2d(1))
10829 s12d = scalar2(Ub2der(1,i+2),vtemp3(1))
10831 call matmat2(achuj_temp(1,1),EUgder(1,1,i+2),gtempd(1,1))
10832 call matmat2(gtempd(1,1),EUg(1,1,i+3),gtempd(1,1))
10833 s13d = (gtempd(1,1)+gtempd(2,2))*ss13
10841 gel_loc_turn6(i+1)=gel_loc_turn6(i+1)
10842 & -0.5d0*ekont*(s1d+s2d+s8d+s12d+s13d)
10844 gel_loc_turn6(i+1)=gel_loc_turn6(i+1)
10845 & -0.5d0*ekont*(s2d+s12d)
10847 C Derivatives in gamma(i+4)
10848 call matmat2(EUgder(1,1,i+3),AEA(1,1,2),auxmatd(1,1))
10849 call matvec2(auxmatd(1,1),Ub2(1,i+4),vtemp3d(1))
10850 s12d = scalar2(Ub2(1,i+2),vtemp3d(1))
10852 call matmat2(achuj_temp(1,1),EUg(1,1,i+2),gtempd(1,1))
10853 call matmat2(gtempd(1,1),EUgder(1,1,i+3),gtempd(1,1))
10854 s13d = (gtempd(1,1)+gtempd(2,2))*ss13
10862 gel_loc_turn6(i+2)=gel_loc_turn6(i+2)-0.5d0*ekont*(s12d+s13d)
10864 gel_loc_turn6(i+2)=gel_loc_turn6(i+2)-0.5d0*ekont*(s12d)
10866 C Derivatives in gamma(i+5)
10868 call transpose2(AEAderg(1,1,1),auxmatd(1,1))
10869 call matmat2(EUg(1,1,i+1),auxmatd(1,1),auxmatd(1,1))
10870 s1d = (auxmatd(1,1)+auxmatd(2,2))*ss1
10872 call matvec2(EUg(1,1,i+2),b1(1,l),vtemp1d(1))
10873 call matvec2(AEAderg(1,1,1),vtemp1d(1),vtemp1d(1))
10874 s2d = scalar2(b1(1,k),vtemp1d(1))
10876 call transpose2(AEA(1,1,2),atempd(1,1))
10877 call matmat2(atempd(1,1),EUgder(1,1,i+4),atempd(1,1))
10878 s8d = -(atempd(1,1)+atempd(2,2))*scalar2(cc(1,1,l),vtemp2(1))
10880 call matvec2(auxmat(1,1),Ub2der(1,i+4),vtemp3d(1))
10881 s12d = scalar2(Ub2(1,i+2),vtemp3d(1))
10883 call matvec2(a_chuj(1,1,jj,i),Ub2der(1,i+4),vtemp4d(1))
10884 ss13d = scalar2(b1(1,k),vtemp4d(1))
10885 s13d = (gtemp(1,1)+gtemp(2,2))*ss13d
10893 gel_loc_turn6(i+3)=gel_loc_turn6(i+3)
10894 & -0.5d0*ekont*(s1d+s2d+s8d+s12d+s13d)
10896 gel_loc_turn6(i+3)=gel_loc_turn6(i+3)
10897 & -0.5d0*ekont*(s2d+s12d)
10899 C Cartesian derivatives
10904 call transpose2(AEAderx(1,1,lll,kkk,iii,1),auxmatd(1,1))
10905 call matmat2(EUg(1,1,i+1),auxmatd(1,1),auxmatd(1,1))
10906 s1d = (auxmatd(1,1)+auxmatd(2,2))*ss1
10908 call matvec2(EUg(1,1,i+2),b1(1,l),vtemp1(1))
10909 call matvec2(AEAderx(1,1,lll,kkk,iii,1),vtemp1(1),
10911 s2d = scalar2(b1(1,k),vtemp1d(1))
10913 call transpose2(AEAderx(1,1,lll,kkk,iii,2),atempd(1,1))
10914 call matmat2(atempd(1,1),EUg(1,1,i+4),atempd(1,1))
10915 s8d = -(atempd(1,1)+atempd(2,2))*
10916 & scalar2(cc(1,1,l),vtemp2(1))
10918 call matmat2(EUg(1,1,i+3),AEAderx(1,1,lll,kkk,iii,2),
10920 call matvec2(auxmatd(1,1),Ub2(1,i+4),vtemp3d(1))
10921 s12d = scalar2(Ub2(1,i+2),vtemp3d(1))
10928 derx_turn(lll,kkk,iii) = derx_turn(lll,kkk,iii)
10929 & - 0.5d0*(s1d+s2d)
10931 derx_turn(lll,kkk,iii) = derx_turn(lll,kkk,iii)
10935 derx_turn(lll,kkk,3-iii) = derx_turn(lll,kkk,3-iii)
10936 & - 0.5d0*(s8d+s12d)
10938 derx_turn(lll,kkk,3-iii) = derx_turn(lll,kkk,3-iii)
10947 call transpose2(a_chuj_der(1,1,lll,kkk,kk,i+1),
10948 & achuj_tempd(1,1))
10949 call matmat2(achuj_tempd(1,1),EUg(1,1,i+2),gtempd(1,1))
10950 call matmat2(gtempd(1,1),EUg(1,1,i+3),gtempd(1,1))
10951 s13d=(gtempd(1,1)+gtempd(2,2))*ss13
10952 derx_turn(lll,kkk,2) = derx_turn(lll,kkk,2)-0.5d0*s13d
10953 call matvec2(a_chuj_der(1,1,lll,kkk,jj,i),Ub2(1,i+4),
10955 ss13d = scalar2(b1(1,k),vtemp4d(1))
10956 s13d = (gtemp(1,1)+gtemp(2,2))*ss13d
10957 derx_turn(lll,kkk,1) = derx_turn(lll,kkk,1)-0.5d0*s13d
10961 cd write(iout,*) 'eel6_turn6',eel_turn6,' eel_turn6_num',
10962 cd & 16*eel_turn6_num
10964 if (j.lt.nres-1) then
10971 if (l.lt.nres-1) then
10979 cgrad ggg1(ll)=eel_turn6*g_contij(ll,1)
10980 cgrad ggg2(ll)=eel_turn6*g_contij(ll,2)
10981 cgrad ghalf=0.5d0*ggg1(ll)
10983 gturn6ij=eel_turn6*g_contij(ll,1)+ekont*derx_turn(ll,1,1)
10984 gturn6kl=eel_turn6*g_contij(ll,2)+ekont*derx_turn(ll,1,2)
10985 gcorr6_turn(ll,i)=gcorr6_turn(ll,i)!+ghalf
10986 & +ekont*derx_turn(ll,2,1)
10987 gcorr6_turn(ll,i+1)=gcorr6_turn(ll,i+1)+ekont*derx_turn(ll,3,1)
10988 gcorr6_turn(ll,j)=gcorr6_turn(ll,j)!+ghalf
10989 & +ekont*derx_turn(ll,4,1)
10990 gcorr6_turn(ll,j1)=gcorr6_turn(ll,j1)+ekont*derx_turn(ll,5,1)
10991 gcorr6_turn_long(ll,j)=gcorr6_turn_long(ll,j)+gturn6ij
10992 gcorr6_turn_long(ll,i)=gcorr6_turn_long(ll,i)-gturn6ij
10993 cgrad ghalf=0.5d0*ggg2(ll)
10995 gcorr6_turn(ll,k)=gcorr6_turn(ll,k)!+ghalf
10996 & +ekont*derx_turn(ll,2,2)
10997 gcorr6_turn(ll,k+1)=gcorr6_turn(ll,k+1)+ekont*derx_turn(ll,3,2)
10998 gcorr6_turn(ll,l)=gcorr6_turn(ll,l)!+ghalf
10999 & +ekont*derx_turn(ll,4,2)
11000 gcorr6_turn(ll,l1)=gcorr6_turn(ll,l1)+ekont*derx_turn(ll,5,2)
11001 gcorr6_turn_long(ll,l)=gcorr6_turn_long(ll,l)+gturn6kl
11002 gcorr6_turn_long(ll,k)=gcorr6_turn_long(ll,k)-gturn6kl
11007 cgrad gcorr6_turn(ll,m)=gcorr6_turn(ll,m)+ggg1(ll)
11012 cgrad gcorr6_turn(ll,m)=gcorr6_turn(ll,m)+ggg2(ll)
11018 cgrad gcorr6_turn(ll,m)=gcorr6_turn(ll,m)+ekont*derx_turn(ll,1,1)
11023 cgrad gcorr6_turn(ll,m)=gcorr6_turn(ll,m)+ekont*derx_turn(ll,1,2)
11027 cd write (2,*) iii,g_corr6_loc(iii)
11029 eello_turn6=ekont*eel_turn6
11030 cd write (2,*) 'ekont',ekont
11031 cd write (2,*) 'eel_turn6',ekont*eel_turn6
11035 C-----------------------------------------------------------------------------
11036 double precision function scalar(u,v)
11037 !DIR$ INLINEALWAYS scalar
11039 cDEC$ ATTRIBUTES FORCEINLINE::scalar
11042 double precision u(3),v(3)
11043 cd double precision sc
11051 scalar=u(1)*v(1)+u(2)*v(2)+u(3)*v(3)
11054 crc-------------------------------------------------
11055 SUBROUTINE MATVEC2(A1,V1,V2)
11056 !DIR$ INLINEALWAYS MATVEC2
11058 cDEC$ ATTRIBUTES FORCEINLINE::MATVEC2
11060 implicit real*8 (a-h,o-z)
11061 include 'DIMENSIONS'
11062 DIMENSION A1(2,2),V1(2),V2(2)
11066 c 3 VI=VI+A1(I,K)*V1(K)
11070 vaux1=a1(1,1)*v1(1)+a1(1,2)*v1(2)
11071 vaux2=a1(2,1)*v1(1)+a1(2,2)*v1(2)
11076 C---------------------------------------
11077 SUBROUTINE MATMAT2(A1,A2,A3)
11079 cDEC$ ATTRIBUTES FORCEINLINE::MATMAT2
11081 implicit real*8 (a-h,o-z)
11082 include 'DIMENSIONS'
11083 DIMENSION A1(2,2),A2(2,2),A3(2,2)
11084 c DIMENSION AI3(2,2)
11088 c A3IJ=A3IJ+A1(I,K)*A2(K,J)
11094 ai3_11=a1(1,1)*a2(1,1)+a1(1,2)*a2(2,1)
11095 ai3_12=a1(1,1)*a2(1,2)+a1(1,2)*a2(2,2)
11096 ai3_21=a1(2,1)*a2(1,1)+a1(2,2)*a2(2,1)
11097 ai3_22=a1(2,1)*a2(1,2)+a1(2,2)*a2(2,2)
11105 c-------------------------------------------------------------------------
11106 double precision function scalar2(u,v)
11107 !DIR$ INLINEALWAYS scalar2
11109 double precision u(2),v(2)
11110 double precision sc
11112 scalar2=u(1)*v(1)+u(2)*v(2)
11116 C-----------------------------------------------------------------------------
11118 subroutine transpose2(a,at)
11119 !DIR$ INLINEALWAYS transpose2
11121 cDEC$ ATTRIBUTES FORCEINLINE::transpose2
11124 double precision a(2,2),at(2,2)
11131 c--------------------------------------------------------------------------
11132 subroutine transpose(n,a,at)
11135 double precision a(n,n),at(n,n)
11143 C---------------------------------------------------------------------------
11144 subroutine prodmat3(a1,a2,kk,transp,prod)
11145 !DIR$ INLINEALWAYS prodmat3
11147 cDEC$ ATTRIBUTES FORCEINLINE::prodmat3
11151 double precision a1(2,2),a2(2,2),a2t(2,2),kk(2,2),prod(2,2)
11153 crc double precision auxmat(2,2),prod_(2,2)
11156 crc call transpose2(kk(1,1),auxmat(1,1))
11157 crc call matmat2(a1(1,1),auxmat(1,1),auxmat(1,1))
11158 crc call matmat2(auxmat(1,1),a2(1,1),prod_(1,1))
11160 prod(1,1)=(a1(1,1)*kk(1,1)+a1(1,2)*kk(1,2))*a2(1,1)
11161 & +(a1(1,1)*kk(2,1)+a1(1,2)*kk(2,2))*a2(2,1)
11162 prod(1,2)=(a1(1,1)*kk(1,1)+a1(1,2)*kk(1,2))*a2(1,2)
11163 & +(a1(1,1)*kk(2,1)+a1(1,2)*kk(2,2))*a2(2,2)
11164 prod(2,1)=(a1(2,1)*kk(1,1)+a1(2,2)*kk(1,2))*a2(1,1)
11165 & +(a1(2,1)*kk(2,1)+a1(2,2)*kk(2,2))*a2(2,1)
11166 prod(2,2)=(a1(2,1)*kk(1,1)+a1(2,2)*kk(1,2))*a2(1,2)
11167 & +(a1(2,1)*kk(2,1)+a1(2,2)*kk(2,2))*a2(2,2)
11170 crc call matmat2(a1(1,1),kk(1,1),auxmat(1,1))
11171 crc call matmat2(auxmat(1,1),a2(1,1),prod_(1,1))
11173 prod(1,1)=(a1(1,1)*kk(1,1)+a1(1,2)*kk(2,1))*a2(1,1)
11174 & +(a1(1,1)*kk(1,2)+a1(1,2)*kk(2,2))*a2(2,1)
11175 prod(1,2)=(a1(1,1)*kk(1,1)+a1(1,2)*kk(2,1))*a2(1,2)
11176 & +(a1(1,1)*kk(1,2)+a1(1,2)*kk(2,2))*a2(2,2)
11177 prod(2,1)=(a1(2,1)*kk(1,1)+a1(2,2)*kk(2,1))*a2(1,1)
11178 & +(a1(2,1)*kk(1,2)+a1(2,2)*kk(2,2))*a2(2,1)
11179 prod(2,2)=(a1(2,1)*kk(1,1)+a1(2,2)*kk(2,1))*a2(1,2)
11180 & +(a1(2,1)*kk(1,2)+a1(2,2)*kk(2,2))*a2(2,2)
11183 c call transpose2(a2(1,1),a2t(1,1))
11186 crc print *,((prod_(i,j),i=1,2),j=1,2)
11187 crc print *,((prod(i,j),i=1,2),j=1,2)
11191 CCC----------------------------------------------
11192 subroutine Eliptransfer(eliptran)
11193 implicit real*8 (a-h,o-z)
11194 include 'DIMENSIONS'
11195 include 'COMMON.GEO'
11196 include 'COMMON.VAR'
11197 include 'COMMON.LOCAL'
11198 include 'COMMON.CHAIN'
11199 include 'COMMON.DERIV'
11200 include 'COMMON.NAMES'
11201 include 'COMMON.INTERACT'
11202 include 'COMMON.IOUNITS'
11203 include 'COMMON.CALC'
11204 include 'COMMON.CONTROL'
11205 include 'COMMON.SPLITELE'
11206 include 'COMMON.SBRIDGE'
11207 C this is done by Adasko
11208 C print *,"wchodze"
11209 C structure of box:
11211 C--bordliptop-- buffore starts
11212 C--bufliptop--- here true lipid starts
11214 C--buflipbot--- lipid ends buffore starts
11215 C--bordlipbot--buffore ends
11217 do i=ilip_start,ilip_end
11219 if (itype(i).eq.ntyp1) cycle
11221 positi=(mod(((c(3,i)+c(3,i+1))/2.0d0),boxzsize))
11222 if (positi.le.0.0) positi=positi+boxzsize
11224 C first for peptide groups
11225 c for each residue check if it is in lipid or lipid water border area
11226 if ((positi.gt.bordlipbot)
11227 &.and.(positi.lt.bordliptop)) then
11228 C the energy transfer exist
11229 if (positi.lt.buflipbot) then
11230 C what fraction I am in
11232 & ((positi-bordlipbot)/lipbufthick)
11233 C lipbufthick is thickenes of lipid buffore
11234 sslip=sscalelip(fracinbuf)
11235 ssgradlip=-sscagradlip(fracinbuf)/lipbufthick
11236 eliptran=eliptran+sslip*pepliptran
11237 gliptranc(3,i)=gliptranc(3,i)+ssgradlip*pepliptran/2.0d0
11238 gliptranc(3,i-1)=gliptranc(3,i-1)+ssgradlip*pepliptran/2.0d0
11239 C gliptranc(3,i-2)=gliptranc(3,i)+ssgradlip*pepliptran
11241 C print *,"doing sccale for lower part"
11242 C print *,i,sslip,fracinbuf,ssgradlip
11243 elseif (positi.gt.bufliptop) then
11244 fracinbuf=1.0d0-((bordliptop-positi)/lipbufthick)
11245 sslip=sscalelip(fracinbuf)
11246 ssgradlip=sscagradlip(fracinbuf)/lipbufthick
11247 eliptran=eliptran+sslip*pepliptran
11248 gliptranc(3,i)=gliptranc(3,i)+ssgradlip*pepliptran/2.0d0
11249 gliptranc(3,i-1)=gliptranc(3,i-1)+ssgradlip*pepliptran/2.0d0
11250 C gliptranc(3,i-2)=gliptranc(3,i)+ssgradlip*pepliptran
11251 C print *, "doing sscalefor top part"
11252 C print *,i,sslip,fracinbuf,ssgradlip
11254 eliptran=eliptran+pepliptran
11255 C print *,"I am in true lipid"
11258 C eliptran=elpitran+0.0 ! I am in water
11261 C print *, "nic nie bylo w lipidzie?"
11262 C now multiply all by the peptide group transfer factor
11263 C eliptran=eliptran*pepliptran
11264 C now the same for side chains
11266 do i=ilip_start,ilip_end
11267 if (itype(i).eq.ntyp1) cycle
11268 positi=(mod(c(3,i+nres),boxzsize))
11269 if (positi.le.0) positi=positi+boxzsize
11270 C print *,mod(c(3,i+nres),boxzsize),bordlipbot,bordliptop
11271 c for each residue check if it is in lipid or lipid water border area
11272 C respos=mod(c(3,i+nres),boxzsize)
11273 C print *,positi,bordlipbot,buflipbot
11274 if ((positi.gt.bordlipbot)
11275 & .and.(positi.lt.bordliptop)) then
11276 C the energy transfer exist
11277 if (positi.lt.buflipbot) then
11279 & ((positi-bordlipbot)/lipbufthick)
11280 C lipbufthick is thickenes of lipid buffore
11281 sslip=sscalelip(fracinbuf)
11282 ssgradlip=-sscagradlip(fracinbuf)/lipbufthick
11283 eliptran=eliptran+sslip*liptranene(itype(i))
11284 gliptranx(3,i)=gliptranx(3,i)
11285 &+ssgradlip*liptranene(itype(i))
11286 gliptranc(3,i-1)= gliptranc(3,i-1)
11287 &+ssgradlip*liptranene(itype(i))
11288 C print *,"doing sccale for lower part"
11289 elseif (positi.gt.bufliptop) then
11291 &((bordliptop-positi)/lipbufthick)
11292 sslip=sscalelip(fracinbuf)
11293 ssgradlip=sscagradlip(fracinbuf)/lipbufthick
11294 eliptran=eliptran+sslip*liptranene(itype(i))
11295 gliptranx(3,i)=gliptranx(3,i)
11296 &+ssgradlip*liptranene(itype(i))
11297 gliptranc(3,i-1)= gliptranc(3,i-1)
11298 &+ssgradlip*liptranene(itype(i))
11299 C print *, "doing sscalefor top part",sslip,fracinbuf
11301 eliptran=eliptran+liptranene(itype(i))
11302 C print *,"I am in true lipid"
11304 endif ! if in lipid or buffor
11306 C eliptran=elpitran+0.0 ! I am in water
11310 C---------------------------------------------------------
11311 C AFM soubroutine for constant force
11312 subroutine AFMforce(Eafmforce)
11313 implicit real*8 (a-h,o-z)
11314 include 'DIMENSIONS'
11315 include 'COMMON.GEO'
11316 include 'COMMON.VAR'
11317 include 'COMMON.LOCAL'
11318 include 'COMMON.CHAIN'
11319 include 'COMMON.DERIV'
11320 include 'COMMON.NAMES'
11321 include 'COMMON.INTERACT'
11322 include 'COMMON.IOUNITS'
11323 include 'COMMON.CALC'
11324 include 'COMMON.CONTROL'
11325 include 'COMMON.SPLITELE'
11326 include 'COMMON.SBRIDGE'
11331 diffafm(i)=c(i,afmend)-c(i,afmbeg)
11332 dist=dist+diffafm(i)**2
11335 Eafmforce=-forceAFMconst*(dist-distafminit)
11337 gradafm(i,afmend-1)=-forceAFMconst*diffafm(i)/dist
11338 gradafm(i,afmbeg-1)=forceAFMconst*diffafm(i)/dist
11340 C print *,'AFM',Eafmforce
11343 C---------------------------------------------------------
11344 C AFM subroutine with pseudoconstant velocity
11345 subroutine AFMvel(Eafmforce)
11346 implicit real*8 (a-h,o-z)
11347 include 'DIMENSIONS'
11348 include 'COMMON.GEO'
11349 include 'COMMON.VAR'
11350 include 'COMMON.LOCAL'
11351 include 'COMMON.CHAIN'
11352 include 'COMMON.DERIV'
11353 include 'COMMON.NAMES'
11354 include 'COMMON.INTERACT'
11355 include 'COMMON.IOUNITS'
11356 include 'COMMON.CALC'
11357 include 'COMMON.CONTROL'
11358 include 'COMMON.SPLITELE'
11359 include 'COMMON.SBRIDGE'
11361 C Only for check grad COMMENT if not used for checkgrad
11363 C--------------------------------------------------------
11364 C print *,"wchodze"
11368 diffafm(i)=c(i,afmend)-c(i,afmbeg)
11369 dist=dist+diffafm(i)**2
11372 Eafmforce=0.5d0*forceAFMconst
11373 & *(distafminit+totTafm*velAFMconst-dist)**2
11374 C Eafmforce=-forceAFMconst*(dist-distafminit)
11376 gradafm(i,afmend-1)=-forceAFMconst*
11377 &(distafminit+totTafm*velAFMconst-dist)
11379 gradafm(i,afmbeg-1)=forceAFMconst*
11380 &(distafminit+totTafm*velAFMconst-dist)
11383 C print *,'AFM',Eafmforce,totTafm*velAFMconst,dist
11386 C-----------------------------------------------------------
11387 C first for shielding is setting of function of side-chains
11388 subroutine set_shield_fac
11389 implicit real*8 (a-h,o-z)
11390 include 'DIMENSIONS'
11391 include 'COMMON.CHAIN'
11392 include 'COMMON.DERIV'
11393 include 'COMMON.IOUNITS'
11394 include 'COMMON.SHIELD'
11395 include 'COMMON.INTERACT'
11396 C this is the squar root 77 devided by 81 the epislion in lipid (in protein)
11397 double precision div77_81/0.974996043d0/,
11398 &div4_81/0.2222222222d0/,sh_frac_dist_grad(3)
11400 C the vector between center of side_chain and peptide group
11401 double precision pep_side(3),long,side_calf(3),
11402 &pept_group(3),costhet_grad(3),cosphi_grad_long(3),
11403 &cosphi_grad_loc(3),pep_side_norm(3),side_calf_norm(3)
11404 C the line belowe needs to be changed for FGPROC>1
11406 if ((itype(i).eq.ntyp1).and.itype(i+1).eq.ntyp1) cycle
11408 Cif there two consequtive dummy atoms there is no peptide group between them
11409 C the line below has to be changed for FGPROC>1
11412 if ((itype(k).eq.ntyp1).or.(itype(k).eq.10)) cycle
11416 C first lets set vector conecting the ithe side-chain with kth side-chain
11417 pep_side(j)=c(j,k+nres)-(c(j,i)+c(j,i+1))/2.0d0
11418 C pep_side(j)=2.0d0
11419 C and vector conecting the side-chain with its proper calfa
11420 side_calf(j)=c(j,k+nres)-c(j,k)
11421 C side_calf(j)=2.0d0
11422 pept_group(j)=c(j,i)-c(j,i+1)
11423 C lets have their lenght
11424 dist_pep_side=pep_side(j)**2+dist_pep_side
11425 dist_side_calf=dist_side_calf+side_calf(j)**2
11426 dist_pept_group=dist_pept_group+pept_group(j)**2
11428 dist_pep_side=dsqrt(dist_pep_side)
11429 dist_pept_group=dsqrt(dist_pept_group)
11430 dist_side_calf=dsqrt(dist_side_calf)
11432 pep_side_norm(j)=pep_side(j)/dist_pep_side
11433 side_calf_norm(j)=dist_side_calf
11435 C now sscale fraction
11436 sh_frac_dist=-(dist_pep_side-rpp(1,1)-buff_shield)/buff_shield
11437 C print *,buff_shield,"buff"
11439 if (sh_frac_dist.le.0.0) cycle
11440 C If we reach here it means that this side chain reaches the shielding sphere
11441 C Lets add him to the list for gradient
11442 ishield_list(i)=ishield_list(i)+1
11443 C ishield_list is a list of non 0 side-chain that contribute to factor gradient
11444 C this list is essential otherwise problem would be O3
11445 shield_list(ishield_list(i),i)=k
11446 C Lets have the sscale value
11447 if (sh_frac_dist.gt.1.0) then
11448 scale_fac_dist=1.0d0
11450 sh_frac_dist_grad(j)=0.0d0
11453 scale_fac_dist=-sh_frac_dist*sh_frac_dist
11454 & *(2.0*sh_frac_dist-3.0d0)
11455 fac_help_scale=6.0*(sh_frac_dist-sh_frac_dist**2)
11456 & /dist_pep_side/buff_shield*0.5
11457 C remember for the final gradient multiply sh_frac_dist_grad(j)
11458 C for side_chain by factor -2 !
11460 sh_frac_dist_grad(j)=fac_help_scale*pep_side(j)
11461 C print *,"jestem",scale_fac_dist,fac_help_scale,
11462 C & sh_frac_dist_grad(j)
11465 C if ((i.eq.3).and.(k.eq.2)) then
11466 C print *,i,sh_frac_dist,dist_pep,fac_help_scale,scale_fac_dist
11470 C this is what is now we have the distance scaling now volume...
11471 short=short_r_sidechain(itype(k))
11472 long=long_r_sidechain(itype(k))
11473 costhet=1.0d0/dsqrt(1.0+short**2/dist_pep_side**2)
11476 costhet_fac=costhet**3*short**2*(-0.5)/dist_pep_side**4
11477 C costhet_fac=0.0d0
11479 costhet_grad(j)=costhet_fac*pep_side(j)
11481 C remember for the final gradient multiply costhet_grad(j)
11482 C for side_chain by factor -2 !
11483 C fac alfa is angle between CB_k,CA_k, CA_i,CA_i+1
11484 C pep_side0pept_group is vector multiplication
11485 pep_side0pept_group=0.0
11487 pep_side0pept_group=pep_side0pept_group+pep_side(j)*side_calf(j)
11489 cosalfa=(pep_side0pept_group/
11490 & (dist_pep_side*dist_side_calf))
11491 fac_alfa_sin=1.0-cosalfa**2
11492 fac_alfa_sin=dsqrt(fac_alfa_sin)
11493 rkprim=fac_alfa_sin*(long-short)+short
11495 cosphi=1.0d0/dsqrt(1.0+rkprim**2/dist_pep_side**2)
11496 cosphi_fac=cosphi**3*rkprim**2*(-0.5)/dist_pep_side**4
11499 cosphi_grad_long(j)=cosphi_fac*pep_side(j)
11500 &+cosphi**3*0.5/dist_pep_side**2*(-rkprim)
11501 &*(long-short)/fac_alfa_sin*cosalfa/
11502 &((dist_pep_side*dist_side_calf))*
11503 &((side_calf(j))-cosalfa*
11504 &((pep_side(j)/dist_pep_side)*dist_side_calf))
11506 cosphi_grad_loc(j)=cosphi**3*0.5/dist_pep_side**2*(-rkprim)
11507 &*(long-short)/fac_alfa_sin*cosalfa
11508 &/((dist_pep_side*dist_side_calf))*
11510 &cosalfa*side_calf(j)/dist_side_calf*dist_pep_side)
11513 VofOverlap=VSolvSphere/2.0d0*(1.0-costhet)*(1.0-cosphi)
11516 C now the gradient...
11517 C grad_shield is gradient of Calfa for peptide groups
11518 C write(iout,*) "shield_compon",i,k,VSolvSphere,scale_fac_dist,
11520 C write(iout,*) "cosphi_compon",i,k,pep_side0pept_group,
11521 C & dist_pep_side,dist_side_calf,c(1,k+nres),c(1,k),itype(k)
11523 grad_shield(j,i)=grad_shield(j,i)
11524 C gradient po skalowaniu
11525 & +(sh_frac_dist_grad(j)
11526 C gradient po costhet
11527 &-scale_fac_dist*costhet_grad(j)/(1.0-costhet)
11528 &-scale_fac_dist*(cosphi_grad_long(j))
11529 &/(1.0-cosphi) )*div77_81
11531 C grad_shield_side is Cbeta sidechain gradient
11532 grad_shield_side(j,ishield_list(i),i)=
11533 & (sh_frac_dist_grad(j)*(-2.0d0)
11534 & +scale_fac_dist*costhet_grad(j)*2.0d0/(1.0-costhet)
11535 & +scale_fac_dist*(cosphi_grad_long(j))
11536 & *2.0d0/(1.0-cosphi))
11537 & *div77_81*VofOverlap
11539 grad_shield_loc(j,ishield_list(i),i)=
11540 & scale_fac_dist*cosphi_grad_loc(j)
11541 & *2.0d0/(1.0-cosphi)
11542 & *div77_81*VofOverlap
11544 VolumeTotal=VolumeTotal+VofOverlap*scale_fac_dist
11546 fac_shield(i)=VolumeTotal*div77_81+div4_81
11547 c write(2,*) "TOTAL VOLUME",i,VolumeTotal,fac_shield(i)
11551 C--------------------------------------------------------------------------
11552 double precision function tschebyshev(m,n,x,y)
11554 include "DIMENSIONS"
11556 double precision x(n),y,yy(0:maxvar),aux
11557 c Tschebyshev polynomial. Note that the first term is omitted
11558 c m=0: the constant term is included
11559 c m=1: the constant term is not included
11563 yy(i)=2*yy(1)*yy(i-1)-yy(i-2)
11572 C--------------------------------------------------------------------------
11573 double precision function gradtschebyshev(m,n,x,y)
11575 include "DIMENSIONS"
11577 double precision x(n+1),y,yy(0:maxvar),aux
11578 c Tschebyshev polynomial. Note that the first term is omitted
11579 c m=0: the constant term is included
11580 c m=1: the constant term is not included
11584 yy(i)=2*y*yy(i-1)-yy(i-2)
11588 aux=aux+x(i+1)*yy(i)*(i+1)
11589 C print *, x(i+1),yy(i),i
11591 gradtschebyshev=aux
11594 C------------------------------------------------------------------------
11595 C first for shielding is setting of function of side-chains
11596 subroutine set_shield_fac2
11597 implicit real*8 (a-h,o-z)
11598 include 'DIMENSIONS'
11599 include 'COMMON.CHAIN'
11600 include 'COMMON.DERIV'
11601 include 'COMMON.IOUNITS'
11602 include 'COMMON.SHIELD'
11603 include 'COMMON.INTERACT'
11604 C this is the squar root 77 devided by 81 the epislion in lipid (in protein)
11605 double precision div77_81/0.974996043d0/,
11606 &div4_81/0.2222222222d0/,sh_frac_dist_grad(3)
11608 C the vector between center of side_chain and peptide group
11609 double precision pep_side(3),long,side_calf(3),
11610 &pept_group(3),costhet_grad(3),cosphi_grad_long(3),
11611 &cosphi_grad_loc(3),pep_side_norm(3),side_calf_norm(3)
11612 C the line belowe needs to be changed for FGPROC>1
11614 if ((itype(i).eq.ntyp1).and.itype(i+1).eq.ntyp1) cycle
11616 Cif there two consequtive dummy atoms there is no peptide group between them
11617 C the line below has to be changed for FGPROC>1
11620 if ((itype(k).eq.ntyp1).or.(itype(k).eq.10)) cycle
11624 C first lets set vector conecting the ithe side-chain with kth side-chain
11625 pep_side(j)=c(j,k+nres)-(c(j,i)+c(j,i+1))/2.0d0
11626 C pep_side(j)=2.0d0
11627 C and vector conecting the side-chain with its proper calfa
11628 side_calf(j)=c(j,k+nres)-c(j,k)
11629 C side_calf(j)=2.0d0
11630 pept_group(j)=c(j,i)-c(j,i+1)
11631 C lets have their lenght
11632 dist_pep_side=pep_side(j)**2+dist_pep_side
11633 dist_side_calf=dist_side_calf+side_calf(j)**2
11634 dist_pept_group=dist_pept_group+pept_group(j)**2
11636 dist_pep_side=dsqrt(dist_pep_side)
11637 dist_pept_group=dsqrt(dist_pept_group)
11638 dist_side_calf=dsqrt(dist_side_calf)
11640 pep_side_norm(j)=pep_side(j)/dist_pep_side
11641 side_calf_norm(j)=dist_side_calf
11643 C now sscale fraction
11644 sh_frac_dist=-(dist_pep_side-rpp(1,1)-buff_shield)/buff_shield
11645 C print *,buff_shield,"buff"
11647 if (sh_frac_dist.le.0.0) cycle
11648 C If we reach here it means that this side chain reaches the shielding sphere
11649 C Lets add him to the list for gradient
11650 ishield_list(i)=ishield_list(i)+1
11651 C ishield_list is a list of non 0 side-chain that contribute to factor gradient
11652 C this list is essential otherwise problem would be O3
11653 shield_list(ishield_list(i),i)=k
11654 C Lets have the sscale value
11655 if (sh_frac_dist.gt.1.0) then
11656 scale_fac_dist=1.0d0
11658 sh_frac_dist_grad(j)=0.0d0
11661 scale_fac_dist=-sh_frac_dist*sh_frac_dist
11662 & *(2.0d0*sh_frac_dist-3.0d0)
11663 fac_help_scale=6.0d0*(sh_frac_dist-sh_frac_dist**2)
11664 & /dist_pep_side/buff_shield*0.5d0
11665 C remember for the final gradient multiply sh_frac_dist_grad(j)
11666 C for side_chain by factor -2 !
11668 sh_frac_dist_grad(j)=fac_help_scale*pep_side(j)
11669 C sh_frac_dist_grad(j)=0.0d0
11670 C scale_fac_dist=1.0d0
11671 C print *,"jestem",scale_fac_dist,fac_help_scale,
11672 C & sh_frac_dist_grad(j)
11675 C this is what is now we have the distance scaling now volume...
11676 short=short_r_sidechain(itype(k))
11677 long=long_r_sidechain(itype(k))
11678 costhet=1.0d0/dsqrt(1.0d0+short**2/dist_pep_side**2)
11679 sinthet=short/dist_pep_side*costhet
11683 costhet_fac=costhet**3*short**2*(-0.5d0)/dist_pep_side**4
11684 C sinthet_fac=costhet**2*0.5d0*(short**3/dist_pep_side**4*costhet
11685 C & -short/dist_pep_side**2/costhet)
11686 C costhet_fac=0.0d0
11688 costhet_grad(j)=costhet_fac*pep_side(j)
11690 C remember for the final gradient multiply costhet_grad(j)
11691 C for side_chain by factor -2 !
11692 C fac alfa is angle between CB_k,CA_k, CA_i,CA_i+1
11693 C pep_side0pept_group is vector multiplication
11694 pep_side0pept_group=0.0d0
11696 pep_side0pept_group=pep_side0pept_group+pep_side(j)*side_calf(j)
11698 cosalfa=(pep_side0pept_group/
11699 & (dist_pep_side*dist_side_calf))
11700 fac_alfa_sin=1.0d0-cosalfa**2
11701 fac_alfa_sin=dsqrt(fac_alfa_sin)
11702 rkprim=fac_alfa_sin*(long-short)+short
11706 cosphi=1.0d0/dsqrt(1.0d0+rkprim**2/dist_pep_side**2)
11708 cosphi_fac=cosphi**3*rkprim**2*(-0.5d0)/dist_pep_side**4
11709 sinphi=rkprim/dist_pep_side/dsqrt(1.0d0+rkprim**2/
11710 & dist_pep_side**2)
11713 cosphi_grad_long(j)=cosphi_fac*pep_side(j)
11714 &+cosphi**3*0.5d0/dist_pep_side**2*(-rkprim)
11715 &*(long-short)/fac_alfa_sin*cosalfa/
11716 &((dist_pep_side*dist_side_calf))*
11717 &((side_calf(j))-cosalfa*
11718 &((pep_side(j)/dist_pep_side)*dist_side_calf))
11719 C cosphi_grad_long(j)=0.0d0
11720 cosphi_grad_loc(j)=cosphi**3*0.5d0/dist_pep_side**2*(-rkprim)
11721 &*(long-short)/fac_alfa_sin*cosalfa
11722 &/((dist_pep_side*dist_side_calf))*
11724 &cosalfa*side_calf(j)/dist_side_calf*dist_pep_side)
11725 C cosphi_grad_loc(j)=0.0d0
11727 C print *,sinphi,sinthet
11728 c write (iout,*) "VSolvSphere",VSolvSphere," VSolvSphere_div",
11729 c & VSolvSphere_div," sinphi",sinphi," sinthet",sinthet
11730 VofOverlap=VSolvSphere/2.0d0*(1.0d0-dsqrt(1.0d0-sinphi*sinthet))
11733 C now the gradient...
11735 grad_shield(j,i)=grad_shield(j,i)
11736 C gradient po skalowaniu
11737 & +(sh_frac_dist_grad(j)*VofOverlap
11738 C gradient po costhet
11739 & +scale_fac_dist*VSolvSphere/VSolvSphere_div/4.0d0*
11740 &(1.0d0/(-dsqrt(1.0d0-sinphi*sinthet))*(
11741 & sinphi/sinthet*costhet*costhet_grad(j)
11742 & +sinthet/sinphi*cosphi*cosphi_grad_long(j)))
11744 C grad_shield_side is Cbeta sidechain gradient
11745 grad_shield_side(j,ishield_list(i),i)=
11746 & (sh_frac_dist_grad(j)*(-2.0d0)
11748 & -scale_fac_dist*VSolvSphere/VSolvSphere_div/2.0d0*
11749 &(1.0d0/(-dsqrt(1.0d0-sinphi*sinthet))*(
11750 & sinphi/sinthet*costhet*costhet_grad(j)
11751 & +sinthet/sinphi*cosphi*cosphi_grad_long(j)))
11754 grad_shield_loc(j,ishield_list(i),i)=
11755 & scale_fac_dist*VSolvSphere/VSolvSphere_div/2.0d0*
11756 &(1.0d0/(dsqrt(1.0d0-sinphi*sinthet))*(
11757 & sinthet/sinphi*cosphi*cosphi_grad_loc(j)
11761 c write (iout,*) "VofOverlap",VofOverlap," scale_fac_dist",
11763 VolumeTotal=VolumeTotal+VofOverlap*scale_fac_dist
11765 fac_shield(i)=VolumeTotal*wshield+(1.0d0-wshield)
11766 c write(2,*) "TOTAL VOLUME",i,VolumeTotal,fac_shield(i),
11767 c & " wshield",wshield
11768 c write(2,*) "TU",rpp(1,1),short,long,buff_shield
11772 C-----------------------------------------------------------------------
11773 C-----------------------------------------------------------
11774 C This subroutine is to mimic the histone like structure but as well can be
11775 C utilizet to nanostructures (infinit) small modification has to be used to
11776 C make it finite (z gradient at the ends has to be changes as well as the x,y
11777 C gradient has to be modified at the ends
11778 C The energy function is Kihara potential
11779 C E=4esp*((sigma/(r-r0))^12 - (sigma/(r-r0))^6)
11780 C 4eps is depth of well sigma is r_minimum r is distance from center of tube
11781 C and r0 is the excluded size of nanotube (can be set to 0 if we want just a
11782 C simple Kihara potential
11783 subroutine calctube(Etube)
11784 implicit real*8 (a-h,o-z)
11785 include 'DIMENSIONS'
11786 include 'COMMON.GEO'
11787 include 'COMMON.VAR'
11788 include 'COMMON.LOCAL'
11789 include 'COMMON.CHAIN'
11790 include 'COMMON.DERIV'
11791 include 'COMMON.NAMES'
11792 include 'COMMON.INTERACT'
11793 include 'COMMON.IOUNITS'
11794 include 'COMMON.CALC'
11795 include 'COMMON.CONTROL'
11796 include 'COMMON.SPLITELE'
11797 include 'COMMON.SBRIDGE'
11798 double precision tub_r,vectube(3),enetube(maxres*2)
11803 C first we calculate the distance from tube center
11804 C first sugare-phosphate group for NARES this would be peptide group
11807 C lets ommit dummy atoms for now
11808 if ((itype(i).eq.ntyp1).or.(itype(i+1).eq.ntyp1)) cycle
11809 C now calculate distance from center of tube and direction vectors
11810 vectube(1)=mod((c(1,i)+c(1,i+1))/2.0d0,boxxsize)
11811 if (vectube(1).lt.0) vectube(1)=vectube(1)+boxxsize
11812 vectube(2)=mod((c(2,i)+c(2,i+1))/2.0d0,boxxsize)
11813 if (vectube(2).lt.0) vectube(2)=vectube(2)+boxxsize
11814 vectube(1)=vectube(1)-tubecenter(1)
11815 vectube(2)=vectube(2)-tubecenter(2)
11817 C print *,"x",(c(1,i)+c(1,i+1))/2.0d0,tubecenter(1)
11818 C print *,"y",(c(2,i)+c(2,i+1))/2.0d0,tubecenter(2)
11820 C as the tube is infinity we do not calculate the Z-vector use of Z
11823 C now calculte the distance
11824 tub_r=dsqrt(vectube(1)**2+vectube(2)**2+vectube(3)**2)
11825 C now normalize vector
11826 vectube(1)=vectube(1)/tub_r
11827 vectube(2)=vectube(2)/tub_r
11828 C calculte rdiffrence between r and r0
11831 rdiff6=rdiff**6.0d0
11832 C for vectorization reasons we will sumup at the end to avoid depenence of previous
11833 enetube(i)=pep_aa_tube/rdiff6**2.0d0-pep_bb_tube/rdiff6
11834 C write(iout,*) "TU13",i,rdiff6,enetube(i)
11835 C print *,rdiff,rdiff6,pep_aa_tube
11836 C pep_aa_tube and pep_bb_tube are precomputed values A=4eps*sigma^12 B=4eps*sigma^6
11837 C now we calculate gradient
11838 fac=(-12.0d0*pep_aa_tube/rdiff6+
11839 & 6.0d0*pep_bb_tube)/rdiff6/rdiff
11840 C write(iout,'(a5,i4,f12.1,3f12.5)') "TU13",i,rdiff6,enetube(i),
11843 C now direction of gg_tube vector
11845 gg_tube(j,i-1)=gg_tube(j,i-1)+vectube(j)*fac/2.0d0
11846 gg_tube(j,i)=gg_tube(j,i)+vectube(j)*fac/2.0d0
11849 C basically thats all code now we split for side-chains (REMEMBER to sum up at the END)
11851 C Lets not jump over memory as we use many times iti
11853 C lets ommit dummy atoms for now
11855 C in UNRES uncomment the line below as GLY has no side-chain...
11858 vectube(1)=c(1,i+nres)
11859 vectube(1)=mod(vectube(1),boxxsize)
11860 if (vectube(1).lt.0) vectube(1)=vectube(1)+boxxsize
11861 vectube(2)=c(2,i+nres)
11862 vectube(2)=mod(vectube(2),boxxsize)
11863 if (vectube(2).lt.0) vectube(2)=vectube(2)+boxxsize
11865 vectube(1)=vectube(1)-tubecenter(1)
11866 vectube(2)=vectube(2)-tubecenter(2)
11868 C as the tube is infinity we do not calculate the Z-vector use of Z
11871 C now calculte the distance
11872 tub_r=dsqrt(vectube(1)**2+vectube(2)**2+vectube(3)**2)
11873 C now normalize vector
11874 vectube(1)=vectube(1)/tub_r
11875 vectube(2)=vectube(2)/tub_r
11876 C calculte rdiffrence between r and r0
11879 rdiff6=rdiff**6.0d0
11880 C for vectorization reasons we will sumup at the end to avoid depenence of previous
11881 sc_aa_tube=sc_aa_tube_par(iti)
11882 sc_bb_tube=sc_bb_tube_par(iti)
11883 enetube(i+nres)=sc_aa_tube/rdiff6**2.0d0-sc_bb_tube/rdiff6
11884 C pep_aa_tube and pep_bb_tube are precomputed values A=4eps*sigma^12 B=4eps*sigma^6
11885 C now we calculate gradient
11886 fac=-12.0d0*sc_aa_tube/rdiff6**2.0d0/rdiff+
11887 & 6.0d0*sc_bb_tube/rdiff6/rdiff
11888 C now direction of gg_tube vector
11890 gg_tube_SC(j,i)=gg_tube_SC(j,i)+vectube(j)*fac
11891 gg_tube(j,i-1)=gg_tube(j,i-1)+vectube(j)*fac
11895 Etube=Etube+enetube(i)
11897 C print *,"ETUBE", etube
11900 C TO DO 1) add to total energy
11901 C 2) add to gradient summation
11902 C 3) add reading parameters (AND of course oppening of PARAM file)
11903 C 4) add reading the center of tube
11905 C 6) add to zerograd
11907 C-----------------------------------------------------------------------
11908 C-----------------------------------------------------------
11909 C This subroutine is to mimic the histone like structure but as well can be
11910 C utilizet to nanostructures (infinit) small modification has to be used to
11911 C make it finite (z gradient at the ends has to be changes as well as the x,y
11912 C gradient has to be modified at the ends
11913 C The energy function is Kihara potential
11914 C E=4esp*((sigma/(r-r0))^12 - (sigma/(r-r0))^6)
11915 C 4eps is depth of well sigma is r_minimum r is distance from center of tube
11916 C and r0 is the excluded size of nanotube (can be set to 0 if we want just a
11917 C simple Kihara potential
11918 subroutine calctube2(Etube)
11919 implicit real*8 (a-h,o-z)
11920 include 'DIMENSIONS'
11921 include 'COMMON.GEO'
11922 include 'COMMON.VAR'
11923 include 'COMMON.LOCAL'
11924 include 'COMMON.CHAIN'
11925 include 'COMMON.DERIV'
11926 include 'COMMON.NAMES'
11927 include 'COMMON.INTERACT'
11928 include 'COMMON.IOUNITS'
11929 include 'COMMON.CALC'
11930 include 'COMMON.CONTROL'
11931 include 'COMMON.SPLITELE'
11932 include 'COMMON.SBRIDGE'
11933 double precision tub_r,vectube(3),enetube(maxres*2)
11938 C first we calculate the distance from tube center
11939 C first sugare-phosphate group for NARES this would be peptide group
11942 C lets ommit dummy atoms for now
11943 if ((itype(i).eq.ntyp1).or.(itype(i+1).eq.ntyp1)) cycle
11944 C now calculate distance from center of tube and direction vectors
11945 vectube(1)=mod((c(1,i)+c(1,i+1))/2.0d0,boxxsize)
11946 if (vectube(1).lt.0) vectube(1)=vectube(1)+boxxsize
11947 vectube(2)=mod((c(2,i)+c(2,i+1))/2.0d0,boxxsize)
11948 if (vectube(2).lt.0) vectube(2)=vectube(2)+boxxsize
11949 vectube(1)=vectube(1)-tubecenter(1)
11950 vectube(2)=vectube(2)-tubecenter(2)
11952 C print *,"x",(c(1,i)+c(1,i+1))/2.0d0,tubecenter(1)
11953 C print *,"y",(c(2,i)+c(2,i+1))/2.0d0,tubecenter(2)
11955 C as the tube is infinity we do not calculate the Z-vector use of Z
11958 C now calculte the distance
11959 tub_r=dsqrt(vectube(1)**2+vectube(2)**2+vectube(3)**2)
11960 C now normalize vector
11961 vectube(1)=vectube(1)/tub_r
11962 vectube(2)=vectube(2)/tub_r
11963 C calculte rdiffrence between r and r0
11966 rdiff6=rdiff**6.0d0
11967 C for vectorization reasons we will sumup at the end to avoid depenence of previous
11968 enetube(i)=pep_aa_tube/rdiff6**2.0d0-pep_bb_tube/rdiff6
11969 C write(iout,*) "TU13",i,rdiff6,enetube(i)
11970 C print *,rdiff,rdiff6,pep_aa_tube
11971 C pep_aa_tube and pep_bb_tube are precomputed values A=4eps*sigma^12 B=4eps*sigma^6
11972 C now we calculate gradient
11973 fac=(-12.0d0*pep_aa_tube/rdiff6+
11974 & 6.0d0*pep_bb_tube)/rdiff6/rdiff
11975 C write(iout,'(a5,i4,f12.1,3f12.5)') "TU13",i,rdiff6,enetube(i),
11978 C now direction of gg_tube vector
11980 gg_tube(j,i-1)=gg_tube(j,i-1)+vectube(j)*fac/2.0d0
11981 gg_tube(j,i)=gg_tube(j,i)+vectube(j)*fac/2.0d0
11984 C basically thats all code now we split for side-chains (REMEMBER to sum up at the END)
11986 C Lets not jump over memory as we use many times iti
11988 C lets ommit dummy atoms for now
11990 C in UNRES uncomment the line below as GLY has no side-chain...
11993 vectube(1)=c(1,i+nres)
11994 vectube(1)=mod(vectube(1),boxxsize)
11995 if (vectube(1).lt.0) vectube(1)=vectube(1)+boxxsize
11996 vectube(2)=c(2,i+nres)
11997 vectube(2)=mod(vectube(2),boxxsize)
11998 if (vectube(2).lt.0) vectube(2)=vectube(2)+boxxsize
12000 vectube(1)=vectube(1)-tubecenter(1)
12001 vectube(2)=vectube(2)-tubecenter(2)
12002 C THIS FRAGMENT MAKES TUBE FINITE
12003 positi=(mod(c(3,i+nres),boxzsize))
12004 if (positi.le.0) positi=positi+boxzsize
12005 C print *,mod(c(3,i+nres),boxzsize),bordlipbot,bordliptop
12006 c for each residue check if it is in lipid or lipid water border area
12007 C respos=mod(c(3,i+nres),boxzsize)
12008 print *,positi,bordtubebot,buftubebot,bordtubetop
12009 if ((positi.gt.bordtubebot)
12010 & .and.(positi.lt.bordtubetop)) then
12011 C the energy transfer exist
12012 if (positi.lt.buftubebot) then
12014 & ((positi-bordtubebot)/tubebufthick)
12015 C lipbufthick is thickenes of lipid buffore
12016 sstube=sscalelip(fracinbuf)
12017 ssgradtube=-sscagradlip(fracinbuf)/tubebufthick
12018 print *,ssgradtube, sstube,tubetranene(itype(i))
12019 enetube(i+nres)=enetube(i+nres)+sstube*tubetranene(itype(i))
12020 gg_tube_SC(3,i)=gg_tube_SC(3,i)
12021 &+ssgradtube*tubetranene(itype(i))
12022 gg_tube(3,i-1)= gg_tube(3,i-1)
12023 &+ssgradtube*tubetranene(itype(i))
12024 C print *,"doing sccale for lower part"
12025 elseif (positi.gt.buftubetop) then
12027 &((bordtubetop-positi)/tubebufthick)
12028 sstube=sscalelip(fracinbuf)
12029 ssgradtube=sscagradlip(fracinbuf)/tubebufthick
12030 enetube(i+nres)=enetube(i+nres)+sstube*tubetranene(itype(i))
12031 C gg_tube_SC(3,i)=gg_tube_SC(3,i)
12032 C &+ssgradtube*tubetranene(itype(i))
12033 C gg_tube(3,i-1)= gg_tube(3,i-1)
12034 C &+ssgradtube*tubetranene(itype(i))
12035 C print *, "doing sscalefor top part",sslip,fracinbuf
12039 enetube(i+nres)=enetube(i+nres)+sstube*tubetranene(itype(i))
12040 C print *,"I am in true lipid"
12046 endif ! if in lipid or buffor
12047 CEND OF FINITE FRAGMENT
12048 C as the tube is infinity we do not calculate the Z-vector use of Z
12051 C now calculte the distance
12052 tub_r=dsqrt(vectube(1)**2+vectube(2)**2+vectube(3)**2)
12053 C now normalize vector
12054 vectube(1)=vectube(1)/tub_r
12055 vectube(2)=vectube(2)/tub_r
12056 C calculte rdiffrence between r and r0
12059 rdiff6=rdiff**6.0d0
12060 C for vectorization reasons we will sumup at the end to avoid depenence of previous
12061 sc_aa_tube=sc_aa_tube_par(iti)
12062 sc_bb_tube=sc_bb_tube_par(iti)
12063 enetube(i+nres)=(sc_aa_tube/rdiff6**2.0d0-sc_bb_tube/rdiff6)
12064 & *sstube+enetube(i+nres)
12065 C pep_aa_tube and pep_bb_tube are precomputed values A=4eps*sigma^12 B=4eps*sigma^6
12066 C now we calculate gradient
12067 fac=(-12.0d0*sc_aa_tube/rdiff6**2.0d0/rdiff+
12068 & 6.0d0*sc_bb_tube/rdiff6/rdiff)*sstube
12069 C now direction of gg_tube vector
12071 gg_tube_SC(j,i)=gg_tube_SC(j,i)+vectube(j)*fac
12072 gg_tube(j,i-1)=gg_tube(j,i-1)+vectube(j)*fac
12074 gg_tube_SC(3,i)=gg_tube_SC(3,i)
12075 &+ssgradtube*enetube(i+nres)/sstube
12076 gg_tube(3,i-1)= gg_tube(3,i-1)
12077 &+ssgradtube*enetube(i+nres)/sstube
12081 Etube=Etube+enetube(i)
12083 C print *,"ETUBE", etube
12086 C TO DO 1) add to total energy
12087 C 2) add to gradient summation
12088 C 3) add reading parameters (AND of course oppening of PARAM file)
12089 C 4) add reading the center of tube
12091 C 6) add to zerograd
12092 c----------------------------------------------------------------------------
12093 subroutine e_saxs(Esaxs_constr)
12095 include 'DIMENSIONS'
12098 include "COMMON.SETUP"
12101 include 'COMMON.SBRIDGE'
12102 include 'COMMON.CHAIN'
12103 include 'COMMON.GEO'
12104 include 'COMMON.DERIV'
12105 include 'COMMON.LOCAL'
12106 include 'COMMON.INTERACT'
12107 include 'COMMON.VAR'
12108 include 'COMMON.IOUNITS'
12109 include 'COMMON.MD'
12110 include 'COMMON.CONTROL'
12111 include 'COMMON.NAMES'
12112 include 'COMMON.TIME1'
12113 include 'COMMON.FFIELD'
12115 double precision Esaxs_constr
12116 integer i,iint,j,k,l
12117 double precision PgradC(maxSAXS,3,maxres),
12118 & PgradX(maxSAXS,3,maxres),Pcalc(maxSAXS)
12120 double precision PgradC_(maxSAXS,3,maxres),
12121 & PgradX_(maxSAXS,3,maxres),Pcalc_(maxSAXS)
12123 double precision dk,dijCACA,dijCASC,dijSCCA,dijSCSC,
12124 & sigma2CACA,sigma2CASC,sigma2SCCA,sigma2SCSC,expCACA,expCASC,
12125 & expSCCA,expSCSC,CASCgrad,SCCAgrad,SCSCgrad,aux,auxC,auxC1,
12126 & auxX,auxX1,CACAgrad,Cnorm,sigmaCACA,threesig
12127 double precision sss2,ssgrad2,rrr,sscalgrad2,sscale2
12128 double precision dist,mygauss,mygaussder
12130 integer llicz,lllicz
12131 double precision time01
12132 c SAXS restraint penalty function
12134 write(iout,*) "------- SAXS penalty function start -------"
12135 write (iout,*) "nsaxs",nsaxs
12136 write (iout,*) "Esaxs: iatsc_s",iatsc_s," iatsc_e",iatsc_e
12137 write (iout,*) "Psaxs"
12139 write (iout,'(i5,e15.5)') i, Psaxs(i)
12145 Esaxs_constr = 0.0d0
12150 PgradC(k,l,j)=0.0d0
12151 PgradX(k,l,j)=0.0d0
12156 do i=iatsc_s,iatsc_e
12157 if (itype(i).eq.ntyp1) cycle
12158 do iint=1,nint_gr(i)
12159 do j=istart(i,iint),iend(i,iint)
12160 if (itype(j).eq.ntyp1) cycle
12163 dijCASC=dist(i,j+nres)
12164 dijSCCA=dist(i+nres,j)
12165 dijSCSC=dist(i+nres,j+nres)
12166 sigma2CACA=2.0d0/(pstok**2)
12167 sigma2CASC=4.0d0/(pstok**2+restok(itype(j))**2)
12168 sigma2SCCA=4.0d0/(pstok**2+restok(itype(i))**2)
12169 sigma2SCSC=4.0d0/(restok(itype(j))**2+restok(itype(i))**2)
12172 expCACA = dexp(-0.5d0*sigma2CACA*(dijCACA-dk)**2)
12173 if (itype(j).ne.10) then
12174 expCASC = dexp(-0.5d0*sigma2CASC*(dijCASC-dk)**2)
12178 if (itype(i).ne.10) then
12179 expSCCA = dexp(-0.5d0*sigma2SCCA*(dijSCCA-dk)**2)
12183 if (itype(i).ne.10 .and. itype(j).ne.10) then
12184 expSCSC = dexp(-0.5d0*sigma2SCSC*(dijSCSC-dk)**2)
12188 Pcalc(k) = Pcalc(k)+expCACA+expCASC+expSCCA+expSCSC
12190 write(iout,*) "i j k Pcalc",i,j,Pcalc(k)
12192 CACAgrad = sigma2CACA*(dijCACA-dk)*expCACA
12193 CASCgrad = sigma2CASC*(dijCASC-dk)*expCASC
12194 SCCAgrad = sigma2SCCA*(dijSCCA-dk)*expSCCA
12195 SCSCgrad = sigma2SCSC*(dijSCSC-dk)*expSCSC
12198 aux = CACAgrad*(C(l,j)-C(l,i))/dijCACA
12199 PgradC(k,l,i) = PgradC(k,l,i)-aux
12200 PgradC(k,l,j) = PgradC(k,l,j)+aux
12202 if (itype(j).ne.10) then
12203 aux = CASCgrad*(C(l,j+nres)-C(l,i))/dijCASC
12204 PgradC(k,l,i) = PgradC(k,l,i)-aux
12205 PgradC(k,l,j) = PgradC(k,l,j)+aux
12206 PgradX(k,l,j) = PgradX(k,l,j)+aux
12209 if (itype(i).ne.10) then
12210 aux = SCCAgrad*(C(l,j)-C(l,i+nres))/dijSCCA
12211 PgradX(k,l,i) = PgradX(k,l,i)-aux
12212 PgradC(k,l,i) = PgradC(k,l,i)-aux
12213 PgradC(k,l,j) = PgradC(k,l,j)+aux
12216 if (itype(i).ne.10 .and. itype(j).ne.10) then
12217 aux = SCSCgrad*(C(l,j+nres)-C(l,i+nres))/dijSCSC
12218 PgradC(k,l,i) = PgradC(k,l,i)-aux
12219 PgradC(k,l,j) = PgradC(k,l,j)+aux
12220 PgradX(k,l,i) = PgradX(k,l,i)-aux
12221 PgradX(k,l,j) = PgradX(k,l,j)+aux
12227 sigma2CACA=scal_rad**2*0.25d0/
12228 & (restok(itype(j))**2+restok(itype(i))**2)
12229 c write (iout,*) "scal_rad",scal_rad," restok",restok(itype(j))
12230 c & ,restok(itype(i)),"sigma",1.0d0/dsqrt(sigma2CACA)
12232 sigmaCACA=dsqrt(sigma2CACA)
12233 threesig=3.0d0/sigmaCACA
12237 if (dabs(dijCACA-dk).ge.threesig) cycle
12240 aux = sigmaCACA*(dijCACA-dk)
12241 expCACA = mygauss(aux)
12242 c if (expcaca.eq.0.0d0) cycle
12243 Pcalc(k) = Pcalc(k)+expCACA
12244 CACAgrad = -sigmaCACA*mygaussder(aux)
12245 c write (iout,*) "i,j,k,aux",i,j,k,CACAgrad
12247 aux = CACAgrad*(C(l,j)-C(l,i))/dijCACA
12248 PgradC(k,l,i) = PgradC(k,l,i)-aux
12249 PgradC(k,l,j) = PgradC(k,l,j)+aux
12252 c write (iout,*) "i",i," j",j," llicz",llicz
12254 IF (saxs_cutoff.eq.0) THEN
12257 expCACA = dexp(-0.5d0*sigma2CACA*(dijCACA-dk)**2)
12258 Pcalc(k) = Pcalc(k)+expCACA
12259 CACAgrad = sigma2CACA*(dijCACA-dk)*expCACA
12261 aux = CACAgrad*(C(l,j)-C(l,i))/dijCACA
12262 PgradC(k,l,i) = PgradC(k,l,i)-aux
12263 PgradC(k,l,j) = PgradC(k,l,j)+aux
12267 rrr = saxs_cutoff*2.0d0/dsqrt(sigma2CACA)
12270 c write (2,*) "ijk",i,j,k
12271 sss2 = sscale2(dijCACA,rrr,dk,0.3d0)
12272 if (sss2.eq.0.0d0) cycle
12273 ssgrad2 = sscalgrad2(dijCACA,rrr,dk,0.3d0)
12274 if (energy_dec) write(iout,'(a4,3i5,8f10.4)')
12275 & 'saxs',i,j,k,dijCACA,restok(itype(i)),restok(itype(j)),
12276 & 1.0d0/dsqrt(sigma2CACA),rrr,dk,
12278 expCACA = dexp(-0.5d0*sigma2CACA*(dijCACA-dk)**2)*sss2
12279 Pcalc(k) = Pcalc(k)+expCACA
12281 write(iout,*) "i j k Pcalc",i,j,Pcalc(k)
12283 CACAgrad = -sigma2CACA*(dijCACA-dk)*expCACA+
12284 & ssgrad2*expCACA/sss2
12287 aux = CACAgrad*(C(l,j)-C(l,i))/dijCACA
12288 PgradC(k,l,i) = PgradC(k,l,i)+aux
12289 PgradC(k,l,j) = PgradC(k,l,j)-aux
12299 c time_SAXS=time_SAXS+MPI_Wtime()-time01
12301 c write (iout,*) "lllicz",lllicz
12303 c time01=MPI_Wtime()
12306 if (nfgtasks.gt.1) then
12307 call MPI_AllReduce(Pcalc(1),Pcalc_(1),nsaxs,MPI_DOUBLE_PRECISION,
12308 & MPI_SUM,FG_COMM,IERR)
12309 c if (fg_rank.eq.king) then
12311 Pcalc(k) = Pcalc_(k)
12314 c call MPI_AllReduce(PgradC(k,1,1),PgradC_(k,1,1),3*maxsaxs*nres,
12315 c & MPI_DOUBLE_PRECISION,MPI_SUM,FG_COMM,IERR)
12316 c if (fg_rank.eq.king) then
12320 c PgradC(k,l,i) = PgradC_(k,l,i)
12326 c call MPI_AllReduce(PgradX(k,1,1),PgradX_(k,1,1),3*maxsaxs*nres,
12327 c & MPI_DOUBLE_PRECISION,MPI_SUM,FG_COMM,IERR)
12328 c if (fg_rank.eq.king) then
12332 c PgradX(k,l,i) = PgradX_(k,l,i)
12342 Cnorm = Cnorm + Pcalc(k)
12345 if (fg_rank.eq.king) then
12347 Esaxs_constr = dlog(Cnorm)-wsaxs0
12349 if (Pcalc(k).gt.0.0d0)
12350 & Esaxs_constr = Esaxs_constr - Psaxs(k)*dlog(Pcalc(k))
12352 write (iout,*) "k",k," Esaxs_constr",Esaxs_constr
12356 write (iout,*) "Cnorm",Cnorm," Esaxs_constr",Esaxs_constr
12371 & auxC = auxC +Psaxs(k)*PgradC(k,l,i)/Pcalc(k)
12372 auxC1 = auxC1+PgradC(k,l,i)
12374 auxX = auxX +Psaxs(k)*PgradX(k,l,i)/Pcalc(k)
12375 auxX1 = auxX1+PgradX(k,l,i)
12378 gsaxsC(l,i) = auxC - auxC1/Cnorm
12380 gsaxsX(l,i) = auxX - auxX1/Cnorm
12382 c write (iout,*) "l i",l,i," gradC",wsaxs*(auxC - auxC1/Cnorm),
12383 c * " gradX",wsaxs*(auxX - auxX1/Cnorm)
12384 c write (iout,*) "l i",l,i," gradC",wsaxs*gsaxsC(l,i),
12385 c * " gradX",wsaxs*gsaxsX(l,i)
12389 time_SAXS=time_SAXS+MPI_Wtime()-time01
12392 write (iout,*) "gsaxsc"
12394 write (iout,'(i5,3e15.5)') i,(gsaxsc(j,i),j=1,3)
12402 c----------------------------------------------------------------------------
12403 subroutine e_saxsC(Esaxs_constr)
12405 include 'DIMENSIONS'
12408 include "COMMON.SETUP"
12411 include 'COMMON.SBRIDGE'
12412 include 'COMMON.CHAIN'
12413 include 'COMMON.GEO'
12414 include 'COMMON.DERIV'
12415 include 'COMMON.LOCAL'
12416 include 'COMMON.INTERACT'
12417 include 'COMMON.VAR'
12418 include 'COMMON.IOUNITS'
12419 include 'COMMON.MD'
12420 include 'COMMON.CONTROL'
12421 include 'COMMON.NAMES'
12422 include 'COMMON.TIME1'
12423 include 'COMMON.FFIELD'
12425 double precision Esaxs_constr
12426 integer i,iint,j,k,l
12427 double precision PgradC(3,maxres),PgradX(3,maxres),Pcalc,logPtot
12429 double precision gsaxsc_(3,maxres),gsaxsx_(3,maxres),logPtot_
12431 double precision dk,dijCASPH,dijSCSPH,
12432 & sigma2CA,sigma2SC,expCASPH,expSCSPH,
12433 & CASPHgrad,SCSPHgrad,aux,auxC,auxC1,
12435 c SAXS restraint penalty function
12437 write(iout,*) "------- SAXS penalty function start -------"
12438 write (iout,*) "nsaxs",nsaxs
12441 print *,MyRank,"C",i,(C(j,i),j=1,3)
12444 print *,MyRank,"CSaxs",i,(Csaxs(j,i),j=1,3)
12447 Esaxs_constr = 0.0d0
12449 do j=isaxs_start,isaxs_end
12458 if (itype(i).eq.ntyp1) cycle
12462 dijCASPH=dijCASPH+(C(l,i)-Csaxs(l,j))**2
12464 if (itype(i).ne.10) then
12466 dijSCSPH=dijSCSPH+(C(l,i+nres)-Csaxs(l,j))**2
12469 sigma2CA=2.0d0/pstok**2
12470 sigma2SC=4.0d0/restok(itype(i))**2
12471 expCASPH = dexp(-0.5d0*sigma2CA*dijCASPH)
12472 expSCSPH = dexp(-0.5d0*sigma2SC*dijSCSPH)
12473 Pcalc = Pcalc+expCASPH+expSCSPH
12475 write(*,*) "processor i j Pcalc",
12476 & MyRank,i,j,dijCASPH,dijSCSPH, Pcalc
12478 CASPHgrad = sigma2CA*expCASPH
12479 SCSPHgrad = sigma2SC*expSCSPH
12481 aux = (C(l,i+nres)-Csaxs(l,j))*SCSPHgrad
12482 PgradX(l,i) = PgradX(l,i) + aux
12483 PgradC(l,i) = PgradC(l,i)+(C(l,i)-Csaxs(l,j))*CASPHgrad+aux
12488 gsaxsc(l,i)=gsaxsc(l,i)+PgradC(l,i)/Pcalc
12489 gsaxsx(l,i)=gsaxsx(l,i)+PgradX(l,i)/Pcalc
12492 logPtot = logPtot - dlog(Pcalc)
12493 c print *,"me",me,MyRank," j",j," logPcalc",-dlog(Pcalc),
12494 c & " logPtot",logPtot
12497 if (nfgtasks.gt.1) then
12498 c write (iout,*) "logPtot before reduction",logPtot
12499 call MPI_Reduce(logPtot,logPtot_,1,MPI_DOUBLE_PRECISION,
12500 & MPI_SUM,king,FG_COMM,IERR)
12502 c write (iout,*) "logPtot after reduction",logPtot
12503 call MPI_Reduce(gsaxsC(1,1),gsaxsC_(1,1),3*nres,
12504 & MPI_DOUBLE_PRECISION,MPI_SUM,king,FG_COMM,IERR)
12505 if (fg_rank.eq.king) then
12508 gsaxsC(l,i) = gsaxsC_(l,i)
12512 call MPI_Reduce(gsaxsX(1,1),gsaxsX_(1,1),3*nres,
12513 & MPI_DOUBLE_PRECISION,MPI_SUM,king,FG_COMM,IERR)
12514 if (fg_rank.eq.king) then
12517 gsaxsX(l,i) = gsaxsX_(l,i)
12523 Esaxs_constr = logPtot
12526 c----------------------------------------------------------------------------
12527 double precision function sscale2(r,r_cut,r0,rlamb)
12529 double precision r,gamm,r_cut,r0,rlamb,rr
12531 c write (2,*) "r",r," r_cut",r_cut," r0",r0," rlamb",rlamb
12532 c write (2,*) "rr",rr
12533 if(rr.lt.r_cut-rlamb) then
12535 else if(rr.le.r_cut.and.rr.ge.r_cut-rlamb) then
12536 gamm=(rr-(r_cut-rlamb))/rlamb
12537 sscale2=1.0d0+gamm*gamm*(2*gamm-3.0d0)
12543 C-----------------------------------------------------------------------
12544 double precision function sscalgrad2(r,r_cut,r0,rlamb)
12546 double precision r,gamm,r_cut,r0,rlamb,rr
12548 if(rr.lt.r_cut-rlamb) then
12550 else if(rr.le.r_cut.and.rr.ge.r_cut-rlamb) then
12551 gamm=(rr-(r_cut-rlamb))/rlamb
12553 sscalgrad2=gamm*(6*gamm-6.0d0)/rlamb
12555 sscalgrad2=-gamm*(6*gamm-6.0d0)/rlamb