1 subroutine etotal(energia)
2 implicit real*8 (a-h,o-z)
7 cMS$ATTRIBUTES C :: proc_proc
12 double precision weights_(n_ene)
14 include 'COMMON.SETUP'
15 include 'COMMON.IOUNITS'
16 double precision energia(0:n_ene)
17 include 'COMMON.LOCAL'
18 include 'COMMON.FFIELD'
19 include 'COMMON.DERIV'
20 include 'COMMON.INTERACT'
21 include 'COMMON.SBRIDGE'
22 include 'COMMON.CHAIN'
25 include 'COMMON.CONTROL'
26 include 'COMMON.TIME1'
27 include 'COMMON.SPLITELE'
29 c print*,"ETOTAL Processor",fg_rank," absolute rank",myrank,
30 c & " nfgtasks",nfgtasks
31 if (nfgtasks.gt.1) then
33 C FG slaves call the following matching MPI_Bcast in ERGASTULUM
34 if (fg_rank.eq.0) then
35 call MPI_Bcast(0,1,MPI_INTEGER,king,FG_COMM,IERROR)
36 c print *,"Processor",myrank," BROADCAST iorder"
37 C FG master sets up the WEIGHTS_ array which will be broadcast to the
38 C FG slaves as WEIGHTS array.
58 C FG Master broadcasts the WEIGHTS_ array
59 call MPI_Bcast(weights_(1),n_ene,
60 & MPI_DOUBLE_PRECISION,king,FG_COMM,IERROR)
62 C FG slaves receive the WEIGHTS array
63 call MPI_Bcast(weights(1),n_ene,
64 & MPI_DOUBLE_PRECISION,king,FG_COMM,IERROR)
85 time_Bcast=time_Bcast+MPI_Wtime()-time00
86 time_Bcastw=time_Bcastw+MPI_Wtime()-time00
87 c call chainbuild_cart
89 c print *,'Processor',myrank,' calling etotal ipot=',ipot
90 c print *,'Processor',myrank,' nnt=',nnt,' nct=',nct
92 c if (modecalc.eq.12.or.modecalc.eq.14) then
93 c call int_from_cart1(.false.)
100 C Compute the side-chain and electrostatic interaction energy
103 goto (101,102,103,104,105,106) ipot
104 C Lennard-Jones potential.
106 cd print '(a)','Exit ELJ'
108 C Lennard-Jones-Kihara potential (shifted).
111 C Berne-Pechukas potential (dilated LJ, angular dependence).
114 C Gay-Berne potential (shifted LJ, angular dependence).
116 C print *,"bylem w egb"
118 C Gay-Berne-Vorobjev potential (shifted LJ, angular dependence).
121 C Soft-sphere potential
122 106 call e_softsphere(evdw)
124 C Calculate electrostatic (H-bonding) energy of the main chain.
128 cmc Sep-06: egb takes care of dynamic ss bonds too
130 c if (dyn_ss) call dyn_set_nss
132 c print *,"Processor",myrank," computed USCSC"
138 time_vec=time_vec+MPI_Wtime()-time01
140 C Introduction of shielding effect first for each peptide group
141 C the shielding factor is set this factor is describing how each
142 C peptide group is shielded by side-chains
143 C the matrix - shield_fac(i) the i index describe the ith between i and i+1
144 C write (iout,*) "shield_mode",shield_mode
145 if (shield_mode.gt.0) then
148 c print *,"Processor",myrank," left VEC_AND_DERIV"
151 if (welec.gt.0d0.or.wvdwpp.gt.0d0.or.wel_loc.gt.0d0.or.
152 & wturn3.gt.0d0.or.wturn4.gt.0d0 .or. wcorr.gt.0.0d0
153 & .or. wcorr4.gt.0.0d0 .or. wcorr5.gt.0.d0
154 & .or. wcorr6.gt.0.0d0 .or. wturn6.gt.0.0d0 ) then
156 if (welec.gt.0d0.or.wel_loc.gt.0d0.or.
157 & wturn3.gt.0d0.or.wturn4.gt.0d0 .or. wcorr.gt.0.0d0
158 & .or. wcorr4.gt.0.0d0 .or. wcorr5.gt.0.d0
159 & .or. wcorr6.gt.0.0d0 .or. wturn6.gt.0.0d0 ) then
161 call eelec(ees,evdw1,eel_loc,eello_turn3,eello_turn4)
170 write (iout,*) "Soft-spheer ELEC potential"
171 c call eelec_soft_sphere(ees,evdw1,eel_loc,eello_turn3,
174 c print *,"Processor",myrank," computed UELEC"
176 C Calculate excluded-volume interaction energy between peptide groups
181 call escp(evdw2,evdw2_14)
187 c write (iout,*) "Soft-sphere SCP potential"
188 call escp_soft_sphere(evdw2,evdw2_14)
191 c Calculate the bond-stretching energy
195 C Calculate the disulfide-bridge and other energy and the contributions
196 C from other distance constraints.
197 cd print *,'Calling EHPB'
199 cd print *,'EHPB exitted succesfully.'
201 C Calculate the virtual-bond-angle energy.
203 if (wang.gt.0d0) then
204 call ebend(ebe,ethetacnstr)
209 c print *,"Processor",myrank," computed UB"
211 C Calculate the SC local energy.
213 C print *,"TU DOCHODZE?"
215 c print *,"Processor",myrank," computed USC"
217 C Calculate the virtual-bond torsional energy.
219 cd print *,'nterm=',nterm
221 call etor(etors,edihcnstr)
226 c print *,"Processor",myrank," computed Utor"
228 C 6/23/01 Calculate double-torsional energy
230 if (wtor_d.gt.0) then
235 c print *,"Processor",myrank," computed Utord"
237 C 21/5/07 Calculate local sicdechain correlation energy
239 if (wsccor.gt.0.0d0) then
240 call eback_sc_corr(esccor)
244 C print *,"PRZED MULIt"
245 c print *,"Processor",myrank," computed Usccorr"
247 C 12/1/95 Multi-body terms
251 if ((wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 .or. wcorr6.gt.0.0d0
252 & .or. wturn6.gt.0.0d0) .and. ipot.lt.6) then
253 call multibody_eello(ecorr,ecorr5,ecorr6,eturn6,n_corr,n_corr1)
254 cd write(2,*)'multibody_eello n_corr=',n_corr,' n_corr1=',n_corr1,
255 cd &" ecorr",ecorr," ecorr5",ecorr5," ecorr6",ecorr6," eturn6",eturn6
262 if ((wcorr4.eq.0.0d0 .and. wcorr.gt.0.0d0) .and. ipot.lt.6) then
263 call multibody_hb(ecorr,ecorr5,ecorr6,n_corr,n_corr1)
264 cd write (iout,*) "multibody_hb ecorr",ecorr
266 c print *,"Processor",myrank," computed Ucorr"
268 C If performing constraint dynamics, call the constraint energy
269 C after the equilibration time
270 if(usampl.and.totT.gt.eq_time) then
277 C 01/27/2015 added by adasko
278 C the energy component below is energy transfer into lipid environment
279 C based on partition function
280 C print *,"przed lipidami"
281 if (wliptran.gt.0) then
282 call Eliptransfer(eliptran)
284 C print *,"za lipidami"
285 if (AFMlog.gt.0) then
286 call AFMforce(Eafmforce)
287 else if (selfguide.gt.0) then
288 call AFMvel(Eafmforce)
291 time_enecalc=time_enecalc+MPI_Wtime()-time00
293 c print *,"Processor",myrank," computed Uconstr"
302 energia(2)=evdw2-evdw2_14
319 energia(8)=eello_turn3
320 energia(9)=eello_turn4
327 energia(19)=edihcnstr
329 energia(20)=Uconst+Uconst_back
332 energia(23)=Eafmforce
333 energia(24)=ethetacnstr
334 c Here are the energies showed per procesor if the are more processors
335 c per molecule then we sum it up in sum_energy subroutine
336 c print *," Processor",myrank," calls SUM_ENERGY"
337 call sum_energy(energia,.true.)
338 if (dyn_ss) call dyn_set_nss
339 c print *," Processor",myrank," left SUM_ENERGY"
341 time_sumene=time_sumene+MPI_Wtime()-time00
345 c-------------------------------------------------------------------------------
346 subroutine sum_energy(energia,reduce)
347 implicit real*8 (a-h,o-z)
352 cMS$ATTRIBUTES C :: proc_proc
358 include 'COMMON.SETUP'
359 include 'COMMON.IOUNITS'
360 double precision energia(0:n_ene),enebuff(0:n_ene+1)
361 include 'COMMON.FFIELD'
362 include 'COMMON.DERIV'
363 include 'COMMON.INTERACT'
364 include 'COMMON.SBRIDGE'
365 include 'COMMON.CHAIN'
367 include 'COMMON.CONTROL'
368 include 'COMMON.TIME1'
371 if (nfgtasks.gt.1 .and. reduce) then
373 write (iout,*) "energies before REDUCE"
374 call enerprint(energia)
378 enebuff(i)=energia(i)
381 call MPI_Barrier(FG_COMM,IERR)
382 time_barrier_e=time_barrier_e+MPI_Wtime()-time00
384 call MPI_Reduce(enebuff(0),energia(0),n_ene+1,
385 & MPI_DOUBLE_PRECISION,MPI_SUM,king,FG_COMM,IERR)
387 write (iout,*) "energies after REDUCE"
388 call enerprint(energia)
391 time_Reduce=time_Reduce+MPI_Wtime()-time00
393 if (fg_rank.eq.0) then
397 evdw2=energia(2)+energia(18)
413 eello_turn3=energia(8)
414 eello_turn4=energia(9)
421 edihcnstr=energia(19)
426 Eafmforce=energia(23)
427 ethetacnstr=energia(24)
429 etot=wsc*evdw+wscp*evdw2+welec*ees+wvdwpp*evdw1
430 & +wang*ebe+wtor*etors+wscloc*escloc
431 & +wstrain*ehpb+wcorr*ecorr+wcorr5*ecorr5
432 & +wcorr6*ecorr6+wturn4*eello_turn4+wturn3*eello_turn3
433 & +wturn6*eturn6+wel_loc*eel_loc+edihcnstr+wtor_d*etors_d
434 & +wbond*estr+Uconst+wsccor*esccor+wliptran*eliptran+Eafmforce
437 etot=wsc*evdw+wscp*evdw2+welec*(ees+evdw1)
438 & +wang*ebe+wtor*etors+wscloc*escloc
439 & +wstrain*ehpb+wcorr*ecorr+wcorr5*ecorr5
440 & +wcorr6*ecorr6+wturn4*eello_turn4+wturn3*eello_turn3
441 & +wturn6*eturn6+wel_loc*eel_loc+edihcnstr+wtor_d*etors_d
442 & +wbond*estr+Uconst+wsccor*esccor+wliptran*eliptran
450 if (isnan(etot).ne.0) energia(0)=1.0d+99
452 if (isnan(etot)) energia(0)=1.0d+99
457 idumm=proc_proc(etot,i)
459 call proc_proc(etot,i)
461 if(i.eq.1)energia(0)=1.0d+99
468 c-------------------------------------------------------------------------------
469 subroutine sum_gradient
470 implicit real*8 (a-h,o-z)
475 cMS$ATTRIBUTES C :: proc_proc
481 double precision gradbufc(3,-1:maxres),gradbufx(3,-1:maxres),
482 & glocbuf(4*maxres),gradbufc_sum(3,-1:maxres)
483 & ,gloc_scbuf(3,-1:maxres)
484 include 'COMMON.SETUP'
485 include 'COMMON.IOUNITS'
486 include 'COMMON.FFIELD'
487 include 'COMMON.DERIV'
488 include 'COMMON.INTERACT'
489 include 'COMMON.SBRIDGE'
490 include 'COMMON.CHAIN'
492 include 'COMMON.CONTROL'
493 include 'COMMON.TIME1'
494 include 'COMMON.MAXGRAD'
495 include 'COMMON.SCCOR'
500 write (iout,*) "sum_gradient gvdwc, gvdwx"
502 write (iout,'(i3,3f10.5,5x,3f10.5,5x,f10.5)')
503 & i,(gvdwx(j,i),j=1,3),(gvdwc(j,i),j=1,3)
508 C FG slaves call the following matching MPI_Bcast in ERGASTULUM
509 if (nfgtasks.gt.1 .and. fg_rank.eq.0)
510 & call MPI_Bcast(1,1,MPI_INTEGER,king,FG_COMM,IERROR)
513 C 9/29/08 AL Transform parts of gradients in site coordinates to the gradient
514 C in virtual-bond-vector coordinates
517 c write (iout,*) "gel_loc gel_loc_long and gel_loc_loc"
519 c write (iout,'(i5,3f10.5,2x,3f10.5,2x,f10.5)')
520 c & i,(gel_loc(j,i),j=1,3),(gel_loc_long(j,i),j=1,3),gel_loc_loc(i)
522 c write (iout,*) "gel_loc_tur3 gel_loc_turn4"
524 c write (iout,'(i5,3f10.5,2x,f10.5)')
525 c & i,(gcorr4_turn(j,i),j=1,3),gel_loc_turn4(i)
527 write (iout,*) "gradcorr5 gradcorr5_long gradcorr5_loc"
529 write (iout,'(i3,3f10.5,5x,3f10.5,5x,f10.5)')
530 & i,(gradcorr5(j,i),j=1,3),(gradcorr5_long(j,i),j=1,3),
538 gradbufc(j,i)=wsc*gvdwc(j,i)+
539 & wscp*(gvdwc_scp(j,i)+gvdwc_scpp(j,i))+
540 & welec*gelc_long(j,i)+wvdwpp*gvdwpp(j,i)+
541 & wel_loc*gel_loc_long(j,i)+
542 & wcorr*gradcorr_long(j,i)+
543 & wcorr5*gradcorr5_long(j,i)+
544 & wcorr6*gradcorr6_long(j,i)+
545 & wturn6*gcorr6_turn_long(j,i)+
547 & +wliptran*gliptranc(j,i)
549 & +welec*gshieldc(j,i)
550 & +wcorr*gshieldc_ec(j,i)
551 & +wturn3*gshieldc_t3(j,i)
552 & +wturn4*gshieldc_t4(j,i)
553 & +wel_loc*gshieldc_ll(j,i)
561 gradbufc(j,i)=wsc*gvdwc(j,i)+
562 & wscp*(gvdwc_scp(j,i)+gvdwc_scpp(j,i))+
563 & welec*gelc_long(j,i)+
565 & wel_loc*gel_loc_long(j,i)+
566 & wcorr*gradcorr_long(j,i)+
567 & wcorr5*gradcorr5_long(j,i)+
568 & wcorr6*gradcorr6_long(j,i)+
569 & wturn6*gcorr6_turn_long(j,i)+
571 & +wliptran*gliptranc(j,i)
573 & +welec*gshieldc(j,i)
574 & +wcorr*gshieldc_ec(j,i)
575 & +wturn4*gshieldc_t4(j,i)
576 & +wel_loc*gshieldc_ll(j,i)
583 if (nfgtasks.gt.1) then
586 write (iout,*) "gradbufc before allreduce"
588 write (iout,'(i3,3f10.5)') i,(gradbufc(j,i),j=1,3)
594 gradbufc_sum(j,i)=gradbufc(j,i)
597 c call MPI_AllReduce(gradbufc(1,1),gradbufc_sum(1,1),3*nres,
598 c & MPI_DOUBLE_PRECISION,MPI_SUM,FG_COMM,IERR)
599 c time_reduce=time_reduce+MPI_Wtime()-time00
601 c write (iout,*) "gradbufc_sum after allreduce"
603 c write (iout,'(i3,3f10.5)') i,(gradbufc_sum(j,i),j=1,3)
608 c time_allreduce=time_allreduce+MPI_Wtime()-time00
616 write (iout,*) "igrad_start",igrad_start," igrad_end",igrad_end
617 write (iout,*) (i," jgrad_start",jgrad_start(i),
618 & " jgrad_end ",jgrad_end(i),
619 & i=igrad_start,igrad_end)
622 c Obsolete and inefficient code; we can make the effort O(n) and, therefore,
623 c do not parallelize this part.
625 c do i=igrad_start,igrad_end
626 c do j=jgrad_start(i),jgrad_end(i)
628 c gradbufc(k,i)=gradbufc(k,i)+gradbufc_sum(k,j)
633 gradbufc(j,nres-1)=gradbufc_sum(j,nres)
637 gradbufc(j,i)=gradbufc(j,i+1)+gradbufc_sum(j,i+1)
641 write (iout,*) "gradbufc after summing"
643 write (iout,'(i3,3f10.5)') i,(gradbufc(j,i),j=1,3)
650 write (iout,*) "gradbufc"
652 write (iout,'(i3,3f10.5)') i,(gradbufc(j,i),j=1,3)
658 gradbufc_sum(j,i)=gradbufc(j,i)
663 gradbufc(j,nres-1)=gradbufc_sum(j,nres)
667 gradbufc(j,i)=gradbufc(j,i+1)+gradbufc_sum(j,i+1)
672 c gradbufc(k,i)=0.0d0
676 c gradbufc(k,i)=gradbufc(k,i)+gradbufc(k,j)
681 write (iout,*) "gradbufc after summing"
683 write (iout,'(i3,3f10.5)') i,(gradbufc(j,i),j=1,3)
691 gradbufc(k,nres)=0.0d0
696 C print *,gradbufc(1,13)
697 C print *,welec*gelc(1,13)
698 C print *,wel_loc*gel_loc(1,13)
699 C print *,0.5d0*(wscp*gvdwc_scpp(1,13))
700 C print *,welec*gelc_long(1,13)+wvdwpp*gvdwpp(1,13)
701 C print *,wel_loc*gel_loc_long(1,13)
702 C print *,gradafm(1,13),"AFM"
703 gradc(j,i,icg)=gradbufc(j,i)+welec*gelc(j,i)+
704 & wel_loc*gel_loc(j,i)+
705 & 0.5d0*(wscp*gvdwc_scpp(j,i)+
706 & welec*gelc_long(j,i)+wvdwpp*gvdwpp(j,i)+
707 & wel_loc*gel_loc_long(j,i)+
708 & wcorr*gradcorr_long(j,i)+
709 & wcorr5*gradcorr5_long(j,i)+
710 & wcorr6*gradcorr6_long(j,i)+
711 & wturn6*gcorr6_turn_long(j,i))+
713 & wcorr*gradcorr(j,i)+
714 & wturn3*gcorr3_turn(j,i)+
715 & wturn4*gcorr4_turn(j,i)+
716 & wcorr5*gradcorr5(j,i)+
717 & wcorr6*gradcorr6(j,i)+
718 & wturn6*gcorr6_turn(j,i)+
719 & wsccor*gsccorc(j,i)
720 & +wscloc*gscloc(j,i)
721 & +wliptran*gliptranc(j,i)
723 & +welec*gshieldc(j,i)
724 & +welec*gshieldc_loc(j,i)
725 & +wcorr*gshieldc_ec(j,i)
726 & +wcorr*gshieldc_loc_ec(j,i)
727 & +wturn3*gshieldc_t3(j,i)
728 & +wturn3*gshieldc_loc_t3(j,i)
729 & +wturn4*gshieldc_t4(j,i)
730 & +wturn4*gshieldc_loc_t4(j,i)
731 & +wel_loc*gshieldc_ll(j,i)
732 & +wel_loc*gshieldc_loc_ll(j,i)
740 gradc(j,i,icg)=gradbufc(j,i)+welec*gelc(j,i)+
741 & wel_loc*gel_loc(j,i)+
742 & 0.5d0*(wscp*gvdwc_scpp(j,i)+
743 & welec*gelc_long(j,i)+
744 & wel_loc*gel_loc_long(j,i)+
745 & wcorr*gcorr_long(j,i)+
746 & wcorr5*gradcorr5_long(j,i)+
747 & wcorr6*gradcorr6_long(j,i)+
748 & wturn6*gcorr6_turn_long(j,i))+
750 & wcorr*gradcorr(j,i)+
751 & wturn3*gcorr3_turn(j,i)+
752 & wturn4*gcorr4_turn(j,i)+
753 & wcorr5*gradcorr5(j,i)+
754 & wcorr6*gradcorr6(j,i)+
755 & wturn6*gcorr6_turn(j,i)+
756 & wsccor*gsccorc(j,i)
757 & +wscloc*gscloc(j,i)
758 & +wliptran*gliptranc(j,i)
760 & +welec*gshieldc(j,i)
761 & +welec*gshieldc_loc(j,i)
762 & +wcorr*gshieldc_ec(j,i)
763 & +wcorr*gshieldc_loc_ec(j,i)
764 & +wturn3*gshieldc_t3(j,i)
765 & +wturn3*gshieldc_loc_t3(j,i)
766 & +wturn4*gshieldc_t4(j,i)
767 & +wturn4*gshieldc_loc_t4(j,i)
768 & +wel_loc*gshieldc_ll(j,i)
769 & +wel_loc*gshieldc_loc_ll(j,i)
776 gradx(j,i,icg)=wsc*gvdwx(j,i)+wscp*gradx_scp(j,i)+
778 & wstrain*ghpbx(j,i)+wcorr*gradxorr(j,i)+
779 & wsccor*gsccorx(j,i)
780 & +wscloc*gsclocx(j,i)
781 & +wliptran*gliptranx(j,i)
782 & +welec*gshieldx(j,i)
783 & +wcorr*gshieldx_ec(j,i)
784 & +wturn3*gshieldx_t3(j,i)
785 & +wturn4*gshieldx_t4(j,i)
786 & +wel_loc*gshieldx_ll(j,i)
793 write (iout,*) "gloc before adding corr"
795 write (iout,*) i,gloc(i,icg)
799 gloc(i,icg)=gloc(i,icg)+wcorr*gcorr_loc(i)
800 & +wcorr5*g_corr5_loc(i)
801 & +wcorr6*g_corr6_loc(i)
802 & +wturn4*gel_loc_turn4(i)
803 & +wturn3*gel_loc_turn3(i)
804 & +wturn6*gel_loc_turn6(i)
805 & +wel_loc*gel_loc_loc(i)
808 write (iout,*) "gloc after adding corr"
810 write (iout,*) i,gloc(i,icg)
814 if (nfgtasks.gt.1) then
817 gradbufc(j,i)=gradc(j,i,icg)
818 gradbufx(j,i)=gradx(j,i,icg)
822 glocbuf(i)=gloc(i,icg)
826 write (iout,*) "gloc_sc before reduce"
829 write (iout,*) i,j,gloc_sc(j,i,icg)
836 gloc_scbuf(j,i)=gloc_sc(j,i,icg)
840 call MPI_Barrier(FG_COMM,IERR)
841 time_barrier_g=time_barrier_g+MPI_Wtime()-time00
843 call MPI_Reduce(gradbufc(1,1),gradc(1,1,icg),3*nres,
844 & MPI_DOUBLE_PRECISION,MPI_SUM,king,FG_COMM,IERR)
845 call MPI_Reduce(gradbufx(1,1),gradx(1,1,icg),3*nres,
846 & MPI_DOUBLE_PRECISION,MPI_SUM,king,FG_COMM,IERR)
847 call MPI_Reduce(glocbuf(1),gloc(1,icg),4*nres,
848 & MPI_DOUBLE_PRECISION,MPI_SUM,king,FG_COMM,IERR)
849 time_reduce=time_reduce+MPI_Wtime()-time00
850 call MPI_Reduce(gloc_scbuf(1,1),gloc_sc(1,1,icg),3*nres,
851 & MPI_DOUBLE_PRECISION,MPI_SUM,king,FG_COMM,IERR)
852 time_reduce=time_reduce+MPI_Wtime()-time00
855 write (iout,*) "gloc_sc after reduce"
858 write (iout,*) i,j,gloc_sc(j,i,icg)
864 write (iout,*) "gloc after reduce"
866 write (iout,*) i,gloc(i,icg)
871 if (gnorm_check) then
873 c Compute the maximum elements of the gradient
883 gcorr3_turn_max=0.0d0
884 gcorr4_turn_max=0.0d0
887 gcorr6_turn_max=0.0d0
897 gvdwc_norm=dsqrt(scalar(gvdwc(1,i),gvdwc(1,i)))
898 if (gvdwc_norm.gt.gvdwc_max) gvdwc_max=gvdwc_norm
899 gvdwc_scp_norm=dsqrt(scalar(gvdwc_scp(1,i),gvdwc_scp(1,i)))
900 if (gvdwc_scp_norm.gt.gvdwc_scp_max)
901 & gvdwc_scp_max=gvdwc_scp_norm
902 gelc_norm=dsqrt(scalar(gelc(1,i),gelc(1,i)))
903 if (gelc_norm.gt.gelc_max) gelc_max=gelc_norm
904 gvdwpp_norm=dsqrt(scalar(gvdwpp(1,i),gvdwpp(1,i)))
905 if (gvdwpp_norm.gt.gvdwpp_max) gvdwpp_max=gvdwpp_norm
906 gradb_norm=dsqrt(scalar(gradb(1,i),gradb(1,i)))
907 if (gradb_norm.gt.gradb_max) gradb_max=gradb_norm
908 ghpbc_norm=dsqrt(scalar(ghpbc(1,i),ghpbc(1,i)))
909 if (ghpbc_norm.gt.ghpbc_max) ghpbc_max=ghpbc_norm
910 gradcorr_norm=dsqrt(scalar(gradcorr(1,i),gradcorr(1,i)))
911 if (gradcorr_norm.gt.gradcorr_max) gradcorr_max=gradcorr_norm
912 gel_loc_norm=dsqrt(scalar(gel_loc(1,i),gel_loc(1,i)))
913 if (gel_loc_norm.gt.gel_loc_max) gel_loc_max=gel_loc_norm
914 gcorr3_turn_norm=dsqrt(scalar(gcorr3_turn(1,i),
916 if (gcorr3_turn_norm.gt.gcorr3_turn_max)
917 & gcorr3_turn_max=gcorr3_turn_norm
918 gcorr4_turn_norm=dsqrt(scalar(gcorr4_turn(1,i),
920 if (gcorr4_turn_norm.gt.gcorr4_turn_max)
921 & gcorr4_turn_max=gcorr4_turn_norm
922 gradcorr5_norm=dsqrt(scalar(gradcorr5(1,i),gradcorr5(1,i)))
923 if (gradcorr5_norm.gt.gradcorr5_max)
924 & gradcorr5_max=gradcorr5_norm
925 gradcorr6_norm=dsqrt(scalar(gradcorr6(1,i),gradcorr6(1,i)))
926 if (gradcorr6_norm.gt.gradcorr6_max) gcorr6_max=gradcorr6_norm
927 gcorr6_turn_norm=dsqrt(scalar(gcorr6_turn(1,i),
929 if (gcorr6_turn_norm.gt.gcorr6_turn_max)
930 & gcorr6_turn_max=gcorr6_turn_norm
931 gsccorr_norm=dsqrt(scalar(gsccorc(1,i),gsccorc(1,i)))
932 if (gsccorr_norm.gt.gsccorr_max) gsccorr_max=gsccorr_norm
933 gscloc_norm=dsqrt(scalar(gscloc(1,i),gscloc(1,i)))
934 if (gscloc_norm.gt.gscloc_max) gscloc_max=gscloc_norm
935 gvdwx_norm=dsqrt(scalar(gvdwx(1,i),gvdwx(1,i)))
936 if (gvdwx_norm.gt.gvdwx_max) gvdwx_max=gvdwx_norm
937 gradx_scp_norm=dsqrt(scalar(gradx_scp(1,i),gradx_scp(1,i)))
938 if (gradx_scp_norm.gt.gradx_scp_max)
939 & gradx_scp_max=gradx_scp_norm
940 ghpbx_norm=dsqrt(scalar(ghpbx(1,i),ghpbx(1,i)))
941 if (ghpbx_norm.gt.ghpbx_max) ghpbx_max=ghpbx_norm
942 gradxorr_norm=dsqrt(scalar(gradxorr(1,i),gradxorr(1,i)))
943 if (gradxorr_norm.gt.gradxorr_max) gradxorr_max=gradxorr_norm
944 gsccorrx_norm=dsqrt(scalar(gsccorx(1,i),gsccorx(1,i)))
945 if (gsccorrx_norm.gt.gsccorrx_max) gsccorrx_max=gsccorrx_norm
946 gsclocx_norm=dsqrt(scalar(gsclocx(1,i),gsclocx(1,i)))
947 if (gsclocx_norm.gt.gsclocx_max) gsclocx_max=gsclocx_norm
951 open(istat,file=statname,position="append")
953 open(istat,file=statname,access="append")
955 write (istat,'(1h#,21f10.2)') gvdwc_max,gvdwc_scp_max,
956 & gelc_max,gvdwpp_max,gradb_max,ghpbc_max,
957 & gradcorr_max,gel_loc_max,gcorr3_turn_max,gcorr4_turn_max,
958 & gradcorr5_max,gradcorr6_max,gcorr6_turn_max,gsccorc_max,
959 & gscloc_max,gvdwx_max,gradx_scp_max,ghpbx_max,gradxorr_max,
960 & gsccorx_max,gsclocx_max
962 if (gvdwc_max.gt.1.0d4) then
963 write (iout,*) "gvdwc gvdwx gradb gradbx"
965 write(iout,'(i5,4(3f10.2,5x))') i,(gvdwc(j,i),gvdwx(j,i),
966 & gradb(j,i),gradbx(j,i),j=1,3)
968 call pdbout(0.0d0,'cipiszcze',iout)
974 write (iout,*) "gradc gradx gloc"
976 write (iout,'(i5,3f10.5,5x,3f10.5,5x,f10.5)')
977 & i,(gradc(j,i,icg),j=1,3),(gradx(j,i,icg),j=1,3),gloc(i,icg)
981 time_sumgradient=time_sumgradient+MPI_Wtime()-time01
985 c-------------------------------------------------------------------------------
986 subroutine rescale_weights(t_bath)
987 implicit real*8 (a-h,o-z)
989 include 'COMMON.IOUNITS'
990 include 'COMMON.FFIELD'
991 include 'COMMON.SBRIDGE'
992 double precision kfac /2.4d0/
993 double precision x,x2,x3,x4,x5,licznik /1.12692801104297249644/
995 c facT=2*temp0/(t_bath+temp0)
996 if (rescale_mode.eq.0) then
1002 else if (rescale_mode.eq.1) then
1003 facT=kfac/(kfac-1.0d0+t_bath/temp0)
1004 facT2=kfac**2/(kfac**2-1.0d0+(t_bath/temp0)**2)
1005 facT3=kfac**3/(kfac**3-1.0d0+(t_bath/temp0)**3)
1006 facT4=kfac**4/(kfac**4-1.0d0+(t_bath/temp0)**4)
1007 facT5=kfac**5/(kfac**5-1.0d0+(t_bath/temp0)**5)
1008 else if (rescale_mode.eq.2) then
1014 facT=licznik/dlog(dexp(x)+dexp(-x))
1015 facT2=licznik/dlog(dexp(x2)+dexp(-x2))
1016 facT3=licznik/dlog(dexp(x3)+dexp(-x3))
1017 facT4=licznik/dlog(dexp(x4)+dexp(-x4))
1018 facT5=licznik/dlog(dexp(x5)+dexp(-x5))
1020 write (iout,*) "Wrong RESCALE_MODE",rescale_mode
1021 write (*,*) "Wrong RESCALE_MODE",rescale_mode
1023 call MPI_Finalize(MPI_COMM_WORLD,IERROR)
1027 welec=weights(3)*fact
1028 wcorr=weights(4)*fact3
1029 wcorr5=weights(5)*fact4
1030 wcorr6=weights(6)*fact5
1031 wel_loc=weights(7)*fact2
1032 wturn3=weights(8)*fact2
1033 wturn4=weights(9)*fact3
1034 wturn6=weights(10)*fact5
1035 wtor=weights(13)*fact
1036 wtor_d=weights(14)*fact2
1037 wsccor=weights(21)*fact
1041 C------------------------------------------------------------------------
1042 subroutine enerprint(energia)
1043 implicit real*8 (a-h,o-z)
1044 include 'DIMENSIONS'
1045 include 'COMMON.IOUNITS'
1046 include 'COMMON.FFIELD'
1047 include 'COMMON.SBRIDGE'
1049 double precision energia(0:n_ene)
1054 evdw2=energia(2)+energia(18)
1066 eello_turn3=energia(8)
1067 eello_turn4=energia(9)
1068 eello_turn6=energia(10)
1074 edihcnstr=energia(19)
1078 eliptran=energia(22)
1079 Eafmforce=energia(23)
1080 ethetacnstr=energia(24)
1082 write (iout,10) evdw,wsc,evdw2,wscp,ees,welec,evdw1,wvdwpp,
1083 & estr,wbond,ebe,wang,
1084 & escloc,wscloc,etors,wtor,etors_d,wtor_d,ehpb,wstrain,
1086 & ecorr5,wcorr5,ecorr6,wcorr6,eel_loc,wel_loc,eello_turn3,wturn3,
1087 & eello_turn4,wturn4,eello_turn6,wturn6,esccor,wsccro,edihcnstr,
1088 & ethetacnstr,ebr*nss,Uconst,eliptran,wliptran,Eafmforc,
1090 10 format (/'Virtual-chain energies:'//
1091 & 'EVDW= ',1pE16.6,' WEIGHT=',1pD16.6,' (SC-SC)'/
1092 & 'EVDW2= ',1pE16.6,' WEIGHT=',1pD16.6,' (SC-p)'/
1093 & 'EES= ',1pE16.6,' WEIGHT=',1pD16.6,' (p-p)'/
1094 & 'EVDWPP=',1pE16.6,' WEIGHT=',1pD16.6,' (p-p VDW)'/
1095 & 'ESTR= ',1pE16.6,' WEIGHT=',1pD16.6,' (stretching)'/
1096 & 'EBE= ',1pE16.6,' WEIGHT=',1pD16.6,' (bending)'/
1097 & 'ESC= ',1pE16.6,' WEIGHT=',1pD16.6,' (SC local)'/
1098 & 'ETORS= ',1pE16.6,' WEIGHT=',1pD16.6,' (torsional)'/
1099 & 'ETORSD=',1pE16.6,' WEIGHT=',1pD16.6,' (double torsional)'/
1100 & 'EHBP= ',1pE16.6,' WEIGHT=',1pD16.6,
1101 & ' (SS bridges & dist. cnstr.)'/
1102 & 'ECORR4=',1pE16.6,' WEIGHT=',1pD16.6,' (multi-body)'/
1103 & 'ECORR5=',1pE16.6,' WEIGHT=',1pD16.6,' (multi-body)'/
1104 & 'ECORR6=',1pE16.6,' WEIGHT=',1pD16.6,' (multi-body)'/
1105 & 'EELLO= ',1pE16.6,' WEIGHT=',1pD16.6,' (electrostatic-local)'/
1106 & 'ETURN3=',1pE16.6,' WEIGHT=',1pD16.6,' (turns, 3rd order)'/
1107 & 'ETURN4=',1pE16.6,' WEIGHT=',1pD16.6,' (turns, 4th order)'/
1108 & 'ETURN6=',1pE16.6,' WEIGHT=',1pD16.6,' (turns, 6th order)'/
1109 & 'ESCCOR=',1pE16.6,' WEIGHT=',1pD16.6,' (backbone-rotamer corr)'/
1110 & 'EDIHC= ',1pE16.6,' (dihedral angle constraints)'/
1111 & 'ETHETC= ',1pE16.6,' (valence angle constraints)'/
1112 & 'ESS= ',1pE16.6,' (disulfide-bridge intrinsic energy)'/
1113 & 'UCONST= ',1pE16.6,' (Constraint energy)'/
1114 & 'ELT=',1pE16.6, ' WEIGHT=',1pD16.6,' (Lipid transfer energy)'/
1115 & 'EAFM= ',1pE16.6,' (atomic-force microscopy)'/
1116 & 'ETOT= ',1pE16.6,' (total)')
1119 write (iout,10) evdw,wsc,evdw2,wscp,ees,welec,
1120 & estr,wbond,ebe,wang,
1121 & escloc,wscloc,etors,wtor,etors_d,wtor_d,ehpb,wstrain,
1123 & ecorr5,wcorr5,ecorr6,wcorr6,eel_loc,wel_loc,eello_turn3,wturn3,
1124 & eello_turn4,wturn4,eello_turn6,wturn6,esccor,wsccro,edihcnstr,
1125 & ethetacnstr,ebr*nss,Uconst,eliptran,wliptran,Eafmforc,
1127 10 format (/'Virtual-chain energies:'//
1128 & 'EVDW= ',1pE16.6,' WEIGHT=',1pD16.6,' (SC-SC)'/
1129 & 'EVDW2= ',1pE16.6,' WEIGHT=',1pD16.6,' (SC-p)'/
1130 & 'EES= ',1pE16.6,' WEIGHT=',1pD16.6,' (p-p)'/
1131 & 'ESTR= ',1pE16.6,' WEIGHT=',1pD16.6,' (stretching)'/
1132 & 'EBE= ',1pE16.6,' WEIGHT=',1pD16.6,' (bending)'/
1133 & 'ESC= ',1pE16.6,' WEIGHT=',1pD16.6,' (SC local)'/
1134 & 'ETORS= ',1pE16.6,' WEIGHT=',1pD16.6,' (torsional)'/
1135 & 'ETORSD=',1pE16.6,' WEIGHT=',1pD16.6,' (double torsional)'/
1136 & 'EHBP= ',1pE16.6,' WEIGHT=',1pD16.6,
1137 & ' (SS bridges & dist. cnstr.)'/
1138 & 'ECORR4=',1pE16.6,' WEIGHT=',1pD16.6,' (multi-body)'/
1139 & 'ECORR5=',1pE16.6,' WEIGHT=',1pD16.6,' (multi-body)'/
1140 & 'ECORR6=',1pE16.6,' WEIGHT=',1pD16.6,' (multi-body)'/
1141 & 'EELLO= ',1pE16.6,' WEIGHT=',1pD16.6,' (electrostatic-local)'/
1142 & 'ETURN3=',1pE16.6,' WEIGHT=',1pD16.6,' (turns, 3rd order)'/
1143 & 'ETURN4=',1pE16.6,' WEIGHT=',1pD16.6,' (turns, 4th order)'/
1144 & 'ETURN6=',1pE16.6,' WEIGHT=',1pD16.6,' (turns, 6th order)'/
1145 & 'ESCCOR=',1pE16.6,' WEIGHT=',1pD16.6,' (backbone-rotamer corr)'/
1146 & 'EDIHC= ',1pE16.6,' (dihedral angle constraints)'/
1147 & 'ETHETC= ',1pE16.6,' (valence angle constraints)'/
1148 & 'ESS= ',1pE16.6,' (disulfide-bridge intrinsic energy)'/
1149 & 'UCONST=',1pE16.6,' (Constraint energy)'/
1150 & 'ELT=',1pE16.6, ' WEIGHT=',1pD16.6,' (Lipid transfer energy)'/
1151 & 'EAFM= ',1pE16.6,' (atomic-force microscopy)'/
1152 & 'ETOT= ',1pE16.6,' (total)')
1156 C-----------------------------------------------------------------------
1157 subroutine elj(evdw)
1159 C This subroutine calculates the interaction energy of nonbonded side chains
1160 C assuming the LJ potential of interaction.
1162 implicit real*8 (a-h,o-z)
1163 include 'DIMENSIONS'
1164 parameter (accur=1.0d-10)
1165 include 'COMMON.GEO'
1166 include 'COMMON.VAR'
1167 include 'COMMON.LOCAL'
1168 include 'COMMON.CHAIN'
1169 include 'COMMON.DERIV'
1170 include 'COMMON.INTERACT'
1171 include 'COMMON.TORSION'
1172 include 'COMMON.SBRIDGE'
1173 include 'COMMON.NAMES'
1174 include 'COMMON.IOUNITS'
1175 include 'COMMON.CONTACTS'
1177 c write(iout,*)'Entering ELJ nnt=',nnt,' nct=',nct,' expon=',expon
1179 do i=iatsc_s,iatsc_e
1180 itypi=iabs(itype(i))
1181 if (itypi.eq.ntyp1) cycle
1182 itypi1=iabs(itype(i+1))
1189 C Calculate SC interaction energy.
1191 do iint=1,nint_gr(i)
1192 cd write (iout,*) 'i=',i,' iint=',iint,' istart=',istart(i,iint),
1193 cd & 'iend=',iend(i,iint)
1194 do j=istart(i,iint),iend(i,iint)
1195 itypj=iabs(itype(j))
1196 if (itypj.eq.ntyp1) cycle
1200 C Change 12/1/95 to calculate four-body interactions
1201 rij=xj*xj+yj*yj+zj*zj
1203 c write (iout,*)'i=',i,' j=',j,' itypi=',itypi,' itypj=',itypj
1204 eps0ij=eps(itypi,itypj)
1206 C have you changed here?
1210 cd sigm=dabs(aa(itypi,itypj)/bb(itypi,itypj))**(1.0D0/6.0D0)
1211 cd epsi=bb(itypi,itypj)**2/aa(itypi,itypj)
1212 cd write (iout,'(2(a3,i3,2x),6(1pd12.4)/2(3(1pd12.4),5x)/)')
1213 cd & restyp(itypi),i,restyp(itypj),j,a(itypi,itypj),
1214 cd & bb(itypi,itypj),1.0D0/dsqrt(rrij),evdwij,epsi,sigm,
1215 cd & (c(k,i),k=1,3),(c(k,j),k=1,3)
1218 C Calculate the components of the gradient in DC and X
1220 fac=-rrij*(e1+evdwij)
1225 gvdwx(k,i)=gvdwx(k,i)-gg(k)
1226 gvdwx(k,j)=gvdwx(k,j)+gg(k)
1227 gvdwc(k,i)=gvdwc(k,i)-gg(k)
1228 gvdwc(k,j)=gvdwc(k,j)+gg(k)
1232 cgrad gvdwc(l,k)=gvdwc(l,k)+gg(l)
1236 C 12/1/95, revised on 5/20/97
1238 C Calculate the contact function. The ith column of the array JCONT will
1239 C contain the numbers of atoms that make contacts with the atom I (of numbers
1240 C greater than I). The arrays FACONT and GACONT will contain the values of
1241 C the contact function and its derivative.
1243 C Uncomment next line, if the correlation interactions include EVDW explicitly.
1244 c if (j.gt.i+1 .and. evdwij.le.0.0D0) then
1245 C Uncomment next line, if the correlation interactions are contact function only
1246 if (j.gt.i+1.and. eps0ij.gt.0.0D0) then
1248 sigij=sigma(itypi,itypj)
1249 r0ij=rs0(itypi,itypj)
1251 C Check whether the SC's are not too far to make a contact.
1254 call gcont(rij,rcut,1.0d0,0.2d0*rcut,fcont,fprimcont)
1255 C Add a new contact, if the SC's are close enough, but not too close (r<sigma).
1257 if (fcont.gt.0.0D0) then
1258 C If the SC-SC distance if close to sigma, apply spline.
1259 cAdam call gcont(-rij,-1.03d0*sigij,2.0d0*sigij,1.0d0,
1260 cAdam & fcont1,fprimcont1)
1261 cAdam fcont1=1.0d0-fcont1
1262 cAdam if (fcont1.gt.0.0d0) then
1263 cAdam fprimcont=fprimcont*fcont1+fcont*fprimcont1
1264 cAdam fcont=fcont*fcont1
1266 C Uncomment following 4 lines to have the geometric average of the epsilon0's
1267 cga eps0ij=1.0d0/dsqrt(eps0ij)
1269 cga gg(k)=gg(k)*eps0ij
1271 cga eps0ij=-evdwij*eps0ij
1272 C Uncomment for AL's type of SC correlation interactions.
1273 cadam eps0ij=-evdwij
1274 num_conti=num_conti+1
1275 jcont(num_conti,i)=j
1276 facont(num_conti,i)=fcont*eps0ij
1277 fprimcont=eps0ij*fprimcont/rij
1279 cAdam gacont(1,num_conti,i)=-fprimcont*xj+fcont*gg(1)
1280 cAdam gacont(2,num_conti,i)=-fprimcont*yj+fcont*gg(2)
1281 cAdam gacont(3,num_conti,i)=-fprimcont*zj+fcont*gg(3)
1282 C Uncomment following 3 lines for Skolnick's type of SC correlation.
1283 gacont(1,num_conti,i)=-fprimcont*xj
1284 gacont(2,num_conti,i)=-fprimcont*yj
1285 gacont(3,num_conti,i)=-fprimcont*zj
1286 cd write (iout,'(2i5,2f10.5)') i,j,rij,facont(num_conti,i)
1287 cd write (iout,'(2i3,3f10.5)')
1288 cd & i,j,(gacont(kk,num_conti,i),kk=1,3)
1294 num_cont(i)=num_conti
1298 gvdwc(j,i)=expon*gvdwc(j,i)
1299 gvdwx(j,i)=expon*gvdwx(j,i)
1302 C******************************************************************************
1306 C To save time, the factor of EXPON has been extracted from ALL components
1307 C of GVDWC and GRADX. Remember to multiply them by this factor before further
1310 C******************************************************************************
1313 C-----------------------------------------------------------------------------
1314 subroutine eljk(evdw)
1316 C This subroutine calculates the interaction energy of nonbonded side chains
1317 C assuming the LJK potential of interaction.
1319 implicit real*8 (a-h,o-z)
1320 include 'DIMENSIONS'
1321 include 'COMMON.GEO'
1322 include 'COMMON.VAR'
1323 include 'COMMON.LOCAL'
1324 include 'COMMON.CHAIN'
1325 include 'COMMON.DERIV'
1326 include 'COMMON.INTERACT'
1327 include 'COMMON.IOUNITS'
1328 include 'COMMON.NAMES'
1331 c print *,'Entering ELJK nnt=',nnt,' nct=',nct,' expon=',expon
1333 do i=iatsc_s,iatsc_e
1334 itypi=iabs(itype(i))
1335 if (itypi.eq.ntyp1) cycle
1336 itypi1=iabs(itype(i+1))
1341 C Calculate SC interaction energy.
1343 do iint=1,nint_gr(i)
1344 do j=istart(i,iint),iend(i,iint)
1345 itypj=iabs(itype(j))
1346 if (itypj.eq.ntyp1) cycle
1350 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
1351 fac_augm=rrij**expon
1352 e_augm=augm(itypi,itypj)*fac_augm
1353 r_inv_ij=dsqrt(rrij)
1355 r_shift_inv=1.0D0/(rij+r0(itypi,itypj)-sigma(itypi,itypj))
1356 fac=r_shift_inv**expon
1357 C have you changed here?
1361 cd sigm=dabs(aa(itypi,itypj)/bb(itypi,itypj))**(1.0D0/6.0D0)
1362 cd epsi=bb(itypi,itypj)**2/aa(itypi,itypj)
1363 cd write (iout,'(2(a3,i3,2x),8(1pd12.4)/2(3(1pd12.4),5x)/)')
1364 cd & restyp(itypi),i,restyp(itypj),j,aa(itypi,itypj),
1365 cd & bb(itypi,itypj),augm(itypi,itypj),epsi,sigm,
1366 cd & sigma(itypi,itypj),1.0D0/dsqrt(rrij),evdwij,
1367 cd & (c(k,i),k=1,3),(c(k,j),k=1,3)
1370 C Calculate the components of the gradient in DC and X
1372 fac=-2.0D0*rrij*e_augm-r_inv_ij*r_shift_inv*(e1+e1+e2)
1377 gvdwx(k,i)=gvdwx(k,i)-gg(k)
1378 gvdwx(k,j)=gvdwx(k,j)+gg(k)
1379 gvdwc(k,i)=gvdwc(k,i)-gg(k)
1380 gvdwc(k,j)=gvdwc(k,j)+gg(k)
1384 cgrad gvdwc(l,k)=gvdwc(l,k)+gg(l)
1392 gvdwc(j,i)=expon*gvdwc(j,i)
1393 gvdwx(j,i)=expon*gvdwx(j,i)
1398 C-----------------------------------------------------------------------------
1399 subroutine ebp(evdw)
1401 C This subroutine calculates the interaction energy of nonbonded side chains
1402 C assuming the Berne-Pechukas potential of interaction.
1404 implicit real*8 (a-h,o-z)
1405 include 'DIMENSIONS'
1406 include 'COMMON.GEO'
1407 include 'COMMON.VAR'
1408 include 'COMMON.LOCAL'
1409 include 'COMMON.CHAIN'
1410 include 'COMMON.DERIV'
1411 include 'COMMON.NAMES'
1412 include 'COMMON.INTERACT'
1413 include 'COMMON.IOUNITS'
1414 include 'COMMON.CALC'
1415 common /srutu/ icall
1416 c double precision rrsave(maxdim)
1419 c print *,'Entering EBP nnt=',nnt,' nct=',nct,' expon=',expon
1421 c if (icall.eq.0) then
1427 do i=iatsc_s,iatsc_e
1428 itypi=iabs(itype(i))
1429 if (itypi.eq.ntyp1) cycle
1430 itypi1=iabs(itype(i+1))
1434 dxi=dc_norm(1,nres+i)
1435 dyi=dc_norm(2,nres+i)
1436 dzi=dc_norm(3,nres+i)
1437 c dsci_inv=dsc_inv(itypi)
1438 dsci_inv=vbld_inv(i+nres)
1440 C Calculate SC interaction energy.
1442 do iint=1,nint_gr(i)
1443 do j=istart(i,iint),iend(i,iint)
1445 itypj=iabs(itype(j))
1446 if (itypj.eq.ntyp1) cycle
1447 c dscj_inv=dsc_inv(itypj)
1448 dscj_inv=vbld_inv(j+nres)
1449 chi1=chi(itypi,itypj)
1450 chi2=chi(itypj,itypi)
1457 alf12=0.5D0*(alf1+alf2)
1458 C For diagnostics only!!!
1471 dxj=dc_norm(1,nres+j)
1472 dyj=dc_norm(2,nres+j)
1473 dzj=dc_norm(3,nres+j)
1474 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
1475 cd if (icall.eq.0) then
1481 C Calculate the angle-dependent terms of energy & contributions to derivatives.
1483 C Calculate whole angle-dependent part of epsilon and contributions
1484 C to its derivatives
1485 C have you changed here?
1486 fac=(rrij*sigsq)**expon2
1489 evdwij=eps1*eps2rt*eps3rt*(e1+e2)
1490 eps2der=evdwij*eps3rt
1491 eps3der=evdwij*eps2rt
1492 evdwij=evdwij*eps2rt*eps3rt
1495 sigm=dabs(aa/bb)**(1.0D0/6.0D0)
1497 cd write (iout,'(2(a3,i3,2x),15(0pf7.3))')
1498 cd & restyp(itypi),i,restyp(itypj),j,
1499 cd & epsi,sigm,chi1,chi2,chip1,chip2,
1500 cd & eps1,eps2rt**2,eps3rt**2,1.0D0/dsqrt(sigsq),
1501 cd & om1,om2,om12,1.0D0/dsqrt(rrij),
1504 C Calculate gradient components.
1505 e1=e1*eps1*eps2rt**2*eps3rt**2
1506 fac=-expon*(e1+evdwij)
1509 C Calculate radial part of the gradient
1513 C Calculate the angular part of the gradient and sum add the contributions
1514 C to the appropriate components of the Cartesian gradient.
1522 C-----------------------------------------------------------------------------
1523 subroutine egb(evdw)
1525 C This subroutine calculates the interaction energy of nonbonded side chains
1526 C assuming the Gay-Berne potential of interaction.
1528 implicit real*8 (a-h,o-z)
1529 include 'DIMENSIONS'
1530 include 'COMMON.GEO'
1531 include 'COMMON.VAR'
1532 include 'COMMON.LOCAL'
1533 include 'COMMON.CHAIN'
1534 include 'COMMON.DERIV'
1535 include 'COMMON.NAMES'
1536 include 'COMMON.INTERACT'
1537 include 'COMMON.IOUNITS'
1538 include 'COMMON.CALC'
1539 include 'COMMON.CONTROL'
1540 include 'COMMON.SPLITELE'
1541 include 'COMMON.SBRIDGE'
1543 integer xshift,yshift,zshift
1546 ccccc energy_dec=.false.
1547 C print *,'Entering EGB nnt=',nnt,' nct=',nct,' expon=',expon
1550 c if (icall.eq.0) lprn=.false.
1552 C the loop over all 27 posible neigbours (for xshift=0,yshift=0,zshift=0
1553 C we have the original box)
1557 do i=iatsc_s,iatsc_e
1558 itypi=iabs(itype(i))
1559 if (itypi.eq.ntyp1) cycle
1560 itypi1=iabs(itype(i+1))
1564 C Return atom into box, boxxsize is size of box in x dimension
1566 c if (xi.gt.((xshift+0.5d0)*boxxsize)) xi=xi-boxxsize
1567 c if (xi.lt.((xshift-0.5d0)*boxxsize)) xi=xi+boxxsize
1568 C Condition for being inside the proper box
1569 c if ((xi.gt.((xshift+0.5d0)*boxxsize)).or.
1570 c & (xi.lt.((xshift-0.5d0)*boxxsize))) then
1574 c if (yi.gt.((yshift+0.5d0)*boxysize)) yi=yi-boxysize
1575 c if (yi.lt.((yshift-0.5d0)*boxysize)) yi=yi+boxysize
1576 C Condition for being inside the proper box
1577 c if ((yi.gt.((yshift+0.5d0)*boxysize)).or.
1578 c & (yi.lt.((yshift-0.5d0)*boxysize))) then
1582 c if (zi.gt.((zshift+0.5d0)*boxzsize)) zi=zi-boxzsize
1583 c if (zi.lt.((zshift-0.5d0)*boxzsize)) zi=zi+boxzsize
1584 C Condition for being inside the proper box
1585 c if ((zi.gt.((zshift+0.5d0)*boxzsize)).or.
1586 c & (zi.lt.((zshift-0.5d0)*boxzsize))) then
1590 if (xi.lt.0) xi=xi+boxxsize
1592 if (yi.lt.0) yi=yi+boxysize
1594 if (zi.lt.0) zi=zi+boxzsize
1595 C define scaling factor for lipids
1597 C if (positi.le.0) positi=positi+boxzsize
1599 C first for peptide groups
1600 c for each residue check if it is in lipid or lipid water border area
1601 if ((zi.gt.bordlipbot)
1602 &.and.(zi.lt.bordliptop)) then
1603 C the energy transfer exist
1604 if (zi.lt.buflipbot) then
1605 C what fraction I am in
1607 & ((zi-bordlipbot)/lipbufthick)
1608 C lipbufthick is thickenes of lipid buffore
1609 sslipi=sscalelip(fracinbuf)
1610 ssgradlipi=-sscagradlip(fracinbuf)/lipbufthick
1611 elseif (zi.gt.bufliptop) then
1612 fracinbuf=1.0d0-((bordliptop-zi)/lipbufthick)
1613 sslipi=sscalelip(fracinbuf)
1614 ssgradlipi=sscagradlip(fracinbuf)/lipbufthick
1624 C xi=xi+xshift*boxxsize
1625 C yi=yi+yshift*boxysize
1626 C zi=zi+zshift*boxzsize
1628 dxi=dc_norm(1,nres+i)
1629 dyi=dc_norm(2,nres+i)
1630 dzi=dc_norm(3,nres+i)
1631 c dsci_inv=dsc_inv(itypi)
1632 dsci_inv=vbld_inv(i+nres)
1633 c write (iout,*) "i",i,dsc_inv(itypi),dsci_inv,1.0d0/vbld(i+nres)
1634 c write (iout,*) "dcnori",dxi*dxi+dyi*dyi+dzi*dzi
1636 C Calculate SC interaction energy.
1638 do iint=1,nint_gr(i)
1639 do j=istart(i,iint),iend(i,iint)
1640 IF (dyn_ss_mask(i).and.dyn_ss_mask(j)) THEN
1642 c write(iout,*) "PRZED ZWYKLE", evdwij
1643 call dyn_ssbond_ene(i,j,evdwij)
1644 c write(iout,*) "PO ZWYKLE", evdwij
1647 if (energy_dec) write (iout,'(a6,2i5,0pf7.3,a3)')
1648 & 'evdw',i,j,evdwij,' ss'
1649 C triple bond artifac removal
1650 do k=j+1,iend(i,iint)
1651 C search over all next residues
1652 if (dyn_ss_mask(k)) then
1653 C check if they are cysteins
1654 C write(iout,*) 'k=',k
1656 c write(iout,*) "PRZED TRI", evdwij
1657 evdwij_przed_tri=evdwij
1658 call triple_ssbond_ene(i,j,k,evdwij)
1659 c if(evdwij_przed_tri.ne.evdwij) then
1660 c write (iout,*) "TRI:", evdwij, evdwij_przed_tri
1663 c write(iout,*) "PO TRI", evdwij
1664 C call the energy function that removes the artifical triple disulfide
1665 C bond the soubroutine is located in ssMD.F
1667 if (energy_dec) write (iout,'(a6,2i5,0pf7.3,a3)')
1668 & 'evdw',i,j,evdwij,'tss'
1669 endif!dyn_ss_mask(k)
1673 itypj=iabs(itype(j))
1674 if (itypj.eq.ntyp1) cycle
1675 c dscj_inv=dsc_inv(itypj)
1676 dscj_inv=vbld_inv(j+nres)
1677 c write (iout,*) "j",j,dsc_inv(itypj),dscj_inv,
1678 c & 1.0d0/vbld(j+nres)
1679 c write (iout,*) "i",i," j", j," itype",itype(i),itype(j)
1680 sig0ij=sigma(itypi,itypj)
1681 chi1=chi(itypi,itypj)
1682 chi2=chi(itypj,itypi)
1689 alf12=0.5D0*(alf1+alf2)
1690 C For diagnostics only!!!
1703 C Return atom J into box the original box
1705 c if (xj.gt.((0.5d0)*boxxsize)) xj=xj-boxxsize
1706 c if (xj.lt.((-0.5d0)*boxxsize)) xj=xj+boxxsize
1707 C Condition for being inside the proper box
1708 c if ((xj.gt.((0.5d0)*boxxsize)).or.
1709 c & (xj.lt.((-0.5d0)*boxxsize))) then
1713 c if (yj.gt.((0.5d0)*boxysize)) yj=yj-boxysize
1714 c if (yj.lt.((-0.5d0)*boxysize)) yj=yj+boxysize
1715 C Condition for being inside the proper box
1716 c if ((yj.gt.((0.5d0)*boxysize)).or.
1717 c & (yj.lt.((-0.5d0)*boxysize))) then
1721 c if (zj.gt.((0.5d0)*boxzsize)) zj=zj-boxzsize
1722 c if (zj.lt.((-0.5d0)*boxzsize)) zj=zj+boxzsize
1723 C Condition for being inside the proper box
1724 c if ((zj.gt.((0.5d0)*boxzsize)).or.
1725 c & (zj.lt.((-0.5d0)*boxzsize))) then
1729 if (xj.lt.0) xj=xj+boxxsize
1731 if (yj.lt.0) yj=yj+boxysize
1733 if (zj.lt.0) zj=zj+boxzsize
1734 if ((zj.gt.bordlipbot)
1735 &.and.(zj.lt.bordliptop)) then
1736 C the energy transfer exist
1737 if (zj.lt.buflipbot) then
1738 C what fraction I am in
1740 & ((zj-bordlipbot)/lipbufthick)
1741 C lipbufthick is thickenes of lipid buffore
1742 sslipj=sscalelip(fracinbuf)
1743 ssgradlipj=-sscagradlip(fracinbuf)/lipbufthick
1744 elseif (zj.gt.bufliptop) then
1745 fracinbuf=1.0d0-((bordliptop-zj)/lipbufthick)
1746 sslipj=sscalelip(fracinbuf)
1747 ssgradlipj=sscagradlip(fracinbuf)/lipbufthick
1756 aa=aa_lip(itypi,itypj)*(sslipi+sslipj)/2.0d0
1757 & +aa_aq(itypi,itypj)*(2.0d0-sslipi-sslipj)/2.0d0
1758 bb=bb_lip(itypi,itypj)*(sslipi+sslipj)/2.0d0
1759 & +bb_aq(itypi,itypj)*(2.0d0-sslipi-sslipj)/2.0d0
1760 C if (aa.ne.aa_aq(itypi,itypj)) write(63,'(2e10.5)')
1761 C &(aa-aa_aq(itypi,itypj)),(bb-bb_aq(itypi,itypj))
1762 C if (ssgradlipj.gt.0.0d0) print *,"??WTF??"
1763 C print *,sslipi,sslipj,bordlipbot,zi,zj
1764 dist_init=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
1772 xj=xj_safe+xshift*boxxsize
1773 yj=yj_safe+yshift*boxysize
1774 zj=zj_safe+zshift*boxzsize
1775 dist_temp=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
1776 if(dist_temp.lt.dist_init) then
1786 if (subchap.eq.1) then
1795 dxj=dc_norm(1,nres+j)
1796 dyj=dc_norm(2,nres+j)
1797 dzj=dc_norm(3,nres+j)
1801 c write (iout,*) "dcnorj",dxi*dxi+dyi*dyi+dzi*dzi
1802 c write (iout,*) "j",j," dc_norm",
1803 c & dc_norm(1,nres+j),dc_norm(2,nres+j),dc_norm(3,nres+j)
1804 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
1806 sss=sscale((1.0d0/rij)/sigma(itypi,itypj))
1807 sssgrad=sscagrad((1.0d0/rij)/sigma(itypi,itypj))
1809 c write (iout,'(a7,4f8.3)')
1810 c & "ssscale",sss,((1.0d0/rij)/sigma(itypi,itypj)),r_cut,rlamb
1811 if (sss.gt.0.0d0) then
1812 C Calculate angle-dependent terms of energy and contributions to their
1816 sig=sig0ij*dsqrt(sigsq)
1817 rij_shift=1.0D0/rij-sig+sig0ij
1818 c for diagnostics; uncomment
1819 c rij_shift=1.2*sig0ij
1820 C I hate to put IF's in the loops, but here don't have another choice!!!!
1821 if (rij_shift.le.0.0D0) then
1823 cd write (iout,'(2(a3,i3,2x),17(0pf7.3))')
1824 cd & restyp(itypi),i,restyp(itypj),j,
1825 cd & rij_shift,1.0D0/rij,sig,sig0ij,sigsq,1-dsqrt(sigsq)
1829 c---------------------------------------------------------------
1830 rij_shift=1.0D0/rij_shift
1831 fac=rij_shift**expon
1832 C here to start with
1837 evdwij=eps1*eps2rt*eps3rt*(e1+e2)
1838 eps2der=evdwij*eps3rt
1839 eps3der=evdwij*eps2rt
1840 C write(63,'(2i3,2e10.3,2f10.5)') i,j,aa,bb, evdwij,
1841 C &((sslipi+sslipj)/2.0d0+
1842 C &(2.0d0-sslipi-sslipj)/2.0d0)
1843 c write (iout,*) "sigsq",sigsq," sig",sig," eps2rt",eps2rt,
1844 c & " eps3rt",eps3rt," eps1",eps1," e1",e1," e2",e2
1845 evdwij=evdwij*eps2rt*eps3rt
1846 evdw=evdw+evdwij*sss
1848 sigm=dabs(aa/bb)**(1.0D0/6.0D0)
1850 write (iout,'(2(a3,i3,2x),17(0pf7.3))')
1851 & restyp(itypi),i,restyp(itypj),j,
1852 & epsi,sigm,chi1,chi2,chip1,chip2,
1853 & eps1,eps2rt**2,eps3rt**2,sig,sig0ij,
1854 & om1,om2,om12,1.0D0/rij,1.0D0/rij_shift,
1858 if (energy_dec) write (iout,'(a6,2i5,0pf7.3)')
1861 C Calculate gradient components.
1862 e1=e1*eps1*eps2rt**2*eps3rt**2
1863 fac=-expon*(e1+evdwij)*rij_shift
1866 c print '(2i4,6f8.4)',i,j,sss,sssgrad*
1867 c & evdwij,fac,sigma(itypi,itypj),expon
1868 fac=fac+evdwij/sss*sssgrad/sigma(itypi,itypj)*rij
1870 C Calculate the radial part of the gradient
1871 gg_lipi(3)=eps1*(eps2rt*eps2rt)
1872 &*(eps3rt*eps3rt)*sss/2.0d0*(faclip*faclip*
1873 & (aa_lip(itypi,itypj)-aa_aq(itypi,itypj))
1874 &+faclip*(bb_lip(itypi,itypj)-bb_aq(itypi,itypj)))
1875 gg_lipj(3)=ssgradlipj*gg_lipi(3)
1876 gg_lipi(3)=gg_lipi(3)*ssgradlipi
1882 C Calculate angular part of the gradient.
1892 c write (iout,*) "Number of loop steps in EGB:",ind
1893 cccc energy_dec=.false.
1896 C-----------------------------------------------------------------------------
1897 subroutine egbv(evdw)
1899 C This subroutine calculates the interaction energy of nonbonded side chains
1900 C assuming the Gay-Berne-Vorobjev potential of interaction.
1902 implicit real*8 (a-h,o-z)
1903 include 'DIMENSIONS'
1904 include 'COMMON.GEO'
1905 include 'COMMON.VAR'
1906 include 'COMMON.LOCAL'
1907 include 'COMMON.CHAIN'
1908 include 'COMMON.DERIV'
1909 include 'COMMON.NAMES'
1910 include 'COMMON.INTERACT'
1911 include 'COMMON.IOUNITS'
1912 include 'COMMON.CALC'
1913 common /srutu/ icall
1916 c print *,'Entering EGB nnt=',nnt,' nct=',nct,' expon=',expon
1919 c if (icall.eq.0) lprn=.true.
1921 do i=iatsc_s,iatsc_e
1922 itypi=iabs(itype(i))
1923 if (itypi.eq.ntyp1) cycle
1924 itypi1=iabs(itype(i+1))
1929 if (xi.lt.0) xi=xi+boxxsize
1931 if (yi.lt.0) yi=yi+boxysize
1933 if (zi.lt.0) zi=zi+boxzsize
1934 C define scaling factor for lipids
1936 C if (positi.le.0) positi=positi+boxzsize
1938 C first for peptide groups
1939 c for each residue check if it is in lipid or lipid water border area
1940 if ((zi.gt.bordlipbot)
1941 &.and.(zi.lt.bordliptop)) then
1942 C the energy transfer exist
1943 if (zi.lt.buflipbot) then
1944 C what fraction I am in
1946 & ((zi-bordlipbot)/lipbufthick)
1947 C lipbufthick is thickenes of lipid buffore
1948 sslipi=sscalelip(fracinbuf)
1949 ssgradlipi=-sscagradlip(fracinbuf)/lipbufthick
1950 elseif (zi.gt.bufliptop) then
1951 fracinbuf=1.0d0-((bordliptop-zi)/lipbufthick)
1952 sslipi=sscalelip(fracinbuf)
1953 ssgradlipi=sscagradlip(fracinbuf)/lipbufthick
1963 dxi=dc_norm(1,nres+i)
1964 dyi=dc_norm(2,nres+i)
1965 dzi=dc_norm(3,nres+i)
1966 c dsci_inv=dsc_inv(itypi)
1967 dsci_inv=vbld_inv(i+nres)
1969 C Calculate SC interaction energy.
1971 do iint=1,nint_gr(i)
1972 do j=istart(i,iint),iend(i,iint)
1974 itypj=iabs(itype(j))
1975 if (itypj.eq.ntyp1) cycle
1976 c dscj_inv=dsc_inv(itypj)
1977 dscj_inv=vbld_inv(j+nres)
1978 sig0ij=sigma(itypi,itypj)
1979 r0ij=r0(itypi,itypj)
1980 chi1=chi(itypi,itypj)
1981 chi2=chi(itypj,itypi)
1988 alf12=0.5D0*(alf1+alf2)
1989 C For diagnostics only!!!
2003 if (xj.lt.0) xj=xj+boxxsize
2005 if (yj.lt.0) yj=yj+boxysize
2007 if (zj.lt.0) zj=zj+boxzsize
2008 if ((zj.gt.bordlipbot)
2009 &.and.(zj.lt.bordliptop)) then
2010 C the energy transfer exist
2011 if (zj.lt.buflipbot) then
2012 C what fraction I am in
2014 & ((zj-bordlipbot)/lipbufthick)
2015 C lipbufthick is thickenes of lipid buffore
2016 sslipj=sscalelip(fracinbuf)
2017 ssgradlipj=-sscagradlip(fracinbuf)/lipbufthick
2018 elseif (zj.gt.bufliptop) then
2019 fracinbuf=1.0d0-((bordliptop-zj)/lipbufthick)
2020 sslipj=sscalelip(fracinbuf)
2021 ssgradlipj=sscagradlip(fracinbuf)/lipbufthick
2030 aa=aa_lip(itypi,itypj)*(sslipi+sslipj)/2.0d0
2031 & +aa_aq(itypi,itypj)*(2.0d0-sslipi-sslipj)/2.0d0
2032 bb=bb_lip(itypi,itypj)*(sslipi+sslipj)/2.0d0
2033 & +bb_aq(itypi,itypj)*(2.0d0-sslipi-sslipj)/2.0d0
2034 C if (aa.ne.aa_aq(itypi,itypj)) write(63,'2e10.5')
2035 C &(aa-aa_aq(itypi,itypj)),(bb-bb_aq(itypi,itypj))
2036 dist_init=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
2044 xj=xj_safe+xshift*boxxsize
2045 yj=yj_safe+yshift*boxysize
2046 zj=zj_safe+zshift*boxzsize
2047 dist_temp=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
2048 if(dist_temp.lt.dist_init) then
2058 if (subchap.eq.1) then
2067 dxj=dc_norm(1,nres+j)
2068 dyj=dc_norm(2,nres+j)
2069 dzj=dc_norm(3,nres+j)
2070 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
2072 C Calculate angle-dependent terms of energy and contributions to their
2076 sig=sig0ij*dsqrt(sigsq)
2077 rij_shift=1.0D0/rij-sig+r0ij
2078 C I hate to put IF's in the loops, but here don't have another choice!!!!
2079 if (rij_shift.le.0.0D0) then
2084 c---------------------------------------------------------------
2085 rij_shift=1.0D0/rij_shift
2086 fac=rij_shift**expon
2089 evdwij=eps1*eps2rt*eps3rt*(e1+e2)
2090 eps2der=evdwij*eps3rt
2091 eps3der=evdwij*eps2rt
2092 fac_augm=rrij**expon
2093 e_augm=augm(itypi,itypj)*fac_augm
2094 evdwij=evdwij*eps2rt*eps3rt
2095 evdw=evdw+evdwij+e_augm
2097 sigm=dabs(aa/bb)**(1.0D0/6.0D0)
2099 write (iout,'(2(a3,i3,2x),17(0pf7.3))')
2100 & restyp(itypi),i,restyp(itypj),j,
2101 & epsi,sigm,sig,(augm(itypi,itypj)/epsi)**(1.0D0/12.0D0),
2102 & chi1,chi2,chip1,chip2,
2103 & eps1,eps2rt**2,eps3rt**2,
2104 & om1,om2,om12,1.0D0/rij,1.0D0/rij_shift,
2107 C Calculate gradient components.
2108 e1=e1*eps1*eps2rt**2*eps3rt**2
2109 fac=-expon*(e1+evdwij)*rij_shift
2111 fac=rij*fac-2*expon*rrij*e_augm
2112 fac=fac+evdwij/sss*sssgrad/sigma(itypi,itypj)*rij
2113 C Calculate the radial part of the gradient
2117 C Calculate angular part of the gradient.
2123 C-----------------------------------------------------------------------------
2124 subroutine sc_angular
2125 C Calculate eps1,eps2,eps3,sigma, and parts of their derivatives in om1,om2,
2126 C om12. Called by ebp, egb, and egbv.
2128 include 'COMMON.CALC'
2129 include 'COMMON.IOUNITS'
2133 om1=dxi*erij(1)+dyi*erij(2)+dzi*erij(3)
2134 om2=dxj*erij(1)+dyj*erij(2)+dzj*erij(3)
2135 om12=dxi*dxj+dyi*dyj+dzi*dzj
2137 C Calculate eps1(om12) and its derivative in om12
2138 faceps1=1.0D0-om12*chiom12
2139 faceps1_inv=1.0D0/faceps1
2140 eps1=dsqrt(faceps1_inv)
2141 C Following variable is eps1*deps1/dom12
2142 eps1_om12=faceps1_inv*chiom12
2147 c write (iout,*) "om12",om12," eps1",eps1
2148 C Calculate sigma(om1,om2,om12) and the derivatives of sigma**2 in om1,om2,
2153 facsig=om1*chiom1+om2*chiom2-2.0D0*om1om2*chiom12
2154 sigsq=1.0D0-facsig*faceps1_inv
2155 sigsq_om1=(chiom1-chiom12*om2)*faceps1_inv
2156 sigsq_om2=(chiom2-chiom12*om1)*faceps1_inv
2157 sigsq_om12=-chi12*(om1om2*faceps1-om12*facsig)*faceps1_inv**2
2163 c write (iout,*) "chiom1",chiom1," chiom2",chiom2," chiom12",chiom12
2164 c write (iout,*) "faceps1",faceps1," faceps1_inv",faceps1_inv,
2166 C Calculate eps2 and its derivatives in om1, om2, and om12.
2169 chipom12=chip12*om12
2170 facp=1.0D0-om12*chipom12
2172 facp1=om1*chipom1+om2*chipom2-2.0D0*om1om2*chipom12
2173 c write (iout,*) "chipom1",chipom1," chipom2",chipom2,
2174 c & " chipom12",chipom12," facp",facp," facp_inv",facp_inv
2175 C Following variable is the square root of eps2
2176 eps2rt=1.0D0-facp1*facp_inv
2177 C Following three variables are the derivatives of the square root of eps
2178 C in om1, om2, and om12.
2179 eps2rt_om1=-4.0D0*(chipom1-chipom12*om2)*facp_inv
2180 eps2rt_om2=-4.0D0*(chipom2-chipom12*om1)*facp_inv
2181 eps2rt_om12=4.0D0*chip12*(om1om2*facp-om12*facp1)*facp_inv**2
2182 C Evaluate the "asymmetric" factor in the VDW constant, eps3
2183 eps3rt=1.0D0-alf1*om1+alf2*om2-alf12*om12
2184 c write (iout,*) "eps2rt",eps2rt," eps3rt",eps3rt
2185 c write (iout,*) "eps2rt_om1",eps2rt_om1," eps2rt_om2",eps2rt_om2,
2186 c & " eps2rt_om12",eps2rt_om12
2187 C Calculate whole angle-dependent part of epsilon and contributions
2188 C to its derivatives
2191 C----------------------------------------------------------------------------
2193 implicit real*8 (a-h,o-z)
2194 include 'DIMENSIONS'
2195 include 'COMMON.CHAIN'
2196 include 'COMMON.DERIV'
2197 include 'COMMON.CALC'
2198 include 'COMMON.IOUNITS'
2199 double precision dcosom1(3),dcosom2(3)
2200 cc print *,'sss=',sss
2201 eom1=eps2der*eps2rt_om1-2.0D0*alf1*eps3der+sigder*sigsq_om1
2202 eom2=eps2der*eps2rt_om2+2.0D0*alf2*eps3der+sigder*sigsq_om2
2203 eom12=evdwij*eps1_om12+eps2der*eps2rt_om12
2204 & -2.0D0*alf12*eps3der+sigder*sigsq_om12
2208 c eom12=evdwij*eps1_om12
2210 c write (iout,*) "eps2der",eps2der," eps3der",eps3der,
2211 c & " sigder",sigder
2212 c write (iout,*) "eps1_om12",eps1_om12," eps2rt_om12",eps2rt_om12
2213 c write (iout,*) "eom1",eom1," eom2",eom2," eom12",eom12
2215 dcosom1(k)=rij*(dc_norm(k,nres+i)-om1*erij(k))
2216 dcosom2(k)=rij*(dc_norm(k,nres+j)-om2*erij(k))
2219 gg(k)=(gg(k)+eom1*dcosom1(k)+eom2*dcosom2(k))*sss
2221 c write (iout,*) "gg",(gg(k),k=1,3)
2223 gvdwx(k,i)=gvdwx(k,i)-gg(k)+gg_lipi(k)
2224 & +(eom12*(dc_norm(k,nres+j)-om12*dc_norm(k,nres+i))
2225 & +eom1*(erij(k)-om1*dc_norm(k,nres+i)))*dsci_inv*sss
2226 gvdwx(k,j)=gvdwx(k,j)+gg(k)+gg_lipj(k)
2227 & +(eom12*(dc_norm(k,nres+i)-om12*dc_norm(k,nres+j))
2228 & +eom2*(erij(k)-om2*dc_norm(k,nres+j)))*dscj_inv*sss
2229 c write (iout,*)(eom12*(dc_norm(k,nres+j)-om12*dc_norm(k,nres+i))
2230 c & +eom1*(erij(k)-om1*dc_norm(k,nres+i)))*dsci_inv
2231 c write (iout,*)(eom12*(dc_norm(k,nres+i)-om12*dc_norm(k,nres+j))
2232 c & +eom2*(erij(k)-om2*dc_norm(k,nres+j)))*dscj_inv
2235 C Calculate the components of the gradient in DC and X
2239 cgrad gvdwc(l,k)=gvdwc(l,k)+gg(l)
2243 gvdwc(l,i)=gvdwc(l,i)-gg(l)+gg_lipi(l)
2244 gvdwc(l,j)=gvdwc(l,j)+gg(l)+gg_lipj(l)
2248 C-----------------------------------------------------------------------
2249 subroutine e_softsphere(evdw)
2251 C This subroutine calculates the interaction energy of nonbonded side chains
2252 C assuming the LJ potential of interaction.
2254 implicit real*8 (a-h,o-z)
2255 include 'DIMENSIONS'
2256 parameter (accur=1.0d-10)
2257 include 'COMMON.GEO'
2258 include 'COMMON.VAR'
2259 include 'COMMON.LOCAL'
2260 include 'COMMON.CHAIN'
2261 include 'COMMON.DERIV'
2262 include 'COMMON.INTERACT'
2263 include 'COMMON.TORSION'
2264 include 'COMMON.SBRIDGE'
2265 include 'COMMON.NAMES'
2266 include 'COMMON.IOUNITS'
2267 include 'COMMON.CONTACTS'
2269 cd print *,'Entering Esoft_sphere nnt=',nnt,' nct=',nct
2271 do i=iatsc_s,iatsc_e
2272 itypi=iabs(itype(i))
2273 if (itypi.eq.ntyp1) cycle
2274 itypi1=iabs(itype(i+1))
2279 C Calculate SC interaction energy.
2281 do iint=1,nint_gr(i)
2282 cd write (iout,*) 'i=',i,' iint=',iint,' istart=',istart(i,iint),
2283 cd & 'iend=',iend(i,iint)
2284 do j=istart(i,iint),iend(i,iint)
2285 itypj=iabs(itype(j))
2286 if (itypj.eq.ntyp1) cycle
2290 rij=xj*xj+yj*yj+zj*zj
2291 c write (iout,*)'i=',i,' j=',j,' itypi=',itypi,' itypj=',itypj
2292 r0ij=r0(itypi,itypj)
2294 c print *,i,j,r0ij,dsqrt(rij)
2295 if (rij.lt.r0ijsq) then
2296 evdwij=0.25d0*(rij-r0ijsq)**2
2304 C Calculate the components of the gradient in DC and X
2310 gvdwx(k,i)=gvdwx(k,i)-gg(k)
2311 gvdwx(k,j)=gvdwx(k,j)+gg(k)
2312 gvdwc(k,i)=gvdwc(k,i)-gg(k)
2313 gvdwc(k,j)=gvdwc(k,j)+gg(k)
2317 cgrad gvdwc(l,k)=gvdwc(l,k)+gg(l)
2325 C--------------------------------------------------------------------------
2326 subroutine eelec_soft_sphere(ees,evdw1,eel_loc,eello_turn3,
2329 C Soft-sphere potential of p-p interaction
2331 implicit real*8 (a-h,o-z)
2332 include 'DIMENSIONS'
2333 include 'COMMON.CONTROL'
2334 include 'COMMON.IOUNITS'
2335 include 'COMMON.GEO'
2336 include 'COMMON.VAR'
2337 include 'COMMON.LOCAL'
2338 include 'COMMON.CHAIN'
2339 include 'COMMON.DERIV'
2340 include 'COMMON.INTERACT'
2341 include 'COMMON.CONTACTS'
2342 include 'COMMON.TORSION'
2343 include 'COMMON.VECTORS'
2344 include 'COMMON.FFIELD'
2346 C write(iout,*) 'In EELEC_soft_sphere'
2353 do i=iatel_s,iatel_e
2354 if (itype(i).eq.ntyp1 .or. itype(i+1).eq.ntyp1) cycle
2358 xmedi=c(1,i)+0.5d0*dxi
2359 ymedi=c(2,i)+0.5d0*dyi
2360 zmedi=c(3,i)+0.5d0*dzi
2361 xmedi=mod(xmedi,boxxsize)
2362 if (xmedi.lt.0) xmedi=xmedi+boxxsize
2363 ymedi=mod(ymedi,boxysize)
2364 if (ymedi.lt.0) ymedi=ymedi+boxysize
2365 zmedi=mod(zmedi,boxzsize)
2366 if (zmedi.lt.0) zmedi=zmedi+boxzsize
2368 c write (iout,*) 'i',i,' ielstart',ielstart(i),' ielend',ielend(i)
2369 do j=ielstart(i),ielend(i)
2370 if (itype(j).eq.ntyp1 .or. itype(j+1).eq.ntyp1) cycle
2374 if (j.eq.i+2 .and. itelj.eq.2) iteli=2
2375 r0ij=rpp(iteli,itelj)
2384 if (xj.lt.0) xj=xj+boxxsize
2386 if (yj.lt.0) yj=yj+boxysize
2388 if (zj.lt.0) zj=zj+boxzsize
2389 dist_init=(xj-xmedi)**2+(yj-ymedi)**2+(zj-zmedi)**2
2397 xj=xj_safe+xshift*boxxsize
2398 yj=yj_safe+yshift*boxysize
2399 zj=zj_safe+zshift*boxzsize
2400 dist_temp=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
2401 if(dist_temp.lt.dist_init) then
2411 if (isubchap.eq.1) then
2420 rij=xj*xj+yj*yj+zj*zj
2421 sss=sscale(sqrt(rij))
2422 sssgrad=sscagrad(sqrt(rij))
2423 if (rij.lt.r0ijsq) then
2424 evdw1ij=0.25d0*(rij-r0ijsq)**2
2430 evdw1=evdw1+evdw1ij*sss
2432 C Calculate contributions to the Cartesian gradient.
2434 ggg(1)=fac*xj*sssgrad
2435 ggg(2)=fac*yj*sssgrad
2436 ggg(3)=fac*zj*sssgrad
2438 gvdwpp(k,i)=gvdwpp(k,i)-ggg(k)
2439 gvdwpp(k,j)=gvdwpp(k,j)+ggg(k)
2442 * Loop over residues i+1 thru j-1.
2446 cgrad gelc(l,k)=gelc(l,k)+ggg(l)
2451 cgrad do i=nnt,nct-1
2453 cgrad gelc(k,i)=gelc(k,i)+0.5d0*gelc(k,i)
2455 cgrad do j=i+1,nct-1
2457 cgrad gelc(k,i)=gelc(k,i)+gelc(k,j)
2463 c------------------------------------------------------------------------------
2464 subroutine vec_and_deriv
2465 implicit real*8 (a-h,o-z)
2466 include 'DIMENSIONS'
2470 include 'COMMON.IOUNITS'
2471 include 'COMMON.GEO'
2472 include 'COMMON.VAR'
2473 include 'COMMON.LOCAL'
2474 include 'COMMON.CHAIN'
2475 include 'COMMON.VECTORS'
2476 include 'COMMON.SETUP'
2477 include 'COMMON.TIME1'
2478 dimension uyder(3,3,2),uzder(3,3,2),vbld_inv_temp(2)
2479 C Compute the local reference systems. For reference system (i), the
2480 C X-axis points from CA(i) to CA(i+1), the Y axis is in the
2481 C CA(i)-CA(i+1)-CA(i+2) plane, and the Z axis is perpendicular to this plane.
2483 do i=ivec_start,ivec_end
2487 if (i.eq.nres-1) then
2488 C Case of the last full residue
2489 C Compute the Z-axis
2490 call vecpr(dc_norm(1,i),dc_norm(1,i-1),uz(1,i))
2491 costh=dcos(pi-theta(nres))
2492 fac=1.0d0/dsqrt(1.0d0-costh*costh)
2496 C Compute the derivatives of uz
2498 uzder(2,1,1)=-dc_norm(3,i-1)
2499 uzder(3,1,1)= dc_norm(2,i-1)
2500 uzder(1,2,1)= dc_norm(3,i-1)
2502 uzder(3,2,1)=-dc_norm(1,i-1)
2503 uzder(1,3,1)=-dc_norm(2,i-1)
2504 uzder(2,3,1)= dc_norm(1,i-1)
2507 uzder(2,1,2)= dc_norm(3,i)
2508 uzder(3,1,2)=-dc_norm(2,i)
2509 uzder(1,2,2)=-dc_norm(3,i)
2511 uzder(3,2,2)= dc_norm(1,i)
2512 uzder(1,3,2)= dc_norm(2,i)
2513 uzder(2,3,2)=-dc_norm(1,i)
2515 C Compute the Y-axis
2518 uy(k,i)=fac*(dc_norm(k,i-1)-costh*dc_norm(k,i))
2520 C Compute the derivatives of uy
2523 uyder(k,j,1)=2*dc_norm(k,i-1)*dc_norm(j,i)
2524 & -dc_norm(k,i)*dc_norm(j,i-1)
2525 uyder(k,j,2)=-dc_norm(j,i)*dc_norm(k,i)
2527 uyder(j,j,1)=uyder(j,j,1)-costh
2528 uyder(j,j,2)=1.0d0+uyder(j,j,2)
2533 uygrad(l,k,j,i)=uyder(l,k,j)
2534 uzgrad(l,k,j,i)=uzder(l,k,j)
2538 call unormderiv(uy(1,i),uyder(1,1,1),facy,uygrad(1,1,1,i))
2539 call unormderiv(uy(1,i),uyder(1,1,2),facy,uygrad(1,1,2,i))
2540 call unormderiv(uz(1,i),uzder(1,1,1),fac,uzgrad(1,1,1,i))
2541 call unormderiv(uz(1,i),uzder(1,1,2),fac,uzgrad(1,1,2,i))
2544 C Compute the Z-axis
2545 call vecpr(dc_norm(1,i),dc_norm(1,i+1),uz(1,i))
2546 costh=dcos(pi-theta(i+2))
2547 fac=1.0d0/dsqrt(1.0d0-costh*costh)
2551 C Compute the derivatives of uz
2553 uzder(2,1,1)=-dc_norm(3,i+1)
2554 uzder(3,1,1)= dc_norm(2,i+1)
2555 uzder(1,2,1)= dc_norm(3,i+1)
2557 uzder(3,2,1)=-dc_norm(1,i+1)
2558 uzder(1,3,1)=-dc_norm(2,i+1)
2559 uzder(2,3,1)= dc_norm(1,i+1)
2562 uzder(2,1,2)= dc_norm(3,i)
2563 uzder(3,1,2)=-dc_norm(2,i)
2564 uzder(1,2,2)=-dc_norm(3,i)
2566 uzder(3,2,2)= dc_norm(1,i)
2567 uzder(1,3,2)= dc_norm(2,i)
2568 uzder(2,3,2)=-dc_norm(1,i)
2570 C Compute the Y-axis
2573 uy(k,i)=facy*(dc_norm(k,i+1)-costh*dc_norm(k,i))
2575 C Compute the derivatives of uy
2578 uyder(k,j,1)=2*dc_norm(k,i+1)*dc_norm(j,i)
2579 & -dc_norm(k,i)*dc_norm(j,i+1)
2580 uyder(k,j,2)=-dc_norm(j,i)*dc_norm(k,i)
2582 uyder(j,j,1)=uyder(j,j,1)-costh
2583 uyder(j,j,2)=1.0d0+uyder(j,j,2)
2588 uygrad(l,k,j,i)=uyder(l,k,j)
2589 uzgrad(l,k,j,i)=uzder(l,k,j)
2593 call unormderiv(uy(1,i),uyder(1,1,1),facy,uygrad(1,1,1,i))
2594 call unormderiv(uy(1,i),uyder(1,1,2),facy,uygrad(1,1,2,i))
2595 call unormderiv(uz(1,i),uzder(1,1,1),fac,uzgrad(1,1,1,i))
2596 call unormderiv(uz(1,i),uzder(1,1,2),fac,uzgrad(1,1,2,i))
2600 vbld_inv_temp(1)=vbld_inv(i+1)
2601 if (i.lt.nres-1) then
2602 vbld_inv_temp(2)=vbld_inv(i+2)
2604 vbld_inv_temp(2)=vbld_inv(i)
2609 uygrad(l,k,j,i)=vbld_inv_temp(j)*uygrad(l,k,j,i)
2610 uzgrad(l,k,j,i)=vbld_inv_temp(j)*uzgrad(l,k,j,i)
2615 #if defined(PARVEC) && defined(MPI)
2616 if (nfgtasks1.gt.1) then
2618 c print *,"Processor",fg_rank1,kolor1," ivec_start",ivec_start,
2619 c & " ivec_displ",(ivec_displ(i),i=0,nfgtasks1-1),
2620 c & " ivec_count",(ivec_count(i),i=0,nfgtasks1-1)
2621 call MPI_Allgatherv(uy(1,ivec_start),ivec_count(fg_rank1),
2622 & MPI_UYZ,uy(1,1),ivec_count(0),ivec_displ(0),MPI_UYZ,
2624 call MPI_Allgatherv(uz(1,ivec_start),ivec_count(fg_rank1),
2625 & MPI_UYZ,uz(1,1),ivec_count(0),ivec_displ(0),MPI_UYZ,
2627 call MPI_Allgatherv(uygrad(1,1,1,ivec_start),
2628 & ivec_count(fg_rank1),MPI_UYZGRAD,uygrad(1,1,1,1),ivec_count(0),
2629 & ivec_displ(0),MPI_UYZGRAD,FG_COMM1,IERR)
2630 call MPI_Allgatherv(uzgrad(1,1,1,ivec_start),
2631 & ivec_count(fg_rank1),MPI_UYZGRAD,uzgrad(1,1,1,1),ivec_count(0),
2632 & ivec_displ(0),MPI_UYZGRAD,FG_COMM1,IERR)
2633 time_gather=time_gather+MPI_Wtime()-time00
2635 c if (fg_rank.eq.0) then
2636 c write (iout,*) "Arrays UY and UZ"
2638 c write (iout,'(i5,3f10.5,5x,3f10.5)') i,(uy(k,i),k=1,3),
2645 C-----------------------------------------------------------------------------
2646 subroutine check_vecgrad
2647 implicit real*8 (a-h,o-z)
2648 include 'DIMENSIONS'
2649 include 'COMMON.IOUNITS'
2650 include 'COMMON.GEO'
2651 include 'COMMON.VAR'
2652 include 'COMMON.LOCAL'
2653 include 'COMMON.CHAIN'
2654 include 'COMMON.VECTORS'
2655 dimension uygradt(3,3,2,maxres),uzgradt(3,3,2,maxres)
2656 dimension uyt(3,maxres),uzt(3,maxres)
2657 dimension uygradn(3,3,2),uzgradn(3,3,2),erij(3)
2658 double precision delta /1.0d-7/
2661 crc write(iout,'(2i5,2(3f10.5,5x))') i,1,dc_norm(:,i)
2662 crc write(iout,'(2i5,2(3f10.5,5x))') i,2,uy(:,i)
2663 crc write(iout,'(2i5,2(3f10.5,5x)/)')i,3,uz(:,i)
2664 cd write(iout,'(2i5,2(3f10.5,5x))') i,1,
2665 cd & (dc_norm(if90,i),if90=1,3)
2666 cd write(iout,'(2i5,2(3f10.5,5x))') i,2,(uy(if90,i),if90=1,3)
2667 cd write(iout,'(2i5,2(3f10.5,5x)/)')i,3,(uz(if90,i),if90=1,3)
2668 cd write(iout,'(a)')
2674 uygradt(l,k,j,i)=uygrad(l,k,j,i)
2675 uzgradt(l,k,j,i)=uzgrad(l,k,j,i)
2688 cd write (iout,*) 'i=',i
2690 erij(k)=dc_norm(k,i)
2694 dc_norm(k,i)=erij(k)
2696 dc_norm(j,i)=dc_norm(j,i)+delta
2697 c fac=dsqrt(scalar(dc_norm(1,i),dc_norm(1,i)))
2699 c dc_norm(k,i)=dc_norm(k,i)/fac
2701 c write (iout,*) (dc_norm(k,i),k=1,3)
2702 c write (iout,*) (erij(k),k=1,3)
2705 uygradn(k,j,1)=(uy(k,i)-uyt(k,i))/delta
2706 uygradn(k,j,2)=(uy(k,i-1)-uyt(k,i-1))/delta
2707 uzgradn(k,j,1)=(uz(k,i)-uzt(k,i))/delta
2708 uzgradn(k,j,2)=(uz(k,i-1)-uzt(k,i-1))/delta
2710 c write (iout,'(i5,3f8.5,3x,3f8.5,5x,3f8.5,3x,3f8.5)')
2711 c & j,(uzgradt(k,j,1,i),k=1,3),(uzgradn(k,j,1),k=1,3),
2712 c & (uzgradt(k,j,2,i-1),k=1,3),(uzgradn(k,j,2),k=1,3)
2715 dc_norm(k,i)=erij(k)
2718 cd write (iout,'(i5,3f8.5,3x,3f8.5,5x,3f8.5,3x,3f8.5)')
2719 cd & k,(uygradt(k,l,1,i),l=1,3),(uygradn(k,l,1),l=1,3),
2720 cd & (uygradt(k,l,2,i-1),l=1,3),(uygradn(k,l,2),l=1,3)
2721 cd write (iout,'(i5,3f8.5,3x,3f8.5,5x,3f8.5,3x,3f8.5)')
2722 cd & k,(uzgradt(k,l,1,i),l=1,3),(uzgradn(k,l,1),l=1,3),
2723 cd & (uzgradt(k,l,2,i-1),l=1,3),(uzgradn(k,l,2),l=1,3)
2724 cd write (iout,'(a)')
2729 C--------------------------------------------------------------------------
2730 subroutine set_matrices
2731 implicit real*8 (a-h,o-z)
2732 include 'DIMENSIONS'
2735 include "COMMON.SETUP"
2737 integer status(MPI_STATUS_SIZE)
2739 include 'COMMON.IOUNITS'
2740 include 'COMMON.GEO'
2741 include 'COMMON.VAR'
2742 include 'COMMON.LOCAL'
2743 include 'COMMON.CHAIN'
2744 include 'COMMON.DERIV'
2745 include 'COMMON.INTERACT'
2746 include 'COMMON.CONTACTS'
2747 include 'COMMON.TORSION'
2748 include 'COMMON.VECTORS'
2749 include 'COMMON.FFIELD'
2750 double precision auxvec(2),auxmat(2,2)
2752 C Compute the virtual-bond-torsional-angle dependent quantities needed
2753 C to calculate the el-loc multibody terms of various order.
2755 c write(iout,*) 'nphi=',nphi,nres
2757 do i=ivec_start+2,ivec_end+2
2762 if (i.gt. nnt+2 .and. i.lt.nct+2) then
2763 iti = itortyp(itype(i-2))
2767 c if (i.gt. iatel_s+1 .and. i.lt.iatel_e+4) then
2768 if (i.gt. nnt+1 .and. i.lt.nct+1) then
2769 iti1 = itortyp(itype(i-1))
2774 b1(1,i-2)=bnew1(1,1,iti)*dsin(theta(i-1)/2.0)
2775 & +bnew1(2,1,iti)*dsin(theta(i-1))
2776 & +bnew1(3,1,iti)*dcos(theta(i-1)/2.0)
2777 gtb1(1,i-2)=bnew1(1,1,iti)*dcos(theta(i-1)/2.0d0)/2.0d0
2778 & +bnew1(2,1,iti)*dcos(theta(i-1))
2779 & -bnew1(3,1,iti)*dsin(theta(i-1)/2.0d0)/2.0d0
2780 c & +bnew1(3,1,iti)*sin(alpha(i))*cos(beta(i))
2781 c &*(cos(theta(i)/2.0)
2782 b2(1,i-2)=bnew2(1,1,iti)*dsin(theta(i-1)/2.0)
2783 & +bnew2(2,1,iti)*dsin(theta(i-1))
2784 & +bnew2(3,1,iti)*dcos(theta(i-1)/2.0)
2785 c & +bnew2(3,1,iti)*sin(alpha(i))*cos(beta(i))
2786 c &*(cos(theta(i)/2.0)
2787 gtb2(1,i-2)=bnew2(1,1,iti)*dcos(theta(i-1)/2.0d0)/2.0d0
2788 & +bnew2(2,1,iti)*dcos(theta(i-1))
2789 & -bnew2(3,1,iti)*dsin(theta(i-1)/2.0d0)/2.0d0
2790 c if (ggb1(1,i).eq.0.0d0) then
2791 c write(iout,*) 'i=',i,ggb1(1,i),
2792 c &bnew1(1,1,iti)*cos(theta(i)/2.0)/2.0,
2793 c &bnew1(2,1,iti)*cos(theta(i)),
2794 c &bnew1(3,1,iti)*sin(theta(i)/2.0)/2.0
2796 b1(2,i-2)=bnew1(1,2,iti)
2798 b2(2,i-2)=bnew2(1,2,iti)
2800 EE(1,1,i-2)=eenew(1,iti)*dcos(theta(i-1))
2801 EE(1,2,i-2)=eeold(1,2,iti)
2802 EE(2,1,i-2)=eeold(2,1,iti)
2803 EE(2,2,i-2)=eeold(2,2,iti)
2804 gtEE(1,1,i-2)=-eenew(1,iti)*dsin(theta(i-1))
2809 c EE(1,2,iti)=0.5d0*eenew(1,iti)
2810 c EE(2,1,iti)=0.5d0*eenew(1,iti)
2811 c b1(2,iti)=bnew1(1,2,iti)*sin(alpha(i))*sin(beta(i))
2812 c b2(2,iti)=bnew2(1,2,iti)*sin(alpha(i))*sin(beta(i))
2813 b1tilde(1,i-2)=b1(1,i-2)
2814 b1tilde(2,i-2)=-b1(2,i-2)
2815 b2tilde(1,i-2)=b2(1,i-2)
2816 b2tilde(2,i-2)=-b2(2,i-2)
2817 c write (iout,*) 'i=',i-2,gtb1(2,i-2),gtb1(1,i-2)
2818 c write(iout,*) 'b1=',b1(1,i-2)
2819 c write (iout,*) 'theta=', theta(i-1)
2822 if (i.gt. nnt+2 .and. i.lt.nct+2) then
2823 iti = itortyp(itype(i-2))
2827 c if (i.gt. iatel_s+1 .and. i.lt.iatel_e+4) then
2828 if (i.gt. nnt+1 .and. i.lt.nct+1) then
2829 iti1 = itortyp(itype(i-1))
2837 b1tilde(1,i-2)=b1(1,i-2)
2838 b1tilde(2,i-2)=-b1(2,i-2)
2839 b2tilde(1,i-2)=b2(1,i-2)
2840 b2tilde(2,i-2)=-b2(2,i-2)
2841 EE(1,2,i-2)=eeold(1,2,iti)
2842 EE(2,1,i-2)=eeold(2,1,iti)
2843 EE(2,2,i-2)=eeold(2,2,iti)
2844 EE(1,1,i-2)=eeold(1,1,iti)
2848 do i=ivec_start+2,ivec_end+2
2852 if (i .lt. nres+1) then
2889 if (i .gt. 3 .and. i .lt. nres+1) then
2890 obrot_der(1,i-2)=-sin1
2891 obrot_der(2,i-2)= cos1
2892 Ugder(1,1,i-2)= sin1
2893 Ugder(1,2,i-2)=-cos1
2894 Ugder(2,1,i-2)=-cos1
2895 Ugder(2,2,i-2)=-sin1
2898 obrot2_der(1,i-2)=-dwasin2
2899 obrot2_der(2,i-2)= dwacos2
2900 Ug2der(1,1,i-2)= dwasin2
2901 Ug2der(1,2,i-2)=-dwacos2
2902 Ug2der(2,1,i-2)=-dwacos2
2903 Ug2der(2,2,i-2)=-dwasin2
2905 obrot_der(1,i-2)=0.0d0
2906 obrot_der(2,i-2)=0.0d0
2907 Ugder(1,1,i-2)=0.0d0
2908 Ugder(1,2,i-2)=0.0d0
2909 Ugder(2,1,i-2)=0.0d0
2910 Ugder(2,2,i-2)=0.0d0
2911 obrot2_der(1,i-2)=0.0d0
2912 obrot2_der(2,i-2)=0.0d0
2913 Ug2der(1,1,i-2)=0.0d0
2914 Ug2der(1,2,i-2)=0.0d0
2915 Ug2der(2,1,i-2)=0.0d0
2916 Ug2der(2,2,i-2)=0.0d0
2918 c if (i.gt. iatel_s+2 .and. i.lt.iatel_e+5) then
2919 if (i.gt. nnt+2 .and. i.lt.nct+2) then
2920 iti = itortyp(itype(i-2))
2924 c if (i.gt. iatel_s+1 .and. i.lt.iatel_e+4) then
2925 if (i.gt. nnt+1 .and. i.lt.nct+1) then
2926 iti1 = itortyp(itype(i-1))
2930 cd write (iout,*) '*******i',i,' iti1',iti
2931 cd write (iout,*) 'b1',b1(:,iti)
2932 cd write (iout,*) 'b2',b2(:,iti)
2933 cd write (iout,*) 'Ug',Ug(:,:,i-2)
2934 c if (i .gt. iatel_s+2) then
2935 if (i .gt. nnt+2) then
2936 call matvec2(Ug(1,1,i-2),b2(1,i-2),Ub2(1,i-2))
2938 call matvec2(Ug(1,1,i-2),gtb2(1,i-2),gUb2(1,i-2))
2939 c write (iout,*) Ug(1,1,i-2),gtb2(1,i-2),gUb2(1,i-2),"chuj"
2941 c write(iout,*) "co jest kurwa", iti, EE(1,1,iti),EE(2,1,iti),
2942 c & EE(1,2,iti),EE(2,2,iti)
2943 call matmat2(EE(1,1,i-2),Ug(1,1,i-2),EUg(1,1,i-2))
2944 call matmat2(gtEE(1,1,i-2),Ug(1,1,i-2),gtEUg(1,1,i-2))
2945 c write(iout,*) "Macierz EUG",
2946 c & eug(1,1,i-2),eug(1,2,i-2),eug(2,1,i-2),
2948 if (wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 .or. wcorr6.gt.0.0d0)
2950 call matmat2(CC(1,1,iti),Ug(1,1,i-2),CUg(1,1,i-2))
2951 call matmat2(DD(1,1,iti),Ug(1,1,i-2),DUg(1,1,i-2))
2952 call matmat2(Dtilde(1,1,iti),Ug2(1,1,i-2),DtUg2(1,1,i-2))
2953 call matvec2(Ctilde(1,1,iti1),obrot(1,i-2),Ctobr(1,i-2))
2954 call matvec2(Dtilde(1,1,iti),obrot2(1,i-2),Dtobr2(1,i-2))
2965 DtUg2(l,k,i-2)=0.0d0
2969 call matvec2(Ugder(1,1,i-2),b2(1,i-2),Ub2der(1,i-2))
2970 call matmat2(EE(1,1,i-2),Ugder(1,1,i-2),EUgder(1,1,i-2))
2972 muder(k,i-2)=Ub2der(k,i-2)
2974 c if (i.gt. iatel_s+1 .and. i.lt.iatel_e+4) then
2975 if (i.gt. nnt+1 .and. i.lt.nct+1) then
2976 if (itype(i-1).le.ntyp) then
2977 iti1 = itortyp(itype(i-1))
2985 mu(k,i-2)=Ub2(k,i-2)+b1(k,i-1)
2987 C write (iout,*) 'mumu',i,b1(1,i-1),Ub2(1,i-2)
2988 c write (iout,*) 'mu ',mu(:,i-2),i-2
2989 cd write (iout,*) 'mu1',mu1(:,i-2)
2990 cd write (iout,*) 'mu2',mu2(:,i-2)
2991 if (wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 .or.wcorr6.gt.0.0d0)
2993 call matmat2(CC(1,1,iti1),Ugder(1,1,i-2),CUgder(1,1,i-2))
2994 call matmat2(DD(1,1,iti),Ugder(1,1,i-2),DUgder(1,1,i-2))
2995 call matmat2(Dtilde(1,1,iti),Ug2der(1,1,i-2),DtUg2der(1,1,i-2))
2996 call matvec2(Ctilde(1,1,iti1),obrot_der(1,i-2),Ctobrder(1,i-2))
2997 call matvec2(Dtilde(1,1,iti),obrot2_der(1,i-2),Dtobr2der(1,i-2))
2998 C Vectors and matrices dependent on a single virtual-bond dihedral.
2999 call matvec2(DD(1,1,iti),b1tilde(1,i-1),auxvec(1))
3000 call matvec2(Ug2(1,1,i-2),auxvec(1),Ug2Db1t(1,i-2))
3001 call matvec2(Ug2der(1,1,i-2),auxvec(1),Ug2Db1tder(1,i-2))
3002 call matvec2(CC(1,1,iti1),Ub2(1,i-2),CUgb2(1,i-2))
3003 call matvec2(CC(1,1,iti1),Ub2der(1,i-2),CUgb2der(1,i-2))
3004 call matmat2(EUg(1,1,i-2),CC(1,1,iti1),EUgC(1,1,i-2))
3005 call matmat2(EUgder(1,1,i-2),CC(1,1,iti1),EUgCder(1,1,i-2))
3006 call matmat2(EUg(1,1,i-2),DD(1,1,iti1),EUgD(1,1,i-2))
3007 call matmat2(EUgder(1,1,i-2),DD(1,1,iti1),EUgDder(1,1,i-2))
3010 C Matrices dependent on two consecutive virtual-bond dihedrals.
3011 C The order of matrices is from left to right.
3012 if (wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 .or.wcorr6.gt.0.0d0)
3014 c do i=max0(ivec_start,2),ivec_end
3016 call matmat2(DtUg2(1,1,i-1),EUg(1,1,i),DtUg2EUg(1,1,i))
3017 call matmat2(DtUg2der(1,1,i-1),EUg(1,1,i),DtUg2EUgder(1,1,1,i))
3018 call matmat2(DtUg2(1,1,i-1),EUgder(1,1,i),DtUg2EUgder(1,1,2,i))
3019 call transpose2(DtUg2(1,1,i-1),auxmat(1,1))
3020 call matmat2(auxmat(1,1),EUg(1,1,i),Ug2DtEUg(1,1,i))
3021 call matmat2(auxmat(1,1),EUgder(1,1,i),Ug2DtEUgder(1,1,2,i))
3022 call transpose2(DtUg2der(1,1,i-1),auxmat(1,1))
3023 call matmat2(auxmat(1,1),EUg(1,1,i),Ug2DtEUgder(1,1,1,i))
3026 #if defined(MPI) && defined(PARMAT)
3028 c if (fg_rank.eq.0) then
3029 write (iout,*) "Arrays UG and UGDER before GATHER"
3031 write (iout,'(i5,4f10.5,5x,4f10.5)') i,
3032 & ((ug(l,k,i),l=1,2),k=1,2),
3033 & ((ugder(l,k,i),l=1,2),k=1,2)
3035 write (iout,*) "Arrays UG2 and UG2DER"
3037 write (iout,'(i5,4f10.5,5x,4f10.5)') i,
3038 & ((ug2(l,k,i),l=1,2),k=1,2),
3039 & ((ug2der(l,k,i),l=1,2),k=1,2)
3041 write (iout,*) "Arrays OBROT OBROT2 OBROTDER and OBROT2DER"
3043 write (iout,'(i5,4f10.5,5x,4f10.5)') i,
3044 & (obrot(k,i),k=1,2),(obrot2(k,i),k=1,2),
3045 & (obrot_der(k,i),k=1,2),(obrot2_der(k,i),k=1,2)
3047 write (iout,*) "Arrays COSTAB SINTAB COSTAB2 and SINTAB2"
3049 write (iout,'(i5,4f10.5,5x,4f10.5)') i,
3050 & costab(i),sintab(i),costab2(i),sintab2(i)
3052 write (iout,*) "Array MUDER"
3054 write (iout,'(i5,2f10.5)') i,muder(1,i),muder(2,i)
3058 if (nfgtasks.gt.1) then
3060 c write(iout,*)"Processor",fg_rank,kolor," ivec_start",ivec_start,
3061 c & " ivec_displ",(ivec_displ(i),i=0,nfgtasks-1),
3062 c & " ivec_count",(ivec_count(i),i=0,nfgtasks-1)
3064 call MPI_Allgatherv(Ub2(1,ivec_start),ivec_count(fg_rank1),
3065 & MPI_MU,Ub2(1,1),ivec_count(0),ivec_displ(0),MPI_MU,
3067 call MPI_Allgatherv(Ub2der(1,ivec_start),ivec_count(fg_rank1),
3068 & MPI_MU,Ub2der(1,1),ivec_count(0),ivec_displ(0),MPI_MU,
3070 call MPI_Allgatherv(mu(1,ivec_start),ivec_count(fg_rank1),
3071 & MPI_MU,mu(1,1),ivec_count(0),ivec_displ(0),MPI_MU,
3073 call MPI_Allgatherv(muder(1,ivec_start),ivec_count(fg_rank1),
3074 & MPI_MU,muder(1,1),ivec_count(0),ivec_displ(0),MPI_MU,
3076 call MPI_Allgatherv(Eug(1,1,ivec_start),ivec_count(fg_rank1),
3077 & MPI_MAT1,Eug(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,
3079 call MPI_Allgatherv(Eugder(1,1,ivec_start),ivec_count(fg_rank1),
3080 & MPI_MAT1,Eugder(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,
3082 call MPI_Allgatherv(costab(ivec_start),ivec_count(fg_rank1),
3083 & MPI_DOUBLE_PRECISION,costab(1),ivec_count(0),ivec_displ(0),
3084 & MPI_DOUBLE_PRECISION,FG_COMM1,IERR)
3085 call MPI_Allgatherv(sintab(ivec_start),ivec_count(fg_rank1),
3086 & MPI_DOUBLE_PRECISION,sintab(1),ivec_count(0),ivec_displ(0),
3087 & MPI_DOUBLE_PRECISION,FG_COMM1,IERR)
3088 call MPI_Allgatherv(costab2(ivec_start),ivec_count(fg_rank1),
3089 & MPI_DOUBLE_PRECISION,costab2(1),ivec_count(0),ivec_displ(0),
3090 & MPI_DOUBLE_PRECISION,FG_COMM1,IERR)
3091 call MPI_Allgatherv(sintab2(ivec_start),ivec_count(fg_rank1),
3092 & MPI_DOUBLE_PRECISION,sintab2(1),ivec_count(0),ivec_displ(0),
3093 & MPI_DOUBLE_PRECISION,FG_COMM1,IERR)
3094 if (wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 .or. wcorr6.gt.0.0d0)
3096 call MPI_Allgatherv(Ctobr(1,ivec_start),ivec_count(fg_rank1),
3097 & MPI_MU,Ctobr(1,1),ivec_count(0),ivec_displ(0),MPI_MU,
3099 call MPI_Allgatherv(Ctobrder(1,ivec_start),ivec_count(fg_rank1),
3100 & MPI_MU,Ctobrder(1,1),ivec_count(0),ivec_displ(0),MPI_MU,
3102 call MPI_Allgatherv(Dtobr2(1,ivec_start),ivec_count(fg_rank1),
3103 & MPI_MU,Dtobr2(1,1),ivec_count(0),ivec_displ(0),MPI_MU,
3105 call MPI_Allgatherv(Dtobr2der(1,ivec_start),ivec_count(fg_rank1),
3106 & MPI_MU,Dtobr2der(1,1),ivec_count(0),ivec_displ(0),MPI_MU,
3108 call MPI_Allgatherv(Ug2Db1t(1,ivec_start),ivec_count(fg_rank1),
3109 & MPI_MU,Ug2Db1t(1,1),ivec_count(0),ivec_displ(0),MPI_MU,
3111 call MPI_Allgatherv(Ug2Db1tder(1,ivec_start),
3112 & ivec_count(fg_rank1),
3113 & MPI_MU,Ug2Db1tder(1,1),ivec_count(0),ivec_displ(0),MPI_MU,
3115 call MPI_Allgatherv(CUgb2(1,ivec_start),ivec_count(fg_rank1),
3116 & MPI_MU,CUgb2(1,1),ivec_count(0),ivec_displ(0),MPI_MU,
3118 call MPI_Allgatherv(CUgb2der(1,ivec_start),ivec_count(fg_rank1),
3119 & MPI_MU,CUgb2der(1,1),ivec_count(0),ivec_displ(0),MPI_MU,
3121 call MPI_Allgatherv(Cug(1,1,ivec_start),ivec_count(fg_rank1),
3122 & MPI_MAT1,Cug(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,
3124 call MPI_Allgatherv(Cugder(1,1,ivec_start),ivec_count(fg_rank1),
3125 & MPI_MAT1,Cugder(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,
3127 call MPI_Allgatherv(Dug(1,1,ivec_start),ivec_count(fg_rank1),
3128 & MPI_MAT1,Dug(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,
3130 call MPI_Allgatherv(Dugder(1,1,ivec_start),ivec_count(fg_rank1),
3131 & MPI_MAT1,Dugder(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,
3133 call MPI_Allgatherv(Dtug2(1,1,ivec_start),ivec_count(fg_rank1),
3134 & MPI_MAT1,Dtug2(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,
3136 call MPI_Allgatherv(Dtug2der(1,1,ivec_start),
3137 & ivec_count(fg_rank1),
3138 & MPI_MAT1,Dtug2der(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,
3140 call MPI_Allgatherv(EugC(1,1,ivec_start),ivec_count(fg_rank1),
3141 & MPI_MAT1,EugC(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,
3143 call MPI_Allgatherv(EugCder(1,1,ivec_start),ivec_count(fg_rank1),
3144 & MPI_MAT1,EugCder(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,
3146 call MPI_Allgatherv(EugD(1,1,ivec_start),ivec_count(fg_rank1),
3147 & MPI_MAT1,EugD(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,
3149 call MPI_Allgatherv(EugDder(1,1,ivec_start),ivec_count(fg_rank1),
3150 & MPI_MAT1,EugDder(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,
3152 call MPI_Allgatherv(DtUg2EUg(1,1,ivec_start),
3153 & ivec_count(fg_rank1),
3154 & MPI_MAT1,DtUg2EUg(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,
3156 call MPI_Allgatherv(Ug2DtEUg(1,1,ivec_start),
3157 & ivec_count(fg_rank1),
3158 & MPI_MAT1,Ug2DtEUg(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,
3160 call MPI_Allgatherv(DtUg2EUgder(1,1,1,ivec_start),
3161 & ivec_count(fg_rank1),
3162 & MPI_MAT2,DtUg2EUgder(1,1,1,1),ivec_count(0),ivec_displ(0),
3163 & MPI_MAT2,FG_COMM1,IERR)
3164 call MPI_Allgatherv(Ug2DtEUgder(1,1,1,ivec_start),
3165 & ivec_count(fg_rank1),
3166 & MPI_MAT2,Ug2DtEUgder(1,1,1,1),ivec_count(0),ivec_displ(0),
3167 & MPI_MAT2,FG_COMM1,IERR)
3170 c Passes matrix info through the ring
3173 if (irecv.lt.0) irecv=nfgtasks1-1
3176 if (inext.ge.nfgtasks1) inext=0
3178 c write (iout,*) "isend",isend," irecv",irecv
3180 lensend=lentyp(isend)
3181 lenrecv=lentyp(irecv)
3182 c write (iout,*) "lensend",lensend," lenrecv",lenrecv
3183 c call MPI_SENDRECV(ug(1,1,ivec_displ(isend)+1),1,
3184 c & MPI_ROTAT1(lensend),inext,2200+isend,
3185 c & ug(1,1,ivec_displ(irecv)+1),1,MPI_ROTAT1(lenrecv),
3186 c & iprev,2200+irecv,FG_COMM,status,IERR)
3187 c write (iout,*) "Gather ROTAT1"
3189 c call MPI_SENDRECV(obrot(1,ivec_displ(isend)+1),1,
3190 c & MPI_ROTAT2(lensend),inext,3300+isend,
3191 c & obrot(1,ivec_displ(irecv)+1),1,MPI_ROTAT2(lenrecv),
3192 c & iprev,3300+irecv,FG_COMM,status,IERR)
3193 c write (iout,*) "Gather ROTAT2"
3195 call MPI_SENDRECV(costab(ivec_displ(isend)+1),1,
3196 & MPI_ROTAT_OLD(lensend),inext,4400+isend,
3197 & costab(ivec_displ(irecv)+1),1,MPI_ROTAT_OLD(lenrecv),
3198 & iprev,4400+irecv,FG_COMM,status,IERR)
3199 c write (iout,*) "Gather ROTAT_OLD"
3201 call MPI_SENDRECV(mu(1,ivec_displ(isend)+1),1,
3202 & MPI_PRECOMP11(lensend),inext,5500+isend,
3203 & mu(1,ivec_displ(irecv)+1),1,MPI_PRECOMP11(lenrecv),
3204 & iprev,5500+irecv,FG_COMM,status,IERR)
3205 c write (iout,*) "Gather PRECOMP11"
3207 call MPI_SENDRECV(Eug(1,1,ivec_displ(isend)+1),1,
3208 & MPI_PRECOMP12(lensend),inext,6600+isend,
3209 & Eug(1,1,ivec_displ(irecv)+1),1,MPI_PRECOMP12(lenrecv),
3210 & iprev,6600+irecv,FG_COMM,status,IERR)
3211 c write (iout,*) "Gather PRECOMP12"
3213 if (wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 .or. wcorr6.gt.0.0d0)
3215 call MPI_SENDRECV(ug2db1t(1,ivec_displ(isend)+1),1,
3216 & MPI_ROTAT2(lensend),inext,7700+isend,
3217 & ug2db1t(1,ivec_displ(irecv)+1),1,MPI_ROTAT2(lenrecv),
3218 & iprev,7700+irecv,FG_COMM,status,IERR)
3219 c write (iout,*) "Gather PRECOMP21"
3221 call MPI_SENDRECV(EUgC(1,1,ivec_displ(isend)+1),1,
3222 & MPI_PRECOMP22(lensend),inext,8800+isend,
3223 & EUgC(1,1,ivec_displ(irecv)+1),1,MPI_PRECOMP22(lenrecv),
3224 & iprev,8800+irecv,FG_COMM,status,IERR)
3225 c write (iout,*) "Gather PRECOMP22"
3227 call MPI_SENDRECV(Ug2DtEUgder(1,1,1,ivec_displ(isend)+1),1,
3228 & MPI_PRECOMP23(lensend),inext,9900+isend,
3229 & Ug2DtEUgder(1,1,1,ivec_displ(irecv)+1),1,
3230 & MPI_PRECOMP23(lenrecv),
3231 & iprev,9900+irecv,FG_COMM,status,IERR)
3232 c write (iout,*) "Gather PRECOMP23"
3237 if (irecv.lt.0) irecv=nfgtasks1-1
3240 time_gather=time_gather+MPI_Wtime()-time00
3243 c if (fg_rank.eq.0) then
3244 write (iout,*) "Arrays UG and UGDER"
3246 write (iout,'(i5,4f10.5,5x,4f10.5)') i,
3247 & ((ug(l,k,i),l=1,2),k=1,2),
3248 & ((ugder(l,k,i),l=1,2),k=1,2)
3250 write (iout,*) "Arrays UG2 and UG2DER"
3252 write (iout,'(i5,4f10.5,5x,4f10.5)') i,
3253 & ((ug2(l,k,i),l=1,2),k=1,2),
3254 & ((ug2der(l,k,i),l=1,2),k=1,2)
3256 write (iout,*) "Arrays OBROT OBROT2 OBROTDER and OBROT2DER"
3258 write (iout,'(i5,4f10.5,5x,4f10.5)') i,
3259 & (obrot(k,i),k=1,2),(obrot2(k,i),k=1,2),
3260 & (obrot_der(k,i),k=1,2),(obrot2_der(k,i),k=1,2)
3262 write (iout,*) "Arrays COSTAB SINTAB COSTAB2 and SINTAB2"
3264 write (iout,'(i5,4f10.5,5x,4f10.5)') i,
3265 & costab(i),sintab(i),costab2(i),sintab2(i)
3267 write (iout,*) "Array MUDER"
3269 write (iout,'(i5,2f10.5)') i,muder(1,i),muder(2,i)
3275 cd iti = itortyp(itype(i))
3278 cd write (iout,'(2f10.5,5x,2f10.5,5x,2f10.5)')
3279 cd & (EE(j,k,iti),k=1,2),(Ug(j,k,i),k=1,2),(EUg(j,k,i),k=1,2)
3284 C--------------------------------------------------------------------------
3285 subroutine eelec(ees,evdw1,eel_loc,eello_turn3,eello_turn4)
3287 C This subroutine calculates the average interaction energy and its gradient
3288 C in the virtual-bond vectors between non-adjacent peptide groups, based on
3289 C the potential described in Liwo et al., Protein Sci., 1993, 2, 1715.
3290 C The potential depends both on the distance of peptide-group centers and on
3291 C the orientation of the CA-CA virtual bonds.
3293 implicit real*8 (a-h,o-z)
3297 include 'DIMENSIONS'
3298 include 'COMMON.CONTROL'
3299 include 'COMMON.SETUP'
3300 include 'COMMON.IOUNITS'
3301 include 'COMMON.GEO'
3302 include 'COMMON.VAR'
3303 include 'COMMON.LOCAL'
3304 include 'COMMON.CHAIN'
3305 include 'COMMON.DERIV'
3306 include 'COMMON.INTERACT'
3307 include 'COMMON.CONTACTS'
3308 include 'COMMON.TORSION'
3309 include 'COMMON.VECTORS'
3310 include 'COMMON.FFIELD'
3311 include 'COMMON.TIME1'
3312 include 'COMMON.SPLITELE'
3313 dimension ggg(3),gggp(3),gggm(3),erij(3),dcosb(3),dcosg(3),
3314 & erder(3,3),uryg(3,3),urzg(3,3),vryg(3,3),vrzg(3,3)
3315 double precision acipa(2,2),agg(3,4),aggi(3,4),aggi1(3,4),
3316 & aggj(3,4),aggj1(3,4),a_temp(2,2),muij(4),gmuij(4)
3317 common /locel/ a_temp,agg,aggi,aggi1,aggj,aggj1,a22,a23,a32,a33,
3318 & dxi,dyi,dzi,dx_normi,dy_normi,dz_normi,xmedi,ymedi,zmedi,
3320 c 4/26/02 - AL scaling factor for 1,4 repulsive VDW interactions
3322 double precision scal_el /1.0d0/
3324 double precision scal_el /0.5d0/
3327 C 13-go grudnia roku pamietnego...
3328 double precision unmat(3,3) /1.0d0,0.0d0,0.0d0,
3329 & 0.0d0,1.0d0,0.0d0,
3330 & 0.0d0,0.0d0,1.0d0/
3331 cd write(iout,*) 'In EELEC'
3333 cd write(iout,*) 'Type',i
3334 cd write(iout,*) 'B1',B1(:,i)
3335 cd write(iout,*) 'B2',B2(:,i)
3336 cd write(iout,*) 'CC',CC(:,:,i)
3337 cd write(iout,*) 'DD',DD(:,:,i)
3338 cd write(iout,*) 'EE',EE(:,:,i)
3340 cd call check_vecgrad
3342 if (icheckgrad.eq.1) then
3344 fac=1.0d0/dsqrt(scalar(dc(1,i),dc(1,i)))
3346 dc_norm(k,i)=dc(k,i)*fac
3348 c write (iout,*) 'i',i,' fac',fac
3351 if (wel_loc.gt.0.0d0 .or. wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0
3352 & .or. wcorr6.gt.0.0d0 .or. wturn3.gt.0.0d0 .or.
3353 & wturn4.gt.0.0d0 .or. wturn6.gt.0.0d0) then
3354 c call vec_and_deriv
3360 time_mat=time_mat+MPI_Wtime()-time01
3364 cd write (iout,*) 'i=',i
3366 cd write (iout,'(i5,2f10.5)') k,uy(k,i),uz(k,i)
3369 cd write (iout,'(f10.5,2x,3f10.5,2x,3f10.5)')
3370 cd & uz(k,i),(uzgrad(k,l,1,i),l=1,3),(uzgrad(k,l,2,i),l=1,3)
3383 cd print '(a)','Enter EELEC'
3384 cd write (iout,*) 'iatel_s=',iatel_s,' iatel_e=',iatel_e
3386 gel_loc_loc(i)=0.0d0
3391 c 9/27/08 AL Split the interaction loop to ensure load balancing of turn terms
3393 C Loop over i,i+2 and i,i+3 pairs of the peptide groups
3395 C 14/01/2014 TURN3,TUNR4 does no go under periodic boundry condition
3396 do i=iturn3_start,iturn3_end
3398 C write(iout,*) "tu jest i",i
3399 if (itype(i).eq.ntyp1 .or. itype(i+1).eq.ntyp1
3400 C changes suggested by Ana to avoid out of bounds
3401 & .or.((i+4).gt.nres)
3403 C end of changes by Ana
3404 & .or. itype(i+2).eq.ntyp1
3405 & .or. itype(i+3).eq.ntyp1) cycle
3407 if(itype(i-1).eq.ntyp1)cycle
3410 if (itype(i+4).eq.ntyp1) cycle
3415 dx_normi=dc_norm(1,i)
3416 dy_normi=dc_norm(2,i)
3417 dz_normi=dc_norm(3,i)
3418 xmedi=c(1,i)+0.5d0*dxi
3419 ymedi=c(2,i)+0.5d0*dyi
3420 zmedi=c(3,i)+0.5d0*dzi
3421 xmedi=mod(xmedi,boxxsize)
3422 if (xmedi.lt.0) xmedi=xmedi+boxxsize
3423 ymedi=mod(ymedi,boxysize)
3424 if (ymedi.lt.0) ymedi=ymedi+boxysize
3425 zmedi=mod(zmedi,boxzsize)
3426 if (zmedi.lt.0) zmedi=zmedi+boxzsize
3428 call eelecij(i,i+2,ees,evdw1,eel_loc)
3429 if (wturn3.gt.0.0d0) call eturn3(i,eello_turn3)
3430 num_cont_hb(i)=num_conti
3432 do i=iturn4_start,iturn4_end
3434 if (itype(i).eq.ntyp1 .or. itype(i+1).eq.ntyp1
3435 C changes suggested by Ana to avoid out of bounds
3436 & .or.((i+5).gt.nres)
3438 C end of changes suggested by Ana
3439 & .or. itype(i+3).eq.ntyp1
3440 & .or. itype(i+4).eq.ntyp1
3441 & .or. itype(i+5).eq.ntyp1
3442 & .or. itype(i).eq.ntyp1
3443 & .or. itype(i-1).eq.ntyp1
3448 dx_normi=dc_norm(1,i)
3449 dy_normi=dc_norm(2,i)
3450 dz_normi=dc_norm(3,i)
3451 xmedi=c(1,i)+0.5d0*dxi
3452 ymedi=c(2,i)+0.5d0*dyi
3453 zmedi=c(3,i)+0.5d0*dzi
3454 C Return atom into box, boxxsize is size of box in x dimension
3456 c if (xmedi.gt.((0.5d0)*boxxsize)) xmedi=xmedi-boxxsize
3457 c if (xmedi.lt.((-0.5d0)*boxxsize)) xmedi=xmedi+boxxsize
3458 C Condition for being inside the proper box
3459 c if ((xmedi.gt.((0.5d0)*boxxsize)).or.
3460 c & (xmedi.lt.((-0.5d0)*boxxsize))) then
3464 c if (ymedi.gt.((0.5d0)*boxysize)) ymedi=ymedi-boxysize
3465 c if (ymedi.lt.((-0.5d0)*boxysize)) ymedi=ymedi+boxysize
3466 C Condition for being inside the proper box
3467 c if ((ymedi.gt.((0.5d0)*boxysize)).or.
3468 c & (ymedi.lt.((-0.5d0)*boxysize))) then
3472 c if (zmedi.gt.((0.5d0)*boxzsize)) zmedi=zmedi-boxzsize
3473 c if (zmedi.lt.((-0.5d0)*boxzsize)) zmedi=zmedi+boxzsize
3474 C Condition for being inside the proper box
3475 c if ((zmedi.gt.((0.5d0)*boxzsize)).or.
3476 c & (zmedi.lt.((-0.5d0)*boxzsize))) then
3479 xmedi=mod(xmedi,boxxsize)
3480 if (xmedi.lt.0) xmedi=xmedi+boxxsize
3481 ymedi=mod(ymedi,boxysize)
3482 if (ymedi.lt.0) ymedi=ymedi+boxysize
3483 zmedi=mod(zmedi,boxzsize)
3484 if (zmedi.lt.0) zmedi=zmedi+boxzsize
3486 num_conti=num_cont_hb(i)
3487 c write(iout,*) "JESTEM W PETLI"
3488 call eelecij(i,i+3,ees,evdw1,eel_loc)
3489 if (wturn4.gt.0.0d0 .and. itype(i+2).ne.ntyp1)
3490 & call eturn4(i,eello_turn4)
3491 num_cont_hb(i)=num_conti
3493 C Loop over all neighbouring boxes
3498 c Loop over all pairs of interacting peptide groups except i,i+2 and i,i+3
3501 do i=iatel_s,iatel_e
3504 if (itype(i).eq.ntyp1 .or. itype(i+1).eq.ntyp1
3505 C changes suggested by Ana to avoid out of bounds
3506 & .or.((i+2).gt.nres)
3508 C end of changes by Ana
3509 & .or. itype(i+2).eq.ntyp1
3510 & .or. itype(i-1).eq.ntyp1
3515 dx_normi=dc_norm(1,i)
3516 dy_normi=dc_norm(2,i)
3517 dz_normi=dc_norm(3,i)
3518 xmedi=c(1,i)+0.5d0*dxi
3519 ymedi=c(2,i)+0.5d0*dyi
3520 zmedi=c(3,i)+0.5d0*dzi
3521 xmedi=mod(xmedi,boxxsize)
3522 if (xmedi.lt.0) xmedi=xmedi+boxxsize
3523 ymedi=mod(ymedi,boxysize)
3524 if (ymedi.lt.0) ymedi=ymedi+boxysize
3525 zmedi=mod(zmedi,boxzsize)
3526 if (zmedi.lt.0) zmedi=zmedi+boxzsize
3527 C xmedi=xmedi+xshift*boxxsize
3528 C ymedi=ymedi+yshift*boxysize
3529 C zmedi=zmedi+zshift*boxzsize
3531 C Return tom into box, boxxsize is size of box in x dimension
3533 c if (xmedi.gt.((xshift+0.5d0)*boxxsize)) xmedi=xmedi-boxxsize
3534 c if (xmedi.lt.((xshift-0.5d0)*boxxsize)) xmedi=xmedi+boxxsize
3535 C Condition for being inside the proper box
3536 c if ((xmedi.gt.((xshift+0.5d0)*boxxsize)).or.
3537 c & (xmedi.lt.((xshift-0.5d0)*boxxsize))) then
3541 c if (ymedi.gt.((yshift+0.5d0)*boxysize)) ymedi=ymedi-boxysize
3542 c if (ymedi.lt.((yshift-0.5d0)*boxysize)) ymedi=ymedi+boxysize
3543 C Condition for being inside the proper box
3544 c if ((ymedi.gt.((yshift+0.5d0)*boxysize)).or.
3545 c & (ymedi.lt.((yshift-0.5d0)*boxysize))) then
3549 c if (zmedi.gt.((zshift+0.5d0)*boxzsize)) zmedi=zmedi-boxzsize
3550 c if (zmedi.lt.((zshift-0.5d0)*boxzsize)) zmedi=zmedi+boxzsize
3551 cC Condition for being inside the proper box
3552 c if ((zmedi.gt.((zshift+0.5d0)*boxzsize)).or.
3553 c & (zmedi.lt.((zshift-0.5d0)*boxzsize))) then
3557 c write (iout,*) 'i',i,' ielstart',ielstart(i),' ielend',ielend(i)
3558 num_conti=num_cont_hb(i)
3560 do j=ielstart(i),ielend(i)
3562 C write (iout,*) i,j
3564 if (itype(j).eq.ntyp1.or. itype(j+1).eq.ntyp1
3565 C changes suggested by Ana to avoid out of bounds
3566 & .or.((j+2).gt.nres)
3568 C end of changes by Ana
3569 & .or.itype(j+2).eq.ntyp1
3570 & .or.itype(j-1).eq.ntyp1
3572 call eelecij(i,j,ees,evdw1,eel_loc)
3574 num_cont_hb(i)=num_conti
3580 c write (iout,*) "Number of loop steps in EELEC:",ind
3582 cd write (iout,'(i3,3f10.5,5x,3f10.5)')
3583 cd & i,(gel_loc(k,i),k=1,3),gel_loc_loc(i)
3585 c 12/7/99 Adam eello_turn3 will be considered as a separate energy term
3586 ccc eel_loc=eel_loc+eello_turn3
3587 cd print *,"Processor",fg_rank," t_eelecij",t_eelecij
3590 C-------------------------------------------------------------------------------
3591 subroutine eelecij(i,j,ees,evdw1,eel_loc)
3592 implicit real*8 (a-h,o-z)
3593 include 'DIMENSIONS'
3597 include 'COMMON.CONTROL'
3598 include 'COMMON.IOUNITS'
3599 include 'COMMON.GEO'
3600 include 'COMMON.VAR'
3601 include 'COMMON.LOCAL'
3602 include 'COMMON.CHAIN'
3603 include 'COMMON.DERIV'
3604 include 'COMMON.INTERACT'
3605 include 'COMMON.CONTACTS'
3606 include 'COMMON.TORSION'
3607 include 'COMMON.VECTORS'
3608 include 'COMMON.FFIELD'
3609 include 'COMMON.TIME1'
3610 include 'COMMON.SPLITELE'
3611 include 'COMMON.SHIELD'
3612 dimension ggg(3),gggp(3),gggm(3),erij(3),dcosb(3),dcosg(3),
3613 & erder(3,3),uryg(3,3),urzg(3,3),vryg(3,3),vrzg(3,3)
3614 double precision acipa(2,2),agg(3,4),aggi(3,4),aggi1(3,4),
3615 & aggj(3,4),aggj1(3,4),a_temp(2,2),muij(4),gmuij1(4),gmuji1(4),
3616 & gmuij2(4),gmuji2(4)
3617 common /locel/ a_temp,agg,aggi,aggi1,aggj,aggj1,a22,a23,a32,a33,
3618 & dxi,dyi,dzi,dx_normi,dy_normi,dz_normi,xmedi,ymedi,zmedi,
3620 c 4/26/02 - AL scaling factor for 1,4 repulsive VDW interactions
3622 double precision scal_el /1.0d0/
3624 double precision scal_el /0.5d0/
3627 C 13-go grudnia roku pamietnego...
3628 double precision unmat(3,3) /1.0d0,0.0d0,0.0d0,
3629 & 0.0d0,1.0d0,0.0d0,
3630 & 0.0d0,0.0d0,1.0d0/
3631 c time00=MPI_Wtime()
3632 cd write (iout,*) "eelecij",i,j
3636 if (j.eq.i+2 .and. itelj.eq.2) iteli=2
3637 aaa=app(iteli,itelj)
3638 bbb=bpp(iteli,itelj)
3639 ael6i=ael6(iteli,itelj)
3640 ael3i=ael3(iteli,itelj)
3644 dx_normj=dc_norm(1,j)
3645 dy_normj=dc_norm(2,j)
3646 dz_normj=dc_norm(3,j)
3647 C xj=c(1,j)+0.5D0*dxj-xmedi
3648 C yj=c(2,j)+0.5D0*dyj-ymedi
3649 C zj=c(3,j)+0.5D0*dzj-zmedi
3654 if (xj.lt.0) xj=xj+boxxsize
3656 if (yj.lt.0) yj=yj+boxysize
3658 if (zj.lt.0) zj=zj+boxzsize
3659 if ((zj.lt.0).or.(xj.lt.0).or.(yj.lt.0)) write (*,*) "CHUJ"
3660 dist_init=(xj-xmedi)**2+(yj-ymedi)**2+(zj-zmedi)**2
3668 xj=xj_safe+xshift*boxxsize
3669 yj=yj_safe+yshift*boxysize
3670 zj=zj_safe+zshift*boxzsize
3671 dist_temp=(xj-xmedi)**2+(yj-ymedi)**2+(zj-zmedi)**2
3672 if(dist_temp.lt.dist_init) then
3682 if (isubchap.eq.1) then
3691 C if ((i+3).lt.j) then !this condition keeps for turn3 and turn4 not subject to PBC
3693 c if (xj.gt.((0.5d0)*boxxsize)) xj=xj-boxxsize
3694 c if (xj.lt.((-0.5d0)*boxxsize)) xj=xj+boxxsize
3695 C Condition for being inside the proper box
3696 c if ((xj.gt.((0.5d0)*boxxsize)).or.
3697 c & (xj.lt.((-0.5d0)*boxxsize))) then
3701 c if (yj.gt.((0.5d0)*boxysize)) yj=yj-boxysize
3702 c if (yj.lt.((-0.5d0)*boxysize)) yj=yj+boxysize
3703 C Condition for being inside the proper box
3704 c if ((yj.gt.((0.5d0)*boxysize)).or.
3705 c & (yj.lt.((-0.5d0)*boxysize))) then
3709 c if (zj.gt.((0.5d0)*boxzsize)) zj=zj-boxzsize
3710 c if (zj.lt.((-0.5d0)*boxzsize)) zj=zj+boxzsize
3711 C Condition for being inside the proper box
3712 c if ((zj.gt.((0.5d0)*boxzsize)).or.
3713 c & (zj.lt.((-0.5d0)*boxzsize))) then
3716 C endif !endPBC condintion
3720 rij=xj*xj+yj*yj+zj*zj
3722 sss=sscale(sqrt(rij))
3723 sssgrad=sscagrad(sqrt(rij))
3724 c if (sss.gt.0.0d0) then
3730 cosa=dx_normi*dx_normj+dy_normi*dy_normj+dz_normi*dz_normj
3731 cosb=(xj*dx_normi+yj*dy_normi+zj*dz_normi)*rmij
3732 cosg=(xj*dx_normj+yj*dy_normj+zj*dz_normj)*rmij
3733 fac=cosa-3.0D0*cosb*cosg
3735 c 4/26/02 - AL scaling down 1,4 repulsive VDW interactions
3736 if (j.eq.i+2) ev1=scal_el*ev1
3741 el1=fac3*(4.0D0+fac*fac-3.0D0*(cosb*cosb+cosg*cosg))
3745 C 12/26/95 - for the evaluation of multi-body H-bonding interactions
3746 ees0ij=4.0D0+fac*fac-3.0D0*(cosb*cosb+cosg*cosg)
3747 if (shield_mode.gt.0) then
3750 el1=el1*fac_shield(i)**2*fac_shield(j)**2
3751 el2=el2*fac_shield(i)**2*fac_shield(j)**2
3760 evdw1=evdw1+evdwij*sss
3761 cd write(iout,'(2(2i3,2x),7(1pd12.4)/2(3(1pd12.4),5x)/)')
3762 cd & iteli,i,itelj,j,aaa,bbb,ael6i,ael3i,
3763 cd & 1.0D0/dsqrt(rrmij),evdwij,eesij,
3764 cd & xmedi,ymedi,zmedi,xj,yj,zj
3766 if (energy_dec) then
3767 write (iout,'(a6,2i5,0pf7.3,2i5,2e11.3)')
3769 &,iteli,itelj,aaa,evdw1
3770 write (iout,'(a6,2i5,0pf7.3,2f8.3)') 'ees',i,j,eesij,
3771 &fac_shield(i),fac_shield(j)
3775 C Calculate contributions to the Cartesian gradient.
3778 facvdw=-6*rrmij*(ev1+evdwij)*sss
3779 facel=-3*rrmij*(el1+eesij)
3786 * Radial derivatives. First process both termini of the fragment (i,j)
3791 if ((fac_shield(i).gt.0).and.(fac_shield(j).gt.0).and.
3792 & (shield_mode.gt.0)) then
3794 do ilist=1,ishield_list(i)
3795 iresshield=shield_list(ilist,i)
3797 rlocshield=grad_shield_side(k,ilist,i)*eesij/fac_shield(i)
3799 gshieldx(k,iresshield)=gshieldx(k,iresshield)+
3801 & +grad_shield_loc(k,ilist,i)*eesij/fac_shield(i)*2.0
3802 gshieldc(k,iresshield-1)=gshieldc(k,iresshield-1)+rlocshield
3803 C gshieldc_loc(k,iresshield)=gshieldc_loc(k,iresshield)
3804 C & +grad_shield_loc(k,ilist,i)*eesij/fac_shield(i)
3805 C if (iresshield.gt.i) then
3806 C do ishi=i+1,iresshield-1
3807 C gshieldc(k,ishi)=gshieldc(k,ishi)+rlocshield
3808 C & +grad_shield_loc(k,ilist,i)*eesij/fac_shield(i)
3812 C do ishi=iresshield,i
3813 C gshieldc(k,ishi)=gshieldc(k,ishi)-rlocshield
3814 C & -grad_shield_loc(k,ilist,i)*eesij/fac_shield(i)
3820 do ilist=1,ishield_list(j)
3821 iresshield=shield_list(ilist,j)
3823 rlocshield=grad_shield_side(k,ilist,j)*eesij/fac_shield(j)
3825 gshieldx(k,iresshield)=gshieldx(k,iresshield)+
3827 & +grad_shield_loc(k,ilist,j)*eesij/fac_shield(j)*2.0
3828 gshieldc(k,iresshield-1)=gshieldc(k,iresshield-1)+rlocshield
3830 C & +grad_shield_loc(k,ilist,j)*eesij/fac_shield(j)
3831 C gshieldc_loc(k,iresshield)=gshieldc_loc(k,iresshield)
3832 C & +grad_shield_loc(k,ilist,j)*eesij/fac_shield(j)
3833 C if (iresshield.gt.j) then
3834 C do ishi=j+1,iresshield-1
3835 C gshieldc(k,ishi)=gshieldc(k,ishi)+rlocshield
3836 C & +grad_shield_loc(k,ilist,j)*eesij/fac_shield(j)
3840 C do ishi=iresshield,j
3841 C gshieldc(k,ishi)=gshieldc(k,ishi)-rlocshield
3842 C & -grad_shield_loc(k,ilist,j)*eesij/fac_shield(j)
3849 gshieldc(k,i)=gshieldc(k,i)+
3850 & grad_shield(k,i)*eesij/fac_shield(i)*2.0
3851 gshieldc(k,j)=gshieldc(k,j)+
3852 & grad_shield(k,j)*eesij/fac_shield(j)*2.0
3853 gshieldc(k,i-1)=gshieldc(k,i-1)+
3854 & grad_shield(k,i)*eesij/fac_shield(i)*2.0
3855 gshieldc(k,j-1)=gshieldc(k,j-1)+
3856 & grad_shield(k,j)*eesij/fac_shield(j)*2.0
3861 c ghalf=0.5D0*ggg(k)
3862 c gelc(k,i)=gelc(k,i)+ghalf
3863 c gelc(k,j)=gelc(k,j)+ghalf
3865 c 9/28/08 AL Gradient compotents will be summed only at the end
3866 C print *,"before", gelc_long(1,i), gelc_long(1,j)
3868 gelc_long(k,j)=gelc_long(k,j)+ggg(k)
3869 C & +grad_shield(k,j)*eesij/fac_shield(j)
3870 gelc_long(k,i)=gelc_long(k,i)-ggg(k)
3871 C & +grad_shield(k,i)*eesij/fac_shield(i)
3872 C gelc_long(k,i-1)=gelc_long(k,i-1)
3873 C & +grad_shield(k,i)*eesij/fac_shield(i)
3874 C gelc_long(k,j-1)=gelc_long(k,j-1)
3875 C & +grad_shield(k,j)*eesij/fac_shield(j)
3877 C print *,"bafter", gelc_long(1,i), gelc_long(1,j)
3880 * Loop over residues i+1 thru j-1.
3884 cgrad gelc(l,k)=gelc(l,k)+ggg(l)
3887 if (sss.gt.0.0) then
3888 ggg(1)=facvdw*xj+sssgrad*rmij*evdwij*xj
3889 ggg(2)=facvdw*yj+sssgrad*rmij*evdwij*yj
3890 ggg(3)=facvdw*zj+sssgrad*rmij*evdwij*zj
3897 c ghalf=0.5D0*ggg(k)
3898 c gvdwpp(k,i)=gvdwpp(k,i)+ghalf
3899 c gvdwpp(k,j)=gvdwpp(k,j)+ghalf
3901 c 9/28/08 AL Gradient compotents will be summed only at the end
3903 gvdwpp(k,j)=gvdwpp(k,j)+ggg(k)
3904 gvdwpp(k,i)=gvdwpp(k,i)-ggg(k)
3907 * Loop over residues i+1 thru j-1.
3911 cgrad gvdwpp(l,k)=gvdwpp(l,k)+ggg(l)
3916 facvdw=(ev1+evdwij)*sss
3919 fac=-3*rrmij*(facvdw+facvdw+facel)
3924 * Radial derivatives. First process both termini of the fragment (i,j)
3927 C+eesij*grad_shield(1,i)+eesij*grad_shield(1,j)
3929 C+eesij*grad_shield(2,i)+eesij*grad_shield(2,j)
3931 C+eesij*grad_shield(3,i)+eesij*grad_shield(3,j)
3933 c ghalf=0.5D0*ggg(k)
3934 c gelc(k,i)=gelc(k,i)+ghalf
3935 c gelc(k,j)=gelc(k,j)+ghalf
3937 c 9/28/08 AL Gradient compotents will be summed only at the end
3939 gelc_long(k,j)=gelc(k,j)+ggg(k)
3940 gelc_long(k,i)=gelc(k,i)-ggg(k)
3943 * Loop over residues i+1 thru j-1.
3947 cgrad gelc(l,k)=gelc(l,k)+ggg(l)
3950 c 9/28/08 AL Gradient compotents will be summed only at the end
3951 ggg(1)=facvdw*xj+sssgrad*rmij*evdwij*xj
3952 ggg(2)=facvdw*yj+sssgrad*rmij*evdwij*yj
3953 ggg(3)=facvdw*zj+sssgrad*rmij*evdwij*zj
3955 gvdwpp(k,j)=gvdwpp(k,j)+ggg(k)
3956 gvdwpp(k,i)=gvdwpp(k,i)-ggg(k)
3962 ecosa=2.0D0*fac3*fac1+fac4
3965 ecosb=(fac3*(fac1*cosg+cosb)+cosg*fac4)
3966 ecosg=(fac3*(fac1*cosb+cosg)+cosb*fac4)
3968 dcosb(k)=rmij*(dc_norm(k,i)-erij(k)*cosb)
3969 dcosg(k)=rmij*(dc_norm(k,j)-erij(k)*cosg)
3971 cd print '(2i3,2(3(1pd14.5),3x))',i,j,(dcosb(k),k=1,3),
3972 cd & (dcosg(k),k=1,3)
3974 ggg(k)=(ecosb*dcosb(k)+ecosg*dcosg(k))*
3975 & fac_shield(i)**2*fac_shield(j)**2
3978 c ghalf=0.5D0*ggg(k)
3979 c gelc(k,i)=gelc(k,i)+ghalf
3980 c & +(ecosa*(dc_norm(k,j)-cosa*dc_norm(k,i))
3981 c & + ecosb*(erij(k)-cosb*dc_norm(k,i)))*vbld_inv(i+1)
3982 c gelc(k,j)=gelc(k,j)+ghalf
3983 c & +(ecosa*(dc_norm(k,i)-cosa*dc_norm(k,j))
3984 c & + ecosg*(erij(k)-cosg*dc_norm(k,j)))*vbld_inv(j+1)
3988 cgrad gelc(l,k)=gelc(l,k)+ggg(l)
3991 C print *,"before22", gelc_long(1,i), gelc_long(1,j)
3994 & +((ecosa*(dc_norm(k,j)-cosa*dc_norm(k,i))
3995 & + ecosb*(erij(k)-cosb*dc_norm(k,i)))*vbld_inv(i+1))
3996 & *fac_shield(i)**2*fac_shield(j)**2
3998 & +((ecosa*(dc_norm(k,i)-cosa*dc_norm(k,j))
3999 & + ecosg*(erij(k)-cosg*dc_norm(k,j)))*vbld_inv(j+1))
4000 & *fac_shield(i)**2*fac_shield(j)**2
4001 gelc_long(k,j)=gelc_long(k,j)+ggg(k)
4002 gelc_long(k,i)=gelc_long(k,i)-ggg(k)
4004 C print *,"before33", gelc_long(1,i), gelc_long(1,j)
4008 IF (wel_loc.gt.0.0d0 .or. wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0
4009 & .or. wcorr6.gt.0.0d0 .or. wturn3.gt.0.0d0
4010 & .or. wturn4.gt.0.0d0 .or. wturn6.gt.0.0d0) THEN
4012 C 9/25/99 Mixed third-order local-electrostatic terms. The local-interaction
4013 C energy of a peptide unit is assumed in the form of a second-order
4014 C Fourier series in the angles lambda1 and lambda2 (see Nishikawa et al.
4015 C Macromolecules, 1974, 7, 797-806 for definition). This correlation terms
4016 C are computed for EVERY pair of non-contiguous peptide groups.
4019 if (j.lt.nres-1) then
4031 muij(kkk)=mu(k,i)*mu(l,j)
4032 c write(iout,*) 'mumu=', mu(k,i),mu(l,j),i,j,k,l
4034 gmuij1(kkk)=gtb1(k,i+1)*mu(l,j)
4035 c write(iout,*) 'k=',k,i,gtb1(k,i+1),gtb1(k,i+1)*mu(l,j)
4036 gmuij2(kkk)=gUb2(k,i)*mu(l,j)
4037 gmuji1(kkk)=mu(k,i)*gtb1(l,j+1)
4038 c write(iout,*) 'l=',l,j,gtb1(l,j+1),gtb1(l,j+1)*mu(k,i)
4039 gmuji2(kkk)=mu(k,i)*gUb2(l,j)
4043 cd write (iout,*) 'EELEC: i',i,' j',j
4044 cd write (iout,*) 'j',j,' j1',j1,' j2',j2
4045 cd write(iout,*) 'muij',muij
4046 ury=scalar(uy(1,i),erij)
4047 urz=scalar(uz(1,i),erij)
4048 vry=scalar(uy(1,j),erij)
4049 vrz=scalar(uz(1,j),erij)
4050 a22=scalar(uy(1,i),uy(1,j))-3*ury*vry
4051 a23=scalar(uy(1,i),uz(1,j))-3*ury*vrz
4052 a32=scalar(uz(1,i),uy(1,j))-3*urz*vry
4053 a33=scalar(uz(1,i),uz(1,j))-3*urz*vrz
4054 fac=dsqrt(-ael6i)*r3ij
4059 cd write (iout,'(4i5,4f10.5)')
4060 cd & i,itortyp(itype(i)),j,itortyp(itype(j)),a22,a23,a32,a33
4061 cd write (iout,'(6f10.5)') (muij(k),k=1,4),fac,eel_loc_ij
4062 cd write (iout,'(2(3f10.5,5x)/2(3f10.5,5x))') uy(:,i),uz(:,i),
4063 cd & uy(:,j),uz(:,j)
4064 cd write (iout,'(4f10.5)')
4065 cd & scalar(uy(1,i),uy(1,j)),scalar(uy(1,i),uz(1,j)),
4066 cd & scalar(uz(1,i),uy(1,j)),scalar(uz(1,i),uz(1,j))
4067 cd write (iout,'(4f10.5)') ury,urz,vry,vrz
4068 cd write (iout,'(9f10.5/)')
4069 cd & fac22,a22,fac23,a23,fac32,a32,fac33,a33,eel_loc_ij
4070 C Derivatives of the elements of A in virtual-bond vectors
4071 call unormderiv(erij(1),unmat(1,1),rmij,erder(1,1))
4073 uryg(k,1)=scalar(erder(1,k),uy(1,i))
4074 uryg(k,2)=scalar(uygrad(1,k,1,i),erij(1))
4075 uryg(k,3)=scalar(uygrad(1,k,2,i),erij(1))
4076 urzg(k,1)=scalar(erder(1,k),uz(1,i))
4077 urzg(k,2)=scalar(uzgrad(1,k,1,i),erij(1))
4078 urzg(k,3)=scalar(uzgrad(1,k,2,i),erij(1))
4079 vryg(k,1)=scalar(erder(1,k),uy(1,j))
4080 vryg(k,2)=scalar(uygrad(1,k,1,j),erij(1))
4081 vryg(k,3)=scalar(uygrad(1,k,2,j),erij(1))
4082 vrzg(k,1)=scalar(erder(1,k),uz(1,j))
4083 vrzg(k,2)=scalar(uzgrad(1,k,1,j),erij(1))
4084 vrzg(k,3)=scalar(uzgrad(1,k,2,j),erij(1))
4086 C Compute radial contributions to the gradient
4104 C Add the contributions coming from er
4107 agg(k,1)=agg(k,1)+fac3*(uryg(k,1)*vry+vryg(k,1)*ury)
4108 agg(k,2)=agg(k,2)+fac3*(uryg(k,1)*vrz+vrzg(k,1)*ury)
4109 agg(k,3)=agg(k,3)+fac3*(urzg(k,1)*vry+vryg(k,1)*urz)
4110 agg(k,4)=agg(k,4)+fac3*(urzg(k,1)*vrz+vrzg(k,1)*urz)
4113 C Derivatives in DC(i)
4114 cgrad ghalf1=0.5d0*agg(k,1)
4115 cgrad ghalf2=0.5d0*agg(k,2)
4116 cgrad ghalf3=0.5d0*agg(k,3)
4117 cgrad ghalf4=0.5d0*agg(k,4)
4118 aggi(k,1)=fac*(scalar(uygrad(1,k,1,i),uy(1,j))
4119 & -3.0d0*uryg(k,2)*vry)!+ghalf1
4120 aggi(k,2)=fac*(scalar(uygrad(1,k,1,i),uz(1,j))
4121 & -3.0d0*uryg(k,2)*vrz)!+ghalf2
4122 aggi(k,3)=fac*(scalar(uzgrad(1,k,1,i),uy(1,j))
4123 & -3.0d0*urzg(k,2)*vry)!+ghalf3
4124 aggi(k,4)=fac*(scalar(uzgrad(1,k,1,i),uz(1,j))
4125 & -3.0d0*urzg(k,2)*vrz)!+ghalf4
4126 C Derivatives in DC(i+1)
4127 aggi1(k,1)=fac*(scalar(uygrad(1,k,2,i),uy(1,j))
4128 & -3.0d0*uryg(k,3)*vry)!+agg(k,1)
4129 aggi1(k,2)=fac*(scalar(uygrad(1,k,2,i),uz(1,j))
4130 & -3.0d0*uryg(k,3)*vrz)!+agg(k,2)
4131 aggi1(k,3)=fac*(scalar(uzgrad(1,k,2,i),uy(1,j))
4132 & -3.0d0*urzg(k,3)*vry)!+agg(k,3)
4133 aggi1(k,4)=fac*(scalar(uzgrad(1,k,2,i),uz(1,j))
4134 & -3.0d0*urzg(k,3)*vrz)!+agg(k,4)
4135 C Derivatives in DC(j)
4136 aggj(k,1)=fac*(scalar(uygrad(1,k,1,j),uy(1,i))
4137 & -3.0d0*vryg(k,2)*ury)!+ghalf1
4138 aggj(k,2)=fac*(scalar(uzgrad(1,k,1,j),uy(1,i))
4139 & -3.0d0*vrzg(k,2)*ury)!+ghalf2
4140 aggj(k,3)=fac*(scalar(uygrad(1,k,1,j),uz(1,i))
4141 & -3.0d0*vryg(k,2)*urz)!+ghalf3
4142 aggj(k,4)=fac*(scalar(uzgrad(1,k,1,j),uz(1,i))
4143 & -3.0d0*vrzg(k,2)*urz)!+ghalf4
4144 C Derivatives in DC(j+1) or DC(nres-1)
4145 aggj1(k,1)=fac*(scalar(uygrad(1,k,2,j),uy(1,i))
4146 & -3.0d0*vryg(k,3)*ury)
4147 aggj1(k,2)=fac*(scalar(uzgrad(1,k,2,j),uy(1,i))
4148 & -3.0d0*vrzg(k,3)*ury)
4149 aggj1(k,3)=fac*(scalar(uygrad(1,k,2,j),uz(1,i))
4150 & -3.0d0*vryg(k,3)*urz)
4151 aggj1(k,4)=fac*(scalar(uzgrad(1,k,2,j),uz(1,i))
4152 & -3.0d0*vrzg(k,3)*urz)
4153 cgrad if (j.eq.nres-1 .and. i.lt.j-2) then
4155 cgrad aggj1(k,l)=aggj1(k,l)+agg(k,l)
4168 aggi(k,l)=-aggi(k,l)
4169 aggi1(k,l)=-aggi1(k,l)
4170 aggj(k,l)=-aggj(k,l)
4171 aggj1(k,l)=-aggj1(k,l)
4174 if (j.lt.nres-1) then
4180 aggi(k,l)=-aggi(k,l)
4181 aggi1(k,l)=-aggi1(k,l)
4182 aggj(k,l)=-aggj(k,l)
4183 aggj1(k,l)=-aggj1(k,l)
4194 aggi(k,l)=-aggi(k,l)
4195 aggi1(k,l)=-aggi1(k,l)
4196 aggj(k,l)=-aggj(k,l)
4197 aggj1(k,l)=-aggj1(k,l)
4202 IF (wel_loc.gt.0.0d0) THEN
4203 C Contribution to the local-electrostatic energy coming from the i-j pair
4204 eel_loc_ij=a22*muij(1)+a23*muij(2)+a32*muij(3)
4206 if (shield_mode.eq.0) then
4213 eel_loc_ij=eel_loc_ij
4214 & *fac_shield(i)*fac_shield(j)
4215 C Now derivative over eel_loc
4216 if ((fac_shield(i).gt.0).and.(fac_shield(j).gt.0).and.
4217 & (shield_mode.gt.0)) then
4220 do ilist=1,ishield_list(i)
4221 iresshield=shield_list(ilist,i)
4223 rlocshield=grad_shield_side(k,ilist,i)*eel_loc_ij
4226 gshieldx_ll(k,iresshield)=gshieldx_ll(k,iresshield)+
4228 & +grad_shield_loc(k,ilist,i)*eel_loc_ij/fac_shield(i)
4229 gshieldc_ll(k,iresshield-1)=gshieldc_ll(k,iresshield-1)
4233 do ilist=1,ishield_list(j)
4234 iresshield=shield_list(ilist,j)
4236 rlocshield=grad_shield_side(k,ilist,j)*eel_loc_ij
4239 gshieldx_ll(k,iresshield)=gshieldx_ll(k,iresshield)+
4241 & +grad_shield_loc(k,ilist,j)*eel_loc_ij/fac_shield(j)
4242 gshieldc_ll(k,iresshield-1)=gshieldc_ll(k,iresshield-1)
4249 gshieldc_ll(k,i)=gshieldc_ll(k,i)+
4250 & grad_shield(k,i)*eel_loc_ij/fac_shield(i)
4251 gshieldc_ll(k,j)=gshieldc_ll(k,j)+
4252 & grad_shield(k,j)*eel_loc_ij/fac_shield(j)
4253 gshieldc_ll(k,i-1)=gshieldc_ll(k,i-1)+
4254 & grad_shield(k,i)*eel_loc_ij/fac_shield(i)
4255 gshieldc_ll(k,j-1)=gshieldc_ll(k,j-1)+
4256 & grad_shield(k,j)*eel_loc_ij/fac_shield(j)
4261 c write (iout,*) 'i',i,' j',j,itype(i),itype(j),
4262 c & ' eel_loc_ij',eel_loc_ij
4263 C write(iout,*) 'muije=',i,j,muij(1),muij(2),muij(3),muij(4)
4264 C Calculate patrial derivative for theta angle
4266 geel_loc_ij=(a22*gmuij1(1)
4270 & *fac_shield(i)*fac_shield(j)
4271 c write(iout,*) "derivative over thatai"
4272 c write(iout,*) a22*gmuij1(1), a23*gmuij1(2) ,a32*gmuij1(3),
4274 gloc(nphi+i,icg)=gloc(nphi+i,icg)+
4275 & geel_loc_ij*wel_loc
4276 c write(iout,*) "derivative over thatai-1"
4277 c write(iout,*) a22*gmuij2(1), a23*gmuij2(2) ,a32*gmuij2(3),
4284 gloc(nphi+i-1,icg)=gloc(nphi+i-1,icg)+
4285 & geel_loc_ij*wel_loc
4286 & *fac_shield(i)*fac_shield(j)
4288 c Derivative over j residue
4289 geel_loc_ji=a22*gmuji1(1)
4293 c write(iout,*) "derivative over thataj"
4294 c write(iout,*) a22*gmuji1(1), a23*gmuji1(2) ,a32*gmuji1(3),
4297 gloc(nphi+j,icg)=gloc(nphi+j,icg)+
4298 & geel_loc_ji*wel_loc
4299 & *fac_shield(i)*fac_shield(j)
4306 c write(iout,*) "derivative over thataj-1"
4307 c write(iout,*) a22*gmuji2(1), a23*gmuji2(2) ,a32*gmuji2(3),
4309 gloc(nphi+j-1,icg)=gloc(nphi+j-1,icg)+
4310 & geel_loc_ji*wel_loc
4311 & *fac_shield(i)*fac_shield(j)
4313 cd write (iout,*) 'i',i,' j',j,' eel_loc_ij',eel_loc_ij
4315 if (energy_dec) write (iout,'(a6,2i5,0pf7.3)')
4316 & 'eelloc',i,j,eel_loc_ij
4317 c if (eel_loc_ij.ne.0)
4318 c & write (iout,'(a4,2i4,8f9.5)')'chuj',
4319 c & i,j,a22,muij(1),a23,muij(2),a32,muij(3),a33,muij(4)
4321 eel_loc=eel_loc+eel_loc_ij
4322 C Partial derivatives in virtual-bond dihedral angles gamma
4324 & gel_loc_loc(i-1)=gel_loc_loc(i-1)+
4325 & (a22*muder(1,i)*mu(1,j)+a23*muder(1,i)*mu(2,j)
4326 & +a32*muder(2,i)*mu(1,j)+a33*muder(2,i)*mu(2,j))
4327 & *fac_shield(i)*fac_shield(j)
4329 gel_loc_loc(j-1)=gel_loc_loc(j-1)+
4330 & (a22*mu(1,i)*muder(1,j)+a23*mu(1,i)*muder(2,j)
4331 & +a32*mu(2,i)*muder(1,j)+a33*mu(2,i)*muder(2,j))
4332 & *fac_shield(i)*fac_shield(j)
4333 C Derivatives of eello in DC(i+1) thru DC(j-1) or DC(nres-2)
4335 ggg(l)=(agg(l,1)*muij(1)+
4336 & agg(l,2)*muij(2)+agg(l,3)*muij(3)+agg(l,4)*muij(4))
4337 & *fac_shield(i)*fac_shield(j)
4338 gel_loc_long(l,j)=gel_loc_long(l,j)+ggg(l)
4339 gel_loc_long(l,i)=gel_loc_long(l,i)-ggg(l)
4340 cgrad ghalf=0.5d0*ggg(l)
4341 cgrad gel_loc(l,i)=gel_loc(l,i)+ghalf
4342 cgrad gel_loc(l,j)=gel_loc(l,j)+ghalf
4346 cgrad gel_loc(l,k)=gel_loc(l,k)+ggg(l)
4349 C Remaining derivatives of eello
4351 gel_loc(l,i)=gel_loc(l,i)+(aggi(l,1)*muij(1)+
4352 & aggi(l,2)*muij(2)+aggi(l,3)*muij(3)+aggi(l,4)*muij(4))
4353 & *fac_shield(i)*fac_shield(j)
4355 gel_loc(l,i+1)=gel_loc(l,i+1)+(aggi1(l,1)*muij(1)+
4356 & aggi1(l,2)*muij(2)+aggi1(l,3)*muij(3)+aggi1(l,4)*muij(4))
4357 & *fac_shield(i)*fac_shield(j)
4359 gel_loc(l,j)=gel_loc(l,j)+(aggj(l,1)*muij(1)+
4360 & aggj(l,2)*muij(2)+aggj(l,3)*muij(3)+aggj(l,4)*muij(4))
4361 & *fac_shield(i)*fac_shield(j)
4363 gel_loc(l,j1)=gel_loc(l,j1)+(aggj1(l,1)*muij(1)+
4364 & aggj1(l,2)*muij(2)+aggj1(l,3)*muij(3)+aggj1(l,4)*muij(4))
4365 & *fac_shield(i)*fac_shield(j)
4369 C Change 12/26/95 to calculate four-body contributions to H-bonding energy
4370 c if (j.gt.i+1 .and. num_conti.le.maxconts) then
4371 if (wcorr+wcorr4+wcorr5+wcorr6.gt.0.0d0
4372 & .and. num_conti.le.maxconts) then
4373 c write (iout,*) i,j," entered corr"
4375 C Calculate the contact function. The ith column of the array JCONT will
4376 C contain the numbers of atoms that make contacts with the atom I (of numbers
4377 C greater than I). The arrays FACONT and GACONT will contain the values of
4378 C the contact function and its derivative.
4379 c r0ij=1.02D0*rpp(iteli,itelj)
4380 c r0ij=1.11D0*rpp(iteli,itelj)
4381 r0ij=2.20D0*rpp(iteli,itelj)
4382 c r0ij=1.55D0*rpp(iteli,itelj)
4383 call gcont(rij,r0ij,1.0D0,0.2d0*r0ij,fcont,fprimcont)
4384 if (fcont.gt.0.0D0) then
4385 num_conti=num_conti+1
4386 if (num_conti.gt.maxconts) then
4387 write (iout,*) 'WARNING - max. # of contacts exceeded;',
4388 & ' will skip next contacts for this conf.'
4390 jcont_hb(num_conti,i)=j
4391 cd write (iout,*) "i",i," j",j," num_conti",num_conti,
4392 cd & " jcont_hb",jcont_hb(num_conti,i)
4393 IF (wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 .or.
4394 & wcorr6.gt.0.0d0 .or. wturn6.gt.0.0d0) THEN
4395 C 9/30/99 (AL) - store components necessary to evaluate higher-order loc-el
4397 d_cont(num_conti,i)=rij
4398 cd write (2,'(3e15.5)') rij,r0ij+0.2d0*r0ij,rij
4399 C --- Electrostatic-interaction matrix ---
4400 a_chuj(1,1,num_conti,i)=a22
4401 a_chuj(1,2,num_conti,i)=a23
4402 a_chuj(2,1,num_conti,i)=a32
4403 a_chuj(2,2,num_conti,i)=a33
4404 C --- Gradient of rij
4406 grij_hb_cont(kkk,num_conti,i)=erij(kkk)
4413 a_chuj_der(k,l,m,1,num_conti,i)=agg(m,kkll)
4414 a_chuj_der(k,l,m,2,num_conti,i)=aggi(m,kkll)
4415 a_chuj_der(k,l,m,3,num_conti,i)=aggi1(m,kkll)
4416 a_chuj_der(k,l,m,4,num_conti,i)=aggj(m,kkll)
4417 a_chuj_der(k,l,m,5,num_conti,i)=aggj1(m,kkll)
4422 IF (wcorr4.eq.0.0d0 .and. wcorr.gt.0.0d0) THEN
4423 C Calculate contact energies
4425 wij=cosa-3.0D0*cosb*cosg
4428 c fac3=dsqrt(-ael6i)/r0ij**3
4429 fac3=dsqrt(-ael6i)*r3ij
4430 c ees0pij=dsqrt(4.0D0+cosa4+wij*wij-3.0D0*cosbg1*cosbg1)
4431 ees0tmp=4.0D0+cosa4+wij*wij-3.0D0*cosbg1*cosbg1
4432 if (ees0tmp.gt.0) then
4433 ees0pij=dsqrt(ees0tmp)
4437 c ees0mij=dsqrt(4.0D0-cosa4+wij*wij-3.0D0*cosbg2*cosbg2)
4438 ees0tmp=4.0D0-cosa4+wij*wij-3.0D0*cosbg2*cosbg2
4439 if (ees0tmp.gt.0) then
4440 ees0mij=dsqrt(ees0tmp)
4445 if (shield_mode.eq.0) then
4449 ees0plist(num_conti,i)=j
4450 C fac_shield(i)=0.4d0
4451 C fac_shield(j)=0.6d0
4453 ees0p(num_conti,i)=0.5D0*fac3*(ees0pij+ees0mij)
4454 & *fac_shield(i)*fac_shield(j)
4455 ees0m(num_conti,i)=0.5D0*fac3*(ees0pij-ees0mij)
4456 & *fac_shield(i)*fac_shield(j)
4457 C Diagnostics. Comment out or remove after debugging!
4458 c ees0p(num_conti,i)=0.5D0*fac3*ees0pij
4459 c ees0m(num_conti,i)=0.5D0*fac3*ees0mij
4460 c ees0m(num_conti,i)=0.0D0
4462 c write (iout,*) 'i=',i,' j=',j,' rij=',rij,' r0ij=',r0ij,
4463 c & ' ees0ij=',ees0p(num_conti,i),ees0m(num_conti,i),' fcont=',fcont
4464 C Angular derivatives of the contact function
4465 ees0pij1=fac3/ees0pij
4466 ees0mij1=fac3/ees0mij
4467 fac3p=-3.0D0*fac3*rrmij
4468 ees0pijp=0.5D0*fac3p*(ees0pij+ees0mij)
4469 ees0mijp=0.5D0*fac3p*(ees0pij-ees0mij)
4471 ecosa1= ees0pij1*( 1.0D0+0.5D0*wij)
4472 ecosb1=-1.5D0*ees0pij1*(wij*cosg+cosbg1)
4473 ecosg1=-1.5D0*ees0pij1*(wij*cosb+cosbg1)
4474 ecosa2= ees0mij1*(-1.0D0+0.5D0*wij)
4475 ecosb2=-1.5D0*ees0mij1*(wij*cosg+cosbg2)
4476 ecosg2=-1.5D0*ees0mij1*(wij*cosb-cosbg2)
4477 ecosap=ecosa1+ecosa2
4478 ecosbp=ecosb1+ecosb2
4479 ecosgp=ecosg1+ecosg2
4480 ecosam=ecosa1-ecosa2
4481 ecosbm=ecosb1-ecosb2
4482 ecosgm=ecosg1-ecosg2
4491 facont_hb(num_conti,i)=fcont
4492 fprimcont=fprimcont/rij
4493 cd facont_hb(num_conti,i)=1.0D0
4494 C Following line is for diagnostics.
4497 dcosb(k)=rmij*(dc_norm(k,i)-erij(k)*cosb)
4498 dcosg(k)=rmij*(dc_norm(k,j)-erij(k)*cosg)
4501 gggp(k)=ecosbp*dcosb(k)+ecosgp*dcosg(k)
4502 gggm(k)=ecosbm*dcosb(k)+ecosgm*dcosg(k)
4504 gggp(1)=gggp(1)+ees0pijp*xj
4505 gggp(2)=gggp(2)+ees0pijp*yj
4506 gggp(3)=gggp(3)+ees0pijp*zj
4507 gggm(1)=gggm(1)+ees0mijp*xj
4508 gggm(2)=gggm(2)+ees0mijp*yj
4509 gggm(3)=gggm(3)+ees0mijp*zj
4510 C Derivatives due to the contact function
4511 gacont_hbr(1,num_conti,i)=fprimcont*xj
4512 gacont_hbr(2,num_conti,i)=fprimcont*yj
4513 gacont_hbr(3,num_conti,i)=fprimcont*zj
4516 c 10/24/08 cgrad and ! comments indicate the parts of the code removed
4517 c following the change of gradient-summation algorithm.
4519 cgrad ghalfp=0.5D0*gggp(k)
4520 cgrad ghalfm=0.5D0*gggm(k)
4521 gacontp_hb1(k,num_conti,i)=!ghalfp
4522 & +(ecosap*(dc_norm(k,j)-cosa*dc_norm(k,i))
4523 & + ecosbp*(erij(k)-cosb*dc_norm(k,i)))*vbld_inv(i+1)
4524 & *fac_shield(i)*fac_shield(j)
4526 gacontp_hb2(k,num_conti,i)=!ghalfp
4527 & +(ecosap*(dc_norm(k,i)-cosa*dc_norm(k,j))
4528 & + ecosgp*(erij(k)-cosg*dc_norm(k,j)))*vbld_inv(j+1)
4529 & *fac_shield(i)*fac_shield(j)
4531 gacontp_hb3(k,num_conti,i)=gggp(k)
4532 & *fac_shield(i)*fac_shield(j)
4534 gacontm_hb1(k,num_conti,i)=!ghalfm
4535 & +(ecosam*(dc_norm(k,j)-cosa*dc_norm(k,i))
4536 & + ecosbm*(erij(k)-cosb*dc_norm(k,i)))*vbld_inv(i+1)
4537 & *fac_shield(i)*fac_shield(j)
4539 gacontm_hb2(k,num_conti,i)=!ghalfm
4540 & +(ecosam*(dc_norm(k,i)-cosa*dc_norm(k,j))
4541 & + ecosgm*(erij(k)-cosg*dc_norm(k,j)))*vbld_inv(j+1)
4542 & *fac_shield(i)*fac_shield(j)
4544 gacontm_hb3(k,num_conti,i)=gggm(k)
4545 & *fac_shield(i)*fac_shield(j)
4548 C Diagnostics. Comment out or remove after debugging!
4550 cdiag gacontp_hb1(k,num_conti,i)=0.0D0
4551 cdiag gacontp_hb2(k,num_conti,i)=0.0D0
4552 cdiag gacontp_hb3(k,num_conti,i)=0.0D0
4553 cdiag gacontm_hb1(k,num_conti,i)=0.0D0
4554 cdiag gacontm_hb2(k,num_conti,i)=0.0D0
4555 cdiag gacontm_hb3(k,num_conti,i)=0.0D0
4558 endif ! num_conti.le.maxconts
4561 if (wturn3.gt.0.0d0 .or. wturn4.gt.0.0d0) then
4564 ghalf=0.5d0*agg(l,k)
4565 aggi(l,k)=aggi(l,k)+ghalf
4566 aggi1(l,k)=aggi1(l,k)+agg(l,k)
4567 aggj(l,k)=aggj(l,k)+ghalf
4570 if (j.eq.nres-1 .and. i.lt.j-2) then
4573 aggj1(l,k)=aggj1(l,k)+agg(l,k)
4578 c t_eelecij=t_eelecij+MPI_Wtime()-time00
4581 C-----------------------------------------------------------------------------
4582 subroutine eturn3(i,eello_turn3)
4583 C Third- and fourth-order contributions from turns
4584 implicit real*8 (a-h,o-z)
4585 include 'DIMENSIONS'
4586 include 'COMMON.IOUNITS'
4587 include 'COMMON.GEO'
4588 include 'COMMON.VAR'
4589 include 'COMMON.LOCAL'
4590 include 'COMMON.CHAIN'
4591 include 'COMMON.DERIV'
4592 include 'COMMON.INTERACT'
4593 include 'COMMON.CONTACTS'
4594 include 'COMMON.TORSION'
4595 include 'COMMON.VECTORS'
4596 include 'COMMON.FFIELD'
4597 include 'COMMON.CONTROL'
4598 include 'COMMON.SHIELD'
4600 double precision auxmat(2,2),auxmat1(2,2),auxmat2(2,2),pizda(2,2),
4601 & e1t(2,2),e2t(2,2),e3t(2,2),e1tder(2,2),e2tder(2,2),e3tder(2,2),
4602 & e1a(2,2),ae3(2,2),ae3e2(2,2),auxvec(2),auxvec1(2),gpizda1(2,2),
4603 & gpizda2(2,2),auxgmat1(2,2),auxgmatt1(2,2),
4604 & auxgmat2(2,2),auxgmatt2(2,2)
4605 double precision agg(3,4),aggi(3,4),aggi1(3,4),
4606 & aggj(3,4),aggj1(3,4),a_temp(2,2),auxmat3(2,2)
4607 common /locel/ a_temp,agg,aggi,aggi1,aggj,aggj1,a22,a23,a32,a33,
4608 & dxi,dyi,dzi,dx_normi,dy_normi,dz_normi,xmedi,ymedi,zmedi,
4611 c write (iout,*) "eturn3",i,j,j1,j2
4616 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
4618 C Third-order contributions
4625 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
4626 cd call checkint_turn3(i,a_temp,eello_turn3_num)
4627 call matmat2(EUg(1,1,i+1),EUg(1,1,i+2),auxmat(1,1))
4628 c auxalary matices for theta gradient
4629 c auxalary matrix for i+1 and constant i+2
4630 call matmat2(gtEUg(1,1,i+1),EUg(1,1,i+2),auxgmat1(1,1))
4631 c auxalary matrix for i+2 and constant i+1
4632 call matmat2(EUg(1,1,i+1),gtEUg(1,1,i+2),auxgmat2(1,1))
4633 call transpose2(auxmat(1,1),auxmat1(1,1))
4634 call transpose2(auxgmat1(1,1),auxgmatt1(1,1))
4635 call transpose2(auxgmat2(1,1),auxgmatt2(1,1))
4636 call matmat2(a_temp(1,1),auxmat1(1,1),pizda(1,1))
4637 call matmat2(a_temp(1,1),auxgmatt1(1,1),gpizda1(1,1))
4638 call matmat2(a_temp(1,1),auxgmatt2(1,1),gpizda2(1,1))
4639 if (shield_mode.eq.0) then
4646 eello_turn3=eello_turn3+0.5d0*(pizda(1,1)+pizda(2,2))
4647 & *fac_shield(i)*fac_shield(j)
4648 eello_t3=0.5d0*(pizda(1,1)+pizda(2,2))
4649 & *fac_shield(i)*fac_shield(j)
4650 C Derivatives in theta
4651 gloc(nphi+i,icg)=gloc(nphi+i,icg)
4652 & +0.5d0*(gpizda1(1,1)+gpizda1(2,2))*wturn3
4653 & *fac_shield(i)*fac_shield(j)
4654 gloc(nphi+i+1,icg)=gloc(nphi+i+1,icg)
4655 & +0.5d0*(gpizda2(1,1)+gpizda2(2,2))*wturn3
4656 & *fac_shield(i)*fac_shield(j)
4659 C if (energy_dec) write (iout,'(a6,2i5,0pf7.3)')
4660 C Derivatives in shield mode
4661 if ((fac_shield(i).gt.0).and.(fac_shield(j).gt.0).and.
4662 & (shield_mode.gt.0)) then
4665 do ilist=1,ishield_list(i)
4666 iresshield=shield_list(ilist,i)
4668 rlocshield=grad_shield_side(k,ilist,i)*eello_t3/fac_shield(i)
4670 gshieldx_t3(k,iresshield)=gshieldx_t3(k,iresshield)+
4672 & +grad_shield_loc(k,ilist,i)*eello_t3/fac_shield(i)
4673 gshieldc_t3(k,iresshield-1)=gshieldc_t3(k,iresshield-1)
4677 do ilist=1,ishield_list(j)
4678 iresshield=shield_list(ilist,j)
4680 rlocshield=grad_shield_side(k,ilist,j)*eello_t3/fac_shield(j)
4682 gshieldx_t3(k,iresshield)=gshieldx_t3(k,iresshield)+
4684 & +grad_shield_loc(k,ilist,j)*eello_t3/fac_shield(j)
4685 gshieldc_t3(k,iresshield-1)=gshieldc_t3(k,iresshield-1)
4692 gshieldc_t3(k,i)=gshieldc_t3(k,i)+
4693 & grad_shield(k,i)*eello_t3/fac_shield(i)
4694 gshieldc_t3(k,j)=gshieldc_t3(k,j)+
4695 & grad_shield(k,j)*eello_t3/fac_shield(j)
4696 gshieldc_t3(k,i-1)=gshieldc_t3(k,i-1)+
4697 & grad_shield(k,i)*eello_t3/fac_shield(i)
4698 gshieldc_t3(k,j-1)=gshieldc_t3(k,j-1)+
4699 & grad_shield(k,j)*eello_t3/fac_shield(j)
4703 C if (energy_dec) write (iout,'(a6,2i5,0pf7.3)')
4704 cd write (2,*) 'i,',i,' j',j,'eello_turn3',
4705 cd & 0.5d0*(pizda(1,1)+pizda(2,2)),
4706 cd & ' eello_turn3_num',4*eello_turn3_num
4707 C Derivatives in gamma(i)
4708 call matmat2(EUgder(1,1,i+1),EUg(1,1,i+2),auxmat2(1,1))
4709 call transpose2(auxmat2(1,1),auxmat3(1,1))
4710 call matmat2(a_temp(1,1),auxmat3(1,1),pizda(1,1))
4711 gel_loc_turn3(i)=gel_loc_turn3(i)+0.5d0*(pizda(1,1)+pizda(2,2))
4712 & *fac_shield(i)*fac_shield(j)
4713 C Derivatives in gamma(i+1)
4714 call matmat2(EUg(1,1,i+1),EUgder(1,1,i+2),auxmat2(1,1))
4715 call transpose2(auxmat2(1,1),auxmat3(1,1))
4716 call matmat2(a_temp(1,1),auxmat3(1,1),pizda(1,1))
4717 gel_loc_turn3(i+1)=gel_loc_turn3(i+1)
4718 & +0.5d0*(pizda(1,1)+pizda(2,2))
4719 & *fac_shield(i)*fac_shield(j)
4720 C Cartesian derivatives
4722 c ghalf1=0.5d0*agg(l,1)
4723 c ghalf2=0.5d0*agg(l,2)
4724 c ghalf3=0.5d0*agg(l,3)
4725 c ghalf4=0.5d0*agg(l,4)
4726 a_temp(1,1)=aggi(l,1)!+ghalf1
4727 a_temp(1,2)=aggi(l,2)!+ghalf2
4728 a_temp(2,1)=aggi(l,3)!+ghalf3
4729 a_temp(2,2)=aggi(l,4)!+ghalf4
4730 call matmat2(a_temp(1,1),auxmat1(1,1),pizda(1,1))
4731 gcorr3_turn(l,i)=gcorr3_turn(l,i)
4732 & +0.5d0*(pizda(1,1)+pizda(2,2))
4733 & *fac_shield(i)*fac_shield(j)
4735 a_temp(1,1)=aggi1(l,1)!+agg(l,1)
4736 a_temp(1,2)=aggi1(l,2)!+agg(l,2)
4737 a_temp(2,1)=aggi1(l,3)!+agg(l,3)
4738 a_temp(2,2)=aggi1(l,4)!+agg(l,4)
4739 call matmat2(a_temp(1,1),auxmat1(1,1),pizda(1,1))
4740 gcorr3_turn(l,i+1)=gcorr3_turn(l,i+1)
4741 & +0.5d0*(pizda(1,1)+pizda(2,2))
4742 & *fac_shield(i)*fac_shield(j)
4743 a_temp(1,1)=aggj(l,1)!+ghalf1
4744 a_temp(1,2)=aggj(l,2)!+ghalf2
4745 a_temp(2,1)=aggj(l,3)!+ghalf3
4746 a_temp(2,2)=aggj(l,4)!+ghalf4
4747 call matmat2(a_temp(1,1),auxmat1(1,1),pizda(1,1))
4748 gcorr3_turn(l,j)=gcorr3_turn(l,j)
4749 & +0.5d0*(pizda(1,1)+pizda(2,2))
4750 & *fac_shield(i)*fac_shield(j)
4751 a_temp(1,1)=aggj1(l,1)
4752 a_temp(1,2)=aggj1(l,2)
4753 a_temp(2,1)=aggj1(l,3)
4754 a_temp(2,2)=aggj1(l,4)
4755 call matmat2(a_temp(1,1),auxmat1(1,1),pizda(1,1))
4756 gcorr3_turn(l,j1)=gcorr3_turn(l,j1)
4757 & +0.5d0*(pizda(1,1)+pizda(2,2))
4758 & *fac_shield(i)*fac_shield(j)
4762 C-------------------------------------------------------------------------------
4763 subroutine eturn4(i,eello_turn4)
4764 C Third- and fourth-order contributions from turns
4765 implicit real*8 (a-h,o-z)
4766 include 'DIMENSIONS'
4767 include 'COMMON.IOUNITS'
4768 include 'COMMON.GEO'
4769 include 'COMMON.VAR'
4770 include 'COMMON.LOCAL'
4771 include 'COMMON.CHAIN'
4772 include 'COMMON.DERIV'
4773 include 'COMMON.INTERACT'
4774 include 'COMMON.CONTACTS'
4775 include 'COMMON.TORSION'
4776 include 'COMMON.VECTORS'
4777 include 'COMMON.FFIELD'
4778 include 'COMMON.CONTROL'
4779 include 'COMMON.SHIELD'
4781 double precision auxmat(2,2),auxmat1(2,2),auxmat2(2,2),pizda(2,2),
4782 & e1t(2,2),e2t(2,2),e3t(2,2),e1tder(2,2),e2tder(2,2),e3tder(2,2),
4783 & e1a(2,2),ae3(2,2),ae3e2(2,2),auxvec(2),auxvec1(2),auxgvec(2),
4784 & auxgEvec1(2),auxgEvec2(2),auxgEvec3(2),
4785 & gte1t(2,2),gte2t(2,2),gte3t(2,2),
4786 & gte1a(2,2),gtae3(2,2),gtae3e2(2,2), ae3gte2(2,2),
4787 & gtEpizda1(2,2),gtEpizda2(2,2),gtEpizda3(2,2)
4788 double precision agg(3,4),aggi(3,4),aggi1(3,4),
4789 & aggj(3,4),aggj1(3,4),a_temp(2,2),auxmat3(2,2)
4790 common /locel/ a_temp,agg,aggi,aggi1,aggj,aggj1,a22,a23,a32,a33,
4791 & dxi,dyi,dzi,dx_normi,dy_normi,dz_normi,xmedi,ymedi,zmedi,
4794 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
4796 C Fourth-order contributions
4804 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
4805 cd call checkint_turn4(i,a_temp,eello_turn4_num)
4806 c write (iout,*) "eturn4 i",i," j",j," j1",j1," j2",j2
4807 c write(iout,*)"WCHODZE W PROGRAM"
4812 iti1=itortyp(itype(i+1))
4813 iti2=itortyp(itype(i+2))
4814 iti3=itortyp(itype(i+3))
4815 c write(iout,*) "iti1",iti1," iti2",iti2," iti3",iti3
4816 call transpose2(EUg(1,1,i+1),e1t(1,1))
4817 call transpose2(Eug(1,1,i+2),e2t(1,1))
4818 call transpose2(Eug(1,1,i+3),e3t(1,1))
4819 C Ematrix derivative in theta
4820 call transpose2(gtEUg(1,1,i+1),gte1t(1,1))
4821 call transpose2(gtEug(1,1,i+2),gte2t(1,1))
4822 call transpose2(gtEug(1,1,i+3),gte3t(1,1))
4823 call matmat2(e1t(1,1),a_temp(1,1),e1a(1,1))
4824 c eta1 in derivative theta
4825 call matmat2(gte1t(1,1),a_temp(1,1),gte1a(1,1))
4826 call matvec2(e1a(1,1),Ub2(1,i+3),auxvec(1))
4827 c auxgvec is derivative of Ub2 so i+3 theta
4828 call matvec2(e1a(1,1),gUb2(1,i+3),auxgvec(1))
4829 c auxalary matrix of E i+1
4830 call matvec2(gte1a(1,1),Ub2(1,i+3),auxgEvec1(1))
4833 s1=scalar2(b1(1,i+2),auxvec(1))
4834 c derivative of theta i+2 with constant i+3
4835 gs23=scalar2(gtb1(1,i+2),auxvec(1))
4836 c derivative of theta i+2 with constant i+2
4837 gs32=scalar2(b1(1,i+2),auxgvec(1))
4838 c derivative of E matix in theta of i+1
4839 gsE13=scalar2(b1(1,i+2),auxgEvec1(1))
4841 call matmat2(a_temp(1,1),e3t(1,1),ae3(1,1))
4842 c ea31 in derivative theta
4843 call matmat2(a_temp(1,1),gte3t(1,1),gtae3(1,1))
4844 call matvec2(ae3(1,1),Ub2(1,i+2),auxvec(1))
4845 c auxilary matrix auxgvec of Ub2 with constant E matirx
4846 call matvec2(ae3(1,1),gUb2(1,i+2),auxgvec(1))
4847 c auxilary matrix auxgEvec1 of E matix with Ub2 constant
4848 call matvec2(gtae3(1,1),Ub2(1,i+2),auxgEvec3(1))
4852 s2=scalar2(b1(1,i+1),auxvec(1))
4853 c derivative of theta i+1 with constant i+3
4854 gs13=scalar2(gtb1(1,i+1),auxvec(1))
4855 c derivative of theta i+2 with constant i+1
4856 gs21=scalar2(b1(1,i+1),auxgvec(1))
4857 c derivative of theta i+3 with constant i+1
4858 gsE31=scalar2(b1(1,i+1),auxgEvec3(1))
4859 c write(iout,*) gs1,gs2,'i=',i,auxgvec(1),gUb2(1,i+2),gtb1(1,i+2),
4861 call matmat2(ae3(1,1),e2t(1,1),ae3e2(1,1))
4862 c two derivatives over diffetent matrices
4863 c gtae3e2 is derivative over i+3
4864 call matmat2(gtae3(1,1),e2t(1,1),gtae3e2(1,1))
4865 c ae3gte2 is derivative over i+2
4866 call matmat2(ae3(1,1),gte2t(1,1),ae3gte2(1,1))
4867 call matmat2(ae3e2(1,1),e1t(1,1),pizda(1,1))
4868 c three possible derivative over theta E matices
4870 call matmat2(ae3e2(1,1),gte1t(1,1),gtEpizda1(1,1))
4872 call matmat2(ae3gte2(1,1),e1t(1,1),gtEpizda2(1,1))
4874 call matmat2(gtae3e2(1,1),e1t(1,1),gtEpizda3(1,1))
4875 s3=0.5d0*(pizda(1,1)+pizda(2,2))
4877 gsEE1=0.5d0*(gtEpizda1(1,1)+gtEpizda1(2,2))
4878 gsEE2=0.5d0*(gtEpizda2(1,1)+gtEpizda2(2,2))
4879 gsEE3=0.5d0*(gtEpizda3(1,1)+gtEpizda3(2,2))
4880 if (shield_mode.eq.0) then
4887 eello_turn4=eello_turn4-(s1+s2+s3)
4888 & *fac_shield(i)*fac_shield(j)
4889 eello_t4=-(s1+s2+s3)
4890 & *fac_shield(i)*fac_shield(j)
4891 c write(iout,*)'chujOWO', auxvec(1),b1(1,iti2)
4892 if (energy_dec) write (iout,'(a6,2i5,0pf7.3,3f7.3)')
4893 & 'eturn4',i,j,-(s1+s2+s3),s1,s2,s3
4894 C Now derivative over shield:
4895 if ((fac_shield(i).gt.0).and.(fac_shield(j).gt.0).and.
4896 & (shield_mode.gt.0)) then
4899 do ilist=1,ishield_list(i)
4900 iresshield=shield_list(ilist,i)
4902 rlocshield=grad_shield_side(k,ilist,i)*eello_t4/fac_shield(i)
4904 gshieldx_t4(k,iresshield)=gshieldx_t4(k,iresshield)+
4906 & +grad_shield_loc(k,ilist,i)*eello_t4/fac_shield(i)
4907 gshieldc_t4(k,iresshield-1)=gshieldc_t4(k,iresshield-1)
4911 do ilist=1,ishield_list(j)
4912 iresshield=shield_list(ilist,j)
4914 rlocshield=grad_shield_side(k,ilist,j)*eello_t4/fac_shield(j)
4916 gshieldx_t4(k,iresshield)=gshieldx_t4(k,iresshield)+
4918 & +grad_shield_loc(k,ilist,j)*eello_t4/fac_shield(j)
4919 gshieldc_t4(k,iresshield-1)=gshieldc_t4(k,iresshield-1)
4926 gshieldc_t4(k,i)=gshieldc_t4(k,i)+
4927 & grad_shield(k,i)*eello_t4/fac_shield(i)
4928 gshieldc_t4(k,j)=gshieldc_t4(k,j)+
4929 & grad_shield(k,j)*eello_t4/fac_shield(j)
4930 gshieldc_t4(k,i-1)=gshieldc_t4(k,i-1)+
4931 & grad_shield(k,i)*eello_t4/fac_shield(i)
4932 gshieldc_t4(k,j-1)=gshieldc_t4(k,j-1)+
4933 & grad_shield(k,j)*eello_t4/fac_shield(j)
4942 cd write (2,*) 'i,',i,' j',j,'eello_turn4',-(s1+s2+s3),
4943 cd & ' eello_turn4_num',8*eello_turn4_num
4945 gloc(nphi+i,icg)=gloc(nphi+i,icg)
4946 & -(gs13+gsE13+gsEE1)*wturn4
4947 & *fac_shield(i)*fac_shield(j)
4948 gloc(nphi+i+1,icg)= gloc(nphi+i+1,icg)
4949 & -(gs23+gs21+gsEE2)*wturn4
4950 & *fac_shield(i)*fac_shield(j)
4952 gloc(nphi+i+2,icg)= gloc(nphi+i+2,icg)
4953 & -(gs32+gsE31+gsEE3)*wturn4
4954 & *fac_shield(i)*fac_shield(j)
4956 c gloc(nphi+i+1,icg)=gloc(nphi+i+1,icg)-
4959 if (energy_dec) write (iout,'(a6,2i5,0pf7.3)')
4960 & 'eturn4',i,j,-(s1+s2+s3)
4961 c write (iout,*) 'i,',i,' j',j,'eello_turn4',-(s1+s2+s3),
4962 c & ' eello_turn4_num',8*eello_turn4_num
4963 C Derivatives in gamma(i)
4964 call transpose2(EUgder(1,1,i+1),e1tder(1,1))
4965 call matmat2(e1tder(1,1),a_temp(1,1),auxmat(1,1))
4966 call matvec2(auxmat(1,1),Ub2(1,i+3),auxvec(1))
4967 s1=scalar2(b1(1,i+2),auxvec(1))
4968 call matmat2(ae3e2(1,1),e1tder(1,1),pizda(1,1))
4969 s3=0.5d0*(pizda(1,1)+pizda(2,2))
4970 gel_loc_turn4(i)=gel_loc_turn4(i)-(s1+s3)
4971 & *fac_shield(i)*fac_shield(j)
4972 C Derivatives in gamma(i+1)
4973 call transpose2(EUgder(1,1,i+2),e2tder(1,1))
4974 call matvec2(ae3(1,1),Ub2der(1,i+2),auxvec(1))
4975 s2=scalar2(b1(1,i+1),auxvec(1))
4976 call matmat2(ae3(1,1),e2tder(1,1),auxmat(1,1))
4977 call matmat2(auxmat(1,1),e1t(1,1),pizda(1,1))
4978 s3=0.5d0*(pizda(1,1)+pizda(2,2))
4979 gel_loc_turn4(i+1)=gel_loc_turn4(i+1)-(s2+s3)
4980 & *fac_shield(i)*fac_shield(j)
4981 C Derivatives in gamma(i+2)
4982 call transpose2(EUgder(1,1,i+3),e3tder(1,1))
4983 call matvec2(e1a(1,1),Ub2der(1,i+3),auxvec(1))
4984 s1=scalar2(b1(1,i+2),auxvec(1))
4985 call matmat2(a_temp(1,1),e3tder(1,1),auxmat(1,1))
4986 call matvec2(auxmat(1,1),Ub2(1,i+2),auxvec(1))
4987 s2=scalar2(b1(1,i+1),auxvec(1))
4988 call matmat2(auxmat(1,1),e2t(1,1),auxmat3(1,1))
4989 call matmat2(auxmat3(1,1),e1t(1,1),pizda(1,1))
4990 s3=0.5d0*(pizda(1,1)+pizda(2,2))
4991 gel_loc_turn4(i+2)=gel_loc_turn4(i+2)-(s1+s2+s3)
4992 & *fac_shield(i)*fac_shield(j)
4993 C Cartesian derivatives
4994 C Derivatives of this turn contributions in DC(i+2)
4995 if (j.lt.nres-1) then
4997 a_temp(1,1)=agg(l,1)
4998 a_temp(1,2)=agg(l,2)
4999 a_temp(2,1)=agg(l,3)
5000 a_temp(2,2)=agg(l,4)
5001 call matmat2(e1t(1,1),a_temp(1,1),e1a(1,1))
5002 call matvec2(e1a(1,1),Ub2(1,i+3),auxvec(1))
5003 s1=scalar2(b1(1,i+2),auxvec(1))
5004 call matmat2(a_temp(1,1),e3t(1,1),ae3(1,1))
5005 call matvec2(ae3(1,1),Ub2(1,i+2),auxvec(1))
5006 s2=scalar2(b1(1,i+1),auxvec(1))
5007 call matmat2(ae3(1,1),e2t(1,1),ae3e2(1,1))
5008 call matmat2(ae3e2(1,1),e1t(1,1),pizda(1,1))
5009 s3=0.5d0*(pizda(1,1)+pizda(2,2))
5011 gcorr4_turn(l,i+2)=gcorr4_turn(l,i+2)-(s1+s2+s3)
5012 & *fac_shield(i)*fac_shield(j)
5015 C Remaining derivatives of this turn contribution
5017 a_temp(1,1)=aggi(l,1)
5018 a_temp(1,2)=aggi(l,2)
5019 a_temp(2,1)=aggi(l,3)
5020 a_temp(2,2)=aggi(l,4)
5021 call matmat2(e1t(1,1),a_temp(1,1),e1a(1,1))
5022 call matvec2(e1a(1,1),Ub2(1,i+3),auxvec(1))
5023 s1=scalar2(b1(1,i+2),auxvec(1))
5024 call matmat2(a_temp(1,1),e3t(1,1),ae3(1,1))
5025 call matvec2(ae3(1,1),Ub2(1,i+2),auxvec(1))
5026 s2=scalar2(b1(1,i+1),auxvec(1))
5027 call matmat2(ae3(1,1),e2t(1,1),ae3e2(1,1))
5028 call matmat2(ae3e2(1,1),e1t(1,1),pizda(1,1))
5029 s3=0.5d0*(pizda(1,1)+pizda(2,2))
5030 gcorr4_turn(l,i)=gcorr4_turn(l,i)-(s1+s2+s3)
5031 & *fac_shield(i)*fac_shield(j)
5032 a_temp(1,1)=aggi1(l,1)
5033 a_temp(1,2)=aggi1(l,2)
5034 a_temp(2,1)=aggi1(l,3)
5035 a_temp(2,2)=aggi1(l,4)
5036 call matmat2(e1t(1,1),a_temp(1,1),e1a(1,1))
5037 call matvec2(e1a(1,1),Ub2(1,i+3),auxvec(1))
5038 s1=scalar2(b1(1,i+2),auxvec(1))
5039 call matmat2(a_temp(1,1),e3t(1,1),ae3(1,1))
5040 call matvec2(ae3(1,1),Ub2(1,i+2),auxvec(1))
5041 s2=scalar2(b1(1,i+1),auxvec(1))
5042 call matmat2(ae3(1,1),e2t(1,1),ae3e2(1,1))
5043 call matmat2(ae3e2(1,1),e1t(1,1),pizda(1,1))
5044 s3=0.5d0*(pizda(1,1)+pizda(2,2))
5045 gcorr4_turn(l,i+1)=gcorr4_turn(l,i+1)-(s1+s2+s3)
5046 & *fac_shield(i)*fac_shield(j)
5047 a_temp(1,1)=aggj(l,1)
5048 a_temp(1,2)=aggj(l,2)
5049 a_temp(2,1)=aggj(l,3)
5050 a_temp(2,2)=aggj(l,4)
5051 call matmat2(e1t(1,1),a_temp(1,1),e1a(1,1))
5052 call matvec2(e1a(1,1),Ub2(1,i+3),auxvec(1))
5053 s1=scalar2(b1(1,i+2),auxvec(1))
5054 call matmat2(a_temp(1,1),e3t(1,1),ae3(1,1))
5055 call matvec2(ae3(1,1),Ub2(1,i+2),auxvec(1))
5056 s2=scalar2(b1(1,i+1),auxvec(1))
5057 call matmat2(ae3(1,1),e2t(1,1),ae3e2(1,1))
5058 call matmat2(ae3e2(1,1),e1t(1,1),pizda(1,1))
5059 s3=0.5d0*(pizda(1,1)+pizda(2,2))
5060 gcorr4_turn(l,j)=gcorr4_turn(l,j)-(s1+s2+s3)
5061 & *fac_shield(i)*fac_shield(j)
5062 a_temp(1,1)=aggj1(l,1)
5063 a_temp(1,2)=aggj1(l,2)
5064 a_temp(2,1)=aggj1(l,3)
5065 a_temp(2,2)=aggj1(l,4)
5066 call matmat2(e1t(1,1),a_temp(1,1),e1a(1,1))
5067 call matvec2(e1a(1,1),Ub2(1,i+3),auxvec(1))
5068 s1=scalar2(b1(1,i+2),auxvec(1))
5069 call matmat2(a_temp(1,1),e3t(1,1),ae3(1,1))
5070 call matvec2(ae3(1,1),Ub2(1,i+2),auxvec(1))
5071 s2=scalar2(b1(1,i+1),auxvec(1))
5072 call matmat2(ae3(1,1),e2t(1,1),ae3e2(1,1))
5073 call matmat2(ae3e2(1,1),e1t(1,1),pizda(1,1))
5074 s3=0.5d0*(pizda(1,1)+pizda(2,2))
5075 c write (iout,*) "s1",s1," s2",s2," s3",s3," s1+s2+s3",s1+s2+s3
5076 gcorr4_turn(l,j1)=gcorr4_turn(l,j1)-(s1+s2+s3)
5077 & *fac_shield(i)*fac_shield(j)
5081 C-----------------------------------------------------------------------------
5082 subroutine vecpr(u,v,w)
5083 implicit real*8(a-h,o-z)
5084 dimension u(3),v(3),w(3)
5085 w(1)=u(2)*v(3)-u(3)*v(2)
5086 w(2)=-u(1)*v(3)+u(3)*v(1)
5087 w(3)=u(1)*v(2)-u(2)*v(1)
5090 C-----------------------------------------------------------------------------
5091 subroutine unormderiv(u,ugrad,unorm,ungrad)
5092 C This subroutine computes the derivatives of a normalized vector u, given
5093 C the derivatives computed without normalization conditions, ugrad. Returns
5096 double precision u(3),ugrad(3,3),unorm,ungrad(3,3)
5097 double precision vec(3)
5098 double precision scalar
5100 c write (2,*) 'ugrad',ugrad
5103 vec(i)=scalar(ugrad(1,i),u(1))
5105 c write (2,*) 'vec',vec
5108 ungrad(j,i)=(ugrad(j,i)-u(j)*vec(i))*unorm
5111 c write (2,*) 'ungrad',ungrad
5114 C-----------------------------------------------------------------------------
5115 subroutine escp_soft_sphere(evdw2,evdw2_14)
5117 C This subroutine calculates the excluded-volume interaction energy between
5118 C peptide-group centers and side chains and its gradient in virtual-bond and
5119 C side-chain vectors.
5121 implicit real*8 (a-h,o-z)
5122 include 'DIMENSIONS'
5123 include 'COMMON.GEO'
5124 include 'COMMON.VAR'
5125 include 'COMMON.LOCAL'
5126 include 'COMMON.CHAIN'
5127 include 'COMMON.DERIV'
5128 include 'COMMON.INTERACT'
5129 include 'COMMON.FFIELD'
5130 include 'COMMON.IOUNITS'
5131 include 'COMMON.CONTROL'
5136 cd print '(a)','Enter ESCP'
5137 cd write (iout,*) 'iatscp_s=',iatscp_s,' iatscp_e=',iatscp_e
5141 do i=iatscp_s,iatscp_e
5142 if (itype(i).eq.ntyp1 .or. itype(i+1).eq.ntyp1) cycle
5144 xi=0.5D0*(c(1,i)+c(1,i+1))
5145 yi=0.5D0*(c(2,i)+c(2,i+1))
5146 zi=0.5D0*(c(3,i)+c(3,i+1))
5147 C Return atom into box, boxxsize is size of box in x dimension
5149 c if (xi.gt.((xshift+0.5d0)*boxxsize)) xi=xi-boxxsize
5150 c if (xi.lt.((xshift-0.5d0)*boxxsize)) xi=xi+boxxsize
5151 C Condition for being inside the proper box
5152 c if ((xi.gt.((xshift+0.5d0)*boxxsize)).or.
5153 c & (xi.lt.((xshift-0.5d0)*boxxsize))) then
5157 c if (yi.gt.((yshift+0.5d0)*boxysize)) yi=yi-boxysize
5158 c if (yi.lt.((yshift-0.5d0)*boxysize)) yi=yi+boxysize
5159 C Condition for being inside the proper box
5160 c if ((yi.gt.((yshift+0.5d0)*boxysize)).or.
5161 c & (yi.lt.((yshift-0.5d0)*boxysize))) then
5165 c if (zi.gt.((zshift+0.5d0)*boxzsize)) zi=zi-boxzsize
5166 c if (zi.lt.((zshift-0.5d0)*boxzsize)) zi=zi+boxzsize
5167 cC Condition for being inside the proper box
5168 c if ((zi.gt.((zshift+0.5d0)*boxzsize)).or.
5169 c & (zi.lt.((zshift-0.5d0)*boxzsize))) then
5173 if (xi.lt.0) xi=xi+boxxsize
5175 if (yi.lt.0) yi=yi+boxysize
5177 if (zi.lt.0) zi=zi+boxzsize
5178 C xi=xi+xshift*boxxsize
5179 C yi=yi+yshift*boxysize
5180 C zi=zi+zshift*boxzsize
5181 do iint=1,nscp_gr(i)
5183 do j=iscpstart(i,iint),iscpend(i,iint)
5184 if (itype(j).eq.ntyp1) cycle
5185 itypj=iabs(itype(j))
5186 C Uncomment following three lines for SC-p interactions
5190 C Uncomment following three lines for Ca-p interactions
5195 c if (xj.gt.((0.5d0)*boxxsize)) xj=xj-boxxsize
5196 c if (xj.lt.((-0.5d0)*boxxsize)) xj=xj+boxxsize
5197 C Condition for being inside the proper box
5198 c if ((xj.gt.((0.5d0)*boxxsize)).or.
5199 c & (xj.lt.((-0.5d0)*boxxsize))) then
5203 c if (yj.gt.((0.5d0)*boxysize)) yj=yj-boxysize
5204 c if (yj.lt.((-0.5d0)*boxysize)) yj=yj+boxysize
5205 cC Condition for being inside the proper box
5206 c if ((yj.gt.((0.5d0)*boxysize)).or.
5207 c & (yj.lt.((-0.5d0)*boxysize))) then
5211 c if (zj.gt.((0.5d0)*boxzsize)) zj=zj-boxzsize
5212 c if (zj.lt.((-0.5d0)*boxzsize)) zj=zj+boxzsize
5213 C Condition for being inside the proper box
5214 c if ((zj.gt.((0.5d0)*boxzsize)).or.
5215 c & (zj.lt.((-0.5d0)*boxzsize))) then
5218 if (xj.lt.0) xj=xj+boxxsize
5220 if (yj.lt.0) yj=yj+boxysize
5222 if (zj.lt.0) zj=zj+boxzsize
5223 dist_init=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
5231 xj=xj_safe+xshift*boxxsize
5232 yj=yj_safe+yshift*boxysize
5233 zj=zj_safe+zshift*boxzsize
5234 dist_temp=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
5235 if(dist_temp.lt.dist_init) then
5245 if (subchap.eq.1) then
5258 rij=xj*xj+yj*yj+zj*zj
5262 if (rij.lt.r0ijsq) then
5263 evdwij=0.25d0*(rij-r0ijsq)**2
5271 C Calculate contributions to the gradient in the virtual-bond and SC vectors.
5276 cgrad if (j.lt.i) then
5277 cd write (iout,*) 'j<i'
5278 C Uncomment following three lines for SC-p interactions
5280 c gradx_scp(k,j)=gradx_scp(k,j)+ggg(k)
5283 cd write (iout,*) 'j>i'
5285 cgrad ggg(k)=-ggg(k)
5286 C Uncomment following line for SC-p interactions
5287 c gradx_scp(k,j)=gradx_scp(k,j)-ggg(k)
5291 cgrad gvdwc_scp(k,i)=gvdwc_scp(k,i)-0.5D0*ggg(k)
5293 cgrad kstart=min0(i+1,j)
5294 cgrad kend=max0(i-1,j-1)
5295 cd write (iout,*) 'i=',i,' j=',j,' kstart=',kstart,' kend=',kend
5296 cd write (iout,*) ggg(1),ggg(2),ggg(3)
5297 cgrad do k=kstart,kend
5299 cgrad gvdwc_scp(l,k)=gvdwc_scp(l,k)-ggg(l)
5303 gvdwc_scpp(k,i)=gvdwc_scpp(k,i)-ggg(k)
5304 gvdwc_scp(k,j)=gvdwc_scp(k,j)+ggg(k)
5315 C-----------------------------------------------------------------------------
5316 subroutine escp(evdw2,evdw2_14)
5318 C This subroutine calculates the excluded-volume interaction energy between
5319 C peptide-group centers and side chains and its gradient in virtual-bond and
5320 C side-chain vectors.
5322 implicit real*8 (a-h,o-z)
5323 include 'DIMENSIONS'
5324 include 'COMMON.GEO'
5325 include 'COMMON.VAR'
5326 include 'COMMON.LOCAL'
5327 include 'COMMON.CHAIN'
5328 include 'COMMON.DERIV'
5329 include 'COMMON.INTERACT'
5330 include 'COMMON.FFIELD'
5331 include 'COMMON.IOUNITS'
5332 include 'COMMON.CONTROL'
5333 include 'COMMON.SPLITELE'
5337 c print *,boxxsize,boxysize,boxzsize,'wymiary pudla'
5338 cd print '(a)','Enter ESCP'
5339 cd write (iout,*) 'iatscp_s=',iatscp_s,' iatscp_e=',iatscp_e
5343 do i=iatscp_s,iatscp_e
5344 if (itype(i).eq.ntyp1 .or. itype(i+1).eq.ntyp1) cycle
5346 xi=0.5D0*(c(1,i)+c(1,i+1))
5347 yi=0.5D0*(c(2,i)+c(2,i+1))
5348 zi=0.5D0*(c(3,i)+c(3,i+1))
5350 if (xi.lt.0) xi=xi+boxxsize
5352 if (yi.lt.0) yi=yi+boxysize
5354 if (zi.lt.0) zi=zi+boxzsize
5355 c xi=xi+xshift*boxxsize
5356 c yi=yi+yshift*boxysize
5357 c zi=zi+zshift*boxzsize
5358 c print *,xi,yi,zi,'polozenie i'
5359 C Return atom into box, boxxsize is size of box in x dimension
5361 c if (xi.gt.((xshift+0.5d0)*boxxsize)) xi=xi-boxxsize
5362 c if (xi.lt.((xshift-0.5d0)*boxxsize)) xi=xi+boxxsize
5363 C Condition for being inside the proper box
5364 c if ((xi.gt.((xshift+0.5d0)*boxxsize)).or.
5365 c & (xi.lt.((xshift-0.5d0)*boxxsize))) then
5369 c print *,xi,boxxsize,"pierwszy"
5371 c if (yi.gt.((yshift+0.5d0)*boxysize)) yi=yi-boxysize
5372 c if (yi.lt.((yshift-0.5d0)*boxysize)) yi=yi+boxysize
5373 C Condition for being inside the proper box
5374 c if ((yi.gt.((yshift+0.5d0)*boxysize)).or.
5375 c & (yi.lt.((yshift-0.5d0)*boxysize))) then
5379 c if (zi.gt.((zshift+0.5d0)*boxzsize)) zi=zi-boxzsize
5380 c if (zi.lt.((zshift-0.5d0)*boxzsize)) zi=zi+boxzsize
5381 C Condition for being inside the proper box
5382 c if ((zi.gt.((zshift+0.5d0)*boxzsize)).or.
5383 c & (zi.lt.((zshift-0.5d0)*boxzsize))) then
5386 do iint=1,nscp_gr(i)
5388 do j=iscpstart(i,iint),iscpend(i,iint)
5389 itypj=iabs(itype(j))
5390 if (itypj.eq.ntyp1) cycle
5391 C Uncomment following three lines for SC-p interactions
5395 C Uncomment following three lines for Ca-p interactions
5400 if (xj.lt.0) xj=xj+boxxsize
5402 if (yj.lt.0) yj=yj+boxysize
5404 if (zj.lt.0) zj=zj+boxzsize
5406 c if (xj.gt.((0.5d0)*boxxsize)) xj=xj-boxxsize
5407 c if (xj.lt.((-0.5d0)*boxxsize)) xj=xj+boxxsize
5408 C Condition for being inside the proper box
5409 c if ((xj.gt.((0.5d0)*boxxsize)).or.
5410 c & (xj.lt.((-0.5d0)*boxxsize))) then
5414 c if (yj.gt.((0.5d0)*boxysize)) yj=yj-boxysize
5415 c if (yj.lt.((-0.5d0)*boxysize)) yj=yj+boxysize
5416 cC Condition for being inside the proper box
5417 c if ((yj.gt.((0.5d0)*boxysize)).or.
5418 c & (yj.lt.((-0.5d0)*boxysize))) then
5422 c if (zj.gt.((0.5d0)*boxzsize)) zj=zj-boxzsize
5423 c if (zj.lt.((-0.5d0)*boxzsize)) zj=zj+boxzsize
5424 C Condition for being inside the proper box
5425 c if ((zj.gt.((0.5d0)*boxzsize)).or.
5426 c & (zj.lt.((-0.5d0)*boxzsize))) then
5429 CHERE IS THE CALCULATION WHICH MIRROR IMAGE IS THE CLOSEST ONE
5430 dist_init=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
5438 xj=xj_safe+xshift*boxxsize
5439 yj=yj_safe+yshift*boxysize
5440 zj=zj_safe+zshift*boxzsize
5441 dist_temp=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
5442 if(dist_temp.lt.dist_init) then
5452 if (subchap.eq.1) then
5461 c print *,xj,yj,zj,'polozenie j'
5462 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
5464 sss=sscale(1.0d0/(dsqrt(rrij)))
5465 c print *,r_cut,1.0d0/dsqrt(rrij),sss,'tu patrz'
5466 c if (sss.eq.0) print *,'czasem jest OK'
5467 if (sss.le.0.0d0) cycle
5468 sssgrad=sscagrad(1.0d0/(dsqrt(rrij)))
5470 e1=fac*fac*aad(itypj,iteli)
5471 e2=fac*bad(itypj,iteli)
5472 if (iabs(j-i) .le. 2) then
5475 evdw2_14=evdw2_14+(e1+e2)*sss
5478 evdw2=evdw2+evdwij*sss
5479 if (energy_dec) write (iout,'(a6,2i5,0pf7.3,2i3,3e11.3)')
5480 & 'evdw2',i,j,evdwij,iteli,itypj,fac,aad(itypj,iteli),
5483 C Calculate contributions to the gradient in the virtual-bond and SC vectors.
5485 fac=-(evdwij+e1)*rrij*sss
5486 fac=fac+(evdwij)*sssgrad*dsqrt(rrij)/expon
5490 cgrad if (j.lt.i) then
5491 cd write (iout,*) 'j<i'
5492 C Uncomment following three lines for SC-p interactions
5494 c gradx_scp(k,j)=gradx_scp(k,j)+ggg(k)
5497 cd write (iout,*) 'j>i'
5499 cgrad ggg(k)=-ggg(k)
5500 C Uncomment following line for SC-p interactions
5501 ccgrad gradx_scp(k,j)=gradx_scp(k,j)-ggg(k)
5502 c gradx_scp(k,j)=gradx_scp(k,j)+ggg(k)
5506 cgrad gvdwc_scp(k,i)=gvdwc_scp(k,i)-0.5D0*ggg(k)
5508 cgrad kstart=min0(i+1,j)
5509 cgrad kend=max0(i-1,j-1)
5510 cd write (iout,*) 'i=',i,' j=',j,' kstart=',kstart,' kend=',kend
5511 cd write (iout,*) ggg(1),ggg(2),ggg(3)
5512 cgrad do k=kstart,kend
5514 cgrad gvdwc_scp(l,k)=gvdwc_scp(l,k)-ggg(l)
5518 gvdwc_scpp(k,i)=gvdwc_scpp(k,i)-ggg(k)
5519 gvdwc_scp(k,j)=gvdwc_scp(k,j)+ggg(k)
5521 c endif !endif for sscale cutoff
5531 gvdwc_scp(j,i)=expon*gvdwc_scp(j,i)
5532 gvdwc_scpp(j,i)=expon*gvdwc_scpp(j,i)
5533 gradx_scp(j,i)=expon*gradx_scp(j,i)
5536 C******************************************************************************
5540 C To save time the factor EXPON has been extracted from ALL components
5541 C of GVDWC and GRADX. Remember to multiply them by this factor before further
5544 C******************************************************************************
5547 C--------------------------------------------------------------------------
5548 subroutine edis(ehpb)
5550 C Evaluate bridge-strain energy and its gradient in virtual-bond and SC vectors.
5552 implicit real*8 (a-h,o-z)
5553 include 'DIMENSIONS'
5554 include 'COMMON.SBRIDGE'
5555 include 'COMMON.CHAIN'
5556 include 'COMMON.DERIV'
5557 include 'COMMON.VAR'
5558 include 'COMMON.INTERACT'
5559 include 'COMMON.IOUNITS'
5560 include 'COMMON.CONTROL'
5566 C write (iout,*) ,"link_end",link_end,constr_dist
5567 cd write(iout,*)'edis: nhpb=',nhpb,' fbr=',fbr
5568 cd write(iout,*)'link_start=',link_start,' link_end=',link_end
5569 if (link_end.eq.0) return
5570 do i=link_start,link_end
5571 C If ihpb(i) and jhpb(i) > NRES, this is a SC-SC distance, otherwise a
5572 C CA-CA distance used in regularization of structure.
5575 C iii and jjj point to the residues for which the distance is assigned.
5576 if (ii.gt.nres) then
5583 c write (iout,*) "i",i," ii",ii," iii",iii," jj",jj," jjj",jjj,
5584 c & dhpb(i),dhpb1(i),forcon(i)
5585 C 24/11/03 AL: SS bridges handled separately because of introducing a specific
5586 C distance and angle dependent SS bond potential.
5587 C if (ii.gt.nres .and. iabs(itype(iii)).eq.1 .and.
5588 C & iabs(itype(jjj)).eq.1) then
5589 cmc if (ii.gt.nres .and. itype(iii).eq.1 .and. itype(jjj).eq.1) then
5590 C 18/07/06 MC: Use the convention that the first nss pairs are SS bonds
5591 if (.not.dyn_ss .and. i.le.nss) then
5592 C 15/02/13 CC dynamic SSbond - additional check
5593 if (ii.gt.nres .and. iabs(itype(iii)).eq.1 .and.
5594 & iabs(itype(jjj)).eq.1) then
5595 call ssbond_ene(iii,jjj,eij)
5598 cd write (iout,*) "eij",eij
5599 cd & ' waga=',waga,' fac=',fac
5600 else if (ii.gt.nres .and. jj.gt.nres) then
5601 c Restraints from contact prediction
5603 if (constr_dist.eq.11) then
5604 ehpb=ehpb+fordepth(i)**4.0d0
5605 & *rlornmr1(dd,dhpb(i),dhpb1(i),forcon(i))
5606 fac=fordepth(i)**4.0d0
5607 & *rlornmr1prim(dd,dhpb(i),dhpb1(i),forcon(i))/dd
5608 if (energy_dec) write (iout,'(a6,2i5,3f8.3)') "edisl",ii,jj,
5609 & ehpb,fordepth(i),dd
5611 if (dhpb1(i).gt.0.0d0) then
5612 ehpb=ehpb+2*forcon(i)*gnmr1(dd,dhpb(i),dhpb1(i))
5613 fac=forcon(i)*gnmr1prim(dd,dhpb(i),dhpb1(i))/dd
5614 c write (iout,*) "beta nmr",
5615 c & dd,2*forcon(i)*gnmr1(dd,dhpb(i),dhpb1(i))
5619 C Get the force constant corresponding to this distance.
5621 C Calculate the contribution to energy.
5622 ehpb=ehpb+waga*rdis*rdis
5623 c write (iout,*) "beta reg",dd,waga*rdis*rdis
5625 C Evaluate gradient.
5631 ggg(j)=fac*(c(j,jj)-c(j,ii))
5634 ghpbx(j,iii)=ghpbx(j,iii)-ggg(j)
5635 ghpbx(j,jjj)=ghpbx(j,jjj)+ggg(j)
5638 ghpbc(k,jjj)=ghpbc(k,jjj)+ggg(k)
5639 ghpbc(k,iii)=ghpbc(k,iii)-ggg(k)
5642 C Calculate the distance between the two points and its difference from the
5645 if (constr_dist.eq.11) then
5646 ehpb=ehpb+fordepth(i)**4.0d0
5647 & *rlornmr1(dd,dhpb(i),dhpb1(i),forcon(i))
5648 fac=fordepth(i)**4.0d0
5649 & *rlornmr1prim(dd,dhpb(i),dhpb1(i),forcon(i))/dd
5650 if (energy_dec) write (iout,'(a6,2i5,3f8.3)') "edisl",ii,jj,
5651 & ehpb,fordepth(i),dd
5653 if (dhpb1(i).gt.0.0d0) then
5654 ehpb=ehpb+2*forcon(i)*gnmr1(dd,dhpb(i),dhpb1(i))
5655 fac=forcon(i)*gnmr1prim(dd,dhpb(i),dhpb1(i))/dd
5656 c write (iout,*) "alph nmr",
5657 c & dd,2*forcon(i)*gnmr1(dd,dhpb(i),dhpb1(i))
5660 C Get the force constant corresponding to this distance.
5662 C Calculate the contribution to energy.
5663 ehpb=ehpb+waga*rdis*rdis
5664 c write (iout,*) "alpha reg",dd,waga*rdis*rdis
5666 C Evaluate gradient.
5672 ggg(j)=fac*(c(j,jj)-c(j,ii))
5674 cd print '(i3,3(1pe14.5))',i,(ggg(j),j=1,3)
5675 C If this is a SC-SC distance, we need to calculate the contributions to the
5676 C Cartesian gradient in the SC vectors (ghpbx).
5679 ghpbx(j,iii)=ghpbx(j,iii)-ggg(j)
5680 ghpbx(j,jjj)=ghpbx(j,jjj)+ggg(j)
5683 cgrad do j=iii,jjj-1
5685 cgrad ghpbc(k,j)=ghpbc(k,j)+ggg(k)
5689 ghpbc(k,jjj)=ghpbc(k,jjj)+ggg(k)
5690 ghpbc(k,iii)=ghpbc(k,iii)-ggg(k)
5694 if (constr_dist.ne.11) ehpb=0.5D0*ehpb
5697 C--------------------------------------------------------------------------
5698 subroutine ssbond_ene(i,j,eij)
5700 C Calculate the distance and angle dependent SS-bond potential energy
5701 C using a free-energy function derived based on RHF/6-31G** ab initio
5702 C calculations of diethyl disulfide.
5704 C A. Liwo and U. Kozlowska, 11/24/03
5706 implicit real*8 (a-h,o-z)
5707 include 'DIMENSIONS'
5708 include 'COMMON.SBRIDGE'
5709 include 'COMMON.CHAIN'
5710 include 'COMMON.DERIV'
5711 include 'COMMON.LOCAL'
5712 include 'COMMON.INTERACT'
5713 include 'COMMON.VAR'
5714 include 'COMMON.IOUNITS'
5715 double precision erij(3),dcosom1(3),dcosom2(3),gg(3)
5716 itypi=iabs(itype(i))
5720 dxi=dc_norm(1,nres+i)
5721 dyi=dc_norm(2,nres+i)
5722 dzi=dc_norm(3,nres+i)
5723 c dsci_inv=dsc_inv(itypi)
5724 dsci_inv=vbld_inv(nres+i)
5725 itypj=iabs(itype(j))
5726 c dscj_inv=dsc_inv(itypj)
5727 dscj_inv=vbld_inv(nres+j)
5731 dxj=dc_norm(1,nres+j)
5732 dyj=dc_norm(2,nres+j)
5733 dzj=dc_norm(3,nres+j)
5734 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
5739 om1=dxi*erij(1)+dyi*erij(2)+dzi*erij(3)
5740 om2=dxj*erij(1)+dyj*erij(2)+dzj*erij(3)
5741 om12=dxi*dxj+dyi*dyj+dzi*dzj
5743 dcosom1(k)=rij*(dc_norm(k,nres+i)-om1*erij(k))
5744 dcosom2(k)=rij*(dc_norm(k,nres+j)-om2*erij(k))
5750 deltat12=om2-om1+2.0d0
5752 eij=akcm*deltad*deltad+akth*(deltat1*deltat1+deltat2*deltat2)
5753 & +akct*deltad*deltat12
5754 & +v1ss*cosphi+v2ss*cosphi*cosphi+v3ss*cosphi*cosphi*cosphi+ebr
5755 c write(iout,*) i,j,"rij",rij,"d0cm",d0cm," akcm",akcm," akth",akth,
5756 c & " akct",akct," deltad",deltad," deltat",deltat1,deltat2,
5757 c & " deltat12",deltat12," eij",eij
5758 ed=2*akcm*deltad+akct*deltat12
5760 pom2=v1ss+2*v2ss*cosphi+3*v3ss*cosphi*cosphi
5761 eom1=-2*akth*deltat1-pom1-om2*pom2
5762 eom2= 2*akth*deltat2+pom1-om1*pom2
5765 ggk=ed*erij(k)+eom1*dcosom1(k)+eom2*dcosom2(k)
5766 ghpbx(k,i)=ghpbx(k,i)-ggk
5767 & +(eom12*(dc_norm(k,nres+j)-om12*dc_norm(k,nres+i))
5768 & +eom1*(erij(k)-om1*dc_norm(k,nres+i)))*dsci_inv
5769 ghpbx(k,j)=ghpbx(k,j)+ggk
5770 & +(eom12*(dc_norm(k,nres+i)-om12*dc_norm(k,nres+j))
5771 & +eom2*(erij(k)-om2*dc_norm(k,nres+j)))*dscj_inv
5772 ghpbc(k,i)=ghpbc(k,i)-ggk
5773 ghpbc(k,j)=ghpbc(k,j)+ggk
5776 C Calculate the components of the gradient in DC and X
5780 cgrad ghpbc(l,k)=ghpbc(l,k)+gg(l)
5785 C--------------------------------------------------------------------------
5786 subroutine ebond(estr)
5788 c Evaluate the energy of stretching of the CA-CA and CA-SC virtual bonds
5790 implicit real*8 (a-h,o-z)
5791 include 'DIMENSIONS'
5792 include 'COMMON.LOCAL'
5793 include 'COMMON.GEO'
5794 include 'COMMON.INTERACT'
5795 include 'COMMON.DERIV'
5796 include 'COMMON.VAR'
5797 include 'COMMON.CHAIN'
5798 include 'COMMON.IOUNITS'
5799 include 'COMMON.NAMES'
5800 include 'COMMON.FFIELD'
5801 include 'COMMON.CONTROL'
5802 include 'COMMON.SETUP'
5803 double precision u(3),ud(3)
5806 do i=ibondp_start,ibondp_end
5807 if (itype(i-1).eq.ntyp1 .and. itype(i).eq.ntyp1) cycle
5808 c estr1=estr1+gnmr1(vbld(i),-1.0d0,distchainmax)
5810 c gradb(j,i-1)=gnmr1prim(vbld(i),-1.0d0,distchainmax)
5811 c & *dc(j,i-1)/vbld(i)
5813 c if (energy_dec) write(iout,*)
5814 c & "estr1",i,gnmr1(vbld(i),-1.0d0,distchainmax)
5816 C Checking if it involves dummy (NH3+ or COO-) group
5817 if (itype(i-1).eq.ntyp1 .or. itype(i).eq.ntyp1) then
5818 C YES vbldpDUM is the equlibrium length of spring for Dummy atom
5819 diff = vbld(i)-vbldpDUM
5821 C NO vbldp0 is the equlibrium lenght of spring for peptide group
5822 diff = vbld(i)-vbldp0
5824 if (energy_dec) write (iout,'(a7,i5,4f7.3)')
5825 & "estr bb",i,vbld(i),vbldp0,diff,AKP*diff*diff
5828 gradb(j,i-1)=AKP*diff*dc(j,i-1)/vbld(i)
5830 c write (iout,'(i5,3f10.5)') i,(gradb(j,i-1),j=1,3)
5833 estr=0.5d0*AKP*estr+estr1
5835 c 09/18/07 AL: multimodal bond potential based on AM1 CA-SC PMF's included
5837 do i=ibond_start,ibond_end
5839 if (iti.ne.10 .and. iti.ne.ntyp1) then
5842 diff=vbld(i+nres)-vbldsc0(1,iti)
5843 if (energy_dec) write (iout,*)
5844 & "estr sc",i,iti,vbld(i+nres),vbldsc0(1,iti),diff,
5845 & AKSC(1,iti),AKSC(1,iti)*diff*diff
5846 estr=estr+0.5d0*AKSC(1,iti)*diff*diff
5848 gradbx(j,i)=AKSC(1,iti)*diff*dc(j,i+nres)/vbld(i+nres)
5852 diff=vbld(i+nres)-vbldsc0(j,iti)
5853 ud(j)=aksc(j,iti)*diff
5854 u(j)=abond0(j,iti)+0.5d0*ud(j)*diff
5868 uprod2=uprod2*u(k)*u(k)
5872 usumsqder=usumsqder+ud(j)*uprod2
5874 estr=estr+uprod/usum
5876 gradbx(j,i)=usumsqder/(usum*usum)*dc(j,i+nres)/vbld(i+nres)
5884 C--------------------------------------------------------------------------
5885 subroutine ebend(etheta,ethetacnstr)
5887 C Evaluate the virtual-bond-angle energy given the virtual-bond dihedral
5888 C angles gamma and its derivatives in consecutive thetas and gammas.
5890 implicit real*8 (a-h,o-z)
5891 include 'DIMENSIONS'
5892 include 'COMMON.LOCAL'
5893 include 'COMMON.GEO'
5894 include 'COMMON.INTERACT'
5895 include 'COMMON.DERIV'
5896 include 'COMMON.VAR'
5897 include 'COMMON.CHAIN'
5898 include 'COMMON.IOUNITS'
5899 include 'COMMON.NAMES'
5900 include 'COMMON.FFIELD'
5901 include 'COMMON.CONTROL'
5902 include 'COMMON.TORCNSTR'
5903 common /calcthet/ term1,term2,termm,diffak,ratak,
5904 & ak,aktc,termpre,termexp,sigc,sig0i,time11,time12,sigcsq,
5905 & delthe0,sig0inv,sigtc,sigsqtc,delthec,it
5906 double precision y(2),z(2)
5908 c time11=dexp(-2*time)
5911 c write (*,'(a,i2)') 'EBEND ICG=',icg
5912 do i=ithet_start,ithet_end
5913 if ((itype(i-1).eq.ntyp1).or.itype(i-2).eq.ntyp1
5914 & .or.itype(i).eq.ntyp1) cycle
5915 C Zero the energy function and its derivative at 0 or pi.
5916 call splinthet(theta(i),0.5d0*delta,ss,ssd)
5918 ichir1=isign(1,itype(i-2))
5919 ichir2=isign(1,itype(i))
5920 if (itype(i-2).eq.10) ichir1=isign(1,itype(i-1))
5921 if (itype(i).eq.10) ichir2=isign(1,itype(i-1))
5922 if (itype(i-1).eq.10) then
5923 itype1=isign(10,itype(i-2))
5924 ichir11=isign(1,itype(i-2))
5925 ichir12=isign(1,itype(i-2))
5926 itype2=isign(10,itype(i))
5927 ichir21=isign(1,itype(i))
5928 ichir22=isign(1,itype(i))
5931 if (i.gt.3 .and. itype(i-3).ne.ntyp1) then
5934 if (phii.ne.phii) phii=150.0
5944 if (i.lt.nres .and. itype(i+1).ne.ntyp1) then
5947 if (phii1.ne.phii1) phii1=150.0
5959 C Calculate the "mean" value of theta from the part of the distribution
5960 C dependent on the adjacent virtual-bond-valence angles (gamma1 & gamma2).
5961 C In following comments this theta will be referred to as t_c.
5962 thet_pred_mean=0.0d0
5964 athetk=athet(k,it,ichir1,ichir2)
5965 bthetk=bthet(k,it,ichir1,ichir2)
5967 athetk=athet(k,itype1,ichir11,ichir12)
5968 bthetk=bthet(k,itype2,ichir21,ichir22)
5970 thet_pred_mean=thet_pred_mean+athetk*y(k)+bthetk*z(k)
5971 c write(iout,*) 'chuj tu', y(k),z(k)
5973 dthett=thet_pred_mean*ssd
5974 thet_pred_mean=thet_pred_mean*ss+a0thet(it)
5975 C Derivatives of the "mean" values in gamma1 and gamma2.
5976 dthetg1=(-athet(1,it,ichir1,ichir2)*y(2)
5977 &+athet(2,it,ichir1,ichir2)*y(1))*ss
5978 dthetg2=(-bthet(1,it,ichir1,ichir2)*z(2)
5979 & +bthet(2,it,ichir1,ichir2)*z(1))*ss
5981 dthetg1=(-athet(1,itype1,ichir11,ichir12)*y(2)
5982 &+athet(2,itype1,ichir11,ichir12)*y(1))*ss
5983 dthetg2=(-bthet(1,itype2,ichir21,ichir22)*z(2)
5984 & +bthet(2,itype2,ichir21,ichir22)*z(1))*ss
5986 if (theta(i).gt.pi-delta) then
5987 call theteng(pi-delta,thet_pred_mean,theta0(it),f0,fprim0,
5989 call mixder(pi-delta,thet_pred_mean,theta0(it),fprim_tc0)
5990 call theteng(pi,thet_pred_mean,theta0(it),f1,fprim1,E_tc1)
5991 call spline1(theta(i),pi-delta,delta,f0,f1,fprim0,ethetai,
5993 call spline2(theta(i),pi-delta,delta,E_tc0,E_tc1,fprim_tc0,
5995 else if (theta(i).lt.delta) then
5996 call theteng(delta,thet_pred_mean,theta0(it),f0,fprim0,E_tc0)
5997 call theteng(0.0d0,thet_pred_mean,theta0(it),f1,fprim1,E_tc1)
5998 call spline1(theta(i),delta,-delta,f0,f1,fprim0,ethetai,
6000 call mixder(delta,thet_pred_mean,theta0(it),fprim_tc0)
6001 call spline2(theta(i),delta,-delta,E_tc0,E_tc1,fprim_tc0,
6004 call theteng(theta(i),thet_pred_mean,theta0(it),ethetai,
6007 etheta=etheta+ethetai
6008 if (energy_dec) write (iout,'(a6,i5,0pf7.3,f7.3,i5)')
6009 & 'ebend',i,ethetai,theta(i),itype(i)
6010 if (i.gt.3) gloc(i-3,icg)=gloc(i-3,icg)+wang*E_tc*dthetg1
6011 if (i.lt.nres) gloc(i-2,icg)=gloc(i-2,icg)+wang*E_tc*dthetg2
6012 gloc(nphi+i-2,icg)=wang*(E_theta+E_tc*dthett)+gloc(nphi+i-2,icg)
6015 C print *,ithetaconstr_start,ithetaconstr_end,"TU"
6016 do i=ithetaconstr_start,ithetaconstr_end
6017 itheta=itheta_constr(i)
6018 thetiii=theta(itheta)
6019 difi=pinorm(thetiii-theta_constr0(i))
6020 if (difi.gt.theta_drange(i)) then
6021 difi=difi-theta_drange(i)
6022 ethetacnstr=ethetcnstr+0.25d0*for_thet_constr(i)*difi**4
6023 gloc(itheta+nphi-2,icg)=gloc(itheta+nphi-2,icg)
6024 & +for_thet_constr(i)*difi**3
6025 else if (difi.lt.-drange(i)) then
6027 ethetacnstr=ethetcnstr+0.25d0*for_thet_constr(i)*difi**4
6028 gloc(itheta+nphi-2,icg)=gloc(itheta+nphi-2,icg)
6029 & +for_thet_constr(i)*difi**3
6033 if (energy_dec) then
6034 write (iout,'(a6,2i5,4f8.3,2e14.5)') "ethetc",
6035 & i,itheta,rad2deg*thetiii,
6036 & rad2deg*theta_constr0(i), rad2deg*theta_drange(i),
6037 & rad2deg*difi,0.25d0*for_thet_constr(i)*difi**4,
6038 & gloc(itheta+nphi-2,icg)
6042 C Ufff.... We've done all this!!!
6045 C---------------------------------------------------------------------------
6046 subroutine theteng(thetai,thet_pred_mean,theta0i,ethetai,E_theta,
6048 implicit real*8 (a-h,o-z)
6049 include 'DIMENSIONS'
6050 include 'COMMON.LOCAL'
6051 include 'COMMON.IOUNITS'
6052 common /calcthet/ term1,term2,termm,diffak,ratak,
6053 & ak,aktc,termpre,termexp,sigc,sig0i,time11,time12,sigcsq,
6054 & delthe0,sig0inv,sigtc,sigsqtc,delthec,it
6055 C Calculate the contributions to both Gaussian lobes.
6056 C 6/6/97 - Deform the Gaussians using the factor of 1/(1+time)
6057 C The "polynomial part" of the "standard deviation" of this part of
6058 C the distributioni.
6059 ccc write (iout,*) thetai,thet_pred_mean
6062 sig=sig*thet_pred_mean+polthet(j,it)
6064 C Derivative of the "interior part" of the "standard deviation of the"
6065 C gamma-dependent Gaussian lobe in t_c.
6066 sigtc=3*polthet(3,it)
6068 sigtc=sigtc*thet_pred_mean+j*polthet(j,it)
6071 C Set the parameters of both Gaussian lobes of the distribution.
6072 C "Standard deviation" of the gamma-dependent Gaussian lobe (sigtc)
6073 fac=sig*sig+sigc0(it)
6076 C Following variable (sigsqtc) is -(1/2)d[sigma(t_c)**(-2))]/dt_c
6077 sigsqtc=-4.0D0*sigcsq*sigtc
6078 c print *,i,sig,sigtc,sigsqtc
6079 C Following variable (sigtc) is d[sigma(t_c)]/dt_c
6080 sigtc=-sigtc/(fac*fac)
6081 C Following variable is sigma(t_c)**(-2)
6082 sigcsq=sigcsq*sigcsq
6084 sig0inv=1.0D0/sig0i**2
6085 delthec=thetai-thet_pred_mean
6086 delthe0=thetai-theta0i
6087 term1=-0.5D0*sigcsq*delthec*delthec
6088 term2=-0.5D0*sig0inv*delthe0*delthe0
6089 C write (iout,*)'term1',term1,term2,sigcsq,delthec,sig0inv,delthe0
6090 C Following fuzzy logic is to avoid underflows in dexp and subsequent INFs and
6091 C NaNs in taking the logarithm. We extract the largest exponent which is added
6092 C to the energy (this being the log of the distribution) at the end of energy
6093 C term evaluation for this virtual-bond angle.
6094 if (term1.gt.term2) then
6096 term2=dexp(term2-termm)
6100 term1=dexp(term1-termm)
6103 C The ratio between the gamma-independent and gamma-dependent lobes of
6104 C the distribution is a Gaussian function of thet_pred_mean too.
6105 diffak=gthet(2,it)-thet_pred_mean
6106 ratak=diffak/gthet(3,it)**2
6107 ak=dexp(gthet(1,it)-0.5D0*diffak*ratak)
6108 C Let's differentiate it in thet_pred_mean NOW.
6110 C Now put together the distribution terms to make complete distribution.
6111 termexp=term1+ak*term2
6112 termpre=sigc+ak*sig0i
6113 C Contribution of the bending energy from this theta is just the -log of
6114 C the sum of the contributions from the two lobes and the pre-exponential
6115 C factor. Simple enough, isn't it?
6116 ethetai=(-dlog(termexp)-termm+dlog(termpre))
6117 C write (iout,*) 'termexp',termexp,termm,termpre,i
6118 C NOW the derivatives!!!
6119 C 6/6/97 Take into account the deformation.
6120 E_theta=(delthec*sigcsq*term1
6121 & +ak*delthe0*sig0inv*term2)/termexp
6122 E_tc=((sigtc+aktc*sig0i)/termpre
6123 & -((delthec*sigcsq+delthec*delthec*sigsqtc)*term1+
6124 & aktc*term2)/termexp)
6127 c-----------------------------------------------------------------------------
6128 subroutine mixder(thetai,thet_pred_mean,theta0i,E_tc_t)
6129 implicit real*8 (a-h,o-z)
6130 include 'DIMENSIONS'
6131 include 'COMMON.LOCAL'
6132 include 'COMMON.IOUNITS'
6133 common /calcthet/ term1,term2,termm,diffak,ratak,
6134 & ak,aktc,termpre,termexp,sigc,sig0i,time11,time12,sigcsq,
6135 & delthe0,sig0inv,sigtc,sigsqtc,delthec,it
6136 delthec=thetai-thet_pred_mean
6137 delthe0=thetai-theta0i
6138 C "Thank you" to MAPLE (probably spared one day of hand-differentiation).
6139 t3 = thetai-thet_pred_mean
6143 t14 = t12+t6*sigsqtc
6145 t21 = thetai-theta0i
6151 E_tc_t = -((sigcsq+2.D0*t3*sigsqtc)*t9-t14*sigcsq*t3*t16*t9
6152 & -aktc*sig0inv*t27)/t32+(t14*t9+aktc*t26)/t40
6153 & *(-t12*t9-ak*sig0inv*t27)
6157 C--------------------------------------------------------------------------
6158 subroutine ebend(etheta,ethetacnstr)
6160 C Evaluate the virtual-bond-angle energy given the virtual-bond dihedral
6161 C angles gamma and its derivatives in consecutive thetas and gammas.
6162 C ab initio-derived potentials from
6163 c Kozlowska et al., J. Phys.: Condens. Matter 19 (2007) 285203
6165 implicit real*8 (a-h,o-z)
6166 include 'DIMENSIONS'
6167 include 'COMMON.LOCAL'
6168 include 'COMMON.GEO'
6169 include 'COMMON.INTERACT'
6170 include 'COMMON.DERIV'
6171 include 'COMMON.VAR'
6172 include 'COMMON.CHAIN'
6173 include 'COMMON.IOUNITS'
6174 include 'COMMON.NAMES'
6175 include 'COMMON.FFIELD'
6176 include 'COMMON.CONTROL'
6177 include 'COMMON.TORCNSTR'
6178 double precision coskt(mmaxtheterm),sinkt(mmaxtheterm),
6179 & cosph1(maxsingle),sinph1(maxsingle),cosph2(maxsingle),
6180 & sinph2(maxsingle),cosph1ph2(maxdouble,maxdouble),
6181 & sinph1ph2(maxdouble,maxdouble)
6182 logical lprn /.false./, lprn1 /.false./
6184 do i=ithet_start,ithet_end
6185 c print *,i,itype(i-1),itype(i),itype(i-2)
6186 if ((itype(i-1).eq.ntyp1).or.itype(i-2).eq.ntyp1
6187 & .or.itype(i).eq.ntyp1) cycle
6188 C print *,i,theta(i)
6189 if (iabs(itype(i+1)).eq.20) iblock=2
6190 if (iabs(itype(i+1)).ne.20) iblock=1
6194 theti2=0.5d0*theta(i)
6195 ityp2=ithetyp((itype(i-1)))
6197 coskt(k)=dcos(k*theti2)
6198 sinkt(k)=dsin(k*theti2)
6201 if (i.gt.3 .and. itype(i-3).ne.ntyp1) then
6204 if (phii.ne.phii) phii=150.0
6208 ityp1=ithetyp((itype(i-2)))
6209 C propagation of chirality for glycine type
6211 cosph1(k)=dcos(k*phii)
6212 sinph1(k)=dsin(k*phii)
6217 ityp1=ithetyp((itype(i-2)))
6222 if (i.lt.nres .and. itype(i+1).ne.ntyp1) then
6225 if (phii1.ne.phii1) phii1=150.0
6230 ityp3=ithetyp((itype(i)))
6232 cosph2(k)=dcos(k*phii1)
6233 sinph2(k)=dsin(k*phii1)
6237 ityp3=ithetyp((itype(i)))
6243 ethetai=aa0thet(ityp1,ityp2,ityp3,iblock)
6246 ccl=cosph1(l)*cosph2(k-l)
6247 ssl=sinph1(l)*sinph2(k-l)
6248 scl=sinph1(l)*cosph2(k-l)
6249 csl=cosph1(l)*sinph2(k-l)
6250 cosph1ph2(l,k)=ccl-ssl
6251 cosph1ph2(k,l)=ccl+ssl
6252 sinph1ph2(l,k)=scl+csl
6253 sinph1ph2(k,l)=scl-csl
6257 write (iout,*) "i",i," ityp1",ityp1," ityp2",ityp2,
6258 & " ityp3",ityp3," theti2",theti2," phii",phii," phii1",phii1
6259 write (iout,*) "coskt and sinkt"
6261 write (iout,*) k,coskt(k),sinkt(k)
6265 ethetai=ethetai+aathet(k,ityp1,ityp2,ityp3,iblock)*sinkt(k)
6266 dethetai=dethetai+0.5d0*k*aathet(k,ityp1,ityp2,ityp3,iblock)
6269 & write (iout,*) "k",k,"
6270 & aathet",aathet(k,ityp1,ityp2,ityp3,iblock),
6271 & " ethetai",ethetai
6274 write (iout,*) "cosph and sinph"
6276 write (iout,*) k,cosph1(k),sinph1(k),cosph2(k),sinph2(k)
6278 write (iout,*) "cosph1ph2 and sinph2ph2"
6281 write (iout,*) l,k,cosph1ph2(l,k),cosph1ph2(k,l),
6282 & sinph1ph2(l,k),sinph1ph2(k,l)
6285 write(iout,*) "ethetai",ethetai
6290 aux=bbthet(k,m,ityp1,ityp2,ityp3,iblock)*cosph1(k)
6291 & +ccthet(k,m,ityp1,ityp2,ityp3,iblock)*sinph1(k)
6292 & +ddthet(k,m,ityp1,ityp2,ityp3,iblock)*cosph2(k)
6293 & +eethet(k,m,ityp1,ityp2,ityp3,iblock)*sinph2(k)
6294 ethetai=ethetai+sinkt(m)*aux
6295 dethetai=dethetai+0.5d0*m*aux*coskt(m)
6296 dephii=dephii+k*sinkt(m)*(
6297 & ccthet(k,m,ityp1,ityp2,ityp3,iblock)*cosph1(k)-
6298 & bbthet(k,m,ityp1,ityp2,ityp3,iblock)*sinph1(k))
6299 dephii1=dephii1+k*sinkt(m)*(
6300 & eethet(k,m,ityp1,ityp2,ityp3,iblock)*cosph2(k)-
6301 & ddthet(k,m,ityp1,ityp2,ityp3,iblock)*sinph2(k))
6303 & write (iout,*) "m",m," k",k," bbthet",
6304 & bbthet(k,m,ityp1,ityp2,ityp3,iblock)," ccthet",
6305 & ccthet(k,m,ityp1,ityp2,ityp3,iblock)," ddthet",
6306 & ddthet(k,m,ityp1,ityp2,ityp3,iblock)," eethet",
6307 & eethet(k,m,ityp1,ityp2,ityp3,iblock)," ethetai",ethetai
6308 C print *,"tu",cosph1(k),sinph1(k),cosph2(k),sinph2(k)
6311 C print *,"cosph1", (cosph1(k), k=1,nsingle)
6312 C print *,"cosph2", (cosph2(k), k=1,nsingle)
6313 C print *,"sinph1", (sinph1(k), k=1,nsingle)
6314 C print *,"sinph2", (sinph2(k), k=1,nsingle)
6316 & write(iout,*) "ethetai",ethetai
6317 C print *,"tu",cosph1(k),sinph1(k),cosph2(k),sinph2(k)
6321 aux=ffthet(l,k,m,ityp1,ityp2,ityp3,iblock)*cosph1ph2(l,k)+
6322 & ffthet(k,l,m,ityp1,ityp2,ityp3,iblock)*cosph1ph2(k,l)+
6323 & ggthet(l,k,m,ityp1,ityp2,ityp3,iblock)*sinph1ph2(l,k)+
6324 & ggthet(k,l,m,ityp1,ityp2,ityp3,iblock)*sinph1ph2(k,l)
6325 ethetai=ethetai+sinkt(m)*aux
6326 dethetai=dethetai+0.5d0*m*coskt(m)*aux
6327 dephii=dephii+l*sinkt(m)*(
6328 & -ffthet(l,k,m,ityp1,ityp2,ityp3,iblock)*sinph1ph2(l,k)-
6329 & ffthet(k,l,m,ityp1,ityp2,ityp3,iblock)*sinph1ph2(k,l)+
6330 & ggthet(l,k,m,ityp1,ityp2,ityp3,iblock)*cosph1ph2(l,k)+
6331 & ggthet(k,l,m,ityp1,ityp2,ityp3,iblock)*cosph1ph2(k,l))
6332 dephii1=dephii1+(k-l)*sinkt(m)*(
6333 & -ffthet(l,k,m,ityp1,ityp2,ityp3,iblock)*sinph1ph2(l,k)+
6334 & ffthet(k,l,m,ityp1,ityp2,ityp3,iblock)*sinph1ph2(k,l)+
6335 & ggthet(l,k,m,ityp1,ityp2,ityp3,iblock)*cosph1ph2(l,k)-
6336 & ggthet(k,l,m,ityp1,ityp2,ityp3,iblock)*cosph1ph2(k,l))
6338 write (iout,*) "m",m," k",k," l",l," ffthet",
6339 & ffthet(l,k,m,ityp1,ityp2,ityp3,iblock),
6340 & ffthet(k,l,m,ityp1,ityp2,ityp3,iblock)," ggthet",
6341 & ggthet(l,k,m,ityp1,ityp2,ityp3,iblock),
6342 & ggthet(k,l,m,ityp1,ityp2,ityp3,iblock),
6343 & " ethetai",ethetai
6344 write (iout,*) cosph1ph2(l,k)*sinkt(m),
6345 & cosph1ph2(k,l)*sinkt(m),
6346 & sinph1ph2(l,k)*sinkt(m),sinph1ph2(k,l)*sinkt(m)
6355 & write (iout,'(i2,3f8.1,9h ethetai ,f10.5)')
6356 & i,theta(i)*rad2deg,phii*rad2deg,
6357 & phii1*rad2deg,ethetai
6359 etheta=etheta+ethetai
6360 if (i.gt.3) gloc(i-3,icg)=gloc(i-3,icg)+wang*dephii
6361 if (i.lt.nres) gloc(i-2,icg)=gloc(i-2,icg)+wang*dephii1
6362 gloc(nphi+i-2,icg)=gloc(nphi+i-2,icg)+wang*dethetai
6366 C print *,ithetaconstr_start,ithetaconstr_end,"TU"
6367 do i=ithetaconstr_start,ithetaconstr_end
6368 itheta=itheta_constr(i)
6369 thetiii=theta(itheta)
6370 difi=pinorm(thetiii-theta_constr0(i))
6371 if (difi.gt.theta_drange(i)) then
6372 difi=difi-theta_drange(i)
6373 ethetacnstr=ethetacnstr+0.25d0*for_thet_constr(i)*difi**4
6374 gloc(itheta+nphi-2,icg)=gloc(itheta+nphi-2,icg)
6375 & +for_thet_constr(i)*difi**3
6376 else if (difi.lt.-drange(i)) then
6378 ethetacnstr=ethetacnstr+0.25d0*for_thet_constr(i)*difi**4
6379 gloc(itheta+nphi-2,icg)=gloc(itheta+nphi-2,icg)
6380 & +for_thet_constr(i)*difi**3
6384 if (energy_dec) then
6385 write (iout,'(a6,2i5,4f8.3,2e14.5)') "ethetc",
6386 & i,itheta,rad2deg*thetiii,
6387 & rad2deg*theta_constr0(i), rad2deg*theta_drange(i),
6388 & rad2deg*difi,0.25d0*for_thet_constr(i)*difi**4,
6389 & gloc(itheta+nphi-2,icg)
6397 c-----------------------------------------------------------------------------
6398 subroutine esc(escloc)
6399 C Calculate the local energy of a side chain and its derivatives in the
6400 C corresponding virtual-bond valence angles THETA and the spherical angles
6402 implicit real*8 (a-h,o-z)
6403 include 'DIMENSIONS'
6404 include 'COMMON.GEO'
6405 include 'COMMON.LOCAL'
6406 include 'COMMON.VAR'
6407 include 'COMMON.INTERACT'
6408 include 'COMMON.DERIV'
6409 include 'COMMON.CHAIN'
6410 include 'COMMON.IOUNITS'
6411 include 'COMMON.NAMES'
6412 include 'COMMON.FFIELD'
6413 include 'COMMON.CONTROL'
6414 double precision x(3),dersc(3),xemp(3),dersc0(3),dersc1(3),
6415 & ddersc0(3),ddummy(3),xtemp(3),temp(3)
6416 common /sccalc/ time11,time12,time112,theti,it,nlobit
6419 c write (iout,'(a)') 'ESC'
6420 do i=loc_start,loc_end
6422 if (it.eq.ntyp1) cycle
6423 if (it.eq.10) goto 1
6424 nlobit=nlob(iabs(it))
6425 c print *,'i=',i,' it=',it,' nlobit=',nlobit
6426 c write (iout,*) 'i=',i,' ssa=',ssa,' ssad=',ssad
6427 theti=theta(i+1)-pipol
6432 if (x(2).gt.pi-delta) then
6436 call enesc(xtemp,escloci0,dersc0,ddersc0,.true.)
6438 call enesc(xtemp,escloci1,dersc1,ddummy,.false.)
6439 call spline1(x(2),pi-delta,delta,escloci0,escloci1,dersc0(2),
6441 call spline2(x(2),pi-delta,delta,dersc0(1),dersc1(1),
6442 & ddersc0(1),dersc(1))
6443 call spline2(x(2),pi-delta,delta,dersc0(3),dersc1(3),
6444 & ddersc0(3),dersc(3))
6446 call enesc_bound(xtemp,esclocbi0,dersc0,dersc12,.true.)
6448 call enesc_bound(xtemp,esclocbi1,dersc1,chuju,.false.)
6449 call spline1(x(2),pi-delta,delta,esclocbi0,esclocbi1,
6450 & dersc0(2),esclocbi,dersc02)
6451 call spline2(x(2),pi-delta,delta,dersc0(1),dersc1(1),
6453 call splinthet(x(2),0.5d0*delta,ss,ssd)
6458 dersc(k)=ss*dersc(k)+(1.0d0-ss)*dersc0(k)
6460 dersc(2)=dersc(2)+ssd*(escloci-esclocbi)
6461 c write (iout,*) 'i=',i,x(2)*rad2deg,escloci0,escloci,
6463 escloci=ss*escloci+(1.0d0-ss)*esclocbi
6465 c write (iout,*) escloci
6466 else if (x(2).lt.delta) then
6470 call enesc(xtemp,escloci0,dersc0,ddersc0,.true.)
6472 call enesc(xtemp,escloci1,dersc1,ddummy,.false.)
6473 call spline1(x(2),delta,-delta,escloci0,escloci1,dersc0(2),
6475 call spline2(x(2),delta,-delta,dersc0(1),dersc1(1),
6476 & ddersc0(1),dersc(1))
6477 call spline2(x(2),delta,-delta,dersc0(3),dersc1(3),
6478 & ddersc0(3),dersc(3))
6480 call enesc_bound(xtemp,esclocbi0,dersc0,dersc12,.true.)
6482 call enesc_bound(xtemp,esclocbi1,dersc1,chuju,.false.)
6483 call spline1(x(2),delta,-delta,esclocbi0,esclocbi1,
6484 & dersc0(2),esclocbi,dersc02)
6485 call spline2(x(2),delta,-delta,dersc0(1),dersc1(1),
6490 call splinthet(x(2),0.5d0*delta,ss,ssd)
6492 dersc(k)=ss*dersc(k)+(1.0d0-ss)*dersc0(k)
6494 dersc(2)=dersc(2)+ssd*(escloci-esclocbi)
6495 c write (iout,*) 'i=',i,x(2)*rad2deg,escloci0,escloci,
6497 escloci=ss*escloci+(1.0d0-ss)*esclocbi
6498 c write (iout,*) escloci
6500 call enesc(x,escloci,dersc,ddummy,.false.)
6503 escloc=escloc+escloci
6504 if (energy_dec) write (iout,'(a6,i5,0pf7.3)')
6505 & 'escloc',i,escloci
6506 c write (iout,*) 'i=',i,' escloci=',escloci,' dersc=',dersc
6508 gloc(nphi+i-1,icg)=gloc(nphi+i-1,icg)+
6510 gloc(ialph(i,1),icg)=wscloc*dersc(2)
6511 gloc(ialph(i,1)+nside,icg)=wscloc*dersc(3)
6516 C---------------------------------------------------------------------------
6517 subroutine enesc(x,escloci,dersc,ddersc,mixed)
6518 implicit real*8 (a-h,o-z)
6519 include 'DIMENSIONS'
6520 include 'COMMON.GEO'
6521 include 'COMMON.LOCAL'
6522 include 'COMMON.IOUNITS'
6523 common /sccalc/ time11,time12,time112,theti,it,nlobit
6524 double precision x(3),z(3),Ax(3,maxlob,-1:1),dersc(3),ddersc(3)
6525 double precision contr(maxlob,-1:1)
6527 c write (iout,*) 'it=',it,' nlobit=',nlobit
6531 if (mixed) ddersc(j)=0.0d0
6535 C Because of periodicity of the dependence of the SC energy in omega we have
6536 C to add up the contributions from x(3)-2*pi, x(3), and x(3+2*pi).
6537 C To avoid underflows, first compute & store the exponents.
6545 z(k)=x(k)-censc(k,j,it)
6550 Axk=Axk+gaussc(l,k,j,it)*z(l)
6556 expfac=expfac+Ax(k,j,iii)*z(k)
6564 C As in the case of ebend, we want to avoid underflows in exponentiation and
6565 C subsequent NaNs and INFs in energy calculation.
6566 C Find the largest exponent
6570 if (emin.gt.contr(j,iii)) emin=contr(j,iii)
6574 cd print *,'it=',it,' emin=',emin
6576 C Compute the contribution to SC energy and derivatives
6581 adexp=bsc(j,iabs(it))-0.5D0*contr(j,iii)+emin
6582 if(adexp.ne.adexp) adexp=1.0
6585 expfac=dexp(bsc(j,iabs(it))-0.5D0*contr(j,iii)+emin)
6587 cd print *,'j=',j,' expfac=',expfac
6588 escloc_i=escloc_i+expfac
6590 dersc(k)=dersc(k)+Ax(k,j,iii)*expfac
6594 ddersc(k)=ddersc(k)+(-Ax(2,j,iii)*Ax(k,j,iii)
6595 & +gaussc(k,2,j,it))*expfac
6602 dersc(1)=dersc(1)/cos(theti)**2
6603 ddersc(1)=ddersc(1)/cos(theti)**2
6606 escloci=-(dlog(escloc_i)-emin)
6608 dersc(j)=dersc(j)/escloc_i
6612 ddersc(j)=(ddersc(j)/escloc_i+dersc(2)*dersc(j))
6617 C------------------------------------------------------------------------------
6618 subroutine enesc_bound(x,escloci,dersc,dersc12,mixed)
6619 implicit real*8 (a-h,o-z)
6620 include 'DIMENSIONS'
6621 include 'COMMON.GEO'
6622 include 'COMMON.LOCAL'
6623 include 'COMMON.IOUNITS'
6624 common /sccalc/ time11,time12,time112,theti,it,nlobit
6625 double precision x(3),z(3),Ax(3,maxlob),dersc(3)
6626 double precision contr(maxlob)
6637 z(k)=x(k)-censc(k,j,it)
6643 Axk=Axk+gaussc(l,k,j,it)*z(l)
6649 expfac=expfac+Ax(k,j)*z(k)
6654 C As in the case of ebend, we want to avoid underflows in exponentiation and
6655 C subsequent NaNs and INFs in energy calculation.
6656 C Find the largest exponent
6659 if (emin.gt.contr(j)) emin=contr(j)
6663 C Compute the contribution to SC energy and derivatives
6667 expfac=dexp(bsc(j,iabs(it))-0.5D0*contr(j)+emin)
6668 escloc_i=escloc_i+expfac
6670 dersc(k)=dersc(k)+Ax(k,j)*expfac
6672 if (mixed) dersc12=dersc12+(-Ax(2,j)*Ax(1,j)
6673 & +gaussc(1,2,j,it))*expfac
6677 dersc(1)=dersc(1)/cos(theti)**2
6678 dersc12=dersc12/cos(theti)**2
6679 escloci=-(dlog(escloc_i)-emin)
6681 dersc(j)=dersc(j)/escloc_i
6683 if (mixed) dersc12=(dersc12/escloc_i+dersc(2)*dersc(1))
6687 c----------------------------------------------------------------------------------
6688 subroutine esc(escloc)
6689 C Calculate the local energy of a side chain and its derivatives in the
6690 C corresponding virtual-bond valence angles THETA and the spherical angles
6691 C ALPHA and OMEGA derived from AM1 all-atom calculations.
6692 C added by Urszula Kozlowska. 07/11/2007
6694 implicit real*8 (a-h,o-z)
6695 include 'DIMENSIONS'
6696 include 'COMMON.GEO'
6697 include 'COMMON.LOCAL'
6698 include 'COMMON.VAR'
6699 include 'COMMON.SCROT'
6700 include 'COMMON.INTERACT'
6701 include 'COMMON.DERIV'
6702 include 'COMMON.CHAIN'
6703 include 'COMMON.IOUNITS'
6704 include 'COMMON.NAMES'
6705 include 'COMMON.FFIELD'
6706 include 'COMMON.CONTROL'
6707 include 'COMMON.VECTORS'
6708 double precision x_prime(3),y_prime(3),z_prime(3)
6709 & , sumene,dsc_i,dp2_i,x(65),
6710 & xx,yy,zz,sumene1,sumene2,sumene3,sumene4,s1,s1_6,s2,s2_6,
6711 & de_dxx,de_dyy,de_dzz,de_dt
6712 double precision s1_t,s1_6_t,s2_t,s2_6_t
6714 & dXX_Ci1(3),dYY_Ci1(3),dZZ_Ci1(3),dXX_Ci(3),
6715 & dYY_Ci(3),dZZ_Ci(3),dXX_XYZ(3),dYY_XYZ(3),dZZ_XYZ(3),
6716 & dt_dCi(3),dt_dCi1(3)
6717 common /sccalc/ time11,time12,time112,theti,it,nlobit
6720 do i=loc_start,loc_end
6721 if (itype(i).eq.ntyp1) cycle
6722 costtab(i+1) =dcos(theta(i+1))
6723 sinttab(i+1) =dsqrt(1-costtab(i+1)*costtab(i+1))
6724 cost2tab(i+1)=dsqrt(0.5d0*(1.0d0+costtab(i+1)))
6725 sint2tab(i+1)=dsqrt(0.5d0*(1.0d0-costtab(i+1)))
6726 cosfac2=0.5d0/(1.0d0+costtab(i+1))
6727 cosfac=dsqrt(cosfac2)
6728 sinfac2=0.5d0/(1.0d0-costtab(i+1))
6729 sinfac=dsqrt(sinfac2)
6731 if (it.eq.10) goto 1
6733 C Compute the axes of tghe local cartesian coordinates system; store in
6734 c x_prime, y_prime and z_prime
6741 C write(2,*) "dc_norm", dc_norm(1,i+nres),dc_norm(2,i+nres),
6742 C & dc_norm(3,i+nres)
6744 x_prime(j) = (dc_norm(j,i) - dc_norm(j,i-1))*cosfac
6745 y_prime(j) = (dc_norm(j,i) + dc_norm(j,i-1))*sinfac
6748 z_prime(j) = -uz(j,i-1)*dsign(1.0d0,dfloat(itype(i)))
6751 c write (2,*) "x_prime",(x_prime(j),j=1,3)
6752 c write (2,*) "y_prime",(y_prime(j),j=1,3)
6753 c write (2,*) "z_prime",(z_prime(j),j=1,3)
6754 c write (2,*) "xx",scalar(x_prime(1),x_prime(1)),
6755 c & " xy",scalar(x_prime(1),y_prime(1)),
6756 c & " xz",scalar(x_prime(1),z_prime(1)),
6757 c & " yy",scalar(y_prime(1),y_prime(1)),
6758 c & " yz",scalar(y_prime(1),z_prime(1)),
6759 c & " zz",scalar(z_prime(1),z_prime(1))
6761 C Transform the unit vector of the ith side-chain centroid, dC_norm(*,i),
6762 C to local coordinate system. Store in xx, yy, zz.
6768 xx = xx + x_prime(j)*dc_norm(j,i+nres)
6769 yy = yy + y_prime(j)*dc_norm(j,i+nres)
6770 zz = zz + z_prime(j)*dc_norm(j,i+nres)
6777 C Compute the energy of the ith side cbain
6779 c write (2,*) "xx",xx," yy",yy," zz",zz
6782 x(j) = sc_parmin(j,it)
6785 Cc diagnostics - remove later
6787 yy1 = dsin(alph(2))*dcos(omeg(2))
6788 zz1 = -dsign(1.0,dfloat(itype(i)))*dsin(alph(2))*dsin(omeg(2))
6789 write(2,'(3f8.1,3f9.3,1x,3f9.3)')
6790 & alph(2)*rad2deg,omeg(2)*rad2deg,theta(3)*rad2deg,xx,yy,zz,
6792 C," --- ", xx_w,yy_w,zz_w
6795 sumene1= x(1)+ x(2)*xx+ x(3)*yy+ x(4)*zz+ x(5)*xx**2
6796 & + x(6)*yy**2+ x(7)*zz**2+ x(8)*xx*zz+ x(9)*xx*yy
6798 sumene2= x(11) + x(12)*xx + x(13)*yy + x(14)*zz + x(15)*xx**2
6799 & + x(16)*yy**2 + x(17)*zz**2 + x(18)*xx*zz + x(19)*xx*yy
6801 sumene3= x(21) +x(22)*xx +x(23)*yy +x(24)*zz +x(25)*xx**2
6802 & +x(26)*yy**2 +x(27)*zz**2 +x(28)*xx*zz +x(29)*xx*yy
6803 & +x(30)*yy*zz +x(31)*xx**3 +x(32)*yy**3 +x(33)*zz**3
6804 & +x(34)*(xx**2)*yy +x(35)*(xx**2)*zz +x(36)*(yy**2)*xx
6805 & +x(37)*(yy**2)*zz +x(38)*(zz**2)*xx +x(39)*(zz**2)*yy
6807 sumene4= x(41) +x(42)*xx +x(43)*yy +x(44)*zz +x(45)*xx**2
6808 & +x(46)*yy**2 +x(47)*zz**2 +x(48)*xx*zz +x(49)*xx*yy
6809 & +x(50)*yy*zz +x(51)*xx**3 +x(52)*yy**3 +x(53)*zz**3
6810 & +x(54)*(xx**2)*yy +x(55)*(xx**2)*zz +x(56)*(yy**2)*xx
6811 & +x(57)*(yy**2)*zz +x(58)*(zz**2)*xx +x(59)*(zz**2)*yy
6813 dsc_i = 0.743d0+x(61)
6815 dscp1=dsqrt(dsc_i**2+dp2_i**2-2*dsc_i*dp2_i
6816 & *(xx*cost2tab(i+1)+yy*sint2tab(i+1)))
6817 dscp2=dsqrt(dsc_i**2+dp2_i**2-2*dsc_i*dp2_i
6818 & *(xx*cost2tab(i+1)-yy*sint2tab(i+1)))
6819 s1=(1+x(63))/(0.1d0 + dscp1)
6820 s1_6=(1+x(64))/(0.1d0 + dscp1**6)
6821 s2=(1+x(65))/(0.1d0 + dscp2)
6822 s2_6=(1+x(65))/(0.1d0 + dscp2**6)
6823 sumene = ( sumene3*sint2tab(i+1) + sumene1)*(s1+s1_6)
6824 & + (sumene4*cost2tab(i+1) +sumene2)*(s2+s2_6)
6825 c write(2,'(i2," sumene",7f9.3)') i,sumene1,sumene2,sumene3,
6827 c & dscp1,dscp2,sumene
6828 c sumene = enesc(x,xx,yy,zz,cost2tab(i+1),sint2tab(i+1))
6829 escloc = escloc + sumene
6830 c write (2,*) "i",i," escloc",sumene,escloc,it,itype(i)
6835 C This section to check the numerical derivatives of the energy of ith side
6836 C chain in xx, yy, zz, and theta. Use the -DDEBUG compiler option or insert
6837 C #define DEBUG in the code to turn it on.
6839 write (2,*) "sumene =",sumene
6843 write (2,*) xx,yy,zz
6844 sumenep = enesc(x,xx,yy,zz,cost2tab(i+1),sint2tab(i+1))
6845 de_dxx_num=(sumenep-sumene)/aincr
6847 write (2,*) "xx+ sumene from enesc=",sumenep
6850 write (2,*) xx,yy,zz
6851 sumenep = enesc(x,xx,yy,zz,cost2tab(i+1),sint2tab(i+1))
6852 de_dyy_num=(sumenep-sumene)/aincr
6854 write (2,*) "yy+ sumene from enesc=",sumenep
6857 write (2,*) xx,yy,zz
6858 sumenep = enesc(x,xx,yy,zz,cost2tab(i+1),sint2tab(i+1))
6859 de_dzz_num=(sumenep-sumene)/aincr
6861 write (2,*) "zz+ sumene from enesc=",sumenep
6862 costsave=cost2tab(i+1)
6863 sintsave=sint2tab(i+1)
6864 cost2tab(i+1)=dcos(0.5d0*(theta(i+1)+aincr))
6865 sint2tab(i+1)=dsin(0.5d0*(theta(i+1)+aincr))
6866 sumenep = enesc(x,xx,yy,zz,cost2tab(i+1),sint2tab(i+1))
6867 de_dt_num=(sumenep-sumene)/aincr
6868 write (2,*) " t+ sumene from enesc=",sumenep
6869 cost2tab(i+1)=costsave
6870 sint2tab(i+1)=sintsave
6871 C End of diagnostics section.
6874 C Compute the gradient of esc
6876 c zz=zz*dsign(1.0,dfloat(itype(i)))
6877 pom_s1=(1.0d0+x(63))/(0.1d0 + dscp1)**2
6878 pom_s16=6*(1.0d0+x(64))/(0.1d0 + dscp1**6)**2
6879 pom_s2=(1.0d0+x(65))/(0.1d0 + dscp2)**2
6880 pom_s26=6*(1.0d0+x(65))/(0.1d0 + dscp2**6)**2
6881 pom_dx=dsc_i*dp2_i*cost2tab(i+1)
6882 pom_dy=dsc_i*dp2_i*sint2tab(i+1)
6883 pom_dt1=-0.5d0*dsc_i*dp2_i*(xx*sint2tab(i+1)-yy*cost2tab(i+1))
6884 pom_dt2=-0.5d0*dsc_i*dp2_i*(xx*sint2tab(i+1)+yy*cost2tab(i+1))
6885 pom1=(sumene3*sint2tab(i+1)+sumene1)
6886 & *(pom_s1/dscp1+pom_s16*dscp1**4)
6887 pom2=(sumene4*cost2tab(i+1)+sumene2)
6888 & *(pom_s2/dscp2+pom_s26*dscp2**4)
6889 sumene1x=x(2)+2*x(5)*xx+x(8)*zz+ x(9)*yy
6890 sumene3x=x(22)+2*x(25)*xx+x(28)*zz+x(29)*yy+3*x(31)*xx**2
6891 & +2*x(34)*xx*yy +2*x(35)*xx*zz +x(36)*(yy**2) +x(38)*(zz**2)
6893 sumene2x=x(12)+2*x(15)*xx+x(18)*zz+ x(19)*yy
6894 sumene4x=x(42)+2*x(45)*xx +x(48)*zz +x(49)*yy +3*x(51)*xx**2
6895 & +2*x(54)*xx*yy+2*x(55)*xx*zz+x(56)*(yy**2)+x(58)*(zz**2)
6897 de_dxx =(sumene1x+sumene3x*sint2tab(i+1))*(s1+s1_6)
6898 & +(sumene2x+sumene4x*cost2tab(i+1))*(s2+s2_6)
6899 & +(pom1+pom2)*pom_dx
6901 write(2,*), "de_dxx = ", de_dxx,de_dxx_num,itype(i)
6904 sumene1y=x(3) + 2*x(6)*yy + x(9)*xx + x(10)*zz
6905 sumene3y=x(23) +2*x(26)*yy +x(29)*xx +x(30)*zz +3*x(32)*yy**2
6906 & +x(34)*(xx**2) +2*x(36)*yy*xx +2*x(37)*yy*zz +x(39)*(zz**2)
6908 sumene2y=x(13) + 2*x(16)*yy + x(19)*xx + x(20)*zz
6909 sumene4y=x(43)+2*x(46)*yy+x(49)*xx +x(50)*zz
6910 & +3*x(52)*yy**2+x(54)*xx**2+2*x(56)*yy*xx +2*x(57)*yy*zz
6911 & +x(59)*zz**2 +x(60)*xx*zz
6912 de_dyy =(sumene1y+sumene3y*sint2tab(i+1))*(s1+s1_6)
6913 & +(sumene2y+sumene4y*cost2tab(i+1))*(s2+s2_6)
6914 & +(pom1-pom2)*pom_dy
6916 write(2,*), "de_dyy = ", de_dyy,de_dyy_num,itype(i)
6919 de_dzz =(x(24) +2*x(27)*zz +x(28)*xx +x(30)*yy
6920 & +3*x(33)*zz**2 +x(35)*xx**2 +x(37)*yy**2 +2*x(38)*zz*xx
6921 & +2*x(39)*zz*yy +x(40)*xx*yy)*sint2tab(i+1)*(s1+s1_6)
6922 & +(x(4) + 2*x(7)*zz+ x(8)*xx + x(10)*yy)*(s1+s1_6)
6923 & +(x(44)+2*x(47)*zz +x(48)*xx +x(50)*yy +3*x(53)*zz**2
6924 & +x(55)*xx**2 +x(57)*(yy**2)+2*x(58)*zz*xx +2*x(59)*zz*yy
6925 & +x(60)*xx*yy)*cost2tab(i+1)*(s2+s2_6)
6926 & + ( x(14) + 2*x(17)*zz+ x(18)*xx + x(20)*yy)*(s2+s2_6)
6928 write(2,*), "de_dzz = ", de_dzz,de_dzz_num,itype(i)
6931 de_dt = 0.5d0*sumene3*cost2tab(i+1)*(s1+s1_6)
6932 & -0.5d0*sumene4*sint2tab(i+1)*(s2+s2_6)
6933 & +pom1*pom_dt1+pom2*pom_dt2
6935 write(2,*), "de_dt = ", de_dt,de_dt_num,itype(i)
6940 cossc=scalar(dc_norm(1,i),dc_norm(1,i+nres))
6941 cossc1=scalar(dc_norm(1,i-1),dc_norm(1,i+nres))
6942 cosfac2xx=cosfac2*xx
6943 sinfac2yy=sinfac2*yy
6945 dt_dCi(k) = -(dc_norm(k,i-1)+costtab(i+1)*dc_norm(k,i))*
6947 dt_dCi1(k)= -(dc_norm(k,i)+costtab(i+1)*dc_norm(k,i-1))*
6949 pom=(dC_norm(k,i+nres)-cossc*dC_norm(k,i))*vbld_inv(i+1)
6950 pom1=(dC_norm(k,i+nres)-cossc1*dC_norm(k,i-1))*vbld_inv(i)
6951 c write (iout,*) "i",i," k",k," pom",pom," pom1",pom1,
6952 c & " dt_dCi",dt_dCi(k)," dt_dCi1",dt_dCi1(k)
6953 c write (iout,*) "dC_norm",(dC_norm(j,i),j=1,3),
6954 c & (dC_norm(j,i-1),j=1,3)," vbld_inv",vbld_inv(i+1),vbld_inv(i)
6955 dXX_Ci(k)=pom*cosfac-dt_dCi(k)*cosfac2xx
6956 dXX_Ci1(k)=-pom1*cosfac-dt_dCi1(k)*cosfac2xx
6957 dYY_Ci(k)=pom*sinfac+dt_dCi(k)*sinfac2yy
6958 dYY_Ci1(k)=pom1*sinfac+dt_dCi1(k)*sinfac2yy
6962 dZZ_Ci(k)=dZZ_Ci(k)-uzgrad(j,k,2,i-1)
6963 & *dsign(1.0d0,dfloat(itype(i)))*dC_norm(j,i+nres)
6964 dZZ_Ci1(k)=dZZ_Ci1(k)-uzgrad(j,k,1,i-1)
6965 & *dsign(1.0d0,dfloat(itype(i)))*dC_norm(j,i+nres)
6968 dXX_XYZ(k)=vbld_inv(i+nres)*(x_prime(k)-xx*dC_norm(k,i+nres))
6969 dYY_XYZ(k)=vbld_inv(i+nres)*(y_prime(k)-yy*dC_norm(k,i+nres))
6970 dZZ_XYZ(k)=vbld_inv(i+nres)*
6971 & (z_prime(k)-zz*dC_norm(k,i+nres))
6973 dt_dCi(k) = -dt_dCi(k)/sinttab(i+1)
6974 dt_dCi1(k)= -dt_dCi1(k)/sinttab(i+1)
6978 dXX_Ctab(k,i)=dXX_Ci(k)
6979 dXX_C1tab(k,i)=dXX_Ci1(k)
6980 dYY_Ctab(k,i)=dYY_Ci(k)
6981 dYY_C1tab(k,i)=dYY_Ci1(k)
6982 dZZ_Ctab(k,i)=dZZ_Ci(k)
6983 dZZ_C1tab(k,i)=dZZ_Ci1(k)
6984 dXX_XYZtab(k,i)=dXX_XYZ(k)
6985 dYY_XYZtab(k,i)=dYY_XYZ(k)
6986 dZZ_XYZtab(k,i)=dZZ_XYZ(k)
6990 c write (iout,*) "k",k," dxx_ci1",dxx_ci1(k)," dyy_ci1",
6991 c & dyy_ci1(k)," dzz_ci1",dzz_ci1(k)
6992 c write (iout,*) "k",k," dxx_ci",dxx_ci(k)," dyy_ci",
6993 c & dyy_ci(k)," dzz_ci",dzz_ci(k)
6994 c write (iout,*) "k",k," dt_dci",dt_dci(k)," dt_dci",
6996 c write (iout,*) "k",k," dxx_XYZ",dxx_XYZ(k)," dyy_XYZ",
6997 c & dyy_XYZ(k)," dzz_XYZ",dzz_XYZ(k)
6998 gscloc(k,i-1)=gscloc(k,i-1)+de_dxx*dxx_ci1(k)
6999 & +de_dyy*dyy_ci1(k)+de_dzz*dzz_ci1(k)+de_dt*dt_dCi1(k)
7000 gscloc(k,i)=gscloc(k,i)+de_dxx*dxx_Ci(k)
7001 & +de_dyy*dyy_Ci(k)+de_dzz*dzz_Ci(k)+de_dt*dt_dCi(k)
7002 gsclocx(k,i)= de_dxx*dxx_XYZ(k)
7003 & +de_dyy*dyy_XYZ(k)+de_dzz*dzz_XYZ(k)
7005 c write(iout,*) "ENERGY GRAD = ", (gscloc(k,i-1),k=1,3),
7006 c & (gscloc(k,i),k=1,3),(gsclocx(k,i),k=1,3)
7008 C to check gradient call subroutine check_grad
7014 c------------------------------------------------------------------------------
7015 double precision function enesc(x,xx,yy,zz,cost2,sint2)
7017 double precision x(65),xx,yy,zz,cost2,sint2,sumene1,sumene2,
7018 & sumene3,sumene4,sumene,dsc_i,dp2_i,dscp1,dscp2,s1,s1_6,s2,s2_6
7019 sumene1= x(1)+ x(2)*xx+ x(3)*yy+ x(4)*zz+ x(5)*xx**2
7020 & + x(6)*yy**2+ x(7)*zz**2+ x(8)*xx*zz+ x(9)*xx*yy
7022 sumene2= x(11) + x(12)*xx + x(13)*yy + x(14)*zz + x(15)*xx**2
7023 & + x(16)*yy**2 + x(17)*zz**2 + x(18)*xx*zz + x(19)*xx*yy
7025 sumene3= x(21) +x(22)*xx +x(23)*yy +x(24)*zz +x(25)*xx**2
7026 & +x(26)*yy**2 +x(27)*zz**2 +x(28)*xx*zz +x(29)*xx*yy
7027 & +x(30)*yy*zz +x(31)*xx**3 +x(32)*yy**3 +x(33)*zz**3
7028 & +x(34)*(xx**2)*yy +x(35)*(xx**2)*zz +x(36)*(yy**2)*xx
7029 & +x(37)*(yy**2)*zz +x(38)*(zz**2)*xx +x(39)*(zz**2)*yy
7031 sumene4= x(41) +x(42)*xx +x(43)*yy +x(44)*zz +x(45)*xx**2
7032 & +x(46)*yy**2 +x(47)*zz**2 +x(48)*xx*zz +x(49)*xx*yy
7033 & +x(50)*yy*zz +x(51)*xx**3 +x(52)*yy**3 +x(53)*zz**3
7034 & +x(54)*(xx**2)*yy +x(55)*(xx**2)*zz +x(56)*(yy**2)*xx
7035 & +x(57)*(yy**2)*zz +x(58)*(zz**2)*xx +x(59)*(zz**2)*yy
7037 dsc_i = 0.743d0+x(61)
7039 dscp1=dsqrt(dsc_i**2+dp2_i**2-2*dsc_i*dp2_i
7040 & *(xx*cost2+yy*sint2))
7041 dscp2=dsqrt(dsc_i**2+dp2_i**2-2*dsc_i*dp2_i
7042 & *(xx*cost2-yy*sint2))
7043 s1=(1+x(63))/(0.1d0 + dscp1)
7044 s1_6=(1+x(64))/(0.1d0 + dscp1**6)
7045 s2=(1+x(65))/(0.1d0 + dscp2)
7046 s2_6=(1+x(65))/(0.1d0 + dscp2**6)
7047 sumene = ( sumene3*sint2 + sumene1)*(s1+s1_6)
7048 & + (sumene4*cost2 +sumene2)*(s2+s2_6)
7053 c------------------------------------------------------------------------------
7054 subroutine gcont(rij,r0ij,eps0ij,delta,fcont,fprimcont)
7056 C This procedure calculates two-body contact function g(rij) and its derivative:
7059 C g(rij) = esp0ij*(-0.9375*x+0.625*x**3-0.1875*x**5) ! -1 =< x =< 1
7062 C where x=(rij-r0ij)/delta
7064 C rij - interbody distance, r0ij - contact distance, eps0ij - contact energy
7067 double precision rij,r0ij,eps0ij,fcont,fprimcont
7068 double precision x,x2,x4,delta
7072 if (x.lt.-1.0D0) then
7075 else if (x.le.1.0D0) then
7078 fcont=eps0ij*(x*(-0.9375D0+0.6250D0*x2-0.1875D0*x4)+0.5D0)
7079 fprimcont=eps0ij * (-0.9375D0+1.8750D0*x2-0.9375D0*x4)/delta
7086 c------------------------------------------------------------------------------
7087 subroutine splinthet(theti,delta,ss,ssder)
7088 implicit real*8 (a-h,o-z)
7089 include 'DIMENSIONS'
7090 include 'COMMON.VAR'
7091 include 'COMMON.GEO'
7094 if (theti.gt.pipol) then
7095 call gcont(theti,thetup,1.0d0,delta,ss,ssder)
7097 call gcont(-theti,-thetlow,1.0d0,delta,ss,ssder)
7102 c------------------------------------------------------------------------------
7103 subroutine spline1(x,x0,delta,f0,f1,fprim0,f,fprim)
7105 double precision x,x0,delta,f0,f1,fprim0,f,fprim
7106 double precision ksi,ksi2,ksi3,a1,a2,a3
7107 a1=fprim0*delta/(f1-f0)
7113 f=f0+(f1-f0)*ksi*(a1+ksi*(a2+a3*ksi))
7114 fprim=(f1-f0)/delta*(a1+ksi*(2*a2+3*ksi*a3))
7117 c------------------------------------------------------------------------------
7118 subroutine spline2(x,x0,delta,f0x,f1x,fprim0x,fx)
7120 double precision x,x0,delta,f0x,f1x,fprim0x,fx
7121 double precision ksi,ksi2,ksi3,a1,a2,a3
7126 a2=3*(f1x-f0x)-2*fprim0x*delta
7127 a3=fprim0x*delta-2*(f1x-f0x)
7128 fx=f0x+a1*ksi+a2*ksi2+a3*ksi3
7131 C-----------------------------------------------------------------------------
7133 C-----------------------------------------------------------------------------
7134 subroutine etor(etors,edihcnstr)
7135 implicit real*8 (a-h,o-z)
7136 include 'DIMENSIONS'
7137 include 'COMMON.VAR'
7138 include 'COMMON.GEO'
7139 include 'COMMON.LOCAL'
7140 include 'COMMON.TORSION'
7141 include 'COMMON.INTERACT'
7142 include 'COMMON.DERIV'
7143 include 'COMMON.CHAIN'
7144 include 'COMMON.NAMES'
7145 include 'COMMON.IOUNITS'
7146 include 'COMMON.FFIELD'
7147 include 'COMMON.TORCNSTR'
7148 include 'COMMON.CONTROL'
7150 C Set lprn=.true. for debugging
7154 do i=iphi_start,iphi_end
7156 if (itype(i-2).eq.ntyp1.or. itype(i-1).eq.ntyp1
7157 & .or. itype(i).eq.ntyp1 .or. itype(i-3).eq.ntyp1) cycle
7158 itori=itortyp(itype(i-2))
7159 itori1=itortyp(itype(i-1))
7162 C Proline-Proline pair is a special case...
7163 if (itori.eq.3 .and. itori1.eq.3) then
7164 if (phii.gt.-dwapi3) then
7166 fac=1.0D0/(1.0D0-cosphi)
7167 etorsi=v1(1,3,3)*fac
7168 etorsi=etorsi+etorsi
7169 etors=etors+etorsi-v1(1,3,3)
7170 if (energy_dec) etors_ii=etors_ii+etorsi-v1(1,3,3)
7171 gloci=gloci-3*fac*etorsi*dsin(3*phii)
7174 v1ij=v1(j+1,itori,itori1)
7175 v2ij=v2(j+1,itori,itori1)
7178 etors=etors+v1ij*cosphi+v2ij*sinphi+dabs(v1ij)+dabs(v2ij)
7179 if (energy_dec) etors_ii=etors_ii+
7180 & v2ij*sinphi+dabs(v1ij)+dabs(v2ij)
7181 gloci=gloci+j*(v2ij*cosphi-v1ij*sinphi)
7185 v1ij=v1(j,itori,itori1)
7186 v2ij=v2(j,itori,itori1)
7189 etors=etors+v1ij*cosphi+v2ij*sinphi+dabs(v1ij)+dabs(v2ij)
7190 if (energy_dec) etors_ii=etors_ii+
7191 & v1ij*cosphi+v2ij*sinphi+dabs(v1ij)+dabs(v2ij)
7192 gloci=gloci+j*(v2ij*cosphi-v1ij*sinphi)
7195 if (energy_dec) write (iout,'(a6,i5,0pf7.3)')
7198 & write (iout,'(2(a3,2x,i3,2x),2i3,6f8.3/26x,6f8.3/)')
7199 & restyp(itype(i-2)),i-2,restyp(itype(i-1)),i-1,itori,itori1,
7200 & (v1(j,itori,itori1),j=1,6),(v2(j,itori,itori1),j=1,6)
7201 gloc(i-3,icg)=gloc(i-3,icg)+wtor*gloci
7202 c write (iout,*) 'i=',i,' gloc=',gloc(i-3,icg)
7204 ! 6/20/98 - dihedral angle constraints
7207 itori=idih_constr(i)
7210 if (difi.gt.drange(i)) then
7212 edihcnstr=edihcnstr+0.25d0*ftors(i)*difi**4
7213 gloc(itori-3,icg)=gloc(itori-3,icg)+ftors(i)*difi**3
7214 else if (difi.lt.-drange(i)) then
7216 edihcnstr=edihcnstr+0.25d0*ftors(i)**difi**4
7217 gloc(itori-3,icg)=gloc(itori-3,icg)+ftors(i)*difi**3
7219 ! write (iout,'(2i5,2f8.3,2e14.5)') i,itori,rad2deg*phii,
7220 ! & rad2deg*difi,0.25d0*ftors*difi**4,gloc(itori-3,icg)
7222 ! write (iout,*) 'edihcnstr',edihcnstr
7225 c------------------------------------------------------------------------------
7226 subroutine etor_d(etors_d)
7230 c----------------------------------------------------------------------------
7232 subroutine etor(etors,edihcnstr)
7233 implicit real*8 (a-h,o-z)
7234 include 'DIMENSIONS'
7235 include 'COMMON.VAR'
7236 include 'COMMON.GEO'
7237 include 'COMMON.LOCAL'
7238 include 'COMMON.TORSION'
7239 include 'COMMON.INTERACT'
7240 include 'COMMON.DERIV'
7241 include 'COMMON.CHAIN'
7242 include 'COMMON.NAMES'
7243 include 'COMMON.IOUNITS'
7244 include 'COMMON.FFIELD'
7245 include 'COMMON.TORCNSTR'
7246 include 'COMMON.CONTROL'
7248 C Set lprn=.true. for debugging
7252 do i=iphi_start,iphi_end
7253 C ANY TWO ARE DUMMY ATOMS in row CYCLE
7254 c if (((itype(i-3).eq.ntyp1).and.(itype(i-2).eq.ntyp1)).or.
7255 c & ((itype(i-2).eq.ntyp1).and.(itype(i-1).eq.ntyp1)) .or.
7256 c & ((itype(i-1).eq.ntyp1).and.(itype(i).eq.ntyp1))) cycle
7257 if (itype(i-2).eq.ntyp1.or. itype(i-1).eq.ntyp1
7258 & .or. itype(i).eq.ntyp1 .or. itype(i-3).eq.ntyp1) cycle
7259 C In current verion the ALL DUMMY ATOM POTENTIALS ARE OFF
7260 C For introducing the NH3+ and COO- group please check the etor_d for reference
7263 if (iabs(itype(i)).eq.20) then
7268 itori=itortyp(itype(i-2))
7269 itori1=itortyp(itype(i-1))
7272 C Regular cosine and sine terms
7273 do j=1,nterm(itori,itori1,iblock)
7274 v1ij=v1(j,itori,itori1,iblock)
7275 v2ij=v2(j,itori,itori1,iblock)
7278 etors=etors+v1ij*cosphi+v2ij*sinphi
7279 if (energy_dec) etors_ii=etors_ii+
7280 & v1ij*cosphi+v2ij*sinphi
7281 gloci=gloci+j*(v2ij*cosphi-v1ij*sinphi)
7285 C E = SUM ----------------------------------- - v1
7286 C [v2 cos(phi/2)+v3 sin(phi/2)]^2 + 1
7288 cosphi=dcos(0.5d0*phii)
7289 sinphi=dsin(0.5d0*phii)
7290 do j=1,nlor(itori,itori1,iblock)
7291 vl1ij=vlor1(j,itori,itori1)
7292 vl2ij=vlor2(j,itori,itori1)
7293 vl3ij=vlor3(j,itori,itori1)
7294 pom=vl2ij*cosphi+vl3ij*sinphi
7295 pom1=1.0d0/(pom*pom+1.0d0)
7296 etors=etors+vl1ij*pom1
7297 if (energy_dec) etors_ii=etors_ii+
7300 gloci=gloci+vl1ij*(vl3ij*cosphi-vl2ij*sinphi)*pom
7302 C Subtract the constant term
7303 etors=etors-v0(itori,itori1,iblock)
7304 if (energy_dec) write (iout,'(a6,i5,0pf7.3)')
7305 & 'etor',i,etors_ii-v0(itori,itori1,iblock)
7307 & write (iout,'(2(a3,2x,i3,2x),2i3,6f8.3/26x,6f8.3/)')
7308 & restyp(itype(i-2)),i-2,restyp(itype(i-1)),i-1,itori,itori1,
7309 & (v1(j,itori,itori1,iblock),j=1,6),
7310 & (v2(j,itori,itori1,iblock),j=1,6)
7311 gloc(i-3,icg)=gloc(i-3,icg)+wtor*gloci
7312 c write (iout,*) 'i=',i,' gloc=',gloc(i-3,icg)
7314 ! 6/20/98 - dihedral angle constraints
7316 c do i=1,ndih_constr
7317 do i=idihconstr_start,idihconstr_end
7318 itori=idih_constr(i)
7320 difi=pinorm(phii-phi0(i))
7321 if (difi.gt.drange(i)) then
7323 edihcnstr=edihcnstr+0.25d0*ftors(i)*difi**4
7324 gloc(itori-3,icg)=gloc(itori-3,icg)+ftors(i)*difi**3
7325 else if (difi.lt.-drange(i)) then
7327 edihcnstr=edihcnstr+0.25d0*ftors(i)*difi**4
7328 gloc(itori-3,icg)=gloc(itori-3,icg)+ftors(i)*difi**3
7332 if (energy_dec) then
7333 write (iout,'(a6,2i5,4f8.3,2e14.5)') "edihc",
7334 & i,itori,rad2deg*phii,
7335 & rad2deg*phi0(i), rad2deg*drange(i),
7336 & rad2deg*difi,0.25d0*ftors(i)*difi**4,gloc(itori-3,icg)
7339 cd write (iout,*) 'edihcnstr',edihcnstr
7342 c----------------------------------------------------------------------------
7343 subroutine etor_d(etors_d)
7344 C 6/23/01 Compute double torsional energy
7345 implicit real*8 (a-h,o-z)
7346 include 'DIMENSIONS'
7347 include 'COMMON.VAR'
7348 include 'COMMON.GEO'
7349 include 'COMMON.LOCAL'
7350 include 'COMMON.TORSION'
7351 include 'COMMON.INTERACT'
7352 include 'COMMON.DERIV'
7353 include 'COMMON.CHAIN'
7354 include 'COMMON.NAMES'
7355 include 'COMMON.IOUNITS'
7356 include 'COMMON.FFIELD'
7357 include 'COMMON.TORCNSTR'
7359 C Set lprn=.true. for debugging
7363 c write(iout,*) "a tu??"
7364 do i=iphid_start,iphid_end
7365 C ANY TWO ARE DUMMY ATOMS in row CYCLE
7366 C if (((itype(i-3).eq.ntyp1).and.(itype(i-2).eq.ntyp1)).or.
7367 C & ((itype(i-2).eq.ntyp1).and.(itype(i-1).eq.ntyp1)).or.
7368 C & ((itype(i-1).eq.ntyp1).and.(itype(i).eq.ntyp1)) .or.
7369 C & ((itype(i).eq.ntyp1).and.(itype(i+1).eq.ntyp1))) cycle
7370 if ((itype(i-2).eq.ntyp1).or.itype(i-3).eq.ntyp1.or.
7371 & (itype(i-1).eq.ntyp1).or.(itype(i).eq.ntyp1).or.
7372 & (itype(i+1).eq.ntyp1)) cycle
7373 C In current verion the ALL DUMMY ATOM POTENTIALS ARE OFF
7374 itori=itortyp(itype(i-2))
7375 itori1=itortyp(itype(i-1))
7376 itori2=itortyp(itype(i))
7382 if (iabs(itype(i+1)).eq.20) iblock=2
7383 C Iblock=2 Proline type
7384 C ADASKO: WHEN PARAMETERS FOR THIS TYPE OF BLOCKING GROUP IS READY UNCOMMENT
7385 C CHECK WEATHER THERE IS NECCESITY FOR iblock=3 for COO-
7386 C if (itype(i+1).eq.ntyp1) iblock=3
7387 C The problem of NH3+ group can be resolved by adding new parameters please note if there
7388 C IS or IS NOT need for this
7389 C IF Yes uncomment below and add to parmread.F appropriate changes and to v1cij and so on
7390 C is (itype(i-3).eq.ntyp1) ntblock=2
7391 C ntblock is N-terminal blocking group
7393 C Regular cosine and sine terms
7394 do j=1,ntermd_1(itori,itori1,itori2,iblock)
7395 C Example of changes for NH3+ blocking group
7396 C do j=1,ntermd_1(itori,itori1,itori2,iblock,ntblock)
7397 C v1cij=v1c(1,j,itori,itori1,itori2,iblock,ntblock)
7398 v1cij=v1c(1,j,itori,itori1,itori2,iblock)
7399 v1sij=v1s(1,j,itori,itori1,itori2,iblock)
7400 v2cij=v1c(2,j,itori,itori1,itori2,iblock)
7401 v2sij=v1s(2,j,itori,itori1,itori2,iblock)
7402 cosphi1=dcos(j*phii)
7403 sinphi1=dsin(j*phii)
7404 cosphi2=dcos(j*phii1)
7405 sinphi2=dsin(j*phii1)
7406 etors_d=etors_d+v1cij*cosphi1+v1sij*sinphi1+
7407 & v2cij*cosphi2+v2sij*sinphi2
7408 gloci1=gloci1+j*(v1sij*cosphi1-v1cij*sinphi1)
7409 gloci2=gloci2+j*(v2sij*cosphi2-v2cij*sinphi2)
7411 do k=2,ntermd_2(itori,itori1,itori2,iblock)
7413 v1cdij = v2c(k,l,itori,itori1,itori2,iblock)
7414 v2cdij = v2c(l,k,itori,itori1,itori2,iblock)
7415 v1sdij = v2s(k,l,itori,itori1,itori2,iblock)
7416 v2sdij = v2s(l,k,itori,itori1,itori2,iblock)
7417 cosphi1p2=dcos(l*phii+(k-l)*phii1)
7418 cosphi1m2=dcos(l*phii-(k-l)*phii1)
7419 sinphi1p2=dsin(l*phii+(k-l)*phii1)
7420 sinphi1m2=dsin(l*phii-(k-l)*phii1)
7421 etors_d=etors_d+v1cdij*cosphi1p2+v2cdij*cosphi1m2+
7422 & v1sdij*sinphi1p2+v2sdij*sinphi1m2
7423 gloci1=gloci1+l*(v1sdij*cosphi1p2+v2sdij*cosphi1m2
7424 & -v1cdij*sinphi1p2-v2cdij*sinphi1m2)
7425 gloci2=gloci2+(k-l)*(v1sdij*cosphi1p2-v2sdij*cosphi1m2
7426 & -v1cdij*sinphi1p2+v2cdij*sinphi1m2)
7429 gloc(i-3,icg)=gloc(i-3,icg)+wtor_d*gloci1
7430 gloc(i-2,icg)=gloc(i-2,icg)+wtor_d*gloci2
7435 c------------------------------------------------------------------------------
7436 subroutine eback_sc_corr(esccor)
7437 c 7/21/2007 Correlations between the backbone-local and side-chain-local
7438 c conformational states; temporarily implemented as differences
7439 c between UNRES torsional potentials (dependent on three types of
7440 c residues) and the torsional potentials dependent on all 20 types
7441 c of residues computed from AM1 energy surfaces of terminally-blocked
7442 c amino-acid residues.
7443 implicit real*8 (a-h,o-z)
7444 include 'DIMENSIONS'
7445 include 'COMMON.VAR'
7446 include 'COMMON.GEO'
7447 include 'COMMON.LOCAL'
7448 include 'COMMON.TORSION'
7449 include 'COMMON.SCCOR'
7450 include 'COMMON.INTERACT'
7451 include 'COMMON.DERIV'
7452 include 'COMMON.CHAIN'
7453 include 'COMMON.NAMES'
7454 include 'COMMON.IOUNITS'
7455 include 'COMMON.FFIELD'
7456 include 'COMMON.CONTROL'
7458 C Set lprn=.true. for debugging
7461 c write (iout,*) "EBACK_SC_COR",itau_start,itau_end
7463 do i=itau_start,itau_end
7464 if ((itype(i-2).eq.ntyp1).or.(itype(i-1).eq.ntyp1)) cycle
7466 isccori=isccortyp(itype(i-2))
7467 isccori1=isccortyp(itype(i-1))
7468 c write (iout,*) "EBACK_SC_COR",i,nterm_sccor(isccori,isccori1)
7470 do intertyp=1,3 !intertyp
7471 cc Added 09 May 2012 (Adasko)
7472 cc Intertyp means interaction type of backbone mainchain correlation:
7473 c 1 = SC...Ca...Ca...Ca
7474 c 2 = Ca...Ca...Ca...SC
7475 c 3 = SC...Ca...Ca...SCi
7477 if (((intertyp.eq.3).and.((itype(i-2).eq.10).or.
7478 & (itype(i-1).eq.10).or.(itype(i-2).eq.ntyp1).or.
7479 & (itype(i-1).eq.ntyp1)))
7480 & .or. ((intertyp.eq.1).and.((itype(i-2).eq.10)
7481 & .or.(itype(i-2).eq.ntyp1).or.(itype(i-1).eq.ntyp1)
7482 & .or.(itype(i).eq.ntyp1)))
7483 & .or.((intertyp.eq.2).and.((itype(i-1).eq.10).or.
7484 & (itype(i-1).eq.ntyp1).or.(itype(i-2).eq.ntyp1).or.
7485 & (itype(i-3).eq.ntyp1)))) cycle
7486 if ((intertyp.eq.2).and.(i.eq.4).and.(itype(1).eq.ntyp1)) cycle
7487 if ((intertyp.eq.1).and.(i.eq.nres).and.(itype(nres).eq.ntyp1))
7489 do j=1,nterm_sccor(isccori,isccori1)
7490 v1ij=v1sccor(j,intertyp,isccori,isccori1)
7491 v2ij=v2sccor(j,intertyp,isccori,isccori1)
7492 cosphi=dcos(j*tauangle(intertyp,i))
7493 sinphi=dsin(j*tauangle(intertyp,i))
7494 esccor=esccor+v1ij*cosphi+v2ij*sinphi
7495 gloci=gloci+j*(v2ij*cosphi-v1ij*sinphi)
7497 c write (iout,*) "EBACK_SC_COR",i,v1ij*cosphi+v2ij*sinphi,intertyp
7498 gloc_sc(intertyp,i-3,icg)=gloc_sc(intertyp,i-3,icg)+wsccor*gloci
7500 & write (iout,'(2(a3,2x,i3,2x),2i3,6f8.3/26x,6f8.3/)')
7501 & restyp(itype(i-2)),i-2,restyp(itype(i-1)),i-1,isccori,isccori1,
7502 & (v1sccor(j,intertyp,isccori,isccori1),j=1,6)
7503 & ,(v2sccor(j,intertyp,isccori,isccori1),j=1,6)
7504 gsccor_loc(i-3)=gsccor_loc(i-3)+gloci
7510 c----------------------------------------------------------------------------
7511 subroutine multibody(ecorr)
7512 C This subroutine calculates multi-body contributions to energy following
7513 C the idea of Skolnick et al. If side chains I and J make a contact and
7514 C at the same time side chains I+1 and J+1 make a contact, an extra
7515 C contribution equal to sqrt(eps(i,j)*eps(i+1,j+1)) is added.
7516 implicit real*8 (a-h,o-z)
7517 include 'DIMENSIONS'
7518 include 'COMMON.IOUNITS'
7519 include 'COMMON.DERIV'
7520 include 'COMMON.INTERACT'
7521 include 'COMMON.CONTACTS'
7522 double precision gx(3),gx1(3)
7525 C Set lprn=.true. for debugging
7529 write (iout,'(a)') 'Contact function values:'
7531 write (iout,'(i2,20(1x,i2,f10.5))')
7532 & i,(jcont(j,i),facont(j,i),j=1,num_cont(i))
7547 num_conti=num_cont(i)
7548 num_conti1=num_cont(i1)
7553 if (j1.eq.j+ishift .or. j1.eq.j-ishift) then
7554 cd write(iout,*)'i=',i,' j=',j,' i1=',i1,' j1=',j1,
7555 cd & ' ishift=',ishift
7556 C Contacts I--J and I+ISHIFT--J+-ISHIFT1 occur simultaneously.
7557 C The system gains extra energy.
7558 ecorr=ecorr+esccorr(i,j,i1,j1,jj,kk)
7559 endif ! j1==j+-ishift
7568 c------------------------------------------------------------------------------
7569 double precision function esccorr(i,j,k,l,jj,kk)
7570 implicit real*8 (a-h,o-z)
7571 include 'DIMENSIONS'
7572 include 'COMMON.IOUNITS'
7573 include 'COMMON.DERIV'
7574 include 'COMMON.INTERACT'
7575 include 'COMMON.CONTACTS'
7576 include 'COMMON.SHIELD'
7577 double precision gx(3),gx1(3)
7582 cd write (iout,'(4i5,3f10.5)') i,j,k,l,eij,ekl,-eij*ekl
7583 C Calculate the multi-body contribution to energy.
7584 C Calculate multi-body contributions to the gradient.
7585 cd write (iout,'(2(2i3,3f10.5))')i,j,(gacont(m,jj,i),m=1,3),
7586 cd & k,l,(gacont(m,kk,k),m=1,3)
7588 gx(m) =ekl*gacont(m,jj,i)
7589 gx1(m)=eij*gacont(m,kk,k)
7590 gradxorr(m,i)=gradxorr(m,i)-gx(m)
7591 gradxorr(m,j)=gradxorr(m,j)+gx(m)
7592 gradxorr(m,k)=gradxorr(m,k)-gx1(m)
7593 gradxorr(m,l)=gradxorr(m,l)+gx1(m)
7597 gradcorr(ll,m)=gradcorr(ll,m)+gx(ll)
7602 gradcorr(ll,m)=gradcorr(ll,m)+gx1(ll)
7608 c------------------------------------------------------------------------------
7609 subroutine multibody_hb(ecorr,ecorr5,ecorr6,n_corr,n_corr1)
7610 C This subroutine calculates multi-body contributions to hydrogen-bonding
7611 implicit real*8 (a-h,o-z)
7612 include 'DIMENSIONS'
7613 include 'COMMON.IOUNITS'
7616 parameter (max_cont=maxconts)
7617 parameter (max_dim=26)
7618 integer source,CorrelType,CorrelID,CorrelType1,CorrelID1,Error
7619 double precision zapas(max_dim,maxconts,max_fg_procs),
7620 & zapas_recv(max_dim,maxconts,max_fg_procs)
7621 common /przechowalnia/ zapas
7622 integer status(MPI_STATUS_SIZE),req(maxconts*2),
7623 & status_array(MPI_STATUS_SIZE,maxconts*2)
7625 include 'COMMON.SETUP'
7626 include 'COMMON.FFIELD'
7627 include 'COMMON.DERIV'
7628 include 'COMMON.INTERACT'
7629 include 'COMMON.CONTACTS'
7630 include 'COMMON.CONTROL'
7631 include 'COMMON.LOCAL'
7632 double precision gx(3),gx1(3),time00
7635 C Set lprn=.true. for debugging
7640 if (nfgtasks.le.1) goto 30
7642 write (iout,'(a)') 'Contact function values before RECEIVE:'
7644 write (iout,'(2i3,50(1x,i2,f5.2))')
7645 & i,num_cont_hb(i),(jcont_hb(j,i),facont_hb(j,i),
7646 & j=1,num_cont_hb(i))
7650 do i=1,ntask_cont_from
7653 do i=1,ntask_cont_to
7656 c write (iout,*) "ntask_cont_from",ntask_cont_from," ntask_cont_to",
7658 C Make the list of contacts to send to send to other procesors
7659 c write (iout,*) "limits",max0(iturn4_end-1,iatel_s),iturn3_end
7661 do i=iturn3_start,iturn3_end
7662 c write (iout,*) "make contact list turn3",i," num_cont",
7664 call add_hb_contact(i,i+2,iturn3_sent_local(1,i))
7666 do i=iturn4_start,iturn4_end
7667 c write (iout,*) "make contact list turn4",i," num_cont",
7669 call add_hb_contact(i,i+3,iturn4_sent_local(1,i))
7673 c write (iout,*) "make contact list longrange",i,ii," num_cont",
7675 do j=1,num_cont_hb(i)
7678 iproc=iint_sent_local(k,jjc,ii)
7679 c write (iout,*) "i",i," j",j," k",k," jjc",jjc," iproc",iproc
7680 if (iproc.gt.0) then
7681 ncont_sent(iproc)=ncont_sent(iproc)+1
7682 nn=ncont_sent(iproc)
7684 zapas(2,nn,iproc)=jjc
7685 zapas(3,nn,iproc)=facont_hb(j,i)
7686 zapas(4,nn,iproc)=ees0p(j,i)
7687 zapas(5,nn,iproc)=ees0m(j,i)
7688 zapas(6,nn,iproc)=gacont_hbr(1,j,i)
7689 zapas(7,nn,iproc)=gacont_hbr(2,j,i)
7690 zapas(8,nn,iproc)=gacont_hbr(3,j,i)
7691 zapas(9,nn,iproc)=gacontm_hb1(1,j,i)
7692 zapas(10,nn,iproc)=gacontm_hb1(2,j,i)
7693 zapas(11,nn,iproc)=gacontm_hb1(3,j,i)
7694 zapas(12,nn,iproc)=gacontp_hb1(1,j,i)
7695 zapas(13,nn,iproc)=gacontp_hb1(2,j,i)
7696 zapas(14,nn,iproc)=gacontp_hb1(3,j,i)
7697 zapas(15,nn,iproc)=gacontm_hb2(1,j,i)
7698 zapas(16,nn,iproc)=gacontm_hb2(2,j,i)
7699 zapas(17,nn,iproc)=gacontm_hb2(3,j,i)
7700 zapas(18,nn,iproc)=gacontp_hb2(1,j,i)
7701 zapas(19,nn,iproc)=gacontp_hb2(2,j,i)
7702 zapas(20,nn,iproc)=gacontp_hb2(3,j,i)
7703 zapas(21,nn,iproc)=gacontm_hb3(1,j,i)
7704 zapas(22,nn,iproc)=gacontm_hb3(2,j,i)
7705 zapas(23,nn,iproc)=gacontm_hb3(3,j,i)
7706 zapas(24,nn,iproc)=gacontp_hb3(1,j,i)
7707 zapas(25,nn,iproc)=gacontp_hb3(2,j,i)
7708 zapas(26,nn,iproc)=gacontp_hb3(3,j,i)
7715 & "Numbers of contacts to be sent to other processors",
7716 & (ncont_sent(i),i=1,ntask_cont_to)
7717 write (iout,*) "Contacts sent"
7718 do ii=1,ntask_cont_to
7720 iproc=itask_cont_to(ii)
7721 write (iout,*) nn," contacts to processor",iproc,
7722 & " of CONT_TO_COMM group"
7724 write(iout,'(2f5.0,4f10.5)')(zapas(j,i,ii),j=1,5)
7732 CorrelID1=nfgtasks+fg_rank+1
7734 C Receive the numbers of needed contacts from other processors
7735 do ii=1,ntask_cont_from
7736 iproc=itask_cont_from(ii)
7738 call MPI_Irecv(ncont_recv(ii),1,MPI_INTEGER,iproc,CorrelType,
7739 & FG_COMM,req(ireq),IERR)
7741 c write (iout,*) "IRECV ended"
7743 C Send the number of contacts needed by other processors
7744 do ii=1,ntask_cont_to
7745 iproc=itask_cont_to(ii)
7747 call MPI_Isend(ncont_sent(ii),1,MPI_INTEGER,iproc,CorrelType,
7748 & FG_COMM,req(ireq),IERR)
7750 c write (iout,*) "ISEND ended"
7751 c write (iout,*) "number of requests (nn)",ireq
7754 & call MPI_Waitall(ireq,req,status_array,ierr)
7756 c & "Numbers of contacts to be received from other processors",
7757 c & (ncont_recv(i),i=1,ntask_cont_from)
7761 do ii=1,ntask_cont_from
7762 iproc=itask_cont_from(ii)
7764 c write (iout,*) "Receiving",nn," contacts from processor",iproc,
7765 c & " of CONT_TO_COMM group"
7769 call MPI_Irecv(zapas_recv(1,1,ii),nn*max_dim,
7770 & MPI_DOUBLE_PRECISION,iproc,CorrelType1,FG_COMM,req(ireq),IERR)
7771 c write (iout,*) "ireq,req",ireq,req(ireq)
7774 C Send the contacts to processors that need them
7775 do ii=1,ntask_cont_to
7776 iproc=itask_cont_to(ii)
7778 c write (iout,*) nn," contacts to processor",iproc,
7779 c & " of CONT_TO_COMM group"
7782 call MPI_Isend(zapas(1,1,ii),nn*max_dim,MPI_DOUBLE_PRECISION,
7783 & iproc,CorrelType1,FG_COMM,req(ireq),IERR)
7784 c write (iout,*) "ireq,req",ireq,req(ireq)
7786 c write(iout,'(2f5.0,4f10.5)')(zapas(j,i,ii),j=1,5)
7790 c write (iout,*) "number of requests (contacts)",ireq
7791 c write (iout,*) "req",(req(i),i=1,4)
7794 & call MPI_Waitall(ireq,req,status_array,ierr)
7795 do iii=1,ntask_cont_from
7796 iproc=itask_cont_from(iii)
7799 write (iout,*) "Received",nn," contacts from processor",iproc,
7800 & " of CONT_FROM_COMM group"
7803 write(iout,'(2f5.0,4f10.5)')(zapas_recv(j,i,iii),j=1,5)
7808 ii=zapas_recv(1,i,iii)
7809 c Flag the received contacts to prevent double-counting
7810 jj=-zapas_recv(2,i,iii)
7811 c write (iout,*) "iii",iii," i",i," ii",ii," jj",jj
7813 nnn=num_cont_hb(ii)+1
7816 facont_hb(nnn,ii)=zapas_recv(3,i,iii)
7817 ees0p(nnn,ii)=zapas_recv(4,i,iii)
7818 ees0m(nnn,ii)=zapas_recv(5,i,iii)
7819 gacont_hbr(1,nnn,ii)=zapas_recv(6,i,iii)
7820 gacont_hbr(2,nnn,ii)=zapas_recv(7,i,iii)
7821 gacont_hbr(3,nnn,ii)=zapas_recv(8,i,iii)
7822 gacontm_hb1(1,nnn,ii)=zapas_recv(9,i,iii)
7823 gacontm_hb1(2,nnn,ii)=zapas_recv(10,i,iii)
7824 gacontm_hb1(3,nnn,ii)=zapas_recv(11,i,iii)
7825 gacontp_hb1(1,nnn,ii)=zapas_recv(12,i,iii)
7826 gacontp_hb1(2,nnn,ii)=zapas_recv(13,i,iii)
7827 gacontp_hb1(3,nnn,ii)=zapas_recv(14,i,iii)
7828 gacontm_hb2(1,nnn,ii)=zapas_recv(15,i,iii)
7829 gacontm_hb2(2,nnn,ii)=zapas_recv(16,i,iii)
7830 gacontm_hb2(3,nnn,ii)=zapas_recv(17,i,iii)
7831 gacontp_hb2(1,nnn,ii)=zapas_recv(18,i,iii)
7832 gacontp_hb2(2,nnn,ii)=zapas_recv(19,i,iii)
7833 gacontp_hb2(3,nnn,ii)=zapas_recv(20,i,iii)
7834 gacontm_hb3(1,nnn,ii)=zapas_recv(21,i,iii)
7835 gacontm_hb3(2,nnn,ii)=zapas_recv(22,i,iii)
7836 gacontm_hb3(3,nnn,ii)=zapas_recv(23,i,iii)
7837 gacontp_hb3(1,nnn,ii)=zapas_recv(24,i,iii)
7838 gacontp_hb3(2,nnn,ii)=zapas_recv(25,i,iii)
7839 gacontp_hb3(3,nnn,ii)=zapas_recv(26,i,iii)
7844 write (iout,'(a)') 'Contact function values after receive:'
7846 write (iout,'(2i3,50(1x,i3,f5.2))')
7847 & i,num_cont_hb(i),(jcont_hb(j,i),facont_hb(j,i),
7848 & j=1,num_cont_hb(i))
7855 write (iout,'(a)') 'Contact function values:'
7857 write (iout,'(2i3,50(1x,i3,f5.2))')
7858 & i,num_cont_hb(i),(jcont_hb(j,i),facont_hb(j,i),
7859 & j=1,num_cont_hb(i))
7863 C Remove the loop below after debugging !!!
7870 C Calculate the local-electrostatic correlation terms
7871 do i=min0(iatel_s,iturn4_start),max0(iatel_e,iturn3_end)
7873 num_conti=num_cont_hb(i)
7874 num_conti1=num_cont_hb(i+1)
7881 c write (iout,*) 'i=',i,' j=',j,' i1=',i1,' j1=',j1,
7882 c & ' jj=',jj,' kk=',kk
7883 if ((j.gt.0 .and. j1.gt.0 .or. j.gt.0 .and. j1.lt.0
7884 & .or. j.lt.0 .and. j1.gt.0) .and.
7885 & (jp1.eq.jp+1 .or. jp1.eq.jp-1)) then
7886 C Contacts I-J and (I+1)-(J+1) or (I+1)-(J-1) occur simultaneously.
7887 C The system gains extra energy.
7888 ecorr=ecorr+ehbcorr(i,jp,i+1,jp1,jj,kk,0.72D0,0.32D0)
7889 if (energy_dec) write (iout,'(a6,2i5,0pf7.3)')
7890 & 'ecorrh',i,j,ehbcorr(i,j,i+1,j1,jj,kk,0.72D0,0.32D0)
7892 else if (j1.eq.j) then
7893 C Contacts I-J and I-(J+1) occur simultaneously.
7894 C The system loses extra energy.
7895 c ecorr=ecorr+ehbcorr(i,j,i+1,j,jj,kk,0.60D0,-0.40D0)
7900 c write (iout,*) 'i=',i,' j=',j,' i1=',i1,' j1=',j1,
7901 c & ' jj=',jj,' kk=',kk
7903 C Contacts I-J and (I+1)-J occur simultaneously.
7904 C The system loses extra energy.
7905 c ecorr=ecorr+ehbcorr(i,j,i,j+1,jj,kk,0.60D0,-0.40D0)
7912 c------------------------------------------------------------------------------
7913 subroutine add_hb_contact(ii,jj,itask)
7914 implicit real*8 (a-h,o-z)
7915 include "DIMENSIONS"
7916 include "COMMON.IOUNITS"
7919 parameter (max_cont=maxconts)
7920 parameter (max_dim=26)
7921 include "COMMON.CONTACTS"
7922 double precision zapas(max_dim,maxconts,max_fg_procs),
7923 & zapas_recv(max_dim,maxconts,max_fg_procs)
7924 common /przechowalnia/ zapas
7925 integer i,j,ii,jj,iproc,itask(4),nn
7926 c write (iout,*) "itask",itask
7929 if (iproc.gt.0) then
7930 do j=1,num_cont_hb(ii)
7932 c write (iout,*) "i",ii," j",jj," jjc",jjc
7934 ncont_sent(iproc)=ncont_sent(iproc)+1
7935 nn=ncont_sent(iproc)
7936 zapas(1,nn,iproc)=ii
7937 zapas(2,nn,iproc)=jjc
7938 zapas(3,nn,iproc)=facont_hb(j,ii)
7939 zapas(4,nn,iproc)=ees0p(j,ii)
7940 zapas(5,nn,iproc)=ees0m(j,ii)
7941 zapas(6,nn,iproc)=gacont_hbr(1,j,ii)
7942 zapas(7,nn,iproc)=gacont_hbr(2,j,ii)
7943 zapas(8,nn,iproc)=gacont_hbr(3,j,ii)
7944 zapas(9,nn,iproc)=gacontm_hb1(1,j,ii)
7945 zapas(10,nn,iproc)=gacontm_hb1(2,j,ii)
7946 zapas(11,nn,iproc)=gacontm_hb1(3,j,ii)
7947 zapas(12,nn,iproc)=gacontp_hb1(1,j,ii)
7948 zapas(13,nn,iproc)=gacontp_hb1(2,j,ii)
7949 zapas(14,nn,iproc)=gacontp_hb1(3,j,ii)
7950 zapas(15,nn,iproc)=gacontm_hb2(1,j,ii)
7951 zapas(16,nn,iproc)=gacontm_hb2(2,j,ii)
7952 zapas(17,nn,iproc)=gacontm_hb2(3,j,ii)
7953 zapas(18,nn,iproc)=gacontp_hb2(1,j,ii)
7954 zapas(19,nn,iproc)=gacontp_hb2(2,j,ii)
7955 zapas(20,nn,iproc)=gacontp_hb2(3,j,ii)
7956 zapas(21,nn,iproc)=gacontm_hb3(1,j,ii)
7957 zapas(22,nn,iproc)=gacontm_hb3(2,j,ii)
7958 zapas(23,nn,iproc)=gacontm_hb3(3,j,ii)
7959 zapas(24,nn,iproc)=gacontp_hb3(1,j,ii)
7960 zapas(25,nn,iproc)=gacontp_hb3(2,j,ii)
7961 zapas(26,nn,iproc)=gacontp_hb3(3,j,ii)
7969 c------------------------------------------------------------------------------
7970 subroutine multibody_eello(ecorr,ecorr5,ecorr6,eturn6,n_corr,
7972 C This subroutine calculates multi-body contributions to hydrogen-bonding
7973 implicit real*8 (a-h,o-z)
7974 include 'DIMENSIONS'
7975 include 'COMMON.IOUNITS'
7978 parameter (max_cont=maxconts)
7979 parameter (max_dim=70)
7980 integer source,CorrelType,CorrelID,CorrelType1,CorrelID1,Error
7981 double precision zapas(max_dim,maxconts,max_fg_procs),
7982 & zapas_recv(max_dim,maxconts,max_fg_procs)
7983 common /przechowalnia/ zapas
7984 integer status(MPI_STATUS_SIZE),req(maxconts*2),
7985 & status_array(MPI_STATUS_SIZE,maxconts*2)
7987 include 'COMMON.SETUP'
7988 include 'COMMON.FFIELD'
7989 include 'COMMON.DERIV'
7990 include 'COMMON.LOCAL'
7991 include 'COMMON.INTERACT'
7992 include 'COMMON.CONTACTS'
7993 include 'COMMON.CHAIN'
7994 include 'COMMON.CONTROL'
7995 include 'COMMON.SHIELD'
7996 double precision gx(3),gx1(3)
7997 integer num_cont_hb_old(maxres)
7999 double precision eello4,eello5,eelo6,eello_turn6
8000 external eello4,eello5,eello6,eello_turn6
8001 C Set lprn=.true. for debugging
8006 num_cont_hb_old(i)=num_cont_hb(i)
8010 if (nfgtasks.le.1) goto 30
8012 write (iout,'(a)') 'Contact function values before RECEIVE:'
8014 write (iout,'(2i3,50(1x,i2,f5.2))')
8015 & i,num_cont_hb(i),(jcont_hb(j,i),facont_hb(j,i),
8016 & j=1,num_cont_hb(i))
8020 do i=1,ntask_cont_from
8023 do i=1,ntask_cont_to
8026 c write (iout,*) "ntask_cont_from",ntask_cont_from," ntask_cont_to",
8028 C Make the list of contacts to send to send to other procesors
8029 do i=iturn3_start,iturn3_end
8030 c write (iout,*) "make contact list turn3",i," num_cont",
8032 call add_hb_contact_eello(i,i+2,iturn3_sent_local(1,i))
8034 do i=iturn4_start,iturn4_end
8035 c write (iout,*) "make contact list turn4",i," num_cont",
8037 call add_hb_contact_eello(i,i+3,iturn4_sent_local(1,i))
8041 c write (iout,*) "make contact list longrange",i,ii," num_cont",
8043 do j=1,num_cont_hb(i)
8046 iproc=iint_sent_local(k,jjc,ii)
8047 c write (iout,*) "i",i," j",j," k",k," jjc",jjc," iproc",iproc
8048 if (iproc.ne.0) then
8049 ncont_sent(iproc)=ncont_sent(iproc)+1
8050 nn=ncont_sent(iproc)
8052 zapas(2,nn,iproc)=jjc
8053 zapas(3,nn,iproc)=d_cont(j,i)
8057 zapas(ind,nn,iproc)=grij_hb_cont(kk,j,i)
8062 zapas(ind,nn,iproc)=a_chuj(ll,kk,j,i)
8070 zapas(ind,nn,iproc)=a_chuj_der(mm,ll,kk,jj,j,i)
8081 & "Numbers of contacts to be sent to other processors",
8082 & (ncont_sent(i),i=1,ntask_cont_to)
8083 write (iout,*) "Contacts sent"
8084 do ii=1,ntask_cont_to
8086 iproc=itask_cont_to(ii)
8087 write (iout,*) nn," contacts to processor",iproc,
8088 & " of CONT_TO_COMM group"
8090 write(iout,'(2f5.0,10f10.5)')(zapas(j,i,ii),j=1,10)
8098 CorrelID1=nfgtasks+fg_rank+1
8100 C Receive the numbers of needed contacts from other processors
8101 do ii=1,ntask_cont_from
8102 iproc=itask_cont_from(ii)
8104 call MPI_Irecv(ncont_recv(ii),1,MPI_INTEGER,iproc,CorrelType,
8105 & FG_COMM,req(ireq),IERR)
8107 c write (iout,*) "IRECV ended"
8109 C Send the number of contacts needed by other processors
8110 do ii=1,ntask_cont_to
8111 iproc=itask_cont_to(ii)
8113 call MPI_Isend(ncont_sent(ii),1,MPI_INTEGER,iproc,CorrelType,
8114 & FG_COMM,req(ireq),IERR)
8116 c write (iout,*) "ISEND ended"
8117 c write (iout,*) "number of requests (nn)",ireq
8120 & call MPI_Waitall(ireq,req,status_array,ierr)
8122 c & "Numbers of contacts to be received from other processors",
8123 c & (ncont_recv(i),i=1,ntask_cont_from)
8127 do ii=1,ntask_cont_from
8128 iproc=itask_cont_from(ii)
8130 c write (iout,*) "Receiving",nn," contacts from processor",iproc,
8131 c & " of CONT_TO_COMM group"
8135 call MPI_Irecv(zapas_recv(1,1,ii),nn*max_dim,
8136 & MPI_DOUBLE_PRECISION,iproc,CorrelType1,FG_COMM,req(ireq),IERR)
8137 c write (iout,*) "ireq,req",ireq,req(ireq)
8140 C Send the contacts to processors that need them
8141 do ii=1,ntask_cont_to
8142 iproc=itask_cont_to(ii)
8144 c write (iout,*) nn," contacts to processor",iproc,
8145 c & " of CONT_TO_COMM group"
8148 call MPI_Isend(zapas(1,1,ii),nn*max_dim,MPI_DOUBLE_PRECISION,
8149 & iproc,CorrelType1,FG_COMM,req(ireq),IERR)
8150 c write (iout,*) "ireq,req",ireq,req(ireq)
8152 c write(iout,'(2f5.0,4f10.5)')(zapas(j,i,ii),j=1,5)
8156 c write (iout,*) "number of requests (contacts)",ireq
8157 c write (iout,*) "req",(req(i),i=1,4)
8160 & call MPI_Waitall(ireq,req,status_array,ierr)
8161 do iii=1,ntask_cont_from
8162 iproc=itask_cont_from(iii)
8165 write (iout,*) "Received",nn," contacts from processor",iproc,
8166 & " of CONT_FROM_COMM group"
8169 write(iout,'(2f5.0,10f10.5)')(zapas_recv(j,i,iii),j=1,10)
8174 ii=zapas_recv(1,i,iii)
8175 c Flag the received contacts to prevent double-counting
8176 jj=-zapas_recv(2,i,iii)
8177 c write (iout,*) "iii",iii," i",i," ii",ii," jj",jj
8179 nnn=num_cont_hb(ii)+1
8182 d_cont(nnn,ii)=zapas_recv(3,i,iii)
8186 grij_hb_cont(kk,nnn,ii)=zapas_recv(ind,i,iii)
8191 a_chuj(ll,kk,nnn,ii)=zapas_recv(ind,i,iii)
8199 a_chuj_der(mm,ll,kk,jj,nnn,ii)=zapas_recv(ind,i,iii)
8208 write (iout,'(a)') 'Contact function values after receive:'
8210 write (iout,'(2i3,50(1x,i3,5f6.3))')
8211 & i,num_cont_hb(i),(jcont_hb(j,i),d_cont(j,i),
8212 & ((a_chuj(ll,kk,j,i),ll=1,2),kk=1,2),j=1,num_cont_hb(i))
8219 write (iout,'(a)') 'Contact function values:'
8221 write (iout,'(2i3,50(1x,i2,5f6.3))')
8222 & i,num_cont_hb(i),(jcont_hb(j,i),d_cont(j,i),
8223 & ((a_chuj(ll,kk,j,i),ll=1,2),kk=1,2),j=1,num_cont_hb(i))
8229 C Remove the loop below after debugging !!!
8236 C Calculate the dipole-dipole interaction energies
8237 if (wcorr6.gt.0.0d0 .or. wturn6.gt.0.0d0) then
8238 do i=iatel_s,iatel_e+1
8239 num_conti=num_cont_hb(i)
8248 C Calculate the local-electrostatic correlation terms
8249 c write (iout,*) "gradcorr5 in eello5 before loop"
8251 c write (iout,'(i5,3f10.5)')
8252 c & iii,(gradcorr5(jjj,iii),jjj=1,3)
8254 do i=min0(iatel_s,iturn4_start),max0(iatel_e+1,iturn3_end+1)
8255 c write (iout,*) "corr loop i",i
8257 num_conti=num_cont_hb(i)
8258 num_conti1=num_cont_hb(i+1)
8265 c write (iout,*) 'i=',i,' j=',j,' i1=',i1,' j1=',j1,
8266 c & ' jj=',jj,' kk=',kk
8267 c if (j1.eq.j+1 .or. j1.eq.j-1) then
8268 if ((j.gt.0 .and. j1.gt.0 .or. j.gt.0 .and. j1.lt.0
8269 & .or. j.lt.0 .and. j1.gt.0) .and.
8270 & (jp1.eq.jp+1 .or. jp1.eq.jp-1)) then
8271 C Contacts I-J and (I+1)-(J+1) or (I+1)-(J-1) occur simultaneously.
8272 C The system gains extra energy.
8274 sqd1=dsqrt(d_cont(jj,i))
8275 sqd2=dsqrt(d_cont(kk,i1))
8276 sred_geom = sqd1*sqd2
8277 IF (sred_geom.lt.cutoff_corr) THEN
8278 call gcont(sred_geom,r0_corr,1.0D0,delt_corr,
8280 cd write (iout,*) 'i=',i,' j=',jp,' i1=',i1,' j1=',jp1,
8281 cd & ' jj=',jj,' kk=',kk
8282 fac_prim1=0.5d0*sqd2/sqd1*fprimcont
8283 fac_prim2=0.5d0*sqd1/sqd2*fprimcont
8285 g_contij(l,1)=fac_prim1*grij_hb_cont(l,jj,i)
8286 g_contij(l,2)=fac_prim2*grij_hb_cont(l,kk,i1)
8289 cd write (iout,*) 'sred_geom=',sred_geom,
8290 cd & ' ekont=',ekont,' fprim=',fprimcont,
8291 cd & ' fac_prim1',fac_prim1,' fac_prim2',fac_prim2
8292 cd write (iout,*) "g_contij",g_contij
8293 cd write (iout,*) "grij_hb_cont i",grij_hb_cont(:,jj,i)
8294 cd write (iout,*) "grij_hb_cont i1",grij_hb_cont(:,jj,i1)
8295 call calc_eello(i,jp,i+1,jp1,jj,kk)
8296 if (wcorr4.gt.0.0d0)
8297 & ecorr=ecorr+eello4(i,jp,i+1,jp1,jj,kk)
8298 CC & *fac_shield(i)**2*fac_shield(j)**2
8299 if (energy_dec.and.wcorr4.gt.0.0d0)
8300 1 write (iout,'(a6,4i5,0pf7.3)')
8301 2 'ecorr4',i,j,i+1,j1,eello4(i,jp,i+1,jp1,jj,kk)
8302 c write (iout,*) "gradcorr5 before eello5"
8304 c write (iout,'(i5,3f10.5)')
8305 c & iii,(gradcorr5(jjj,iii),jjj=1,3)
8307 if (wcorr5.gt.0.0d0)
8308 & ecorr5=ecorr5+eello5(i,jp,i+1,jp1,jj,kk)
8309 c write (iout,*) "gradcorr5 after eello5"
8311 c write (iout,'(i5,3f10.5)')
8312 c & iii,(gradcorr5(jjj,iii),jjj=1,3)
8314 if (energy_dec.and.wcorr5.gt.0.0d0)
8315 1 write (iout,'(a6,4i5,0pf7.3)')
8316 2 'ecorr5',i,j,i+1,j1,eello5(i,jp,i+1,jp1,jj,kk)
8317 cd write(2,*)'wcorr6',wcorr6,' wturn6',wturn6
8318 cd write(2,*)'ijkl',i,jp,i+1,jp1
8319 if (wcorr6.gt.0.0d0 .and. (jp.ne.i+4 .or. jp1.ne.i+3
8320 & .or. wturn6.eq.0.0d0))then
8321 cd write (iout,*) '******ecorr6: i,j,i+1,j1',i,j,i+1,j1
8322 ecorr6=ecorr6+eello6(i,jp,i+1,jp1,jj,kk)
8323 if (energy_dec) write (iout,'(a6,4i5,0pf7.3)')
8324 1 'ecorr6',i,j,i+1,j1,eello6(i,jp,i+1,jp1,jj,kk)
8325 cd write (iout,*) 'ecorr',ecorr,' ecorr5=',ecorr5,
8326 cd & 'ecorr6=',ecorr6
8327 cd write (iout,'(4e15.5)') sred_geom,
8328 cd & dabs(eello4(i,jp,i+1,jp1,jj,kk)),
8329 cd & dabs(eello5(i,jp,i+1,jp1,jj,kk)),
8330 cd & dabs(eello6(i,jp,i+1,jp1,jj,kk))
8331 else if (wturn6.gt.0.0d0
8332 & .and. (jp.eq.i+4 .and. jp1.eq.i+3)) then
8333 cd write (iout,*) '******eturn6: i,j,i+1,j1',i,jip,i+1,jp1
8334 eturn6=eturn6+eello_turn6(i,jj,kk)
8335 if (energy_dec) write (iout,'(a6,4i5,0pf7.3)')
8336 1 'eturn6',i,j,i+1,j1,eello_turn6(i,jj,kk)
8337 cd write (2,*) 'multibody_eello:eturn6',eturn6
8346 num_cont_hb(i)=num_cont_hb_old(i)
8348 c write (iout,*) "gradcorr5 in eello5"
8350 c write (iout,'(i5,3f10.5)')
8351 c & iii,(gradcorr5(jjj,iii),jjj=1,3)
8355 c------------------------------------------------------------------------------
8356 subroutine add_hb_contact_eello(ii,jj,itask)
8357 implicit real*8 (a-h,o-z)
8358 include "DIMENSIONS"
8359 include "COMMON.IOUNITS"
8362 parameter (max_cont=maxconts)
8363 parameter (max_dim=70)
8364 include "COMMON.CONTACTS"
8365 double precision zapas(max_dim,maxconts,max_fg_procs),
8366 & zapas_recv(max_dim,maxconts,max_fg_procs)
8367 common /przechowalnia/ zapas
8368 integer i,j,ii,jj,iproc,itask(4),nn
8369 c write (iout,*) "itask",itask
8372 if (iproc.gt.0) then
8373 do j=1,num_cont_hb(ii)
8375 c write (iout,*) "send turns i",ii," j",jj," jjc",jjc
8377 ncont_sent(iproc)=ncont_sent(iproc)+1
8378 nn=ncont_sent(iproc)
8379 zapas(1,nn,iproc)=ii
8380 zapas(2,nn,iproc)=jjc
8381 zapas(3,nn,iproc)=d_cont(j,ii)
8385 zapas(ind,nn,iproc)=grij_hb_cont(kk,j,ii)
8390 zapas(ind,nn,iproc)=a_chuj(ll,kk,j,ii)
8398 zapas(ind,nn,iproc)=a_chuj_der(mm,ll,kk,jj,j,ii)
8410 c------------------------------------------------------------------------------
8411 double precision function ehbcorr(i,j,k,l,jj,kk,coeffp,coeffm)
8412 implicit real*8 (a-h,o-z)
8413 include 'DIMENSIONS'
8414 include 'COMMON.IOUNITS'
8415 include 'COMMON.DERIV'
8416 include 'COMMON.INTERACT'
8417 include 'COMMON.CONTACTS'
8418 include 'COMMON.SHIELD'
8419 include 'COMMON.CONTROL'
8420 double precision gx(3),gx1(3)
8423 C print *,"wchodze",fac_shield(i),shield_mode
8431 ees=-(coeffp*ees0pij*ees0pkl+coeffm*ees0mij*ees0mkl)
8433 C & fac_shield(i)**2*fac_shield(j)**2
8434 cd ees=-(coeffp*ees0pkl+coeffm*ees0mkl)
8435 C Following 4 lines for diagnostics.
8440 c write (iout,'(2(a,2i3,a,f10.5,a,2f10.5),a,f10.5,a,$)')
8441 c & 'Contacts ',i,j,
8442 c & ' eij',eij,' eesij',ees0pij,ees0mij,' and ',k,l
8443 c & ,' fcont ',ekl,' eeskl',ees0pkl,ees0mkl,' energy=',ekont*ees,
8445 C Calculate the multi-body contribution to energy.
8446 c ecorr=ecorr+ekont*ees
8447 C Calculate multi-body contributions to the gradient.
8448 coeffpees0pij=coeffp*ees0pij
8449 coeffmees0mij=coeffm*ees0mij
8450 coeffpees0pkl=coeffp*ees0pkl
8451 coeffmees0mkl=coeffm*ees0mkl
8453 cgrad ghalfi=ees*ekl*gacont_hbr(ll,jj,i)
8454 gradcorr(ll,i)=gradcorr(ll,i)!+0.5d0*ghalfi
8455 & -ekont*(coeffpees0pkl*gacontp_hb1(ll,jj,i)+
8456 & coeffmees0mkl*gacontm_hb1(ll,jj,i))
8457 gradcorr(ll,j)=gradcorr(ll,j)!+0.5d0*ghalfi
8458 & -ekont*(coeffpees0pkl*gacontp_hb2(ll,jj,i)+
8459 & coeffmees0mkl*gacontm_hb2(ll,jj,i))
8460 cgrad ghalfk=ees*eij*gacont_hbr(ll,kk,k)
8461 gradcorr(ll,k)=gradcorr(ll,k)!+0.5d0*ghalfk
8462 & -ekont*(coeffpees0pij*gacontp_hb1(ll,kk,k)+
8463 & coeffmees0mij*gacontm_hb1(ll,kk,k))
8464 gradcorr(ll,l)=gradcorr(ll,l)!+0.5d0*ghalfk
8465 & -ekont*(coeffpees0pij*gacontp_hb2(ll,kk,k)+
8466 & coeffmees0mij*gacontm_hb2(ll,kk,k))
8467 gradlongij=ees*ekl*gacont_hbr(ll,jj,i)-
8468 & ekont*(coeffpees0pkl*gacontp_hb3(ll,jj,i)+
8469 & coeffmees0mkl*gacontm_hb3(ll,jj,i))
8470 gradcorr_long(ll,j)=gradcorr_long(ll,j)+gradlongij
8471 gradcorr_long(ll,i)=gradcorr_long(ll,i)-gradlongij
8472 gradlongkl=ees*eij*gacont_hbr(ll,kk,k)-
8473 & ekont*(coeffpees0pij*gacontp_hb3(ll,kk,k)+
8474 & coeffmees0mij*gacontm_hb3(ll,kk,k))
8475 gradcorr_long(ll,l)=gradcorr_long(ll,l)+gradlongkl
8476 gradcorr_long(ll,k)=gradcorr_long(ll,k)-gradlongkl
8477 c write (iout,'(2f10.5,2x,$)') gradlongij,gradlongkl
8482 cgrad gradcorr(ll,m)=gradcorr(ll,m)+
8483 cgrad & ees*ekl*gacont_hbr(ll,jj,i)-
8484 cgrad & ekont*(coeffp*ees0pkl*gacontp_hb3(ll,jj,i)+
8485 cgrad & coeffm*ees0mkl*gacontm_hb3(ll,jj,i))
8490 cgrad gradcorr(ll,m)=gradcorr(ll,m)+
8491 cgrad & ees*eij*gacont_hbr(ll,kk,k)-
8492 cgrad & ekont*(coeffp*ees0pij*gacontp_hb3(ll,kk,k)+
8493 cgrad & coeffm*ees0mij*gacontm_hb3(ll,kk,k))
8496 c write (iout,*) "ehbcorr",ekont*ees
8497 C print *,ekont,ees,i,k
8499 C now gradient over shielding
8501 if (shield_mode.gt.0) then
8504 C print *,i,j,fac_shield(i),fac_shield(j),
8505 C &fac_shield(k),fac_shield(l)
8506 if ((fac_shield(i).gt.0).and.(fac_shield(j).gt.0).and.
8507 & (fac_shield(k).gt.0).and.(fac_shield(l).gt.0)) then
8508 do ilist=1,ishield_list(i)
8509 iresshield=shield_list(ilist,i)
8511 rlocshield=grad_shield_side(m,ilist,i)*ehbcorr/fac_shield(i)
8513 gshieldx_ec(m,iresshield)=gshieldx_ec(m,iresshield)+
8515 & +grad_shield_loc(m,ilist,i)*ehbcorr/fac_shield(i)
8516 gshieldc_ec(m,iresshield-1)=gshieldc_ec(m,iresshield-1)
8520 do ilist=1,ishield_list(j)
8521 iresshield=shield_list(ilist,j)
8523 rlocshield=grad_shield_side(m,ilist,j)*ehbcorr/fac_shield(j)
8525 gshieldx_ec(m,iresshield)=gshieldx_ec(m,iresshield)+
8527 & +grad_shield_loc(m,ilist,j)*ehbcorr/fac_shield(j)
8528 gshieldc_ec(m,iresshield-1)=gshieldc_ec(m,iresshield-1)
8533 do ilist=1,ishield_list(k)
8534 iresshield=shield_list(ilist,k)
8536 rlocshield=grad_shield_side(m,ilist,k)*ehbcorr/fac_shield(k)
8538 gshieldx_ec(m,iresshield)=gshieldx_ec(m,iresshield)+
8540 & +grad_shield_loc(m,ilist,k)*ehbcorr/fac_shield(k)
8541 gshieldc_ec(m,iresshield-1)=gshieldc_ec(m,iresshield-1)
8545 do ilist=1,ishield_list(l)
8546 iresshield=shield_list(ilist,l)
8548 rlocshield=grad_shield_side(m,ilist,l)*ehbcorr/fac_shield(l)
8550 gshieldx_ec(m,iresshield)=gshieldx_ec(m,iresshield)+
8552 & +grad_shield_loc(m,ilist,l)*ehbcorr/fac_shield(l)
8553 gshieldc_ec(m,iresshield-1)=gshieldc_ec(m,iresshield-1)
8557 C print *,gshieldx(m,iresshield)
8559 gshieldc_ec(m,i)=gshieldc_ec(m,i)+
8560 & grad_shield(m,i)*ehbcorr/fac_shield(i)
8561 gshieldc_ec(m,j)=gshieldc_ec(m,j)+
8562 & grad_shield(m,j)*ehbcorr/fac_shield(j)
8563 gshieldc_ec(m,i-1)=gshieldc_ec(m,i-1)+
8564 & grad_shield(m,i)*ehbcorr/fac_shield(i)
8565 gshieldc_ec(m,j-1)=gshieldc_ec(m,j-1)+
8566 & grad_shield(m,j)*ehbcorr/fac_shield(j)
8568 gshieldc_ec(m,k)=gshieldc_ec(m,k)+
8569 & grad_shield(m,k)*ehbcorr/fac_shield(k)
8570 gshieldc_ec(m,l)=gshieldc_ec(m,l)+
8571 & grad_shield(m,l)*ehbcorr/fac_shield(l)
8572 gshieldc_ec(m,k-1)=gshieldc_ec(m,k-1)+
8573 & grad_shield(m,k)*ehbcorr/fac_shield(k)
8574 gshieldc_ec(m,l-1)=gshieldc_ec(m,l-1)+
8575 & grad_shield(m,l)*ehbcorr/fac_shield(l)
8583 C---------------------------------------------------------------------------
8584 subroutine dipole(i,j,jj)
8585 implicit real*8 (a-h,o-z)
8586 include 'DIMENSIONS'
8587 include 'COMMON.IOUNITS'
8588 include 'COMMON.CHAIN'
8589 include 'COMMON.FFIELD'
8590 include 'COMMON.DERIV'
8591 include 'COMMON.INTERACT'
8592 include 'COMMON.CONTACTS'
8593 include 'COMMON.TORSION'
8594 include 'COMMON.VAR'
8595 include 'COMMON.GEO'
8596 dimension dipi(2,2),dipj(2,2),dipderi(2),dipderj(2),auxvec(2),
8598 iti1 = itortyp(itype(i+1))
8599 if (j.lt.nres-1) then
8600 itj1 = itortyp(itype(j+1))
8605 dipi(iii,1)=Ub2(iii,i)
8606 dipderi(iii)=Ub2der(iii,i)
8607 dipi(iii,2)=b1(iii,i+1)
8608 dipj(iii,1)=Ub2(iii,j)
8609 dipderj(iii)=Ub2der(iii,j)
8610 dipj(iii,2)=b1(iii,j+1)
8614 call matvec2(a_chuj(1,1,jj,i),dipj(1,iii),auxvec(1))
8617 dip(kkk,jj,i)=scalar2(dipi(1,jjj),auxvec(1))
8624 call matvec2(a_chuj_der(1,1,lll,kkk,jj,i),dipj(1,iii),
8628 dipderx(lll,kkk,mmm,jj,i)=scalar2(dipi(1,jjj),auxvec(1))
8633 call transpose2(a_chuj(1,1,jj,i),auxmat(1,1))
8634 call matvec2(auxmat(1,1),dipderi(1),auxvec(1))
8636 dipderg(iii,jj,i)=scalar2(auxvec(1),dipj(1,iii))
8638 call matvec2(a_chuj(1,1,jj,i),dipderj(1),auxvec(1))
8640 dipderg(iii+2,jj,i)=scalar2(auxvec(1),dipi(1,iii))
8645 C---------------------------------------------------------------------------
8646 subroutine calc_eello(i,j,k,l,jj,kk)
8648 C This subroutine computes matrices and vectors needed to calculate
8649 C the fourth-, fifth-, and sixth-order local-electrostatic terms.
8651 implicit real*8 (a-h,o-z)
8652 include 'DIMENSIONS'
8653 include 'COMMON.IOUNITS'
8654 include 'COMMON.CHAIN'
8655 include 'COMMON.DERIV'
8656 include 'COMMON.INTERACT'
8657 include 'COMMON.CONTACTS'
8658 include 'COMMON.TORSION'
8659 include 'COMMON.VAR'
8660 include 'COMMON.GEO'
8661 include 'COMMON.FFIELD'
8662 double precision aa1(2,2),aa2(2,2),aa1t(2,2),aa2t(2,2),
8663 & aa1tder(2,2,3,5),aa2tder(2,2,3,5),auxmat(2,2)
8666 cd write (iout,*) 'calc_eello: i=',i,' j=',j,' k=',k,' l=',l,
8667 cd & ' jj=',jj,' kk=',kk
8668 cd if (i.ne.2 .or. j.ne.4 .or. k.ne.3 .or. l.ne.5) return
8669 cd write (iout,*) "a_chujij",((a_chuj(iii,jjj,jj,i),iii=1,2),jjj=1,2)
8670 cd write (iout,*) "a_chujkl",((a_chuj(iii,jjj,kk,k),iii=1,2),jjj=1,2)
8673 aa1(iii,jjj)=a_chuj(iii,jjj,jj,i)
8674 aa2(iii,jjj)=a_chuj(iii,jjj,kk,k)
8677 call transpose2(aa1(1,1),aa1t(1,1))
8678 call transpose2(aa2(1,1),aa2t(1,1))
8681 call transpose2(a_chuj_der(1,1,lll,kkk,jj,i),
8682 & aa1tder(1,1,lll,kkk))
8683 call transpose2(a_chuj_der(1,1,lll,kkk,kk,k),
8684 & aa2tder(1,1,lll,kkk))
8688 C parallel orientation of the two CA-CA-CA frames.
8690 iti=itortyp(itype(i))
8694 itk1=itortyp(itype(k+1))
8695 itj=itortyp(itype(j))
8696 if (l.lt.nres-1) then
8697 itl1=itortyp(itype(l+1))
8701 C A1 kernel(j+1) A2T
8703 cd write (iout,'(3f10.5,5x,3f10.5)')
8704 cd & (EUg(iii,jjj,k),jjj=1,2),(EUg(iii,jjj,l),jjj=1,2)
8706 call kernel(aa1(1,1),aa2t(1,1),a_chuj_der(1,1,1,1,jj,i),
8707 & aa2tder(1,1,1,1),1,.false.,EUg(1,1,l),EUgder(1,1,l),
8708 & AEA(1,1,1),AEAderg(1,1,1),AEAderx(1,1,1,1,1,1))
8709 C Following matrices are needed only for 6-th order cumulants
8710 IF (wcorr6.gt.0.0d0) THEN
8711 call kernel(aa1(1,1),aa2t(1,1),a_chuj_der(1,1,1,1,jj,i),
8712 & aa2tder(1,1,1,1),1,.false.,EUgC(1,1,l),EUgCder(1,1,l),
8713 & AECA(1,1,1),AECAderg(1,1,1),AECAderx(1,1,1,1,1,1))
8714 call kernel(aa1(1,1),aa2t(1,1),a_chuj_der(1,1,1,1,jj,i),
8715 & aa2tder(1,1,1,1),2,.false.,Ug2DtEUg(1,1,l),
8716 & Ug2DtEUgder(1,1,1,l),ADtEA(1,1,1),ADtEAderg(1,1,1,1),
8717 & ADtEAderx(1,1,1,1,1,1))
8719 call kernel(aa1(1,1),aa2t(1,1),a_chuj_der(1,1,1,1,jj,i),
8720 & aa2tder(1,1,1,1),2,.false.,DtUg2EUg(1,1,l),
8721 & DtUg2EUgder(1,1,1,l),ADtEA1(1,1,1),ADtEA1derg(1,1,1,1),
8722 & ADtEA1derx(1,1,1,1,1,1))
8724 C End 6-th order cumulants
8727 cd write (2,*) 'In calc_eello6'
8729 cd write (2,*) 'iii=',iii
8731 cd write (2,*) 'kkk=',kkk
8733 cd write (2,'(3(2f10.5),5x)')
8734 cd & ((ADtEA1derx(jjj,mmm,lll,kkk,iii,1),mmm=1,2),lll=1,3)
8739 call transpose2(EUgder(1,1,k),auxmat(1,1))
8740 call matmat2(auxmat(1,1),AEA(1,1,1),EAEAderg(1,1,1,1))
8741 call transpose2(EUg(1,1,k),auxmat(1,1))
8742 call matmat2(auxmat(1,1),AEA(1,1,1),EAEA(1,1,1))
8743 call matmat2(auxmat(1,1),AEAderg(1,1,1),EAEAderg(1,1,2,1))
8747 call matmat2(auxmat(1,1),AEAderx(1,1,lll,kkk,iii,1),
8748 & EAEAderx(1,1,lll,kkk,iii,1))
8752 C A1T kernel(i+1) A2
8753 call kernel(aa1t(1,1),aa2(1,1),aa1tder(1,1,1,1),
8754 & a_chuj_der(1,1,1,1,kk,k),1,.false.,EUg(1,1,k),EUgder(1,1,k),
8755 & AEA(1,1,2),AEAderg(1,1,2),AEAderx(1,1,1,1,1,2))
8756 C Following matrices are needed only for 6-th order cumulants
8757 IF (wcorr6.gt.0.0d0) THEN
8758 call kernel(aa1t(1,1),aa2(1,1),aa1tder(1,1,1,1),
8759 & a_chuj_der(1,1,1,1,kk,k),1,.false.,EUgC(1,1,k),EUgCder(1,1,k),
8760 & AECA(1,1,2),AECAderg(1,1,2),AECAderx(1,1,1,1,1,2))
8761 call kernel(aa1t(1,1),aa2(1,1),aa1tder(1,1,1,1),
8762 & a_chuj_der(1,1,1,1,kk,k),2,.false.,Ug2DtEUg(1,1,k),
8763 & Ug2DtEUgder(1,1,1,k),ADtEA(1,1,2),ADtEAderg(1,1,1,2),
8764 & ADtEAderx(1,1,1,1,1,2))
8765 call kernel(aa1t(1,1),aa2(1,1),aa1tder(1,1,1,1),
8766 & a_chuj_der(1,1,1,1,kk,k),2,.false.,DtUg2EUg(1,1,k),
8767 & DtUg2EUgder(1,1,1,k),ADtEA1(1,1,2),ADtEA1derg(1,1,1,2),
8768 & ADtEA1derx(1,1,1,1,1,2))
8770 C End 6-th order cumulants
8771 call transpose2(EUgder(1,1,l),auxmat(1,1))
8772 call matmat2(auxmat(1,1),AEA(1,1,2),EAEAderg(1,1,1,2))
8773 call transpose2(EUg(1,1,l),auxmat(1,1))
8774 call matmat2(auxmat(1,1),AEA(1,1,2),EAEA(1,1,2))
8775 call matmat2(auxmat(1,1),AEAderg(1,1,2),EAEAderg(1,1,2,2))
8779 call matmat2(auxmat(1,1),AEAderx(1,1,lll,kkk,iii,2),
8780 & EAEAderx(1,1,lll,kkk,iii,2))
8785 C Calculate the vectors and their derivatives in virtual-bond dihedral angles.
8786 C They are needed only when the fifth- or the sixth-order cumulants are
8788 IF (wcorr5.gt.0.0d0 .or. wcorr6.gt.0.0d0) THEN
8789 call transpose2(AEA(1,1,1),auxmat(1,1))
8790 call matvec2(auxmat(1,1),b1(1,i),AEAb1(1,1,1))
8791 call matvec2(auxmat(1,1),Ub2(1,i),AEAb2(1,1,1))
8792 call matvec2(auxmat(1,1),Ub2der(1,i),AEAb2derg(1,2,1,1))
8793 call transpose2(AEAderg(1,1,1),auxmat(1,1))
8794 call matvec2(auxmat(1,1),b1(1,i),AEAb1derg(1,1,1))
8795 call matvec2(auxmat(1,1),Ub2(1,i),AEAb2derg(1,1,1,1))
8796 call matvec2(AEA(1,1,1),b1(1,k+1),AEAb1(1,2,1))
8797 call matvec2(AEAderg(1,1,1),b1(1,k+1),AEAb1derg(1,2,1))
8798 call matvec2(AEA(1,1,1),Ub2(1,k+1),AEAb2(1,2,1))
8799 call matvec2(AEAderg(1,1,1),Ub2(1,k+1),AEAb2derg(1,1,2,1))
8800 call matvec2(AEA(1,1,1),Ub2der(1,k+1),AEAb2derg(1,2,2,1))
8801 call transpose2(AEA(1,1,2),auxmat(1,1))
8802 call matvec2(auxmat(1,1),b1(1,j),AEAb1(1,1,2))
8803 call matvec2(auxmat(1,1),Ub2(1,j),AEAb2(1,1,2))
8804 call matvec2(auxmat(1,1),Ub2der(1,j),AEAb2derg(1,2,1,2))
8805 call transpose2(AEAderg(1,1,2),auxmat(1,1))
8806 call matvec2(auxmat(1,1),b1(1,j),AEAb1derg(1,1,2))
8807 call matvec2(auxmat(1,1),Ub2(1,j),AEAb2derg(1,1,1,2))
8808 call matvec2(AEA(1,1,2),b1(1,l+1),AEAb1(1,2,2))
8809 call matvec2(AEAderg(1,1,2),b1(1,l+1),AEAb1derg(1,2,2))
8810 call matvec2(AEA(1,1,2),Ub2(1,l+1),AEAb2(1,2,2))
8811 call matvec2(AEAderg(1,1,2),Ub2(1,l+1),AEAb2derg(1,1,2,2))
8812 call matvec2(AEA(1,1,2),Ub2der(1,l+1),AEAb2derg(1,2,2,2))
8813 C Calculate the Cartesian derivatives of the vectors.
8817 call transpose2(AEAderx(1,1,lll,kkk,iii,1),auxmat(1,1))
8818 call matvec2(auxmat(1,1),b1(1,i),
8819 & AEAb1derx(1,lll,kkk,iii,1,1))
8820 call matvec2(auxmat(1,1),Ub2(1,i),
8821 & AEAb2derx(1,lll,kkk,iii,1,1))
8822 call matvec2(AEAderx(1,1,lll,kkk,iii,1),b1(1,k+1),
8823 & AEAb1derx(1,lll,kkk,iii,2,1))
8824 call matvec2(AEAderx(1,1,lll,kkk,iii,1),Ub2(1,k+1),
8825 & AEAb2derx(1,lll,kkk,iii,2,1))
8826 call transpose2(AEAderx(1,1,lll,kkk,iii,2),auxmat(1,1))
8827 call matvec2(auxmat(1,1),b1(1,j),
8828 & AEAb1derx(1,lll,kkk,iii,1,2))
8829 call matvec2(auxmat(1,1),Ub2(1,j),
8830 & AEAb2derx(1,lll,kkk,iii,1,2))
8831 call matvec2(AEAderx(1,1,lll,kkk,iii,2),b1(1,l+1),
8832 & AEAb1derx(1,lll,kkk,iii,2,2))
8833 call matvec2(AEAderx(1,1,lll,kkk,iii,2),Ub2(1,l+1),
8834 & AEAb2derx(1,lll,kkk,iii,2,2))
8841 C Antiparallel orientation of the two CA-CA-CA frames.
8843 iti=itortyp(itype(i))
8847 itk1=itortyp(itype(k+1))
8848 itl=itortyp(itype(l))
8849 itj=itortyp(itype(j))
8850 if (j.lt.nres-1) then
8851 itj1=itortyp(itype(j+1))
8855 C A2 kernel(j-1)T A1T
8856 call kernel(aa1(1,1),aa2t(1,1),a_chuj_der(1,1,1,1,jj,i),
8857 & aa2tder(1,1,1,1),1,.true.,EUg(1,1,j),EUgder(1,1,j),
8858 & AEA(1,1,1),AEAderg(1,1,1),AEAderx(1,1,1,1,1,1))
8859 C Following matrices are needed only for 6-th order cumulants
8860 IF (wcorr6.gt.0.0d0 .or. (wturn6.gt.0.0d0 .and.
8861 & j.eq.i+4 .and. l.eq.i+3)) THEN
8862 call kernel(aa1(1,1),aa2t(1,1),a_chuj_der(1,1,1,1,jj,i),
8863 & aa2tder(1,1,1,1),1,.true.,EUgC(1,1,j),EUgCder(1,1,j),
8864 & AECA(1,1,1),AECAderg(1,1,1),AECAderx(1,1,1,1,1,1))
8865 call kernel(aa2(1,1),aa2t(1,1),a_chuj_der(1,1,1,1,jj,i),
8866 & aa2tder(1,1,1,1),2,.true.,Ug2DtEUg(1,1,j),
8867 & Ug2DtEUgder(1,1,1,j),ADtEA(1,1,1),ADtEAderg(1,1,1,1),
8868 & ADtEAderx(1,1,1,1,1,1))
8869 call kernel(aa1(1,1),aa2t(1,1),a_chuj_der(1,1,1,1,jj,i),
8870 & aa2tder(1,1,1,1),2,.true.,DtUg2EUg(1,1,j),
8871 & DtUg2EUgder(1,1,1,j),ADtEA1(1,1,1),ADtEA1derg(1,1,1,1),
8872 & ADtEA1derx(1,1,1,1,1,1))
8874 C End 6-th order cumulants
8875 call transpose2(EUgder(1,1,k),auxmat(1,1))
8876 call matmat2(auxmat(1,1),AEA(1,1,1),EAEAderg(1,1,1,1))
8877 call transpose2(EUg(1,1,k),auxmat(1,1))
8878 call matmat2(auxmat(1,1),AEA(1,1,1),EAEA(1,1,1))
8879 call matmat2(auxmat(1,1),AEAderg(1,1,1),EAEAderg(1,1,2,1))
8883 call matmat2(auxmat(1,1),AEAderx(1,1,lll,kkk,iii,1),
8884 & EAEAderx(1,1,lll,kkk,iii,1))
8888 C A2T kernel(i+1)T A1
8889 call kernel(aa2t(1,1),aa1(1,1),aa2tder(1,1,1,1),
8890 & a_chuj_der(1,1,1,1,jj,i),1,.true.,EUg(1,1,k),EUgder(1,1,k),
8891 & AEA(1,1,2),AEAderg(1,1,2),AEAderx(1,1,1,1,1,2))
8892 C Following matrices are needed only for 6-th order cumulants
8893 IF (wcorr6.gt.0.0d0 .or. (wturn6.gt.0.0d0 .and.
8894 & j.eq.i+4 .and. l.eq.i+3)) THEN
8895 call kernel(aa2t(1,1),aa1(1,1),aa2tder(1,1,1,1),
8896 & a_chuj_der(1,1,1,1,jj,i),1,.true.,EUgC(1,1,k),EUgCder(1,1,k),
8897 & AECA(1,1,2),AECAderg(1,1,2),AECAderx(1,1,1,1,1,2))
8898 call kernel(aa2t(1,1),aa1(1,1),aa2tder(1,1,1,1),
8899 & a_chuj_der(1,1,1,1,jj,i),2,.true.,Ug2DtEUg(1,1,k),
8900 & Ug2DtEUgder(1,1,1,k),ADtEA(1,1,2),ADtEAderg(1,1,1,2),
8901 & ADtEAderx(1,1,1,1,1,2))
8902 call kernel(aa2t(1,1),aa1(1,1),aa2tder(1,1,1,1),
8903 & a_chuj_der(1,1,1,1,jj,i),2,.true.,DtUg2EUg(1,1,k),
8904 & DtUg2EUgder(1,1,1,k),ADtEA1(1,1,2),ADtEA1derg(1,1,1,2),
8905 & ADtEA1derx(1,1,1,1,1,2))
8907 C End 6-th order cumulants
8908 call transpose2(EUgder(1,1,j),auxmat(1,1))
8909 call matmat2(auxmat(1,1),AEA(1,1,1),EAEAderg(1,1,2,2))
8910 call transpose2(EUg(1,1,j),auxmat(1,1))
8911 call matmat2(auxmat(1,1),AEA(1,1,2),EAEA(1,1,2))
8912 call matmat2(auxmat(1,1),AEAderg(1,1,2),EAEAderg(1,1,2,2))
8916 call matmat2(auxmat(1,1),AEAderx(1,1,lll,kkk,iii,2),
8917 & EAEAderx(1,1,lll,kkk,iii,2))
8922 C Calculate the vectors and their derivatives in virtual-bond dihedral angles.
8923 C They are needed only when the fifth- or the sixth-order cumulants are
8925 IF (wcorr5.gt.0.0d0 .or. wcorr6.gt.0.0d0 .or.
8926 & (wturn6.gt.0.0d0 .and. j.eq.i+4 .and. l.eq.i+3)) THEN
8927 call transpose2(AEA(1,1,1),auxmat(1,1))
8928 call matvec2(auxmat(1,1),b1(1,i),AEAb1(1,1,1))
8929 call matvec2(auxmat(1,1),Ub2(1,i),AEAb2(1,1,1))
8930 call matvec2(auxmat(1,1),Ub2der(1,i),AEAb2derg(1,2,1,1))
8931 call transpose2(AEAderg(1,1,1),auxmat(1,1))
8932 call matvec2(auxmat(1,1),b1(1,i),AEAb1derg(1,1,1))
8933 call matvec2(auxmat(1,1),Ub2(1,i),AEAb2derg(1,1,1,1))
8934 call matvec2(AEA(1,1,1),b1(1,k+1),AEAb1(1,2,1))
8935 call matvec2(AEAderg(1,1,1),b1(1,k+1),AEAb1derg(1,2,1))
8936 call matvec2(AEA(1,1,1),Ub2(1,k+1),AEAb2(1,2,1))
8937 call matvec2(AEAderg(1,1,1),Ub2(1,k+1),AEAb2derg(1,1,2,1))
8938 call matvec2(AEA(1,1,1),Ub2der(1,k+1),AEAb2derg(1,2,2,1))
8939 call transpose2(AEA(1,1,2),auxmat(1,1))
8940 call matvec2(auxmat(1,1),b1(1,j+1),AEAb1(1,1,2))
8941 call matvec2(auxmat(1,1),Ub2(1,l),AEAb2(1,1,2))
8942 call matvec2(auxmat(1,1),Ub2der(1,l),AEAb2derg(1,2,1,2))
8943 call transpose2(AEAderg(1,1,2),auxmat(1,1))
8944 call matvec2(auxmat(1,1),b1(1,l),AEAb1(1,1,2))
8945 call matvec2(auxmat(1,1),Ub2(1,l),AEAb2derg(1,1,1,2))
8946 call matvec2(AEA(1,1,2),b1(1,j+1),AEAb1(1,2,2))
8947 call matvec2(AEAderg(1,1,2),b1(1,j+1),AEAb1derg(1,2,2))
8948 call matvec2(AEA(1,1,2),Ub2(1,j),AEAb2(1,2,2))
8949 call matvec2(AEAderg(1,1,2),Ub2(1,j),AEAb2derg(1,1,2,2))
8950 call matvec2(AEA(1,1,2),Ub2der(1,j),AEAb2derg(1,2,2,2))
8951 C Calculate the Cartesian derivatives of the vectors.
8955 call transpose2(AEAderx(1,1,lll,kkk,iii,1),auxmat(1,1))
8956 call matvec2(auxmat(1,1),b1(1,i),
8957 & AEAb1derx(1,lll,kkk,iii,1,1))
8958 call matvec2(auxmat(1,1),Ub2(1,i),
8959 & AEAb2derx(1,lll,kkk,iii,1,1))
8960 call matvec2(AEAderx(1,1,lll,kkk,iii,1),b1(1,k+1),
8961 & AEAb1derx(1,lll,kkk,iii,2,1))
8962 call matvec2(AEAderx(1,1,lll,kkk,iii,1),Ub2(1,k+1),
8963 & AEAb2derx(1,lll,kkk,iii,2,1))
8964 call transpose2(AEAderx(1,1,lll,kkk,iii,2),auxmat(1,1))
8965 call matvec2(auxmat(1,1),b1(1,l),
8966 & AEAb1derx(1,lll,kkk,iii,1,2))
8967 call matvec2(auxmat(1,1),Ub2(1,l),
8968 & AEAb2derx(1,lll,kkk,iii,1,2))
8969 call matvec2(AEAderx(1,1,lll,kkk,iii,2),b1(1,j+1),
8970 & AEAb1derx(1,lll,kkk,iii,2,2))
8971 call matvec2(AEAderx(1,1,lll,kkk,iii,2),Ub2(1,j),
8972 & AEAb2derx(1,lll,kkk,iii,2,2))
8981 C---------------------------------------------------------------------------
8982 subroutine kernel(aa1,aa2t,aa1derx,aa2tderx,nderg,transp,
8983 & KK,KKderg,AKA,AKAderg,AKAderx)
8987 double precision aa1(2,2),aa2t(2,2),aa1derx(2,2,3,5),
8988 & aa2tderx(2,2,3,5),KK(2,2),KKderg(2,2,nderg),AKA(2,2),
8989 & AKAderg(2,2,nderg),AKAderx(2,2,3,5,2)
8994 call prodmat3(aa1(1,1),aa2t(1,1),KK(1,1),transp,AKA(1,1))
8996 call prodmat3(aa1(1,1),aa2t(1,1),KKderg(1,1,iii),transp,
8999 cd if (lprn) write (2,*) 'In kernel'
9001 cd if (lprn) write (2,*) 'kkk=',kkk
9003 call prodmat3(aa1derx(1,1,lll,kkk),aa2t(1,1),
9004 & KK(1,1),transp,AKAderx(1,1,lll,kkk,1))
9006 cd write (2,*) 'lll=',lll
9007 cd write (2,*) 'iii=1'
9009 cd write (2,'(3(2f10.5),5x)')
9010 cd & (AKAderx(jjj,mmm,lll,kkk,1),mmm=1,2)
9013 call prodmat3(aa1(1,1),aa2tderx(1,1,lll,kkk),
9014 & KK(1,1),transp,AKAderx(1,1,lll,kkk,2))
9016 cd write (2,*) 'lll=',lll
9017 cd write (2,*) 'iii=2'
9019 cd write (2,'(3(2f10.5),5x)')
9020 cd & (AKAderx(jjj,mmm,lll,kkk,2),mmm=1,2)
9027 C---------------------------------------------------------------------------
9028 double precision function eello4(i,j,k,l,jj,kk)
9029 implicit real*8 (a-h,o-z)
9030 include 'DIMENSIONS'
9031 include 'COMMON.IOUNITS'
9032 include 'COMMON.CHAIN'
9033 include 'COMMON.DERIV'
9034 include 'COMMON.INTERACT'
9035 include 'COMMON.CONTACTS'
9036 include 'COMMON.TORSION'
9037 include 'COMMON.VAR'
9038 include 'COMMON.GEO'
9039 double precision pizda(2,2),ggg1(3),ggg2(3)
9040 cd if (i.ne.1 .or. j.ne.5 .or. k.ne.2 .or.l.ne.4) then
9044 cd print *,'eello4:',i,j,k,l,jj,kk
9045 cd write (2,*) 'i',i,' j',j,' k',k,' l',l
9046 cd call checkint4(i,j,k,l,jj,kk,eel4_num)
9047 cold eij=facont_hb(jj,i)
9048 cold ekl=facont_hb(kk,k)
9050 eel4=-EAEA(1,1,1)-EAEA(2,2,1)
9051 cd eel41=-EAEA(1,1,2)-EAEA(2,2,2)
9052 gcorr_loc(k-1)=gcorr_loc(k-1)
9053 & -ekont*(EAEAderg(1,1,1,1)+EAEAderg(2,2,1,1))
9055 gcorr_loc(l-1)=gcorr_loc(l-1)
9056 & -ekont*(EAEAderg(1,1,2,1)+EAEAderg(2,2,2,1))
9058 gcorr_loc(j-1)=gcorr_loc(j-1)
9059 & -ekont*(EAEAderg(1,1,2,1)+EAEAderg(2,2,2,1))
9064 derx(lll,kkk,iii)=-EAEAderx(1,1,lll,kkk,iii,1)
9065 & -EAEAderx(2,2,lll,kkk,iii,1)
9066 cd derx(lll,kkk,iii)=0.0d0
9070 cd gcorr_loc(l-1)=0.0d0
9071 cd gcorr_loc(j-1)=0.0d0
9072 cd gcorr_loc(k-1)=0.0d0
9074 cd write (iout,*)'Contacts have occurred for peptide groups',
9075 cd & i,j,' fcont:',eij,' eij',' and ',k,l,
9076 cd & ' fcont ',ekl,' eel4=',eel4,' eel4_num',16*eel4_num
9077 if (j.lt.nres-1) then
9084 if (l.lt.nres-1) then
9092 cgrad ggg1(ll)=eel4*g_contij(ll,1)
9093 cgrad ggg2(ll)=eel4*g_contij(ll,2)
9094 glongij=eel4*g_contij(ll,1)+ekont*derx(ll,1,1)
9095 glongkl=eel4*g_contij(ll,2)+ekont*derx(ll,1,2)
9096 cgrad ghalf=0.5d0*ggg1(ll)
9097 gradcorr(ll,i)=gradcorr(ll,i)+ekont*derx(ll,2,1)
9098 gradcorr(ll,i+1)=gradcorr(ll,i+1)+ekont*derx(ll,3,1)
9099 gradcorr(ll,j)=gradcorr(ll,j)+ekont*derx(ll,4,1)
9100 gradcorr(ll,j1)=gradcorr(ll,j1)+ekont*derx(ll,5,1)
9101 gradcorr_long(ll,j)=gradcorr_long(ll,j)+glongij
9102 gradcorr_long(ll,i)=gradcorr_long(ll,i)-glongij
9103 cgrad ghalf=0.5d0*ggg2(ll)
9104 gradcorr(ll,k)=gradcorr(ll,k)+ekont*derx(ll,2,2)
9105 gradcorr(ll,k+1)=gradcorr(ll,k+1)+ekont*derx(ll,3,2)
9106 gradcorr(ll,l)=gradcorr(ll,l)+ekont*derx(ll,4,2)
9107 gradcorr(ll,l1)=gradcorr(ll,l1)+ekont*derx(ll,5,2)
9108 gradcorr_long(ll,l)=gradcorr_long(ll,l)+glongkl
9109 gradcorr_long(ll,k)=gradcorr_long(ll,k)-glongkl
9113 cgrad gradcorr(ll,m)=gradcorr(ll,m)+ggg1(ll)
9118 cgrad gradcorr(ll,m)=gradcorr(ll,m)+ggg2(ll)
9123 cgrad gradcorr(ll,m)=gradcorr(ll,m)+ekont*derx(ll,1,1)
9128 cgrad gradcorr(ll,m)=gradcorr(ll,m)+ekont*derx(ll,1,2)
9132 cd write (2,*) iii,gcorr_loc(iii)
9135 cd write (2,*) 'ekont',ekont
9136 cd write (iout,*) 'eello4',ekont*eel4
9139 C---------------------------------------------------------------------------
9140 double precision function eello5(i,j,k,l,jj,kk)
9141 implicit real*8 (a-h,o-z)
9142 include 'DIMENSIONS'
9143 include 'COMMON.IOUNITS'
9144 include 'COMMON.CHAIN'
9145 include 'COMMON.DERIV'
9146 include 'COMMON.INTERACT'
9147 include 'COMMON.CONTACTS'
9148 include 'COMMON.TORSION'
9149 include 'COMMON.VAR'
9150 include 'COMMON.GEO'
9151 double precision pizda(2,2),auxmat(2,2),auxmat1(2,2),vv(2)
9152 double precision ggg1(3),ggg2(3)
9153 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
9158 C /l\ / \ \ / \ / \ / C
9159 C / \ / \ \ / \ / \ / C
9160 C j| o |l1 | o | o| o | | o |o C
9161 C \ |/k\| |/ \| / |/ \| |/ \| C
9162 C \i/ \ / \ / / \ / \ C
9164 C (I) (II) (III) (IV) C
9166 C eello5_1 eello5_2 eello5_3 eello5_4 C
9168 C Antiparallel chains C
9171 C /j\ / \ \ / \ / \ / C
9172 C / \ / \ \ / \ / \ / C
9173 C j1| o |l | o | o| o | | o |o C
9174 C \ |/k\| |/ \| / |/ \| |/ \| C
9175 C \i/ \ / \ / / \ / \ C
9177 C (I) (II) (III) (IV) C
9179 C eello5_1 eello5_2 eello5_3 eello5_4 C
9181 C o denotes a local interaction, vertical lines an electrostatic interaction. C
9183 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
9184 cd if (i.ne.2 .or. j.ne.6 .or. k.ne.3 .or. l.ne.5) then
9189 cd & 'EELLO5: Contacts have occurred for peptide groups',i,j,
9191 itk=itortyp(itype(k))
9192 itl=itortyp(itype(l))
9193 itj=itortyp(itype(j))
9198 cd call checkint5(i,j,k,l,jj,kk,eel5_1_num,eel5_2_num,
9199 cd & eel5_3_num,eel5_4_num)
9203 derx(lll,kkk,iii)=0.0d0
9207 cd eij=facont_hb(jj,i)
9208 cd ekl=facont_hb(kk,k)
9210 cd write (iout,*)'Contacts have occurred for peptide groups',
9211 cd & i,j,' fcont:',eij,' eij',' and ',k,l
9213 C Contribution from the graph I.
9214 cd write (2,*) 'AEA ',AEA(1,1,1),AEA(2,1,1),AEA(1,2,1),AEA(2,2,1)
9215 cd write (2,*) 'AEAb2',AEAb2(1,1,1),AEAb2(2,1,1)
9216 call transpose2(EUg(1,1,k),auxmat(1,1))
9217 call matmat2(AEA(1,1,1),auxmat(1,1),pizda(1,1))
9218 vv(1)=pizda(1,1)-pizda(2,2)
9219 vv(2)=pizda(1,2)+pizda(2,1)
9220 eello5_1=scalar2(AEAb2(1,1,1),Ub2(1,k))
9221 & +0.5d0*scalar2(vv(1),Dtobr2(1,i))
9222 C Explicit gradient in virtual-dihedral angles.
9223 if (i.gt.1) g_corr5_loc(i-1)=g_corr5_loc(i-1)
9224 & +ekont*(scalar2(AEAb2derg(1,2,1,1),Ub2(1,k))
9225 & +0.5d0*scalar2(vv(1),Dtobr2der(1,i)))
9226 call transpose2(EUgder(1,1,k),auxmat1(1,1))
9227 call matmat2(AEA(1,1,1),auxmat1(1,1),pizda(1,1))
9228 vv(1)=pizda(1,1)-pizda(2,2)
9229 vv(2)=pizda(1,2)+pizda(2,1)
9230 g_corr5_loc(k-1)=g_corr5_loc(k-1)
9231 & +ekont*(scalar2(AEAb2(1,1,1),Ub2der(1,k))
9232 & +0.5d0*scalar2(vv(1),Dtobr2(1,i)))
9233 call matmat2(AEAderg(1,1,1),auxmat(1,1),pizda(1,1))
9234 vv(1)=pizda(1,1)-pizda(2,2)
9235 vv(2)=pizda(1,2)+pizda(2,1)
9237 if (l.lt.nres-1) g_corr5_loc(l-1)=g_corr5_loc(l-1)
9238 & +ekont*(scalar2(AEAb2derg(1,1,1,1),Ub2(1,k))
9239 & +0.5d0*scalar2(vv(1),Dtobr2(1,i)))
9241 if (j.lt.nres-1) g_corr5_loc(j-1)=g_corr5_loc(j-1)
9242 & +ekont*(scalar2(AEAb2derg(1,1,1,1),Ub2(1,k))
9243 & +0.5d0*scalar2(vv(1),Dtobr2(1,i)))
9245 C Cartesian gradient
9249 call matmat2(AEAderx(1,1,lll,kkk,iii,1),auxmat(1,1),
9251 vv(1)=pizda(1,1)-pizda(2,2)
9252 vv(2)=pizda(1,2)+pizda(2,1)
9253 derx(lll,kkk,iii)=derx(lll,kkk,iii)
9254 & +scalar2(AEAb2derx(1,lll,kkk,iii,1,1),Ub2(1,k))
9255 & +0.5d0*scalar2(vv(1),Dtobr2(1,i))
9261 C Contribution from graph II
9262 call transpose2(EE(1,1,itk),auxmat(1,1))
9263 call matmat2(auxmat(1,1),AEA(1,1,1),pizda(1,1))
9264 vv(1)=pizda(1,1)+pizda(2,2)
9265 vv(2)=pizda(2,1)-pizda(1,2)
9266 eello5_2=scalar2(AEAb1(1,2,1),b1(1,k))
9267 & -0.5d0*scalar2(vv(1),Ctobr(1,k))
9268 C Explicit gradient in virtual-dihedral angles.
9269 g_corr5_loc(k-1)=g_corr5_loc(k-1)
9270 & -0.5d0*ekont*scalar2(vv(1),Ctobrder(1,k))
9271 call matmat2(auxmat(1,1),AEAderg(1,1,1),pizda(1,1))
9272 vv(1)=pizda(1,1)+pizda(2,2)
9273 vv(2)=pizda(2,1)-pizda(1,2)
9275 g_corr5_loc(l-1)=g_corr5_loc(l-1)
9276 & +ekont*(scalar2(AEAb1derg(1,2,1),b1(1,k))
9277 & -0.5d0*scalar2(vv(1),Ctobr(1,k)))
9279 g_corr5_loc(j-1)=g_corr5_loc(j-1)
9280 & +ekont*(scalar2(AEAb1derg(1,2,1),b1(1,k))
9281 & -0.5d0*scalar2(vv(1),Ctobr(1,k)))
9283 C Cartesian gradient
9287 call matmat2(auxmat(1,1),AEAderx(1,1,lll,kkk,iii,1),
9289 vv(1)=pizda(1,1)+pizda(2,2)
9290 vv(2)=pizda(2,1)-pizda(1,2)
9291 derx(lll,kkk,iii)=derx(lll,kkk,iii)
9292 & +scalar2(AEAb1derx(1,lll,kkk,iii,2,1),b1(1,k))
9293 & -0.5d0*scalar2(vv(1),Ctobr(1,k))
9301 C Parallel orientation
9302 C Contribution from graph III
9303 call transpose2(EUg(1,1,l),auxmat(1,1))
9304 call matmat2(AEA(1,1,2),auxmat(1,1),pizda(1,1))
9305 vv(1)=pizda(1,1)-pizda(2,2)
9306 vv(2)=pizda(1,2)+pizda(2,1)
9307 eello5_3=scalar2(AEAb2(1,1,2),Ub2(1,l))
9308 & +0.5d0*scalar2(vv(1),Dtobr2(1,j))
9309 C Explicit gradient in virtual-dihedral angles.
9310 g_corr5_loc(j-1)=g_corr5_loc(j-1)
9311 & +ekont*(scalar2(AEAb2derg(1,2,1,2),Ub2(1,l))
9312 & +0.5d0*scalar2(vv(1),Dtobr2der(1,j)))
9313 call matmat2(AEAderg(1,1,2),auxmat(1,1),pizda(1,1))
9314 vv(1)=pizda(1,1)-pizda(2,2)
9315 vv(2)=pizda(1,2)+pizda(2,1)
9316 g_corr5_loc(k-1)=g_corr5_loc(k-1)
9317 & +ekont*(scalar2(AEAb2derg(1,1,1,2),Ub2(1,l))
9318 & +0.5d0*scalar2(vv(1),Dtobr2(1,j)))
9319 call transpose2(EUgder(1,1,l),auxmat1(1,1))
9320 call matmat2(AEA(1,1,2),auxmat1(1,1),pizda(1,1))
9321 vv(1)=pizda(1,1)-pizda(2,2)
9322 vv(2)=pizda(1,2)+pizda(2,1)
9323 g_corr5_loc(l-1)=g_corr5_loc(l-1)
9324 & +ekont*(scalar2(AEAb2(1,1,2),Ub2der(1,l))
9325 & +0.5d0*scalar2(vv(1),Dtobr2(1,j)))
9326 C Cartesian gradient
9330 call matmat2(AEAderx(1,1,lll,kkk,iii,2),auxmat(1,1),
9332 vv(1)=pizda(1,1)-pizda(2,2)
9333 vv(2)=pizda(1,2)+pizda(2,1)
9334 derx(lll,kkk,iii)=derx(lll,kkk,iii)
9335 & +scalar2(AEAb2derx(1,lll,kkk,iii,1,2),Ub2(1,l))
9336 & +0.5d0*scalar2(vv(1),Dtobr2(1,j))
9341 C Contribution from graph IV
9343 call transpose2(EE(1,1,itl),auxmat(1,1))
9344 call matmat2(auxmat(1,1),AEA(1,1,2),pizda(1,1))
9345 vv(1)=pizda(1,1)+pizda(2,2)
9346 vv(2)=pizda(2,1)-pizda(1,2)
9347 eello5_4=scalar2(AEAb1(1,2,2),b1(1,l))
9348 & -0.5d0*scalar2(vv(1),Ctobr(1,l))
9349 C Explicit gradient in virtual-dihedral angles.
9350 g_corr5_loc(l-1)=g_corr5_loc(l-1)
9351 & -0.5d0*ekont*scalar2(vv(1),Ctobrder(1,l))
9352 call matmat2(auxmat(1,1),AEAderg(1,1,2),pizda(1,1))
9353 vv(1)=pizda(1,1)+pizda(2,2)
9354 vv(2)=pizda(2,1)-pizda(1,2)
9355 g_corr5_loc(k-1)=g_corr5_loc(k-1)
9356 & +ekont*(scalar2(AEAb1derg(1,2,2),b1(1,l))
9357 & -0.5d0*scalar2(vv(1),Ctobr(1,l)))
9358 C Cartesian gradient
9362 call matmat2(auxmat(1,1),AEAderx(1,1,lll,kkk,iii,2),
9364 vv(1)=pizda(1,1)+pizda(2,2)
9365 vv(2)=pizda(2,1)-pizda(1,2)
9366 derx(lll,kkk,iii)=derx(lll,kkk,iii)
9367 & +scalar2(AEAb1derx(1,lll,kkk,iii,2,2),b1(1,l))
9368 & -0.5d0*scalar2(vv(1),Ctobr(1,l))
9373 C Antiparallel orientation
9374 C Contribution from graph III
9376 call transpose2(EUg(1,1,j),auxmat(1,1))
9377 call matmat2(AEA(1,1,2),auxmat(1,1),pizda(1,1))
9378 vv(1)=pizda(1,1)-pizda(2,2)
9379 vv(2)=pizda(1,2)+pizda(2,1)
9380 eello5_3=scalar2(AEAb2(1,1,2),Ub2(1,j))
9381 & +0.5d0*scalar2(vv(1),Dtobr2(1,l))
9382 C Explicit gradient in virtual-dihedral angles.
9383 g_corr5_loc(l-1)=g_corr5_loc(l-1)
9384 & +ekont*(scalar2(AEAb2derg(1,2,1,2),Ub2(1,j))
9385 & +0.5d0*scalar2(vv(1),Dtobr2der(1,l)))
9386 call matmat2(AEAderg(1,1,2),auxmat(1,1),pizda(1,1))
9387 vv(1)=pizda(1,1)-pizda(2,2)
9388 vv(2)=pizda(1,2)+pizda(2,1)
9389 g_corr5_loc(k-1)=g_corr5_loc(k-1)
9390 & +ekont*(scalar2(AEAb2derg(1,1,1,2),Ub2(1,j))
9391 & +0.5d0*scalar2(vv(1),Dtobr2(1,l)))
9392 call transpose2(EUgder(1,1,j),auxmat1(1,1))
9393 call matmat2(AEA(1,1,2),auxmat1(1,1),pizda(1,1))
9394 vv(1)=pizda(1,1)-pizda(2,2)
9395 vv(2)=pizda(1,2)+pizda(2,1)
9396 g_corr5_loc(j-1)=g_corr5_loc(j-1)
9397 & +ekont*(scalar2(AEAb2(1,1,2),Ub2der(1,j))
9398 & +0.5d0*scalar2(vv(1),Dtobr2(1,l)))
9399 C Cartesian gradient
9403 call matmat2(AEAderx(1,1,lll,kkk,iii,2),auxmat(1,1),
9405 vv(1)=pizda(1,1)-pizda(2,2)
9406 vv(2)=pizda(1,2)+pizda(2,1)
9407 derx(lll,kkk,3-iii)=derx(lll,kkk,3-iii)
9408 & +scalar2(AEAb2derx(1,lll,kkk,iii,1,2),Ub2(1,j))
9409 & +0.5d0*scalar2(vv(1),Dtobr2(1,l))
9414 C Contribution from graph IV
9416 call transpose2(EE(1,1,itj),auxmat(1,1))
9417 call matmat2(auxmat(1,1),AEA(1,1,2),pizda(1,1))
9418 vv(1)=pizda(1,1)+pizda(2,2)
9419 vv(2)=pizda(2,1)-pizda(1,2)
9420 eello5_4=scalar2(AEAb1(1,2,2),b1(1,j))
9421 & -0.5d0*scalar2(vv(1),Ctobr(1,j))
9422 C Explicit gradient in virtual-dihedral angles.
9423 g_corr5_loc(j-1)=g_corr5_loc(j-1)
9424 & -0.5d0*ekont*scalar2(vv(1),Ctobrder(1,j))
9425 call matmat2(auxmat(1,1),AEAderg(1,1,2),pizda(1,1))
9426 vv(1)=pizda(1,1)+pizda(2,2)
9427 vv(2)=pizda(2,1)-pizda(1,2)
9428 g_corr5_loc(k-1)=g_corr5_loc(k-1)
9429 & +ekont*(scalar2(AEAb1derg(1,2,2),b1(1,j))
9430 & -0.5d0*scalar2(vv(1),Ctobr(1,j)))
9431 C Cartesian gradient
9435 call matmat2(auxmat(1,1),AEAderx(1,1,lll,kkk,iii,2),
9437 vv(1)=pizda(1,1)+pizda(2,2)
9438 vv(2)=pizda(2,1)-pizda(1,2)
9439 derx(lll,kkk,3-iii)=derx(lll,kkk,3-iii)
9440 & +scalar2(AEAb1derx(1,lll,kkk,iii,2,2),b1(1,j))
9441 & -0.5d0*scalar2(vv(1),Ctobr(1,j))
9447 eel5=eello5_1+eello5_2+eello5_3+eello5_4
9448 cd if (i.eq.2 .and. j.eq.8 .and. k.eq.3 .and. l.eq.7) then
9449 cd write (2,*) 'ijkl',i,j,k,l
9450 cd write (2,*) 'eello5_1',eello5_1,' eello5_2',eello5_2,
9451 cd & ' eello5_3',eello5_3,' eello5_4',eello5_4
9453 cd write(iout,*) 'eello5_1',eello5_1,' eel5_1_num',16*eel5_1_num
9454 cd write(iout,*) 'eello5_2',eello5_2,' eel5_2_num',16*eel5_2_num
9455 cd write(iout,*) 'eello5_3',eello5_3,' eel5_3_num',16*eel5_3_num
9456 cd write(iout,*) 'eello5_4',eello5_4,' eel5_4_num',16*eel5_4_num
9457 if (j.lt.nres-1) then
9464 if (l.lt.nres-1) then
9474 cd write (2,*) 'eij',eij,' ekl',ekl,' ekont',ekont
9475 C 2/11/08 AL Gradients over DC's connecting interacting sites will be
9476 C summed up outside the subrouine as for the other subroutines
9477 C handling long-range interactions. The old code is commented out
9478 C with "cgrad" to keep track of changes.
9480 cgrad ggg1(ll)=eel5*g_contij(ll,1)
9481 cgrad ggg2(ll)=eel5*g_contij(ll,2)
9482 gradcorr5ij=eel5*g_contij(ll,1)+ekont*derx(ll,1,1)
9483 gradcorr5kl=eel5*g_contij(ll,2)+ekont*derx(ll,1,2)
9484 c write (iout,'(a,3i3,a,5f8.3,2i3,a,5f8.3,a,f8.3)')
9485 c & "ecorr5",ll,i,j," derx",derx(ll,2,1),derx(ll,3,1),derx(ll,4,1),
9486 c & derx(ll,5,1),k,l," derx",derx(ll,2,2),derx(ll,3,2),
9487 c & derx(ll,4,2),derx(ll,5,2)," ekont",ekont
9488 c write (iout,'(a,3i3,a,3f8.3,2i3,a,3f8.3)')
9489 c & "ecorr5",ll,i,j," gradcorr5",g_contij(ll,1),derx(ll,1,1),
9491 c & k,l," gradcorr5",g_contij(ll,2),derx(ll,1,2),gradcorr5kl
9492 cold ghalf=0.5d0*eel5*ekl*gacont_hbr(ll,jj,i)
9493 cgrad ghalf=0.5d0*ggg1(ll)
9495 gradcorr5(ll,i)=gradcorr5(ll,i)+ekont*derx(ll,2,1)
9496 gradcorr5(ll,i+1)=gradcorr5(ll,i+1)+ekont*derx(ll,3,1)
9497 gradcorr5(ll,j)=gradcorr5(ll,j)+ekont*derx(ll,4,1)
9498 gradcorr5(ll,j1)=gradcorr5(ll,j1)+ekont*derx(ll,5,1)
9499 gradcorr5_long(ll,j)=gradcorr5_long(ll,j)+gradcorr5ij
9500 gradcorr5_long(ll,i)=gradcorr5_long(ll,i)-gradcorr5ij
9501 cold ghalf=0.5d0*eel5*eij*gacont_hbr(ll,kk,k)
9502 cgrad ghalf=0.5d0*ggg2(ll)
9504 gradcorr5(ll,k)=gradcorr5(ll,k)+ekont*derx(ll,2,2)
9505 gradcorr5(ll,k+1)=gradcorr5(ll,k+1)+ekont*derx(ll,3,2)
9506 gradcorr5(ll,l)=gradcorr5(ll,l)+ekont*derx(ll,4,2)
9507 gradcorr5(ll,l1)=gradcorr5(ll,l1)+ekont*derx(ll,5,2)
9508 gradcorr5_long(ll,l)=gradcorr5_long(ll,l)+gradcorr5kl
9509 gradcorr5_long(ll,k)=gradcorr5_long(ll,k)-gradcorr5kl
9514 cold gradcorr5(ll,m)=gradcorr5(ll,m)+eel5*ekl*gacont_hbr(ll,jj,i)
9515 cgrad gradcorr5(ll,m)=gradcorr5(ll,m)+ggg1(ll)
9520 cold gradcorr5(ll,m)=gradcorr5(ll,m)+eel5*eij*gacont_hbr(ll,kk,k)
9521 cgrad gradcorr5(ll,m)=gradcorr5(ll,m)+ggg2(ll)
9527 cgrad gradcorr5(ll,m)=gradcorr5(ll,m)+ekont*derx(ll,1,1)
9532 cgrad gradcorr5(ll,m)=gradcorr5(ll,m)+ekont*derx(ll,1,2)
9536 cd write (2,*) iii,g_corr5_loc(iii)
9539 cd write (2,*) 'ekont',ekont
9540 cd write (iout,*) 'eello5',ekont*eel5
9543 c--------------------------------------------------------------------------
9544 double precision function eello6(i,j,k,l,jj,kk)
9545 implicit real*8 (a-h,o-z)
9546 include 'DIMENSIONS'
9547 include 'COMMON.IOUNITS'
9548 include 'COMMON.CHAIN'
9549 include 'COMMON.DERIV'
9550 include 'COMMON.INTERACT'
9551 include 'COMMON.CONTACTS'
9552 include 'COMMON.TORSION'
9553 include 'COMMON.VAR'
9554 include 'COMMON.GEO'
9555 include 'COMMON.FFIELD'
9556 double precision ggg1(3),ggg2(3)
9557 cd if (i.ne.1 .or. j.ne.3 .or. k.ne.2 .or. l.ne.4) then
9562 cd & 'EELLO6: Contacts have occurred for peptide groups',i,j,
9570 cd call checkint6(i,j,k,l,jj,kk,eel6_1_num,eel6_2_num,
9571 cd & eel6_3_num,eel6_4_num,eel6_5_num,eel6_6_num)
9575 derx(lll,kkk,iii)=0.0d0
9579 cd eij=facont_hb(jj,i)
9580 cd ekl=facont_hb(kk,k)
9586 eello6_1=eello6_graph1(i,j,k,l,1,.false.)
9587 eello6_2=eello6_graph1(j,i,l,k,2,.false.)
9588 eello6_3=eello6_graph2(i,j,k,l,jj,kk,.false.)
9589 eello6_4=eello6_graph4(i,j,k,l,jj,kk,1,.false.)
9590 eello6_5=eello6_graph4(j,i,l,k,jj,kk,2,.false.)
9591 eello6_6=eello6_graph3(i,j,k,l,jj,kk,.false.)
9593 eello6_1=eello6_graph1(i,j,k,l,1,.false.)
9594 eello6_2=eello6_graph1(l,k,j,i,2,.true.)
9595 eello6_3=eello6_graph2(i,l,k,j,jj,kk,.true.)
9596 eello6_4=eello6_graph4(i,j,k,l,jj,kk,1,.false.)
9597 if (wturn6.eq.0.0d0 .or. j.ne.i+4) then
9598 eello6_5=eello6_graph4(l,k,j,i,kk,jj,2,.true.)
9602 eello6_6=eello6_graph3(i,l,k,j,jj,kk,.true.)
9604 C If turn contributions are considered, they will be handled separately.
9605 eel6=eello6_1+eello6_2+eello6_3+eello6_4+eello6_5+eello6_6
9606 cd write(iout,*) 'eello6_1',eello6_1!,' eel6_1_num',16*eel6_1_num
9607 cd write(iout,*) 'eello6_2',eello6_2!,' eel6_2_num',16*eel6_2_num
9608 cd write(iout,*) 'eello6_3',eello6_3!,' eel6_3_num',16*eel6_3_num
9609 cd write(iout,*) 'eello6_4',eello6_4!,' eel6_4_num',16*eel6_4_num
9610 cd write(iout,*) 'eello6_5',eello6_5!,' eel6_5_num',16*eel6_5_num
9611 cd write(iout,*) 'eello6_6',eello6_6!,' eel6_6_num',16*eel6_6_num
9613 if (j.lt.nres-1) then
9620 if (l.lt.nres-1) then
9628 cgrad ggg1(ll)=eel6*g_contij(ll,1)
9629 cgrad ggg2(ll)=eel6*g_contij(ll,2)
9630 cold ghalf=0.5d0*eel6*ekl*gacont_hbr(ll,jj,i)
9631 cgrad ghalf=0.5d0*ggg1(ll)
9633 gradcorr6ij=eel6*g_contij(ll,1)+ekont*derx(ll,1,1)
9634 gradcorr6kl=eel6*g_contij(ll,2)+ekont*derx(ll,1,2)
9635 gradcorr6(ll,i)=gradcorr6(ll,i)+ekont*derx(ll,2,1)
9636 gradcorr6(ll,i+1)=gradcorr6(ll,i+1)+ekont*derx(ll,3,1)
9637 gradcorr6(ll,j)=gradcorr6(ll,j)+ekont*derx(ll,4,1)
9638 gradcorr6(ll,j1)=gradcorr6(ll,j1)+ekont*derx(ll,5,1)
9639 gradcorr6_long(ll,j)=gradcorr6_long(ll,j)+gradcorr6ij
9640 gradcorr6_long(ll,i)=gradcorr6_long(ll,i)-gradcorr6ij
9641 cgrad ghalf=0.5d0*ggg2(ll)
9642 cold ghalf=0.5d0*eel6*eij*gacont_hbr(ll,kk,k)
9644 gradcorr6(ll,k)=gradcorr6(ll,k)+ekont*derx(ll,2,2)
9645 gradcorr6(ll,k+1)=gradcorr6(ll,k+1)+ekont*derx(ll,3,2)
9646 gradcorr6(ll,l)=gradcorr6(ll,l)+ekont*derx(ll,4,2)
9647 gradcorr6(ll,l1)=gradcorr6(ll,l1)+ekont*derx(ll,5,2)
9648 gradcorr6_long(ll,l)=gradcorr6_long(ll,l)+gradcorr6kl
9649 gradcorr6_long(ll,k)=gradcorr6_long(ll,k)-gradcorr6kl
9654 cold gradcorr6(ll,m)=gradcorr6(ll,m)+eel6*ekl*gacont_hbr(ll,jj,i)
9655 cgrad gradcorr6(ll,m)=gradcorr6(ll,m)+ggg1(ll)
9660 cold gradcorr6(ll,m)=gradcorr6(ll,m)+eel6*eij*gacont_hbr(ll,kk,k)
9661 cgrad gradcorr6(ll,m)=gradcorr6(ll,m)+ggg2(ll)
9667 cgrad gradcorr6(ll,m)=gradcorr6(ll,m)+ekont*derx(ll,1,1)
9672 cgrad gradcorr6(ll,m)=gradcorr6(ll,m)+ekont*derx(ll,1,2)
9676 cd write (2,*) iii,g_corr6_loc(iii)
9679 cd write (2,*) 'ekont',ekont
9680 cd write (iout,*) 'eello6',ekont*eel6
9683 c--------------------------------------------------------------------------
9684 double precision function eello6_graph1(i,j,k,l,imat,swap)
9685 implicit real*8 (a-h,o-z)
9686 include 'DIMENSIONS'
9687 include 'COMMON.IOUNITS'
9688 include 'COMMON.CHAIN'
9689 include 'COMMON.DERIV'
9690 include 'COMMON.INTERACT'
9691 include 'COMMON.CONTACTS'
9692 include 'COMMON.TORSION'
9693 include 'COMMON.VAR'
9694 include 'COMMON.GEO'
9695 double precision vv(2),vv1(2),pizda(2,2),auxmat(2,2),pizda1(2,2)
9699 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
9701 C Parallel Antiparallel C
9707 C \ j|/k\| / \ |/k\|l / C
9712 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
9713 itk=itortyp(itype(k))
9714 s1= scalar2(AEAb1(1,2,imat),CUgb2(1,i))
9715 s2=-scalar2(AEAb2(1,1,imat),Ug2Db1t(1,k))
9716 s3= scalar2(AEAb2(1,1,imat),CUgb2(1,k))
9717 call transpose2(EUgC(1,1,k),auxmat(1,1))
9718 call matmat2(AEA(1,1,imat),auxmat(1,1),pizda1(1,1))
9719 vv1(1)=pizda1(1,1)-pizda1(2,2)
9720 vv1(2)=pizda1(1,2)+pizda1(2,1)
9721 s4=0.5d0*scalar2(vv1(1),Dtobr2(1,i))
9722 vv(1)=AEAb1(1,2,imat)*b1(1,k)-AEAb1(2,2,imat)*b1(2,k)
9723 vv(2)=AEAb1(1,2,imat)*b1(2,k)+AEAb1(2,2,imat)*b1(1,k)
9724 s5=scalar2(vv(1),Dtobr2(1,i))
9725 cd write (2,*) 's1',s1,' s2',s2,' s3',s3,' s4', s4,' s5',s5
9726 eello6_graph1=-0.5d0*(s1+s2+s3+s4+s5)
9727 if (i.gt.1) g_corr6_loc(i-1)=g_corr6_loc(i-1)
9728 & -0.5d0*ekont*(scalar2(AEAb1(1,2,imat),CUgb2der(1,i))
9729 & -scalar2(AEAb2derg(1,2,1,imat),Ug2Db1t(1,k))
9730 & +scalar2(AEAb2derg(1,2,1,imat),CUgb2(1,k))
9731 & +0.5d0*scalar2(vv1(1),Dtobr2der(1,i))
9732 & +scalar2(vv(1),Dtobr2der(1,i)))
9733 call matmat2(AEAderg(1,1,imat),auxmat(1,1),pizda1(1,1))
9734 vv1(1)=pizda1(1,1)-pizda1(2,2)
9735 vv1(2)=pizda1(1,2)+pizda1(2,1)
9736 vv(1)=AEAb1derg(1,2,imat)*b1(1,k)-AEAb1derg(2,2,imat)*b1(2,k)
9737 vv(2)=AEAb1derg(1,2,imat)*b1(2,k)+AEAb1derg(2,2,imat)*b1(1,k)
9739 g_corr6_loc(l-1)=g_corr6_loc(l-1)
9740 & +ekont*(-0.5d0*(scalar2(AEAb1derg(1,2,imat),CUgb2(1,i))
9741 & -scalar2(AEAb2derg(1,1,1,imat),Ug2Db1t(1,k))
9742 & +scalar2(AEAb2derg(1,1,1,imat),CUgb2(1,k))
9743 & +0.5d0*scalar2(vv1(1),Dtobr2(1,i))+scalar2(vv(1),Dtobr2(1,i))))
9745 g_corr6_loc(j-1)=g_corr6_loc(j-1)
9746 & +ekont*(-0.5d0*(scalar2(AEAb1derg(1,2,imat),CUgb2(1,i))
9747 & -scalar2(AEAb2derg(1,1,1,imat),Ug2Db1t(1,k))
9748 & +scalar2(AEAb2derg(1,1,1,imat),CUgb2(1,k))
9749 & +0.5d0*scalar2(vv1(1),Dtobr2(1,i))+scalar2(vv(1),Dtobr2(1,i))))
9751 call transpose2(EUgCder(1,1,k),auxmat(1,1))
9752 call matmat2(AEA(1,1,imat),auxmat(1,1),pizda1(1,1))
9753 vv1(1)=pizda1(1,1)-pizda1(2,2)
9754 vv1(2)=pizda1(1,2)+pizda1(2,1)
9755 if (k.gt.1) g_corr6_loc(k-1)=g_corr6_loc(k-1)
9756 & +ekont*(-0.5d0*(-scalar2(AEAb2(1,1,imat),Ug2Db1tder(1,k))
9757 & +scalar2(AEAb2(1,1,imat),CUgb2der(1,k))
9758 & +0.5d0*scalar2(vv1(1),Dtobr2(1,i))))
9767 s1= scalar2(AEAb1derx(1,lll,kkk,iii,2,imat),CUgb2(1,i))
9768 s2=-scalar2(AEAb2derx(1,lll,kkk,iii,1,imat),Ug2Db1t(1,k))
9769 s3= scalar2(AEAb2derx(1,lll,kkk,iii,1,imat),CUgb2(1,k))
9770 call transpose2(EUgC(1,1,k),auxmat(1,1))
9771 call matmat2(AEAderx(1,1,lll,kkk,iii,imat),auxmat(1,1),
9773 vv1(1)=pizda1(1,1)-pizda1(2,2)
9774 vv1(2)=pizda1(1,2)+pizda1(2,1)
9775 s4=0.5d0*scalar2(vv1(1),Dtobr2(1,i))
9776 vv(1)=AEAb1derx(1,lll,kkk,iii,2,imat)*b1(1,k)
9777 & -AEAb1derx(2,lll,kkk,iii,2,imat)*b1(2,k)
9778 vv(2)=AEAb1derx(1,lll,kkk,iii,2,imat)*b1(2,k)
9779 & +AEAb1derx(2,lll,kkk,iii,2,imat)*b1(1,k)
9780 s5=scalar2(vv(1),Dtobr2(1,i))
9781 derx(lll,kkk,ind)=derx(lll,kkk,ind)-0.5d0*(s1+s2+s3+s4+s5)
9787 c----------------------------------------------------------------------------
9788 double precision function eello6_graph2(i,j,k,l,jj,kk,swap)
9789 implicit real*8 (a-h,o-z)
9790 include 'DIMENSIONS'
9791 include 'COMMON.IOUNITS'
9792 include 'COMMON.CHAIN'
9793 include 'COMMON.DERIV'
9794 include 'COMMON.INTERACT'
9795 include 'COMMON.CONTACTS'
9796 include 'COMMON.TORSION'
9797 include 'COMMON.VAR'
9798 include 'COMMON.GEO'
9800 double precision vv(2),pizda(2,2),auxmat(2,2),auxvec(2),
9801 & auxvec1(2),auxvec2(2),auxmat1(2,2)
9804 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
9806 C Parallel Antiparallel C
9812 C \ j|/k\| \ |/k\|l C
9817 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
9818 cd write (2,*) 'eello6_graph2: i,',i,' j',j,' k',k,' l',l
9819 C AL 7/4/01 s1 would occur in the sixth-order moment,
9820 C but not in a cluster cumulant
9822 s1=dip(1,jj,i)*dip(1,kk,k)
9824 call matvec2(ADtEA1(1,1,1),Ub2(1,k),auxvec(1))
9825 s2=-0.5d0*scalar2(Ub2(1,i),auxvec(1))
9826 call matvec2(ADtEA(1,1,2),Ub2(1,l),auxvec1(1))
9827 s3=-0.5d0*scalar2(Ub2(1,j),auxvec1(1))
9828 call transpose2(EUg(1,1,k),auxmat(1,1))
9829 call matmat2(ADtEA1(1,1,1),auxmat(1,1),pizda(1,1))
9830 vv(1)=pizda(1,1)-pizda(2,2)
9831 vv(2)=pizda(1,2)+pizda(2,1)
9832 s4=-0.25d0*scalar2(vv(1),Dtobr2(1,i))
9833 cd write (2,*) 'eello6_graph2:','s1',s1,' s2',s2,' s3',s3,' s4',s4
9835 eello6_graph2=-(s1+s2+s3+s4)
9837 eello6_graph2=-(s2+s3+s4)
9840 C Derivatives in gamma(i-1)
9843 s1=dipderg(1,jj,i)*dip(1,kk,k)
9845 s2=-0.5d0*scalar2(Ub2der(1,i),auxvec(1))
9846 call matvec2(ADtEAderg(1,1,1,2),Ub2(1,l),auxvec2(1))
9847 s3=-0.5d0*scalar2(Ub2(1,j),auxvec2(1))
9848 s4=-0.25d0*scalar2(vv(1),Dtobr2der(1,i))
9850 g_corr6_loc(i-1)=g_corr6_loc(i-1)-ekont*(s1+s2+s3+s4)
9852 g_corr6_loc(i-1)=g_corr6_loc(i-1)-ekont*(s2+s3+s4)
9854 c g_corr6_loc(i-1)=g_corr6_loc(i-1)-s3
9856 C Derivatives in gamma(k-1)
9858 s1=dip(1,jj,i)*dipderg(1,kk,k)
9860 call matvec2(ADtEA1(1,1,1),Ub2der(1,k),auxvec2(1))
9861 s2=-0.5d0*scalar2(Ub2(1,i),auxvec2(1))
9862 call matvec2(ADtEAderg(1,1,2,2),Ub2(1,l),auxvec2(1))
9863 s3=-0.5d0*scalar2(Ub2(1,j),auxvec2(1))
9864 call transpose2(EUgder(1,1,k),auxmat1(1,1))
9865 call matmat2(ADtEA1(1,1,1),auxmat1(1,1),pizda(1,1))
9866 vv(1)=pizda(1,1)-pizda(2,2)
9867 vv(2)=pizda(1,2)+pizda(2,1)
9868 s4=-0.25d0*scalar2(vv(1),Dtobr2(1,i))
9870 g_corr6_loc(k-1)=g_corr6_loc(k-1)-ekont*(s1+s2+s3+s4)
9872 g_corr6_loc(k-1)=g_corr6_loc(k-1)-ekont*(s2+s3+s4)
9874 c g_corr6_loc(k-1)=g_corr6_loc(k-1)-s3
9875 C Derivatives in gamma(j-1) or gamma(l-1)
9878 s1=dipderg(3,jj,i)*dip(1,kk,k)
9880 call matvec2(ADtEA1derg(1,1,1,1),Ub2(1,k),auxvec2(1))
9881 s2=-0.5d0*scalar2(Ub2(1,i),auxvec2(1))
9882 s3=-0.5d0*scalar2(Ub2der(1,j),auxvec1(1))
9883 call matmat2(ADtEA1derg(1,1,1,1),auxmat(1,1),pizda(1,1))
9884 vv(1)=pizda(1,1)-pizda(2,2)
9885 vv(2)=pizda(1,2)+pizda(2,1)
9886 s4=-0.25d0*scalar2(vv(1),Dtobr2(1,i))
9889 g_corr6_loc(l-1)=g_corr6_loc(l-1)-ekont*s1
9891 g_corr6_loc(j-1)=g_corr6_loc(j-1)-ekont*s1
9894 g_corr6_loc(j-1)=g_corr6_loc(j-1)-ekont*(s2+s3+s4)
9895 c g_corr6_loc(j-1)=g_corr6_loc(j-1)-s3
9897 C Derivatives in gamma(l-1) or gamma(j-1)
9900 s1=dip(1,jj,i)*dipderg(3,kk,k)
9902 call matvec2(ADtEA1derg(1,1,2,1),Ub2(1,k),auxvec2(1))
9903 s2=-0.5d0*scalar2(Ub2(1,i),auxvec2(1))
9904 call matvec2(ADtEA(1,1,2),Ub2der(1,l),auxvec2(1))
9905 s3=-0.5d0*scalar2(Ub2(1,j),auxvec2(1))
9906 call matmat2(ADtEA1derg(1,1,2,1),auxmat(1,1),pizda(1,1))
9907 vv(1)=pizda(1,1)-pizda(2,2)
9908 vv(2)=pizda(1,2)+pizda(2,1)
9909 s4=-0.25d0*scalar2(vv(1),Dtobr2(1,i))
9912 g_corr6_loc(j-1)=g_corr6_loc(j-1)-ekont*s1
9914 g_corr6_loc(l-1)=g_corr6_loc(l-1)-ekont*s1
9917 g_corr6_loc(l-1)=g_corr6_loc(l-1)-ekont*(s2+s3+s4)
9918 c g_corr6_loc(l-1)=g_corr6_loc(l-1)-s3
9920 C Cartesian derivatives.
9922 write (2,*) 'In eello6_graph2'
9924 write (2,*) 'iii=',iii
9926 write (2,*) 'kkk=',kkk
9928 write (2,'(3(2f10.5),5x)')
9929 & ((ADtEA1derx(jjj,mmm,lll,kkk,iii,1),mmm=1,2),lll=1,3)
9939 s1=dipderx(lll,kkk,1,jj,i)*dip(1,kk,k)
9941 s1=dip(1,jj,i)*dipderx(lll,kkk,1,kk,k)
9944 call matvec2(ADtEA1derx(1,1,lll,kkk,iii,1),Ub2(1,k),
9946 s2=-0.5d0*scalar2(Ub2(1,i),auxvec(1))
9947 call matvec2(ADtEAderx(1,1,lll,kkk,iii,2),Ub2(1,l),
9949 s3=-0.5d0*scalar2(Ub2(1,j),auxvec(1))
9950 call transpose2(EUg(1,1,k),auxmat(1,1))
9951 call matmat2(ADtEA1derx(1,1,lll,kkk,iii,1),auxmat(1,1),
9953 vv(1)=pizda(1,1)-pizda(2,2)
9954 vv(2)=pizda(1,2)+pizda(2,1)
9955 s4=-0.25d0*scalar2(vv(1),Dtobr2(1,i))
9956 cd write (2,*) 's1',s1,' s2',s2,' s3',s3,' s4',s4
9958 derx(lll,kkk,iii)=derx(lll,kkk,iii)-(s1+s2+s4)
9960 derx(lll,kkk,iii)=derx(lll,kkk,iii)-(s2+s4)
9963 derx(lll,kkk,3-iii)=derx(lll,kkk,3-iii)-s3
9965 derx(lll,kkk,iii)=derx(lll,kkk,iii)-s3
9972 c----------------------------------------------------------------------------
9973 double precision function eello6_graph3(i,j,k,l,jj,kk,swap)
9974 implicit real*8 (a-h,o-z)
9975 include 'DIMENSIONS'
9976 include 'COMMON.IOUNITS'
9977 include 'COMMON.CHAIN'
9978 include 'COMMON.DERIV'
9979 include 'COMMON.INTERACT'
9980 include 'COMMON.CONTACTS'
9981 include 'COMMON.TORSION'
9982 include 'COMMON.VAR'
9983 include 'COMMON.GEO'
9984 double precision vv(2),pizda(2,2),auxmat(2,2),auxvec(2)
9986 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
9988 C Parallel Antiparallel C
9994 C j|/k\| / |/k\|l / C
9999 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
10001 C 4/7/01 AL Component s1 was removed, because it pertains to the respective
10002 C energy moment and not to the cluster cumulant.
10003 iti=itortyp(itype(i))
10004 if (j.lt.nres-1) then
10005 itj1=itortyp(itype(j+1))
10009 itk=itortyp(itype(k))
10010 itk1=itortyp(itype(k+1))
10011 if (l.lt.nres-1) then
10012 itl1=itortyp(itype(l+1))
10017 s1=dip(4,jj,i)*dip(4,kk,k)
10019 call matvec2(AECA(1,1,1),b1(1,k+1),auxvec(1))
10020 s2=0.5d0*scalar2(b1(1,k),auxvec(1))
10021 call matvec2(AECA(1,1,2),b1(1,l+1),auxvec(1))
10022 s3=0.5d0*scalar2(b1(1,j+1),auxvec(1))
10023 call transpose2(EE(1,1,itk),auxmat(1,1))
10024 call matmat2(auxmat(1,1),AECA(1,1,1),pizda(1,1))
10025 vv(1)=pizda(1,1)+pizda(2,2)
10026 vv(2)=pizda(2,1)-pizda(1,2)
10027 s4=-0.25d0*scalar2(vv(1),Ctobr(1,k))
10028 cd write (2,*) 'eello6_graph3:','s1',s1,' s2',s2,' s3',s3,' s4',s4,
10029 cd & "sum",-(s2+s3+s4)
10031 eello6_graph3=-(s1+s2+s3+s4)
10033 eello6_graph3=-(s2+s3+s4)
10035 c eello6_graph3=-s4
10036 C Derivatives in gamma(k-1)
10037 call matvec2(AECAderg(1,1,2),b1(1,l+1),auxvec(1))
10038 s3=0.5d0*scalar2(b1(1,j+1),auxvec(1))
10039 s4=-0.25d0*scalar2(vv(1),Ctobrder(1,k))
10040 g_corr6_loc(k-1)=g_corr6_loc(k-1)-ekont*(s3+s4)
10041 C Derivatives in gamma(l-1)
10042 call matvec2(AECAderg(1,1,1),b1(1,k+1),auxvec(1))
10043 s2=0.5d0*scalar2(b1(1,k),auxvec(1))
10044 call matmat2(auxmat(1,1),AECAderg(1,1,1),pizda(1,1))
10045 vv(1)=pizda(1,1)+pizda(2,2)
10046 vv(2)=pizda(2,1)-pizda(1,2)
10047 s4=-0.25d0*scalar2(vv(1),Ctobr(1,k))
10048 g_corr6_loc(l-1)=g_corr6_loc(l-1)-ekont*(s2+s4)
10049 C Cartesian derivatives.
10055 s1=dipderx(lll,kkk,4,jj,i)*dip(4,kk,k)
10057 s1=dip(4,jj,i)*dipderx(lll,kkk,4,kk,k)
10060 call matvec2(AECAderx(1,1,lll,kkk,iii,1),b1(1,k+1),
10062 s2=0.5d0*scalar2(b1(1,k),auxvec(1))
10063 call matvec2(AECAderx(1,1,lll,kkk,iii,2),b1(1,l+1),
10065 s3=0.5d0*scalar2(b1(1,j+1),auxvec(1))
10066 call matmat2(auxmat(1,1),AECAderx(1,1,lll,kkk,iii,1),
10068 vv(1)=pizda(1,1)+pizda(2,2)
10069 vv(2)=pizda(2,1)-pizda(1,2)
10070 s4=-0.25d0*scalar2(vv(1),Ctobr(1,k))
10072 derx(lll,kkk,iii)=derx(lll,kkk,iii)-(s1+s2+s4)
10074 derx(lll,kkk,iii)=derx(lll,kkk,iii)-(s2+s4)
10077 derx(lll,kkk,3-iii)=derx(lll,kkk,3-iii)-s3
10079 derx(lll,kkk,iii)=derx(lll,kkk,iii)-s3
10081 c derx(lll,kkk,iii)=derx(lll,kkk,iii)-s4
10087 c----------------------------------------------------------------------------
10088 double precision function eello6_graph4(i,j,k,l,jj,kk,imat,swap)
10089 implicit real*8 (a-h,o-z)
10090 include 'DIMENSIONS'
10091 include 'COMMON.IOUNITS'
10092 include 'COMMON.CHAIN'
10093 include 'COMMON.DERIV'
10094 include 'COMMON.INTERACT'
10095 include 'COMMON.CONTACTS'
10096 include 'COMMON.TORSION'
10097 include 'COMMON.VAR'
10098 include 'COMMON.GEO'
10099 include 'COMMON.FFIELD'
10100 double precision vv(2),pizda(2,2),auxmat(2,2),auxvec(2),
10101 & auxvec1(2),auxmat1(2,2)
10103 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
10105 C Parallel Antiparallel C
10110 C /| o |o o| o |\ C
10111 C \ j|/k\| \ |/k\|l C
10116 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
10118 C 4/7/01 AL Component s1 was removed, because it pertains to the respective
10119 C energy moment and not to the cluster cumulant.
10120 cd write (2,*) 'eello_graph4: wturn6',wturn6
10121 iti=itortyp(itype(i))
10122 itj=itortyp(itype(j))
10123 if (j.lt.nres-1) then
10124 itj1=itortyp(itype(j+1))
10128 itk=itortyp(itype(k))
10129 if (k.lt.nres-1) then
10130 itk1=itortyp(itype(k+1))
10134 itl=itortyp(itype(l))
10135 if (l.lt.nres-1) then
10136 itl1=itortyp(itype(l+1))
10140 cd write (2,*) 'eello6_graph4:','i',i,' j',j,' k',k,' l',l
10141 cd write (2,*) 'iti',iti,' itj',itj,' itj1',itj1,' itk',itk,
10142 cd & ' itl',itl,' itl1',itl1
10144 if (imat.eq.1) then
10145 s1=dip(3,jj,i)*dip(3,kk,k)
10147 s1=dip(2,jj,j)*dip(2,kk,l)
10150 call matvec2(AECA(1,1,imat),Ub2(1,k),auxvec(1))
10151 s2=0.5d0*scalar2(Ub2(1,i),auxvec(1))
10153 call matvec2(ADtEA1(1,1,3-imat),b1(1,j+1),auxvec1(1))
10154 s3=-0.5d0*scalar2(b1(1,j),auxvec1(1))
10156 call matvec2(ADtEA1(1,1,3-imat),b1(1,l+1),auxvec1(1))
10157 s3=-0.5d0*scalar2(b1(1,l),auxvec1(1))
10159 call transpose2(EUg(1,1,k),auxmat(1,1))
10160 call matmat2(AECA(1,1,imat),auxmat(1,1),pizda(1,1))
10161 vv(1)=pizda(1,1)-pizda(2,2)
10162 vv(2)=pizda(2,1)+pizda(1,2)
10163 s4=0.25d0*scalar2(vv(1),Dtobr2(1,i))
10164 cd write (2,*) 'eello6_graph4:','s1',s1,' s2',s2,' s3',s3,' s4',s4
10166 eello6_graph4=-(s1+s2+s3+s4)
10168 eello6_graph4=-(s2+s3+s4)
10170 C Derivatives in gamma(i-1)
10173 if (imat.eq.1) then
10174 s1=dipderg(2,jj,i)*dip(3,kk,k)
10176 s1=dipderg(4,jj,j)*dip(2,kk,l)
10179 s2=0.5d0*scalar2(Ub2der(1,i),auxvec(1))
10181 call matvec2(ADtEA1derg(1,1,1,3-imat),b1(1,j+1),auxvec1(1))
10182 s3=-0.5d0*scalar2(b1(1,j),auxvec1(1))
10184 call matvec2(ADtEA1derg(1,1,1,3-imat),b1(1,l+1),auxvec1(1))
10185 s3=-0.5d0*scalar2(b1(1,l),auxvec1(1))
10187 s4=0.25d0*scalar2(vv(1),Dtobr2der(1,i))
10188 if (wturn6.gt.0.0d0 .and. k.eq.l+4 .and. i.eq.j+2) then
10189 cd write (2,*) 'turn6 derivatives'
10191 gel_loc_turn6(i-1)=gel_loc_turn6(i-1)-ekont*(s1+s2+s3+s4)
10193 gel_loc_turn6(i-1)=gel_loc_turn6(i-1)-ekont*(s2+s3+s4)
10197 g_corr6_loc(i-1)=g_corr6_loc(i-1)-ekont*(s1+s2+s3+s4)
10199 g_corr6_loc(i-1)=g_corr6_loc(i-1)-ekont*(s2+s3+s4)
10203 C Derivatives in gamma(k-1)
10205 if (imat.eq.1) then
10206 s1=dip(3,jj,i)*dipderg(2,kk,k)
10208 s1=dip(2,jj,j)*dipderg(4,kk,l)
10211 call matvec2(AECA(1,1,imat),Ub2der(1,k),auxvec1(1))
10212 s2=0.5d0*scalar2(Ub2(1,i),auxvec1(1))
10214 call matvec2(ADtEA1derg(1,1,2,3-imat),b1(1,j+1),auxvec1(1))
10215 s3=-0.5d0*scalar2(b1(1,j),auxvec1(1))
10217 call matvec2(ADtEA1derg(1,1,2,3-imat),b1(1,l+1),auxvec1(1))
10218 s3=-0.5d0*scalar2(b1(1,l),auxvec1(1))
10220 call transpose2(EUgder(1,1,k),auxmat1(1,1))
10221 call matmat2(AECA(1,1,imat),auxmat1(1,1),pizda(1,1))
10222 vv(1)=pizda(1,1)-pizda(2,2)
10223 vv(2)=pizda(2,1)+pizda(1,2)
10224 s4=0.25d0*scalar2(vv(1),Dtobr2(1,i))
10225 if (wturn6.gt.0.0d0 .and. k.eq.l+4 .and. i.eq.j+2) then
10227 gel_loc_turn6(k-1)=gel_loc_turn6(k-1)-ekont*(s1+s2+s3+s4)
10229 gel_loc_turn6(k-1)=gel_loc_turn6(k-1)-ekont*(s2+s3+s4)
10233 g_corr6_loc(k-1)=g_corr6_loc(k-1)-ekont*(s1+s2+s3+s4)
10235 g_corr6_loc(k-1)=g_corr6_loc(k-1)-ekont*(s2+s3+s4)
10238 C Derivatives in gamma(j-1) or gamma(l-1)
10239 if (l.eq.j+1 .and. l.gt.1) then
10240 call matvec2(AECAderg(1,1,imat),Ub2(1,k),auxvec(1))
10241 s2=0.5d0*scalar2(Ub2(1,i),auxvec(1))
10242 call matmat2(AECAderg(1,1,imat),auxmat(1,1),pizda(1,1))
10243 vv(1)=pizda(1,1)-pizda(2,2)
10244 vv(2)=pizda(2,1)+pizda(1,2)
10245 s4=0.25d0*scalar2(vv(1),Dtobr2(1,i))
10246 g_corr6_loc(l-1)=g_corr6_loc(l-1)-ekont*(s2+s4)
10247 else if (j.gt.1) then
10248 call matvec2(AECAderg(1,1,imat),Ub2(1,k),auxvec(1))
10249 s2=0.5d0*scalar2(Ub2(1,i),auxvec(1))
10250 call matmat2(AECAderg(1,1,imat),auxmat(1,1),pizda(1,1))
10251 vv(1)=pizda(1,1)-pizda(2,2)
10252 vv(2)=pizda(2,1)+pizda(1,2)
10253 s4=0.25d0*scalar2(vv(1),Dtobr2(1,i))
10254 if (wturn6.gt.0.0d0 .and. k.eq.l+4 .and. i.eq.j+2) then
10255 gel_loc_turn6(j-1)=gel_loc_turn6(j-1)-ekont*(s2+s4)
10257 g_corr6_loc(j-1)=g_corr6_loc(j-1)-ekont*(s2+s4)
10260 C Cartesian derivatives.
10266 if (imat.eq.1) then
10267 s1=dipderx(lll,kkk,3,jj,i)*dip(3,kk,k)
10269 s1=dipderx(lll,kkk,2,jj,j)*dip(2,kk,l)
10272 if (imat.eq.1) then
10273 s1=dip(3,jj,i)*dipderx(lll,kkk,3,kk,k)
10275 s1=dip(2,jj,j)*dipderx(lll,kkk,2,kk,l)
10279 call matvec2(AECAderx(1,1,lll,kkk,iii,imat),Ub2(1,k),
10281 s2=0.5d0*scalar2(Ub2(1,i),auxvec(1))
10283 call matvec2(ADtEA1derx(1,1,lll,kkk,iii,3-imat),
10284 & b1(1,j+1),auxvec(1))
10285 s3=-0.5d0*scalar2(b1(1,j),auxvec(1))
10287 call matvec2(ADtEA1derx(1,1,lll,kkk,iii,3-imat),
10288 & b1(1,l+1),auxvec(1))
10289 s3=-0.5d0*scalar2(b1(1,l),auxvec(1))
10291 call matmat2(AECAderx(1,1,lll,kkk,iii,imat),auxmat(1,1),
10293 vv(1)=pizda(1,1)-pizda(2,2)
10294 vv(2)=pizda(2,1)+pizda(1,2)
10295 s4=0.25d0*scalar2(vv(1),Dtobr2(1,i))
10297 if (wturn6.gt.0.0d0 .and. k.eq.l+4 .and. i.eq.j+2) then
10299 derx_turn(lll,kkk,3-iii)=derx_turn(lll,kkk,3-iii)
10302 derx_turn(lll,kkk,3-iii)=derx_turn(lll,kkk,3-iii)
10305 derx_turn(lll,kkk,iii)=derx_turn(lll,kkk,iii)-s3
10308 derx(lll,kkk,3-iii)=derx(lll,kkk,3-iii)-(s1+s2+s4)
10310 derx(lll,kkk,3-iii)=derx(lll,kkk,3-iii)-(s2+s4)
10312 derx(lll,kkk,iii)=derx(lll,kkk,iii)-s3
10316 derx(lll,kkk,iii)=derx(lll,kkk,iii)-(s1+s2+s4)
10318 derx(lll,kkk,iii)=derx(lll,kkk,iii)-(s2+s4)
10321 derx(lll,kkk,iii)=derx(lll,kkk,iii)-s3
10323 derx(lll,kkk,3-iii)=derx(lll,kkk,3-iii)-s3
10331 c----------------------------------------------------------------------------
10332 double precision function eello_turn6(i,jj,kk)
10333 implicit real*8 (a-h,o-z)
10334 include 'DIMENSIONS'
10335 include 'COMMON.IOUNITS'
10336 include 'COMMON.CHAIN'
10337 include 'COMMON.DERIV'
10338 include 'COMMON.INTERACT'
10339 include 'COMMON.CONTACTS'
10340 include 'COMMON.TORSION'
10341 include 'COMMON.VAR'
10342 include 'COMMON.GEO'
10343 double precision vtemp1(2),vtemp2(2),vtemp3(2),vtemp4(2),
10344 & atemp(2,2),auxmat(2,2),achuj_temp(2,2),gtemp(2,2),gvec(2),
10346 double precision vtemp1d(2),vtemp2d(2),vtemp3d(2),vtemp4d(2),
10347 & atempd(2,2),auxmatd(2,2),achuj_tempd(2,2),gtempd(2,2),gvecd(2)
10348 C 4/7/01 AL Components s1, s8, and s13 were removed, because they pertain to
10349 C the respective energy moment and not to the cluster cumulant.
10358 iti=itortyp(itype(i))
10359 itk=itortyp(itype(k))
10360 itk1=itortyp(itype(k+1))
10361 itl=itortyp(itype(l))
10362 itj=itortyp(itype(j))
10363 cd write (2,*) 'itk',itk,' itk1',itk1,' itl',itl,' itj',itj
10364 cd write (2,*) 'i',i,' k',k,' j',j,' l',l
10365 cd if (i.ne.1 .or. j.ne.3 .or. k.ne.2 .or. l.ne.4) then
10370 cd & 'EELLO6: Contacts have occurred for peptide groups',i,j,
10372 cd call checkint_turn6(i,jj,kk,eel_turn6_num)
10376 derx_turn(lll,kkk,iii)=0.0d0
10383 eello6_5=eello6_graph4(l,k,j,i,kk,jj,2,.true.)
10385 cd write (2,*) 'eello6_5',eello6_5
10387 call transpose2(AEA(1,1,1),auxmat(1,1))
10388 call matmat2(EUg(1,1,i+1),auxmat(1,1),auxmat(1,1))
10389 ss1=scalar2(Ub2(1,i+2),b1(1,l))
10390 s1 = (auxmat(1,1)+auxmat(2,2))*ss1
10392 call matvec2(EUg(1,1,i+2),b1(1,l),vtemp1(1))
10393 call matvec2(AEA(1,1,1),vtemp1(1),vtemp1(1))
10394 s2 = scalar2(b1(1,k),vtemp1(1))
10396 call transpose2(AEA(1,1,2),atemp(1,1))
10397 call matmat2(atemp(1,1),EUg(1,1,i+4),atemp(1,1))
10398 call matvec2(Ug2(1,1,i+2),dd(1,1,itk1),vtemp2(1))
10399 s8 = -(atemp(1,1)+atemp(2,2))*scalar2(cc(1,1,itl),vtemp2(1))
10401 call matmat2(EUg(1,1,i+3),AEA(1,1,2),auxmat(1,1))
10402 call matvec2(auxmat(1,1),Ub2(1,i+4),vtemp3(1))
10403 s12 = scalar2(Ub2(1,i+2),vtemp3(1))
10405 call transpose2(a_chuj(1,1,kk,i+1),achuj_temp(1,1))
10406 call matmat2(achuj_temp(1,1),EUg(1,1,i+2),gtemp(1,1))
10407 call matmat2(gtemp(1,1),EUg(1,1,i+3),gtemp(1,1))
10408 call matvec2(a_chuj(1,1,jj,i),Ub2(1,i+4),vtemp4(1))
10409 ss13 = scalar2(b1(1,k),vtemp4(1))
10410 s13 = (gtemp(1,1)+gtemp(2,2))*ss13
10412 c write (2,*) 's1,s2,s8,s12,s13',s1,s2,s8,s12,s13
10418 eel_turn6 = eello6_5 - 0.5d0*(s1+s2+s12+s8+s13)
10419 C Derivatives in gamma(i+2)
10423 call transpose2(AEA(1,1,1),auxmatd(1,1))
10424 call matmat2(EUgder(1,1,i+1),auxmatd(1,1),auxmatd(1,1))
10425 s1d = (auxmatd(1,1)+auxmatd(2,2))*ss1
10426 call transpose2(AEAderg(1,1,2),atempd(1,1))
10427 call matmat2(atempd(1,1),EUg(1,1,i+4),atempd(1,1))
10428 s8d = -(atempd(1,1)+atempd(2,2))*scalar2(cc(1,1,itl),vtemp2(1))
10430 call matmat2(EUg(1,1,i+3),AEAderg(1,1,2),auxmatd(1,1))
10431 call matvec2(auxmatd(1,1),Ub2(1,i+4),vtemp3d(1))
10432 s12d = scalar2(Ub2(1,i+2),vtemp3d(1))
10438 gel_loc_turn6(i)=gel_loc_turn6(i)-0.5d0*ekont*(s1d+s8d+s12d)
10439 C Derivatives in gamma(i+3)
10441 call transpose2(AEA(1,1,1),auxmatd(1,1))
10442 call matmat2(EUg(1,1,i+1),auxmatd(1,1),auxmatd(1,1))
10443 ss1d=scalar2(Ub2der(1,i+2),b1(1,l))
10444 s1d = (auxmatd(1,1)+auxmatd(2,2))*ss1d
10446 call matvec2(EUgder(1,1,i+2),b1(1,l),vtemp1d(1))
10447 call matvec2(AEA(1,1,1),vtemp1d(1),vtemp1d(1))
10448 s2d = scalar2(b1(1,k),vtemp1d(1))
10450 call matvec2(Ug2der(1,1,i+2),dd(1,1,itk1),vtemp2d(1))
10451 s8d = -(atemp(1,1)+atemp(2,2))*scalar2(cc(1,1,itl),vtemp2d(1))
10453 s12d = scalar2(Ub2der(1,i+2),vtemp3(1))
10455 call matmat2(achuj_temp(1,1),EUgder(1,1,i+2),gtempd(1,1))
10456 call matmat2(gtempd(1,1),EUg(1,1,i+3),gtempd(1,1))
10457 s13d = (gtempd(1,1)+gtempd(2,2))*ss13
10465 gel_loc_turn6(i+1)=gel_loc_turn6(i+1)
10466 & -0.5d0*ekont*(s1d+s2d+s8d+s12d+s13d)
10468 gel_loc_turn6(i+1)=gel_loc_turn6(i+1)
10469 & -0.5d0*ekont*(s2d+s12d)
10471 C Derivatives in gamma(i+4)
10472 call matmat2(EUgder(1,1,i+3),AEA(1,1,2),auxmatd(1,1))
10473 call matvec2(auxmatd(1,1),Ub2(1,i+4),vtemp3d(1))
10474 s12d = scalar2(Ub2(1,i+2),vtemp3d(1))
10476 call matmat2(achuj_temp(1,1),EUg(1,1,i+2),gtempd(1,1))
10477 call matmat2(gtempd(1,1),EUgder(1,1,i+3),gtempd(1,1))
10478 s13d = (gtempd(1,1)+gtempd(2,2))*ss13
10486 gel_loc_turn6(i+2)=gel_loc_turn6(i+2)-0.5d0*ekont*(s12d+s13d)
10488 gel_loc_turn6(i+2)=gel_loc_turn6(i+2)-0.5d0*ekont*(s12d)
10490 C Derivatives in gamma(i+5)
10492 call transpose2(AEAderg(1,1,1),auxmatd(1,1))
10493 call matmat2(EUg(1,1,i+1),auxmatd(1,1),auxmatd(1,1))
10494 s1d = (auxmatd(1,1)+auxmatd(2,2))*ss1
10496 call matvec2(EUg(1,1,i+2),b1(1,l),vtemp1d(1))
10497 call matvec2(AEAderg(1,1,1),vtemp1d(1),vtemp1d(1))
10498 s2d = scalar2(b1(1,k),vtemp1d(1))
10500 call transpose2(AEA(1,1,2),atempd(1,1))
10501 call matmat2(atempd(1,1),EUgder(1,1,i+4),atempd(1,1))
10502 s8d = -(atempd(1,1)+atempd(2,2))*scalar2(cc(1,1,itl),vtemp2(1))
10504 call matvec2(auxmat(1,1),Ub2der(1,i+4),vtemp3d(1))
10505 s12d = scalar2(Ub2(1,i+2),vtemp3d(1))
10507 call matvec2(a_chuj(1,1,jj,i),Ub2der(1,i+4),vtemp4d(1))
10508 ss13d = scalar2(b1(1,k),vtemp4d(1))
10509 s13d = (gtemp(1,1)+gtemp(2,2))*ss13d
10517 gel_loc_turn6(i+3)=gel_loc_turn6(i+3)
10518 & -0.5d0*ekont*(s1d+s2d+s8d+s12d+s13d)
10520 gel_loc_turn6(i+3)=gel_loc_turn6(i+3)
10521 & -0.5d0*ekont*(s2d+s12d)
10523 C Cartesian derivatives
10528 call transpose2(AEAderx(1,1,lll,kkk,iii,1),auxmatd(1,1))
10529 call matmat2(EUg(1,1,i+1),auxmatd(1,1),auxmatd(1,1))
10530 s1d = (auxmatd(1,1)+auxmatd(2,2))*ss1
10532 call matvec2(EUg(1,1,i+2),b1(1,l),vtemp1(1))
10533 call matvec2(AEAderx(1,1,lll,kkk,iii,1),vtemp1(1),
10535 s2d = scalar2(b1(1,k),vtemp1d(1))
10537 call transpose2(AEAderx(1,1,lll,kkk,iii,2),atempd(1,1))
10538 call matmat2(atempd(1,1),EUg(1,1,i+4),atempd(1,1))
10539 s8d = -(atempd(1,1)+atempd(2,2))*
10540 & scalar2(cc(1,1,itl),vtemp2(1))
10542 call matmat2(EUg(1,1,i+3),AEAderx(1,1,lll,kkk,iii,2),
10544 call matvec2(auxmatd(1,1),Ub2(1,i+4),vtemp3d(1))
10545 s12d = scalar2(Ub2(1,i+2),vtemp3d(1))
10552 derx_turn(lll,kkk,iii) = derx_turn(lll,kkk,iii)
10553 & - 0.5d0*(s1d+s2d)
10555 derx_turn(lll,kkk,iii) = derx_turn(lll,kkk,iii)
10559 derx_turn(lll,kkk,3-iii) = derx_turn(lll,kkk,3-iii)
10560 & - 0.5d0*(s8d+s12d)
10562 derx_turn(lll,kkk,3-iii) = derx_turn(lll,kkk,3-iii)
10571 call transpose2(a_chuj_der(1,1,lll,kkk,kk,i+1),
10572 & achuj_tempd(1,1))
10573 call matmat2(achuj_tempd(1,1),EUg(1,1,i+2),gtempd(1,1))
10574 call matmat2(gtempd(1,1),EUg(1,1,i+3),gtempd(1,1))
10575 s13d=(gtempd(1,1)+gtempd(2,2))*ss13
10576 derx_turn(lll,kkk,2) = derx_turn(lll,kkk,2)-0.5d0*s13d
10577 call matvec2(a_chuj_der(1,1,lll,kkk,jj,i),Ub2(1,i+4),
10579 ss13d = scalar2(b1(1,k),vtemp4d(1))
10580 s13d = (gtemp(1,1)+gtemp(2,2))*ss13d
10581 derx_turn(lll,kkk,1) = derx_turn(lll,kkk,1)-0.5d0*s13d
10585 cd write(iout,*) 'eel6_turn6',eel_turn6,' eel_turn6_num',
10586 cd & 16*eel_turn6_num
10588 if (j.lt.nres-1) then
10595 if (l.lt.nres-1) then
10603 cgrad ggg1(ll)=eel_turn6*g_contij(ll,1)
10604 cgrad ggg2(ll)=eel_turn6*g_contij(ll,2)
10605 cgrad ghalf=0.5d0*ggg1(ll)
10607 gturn6ij=eel_turn6*g_contij(ll,1)+ekont*derx_turn(ll,1,1)
10608 gturn6kl=eel_turn6*g_contij(ll,2)+ekont*derx_turn(ll,1,2)
10609 gcorr6_turn(ll,i)=gcorr6_turn(ll,i)!+ghalf
10610 & +ekont*derx_turn(ll,2,1)
10611 gcorr6_turn(ll,i+1)=gcorr6_turn(ll,i+1)+ekont*derx_turn(ll,3,1)
10612 gcorr6_turn(ll,j)=gcorr6_turn(ll,j)!+ghalf
10613 & +ekont*derx_turn(ll,4,1)
10614 gcorr6_turn(ll,j1)=gcorr6_turn(ll,j1)+ekont*derx_turn(ll,5,1)
10615 gcorr6_turn_long(ll,j)=gcorr6_turn_long(ll,j)+gturn6ij
10616 gcorr6_turn_long(ll,i)=gcorr6_turn_long(ll,i)-gturn6ij
10617 cgrad ghalf=0.5d0*ggg2(ll)
10619 gcorr6_turn(ll,k)=gcorr6_turn(ll,k)!+ghalf
10620 & +ekont*derx_turn(ll,2,2)
10621 gcorr6_turn(ll,k+1)=gcorr6_turn(ll,k+1)+ekont*derx_turn(ll,3,2)
10622 gcorr6_turn(ll,l)=gcorr6_turn(ll,l)!+ghalf
10623 & +ekont*derx_turn(ll,4,2)
10624 gcorr6_turn(ll,l1)=gcorr6_turn(ll,l1)+ekont*derx_turn(ll,5,2)
10625 gcorr6_turn_long(ll,l)=gcorr6_turn_long(ll,l)+gturn6kl
10626 gcorr6_turn_long(ll,k)=gcorr6_turn_long(ll,k)-gturn6kl
10631 cgrad gcorr6_turn(ll,m)=gcorr6_turn(ll,m)+ggg1(ll)
10636 cgrad gcorr6_turn(ll,m)=gcorr6_turn(ll,m)+ggg2(ll)
10642 cgrad gcorr6_turn(ll,m)=gcorr6_turn(ll,m)+ekont*derx_turn(ll,1,1)
10647 cgrad gcorr6_turn(ll,m)=gcorr6_turn(ll,m)+ekont*derx_turn(ll,1,2)
10651 cd write (2,*) iii,g_corr6_loc(iii)
10653 eello_turn6=ekont*eel_turn6
10654 cd write (2,*) 'ekont',ekont
10655 cd write (2,*) 'eel_turn6',ekont*eel_turn6
10659 C-----------------------------------------------------------------------------
10660 double precision function scalar(u,v)
10661 !DIR$ INLINEALWAYS scalar
10663 cDEC$ ATTRIBUTES FORCEINLINE::scalar
10666 double precision u(3),v(3)
10667 cd double precision sc
10675 scalar=u(1)*v(1)+u(2)*v(2)+u(3)*v(3)
10678 crc-------------------------------------------------
10679 SUBROUTINE MATVEC2(A1,V1,V2)
10680 !DIR$ INLINEALWAYS MATVEC2
10682 cDEC$ ATTRIBUTES FORCEINLINE::MATVEC2
10684 implicit real*8 (a-h,o-z)
10685 include 'DIMENSIONS'
10686 DIMENSION A1(2,2),V1(2),V2(2)
10690 c 3 VI=VI+A1(I,K)*V1(K)
10694 vaux1=a1(1,1)*v1(1)+a1(1,2)*v1(2)
10695 vaux2=a1(2,1)*v1(1)+a1(2,2)*v1(2)
10700 C---------------------------------------
10701 SUBROUTINE MATMAT2(A1,A2,A3)
10703 cDEC$ ATTRIBUTES FORCEINLINE::MATMAT2
10705 implicit real*8 (a-h,o-z)
10706 include 'DIMENSIONS'
10707 DIMENSION A1(2,2),A2(2,2),A3(2,2)
10708 c DIMENSION AI3(2,2)
10712 c A3IJ=A3IJ+A1(I,K)*A2(K,J)
10718 ai3_11=a1(1,1)*a2(1,1)+a1(1,2)*a2(2,1)
10719 ai3_12=a1(1,1)*a2(1,2)+a1(1,2)*a2(2,2)
10720 ai3_21=a1(2,1)*a2(1,1)+a1(2,2)*a2(2,1)
10721 ai3_22=a1(2,1)*a2(1,2)+a1(2,2)*a2(2,2)
10729 c-------------------------------------------------------------------------
10730 double precision function scalar2(u,v)
10731 !DIR$ INLINEALWAYS scalar2
10733 double precision u(2),v(2)
10734 double precision sc
10736 scalar2=u(1)*v(1)+u(2)*v(2)
10740 C-----------------------------------------------------------------------------
10742 subroutine transpose2(a,at)
10743 !DIR$ INLINEALWAYS transpose2
10745 cDEC$ ATTRIBUTES FORCEINLINE::transpose2
10748 double precision a(2,2),at(2,2)
10755 c--------------------------------------------------------------------------
10756 subroutine transpose(n,a,at)
10759 double precision a(n,n),at(n,n)
10767 C---------------------------------------------------------------------------
10768 subroutine prodmat3(a1,a2,kk,transp,prod)
10769 !DIR$ INLINEALWAYS prodmat3
10771 cDEC$ ATTRIBUTES FORCEINLINE::prodmat3
10775 double precision a1(2,2),a2(2,2),a2t(2,2),kk(2,2),prod(2,2)
10777 crc double precision auxmat(2,2),prod_(2,2)
10780 crc call transpose2(kk(1,1),auxmat(1,1))
10781 crc call matmat2(a1(1,1),auxmat(1,1),auxmat(1,1))
10782 crc call matmat2(auxmat(1,1),a2(1,1),prod_(1,1))
10784 prod(1,1)=(a1(1,1)*kk(1,1)+a1(1,2)*kk(1,2))*a2(1,1)
10785 & +(a1(1,1)*kk(2,1)+a1(1,2)*kk(2,2))*a2(2,1)
10786 prod(1,2)=(a1(1,1)*kk(1,1)+a1(1,2)*kk(1,2))*a2(1,2)
10787 & +(a1(1,1)*kk(2,1)+a1(1,2)*kk(2,2))*a2(2,2)
10788 prod(2,1)=(a1(2,1)*kk(1,1)+a1(2,2)*kk(1,2))*a2(1,1)
10789 & +(a1(2,1)*kk(2,1)+a1(2,2)*kk(2,2))*a2(2,1)
10790 prod(2,2)=(a1(2,1)*kk(1,1)+a1(2,2)*kk(1,2))*a2(1,2)
10791 & +(a1(2,1)*kk(2,1)+a1(2,2)*kk(2,2))*a2(2,2)
10794 crc call matmat2(a1(1,1),kk(1,1),auxmat(1,1))
10795 crc call matmat2(auxmat(1,1),a2(1,1),prod_(1,1))
10797 prod(1,1)=(a1(1,1)*kk(1,1)+a1(1,2)*kk(2,1))*a2(1,1)
10798 & +(a1(1,1)*kk(1,2)+a1(1,2)*kk(2,2))*a2(2,1)
10799 prod(1,2)=(a1(1,1)*kk(1,1)+a1(1,2)*kk(2,1))*a2(1,2)
10800 & +(a1(1,1)*kk(1,2)+a1(1,2)*kk(2,2))*a2(2,2)
10801 prod(2,1)=(a1(2,1)*kk(1,1)+a1(2,2)*kk(2,1))*a2(1,1)
10802 & +(a1(2,1)*kk(1,2)+a1(2,2)*kk(2,2))*a2(2,1)
10803 prod(2,2)=(a1(2,1)*kk(1,1)+a1(2,2)*kk(2,1))*a2(1,2)
10804 & +(a1(2,1)*kk(1,2)+a1(2,2)*kk(2,2))*a2(2,2)
10807 c call transpose2(a2(1,1),a2t(1,1))
10810 crc print *,((prod_(i,j),i=1,2),j=1,2)
10811 crc print *,((prod(i,j),i=1,2),j=1,2)
10815 CCC----------------------------------------------
10816 subroutine Eliptransfer(eliptran)
10817 implicit real*8 (a-h,o-z)
10818 include 'DIMENSIONS'
10819 include 'COMMON.GEO'
10820 include 'COMMON.VAR'
10821 include 'COMMON.LOCAL'
10822 include 'COMMON.CHAIN'
10823 include 'COMMON.DERIV'
10824 include 'COMMON.NAMES'
10825 include 'COMMON.INTERACT'
10826 include 'COMMON.IOUNITS'
10827 include 'COMMON.CALC'
10828 include 'COMMON.CONTROL'
10829 include 'COMMON.SPLITELE'
10830 include 'COMMON.SBRIDGE'
10831 C this is done by Adasko
10832 C print *,"wchodze"
10833 C structure of box:
10835 C--bordliptop-- buffore starts
10836 C--bufliptop--- here true lipid starts
10838 C--buflipbot--- lipid ends buffore starts
10839 C--bordlipbot--buffore ends
10841 do i=ilip_start,ilip_end
10843 if (itype(i).eq.ntyp1) cycle
10845 positi=(mod(((c(3,i)+c(3,i+1))/2.0d0),boxzsize))
10846 if (positi.le.0) positi=positi+boxzsize
10848 C first for peptide groups
10849 c for each residue check if it is in lipid or lipid water border area
10850 if ((positi.gt.bordlipbot)
10851 &.and.(positi.lt.bordliptop)) then
10852 C the energy transfer exist
10853 if (positi.lt.buflipbot) then
10854 C what fraction I am in
10856 & ((positi-bordlipbot)/lipbufthick)
10857 C lipbufthick is thickenes of lipid buffore
10858 sslip=sscalelip(fracinbuf)
10859 ssgradlip=-sscagradlip(fracinbuf)/lipbufthick
10860 eliptran=eliptran+sslip*pepliptran
10861 gliptranc(3,i)=gliptranc(3,i)+ssgradlip*pepliptran/2.0d0
10862 gliptranc(3,i-1)=gliptranc(3,i-1)+ssgradlip*pepliptran/2.0d0
10863 C gliptranc(3,i-2)=gliptranc(3,i)+ssgradlip*pepliptran
10865 C print *,"doing sccale for lower part"
10866 C print *,i,sslip,fracinbuf,ssgradlip
10867 elseif (positi.gt.bufliptop) then
10868 fracinbuf=1.0d0-((bordliptop-positi)/lipbufthick)
10869 sslip=sscalelip(fracinbuf)
10870 ssgradlip=sscagradlip(fracinbuf)/lipbufthick
10871 eliptran=eliptran+sslip*pepliptran
10872 gliptranc(3,i)=gliptranc(3,i)+ssgradlip*pepliptran/2.0d0
10873 gliptranc(3,i-1)=gliptranc(3,i-1)+ssgradlip*pepliptran/2.0d0
10874 C gliptranc(3,i-2)=gliptranc(3,i)+ssgradlip*pepliptran
10875 C print *, "doing sscalefor top part"
10876 C print *,i,sslip,fracinbuf,ssgradlip
10878 eliptran=eliptran+pepliptran
10879 C print *,"I am in true lipid"
10882 C eliptran=elpitran+0.0 ! I am in water
10885 C print *, "nic nie bylo w lipidzie?"
10886 C now multiply all by the peptide group transfer factor
10887 C eliptran=eliptran*pepliptran
10888 C now the same for side chains
10890 do i=ilip_start,ilip_end
10891 if (itype(i).eq.ntyp1) cycle
10892 positi=(mod(c(3,i+nres),boxzsize))
10893 if (positi.le.0) positi=positi+boxzsize
10894 C print *,mod(c(3,i+nres),boxzsize),bordlipbot,bordliptop
10895 c for each residue check if it is in lipid or lipid water border area
10896 C respos=mod(c(3,i+nres),boxzsize)
10897 C print *,positi,bordlipbot,buflipbot
10898 if ((positi.gt.bordlipbot)
10899 & .and.(positi.lt.bordliptop)) then
10900 C the energy transfer exist
10901 if (positi.lt.buflipbot) then
10903 & ((positi-bordlipbot)/lipbufthick)
10904 C lipbufthick is thickenes of lipid buffore
10905 sslip=sscalelip(fracinbuf)
10906 ssgradlip=-sscagradlip(fracinbuf)/lipbufthick
10907 eliptran=eliptran+sslip*liptranene(itype(i))
10908 gliptranx(3,i)=gliptranx(3,i)
10909 &+ssgradlip*liptranene(itype(i))
10910 gliptranc(3,i-1)= gliptranc(3,i-1)
10911 &+ssgradlip*liptranene(itype(i))
10912 C print *,"doing sccale for lower part"
10913 elseif (positi.gt.bufliptop) then
10915 &((bordliptop-positi)/lipbufthick)
10916 sslip=sscalelip(fracinbuf)
10917 ssgradlip=sscagradlip(fracinbuf)/lipbufthick
10918 eliptran=eliptran+sslip*liptranene(itype(i))
10919 gliptranx(3,i)=gliptranx(3,i)
10920 &+ssgradlip*liptranene(itype(i))
10921 gliptranc(3,i-1)= gliptranc(3,i-1)
10922 &+ssgradlip*liptranene(itype(i))
10923 C print *, "doing sscalefor top part",sslip,fracinbuf
10925 eliptran=eliptran+liptranene(itype(i))
10926 C print *,"I am in true lipid"
10928 endif ! if in lipid or buffor
10930 C eliptran=elpitran+0.0 ! I am in water
10934 C---------------------------------------------------------
10935 C AFM soubroutine for constant force
10936 subroutine AFMforce(Eafmforce)
10937 implicit real*8 (a-h,o-z)
10938 include 'DIMENSIONS'
10939 include 'COMMON.GEO'
10940 include 'COMMON.VAR'
10941 include 'COMMON.LOCAL'
10942 include 'COMMON.CHAIN'
10943 include 'COMMON.DERIV'
10944 include 'COMMON.NAMES'
10945 include 'COMMON.INTERACT'
10946 include 'COMMON.IOUNITS'
10947 include 'COMMON.CALC'
10948 include 'COMMON.CONTROL'
10949 include 'COMMON.SPLITELE'
10950 include 'COMMON.SBRIDGE'
10955 diffafm(i)=c(i,afmend)-c(i,afmbeg)
10956 dist=dist+diffafm(i)**2
10959 Eafmforce=-forceAFMconst*(dist-distafminit)
10961 gradafm(i,afmend-1)=-forceAFMconst*diffafm(i)/dist
10962 gradafm(i,afmbeg-1)=forceAFMconst*diffafm(i)/dist
10964 C print *,'AFM',Eafmforce
10967 C---------------------------------------------------------
10968 C AFM subroutine with pseudoconstant velocity
10969 subroutine AFMvel(Eafmforce)
10970 implicit real*8 (a-h,o-z)
10971 include 'DIMENSIONS'
10972 include 'COMMON.GEO'
10973 include 'COMMON.VAR'
10974 include 'COMMON.LOCAL'
10975 include 'COMMON.CHAIN'
10976 include 'COMMON.DERIV'
10977 include 'COMMON.NAMES'
10978 include 'COMMON.INTERACT'
10979 include 'COMMON.IOUNITS'
10980 include 'COMMON.CALC'
10981 include 'COMMON.CONTROL'
10982 include 'COMMON.SPLITELE'
10983 include 'COMMON.SBRIDGE'
10985 C Only for check grad COMMENT if not used for checkgrad
10987 C--------------------------------------------------------
10988 C print *,"wchodze"
10992 diffafm(i)=c(i,afmend)-c(i,afmbeg)
10993 dist=dist+diffafm(i)**2
10996 Eafmforce=0.5d0*forceAFMconst
10997 & *(distafminit+totTafm*velAFMconst-dist)**2
10998 C Eafmforce=-forceAFMconst*(dist-distafminit)
11000 gradafm(i,afmend-1)=-forceAFMconst*
11001 &(distafminit+totTafm*velAFMconst-dist)
11003 gradafm(i,afmbeg-1)=forceAFMconst*
11004 &(distafminit+totTafm*velAFMconst-dist)
11007 C print *,'AFM',Eafmforce,totTafm*velAFMconst,dist
11010 C-----------------------------------------------------------
11011 C first for shielding is setting of function of side-chains
11012 subroutine set_shield_fac
11013 implicit real*8 (a-h,o-z)
11014 include 'DIMENSIONS'
11015 include 'COMMON.CHAIN'
11016 include 'COMMON.DERIV'
11017 include 'COMMON.IOUNITS'
11018 include 'COMMON.SHIELD'
11019 include 'COMMON.INTERACT'
11020 C this is the squar root 77 devided by 81 the epislion in lipid (in protein)
11021 double precision div77_81/0.974996043d0/,
11022 &div4_81/0.2222222222d0/,sh_frac_dist_grad(3)
11024 C the vector between center of side_chain and peptide group
11025 double precision pep_side(3),long,side_calf(3),
11026 &pept_group(3),costhet_grad(3),cosphi_grad_long(3),
11027 &cosphi_grad_loc(3),pep_side_norm(3),side_calf_norm(3)
11028 C the line belowe needs to be changed for FGPROC>1
11030 if ((itype(i).eq.ntyp1).and.itype(i+1).eq.ntyp1) cycle
11032 Cif there two consequtive dummy atoms there is no peptide group between them
11033 C the line below has to be changed for FGPROC>1
11036 if ((itype(k).eq.ntyp1).or.(itype(k).eq.10)) cycle
11040 C first lets set vector conecting the ithe side-chain with kth side-chain
11041 pep_side(j)=c(j,k+nres)-(c(j,i)+c(j,i+1))/2.0d0
11042 C pep_side(j)=2.0d0
11043 C and vector conecting the side-chain with its proper calfa
11044 side_calf(j)=c(j,k+nres)-c(j,k)
11045 C side_calf(j)=2.0d0
11046 pept_group(j)=c(j,i)-c(j,i+1)
11047 C lets have their lenght
11048 dist_pep_side=pep_side(j)**2+dist_pep_side
11049 dist_side_calf=dist_side_calf+side_calf(j)**2
11050 dist_pept_group=dist_pept_group+pept_group(j)**2
11052 dist_pep_side=dsqrt(dist_pep_side)
11053 dist_pept_group=dsqrt(dist_pept_group)
11054 dist_side_calf=dsqrt(dist_side_calf)
11056 pep_side_norm(j)=pep_side(j)/dist_pep_side
11057 side_calf_norm(j)=dist_side_calf
11059 C now sscale fraction
11060 sh_frac_dist=-(dist_pep_side-rpp(1,1)-buff_shield)/buff_shield
11061 C print *,buff_shield,"buff"
11063 if (sh_frac_dist.le.0.0) cycle
11064 C If we reach here it means that this side chain reaches the shielding sphere
11065 C Lets add him to the list for gradient
11066 ishield_list(i)=ishield_list(i)+1
11067 C ishield_list is a list of non 0 side-chain that contribute to factor gradient
11068 C this list is essential otherwise problem would be O3
11069 shield_list(ishield_list(i),i)=k
11070 C Lets have the sscale value
11071 if (sh_frac_dist.gt.1.0) then
11072 scale_fac_dist=1.0d0
11074 sh_frac_dist_grad(j)=0.0d0
11077 scale_fac_dist=-sh_frac_dist*sh_frac_dist
11078 & *(2.0*sh_frac_dist-3.0d0)
11079 fac_help_scale=6.0*(sh_frac_dist-sh_frac_dist**2)
11080 & /dist_pep_side/buff_shield*0.5
11081 C remember for the final gradient multiply sh_frac_dist_grad(j)
11082 C for side_chain by factor -2 !
11084 sh_frac_dist_grad(j)=fac_help_scale*pep_side(j)
11085 C print *,"jestem",scale_fac_dist,fac_help_scale,
11086 C & sh_frac_dist_grad(j)
11089 C if ((i.eq.3).and.(k.eq.2)) then
11090 C print *,i,sh_frac_dist,dist_pep,fac_help_scale,scale_fac_dist
11094 C this is what is now we have the distance scaling now volume...
11095 short=short_r_sidechain(itype(k))
11096 long=long_r_sidechain(itype(k))
11097 costhet=1.0d0/dsqrt(1.0+short**2/dist_pep_side**2)
11100 costhet_fac=costhet**3*short**2*(-0.5)/dist_pep_side**4
11101 C costhet_fac=0.0d0
11103 costhet_grad(j)=costhet_fac*pep_side(j)
11105 C remember for the final gradient multiply costhet_grad(j)
11106 C for side_chain by factor -2 !
11107 C fac alfa is angle between CB_k,CA_k, CA_i,CA_i+1
11108 C pep_side0pept_group is vector multiplication
11109 pep_side0pept_group=0.0
11111 pep_side0pept_group=pep_side0pept_group+pep_side(j)*side_calf(j)
11113 cosalfa=(pep_side0pept_group/
11114 & (dist_pep_side*dist_side_calf))
11115 fac_alfa_sin=1.0-cosalfa**2
11116 fac_alfa_sin=dsqrt(fac_alfa_sin)
11117 rkprim=fac_alfa_sin*(long-short)+short
11119 cosphi=1.0d0/dsqrt(1.0+rkprim**2/dist_pep_side**2)
11120 cosphi_fac=cosphi**3*rkprim**2*(-0.5)/dist_pep_side**4
11123 cosphi_grad_long(j)=cosphi_fac*pep_side(j)
11124 &+cosphi**3*0.5/dist_pep_side**2*(-rkprim)
11125 &*(long-short)/fac_alfa_sin*cosalfa/
11126 &((dist_pep_side*dist_side_calf))*
11127 &((side_calf(j))-cosalfa*
11128 &((pep_side(j)/dist_pep_side)*dist_side_calf))
11130 cosphi_grad_loc(j)=cosphi**3*0.5/dist_pep_side**2*(-rkprim)
11131 &*(long-short)/fac_alfa_sin*cosalfa
11132 &/((dist_pep_side*dist_side_calf))*
11134 &cosalfa*side_calf(j)/dist_side_calf*dist_pep_side)
11137 VofOverlap=VSolvSphere/2.0d0*(1.0-costhet)*(1.0-cosphi)
11139 C now the gradient...
11140 C grad_shield is gradient of Calfa for peptide groups
11141 C write(iout,*) "shield_compon",i,k,VSolvSphere,scale_fac_dist,
11143 C write(iout,*) "cosphi_compon",i,k,pep_side0pept_group,
11144 C & dist_pep_side,dist_side_calf,c(1,k+nres),c(1,k),itype(k)
11146 grad_shield(j,i)=grad_shield(j,i)
11147 C gradient po skalowaniu
11148 & +(sh_frac_dist_grad(j)
11149 C gradient po costhet
11150 &-scale_fac_dist*costhet_grad(j)/(1.0-costhet)
11151 &-scale_fac_dist*(cosphi_grad_long(j))
11152 &/(1.0-cosphi) )*div77_81
11154 C grad_shield_side is Cbeta sidechain gradient
11155 grad_shield_side(j,ishield_list(i),i)=
11156 & (sh_frac_dist_grad(j)*-2.0d0
11157 & +scale_fac_dist*costhet_grad(j)*2.0d0/(1.0-costhet)
11158 & +scale_fac_dist*(cosphi_grad_long(j))
11159 & *2.0d0/(1.0-cosphi))
11160 & *div77_81*VofOverlap
11162 grad_shield_loc(j,ishield_list(i),i)=
11163 & scale_fac_dist*cosphi_grad_loc(j)
11164 & *2.0d0/(1.0-cosphi)
11165 & *div77_81*VofOverlap
11167 VolumeTotal=VolumeTotal+VofOverlap*scale_fac_dist
11169 fac_shield(i)=VolumeTotal*div77_81+div4_81
11170 C write(2,*) "TOTAL VOLUME",i,VolumeTotal,fac_shield(i)