1 subroutine w2x(nvarr,x,*)
4 include "DIMENSIONS.ZSCOPT"
5 include "COMMON.CONTROL"
6 include "COMMON.INTERACT"
7 include "COMMON.TORSION"
9 include "COMMON.WEIGHTS"
10 include "COMMON.ENERGIES"
11 include "COMMON.IOUNITS"
12 include "COMMON.NAMES"
14 include "COMMON.VMCPAR"
15 include "COMMON.CLASSES"
16 include "COMMON.WEIGHTDER"
17 include "COMMON.FFIELD"
18 include "COMMON.SCCOR"
19 integer itor2typ(-2:2) /-20,-20,10,9,20/
20 integer ind_shield /25/
22 double precision x(max_paropt),xchuj,epsi
23 integer nvarr,i,ii,j,k,l,ll,iprot,iblock
26 write (iout,*) "W2X: SPLIT_FOURIERTOR",SPLIT_FOURIERTOR,
27 & " tor_mode",tor_mode," mod_ang",mod_ang," nloctyp",nloctyp,
28 * " mod_fourier",mod_fourier(nloctyp),
29 & " mod_fouriertor",mod_fouriertor(nloctyp)
32 if (imask(i).gt.0 .and. i.ne.ind_shield) then
41 c 2/10/208 AL: insert the base torsional PMFs
42 if (mod_fourier(nloctyp).gt.0.or.mod_fouriertor(nloctyp).gt.0)then
48 x_low(ii)=e0_low(iti,itj)
49 x_up(ii)=e0_up(iti,itj)
60 if (torsion_pmf.and.eello_pmf) then
63 x_low(ii)=wello_PMF_low
69 if (turn_pmf.and.(torsion_pmf.or.eello_pmf)) then
72 x_low(ii)=wturn_PMF_low
78 if (pdbpmf .and. mask_beta_PDB.gt.0) then
82 x_low(ii)=beta_PDB_low
92 c Change 9/21/07 AL Variables are epsilons and not the increments on epsilons
93 c to enable control on their deviations from original values.
94 c Single-body epsilons are now defined as epsilons of pairs of same type side
97 c write (iout,*) "W2X: mod_side",mod_side," nsingle_sc",nsingle_sc,
98 c & " npair_sc",npair_sc
103 eps_orig(i,j)=eps(i,j)
111 c write (iout,*) "ii",ii," x",x(ii)
112 x_low(ii)=epss_low(i)
114 c if (epss_up(i).eq.0.0d0) then
115 c x_up(ii)=dabs(epsi)*epss_low(i)
116 c x_low(ii)=epsi-x_up(ii)
117 c x_up(ii)=epsi+x_up(ii)
119 c x_low(ii)=epss_low(i)
120 c x_up(ii)=epss_up(i)
129 if (ityp_ssc(j).eq.iti) then
130 write (iout,*) "Error - pair ",restyp(iti),"-",
132 & " specified in variable epsilon list but type defined",
133 & " in single-type list."
140 x_low(ii)=epsp_low(i)
142 c if (epsp_up(i).eq.0.0d0) then
143 c x_up(ii)=dabs(epsi)*epsp_low(i)
144 c x_low(ii)=epsi-x_up(ii)
145 c x_up(ii)=epsi+x_up(ii)
147 c x_low(ii)=epsp_low(i)
148 c x_up(ii)=epsp_up(i)
150 c write (iout,*) "ii",ii," x",x(ii)
160 c write (iout,*) "Indices of optimizable torsionals"
161 do i=-ntortyp+1,ntortyp-1
162 do j=-ntortyp+1,ntortyp-1
163 c write (iout,*) "mask",i,j,mask_tor(j,i)
165 if (tor_mode.eq.0) then
168 if (mask_tor(0,j,i,iblock).eq.1) then
171 x(ii)=weitor(0,j,i,iblock)
172 x_low(ii)=weitor_low(0,j,i,iblock)
173 x_up(ii)=weitor_up(0,j,i,iblock)
174 c write (iout,'(2a4,2i4)') restyp(itor2typ(j)),
175 c & restyp(itor2typ(i)),iblock,ii
176 else if (mask_tor(0,j,i,iblock).eq.2) then
177 do k=1,nterm(j,i,iblock)
180 x(ii)=v1(k,j,i,iblock)
181 x_low(ii)=weitor_low(0,j,i,iblock)
182 x_up(ii)=weitor_up(0,j,i,iblock)
183 c write (iout,'(2a4,3i4)') restyp(itor2typ(j)),
184 c & restyp(itor2typ(i)),iblock,k,ii
186 else if (mask_tor(0,j,i,iblock).gt.2) then
187 do k=1,nterm(j,i,iblock)
190 x(ii)=v1(k,j,i,iblock)
191 x_low(ii)=weitor_low(0,j,i,iblock)
192 x_up(ii)=weitor_up(0,j,i,iblock)
193 c write (iout,'(2a4,3i4)') restyp(itor2typ(j)),
194 c & restyp(itor2typ(i)),iblock,k,ii
196 do k=1,nterm(j,i,iblock)
199 x(ii)=v2(k,j,i,iblock)
200 x_low(ii)=weitor_low(0,j,i,iblock)
201 x_up(ii)=weitor_up(0,j,i,iblock)
202 c write (iout,'(2a4,3i4)') restyp(itor2typ(j)),
203 c & restyp(itor2typ(i)),ii,k,ii
208 else if (tor_mode.eq.1) then
210 if (mask_tor(0,j,i,1).eq.1) then
213 x(ii)=weitor(0,j,i,1)
214 x_low(ii)=weitor_low(0,j,i,1)
215 x_up(ii)=weitor_up(0,j,i,1)
216 c write (iout,'(2a4,i4)') restyp(itor2typ(j)),
217 c & restyp(itor2typ(i)),ii
218 else if (mask_tor(0,j,i,1).eq.2) then
219 do k=1,nterm_kcc(j,i)
220 do l=1,nterm_kcc_Tb(j,i)
221 do ll=1,nterm_kcc_Tb(j,i)
224 x(ii)=v1_kcc(ll,l,k,j,i)
225 x_low(ii)=weitor_low(0,j,i,1)
226 x_up(ii)=weitor_up(0,j,i,1)
227 c write (iout,'(2a4,2i4)') restyp(itor2typ(j)),
228 c & restyp(itor2typ(i)),k,ii
232 else if (mask_tor(0,j,i,1).gt.2) then
233 do k=1,nterm_kcc(j,i)
234 do l=1,nterm_kcc_Tb(j,i)
235 do ll=1,nterm_kcc_Tb(j,i)
238 x(ii)=v1_kcc(ll,l,k,j,i)
239 x_low(ii)=weitor_low(0,j,i,1)
240 x_up(ii)=weitor_up(0,j,i,1)
241 c write (iout,'(2a4,2i4)') restyp(itor2typ(j)),
242 c & restyp(itor2typ(i)),k,ii
246 do k=1,nterm_kcc(j,i)
247 do l=1,nterm_kcc_Tb(j,i)
248 do ll=1,nterm_kcc_Tb(j,i)
251 x(ii)=v2_kcc(ll,l,k,j,i)
252 x_low(ii)=weitor_low(0,j,i,1)
253 x_up(ii)=weitor_up(0,j,i,1)
254 c write (iout,'(2a4,2i4)') restyp(itor2typ(j)),
255 c & restyp(itor2typ(i)),k,ii
262 c Compute torsional coefficients from local energy surface expansion coeffs
263 if (mask_tor(0,j,i,1).eq.1) then
265 c write (iout,*) "i",i," j",j," weitor",weitor(0,j,i,1)
266 x(ii)=weitor(0,j,i,1)
267 x_low(ii)=weitor_low(0,j,i,1)
268 x_up(ii)=weitor_up(0,j,i,1)
271 write (iout,*) "ERROR: TOR_MODE>1 ALLOWED ONLY WITH NEWCORR"
280 nbacktor_var=ntor_var
281 c write (iout,*) "nbacktor_var",nbacktor_var
285 c write (iout,*) "Indices of optimizable SCCOR torsionals"
286 do i=-nsccortyp,nsccortyp
287 do j=-nsccortyp,nsccortyp
289 c write (iout,*) "mask",i,j,mask_tor(j,i)
290 if (mask_tor(k,j,i,1).eq.1) then
293 x(ii)=weitor(k,j,i,1)
294 x_low(ii)=weitor_low(k,j,i,1)
295 x_up(ii)=weitor_up(k,j,i,1)
296 c write (iout,'(i4,2a4,i4)') k,restyp(j),restyp(i),ii
297 else if (mask_tor(k,j,i,1).eq.2) then
298 do l=1,nterm_sccor(j,i)
301 x(ii)=v1sccor(l,k,j,i)
302 x_low(ii)=weitor_low(k,j,i,1)
303 x_up(ii)=weitor_up(k,j,i,1)
304 c write (iout,'(i4,2a4,2i4)') k,restyp(j),restyp(i),l,ii
306 else if (mask_tor(k,j,i,1).gt.2) then
307 do l=1,nterm_sccor(j,i)
310 x(ii)=v1sccor(l,k,j,i)
311 x_low(ii)=weitor_low(k,j,i,1)
312 x_up(ii)=weitor_up(k,j,i,1)
313 c write (iout,'(i4,2a4,2i4)') k,restyp(j),restyp(i),l,ii
315 do l=1,nterm_sccor(j,i)
318 x(ii)=v2sccor(l,k,j,i)
319 x_low(ii)=weitor_low(k,j,i,1)
320 x_up(ii)=weitor_up(k,j,i,1)
321 c write (iout,'(i4,2a4,2i4)') k,restyp(j),restyp(i),l,ii
330 c 7/8/17 AL Optimization of the bending potentials
335 if (mask_ang(i).eq.0) cycle
339 c write (iout,*) "var2x: angle_PMF",ii
340 mask_v1bend_chyb(0,i)=ii
341 c nang_var=nang_var+1
342 x(ii)=v1bend_chyb(0,i)
343 x_low(ii)=v1bend_low(0,i)
344 x_up(ii)=v1bend_up(0,i)
347 do j=0,nbend_kcc_TB(i)
349 mask_v1bend_chyb(j,i)=ii
351 x(ii)=v1bend_chyb(j,i)
352 x_low(ii)=v1bend_low(j,i)
353 x_up(ii)=v1bend_up(j,i)
357 c write (iout,*) "nang_var",nang_var
359 c Optimized cumulant coefficients
361 if(mod_fourier(nloctyp).gt.0)then
366 if (mod_fourier(i).gt.0) then
370 if (mask_bnew1(k,j,i).gt.0) then
373 if (mask_bnewtor1(k,j,i).eq.0) mask_bnewtor1(k,j,i)=-ii
375 x_low(ii)=bnew1_low(k,j,i)
376 x_up(ii)=bnew1_up(k,j,i)
383 if (mask_bnew2(k,j,i).gt.0) then
387 x_low(ii)=bnew2_low(k,j,i)
388 x_up(ii)=bnew2_up(k,j,i)
395 if (mask_ccnew(k,j,i).gt.0) then
399 x_low(ii)=ccnew_low(k,j,i)
400 x_up(ii)=ccnew_up(k,j,i)
407 if (mask_ddnew(k,j,i).gt.0) then
411 x_low(ii)=ddnew_low(k,j,i)
412 x_up(ii)=ddnew_up(k,j,i)
418 if (mask_e0new(j,i).gt.0) then
422 x_low(ii)=e0new_low(j,i)
423 x_up(ii)=e0new_up(j,i)
430 if (mask_eenew(l,k,j,i).gt.0) then
432 mask_eenew(l,k,j,i)=ii
434 x_low(ii)=eenew_low(l,k,j,i)
435 x_up(ii)=eenew_up(l,k,j,i)
447 IF ( SPLIT_FOURIERTOR .and. tor_mode.eq.2) THEN
451 write (iout,*) "type",i," mod_fouriertor",mod_fouriertor(i)
452 if (mod_fouriertor(i).gt.0) then
456 write (iout,*) "mask_bnew2tor",k,j,mask_bnew1tor(k,j,i)
457 if (mask_bnew1tor(k,j,i).gt.0) then
459 mask_bnew1tor(k,j,i)=ii
460 x(ii)=bnew1tor(k,j,i)
461 x_low(ii)=bnew1tor_low(k,j,i)
462 x_up(ii)=bnew1tor_up(k,j,i)
469 write (iout,*) "mask_bnew2tor",j,k,mask_bnew2tor(k,j,i)
470 if (mask_bnew2tor(k,j,i).gt.0) then
472 write (iout,*) "ii",ii
473 mask_bnew2tor(k,j,i)=ii
474 x(ii)=bnew2tor(k,j,i)
475 x_low(ii)=bnew2tor_low(k,j,i)
476 x_up(ii)=bnew2tor_up(k,j,i)
483 write (iout,*) "mask_ccnewtor",k,j,mask_ccnewtor(k,j,i)
484 if (mask_ccnewtor(k,j,i).gt.0) then
486 write (iout,*) "ii",ii
487 mask_ccnewtor(k,j,i)=ii
488 x(ii)=ccnewtor(k,j,i)
489 x_low(ii)=ccnewtor_low(k,j,i)
490 x_up(ii)=ccnewtor_up(k,j,i)
497 write (iout,*) "mask_ddnewtor",k,j,mask_ddnewtor(k,j,i)
498 if (mask_ddnewtor(k,j,i).gt.0) then
500 write (iout,*) "ii",ii
501 mask_ddnewtor(k,j,i)=ii
502 x(ii)=ddnewtor(k,j,i)
503 x_low(ii)=ddnewtor_low(k,j,i)
504 x_up(ii)=ddnewtor_up(k,j,i)
509 c write (iout,*) "type",i
511 c write (iout,*) "mask_e0newtor",j,mask_e0newtor(j,i)
512 if (mask_e0newtor(j,i).gt.0) then
514 mask_e0newtor(j,i)=ii
516 x_low(ii)=e0newtor_low(j,i)
517 x_up(ii)=e0newtor_up(j,i)
518 c write (iout,*) j," e0newtorlow",e0newtor_low(j,i),
519 c & " e0newtorup",e0newtor_up(j,i)
526 c write (iout,*)"mask_eenewtor",l,k,j,mask_eenewtor(l,k,j,i)
527 if (mask_eenewtor(l,k,j,i).gt.0) then
529 mask_eenewtor(l,k,j,i)=ii
530 x(ii)=eenewtor(l,k,j,i)
531 x_low(ii)=eenewtor_low(l,k,j,i)
532 x_up(ii)=eenewtor_up(l,k,j,i)
533 c write (iout,*) j,k,l,
534 c & " eenewtorlow",eenewtor_low(l,k,j,i),
535 c & " eenewtorup",eenewtor_up(l,k,j,i)
550 mask_bnewtor1(k,j,i)=-mask_bnew1(k,j,i)
556 mask_bnewtor2(k,j,i)=-mask_bnew2(k,j,i)
562 mask_ccnewtor(k,j,i)=-mask_ccnew(k,j,i)
568 mask_ddnewtor(k,j,i)=-mask_ddnew(k,j,i)
573 mask_e0newtor(j,i)=-mask_e0new(j,i)
579 mask_eenewtor(l,k,j,i)=-mask_eenew(l,k,j,i)
589 if (mod_fourier(i).gt.0) then
591 if (mask_fourier(j,i).gt.0) then
603 c Added SC sigmas and anisotropies
605 if (mod_side_other) then
607 if (mask_sigma(1,i).gt.0) then
610 x_low(ii)=sigma_low(1,i)
611 x_up(ii)=sigma_up(1,i)
612 c write (iout,*) "sig0",i,ii,x(ii), x_low(ii),x_up(ii)
614 if (mask_sigma(2,i).gt.0) then
617 x_low(ii)=sigma_low(2,i)
618 x_up(ii)=sigma_up(2,i)
619 c write (iout,*) "sigi",i,ii,x(ii), x_low(ii),x_up(ii)
621 if (mask_sigma(3,i).gt.0) then
624 x_low(ii)=sigma_low(3,i)
625 x_up(ii)=sigma_up(3,i)
626 c write (iout,*) "chi",i,ii,x(ii), x_low(ii),x_up(ii)
628 if (mask_sigma(4,i).gt.0) then
631 x_low(ii)=sigma_low(4,i)
632 x_up(ii)=sigma_up(4,i)
633 c write (iout,*) "alp",i,ii,x(ii), x_low(ii),x_up(ii)
643 if (mask_elec(i,j,1).gt.0) then
646 x_low(ii)=epp_low(i,j)
649 if (mask_elec(i,j,2).gt.0) then
652 x_low(ii)=rpp_low(i,j)
655 if (mask_elec(i,j,3).gt.0) then
658 x_low(ii)=elpp6_low(i,j)
659 x_up(ii)=elpp6_up(i,j)
661 if (mask_elec(i,j,4).gt.0) then
664 x_low(ii)=elpp3_low(i,j)
665 x_up(ii)=elpp3_up(i,j)
672 C Define the SC-p interaction constants
676 if (mask_scp(0,1,1)+mask_scp(0,2,1)+mask_scp(0,1,2)+
677 & mask_scp(0,2,2) .gt. 0) then
679 if (mask_scp(0,j,1).gt.0) then
682 x_low(ii)=epscp_low(0,j)
683 x_up(ii)=epscp_up(0,j)
685 if (mask_scp(0,j,2).gt.0) then
688 x_low(ii)=rscp_low(0,j)
689 x_up(ii)=rscp_up(0,j)
695 if (mask_scp(i,j,1).gt.0) then
698 x_low(ii)=epscp_low(i,j)
699 x_up(ii)=epscp_up(i,j)
701 if (mask_scp(i,j,2).gt.0) then
704 x_low(ii)=rscp_low(i,j)
705 x_up(ii)=rscp_up(i,j)
713 c Weight of the shielding term
714 if (imask(ind_shield).eq.1) then
717 x_low(ii)=ww_low(ind_shield)
718 x_up(ii)=ww_up(ind_shield)
722 c Compute boundaries, if defined relative to starting values
724 write (iout,*) "i",i," x_low",x_low(i)," x_up",x_up(i)
725 if (x_up(i).eq.0.0d0 .and. x_low(i).gt.0.0d0) then
729 else if (x_up(i).eq.-1.0d0 .and. x_low(i).gt.0.0d0) then
731 if (x(i).gt.0.0d0) then
732 x_low(i)=x(i)*(1.0d0-xchuj)
733 x_up(i)=x(i)*(1.0d0+xchuj)
735 x_low(i)=x(i)*(1.0d0+xchuj)
736 x_up(i)=x(i)*(1.0d0-xchuj)
741 c Base of heat capacity
744 if (nbeta(2,iprot).gt.0) then
746 x(ii)=heatbase(iprot)
754 write (iout,*) "Number of optimizable parameters:",nvarr
756 write (iout,*) "Initial variables and boundaries:"
757 write (iout,'(3x,3a15)') " x"," x_low"," x_up"
759 write (iout,'(i3,3e15.5)') i,x(i),x_low(i),x_up(i)
764 c------------------------------------------------------------------------------
765 subroutine x2w(nvarr,x)
768 include "DIMENSIONS.ZSCOPT"
769 include "COMMON.CONTROL"
770 include "COMMON.NAMES"
771 include "COMMON.WEIGHTS"
772 include "COMMON.INTERACT"
773 include "COMMON.ENERGIES"
774 include "COMMON.FFIELD"
775 include "COMMON.TORSION"
776 include "COMMON.LOCAL"
777 include "COMMON.IOUNITS"
778 include "COMMON.VMCPAR"
779 include "COMMON.CLASSES"
780 include "COMMON.WEIGHTDER"
781 include "COMMON.SCCOR"
782 include "COMMON.SHIELD"
784 integer i,j,k,kk,l,ll,ii,nvarr,iti,itj,iprot,iblock
785 double precision rri,v0ij,si
786 double precision x(nvarr)
787 double precision epsij,rrij,sigeps,sigt1sq,sigt2sq,sigii1,sigii2,
788 & ratsig1,ratsig2,rsum_max,dwa16,r_augm
789 double precision eps_temp(ntyp,ntyp)
790 double precision ftune_eps,ftune_epsprim
791 logical in_sc_pair_list
792 external in_sc_pair_list
793 integer itor2typ(3) /10,9,20/
794 integer ind_shield /25/
799 write (iout,*) "x2w: nvar",nvarr
800 write (iout,*) "x",(x(i),i=1,nvarr)
801 write(iout,*)"X2W: SPLIT_FOURIERTOR",SPLIT_FOURIERTOR,
802 & " tor_mode",tor_mode
803 write(iout,*) "PDBPMF",pdbpmf," mask_beta_pdb",mask_beta_pdb
807 if (imask(i).gt.0 .and. i.ne.ind_shield) then
810 c write (iout,*) i, wname(i)," ",ww(i)
814 c 2/10/208 AL: insert the base torsional PMFs
815 if(mod_fourier(nloctyp).gt.0.or.mod_fouriertor(nloctyp).gt.0)then
818 if (mask_e0(iti,itj).gt.0) then
824 if (mask_ello_PMF.gt.0) then
828 if (mask_turn_PMF.gt.0) then
832 if (mask_beta_PDB.gt.0) then
864 write (iout,*) "Weights:"
866 write (iout,'(a,f10.5)') wname(i),ww(i)
877 if (.not. in_sc_pair_list(iti,j)) then
878 eps(iti,j)=eps_orig(iti,j)
879 & +0.5d0*(x(ii)-eps_orig(iti,iti))
880 eps(j,iti)=eps(iti,j)
894 if (mod_tor .or. mod_fourier(nloctyp).gt.0) then
895 c write (iout,*) "w2x: mod_tor",mod_tor," mod_fourier",
896 c & mod_fourier(nloctyp)
900 do i=-ntortyp+1,ntortyp-1
901 do j=-ntortyp+1,ntortyp-1
902 if (tor_mode.eq.0) then
904 if (mask_tor(0,j,i,iblock).eq.1) then
906 weitor(0,j,i,iblock)=x(ii)
907 else if (mask_tor(0,j,i,iblock).eq.2) then
908 do k=1,nterm(j,i,iblock)
910 v1(k,j,i,iblock)=x(ii)
912 else if (mask_tor(0,j,i,iblock).gt.2) then
913 do k=1,nterm(j,i,iblock)
915 v1(k,j,i,iblock)=x(ii)
917 do k=1,nterm(j,i,iblock)
919 v2(k,j,i,iblock)=x(ii)
924 do k=1,nterm(i,j,iblock)
925 v1(k,-i,-j,iblock)=v1(k,i,j,iblock)
926 v2(k,-i,-j,iblock)=-v2(k,i,j,iblock)
927 v0ij=v0ij+si*v1(k,i,j,iblock)
930 do k=1,nlor(i,j,iblock)
931 v0ij=v0ij+vlor1(k,i,j)/(1+vlor3(k,i,j)**2)
934 v0(-i,-j,iblock)=v0ij
936 else if (tor_mode.eq.1) then
937 if (mask_tor(0,j,i,1).eq.1) then
939 weitor(0,j,i,1)=x(ii)
940 else if (mask_tor(0,j,i,1).eq.2) then
941 do k=1,nterm_kcc(j,i)
942 do l=1,nterm_kcc_Tb(j,i)
943 do ll=1,nterm_kcc_Tb(j,i)
945 v1_kcc(ll,l,k,j,i)=x(ii)
949 else if (mask_tor(0,j,i,1).gt.2) then
950 do k=1,nterm_kcc(j,i)
951 do l=1,nterm_kcc_Tb(j,i)
952 do ll=1,nterm_kcc_Tb(j,i)
954 v1_kcc(ll,l,k,j,i)=x(ii)
958 do k=1,nterm_kcc(j,i)
959 do l=1,nterm_kcc_Tb(j,i)
960 do ll=1,nterm_kcc_Tb(j,i)
962 v2_kcc(ll,l,k,j,i)=x(ii)
969 c Compute torsional coefficients from local energy surface expansion coeffs
970 if (mask_tor(0,j,i,1).eq.1) then
972 weitor(0,j,i,1)=x(ii)
973 c else if (mask_tor(0,j,i,1).eq.2) then
976 write (iout,*) "ERROR: TOR_MODE>1 ALLOWED ONLY WITH NEWCORR"
986 do i=-nsccortyp,nsccortyp
987 do j=-nsccortyp,nsccortyp
989 if (mask_tor(k,j,i,1).eq.1) then
991 weitor(k,j,i,1)=x(ii)
992 else if (mask_tor(k,j,i,1).eq.2) then
995 v1sccor(l,k,j,i)=x(ii)
997 else if (mask_tor(k,j,i,1).gt.2) then
998 do l=1,nterm_sccor(j,i)
1000 v1sccor(l,k,j,i)=x(ii)
1002 do l=1,nterm_sccor(j,i)
1004 v2sccor(l,k,j,i)=x(ii)
1013 c 7/8/17 AL Optimization of the bending potentials
1017 if (mask_ang(i).eq.0) cycle
1021 c write (iout,*) "angle_PMF:",ii
1022 v1bend_chyb(0,i)=x(ii)
1023 v1bend_chyb(0,-i)=x(ii)
1026 do j=0,nbend_kcc_TB(i)
1028 v1bend_chyb(j,i)=x(ii)
1029 v1bend_chyb(j,-i)=x(ii)
1035 if (mod_fourier(nloctyp).gt.0) then
1040 if (mod_fourier(i).gt.0) then
1044 if (mask_bnew1(k,j,i).gt.0) then
1053 if (mask_bnew2(k,j,i).gt.0) then
1062 if (mask_ccnew(k,j,i).gt.0) then
1071 if (mask_ddnew(k,j,i).gt.0) then
1079 if (mask_e0new(j,i).gt.0) then
1088 if (mask_eenew(l,k,j,i).gt.0) then
1090 eenew(l,k,j,i)=x(ii)
1102 bnew1(j,1,-i)= bnew1(j,1,i)
1103 bnew1(j,2,-i)=-bnew1(j,2,i)
1104 bnew2(j,1,-i)= bnew2(j,1,i)
1105 bnew2(j,2,-i)=-bnew2(j,2,i)
1108 c ccnew(j,1,i)=ccnew(j,1,i)/2
1109 c ccnew(j,2,i)=ccnew(j,2,i)/2
1110 c ddnew(j,1,i)=ddnew(j,1,i)/2
1111 c ddnew(j,2,i)=ddnew(j,2,i)/2
1112 ccnew(j,1,-i)=ccnew(j,1,i)
1113 ccnew(j,2,-i)=-ccnew(j,2,i)
1114 ddnew(j,1,-i)=ddnew(j,1,i)
1115 ddnew(j,2,-i)=-ddnew(j,2,i)
1117 e0new(1,-i)= e0new(1,i)
1118 e0new(2,-i)=-e0new(2,i)
1119 e0new(3,-i)=-e0new(3,i)
1121 eenew(kk,1,1,-i)= eenew(kk,1,1,i)
1122 eenew(kk,1,2,-i)=-eenew(kk,1,2,i)
1123 eenew(kk,2,1,-i)=-eenew(kk,2,1,i)
1124 eenew(kk,2,2,-i)= eenew(kk,2,2,i)
1128 write (iout,'(a)') "Coefficients of the multibody terms"
1129 do i=-nloctyp+1,nloctyp-1
1130 write (iout,*) "Type: ",onelet(iloctyp(i))
1131 write (iout,*) "Coefficients of the expansion of B1"
1133 write (iout,'(3hB1(,i1,1h),3f10.5)') j,(bnew1(k,j,i),k=1,3)
1135 write (iout,*) "Coefficients of the expansion of B2"
1137 write (iout,'(3hB2(,i1,1h),3f10.5)') j,(bnew2(k,j,i),k=1,3)
1139 write (iout,*) "Coefficients of the expansion of C"
1140 write (iout,'(3hC11,3f10.5)') (ccnew(j,1,i),j=1,3)
1141 write (iout,'(3hC12,3f10.5)') (ccnew(j,2,i),j=1,3)
1142 write (iout,*) "Coefficients of the expansion of D"
1143 write (iout,'(3hD11,3f10.5)') (ddnew(j,1,i),j=1,3)
1144 write (iout,'(3hD12,3f10.5)') (ddnew(j,2,i),j=1,3)
1145 write (iout,*) "Coefficients of the expansion of E"
1146 write (iout,'(2hE0,3f10.5)') (e0new(j,i),j=1,3)
1149 write (iout,'(1hE,2i1,2f10.5)') j,k,(eenew(l,j,k,i),l=1,2)
1158 IF (SPLIT_FOURIERTOR .and. tor_mode.eq.2) THEN
1161 if (mod_fouriertor(i).gt.0) then
1165 if (mask_bnew1tor(k,j,i).gt.0) then
1167 bnew1tor(k,j,i)=x(ii)
1174 if (mask_bnew2tor(k,j,i).gt.0) then
1176 bnew2tor(k,j,i)=x(ii)
1183 if (mask_ccnewtor(k,j,i).gt.0) then
1185 ccnewtor(k,j,i)=x(ii)
1192 if (mask_ddnewtor(k,j,i).gt.0) then
1194 ddnewtor(k,j,i)=x(ii)
1200 if (mask_e0newtor(j,i).gt.0) then
1209 if (mask_eenewtor(l,k,j,i).gt.0) then
1211 eenewtor(l,k,j,i)=x(ii)
1224 bnew1tor(j,1,-i)= bnew1tor(j,1,i)
1225 bnew1tor(j,2,-i)=-bnew1tor(j,2,i)
1226 bnew2tor(j,1,-i)= bnew2tor(j,1,i)
1227 bnew2tor(j,2,-i)=-bnew2tor(j,2,i)
1230 c ccnew(j,1,i)=ccnew(j,1,i)/2
1231 c ccnew(j,2,i)=ccnew(j,2,i)/2
1232 c ddnew(j,1,i)=ddnew(j,1,i)/2
1233 c ddnew(j,2,i)=ddnew(j,2,i)/2
1234 ccnewtor(j,1,-i)=ccnewtor(j,1,i)
1235 ccnewtor(j,2,-i)=-ccnewtor(j,2,i)
1236 ddnewtor(j,1,-i)=ddnewtor(j,1,i)
1237 ddnewtor(j,2,-i)=-ddnewtor(j,2,i)
1239 e0newtor(1,-i)= e0newtor(1,i)
1240 e0newtor(2,-i)=-e0newtor(2,i)
1241 e0newtor(3,-i)=-e0newtor(3,i)
1243 eenewtor(kk,1,1,-i)= eenewtor(kk,1,1,i)
1244 eenewtor(kk,1,2,-i)=-eenewtor(kk,1,2,i)
1245 eenewtor(kk,2,1,-i)=-eenewtor(kk,2,1,i)
1246 eenewtor(kk,2,2,-i)= eenewtor(kk,2,2,i)
1251 & "Coefficients of the single-body torsional terms"
1252 do i=-nloctyp+1,nloctyp-1
1253 write (iout,*) "Type: ",onelet(iloctyp(i))
1254 write (iout,*) "Coefficients of the expansion of B1"
1256 write (iout,'(3hB1(,i1,1h),3f10.5)')
1257 & j,(bnew1tor(k,j,i),k=1,3)
1259 write (iout,*) "Coefficients of the expansion of B2"
1261 write (iout,'(3hB2(,i1,1h),3f10.5)')
1262 & j,(bnew2tor(k,j,i),k=1,3)
1264 write (iout,*) "Coefficients of the expansion of C"
1265 write (iout,'(3hC11,3f10.5)') (ccnewtor(j,1,i),j=1,3)
1266 write (iout,'(3hC12,3f10.5)') (ccnewtor(j,2,i),j=1,3)
1267 write (iout,*) "Coefficients of the expansion of D"
1268 write (iout,'(3hD11,3f10.5)') (ddnewtor(j,1,i),j=1,3)
1269 write (iout,'(3hD12,3f10.5)') (ddnewtor(j,2,i),j=1,3)
1270 write (iout,*) "Coefficients of the expansion of E"
1271 write (iout,'(2hE0,3f10.5)') (e0newtor(j,i),j=1,3)
1274 write (iout,'(1hE,2i1,2f10.5)')
1275 & j,k,(eenewtor(l,j,k,i),l=1,2)
1284 do i=-nloctyp+1,nloctyp-1
1287 bnew1tor(k,j,i)=bnew1(k,j,i)
1292 bnew2tor(k,j,i)=bnew2(k,j,i)
1296 ccnewtor(k,1,i)=ccnew(k,1,i)
1297 ccnewtor(k,2,i)=ccnew(k,2,i)
1298 ddnewtor(k,1,i)=ddnew(k,1,i)
1299 ddnewtor(k,2,i)=ddnew(k,2,i)
1303 e0newtor(j,i)=e0new(j,i)
1309 eenewtor(l,k,j,i)=eenew(l,k,j,i)
1316 ENDIF ! SPLIT_FOURIERTOR
1318 if (tor_mode.eq.2) then
1319 c Recalculate new torsional potential coefficients
1320 do i=-ntortyp+1,ntortyp-1
1321 do j=-ntortyp+1,ntortyp-1
1322 do k=1,nterm_kcc_Tb(j,i)
1323 do l=1,nterm_kcc_Tb(j,i)
1324 v1_kcc(k,l,1,i,j)=bnew1tor(k,1,i)*bnew2tor(l,1,j)
1325 & +bnew1tor(k,2,i)*bnew2tor(l,2,j)
1326 v2_kcc(k,l,1,i,j)=bnew1tor(k,1,i)*bnew2tor(l,2,j)
1327 & +bnew1tor(k,2,i)*bnew2tor(l,1,j)
1330 do k=1,nterm_kcc_Tb(j,i)
1331 do l=1,nterm_kcc_Tb(j,i)
1332 c v1_kcc(k,l,2,i,j)=-0.25*(ccnewtor(k,1,i)*ddnewtor(l,1,j)
1333 c & -ccnewtor(k,2,i)*ddnewtor(l,2,j))
1334 c v2_kcc(k,l,2,i,j)=-0.25*(ccnewtor(k,2,i)*ddnewtor(l,1,j)
1335 c & +ccnewtor(k,1,i)*ddnewtor(l,2,j))
1336 v1_kcc(k,l,2,i,j)=-(ccnewtor(k,1,i)*ddnewtor(l,1,j)
1337 & -ccnewtor(k,2,i)*ddnewtor(l,2,j))
1338 v2_kcc(k,l,2,i,j)=-(ccnewtor(k,2,i)*ddnewtor(l,1,j)
1339 & +ccnewtor(k,1,i)*ddnewtor(l,2,j))
1348 if (mod_fourier(i).gt.0) then
1351 if (mask_fourier(j,i).gt.0) then
1358 write (iout,*) "Fourier coefficients of cumulants"
1359 write (iout,*) 'Type',i
1360 write (iout,'(a,i2,a,f10.5)') ('b(',j,')=',b(j,i),j=1,13)
1371 c B1tilde(1,i) = b(3,i)
1372 c B1tilde(2,i) =-b(5,i)
1375 CCold(1,1,i)= b(7,i)
1376 CCold(2,2,i)=-b(7,i)
1377 CCold(2,1,i)= b(9,i)
1378 CCold(1,2,i)= b(9,i)
1379 CCold(1,1,-i)= b(7,i)
1380 CCold(2,2,-i)=-b(7,i)
1381 CCold(2,1,-i)=-b(9,i)
1382 CCold(1,2,-i)=-b(9,i)
1383 c Ctilde(1,1,i)=b(7,i)
1384 c Ctilde(1,2,i)=b(9,i)
1385 c Ctilde(2,1,i)=-b(9,i)
1386 c Ctilde(2,2,i)=b(7,i)
1387 DDold(1,1,i)= b(6,i)
1388 DDold(2,2,i)=-b(6,i)
1389 DDold(2,1,i)= b(8,i)
1390 DDold(1,2,i)= b(8,i)
1391 DDold(1,1,-i)= b(6,i)
1392 DDold(2,2,-i)=-b(6,i)
1393 DDold(2,1,-i)=-b(8,i)
1394 DDold(1,2,-i)=-b(8,i)
1395 c Dtilde(1,1,i)=b(6,i)
1396 c Dtilde(1,2,i)=b(8,i)
1397 c Dtilde(2,1,i)=-b(8,i)
1398 c Dtilde(2,2,i)=b(6,i)
1399 EEold(1,1,i)= b(10,i)+b(11,i)
1400 EEold(2,2,i)=-b(10,i)+b(11,i)
1401 EEold(2,1,i)= b(12,i)-b(13,i)
1402 EEold(1,2,i)= b(12,i)+b(13,i)
1403 EEold(1,1,i)= b(10,i)+b(11,i)
1404 EEold(2,2,i)=-b(10,i)+b(11,i)
1405 EEold(2,1,i)= b(12,i)-b(13,i)
1406 EEold(1,2,i)= b(12,i)+b(13,i)
1407 EEold(1,1,-i)= b(10,i)+b(11,i)
1408 EEold(2,2,-i)=-b(10,i)+b(11,i)
1409 EEold(2,1,-i)=-b(12,i)+b(13,i)
1410 EEold(1,2,-i)=-b(12,i)-b(13,i)
1418 &"Coefficients of the cumulants (independent of valence angles)"
1419 do i=-nloctyp+1,nloctyp-1
1420 write (iout,*) 'Type ',onelet(iloctyp(i))
1422 write(iout,'(2f10.5)') B(3,i),B(5,i)
1424 write(iout,'(2f10.5)') B(2,i),B(4,i)
1427 write (iout,'(2f10.5)') CCold(j,1,i),CCold(j,2,i)
1431 write (iout,'(2f10.5)') DDold(j,1,i),DDold(j,2,i)
1435 write (iout,'(2f10.5)') EEold(j,1,i),EEold(j,2,i)
1441 c SC sigmas and anisotropies as parameters
1442 if (mod_side_other) then
1444 c write (iout,*) "mask",i,(mask_sigma(k,i),k=1,4)
1447 if (mask_sigma(1,i).gt.0) then
1450 c write(iout,*) "sig0",i,ii,x(ii)
1452 if (mask_sigma(2,i).gt.0) then
1455 c write(iout,*) "sigi",i,ii,x(ii)
1457 if (mask_sigma(3,i).gt.0) then
1460 c write(iout,*) "chip",i,ii,x(ii)
1462 if (mask_sigma(4,i).gt.0) then
1465 c write(iout,*) "alp",i,ii,x(ii)
1470 if (mod_side.or.mod_side_other) then
1471 if (lprint) write(iout,'(/3a,2i3)') 'Potential is ',
1472 & potname(ipot),', exponents are ',expon,2*expon
1473 C-----------------------------------------------------------------------
1474 C Calculate the "working" parameters of SC interactions.
1475 dwa16=2.0d0**(1.0d0/6.0d0)
1478 chip(i)=(chip0(i)-1.0D0)/(chip0(i)+1.0D0)
1483 sigma(i,j)=dsqrt(sigma0(i)**2+sigma0(j)**2)
1484 sigma(j,i)=sigma(i,j)
1485 rs0(i,j)=dwa16*sigma(i,j)
1489 if (lprint) call printmat(ntyp,ntyp,ntyp,iout,restyp,eps)
1490 if (lprint) write (iout,'(/a/10x,7a/72(1h-))')
1491 & 'Working parameters of the SC interactions:',
1492 & ' a ',' b ',' augm ',' sigma ',' r0 ',
1497 if (ipot.eq.1 .or. ipot.eq.3 .or. ipot.eq.4) then
1506 c sigeps=dsign(1.0D0,epsij)
1507 aa(i,j)=ftune_eps(epsij)*rrij*rrij
1512 sigt1sq=sigma0(i)**2
1513 sigt2sq=sigma0(j)**2
1516 ratsig1=sigt2sq/sigt1sq
1517 ratsig2=1.0D0/ratsig1
1518 chi(i,j)=(sigii1-1.0D0)/(sigii1+ratsig1)
1519 if (j.gt.i) chi(j,i)=(sigii2-1.0D0)/(sigii2+ratsig2)
1520 rsum_max=dsqrt(sigii1*sigt1sq+sigii2*sigt2sq)
1524 sigmaii(i,j)=rsum_max
1525 sigmaii(j,i)=rsum_max
1526 if ((ipot.eq.2 .or. ipot.eq.5) .and. r0(i,j).gt.rsum_max)
1528 r_augm=sigma(i,j)*(rrij-sigma(i,j))/rrij
1529 augm(i,j)=epsij*r_augm**(2*expon)
1530 c augm(i,j)=0.5D0**(2*expon)*aa(i,j)
1537 write (iout,'(2(a3,2x),3(1pe10.3),5(0pf8.3))')
1538 & restyp(i),restyp(j),aa(i,j),bb(i,j),augm(i,j),
1539 & sigma(i,j),r0(i,j),chi(i,j),chi(j,i)
1550 if (mask_elec(i,j,1).gt.0) then
1553 if (epp(i,j).lt.0.0d0) epp(i,j)=0.0d0
1556 if (mask_elec(i,j,2).gt.0) then
1558 rpp(i,j)=dabs(x(ii))
1559 rpp(j,i)=dabs(x(ii))
1561 if (mask_elec(i,j,3).gt.0) then
1564 if (elpp6(i,j).gt.0.0d0) elpp6(i,j)=0.0d0
1565 elpp6(j,i)=elpp6(i,j)
1567 if (mask_elec(i,j,4).gt.0) then
1573 app (i,j)=epp(i,j)*rri*rri
1574 app (j,i)=epp(j,i)*rri*rri
1575 bpp (i,j)=-2.0D0*epp(i,j)*rri
1576 bpp (j,i)=-2.0D0*epp(i,j)*rri
1577 ael6(i,j)=elpp6(i,j)*4.2D0**6
1578 ael6(j,i)=elpp6(i,j)*4.2D0**6
1579 ael3(i,j)=elpp3(i,j)*4.2D0**3
1580 ael3(j,i)=elpp3(i,j)*4.2D0**3
1584 write (iout,'(/a)') 'Electrostatic interaction constants:'
1585 write (iout,'(1x,a,1x,a,10x,a,11x,a,11x,a,11x,a)')
1586 & 'IT','JT','APP','BPP','AEL6','AEL3'
1589 write(iout,'(2i3,4(1pe15.4))')i,j,app(i,j),bpp(i,j),
1590 & ael6(i,j),ael3(i,j)
1597 C Define the SC-p interaction constants
1601 if (mask_scp(0,1,1)+mask_scp(0,2,1)+mask_scp(0,1,2)+
1602 & mask_scp(0,2,2) .gt. 0) then
1604 if (mask_scp(0,j,1).gt.0) then
1610 if (mask_scp(0,j,2).gt.0) then
1620 if (mask_scp(i,j,1).gt.0) then
1624 if (mask_scp(i,j,2).gt.0) then
1632 aad(i,1)=dabs(eps_scp(i,1))*rscp(i,1)**12
1633 aad(i,2)=dabs(eps_scp(i,2))*rscp(i,2)**12
1634 bad(i,1)=-2*eps_scp(i,1)*rscp(i,1)**6
1635 bad(i,2)=-2*eps_scp(i,2)*rscp(i,2)**6
1639 write (iout,*) "Parameters of SC-p interactions:"
1641 write (iout,'(4f8.3,4e12.4)') eps_scp(i,1),rscp(i,1),
1642 & eps_scp(i,2),rscp(i,2),aad(i,1),bad(i,1),aad(i,2),bad(i,2)
1648 c Weight of the shielding term
1649 if (imask(ind_shield).eq.1) then
1651 ww(ind_shield)=x(ii)
1653 wshield=ww(ind_shield)
1655 c write (iout,*) "x2w: nvar",nvarr
1657 c Base of heat capacity
1660 if (nbeta(2,iprot).gt.0) then
1662 heatbase(iprot)=x(ii)
1666 if (ii.ne.nvarr) then
1667 write (iout,*) "!!!!! SEVERE ERROR IN X2W !!!!! (chuj nastapil)"
1668 write (iout,*) "NVAR=",nvarr," LAST VARIABLE INDEX=",ii
1669 stop "CHUJ ABSOLUTNY!!!!"
1674 c---------------------------------------------------------------------------
1675 double precision function ftune_eps(x)
1677 double precision x,y
1678 double precision delta /1.0d-5/
1679 if (dabs(x).lt.delta) then
1681 ftune_eps=delta*(3.0d0+6.0d0*y**2-y**4)/8
1687 c---------------------------------------------------------------------------
1688 double precision function ftune_epsprim(x)
1690 double precision x,y
1691 double precision delta /1.0d-5/
1692 if (dabs(x).lt.delta) then
1694 ftune_epsprim=1.5d0*y-0.5*y**3
1696 ftune_epsprim=dsign(1.0d0,x)
1700 c---------------------------------------------------------------------------
1701 double precision function ftune_epsbis(x)
1703 double precision x,y
1704 double precision delta /1.0d-5/
1705 if (dabs(x).lt.delta) then
1707 ftune_epsbis=(1.5d0-1.5d0*y**3)/delta
1713 c---------------------------------------------------------------------------
1714 logical function in_sc_pair_list(iti,itj)
1716 include "DIMENSIONS"
1717 include "DIMENSIONS.ZSCOPT"
1718 include "COMMON.WEIGHTS"
1721 if (ityp_psc(1,i).eq.iti .and. ityp_psc(2,i).eq.itj .or.
1722 & ityp_psc(1,i).eq.itj .and. ityp_psc(2,i).eq.iti) then
1723 in_sc_pair_list=.true.
1727 in_sc_pair_list=.false.