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 c write (iout,*) "W2X: SPLIT_FOURIERTOR",SPLIT_FOURIERTOR,
27 c & " tor_mode",tor_mode
30 if (imask(i).eq.1 .and. i.ne.ind_shield) then
38 c 2/10/208 AL: insert the base torsional PMFs
39 if (mod_fourier(nloctyp).gt.0) then
45 x_low(ii)=e0_low(iti,itj)
46 x_up(ii)=e0_up(iti,itj)
57 if (torsion_pmf.and.eello_pmf) then
60 x_low(ii)=wello_PMF_low
66 if (turn_pmf.and.(torsion_pmf.or.eello_pmf)) then
69 x_low(ii)=wturn_PMF_low
80 c Change 9/21/07 AL Variables are epsilons and not the increments on epsilons
81 c to enable control on their deviations from original values.
82 c Single-body epsilons are now defined as epsilons of pairs of same type side
85 c write (iout,*) "W2X: mod_side",mod_side," nsingle_sc",nsingle_sc,
86 c & " npair_sc",npair_sc
91 eps_orig(i,j)=eps(i,j)
99 c write (iout,*) "ii",ii," x",x(ii)
100 x_low(ii)=epss_low(i)
102 c if (epss_up(i).eq.0.0d0) then
103 c x_up(ii)=dabs(epsi)*epss_low(i)
104 c x_low(ii)=epsi-x_up(ii)
105 c x_up(ii)=epsi+x_up(ii)
107 c x_low(ii)=epss_low(i)
108 c x_up(ii)=epss_up(i)
117 if (ityp_ssc(j).eq.iti) then
118 write (iout,*) "Error - pair ",restyp(iti),"-",
120 & " specified in variable epsilon list but type defined",
121 & " in single-type list."
128 x_low(ii)=epsp_low(i)
130 c if (epsp_up(i).eq.0.0d0) then
131 c x_up(ii)=dabs(epsi)*epsp_low(i)
132 c x_low(ii)=epsi-x_up(ii)
133 c x_up(ii)=epsi+x_up(ii)
135 c x_low(ii)=epsp_low(i)
136 c x_up(ii)=epsp_up(i)
138 c write (iout,*) "ii",ii," x",x(ii)
148 c write (iout,*) "Indices of optimizable torsionals"
149 do i=-ntortyp+1,ntortyp-1
150 do j=-ntortyp+1,ntortyp-1
151 c write (iout,*) "mask",i,j,mask_tor(j,i)
153 if (tor_mode.eq.0) then
156 if (mask_tor(0,j,i,iblock).eq.1) then
159 x(ii)=weitor(0,j,i,iblock)
160 x_low(ii)=weitor_low(0,j,i,iblock)
161 x_up(ii)=weitor_up(0,j,i,iblock)
162 c write (iout,'(2a4,2i4)') restyp(itor2typ(j)),
163 c & restyp(itor2typ(i)),iblock,ii
164 else if (mask_tor(0,j,i,iblock).eq.2) then
165 do k=1,nterm(j,i,iblock)
168 x(ii)=v1(k,j,i,iblock)
169 x_low(ii)=weitor_low(0,j,i,iblock)
170 x_up(ii)=weitor_up(0,j,i,iblock)
171 c write (iout,'(2a4,3i4)') restyp(itor2typ(j)),
172 c & restyp(itor2typ(i)),iblock,k,ii
174 else if (mask_tor(0,j,i,iblock).gt.2) then
175 do k=1,nterm(j,i,iblock)
178 x(ii)=v1(k,j,i,iblock)
179 x_low(ii)=weitor_low(0,j,i,iblock)
180 x_up(ii)=weitor_up(0,j,i,iblock)
181 c write (iout,'(2a4,3i4)') restyp(itor2typ(j)),
182 c & restyp(itor2typ(i)),iblock,k,ii
184 do k=1,nterm(j,i,iblock)
187 x(ii)=v2(k,j,i,iblock)
188 x_low(ii)=weitor_low(0,j,i,iblock)
189 x_up(ii)=weitor_up(0,j,i,iblock)
190 c write (iout,'(2a4,3i4)') restyp(itor2typ(j)),
191 c & restyp(itor2typ(i)),ii,k,ii
196 else if (tor_mode.eq.1) then
198 if (mask_tor(0,j,i,1).eq.1) then
201 x(ii)=weitor(0,j,i,1)
202 x_low(ii)=weitor_low(0,j,i,1)
203 x_up(ii)=weitor_up(0,j,i,1)
204 c write (iout,'(2a4,i4)') restyp(itor2typ(j)),
205 c & restyp(itor2typ(i)),ii
206 else if (mask_tor(0,j,i,1).eq.2) then
207 do k=1,nterm_kcc(j,i)
208 do l=1,nterm_kcc_Tb(j,i)
209 do ll=1,nterm_kcc_Tb(j,i)
212 x(ii)=v1_kcc(ll,l,k,j,i)
213 x_low(ii)=weitor_low(0,j,i,1)
214 x_up(ii)=weitor_up(0,j,i,1)
215 c write (iout,'(2a4,2i4)') restyp(itor2typ(j)),
216 c & restyp(itor2typ(i)),k,ii
220 else if (mask_tor(0,j,i,1).gt.2) then
221 do k=1,nterm_kcc(j,i)
222 do l=1,nterm_kcc_Tb(j,i)
223 do ll=1,nterm_kcc_Tb(j,i)
226 x(ii)=v1_kcc(ll,l,k,j,i)
227 x_low(ii)=weitor_low(0,j,i,1)
228 x_up(ii)=weitor_up(0,j,i,1)
229 c write (iout,'(2a4,2i4)') restyp(itor2typ(j)),
230 c & restyp(itor2typ(i)),k,ii
234 do k=1,nterm_kcc(j,i)
235 do l=1,nterm_kcc_Tb(j,i)
236 do ll=1,nterm_kcc_Tb(j,i)
239 x(ii)=v2_kcc(ll,l,k,j,i)
240 x_low(ii)=weitor_low(0,j,i,1)
241 x_up(ii)=weitor_up(0,j,i,1)
242 c write (iout,'(2a4,2i4)') restyp(itor2typ(j)),
243 c & restyp(itor2typ(i)),k,ii
250 c Compute torsional coefficients from local energy surface expansion coeffs
251 if (mask_tor(0,j,i,1).eq.1) then
253 c write (iout,*) "i",i," j",j," weitor",weitor(0,j,i,1)
254 x(ii)=weitor(0,j,i,1)
255 x_low(ii)=weitor_low(0,j,i,1)
256 x_up(ii)=weitor_up(0,j,i,1)
259 write (iout,*) "ERROR: TOR_MODE>1 ALLOWED ONLY WITH NEWCORR"
268 nbacktor_var=ntor_var
269 c write (iout,*) "nbacktor_var",nbacktor_var
273 c write (iout,*) "Indices of optimizable SCCOR torsionals"
274 do i=-nsccortyp,nsccortyp
275 do j=-nsccortyp,nsccortyp
277 c write (iout,*) "mask",i,j,mask_tor(j,i)
278 if (mask_tor(k,j,i,1).eq.1) then
281 x(ii)=weitor(k,j,i,1)
282 x_low(ii)=weitor_low(k,j,i,1)
283 x_up(ii)=weitor_up(k,j,i,1)
284 c write (iout,'(i4,2a4,i4)') k,restyp(j),restyp(i),ii
285 else if (mask_tor(k,j,i,1).eq.2) then
286 do l=1,nterm_sccor(j,i)
289 x(ii)=v1sccor(l,k,j,i)
290 x_low(ii)=weitor_low(k,j,i,1)
291 x_up(ii)=weitor_up(k,j,i,1)
292 c write (iout,'(i4,2a4,2i4)') k,restyp(j),restyp(i),l,ii
294 else if (mask_tor(k,j,i,1).gt.2) then
295 do l=1,nterm_sccor(j,i)
298 x(ii)=v1sccor(l,k,j,i)
299 x_low(ii)=weitor_low(k,j,i,1)
300 x_up(ii)=weitor_up(k,j,i,1)
301 c write (iout,'(i4,2a4,2i4)') k,restyp(j),restyp(i),l,ii
303 do l=1,nterm_sccor(j,i)
306 x(ii)=v2sccor(l,k,j,i)
307 x_low(ii)=weitor_low(k,j,i,1)
308 x_up(ii)=weitor_up(k,j,i,1)
309 c write (iout,'(i4,2a4,2i4)') k,restyp(j),restyp(i),l,ii
318 c 7/8/17 AL Optimization of the bending potentials
323 if (mask_ang(i).eq.0) cycle
324 do j=1,nbend_kcc_TB(i)
327 x(ii)=v1bend_chyb(j,i)
328 x_low(ii)=v1bend_low(j,i)
329 x_up(ii)=v1bend_up(j,i)
333 c write (iout,*) "nang_var",nang_var
335 c Optimized cumulant coefficients
337 if (mod_fourier(nloctyp).gt.0) then
342 if (mod_fourier(i).gt.0) then
346 if (mask_bnew1(k,j,i).gt.0) then
349 if (mask_bnewtor1(k,j,i).eq.0) mask_bnewtor1(k,j,i)=-ii
351 x_low(ii)=bnew1_low(k,j,i)
352 x_up(ii)=bnew1_up(k,j,i)
359 if (mask_bnew2(k,j,i).gt.0) then
363 x_low(ii)=bnew2_low(k,j,i)
364 x_up(ii)=bnew2_up(k,j,i)
371 if (mask_ccnew(k,j,i).gt.0) then
375 x_low(ii)=ccnew_low(k,j,i)
376 x_up(ii)=ccnew_up(k,j,i)
383 if (mask_ddnew(k,j,i).gt.0) then
387 x_low(ii)=ddnew_low(k,j,i)
388 x_up(ii)=ddnew_up(k,j,i)
394 if (mask_e0new(j,i).gt.0) then
398 x_low(ii)=e0new_low(j,i)
399 x_up(ii)=e0new_up(j,i)
406 if (mask_eenew(l,k,j,i).gt.0) then
408 mask_eenew(l,k,j,i)=ii
410 x_low(ii)=eenew_low(l,k,j,i)
411 x_up(ii)=eenew_up(l,k,j,i)
421 IF (SPLIT_FOURIERTOR .and. tor_mode.eq.2) THEN
425 c write (iout,*) "type",i," mod_fouriertor",mod_fouriertor(i)
426 if (mod_fouriertor(i).gt.0) then
430 c write (iout,*) "mask_bnew2tor",k,j,mask_bnew1tor(k,j,i)
431 if (mask_bnew1tor(k,j,i).gt.0) then
433 mask_bnew1tor(k,j,i)=ii
434 x(ii)=bnew1tor(k,j,i)
435 x_low(ii)=bnew1tor_low(k,j,i)
436 x_up(ii)=bnew1tor_up(k,j,i)
443 c write (iout,*) "mask_bnew2tor",j,k,mask_bnew2tor(k,j,i)
444 if (mask_bnew2tor(k,j,i).gt.0) then
446 mask_bnew2tor(k,j,i)=ii
447 x(ii)=bnew2tor(k,j,i)
448 x_low(ii)=bnew2tor_low(k,j,i)
449 x_up(ii)=bnew2tor_up(k,j,i)
456 c write (iout,*) "mask_ccnewtor",k,j,mask_ccnewtor(k,j,i)
457 if (mask_ccnewtor(k,j,i).gt.0) then
459 mask_ccnewtor(k,j,i)=ii
460 x(ii)=ccnewtor(k,j,i)
461 x_low(ii)=ccnewtor_low(k,j,i)
462 x_up(ii)=ccnewtor_up(k,j,i)
469 c write (iout,*) "mask_ddnewtor",k,j,mask_ddnewtor(k,j,i)
470 if (mask_ddnewtor(k,j,i).gt.0) then
472 mask_ddnewtor(k,j,i)=ii
473 x(ii)=ddnewtor(k,j,i)
474 x_low(ii)=ddnewtor_low(k,j,i)
475 x_up(ii)=ddnewtor_up(k,j,i)
480 c write (iout,*) "type",i
482 c write (iout,*) "mask_e0newtor",j,mask_e0newtor(j,i)
483 if (mask_e0newtor(j,i).gt.0) then
485 mask_e0newtor(j,i)=ii
487 x_low(ii)=e0newtor_low(j,i)
488 x_up(ii)=e0newtor_up(j,i)
489 c write (iout,*) j," e0newtorlow",e0newtor_low(j,i),
490 c & " e0newtorup",e0newtor_up(j,i)
497 c write (iout,*)"mask_eenewtor",l,k,j,mask_eenewtor(l,k,j,i)
498 if (mask_eenewtor(l,k,j,i).gt.0) then
500 mask_eenewtor(l,k,j,i)=ii
501 x(ii)=eenewtor(l,k,j,i)
502 x_low(ii)=eenewtor_low(l,k,j,i)
503 x_up(ii)=eenewtor_up(l,k,j,i)
504 c write (iout,*) j,k,l,
505 c & " eenewtorlow",eenewtor_low(l,k,j,i),
506 c & " eenewtorup",eenewtor_up(l,k,j,i)
521 mask_bnewtor1(k,j,i)=-mask_bnew1(k,j,i)
527 mask_bnewtor2(k,j,i)=-mask_bnew2(k,j,i)
533 mask_ccnewtor(k,j,i)=-mask_ccnew(k,j,i)
539 mask_ddnewtor(k,j,i)=-mask_ddnew(k,j,i)
544 mask_e0newtor(j,i)=-mask_e0new(j,i)
550 mask_eenewtor(l,k,j,i)=-mask_eenew(l,k,j,i)
560 if (mod_fourier(i).gt.0) then
562 if (mask_fourier(j,i).gt.0) then
575 c Added SC sigmas and anisotropies
577 if (mod_side_other) then
579 if (mask_sigma(1,i).gt.0) then
582 x_low(ii)=sigma_low(1,i)
583 x_up(ii)=sigma_up(1,i)
584 c write (iout,*) "sig0",i,ii,x(ii), x_low(ii),x_up(ii)
586 if (mask_sigma(2,i).gt.0) then
589 x_low(ii)=sigma_low(2,i)
590 x_up(ii)=sigma_up(2,i)
591 c write (iout,*) "sigi",i,ii,x(ii), x_low(ii),x_up(ii)
593 if (mask_sigma(3,i).gt.0) then
596 x_low(ii)=sigma_low(3,i)
597 x_up(ii)=sigma_up(3,i)
598 c write (iout,*) "chi",i,ii,x(ii), x_low(ii),x_up(ii)
600 if (mask_sigma(4,i).gt.0) then
603 x_low(ii)=sigma_low(4,i)
604 x_up(ii)=sigma_up(4,i)
605 c write (iout,*) "alp",i,ii,x(ii), x_low(ii),x_up(ii)
607 if (mask_sigma(5,i).gt.0) then
610 x_low(ii)=sigma_low(5,i)
611 x_up(ii)=sigma_up(5,i)
612 c write (iout,*) "alp",i,ii,x(ii), x_low(ii),x_up(ii)
622 if (mask_elec(i,j,1).gt.0) then
625 x_low(ii)=epp_low(i,j)
628 if (mask_elec(i,j,2).gt.0) then
631 x_low(ii)=rpp_low(i,j)
634 if (mask_elec(i,j,3).gt.0) then
637 x_low(ii)=elpp6_low(i,j)
638 x_up(ii)=elpp6_up(i,j)
640 if (mask_elec(i,j,4).gt.0) then
643 x_low(ii)=elpp3_low(i,j)
644 x_up(ii)=elpp3_up(i,j)
651 C Define the SC-p interaction constants
655 if (mask_scp(0,1,1)+mask_scp(0,2,1)+mask_scp(0,1,2)+
656 & mask_scp(0,2,2) .gt. 0) then
658 if (mask_scp(0,j,1).gt.0) then
661 x_low(ii)=epscp_low(0,j)
662 x_up(ii)=epscp_up(0,j)
664 if (mask_scp(0,j,2).gt.0) then
667 x_low(ii)=rscp_low(0,j)
668 x_up(ii)=rscp_up(0,j)
674 if (mask_scp(i,j,1).gt.0) then
677 x_low(ii)=epscp_low(i,j)
678 x_up(ii)=epscp_up(i,j)
680 if (mask_scp(i,j,2).gt.0) then
683 x_low(ii)=rscp_low(i,j)
684 x_up(ii)=rscp_up(i,j)
692 c Weight of the shielding term
693 if (imask(ind_shield).eq.1) then
696 x_low(ii)=ww_low(ind_shield)
697 x_up(ii)=ww_up(ind_shield)
701 c Compute boundaries, if defined relative to starting values
703 write (iout,*) "i",i," x_low",x_low(i)," x_up",x_up(i)
704 if (x_up(i).eq.0.0d0 .and. x_low(i).gt.0.0d0) then
708 else if (x_up(i).eq.-1.0d0 .and. x_low(i).gt.0.0d0) then
710 if (x(i).gt.0.0d0) then
711 x_low(i)=x(i)*(1.0d0-xchuj)
712 x_up(i)=x(i)*(1.0d0+xchuj)
714 x_low(i)=x(i)*(1.0d0+xchuj)
715 x_up(i)=x(i)*(1.0d0-xchuj)
720 c Base of heat capacity
723 if (nbeta(2,iprot).gt.0) then
725 x(ii)=heatbase(iprot)
733 write (iout,*) "Number of optimizable parameters:",nvarr
735 write (iout,*) "Initial variables and boundaries:"
736 write (iout,'(3x,3a15)') " x"," x_low"," x_up"
738 write (iout,'(i3,3e15.5)') i,x(i),x_low(i),x_up(i)
743 c------------------------------------------------------------------------------
744 subroutine x2w(nvarr,x)
747 include "DIMENSIONS.ZSCOPT"
748 include "COMMON.CONTROL"
749 include "COMMON.NAMES"
750 include "COMMON.WEIGHTS"
751 include "COMMON.INTERACT"
752 include "COMMON.ENERGIES"
753 include "COMMON.FFIELD"
754 include "COMMON.TORSION"
755 include "COMMON.LOCAL"
756 include "COMMON.IOUNITS"
757 include "COMMON.VMCPAR"
758 include "COMMON.CLASSES"
759 include "COMMON.WEIGHTDER"
760 include "COMMON.SCCOR"
761 include "COMMON.SHIELD"
763 integer i,j,k,kk,l,ll,ii,nvarr,iti,itj,iprot,iblock
764 double precision rri,v0ij,si
765 double precision x(nvarr)
766 double precision epsij,rrij,sigeps,sigt1sq,sigt2sq,sigii1,sigii2,
767 & ratsig1,ratsig2,rsum_max,dwa16,r_augm
768 double precision eps_temp(ntyp,ntyp)
769 double precision ftune_eps,ftune_epsprim
770 logical in_sc_pair_list
771 external in_sc_pair_list
772 integer itor2typ(3) /10,9,20/
773 integer ind_shield /25/
777 if (lprint) write (iout,*) "x2w: nvar",nvarr
778 if (lprint) write (iout,*) "x",(x(i),i=1,nvarr)
779 if (lprint) write(iout,*)"X2W: SPLIT_FOURIERTOR",SPLIT_FOURIERTOR,
780 & " tor_mode",tor_mode
783 if (imask(i).eq.1 .and. i.ne.ind_shield) then
786 c write (iout,*) i, wname(i)," ",ww(i)
790 c 2/10/208 AL: insert the base torsional PMFs
791 if (mod_fourier(nloctyp).gt.0) then
794 if (mask_e0(iti,itj).gt.0) then
800 if (mask_ello_PMF.gt.0) then
804 if (mask_turn_PMF.gt.0) then
836 write (iout,*) "Weights:"
838 write (iout,'(a,f10.5)') wname(i),ww(i)
849 if (.not. in_sc_pair_list(iti,j)) then
850 eps(iti,j)=eps_orig(iti,j)
851 & +0.5d0*(x(ii)-eps_orig(iti,iti))
852 eps(j,iti)=eps(iti,j)
866 if (mod_tor .or. mod_fourier(nloctyp).gt.0) then
867 c write (iout,*) "w2x: mod_tor",mod_tor," mod_fourier",
868 c & mod_fourier(nloctyp)
872 do i=-ntortyp+1,ntortyp-1
873 do j=-ntortyp+1,ntortyp-1
874 if (tor_mode.eq.0) then
876 if (mask_tor(0,j,i,iblock).eq.1) then
878 weitor(0,j,i,iblock)=x(ii)
879 else if (mask_tor(0,j,i,iblock).eq.2) then
880 do k=1,nterm(j,i,iblock)
882 v1(k,j,i,iblock)=x(ii)
884 else if (mask_tor(0,j,i,iblock).gt.2) then
885 do k=1,nterm(j,i,iblock)
887 v1(k,j,i,iblock)=x(ii)
889 do k=1,nterm(j,i,iblock)
891 v2(k,j,i,iblock)=x(ii)
896 do k=1,nterm(i,j,iblock)
897 v1(k,-i,-j,iblock)=v1(k,i,j,iblock)
898 v2(k,-i,-j,iblock)=-v2(k,i,j,iblock)
899 v0ij=v0ij+si*v1(k,i,j,iblock)
902 do k=1,nlor(i,j,iblock)
903 v0ij=v0ij+vlor1(k,i,j)/(1+vlor3(k,i,j)**2)
906 v0(-i,-j,iblock)=v0ij
908 else if (tor_mode.eq.1) then
909 if (mask_tor(0,j,i,1).eq.1) then
911 weitor(0,j,i,1)=x(ii)
912 else if (mask_tor(0,j,i,1).eq.2) then
913 do k=1,nterm_kcc(j,i)
914 do l=1,nterm_kcc_Tb(j,i)
915 do ll=1,nterm_kcc_Tb(j,i)
917 v1_kcc(ll,l,k,j,i)=x(ii)
921 else if (mask_tor(0,j,i,1).gt.2) then
922 do k=1,nterm_kcc(j,i)
923 do l=1,nterm_kcc_Tb(j,i)
924 do ll=1,nterm_kcc_Tb(j,i)
926 v1_kcc(ll,l,k,j,i)=x(ii)
930 do k=1,nterm_kcc(j,i)
931 do l=1,nterm_kcc_Tb(j,i)
932 do ll=1,nterm_kcc_Tb(j,i)
934 v2_kcc(ll,l,k,j,i)=x(ii)
941 c Compute torsional coefficients from local energy surface expansion coeffs
942 if (mask_tor(0,j,i,1).eq.1) then
944 weitor(0,j,i,1)=x(ii)
945 c else if (mask_tor(0,j,i,1).eq.2) then
948 write (iout,*) "ERROR: TOR_MODE>1 ALLOWED ONLY WITH NEWCORR"
958 do i=-nsccortyp,nsccortyp
959 do j=-nsccortyp,nsccortyp
961 if (mask_tor(k,j,i,1).eq.1) then
963 weitor(k,j,i,1)=x(ii)
964 else if (mask_tor(k,j,i,1).eq.2) then
967 v1sccor(l,k,j,i)=x(ii)
969 else if (mask_tor(k,j,i,1).gt.2) then
970 do l=1,nterm_sccor(j,i)
972 v1sccor(l,k,j,i)=x(ii)
974 do l=1,nterm_sccor(j,i)
976 v2sccor(l,k,j,i)=x(ii)
985 c 7/8/17 AL Optimization of the bending potentials
989 if (mask_ang(i).eq.0) cycle
990 do j=1,nbend_kcc_TB(i)
992 v1bend_chyb(j,i)=x(ii)
993 v1bend_chyb(j,-i)=x(ii)
999 if (mod_fourier(nloctyp).gt.0) then
1004 if (mod_fourier(i).gt.0) then
1008 if (mask_bnew1(k,j,i).gt.0) then
1017 if (mask_bnew2(k,j,i).gt.0) then
1026 if (mask_ccnew(k,j,i).gt.0) then
1035 if (mask_ddnew(k,j,i).gt.0) then
1043 if (mask_e0new(j,i).gt.0) then
1052 if (mask_eenew(l,k,j,i).gt.0) then
1054 eenew(l,k,j,i)=x(ii)
1066 bnew1(j,1,-i)= bnew1(j,1,i)
1067 bnew1(j,2,-i)=-bnew1(j,2,i)
1068 bnew2(j,1,-i)= bnew2(j,1,i)
1069 bnew2(j,2,-i)=-bnew2(j,2,i)
1072 c ccnew(j,1,i)=ccnew(j,1,i)/2
1073 c ccnew(j,2,i)=ccnew(j,2,i)/2
1074 c ddnew(j,1,i)=ddnew(j,1,i)/2
1075 c ddnew(j,2,i)=ddnew(j,2,i)/2
1076 ccnew(j,1,-i)=ccnew(j,1,i)
1077 ccnew(j,2,-i)=-ccnew(j,2,i)
1078 ddnew(j,1,-i)=ddnew(j,1,i)
1079 ddnew(j,2,-i)=-ddnew(j,2,i)
1081 e0new(1,-i)= e0new(1,i)
1082 e0new(2,-i)=-e0new(2,i)
1083 e0new(3,-i)=-e0new(3,i)
1085 eenew(kk,1,1,-i)= eenew(kk,1,1,i)
1086 eenew(kk,1,2,-i)=-eenew(kk,1,2,i)
1087 eenew(kk,2,1,-i)=-eenew(kk,2,1,i)
1088 eenew(kk,2,2,-i)= eenew(kk,2,2,i)
1092 write (iout,'(a)') "Coefficients of the multibody terms"
1093 do i=-nloctyp+1,nloctyp-1
1094 write (iout,*) "Type: ",onelet(iloctyp(i))
1095 write (iout,*) "Coefficients of the expansion of B1"
1097 write (iout,'(3hB1(,i1,1h),3f10.5)') j,(bnew1(k,j,i),k=1,3)
1099 write (iout,*) "Coefficients of the expansion of B2"
1101 write (iout,'(3hB2(,i1,1h),3f10.5)') j,(bnew2(k,j,i),k=1,3)
1103 write (iout,*) "Coefficients of the expansion of C"
1104 write (iout,'(3hC11,3f10.5)') (ccnew(j,1,i),j=1,3)
1105 write (iout,'(3hC12,3f10.5)') (ccnew(j,2,i),j=1,3)
1106 write (iout,*) "Coefficients of the expansion of D"
1107 write (iout,'(3hD11,3f10.5)') (ddnew(j,1,i),j=1,3)
1108 write (iout,'(3hD12,3f10.5)') (ddnew(j,2,i),j=1,3)
1109 write (iout,*) "Coefficients of the expansion of E"
1110 write (iout,'(2hE0,3f10.5)') (e0new(j,i),j=1,3)
1113 write (iout,'(1hE,2i1,2f10.5)') j,k,(eenew(l,j,k,i),l=1,2)
1120 IF (SPLIT_FOURIERTOR .and. tor_mode.eq.2) THEN
1123 if (mod_fouriertor(i).gt.0) then
1127 if (mask_bnew1tor(k,j,i).gt.0) then
1129 bnew1tor(k,j,i)=x(ii)
1136 if (mask_bnew2tor(k,j,i).gt.0) then
1138 bnew2tor(k,j,i)=x(ii)
1145 if (mask_ccnewtor(k,j,i).gt.0) then
1147 ccnewtor(k,j,i)=x(ii)
1154 if (mask_ddnewtor(k,j,i).gt.0) then
1156 ddnewtor(k,j,i)=x(ii)
1162 if (mask_e0newtor(j,i).gt.0) then
1171 if (mask_eenewtor(l,k,j,i).gt.0) then
1173 eenewtor(l,k,j,i)=x(ii)
1186 bnew1tor(j,1,-i)= bnew1tor(j,1,i)
1187 bnew1tor(j,2,-i)=-bnew1tor(j,2,i)
1188 bnew2tor(j,1,-i)= bnew2tor(j,1,i)
1189 bnew2tor(j,2,-i)=-bnew2tor(j,2,i)
1192 c ccnew(j,1,i)=ccnew(j,1,i)/2
1193 c ccnew(j,2,i)=ccnew(j,2,i)/2
1194 c ddnew(j,1,i)=ddnew(j,1,i)/2
1195 c ddnew(j,2,i)=ddnew(j,2,i)/2
1196 ccnewtor(j,1,-i)=ccnewtor(j,1,i)
1197 ccnewtor(j,2,-i)=-ccnewtor(j,2,i)
1198 ddnewtor(j,1,-i)=ddnewtor(j,1,i)
1199 ddnewtor(j,2,-i)=-ddnewtor(j,2,i)
1201 e0newtor(1,-i)= e0newtor(1,i)
1202 e0newtor(2,-i)=-e0newtor(2,i)
1203 e0newtor(3,-i)=-e0newtor(3,i)
1205 eenewtor(kk,1,1,-i)= eenewtor(kk,1,1,i)
1206 eenewtor(kk,1,2,-i)=-eenewtor(kk,1,2,i)
1207 eenewtor(kk,2,1,-i)=-eenewtor(kk,2,1,i)
1208 eenewtor(kk,2,2,-i)= eenewtor(kk,2,2,i)
1213 & "Coefficients of the single-body torsional terms"
1214 do i=-nloctyp+1,nloctyp-1
1215 write (iout,*) "Type: ",onelet(iloctyp(i))
1216 write (iout,*) "Coefficients of the expansion of B1"
1218 write (iout,'(3hB1(,i1,1h),3f10.5)')
1219 & j,(bnew1tor(k,j,i),k=1,3)
1221 write (iout,*) "Coefficients of the expansion of B2"
1223 write (iout,'(3hB2(,i1,1h),3f10.5)')
1224 & j,(bnew2tor(k,j,i),k=1,3)
1226 write (iout,*) "Coefficients of the expansion of C"
1227 write (iout,'(3hC11,3f10.5)') (ccnewtor(j,1,i),j=1,3)
1228 write (iout,'(3hC12,3f10.5)') (ccnewtor(j,2,i),j=1,3)
1229 write (iout,*) "Coefficients of the expansion of D"
1230 write (iout,'(3hD11,3f10.5)') (ddnewtor(j,1,i),j=1,3)
1231 write (iout,'(3hD12,3f10.5)') (ddnewtor(j,2,i),j=1,3)
1232 write (iout,*) "Coefficients of the expansion of E"
1233 write (iout,'(2hE0,3f10.5)') (e0newtor(j,i),j=1,3)
1236 write (iout,'(1hE,2i1,2f10.5)')
1237 & j,k,(eenewtor(l,j,k,i),l=1,2)
1246 do i=-nloctyp+1,nloctyp-1
1249 bnew1tor(k,j,i)=bnew1(k,j,i)
1254 bnew2tor(k,j,i)=bnew2(k,j,i)
1258 ccnewtor(k,1,i)=ccnew(k,1,i)
1259 ccnewtor(k,2,i)=ccnew(k,2,i)
1260 ddnewtor(k,1,i)=ddnew(k,1,i)
1261 ddnewtor(k,2,i)=ddnew(k,2,i)
1265 e0newtor(j,i)=e0new(j,i)
1271 eenewtor(l,k,j,i)=eenew(l,k,j,i)
1278 ENDIF ! SPLIT_FOURIERTOR
1280 if (tor_mode.eq.2) then
1281 c Recalculate new torsional potential coefficients
1282 do i=-ntortyp+1,ntortyp-1
1283 do j=-ntortyp+1,ntortyp-1
1284 do k=1,nterm_kcc_Tb(j,i)
1285 do l=1,nterm_kcc_Tb(j,i)
1286 v1_kcc(k,l,1,i,j)=bnew1tor(k,1,i)*bnew2tor(l,1,j)
1287 & +bnew1tor(k,2,i)*bnew2tor(l,2,j)
1288 v2_kcc(k,l,1,i,j)=bnew1tor(k,1,i)*bnew2tor(l,2,j)
1289 & +bnew1tor(k,2,i)*bnew2tor(l,1,j)
1292 do k=1,nterm_kcc_Tb(j,i)
1293 do l=1,nterm_kcc_Tb(j,i)
1294 c v1_kcc(k,l,2,i,j)=-0.25*(ccnewtor(k,1,i)*ddnewtor(l,1,j)
1295 c & -ccnewtor(k,2,i)*ddnewtor(l,2,j))
1296 c v2_kcc(k,l,2,i,j)=-0.25*(ccnewtor(k,2,i)*ddnewtor(l,1,j)
1297 c & +ccnewtor(k,1,i)*ddnewtor(l,2,j))
1298 v1_kcc(k,l,2,i,j)=-(ccnewtor(k,1,i)*ddnewtor(l,1,j)
1299 & -ccnewtor(k,2,i)*ddnewtor(l,2,j))
1300 v2_kcc(k,l,2,i,j)=-(ccnewtor(k,2,i)*ddnewtor(l,1,j)
1301 & +ccnewtor(k,1,i)*ddnewtor(l,2,j))
1310 if (mod_fourier(i).gt.0) then
1313 if (mask_fourier(j,i).gt.0) then
1320 write (iout,*) "Fourier coefficients of cumulants"
1321 write (iout,*) 'Type',i
1322 write (iout,'(a,i2,a,f10.5)') ('b(',j,')=',b(j,i),j=1,13)
1333 c B1tilde(1,i) = b(3,i)
1334 c B1tilde(2,i) =-b(5,i)
1337 CCold(1,1,i)= b(7,i)
1338 CCold(2,2,i)=-b(7,i)
1339 CCold(2,1,i)= b(9,i)
1340 CCold(1,2,i)= b(9,i)
1341 CCold(1,1,-i)= b(7,i)
1342 CCold(2,2,-i)=-b(7,i)
1343 CCold(2,1,-i)=-b(9,i)
1344 CCold(1,2,-i)=-b(9,i)
1345 c Ctilde(1,1,i)=b(7,i)
1346 c Ctilde(1,2,i)=b(9,i)
1347 c Ctilde(2,1,i)=-b(9,i)
1348 c Ctilde(2,2,i)=b(7,i)
1349 DDold(1,1,i)= b(6,i)
1350 DDold(2,2,i)=-b(6,i)
1351 DDold(2,1,i)= b(8,i)
1352 DDold(1,2,i)= b(8,i)
1353 DDold(1,1,-i)= b(6,i)
1354 DDold(2,2,-i)=-b(6,i)
1355 DDold(2,1,-i)=-b(8,i)
1356 DDold(1,2,-i)=-b(8,i)
1357 c Dtilde(1,1,i)=b(6,i)
1358 c Dtilde(1,2,i)=b(8,i)
1359 c Dtilde(2,1,i)=-b(8,i)
1360 c Dtilde(2,2,i)=b(6,i)
1361 EEold(1,1,i)= b(10,i)+b(11,i)
1362 EEold(2,2,i)=-b(10,i)+b(11,i)
1363 EEold(2,1,i)= b(12,i)-b(13,i)
1364 EEold(1,2,i)= b(12,i)+b(13,i)
1365 EEold(1,1,i)= b(10,i)+b(11,i)
1366 EEold(2,2,i)=-b(10,i)+b(11,i)
1367 EEold(2,1,i)= b(12,i)-b(13,i)
1368 EEold(1,2,i)= b(12,i)+b(13,i)
1369 EEold(1,1,-i)= b(10,i)+b(11,i)
1370 EEold(2,2,-i)=-b(10,i)+b(11,i)
1371 EEold(2,1,-i)=-b(12,i)+b(13,i)
1372 EEold(1,2,-i)=-b(12,i)-b(13,i)
1380 &"Coefficients of the cumulants (independent of valence angles)"
1381 do i=-nloctyp+1,nloctyp-1
1382 write (iout,*) 'Type ',onelet(iloctyp(i))
1384 write(iout,'(2f10.5)') B(3,i),B(5,i)
1386 write(iout,'(2f10.5)') B(2,i),B(4,i)
1389 write (iout,'(2f10.5)') CCold(j,1,i),CCold(j,2,i)
1393 write (iout,'(2f10.5)') DDold(j,1,i),DDold(j,2,i)
1397 write (iout,'(2f10.5)') EEold(j,1,i),EEold(j,2,i)
1404 c SC sigmas and anisotropies as parameters
1405 if (mod_side_other) then
1407 c write (iout,*) "mask",i,(mask_sigma(k,i),k=1,4)
1410 if (mask_sigma(1,i).gt.0) then
1413 c write(iout,*) "sig0",i,ii,x(ii)
1415 if (mask_sigma(2,i).gt.0) then
1418 c write(iout,*) "sigi",i,ii,x(ii)
1420 if (mask_sigma(3,i).gt.0) then
1423 c write(iout,*) "chip",i,ii,x(ii)
1425 if (mask_sigma(4,i).gt.0) then
1428 c write(iout,*) "alp",i,ii,x(ii)
1430 if (mask_sigma(5,i).gt.0) then
1433 c write(iout,*) "alp",i,ii,x(ii)
1438 c write (iout,*)"mod_side",mod_side," mod_side_ohter",mod_side_other
1439 if (mod_side.or.mod_side_other) then
1440 if (lprint) write(iout,'(/3a,2i3)') 'Potential is ',
1441 & potname(ipot),', exponents are ',expon,2*expon
1442 C-----------------------------------------------------------------------
1443 C Calculate the "working" parameters of SC interactions.
1444 dwa16=2.0d0**(1.0d0/6.0d0)
1446 chip(i)=(chip0(i)-1.0D0)/(chip0(i)+1.0D0)
1450 sigma(i,j)=dsqrt(sigma0(i)**2+sigma0(j)**2)
1451 sigma(j,i)=sigma(i,j)
1452 rs0(i,j)=dwa16*sigma(i,j)
1457 write (iout,'(/a)') 'One-body parameters:'
1459 write (iout,'(a,4x,a)') 'residue','sigma'
1460 write (iout,'(a3,6x,f10.5)') (restyp(i),sigma0(i),i=1,ntyp)
1461 else if (ipot.eq.2) then
1462 write (iout,'(a,4x,2a)') 'residue',' sigma ',' r0 '
1463 write (iout,'(a3,6x,2f10.5)') (restyp(i),sigma0(i),rr0(i),
1465 else if (ipot.eq.3 .or. ipot.eq.4) then
1466 write (iout,'(a,4x,5a)') 'residue',' sigma ','s||/s_|_^2',
1467 & ' chip0 ',' chip ',' alph '
1468 write (iout,'(a3,6x,5f10.5)') (restyp(i),sigma0(i),sigii(i),
1469 & chip0(i),chip(i),alp(i),i=1,ntyp)
1470 else if (ipot.eq.5) then
1471 write (iout,'(a,4x,6a)') 'residue',' sigma ',' r0 ',
1472 & 's||/s_|_^2',' chip0 ',' chip ',' alph '
1473 write (iout,'(a3,6x,6f10.5)') (restyp(i),sigma0(i),rr0(i),
1474 & sigii(i),chip0(i),chip(i),alp(i),i=1,ntyp)
1476 write (iout,'(/a/10x,7a/72(1h-))')
1477 & 'Working parameters of the SC interactions:',
1478 & ' a ',' b ',' augm ',' sigma ',' r0 ',
1484 if (ipot.eq.1 .or. ipot.eq.3 .or. ipot.eq.4) then
1493 c sigeps=dsign(1.0D0,epsij)
1494 aa(i,j)=ftune_eps(epsij)*rrij*rrij
1499 sigt1sq=sigma0(i)**2
1500 sigt2sq=sigma0(j)**2
1503 ratsig1=sigt2sq/sigt1sq
1504 ratsig2=1.0D0/ratsig1
1505 chi(i,j)=(sigii1-1.0D0)/(sigii1+ratsig1)
1506 if (j.gt.i) chi(j,i)=(sigii2-1.0D0)/(sigii2+ratsig2)
1507 rsum_max=dsqrt(sigii1*sigt1sq+sigii2*sigt2sq)
1511 sigmaii(i,j)=rsum_max
1512 sigmaii(j,i)=rsum_max
1513 if ((ipot.eq.2 .or. ipot.eq.5) .and. r0(i,j).gt.rsum_max)
1515 r_augm=sigma(i,j)*(rrij-sigma(i,j))/rrij
1516 augm(i,j)=epsij*r_augm**(2*expon)
1517 c augm(i,j)=0.5D0**(2*expon)*aa(i,j)
1524 write (iout,'(2(a3,2x),3(1pe10.3),5(0pf8.3))')
1525 & restyp(i),restyp(j),aa(i,j),bb(i,j),augm(i,j),
1526 & sigma(i,j),r0(i,j),chi(i,j),chi(j,i)
1537 if (mask_elec(i,j,1).gt.0) then
1540 if (epp(i,j).lt.0.0d0) epp(i,j)=0.0d0
1543 if (mask_elec(i,j,2).gt.0) then
1545 rpp(i,j)=dabs(x(ii))
1546 rpp(j,i)=dabs(x(ii))
1548 if (mask_elec(i,j,3).gt.0) then
1551 if (elpp6(i,j).gt.0.0d0) elpp6(i,j)=0.0d0
1552 elpp6(j,i)=elpp6(i,j)
1554 if (mask_elec(i,j,4).gt.0) then
1560 app (i,j)=epp(i,j)*rri*rri
1561 app (j,i)=epp(j,i)*rri*rri
1562 bpp (i,j)=-2.0D0*epp(i,j)*rri
1563 bpp (j,i)=-2.0D0*epp(i,j)*rri
1564 ael6(i,j)=elpp6(i,j)*4.2D0**6
1565 ael6(j,i)=elpp6(i,j)*4.2D0**6
1566 ael3(i,j)=elpp3(i,j)*4.2D0**3
1567 ael3(j,i)=elpp3(i,j)*4.2D0**3
1571 write (iout,'(/a)') 'Electrostatic interaction constants:'
1572 write (iout,'(1x,a,1x,a,10x,a,11x,a,11x,a,11x,a)')
1573 & 'IT','JT','APP','BPP','AEL6','AEL3'
1576 write(iout,'(2i3,4(1pe15.4))')i,j,app(i,j),bpp(i,j),
1577 & ael6(i,j),ael3(i,j)
1584 C Define the SC-p interaction constants
1588 if (mask_scp(0,1,1)+mask_scp(0,2,1)+mask_scp(0,1,2)+
1589 & mask_scp(0,2,2) .gt. 0) then
1591 if (mask_scp(0,j,1).gt.0) then
1597 if (mask_scp(0,j,2).gt.0) then
1607 if (mask_scp(i,j,1).gt.0) then
1611 if (mask_scp(i,j,2).gt.0) then
1619 aad(i,1)=dabs(eps_scp(i,1))*rscp(i,1)**12
1620 aad(i,2)=dabs(eps_scp(i,2))*rscp(i,2)**12
1621 bad(i,1)=-2*eps_scp(i,1)*rscp(i,1)**6
1622 bad(i,2)=-2*eps_scp(i,2)*rscp(i,2)**6
1626 write (iout,*) "Parameters of SC-p interactions:"
1628 write (iout,'(4f8.3,4e12.4)') eps_scp(i,1),rscp(i,1),
1629 & eps_scp(i,2),rscp(i,2),aad(i,1),bad(i,1),aad(i,2),bad(i,2)
1635 c Weight of the shielding term
1636 if (imask(ind_shield).eq.1) then
1638 ww(ind_shield)=x(ii)
1640 wshield=ww(ind_shield)
1642 c write (iout,*) "x2w: nvar",nvarr
1644 c Base of heat capacity
1647 if (nbeta(2,iprot).gt.0) then
1649 heatbase(iprot)=x(ii)
1653 if (ii.ne.nvarr) then
1654 write (iout,*) "!!!!! SEVERE ERROR IN X2W !!!!! (chuj nastapil)"
1655 write (iout,*) "NVAR=",nvarr," LAST VARIABLE INDEX=",ii
1656 stop "CHUJ ABSOLUTNY!!!!"
1661 c---------------------------------------------------------------------------
1662 double precision function ftune_eps(x)
1664 double precision x,y
1665 double precision delta /1.0d-5/
1666 if (dabs(x).lt.delta) then
1668 ftune_eps=delta*(3.0d0+6.0d0*y**2-y**4)/8
1674 c---------------------------------------------------------------------------
1675 double precision function ftune_epsprim(x)
1677 double precision x,y
1678 double precision delta /1.0d-5/
1679 if (dabs(x).lt.delta) then
1681 ftune_epsprim=1.5d0*y-0.5*y**3
1683 ftune_epsprim=dsign(1.0d0,x)
1687 c---------------------------------------------------------------------------
1688 double precision function ftune_epsbis(x)
1690 double precision x,y
1691 double precision delta /1.0d-5/
1692 if (dabs(x).lt.delta) then
1694 ftune_epsbis=(1.5d0-1.5d0*y**3)/delta
1700 c---------------------------------------------------------------------------
1701 logical function in_sc_pair_list(iti,itj)
1703 include "DIMENSIONS"
1704 include "DIMENSIONS.ZSCOPT"
1705 include "COMMON.WEIGHTS"
1708 if (ityp_psc(1,i).eq.iti .and. ityp_psc(2,i).eq.itj .or.
1709 & ityp_psc(1,i).eq.itj .and. ityp_psc(2,i).eq.iti) then
1710 in_sc_pair_list=.true.
1714 in_sc_pair_list=.false.