From e707236bf733c00964b4794412433eb30e1bf7d7 Mon Sep 17 00:00:00 2001 From: MaziarHeidari Date: Mon, 20 Jun 2016 17:46:01 +0200 Subject: [PATCH 01/15] HADRESS_NEW_REVISION --- doc/Eqs/HADRESS_AT_pair_coul_dsf.jpg | Bin 0 -> 5732 bytes doc/Eqs/HADRESS_AT_pair_coul_dsf.tex | 10 + doc/Eqs/HADRESS_AT_pair_lj.png | Bin 0 -> 2870 bytes doc/Eqs/HADRESS_AT_pair_lj.tex | 11 + doc/Eqs/HADRESS_CG_pair_lj.png | Bin 0 -> 2924 bytes doc/Eqs/HADRESS_CG_pair_lj.tex | 11 + .../HADRESS_Switching_Function_Cylinder.tex | 15 + doc/Eqs/HADRESS_Switching_Function_Slab.png | Bin 0 -> 3285 bytes doc/Eqs/HADRESS_Switching_Function_Slab.tex | 13 + doc/Eqs/HADRESS_Switching_Function_Sphere.png | Bin 0 -> 2540 bytes doc/Eqs/HADRESS_Switching_Function_Sphere.tex | 15 + doc/Eqs/HADRESS_System_Hamiltonian.png | Bin 0 -> 3653 bytes doc/Eqs/HADRESS_System_Hamiltonian.tex | 9 + doc/Eqs/HADRESS_System_Potentials.png | Bin 0 -> 7050 bytes doc/Eqs/HADRESS_System_Potentials.tex | 10 + doc/JPG/HADRESS_MODEL_LAMMPS.png | Bin 0 -> 75013 bytes doc/fix_lambdah_calc.html | 244 ++ doc/fix_lambdah_calc.txt | 212 ++ doc/pair_lj_hars.html | 198 ++ doc/pair_lj_hars.txt | 181 ++ src/USER-HADRESS/Install.sh | 60 + src/USER-HADRESS/atom.cpp | 2206 +++++++++++++++++ src/USER-HADRESS/atom.h | 519 ++++ src/USER-HADRESS/atom_vec_full_hars.cpp | 1352 ++++++++++ src/USER-HADRESS/atom_vec_full_hars.h | 104 + src/USER-HADRESS/fix_lambdah_calc.cpp | 958 +++++++ src/USER-HADRESS/fix_lambdah_calc.h | 102 + src/USER-HADRESS/molecule.cpp | 1829 ++++++++++++++ src/USER-HADRESS/molecule.h | 432 ++++ .../pair_lj_cut_coul_dsf_hars_at.cpp | 971 ++++++++ .../pair_lj_cut_coul_dsf_hars_at.h | 115 + src/USER-HADRESS/pair_lj_cut_hars_at.cpp | 1039 ++++++++ src/USER-HADRESS/pair_lj_cut_hars_at.h | 119 + src/USER-HADRESS/pair_lj_cut_hars_cg.cpp | 1120 +++++++++ src/USER-HADRESS/pair_lj_cut_hars_cg.h | 123 + src/USER-HADRESS/read_data.cpp | 2023 +++++++++++++++ src/USER-HADRESS/read_data.h | 560 +++++ 37 files changed, 14561 insertions(+) create mode 100644 doc/Eqs/HADRESS_AT_pair_coul_dsf.jpg create mode 100644 doc/Eqs/HADRESS_AT_pair_coul_dsf.tex create mode 100644 doc/Eqs/HADRESS_AT_pair_lj.png create mode 100644 doc/Eqs/HADRESS_AT_pair_lj.tex create mode 100644 doc/Eqs/HADRESS_CG_pair_lj.png create mode 100644 doc/Eqs/HADRESS_CG_pair_lj.tex create mode 100644 doc/Eqs/HADRESS_Switching_Function_Cylinder.tex create mode 100644 doc/Eqs/HADRESS_Switching_Function_Slab.png create mode 100644 doc/Eqs/HADRESS_Switching_Function_Slab.tex create mode 100644 doc/Eqs/HADRESS_Switching_Function_Sphere.png create mode 100644 doc/Eqs/HADRESS_Switching_Function_Sphere.tex create mode 100644 doc/Eqs/HADRESS_System_Hamiltonian.png create mode 100644 doc/Eqs/HADRESS_System_Hamiltonian.tex create mode 100644 doc/Eqs/HADRESS_System_Potentials.png create mode 100644 doc/Eqs/HADRESS_System_Potentials.tex create mode 100644 doc/JPG/HADRESS_MODEL_LAMMPS.png create mode 100644 doc/fix_lambdah_calc.html create mode 100644 doc/fix_lambdah_calc.txt create mode 100644 doc/pair_lj_hars.html create mode 100644 doc/pair_lj_hars.txt create mode 100644 src/USER-HADRESS/Install.sh create mode 100644 src/USER-HADRESS/atom.cpp create mode 100644 src/USER-HADRESS/atom.h create mode 100644 src/USER-HADRESS/atom_vec_full_hars.cpp create mode 100644 src/USER-HADRESS/atom_vec_full_hars.h create mode 100644 src/USER-HADRESS/fix_lambdah_calc.cpp create mode 100644 src/USER-HADRESS/fix_lambdah_calc.h create mode 100644 src/USER-HADRESS/molecule.cpp create mode 100644 src/USER-HADRESS/molecule.h create mode 100644 src/USER-HADRESS/pair_lj_cut_coul_dsf_hars_at.cpp create mode 100644 src/USER-HADRESS/pair_lj_cut_coul_dsf_hars_at.h create mode 100644 src/USER-HADRESS/pair_lj_cut_hars_at.cpp create mode 100644 src/USER-HADRESS/pair_lj_cut_hars_at.h create mode 100644 src/USER-HADRESS/pair_lj_cut_hars_cg.cpp create mode 100644 src/USER-HADRESS/pair_lj_cut_hars_cg.h create mode 100644 src/USER-HADRESS/read_data.cpp create mode 100644 src/USER-HADRESS/read_data.h diff --git a/doc/Eqs/HADRESS_AT_pair_coul_dsf.jpg b/doc/Eqs/HADRESS_AT_pair_coul_dsf.jpg new file mode 100644 index 0000000000000000000000000000000000000000..2edcc1fc5340367d4231cd02fae2a0ebcd7f43ab GIT binary patch literal 5732 zcma)AXHZl9vyLDj9qFA=q?Z7S^d`MZk)m`6C`5r!0)&9{K&T?Usi1%$5KwyWNSEHL z^cD!cc=3JzGk5NXd*}XU&e`+q?z6k+ne*YyMn2V3CnaJe0ssJ{ni?vG008d7?en91 zcW>{9{qf4T=B|^Ht`Y!%jw8OZ#k<9KJPg&90VM;>o3{XHuVJVQ0QhkO0B=J9fQwt# z+YJD~3j_dc*#H32sQ>_-TV}0+>}>$YPFr0C@Fya!ujv*Mx@nku+**x)F0~#Pc>sW# zOjAY4*k^h-Yd0yQn=(9Sy5i2_)IH(EJC&TE#GuYtn@0>U2UHf@9GW3_UAS>q@0A$f z|LSk%2&q*FrOFDtPY)js_nx>P>nNU1`7B(vKb)TRzB`yOG-QD64Vy@;H<>ethuVOaEq}@7a?~W zj}Plz9g-Y+KiXi@{oTikth@vH$7l3(`q-z>Sdql)%+wSyGA8sU&JTUov+@8nU)5Ey z9V}Q)AdenhSL-ct$9{9&nhxzdSX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dMZ$;0Tikmt&{sd1it`JoLAVt6Oc3MN-RRluO09#=}R{{bbm7r`A9fhOX-{oErX2$5(4&if|mtZRg(RwP&r z%#!&3_P5BtvUS1#=(zklKPZUo?g=J#Pj;er13Ozy}Zj=->9b n^m{ogF7PW(z!C%SWD+jGpLG(@Zz1GgA6vlO)EZF-zj6D&>0&9; literal 0 HcmV?d00001 diff --git a/doc/Eqs/HADRESS_AT_pair_lj.tex b/doc/Eqs/HADRESS_AT_pair_lj.tex new file mode 100644 index 0000000000..6e28b198b0 --- /dev/null +++ b/doc/Eqs/HADRESS_AT_pair_lj.tex @@ -0,0 +1,11 @@ +\documentstyle[12pt]{article} + +\begin{document} + +$$ + V^{AT} = 4 \epsilon \left[ \left(\frac{\sigma}{r}\right)^{12} - + \left(\frac{\sigma}{r}\right)^6 \right] + \qquad r < r_c +$$ + +\end{document} diff --git a/doc/Eqs/HADRESS_CG_pair_lj.png b/doc/Eqs/HADRESS_CG_pair_lj.png new file mode 100644 index 0000000000000000000000000000000000000000..518845994a31634824469370b1a786121b777050 GIT binary patch literal 2924 zcmZ`*c{tQ-8~!m!LQ)PR%h=6j8)Qy1mKb7?RFrMVHYQBQjNdSlU6zoLrDVx^lIQW;vn|#W!~p+ z#No)6W+wKuspb6DyT$#Yy^++ymUUEq}Cc?~qfxyCTxCUqzlSdv;($?_OHu6W1tV zI%#rRv83rx(9Z4A4x=Bf%VXe?u{5xLAuIG7o|<3aWbkvexkOD^n9d5D*1M1~5GPk? zAR1t$$*1y+@vZpq)ts8Jt&nNnB_2;#oR+S38v-93s4>^7X^g`_S+&ao@GfP=N$tc> zq#tF6-sF}d8UE8{Eahz`BTJ5pYhTJWZ;mwKwm2Aw9}9*bYFHzKf>8qzajf)YH)ge< zH0$=~gYzOJ!u4Fp?>b{i-8@>KHoGz-8eNO0jcY*HPJxCUDbp`5&DxNkQxVS=j_oy# z)-cgP_(JGkcwokAeNO;p#C~l>5I0(GHesZnH5bJyrpL`CbFF#1r#miKZq(9w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CvG94Rt>|1?k+b5L6#J^YwQzSwRNZ}wf{O>*Un1sRJL0ln3tN>x+2 z@_miiGfS9D285F#`jW}rlkAO(p}LEFxhp)_5f8g4>$mS_L_sCnt$J;f)96xX$ITrp zMoBdMWWxEzDxHXCPiKNTM6I(-GB2XEq2gynJ*8;1idOgW{nmR%RbUUo7Zzs*Ar1#I z7p>^l;+i=NgDXRNo?J#*6DQiU?9E?;yW$j7%?(ZYm zdQE<`zjuDckeWMmRep7eP2zUa9e=nu5H@eDOzYErBm>`2a7~kO;Jn808V=e%wz)*c zZ&2s)n8=)K-w45c;=r!Q#ezY5_sAX^!5PpXfFz$1Aq=f8>xZN)6h9#k3gZdPoQ-X zY6t`xf%q#>`PYE>U%^$9x35p=zYF3u3Z8NVO}}m+a;#~9qN0!h?2=oUsYN)<5OxBF z!v_ZW5=j9t91-sWy8HvGI3J3KR~RnHmvGf1Jd6^Kqxcf8fN-}kZJltK28?6z|Ko3y ze^n!4|MQsq3co+#@WQ`% g3O r_{at}+r_{hy} +\end{array} +\right. +\end{eqnarray*} + +\end{document} \ No newline at end of file diff --git a/doc/Eqs/HADRESS_Switching_Function_Slab.png b/doc/Eqs/HADRESS_Switching_Function_Slab.png new file mode 100644 index 0000000000000000000000000000000000000000..c50bcb4583d1fd75d2d448c952a149213a6be7de GIT binary patch literal 3285 zcmbW45`O^ zE)fI-F88_r!95?&dB2?Bb3UBsea?wAKxp2iW}^lG05`R@;6?xdF!Nd?s7SA~;jpyW zbx|?ULuy=IU0uunJG#i{xvrZTJ&h2?0QfgZNh5dKI?2hGf@p3O*>b0~i0tgMcM9LlwWHKmTGmSnBH}d@S|wcc+qbf;5?A z2I81Z2yuVEd{X=-GA$k_JD7H{Rt(s15%x5}ZL`Ac(#%NnqjM}xX+J`7yJQB2MVndU zq~S@Fh1rgAgd=Gqea$hlj8W4RJ8axFR>cxw(B^4`ITtBMZg3zv4_R3fSsekLko zJYDMTn9#lFlM9CgpS=077AiPgaz*!LT~xd`p!mIh)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!Ze7@mA^`>oA$?|?8%$$;vcVG z^(HLp3YDmaQtkf6pr9#!;i%VLrCQU3mb2$h9715awtHBrvg*t*2)9l=XS=?ZCMj+2 zB13jbLO)k`=W0~=Iot}b8 za!MXj>Qz*Qf-0Wu2gwC%7&-!CJ~*z#5X%(qA8dPe-UAKo#%I_5aPdTqt>R`ve>RKN z-3sEgH5z}4xKw|?pyjp$`d;jJ2eLKuikmUDTOZpMuQA3RK_lq}%1p0*P%QiE>58`S zbdG%h&e_Nu?hDszqKX<&u4^Q>T4%i4WgoBeYHpBbt1MQyWx~Vap-0MJWs2@BA`gtG zQ(#paaAJp4LfxXkZO`eVW*6GsIk7s5RB?XGm@L|f(#_}&SGw|V56~vq#hi)w0*d-^ z?<`6c0<<;kf>W7#h`PRmh)Q!~8Mmrv$evkg7F+Obbciag5kD+z{Z+fK<`YXY*5Vo; z+Mo4lrpDs!Rm_c}_Kpi`vsjW`?+vloe7e^6B8~*(+8}ciIhzN z3ReJ6H?lpFxT!t({*v0I_Q~%5v><(*?=%SJsxIg_zwnys+9CTccWm_fAzuutMvq z==o8+D@j~|#jD)Yxo9xNEJbd}ob7aO+mf*HlwwDuy0L$+mk0>0dTyFQdvIfZH1D|> zl|hXC3+dZ(Ejf(n0ir;%;F)k`FRPR%k8qNC?m@T!boKiBvf1#~m9SVM*zjp=|AC0h6(^axo_0hvOe}QACQJ~s`?dJrFq&7$W-n(KU~ea z=b%UGF-?~rY2WD_3tY;RcWi2U>v1ud6hb8dT@q=VbO#uu*jwg;YVcC;PlYRAS5RdZ zj>$()nz+|c-iY^c^`>>VWKzBT{xac3kT>HM3iH7+&7m3Bz2&SpEilJh_&ro*F-STj?<3yI;c46(!6bEnn^;VfNq8L|X#^FITe(`479& B1}6Xj literal 0 HcmV?d00001 diff --git a/doc/Eqs/HADRESS_Switching_Function_Slab.tex b/doc/Eqs/HADRESS_Switching_Function_Slab.tex new file mode 100644 index 0000000000..878bb4da89 --- /dev/null +++ b/doc/Eqs/HADRESS_Switching_Function_Slab.tex @@ -0,0 +1,13 @@ +\documentclass[12pt]{article} + +\begin{document} +$$ +\lambda(x)=\left\{ +\begin{array}{ll} +1 & |x| \leq L_{AT}/2\\ +\cos^2\left(\frac{\pi(x-L_{AT}/2)}{2L_{HY}}\right) & \frac{L_{AT}}{2}< |x| \leq \frac{L_{AT}}{2}+L_{HY}\\ +0 & |x| > L_{AT}+L_{HY} +\end{array} +\right. +$$ +\end{document} \ No newline at end of file diff --git a/doc/Eqs/HADRESS_Switching_Function_Sphere.png b/doc/Eqs/HADRESS_Switching_Function_Sphere.png new file mode 100644 index 0000000000000000000000000000000000000000..6a16b9838feb23e1d0c327a3bb7bb4094de4d02a GIT binary patch literal 2540 zcmbW3=OYx31ICfPSN5v2zGakfHfP>R)}f5ESDjV%-6?#@=#0$l5E;pgIG04`iBLv1 zoii_-&E2=(zwmore4fvn=lzppX>P*CEW}JjMa2dI8(LFQQ6v7kIpdYT6kL(7`&+t} zW;R9?3gxf<-}y?nAoh368)9t^r7|43UW?%*dgm$Ggv}?FzSV2{3T_80QBg60A%-BE z2D$TqU6P~>mc)M#)zZK%On>C~#=K$s0-?4WWaHYNyZWPf2ul-(xKps6*3w8&bXUw` z{w55Af)E6^iuy+hpeKOq5=qfQplRF-CPN#^(2ar@`ilxjs?R$rml$F|VXC@(KxWlG znfFZCS4!j?n+=lyn%F(&3XF7l$Z`!_f6@LHbk38gAIWLykoI#PetgRoL%8HdsH;L% zysf_hQ(euV`7Qp65@xM|>jSIJQRbMBNXlr}F4np`-1Aet89sJ$_e58=fpo?Zh7XxA z@L18@Hh@$XKqiQP9y$iz|9FK&)qn}$`v!Db7k#}b@;OSJ{F*Y2IR{Zd1PW{}tZ7;o zZi0d?>1alzKl`$^gg*#Yc80h*$R)tEp$RpJR3+u)OEi1kB`y*O1@zW@Vb~&d3q0l|J-n<}snY z@_W=W=|&NqqxRmH$+es>hb55wkg@$oQyd0?W(nn`-9+2NoypdvPVai?X0e#J;%<~; zTrjeUx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P-(>S)^*7eJo_-sk-E>b^NNnwfd9coXPaJhW(#TtM5Gy z*61*h`s7SK551%AXM?+iJ?DoDa(uYAQph~ErpT?t9wB5jt?`jG58=S4?Q~8Fe)j7I zM~U^h|IoMk+``!Bft#DqoNv4uoe1*J&V4as%iPw$l!{t>?WCO zFl;QU>BL3o0-tY9XkMQ=;QLkhAg_g^brJVrsIC3Bmmnp=M6L9_PY*q zh)3XXD~0&tWx=gJ*^1|$?|Lj1kXj!{81J_q+8FQNtW7TUv7KJNVbmuE%YL*7s~17o zxA#O_v*M$&tPe3;SMi75)6$VBdTC&8p(o+or{Hb>V!vhxkf6=9cEahR*eSK>f@9w2nr-R6*ZfSrVux^Mspy(fO@2`66SCp~*wpS)y=6 z9VD3!*eex_FZPY#cIjPy;eZ$(p+O9P3nF#3k*-Z7%4m-J7>JVX(2Q$fl;g#q-U>iO zXZBmc5DP(2DTQ)I^gA*(QOh;Y0+L*{8AT-b=!ASE_UPD4;A=%)xnt!}RD?{_V99oV zVuA%Nd&Ws8z0_VL`=aKxaDVyIw!1g(5<;wr_OFq`FM$bgs@K3E^R3uqa zYA@T0=o~k73kIJ@1UwjhdGb>YwSH!)0CO{jzNbvc8SAwgIjyc7Jx!*j*3pja6g9gv rmEq$2F-o-1KhoHv_^>~?olLpnv>ca8lIyF}KC literal 0 HcmV?d00001 diff --git a/doc/Eqs/HADRESS_Switching_Function_Sphere.tex b/doc/Eqs/HADRESS_Switching_Function_Sphere.tex new file mode 100644 index 0000000000..bd6b156c03 --- /dev/null +++ b/doc/Eqs/HADRESS_Switching_Function_Sphere.tex @@ -0,0 +1,15 @@ +\documentclass[12pt]{article} + +\begin{document} + +\begin{eqnarray*} +\lambda(r)=\left\{ +\begin{array}{ll} +1 & r \leq r_{at}\\ +\cos^2\left(\frac{\pi(r-r_{at})}{2r_{hy}}\right) & r_{at}< r \leq r_{at}+r_{hy}\\ +0 & r > r_{at}+r_{hy} +\end{array} +\right. +\end{eqnarray*} + +\end{document} \ No newline at end of file diff --git a/doc/Eqs/HADRESS_System_Hamiltonian.png b/doc/Eqs/HADRESS_System_Hamiltonian.png new file mode 100644 index 0000000000000000000000000000000000000000..2e76b48195384051e451558ff4c0c7b927065601 GIT binary patch literal 3653 zcmai1cQ_kv*N)<~X{ga3C6uIU&l=HIP*EeOnz3gPGe{Z~MN8~mvuL$7TeWJG+M}wi zy+^4{M2%Yc()YT)^~ZO8&viY|Ip;q2ea>_KJTZm_+ANI!FaiJo79F^zF#vE$isGx# z(@@?Y7QSC8hQ?K0UmXB=pU8A(PfLlZ{Ef9?fXc6Y>y!ZG2shRT03Lw>fUrma;DiE& ztpNZ5(g47Q9i>nf0Kn~&+h_!(BrZAVYHI?>PZPhiQX&Q)xP?E(!vB5m^?BR|0GQo% zG}TS8Q`>plwYf^{(E{6(0CNOQ_tk{}nvTJ+%^16etH0GaKJ(>L<iOlK5)-+*|Qggwxj8>qt1KkZ5+wC>J^okkON zuu_O7lZ#gu2kG-w%OOvwn>)I?(0SzeRqLrwj6$n#2S4`uD*OK8m6UWf2zx@{EZ~LF zoJBAN|LiP-5}w^@+KLUcB`PJZ^4y)0Po{_0?ss?cj`NS*IluafFL>$X+hk71WYD$i z43<6ov^Ip~cb|qX1?`T73dDrv*0@ZHh`?<6fI)cjEx-q4n@)w?Vh zFcsMm9_QqJQ96cw31`haeG?_dPz@Ay!q*?3!Zk58jWpboE}73P%gg-X&w67T&oM_< zr#9^TA27^=Whz%j5on3hVOqafG2A8L^>a5WO>A%7JCAu~t<%s9pQ65#Jo;&|?ca4g z-=d3(m+L+r8lL_3H*rO>H)?duT?vtjp}q$eIzAZci1@+!=bdBC1zXb5@0-9SxLZ6y zNq@ZO)peIl>7votEm?+!Bh4DqwzLkyQgHB9@tzZSYH?8A=z}20S||sdP&J{qO%S{S z5(I(08bPe0qA3w0k^F}Ge!_k_uY2;cVM&6!aDQK2qlr-?OER4}d$pWZ@|#UitF|iF z)@t0NK~!S7X(vIqm;vt^kI_Od71FHS?Jm;!43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ag2l?AOVYISeY6g5q*4*^(L~MIA^&1mrjJ26;$RTp z#ihBg7EAXq)TgxObTI`z>+tx^N1gX>sv=ppLSQ#az1s?bdQ{dwcuk zt^VYws3<}6JqLSxdwSDmb8~Z^2u>+3F0N?1F2etln$V|WV+0auniu8oyhw`bLfhS< zg$hsE@<)G{VzV;eVk~Qcf;1x_^AG7{V$53)zPGmn%CR^l`hu{`6C(X_+b+I-puLFA zV=4p+r6xD>^~w>$+3Hz((DsGY6fOVGshkrRmqPg=39GbMp?sOuXNEi-&&8!-zDL3~ z><=Ybm?P~V+H6nhj+viF(E`YH(sUibXjH^~%K9OK(K5$4*<+kl9Q~Xr1|TafqbMP* zAR#MnBCVvNAgdy;BqlAbA}w9X)THvi1ZZz3lnd_v7R;McM^gkDe>-?mN@D?FFdU=? zLZa<4ZjSbzAYG6c$kYap^1_5rJfwdB+7^$r_w;eI4*?-Pon0_UJRa$3k9KgfxBX8X zPZ6k_g#1@52EyNv0ZCB!|C1*g0{TnT(Ee{C(hue8hCzlPkszd(w^sn#!P!qu?*(P; z12F&np`*8_w;w?I->1Fcu#keY{>A;A{k=T{Feq;?%B0c>gFJb;dtfo3JlF5*7` DUK-Pm literal 0 HcmV?d00001 diff --git a/doc/Eqs/HADRESS_System_Hamiltonian.tex b/doc/Eqs/HADRESS_System_Hamiltonian.tex new file mode 100644 index 0000000000..34239bc52c --- /dev/null +++ b/doc/Eqs/HADRESS_System_Hamiltonian.tex @@ -0,0 +1,9 @@ +\documentclass[12pt]{article} + +\begin{document} + +\begin{eqnarray}\label{hadress_H} +&&H = K + V^{int} + \sum_{\alpha} \left\{{\lambda_\alpha} {V^{AT}_\alpha} + {(1 - \lambda_\alpha)} {V^{CG}_\alpha} \right\}\\ \nonumber +\end{eqnarray} + +\end{document} \ No newline at end of file diff --git a/doc/Eqs/HADRESS_System_Potentials.png b/doc/Eqs/HADRESS_System_Potentials.png new file mode 100644 index 0000000000000000000000000000000000000000..8cfcfe6124fcc1f29806a871ba474a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|XEp{|_8adp!UE literal 0 HcmV?d00001 diff --git a/doc/Eqs/HADRESS_System_Potentials.tex b/doc/Eqs/HADRESS_System_Potentials.tex new file mode 100644 index 0000000000..821df897ad --- /dev/null +++ b/doc/Eqs/HADRESS_System_Potentials.tex @@ -0,0 +1,10 @@ +\documentclass[12pt]{article} + +\begin{document} + +\begin{eqnarray}\label{hadress_V} +&& V^{AT}_\alpha \equiv \displaystyle\frac{1}{2}\sum_{\beta,\beta\neq \alpha}^{N} \sum_{ij} V^{AT}(|\textbf{r}_{\alpha i} - \textbf{r}_{\beta j}|)\\ \nonumber +&& V^{CG}_\alpha \equiv \displaystyle\frac{1}{2}\sum_{\beta,\beta\neq \alpha}^{N} V^{CG}(|\textbf{R}_\alpha - \textbf{R}_\beta|) +\end{eqnarray} + +\end{document} \ No newline at end of file diff --git a/doc/JPG/HADRESS_MODEL_LAMMPS.png b/doc/JPG/HADRESS_MODEL_LAMMPS.png new file mode 100644 index 0000000000000000000000000000000000000000..5626fef663bd1f6a7712be2f9e93aac2d615defc GIT binary patch literal 75013 zcmb5VV{~QD(*~MMY)|ZoZQHhO+jcUO2`9F3V%y2Ywr$(EXMXGb->-Mwz1BHO#EUg`|j3iT=^NIcS%S%8-?zY(a zk4AzeEA{uN+HdTFR@6U((ThBamh?_9Km2Wp4B@ET16!w%Fpnm)T+A=WTV0OE`7}tN zg9Cp8k72u@hH?yK6yR~fD_THLLPFwZ~i*;wNFY?ygSMKLes;KUtfee=sZ`t82L%o~VZAVu54jzRHu)%`T zn9=1w9IogS))rh((!GVnA#c}drOT+>m80zy%;YeV*wpk$eQ(59e#MU zizA^t62O^U)iOSJ1GWj_{?<+}!O$;Q>7_)LjaHo{kSrC+M7M?gf`P$4IX*jeFTw#? zXR+VymVXo&_45U@)rRN)ZFJFe^8&WQI@HI!+~OFfyOGCr z=U(dKlw@{v+h0Sg+RuwsvS9n6_WIZ~^{@;>uVIryj5`X8JQoTX9b@4%brzPvPQ7}m z>gzpHWJqDiS^+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KtBl`BmztJig?sH!3(KOZYIGs>!}XyoO^t@Jd~A7|0M zWg8r9tpAW#!Sm<1*xDfoiK!29vA4s=&Fyu5rIi(AZ zP$(2=G#XCDUq!9aP}kFw)XYrsi;FQgGi6ARUYMv<kc-SmNX0SL#@-I zQYxv@XefC83`bjAGIR5(s;*(ogr%fhK0-kI?!+8gkGrG&>oWeQOZs$LEgAU*c)K{G zQmH7dtiaO5><@L&YP2YglqeJmYHDgwC>3wmP;F>6TC_SX#>U2P_`yHo@U6cG{$)u0 tE#BfS-r_Cvi-O+bE#BfS-r`>b{|+rMRuEvpcd7sY002ovPDHLkV1lEaim(6x literal 0 HcmV?d00001 diff --git a/doc/fix_lambdah_calc.html b/doc/fix_lambdah_calc.html new file mode 100644 index 0000000000..269af18ff0 --- /dev/null +++ b/doc/fix_lambdah_calc.html @@ -0,0 +1,244 @@ + + + + + + + + +
+ +

fix lambdah command +

+

Syntax: +

+
fix ID group-ID lambdah/calc NH-mol LHY LAT Pflag δλ dTp TpStart TpEnd HYShape Dflag Δx dTd TdStart TdEnd σ R ρ0 c fileflag 
+
+
  • ID is documented in fix command + +
  • group-ID has to be all + +
  • lambdaH/calc = style name of this fix command + +
  • NH-mol = Number of molecular types within the low resolution + +
  • LHY = Length of Hybrid region + +
  • LAT = Length of Atomistic (high resolution) region + +
  • Pflag = 0 or 1 + +
      0 Constant-pressure route is off
    +  1 Constant-pressure route is on 
    +
    +
  • δλ = Bin size in constant-pressure route + +
  • dTp = Time step interval of constant-pressure route + +
  • TpStart = Starting time step of constant-pressure route + +
  • TpEnd = Ending time step of constant-pressure route + +
  • HYShape = Shape of Hybrid region : slab, sphere, cylinder + +
      slab is for rectangular hybrid region
    +  sphere is for spherical hybrid region
    +  cylinder is for cylinderical hybrid region 
    +
    +
  • Dflag = 0 or 1 + +
      0 Constant-density route is off 
    +  1 Constant-density route is on 
    +
    +
  • Δx = Bin size in constant-density route (length unit) + +
  • dTd = Time step interval of constant-density route + +
  • TdStart = Starting time step of constant-density route + +
  • TdEnd = Ending time step of constant-density route + +
  • σ = Width of gaussian function in constant-density route (length unit) + +
  • R = Range of gaussian function in constant-density route (length unit) + +
  • ρ0 = Reference number density in constant-density route + +
  • c = Prefactor in constant-density route (energy unit) + +
  • fileflag = 0 or 1 + +
      0 Do not employ density-balancing file 
    +  1 Employ density-balancing file 
    +
    + +
+

Examples: +

+
fix 1 all lambdah/calc 1 25 60 1 0.02 1000 150000 300000 slab 1 1.5 500 400000 700000 6 2 0.1 2 0
+fix 1 all lambdah/calc 1 25 60 1 0.02 1000 100000 200000 sphere 1 1.5 500 300000 700000 6 2 0.1 2 0 
+
+

Description: +

+

The Hamiltonian adaptive resolution simulation scheme (H-AdResS) is a dual-resolution simulation method that +joins models with different levels of complexity for the same system within a global Hamiltonian framework (Potestio2013_1), (Potestio2013_2), (Heidari2016). +

+

Depending on the shape of the Hybrid region which might be either slab, sphere or cynlinder, this fix calculates +the resolution of every atom based on the center of mass of its molecule. +The following switching function is defined for a simulation box whose atomistic region is limited to [-0.5LAT 0.5LAT]: +

+
+
+

The following switching function is defined for a spherical/cylinderical atomistic region located at the middle of the simulation box: +

+
+
+

A setup of a Hamiltonian Adaptive Resolution Simulation is shown below. The box is partitioned into three + different region types, namely: Coarse-grained (CG), Hybrid (HY), and Atomistic (AT). In each region, + the resolution of each molecule (here water) is determined by the instantaneous value of the + smooth function λ represented above the simulation snapshot. +

+
+
+

NH-mol determines the number of molecular types within the low resolution. For instance, for a system containing +coarse-grained water molecules in the coarse-grained region, this number equals one. However, for a sytem containing +water molecules and ions such as Na and Cl and they interact differently in the coarse-grained region, +this number is 3. +

+

The LHY specifies the length of the Hybrid region. For the cases of cylinderical or spherical hybrid regions, this quantity denotes rHY. +

+

The LAT determines the length of Atomistic region. For the cases of cylinderical or spherical hybrid regions, this quantity denotes rAT. +

+

The Pflag switches off and on the constant-pressure route. +

+

The δλ denotes the bin size over the hybrid region. In the on-the-fly method of averaging the drift forces, +particles are sorted into uniformly spaced λ bins of δλ side. +

+

The dTp denotes the time intervals in constant-pressure route at which the averaged drift forces are applied on the molecules of the hybrid region. +

+

The TpStart denotes the time step at which the simulation of the constant-pressure route is started. +

+

The TpEnd specifies the ending time step of the constant-pressure route. +

+

The HYShape specifies the geometry of the Hybrid region. This could be slab, sphere, cylinder. +

+

Dflag switches off and on the constant-pressure route. +

+

Δx is the bin size by which the simulation box is descritized in the constant-density route. +

+

dTd is the time interval in constant-density route at which the averaged thermodynamic forces are applied. +

+

TdStart is the starting time step of constant-density route. +

+

TdEnd is the ending time step of constant-density route. +

+

σ is the width of Gaussian function in the constant-density route. +

+

R is the range of Gaussian function in the constant-density route. +

+

ρ0 is the reference density in the constant-density route. +

+

c is the prefactor in the constant-density route. +

+

fileflag denotes a flag whether the file containing the density-balancing force is employed or not. +

+
+ +

Restart, fix_modify, output, run start/stop, minimize info: +

+

No information about this fix is written to binary restart +files. +

+

This fix creates a file named "Mean_Comp_Density.txt" in which the compensation forces are printed. +This file is created at TdStart and is updated every dTd. +The updating process of the file is finished at time step TdEnd. +For those equillibrated simulations starting at time step larger than TdEnd, +the file "Mean_Comp_Density.txt" is loaded in this fix. +

+
+ +

Restrictions: +

+

This fix calculates the center of mass of the particles. Thus at the beginning of the calculation, +it is required that all atoms belonging to a molecule are on the same side of the box. +

+

To employ the H-AdResS scheme, the full/hars atom style has to be used: +

+
  atom_style      full/hars 
+
+

To perform HAdResS, Data File should contain the following extra information with respect to the Data File defined in full atom style: +

+

[1] mol_H determines the number of molecular types in the low resolution (coarse-grained) region. +

+

[2] representative_flag determines which atom carries the molecule's information +(center of mass, molecule's resolution, ...) in the low resolution (coarse-grained) region. +

+

[3] mol_type denotes the type of the molecule in the low resolution (coarse-grained) region. +

+

The following example is extracted from a Data File in which the simulation box contains water molecules and the ions of sodium and cholorine: +

+
30720 atoms
+20480 bonds
+10240 angles 
+
+
4 atom types
+1 mol_H types
+1 bond types
+1 angle types 
+
+
-99.968000 99.968000 xlo xhi
+-20.793600 20.793600 ylo yhi
+-20.793600 20.793600 zlo zhi 
+
+
Masses 
+
+
1 15.999400
+2 1.007940
+3 22.9898 
+4 35.453 
+
+
Atoms
+#atomID molecule-tag atom-type q representative_flag mol_type x y z
+1 1 1 -0.847200 1 1 -99.654503 -19.897600 -20.192101
+2 1 2 0.423600 0 1 -100.568001 -19.999300 -20.586599
+3 1 2 0.423600 0 1 -99.777702 -20.103100 -19.221300
+4 2 1 -0.847200 1 1 -97.826401 -17.709900 -20.127100
+5 2 2 0.423600 0 1 -96.938400 -18.071301 -19.842800
+6 2 2 0.423600 0 1 -97.735100 -16.718800 -20.030100
+7 3 3 1.0 1 1 -97.429398 -20.402201 -17.494900
+8 3 4 -1.0 1 1 -96.834000 -19.671400 -17.160999
+.
+.
+. 
+
+

As it is shown, the representative_flag of the oxygen atoms is equal 1, and +since the soldium and cholorine are single atom ions, their representative_flags are also equals 1. +The interactions of water molecules and ions are the same in the coarse-grained region, +thus they all carry the same molecular type (mol_type). +

+
+ +

Related commands: +

+

pair_lj_hars.html +

+

Default: none +

+
+ + + +

(Potestio2013_1) R. Potestio, S. Fritsch, P. Espanol, R. Delgado-Buscalioni, K. Kremer, R. Everaers, and D. Donadio, Hamiltonian Adaptive Resolution Simulation for Molecular Liquids, Phys. Rev. Lett. [110], +108301 (2013) +

+ + +

(Potestio2013_2) R. Potestio, S. Fritsch, P. Espanol, R. Delgado-Buscalioni, K. Kremer, R. Everaers, and D. Donadio, Monte Carlo Adaptive Resolution Simulation of Multicomponent Molecular Liquids, Phys. Rev. Lett. [111], +060601 (2013) +

+ + +

(Heidari2016) M. Heidari, R. Cortes-Huerto, D. Donadio and R. Potestio, Accurate and general treatment of electrostatic interaction in Hamiltonian adaptive resolution simulations, "EPJST (2016)" +

+ diff --git a/doc/fix_lambdah_calc.txt b/doc/fix_lambdah_calc.txt new file mode 100644 index 0000000000..178f727d16 --- /dev/null +++ b/doc/fix_lambdah_calc.txt @@ -0,0 +1,212 @@ +"LAMMPS WWW Site"_lws - "LAMMPS Documentation"_ld - "LAMMPS Commands"_lc :c + +:link(lws,http://lammps.sandia.gov) +:link(ld,Manual.html) +:link(lc,Section_commands.html#comm) + +:line + +fix lambdah command :h3 + +[Syntax:] + +fix ID group-ID lambdah/calc NH-mol LHY LAT Pflag δλ dTp TpStart TpEnd HYShape Dflag Δx dTd TdStart TdEnd σ R ρ0 c fileflag :pre + +ID is documented in "fix"_fix.html command :ulb,l +group-ID has to be all :l +lambdaH/calc = style name of this fix command :l +NH-mol = Number of molecular types within the low resolution :l +LHY = Length of Hybrid region :l +LAT = Length of Atomistic (high resolution) region :l +Pflag = {0} or {1} :l + {0} Constant-pressure route is off + {1} Constant-pressure route is on :pre +δλ = Bin size in constant-pressure route :l +dTp = Time step interval of constant-pressure route :l +TpStart = Starting time step of constant-pressure route :l +TpEnd = Ending time step of constant-pressure route :l +HYShape = Shape of Hybrid region : {slab}, {sphere}, {cylinder} :l + {slab} is for rectangular hybrid region + {sphere} is for spherical hybrid region + {cylinder} is for cylinderical hybrid region :pre +Dflag = {0} or {1} :l + {0} Constant-density route is off + {1} Constant-density route is on :pre +Δx = Bin size in constant-density route (length unit) :l +dTd = Time step interval of constant-density route :l +TdStart = Starting time step of constant-density route :l +TdEnd = Ending time step of constant-density route :l +σ = Width of gaussian function in constant-density route (length unit) :l +R = Range of gaussian function in constant-density route (length unit) :l +ρ0 = Reference number density in constant-density route :l +c = Prefactor in constant-density route (energy unit) :l +fileflag = {0} or {1} :l + {0} Do not employ density-balancing file + {1} Employ density-balancing file :pre + +:ule + +[Examples:] + +fix 1 all lambdah/calc 1 25 60 1 0.02 1000 150000 300000 slab 1 1.5 500 400000 700000 6 2 0.1 2 0 +fix 1 all lambdah/calc 1 25 60 1 0.02 1000 100000 200000 sphere 1 1.5 500 300000 700000 6 2 0.1 2 0 :pre + +[Description:] + +The Hamiltonian adaptive resolution simulation scheme (H-AdResS) is a dual-resolution simulation method that +joins models with different levels of complexity for the same system within a global Hamiltonian framework "(Potestio2013_1)"_#Potestio2013_1, "(Potestio2013_2)"_#Potestio2013_2, "(Heidari2016)"_#Heidari2016. + +Depending on the shape of the Hybrid region which might be either slab, sphere or cynlinder, this fix calculates +the resolution of every atom based on the center of mass of its molecule. +The following switching function is defined for a simulation box whose atomistic region is limited to \[-0.5LAT 0.5LAT\]: + +:c,image(Eqs/HADRESS_Switching_Function_Slab.png) + +The following switching function is defined for a spherical/cylinderical atomistic region located at the middle of the simulation box: + +:c,image(Eqs/HADRESS_Switching_Function_Sphere.png) + +A setup of a Hamiltonian Adaptive Resolution Simulation is shown below. The box is partitioned into three + different region types, namely: Coarse-grained (CG), Hybrid (HY), and Atomistic (AT). In each region, + the resolution of each molecule (here water) is determined by the instantaneous value of the + smooth function λ represented above the simulation snapshot. + +:c,image(JPG/HADRESS_MODEL_LAMMPS.png) + +{NH-mol} determines the number of molecular types within the low resolution. For instance, for a system containing +coarse-grained water molecules in the coarse-grained region, this number equals one. However, for a sytem containing +water molecules and ions such as Na and Cl and they interact differently in the coarse-grained region, +this number is 3. + +The {LHY} specifies the length of the Hybrid region. For the cases of cylinderical or spherical hybrid regions, this quantity denotes {rHY}. + +The {LAT} determines the length of Atomistic region. For the cases of cylinderical or spherical hybrid regions, this quantity denotes {rAT}. + +The {Pflag} switches off and on the constant-pressure route. + +The {δλ} denotes the bin size over the hybrid region. In the on-the-fly method of averaging the drift forces, +particles are sorted into uniformly spaced λ bins of {δλ} side. + +The {dTp} denotes the time intervals in constant-pressure route at which the averaged drift forces are applied on the molecules of the hybrid region. + +The {TpStart} denotes the time step at which the simulation of the constant-pressure route is started. + +The {TpEnd} specifies the ending time step of the constant-pressure route. + +The {HYShape} specifies the geometry of the Hybrid region. This could be {slab}, {sphere}, {cylinder}. + +{Dflag} switches off and on the constant-pressure route. + +{Δx} is the bin size by which the simulation box is descritized in the constant-density route. + +{dTd} is the time interval in constant-density route at which the averaged thermodynamic forces are applied. + +{TdStart} is the starting time step of constant-density route. + +{TdEnd} is the ending time step of constant-density route. + +{σ} is the width of Gaussian function in the constant-density route. + +{R} is the range of Gaussian function in the constant-density route. + +{ρ0} is the reference density in the constant-density route. + +{c} is the prefactor in the constant-density route. + +{fileflag} denotes a flag whether the file containing the density-balancing force is employed or not. + +:line + +[Restart, fix_modify, output, run start/stop, minimize info:] + +No information about this fix is written to "binary restart +files"_restart.html. + +This fix creates a file named "Mean_Comp_Density.txt" in which the compensation forces are printed. +This file is created at {TdStart} and is updated every {dTd}. +The updating process of the file is finished at time step {TdEnd}. +For those equillibrated simulations starting at time step larger than {TdEnd}, +the file "Mean_Comp_Density.txt" is loaded in this fix. + +:line + +[Restrictions:] + +This fix calculates the center of mass of the particles. Thus at the beginning of the calculation, +it is required that all atoms belonging to a molecule are on the same side of the box. + +To employ the H-AdResS scheme, the full/hars atom style has to be used: + + atom_style full/hars :pre + +To perform HAdResS, Data File should contain the following extra information with respect to the Data File defined in full atom style: + +\[1\] [mol_H] determines the number of molecular types in the low resolution (coarse-grained) region. + +\[2\] [representative_flag] determines which atom carries the molecule's information +(center of mass, molecule's resolution, ...) in the low resolution (coarse-grained) region. + +\[3\] [mol_type] denotes the type of the molecule in the low resolution (coarse-grained) region. + +The following example is extracted from a Data File in which the simulation box contains water molecules and the ions of sodium and cholorine: + +30720 atoms +20480 bonds +10240 angles :pre + +4 atom types +[1 mol_H types] +1 bond types +1 angle types :pre + +-99.968000 99.968000 xlo xhi +-20.793600 20.793600 ylo yhi +-20.793600 20.793600 zlo zhi :pre + +Masses :pre + +1 15.999400 +2 1.007940 +3 22.9898 +4 35.453 :pre + +Atoms +#atomID molecule-tag atom-type q [representative_flag mol_type] x y z +1 1 1 -0.847200 1 1 -99.654503 -19.897600 -20.192101 +2 1 2 0.423600 0 1 -100.568001 -19.999300 -20.586599 +3 1 2 0.423600 0 1 -99.777702 -20.103100 -19.221300 +4 2 1 -0.847200 1 1 -97.826401 -17.709900 -20.127100 +5 2 2 0.423600 0 1 -96.938400 -18.071301 -19.842800 +6 2 2 0.423600 0 1 -97.735100 -16.718800 -20.030100 +7 3 3 1.0 1 1 -97.429398 -20.402201 -17.494900 +8 3 4 -1.0 1 1 -96.834000 -19.671400 -17.160999 +. +. +. :pre + +As it is shown, the representative_flag of the oxygen atoms is equal 1, and +since the soldium and cholorine are single atom ions, their representative_flags are also equals 1. +The interactions of water molecules and ions are the same in the coarse-grained region, +thus they all carry the same molecular type (mol_type). + +:line + +[Related commands:] + +"pair_lj_hars.html"_pair_lj_hars.html + +[Default:] none + +:line + + +:link(Potestio2013_1) +[(Potestio2013_1)] R. Potestio, S. Fritsch, P. Espanol, R. Delgado-Buscalioni, K. Kremer, R. Everaers, and D. Donadio, {Hamiltonian Adaptive Resolution Simulation for Molecular Liquids}, "Phys. Rev. Lett. \[110\], +108301 (2013)"_http://dx.doi.org/10.1103/PhysRevLett.110.108301 + +:link(Potestio2013_2) +[(Potestio2013_2)] R. Potestio, S. Fritsch, P. Espanol, R. Delgado-Buscalioni, K. Kremer, R. Everaers, and D. Donadio, {Monte Carlo Adaptive Resolution Simulation of Multicomponent Molecular Liquids}, "Phys. Rev. Lett. \[111\], +060601 (2013)"_http://dx.doi.org/10.1103/PhysRevLett.111.060601 + +:link(Heidari2016) +[(Heidari2016)] M. Heidari, R. Cortes-Huerto, D. Donadio and R. Potestio, {Accurate and general treatment of electrostatic interaction in Hamiltonian adaptive resolution simulations}, "EPJST (2016)" diff --git a/doc/pair_lj_hars.html b/doc/pair_lj_hars.html new file mode 100644 index 0000000000..50596c9d30 --- /dev/null +++ b/doc/pair_lj_hars.html @@ -0,0 +1,198 @@ + +
LAMMPS WWW Site - LAMMPS Documentation - LAMMPS Commands +
+ + + + + + +
+ +

pair_style lj/cut/hars/at command +

+

pair_style lj/cut/coul/dsf/hars/at command +

+

pair_style lj/cut/hars/cg command +

+

Syntax: +

+
pair_style style args 
+
+
  • style = + +
    	lj/cut/hars/at or
    +	lj/cut/coul/dsf/hars/at or
    +	lj/cut/hars/cg 
    +
    +
  • args = list of arguments for a particular style + +
      lj/cut/hars/at args = cutoff All_AT Flag_Load_File
    +    cutoff = global cutoff for Lennard Jones interactions (distance units)
    +    All_AT = Fully atomic simulation flag, = 0 or 1
    +      0 Fully atomic simulation is off and HAdResS is on
    +      1 Fully atomic simulation is on and HAdResS is off 
    +    Flag_Load_File = Flag of employing compensation energy file, = 0 or 1
    +      0 Do not employ compensation energy until TpStart
    +      1 Employ compensation energy file immediately 
    +
    +
      lj/cut/coul/dsf/hars/at args = Alpha LJcutoff Coulcutoff All_AT Flag_Load_File
    +    Alpha = Damping coefficient in DSF potential (1.0/distance units)
    +    LJcutoff = global cutoff for Lennard Jones interactions (distance units)
    +    Coulcutoff = global cutoff for DSF coulombic interactions (distance units)
    +    All_AT = Fully atomic simulation flag, = 0 or 1
    +      0 Fully atomic simulation is off and HAdResS is on
    +      1 Fully atomic simulation is on and HAdResS is off 
    +    Flag_Load_File = Flag of employing compensation energy file, = 0 or 1
    +      0 Do not employ compensation energy until TpStart
    +      1 Employ compensation energy file immediately 
    +
    +
      lj/cut/hars/cg args = cutoff All_CG Flag_Load_File
    +    cutoff = global cutoff for Lennard Jones interactions (distance units)
    +    All_CG = Fully coarse-grained simulation flag, = 0 or 1
    +      0 Fully coarse-grained simulation is off and HAdResS is on
    +      1 Fully coarse-grained simulation is on and HAdResS is off
    +    Flag_Load_File = Flag of employing compensation energy file, = 0 or 1
    +      0 Do not employ compensation energy until TpStart
    +      1 Employ compensation energy file immediately 
    +
    +

    Examples: +

    +
    pair_style      hybrid/overlay lj/cut/hars/cg 2.469416506 0 0 lj/cut/hars/at 0.2 10.0 12.0 0 0
    +pair_style      hybrid/overlay lj/cut/hars/cg 1.1224 1 0 lj/cut/hars/at 1.5 1 0 
    +
    +

    Description: +

    +

    In the H-AdResS scheme, the description of the interactions within a system of particles is given in terms +of a global Hamiltonian function H, which has the following form (Potestio2013_1), (Potestio2013_2), (Heidari2016): +

    +
    +
    +

    The term K is the atomistic kinetic energy, and Vint consists of all the intramolecular bonded interactions (e.g. bond stretching). +The value of the switching function is determined by the sizes LAT +LHY of the atomistic and hybrid regions, respectively, and of the specific geometry of the atomistic region. +

    +

    In the Hamiltonian, the non-bonded potential energy contribution of each molecule is given by a weighted sum of two terms +VαCG and VαAT, defined as: +

    +
    +
    +

    The lj/cut/hars/at styles compute the standard 12/6 Lennard-Jones potential for the atoms located in atomistic (high resolution) and hybrid region. +The general formula is given by +

    +
    +
    +

    rc is the cutoff. +

    +

    Style lj/cut/coul/dsf/hars/at computes the standard 12/6 Lennard-Jones and Coulomb interactions for atoms of atomistic (high resolution) and hybrid region. +The Coulombic term is computed via the damped shifted force model introduced by Fennell et al., given by: +

    +
    +
    +

    where alpha is the damping parameter and erfc() is the complementary +error-function. This potential is essentially a short-range, +spherically-truncated, charge-neutralized, shifted, pairwise 1/r +summation. +

    +

    The lj/cut/hars/cg styles compute the standard 12/6 Lennard-Jones potential for the atoms located in the low resolution (coarse-grained) and hybrid region. +The general formula is given by +

    +
    +
    +

    rc is the cutoff. +As mentioned above, the interactions in the coarse-grained region are computed based on the center of mass of the particles. +

    +

    Important Note: For dual resolution simulations, it is required to use hybrid/overlay to include +both resolution pair-styles. +

    +

    For all of dual resolution pair styles, the following coefficients must +be defined for each pair of atoms types via the +pair_coeff command as in the examples below +

    +
  • epsilon (energy units) + +
  • sigma (distance units) + +
  • cutoff (distance units) + +

    For examples: +

    +
      pair_coeff      * * lj/cut/hars/cg 1.0 2.2
    +  pair_coeff      1 1 lj/cut/coul/dsf/hars/at 0.15535 3.166
    +  pair_coeff      * 2 lj/cut/coul/dsf/hars/at 0.0000 0.0000 
    +
    +

    Note that sigma is defined in the LJ formula as the zero-crossing +distance for the potential, not as the energy minimum at 2^(1/6) +sigma. +

    +

    All potentials have to be shifted at the cutoff through the command +

    +
      pair_modify     shift yes 
    +
    +
    + +

    Mixing, shift, table, tail correction, restart, rRESPA info: +

    +

    All of the lj/cut pair styles support the +pair_modify shift option for the energy of the +Lennard-Jones portion of the pair interaction. +

    +

    All of the lj/cut pair styles write their information to binary +restart files, so pair_style and pair_coeff commands do +not need to be specified in an input script that reads a restart file. +

    +

    The pair styles do not support the use of the rRESPA hierarchy. +

    +

    Each pair styles creates a file named as "Mean_Comp_Energy_XX.txt", where the file name's suffix "XX", is replaced by "AT" and "CG" for atomistic and coarse-grained pairwise interactions respectively. +In these files the averaged compensation energy as function of the resolution (λ) is printed. Each file is created at TpStart and is updated every dTp. +The updating process of the files is finished at time step TpEnd. +For those equilibrated simulations starting at time step larger than TpEnd, the file "Mean_Comp_Energy_XX.txt" is loaded in each pair styles. For more information, +see fix_lambdah_calc. +

    +
    + +

    Restrictions: +

    +

    In HAdResS, it is required to include both high resolution (atomistic) +and low resolution (coarse-grained) force fields together through +

    +
      pair_style      hybrid/overlay 
    +
    +

    An example of such setup is given above. +

    +

    To employ the H-AdResS scheme, the full/hars atom style as well as (fix_lambdah_calc) have to be used: +

    +
      atom_style      full/hars 
    +
    +
      fix             ID group-ID lambdah/calc ... 
    +
    +
    + +

    Related commands: +

    +

    fix_lambdah_calc, pair_coeff +

    +

    Default: none +

    +
    + + + +

    (Potestio2013_1) R. Potestio, S. Fritsch, P. Espanol, R. Delgado-Buscalioni, K. Kremer, R. Everaers, and D. Donadio, Hamiltonian Adaptive Resolution Simulation for Molecular Liquids, Phys. Rev. Lett. [110], +108301 (2013) +

    + + +

    (Potestio2013_2) R. Potestio, S. Fritsch, P. Espanol, R. Delgado-Buscalioni, K. Kremer, R. Everaers, and D. Donadio, Monte Carlo Adaptive Resolution Simulation of Multicomponent Molecular Liquids, Phys. Rev. Lett. [111], +060601 (2013) +

    + + +

    (Heidari2016) M. Heidari, R. Cortes-Huerto, D. Donadio and R. Potestio, Accurate and general treatment of electrostatic interaction in Hamiltonian adaptive resolution simulations, "EPJST (2016)" +

    + + +

    (Fennell) C. J. Fennell, J. D. Gezelter, J Chem Phys, 124, +234104 (2006). +

    + diff --git a/doc/pair_lj_hars.txt b/doc/pair_lj_hars.txt new file mode 100644 index 0000000000..7813f40aa2 --- /dev/null +++ b/doc/pair_lj_hars.txt @@ -0,0 +1,181 @@ +"LAMMPS WWW Site"_lws - "LAMMPS Documentation"_ld - "LAMMPS Commands"_lc :c + +:link(lws,http://lammps.sandia.gov) +:link(ld,Manual.html) +:link(lc,Section_commands.html#comm) + +:line + +pair_style lj/cut/hars/at command :h3 +pair_style lj/cut/coul/dsf/hars/at command :h3 +pair_style lj/cut/hars/cg command :h3 + +[Syntax:] + +pair_style style args :pre + +style = :l + {lj/cut/hars/at} or + {lj/cut/coul/dsf/hars/at} or + {lj/cut/hars/cg} :pre +args = list of arguments for a particular style :l + {lj/cut/hars/at} args = cutoff All_AT Flag_Load_File + cutoff = global cutoff for Lennard Jones interactions (distance units) + All_AT = Fully atomic simulation flag, = {0} or {1} + {0} Fully atomic simulation is off and HAdResS is on + {1} Fully atomic simulation is on and HAdResS is off + Flag_Load_File = Flag of employing compensation energy file, = {0} or {1} + {0} Do not employ compensation energy until TpStart + {1} Employ compensation energy file immediately :pre + {lj/cut/coul/dsf/hars/at} args = Alpha LJcutoff Coulcutoff All_AT Flag_Load_File + Alpha = Damping coefficient in DSF potential (1.0/distance units) + LJcutoff = global cutoff for Lennard Jones interactions (distance units) + Coulcutoff = global cutoff for DSF coulombic interactions (distance units) + All_AT = Fully atomic simulation flag, = {0} or {1} + {0} Fully atomic simulation is off and HAdResS is on + {1} Fully atomic simulation is on and HAdResS is off + Flag_Load_File = Flag of employing compensation energy file, = {0} or {1} + {0} Do not employ compensation energy until TpStart + {1} Employ compensation energy file immediately :pre + {lj/cut/hars/cg} args = cutoff All_CG Flag_Load_File + cutoff = global cutoff for Lennard Jones interactions (distance units) + All_CG = Fully coarse-grained simulation flag, = {0} or {1} + {0} Fully coarse-grained simulation is off and HAdResS is on + {1} Fully coarse-grained simulation is on and HAdResS is off + Flag_Load_File = Flag of employing compensation energy file, = {0} or {1} + {0} Do not employ compensation energy until TpStart + {1} Employ compensation energy file immediately :pre + +[Examples:] + +pair_style hybrid/overlay lj/cut/hars/cg 2.469416506 0 0 lj/cut/hars/at 0.2 10.0 12.0 0 0 +pair_style hybrid/overlay lj/cut/hars/cg 1.1224 1 0 lj/cut/hars/at 1.5 1 0 :pre + +[Description:] + +In the H-AdResS scheme, the description of the interactions within a system of particles is given in terms +of a global Hamiltonian function H, which has the following form "(Potestio2013_1)"_#Potestio2013_1, "(Potestio2013_2)"_#Potestio2013_2, "(Heidari2016)"_#Heidari2016: + +:c,image(Eqs/HADRESS_System_Hamiltonian.png) + +The term K is the atomistic kinetic energy, and Vint consists of all the intramolecular bonded interactions (e.g. bond stretching). +The value of the switching function is determined by the sizes LAT +LHY of the atomistic and hybrid regions, respectively, and of the specific geometry of the atomistic region. + +In the Hamiltonian, the non-bonded potential energy contribution of each molecule is given by a weighted sum of two terms +VαCG and VαAT, defined as: + +:c,image(Eqs/HADRESS_System_Potentials.png) + +The {lj/cut/hars/at} styles compute the standard 12/6 Lennard-Jones potential for the atoms located in atomistic (high resolution) and hybrid region. +The general formula is given by + +:c,image(Eqs/HADRESS_AT_pair_lj.png) + +rc is the cutoff. + +Style {lj/cut/coul/dsf/hars/at} computes the standard 12/6 Lennard-Jones and Coulomb interactions for atoms of atomistic (high resolution) and hybrid region. +The Coulombic term is computed via the damped shifted force model introduced by "Fennell et al."_#Fennell, given by: + +:c,image(Eqs/HADRESS_AT_pair_coul_dsf.jpg) + +where {alpha} is the damping parameter and erfc() is the complementary +error-function. This potential is essentially a short-range, +spherically-truncated, charge-neutralized, shifted, pairwise {1/r} +summation. + +The {lj/cut/hars/cg} styles compute the standard 12/6 Lennard-Jones potential for the atoms located in the low resolution (coarse-grained) and hybrid region. +The general formula is given by + +:c,image(Eqs/HADRESS_CG_pair_lj.png) + +rc is the cutoff. +As mentioned above, the interactions in the coarse-grained region are computed based on the center of mass of the particles. + +Important Note: For dual resolution simulations, it is required to use hybrid/overlay to include +both resolution pair-styles. + +For all of dual resolution pair styles, the following coefficients must +be defined for each pair of atoms types via the +"pair_coeff"_pair_coeff.html command as in the examples below + +epsilon (energy units) :l +sigma (distance units) :l +cutoff (distance units) :l + +For examples: + + pair_coeff * * lj/cut/hars/cg 1.0 2.2 + pair_coeff 1 1 lj/cut/coul/dsf/hars/at 0.15535 3.166 + pair_coeff * 2 lj/cut/coul/dsf/hars/at 0.0000 0.0000 :pre + +Note that sigma is defined in the LJ formula as the zero-crossing +distance for the potential, not as the energy minimum at 2^(1/6) +sigma. + +All potentials have to be shifted at the cutoff through the command + + pair_modify shift yes :pre + + +:line + + +[Mixing, shift, table, tail correction, restart, rRESPA info]: + +All of the {lj/cut} pair styles support the +"pair_modify"_pair_modify.html shift option for the energy of the +Lennard-Jones portion of the pair interaction. + +All of the {lj/cut} pair styles write their information to "binary +restart files"_restart.html, so pair_style and pair_coeff commands do +not need to be specified in an input script that reads a restart file. + +The pair styles do not support the use of the rRESPA hierarchy. + +Each pair styles creates a file named as "Mean_Comp_Energy_XX.txt", where the file name's suffix "XX", is replaced by "AT" and "CG" for atomistic and coarse-grained pairwise interactions respectively. +In these files the averaged compensation energy as function of the resolution (λ) is printed. Each file is created at {TpStart} and is updated every {dTp}. +The updating process of the files is finished at time step {TpEnd}. +For those equilibrated simulations starting at time step larger than {TpEnd}, the file "Mean_Comp_Energy_XX.txt" is loaded in each pair styles. For more information, +see "fix_lambdah_calc"_fix_lambdah_calc.html. + +:line + +[Restrictions:] + +In HAdResS, it is required to include both high resolution (atomistic) +and low resolution (coarse-grained) force fields together through + + pair_style hybrid/overlay :pre +An example of such setup is given above. + +To employ the H-AdResS scheme, the full/hars atom style as well as "(fix_lambdah_calc)"_fix_lambdah_calc.html have to be used: + + atom_style full/hars :pre + + fix ID group-ID lambdah/calc ... :pre + +:line + +[Related commands:] + +"fix_lambdah_calc"_fix_lambdah_calc.html, "pair_coeff"_pair_coeff.html + +[Default:] none + +:line + +:link(Potestio2013_1) +[(Potestio2013_1)] R. Potestio, S. Fritsch, P. Espanol, R. Delgado-Buscalioni, K. Kremer, R. Everaers, and D. Donadio, {Hamiltonian Adaptive Resolution Simulation for Molecular Liquids}, "Phys. Rev. Lett. \[110\], +108301 (2013)"_http://dx.doi.org/10.1103/PhysRevLett.110.108301 + +:link(Potestio2013_2) +[(Potestio2013_2)] R. Potestio, S. Fritsch, P. Espanol, R. Delgado-Buscalioni, K. Kremer, R. Everaers, and D. Donadio, {Monte Carlo Adaptive Resolution Simulation of Multicomponent Molecular Liquids}, "Phys. Rev. Lett. \[111\], +060601 (2013)"_http://dx.doi.org/10.1103/PhysRevLett.111.060601 + +:link(Heidari2016) +[(Heidari2016)] M. Heidari, R. Cortes-Huerto, D. Donadio and R. Potestio, {Accurate and general treatment of electrostatic interaction in Hamiltonian adaptive resolution simulations}, "EPJST (2016)" + +:link(Fennell) +[(Fennell)] C. J. Fennell, J. D. Gezelter, J Chem Phys, 124, +234104 (2006). diff --git a/src/USER-HADRESS/Install.sh b/src/USER-HADRESS/Install.sh new file mode 100644 index 0000000000..1b919c4c58 --- /dev/null +++ b/src/USER-HADRESS/Install.sh @@ -0,0 +1,60 @@ +# Install/unInstall package files in LAMMPS +# mode = 0/1/2 for uninstall/install/update + +mode=$1 + +# arg1 = file, arg2 = file it depends on + +action () { + if (test $mode = 0) then + rm -f ../$1 + elif (! cmp -s $1 ../$1) then + if (test -z "$2" || test -e ../$2) then + cp $1 .. + if (test $mode = 2) then + echo " updating src/$1" + fi + fi + elif (test -n "$2") then + if (test ! -e ../$2) then + rm -f ../$1 + fi + fi +} + +# all package files with no dependencies + +for file in *.cpp *.h; do + action $file +done + +# edit 2 Makefile.package files to include/exclude package info + +if (test $1 = 1) then + + if (test -e ../Makefile.package) then + sed -i -e 's/[^ \t]*user-hadress[^ \t]* //' ../Makefile.package + sed -i -e 's|^PKG_SYSINC =[ \t]*|&$(user-hadress_SYSINC) |' ../Makefile.package + sed -i -e 's|^PKG_SYSLIB =[ \t]*|&$(user-hadress_SYSLIB) |' ../Makefile.package + sed -i -e 's|^PKG_SYSPATH =[ \t]*|&$(user-hadress_SYSPATH) |' ../Makefile.package + fi + + if (test -e ../Makefile.package.settings) then + sed -i -e '/^include.*user-hadress.*$/d' ../Makefile.package.settings + # multiline form needed for BSD sed on Macs + sed -i -e '4 i \ +include ..\/..\/lib\/user-hadress\/Makefile.lammps +' ../Makefile.package.settings + fi + +elif (test $1 = 0) then + + if (test -e ../Makefile.package) then + sed -i -e 's/[^ \t]*user-hadress[^ \t]* //' ../Makefile.package + fi + + if (test -e ../Makefile.package.settings) then + sed -i -e '/^include.*user-hadress.*$/d' ../Makefile.package.settings + fi + +fi diff --git a/src/USER-HADRESS/atom.cpp b/src/USER-HADRESS/atom.cpp new file mode 100644 index 0000000000..6ef632683b --- /dev/null +++ b/src/USER-HADRESS/atom.cpp @@ -0,0 +1,2206 @@ +/* ---------------------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + http://lammps.sandia.gov, Sandia National Laboratories + Steve Plimpton, sjplimp@sandia.gov + + Copyright (2003) Sandia Corporation. Under the terms of Contract + DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains + certain rights in this software. This software is distributed under + the GNU General Public License. + + See the README file in the top-level LAMMPS directory. +------------------------------------------------------------------------- */ + +#include +#include +#include +#include +#include +#include +#include "atom.h" +#include "style_atom.h" +#include "atom_vec.h" +#include "atom_vec_ellipsoid.h" +#include "comm.h" +#include "neighbor.h" +#include "force.h" +#include "modify.h" +#include "fix.h" +#include "output.h" +#include "thermo.h" +#include "update.h" +#include "domain.h" +#include "group.h" +#include "molecule.h" +#include "accelerator_cuda.h" +#include "atom_masks.h" +#include "math_const.h" +#include "memory.h" +#include "error.h" + +using namespace LAMMPS_NS; +using namespace MathConst; + +#define DELTA 1 +#define DELTA_MEMSTR 1024 +#define EPSILON 1.0e-6 +#define CUDA_CHUNK 3000 + +enum{LAYOUT_UNIFORM,LAYOUT_NONUNIFORM,LAYOUT_TILED}; // several files + +/* ---------------------------------------------------------------------- */ + +Atom::Atom(LAMMPS *lmp) : Pointers(lmp) +{ + natoms = 0; + nlocal = nghost = nmax = 0; + ntypes = 0; + nbondtypes = nangletypes = ndihedraltypes = nimpropertypes = 0; + nbonds = nangles = ndihedrals = nimpropers = 0; + + firstgroupname = NULL; + sortfreq = 1000; + nextsort = 0; + userbinsize = 0.0; + maxbin = maxnext = 0; + binhead = NULL; + next = permute = NULL; + + // initialize atom arrays + // customize by adding new array + + tag = NULL; + type = mask = NULL; + image = NULL; + x = v = f = NULL; + + molecule = NULL; + molindex = molatom = NULL; + q = NULL; + mu = NULL; + omega = angmom = torque = NULL; + radius = rmass = NULL; + ellipsoid = line = tri = body = NULL; + + lambdaH = NULL; + gradlambdaH = NULL; + replambdaH = NULL; + moltypeH = NULL; + comH = NULL; + nmoltypesH = 0; + + vfrac = s0 = NULL; + x0 = NULL; + + spin = NULL; + eradius = ervel = erforce = NULL; + cs = csforce = vforce = ervelforce = NULL; + etag = NULL; + + rho = drho = e = de = cv = NULL; + vest = NULL; + + // USER-DPD + + uCond = uMech = uChem = uCG = uCGnew = NULL; + duCond = duMech = duChem = NULL; + dpdTheta = NULL; + + // USER-SMD + + contact_radius = NULL; + smd_data_9 = NULL; + smd_stress = NULL; + eff_plastic_strain = NULL; + eff_plastic_strain_rate = NULL; + damage = NULL; + + // molecular info + + bond_per_atom = extra_bond_per_atom = 0; + num_bond = NULL; + bond_type = NULL; + bond_atom = NULL; + + angle_per_atom = extra_angle_per_atom = 0; + num_angle = NULL; + angle_type = NULL; + angle_atom1 = angle_atom2 = angle_atom3 = NULL; + + dihedral_per_atom = extra_dihedral_per_atom = 0; + num_dihedral = NULL; + dihedral_type = NULL; + dihedral_atom1 = dihedral_atom2 = dihedral_atom3 = dihedral_atom4 = NULL; + + improper_per_atom = extra_improper_per_atom = 0; + num_improper = NULL; + improper_type = NULL; + improper_atom1 = improper_atom2 = improper_atom3 = improper_atom4 = NULL; + + maxspecial = 1; + nspecial = NULL; + special = NULL; + + // user-defined molecules + + nmolecule = 0; + molecules = NULL; + + // custom atom arrays + + nivector = ndvector = 0; + ivector = NULL; + dvector = NULL; + iname = dname = NULL; + + // initialize atom style and array existence flags + // customize by adding new flag + + sphere_flag = peri_flag = electron_flag = 0; + wavepacket_flag = sph_flag = 0; + + molecule_flag = 0; + q_flag = mu_flag = 0; + omega_flag = torque_flag = angmom_flag = 0; + radius_flag = rmass_flag = 0; + ellipsoid_flag = line_flag = tri_flag = body_flag = 0; + + vfrac_flag = 0; + spin_flag = eradius_flag = ervel_flag = erforce_flag = ervelforce_flag = 0; + cs_flag = csforce_flag = vforce_flag = etag_flag = 0; + + rho_flag = e_flag = cv_flag = vest_flag = 0; + dpd_flag = 0; + + // USER-SMD + + smd_flag = 0; + contact_radius_flag = 0; + smd_data_9_flag = 0; + smd_stress_flag = 0; + x0_flag = 0; + eff_plastic_strain_flag = 0; + eff_plastic_strain_rate_flag = 0; + damage_flag = 0; + + // Peridynamic scale factor + + pdscale = 1.0; + + // ntype-length arrays + + mass = NULL; + mass_setflag = NULL; + + // callback lists & extra restart info + + nextra_grow = nextra_restart = nextra_border = 0; + extra_grow = extra_restart = extra_border = NULL; + nextra_grow_max = nextra_restart_max = nextra_border_max = 0; + nextra_store = 0; + extra = NULL; + + // default atom ID and mapping values + + tag_enable = 1; + map_style = map_user = 0; + map_tag_max = -1; + map_maxarray = map_nhash = -1; + + max_same = 0; + sametag = NULL; + map_array = NULL; + map_bucket = NULL; + map_hash = NULL; + + atom_style = NULL; + avec = NULL; + + datamask = ALL_MASK; + datamask_ext = ALL_MASK; +} + +/* ---------------------------------------------------------------------- */ + +Atom::~Atom() +{ + delete [] atom_style; + delete avec; + + delete [] firstgroupname; + memory->destroy(binhead); + memory->destroy(next); + memory->destroy(permute); + + // delete atom arrays + // customize by adding new array + + memory->destroy(tag); + memory->destroy(type); + memory->destroy(mask); + memory->destroy(image); + memory->destroy(x); + memory->destroy(v); + memory->destroy(f); + + memory->destroy(molecule); + memory->destroy(molindex); + memory->destroy(molatom); + + memory->destroy(lambdaH); + memory->destroy(replambdaH); + memory->destroy(moltypeH); + memory->destroy(gradlambdaH); + memory->destroy(comH); + + memory->destroy(q); + memory->destroy(mu); + memory->destroy(omega); + memory->destroy(angmom); + memory->destroy(torque); + memory->destroy(radius); + memory->destroy(rmass); + memory->destroy(ellipsoid); + memory->destroy(line); + memory->destroy(tri); + memory->destroy(body); + + memory->destroy(vfrac); + memory->destroy(s0); + memory->destroy(x0); + + memory->destroy(spin); + memory->destroy(eradius); + memory->destroy(ervel); + memory->destroy(erforce); + memory->destroy(ervelforce); + memory->destroy(cs); + memory->destroy(csforce); + memory->destroy(vforce); + memory->destroy(etag); + + memory->destroy(rho); + memory->destroy(drho); + memory->destroy(e); + memory->destroy(de); + memory->destroy(cv); + memory->destroy(vest); + + memory->destroy(contact_radius); + memory->destroy(smd_data_9); + memory->destroy(smd_stress); + memory->destroy(eff_plastic_strain); + memory->destroy(eff_plastic_strain_rate); + memory->destroy(damage); + + memory->destroy(dpdTheta); + memory->destroy(uCond); + memory->destroy(uMech); + memory->destroy(uChem); + memory->destroy(uCG); + memory->destroy(uCGnew); + memory->destroy(duCond); + memory->destroy(duMech); + memory->destroy(duChem); + + memory->destroy(nspecial); + memory->destroy(special); + + memory->destroy(num_bond); + memory->destroy(bond_type); + memory->destroy(bond_atom); + + memory->destroy(num_angle); + memory->destroy(angle_type); + memory->destroy(angle_atom1); + memory->destroy(angle_atom2); + memory->destroy(angle_atom3); + + memory->destroy(num_dihedral); + memory->destroy(dihedral_type); + memory->destroy(dihedral_atom1); + memory->destroy(dihedral_atom2); + memory->destroy(dihedral_atom3); + memory->destroy(dihedral_atom4); + + memory->destroy(num_improper); + memory->destroy(improper_type); + memory->destroy(improper_atom1); + memory->destroy(improper_atom2); + memory->destroy(improper_atom3); + memory->destroy(improper_atom4); + + // delete custom atom arrays + + for (int i = 0; i < nivector; i++) { + delete [] iname[i]; + memory->destroy(ivector[i]); + } + for (int i = 0; i < ndvector; i++) { + delete [] dname[i]; + memory->destroy(dvector[i]); + } + + memory->sfree(iname); + memory->sfree(dname); + memory->sfree(ivector); + memory->sfree(dvector); + + // delete user-defined molecules + + for (int i = 0; i < nmolecule; i++) delete molecules[i]; + memory->sfree(molecules); + + // delete per-type arrays + + delete [] mass; + delete [] mass_setflag; + + // delete extra arrays + + memory->destroy(extra_grow); + memory->destroy(extra_restart); + memory->destroy(extra_border); + memory->destroy(extra); + + // delete mapping data structures + + map_delete(); +} + +/* ---------------------------------------------------------------------- + copy modify settings from old Atom class to current Atom class +------------------------------------------------------------------------- */ + +void Atom::settings(Atom *old) +{ + tag_enable = old->tag_enable; + map_user = old->map_user; + map_style = old->map_style; + sortfreq = old->sortfreq; + userbinsize = old->userbinsize; + if (old->firstgroupname) { + int n = strlen(old->firstgroupname) + 1; + firstgroupname = new char[n]; + strcpy(firstgroupname,old->firstgroupname); + } +} + +/* ---------------------------------------------------------------------- + create an AtomVec style + called from lammps.cpp, input script, restart file, replicate +------------------------------------------------------------------------- */ + +void Atom::create_avec(const char *style, int narg, char **arg, int trysuffix) +{ + delete [] atom_style; + if (avec) delete avec; + + // unset atom style and array existence flags + // may have been set by old avec + // customize by adding new flag + + sphere_flag = peri_flag = electron_flag = 0; + wavepacket_flag = sph_flag = 0; + + molecule_flag = 0; + q_flag = mu_flag = 0; + replambdaH_flag = 0; + moltypeH_flag = 0; + + omega_flag = torque_flag = angmom_flag = 0; + radius_flag = rmass_flag = 0; + ellipsoid_flag = line_flag = tri_flag = body_flag = 0; + + vfrac_flag = 0; + spin_flag = eradius_flag = ervel_flag = erforce_flag = ervelforce_flag = 0; + cs_flag = csforce_flag = vforce_flag = etag_flag = 0; + + rho_flag = e_flag = cv_flag = vest_flag = 0; + + // create instance of AtomVec + // use grow() to initialize atom-based arrays to length 1 + // so that x[0][0] can always be referenced even if proc has no atoms + + int sflag; + avec = new_avec(style,trysuffix,sflag); + avec->store_args(narg,arg); + avec->process_args(narg,arg); + avec->grow(1); + + if (sflag) { + char estyle[256]; + if (sflag == 1) sprintf(estyle,"%s/%s",style,lmp->suffix); + else sprintf(estyle,"%s/%s",style,lmp->suffix2); + int n = strlen(estyle) + 1; + atom_style = new char[n]; + strcpy(atom_style,estyle); + } else { + int n = strlen(style) + 1; + atom_style = new char[n]; + strcpy(atom_style,style); + } + + // if molecular system: + // atom IDs must be defined + // force atom map to be created + // map style may be reset by map_init() and its call to map_style_set() + + molecular = avec->molecular; + if (molecular && tag_enable == 0) + error->all(FLERR,"Atom IDs must be used for molecular systems"); + if (molecular) map_style = 1; +} + +/* ---------------------------------------------------------------------- + generate an AtomVec class, first with suffix appended +------------------------------------------------------------------------- */ + +AtomVec *Atom::new_avec(const char *style, int trysuffix, int &sflag) +{ + if (trysuffix && lmp->suffix_enable) { + if (lmp->suffix) { + sflag = 1; + char estyle[256]; + sprintf(estyle,"%s/%s",style,lmp->suffix); + + if (0) return NULL; + +#define ATOM_CLASS +#define AtomStyle(key,Class) \ + else if (strcmp(estyle,#key) == 0) return new Class(lmp); +#include "style_atom.h" +#undef AtomStyle +#undef ATOM_CLASS + } + + if (lmp->suffix2) { + sflag = 2; + char estyle[256]; + sprintf(estyle,"%s/%s",style,lmp->suffix2); + + if (0) return NULL; + +#define ATOM_CLASS +#define AtomStyle(key,Class) \ + else if (strcmp(estyle,#key) == 0) return new Class(lmp); +#include "style_atom.h" +#undef AtomStyle +#undef ATOM_CLASS + } + } + + sflag = 0; + if (0) return NULL; + +#define ATOM_CLASS +#define AtomStyle(key,Class) \ + else if (strcmp(style,#key) == 0) return new Class(lmp); +#include "style_atom.h" +#undef ATOM_CLASS + + else error->all(FLERR,"Unknown atom style"); + return NULL; +} + +/* ---------------------------------------------------------------------- */ + +void Atom::init() +{ + // delete extra array since it doesn't persist past first run + + if (nextra_store) { + memory->destroy(extra); + extra = NULL; + nextra_store = 0; + } + + // check arrays that are atom type in length + + check_mass(); + + // setup of firstgroup + + if (firstgroupname) { + firstgroup = group->find(firstgroupname); + if (firstgroup < 0) + error->all(FLERR,"Could not find atom_modify first group ID"); + } else firstgroup = -1; + + // init AtomVec + + avec->init(); +} + +/* ---------------------------------------------------------------------- */ + +void Atom::setup() +{ + // setup bins for sorting + // cannot do this in init() because uses neighbor cutoff + + if (sortfreq > 0) setup_sort_bins(); +} + +/* ---------------------------------------------------------------------- + return ptr to AtomVec class if matches style or to matching hybrid sub-class + return NULL if no match +------------------------------------------------------------------------- */ + +AtomVec *Atom::style_match(const char *style) +{ + if (strcmp(atom_style,style) == 0) return avec; + else if (strcmp(atom_style,"hybrid") == 0) { + AtomVecHybrid *avec_hybrid = (AtomVecHybrid *) avec; + for (int i = 0; i < avec_hybrid->nstyles; i++) + if (strcmp(avec_hybrid->keywords[i],style) == 0) + return avec_hybrid->styles[i]; + } + return NULL; +} + +/* ---------------------------------------------------------------------- + modify parameters of the atom style + some options can only be invoked before simulation box is defined + first and sort options cannot be used together +------------------------------------------------------------------------- */ + +void Atom::modify_params(int narg, char **arg) +{ + if (narg == 0) error->all(FLERR,"Illegal atom_modify command"); + + int iarg = 0; + while (iarg < narg) { + if (strcmp(arg[iarg],"id") == 0) { + if (iarg+2 > narg) error->all(FLERR,"Illegal atom_modify command"); + if (domain->box_exist) + error->all(FLERR, + "Atom_modify id command after simulation box is defined"); + if (strcmp(arg[iarg+1],"yes") == 0) tag_enable = 1; + else if (strcmp(arg[iarg+1],"no") == 0) tag_enable = 0; + else error->all(FLERR,"Illegal atom_modify command"); + iarg += 2; + } else if (strcmp(arg[iarg],"map") == 0) { + if (iarg+2 > narg) error->all(FLERR,"Illegal atom_modify command"); + if (domain->box_exist) + error->all(FLERR, + "Atom_modify map command after simulation box is defined"); + if (strcmp(arg[iarg+1],"array") == 0) map_user = 1; + else if (strcmp(arg[iarg+1],"hash") == 0) map_user = 2; + else error->all(FLERR,"Illegal atom_modify command"); + map_style = map_user; + iarg += 2; + } else if (strcmp(arg[iarg],"first") == 0) { + if (iarg+2 > narg) error->all(FLERR,"Illegal atom_modify command"); + if (strcmp(arg[iarg+1],"all") == 0) { + delete [] firstgroupname; + firstgroupname = NULL; + } else { + int n = strlen(arg[iarg+1]) + 1; + firstgroupname = new char[n]; + strcpy(firstgroupname,arg[iarg+1]); + sortfreq = 0; + } + iarg += 2; + } else if (strcmp(arg[iarg],"sort") == 0) { + if (iarg+3 > narg) error->all(FLERR,"Illegal atom_modify command"); + sortfreq = force->inumeric(FLERR,arg[iarg+1]); + userbinsize = force->numeric(FLERR,arg[iarg+2]); + if (sortfreq < 0 || userbinsize < 0.0) + error->all(FLERR,"Illegal atom_modify command"); + if (sortfreq >= 0 && firstgroupname) + error->all(FLERR,"Atom_modify sort and first options " + "cannot be used together"); + iarg += 3; + } else error->all(FLERR,"Illegal atom_modify command"); + } +} + +/* ---------------------------------------------------------------------- + check that atom IDs are valid + error if any atom ID < 0 or atom ID = MAXTAGINT + if any atom ID > 0, error if any atom ID == 0 + if any atom ID > 0, error if tag_enable = 0 + if all atom IDs = 0, tag_enable must be 0 + if max atom IDs < natoms, must be duplicates + OK if max atom IDs > natoms + NOTE: not fully checking that atom IDs are unique +------------------------------------------------------------------------- */ + +void Atom::tag_check() +{ + tagint min = MAXTAGINT; + tagint max = 0; + + for (int i = 0; i < nlocal; i++) { + min = MIN(min,tag[i]); + max = MAX(max,tag[i]); + } + + tagint minall,maxall; + MPI_Allreduce(&min,&minall,1,MPI_LMP_TAGINT,MPI_MIN,world); + MPI_Allreduce(&max,&maxall,1,MPI_LMP_TAGINT,MPI_MAX,world); + + if (minall < 0) error->all(FLERR,"One or more Atom IDs is negative"); + if (maxall >= MAXTAGINT) error->all(FLERR,"One or more atom IDs is too big"); + if (maxall > 0 && minall == 0) + error->all(FLERR,"One or more atom IDs is zero"); + if (maxall > 0 && tag_enable == 0) + error->all(FLERR,"Non-zero atom IDs with atom_modify id = no"); + if (maxall == 0 && natoms && tag_enable) + error->all(FLERR,"All atom IDs = 0 but atom_modify id = yes"); + if (tag_enable && maxall < natoms) + error->all(FLERR,"Duplicate atom IDs exist"); +} + +/* ---------------------------------------------------------------------- + add unique tags to any atoms with tag = 0 + new tags are grouped by proc and start after max current tag + called after creating new atoms + error if new tags will exceed MAXTAGINT +------------------------------------------------------------------------- */ + +void Atom::tag_extend() +{ + // maxtag_all = max tag for all atoms + + tagint maxtag = 0; + for (int i = 0; i < nlocal; i++) maxtag = MAX(maxtag,tag[i]); + tagint maxtag_all; + MPI_Allreduce(&maxtag,&maxtag_all,1,MPI_LMP_TAGINT,MPI_MAX,world); + + // DEBUG: useful for generating 64-bit IDs even for small systems + // use only when LAMMPS is compiled with BIGBIG + + //maxtag_all += 1000000000000; + + // notag = # of atoms I own with no tag (tag = 0) + // notag_sum = # of total atoms on procs <= me with no tag + + bigint notag = 0; + for (int i = 0; i < nlocal; i++) if (tag[i] == 0) notag++; + + bigint notag_total; + MPI_Allreduce(¬ag,¬ag_total,1,MPI_LMP_BIGINT,MPI_SUM,world); + if (notag_total >= MAXTAGINT) + error->all(FLERR,"New atom IDs exceed maximum allowed ID"); + + bigint notag_sum; + MPI_Scan(¬ag,¬ag_sum,1,MPI_LMP_BIGINT,MPI_SUM,world); + + // itag = 1st new tag that my untagged atoms should use + + tagint itag = maxtag_all + notag_sum - notag + 1; + for (int i = 0; i < nlocal; i++) if (tag[i] == 0) tag[i] = itag++; +} + +/* ---------------------------------------------------------------------- + check that atom IDs span range from 1 to Natoms inclusive + return 0 if mintag != 1 or maxtag != Natoms + return 1 if OK + doesn't actually check if all tag values are used +------------------------------------------------------------------------- */ + +int Atom::tag_consecutive() +{ + tagint idmin = MAXTAGINT; + tagint idmax = 0; + + for (int i = 0; i < nlocal; i++) { + idmin = MIN(idmin,tag[i]); + idmax = MAX(idmax,tag[i]); + } + tagint idminall,idmaxall; + MPI_Allreduce(&idmin,&idminall,1,MPI_LMP_TAGINT,MPI_MIN,world); + MPI_Allreduce(&idmax,&idmaxall,1,MPI_LMP_TAGINT,MPI_MAX,world); + + if (idminall != 1 || idmaxall != natoms) return 0; + return 1; +} + +/* ---------------------------------------------------------------------- + count and return words in a single line + make copy of line before using strtok so as not to change line + trim anything from '#' onward +------------------------------------------------------------------------- */ + +int Atom::count_words(const char *line) +{ + int n = strlen(line) + 1; + char *copy; + memory->create(copy,n,"atom:copy"); + strcpy(copy,line); + + char *ptr; + if ((ptr = strchr(copy,'#'))) *ptr = '\0'; + + if (strtok(copy," \t\n\r\f") == NULL) { + memory->destroy(copy); + return 0; + } + n = 1; + while (strtok(NULL," \t\n\r\f")) n++; + + memory->destroy(copy); + return n; +} + +/* ---------------------------------------------------------------------- + count and return words in a single line using provided copy buf + make copy of line before using strtok so as not to change line + trim anything from '#' onward +------------------------------------------------------------------------- */ + +int Atom::count_words(const char *line, char *copy) +{ + strcpy(copy,line); + + char *ptr; + if ((ptr = strchr(copy,'#'))) *ptr = '\0'; + + if (strtok(copy," \t\n\r\f") == NULL) { + memory->destroy(copy); + return 0; + } + int n = 1; + while (strtok(NULL," \t\n\r\f")) n++; + + return n; +} + +/* ---------------------------------------------------------------------- + deallocate molecular topology arrays + done before realloc with (possibly) new 2nd dimension set to + correctly initialized per-atom values, e.g. bond_per_atom + needs to be called whenever 2nd dimensions are changed + and these arrays are already pre-allocated, + e.g. due to grow(1) in create_avec() +------------------------------------------------------------------------- */ + +void Atom::deallocate_topology() +{ + memory->destroy(atom->bond_type); + memory->destroy(atom->bond_atom); + atom->bond_type = NULL; + atom->bond_atom = NULL; + + memory->destroy(atom->angle_type); + memory->destroy(atom->angle_atom1); + memory->destroy(atom->angle_atom2); + memory->destroy(atom->angle_atom3); + atom->angle_type = NULL; + atom->angle_atom1 = atom->angle_atom2 = atom->angle_atom3 = NULL; + + memory->destroy(atom->dihedral_type); + memory->destroy(atom->dihedral_atom1); + memory->destroy(atom->dihedral_atom2); + memory->destroy(atom->dihedral_atom3); + memory->destroy(atom->dihedral_atom4); + atom->dihedral_type = NULL; + atom->dihedral_atom1 = atom->dihedral_atom2 = + atom->dihedral_atom3 = atom->dihedral_atom4 = NULL; + + memory->destroy(atom->improper_type); + memory->destroy(atom->improper_atom1); + memory->destroy(atom->improper_atom2); + memory->destroy(atom->improper_atom3); + memory->destroy(atom->improper_atom4); + atom->improper_type = NULL; + atom->improper_atom1 = atom->improper_atom2 = + atom->improper_atom3 = atom->improper_atom4 = NULL; +} + +/* ---------------------------------------------------------------------- + unpack N lines from Atom section of data file + call style-specific routine to parse line +------------------------------------------------------------------------- */ + +void Atom::data_atoms(int n, char *buf, tagint id_offset, int type_offset, + int shiftflag, double *shift) +{ + int m,xptr,iptr; + imageint imagedata; + double xdata[3],lamda[3]; + double *coord; + char *next; + + next = strchr(buf,'\n'); + *next = '\0'; + int nwords = count_words(buf); + *next = '\n'; + + if (nwords != avec->size_data_atom && nwords != avec->size_data_atom + 3) + error->all(FLERR,"Incorrect atom format in data file"); + + char **values = new char*[nwords]; + + // set bounds for my proc + // if periodic and I am lo/hi proc, adjust bounds by EPSILON + // insures all data atoms will be owned even with round-off + + int triclinic = domain->triclinic; + + double epsilon[3]; + if (triclinic) epsilon[0] = epsilon[1] = epsilon[2] = EPSILON; + else { + epsilon[0] = domain->prd[0] * EPSILON; + epsilon[1] = domain->prd[1] * EPSILON; + epsilon[2] = domain->prd[2] * EPSILON; + } + + double sublo[3],subhi[3]; + if (triclinic == 0) { + sublo[0] = domain->sublo[0]; subhi[0] = domain->subhi[0]; + sublo[1] = domain->sublo[1]; subhi[1] = domain->subhi[1]; + sublo[2] = domain->sublo[2]; subhi[2] = domain->subhi[2]; + } else { + sublo[0] = domain->sublo_lamda[0]; subhi[0] = domain->subhi_lamda[0]; + sublo[1] = domain->sublo_lamda[1]; subhi[1] = domain->subhi_lamda[1]; + sublo[2] = domain->sublo_lamda[2]; subhi[2] = domain->subhi_lamda[2]; + } + + if (comm->layout != LAYOUT_TILED) { + if (domain->xperiodic) { + if (comm->myloc[0] == 0) sublo[0] -= epsilon[0]; + if (comm->myloc[0] == comm->procgrid[0]-1) subhi[0] += epsilon[0]; + } + if (domain->yperiodic) { + if (comm->myloc[1] == 0) sublo[1] -= epsilon[1]; + if (comm->myloc[1] == comm->procgrid[1]-1) subhi[1] += epsilon[1]; + } + if (domain->zperiodic) { + if (comm->myloc[2] == 0) sublo[2] -= epsilon[2]; + if (comm->myloc[2] == comm->procgrid[2]-1) subhi[2] += epsilon[2]; + } + + } else { + if (domain->xperiodic) { + if (comm->mysplit[0][0] == 0.0) sublo[0] -= epsilon[0]; + if (comm->mysplit[0][1] == 1.0) subhi[0] += epsilon[0]; + } + if (domain->yperiodic) { + if (comm->mysplit[1][0] == 0.0) sublo[1] -= epsilon[1]; + if (comm->mysplit[1][1] == 1.0) subhi[1] += epsilon[1]; + } + if (domain->zperiodic) { + if (comm->mysplit[2][0] == 0.0) sublo[2] -= epsilon[2]; + if (comm->mysplit[2][1] == 1.0) subhi[2] += epsilon[2]; + } + } + + // xptr = which word in line starts xyz coords + // iptr = which word in line starts ix,iy,iz image flags + + xptr = avec->xcol_data - 1; + int imageflag = 0; + if (nwords > avec->size_data_atom) imageflag = 1; + if (imageflag) iptr = nwords - 3; + + // loop over lines of atom data + // tokenize the line into values + // extract xyz coords and image flags + // remap atom into simulation box + // if atom is in my sub-domain, unpack its values + + for (int i = 0; i < n; i++) { + next = strchr(buf,'\n'); + + values[0] = strtok(buf," \t\n\r\f"); + if (values[0] == NULL) + error->all(FLERR,"Incorrect atom format in data file"); + for (m = 1; m < nwords; m++) { + values[m] = strtok(NULL," \t\n\r\f"); + if (values[m] == NULL) + error->all(FLERR,"Incorrect atom format in data file"); + } + + if (imageflag) + imagedata = ((imageint) (atoi(values[iptr]) + IMGMAX) & IMGMASK) | + (((imageint) (atoi(values[iptr+1]) + IMGMAX) & IMGMASK) << IMGBITS) | + (((imageint) (atoi(values[iptr+2]) + IMGMAX) & IMGMASK) << IMG2BITS); + else imagedata = ((imageint) IMGMAX << IMG2BITS) | + ((imageint) IMGMAX << IMGBITS) | IMGMAX; + + xdata[0] = atof(values[xptr]); + xdata[1] = atof(values[xptr+1]); + xdata[2] = atof(values[xptr+2]); + if (shiftflag) { + xdata[0] += shift[0]; + xdata[1] += shift[1]; + xdata[2] += shift[2]; + } + + domain->remap(xdata,imagedata); + if (triclinic) { + domain->x2lamda(xdata,lamda); + coord = lamda; + } else coord = xdata; + + if (coord[0] >= sublo[0] && coord[0] < subhi[0] && + coord[1] >= sublo[1] && coord[1] < subhi[1] && + coord[2] >= sublo[2] && coord[2] < subhi[2]) { + avec->data_atom(xdata,imagedata,values); + if (id_offset) tag[nlocal-1] += id_offset; + if (type_offset) { + type[nlocal-1] += type_offset; + if (type[nlocal-1] > ntypes) + error->one(FLERR,"Invalid atom type in Atoms section of data file"); + } + } + + buf = next + 1; + } + + delete [] values; +} + +/* ---------------------------------------------------------------------- + unpack N lines from Velocity section of data file + check that atom IDs are > 0 and <= map_tag_max + call style-specific routine to parse line +------------------------------------------------------------------------- */ + +void Atom::data_vels(int n, char *buf, tagint id_offset) +{ + int j,m; + tagint tagdata; + char *next; + + next = strchr(buf,'\n'); + *next = '\0'; + int nwords = count_words(buf); + *next = '\n'; + + if (nwords != avec->size_data_vel) + error->all(FLERR,"Incorrect velocity format in data file"); + + char **values = new char*[nwords]; + + // loop over lines of atom velocities + // tokenize the line into values + // if I own atom tag, unpack its values + + for (int i = 0; i < n; i++) { + next = strchr(buf,'\n'); + + values[0] = strtok(buf," \t\n\r\f"); + for (j = 1; j < nwords; j++) + values[j] = strtok(NULL," \t\n\r\f"); + + tagdata = ATOTAGINT(values[0]) + id_offset; + if (tagdata <= 0 || tagdata > map_tag_max) + error->one(FLERR,"Invalid atom ID in Velocities section of data file"); + if ((m = map(tagdata)) >= 0) avec->data_vel(m,&values[1]); + + buf = next + 1; + } + + delete [] values; +} + +/* ---------------------------------------------------------------------- + process N bonds read into buf from data files + if count is non-NULL, just count bonds per atom + else store them with atoms + check that atom IDs are > 0 and <= map_tag_max +------------------------------------------------------------------------- */ + +void Atom::data_bonds(int n, char *buf, int *count, tagint id_offset, + int type_offset) +{ + int m,tmp,itype; + tagint atom1,atom2; + char *next; + int newton_bond = force->newton_bond; + + for (int i = 0; i < n; i++) { + next = strchr(buf,'\n'); + *next = '\0'; + sscanf(buf,"%d %d " TAGINT_FORMAT " " TAGINT_FORMAT, + &tmp,&itype,&atom1,&atom2); + if (id_offset) { + atom1 += id_offset; + atom2 += id_offset; + } + itype += type_offset; + + if (atom1 <= 0 || atom1 > map_tag_max || + atom2 <= 0 || atom2 > map_tag_max) + error->one(FLERR,"Invalid atom ID in Bonds section of data file"); + if (itype <= 0 || itype > nbondtypes) + error->one(FLERR,"Invalid bond type in Bonds section of data file"); + if ((m = map(atom1)) >= 0) { + if (count) count[m]++; + else { + bond_type[m][num_bond[m]] = itype; + bond_atom[m][num_bond[m]] = atom2; + num_bond[m]++; + } + } + if (newton_bond == 0) { + if ((m = map(atom2)) >= 0) { + if (count) count[m]++; + else { + bond_type[m][num_bond[m]] = itype; + bond_atom[m][num_bond[m]] = atom1; + num_bond[m]++; + } + } + } + buf = next + 1; + } +} + +/* ---------------------------------------------------------------------- + process N angles read into buf from data files + if count is non-NULL, just count angles per atom + else store them with atoms + check that atom IDs are > 0 and <= map_tag_max +------------------------------------------------------------------------- */ + +void Atom::data_angles(int n, char *buf, int *count, tagint id_offset, + int type_offset) +{ + int m,tmp,itype; + tagint atom1,atom2,atom3; + char *next; + int newton_bond = force->newton_bond; + + for (int i = 0; i < n; i++) { + next = strchr(buf,'\n'); + *next = '\0'; + sscanf(buf,"%d %d " TAGINT_FORMAT " " TAGINT_FORMAT " " TAGINT_FORMAT, + &tmp,&itype,&atom1,&atom2,&atom3); + if (id_offset) { + atom1 += id_offset; + atom2 += id_offset; + atom3 += id_offset; + } + itype += type_offset; + + if (atom1 <= 0 || atom1 > map_tag_max || + atom2 <= 0 || atom2 > map_tag_max || + atom3 <= 0 || atom3 > map_tag_max) + error->one(FLERR,"Invalid atom ID in Angles section of data file"); + if (itype <= 0 || itype > nangletypes) + error->one(FLERR,"Invalid angle type in Angles section of data file"); + if ((m = map(atom2)) >= 0) { + if (count) count[m]++; + else { + angle_type[m][num_angle[m]] = itype; + angle_atom1[m][num_angle[m]] = atom1; + angle_atom2[m][num_angle[m]] = atom2; + angle_atom3[m][num_angle[m]] = atom3; + num_angle[m]++; + } + } + if (newton_bond == 0) { + if ((m = map(atom1)) >= 0) { + if (count) count[m]++; + else { + angle_type[m][num_angle[m]] = itype; + angle_atom1[m][num_angle[m]] = atom1; + angle_atom2[m][num_angle[m]] = atom2; + angle_atom3[m][num_angle[m]] = atom3; + num_angle[m]++; + } + } + if ((m = map(atom3)) >= 0) { + if (count) count[m]++; + else { + angle_type[m][num_angle[m]] = itype; + angle_atom1[m][num_angle[m]] = atom1; + angle_atom2[m][num_angle[m]] = atom2; + angle_atom3[m][num_angle[m]] = atom3; + num_angle[m]++; + } + } + } + buf = next + 1; + } +} + +/* ---------------------------------------------------------------------- + process N dihedrals read into buf from data files + if count is non-NULL, just count diihedrals per atom + else store them with atoms + check that atom IDs are > 0 and <= map_tag_max +------------------------------------------------------------------------- */ + +void Atom::data_dihedrals(int n, char *buf, int *count, tagint id_offset, + int type_offset) +{ + int m,tmp,itype; + tagint atom1,atom2,atom3,atom4; + char *next; + int newton_bond = force->newton_bond; + + for (int i = 0; i < n; i++) { + next = strchr(buf,'\n'); + *next = '\0'; + sscanf(buf,"%d %d " + TAGINT_FORMAT " " TAGINT_FORMAT " " TAGINT_FORMAT " " TAGINT_FORMAT, + &tmp,&itype,&atom1,&atom2,&atom3,&atom4); + if (id_offset) { + atom1 += id_offset; + atom2 += id_offset; + atom3 += id_offset; + atom4 += id_offset; + } + itype += type_offset; + + if (atom1 <= 0 || atom1 > map_tag_max || + atom2 <= 0 || atom2 > map_tag_max || + atom3 <= 0 || atom3 > map_tag_max || + atom4 <= 0 || atom4 > map_tag_max) + error->one(FLERR,"Invalid atom ID in Dihedrals section of data file"); + if (itype <= 0 || itype > ndihedraltypes) + error->one(FLERR, + "Invalid dihedral type in Dihedrals section of data file"); + if ((m = map(atom2)) >= 0) { + if (count) count[m]++; + else { + dihedral_type[m][num_dihedral[m]] = itype; + dihedral_atom1[m][num_dihedral[m]] = atom1; + dihedral_atom2[m][num_dihedral[m]] = atom2; + dihedral_atom3[m][num_dihedral[m]] = atom3; + dihedral_atom4[m][num_dihedral[m]] = atom4; + num_dihedral[m]++; + } + } + if (newton_bond == 0) { + if ((m = map(atom1)) >= 0) { + if (count) count[m]++; + else { + dihedral_type[m][num_dihedral[m]] = itype; + dihedral_atom1[m][num_dihedral[m]] = atom1; + dihedral_atom2[m][num_dihedral[m]] = atom2; + dihedral_atom3[m][num_dihedral[m]] = atom3; + dihedral_atom4[m][num_dihedral[m]] = atom4; + num_dihedral[m]++; + } + } + if ((m = map(atom3)) >= 0) { + if (count) count[m]++; + else { + dihedral_type[m][num_dihedral[m]] = itype; + dihedral_atom1[m][num_dihedral[m]] = atom1; + dihedral_atom2[m][num_dihedral[m]] = atom2; + dihedral_atom3[m][num_dihedral[m]] = atom3; + dihedral_atom4[m][num_dihedral[m]] = atom4; + num_dihedral[m]++; + } + } + if ((m = map(atom4)) >= 0) { + if (count) count[m]++; + else { + dihedral_type[m][num_dihedral[m]] = itype; + dihedral_atom1[m][num_dihedral[m]] = atom1; + dihedral_atom2[m][num_dihedral[m]] = atom2; + dihedral_atom3[m][num_dihedral[m]] = atom3; + dihedral_atom4[m][num_dihedral[m]] = atom4; + num_dihedral[m]++; + } + } + } + buf = next + 1; + } +} + +/* ---------------------------------------------------------------------- + process N impropers read into buf from data files + if count is non-NULL, just count impropers per atom + else store them with atoms + check that atom IDs are > 0 and <= map_tag_max +------------------------------------------------------------------------- */ + +void Atom::data_impropers(int n, char *buf, int *count, tagint id_offset, + int type_offset) +{ + int m,tmp,itype; + tagint atom1,atom2,atom3,atom4; + char *next; + int newton_bond = force->newton_bond; + + for (int i = 0; i < n; i++) { + next = strchr(buf,'\n'); + *next = '\0'; + sscanf(buf,"%d %d " + TAGINT_FORMAT " " TAGINT_FORMAT " " TAGINT_FORMAT " " TAGINT_FORMAT, + &tmp,&itype,&atom1,&atom2,&atom3,&atom4); + if (id_offset) { + atom1 += id_offset; + atom2 += id_offset; + atom3 += id_offset; + atom4 += id_offset; + } + itype += type_offset; + + if (atom1 <= 0 || atom1 > map_tag_max || + atom2 <= 0 || atom2 > map_tag_max || + atom3 <= 0 || atom3 > map_tag_max || + atom4 <= 0 || atom4 > map_tag_max) + error->one(FLERR,"Invalid atom ID in Impropers section of data file"); + if (itype <= 0 || itype > nimpropertypes) + error->one(FLERR, + "Invalid improper type in Impropers section of data file"); + if ((m = map(atom2)) >= 0) { + if (count) count[m]++; + else { + improper_type[m][num_improper[m]] = itype; + improper_atom1[m][num_improper[m]] = atom1; + improper_atom2[m][num_improper[m]] = atom2; + improper_atom3[m][num_improper[m]] = atom3; + improper_atom4[m][num_improper[m]] = atom4; + num_improper[m]++; + } + } + if (newton_bond == 0) { + if ((m = map(atom1)) >= 0) { + if (count) count[m]++; + else { + improper_type[m][num_improper[m]] = itype; + improper_atom1[m][num_improper[m]] = atom1; + improper_atom2[m][num_improper[m]] = atom2; + improper_atom3[m][num_improper[m]] = atom3; + improper_atom4[m][num_improper[m]] = atom4; + num_improper[m]++; + } + } + if ((m = map(atom3)) >= 0) { + if (count) count[m]++; + else { + improper_type[m][num_improper[m]] = itype; + improper_atom1[m][num_improper[m]] = atom1; + improper_atom2[m][num_improper[m]] = atom2; + improper_atom3[m][num_improper[m]] = atom3; + improper_atom4[m][num_improper[m]] = atom4; + num_improper[m]++; + } + } + if ((m = map(atom4)) >= 0) { + if (count) count[m]++; + else { + improper_type[m][num_improper[m]] = itype; + improper_atom1[m][num_improper[m]] = atom1; + improper_atom2[m][num_improper[m]] = atom2; + improper_atom3[m][num_improper[m]] = atom3; + improper_atom4[m][num_improper[m]] = atom4; + num_improper[m]++; + } + } + } + buf = next + 1; + } +} + +/* ---------------------------------------------------------------------- + unpack N lines from atom-style specific bonus section of data file + check that atom IDs are > 0 and <= map_tag_max + call style-specific routine to parse line +------------------------------------------------------------------------- */ + +void Atom::data_bonus(int n, char *buf, AtomVec *avec_bonus, tagint id_offset) +{ + int j,m,tagdata; + char *next; + + next = strchr(buf,'\n'); + *next = '\0'; + int nwords = count_words(buf); + *next = '\n'; + + if (nwords != avec_bonus->size_data_bonus) + error->all(FLERR,"Incorrect bonus data format in data file"); + + char **values = new char*[nwords]; + + // loop over lines of bonus atom data + // tokenize the line into values + // if I own atom tag, unpack its values + + for (int i = 0; i < n; i++) { + next = strchr(buf,'\n'); + + values[0] = strtok(buf," \t\n\r\f"); + for (j = 1; j < nwords; j++) + values[j] = strtok(NULL," \t\n\r\f"); + + tagdata = ATOTAGINT(values[0]) + id_offset; + if (tagdata <= 0 || tagdata > map_tag_max) + error->one(FLERR,"Invalid atom ID in Bonus section of data file"); + + // ok to call child's data_atom_bonus() method thru parent avec_bonus, + // since data_bonus() was called with child ptr, and method is virtual + + if ((m = map(tagdata)) >= 0) avec_bonus->data_atom_bonus(m,&values[1]); + + buf = next + 1; + } + + delete [] values; +} + +/* ---------------------------------------------------------------------- + unpack N bodies from Bodies section of data file + each body spans multiple lines + check that atom IDs are > 0 and <= map_tag_max + call style-specific routine to parse line +------------------------------------------------------------------------- */ + +void Atom::data_bodies(int n, char *buf, AtomVecBody *avec_body, + tagint id_offset) +{ + int j,m,nvalues,tagdata,ninteger,ndouble; + + int maxint = 0; + int maxdouble = 0; + int *ivalues = NULL; + double *dvalues = NULL; + + // loop over lines of body data + // if I own atom tag, tokenize lines into ivalues/dvalues, call data_body() + // else skip values + + for (int i = 0; i < n; i++) { + if (i == 0) tagdata = ATOTAGINT(strtok(buf," \t\n\r\f")) + id_offset; + else tagdata = ATOTAGINT(strtok(NULL," \t\n\r\f")) + id_offset; + + if (tagdata <= 0 || tagdata > map_tag_max) + error->one(FLERR,"Invalid atom ID in Bodies section of data file"); + + ninteger = force->inumeric(FLERR,strtok(NULL," \t\n\r\f")); + ndouble = force->inumeric(FLERR,strtok(NULL," \t\n\r\f")); + + if ((m = map(tagdata)) >= 0) { + if (ninteger > maxint) { + delete [] ivalues; + maxint = ninteger; + ivalues = new int[maxint]; + } + if (ndouble > maxdouble) { + delete [] dvalues; + maxdouble = ndouble; + dvalues = new double[maxdouble]; + } + + for (j = 0; j < ninteger; j++) + ivalues[j] = force->inumeric(FLERR,strtok(NULL," \t\n\r\f")); + for (j = 0; j < ndouble; j++) + dvalues[j] = force->numeric(FLERR,strtok(NULL," \t\n\r\f")); + + avec_body->data_body(m,ninteger,ndouble,ivalues,dvalues); + + } else { + nvalues = ninteger + ndouble; // number of values to skip + for (j = 0; j < nvalues; j++) + strtok(NULL," \t\n\r\f"); + } + } + + delete [] ivalues; + delete [] dvalues; +} + +/* ---------------------------------------------------------------------- + allocate arrays of length ntypes + only done after ntypes is set +------------------------------------------------------------------------- */ + +void Atom::allocate_type_arrays() +{ + if (avec->mass_type) { + mass = new double[ntypes+1]; + mass_setflag = new int[ntypes+1]; + for (int itype = 1; itype <= ntypes; itype++) mass_setflag[itype] = 0; + } +} + +/* ---------------------------------------------------------------------- + set a mass and flag it as set + called from reading of data file + type_offset may be used when reading multiple data files +------------------------------------------------------------------------- */ + +void Atom::set_mass(const char *str, int type_offset) +{ + if (mass == NULL) error->all(FLERR,"Cannot set mass for this atom style"); + + int itype; + double mass_one; + int n = sscanf(str,"%d %lg",&itype,&mass_one); + if (n != 2) error->all(FLERR,"Invalid mass line in data file"); + itype += type_offset; + + if (itype < 1 || itype > ntypes) + error->all(FLERR,"Invalid type for mass set"); + + mass[itype] = mass_one; + mass_setflag[itype] = 1; + + if (mass[itype] <= 0.0) error->all(FLERR,"Invalid mass value"); +} + +/* ---------------------------------------------------------------------- + set a mass and flag it as set + called from EAM pair routine +------------------------------------------------------------------------- */ + +void Atom::set_mass(int itype, double value) +{ + if (mass == NULL) error->all(FLERR,"Cannot set mass for this atom style"); + if (itype < 1 || itype > ntypes) + error->all(FLERR,"Invalid type for mass set"); + + mass[itype] = value; + mass_setflag[itype] = 1; + + if (mass[itype] <= 0.0) error->all(FLERR,"Invalid mass value"); +} + +/* ---------------------------------------------------------------------- + set one or more masses and flag them as set + called from reading of input script +------------------------------------------------------------------------- */ + +void Atom::set_mass(int narg, char **arg) +{ + if (mass == NULL) error->all(FLERR,"Cannot set mass for this atom style"); + + int lo,hi; + force->bounds(arg[0],ntypes,lo,hi); + if (lo < 1 || hi > ntypes) error->all(FLERR,"Invalid type for mass set"); + + for (int itype = lo; itype <= hi; itype++) { + mass[itype] = atof(arg[1]); + mass_setflag[itype] = 1; + + if (mass[itype] <= 0.0) error->all(FLERR,"Invalid mass value"); + } +} + +/* ---------------------------------------------------------------------- + set all masses as read in from restart file +------------------------------------------------------------------------- */ + +void Atom::set_mass(double *values) +{ + for (int itype = 1; itype <= ntypes; itype++) { + mass[itype] = values[itype]; + mass_setflag[itype] = 1; + } +} + +/* ---------------------------------------------------------------------- + check that all masses have been set +------------------------------------------------------------------------- */ + +void Atom::check_mass() +{ + if (mass == NULL) return; + for (int itype = 1; itype <= ntypes; itype++) + if (mass_setflag[itype] == 0) error->all(FLERR,"All masses are not set"); +} + +/* ---------------------------------------------------------------------- + check that radii of all particles of itype are the same + return 1 if true, else return 0 + also return the radius value for that type +------------------------------------------------------------------------- */ + +int Atom::radius_consistency(int itype, double &rad) +{ + double value = -1.0; + int flag = 0; + for (int i = 0; i < nlocal; i++) { + if (type[i] != itype) continue; + if (value < 0.0) value = radius[i]; + else if (value != radius[i]) flag = 1; + } + + int flagall; + MPI_Allreduce(&flag,&flagall,1,MPI_INT,MPI_SUM,world); + if (flagall) return 0; + + MPI_Allreduce(&value,&rad,1,MPI_DOUBLE,MPI_MAX,world); + return 1; +} + +/* ---------------------------------------------------------------------- + check that shape of all particles of itype are the same + return 1 if true, else return 0 + also return the 3 shape params for itype +------------------------------------------------------------------------- */ + +int Atom::shape_consistency(int itype, + double &shapex, double &shapey, double &shapez) +{ + double zero[3] = {0.0, 0.0, 0.0}; + double one[3] = {-1.0, -1.0, -1.0}; + double *shape; + + AtomVecEllipsoid *avec_ellipsoid = + (AtomVecEllipsoid *) style_match("ellipsoid"); + AtomVecEllipsoid::Bonus *bonus = avec_ellipsoid->bonus; + + int flag = 0; + for (int i = 0; i < nlocal; i++) { + if (type[i] != itype) continue; + if (ellipsoid[i] < 0) shape = zero; + else shape = bonus[ellipsoid[i]].shape; + + if (one[0] < 0.0) { + one[0] = shape[0]; + one[1] = shape[1]; + one[2] = shape[2]; + } else if (one[0] != shape[0] || one[1] != shape[1] || one[2] != shape[2]) + flag = 1; + } + + int flagall; + MPI_Allreduce(&flag,&flagall,1,MPI_INT,MPI_SUM,world); + if (flagall) return 0; + + double oneall[3]; + MPI_Allreduce(one,oneall,3,MPI_DOUBLE,MPI_MAX,world); + shapex = oneall[0]; + shapey = oneall[1]; + shapez = oneall[2]; + return 1; +} + +/* ---------------------------------------------------------------------- + add a new molecule template = set of molecules +------------------------------------------------------------------------- */ + +void Atom::add_molecule(int narg, char **arg) +{ + if (narg < 1) error->all(FLERR,"Illegal molecule command"); + + if (find_molecule(arg[0]) >= 0) + error->all(FLERR,"Reuse of molecule template ID"); + + // 1st molecule in set stores nset = # of mols, others store nset = 0 + // ifile = count of molecules in set + // index = argument index where next molecule starts, updated by constructor + + int ifile = 1; + int index = 1; + while (1) { + molecules = (Molecule **) + memory->srealloc(molecules,(nmolecule+1)*sizeof(Molecule *), + "atom::molecules"); + molecules[nmolecule] = new Molecule(lmp,narg,arg,index); + molecules[nmolecule]->nset = 0; + molecules[nmolecule-ifile+1]->nset++; + nmolecule++; + if (molecules[nmolecule-1]->last) break; + ifile++; + } +} + +/* ---------------------------------------------------------------------- + find first molecule in set with template ID + return -1 if does not exist +------------------------------------------------------------------------- */ + +int Atom::find_molecule(char *id) +{ + int imol; + for (imol = 0; imol < nmolecule; imol++) + if (strcmp(id,molecules[imol]->id) == 0) return imol; + return -1; +} + +/* ---------------------------------------------------------------------- + add info to current atom ilocal from molecule template onemol and its iatom + offset = atom ID preceeding IDs of atoms in this molecule + called by fixes and commands that add molecules +------------------------------------------------------------------------- */ + +void Atom::add_molecule_atom(Molecule *onemol, int iatom, + int ilocal, tagint offset) +{ + if (onemol->qflag && q_flag) q[ilocal] = onemol->q[iatom]; + if (onemol->radiusflag && radius_flag) radius[ilocal] = onemol->radius[iatom]; + if (onemol->rmassflag && rmass_flag) rmass[ilocal] = onemol->rmass[iatom]; + if (onemol->replambdaHflag && replambdaH_flag) replambdaH[ilocal] = onemol->replambdaH[iatom]; + if (onemol->moltypeHflag && moltypeH_flag) moltypeH[ilocal] = onemol->moltypeH[iatom]; + else if (rmass_flag) + rmass[ilocal] = 4.0*MY_PI/3.0 * + radius[ilocal]*radius[ilocal]*radius[ilocal]; + if (onemol->bodyflag) { + body[ilocal] = 0; // as if a body read from data file + onemol->avec_body->data_body(ilocal,onemol->nibody,onemol->ndbody, + onemol->ibodyparams,onemol->dbodyparams); + onemol->avec_body->set_quat(ilocal,onemol->quat_external); + } + + if (molecular != 1) return; + + // add bond topology info + // for molecular atom styles, but not atom style template + + if (avec->bonds_allow) { + num_bond[ilocal] = onemol->num_bond[iatom]; + for (int i = 0; i < num_bond[ilocal]; i++) { + bond_type[ilocal][i] = onemol->bond_type[iatom][i]; + bond_atom[ilocal][i] = onemol->bond_atom[iatom][i] + offset; + } + } + + if (avec->angles_allow) { + num_angle[ilocal] = onemol->num_angle[iatom]; + for (int i = 0; i < num_angle[ilocal]; i++) { + angle_type[ilocal][i] = onemol->angle_type[iatom][i]; + angle_atom1[ilocal][i] = onemol->angle_atom1[iatom][i] + offset; + angle_atom2[ilocal][i] = onemol->angle_atom2[iatom][i] + offset; + angle_atom3[ilocal][i] = onemol->angle_atom3[iatom][i] + offset; + } + } + + if (avec->dihedrals_allow) { + num_dihedral[ilocal] = onemol->num_dihedral[iatom]; + for (int i = 0; i < num_dihedral[ilocal]; i++) { + dihedral_type[ilocal][i] = onemol->dihedral_type[iatom][i]; + dihedral_atom1[ilocal][i] = onemol->dihedral_atom1[iatom][i] + offset; + dihedral_atom2[ilocal][i] = onemol->dihedral_atom2[iatom][i] + offset; + dihedral_atom3[ilocal][i] = onemol->dihedral_atom3[iatom][i] + offset; + dihedral_atom4[ilocal][i] = onemol->dihedral_atom4[iatom][i] + offset; + } + } + + if (avec->impropers_allow) { + num_improper[ilocal] = onemol->num_improper[iatom]; + for (int i = 0; i < num_improper[ilocal]; i++) { + improper_type[ilocal][i] = onemol->improper_type[iatom][i]; + improper_atom1[ilocal][i] = onemol->improper_atom1[iatom][i] + offset; + improper_atom2[ilocal][i] = onemol->improper_atom2[iatom][i] + offset; + improper_atom3[ilocal][i] = onemol->improper_atom3[iatom][i] + offset; + improper_atom4[ilocal][i] = onemol->improper_atom4[iatom][i] + offset; + } + } + + if (onemol->specialflag) { + nspecial[ilocal][0] = onemol->nspecial[iatom][0]; + nspecial[ilocal][1] = onemol->nspecial[iatom][1]; + int n = nspecial[ilocal][2] = onemol->nspecial[iatom][2]; + for (int i = 0; i < n; i++) + special[ilocal][i] = onemol->special[iatom][i] + offset; + } +} + +/* ---------------------------------------------------------------------- + reorder owned atoms so those in firstgroup appear first + called by comm->exchange() if atom_modify first group is set + only owned atoms exist at this point, no ghost atoms +------------------------------------------------------------------------- */ + +void Atom::first_reorder() +{ + // insure there is one extra atom location at end of arrays for swaps + + if (nlocal == nmax) avec->grow(0); + + // loop over owned atoms + // nfirst = index of first atom not in firstgroup + // when find firstgroup atom out of place, swap it with atom nfirst + + int bitmask = group->bitmask[firstgroup]; + nfirst = 0; + while (nfirst < nlocal && mask[nfirst] & bitmask) nfirst++; + + for (int i = 0; i < nlocal; i++) { + if (mask[i] & bitmask && i > nfirst) { + avec->copy(i,nlocal,0); + avec->copy(nfirst,i,0); + avec->copy(nlocal,nfirst,0); + while (nfirst < nlocal && mask[nfirst] & bitmask) nfirst++; + } + } +} + +/* ---------------------------------------------------------------------- + perform spatial sort of atoms within my sub-domain + always called between comm->exchange() and comm->borders() + don't have to worry about clearing/setting atom->map since done in comm +------------------------------------------------------------------------- */ + +void Atom::sort() +{ + int i,m,n,ix,iy,iz,ibin,empty; + + // set next timestep for sorting to take place + + nextsort = (update->ntimestep/sortfreq)*sortfreq + sortfreq; + + // download data from GPU if necessary + + if (lmp->cuda && !lmp->cuda->oncpu) lmp->cuda->downloadAll(); + + // re-setup sort bins if needed + + if (domain->box_change) setup_sort_bins(); + if (nbins == 1) return; + + // reallocate per-atom vectors if needed + + if (nlocal > maxnext) { + memory->destroy(next); + memory->destroy(permute); + maxnext = atom->nmax; + memory->create(next,maxnext,"atom:next"); + memory->create(permute,maxnext,"atom:permute"); + } + + // insure there is one extra atom location at end of arrays for swaps + + if (nlocal == nmax) avec->grow(0); + + // bin atoms in reverse order so linked list will be in forward order + + for (i = 0; i < nbins; i++) binhead[i] = -1; + + for (i = nlocal-1; i >= 0; i--) { + ix = static_cast ((x[i][0]-bboxlo[0])*bininvx); + iy = static_cast ((x[i][1]-bboxlo[1])*bininvy); + iz = static_cast ((x[i][2]-bboxlo[2])*bininvz); + ix = MAX(ix,0); + iy = MAX(iy,0); + iz = MAX(iz,0); + ix = MIN(ix,nbinx-1); + iy = MIN(iy,nbiny-1); + iz = MIN(iz,nbinz-1); + ibin = iz*nbiny*nbinx + iy*nbinx + ix; + next[i] = binhead[ibin]; + binhead[ibin] = i; + } + + // permute = desired permutation of atoms + // permute[I] = J means Ith new atom will be Jth old atom + + n = 0; + for (m = 0; m < nbins; m++) { + i = binhead[m]; + while (i >= 0) { + permute[n++] = i; + i = next[i]; + } + } + + // current = current permutation, just reuse next vector + // current[I] = J means Ith current atom is Jth old atom + + int *current = next; + for (i = 0; i < nlocal; i++) current[i] = i; + + // reorder local atom list, when done, current = permute + // perform "in place" using copy() to extra atom location at end of list + // inner while loop processes one cycle of the permutation + // copy before inner-loop moves an atom to end of atom list + // copy after inner-loop moves atom at end of list back into list + // empty = location in atom list that is currently empty + + for (i = 0; i < nlocal; i++) { + if (current[i] == permute[i]) continue; + avec->copy(i,nlocal,0); + empty = i; + while (permute[empty] != i) { + avec->copy(permute[empty],empty,0); + empty = current[empty] = permute[empty]; + } + avec->copy(nlocal,empty,0); + current[empty] = permute[empty]; + } + + // upload data back to GPU if necessary + + if (lmp->cuda && !lmp->cuda->oncpu) lmp->cuda->uploadAll(); + + // sanity check that current = permute + + //int flag = 0; + //for (i = 0; i < nlocal; i++) + // if (current[i] != permute[i]) flag = 1; + //int flagall; + //MPI_Allreduce(&flag,&flagall,1,MPI_INT,MPI_SUM,world); + //if (flagall) error->all(FLERR,"Atom sort did not operate correctly"); +} + +/* ---------------------------------------------------------------------- + setup bins for spatial sorting of atoms +------------------------------------------------------------------------- */ + +void Atom::setup_sort_bins() +{ + // binsize: + // user setting if explicitly set + // 1/2 of neighbor cutoff for non-CUDA + // CUDA_CHUNK atoms/proc for CUDA + // check if neighbor cutoff = 0.0 + + double binsize; + if (userbinsize > 0.0) binsize = userbinsize; + else if (!lmp->cuda) binsize = 0.5 * neighbor->cutneighmax; + else { + if (domain->dimension == 3) { + double vol = (domain->boxhi[0]-domain->boxlo[0]) * + (domain->boxhi[1]-domain->boxlo[1]) * + (domain->boxhi[2]-domain->boxlo[2]); + binsize = pow(1.0*CUDA_CHUNK/natoms*vol,1.0/3.0); + } else { + double area = (domain->boxhi[0]-domain->boxlo[0]) * + (domain->boxhi[1]-domain->boxlo[1]); + binsize = pow(1.0*CUDA_CHUNK/natoms*area,1.0/2.0); + } + } + if (binsize == 0.0) error->all(FLERR,"Atom sorting has bin size = 0.0"); + + double bininv = 1.0/binsize; + + // nbin xyz = local bins + // bbox lo/hi = bounding box of my sub-domain + + if (domain->triclinic) + domain->bbox(domain->sublo_lamda,domain->subhi_lamda,bboxlo,bboxhi); + else { + bboxlo[0] = domain->sublo[0]; + bboxlo[1] = domain->sublo[1]; + bboxlo[2] = domain->sublo[2]; + bboxhi[0] = domain->subhi[0]; + bboxhi[1] = domain->subhi[1]; + bboxhi[2] = domain->subhi[2]; + } + + nbinx = static_cast ((bboxhi[0]-bboxlo[0]) * bininv); + nbiny = static_cast ((bboxhi[1]-bboxlo[1]) * bininv); + nbinz = static_cast ((bboxhi[2]-bboxlo[2]) * bininv); + if (domain->dimension == 2) nbinz = 1; + + if (nbinx == 0) nbinx = 1; + if (nbiny == 0) nbiny = 1; + if (nbinz == 0) nbinz = 1; + + bininvx = nbinx / (bboxhi[0]-bboxlo[0]); + bininvy = nbiny / (bboxhi[1]-bboxlo[1]); + bininvz = nbinz / (bboxhi[2]-bboxlo[2]); + + if (1.0*nbinx*nbiny*nbinz > INT_MAX) + error->one(FLERR,"Too many atom sorting bins"); + + nbins = nbinx*nbiny*nbinz; + + // reallocate per-bin memory if needed + + if (nbins > maxbin) { + memory->destroy(binhead); + maxbin = nbins; + memory->create(binhead,maxbin,"atom:binhead"); + } +} + +/* ---------------------------------------------------------------------- + register a callback to a fix so it can manage atom-based arrays + happens when fix is created + flag = 0 for grow, 1 for restart, 2 for border comm +------------------------------------------------------------------------- */ + +void Atom::add_callback(int flag) +{ + int ifix; + + // find the fix + // if find NULL ptr: + // it's this one, since it is being replaced and has just been deleted + // at this point in re-creation + // if don't find NULL ptr: + // i is set to nfix = new one currently being added at end of list + + for (ifix = 0; ifix < modify->nfix; ifix++) + if (modify->fix[ifix] == NULL) break; + + // add callback to lists, reallocating if necessary + + if (flag == 0) { + if (nextra_grow == nextra_grow_max) { + nextra_grow_max += DELTA; + memory->grow(extra_grow,nextra_grow_max,"atom:extra_grow"); + } + extra_grow[nextra_grow] = ifix; + nextra_grow++; + } else if (flag == 1) { + if (nextra_restart == nextra_restart_max) { + nextra_restart_max += DELTA; + memory->grow(extra_restart,nextra_restart_max,"atom:extra_restart"); + } + extra_restart[nextra_restart] = ifix; + nextra_restart++; + } else if (flag == 2) { + if (nextra_border == nextra_border_max) { + nextra_border_max += DELTA; + memory->grow(extra_border,nextra_border_max,"atom:extra_border"); + } + extra_border[nextra_border] = ifix; + nextra_border++; + } +} + +/* ---------------------------------------------------------------------- + unregister a callback to a fix + happens when fix is deleted, called by its destructor + flag = 0 for grow, 1 for restart +------------------------------------------------------------------------- */ + +void Atom::delete_callback(const char *id, int flag) +{ + int ifix; + for (ifix = 0; ifix < modify->nfix; ifix++) + if (strcmp(id,modify->fix[ifix]->id) == 0) break; + + // compact the list of callbacks + + if (flag == 0) { + int match; + for (match = 0; match < nextra_grow; match++) + if (extra_grow[match] == ifix) break; + for (int i = match; i < nextra_grow-1; i++) + extra_grow[i] = extra_grow[i+1]; + nextra_grow--; + + } else if (flag == 1) { + int match; + for (match = 0; match < nextra_restart; match++) + if (extra_restart[match] == ifix) break; + for (int i = match; i < nextra_restart-1; i++) + extra_restart[i] = extra_restart[i+1]; + nextra_restart--; + + } else if (flag == 2) { + int match; + for (match = 0; match < nextra_border; match++) + if (extra_border[match] == ifix) break; + for (int i = match; i < nextra_border-1; i++) + extra_border[i] = extra_border[i+1]; + nextra_border--; + } +} + +/* ---------------------------------------------------------------------- + decrement ptrs in callback lists to fixes beyond the deleted ifix + happens after fix is deleted +------------------------------------------------------------------------- */ + +void Atom::update_callback(int ifix) +{ + for (int i = 0; i < nextra_grow; i++) + if (extra_grow[i] > ifix) extra_grow[i]--; + for (int i = 0; i < nextra_restart; i++) + if (extra_restart[i] > ifix) extra_restart[i]--; + for (int i = 0; i < nextra_border; i++) + if (extra_border[i] > ifix) extra_border[i]--; +} + +/* ---------------------------------------------------------------------- + find custom per-atom vector with name + return index if found, and flag = 0/1 for int/double + return -1 if not found +------------------------------------------------------------------------- */ + +int Atom::find_custom(char *name, int &flag) +{ + for (int i = 0; i < nivector; i++) + if (iname[i] && strcmp(iname[i],name) == 0) { + flag = 0; + return i; + } + + for (int i = 0; i < ndvector; i++) + if (dname[i] && strcmp(dname[i],name) == 0) { + flag = 1; + return i; + } + + return -1; +} + +/* ---------------------------------------------------------------------- + add a custom variable with name of type flag = 0/1 for int/double + assumes name does not already exist + return index in ivector or dvector of its location +------------------------------------------------------------------------- */ + +int Atom::add_custom(char *name, int flag) +{ + int index; + + if (flag == 0) { + index = nivector; + nivector++; + iname = (char **) memory->srealloc(iname,nivector*sizeof(char *), + "atom:iname"); + int n = strlen(name) + 1; + iname[index] = new char[n]; + strcpy(iname[index],name); + ivector = (int **) memory->srealloc(ivector,nivector*sizeof(int *), + "atom:ivector"); + memory->create(ivector[index],nmax,"atom:ivector"); + } else { + index = ndvector; + ndvector++; + dname = (char **) memory->srealloc(dname,ndvector*sizeof(char *), + "atom:dname"); + int n = strlen(name) + 1; + dname[index] = new char[n]; + strcpy(dname[index],name); + dvector = (double **) memory->srealloc(dvector,ndvector*sizeof(double *), + "atom:dvector"); + memory->create(dvector[index],nmax,"atom:dvector"); + } + + return index; +} + +/* ---------------------------------------------------------------------- + remove a custom variable of type flag = 0/1 for int/double at index + free memory for vector and name and set ptrs to NULL + ivector/dvector and iname/dname lists never shrink +------------------------------------------------------------------------- */ + +void Atom::remove_custom(int flag, int index) +{ + if (flag == 0) { + memory->destroy(ivector[index]); + ivector[index] = NULL; + delete [] iname[index]; + iname[index] = NULL; + } else { + memory->destroy(dvector[index]); + dvector[index] = NULL; + delete [] dname[index]; + dname[index] = NULL; + } +} + +/* ---------------------------------------------------------------------- + return a pointer to a named internal variable + if don't recognize name, return NULL + customize by adding names +------------------------------------------------------------------------- */ + +void *Atom::extract(char *name) +{ + if (strcmp(name,"mass") == 0) return (void *) mass; + + if (strcmp(name,"id") == 0) return (void *) tag; + if (strcmp(name,"type") == 0) return (void *) type; + if (strcmp(name,"mask") == 0) return (void *) mask; + if (strcmp(name,"image") == 0) return (void *) image; + if (strcmp(name,"x") == 0) return (void *) x; + if (strcmp(name,"v") == 0) return (void *) v; + if (strcmp(name,"f") == 0) return (void *) f; + if (strcmp(name,"molecule") == 0) return (void *) molecule; + if (strcmp(name,"q") == 0) return (void *) q; + if (strcmp(name,"lambdaH") == 0) return (void *) lambdaH; + if (strcmp(name,"gradlambdaH") == 0) return (void *) gradlambdaH; + if (strcmp(name,"replambdaH") == 0) return (void *) replambdaH; + if (strcmp(name,"mu") == 0) return (void *) mu; + if (strcmp(name,"omega") == 0) return (void *) omega; + if (strcmp(name,"angmom") == 0) return (void *) angmom; + if (strcmp(name,"torque") == 0) return (void *) torque; + if (strcmp(name,"radius") == 0) return (void *) radius; + if (strcmp(name,"rmass") == 0) return (void *) rmass; + if (strcmp(name,"ellipsoid") == 0) return (void *) ellipsoid; + if (strcmp(name,"line") == 0) return (void *) line; + if (strcmp(name,"tri") == 0) return (void *) tri; + + if (strcmp(name,"vfrac") == 0) return (void *) vfrac; + if (strcmp(name,"s0") == 0) return (void *) s0; + if (strcmp(name,"x0") == 0) return (void *) x0; + + if (strcmp(name,"spin") == 0) return (void *) spin; + if (strcmp(name,"eradius") == 0) return (void *) eradius; + if (strcmp(name,"ervel") == 0) return (void *) ervel; + if (strcmp(name,"erforce") == 0) return (void *) erforce; + if (strcmp(name,"ervelforce") == 0) return (void *) ervelforce; + if (strcmp(name,"cs") == 0) return (void *) cs; + if (strcmp(name,"csforce") == 0) return (void *) csforce; + if (strcmp(name,"vforce") == 0) return (void *) vforce; + if (strcmp(name,"etag") == 0) return (void *) etag; + + if (strcmp(name,"rho") == 0) return (void *) rho; + if (strcmp(name,"drho") == 0) return (void *) drho; + if (strcmp(name,"e") == 0) return (void *) e; + if (strcmp(name,"de") == 0) return (void *) de; + if (strcmp(name,"cv") == 0) return (void *) cv; + if (strcmp(name,"vest") == 0) return (void *) vest; + + if (strcmp(name, "contact_radius") == 0) return (void *) contact_radius; + if (strcmp(name, "smd_data_9") == 0) return (void *) smd_data_9; + if (strcmp(name, "smd_stress") == 0) return (void *) smd_stress; + if (strcmp(name, "eff_plastic_strain") == 0) + return (void *) eff_plastic_strain; + if (strcmp(name, "eff_plastic_strain_rate") == 0) + return (void *) eff_plastic_strain_rate; + if (strcmp(name, "damage") == 0) return (void *) damage; + + if (strcmp(name,"dpdTheta") == 0) return (void *) dpdTheta; + + return NULL; +} + +/* ---------------------------------------------------------------------- + return # of bytes of allocated memory + call to avec tallies per-atom vectors + add in global to local mapping storage +------------------------------------------------------------------------- */ + +bigint Atom::memory_usage() +{ + memlength = DELTA_MEMSTR; + memory->create(memstr,memlength,"atom:memstr"); + memstr[0] = '\0'; + bigint bytes = avec->memory_usage(); + memory->destroy(memstr); + + bytes += max_same*sizeof(int); + if (map_style == 1 && map_tag_max >= 0) + bytes += memory->usage(map_array,map_maxarray); + else if (map_style == 2 && map_nhash >=0) { + bytes += map_nbucket*sizeof(int); + bytes += map_nhash*sizeof(HashElem); + } + if (maxnext) { + bytes += memory->usage(next,maxnext); + bytes += memory->usage(permute,maxnext); + } + + return bytes; +} + +/* ---------------------------------------------------------------------- + accumulate per-atom vec names in memstr, padded by spaces + return 1 if padded str is not already in memlist, else 0 +------------------------------------------------------------------------- */ + +int Atom::memcheck(const char *str) +{ + int n = strlen(str) + 3; + char *padded = new char[n]; + strcpy(padded," "); + strcat(padded,str); + strcat(padded," "); + + if (strstr(memstr,padded)) { + delete [] padded; + return 0; + } + + if (strlen(memstr) + n >= memlength) { + memlength += DELTA_MEMSTR; + memory->grow(memstr,memlength,"atom:memstr"); + } + + strcat(memstr,padded); + delete [] padded; + return 1; +} diff --git a/src/USER-HADRESS/atom.h b/src/USER-HADRESS/atom.h new file mode 100644 index 0000000000..1675e7fe24 --- /dev/null +++ b/src/USER-HADRESS/atom.h @@ -0,0 +1,519 @@ +/* -*- c++ -*- ---------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + http://lammps.sandia.gov, Sandia National Laboratories + Steve Plimpton, sjplimp@sandia.gov + + Copyright (2003) Sandia Corporation. Under the terms of Contract + DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains + certain rights in this software. This software is distributed under + the GNU General Public License. + + See the README file in the top-level LAMMPS directory. +------------------------------------------------------------------------- */ + +#ifndef LMP_ATOM_H +#define LMP_ATOM_H + +#include "pointers.h" + +namespace LAMMPS_NS { + +class Atom : protected Pointers { + public: + char *atom_style; + class AtomVec *avec; + + // atom counts + + bigint natoms; // total # of atoms in system, could be 0 + // natoms may not be current if atoms lost + int nlocal,nghost; // # of owned and ghost atoms on this proc + int nmax; // max # of owned+ghost in arrays on this proc + int tag_enable; // 0/1 if atom ID tags are defined + int molecular; // 0 = atomic, 1 = standard molecular system, + // 2 = molecule template system + + bigint nbonds,nangles,ndihedrals,nimpropers; + int ntypes,nbondtypes,nangletypes,ndihedraltypes,nimpropertypes; + int bond_per_atom,angle_per_atom,dihedral_per_atom,improper_per_atom; + int extra_bond_per_atom,extra_angle_per_atom; + int extra_dihedral_per_atom,extra_improper_per_atom; + + int firstgroup; // store atoms in this group first, -1 if unset + int nfirst; // # of atoms in first group on this proc + char *firstgroupname; // group-ID to store first, NULL if unset + + // per-atom arrays + // customize by adding new array + + tagint *tag; + int *type,*mask; + imageint *image; + double **x,**v,**f; + + tagint *molecule; + int *molindex,*molatom; + + double *q,**mu; + double *lambdaH,**gradlambdaH; + int *replambdaH; + int *moltypeH; + int nmoltypesH; + double **comH; + + double **omega,**angmom,**torque; + double *radius,*rmass; + int *ellipsoid,*line,*tri,*body; + + // PERI package + + double *vfrac,*s0; + double **x0; + + // USER-EFF and USER-AWPMD packages + + int *spin; + double *eradius,*ervel,*erforce,*ervelforce; + double *cs,*csforce,*vforce; + int *etag; + + // USER-SPH package + + double *rho,*drho,*e,*de,*cv; + double **vest; + + // USER-SMD package + + double *contact_radius; + double **smd_data_9; + double **smd_stress; + double *eff_plastic_strain; + double *eff_plastic_strain_rate; + double *damage; + + // USER-DPD package + + double *uCond, *uMech, *uChem, *uCGnew, *uCG; + double *duCond, *duMech, *duChem; + double *dpdTheta; + + // molecular info + + int **nspecial; // 0,1,2 = cummulative # of 1-2,1-3,1-4 neighs + tagint **special; // IDs of 1-2,1-3,1-4 neighs of each atom + int maxspecial; // special[nlocal][maxspecial] + + int *num_bond; + int **bond_type; + tagint **bond_atom; + + int *num_angle; + int **angle_type; + tagint **angle_atom1,**angle_atom2,**angle_atom3; + + int *num_dihedral; + int **dihedral_type; + tagint **dihedral_atom1,**dihedral_atom2,**dihedral_atom3,**dihedral_atom4; + + int *num_improper; + int **improper_type; + tagint **improper_atom1,**improper_atom2,**improper_atom3,**improper_atom4; + + // custom arrays used by fix property/atom + + int **ivector; + double **dvector; + char **iname,**dname; + int nivector,ndvector; + + // used by USER-CUDA to flag used per-atom arrays + + unsigned int datamask; + unsigned int datamask_ext; + + // atom style and per-atom array existence flags + // customize by adding new flag + + int sphere_flag,ellipsoid_flag,line_flag,tri_flag,body_flag; + int peri_flag,electron_flag; + int ecp_flag; + int wavepacket_flag,sph_flag; + + int molecule_flag,molindex_flag,molatom_flag; + int q_flag,mu_flag; + int replambdaH_flag, moltypeH_flag; + int rmass_flag,radius_flag,omega_flag,torque_flag,angmom_flag; + int vfrac_flag,spin_flag,eradius_flag,ervel_flag,erforce_flag; + int cs_flag,csforce_flag,vforce_flag,ervelforce_flag,etag_flag; + int rho_flag,e_flag,cv_flag,vest_flag; + int dpd_flag; + + // USER-SMD package + + int smd_flag; + int contact_radius_flag; + int smd_data_9_flag; + int smd_stress_flag; + int x0_flag; + int eff_plastic_strain_flag; + int eff_plastic_strain_rate_flag; + int damage_flag; + + // Peridynamics scale factor, used by dump cfg + + double pdscale; + + // molecule templates + // each template can be a set of consecutive molecules + // each with same ID (stored in molecules) + // 1st molecule in template stores nset = # in set + + int nmolecule; + class Molecule **molecules; + + // extra peratom info in restart file destined for fix & diag + + double **extra; + + // per-type arrays + + double *mass; + int *mass_setflag; + + // callback ptrs for atom arrays managed by fix classes + + int nextra_grow,nextra_restart,nextra_border; // # of callbacks of each type + int *extra_grow,*extra_restart,*extra_border; // index of fix to callback to + int nextra_grow_max,nextra_restart_max; // size of callback lists + int nextra_border_max; + int nextra_store; + + int map_style; // style of atom map: 0=none, 1=array, 2=hash + int map_user; // user selected style = same 0,1,2 + tagint map_tag_max; // max atom ID that map() is setup for + + // spatial sorting of atoms + + int sortfreq; // sort atoms every this many steps, 0 = off + bigint nextsort; // next timestep to sort on + double userbinsize; // requested sort bin size + + // indices of atoms with same ID + + int *sametag; // sametag[I] = next atom with same ID, -1 if no more + + // functions + + Atom(class LAMMPS *); + ~Atom(); + + void settings(class Atom *); + void create_avec(const char *, int, char **, int); + virtual class AtomVec *new_avec(const char *, int, int &); + void init(); + void setup(); + + class AtomVec *style_match(const char *); + void modify_params(int, char **); + void tag_check(); + void tag_extend(); + int tag_consecutive(); + + int parse_data(const char *); + int count_words(const char *); + int count_words(const char *, char *); + + void deallocate_topology(); + + void data_atoms(int, char *, tagint, int, int, double *); + void data_vels(int, char *, tagint); + + void data_bonds(int, char *, int *, tagint, int); + void data_angles(int, char *, int *, tagint, int); + void data_dihedrals(int, char *, int *, tagint, int); + void data_impropers(int, char *, int *, tagint, int); + + void data_bonus(int, char *, class AtomVec *, tagint); + void data_bodies(int, char *, class AtomVecBody *, tagint); + + virtual void allocate_type_arrays(); + void set_mass(const char *, int); + void set_mass(int, double); + void set_mass(int, char **); + void set_mass(double *); + void check_mass(); + + int radius_consistency(int, double &); + int shape_consistency(int, double &, double &, double &); + + void add_molecule(int, char **); + int find_molecule(char *); + void add_molecule_atom(class Molecule *, int, int, tagint); + + void first_reorder(); + virtual void sort(); + + void add_callback(int); + void delete_callback(const char *, int); + void update_callback(int); + + int find_custom(char *, int &); + int add_custom(char *, int); + void remove_custom(int, int); + + virtual void sync_modify(ExecutionSpace, unsigned int, unsigned int) {} + + void *extract(char *); + + inline int* get_map_array() {return map_array;}; + inline int get_map_size() {return map_tag_max+1;}; + + bigint memory_usage(); + int memcheck(const char *); + + // functions for global to local ID mapping + // map lookup function inlined for efficiency + // return -1 if no map defined + + inline int map(tagint global) { + if (map_style == 1) return map_array[global]; + else if (map_style == 2) return map_find_hash(global); + else return -1; + }; + + void map_init(int check = 1); + void map_clear(); + void map_set(); + void map_one(tagint, int); + int map_style_set(); + void map_delete(); + int map_find_hash(tagint); + + protected: + + // global to local ID mapping + + int *map_array; // direct map via array that holds map_tag_max + int map_maxarray; // allocated size of map_array (1 larger than this) + + struct HashElem { // hashed map + tagint global; // key to search on = global ID + int local; // value associated with key = local index + int next; // next entry in this bucket, -1 if last + }; + int map_nhash; // # of entries hash table can hold + int map_nused; // # of actual entries in hash table + int map_free; // ptr to 1st unused entry in hash table + int map_nbucket; // # of hash buckets + int *map_bucket; // ptr to 1st entry in each bucket + HashElem *map_hash; // hash table + + int max_same; // allocated size of sametag + + // spatial sorting of atoms + + int nbins; // # of sorting bins + int nbinx,nbiny,nbinz; // bins in each dimension + int maxbin; // max # of bins + int maxnext; // max size of next,permute + int *binhead; // 1st atom in each bin + int *next; // next atom in bin + int *permute; // permutation vector + double bininvx,bininvy,bininvz; // inverse actual bin sizes + double bboxlo[3],bboxhi[3]; // bounding box of my sub-domain + + int memlength; // allocated size of memstr + char *memstr; // string of array names already counted + + void setup_sort_bins(); + int next_prime(int); +}; + +} + +#endif + +/* ERROR/WARNING messages: + +E: Atom IDs must be used for molecular systems + +Atom IDs are used to identify and find partner atoms in bonds. + +E: Unknown atom style + +The choice of atom style is unknown. + +E: Could not find atom_modify first group ID + +Self-explanatory. + +E: Illegal ... command + +Self-explanatory. Check the input script syntax and compare to the +documentation for the command. You can use -echo screen as a +command-line option when running LAMMPS to see the offending line. + +E: Atom_modify id command after simulation box is defined + +The atom_modify id command cannot be used after a read_data, +read_restart, or create_box command. + +E: Atom_modify map command after simulation box is defined + +The atom_modify map command cannot be used after a read_data, +read_restart, or create_box command. + +E: Atom_modify sort and first options cannot be used together + +Self-explanatory. + +E: One or more Atom IDs is negative + +Atom IDs must be positive integers. + +E: One or more atom IDs is too big + +The limit on atom IDs is set by the SMALLBIG, BIGBIG, SMALLSMALL +setting in your Makefile. See Section_start 2.2 of the manual for +more details. + +E: One or more atom IDs is zero + +Either all atoms IDs must be zero or none of them. + +E: Non-zero atom IDs with atom_modify id = no + +Self-explanatory. + +E: All atom IDs = 0 but atom_modify id = yes + +Self-explanatory. + +E: Duplicate atom IDs exist + +Self-explanatory. + +E: New atom IDs exceed maximum allowed ID + +See the setting for tagint in the src/lmptype.h file. + +E: Incorrect atom format in data file + +Number of values per atom line in the data file is not consistent with +the atom style. + +E: Invalid atom type in Atoms section of data file + +Atom types must range from 1 to specified # of types. + +E: Incorrect velocity format in data file + +Each atom style defines a format for the Velocity section +of the data file. The read-in lines do not match. + +E: Invalid atom ID in Velocities section of data file + +Atom IDs must be positive integers and within range of defined +atoms. + +E: Invalid atom ID in Bonds section of data file + +Atom IDs must be positive integers and within range of defined +atoms. + +E: Invalid bond type in Bonds section of data file + +Bond type must be positive integer and within range of specified bond +types. + +E: Invalid atom ID in Angles section of data file + +Atom IDs must be positive integers and within range of defined +atoms. + +E: Invalid angle type in Angles section of data file + +Angle type must be positive integer and within range of specified angle +types. + +E: Invalid atom ID in Dihedrals section of data file + +Atom IDs must be positive integers and within range of defined +atoms. + +E: Invalid dihedral type in Dihedrals section of data file + +Dihedral type must be positive integer and within range of specified +dihedral types. + +E: Invalid atom ID in Impropers section of data file + +Atom IDs must be positive integers and within range of defined +atoms. + +E: Invalid improper type in Impropers section of data file + +Improper type must be positive integer and within range of specified +improper types. + +E: Incorrect bonus data format in data file + +See the read_data doc page for a description of how various kinds of +bonus data must be formatted for certain atom styles. + +E: Invalid atom ID in Bonus section of data file + +Atom IDs must be positive integers and within range of defined +atoms. + +E: Invalid atom ID in Bodies section of data file + +Atom IDs must be positive integers and within range of defined +atoms. + +E: Cannot set mass for this atom style + +This atom style does not support mass settings for each atom type. +Instead they are defined on a per-atom basis in the data file. + +E: Invalid mass line in data file + +Self-explanatory. + +E: Invalid type for mass set + +Mass command must set a type from 1-N where N is the number of atom +types. + +E: Invalid mass value + +Self-explanatory. + +E: All masses are not set + +For atom styles that define masses for each atom type, all masses must +be set in the data file or by the mass command before running a +simulation. They must also be set before using the velocity +command. + +E: Reuse of molecule template ID + +The template IDs must be unique. + +E: Atom sort did not operate correctly + +This is an internal LAMMPS error. Please report it to the +developers. + +E: Atom sorting has bin size = 0.0 + +The neighbor cutoff is being used as the bin size, but it is zero. +Thus you must explicitly list a bin size in the atom_modify sort +command or turn off sorting. + +E: Too many atom sorting bins + +This is likely due to an immense simulation box that has blown up +to a large size. + +*/ diff --git a/src/USER-HADRESS/atom_vec_full_hars.cpp b/src/USER-HADRESS/atom_vec_full_hars.cpp new file mode 100644 index 0000000000..fe01c0fa98 --- /dev/null +++ b/src/USER-HADRESS/atom_vec_full_hars.cpp @@ -0,0 +1,1352 @@ +/* ---------------------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + http://lammps.sandia.gov, Sandia National Laboratories + Steve Plimpton, sjplimp@sandia.gov + + Copyright (2003) Sandia Corporation. Under the terms of Contract + DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains + certain rights in this software. This software is distributed under + the GNU General Public License. + + See the README file in the top-level LAMMPS directory. +------------------------------------------------------------------------- */ + +#include "stdlib.h" +#include "atom_vec_full_hars.h" +#include "atom.h" +#include "comm.h" +#include "domain.h" +#include "modify.h" +#include "fix.h" +#include "memory.h" +#include "error.h" + +using namespace LAMMPS_NS; + +/* ---------------------------------------------------------------------- */ + +AtomVecFullHars::AtomVecFullHars(LAMMPS *lmp) : AtomVec(lmp) +{ + molecular = 1; + bonds_allow = angles_allow = dihedrals_allow = impropers_allow = 1; + mass_type = 1; + + comm_x_only = comm_f_only = 0; + size_forward = 10; + size_reverse = 3; + size_border = 17; + size_velocity = 3; + size_data_atom = 9; + size_data_vel = 4; + xcol_data = 7; + + atom->molecule_flag = atom->q_flag = 1; + atom->replambdaH_flag = 1; + atom->moltypeH_flag = 1; + +} + +/* ---------------------------------------------------------------------- + grow atom arrays + n = 0 grows arrays by a chunk + n > 0 allocates arrays to size n +------------------------------------------------------------------------- */ + +void AtomVecFullHars::grow(int n) +{ + if (n == 0) grow_nmax(); + else nmax = n; + atom->nmax = nmax; + if (nmax < 0 || nmax > MAXSMALLINT) + error->one(FLERR,"Per-processor system is too big"); + + tag = memory->grow(atom->tag,nmax,"atom:tag"); + type = memory->grow(atom->type,nmax,"atom:type"); + mask = memory->grow(atom->mask,nmax,"atom:mask"); + image = memory->grow(atom->image,nmax,"atom:image"); + x = memory->grow(atom->x,nmax,3,"atom:x"); + v = memory->grow(atom->v,nmax,3,"atom:v"); + f = memory->grow(atom->f,nmax*comm->nthreads,3,"atom:f"); + + q = memory->grow(atom->q,nmax,"atom:q"); + lambdaH = memory->grow(atom->lambdaH,nmax,"atom:lambdaH"); + gradlambdaH = memory->grow(atom->gradlambdaH,nmax,3,"atom:gradlambdaH"); + replambdaH = memory->grow(atom->replambdaH,nmax,"atom:replambdaH"); + moltypeH = memory->grow(atom->moltypeH,nmax,"atom:moltypeH"); + comH = memory->grow(atom->comH,nmax,3,"atom:comH"); + + molecule = memory->grow(atom->molecule,nmax,"atom:molecule"); + + nspecial = memory->grow(atom->nspecial,nmax,3,"atom:nspecial"); + special = memory->grow(atom->special,nmax,atom->maxspecial,"atom:special"); + + num_bond = memory->grow(atom->num_bond,nmax,"atom:num_bond"); + bond_type = memory->grow(atom->bond_type,nmax,atom->bond_per_atom, + "atom:bond_type"); + bond_atom = memory->grow(atom->bond_atom,nmax,atom->bond_per_atom, + "atom:bond_atom"); + + num_angle = memory->grow(atom->num_angle,nmax,"atom:num_angle"); + angle_type = memory->grow(atom->angle_type,nmax,atom->angle_per_atom, + "atom:angle_type"); + angle_atom1 = memory->grow(atom->angle_atom1,nmax,atom->angle_per_atom, + "atom:angle_atom1"); + angle_atom2 = memory->grow(atom->angle_atom2,nmax,atom->angle_per_atom, + "atom:angle_atom2"); + angle_atom3 = memory->grow(atom->angle_atom3,nmax,atom->angle_per_atom, + "atom:angle_atom3"); + + num_dihedral = memory->grow(atom->num_dihedral,nmax,"atom:num_dihedral"); + dihedral_type = memory->grow(atom->dihedral_type,nmax, + atom->dihedral_per_atom,"atom:dihedral_type"); + dihedral_atom1 = + memory->grow(atom->dihedral_atom1,nmax,atom->dihedral_per_atom, + "atom:dihedral_atom1"); + dihedral_atom2 = + memory->grow(atom->dihedral_atom2,nmax,atom->dihedral_per_atom, + "atom:dihedral_atom2"); + dihedral_atom3 = + memory->grow(atom->dihedral_atom3,nmax,atom->dihedral_per_atom, + "atom:dihedral_atom3"); + dihedral_atom4 = + memory->grow(atom->dihedral_atom4,nmax,atom->dihedral_per_atom, + "atom:dihedral_atom4"); + + num_improper = memory->grow(atom->num_improper,nmax,"atom:num_improper"); + improper_type = + memory->grow(atom->improper_type,nmax,atom->improper_per_atom, + "atom:improper_type"); + improper_atom1 = + memory->grow(atom->improper_atom1,nmax,atom->improper_per_atom, + "atom:improper_atom1"); + improper_atom2 = + memory->grow(atom->improper_atom2,nmax,atom->improper_per_atom, + "atom:improper_atom2"); + improper_atom3 = + memory->grow(atom->improper_atom3,nmax,atom->improper_per_atom, + "atom:improper_atom3"); + improper_atom4 = + memory->grow(atom->improper_atom4,nmax,atom->improper_per_atom, + "atom:improper_atom4"); + + if (atom->nextra_grow) + for (int iextra = 0; iextra < atom->nextra_grow; iextra++) + modify->fix[atom->extra_grow[iextra]]->grow_arrays(nmax); +} + +/* ---------------------------------------------------------------------- + reset local array ptrs +------------------------------------------------------------------------- */ + +void AtomVecFullHars::grow_reset() +{ + tag = atom->tag; type = atom->type; + mask = atom->mask; image = atom->image; + x = atom->x; v = atom->v; f = atom->f; comH = atom->comH; + q = atom->q; lambdaH = atom->lambdaH;gradlambdaH = atom->gradlambdaH; + replambdaH = atom->replambdaH;moltypeH = atom->moltypeH;molecule = atom->molecule; + nspecial = atom->nspecial; special = atom->special; + num_bond = atom->num_bond; bond_type = atom->bond_type; + bond_atom = atom->bond_atom; + num_angle = atom->num_angle; angle_type = atom->angle_type; + angle_atom1 = atom->angle_atom1; angle_atom2 = atom->angle_atom2; + angle_atom3 = atom->angle_atom3; + num_dihedral = atom->num_dihedral; dihedral_type = atom->dihedral_type; + dihedral_atom1 = atom->dihedral_atom1; dihedral_atom2 = atom->dihedral_atom2; + dihedral_atom3 = atom->dihedral_atom3; dihedral_atom4 = atom->dihedral_atom4; + num_improper = atom->num_improper; improper_type = atom->improper_type; + improper_atom1 = atom->improper_atom1; improper_atom2 = atom->improper_atom2; + improper_atom3 = atom->improper_atom3; improper_atom4 = atom->improper_atom4; +} + +/* ---------------------------------------------------------------------- + copy atom I info to atom J +------------------------------------------------------------------------- */ + +void AtomVecFullHars::copy(int i, int j, int delflag) +{ + int k; + + tag[j] = tag[i]; + type[j] = type[i]; + mask[j] = mask[i]; + image[j] = image[i]; + x[j][0] = x[i][0]; + x[j][1] = x[i][1]; + x[j][2] = x[i][2]; + v[j][0] = v[i][0]; + v[j][1] = v[i][1]; + v[j][2] = v[i][2]; + + comH[j][0] = comH[i][0]; + comH[j][1] = comH[i][1]; + comH[j][2] = comH[i][2]; + + q[j] = q[i]; + lambdaH[j] = lambdaH[i]; + gradlambdaH[j][0] = gradlambdaH[i][0]; + gradlambdaH[j][1] = gradlambdaH[i][1]; + gradlambdaH[j][2] = gradlambdaH[i][2]; + replambdaH[j] = replambdaH[i]; + moltypeH[j] = moltypeH[i]; + molecule[j] = molecule[i]; + + + num_bond[j] = num_bond[i]; + for (k = 0; k < num_bond[j]; k++) { + bond_type[j][k] = bond_type[i][k]; + bond_atom[j][k] = bond_atom[i][k]; + } + + num_angle[j] = num_angle[i]; + for (k = 0; k < num_angle[j]; k++) { + angle_type[j][k] = angle_type[i][k]; + angle_atom1[j][k] = angle_atom1[i][k]; + angle_atom2[j][k] = angle_atom2[i][k]; + angle_atom3[j][k] = angle_atom3[i][k]; + } + + num_dihedral[j] = num_dihedral[i]; + for (k = 0; k < num_dihedral[j]; k++) { + dihedral_type[j][k] = dihedral_type[i][k]; + dihedral_atom1[j][k] = dihedral_atom1[i][k]; + dihedral_atom2[j][k] = dihedral_atom2[i][k]; + dihedral_atom3[j][k] = dihedral_atom3[i][k]; + dihedral_atom4[j][k] = dihedral_atom4[i][k]; + } + + num_improper[j] = num_improper[i]; + for (k = 0; k < num_improper[j]; k++) { + improper_type[j][k] = improper_type[i][k]; + improper_atom1[j][k] = improper_atom1[i][k]; + improper_atom2[j][k] = improper_atom2[i][k]; + improper_atom3[j][k] = improper_atom3[i][k]; + improper_atom4[j][k] = improper_atom4[i][k]; + } + + nspecial[j][0] = nspecial[i][0]; + nspecial[j][1] = nspecial[i][1]; + nspecial[j][2] = nspecial[i][2]; + for (k = 0; k < nspecial[j][2]; k++) special[j][k] = special[i][k]; + + if (atom->nextra_grow) + for (int iextra = 0; iextra < atom->nextra_grow; iextra++) + modify->fix[atom->extra_grow[iextra]]->copy_arrays(i,j,delflag); +} + +/* ---------------------------------------------------------------------- */ + +int AtomVecFullHars::pack_comm(int n, int *list, double *buf, + int pbc_flag, int *pbc) +{ + int i,j,m; + double dx,dy,dz; + + m = 0; + if (pbc_flag == 0) { + for (i = 0; i < n; i++) { + j = list[i]; + buf[m++] = x[j][0]; + buf[m++] = x[j][1]; + buf[m++] = x[j][2]; + buf[m++] = lambdaH[j]; + buf[m++] = gradlambdaH[j][0]; + buf[m++] = gradlambdaH[j][1]; + buf[m++] = gradlambdaH[j][2]; + buf[m++] = comH[j][0]; + buf[m++] = comH[j][1]; + buf[m++] = comH[j][2]; + + } + } else { + if (domain->triclinic == 0) { + dx = pbc[0]*domain->xprd; + dy = pbc[1]*domain->yprd; + dz = pbc[2]*domain->zprd; + } else { + dx = pbc[0]*domain->xprd + pbc[5]*domain->xy + pbc[4]*domain->xz; + dy = pbc[1]*domain->yprd + pbc[3]*domain->yz; + dz = pbc[2]*domain->zprd; + } + for (i = 0; i < n; i++) { + j = list[i]; + buf[m++] = x[j][0] + dx; + buf[m++] = x[j][1] + dy; + buf[m++] = x[j][2] + dz; + buf[m++] = lambdaH[j]; + buf[m++] = gradlambdaH[j][0]; + buf[m++] = gradlambdaH[j][1]; + buf[m++] = gradlambdaH[j][2]; + buf[m++] = comH[j][0]; + buf[m++] = comH[j][1]; + buf[m++] = comH[j][2]; + + + } + } + return m; +} + +/* ---------------------------------------------------------------------- */ + +int AtomVecFullHars::pack_comm_vel(int n, int *list, double *buf, + int pbc_flag, int *pbc) +{ + int i,j,m; + double dx,dy,dz,dvx,dvy,dvz; + + m = 0; + if (pbc_flag == 0) { + for (i = 0; i < n; i++) { + j = list[i]; + buf[m++] = x[j][0]; + buf[m++] = x[j][1]; + buf[m++] = x[j][2]; + buf[m++] = lambdaH[j]; + buf[m++] = gradlambdaH[j][0]; + buf[m++] = gradlambdaH[j][1]; + buf[m++] = gradlambdaH[j][2]; + buf[m++] = comH[j][0]; + buf[m++] = comH[j][1]; + buf[m++] = comH[j][2]; + + buf[m++] = v[j][0]; + buf[m++] = v[j][1]; + buf[m++] = v[j][2]; + + } + } else { + if (domain->triclinic == 0) { + dx = pbc[0]*domain->xprd; + dy = pbc[1]*domain->yprd; + dz = pbc[2]*domain->zprd; + } else { + dx = pbc[0]*domain->xprd + pbc[5]*domain->xy + pbc[4]*domain->xz; + dy = pbc[1]*domain->yprd + pbc[3]*domain->yz; + dz = pbc[2]*domain->zprd; + } + if (!deform_vremap) { + for (i = 0; i < n; i++) { + j = list[i]; + buf[m++] = x[j][0] + dx; + buf[m++] = x[j][1] + dy; + buf[m++] = x[j][2] + dz; + buf[m++] = lambdaH[j]; + buf[m++] = gradlambdaH[j][0]; + buf[m++] = gradlambdaH[j][1]; + buf[m++] = gradlambdaH[j][2]; + buf[m++] = comH[j][0]; + buf[m++] = comH[j][1]; + buf[m++] = comH[j][2]; + + buf[m++] = v[j][0]; + buf[m++] = v[j][1]; + buf[m++] = v[j][2]; + } + } else { + dvx = pbc[0]*h_rate[0] + pbc[5]*h_rate[5] + pbc[4]*h_rate[4]; + dvy = pbc[1]*h_rate[1] + pbc[3]*h_rate[3]; + dvz = pbc[2]*h_rate[2]; + for (i = 0; i < n; i++) { + j = list[i]; + buf[m++] = x[j][0] + dx; + buf[m++] = x[j][1] + dy; + buf[m++] = x[j][2] + dz; + buf[m++] = lambdaH[j]; + buf[m++] = gradlambdaH[j][0]; + buf[m++] = gradlambdaH[j][1]; + buf[m++] = gradlambdaH[j][2]; + buf[m++] = comH[j][0]; + buf[m++] = comH[j][1]; + buf[m++] = comH[j][2]; + + + + if (mask[i] & deform_groupbit) { + buf[m++] = v[j][0] + dvx; + buf[m++] = v[j][1] + dvy; + buf[m++] = v[j][2] + dvz; + } else { + buf[m++] = v[j][0]; + buf[m++] = v[j][1]; + buf[m++] = v[j][2]; + } + } + } + } + return m; +} + +/* ---------------------------------------------------------------------- */ + +void AtomVecFullHars::unpack_comm(int n, int first, double *buf) +{ + int i,m,last; + + m = 0; + last = first + n; + for (i = first; i < last; i++) { + x[i][0] = buf[m++]; + x[i][1] = buf[m++]; + x[i][2] = buf[m++]; + lambdaH[i] = buf[m++]; + gradlambdaH[i][0] = buf[m++]; + gradlambdaH[i][1] = buf[m++]; + gradlambdaH[i][2] = buf[m++]; + comH[i][0] = buf[m++]; + comH[i][1] = buf[m++]; + comH[i][2] = buf[m++]; + + + + } +} + +/* ---------------------------------------------------------------------- */ + +void AtomVecFullHars::unpack_comm_vel(int n, int first, double *buf) +{ + int i,m,last; + + m = 0; + last = first + n; + for (i = first; i < last; i++) { + x[i][0] = buf[m++]; + x[i][1] = buf[m++]; + x[i][2] = buf[m++]; + lambdaH[i] = buf[m++]; + gradlambdaH[i][0] = buf[m++]; + gradlambdaH[i][1] = buf[m++]; + gradlambdaH[i][2] = buf[m++]; + comH[i][0] = buf[m++]; + comH[i][1] = buf[m++]; + comH[i][2] = buf[m++]; + + v[i][0] = buf[m++]; + v[i][1] = buf[m++]; + v[i][2] = buf[m++]; + } +} + +/* ---------------------------------------------------------------------- */ + +int AtomVecFullHars::pack_reverse(int n, int first, double *buf) +{ + int i,m,last; + + m = 0; + last = first + n; + for (i = first; i < last; i++) { + buf[m++] = f[i][0]; + buf[m++] = f[i][1]; + buf[m++] = f[i][2]; + + } + return m; +} + +/* ---------------------------------------------------------------------- */ + +void AtomVecFullHars::unpack_reverse(int n, int *list, double *buf) +{ + int i,j,m; + + m = 0; + for (i = 0; i < n; i++) { + j = list[i]; + f[j][0] += buf[m++]; + f[j][1] += buf[m++]; + f[j][2] += buf[m++]; + + + } +} + +/* ---------------------------------------------------------------------- */ + +int AtomVecFullHars::pack_border(int n, int *list, double *buf, + int pbc_flag, int *pbc) +{ + int i,j,m; + double dx,dy,dz; + + m = 0; + if (pbc_flag == 0) { + for (i = 0; i < n; i++) { + j = list[i]; + buf[m++] = x[j][0]; + buf[m++] = x[j][1]; + buf[m++] = x[j][2]; + buf[m++] = ubuf(tag[j]).d; + buf[m++] = ubuf(type[j]).d; + buf[m++] = ubuf(mask[j]).d; + buf[m++] = q[j]; + buf[m++] = lambdaH[j]; + buf[m++] = gradlambdaH[j][0]; + buf[m++] = gradlambdaH[j][1]; + buf[m++] = gradlambdaH[j][2]; + buf[m++] = comH[j][0]; + buf[m++] = comH[j][1]; + buf[m++] = comH[j][2]; + + buf[m++] = ubuf(replambdaH[j]).d; + buf[m++] = ubuf(moltypeH[j]).d; + + buf[m++] = ubuf(molecule[j]).d; + } + } else { + if (domain->triclinic == 0) { + dx = pbc[0]*domain->xprd; + dy = pbc[1]*domain->yprd; + dz = pbc[2]*domain->zprd; + } else { + dx = pbc[0]; + dy = pbc[1]; + dz = pbc[2]; + } + for (i = 0; i < n; i++) { + j = list[i]; + buf[m++] = x[j][0] + dx; + buf[m++] = x[j][1] + dy; + buf[m++] = x[j][2] + dz; + buf[m++] = ubuf(tag[j]).d; + buf[m++] = ubuf(type[j]).d; + buf[m++] = ubuf(mask[j]).d; + buf[m++] = q[j]; + buf[m++] = lambdaH[j]; + buf[m++] = gradlambdaH[j][0]; + buf[m++] = gradlambdaH[j][1]; + buf[m++] = gradlambdaH[j][2]; + buf[m++] = comH[j][0]; + buf[m++] = comH[j][1]; + buf[m++] = comH[j][2]; + + buf[m++] = ubuf(replambdaH[j]).d; + buf[m++] = ubuf(moltypeH[j]).d; + + buf[m++] = ubuf(molecule[j]).d; + } + } + + if (atom->nextra_border) + for (int iextra = 0; iextra < atom->nextra_border; iextra++) + m += modify->fix[atom->extra_border[iextra]]->pack_border(n,list,&buf[m]); + + return m; +} + +/* ---------------------------------------------------------------------- */ + +int AtomVecFullHars::pack_border_vel(int n, int *list, double *buf, + int pbc_flag, int *pbc) +{ + int i,j,m; + double dx,dy,dz,dvx,dvy,dvz; + + m = 0; + if (pbc_flag == 0) { + for (i = 0; i < n; i++) { + j = list[i]; + buf[m++] = x[j][0]; + buf[m++] = x[j][1]; + buf[m++] = x[j][2]; + buf[m++] = ubuf(tag[j]).d; + buf[m++] = ubuf(type[j]).d; + buf[m++] = ubuf(mask[j]).d; + buf[m++] = q[j]; + buf[m++] = lambdaH[j]; + buf[m++] = gradlambdaH[j][0]; + buf[m++] = gradlambdaH[j][1]; + buf[m++] = gradlambdaH[j][2]; + buf[m++] = comH[j][0]; + buf[m++] = comH[j][1]; + buf[m++] = comH[j][2]; + + buf[m++] = ubuf(replambdaH[j]).d; + buf[m++] = ubuf(moltypeH[j]).d; + + buf[m++] = ubuf(molecule[j]).d; + buf[m++] = v[j][0]; + buf[m++] = v[j][1]; + buf[m++] = v[j][2]; + } + } else { + if (domain->triclinic == 0) { + dx = pbc[0]*domain->xprd; + dy = pbc[1]*domain->yprd; + dz = pbc[2]*domain->zprd; + } else { + dx = pbc[0]; + dy = pbc[1]; + dz = pbc[2]; + } + if (!deform_vremap) { + for (i = 0; i < n; i++) { + j = list[i]; + buf[m++] = x[j][0] + dx; + buf[m++] = x[j][1] + dy; + buf[m++] = x[j][2] + dz; + buf[m++] = ubuf(tag[j]).d; + buf[m++] = ubuf(type[j]).d; + buf[m++] = ubuf(mask[j]).d; + buf[m++] = q[j]; + buf[m++] = lambdaH[j]; + buf[m++] = gradlambdaH[j][0]; + buf[m++] = gradlambdaH[j][1]; + buf[m++] = gradlambdaH[j][2]; + buf[m++] = comH[j][0]; + buf[m++] = comH[j][1]; + buf[m++] = comH[j][2]; + + buf[m++] = ubuf(replambdaH[j]).d; + buf[m++] = ubuf(moltypeH[j]).d; + + buf[m++] = ubuf(molecule[j]).d; + buf[m++] = v[j][0]; + buf[m++] = v[j][1]; + buf[m++] = v[j][2]; + } + } else { + dvx = pbc[0]*h_rate[0] + pbc[5]*h_rate[5] + pbc[4]*h_rate[4]; + dvy = pbc[1]*h_rate[1] + pbc[3]*h_rate[3]; + dvz = pbc[2]*h_rate[2]; + for (i = 0; i < n; i++) { + j = list[i]; + buf[m++] = x[j][0] + dx; + buf[m++] = x[j][1] + dy; + buf[m++] = x[j][2] + dz; + buf[m++] = ubuf(tag[j]).d; + buf[m++] = ubuf(type[j]).d; + buf[m++] = ubuf(mask[j]).d; + buf[m++] = q[j]; + buf[m++] = lambdaH[j]; + buf[m++] = gradlambdaH[j][0]; + buf[m++] = gradlambdaH[j][1]; + buf[m++] = gradlambdaH[j][2]; + buf[m++] = comH[j][0]; + buf[m++] = comH[j][1]; + buf[m++] = comH[j][2]; + + buf[m++] = ubuf(replambdaH[j]).d; + buf[m++] = ubuf(moltypeH[j]).d; + + buf[m++] = ubuf(molecule[j]).d; + if (mask[i] & deform_groupbit) { + buf[m++] = v[j][0] + dvx; + buf[m++] = v[j][1] + dvy; + buf[m++] = v[j][2] + dvz; + } else { + buf[m++] = v[j][0]; + buf[m++] = v[j][1]; + buf[m++] = v[j][2]; + } + } + } + } + + if (atom->nextra_border) + for (int iextra = 0; iextra < atom->nextra_border; iextra++) + m += modify->fix[atom->extra_border[iextra]]->pack_border(n,list,&buf[m]); + + return m; +} + +/* ---------------------------------------------------------------------- */ + +int AtomVecFullHars::pack_border_hybrid(int n, int *list, double *buf) +{ + int i,j,m; + + m = 0; + for (i = 0; i < n; i++) { + j = list[i]; + buf[m++] = q[j]; + buf[m++] = ubuf(replambdaH[j]).d; + buf[m++] = ubuf(moltypeH[j]).d; + buf[m++] = ubuf(molecule[j]).d; + } + return m; +} + +/* ---------------------------------------------------------------------- */ + +void AtomVecFullHars::unpack_border(int n, int first, double *buf) +{ + int i,m,last; + + m = 0; + last = first + n; + for (i = first; i < last; i++) { + if (i == nmax) grow(0); + x[i][0] = buf[m++]; + x[i][1] = buf[m++]; + x[i][2] = buf[m++]; + tag[i] = (tagint) ubuf(buf[m++]).i; + type[i] = (int) ubuf(buf[m++]).i; + mask[i] = (int) ubuf(buf[m++]).i; + q[i] = buf[m++]; + lambdaH[i] = buf[m++]; + gradlambdaH[i][0] = buf[m++]; + gradlambdaH[i][1] = buf[m++]; + gradlambdaH[i][2] = buf[m++]; + comH[i][0] = buf[m++]; + comH[i][1] = buf[m++]; + comH[i][2] = buf[m++]; + + replambdaH[i] = (int) ubuf(buf[m++]).i; + moltypeH[i] = (int) ubuf(buf[m++]).i; + + molecule[i] = (tagint) ubuf(buf[m++]).i; + + } + + if (atom->nextra_border) + for (int iextra = 0; iextra < atom->nextra_border; iextra++) + m += modify->fix[atom->extra_border[iextra]]-> + unpack_border(n,first,&buf[m]); +} + +/* ---------------------------------------------------------------------- */ + +void AtomVecFullHars::unpack_border_vel(int n, int first, double *buf) +{ + int i,m,last; + + m = 0; + last = first + n; + for (i = first; i < last; i++) { + if (i == nmax) grow(0); + x[i][0] = buf[m++]; + x[i][1] = buf[m++]; + x[i][2] = buf[m++]; + tag[i] = (tagint) ubuf(buf[m++]).i; + type[i] = (int) ubuf(buf[m++]).i; + mask[i] = (int) ubuf(buf[m++]).i; + q[i] = buf[m++]; + lambdaH[i] = buf[m++]; + gradlambdaH[i][0] = buf[m++]; + gradlambdaH[i][1] = buf[m++]; + gradlambdaH[i][2] = buf[m++]; + comH[i][0] = buf[m++]; + comH[i][1] = buf[m++]; + comH[i][2] = buf[m++]; + + replambdaH[i] = (int) ubuf(buf[m++]).i; + moltypeH[i] = (int) ubuf(buf[m++]).i; + + molecule[i] = (tagint) ubuf(buf[m++]).i; + v[i][0] = buf[m++]; + v[i][1] = buf[m++]; + v[i][2] = buf[m++]; + } + + if (atom->nextra_border) + for (int iextra = 0; iextra < atom->nextra_border; iextra++) + m += modify->fix[atom->extra_border[iextra]]-> + unpack_border(n,first,&buf[m]); +} + +/* ---------------------------------------------------------------------- */ + +int AtomVecFullHars::unpack_border_hybrid(int n, int first, double *buf) +{ + int i,m,last; + + m = 0; + last = first + n; + for (i = first; i < last; i++) { + q[i] = buf[m++]; + replambdaH[i] = (int) ubuf(buf[m++]).i; + moltypeH[i] = (int) ubuf(buf[m++]).i; + molecule[i] = (tagint) ubuf(buf[m++]).i; + } + return m; +} + +/* ---------------------------------------------------------------------- + pack data for atom I for sending to another proc + xyz must be 1st 3 values, so comm::exchange() can test on them +------------------------------------------------------------------------- */ + +int AtomVecFullHars::pack_exchange(int i, double *buf) +{ + int k; + + int m = 1; + buf[m++] = x[i][0]; + buf[m++] = x[i][1]; + buf[m++] = x[i][2]; + buf[m++] = v[i][0]; + buf[m++] = v[i][1]; + buf[m++] = v[i][2]; + buf[m++] = ubuf(tag[i]).d; + buf[m++] = ubuf(type[i]).d; + buf[m++] = ubuf(mask[i]).d; + buf[m++] = ubuf(image[i]).d; + + buf[m++] = q[i]; + buf[m++] = lambdaH[i]; + buf[m++] = gradlambdaH[i][0]; + buf[m++] = gradlambdaH[i][1]; + buf[m++] = gradlambdaH[i][2]; + buf[m++] = comH[i][0]; + buf[m++] = comH[i][1]; + buf[m++] = comH[i][2]; + + buf[m++] = ubuf(replambdaH[i]).d; + buf[m++] = ubuf(moltypeH[i]).d; + + buf[m++] = ubuf(molecule[i]).d; + + buf[m++] = ubuf(num_bond[i]).d; + for (k = 0; k < num_bond[i]; k++) { + buf[m++] = ubuf(bond_type[i][k]).d; + buf[m++] = ubuf(bond_atom[i][k]).d; + } + + buf[m++] = ubuf(num_angle[i]).d; + for (k = 0; k < num_angle[i]; k++) { + buf[m++] = ubuf(angle_type[i][k]).d; + buf[m++] = ubuf(angle_atom1[i][k]).d; + buf[m++] = ubuf(angle_atom2[i][k]).d; + buf[m++] = ubuf(angle_atom3[i][k]).d; + } + + buf[m++] = ubuf(num_dihedral[i]).d; + for (k = 0; k < num_dihedral[i]; k++) { + buf[m++] = ubuf(dihedral_type[i][k]).d; + buf[m++] = ubuf(dihedral_atom1[i][k]).d; + buf[m++] = ubuf(dihedral_atom2[i][k]).d; + buf[m++] = ubuf(dihedral_atom3[i][k]).d; + buf[m++] = ubuf(dihedral_atom4[i][k]).d; + } + + buf[m++] = ubuf(num_improper[i]).d; + for (k = 0; k < num_improper[i]; k++) { + buf[m++] = ubuf(improper_type[i][k]).d; + buf[m++] = ubuf(improper_atom1[i][k]).d; + buf[m++] = ubuf(improper_atom2[i][k]).d; + buf[m++] = ubuf(improper_atom3[i][k]).d; + buf[m++] = ubuf(improper_atom4[i][k]).d; + } + + buf[m++] = ubuf(nspecial[i][0]).d; + buf[m++] = ubuf(nspecial[i][1]).d; + buf[m++] = ubuf(nspecial[i][2]).d; + for (k = 0; k < nspecial[i][2]; k++) buf[m++] = ubuf(special[i][k]).d; + + if (atom->nextra_grow) + for (int iextra = 0; iextra < atom->nextra_grow; iextra++) + m += modify->fix[atom->extra_grow[iextra]]->pack_exchange(i,&buf[m]); + + buf[0] = m; + return m; +} + +/* ---------------------------------------------------------------------- */ + +int AtomVecFullHars::unpack_exchange(double *buf) +{ + int k; + + int nlocal = atom->nlocal; + if (nlocal == nmax) grow(0); + + int m = 1; + x[nlocal][0] = buf[m++]; + x[nlocal][1] = buf[m++]; + x[nlocal][2] = buf[m++]; + v[nlocal][0] = buf[m++]; + v[nlocal][1] = buf[m++]; + v[nlocal][2] = buf[m++]; + tag[nlocal] = (tagint) ubuf(buf[m++]).i; + type[nlocal] = (int) ubuf(buf[m++]).i; + mask[nlocal] = (int) ubuf(buf[m++]).i; + image[nlocal] = (imageint) ubuf(buf[m++]).i; + + q[nlocal] = buf[m++]; + lambdaH[nlocal] = buf[m++]; + gradlambdaH[nlocal][0] = buf[m++]; + gradlambdaH[nlocal][1] = buf[m++]; + gradlambdaH[nlocal][2] = buf[m++]; + comH[nlocal][0] = buf[m++]; + comH[nlocal][1] = buf[m++]; + comH[nlocal][2] = buf[m++]; + + replambdaH[nlocal] = (int) ubuf(buf[m++]).i; + moltypeH[nlocal] = (int) ubuf(buf[m++]).i; + + molecule[nlocal] = (tagint) ubuf(buf[m++]).i; + + num_bond[nlocal] = (int) ubuf(buf[m++]).i; + for (k = 0; k < num_bond[nlocal]; k++) { + bond_type[nlocal][k] = (int) ubuf(buf[m++]).i; + bond_atom[nlocal][k] = (tagint) ubuf(buf[m++]).i; + } + + num_angle[nlocal] = (int) ubuf(buf[m++]).i; + for (k = 0; k < num_angle[nlocal]; k++) { + angle_type[nlocal][k] = (int) ubuf(buf[m++]).i; + angle_atom1[nlocal][k] = (tagint) ubuf(buf[m++]).i; + angle_atom2[nlocal][k] = (tagint) ubuf(buf[m++]).i; + angle_atom3[nlocal][k] = (tagint) ubuf(buf[m++]).i; + } + + num_dihedral[nlocal] = (int) ubuf(buf[m++]).i; + for (k = 0; k < num_dihedral[nlocal]; k++) { + dihedral_type[nlocal][k] = (int) ubuf(buf[m++]).i; + dihedral_atom1[nlocal][k] = (tagint) ubuf(buf[m++]).i; + dihedral_atom2[nlocal][k] = (tagint) ubuf(buf[m++]).i; + dihedral_atom3[nlocal][k] = (tagint) ubuf(buf[m++]).i; + dihedral_atom4[nlocal][k] = (tagint) ubuf(buf[m++]).i; + } + + num_improper[nlocal] = (int) ubuf(buf[m++]).i; + for (k = 0; k < num_improper[nlocal]; k++) { + improper_type[nlocal][k] = (int) ubuf(buf[m++]).i; + improper_atom1[nlocal][k] = (tagint) ubuf(buf[m++]).i; + improper_atom2[nlocal][k] = (tagint) ubuf(buf[m++]).i; + improper_atom3[nlocal][k] = (tagint) ubuf(buf[m++]).i; + improper_atom4[nlocal][k] = (tagint) ubuf(buf[m++]).i; + } + + nspecial[nlocal][0] = (int) ubuf(buf[m++]).i; + nspecial[nlocal][1] = (int) ubuf(buf[m++]).i; + nspecial[nlocal][2] = (int) ubuf(buf[m++]).i; + for (k = 0; k < nspecial[nlocal][2]; k++) + special[nlocal][k] = (tagint) ubuf(buf[m++]).i; + + if (atom->nextra_grow) + for (int iextra = 0; iextra < atom->nextra_grow; iextra++) + m += modify->fix[atom->extra_grow[iextra]]-> + unpack_exchange(nlocal,&buf[m]); + + atom->nlocal++; + return m; +} + +/* ---------------------------------------------------------------------- + size of restart data for all atoms owned by this proc + include extra data stored by fixes +------------------------------------------------------------------------- */ + +int AtomVecFullHars::size_restart() +{ + int i; + + int nlocal = atom->nlocal; + int n = 0; + for (i = 0; i < nlocal; i++) + n += 17 + 2*num_bond[i] + 4*num_angle[i] + + 5*num_dihedral[i] + 5*num_improper[i]+9; + + if (atom->nextra_restart) + for (int iextra = 0; iextra < atom->nextra_restart; iextra++) + for (i = 0; i < nlocal; i++) + n += modify->fix[atom->extra_restart[iextra]]->size_restart(i); + + return n; +} + +/* ---------------------------------------------------------------------- + pack atom I's data for restart file including extra quantities + xyz must be 1st 3 values, so that read_restart can test on them + molecular types may be negative, but write as positive +------------------------------------------------------------------------- */ + +int AtomVecFullHars::pack_restart(int i, double *buf) +{ + int k; + + int m = 1; + buf[m++] = x[i][0]; + buf[m++] = x[i][1]; + buf[m++] = x[i][2]; + buf[m++] = ubuf(tag[i]).d; + buf[m++] = ubuf(type[i]).d; + buf[m++] = ubuf(mask[i]).d; + buf[m++] = ubuf(image[i]).d; + buf[m++] = v[i][0]; + buf[m++] = v[i][1]; + buf[m++] = v[i][2]; + + buf[m++] = q[i]; + buf[m++] = lambdaH[i]; + buf[m++] = gradlambdaH[i][0]; + buf[m++] = gradlambdaH[i][1]; + buf[m++] = gradlambdaH[i][2]; + buf[m++] = comH[i][0]; + buf[m++] = comH[i][1]; + buf[m++] = comH[i][2]; + + buf[m++] = ubuf(replambdaH[i]).d; + buf[m++] = ubuf(moltypeH[i]).d; + buf[m++] = ubuf(molecule[i]).d; + + buf[m++] = ubuf(num_bond[i]).d; + for (k = 0; k < num_bond[i]; k++) { + buf[m++] = ubuf(MAX(bond_type[i][k],-bond_type[i][k])).d; + buf[m++] = ubuf(bond_atom[i][k]).d; + } + + buf[m++] = ubuf(num_angle[i]).d; + for (k = 0; k < num_angle[i]; k++) { + buf[m++] = ubuf(MAX(angle_type[i][k],-angle_type[i][k])).d; + buf[m++] = ubuf(angle_atom1[i][k]).d; + buf[m++] = ubuf(angle_atom2[i][k]).d; + buf[m++] = ubuf(angle_atom3[i][k]).d; + } + + buf[m++] = ubuf(num_dihedral[i]).d; + for (k = 0; k < num_dihedral[i]; k++) { + buf[m++] = ubuf(MAX(dihedral_type[i][k],-dihedral_type[i][k])).d; + buf[m++] = ubuf(dihedral_atom1[i][k]).d; + buf[m++] = ubuf(dihedral_atom2[i][k]).d; + buf[m++] = ubuf(dihedral_atom3[i][k]).d; + buf[m++] = ubuf(dihedral_atom4[i][k]).d; + } + + buf[m++] = ubuf(num_improper[i]).d; + for (k = 0; k < num_improper[i]; k++) { + buf[m++] = ubuf(MAX(improper_type[i][k],-improper_type[i][k])).d; + buf[m++] = ubuf(improper_atom1[i][k]).d; + buf[m++] = ubuf(improper_atom2[i][k]).d; + buf[m++] = ubuf(improper_atom3[i][k]).d; + buf[m++] = ubuf(improper_atom4[i][k]).d; + } + + if (atom->nextra_restart) + for (int iextra = 0; iextra < atom->nextra_restart; iextra++) + m += modify->fix[atom->extra_restart[iextra]]->pack_restart(i,&buf[m]); + + buf[0] = m; + return m; +} + +/* ---------------------------------------------------------------------- + unpack data for one atom from restart file including extra quantities +------------------------------------------------------------------------- */ + +int AtomVecFullHars::unpack_restart(double *buf) +{ + int k; + + int nlocal = atom->nlocal; + if (nlocal == nmax) { + grow(0); + if (atom->nextra_store) + memory->grow(atom->extra,nmax,atom->nextra_store,"atom:extra"); + } + + int m = 1; + x[nlocal][0] = buf[m++]; + x[nlocal][1] = buf[m++]; + x[nlocal][2] = buf[m++]; + tag[nlocal] = (tagint) ubuf(buf[m++]).i; + type[nlocal] = (int) ubuf(buf[m++]).i; + mask[nlocal] = (int) ubuf(buf[m++]).i; + image[nlocal] = (imageint) ubuf(buf[m++]).i; + v[nlocal][0] = buf[m++]; + v[nlocal][1] = buf[m++]; + v[nlocal][2] = buf[m++]; + + q[nlocal] = buf[m++]; + lambdaH[nlocal] = buf[m++]; + gradlambdaH[nlocal][0] = buf[m++]; + gradlambdaH[nlocal][1] = buf[m++]; + gradlambdaH[nlocal][2] = buf[m++]; + comH[nlocal][0] = buf[m++]; + comH[nlocal][1] = buf[m++]; + comH[nlocal][2] = buf[m++]; + replambdaH[nlocal] = (int) ubuf(buf[m++]).i; + moltypeH[nlocal] = (int) ubuf(buf[m++]).i; + + molecule[nlocal] = (tagint) ubuf(buf[m++]).i; + + num_bond[nlocal] = (int) ubuf(buf[m++]).i; + for (k = 0; k < num_bond[nlocal]; k++) { + bond_type[nlocal][k] = (int) ubuf(buf[m++]).i; + bond_atom[nlocal][k] = (tagint) ubuf(buf[m++]).i; + } + + num_angle[nlocal] = (int) ubuf(buf[m++]).i; + for (k = 0; k < num_angle[nlocal]; k++) { + angle_type[nlocal][k] = (int) ubuf(buf[m++]).i; + angle_atom1[nlocal][k] = (tagint) ubuf(buf[m++]).i; + angle_atom2[nlocal][k] = (tagint) ubuf(buf[m++]).i; + angle_atom3[nlocal][k] = (tagint) ubuf(buf[m++]).i; + } + + num_dihedral[nlocal] = (int) ubuf(buf[m++]).i; + for (k = 0; k < num_dihedral[nlocal]; k++) { + dihedral_type[nlocal][k] = (int) ubuf(buf[m++]).i; + dihedral_atom1[nlocal][k] = (tagint) ubuf(buf[m++]).i; + dihedral_atom2[nlocal][k] = (tagint) ubuf(buf[m++]).i; + dihedral_atom3[nlocal][k] = (tagint) ubuf(buf[m++]).i; + dihedral_atom4[nlocal][k] = (tagint) ubuf(buf[m++]).i; + } + + num_improper[nlocal] = (int) ubuf(buf[m++]).i; + for (k = 0; k < num_improper[nlocal]; k++) { + improper_type[nlocal][k] = (int) ubuf(buf[m++]).i; + improper_atom1[nlocal][k] = (tagint) ubuf(buf[m++]).i; + improper_atom2[nlocal][k] = (tagint) ubuf(buf[m++]).i; + improper_atom3[nlocal][k] = (tagint) ubuf(buf[m++]).i; + improper_atom4[nlocal][k] = (tagint) ubuf(buf[m++]).i; + } + + nspecial[nlocal][0] = nspecial[nlocal][1] = nspecial[nlocal][2] = 0; + + double **extra = atom->extra; + if (atom->nextra_store) { + int size = static_cast (buf[0]) - m; + for (int i = 0; i < size; i++) extra[nlocal][i] = buf[m++]; + } + + atom->nlocal++; + return m; +} + +/* ---------------------------------------------------------------------- + create one atom of itype at coord + set other values to defaults +------------------------------------------------------------------------- */ + +void AtomVecFullHars::create_atom(int itype, double *coord) +{ + int nlocal = atom->nlocal; + if (nlocal == nmax) grow(0); + + tag[nlocal] = 0; + type[nlocal] = itype; + x[nlocal][0] = coord[0]; + x[nlocal][1] = coord[1]; + x[nlocal][2] = coord[2]; + mask[nlocal] = 1; + image[nlocal] = ((imageint) IMGMAX << IMG2BITS) | + ((imageint) IMGMAX << IMGBITS) | IMGMAX; + v[nlocal][0] = 0.0; + v[nlocal][1] = 0.0; + v[nlocal][2] = 0.0; + + q[nlocal] = 0.0; + lambdaH[nlocal] = 0.0; + gradlambdaH[nlocal][0] = 0.0; + gradlambdaH[nlocal][1] = 0.0; + gradlambdaH[nlocal][2] = 0.0; + comH[nlocal][0] = 0; + comH[nlocal][1] = 0; + comH[nlocal][2] = 0; + + replambdaH[nlocal] = 0; + moltypeH[nlocal] = 0; + + molecule[nlocal] = 0; + num_bond[nlocal] = 0; + num_angle[nlocal] = 0; + num_dihedral[nlocal] = 0; + num_improper[nlocal] = 0; + nspecial[nlocal][0] = nspecial[nlocal][1] = nspecial[nlocal][2] = 0; + + atom->nlocal++; +} + +/* ---------------------------------------------------------------------- + unpack one line from Atoms section of data file + initialize other atom quantities +------------------------------------------------------------------------- */ + +void AtomVecFullHars::data_atom(double *coord, imageint imagetmp, char **values) +{ + int nlocal = atom->nlocal; + if (nlocal == nmax) grow(0); + + tag[nlocal] = ATOTAGINT(values[0]); + molecule[nlocal] = ATOTAGINT(values[1]); + type[nlocal] = atoi(values[2]); + if (type[nlocal] <= 0 || type[nlocal] > atom->ntypes) + error->one(FLERR,"Invalid atom type in Atoms section of data file"); + + q[nlocal] = atof(values[3]); + replambdaH[nlocal] = atoi(values[4]); + moltypeH[nlocal] = atoi(values[5]); + + + x[nlocal][0] = coord[0]; + x[nlocal][1] = coord[1]; + x[nlocal][2] = coord[2]; + + comH[nlocal][0] = 0; + comH[nlocal][1] = 0; + comH[nlocal][2] = 0; + + image[nlocal] = imagetmp; + + mask[nlocal] = 1; + v[nlocal][0] = 0.0; + v[nlocal][1] = 0.0; + v[nlocal][2] = 0.0; + num_bond[nlocal] = 0; + num_angle[nlocal] = 0; + num_dihedral[nlocal] = 0; + num_improper[nlocal] = 0; + + atom->nlocal++; +} + +/* ---------------------------------------------------------------------- + unpack hybrid quantities from one line in Atoms section of data file + initialize other atom quantities for this sub-style +------------------------------------------------------------------------- */ + +int AtomVecFullHars::data_atom_hybrid(int nlocal, char **values) +{ + molecule[nlocal] = ATOTAGINT(values[0]); + q[nlocal] = atof(values[1]); + replambdaH[nlocal] = atoi(values[2]); + moltypeH[nlocal] = atoi(values[3]); + + num_bond[nlocal] = 0; + num_angle[nlocal] = 0; + num_dihedral[nlocal] = 0; + num_improper[nlocal] = 0; + + return 2; +} + +/* ---------------------------------------------------------------------- + pack atom info for data file including 3 image flags +------------------------------------------------------------------------- */ + +void AtomVecFullHars::pack_data(double **buf) +{ + int nlocal = atom->nlocal; + for (int i = 0; i < nlocal; i++) { + buf[i][0] = ubuf(tag[i]).d; + buf[i][1] = ubuf(molecule[i]).d; + buf[i][2] = ubuf(type[i]).d; + buf[i][3] = q[i]; + buf[i][4] = ubuf(replambdaH[i]).d; + buf[i][5] = ubuf(moltypeH[i]).d; + + buf[i][6] = x[i][0]; + buf[i][7] = x[i][1]; + buf[i][8] = x[i][2]; + buf[i][9] = ubuf((image[i] & IMGMASK) - IMGMAX).d; + buf[i][10] = ubuf((image[i] >> IMGBITS & IMGMASK) - IMGMAX).d; + buf[i][11] = ubuf((image[i] >> IMG2BITS) - IMGMAX).d; + } +} + +/* ---------------------------------------------------------------------- + pack hybrid atom info for data file +------------------------------------------------------------------------- */ + +int AtomVecFullHars::pack_data_hybrid(int i, double *buf) +{ + buf[0] = ubuf(molecule[i]).d; + buf[1] = q[i]; + buf[2] = ubuf(replambdaH[i]).d; + buf[3] = ubuf(moltypeH[i]).d; + + return 2; +} + +/* ---------------------------------------------------------------------- + write atom info to data file including 3 image flags +------------------------------------------------------------------------- */ + +void AtomVecFullHars::write_data(FILE *fp, int n, double **buf) +{ + for (int i = 0; i < n; i++) + fprintf(fp,TAGINT_FORMAT " " TAGINT_FORMAT + " %d %-1.16e %-1.16e %-1.16e %-1.16e %d %d %d\n", + (tagint) ubuf(buf[i][0]).i,(tagint) ubuf(buf[i][1]).i, + (int) ubuf(buf[i][2]).i, + buf[i][3],buf[i][4],buf[i][5],buf[i][6], + (int) ubuf(buf[i][7]).i,(int) ubuf(buf[i][8]).i, + (int) ubuf(buf[i][9]).i); +} + +/* ---------------------------------------------------------------------- + write hybrid atom info to data file +------------------------------------------------------------------------- */ + +int AtomVecFullHars::write_data_hybrid(FILE *fp, double *buf) +{ + fprintf(fp," " TAGINT_FORMAT " %-1.16e",(tagint) ubuf(buf[0]).i,buf[1]); + return 2; +} + +/* ---------------------------------------------------------------------- + return # of bytes of allocated memory +------------------------------------------------------------------------- */ + +bigint AtomVecFullHars::memory_usage() +{ + bigint bytes = 0; + + if (atom->memcheck("tag")) bytes += memory->usage(tag,nmax); + if (atom->memcheck("type")) bytes += memory->usage(type,nmax); + if (atom->memcheck("mask")) bytes += memory->usage(mask,nmax); + if (atom->memcheck("image")) bytes += memory->usage(image,nmax); + if (atom->memcheck("x")) bytes += memory->usage(x,nmax,3); + if (atom->memcheck("v")) bytes += memory->usage(v,nmax,3); + if (atom->memcheck("f")) bytes += memory->usage(f,nmax*comm->nthreads,3); + + if (atom->memcheck("q")) bytes += memory->usage(q,nmax); + if (atom->memcheck("lambdaH")) bytes += memory->usage(lambdaH,nmax); + if (atom->memcheck("gradlambdaH")) bytes += memory->usage(gradlambdaH,nmax,3); + if (atom->memcheck("replambdaH")) bytes += memory->usage(replambdaH,nmax); + if (atom->memcheck("moltypeH")) bytes += memory->usage(moltypeH,nmax); + + if (atom->memcheck("comH")) bytes += memory->usage(comH,nmax,3); + + + if (atom->memcheck("molecule")) bytes += memory->usage(molecule,nmax); + if (atom->memcheck("nspecial")) bytes += memory->usage(nspecial,nmax,3); + if (atom->memcheck("special")) + bytes += memory->usage(special,nmax,atom->maxspecial); + + if (atom->memcheck("num_bond")) bytes += memory->usage(num_bond,nmax); + if (atom->memcheck("bond_type")) + bytes += memory->usage(bond_type,nmax,atom->bond_per_atom); + if (atom->memcheck("bond_atom")) + bytes += memory->usage(bond_atom,nmax,atom->bond_per_atom); + + if (atom->memcheck("num_angle")) bytes += memory->usage(num_angle,nmax); + if (atom->memcheck("angle_type")) + bytes += memory->usage(angle_type,nmax,atom->angle_per_atom); + if (atom->memcheck("angle_atom1")) + bytes += memory->usage(angle_atom1,nmax,atom->angle_per_atom); + if (atom->memcheck("angle_atom2")) + bytes += memory->usage(angle_atom2,nmax,atom->angle_per_atom); + if (atom->memcheck("angle_atom3")) + bytes += memory->usage(angle_atom3,nmax,atom->angle_per_atom); + + if (atom->memcheck("num_dihedral")) bytes += memory->usage(num_dihedral,nmax); + if (atom->memcheck("dihedral_type")) + bytes += memory->usage(dihedral_type,nmax,atom->dihedral_per_atom); + if (atom->memcheck("dihedral_atom1")) + bytes += memory->usage(dihedral_atom1,nmax,atom->dihedral_per_atom); + if (atom->memcheck("dihedral_atom2")) + bytes += memory->usage(dihedral_atom2,nmax,atom->dihedral_per_atom); + if (atom->memcheck("dihedral_atom3")) + bytes += memory->usage(dihedral_atom3,nmax,atom->dihedral_per_atom); + if (atom->memcheck("dihedral_atom4")) + bytes += memory->usage(dihedral_atom4,nmax,atom->dihedral_per_atom); + + if (atom->memcheck("num_improper")) bytes += memory->usage(num_improper,nmax); + if (atom->memcheck("improper_type")) + bytes += memory->usage(improper_type,nmax,atom->improper_per_atom); + if (atom->memcheck("improper_atom1")) + bytes += memory->usage(improper_atom1,nmax,atom->improper_per_atom); + if (atom->memcheck("improper_atom2")) + bytes += memory->usage(improper_atom2,nmax,atom->improper_per_atom); + if (atom->memcheck("improper_atom3")) + bytes += memory->usage(improper_atom3,nmax,atom->improper_per_atom); + if (atom->memcheck("improper_atom4")) + bytes += memory->usage(improper_atom4,nmax,atom->improper_per_atom); + + return bytes; +} diff --git a/src/USER-HADRESS/atom_vec_full_hars.h b/src/USER-HADRESS/atom_vec_full_hars.h new file mode 100644 index 0000000000..59bac9a3b9 --- /dev/null +++ b/src/USER-HADRESS/atom_vec_full_hars.h @@ -0,0 +1,104 @@ +/* -*- c++ -*- ---------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + http://lammps.sandia.gov, Sandia National Laboratories + Steve Plimpton, sjplimp@sandia.gov + + Copyright (2003) Sandia Corporation. Under the terms of Contract + DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains + certain rights in this software. This software is distributed under + the GNU General Public License. + + See the README file in the top-level LAMMPS directory. +------------------------------------------------------------------------- */ + +#ifdef ATOM_CLASS + +AtomStyle(full/hars,AtomVecFullHars) + +#else + +#ifndef LMP_ATOM_VEC_FULL_HARS_H +#define LMP_ATOM_VEC_FULL_HARS_H + +#include "atom_vec.h" + +namespace LAMMPS_NS { + +class AtomVecFullHars : public AtomVec { + public: + AtomVecFullHars(class LAMMPS *); + virtual ~AtomVecFullHars() {} + void grow(int); + void grow_reset(); + void copy(int, int, int); + virtual int pack_comm(int, int *, double *, int, int *); + virtual int pack_comm_vel(int, int *, double *, int, int *); + virtual void unpack_comm(int, int, double *); + virtual void unpack_comm_vel(int, int, double *); + int pack_reverse(int, int, double *); + void unpack_reverse(int, int *, double *); + virtual int pack_border(int, int *, double *, int, int *); + virtual int pack_border_vel(int, int *, double *, int, int *); + int pack_border_hybrid(int, int *, double *); + virtual void unpack_border(int, int, double *); + virtual void unpack_border_vel(int, int, double *); + int unpack_border_hybrid(int, int, double *); + virtual int pack_exchange(int, double *); + virtual int unpack_exchange(double *); + int size_restart(); + int pack_restart(int, double *); + int unpack_restart(double *); + void create_atom(int, double *); + void data_atom(double *, imageint, char **); + int data_atom_hybrid(int, char **); + void pack_data(double **); + int pack_data_hybrid(int, double *); + void write_data(FILE *, int, double **); + int write_data_hybrid(FILE *, double *); + bigint memory_usage(); + + protected: + tagint *tag; + int *type,*mask; + imageint *image; + double **x,**v,**f; + double *q; + double *lambdaH; + double **gradlambdaH; + int *replambdaH; + int *moltypeH; + double **comH; + tagint *molecule; + int **nspecial; + tagint **special; + int *num_bond; + int **bond_type; + tagint **bond_atom; + int *num_angle; + int **angle_type; + tagint **angle_atom1,**angle_atom2,**angle_atom3; + int *num_dihedral; + int **dihedral_type; + tagint **dihedral_atom1,**dihedral_atom2,**dihedral_atom3,**dihedral_atom4; + int *num_improper; + int **improper_type; + tagint **improper_atom1,**improper_atom2,**improper_atom3,**improper_atom4; +}; + +} + +#endif +#endif + +/* ERROR/WARNING messages: + +E: Per-processor system is too big + +The number of owned atoms plus ghost atoms on a single +processor must fit in 32-bit integer. + +E: Invalid atom type in Atoms section of data file + +Atom types must range from 1 to specified # of types. + +*/ diff --git a/src/USER-HADRESS/fix_lambdah_calc.cpp b/src/USER-HADRESS/fix_lambdah_calc.cpp new file mode 100644 index 0000000000..17d84032d5 --- /dev/null +++ b/src/USER-HADRESS/fix_lambdah_calc.cpp @@ -0,0 +1,958 @@ +/* ---------------------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + http://lammps.sandia.gov, Sandia National Laboratories + Steve Plimpton, sjplimp@sandia.gov + + Copyright (2003) Sandia Corporation. Under the terms of Contract + DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains + certain rights in this software. This software is distributed under + the GNU General Public License. + + See the README file in the top-level LAMMPS directory. +------------------------------------------------------------------------- */ + +/* ---------------------------------------------------------------------- + Contributing author: Maziar Heidari (Max Planck Institute for Polymer Research) +------------------------------------------------------------------------- */ + +#include "math.h" +#include "string.h" +#include "stdlib.h" +#include "fix_lambdah_calc.h" +#include "atom.h" +#include "input.h" +#include "variable.h" +#include "domain.h" +#include "lattice.h" +#include "update.h" +#include "modify.h" +#include "output.h" +#include "respa.h" +#include "error.h" +#include "force.h" +#include "math_const.h" +#include "memory.h" +#include "comm.h" +#include "citeme.h" + + +using namespace LAMMPS_NS; +using namespace FixConst; +using namespace MathConst; + +#define BIG MAXTAGINT + +static const char cite_HAdResS[] = + "@Article{Heidari et al.2016\n" + " author = {M. Heidari, R. Cortes-Huerto, D. Donadio and R. Potestio},\n" + " title = {Accurate and general treatment of electrostatic interaction in Hamiltonian adaptive resolution simulations},\n" + " journal = {Eur. Phys. J. Special Topics},\n" + " year = 2016,\n" + " volume = Submitted,\n" + " pages = {}\n" + "}\n\n"; + + +/* ---------------------------------------------------------------------- */ + +FixLambdaHCalc::FixLambdaHCalc(LAMMPS *lmp, int narg, char **arg) : + Fix(lmp, narg, arg) +{ + + + if (lmp->citeme) lmp->citeme->add(cite_HAdResS); + + massproc_H = NULL; + masstotal_H = NULL; + com_H = NULL; + comall_H = NULL; + molmap_H = NULL; + lambdaCM = NULL; + gradlambdaCM = NULL; + Comp_Density_Num_H = NULL; + Comp_Density_Num_all_H = NULL; + Mean_Density_H = NULL; + Int_Mean_Density_H = NULL; + Mean_Comp_Density_Conv_H = NULL; + grad_Comp_Density_Conv_H = NULL; + Mean_grad_Comp_Density_Conv_H = NULL; + + + + me = comm->me; + + if (narg < 8) error->all(FLERR,"Illegal fix LambdaH/Calc command"); + + atom->nmoltypesH = force->numeric(FLERR,arg[3]); + Length_Hyb = force->numeric(FLERR,arg[4]); + Length_ATRegion = force->numeric(FLERR,arg[5]); + Pressure_Comp_Flag = force->numeric(FLERR,arg[6]); + Pressure_lambda_Increment = force->numeric(FLERR,arg[7]); + Pressure_Update_Frequency = force->numeric(FLERR,arg[8]); + Pressure_Update_Time_Begin = force->numeric(FLERR,arg[9]); + Pressure_Update_Time_End = force->numeric(FLERR,arg[10]); + + if (strcmp(arg[11],"slab") == 0) Hybrid_Style = 0; + else if (strcmp(arg[11],"sphere") == 0) Hybrid_Style = 1; + else if (strcmp(arg[11],"cylinder") == 0) Hybrid_Style = 2; + else error->all(FLERR,"Illegal fix LambdaH/Calc command"); + + Density_Comp_Flag = force->numeric(FLERR,arg[12]); + Density_Bin_Size = force->numeric(FLERR,arg[13]); + Density_Update_Frequency = force->numeric(FLERR,arg[14]); + Density_Update_Time_Begin = force->numeric(FLERR,arg[15]); + Density_Update_Time_End = force->numeric(FLERR,arg[16]); + Density_Sigma_Gauss = force->numeric(FLERR,arg[17]); + Density_Gauss_Int_Range = force->numeric(FLERR,arg[18]); + Density_Ref = force->numeric(FLERR,arg[19]); + Comp_Density_Scaling_factor_H = force->numeric(FLERR,arg[20]); + Load_File_Flag = force->numeric(FLERR,arg[21]); + + x0lo = domain->boxlo[0]; + x0hi = domain->boxhi[0]; + x1lo = domain->boxlo[1]; + x1hi = domain->boxhi[1]; + x2lo = domain->boxlo[2]; + x2hi = domain->boxhi[2]; + + center_box[0] = (x0hi + x0lo)/2.0; + center_box[1] = (x1hi + x1lo)/2.0; + center_box[2] = (x2hi + x2lo)/2.0; + + + x0BoxSize = x0hi - x0lo; + Length_CGRegion = x0BoxSize - 2*Length_Hyb - Length_ATRegion; + R_Start_Hybrid_1 = x0lo + Length_CGRegion/2.0; + R_Start_Hybrid_2 = x0lo + x0BoxSize - (Length_CGRegion/2.0 + Length_Hyb); + S_Start_Hybrid = Length_ATRegion; + Pressure_Bin_Num = 1.0 / Pressure_lambda_Increment; + xmin_AT = R_Start_Hybrid_1 + Length_Hyb; + xmax_AT= R_Start_Hybrid_1 + Length_Hyb + Length_ATRegion; + if(Hybrid_Style==0)Density_Bin_Num = floor(x0BoxSize / Density_Bin_Size); + else if(Hybrid_Style==1)Density_Bin_Num = floor(sqrt(pow(0.5*(x0hi-x0lo),2.0)+pow(0.5*(x1hi-x1lo),2.0)+pow(0.5*(x2hi-x2lo),2.0)) / Density_Bin_Size); + else if(Hybrid_Style==2)Density_Bin_Num = floor(sqrt(pow(0.5*(x0hi-x0lo),2.0)+pow(0.5*(x1hi-x1lo),2.0)) / Density_Bin_Size); + + + Comp_Counter_H = 0; + Density_Counter_H = 0; + Density_Compensation_Run = 0; + + memory->create(Comp_Density_Num_H,Density_Bin_Num,atom->nmoltypesH+1,"lambdaH/calc:Comp_Density_Num_H"); + memory->create(Comp_Density_Num_all_H,Density_Bin_Num,atom->nmoltypesH+1,"lambdaH/calc:Comp_Density_Num_all_H"); + + if(me==0){ + if (screen){ + fprintf(screen,"nmoltypes= %d\n",atom->nmoltypesH); + fprintf(screen,"Length_Hyb= %f\n",Length_Hyb); + fprintf(screen,"Length_ATRegion= %f\n",Length_ATRegion); + fprintf(screen,"Pressure_Comp_Flag= %d\n",Pressure_Comp_Flag); + fprintf(screen,"Pressure_lambda_Increment= %f\n",Pressure_lambda_Increment); + fprintf(screen,"Pressure_Update_Frequency= %d\n",Pressure_Update_Frequency); + fprintf(screen,"Pressure_Update_Time_Begin= %d\n",Pressure_Update_Time_Begin); + fprintf(screen,"Pressure_Update_Time_End= %d\n",Pressure_Update_Time_End); + fprintf(screen,"Density_Comp_Flag= %d\n",Density_Comp_Flag); + fprintf(screen,"Density_Bin_Size= %f\n",Density_Bin_Size); + fprintf(screen,"Density_Update_Frequency= %d\n",Density_Update_Frequency); + fprintf(screen,"Density_Update_Time_Begin= %d\n",Density_Update_Time_Begin); + fprintf(screen,"Density_Update_Time_End= %d\n",Density_Update_Time_End); + fprintf(screen,"Density_Sigma_Gauss= %f\n",Density_Sigma_Gauss); + fprintf(screen,"Density_Gauss_Int_Range= %d\n",Density_Gauss_Int_Range); + fprintf(screen,"Density_Ref= %f\n",Density_Ref); + fprintf(screen,"Comp_Density_Scaling_factor_H = %f\n",Comp_Density_Scaling_factor_H); + fprintf(screen,"Load_File_Flag = %d\n",Load_File_Flag); + fprintf(screen,"Center_box = %f %f %f\n",center_box[0],center_box[1],center_box[2]); + fprintf(screen,"Density_Bin_Size = %f\n",Density_Bin_Size); + fprintf(screen,"Density_Bin_Num = %d\n",Density_Bin_Num); + fprintf(screen,"x0lo= %f\n",x0lo); + fprintf(screen,"x0hi= %f\n",x0hi); + fprintf(screen,"x0BoxSize= %f\n",x0BoxSize); + fprintf(screen,"d1= %f\n",R_Start_Hybrid_1); + fprintf(screen,"d2= %f\n",R_Start_Hybrid_2); + fprintf(screen,"moltype%d\n",atom->nmoltypesH); + + } + if (logfile){ + fprintf(logfile,"nmoltypes= %d\n",atom->nmoltypesH); + fprintf(logfile,"Length_Hyb= %f\n",Length_Hyb); + fprintf(logfile,"Length_ATRegion= %f\n",Length_ATRegion); + fprintf(logfile,"Pressure_Comp_Flag= %d\n",Pressure_Comp_Flag); + fprintf(logfile,"Pressure_lambda_Increment= %f\n",Pressure_lambda_Increment); + fprintf(logfile,"Pressure_Update_Frequency= %d\n",Pressure_Update_Frequency); + fprintf(logfile,"Pressure_Update_Time_Begin= %d\n",Pressure_Update_Time_Begin); + fprintf(logfile,"Pressure_Update_Time_End= %d\n",Pressure_Update_Time_End); + fprintf(logfile,"Density_Comp_Flag= %d\n",Density_Comp_Flag); + fprintf(logfile,"Density_Bin_Size= %f\n",Density_Bin_Size); + fprintf(logfile,"Density_Update_Frequency= %d\n",Density_Update_Frequency); + fprintf(logfile,"Density_Update_Time_Begin= %d\n",Density_Update_Time_Begin); + fprintf(logfile,"Density_Update_Time_End= %d\n",Density_Update_Time_End); + fprintf(logfile,"Density_Sigma_Gauss= %f\n",Density_Sigma_Gauss); + fprintf(logfile,"Density_Gauss_Int_Range= %d\n",Density_Gauss_Int_Range); + fprintf(logfile,"Density_Ref= %f\n",Density_Ref); + fprintf(logfile,"Comp_Density_Scaling_factor_H = %f\n",Comp_Density_Scaling_factor_H); + fprintf(logfile,"Load_File_Flag = %d\n",Load_File_Flag); + fprintf(logfile,"Center_box = %f %f %f\n",center_box[0],center_box[1],center_box[2]); + fprintf(logfile,"Density_Bin_Size = %f\n",Density_Bin_Size); + fprintf(logfile,"Density_Bin_Num = %d\n",Density_Bin_Num); + fprintf(logfile,"x0lo= %f\n",x0lo); + fprintf(logfile,"x0hi= %f\n",x0hi); + fprintf(logfile,"x0BoxSize= %f\n",x0BoxSize); + fprintf(logfile,"d1= %f\n",R_Start_Hybrid_1); + fprintf(logfile,"d2= %f\n",R_Start_Hybrid_2); + fprintf(logfile,"moltype%d\n",atom->nmoltypesH); + + } + } + + memory->create(Int_Mean_Density_H,Density_Bin_Num,atom->nmoltypesH+1,"lambdaH/calc:Int_Mean_Density_H"); + memory->create(Mean_Density_H,Density_Bin_Num,atom->nmoltypesH+1,"lambdaH/calc:Mean_Density_H"); + memory->create(Mean_Comp_Density_Conv_H,Density_Bin_Num,atom->nmoltypesH+1,"lambdaH/calc:Mean_Comp_Density_Conv_H"); + memory->create(grad_Comp_Density_Conv_H,Density_Bin_Num,atom->nmoltypesH+1,"lambdaH/calc:grad_Comp_Density_Conv_H"); + memory->create(Mean_grad_Comp_Density_Conv_H,Density_Bin_Num,atom->nmoltypesH+1,"lambdaH/calc:Mean_grad_Comp_Density_Conv_H"); + + + int This_Step = update->ntimestep; + + for(int i = 0;i < Density_Bin_Num; i++){ + for(int j = 0; j < atom->nmoltypesH; j++){ + Comp_Density_Num_H[i][j] = 0; + Comp_Density_Num_all_H[i][j] = 0; + Int_Mean_Density_H[i][j] = 0; + Mean_Density_H[i][j] = 0; + Mean_Comp_Density_Conv_H[i][j] = 0; + Mean_grad_Comp_Density_Conv_H[i][j] = 0; + grad_Comp_Density_Conv_H[i][j] = 0; + } + } + + if((This_Step >= Density_Update_Time_End || Load_File_Flag) && Density_Comp_Flag != 0)Load_Compensation_Density(); + + if (atom->molecular == 0) + error->all(FLERR,"Compute com/molecule requires molecular atom style"); + + array_flag = 1; + size_array_cols = 3; + extarray = 0; + // setup molecule-based data + nmolecules = molecules_in_group(idlo,idhi); + size_array_rows = nmolecules; + + //printf("Nmolecules= %d\n",nmolecules); + + memory->create(massproc_H,nmolecules,"lambdaH/calc:massproc_H"); + memory->create(masstotal_H,nmolecules,"lambdaH/calc:masstotal_H"); + memory->create(com_H,nmolecules,3,"lambdaH/calc:com_H"); + memory->create(comall_H,nmolecules,3,"lambdaH/calc:comall_H"); + memory->create(lambdaCM,nmolecules,"lambdaH/calc:lambdaCM"); + memory->create(gradlambdaCM,nmolecules,3,"lambdaH/calc:gradlambdaCM"); + + // compute masstotal for each molecule + + int *mask = atom->mask; + tagint *molecule = atom->molecule; + int *type = atom->type; + double *mass = atom->mass; + double *rmass = atom->rmass; + int nlocal = atom->nlocal; + tagint imol; + double massone; + + for (int i = 0; i < nmolecules; i++) massproc_H[i] = 0.0; + + for (int i = 0; i < nlocal; i++) + { + if (mask[i] & groupbit) { + if (rmass) massone = rmass[i]; + else massone = mass[type[i]]; + imol = molecule[i]; + if (molmap_H) imol = molmap_H[imol-idlo]; + else imol--; + massproc_H[imol] += massone; + } +} + + MPI_Allreduce(massproc_H,masstotal_H,nmolecules,MPI_DOUBLE,MPI_SUM,world); + int *replambdaH = atom->replambdaH; + int pass = 0; + for (int i = 0; i < nlocal; i++) if(replambdaH[i] != 0)pass=1; + if(pass==0) error->all(FLERR,"No representative atom (replambdaH) has been defined!"); + +} + +/* ---------------------------------------------------------------------- */ + +FixLambdaHCalc::~FixLambdaHCalc() +{ + + memory->destroy(massproc_H); + memory->destroy(masstotal_H); + memory->destroy(com_H); + memory->destroy(comall_H); + memory->destroy(molmap_H); + memory->destroy(lambdaCM); + memory->destroy(gradlambdaCM); + memory->destroy(Comp_Density_Num_H); + memory->destroy(Comp_Density_Num_all_H); + memory->destroy(Mean_Density_H); + memory->destroy(Int_Mean_Density_H); + memory->destroy(Mean_Comp_Density_Conv_H); + memory->destroy(grad_Comp_Density_Conv_H); + memory->destroy(Mean_grad_Comp_Density_Conv_H); +} + +/* ---------------------------------------------------------------------- */ + +int FixLambdaHCalc::setmask() +{ + int mask = 0; + //mask |= PRE_FORCE; +// mask |= PRE_NEIGHBOR; + mask |= POST_INTEGRATE; + mask |= THERMO_ENERGY; +// mask |= POST_FORCE_RESPA; + mask |= MIN_PRE_FORCE; + return mask; +} + +/* ---------------------------------------------------------------------- */ + +void FixLambdaHCalc::init() +{ + int ntmp = molecules_in_group(idlo,idhi); + if (ntmp != nmolecules) + error->all(FLERR,"Molecule count changed in compute com/molecule"); + + + +} + +/* ---------------------------------------------------------------------- */ + +void FixLambdaHCalc::setup(int vflag) +{ + +// if (strstr(update->integrate_style,"verlet")) + //pre_force(vflag); + post_integrate(); +// else { +// ((Respa *) update->integrate)->copy_flevel_f(nlevels_respa-1); +// post_force_respa(vflag,nlevels_respa-1,0); + // ((Respa *) update->integrate)->copy_f_flevel(nlevels_respa-1); + // } +} + +/* ---------------------------------------------------------------------- */ + + +void FixLambdaHCalc::post_integrate() +{ + + tagint imol; + double massone; + double unwrap[3]; + + + //invoked_array = update->ntimestep; + for (int i = 0; i < nmolecules; i++) + com_H[i][0] = com_H[i][1] = com_H[i][2] = 0.0; + + double **x = atom->x; + int *mask = atom->mask; + tagint *molecule = atom->molecule; + int *type = atom->type; + imageint *image = atom->image; + double *mass = atom->mass; + double *rmass = atom->rmass; + int nlocal = atom->nlocal; + + double *lambdaH = atom->lambdaH; + double **gradlambdaH = atom->gradlambdaH; + double **comH = atom->comH; + + int This_Step = update->ntimestep; + if(This_Step >= Density_Update_Time_Begin && This_Step <= Density_Update_Time_End && Density_Comp_Flag == 1){ + Density_Compensation_Run = 1; + if(me==0 && This_Step == Density_Update_Time_Begin){ + if(screen)fprintf(screen,"\nStart of constant-density route\n"); + if(logfile)fprintf(logfile,"\nStart of constant-density route\n"); + Clear_File_Compensation_Density(); + } + } + + + for (int i = 0; i < nlocal; i++) + if (mask[i] & groupbit) { + + if (rmass) massone = rmass[i]; + else massone = mass[type[i]]; + imol = molecule[i]; + if (molmap_H) imol = molmap_H[imol-idlo]; + else imol--; + domain->unmap(x[i],image[i],unwrap); + massone /= masstotal_H[imol]; + + com_H[imol][0] += unwrap[0] * massone; + com_H[imol][1] += unwrap[1] * massone; + com_H[imol][2] += unwrap[2] * massone; + } + + + MPI_Allreduce(&com_H[0][0],&comall_H[0][0],3*nmolecules,MPI_DOUBLE,MPI_SUM,world); + + + double xtmp,ytmp,ztmp; + double delx,dely,delz; + double Grad_Factor; + double rdiff; + + for (int i = 0; i < nmolecules; i++){ + + + domain->remap(comall_H[i]); + + if(Hybrid_Style==0){ + xtmp = comall_H[i][0]; + + if(xtmp < R_Start_Hybrid_1){ + lambdaCM[i] = 0.0; + gradlambdaCM[i][0] = 0.0; + gradlambdaCM[i][1] = 0.0; + gradlambdaCM[i][2] = 0.0; + + } + else if(xtmp >= R_Start_Hybrid_1 && xtmp < R_Start_Hybrid_1+Length_Hyb){ + cosx=cos(MY_PI*(xtmp-R_Start_Hybrid_1+Length_Hyb)/(2.0*Length_Hyb)); + sinx=sin(MY_PI*(xtmp-R_Start_Hybrid_1+Length_Hyb)/(2.0*Length_Hyb)); + lambdaCM[i] = cosx * cosx; + gradlambdaCM[i][0] = -(MY_PI/Length_Hyb) * sinx * cosx; + gradlambdaCM[i][1] = 0.0; + gradlambdaCM[i][2] = 0.0; + + } + else if(xtmp >=R_Start_Hybrid_1+Length_Hyb && xtmp < R_Start_Hybrid_2){ + lambdaCM[i] = 1.0; + gradlambdaCM[i][0] = 0.0; + gradlambdaCM[i][1] = 0.0; + gradlambdaCM[i][2] = 0.0; + + } + else if(xtmp >= R_Start_Hybrid_2 && xtmp < R_Start_Hybrid_2+Length_Hyb){ + cosx = cos(MY_PI*(xtmp-R_Start_Hybrid_2)/(2.0*Length_Hyb)); + sinx = sin(MY_PI*(xtmp-R_Start_Hybrid_2)/(2.0*Length_Hyb)); + lambdaCM[i] = cosx * cosx; + gradlambdaCM[i][0] = -(MY_PI/Length_Hyb) * sinx * cosx; + gradlambdaCM[i][1] = 0.0; + gradlambdaCM[i][2] = 0.0; + + } + else if(xtmp >=R_Start_Hybrid_2+Length_Hyb){ + lambdaCM[i] = 0.0; + gradlambdaCM[i][0] = 0.0; + gradlambdaCM[i][1] = 0.0; + gradlambdaCM[i][2] = 0.0; + + } + } + + else if(Hybrid_Style==1){ + xtmp = comall_H[i][0]; + ytmp = comall_H[i][1]; + ztmp = comall_H[i][2]; + + delx = (xtmp-center_box[0]); + dely = (ytmp-center_box[1]); + delz = (ztmp-center_box[2]); + + r = sqrt(delx*delx+dely*dely+delz*delz); + + if(r < S_Start_Hybrid){ + lambdaCM[i] = 1.0; + gradlambdaCM[i][0] = 0.0; + gradlambdaCM[i][1] = 0.0; + gradlambdaCM[i][2] = 0.0; + } + else if(r >= S_Start_Hybrid && r < S_Start_Hybrid+Length_Hyb) { + rdiff = MY_PI*(r-S_Start_Hybrid)/(2.0*Length_Hyb); + cosr=cos(rdiff); + sinr=sin(rdiff); + lambdaCM[i] = cosr * cosr; + Grad_Factor = -MY_PI * sinr * cosr / (Length_Hyb * r); + gradlambdaCM[i][0] = Grad_Factor * delx; + gradlambdaCM[i][1] = Grad_Factor * dely; + gradlambdaCM[i][2] = Grad_Factor * delz; + } + else if(r >= S_Start_Hybrid+Length_Hyb){ + lambdaCM[i] = 0.0; + gradlambdaCM[i][0] = 0.0; + gradlambdaCM[i][1] = 0.0; + gradlambdaCM[i][2] = 0.0; + } + } + + else if(Hybrid_Style==2){ + + xtmp = comall_H[i][0]; + ytmp = comall_H[i][1]; + + delx = (xtmp-center_box[0]); + dely = (ytmp-center_box[1]); + + r = sqrt(delx*delx+dely*dely); + + if(r < S_Start_Hybrid){ + lambdaCM[i] = 1.0; + gradlambdaCM[i][0] = 0.0; + gradlambdaCM[i][1] = 0.0; + gradlambdaCM[i][2] = 0.0; + } + else if(r >= S_Start_Hybrid && r < S_Start_Hybrid+Length_Hyb) { + rdiff = MY_PI*(r-S_Start_Hybrid)/(2.0*Length_Hyb); + cosr=cos(rdiff); + sinr=sin(rdiff); + lambdaCM[i] = cosr * cosr; + Grad_Factor = -MY_PI * sinr * cosr / (Length_Hyb * r); + + gradlambdaCM[i][0] = Grad_Factor * delx; + gradlambdaCM[i][1] = Grad_Factor * dely; + gradlambdaCM[i][2] = 0.0; + } + else if(r >= S_Start_Hybrid+Length_Hyb){ + lambdaCM[i] = 0.0; + gradlambdaCM[i][0] = 0.0; + gradlambdaCM[i][1] = 0.0; + gradlambdaCM[i][2] = 0.0; + } + } + + +} + + int ibin,imoltypeH; + int *moltypeH = atom->moltypeH; + + for (int i = 0; i < nlocal; i++) + if (mask[i] & groupbit) + { + imol = molecule[i]; + imoltypeH = moltypeH[i]; + if (molmap_H) imol = molmap_H[imol-idlo]; + else imol--; + lambdaH[i] = lambdaCM[imol]; + gradlambdaH[i][0] = gradlambdaCM[imol][0]; + gradlambdaH[i][1] = gradlambdaCM[imol][1]; + gradlambdaH[i][2] = gradlambdaCM[imol][2]; +// if(gradlambdaH[i][2]!=0) printf("gradlambdaH[i][2] = %f\n",gradlambdaH[i][2]); + +// gradlambdaH[i][2] = 0.0; + //gradlambdaH[i] = 0; +// if(replambdaH[i] == 1){ + comH[i][0] = comall_H[imol][0]; + comH[i][1] = comall_H[imol][1]; + comH[i][2] = comall_H[imol][2]; +// } + + if(Density_Comp_Flag != 0 && Density_Compensation_Run != 0){ + + if(Hybrid_Style==0){ +// xtmp = comall_H[imol][0]-x0lo; + xtmp = comH[i][0]-x0lo; +// if(xtmp <= 0.5*x0BoxSize)ibin = floor(xtmp/Density_Bin_Size); +// else ibin = floor((x0BoxSize-xtmp)/Density_Bin_Size); + + ibin = floor(xtmp/Density_Bin_Size); + + } + + else if(Hybrid_Style==1){ + xtmp = comall_H[imol][0]; + ytmp = comall_H[imol][1]; + ztmp = comall_H[imol][2]; + + delx = (xtmp-center_box[0]); + dely = (ytmp-center_box[1]); + delz = (ztmp-center_box[2]); + + r = sqrt(delx*delx+dely*dely+delz*delz); + ibin = floor(r/Density_Bin_Size); + } + + else if(Hybrid_Style==2){ + + xtmp = comall_H[imol][0]; + ytmp = comall_H[imol][1]; + + delx = (xtmp-center_box[0]); + dely = (ytmp-center_box[1]); + + r = sqrt(delx*delx+dely*dely); + ibin = floor(r/Density_Bin_Size); + } + + if(ibin>=Density_Bin_Num)ibin = Density_Bin_Num - 1; + Comp_Density_Num_H[ibin][imoltypeH-1]++; + + } + + } + + +// int Middle_Bin_Num = (Density_Bin_Num-1) / 2; + +// if(Hybrid_Style == 0)for(int i = Middle_Bin_Num+1;i < Density_Bin_Num; i++)Comp_Density_Num_H[i] = Comp_Density_Num_H[Density_Bin_Num-1-i]; + if(Density_Compensation_Run)Density_Counter_H++; + + double Density_Bin_Vol, exponent; + double Normalization; + int jmin, jmax,jj; + if(This_Step % Density_Update_Frequency == 0 && Density_Comp_Flag != 0 && Density_Compensation_Run != 0){ + + // if(atom->nmoltypesH ==1) MPI_Allreduce(&Comp_Density_Num_H[0][0],&Comp_Density_Num_all_H[0][0],Density_Bin_Num,MPI_INT,MPI_SUM,world); + MPI_Allreduce(&Comp_Density_Num_H[0][0],&Comp_Density_Num_all_H[0][0],Density_Bin_Num*(atom->nmoltypesH+1),MPI_INT,MPI_SUM,world); + + if(Hybrid_Style == 0)Density_Bin_Vol = 1.0*Density_Bin_Size * (x1hi-x1lo) * (x2hi-x2lo); + + for(int i = 0; i < Density_Bin_Num; i++){ + if(Hybrid_Style == 1)Density_Bin_Vol = (4.0/3.0) * MY_PI * (pow(((i+1) * Density_Bin_Size),3.0) - pow((i * Density_Bin_Size),3.0)); + if(Hybrid_Style == 2)Density_Bin_Vol = 4.0 * MY_PI * (x2hi-x2lo) * (pow(((i+1) * Density_Bin_Size),2.0) - pow((i * Density_Bin_Size),2.0)); + for(int j = 0; j < atom->nmoltypesH; j++){ + Mean_Density_H[i][j] = Comp_Density_Num_all_H[i][j] / (Density_Counter_H * Density_Bin_Vol); + } + } + + Density_Counter_H = 0; + + for(int k = 0; k < atom->nmoltypesH;k++){ + for(int i = 0;i < Density_Bin_Num; i++){ + Normalization = 0; + jmin = i - Density_Gauss_Int_Range*floor(Density_Sigma_Gauss / Density_Bin_Size); + jmax = i + Density_Gauss_Int_Range*floor(Density_Sigma_Gauss / Density_Bin_Size); + Mean_Comp_Density_Conv_H[i][k] = 0; + if(Hybrid_Style != 0){ + if(jmin<0)jmin=0; + if(jmax>=Density_Bin_Num)jmax=Density_Bin_Num-1; + } + + for(int j = jmin;j <= jmax; j++){ + jj = j; + if(Hybrid_Style == 0){ + if(j < 0)jj = Density_Bin_Num + j; + if(j >= Density_Bin_Num)jj = j - Density_Bin_Num; + } + exponent = (i-j)*Density_Bin_Size/Density_Sigma_Gauss; + exponent = pow(exponent,2.0); + Normalization += exp(-exponent)*Density_Bin_Size; + Mean_Comp_Density_Conv_H[i][k] += Mean_Density_H[jj][k] * exp(-exponent)*Density_Bin_Size; + // Mean_Comp_Density_Conv_H[i] += Mean_Density_H[j] * exp(-exponent); + } + Mean_Comp_Density_Conv_H[i][k] /= Normalization; + + } + } + + Density_Fluctuation = 0; + for(int k = 0; k < atom->nmoltypesH;k++)for(int i = 0;i < Density_Bin_Num; i++)Density_Fluctuation += (Density_Bin_Size/x0BoxSize)*pow((Mean_Density_H[i][k]-Density_Ref)/Density_Ref,2.0); + for(int k = 0; k < atom->nmoltypesH;k++) + for(int i = 1;i < Density_Bin_Num-1; i++) + grad_Comp_Density_Conv_H[i][k] = Comp_Density_Scaling_factor_H * (Mean_Comp_Density_Conv_H[i+1][k] - Mean_Comp_Density_Conv_H[i-1][k])/(2*Density_Bin_Size*Density_Ref); + + + //for(int i = 1;i < Density_Bin_Num-1; i++)Mean_grad_Comp_Density_Conv_H[i] = (Comp_Counter_H * Mean_grad_Comp_Density_Conv_H[i] + grad_Comp_Density_Conv_H[i]) / (Comp_Counter_H + 1); + for(int k = 0; k < atom->nmoltypesH;k++) + for(int i = 1;i < Density_Bin_Num-1; i++) + Mean_grad_Comp_Density_Conv_H[i][k] += grad_Comp_Density_Conv_H[i][k]; + +// for(int i = Middle_Bin_Num+1;i < Density_Bin_Num; i++)Comp_Density_Num_H[i] = Comp_Density_Num_H[Density_Bin_Num-1-i]; + + for(int k = 0; k < atom->nmoltypesH;k++) + for(int i = 0;i < Density_Bin_Num; i++) + Int_Mean_Density_H[i][k]=0; + + for(int k = 0; k < atom->nmoltypesH;k++) + for(int i = 0;i < Density_Bin_Num; i++) + for(int j = 0;j <= i; j++) + Int_Mean_Density_H[i][k] += Mean_grad_Comp_Density_Conv_H[j][k] * Density_Bin_Size; + + Comp_Counter_H += 1; + + for(int k = 0; k < atom->nmoltypesH;k++) + for(int i = 0;i < Density_Bin_Num; i++){ + Comp_Density_Num_H[i][k] = 0; + Comp_Density_Num_all_H[i][k] = 0; + } + + + } + + if(This_Step == Density_Update_Time_End && Density_Compensation_Run != 0){ + Density_Compensation_Run = 0; + if(me==0){ + if(screen)fprintf(screen,"\nEnd of constant-density route\n"); + if(logfile)fprintf(logfile,"\nEnd of constant-density route\n"); + } + } + + if (me == 0 && This_Step % Density_Update_Frequency == 0 && Density_Compensation_Run != 0) Print_Compensation_Density(); + +} + + +double FixLambdaHCalc::memory_usage() +{ + double bytes = (bigint) nmolecules * 2 * sizeof(double); + if (molmap_H) bytes += (idhi-idlo+1) * sizeof(int); + bytes += (bigint) nmolecules * 2*3 * sizeof(double); + bytes += (bigint) nmolecules * 2*3 * sizeof(double); + return bytes; +} + +/* ---------------------------------------------------------------------- */ + + +int FixLambdaHCalc::molecules_in_group(tagint &idlo, tagint &idhi) +{ + int i; + + memory->destroy(molmap_H); + molmap_H = NULL; + + // find lo/hi molecule ID for any atom in group + // warn if atom in group has ID = 0 + + tagint *molecule = atom->molecule; + int *mask = atom->mask; + int nlocal = atom->nlocal; + + tagint lo = BIG; + tagint hi = -BIG; + int flag = 0; + for (i = 0; i < nlocal; i++) + { + if (mask[i] & groupbit) { + if (molecule[i] == 0) flag = 1; + lo = MIN(lo,molecule[i]); + hi = MAX(hi,molecule[i]); + } + } + + int flagall; + MPI_Allreduce(&flag,&flagall,1,MPI_INT,MPI_SUM,world); + if (flagall && comm->me == 0) + error->warning(FLERR,"Atom with molecule ID = 0 included in " + "compute molecule group"); + + MPI_Allreduce(&lo,&idlo,1,MPI_LMP_TAGINT,MPI_MIN,world); + MPI_Allreduce(&hi,&idhi,1,MPI_LMP_TAGINT,MPI_MAX,world); + if (idlo == BIG) return 0; + + // molmap = vector of length nlen + // set to 1 for IDs that appear in group across all procs, else 0 + + tagint nlen_tag = idhi-idlo+1; + if (nlen_tag > MAXSMALLINT) + error->all(FLERR,"Too many molecules for compute"); + int nlen = (int) nlen_tag; + + memory->create(molmap_H,nlen,"lambdaH/calc:molmap"); + for (i = 0; i < nlen; i++) molmap_H[i] = 0; + + for (i = 0; i < nlocal; i++) + if (mask[i] & groupbit) + molmap_H[molecule[i]-idlo] = 1; + + int *molmapall; + memory->create(molmapall,nlen,"compute:molmapall"); + MPI_Allreduce(molmap_H,molmapall,nlen,MPI_INT,MPI_MAX,world); + + // nmolecules = # of non-zero IDs in molmap + // molmap[i] = index of molecule, skipping molecules not in group with -1 + + int nmolecules = 0; + for (i = 0; i < nlen; i++) + if (molmapall[i]) molmap_H[i] = nmolecules++; + else molmap_H[i] = -1; + memory->destroy(molmapall); + + // warn if any molecule has some atoms in group and some not in group + + flag = 0; + for (i = 0; i < nlocal; i++) { + if (mask[i] & groupbit) continue; + if (molecule[i] < idlo || molecule[i] > idhi) continue; + if (molmap_H[molecule[i]-idlo] >= 0) flag = 1; + } + + MPI_Allreduce(&flag,&flagall,1,MPI_INT,MPI_SUM,world); + if (flagall && comm->me == 0) + error->warning(FLERR, + "One or more compute molecules has atoms not in group"); + + // if molmap simply stores 1 to Nmolecules, then free it + + if (idlo == 1 && idhi == nmolecules && nlen == nmolecules) { + memory->destroy(molmap_H); + molmap_H = NULL; + } + return nmolecules; +} + + +void FixLambdaHCalc::Print_Compensation_Density(){ + + + FILE *fp1; + fp1 = fopen("Mean_Comp_Density.txt","w"); + + if (fp1 == NULL) { + char str[128]; + sprintf(str,"Cannot open fix Mean_Comp_Density file %s","Mean_Comp_Density.txt"); + error->one(FLERR,str); + } + + + for(int i = 0;i < Density_Bin_Num; i++){ + fprintf(fp1,"%d",i+1); + for(int k = 0; k < atom->nmoltypesH;k++) + fprintf(fp1,"\t%.10f",Mean_grad_Comp_Density_Conv_H[i][k]); + fprintf(fp1,"\n"); + } + fclose(fp1); + + /* + FILE *fp2; + + char filename2[1000]; + sprintf(filename2, "Mean_Comp_Density%4.1f_%d.txt", Comp_Density_Scaling_factor_H,Density_Update_Frequency); + + fp2 = fopen(filename2,"a"); + + if (fp2 == NULL) { + char str[128]; + sprintf(str,"Cannot open fix Mean_Comp_Density file %s","Mean_Comp_Density.txt"); + error->one(FLERR,str); + } + + printf("Density_Fluctuation = %f\n",Density_Fluctuation); + + double x0; + if(Hybrid_Style==0)x0=x0lo; + else x0=0; + + for(int i = 0;i < Density_Bin_Num; i++){ + fprintf(fp2,"%d\t %.10f\t",i+1,i*Density_Bin_Size+x0); + for(int k = 0; k < atom->nmoltypesH;k++) + fprintf(fp2,"\t%.10f\t %.10f\t %.10f\t %.10f",Mean_Comp_Density_Conv_H[i][k],grad_Comp_Density_Conv_H[i][k],Mean_grad_Comp_Density_Conv_H[i][k]); + fprintf(fp2,"\n"); + + } + fclose(fp2); + + + FILE *fp3; + char filename3[1000]; + sprintf(filename3, "Density_Fluctuation%4.1f_%d.txt", Comp_Density_Scaling_factor_H,Density_Update_Frequency); + + fp3 = fopen(filename3,"a"); + + if (fp3 == NULL) { + char str[128]; + sprintf(str,"Cannot open fix Density_Fluctuation file %s","Density_Fluctuation.txt"); + error->one(FLERR,str); + } + + int This_Step = update->ntimestep; + fprintf(fp3,"%d %.10f\n",This_Step,Density_Fluctuation); + + fclose(fp3); + +*/ +} + +void FixLambdaHCalc::Clear_File_Compensation_Density(){ + + FILE *fp1; + fp1 = fopen("Mean_Comp_Density.txt","w"); + + if (fp1 == NULL) { + char str[128]; + sprintf(str,"Cannot open fix Mean_Comp_Density file %s","Mean_Comp_Density.txt"); + error->one(FLERR,str); + } + + + fclose(fp1); + + /* + FILE *fp2; + + char filename2[1000]; + sprintf(filename2, "Mean_Comp_Density%4.1f_%d.txt", Comp_Density_Scaling_factor_H,Density_Update_Frequency); + + fp2 = fopen(filename2,"w"); + + if (fp2 == NULL) { + char str[128]; + sprintf(str,"Cannot open fix Mean_Comp_Density file %s","Mean_Comp_Density.txt"); + error->one(FLERR,str); + } + + + fclose(fp2); + + FILE *fp3; + char filename3[1000]; + sprintf(filename3, "Density_Fluctuation%4.1f_%d.txt", Comp_Density_Scaling_factor_H,Density_Update_Frequency); + + fp3 = fopen(filename3,"w"); + + if (fp3 == NULL) { + char str[128]; + sprintf(str,"Cannot open fix Density_Fluctuation file %s","Density_Fluctuation.txt"); + error->one(FLERR,str); + } + + fclose(fp3); + */ + +} + +void FixLambdaHCalc::Load_Compensation_Density(){ + + if(me == 0){ + FILE *fp1; + char str[128]; + + fp1 = fopen("Mean_Comp_Density.txt","r"); + if (fp1 == NULL) { + sprintf(str,"Cannot open fix Mean_Comp_Density.txt file %s","Mean_Comp_Density.txt"); + error->one(FLERR,str); + } + + int i1; + float i2; + + while (!feof(fp1)){ + fscanf (fp1,"%d",&i1); + for(int k = 0; k < atom->nmoltypesH;k++){ + fscanf (fp1,"\t%f",&i2); + Mean_grad_Comp_Density_Conv_H[i1-1][k] = (double) i2; + } + fscanf (fp1,"\n"); + + if(i1 > Density_Bin_Num){ + sprintf(str,"Density bin number mismatches %d != %d",Density_Bin_Num,i1); + error->one(FLERR,str); + } + + } + + fclose(fp1); + + + if(me==0){ + if(screen)fprintf(screen,"\n\nDensity componsation forces distributed successfully!\n\n"); + if(logfile)fprintf(logfile,"\n\nDensity componsation forces distributed successfully!\n\n"); + } + } + + MPI_Bcast(Mean_grad_Comp_Density_Conv_H,Density_Bin_Num*(atom->nmoltypesH+1),MPI_DOUBLE,0,world); + +} diff --git a/src/USER-HADRESS/fix_lambdah_calc.h b/src/USER-HADRESS/fix_lambdah_calc.h new file mode 100644 index 0000000000..d3552e17f2 --- /dev/null +++ b/src/USER-HADRESS/fix_lambdah_calc.h @@ -0,0 +1,102 @@ +/* -*- c++ -*- ---------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + http://lammps.sandia.gov, Sandia National Laboratories + Steve Plimpton, sjplimp@sandia.gov + + Copyright (2003) Sandia Corporation. Under the terms of Contract + DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains + certain rights in this software. This software is distributed under + the GNU General Public License. + + See the README file in the top-level LAMMPS directory. +------------------------------------------------------------------------- */ + +#ifdef FIX_CLASS + +FixStyle(lambdah/calc,FixLambdaHCalc) + +#else + +#ifndef LMP_FIX_LAMBDAH_CALC_H +#define LMP_FIX_LAMBDAH_CALC_H + +#include "fix.h" + +namespace LAMMPS_NS { + +class FixLambdaHCalc : public Fix { + public: + FixLambdaHCalc(class LAMMPS *, int, char **); + ~FixLambdaHCalc(); + int setmask(); + void init(); + void setup(int); + + void post_integrate(); + double memory_usage(); + + + double Length_Hyb,Length_ATRegion,Length_CGRegion; + int Hybrid_Style; + int Pressure_Comp_Flag,Pressure_Bin_Num,Pressure_Update_Frequency,Pressure_Update_Time_End, Pressure_Update_Time_Begin; + double Pressure_lambda_Increment; + int Density_Comp_Flag,Density_Compensation_Run,Density_Bin_Num,Density_Update_Frequency,Density_Update_Time_End,Density_Update_Time_Begin; + double Density_Bin_Size; + int Comp_Counter_H,Density_Counter_H; + double **Mean_grad_Comp_Density_Conv_H; + + double Density_Ref; + double center_box[3]; + int me; + double x0lo,x0hi,x1lo,x1hi,x2lo,x2hi,x0BoxSize; + double Density_Sigma_Gauss; + double Comp_Density_Scaling_factor_H; + int Density_Gauss_Int_Range; + + double xmin_AT,xmax_AT; + private: + int nmolecules; + tagint idlo,idhi; + double *massproc_H,*masstotal_H; + double **com_H,**comall_H; + double Density_Fluctuation; + int **Comp_Density_Num_H, **Comp_Density_Num_all_H; + double **Int_Mean_Density_H, **Mean_Density_H, **grad_Comp_Density_Conv_H, **Mean_Comp_Density_Conv_H; + int Load_File_Flag; + double R_Start_Hybrid_1,R_Start_Hybrid_2,S_Start_Hybrid,r,cosr,sinr,sinx,cosx; + double *lambdaCM, **gradlambdaCM; + int *molmap_H; // convert molecule ID to local index + + int molecules_in_group(tagint &, tagint &); + + void Print_Compensation_Density(); + void Load_Compensation_Density(); + void Clear_File_Compensation_Density(); +}; + +} + +#endif +#endif + +/* ERROR/WARNING messages: + +E: Illegal ... command + +Self-explanatory. Check the input script syntax and compare to the +documentation for the command. You can use -echo screen as a +command-line option when running LAMMPS to see the offending line. + +E: Variable name for fix indent does not exist + +Self-explanatory. + +E: Variable for fix indent is invalid style + +Only equal-style variables can be used. + +E: Variable for fix indent is not equal style + +Only equal-style variables can be used. + +*/ diff --git a/src/USER-HADRESS/molecule.cpp b/src/USER-HADRESS/molecule.cpp new file mode 100644 index 0000000000..89ca26d051 --- /dev/null +++ b/src/USER-HADRESS/molecule.cpp @@ -0,0 +1,1829 @@ +/* ---------------------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + http://lammps.sandia.gov, Sandia National Laboratories + Steve Plimpton, sjplimp@sandia.gov + + Copyright (2003) Sandia Corporation. Under the terms of Contract + DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains + certain rights in this software. This software is distributed under + the GNU General Public License. + + See the README file in the top-level LAMMPS directory. +------------------------------------------------------------------------- */ + +#include +#include +#include "molecule.h" +#include "atom.h" +#include "atom_vec.h" +#include "atom_vec_body.h" +#include "force.h" +#include "comm.h" +#include "domain.h" +#include "math_extra.h" +#include "math_const.h" +#include "memory.h" +#include "error.h" + +using namespace LAMMPS_NS; +using namespace MathConst; + +#define MAXLINE 256 +#define EPSILON 1.0e-7 +#define BIG 1.0e20 + +#define SINERTIA 0.4 // moment of inertia prefactor for sphere + +/* ---------------------------------------------------------------------- */ + +Molecule::Molecule(LAMMPS *lmp, int narg, char **arg, int &index) : + Pointers(lmp) +{ + me = comm->me; + + if (index >= narg) error->all(FLERR,"Illegal molecule command"); + + int n = strlen(arg[0]) + 1; + id = new char[n]; + strcpy(id,arg[0]); + + for (int i = 0; i < n-1; i++) + if (!isalnum(id[i]) && id[i] != '_') + error->all(FLERR,"Molecule template ID must be " + "alphanumeric or underscore characters"); + + // parse args until reach unknown arg (next file) + + toffset = 0; + boffset = aoffset = doffset = ioffset = 0; + sizescale = 1.0; + + int ifile = index; + int iarg = ifile+1; + + while (iarg < narg) { + if (strcmp(arg[iarg],"offset") == 0) { + if (iarg+6 > narg) error->all(FLERR,"Illegal molecule command"); + toffset = force->inumeric(FLERR,arg[iarg+1]); + boffset = force->inumeric(FLERR,arg[iarg+2]); + aoffset = force->inumeric(FLERR,arg[iarg+3]); + doffset = force->inumeric(FLERR,arg[iarg+4]); + ioffset = force->inumeric(FLERR,arg[iarg+5]); + if (toffset < 0 || boffset < 0 || aoffset < 0 || + doffset < 0 || ioffset < 0) + error->all(FLERR,"Illegal molecule command"); + iarg += 6; + } else if (strcmp(arg[iarg],"toff") == 0) { + if (iarg+2 > narg) error->all(FLERR,"Illegal molecule command"); + toffset = force->inumeric(FLERR,arg[iarg+1]); + if (toffset < 0) error->all(FLERR,"Illegal molecule command"); + iarg += 2; + } else if (strcmp(arg[iarg],"boff") == 0) { + if (iarg+2 > narg) error->all(FLERR,"Illegal molecule command"); + boffset = force->inumeric(FLERR,arg[iarg+1]); + if (boffset < 0) error->all(FLERR,"Illegal molecule command"); + iarg += 2; + } else if (strcmp(arg[iarg],"aoff") == 0) { + if (iarg+2 > narg) error->all(FLERR,"Illegal molecule command"); + aoffset = force->inumeric(FLERR,arg[iarg+1]); + if (aoffset < 0) error->all(FLERR,"Illegal molecule command"); + iarg += 2; + } else if (strcmp(arg[iarg],"doff") == 0) { + if (iarg+2 > narg) error->all(FLERR,"Illegal molecule command"); + doffset = force->inumeric(FLERR,arg[iarg+1]); + if (doffset < 0) error->all(FLERR,"Illegal molecule command"); + iarg += 2; + } else if (strcmp(arg[iarg],"ioff") == 0) { + if (iarg+2 > narg) error->all(FLERR,"Illegal molecule command"); + ioffset = force->inumeric(FLERR,arg[iarg+1]); + if (ioffset < 0) error->all(FLERR,"Illegal molecule command"); + iarg += 2; + } else if (strcmp(arg[iarg],"scale") == 0) { + if (iarg+2 > narg) error->all(FLERR,"Illegal molecule command"); + sizescale = force->numeric(FLERR,arg[iarg+1]); + if (sizescale <= 0.0) error->all(FLERR,"Illegal molecule command"); + iarg += 2; + } else break; + } + + index = iarg; + + // last molecule if have scanned all args + + if (iarg == narg) last = 1; + else last = 0; + + // initialize all fields to empty + + initialize(); + + // scan file for sizes of all fields and allocate them + + if (me == 0) open(arg[ifile]); + read(0); + if (me == 0) fclose(fp); + allocate(); + + // read file again to populate all fields + + if (me == 0) open(arg[ifile]); + read(1); + if (me == 0) fclose(fp); + + // stats + + if (me == 0) { + if (screen) + fprintf(screen,"Read molecule %s:\n" + " %d atoms with %d types\n %d bonds with %d types\n" + " %d angles with %d types\n %d dihedrals with %d types\n" + " %d impropers with %d types\n", + id,natoms,ntypes, + nbonds,nbondtypes,nangles,nangletypes, + ndihedrals,ndihedraltypes,nimpropers,nimpropertypes); + if (logfile) + fprintf(logfile,"Read molecule %s:\n" + " %d atoms with %d types\n %d bonds with %d types\n" + " %d angles with %d types\n %d dihedrals with %d types\n" + " %d impropers with %d types\n", + id,natoms,ntypes, + nbonds,nbondtypes,nangles,nangletypes, + ndihedrals,ndihedraltypes,nimpropers,nimpropertypes); + } +} + +/* ---------------------------------------------------------------------- */ + +Molecule::~Molecule() +{ + delete [] id; + deallocate(); +} + +/* ---------------------------------------------------------------------- + compute center = geometric center of molecule + also compute: + dx = displacement of each atom from center + molradius = radius of molecule from center + including finite-size particles or body particles +------------------------------------------------------------------------- */ + +void Molecule::compute_center() +{ + if (centerflag) return; + centerflag = 1; + + center[0] = center[1] = center[2] = 0.0; + for (int i = 0; i < natoms; i++) { + center[0] += x[i][0]; + center[1] += x[i][1]; + center[2] += x[i][2]; + } + center[0] /= natoms; + center[1] /= natoms; + center[2] /= natoms; + + memory->destroy(dx); + memory->create(dx,natoms,3,"molecule:dx"); + + for (int i = 0; i < natoms; i++) { + dx[i][0] = x[i][0] - center[0]; + dx[i][1] = x[i][1] - center[1]; + dx[i][2] = x[i][2] - center[2]; + } + + molradius = 0.0; + for (int i = 0; i < natoms; i++) { + double rad = MathExtra::len3(dx[i]); + if (radiusflag) rad += radius[i]; + molradius = MAX(molradius,rad); + } +} + +/* ---------------------------------------------------------------------- + compute masstotal = total mass of molecule + could have been set by user, otherwise calculate it +------------------------------------------------------------------------- */ + +void Molecule::compute_mass() +{ + if (massflag) return; + massflag = 1; + + if (!rmassflag) atom->check_mass(); + + masstotal = 0.0; + for (int i = 0; i < natoms; i++) { + if (rmassflag) masstotal += rmass[i]; + else masstotal += atom->mass[type[i]]; + } +} + +/* ---------------------------------------------------------------------- + compute com = center of mass of molecule + could have been set by user, otherwise calculate it + works for finite size particles assuming no overlap + also compute: + dxcom = displacement of each atom from COM + comatom = which atom (1-Natom) is nearest the COM + maxextent = furthest any atom in molecule is from comatom (not COM) +------------------------------------------------------------------------- */ + +void Molecule::compute_com() +{ + if (!comflag) { + comflag = 1; + + if (!rmassflag) atom->check_mass(); + + double onemass; + com[0] = com[1] = com[2] = 0.0; + for (int i = 0; i < natoms; i++) { + if (rmassflag) onemass = rmass[i]; + else onemass = atom->mass[type[i]]; + com[0] += x[i][0]*onemass; + com[1] += x[i][1]*onemass; + com[2] += x[i][2]*onemass; + } + com[0] /= masstotal; + com[1] /= masstotal; + com[2] /= masstotal; + } + + memory->destroy(dxcom); + memory->create(dxcom,natoms,3,"molecule:dxcom"); + + for (int i = 0; i < natoms; i++) { + dxcom[i][0] = x[i][0] - com[0]; + dxcom[i][1] = x[i][1] - com[1]; + dxcom[i][2] = x[i][2] - com[2]; + } + + double rsqmin = BIG; + for (int i = 0; i < natoms; i++) { + double rsq = MathExtra::lensq3(dxcom[i]); + if (rsq < rsqmin) { + comatom = i; + rsqmin = rsq; + } + } + + double rsqmax = 0.0; + for (int i = 0; i < natoms; i++) { + double dx = x[comatom][0] - x[i][0]; + double dy = x[comatom][1] - x[i][1]; + double dz = x[comatom][2] - x[i][2]; + double rsq = dx*dx + dy*dy + dz*dz; + rsqmax = MAX(rsqmax,rsq); + } + + comatom++; + maxextent = sqrt(rsqmax); +} + +/* ---------------------------------------------------------------------- + compute itensor = 6 moments of inertia of molecule around xyz axes + could have been set by user, otherwise calculate it + accounts for finite size spheres, assuming no overlap + also compute: + inertia = 3 principal components of inertia + ex,ey,ez = principal axes in space coords + quat = quaternion for orientation of molecule + dxbody = displacement of each atom from COM in body frame +------------------------------------------------------------------------- */ + +void Molecule::compute_inertia() +{ + if (!inertiaflag) { + inertiaflag = 1; + + if (!rmassflag) atom->check_mass(); + + double onemass,dx,dy,dz; + for (int i = 0; i < 6; i++) itensor[i] = 0.0; + for (int i = 0; i < natoms; i++) { + if (rmassflag) onemass = rmass[i]; + else onemass = atom->type[type[i]]; + dx = dxcom[i][0]; + dy = dxcom[i][1]; + dz = dxcom[i][2]; + itensor[0] += onemass * (dy*dy + dz*dz); + itensor[1] += onemass * (dx*dx + dz*dz); + itensor[2] += onemass * (dx*dx + dy*dy); + itensor[3] -= onemass * dy*dz; + itensor[4] -= onemass * dx*dz; + itensor[5] -= onemass * dx*dy; + } + + if (radiusflag) { + for (int i = 0; i < natoms; i++) { + if (rmassflag) onemass = rmass[i]; + else onemass = atom->type[type[i]]; + itensor[0] += SINERTIA*onemass * radius[i]*radius[i]; + itensor[1] += SINERTIA*onemass * radius[i]*radius[i]; + itensor[2] += SINERTIA*onemass * radius[i]*radius[i]; + } + } + } + + // diagonalize inertia tensor for each body via Jacobi rotations + // inertia = 3 eigenvalues = principal moments of inertia + // evectors and exzy = 3 evectors = principal axes of rigid body + + double cross[3]; + double tensor[3][3],evectors[3][3]; + + tensor[0][0] = itensor[0]; + tensor[1][1] = itensor[1]; + tensor[2][2] = itensor[2]; + tensor[1][2] = tensor[2][1] = itensor[3]; + tensor[0][2] = tensor[2][0] = itensor[4]; + tensor[0][1] = tensor[1][0] = itensor[5]; + + if (MathExtra::jacobi(tensor,inertia,evectors)) + error->all(FLERR,"Insufficient Jacobi rotations for rigid molecule"); + + ex[0] = evectors[0][0]; + ex[1] = evectors[1][0]; + ex[2] = evectors[2][0]; + ey[0] = evectors[0][1]; + ey[1] = evectors[1][1]; + ey[2] = evectors[2][1]; + ez[0] = evectors[0][2]; + ez[1] = evectors[1][2]; + ez[2] = evectors[2][2]; + + // if any principal moment < scaled EPSILON, set to 0.0 + + double max; + max = MAX(inertia[0],inertia[1]); + max = MAX(max,inertia[2]); + + if (inertia[0] < EPSILON*max) inertia[0] = 0.0; + if (inertia[1] < EPSILON*max) inertia[1] = 0.0; + if (inertia[2] < EPSILON*max) inertia[2] = 0.0; + + // enforce 3 evectors as a right-handed coordinate system + // flip 3rd vector if needed + + MathExtra::cross3(ex,ey,cross); + if (MathExtra::dot3(cross,ez) < 0.0) MathExtra::negate3(ez); + + // create quaternion + + MathExtra::exyz_to_q(ex,ey,ez,quat); + + // compute displacements in body frame defined by quat + + memory->destroy(dxbody); + memory->create(dxbody,natoms,3,"molecule:dxbody"); + + for (int i = 0; i < natoms; i++) + MathExtra::transpose_matvec(ex,ey,ez,dxcom[i],dxbody[i]); +} + +/* ---------------------------------------------------------------------- + read molecule info from file + flag = 0, just scan for sizes of fields + flag = 1, read and store fields +------------------------------------------------------------------------- */ + +void Molecule::read(int flag) +{ + char line[MAXLINE],keyword[MAXLINE]; + char *eof,*ptr; + + // skip 1st line of file + + if (me == 0) { + eof = fgets(line,MAXLINE,fp); + if (eof == NULL) error->one(FLERR,"Unexpected end of molecule file"); + } + + // read header lines + // skip blank lines or lines that start with "#" + // stop when read an unrecognized line + + while (1) { + + readline(line); + + // trim anything from '#' onward + // if line is blank, continue + + if ((ptr = strchr(line,'#'))) *ptr = '\0'; + if (strspn(line," \t\n\r") == strlen(line)) continue; + + // search line for header keywords and set corresponding variable + + if (strstr(line,"atoms")) sscanf(line,"%d",&natoms); + else if (strstr(line,"bonds")) sscanf(line,"%d",&nbonds); + else if (strstr(line,"angles")) sscanf(line,"%d",&nangles); + else if (strstr(line,"dihedrals")) sscanf(line,"%d",&ndihedrals); + else if (strstr(line,"impropers")) sscanf(line,"%d",&nimpropers); + + else if (strstr(line,"mass")) { + massflag = 1; + sscanf(line,"%lg",&masstotal); + masstotal *= sizescale*sizescale*sizescale; + } + else if (strstr(line,"com")) { + comflag = 1; + sscanf(line,"%lg %lg %lg",&com[0],&com[1],&com[2]); + com[0] *= sizescale; + com[1] *= sizescale; + com[2] *= sizescale; + if (domain->dimension == 2 && com[2] != 0.0) + error->all(FLERR,"Molecule file z center-of-mass must be 0.0 for 2d"); + } + else if (strstr(line,"inertia")) { + inertiaflag = 1; + sscanf(line,"%lg %lg %lg %lg %lg %lg", + &itensor[0],&itensor[1],&itensor[2], + &itensor[3],&itensor[4],&itensor[5]); + itensor[0] *= sizescale*sizescale*sizescale*sizescale*sizescale; + itensor[1] *= sizescale*sizescale*sizescale*sizescale*sizescale; + itensor[2] *= sizescale*sizescale*sizescale*sizescale*sizescale; + itensor[3] *= sizescale*sizescale*sizescale*sizescale*sizescale; + itensor[4] *= sizescale*sizescale*sizescale*sizescale*sizescale; + itensor[5] *= sizescale*sizescale*sizescale*sizescale*sizescale; + } + else if (strstr(line,"body")) { + bodyflag = 1; + avec_body = (AtomVecBody *) atom->style_match("body"); + if (!avec_body) + error->all(FLERR,"Molecule file requires atom style body"); + sscanf(line,"%d %d",&nibody,&ndbody); + } + + else break; + } + + // error checks + + if (natoms < 1) error->all(FLERR,"No count or invalid atom count in molecule file"); + if (nbonds < 0) error->all(FLERR,"Invalid bond count in molecule file"); + if (nangles < 0) error->all(FLERR,"Invalid angle count in molecule file"); + if (ndihedrals < 0) + error->all(FLERR,"Invalid dihedral count in molecule file"); + if (nimpropers < 0) + error->all(FLERR,"Invalid improper count in molecule file"); + + // count = vector for tallying bonds,angles,etc per atom + + if (flag == 0) memory->create(count,natoms,"molecule:count"); + else count = NULL; + + // grab keyword and skip next line + + parse_keyword(0,line,keyword); + readline(line); + + // loop over sections of molecule file + + while (strlen(keyword)) { + if (strcmp(keyword,"Coords") == 0) { + xflag = 1; + if (flag) coords(line); + else skip_lines(natoms,line); + } else if (strcmp(keyword,"Types") == 0) { + typeflag = 1; + if (flag) types(line); + else skip_lines(natoms,line); + } else if (strcmp(keyword,"Charges") == 0) { + qflag = 1; + if (flag) charges(line); + else skip_lines(natoms,line); + } else if (strcmp(keyword,"Diameters") == 0) { + radiusflag = 1; + if (flag) diameters(line); + else skip_lines(natoms,line); + } else if (strcmp(keyword,"Masses") == 0) { + rmassflag = 1; + if (flag) masses(line); + else skip_lines(natoms,line); + + } else if (strcmp(keyword,"replambdaH") == 0) { + replambdaHflag = 1; + if (flag) representative_atom(line); + else skip_lines(natoms,line); + } else if (strcmp(keyword,"moltypeH") == 0) { + moltypeHflag = 1; + if (flag) moltype_atom(line); + else skip_lines(natoms,line); + + } else if (strcmp(keyword,"Bonds") == 0) { + if (nbonds == 0) + error->all(FLERR,"Molecule file has bonds but no nbonds setting"); + bondflag = tag_require = 1; + bonds(flag,line); + } else if (strcmp(keyword,"Angles") == 0) { + if (nangles == 0) + error->all(FLERR,"Molecule file has angles but no nangles setting"); + angleflag = tag_require = 1; + angles(flag,line); + } else if (strcmp(keyword,"Dihedrals") == 0) { + if (ndihedrals == 0) error->all(FLERR,"Molecule file has dihedrals " + "but no ndihedrals setting"); + dihedralflag = tag_require = 1; + dihedrals(flag,line); + } else if (strcmp(keyword,"Impropers") == 0) { + if (nimpropers == 0) error->all(FLERR,"Molecule file has impropers " + "but no nimpropers setting"); + improperflag = tag_require = 1; + impropers(flag,line); + + } else if (strcmp(keyword,"Special Bond Counts") == 0) { + nspecialflag = 1; + nspecial_read(flag,line); + } else if (strcmp(keyword,"Special Bonds") == 0) { + specialflag = tag_require = 1; + if (flag) special_read(line); + else skip_lines(natoms,line); + + } else if (strcmp(keyword,"Shake Flags") == 0) { + shakeflagflag = 1; + if (flag) shakeflag_read(line); + else skip_lines(natoms,line); + } else if (strcmp(keyword,"Shake Atoms") == 0) { + shakeatomflag = tag_require = 1; + if (shaketypeflag) shakeflag = 1; + if (!shakeflagflag) + error->all(FLERR,"Molecule file shake flags not before shake atoms"); + if (flag) shakeatom_read(line); + else skip_lines(natoms,line); + } else if (strcmp(keyword,"Shake Bond Types") == 0) { + shaketypeflag = 1; + if (shakeatomflag) shakeflag = 1; + if (!shakeflagflag) + error->all(FLERR,"Molecule file shake flags not before shake bonds"); + if (flag) shaketype_read(line); + else skip_lines(natoms,line); + + } else if (strcmp(keyword,"Body Integers") == 0) { + if (bodyflag == 0 || nibody == 0) + error->all(FLERR,"Molecule file has body params " + "but no setting for them"); + ibodyflag = 1; + body(flag,0,line); + } else if (strcmp(keyword,"Body Doubles") == 0) { + if (bodyflag == 0 || ndbody == 0) + error->all(FLERR,"Molecule file has body params " + "but no setting for them"); + dbodyflag = 1; + body(flag,1,line); + + } else error->one(FLERR,"Unknown section in molecule file"); + + parse_keyword(1,line,keyword); + } + + // clean up + + memory->destroy(count); + + // error check + + if (flag == 0) { + if ((nspecialflag && !specialflag) || (!nspecialflag && specialflag)) + error->all(FLERR,"Molecule file needs both Special Bond sections"); + if (specialflag && !bondflag) + error->all(FLERR,"Molecule file has special flags but no bonds"); + if ((shakeflagflag || shakeatomflag || shaketypeflag) && !shakeflag) + error->all(FLERR,"Molecule file shake info is incomplete"); + if (bodyflag && nibody && ibodyflag == 0) + error->all(FLERR,"Molecule file has no Body Integers section"); + if (bodyflag && ndbody && dbodyflag == 0) + error->all(FLERR,"Molecule file has no Body Doubles section"); + } + + // auto-generate special bonds + + if (bondflag && !specialflag) { + specialflag = 1; + nspecialflag = 1; + maxspecial = atom->maxspecial; + if (flag) special_generate(); + } + + // body particle must have natom = 1 + // set radius by having body class compute its own radius + + if (bodyflag) { + radiusflag = 1; + if (natoms != 1) + error->all(FLERR,"Molecule natoms must be 1 for body particle"); + if (sizescale != 1.0) + error->all(FLERR,"Molecule sizescale must be 1.0 for body particle"); + if (flag) { + radius[0] = avec_body->radius_body(nibody,ndbody,ibodyparams,dbodyparams); + maxradius = radius[0]; + } + } +} + +/* ---------------------------------------------------------------------- + read coords from file +------------------------------------------------------------------------- */ + +void Molecule::coords(char *line) +{ + int tmp; + for (int i = 0; i < natoms; i++) { + readline(line); + if (i == 0) { + int nwords = atom->count_words(line); + if (nwords != 4) + error->all(FLERR,"Invalid Coords section in molecule file"); + } + sscanf(line,"%d %lg %lg %lg",&tmp,&x[i][0],&x[i][1],&x[i][2]); + x[i][0] *= sizescale; + x[i][1] *= sizescale; + x[i][2] *= sizescale; + } + + if (domain->dimension == 2) { + for (int i = 0; i < natoms; i++) + if (x[i][2] != 0.0) + error->all(FLERR,"Molecule file z coord must be 0.0 for 2d"); + } +} + +/* ---------------------------------------------------------------------- + read types from file + set ntypes = max of any atom type +------------------------------------------------------------------------- */ + +void Molecule::types(char *line) +{ + int tmp; + for (int i = 0; i < natoms; i++) { + readline(line); + if (i == 0) { + int nwords = atom->count_words(line); + if (nwords != 2) + error->all(FLERR,"Invalid Types section in molecule file"); + } + sscanf(line,"%d %d",&tmp,&type[i]); + type[i] += toffset; + } + + for (int i = 0; i < natoms; i++) + if (type[i] <= 0) + error->all(FLERR,"Invalid atom type in molecule file"); + + for (int i = 0; i < natoms; i++) + ntypes = MAX(ntypes,type[i]); +} + +/* ---------------------------------------------------------------------- + read charges from file +------------------------------------------------------------------------- */ + +void Molecule::charges(char *line) +{ + int tmp; + for (int i = 0; i < natoms; i++) { + readline(line); + if (i == 0) { + int nwords = atom->count_words(line); + if (nwords != 2) + error->all(FLERR,"Invalid Charges section in molecule file"); + } + sscanf(line,"%d %lg",&tmp,&q[i]); + } +} + +void Molecule::representative_atom(char *line) +{ + int tmp; + for (int i = 0; i < natoms; i++) { + readline(line); + sscanf(line,"%d %d",&tmp,&replambdaH[i]); + printf("i=%d rep = %d",i,replambdaH[i]); + } +} + +void Molecule::moltype_atom(char *line) +{ + int tmp; + for (int i = 0; i < natoms; i++) { + readline(line); + sscanf(line,"%d %d",&tmp,&moltypeH[i]); + printf("i=%d rep = %d",i,moltypeH[i]); + } +} + +/* ---------------------------------------------------------------------- + read diameters from file and set radii +------------------------------------------------------------------------- */ + +void Molecule::diameters(char *line) +{ + int tmp; + maxradius = 0.0; + for (int i = 0; i < natoms; i++) { + readline(line); + if (i == 0) { + int nwords = atom->count_words(line); + if (nwords != 2) + error->all(FLERR,"Invalid Diameters section in molecule file"); + } + sscanf(line,"%d %lg",&tmp,&radius[i]); + radius[i] *= sizescale; + radius[i] *= 0.5; + maxradius = MAX(maxradius,radius[i]); + } + + for (int i = 0; i < natoms; i++) + if (radius[i] < 0.0) + error->all(FLERR,"Invalid atom diameter in molecule file"); +} + +/* ---------------------------------------------------------------------- + read masses from file +------------------------------------------------------------------------- */ + +void Molecule::masses(char *line) +{ + int tmp; + for (int i = 0; i < natoms; i++) { + readline(line); + if (i == 0) { + int nwords = atom->count_words(line); + if (nwords != 2) + error->all(FLERR,"Invalid Masses section in molecule file"); + } + sscanf(line,"%d %lg",&tmp,&rmass[i]); + rmass[i] *= sizescale*sizescale*sizescale; + } + + for (int i = 0; i < natoms; i++) + if (rmass[i] <= 0.0) error->all(FLERR,"Invalid atom mass in molecule file"); +} + +/* ---------------------------------------------------------------------- + read bonds from file + set nbondtypes = max type of any bond + store each with both atoms if newton_bond = 0 + if flag = 0, just count bonds/atom + if flag = 1, store them with atoms +------------------------------------------------------------------------- */ + +void Molecule::bonds(int flag, char *line) +{ + int tmp,itype; + tagint m,atom1,atom2; + int newton_bond = force->newton_bond; + + if (flag == 0) + for (int i = 0; i < natoms; i++) count[i] = 0; + else + for (int i = 0; i < natoms; i++) num_bond[i] = 0; + + for (int i = 0; i < nbonds; i++) { + readline(line); + if (i == 0) { + int nwords = atom->count_words(line); + if (nwords != 4) + error->all(FLERR,"Invalid Bonds section in molecule file"); + } + sscanf(line,"%d %d " TAGINT_FORMAT " " TAGINT_FORMAT, + &tmp,&itype,&atom1,&atom2); + itype += boffset; + + if (atom1 <= 0 || atom1 > natoms || + atom2 <= 0 || atom2 > natoms) + error->one(FLERR,"Invalid atom ID in Bonds section of molecule file"); + if (itype <= 0) + error->one(FLERR,"Invalid bond type in Bonds section of molecule file"); + + if (flag) { + m = atom1-1; + nbondtypes = MAX(nbondtypes,itype); + bond_type[m][num_bond[m]] = itype; + bond_atom[m][num_bond[m]] = atom2; + num_bond[m]++; + if (newton_bond == 0) { + m = atom2-1; + bond_type[m][num_bond[m]] = itype; + bond_atom[m][num_bond[m]] = atom1; + num_bond[m]++; + } + } else { + count[atom1-1]++; + if (newton_bond == 0) count[atom2-1]++; + } + } + + // bond_per_atom = max of count vector + + if (flag == 0) { + bond_per_atom = 0; + for (int i = 0; i < natoms; i++) + bond_per_atom = MAX(bond_per_atom,count[i]); + } +} + +/* ---------------------------------------------------------------------- + read angles from file + store each with all 3 atoms if newton_bond = 0 + if flag = 0, just count angles/atom + if flag = 1, store them with atoms +------------------------------------------------------------------------- */ + +void Molecule::angles(int flag, char *line) +{ + int tmp,itype; + tagint m,atom1,atom2,atom3; + int newton_bond = force->newton_bond; + + if (flag == 0) + for (int i = 0; i < natoms; i++) count[i] = 0; + else + for (int i = 0; i < natoms; i++) num_angle[i] = 0; + + for (int i = 0; i < nangles; i++) { + readline(line); + if (i == 0) { + int nwords = atom->count_words(line); + if (nwords != 5) + error->all(FLERR,"Invalid Angles section in molecule file"); + } + sscanf(line,"%d %d " TAGINT_FORMAT " " TAGINT_FORMAT " " TAGINT_FORMAT, + &tmp,&itype,&atom1,&atom2,&atom3); + itype += aoffset; + + if (atom1 <= 0 || atom1 > natoms || + atom2 <= 0 || atom2 > natoms || + atom3 <= 0 || atom3 > natoms) + error->one(FLERR,"Invalid atom ID in Angles section of molecule file"); + if (itype <= 0) + error->one(FLERR,"Invalid angle type in Angles section of molecule file"); + + if (flag) { + m = atom2-1; + nangletypes = MAX(nangletypes,itype); + angle_type[m][num_angle[m]] = itype; + angle_atom1[m][num_angle[m]] = atom1; + angle_atom2[m][num_angle[m]] = atom2; + angle_atom3[m][num_angle[m]] = atom3; + num_angle[m]++; + if (newton_bond == 0) { + m = atom1-1; + angle_type[m][num_angle[m]] = itype; + angle_atom1[m][num_angle[m]] = atom1; + angle_atom2[m][num_angle[m]] = atom2; + angle_atom3[m][num_angle[m]] = atom3; + num_angle[m]++; + m = atom3-1; + angle_type[m][num_angle[m]] = itype; + angle_atom1[m][num_angle[m]] = atom1; + angle_atom2[m][num_angle[m]] = atom2; + angle_atom3[m][num_angle[m]] = atom3; + num_angle[m]++; + } + } else { + count[atom2-1]++; + if (newton_bond == 0) { + count[atom1-1]++; + count[atom3-1]++; + } + } + } + + // angle_per_atom = max of count vector + + if (flag == 0) { + angle_per_atom = 0; + for (int i = 0; i < natoms; i++) + angle_per_atom = MAX(angle_per_atom,count[i]); + } +} + +/* ---------------------------------------------------------------------- + read dihedrals from file + store each with all 4 atoms if newton_bond = 0 + if flag = 0, just count dihedrals/atom + if flag = 1, store them with atoms +------------------------------------------------------------------------- */ + +void Molecule::dihedrals(int flag, char *line) +{ + int tmp,itype; + tagint m,atom1,atom2,atom3,atom4; + int newton_bond = force->newton_bond; + + if (flag == 0) + for (int i = 0; i < natoms; i++) count[i] = 0; + else + for (int i = 0; i < natoms; i++) num_dihedral[i] = 0; + + for (int i = 0; i < ndihedrals; i++) { + readline(line); + if (i == 0) { + int nwords = atom->count_words(line); + if (nwords != 6) + error->all(FLERR,"Invalid Dihedrals section in molecule file"); + } + sscanf(line,"%d %d " TAGINT_FORMAT " " TAGINT_FORMAT " " + TAGINT_FORMAT " " TAGINT_FORMAT " ", + &tmp,&itype,&atom1,&atom2,&atom3,&atom4); + itype += doffset; + + if (atom1 <= 0 || atom1 > natoms || + atom2 <= 0 || atom2 > natoms || + atom3 <= 0 || atom3 > natoms || + atom4 <= 0 || atom4 > natoms) + error->one(FLERR, + "Invalid atom ID in dihedrals section of molecule file"); + if (itype <= 0) + error->one(FLERR, + "Invalid dihedral type in dihedrals section of molecule file"); + + if (flag) { + m = atom2-1; + ndihedraltypes = MAX(ndihedraltypes,itype); + dihedral_type[m][num_dihedral[m]] = itype; + dihedral_atom1[m][num_dihedral[m]] = atom1; + dihedral_atom2[m][num_dihedral[m]] = atom2; + dihedral_atom3[m][num_dihedral[m]] = atom3; + dihedral_atom4[m][num_dihedral[m]] = atom4; + num_dihedral[m]++; + if (newton_bond == 0) { + m = atom1-1; + dihedral_type[m][num_dihedral[m]] = itype; + dihedral_atom1[m][num_dihedral[m]] = atom1; + dihedral_atom2[m][num_dihedral[m]] = atom2; + dihedral_atom3[m][num_dihedral[m]] = atom3; + dihedral_atom4[m][num_dihedral[m]] = atom4; + num_dihedral[m]++; + m = atom3-1; + dihedral_type[m][num_dihedral[m]] = itype; + dihedral_atom1[m][num_dihedral[m]] = atom1; + dihedral_atom2[m][num_dihedral[m]] = atom2; + dihedral_atom3[m][num_dihedral[m]] = atom3; + dihedral_atom4[m][num_dihedral[m]] = atom4; + num_dihedral[m]++; + m = atom4-1; + dihedral_type[m][num_dihedral[m]] = itype; + dihedral_atom1[m][num_dihedral[m]] = atom1; + dihedral_atom2[m][num_dihedral[m]] = atom2; + dihedral_atom3[m][num_dihedral[m]] = atom3; + dihedral_atom4[m][num_dihedral[m]] = atom4; + num_dihedral[m]++; + } + } else { + count[atom2-1]++; + if (newton_bond == 0) { + count[atom1-1]++; + count[atom3-1]++; + count[atom4-1]++; + } + } + } + + // dihedral_per_atom = max of count vector + + if (flag == 0) { + dihedral_per_atom = 0; + for (int i = 0; i < natoms; i++) + dihedral_per_atom = MAX(dihedral_per_atom,count[i]); + } +} + +/* ---------------------------------------------------------------------- + read impropers from file + store each with all 4 atoms if newton_bond = 0 + if flag = 0, just count impropers/atom + if flag = 1, store them with atoms +------------------------------------------------------------------------- */ + +void Molecule::impropers(int flag, char *line) +{ + int tmp,itype; + tagint m,atom1,atom2,atom3,atom4; + int newton_bond = force->newton_bond; + + if (flag == 0) + for (int i = 0; i < natoms; i++) count[i] = 0; + else + for (int i = 0; i < natoms; i++) num_improper[i] = 0; + + for (int i = 0; i < nimpropers; i++) { + readline(line); + if (i == 0) { + int nwords = atom->count_words(line); + if (nwords != 6) + error->all(FLERR,"Invalid Impropers section in molecule file"); + } + sscanf(line,"%d %d " TAGINT_FORMAT " " TAGINT_FORMAT " " + TAGINT_FORMAT " " TAGINT_FORMAT " ", + &tmp,&itype,&atom1,&atom2,&atom3,&atom4); + itype += ioffset; + + if (atom1 <= 0 || atom1 > natoms || + atom2 <= 0 || atom2 > natoms || + atom3 <= 0 || atom3 > natoms || + atom4 <= 0 || atom4 > natoms) + error->one(FLERR, + "Invalid atom ID in impropers section of molecule file"); + if (itype <= 0) + error->one(FLERR, + "Invalid improper type in impropers section of molecule file"); + + if (flag) { + m = atom2-1; + nimpropertypes = MAX(nimpropertypes,itype); + improper_type[m][num_improper[m]] = itype; + improper_atom1[m][num_improper[m]] = atom1; + improper_atom2[m][num_improper[m]] = atom2; + improper_atom3[m][num_improper[m]] = atom3; + improper_atom4[m][num_improper[m]] = atom4; + num_improper[m]++; + if (newton_bond == 0) { + m = atom1-1; + improper_type[m][num_improper[m]] = itype; + improper_atom1[m][num_improper[m]] = atom1; + improper_atom2[m][num_improper[m]] = atom2; + improper_atom3[m][num_improper[m]] = atom3; + improper_atom4[m][num_improper[m]] = atom4; + num_improper[m]++; + m = atom3-1; + improper_type[m][num_improper[m]] = itype; + improper_atom1[m][num_improper[m]] = atom1; + improper_atom2[m][num_improper[m]] = atom2; + improper_atom3[m][num_improper[m]] = atom3; + improper_atom4[m][num_improper[m]] = atom4; + num_improper[m]++; + m = atom4-1; + improper_type[m][num_improper[m]] = itype; + improper_atom1[m][num_improper[m]] = atom1; + improper_atom2[m][num_improper[m]] = atom2; + improper_atom3[m][num_improper[m]] = atom3; + improper_atom4[m][num_improper[m]] = atom4; + num_improper[m]++; + } + } else { + count[atom2-1]++; + if (newton_bond == 0) { + count[atom1-1]++; + count[atom3-1]++; + count[atom4-1]++; + } + } + } + + // improper_per_atom = max of count vector + + if (flag == 0) { + improper_per_atom = 0; + for (int i = 0; i < natoms; i++) + improper_per_atom = MAX(improper_per_atom,count[i]); + } +} + +/* ---------------------------------------------------------------------- + read 3 special bonds counts from file + if flag = 0, just tally maxspecial + if flag = 1, store them with atoms +------------------------------------------------------------------------- */ + +void Molecule::nspecial_read(int flag, char *line) +{ + int tmp,c1,c2,c3; + + if (flag == 0) maxspecial = 0; + + for (int i = 0; i < natoms; i++) { + readline(line); + if (i == 0) { + int nwords = atom->count_words(line); + if (nwords != 4) + error->all(FLERR,"Invalid Special Bond Counts section in " + "molecule file"); + } + sscanf(line,"%d %d %d %d",&tmp,&c1,&c2,&c3); + + if (flag) { + nspecial[i][0] = c1; + nspecial[i][1] = c1+c2; + nspecial[i][2] = c1+c2+c3; + } else maxspecial = MAX(maxspecial,c1+c2+c3); + } +} + +/* ---------------------------------------------------------------------- + read special bond indices from file +------------------------------------------------------------------------- */ + +void Molecule::special_read(char *line) +{ + int m,nwords; + char **words = new char*[maxspecial+1]; + + for (int i = 0; i < natoms; i++) { + readline(line); + nwords = parse(line,words,maxspecial+1); + if (nwords != nspecial[i][2]+1) + error->all(FLERR,"Molecule file special list " + "does not match special count"); + + for (m = 1; m < nwords; m++) { + special[i][m-1] = ATOTAGINT(words[m]); + if (special[i][m-1] <= 0 || special[i][m-1] > natoms || + special[i][m-1] == i+1) + error->all(FLERR,"Invalid special atom index in molecule file"); + } + } + + delete [] words; +} + +/* ---------------------------------------------------------------------- + auto generate special bond info +------------------------------------------------------------------------- */ + +void Molecule::special_generate() +{ + int newton_bond = force->newton_bond; + tagint atom1,atom2; + int count[natoms]; + + for (int i = 0; i < natoms; i++) count[i] = 0; + + // 1-2 neighbors + + if (newton_bond) { + for (int i = 0; i < natoms; i++) { + for (int j = 0; j < num_bond[i]; j++) { + atom1 = i; + atom2 = bond_atom[i][j]-1; + nspecial[i][0]++; + nspecial[atom2][0]++; + if (count[i] >= maxspecial || count[atom2] >= maxspecial) + error->one(FLERR,"Molecule auto special bond generation overflow"); + special[i][count[i]++] = atom2 + 1; + special[atom2][count[atom2]++] = i + 1; + } + } + } else { + for (int i = 0; i < natoms; i++) { + nspecial[i][0] = num_bond[i]; + for (int j = 0; j < num_bond[i]; j++) { + atom1 = i; + atom2 = bond_atom[i][j]; + if (count[atom1] >= maxspecial) + error->one(FLERR,"Molecule auto special bond generation overflow"); + special[i][count[atom1]++] = atom2; + } + } + } + + // 1-3 neighbors with no duplicates + + for (int i = 0; i < natoms; i++) nspecial[i][1] = nspecial[i][0]; + + int dedup; + for (int i = 0; i < natoms; i++) { + for (int m = 0; m < nspecial[i][0]; m++) { + for (int j = 0; j < nspecial[special[i][m]-1][0]; j++) { + dedup = 0; + for (int k =0; k < count[i]; k++) { + if (special[special[i][m]-1][j] == special[i][k] || + special[special[i][m]-1][j] == i+1) { + dedup = 1; + } + } + if (!dedup) { + if (count[i] >= maxspecial) + error->one(FLERR,"Molecule auto special bond generation overflow"); + special[i][count[i]++] = special[special[i][m]-1][j]; + nspecial[i][1]++; + } + } + } + } + + // 1-4 neighbors with no duplicates + + for (int i = 0; i < natoms; i++) nspecial[i][2] = nspecial[i][1]; + + for (int i = 0; i < natoms; i++) { + for (int m = nspecial[i][0]; m < nspecial[i][1]; m++) { + for (int j = 0; j < nspecial[special[i][m]-1][0]; j++) { + dedup = 0; + for (int k =0; k < count[i]; k++) { + if (special[special[i][m]-1][j] == special[i][k] || + special[special[i][m]-1][j] == i+1) { + dedup = 1; + } + } + if (!dedup) { + if (count[i] >= maxspecial) + error->one(FLERR,"Molecule auto special bond generation overflow"); + special[i][count[i]++] = special[special[i][m]-1][j]; + nspecial[i][2]++; + } + } + } + } +} + +/* ---------------------------------------------------------------------- + read SHAKE flags from file +------------------------------------------------------------------------- */ + +void Molecule::shakeflag_read(char *line) +{ + int tmp; + for (int i = 0; i < natoms; i++) { + readline(line); + sscanf(line,"%d %d",&tmp,&shake_flag[i]); + } + + for (int i = 0; i < natoms; i++) + if (shake_flag[i] < 0 || shake_flag[i] > 4) + error->all(FLERR,"Invalid shake flag in molecule file"); +} + +/* ---------------------------------------------------------------------- + read SHAKE atom info from file +------------------------------------------------------------------------- */ + +void Molecule::shakeatom_read(char *line) +{ + int tmp; + for (int i = 0; i < natoms; i++) { + readline(line); + if (shake_flag[i] == 1) + sscanf(line,"%d " TAGINT_FORMAT " " TAGINT_FORMAT " " TAGINT_FORMAT, + &tmp,&shake_atom[i][0],&shake_atom[i][1],&shake_atom[i][2]); + else if (shake_flag[i] == 2) + sscanf(line,"%d " TAGINT_FORMAT " " TAGINT_FORMAT, + &tmp,&shake_atom[i][0],&shake_atom[i][1]); + else if (shake_flag[i] == 3) + sscanf(line,"%d " TAGINT_FORMAT " " TAGINT_FORMAT " " TAGINT_FORMAT, + &tmp,&shake_atom[i][0],&shake_atom[i][1],&shake_atom[i][2]); + else if (shake_flag[i] == 4) + sscanf(line,"%d " TAGINT_FORMAT " " TAGINT_FORMAT " " + TAGINT_FORMAT " " TAGINT_FORMAT, + &tmp,&shake_atom[i][0],&shake_atom[i][1], + &shake_atom[i][2],&shake_atom[i][3]); + } + + for (int i = 0; i < natoms; i++) { + int m = shake_flag[i]; + if (m == 1) m = 3; + for (int j = 0; j < m; j++) + if (shake_atom[i][j] <= 0 || shake_atom[i][j] > natoms) + error->all(FLERR,"Invalid shake atom in molecule file"); + } +} + +/* ---------------------------------------------------------------------- + read SHAKE bond type info from file +------------------------------------------------------------------------- */ + +void Molecule::shaketype_read(char *line) +{ + int tmp; + for (int i = 0; i < natoms; i++) { + readline(line); + if (shake_flag[i] == 1) + sscanf(line,"%d %d %d %d",&tmp, + &shake_type[i][0],&shake_type[i][1],&shake_type[i][2]); + else if (shake_flag[i] == 2) + sscanf(line,"%d %d",&tmp,&shake_type[i][0]); + else if (shake_flag[i] == 3) + sscanf(line,"%d %d %d",&tmp,&shake_type[i][0],&shake_type[i][1]); + else if (shake_flag[i] == 4) + sscanf(line,"%d %d %d %d",&tmp, + &shake_type[i][0],&shake_type[i][1],&shake_type[i][2]); + } + + for (int i = 0; i < natoms; i++) { + int m = shake_flag[i]; + if (m == 1) m = 3; + for (int j = 0; j < m-1; j++) + if (shake_type[i][j] <= 0) + error->all(FLERR,"Invalid shake bond type in molecule file"); + if (shake_flag[i] == 1) + if (shake_type[i][2] <= 0) + error->all(FLERR,"Invalid shake angle type in molecule file"); + } +} + +/* ---------------------------------------------------------------------- + read body params from file + pflag = 0/1 for integer/double params +------------------------------------------------------------------------- */ + +void Molecule::body(int flag, int pflag, char *line) +{ + int i,ncount; + + int nparam = nibody; + if (pflag) nparam = ndbody; + + int nword = 0; + while (nword < nparam) { + readline(line); + + ncount = atom->count_words(line); + if (ncount == 0) + error->one(FLERR,"Too few values in body section of molecule file"); + if (nword+ncount > nparam) + error->all(FLERR,"Too many values in body section of molecule file"); + + if (flag) { + if (pflag == 0) { + ibodyparams[nword++] = force->inumeric(FLERR,strtok(line," \t\n\r\f")); + for (i = 1; i < ncount; i++) + ibodyparams[nword++] = + force->inumeric(FLERR,strtok(NULL," \t\n\r\f")); + } else { + dbodyparams[nword++] = force->numeric(FLERR,strtok(line," \t\n\r\f")); + for (i = 1; i < ncount; i++) + dbodyparams[nword++] = + force->numeric(FLERR,strtok(NULL," \t\n\r\f")); + } + } else nword += ncount; + } +} + +/* ---------------------------------------------------------------------- + error check molecule attributes and topology against system settings + flag = 0, just check this molecule + flag = 1, check all molecules in set, this is 1st molecule in set +------------------------------------------------------------------------- */ + +void Molecule::check_attributes(int flag) +{ + int n = 1; + if (flag) n = nset; + int imol = atom->find_molecule(id); + + for (int i = imol; i < imol+n; i++) { + Molecule *onemol = atom->molecules[imol]; + + // check per-atom attributes of molecule + // warn if not a match + + int mismatch = 0; + if (onemol->replambdaHflag && !atom->replambdaH_flag) mismatch = 1; + if (onemol->moltypeHflag && !atom->moltypeH_flag) mismatch = 1; + if (onemol->qflag && !atom->q_flag) mismatch = 1; + if (onemol->radiusflag && !atom->radius_flag) mismatch = 1; + if (onemol->rmassflag && !atom->rmass_flag) mismatch = 1; + + if (mismatch && me == 0) + error->warning(FLERR, + "Molecule attributes do not match system attributes"); + + // for all atom styles, check nbondtype,etc + + mismatch = 0; + if (atom->nbondtypes < onemol->nbondtypes) mismatch = 1; + if (atom->nangletypes < onemol->nangletypes) mismatch = 1; + if (atom->ndihedraltypes < onemol->ndihedraltypes) mismatch = 1; + if (atom->nimpropertypes < onemol->nimpropertypes) mismatch = 1; + + if (mismatch) + error->all(FLERR,"Molecule topology type exceeds system topology type"); + + // for molecular atom styles, check bond_per_atom,etc + maxspecial + // do not check for atom style template, since nothing stored per atom + + if (atom->molecular == 1) { + if (atom->avec->bonds_allow && + atom->bond_per_atom < onemol->bond_per_atom) mismatch = 1; + if (atom->avec->angles_allow && + atom->angle_per_atom < onemol->angle_per_atom) mismatch = 1; + if (atom->avec->dihedrals_allow && + atom->dihedral_per_atom < onemol->dihedral_per_atom) mismatch = 1; + if (atom->avec->impropers_allow && + atom->improper_per_atom < onemol->improper_per_atom) mismatch = 1; + if (atom->maxspecial < onemol->maxspecial) mismatch = 1; + + if (mismatch) + error->all(FLERR,"Molecule toplogy/atom exceeds system topology/atom"); + } + + // warn if molecule topology defined but no special settings + + if (onemol->bondflag && !onemol->specialflag) + if (me == 0) error->warning(FLERR,"Molecule has bond topology " + "but no special bond settings"); + } +} + +/* ---------------------------------------------------------------------- + init all data structures to empty +------------------------------------------------------------------------- */ + +void Molecule::initialize() +{ + natoms = 0; + nbonds = nangles = ndihedrals = nimpropers = 0; + ntypes = 0; + nbondtypes = nangletypes = ndihedraltypes = nimpropertypes = 0; + nibody = ndbody = 0; + + bond_per_atom = angle_per_atom = dihedral_per_atom = improper_per_atom = 0; + maxspecial = 0; + + xflag = typeflag = qflag = radiusflag = rmassflag = 0; + bondflag = angleflag = dihedralflag = improperflag = 0; + nspecialflag = specialflag = 0; + shakeflag = shakeflagflag = shakeatomflag = shaketypeflag = 0; + bodyflag = ibodyflag = dbodyflag = 0; + + centerflag = massflag = comflag = inertiaflag = 0; + tag_require = 0; + + x = NULL; + type = NULL; + q = NULL; + radius = NULL; + rmass = NULL; + + num_bond = NULL; + bond_type = NULL; + bond_atom = NULL; + + num_angle = NULL; + angle_type = NULL; + angle_atom1 = angle_atom2 = angle_atom3 = NULL; + + num_dihedral = NULL; + dihedral_type = NULL; + dihedral_atom1 = dihedral_atom2 = dihedral_atom3 = dihedral_atom4 = NULL; + + num_improper = NULL; + improper_type = NULL; + improper_atom1 = improper_atom2 = improper_atom3 = improper_atom4 = NULL; + + nspecial = NULL; + special = NULL; + + shake_flag = NULL; + shake_atom = NULL; + shake_type = NULL; + + ibodyparams = NULL; + dbodyparams = NULL; + + dx = NULL; + dxcom = NULL; + dxbody = NULL; +} + +/* ---------------------------------------------------------------------- + allocate all data structures + also initialize values for data structures that are always allocated +------------------------------------------------------------------------- */ + +void Molecule::allocate() +{ + if (xflag) memory->create(x,natoms,3,"molecule:x"); + if (typeflag) memory->create(type,natoms,"molecule:type"); + if (qflag) memory->create(q,natoms,"molecule:q"); + if (radiusflag) memory->create(radius,natoms,"molecule:radius"); + if (rmassflag) memory->create(rmass,natoms,"molecule:rmass"); + if (replambdaHflag) memory->create(replambdaH,natoms,"molecule:replambdaH"); + if (moltypeHflag) memory->create(moltypeH,natoms,"molecule:moltypeH"); + + // always allocate num_bond,num_angle,etc and special+nspecial + // even if not in molecule file, initialize to 0 + // this is so methods that use these arrays don't have to check they exist + + memory->create(num_bond,natoms,"molecule:num_bond"); + for (int i = 0; i < natoms; i++) num_bond[i] = 0; + memory->create(num_angle,natoms,"molecule:num_angle"); + for (int i = 0; i < natoms; i++) num_angle[i] = 0; + memory->create(num_dihedral,natoms,"molecule:num_dihedral"); + for (int i = 0; i < natoms; i++) num_dihedral[i] = 0; + memory->create(num_improper,natoms,"molecule:num_improper"); + for (int i = 0; i < natoms; i++) num_improper[i] = 0; + + memory->create(special,natoms,maxspecial,"molecule:special"); + + memory->create(nspecial,natoms,3,"molecule:nspecial"); + for (int i = 0; i < natoms; i++) + nspecial[i][0] = nspecial[i][1] = nspecial[i][2] = 0; + + if (bondflag) { + memory->create(bond_type,natoms,bond_per_atom, + "molecule:bond_type"); + memory->create(bond_atom,natoms,bond_per_atom, + "molecule:bond_atom"); + } + + if (angleflag) { + memory->create(angle_type,natoms,angle_per_atom, + "molecule:angle_type"); + memory->create(angle_atom1,natoms,angle_per_atom, + "molecule:angle_atom1"); + memory->create(angle_atom2,natoms,angle_per_atom, + "molecule:angle_atom2"); + memory->create(angle_atom3,natoms,angle_per_atom, + "molecule:angle_atom3"); + } + + if (dihedralflag) { + memory->create(dihedral_type,natoms,dihedral_per_atom, + "molecule:dihedral_type"); + memory->create(dihedral_atom1,natoms,dihedral_per_atom, + "molecule:dihedral_atom1"); + memory->create(dihedral_atom2,natoms,dihedral_per_atom, + "molecule:dihedral_atom2"); + memory->create(dihedral_atom3,natoms,dihedral_per_atom, + "molecule:dihedral_atom3"); + memory->create(dihedral_atom4,natoms,dihedral_per_atom, + "molecule:dihedral_atom4"); + } + + if (improperflag) { + memory->create(improper_type,natoms,improper_per_atom, + "molecule:improper_type"); + memory->create(improper_atom1,natoms,improper_per_atom, + "molecule:improper_atom1"); + memory->create(improper_atom2,natoms,improper_per_atom, + "molecule:improper_atom2"); + memory->create(improper_atom3,natoms,improper_per_atom, + "molecule:improper_atom3"); + memory->create(improper_atom4,natoms,improper_per_atom, + "molecule:improper_atom4"); + } + + if (shakeflag) { + memory->create(shake_flag,natoms,"molecule:shake_flag"); + memory->create(shake_atom,natoms,4,"molecule:shake_flag"); + memory->create(shake_type,natoms,3,"molecule:shake_flag"); + } + + if (bodyflag) { + if (nibody) memory->create(ibodyparams,nibody,"molecule:ibodyparams"); + if (ndbody) memory->create(dbodyparams,ndbody,"molecule:dbodyparams"); + } +} + +/* ---------------------------------------------------------------------- + deallocate all data structures +------------------------------------------------------------------------- */ + +void Molecule::deallocate() +{ + memory->destroy(x); + memory->destroy(type); + memory->destroy(q); + memory->destroy(radius); + memory->destroy(replambdaH); + memory->destroy(moltypeH); + memory->destroy(rmass); + + memory->destroy(num_bond); + memory->destroy(bond_type); + memory->destroy(bond_atom); + + memory->destroy(num_angle); + memory->destroy(angle_type); + memory->destroy(angle_atom1); + memory->destroy(angle_atom2); + memory->destroy(angle_atom3); + + memory->destroy(num_dihedral); + memory->destroy(dihedral_type); + memory->destroy(dihedral_atom1); + memory->destroy(dihedral_atom2); + memory->destroy(dihedral_atom3); + memory->destroy(dihedral_atom4); + + memory->destroy(num_improper); + memory->destroy(improper_type); + memory->destroy(improper_atom1); + memory->destroy(improper_atom2); + memory->destroy(improper_atom3); + memory->destroy(improper_atom4); + + memory->destroy(nspecial); + memory->destroy(special); + + memory->destroy(shake_flag); + memory->destroy(shake_atom); + memory->destroy(shake_type); + + memory->destroy(dx); + memory->destroy(dxcom); + memory->destroy(dxbody); + + memory->destroy(ibodyparams); + memory->destroy(dbodyparams); +} + +/* ---------------------------------------------------------------------- + open molecule file +------------------------------------------------------------------------- */ + +void Molecule::open(char *file) +{ + fp = fopen(file,"r"); + if (fp == NULL) { + char str[128]; + sprintf(str,"Cannot open molecule file %s",file); + error->one(FLERR,str); + } +} + +/* ---------------------------------------------------------------------- + read and bcast a line +------------------------------------------------------------------------- */ + +void Molecule::readline(char *line) +{ + int n; + if (me == 0) { + if (fgets(line,MAXLINE,fp) == NULL) n = 0; + else n = strlen(line) + 1; + } + MPI_Bcast(&n,1,MPI_INT,0,world); + if (n == 0) error->all(FLERR,"Unexpected end of molecule file"); + MPI_Bcast(line,n,MPI_CHAR,0,world); +} + +/* ---------------------------------------------------------------------- + extract keyword from line + flag = 0, read and bcast line + flag = 1, line has already been read +------------------------------------------------------------------------- */ + +void Molecule::parse_keyword(int flag, char *line, char *keyword) +{ + if (flag) { + + // read upto non-blank line plus 1 following line + // eof is set to 1 if any read hits end-of-file + + int eof = 0; + if (me == 0) { + if (fgets(line,MAXLINE,fp) == NULL) eof = 1; + while (eof == 0 && strspn(line," \t\n\r") == strlen(line)) { + if (fgets(line,MAXLINE,fp) == NULL) eof = 1; + } + if (fgets(keyword,MAXLINE,fp) == NULL) eof = 1; + } + + // if eof, set keyword empty and return + + MPI_Bcast(&eof,1,MPI_INT,0,world); + if (eof) { + keyword[0] = '\0'; + return; + } + + // bcast keyword line to all procs + + int n; + if (me == 0) n = strlen(line) + 1; + MPI_Bcast(&n,1,MPI_INT,0,world); + MPI_Bcast(line,n,MPI_CHAR,0,world); + } + + // copy non-whitespace portion of line into keyword + + int start = strspn(line," \t\n\r"); + int stop = strlen(line) - 1; + while (line[stop] == ' ' || line[stop] == '\t' + || line[stop] == '\n' || line[stop] == '\r') stop--; + line[stop+1] = '\0'; + strcpy(keyword,&line[start]); +} + +/* ---------------------------------------------------------------------- + skip N lines of file +------------------------------------------------------------------------- */ + +void Molecule::skip_lines(int n, char *line) +{ + for (int i = 0; i < n; i++) readline(line); +} + +/* ---------------------------------------------------------------------- + parse line into words separated by whitespace + return # of words + max = max pointers storable in words +------------------------------------------------------------------------- */ + +int Molecule::parse(char *line, char **words, int max) +{ + char *ptr; + + int nwords = 0; + words[nwords++] = strtok(line," \t\n\r\f"); + + while ((ptr = strtok(NULL," \t\n\r\f"))) { + if (nwords < max) words[nwords] = ptr; + nwords++; + } + + return nwords; +} + +/* ---------------------------------------------------------------------- + proc 0 prints molecule params +------------------------------------------------------------------------- */ + +/* + +void Molecule::print() +{ + printf("MOLECULE %s\n",id); + printf(" %d natoms\n",natoms); + if (nbonds) printf(" %d nbonds\n",nbonds); + if (nangles) printf(" %d nangles\n",nangles); + if (ndihedrals) printf(" %d ndihedrals\n",ndihedrals); + if (nimpropers) printf(" %d nimpropers\n",nimpropers); + + if (xflag) { + printf( "Coords:\n"); + for (int i = 0; i < natoms; i++) + printf(" %d %g %g %g\n",i+1,x[i][0],x[i][1],x[i][2]); + } + if (typeflag) { + printf( "Types:\n"); + for (int i = 0; i < natoms; i++) + printf(" %d %d\n",i+1,type[i]); + } + if (qflag) { + printf( "Charges:\n"); + for (int i = 0; i < natoms; i++) + printf(" %d %g\n",i+1,q[i]); + } + if (radiusflag) { + printf( "Radii:\n"); + for (int i = 0; i < natoms; i++) + printf(" %d %g\n",i+1,radius[i]); + } + if (rmassflag) { + printf( "Masses:\n"); + for (int i = 0; i < natoms; i++) + printf(" %d %g\n",i+1,rmass[i]); + } + + if (bondflag) { + printf( "Bonds:\n"); + for (int i = 0; i < natoms; i++) { + printf(" %d %d\n",i+1,num_bond[i]); + for (int j = 0; j < num_bond[i]; j++) + printf(" %d %d %d %d\n",j+1,bond_type[i][j],i+1,bond_atom[i][j]); + } + } + if (angleflag) { + printf( "Angles:\n"); + for (int i = 0; i < natoms; i++) { + printf(" %d %d\n",i+1,num_angle[i]); + for (int j = 0; j < num_angle[i]; j++) + printf(" %d %d %d %d %d\n", + j+1,angle_type[i][j], + angle_atom1[i][j],angle_atom2[i][j],angle_atom3[i][j]); + } + } + if (dihedralflag) { + printf( "Dihedrals:\n"); + for (int i = 0; i < natoms; i++) { + printf(" %d %d\n",i+1,num_dihedral[i]); + for (int j = 0; j < num_dihedral[i]; j++) + printf(" %d %d %d %d %d %d\n", + j+1,dihedral_type[i][j], + dihedral_atom1[i][j],dihedral_atom2[i][j], + dihedral_atom3[i][j],dihedral_atom4[i][j]); + } + } + if (improperflag) { + printf( "Impropers:\n"); + for (int i = 0; i < natoms; i++) { + printf(" %d %d\n",i+1,num_improper[i]); + for (int j = 0; j < num_improper[i]; j++) + printf(" %d %d %d %d %d %d\n", + j+1,improper_type[i][j], + improper_atom1[i][j],improper_atom2[i][j], + improper_atom3[i][j],improper_atom4[i][j]); + } + } + + if (specialflag) { + printf( "Special neighs:\n"); + for (int i = 0; i < natoms; i++) { + printf(" %d %d %d %d\n",i+1, + nspecial[i][0],nspecial[i][1]-nspecial[i][0], + nspecial[i][2]-nspecial[i][1]); + printf(" "); + for (int j = 0; j < nspecial[i][2]; j++) + printf(" %d",special[i][j]); + printf("\n"); + } + } +} + +*/ diff --git a/src/USER-HADRESS/molecule.h b/src/USER-HADRESS/molecule.h new file mode 100644 index 0000000000..4521fc45bc --- /dev/null +++ b/src/USER-HADRESS/molecule.h @@ -0,0 +1,432 @@ +/* -*- c++ -*- ---------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + http://lammps.sandia.gov, Sandia National Laboratories + Steve Plimpton, sjplimp@sandia.gov + + Copyright (2003) Sandia Corporation. Under the terms of Contract + DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains + certain rights in this software. This software is distributed under + the GNU General Public License. + + See the README file in the top-level LAMMPS directory. +------------------------------------------------------------------------- */ + +#ifndef LMP_ONE_MOLECULE_H +#define LMP_ONE_MOLECULE_H + +#include "pointers.h" + +namespace LAMMPS_NS { + +class Molecule : protected Pointers { + public: + char *id; // template id of this molecule, same for all molecules in set + int nset; // if first in set, # of molecules in this set + // else 0 if not first in set + int last; // 1 if last molecule in set, else 0 + + // number of atoms,bonds,etc in molecule + // nibody,ndbody = # of integer/double fields in body + + int natoms; + int nbonds,nangles,ndihedrals,nimpropers; + int ntypes; + int nbondtypes,nangletypes,ndihedraltypes,nimpropertypes; + int nibody,ndbody; + + // max bond,angle,etc per atom + + int bond_per_atom,angle_per_atom,dihedral_per_atom,improper_per_atom; + int maxspecial; + + // 1 if attribute defined in file, 0 if not + + int xflag,typeflag,qflag,radiusflag,rmassflag; + int replambdaHflag,moltypeHflag; + int bondflag,angleflag,dihedralflag,improperflag; + int nspecialflag,specialflag; + int shakeflag,shakeflagflag,shakeatomflag,shaketypeflag; + int bodyflag,ibodyflag,dbodyflag; + + // 1 if attribute defined or computed, 0 if not + + int centerflag,massflag,comflag,inertiaflag; + + // 1 if molecule fields require atom IDs + + int tag_require; + + // attributes + + double **x; // displacement of each atom from origin + int *type; // type of each atom + double *q; // charge on each atom + + int *replambdaH; // replambdaH on each atom + int *moltypeH; // moltypeH on each atom + + double *radius; // radius of each atom + double *rmass; // mass of each atom + + int *num_bond; // bonds, angles, dihedrals, impropers for each atom + int **bond_type; + tagint **bond_atom; + + int *num_angle; + int **angle_type; + tagint **angle_atom1,**angle_atom2,**angle_atom3; + + int *num_dihedral; + int **dihedral_type; + tagint **dihedral_atom1,**dihedral_atom2,**dihedral_atom3,**dihedral_atom4; + + int *num_improper; + int **improper_type; + tagint **improper_atom1,**improper_atom2,**improper_atom3,**improper_atom4; + + int **nspecial; + tagint **special; + + int *shake_flag; + tagint **shake_atom; + int **shake_type; + + class AtomVecBody *avec_body; + int *ibodyparams; // integer and double body params + double *dbodyparams; + + double center[3]; // geometric center of molecule + double masstotal; // total mass of molecule + double com[3]; // center of mass of molecule + double itensor[6]; // moments of inertia of molecule + double inertia[3]; // principal moments of inertia of molecule + double ex[3],ey[3],ez[3]; // principal axes of molecule in space coords + double quat[4]; // quaternion for orientation of molecule + + double maxradius; // max radius of any atom in molecule + double molradius; // radius of molecule from geometric center + // including finite-size particle radii + int comatom; // index (1-Natom) of atom closest to COM + double maxextent; // furthest any atom in molecule is from comatom + + double **dx; // displacement of each atom relative to center + double **dxcom; // displacement of each atom relative to COM + double **dxbody; // displacement of each atom relative to COM + // in body frame (diagonalized interia tensor) + + double *quat_external; // orientation imposed by external class + // e.g. FixPour or CreateAtoms + + Molecule(class LAMMPS *, int, char **, int &); + ~Molecule(); + void compute_center(); + void compute_mass(); + void compute_com(); + void compute_inertia(); + void check_attributes(int); + + private: + int me; + FILE *fp; + int *count; + int toffset,boffset,aoffset,doffset,ioffset; + int autospecial; + double sizescale; + + void read(int); + void coords(char *); + void types(char *); + void charges(char *); + void representative_atom(char *); + void moltype_atom(char *); + void diameters(char *); + void masses(char *); + void bonds(int, char *); + void angles(int, char *); + void dihedrals(int, char *); + void impropers(int, char *); + void nspecial_read(int, char *); + void special_read(char *); + void special_generate(); + void shakeflag_read(char *); + void shakeatom_read(char *); + void shaketype_read(char *); + void body(int, int, char *); + + void initialize(); + void allocate(); + void deallocate(); + + void open(char *); + void readline(char *); + void parse_keyword(int, char *, char *); + void skip_lines(int, char *); + int parse(char *, char **, int); + + // void print(); +}; + +} + +#endif + +/* ERROR/WARNING messages: + +E: Illegal ... command + +Self-explanatory. Check the input script syntax and compare to the +documentation for the command. You can use -echo screen as a +command-line option when running LAMMPS to see the offending line. + +E: Molecule template ID must be alphanumeric or underscore characters + +Self-explanatory. + +E: Insufficient Jacobi rotations for rigid molecule + +Eigensolve for rigid body was not sufficiently accurate. + +E: Unexpected end of molecule file + +Self-explanatory. + +E: Molecule file z center-of-mass must be 0.0 for 2d + +Self-explanatory. + +E: Molecule file requires atom style body + +Self-explanatory. + +E: No count or invalid atom count in molecule file + +The number of atoms must be specified. + +E: Invalid bond count in molecule file + +Self-explanatory. + +E: Invalid angle count in molecule file + +Self-explanatory. + +E: Invalid dihedral count in molecule file + +Self-explanatory. + +E: Invalid improper count in molecule file + +Self-explanatory. + +E: Molecule file has bonds but no nbonds setting + +Self-explanatory. + +E: Molecule file has angles but no nangles setting + +Self-explanatory. + +E: Molecule file has dihedrals but no ndihedrals setting + +Self-explanatory. + +E: Molecule file has impropers but no nimpropers setting + +Self-explanatory. + +E: Molecule file shake flags not before shake atoms + +The order of the two sections is important. + +E: Molecule file shake flags not before shake bonds + +The order of the two sections is important. + +E: Molecule file has body params but no setting for them + +Self-explanatory. + +E: Unknown section in molecule file + +Self-explanatory. + +E: Molecule file needs both Special Bond sections + +Self-explanatory. + +E: Molecule file has special flags but no bonds + +Self-explanatory. + +E: Molecule file shake info is incomplete + +All 3 SHAKE sections are needed. + +E: Molecule file has no Body Integers section + +Self-explanatory. + +E: Molecule file has no Body Doubles section + +Self-explanatory. + +E: Molecule natoms must be 1 for body particle + +Self-explanatory. + +E: Molecule sizescale must be 1.0 for body particle + +Self-explanatory. + +E: Invalid Coords section in molecule file + +Self-explanatory. + +E: Molecule file z coord must be 0.0 for 2d + +Self-explanatory. + +E: Invalid Types section in molecule file + +Self-explanatory. + +E: Invalid atom type in molecule file + +Atom types must range from 1 to specified # of types. + +E: Invalid Charges section in molecule file + +Self-explanatory. + +E: Invalid Diameters section in molecule file + +Self-explanatory. + +E: Invalid atom diameter in molecule file + +Diameters must be >= 0.0. + +E: Invalid Masses section in molecule file + +Self-explanatory. + +E: Invalid atom mass in molecule file + +Masses must be > 0.0. + +E: Invalid Bonds section in molecule file + +Self-explanatory. + +E: Invalid atom ID in Bonds section of molecule file + +Self-explanatory. + +E: Invalid bond type in Bonds section of molecule file + +Self-explanatory. + +E: Invalid Angles section in molecule file + +Self-explanatory. + +E: Invalid atom ID in Angles section of molecule file + +Self-explanatory. + +E: Invalid angle type in Angles section of molecule file + +Self-explanatory. + +E: Invalid Dihedrals section in molecule file + +Self-explanatory. + +E: Invalid atom ID in dihedrals section of molecule file + +Self-explanatory. + +E: Invalid dihedral type in dihedrals section of molecule file + +Self-explanatory. + +E: Invalid Impropers section in molecule file + +Self-explanatory. + +E: Invalid atom ID in impropers section of molecule file + +Self-explanatory. + +E: Invalid improper type in impropers section of molecule file + +Self-explanatory. + +E: Invalid Special Bond Counts section in molecule file + +Self-explanatory. + +E: Molecule file special list does not match special count + +The number of values in an atom's special list does not match count. + +E: Invalid special atom index in molecule file + +Self-explanatory. + +E: Molecule auto special bond generation overflow + +Counts exceed maxspecial setting for other atoms in system. + +E: Invalid shake flag in molecule file + +Self-explanatory. + +E: Invalid shake atom in molecule file + +Self-explanatory. + +E: Invalid shake bond type in molecule file + +Self-explanatory. + +E: Invalid shake angle type in molecule file + +Self-explanatory. + +E: Too few values in body section of molecule file + +Self-explanatory. + +E: Too many values in body section of molecule file + +Self-explanatory. + +W: Molecule attributes do not match system attributes + +An attribute is specified (e.g. diameter, charge) that is +not defined for the specified atom style. + +E: Molecule topology type exceeds system topology type + +The number of bond, angle, etc types in the molecule exceeds the +system setting. See the create_box command for how to specify these +values. + +E: Molecule toplogy/atom exceeds system topology/atom + +The number of bonds, angles, etc per-atom in the molecule exceeds the +system setting. See the create_box command for how to specify these +values. + +W: Molecule has bond topology but no special bond settings + +This means the bonded atoms will not be excluded in pair-wise +interactions. + +E: Cannot open molecule file %s + +The specified file cannot be opened. Check that the path and name are +correct. + +*/ diff --git a/src/USER-HADRESS/pair_lj_cut_coul_dsf_hars_at.cpp b/src/USER-HADRESS/pair_lj_cut_coul_dsf_hars_at.cpp new file mode 100644 index 0000000000..5a60d7ef75 --- /dev/null +++ b/src/USER-HADRESS/pair_lj_cut_coul_dsf_hars_at.cpp @@ -0,0 +1,971 @@ +/* ---------------------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + http://lammps.sandia.gov, Sandia National Laboratories + Steve Plimpton, sjplimp@sandia.gov + + Copyright (2003) Sandia Corporation. Under the terms of Contract + DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains + certain rights in this software. This software is distributed under + the GNU General Public License. + + See the README file in the top-level LAMMPS directory. +------------------------------------------------------------------------- */ + +/* ---------------------------------------------------------------------- + Contributing author: Maziar Heidari, + Robinson Cortes-Huerto, + Davide Donadio and + Raffaello Potestio + (Max Planck Institute for Polymer Research, 2015-2016) +------------------------------------------------------------------------- */ + +#include "math.h" +#include "stdio.h" +#include "stdlib.h" +#include "string.h" +#include "pair_lj_cut_coul_dsf_hars_at.h" +#include "atom.h" +#include "comm.h" +#include "force.h" +#include "neighbor.h" +#include "neigh_list.h" +#include "memory.h" +#include "math_const.h" +#include "error.h" +#include "fix_lambdah_calc.h" +#include "update.h" + + +using namespace LAMMPS_NS; +using namespace MathConst; +#define BIG MAXTAGINT + + +#define EWALD_F 1.12837917 +#define EWALD_P 0.3275911 +#define A1 0.254829592 +#define A2 -0.284496736 +#define A3 1.421413741 +#define A4 -1.453152027 +#define A5 1.061405429 + +/* ---------------------------------------------------------------------- */ + +PairLJCutCoulDSFHARSAT::PairLJCutCoulDSFHARSAT(LAMMPS *lmp) : Pair(lmp) +{ + single_enable = 0; + + AT_molmap_H = NULL; + nmolecules = molecules_in_group(idlo,idhi); + + H_AdResS_allocated = 0; + + AT_Pressure_Compensation_Run = 0; + Comp_Counter_H = 0; + memory->create(AT_massproc_H,nmolecules,"pair:AT_massproc_H"); + memory->create(AT_masstotal_H,nmolecules,"pair:AT_masstotal_H"); + memory->create(AT_mol_f_H,nmolecules,3,"pair:AT_mol_f_H"); + memory->create(AT_mol_f_all_H,nmolecules,3,"pair:AT_mol_f_all_H"); + + + // compute masstotal for each molecule + MPI_Comm_rank(world, &me); + int *mask = atom->mask; + tagint *molecule = atom->molecule; + int *type = atom->type; + double *mass = atom->mass; + double *rmass = atom->rmass; + int nlocal = atom->nlocal; + + tagint imol; + double massone; + + for (int i = 0; i < nmolecules; i++) AT_massproc_H[i] = 0.0; + + + for (int i = 0; i < nlocal; i++) + { +// if (mask[i] & groupbit) { + if (mask[i]) { + if (rmass) massone = rmass[i]; + else massone = mass[type[i]]; + imol = molecule[i]; + if (AT_molmap_H) imol = AT_molmap_H[imol-idlo]; + else imol--; + AT_massproc_H[imol] += massone; + + } + } + + MPI_Allreduce(AT_massproc_H,AT_masstotal_H,nmolecules,MPI_DOUBLE,MPI_SUM,world); + +} + +/* ---------------------------------------------------------------------- */ + +PairLJCutCoulDSFHARSAT::~PairLJCutCoulDSFHARSAT() +{ + if (allocated) { + memory->destroy(setflag); + memory->destroy(cutsq); + + memory->destroy(cut_lj); + memory->destroy(cut_ljsq); + memory->destroy(epsilon); + memory->destroy(sigma); + memory->destroy(lj1); + memory->destroy(lj2); + memory->destroy(lj3); + memory->destroy(lj4); + memory->destroy(offset); + } +} + +/* ---------------------------------------------------------------------- */ + +void PairLJCutCoulDSFHARSAT::compute(int eflag, int vflag) +{ + int i,j,ii,jj,inum,jnum,itype,jtype; + double qtmp,xtmp,ytmp,ztmp,delx,dely,delz,evdwl,ecoul,fpair; + double r,rsq,r2inv,r6inv,forcecoul,forcelj,factor_coul,factor_lj,Vij_Coul,Vij_Lj;; + double prefactor,erfcc,erfcd,t; + int *ilist,*jlist,*numneigh,**firstneigh; + int imoltypeH,jmoltypeH; + + evdwl = ecoul = 0.0; + if (eflag || vflag) ev_setup(eflag,vflag); + else evflag = vflag_fdotr = 0; + + double **x = atom->x; + double **f = atom->f; + double *q = atom->q; + double *lambdaH = atom->lambdaH; + double **gradlambdaH = atom->gradlambdaH; + + int *type = atom->type; + int nlocal = atom->nlocal; + double *special_lj = force->special_lj; + double *special_coul = force->special_coul; + int newton_pair = force->newton_pair; + double qqrd2e = force->qqrd2e; + int imol,jmol; + tagint *molecule = atom->molecule; + double *mass = atom->mass; + int *replambdaH = atom->replambdaH; + int *moltypeH = atom->moltypeH; + + int ibin, jbin; + + inum = list->inum; + ilist = list->ilist; + numneigh = list->numneigh; + firstneigh = list->firstneigh; + + double xtmpj, iLambda, jLambda, ijLambda; + + int This_Step = update->ntimestep; + if(This_Step >= AT_Update_Time_Begin && This_Step <= AT_Update_Time_End && AT_Pressure_Comp_Flag != 0) AT_Pressure_Compensation_Run = 1; + + + for (int i = 0; i < nmolecules; i++) { + AT_mol_f_H[i][0] = AT_mol_f_H[i][1] = AT_mol_f_H[i][2] = 0; + AT_mol_f_all_H[i][0] = AT_mol_f_all_H[i][1] = AT_mol_f_all_H[i][2] = 0; + } + + // loop over neighbors of my atoms +// if(update->ntimestepntypes; + + memory->create(setflag,n+1,n+1,"pair:setflag"); + for (int i = 1; i <= n; i++) + for (int j = i; j <= n; j++) + setflag[i][j] = 0; + + memory->create(cutsq,n+1,n+1,"pair:cutsq"); + + memory->create(cut_lj,n+1,n+1,"pair:cut_lj"); + memory->create(cut_ljsq,n+1,n+1,"pair:cut_ljsq"); + memory->create(epsilon,n+1,n+1,"pair:epsilon"); + memory->create(sigma,n+1,n+1,"pair:sigma"); + memory->create(lj1,n+1,n+1,"pair:lj1"); + memory->create(lj2,n+1,n+1,"pair:lj2"); + memory->create(lj3,n+1,n+1,"pair:lj3"); + memory->create(lj4,n+1,n+1,"pair:lj4"); + memory->create(offset,n+1,n+1,"pair:offset"); +} + +/* ---------------------------------------------------------------------- + global settings +------------------------------------------------------------------------- */ + +void PairLJCutCoulDSFHARSAT::settings(int narg, char **arg) +{ + if (narg != 5) error->all(FLERR,"Illegal pair_style command"); + + alpha = force->numeric(FLERR,arg[0]); + cut_lj_global = force->numeric(FLERR,arg[1]); + cut_coul = force->numeric(FLERR,arg[2]); + + AllAtomistic = force->numeric(FLERR,arg[3]); + Load_File_Flag = force->numeric(FLERR,arg[4]); + // reset cutoffs that have been explicitly set + + if (allocated) { + int i,j; + for (i = 1; i <= atom->ntypes; i++) + for (j = i+1; j <= atom->ntypes; j++) + if (setflag[i][j]) + cut_lj[i][j] = cut_lj_global; + } +} + +/* ---------------------------------------------------------------------- + set coeffs for one or more type pairs +------------------------------------------------------------------------- */ + +void PairLJCutCoulDSFHARSAT::coeff(int narg, char **arg) +{ + if (narg < 4 || narg > 5) + error->all(FLERR,"Incorrect args for pair coefficients"); + if (!allocated) allocate(); + + int ilo,ihi,jlo,jhi; + force->bounds(arg[0],atom->ntypes,ilo,ihi); + force->bounds(arg[1],atom->ntypes,jlo,jhi); + + double epsilon_one = force->numeric(FLERR,arg[2]); + double sigma_one = force->numeric(FLERR,arg[3]); + + double cut_lj_one = cut_lj_global; + if (narg == 5) cut_lj_one = force->numeric(FLERR,arg[4]); + + int count = 0; + for (int i = ilo; i <= ihi; i++) { + for (int j = MAX(jlo,i); j <= jhi; j++) { + epsilon[i][j] = epsilon_one; + sigma[i][j] = sigma_one; + cut_lj[i][j] = cut_lj_one; + setflag[i][j] = 1; + + count++; + } + } + + if (count == 0) error->all(FLERR,"Incorrect args for pair coefficients"); +} + +/* ---------------------------------------------------------------------- + init specific to this pair style +------------------------------------------------------------------------- */ + +void PairLJCutCoulDSFHARSAT::init_style() +{ + if (!atom->q_flag) + error->all(FLERR,"Pair style lj/cut/coul/dsf requires atom attribute q"); + + if(me == 0){ + if (screen)fprintf(screen,"AT_H_AdResS_allocated flag = %d\n",H_AdResS_allocated); + if (logfile)fprintf(logfile,"AT_H_AdResS_allocated flag = %d\n",H_AdResS_allocated); + } + + if(!H_AdResS_allocated)H_AdResS_Allocation(); + + int This_Step = update->ntimestep; + AT_Restart_Time_Step = This_Step; + + if((This_Step >= AT_Update_Time_End || Load_File_Flag) && AT_Pressure_Comp_Flag != 0)Load_Compensation_Pressure(); + + neighbor->request(this,instance_me); + + cut_coulsq = cut_coul * cut_coul; + double erfcc = erfc(alpha*cut_coul); + double erfcd = exp(-alpha*alpha*cut_coul*cut_coul); + f_shift = -(erfcc/cut_coulsq + 2.0/MY_PIS*alpha*erfcd/cut_coul); + e_shift = erfcc/cut_coul - f_shift*cut_coul; + +} + +/* ---------------------------------------------------------------------- + init for one type pair i,j and corresponding j,i +------------------------------------------------------------------------- */ + +double PairLJCutCoulDSFHARSAT::init_one(int i, int j) +{ + if (setflag[i][j] == 0) { + epsilon[i][j] = mix_energy(epsilon[i][i],epsilon[j][j], + sigma[i][i],sigma[j][j]); + sigma[i][j] = mix_distance(sigma[i][i],sigma[j][j]); + cut_lj[i][j] = mix_distance(cut_lj[i][i],cut_lj[j][j]); + } + + double cut = MAX(cut_lj[i][j],cut_coul); + cut_ljsq[i][j] = cut_lj[i][j] * cut_lj[i][j]; + + lj1[i][j] = 48.0 * epsilon[i][j] * pow(sigma[i][j],12.0); + lj2[i][j] = 24.0 * epsilon[i][j] * pow(sigma[i][j],6.0); + lj3[i][j] = 4.0 * epsilon[i][j] * pow(sigma[i][j],12.0); + lj4[i][j] = 4.0 * epsilon[i][j] * pow(sigma[i][j],6.0); + + if (offset_flag) { + double ratio = sigma[i][j] / cut_lj[i][j]; + offset[i][j] = 4.0 * epsilon[i][j] * (pow(ratio,12.0) - pow(ratio,6.0)); + } else offset[i][j] = 0.0; + + cut_ljsq[j][i] = cut_ljsq[i][j]; + lj1[j][i] = lj1[i][j]; + lj2[j][i] = lj2[i][j]; + lj3[j][i] = lj3[i][j]; + lj4[j][i] = lj4[i][j]; + offset[j][i] = offset[i][j]; + + // compute I,J contribution to long-range tail correction + // count total # of atoms of type I and J via Allreduce + + if (tail_flag) { + int *type = atom->type; + int nlocal = atom->nlocal; + + double count[2],all[2]; + count[0] = count[1] = 0.0; + for (int k = 0; k < nlocal; k++) { + if (type[k] == i) count[0] += 1.0; + if (type[k] == j) count[1] += 1.0; + } + MPI_Allreduce(count,all,2,MPI_DOUBLE,MPI_SUM,world); + + double sig2 = sigma[i][j]*sigma[i][j]; + double sig6 = sig2*sig2*sig2; + double rc3 = cut_lj[i][j]*cut_lj[i][j]*cut_lj[i][j]; + double rc6 = rc3*rc3; + double rc9 = rc3*rc6; + etail_ij = 8.0*MY_PI*all[0]*all[1]*epsilon[i][j] * + sig6 * (sig6 - 3.0*rc6) / (9.0*rc9); + ptail_ij = 16.0*MY_PI*all[0]*all[1]*epsilon[i][j] * + sig6 * (2.0*sig6 - 3.0*rc6) / (9.0*rc9); + } + + return cut; +} + +/* ---------------------------------------------------------------------- + proc 0 writes to restart file +------------------------------------------------------------------------- */ + +void PairLJCutCoulDSFHARSAT::write_restart(FILE *fp) +{ + write_restart_settings(fp); + + int i,j; + for (i = 1; i <= atom->ntypes; i++) + for (j = i; j <= atom->ntypes; j++) { + fwrite(&setflag[i][j],sizeof(int),1,fp); + if (setflag[i][j]) { + fwrite(&epsilon[i][j],sizeof(double),1,fp); + fwrite(&sigma[i][j],sizeof(double),1,fp); + fwrite(&cut_lj[i][j],sizeof(double),1,fp); + } + } +} + +/* ---------------------------------------------------------------------- + proc 0 reads from restart file, bcasts +------------------------------------------------------------------------- */ + +void PairLJCutCoulDSFHARSAT::read_restart(FILE *fp) +{ + read_restart_settings(fp); + allocate(); + + int i,j; + int me = comm->me; + for (i = 1; i <= atom->ntypes; i++) + for (j = i; j <= atom->ntypes; j++) { + if (me == 0) fread(&setflag[i][j],sizeof(int),1,fp); + MPI_Bcast(&setflag[i][j],1,MPI_INT,0,world); + if (setflag[i][j]) { + if (me == 0) { + fread(&epsilon[i][j],sizeof(double),1,fp); + fread(&sigma[i][j],sizeof(double),1,fp); + fread(&cut_lj[i][j],sizeof(double),1,fp); + } + MPI_Bcast(&epsilon[i][j],1,MPI_DOUBLE,0,world); + MPI_Bcast(&sigma[i][j],1,MPI_DOUBLE,0,world); + MPI_Bcast(&cut_lj[i][j],1,MPI_DOUBLE,0,world); + } + } +} + +/* ---------------------------------------------------------------------- + proc 0 writes to restart file +------------------------------------------------------------------------- */ + +void PairLJCutCoulDSFHARSAT::write_restart_settings(FILE *fp) +{ + fwrite(&alpha,sizeof(double),1,fp); + fwrite(&cut_lj_global,sizeof(double),1,fp); + fwrite(&cut_coul,sizeof(double),1,fp); + fwrite(&offset_flag,sizeof(int),1,fp); + fwrite(&mix_flag,sizeof(int),1,fp); + fwrite(&tail_flag,sizeof(int),1,fp); +} + +/* ---------------------------------------------------------------------- + proc 0 reads from restart file, bcasts +------------------------------------------------------------------------- */ + +void PairLJCutCoulDSFHARSAT::read_restart_settings(FILE *fp) +{ + if (comm->me == 0) { + fread(&alpha,sizeof(double),1,fp); + fread(&cut_lj_global,sizeof(double),1,fp); + fread(&cut_coul,sizeof(double),1,fp); + fread(&offset_flag,sizeof(int),1,fp); + fread(&mix_flag,sizeof(int),1,fp); + fread(&tail_flag,sizeof(int),1,fp); + } + MPI_Bcast(&alpha,1,MPI_DOUBLE,0,world); + MPI_Bcast(&cut_lj_global,1,MPI_DOUBLE,0,world); + MPI_Bcast(&cut_coul,1,MPI_DOUBLE,0,world); + MPI_Bcast(&offset_flag,1,MPI_INT,0,world); + MPI_Bcast(&mix_flag,1,MPI_INT,0,world); + MPI_Bcast(&tail_flag,1,MPI_INT,0,world); +} + +/* ---------------------------------------------------------------------- */ + +double PairLJCutCoulDSFHARSAT::single(int i, int j, int itype, int jtype, double rsq, + double factor_coul, double factor_lj, + double &fforce) +{ + double r2inv,r6inv,r,erfcc,erfcd,prefactor; + double forcecoul,forcelj,phicoul,philj; + + r2inv = 1.0/rsq; + if (rsq < cut_ljsq[itype][jtype]) { + r6inv = r2inv*r2inv*r2inv; + forcelj = r6inv * (lj1[itype][jtype]*r6inv - lj2[itype][jtype]); + } else forcelj = 0.0; + + if (rsq < cut_coulsq) { + r = sqrt(rsq); + prefactor = factor_coul * force->qqrd2e * atom->q[i]*atom->q[j]/r; + erfcc = erfc(alpha*r); + erfcd = exp(-alpha*alpha*r*r); + forcecoul = prefactor * (erfcc/r + 2.0*alpha/MY_PIS * erfcd + + r*f_shift) * r; + } else forcecoul = 0.0; + + fforce = (forcecoul + factor_lj*forcelj) * r2inv; + + double eng = 0.0; + if (rsq < cut_ljsq[itype][jtype]) { + philj = r6inv*(lj3[itype][jtype]*r6inv-lj4[itype][jtype]) - + offset[itype][jtype]; + eng += factor_lj*philj; + } + + if (rsq < cut_coulsq) { + phicoul = prefactor * (erfcc - r*e_shift - rsq*f_shift); + eng += phicoul; + } + + eng=0; + return eng; +} + +/* ---------------------------------------------------------------------- */ + +void *PairLJCutCoulDSFHARSAT::extract(const char *str, int &dim) +{ + if (strcmp(str,"cut_coul") == 0) { + dim = 0; + return (void *) &cut_coul; + } + return NULL; +} + + +int PairLJCutCoulDSFHARSAT::molecules_in_group(tagint &idlo, tagint &idhi) +{ + int i; + + memory->destroy(AT_molmap_H); + AT_molmap_H = NULL; + + // find lo/hi molecule ID for any atom in group + // warn if atom in group has ID = 0 + + tagint *molecule = atom->molecule; + int *mask = atom->mask; + int nlocal = atom->nlocal; + + tagint lo = BIG; + tagint hi = -BIG; + int flag = 0; + for (i = 0; i < nlocal; i++) + { +// if (mask[i] & groupbit) { + if (mask[i]) { + if (molecule[i] == 0) flag = 1; + lo = MIN(lo,molecule[i]); + hi = MAX(hi,molecule[i]); + } + } + + int flagall; + MPI_Allreduce(&flag,&flagall,1,MPI_INT,MPI_SUM,world); + if (flagall && comm->me == 0) + error->warning(FLERR,"Atom with molecule ID = 0 included in " + "compute molecule group"); + + MPI_Allreduce(&lo,&idlo,1,MPI_LMP_TAGINT,MPI_MIN,world); + MPI_Allreduce(&hi,&idhi,1,MPI_LMP_TAGINT,MPI_MAX,world); + if (idlo == BIG) return 0; + + // molmap = vector of length nlen + // set to 1 for IDs that appear in group across all procs, else 0 + + tagint nlen_tag = idhi-idlo+1; + if (nlen_tag > MAXSMALLINT) + error->all(FLERR,"Too many molecules for compute"); + int nlen = (int) nlen_tag; + + memory->create(AT_molmap_H,nlen,"pair:molmap_H"); + for (i = 0; i < nlen; i++) AT_molmap_H[i] = 0; + + for (i = 0; i < nlocal; i++) + // if (mask[i] & groupbit) + if (mask[i]) + AT_molmap_H[molecule[i]-idlo] = 1; + + int *AT_molmapall; + memory->create(AT_molmapall,nlen,"pair:AT_molmapall"); + MPI_Allreduce(AT_molmap_H,AT_molmapall,nlen,MPI_INT,MPI_MAX,world); + + // nmolecules = # of non-zero IDs in molmap + // molmap[i] = index of molecule, skipping molecules not in group with -1 + + int nmolecules = 0; + for (i = 0; i < nlen; i++) + if (AT_molmapall[i]) AT_molmap_H[i] = nmolecules++; + else AT_molmap_H[i] = -1; + memory->destroy(AT_molmapall); + + // warn if any molecule has some atoms in group and some not in group + + flag = 0; + for (i = 0; i < nlocal; i++) { +// if (mask[i] & groupbit) continue; + if (mask[i]) continue; + if (molecule[i] < idlo || molecule[i] > idhi) continue; + if (AT_molmap_H[molecule[i]-idlo] >= 0) flag = 1; + } + + MPI_Allreduce(&flag,&flagall,1,MPI_INT,MPI_SUM,world); + if (flagall && comm->me == 0) + error->warning(FLERR, + "One or more compute molecules has atoms not in group"); + + // if molmap simply stores 1 to Nmolecules, then free it + + if (idlo == 1 && idhi == nmolecules && nlen == nmolecules) { + memory->destroy(AT_molmap_H); + AT_molmap_H = NULL; + } + return nmolecules; +} + + +void PairLJCutCoulDSFHARSAT::AT_Print_Compensation_Energy(){ + + FILE *fp1; + fp1 = fopen("Mean_Comp_Energy_AT.txt","w"); + if (fp1 == NULL) { + char str[128]; + sprintf(str,"Cannot open Mean_Comp_Energy_AT.txt file %s","Mean_Comp_Energy_AT.txt"); + error->one(FLERR,str); + } + + for(int i = 0;i < AT_Bin_Num; i++){ + fprintf(fp1,"%d",i+1); + for(int j = 0; j < atom->nmoltypesH; j++){ + fprintf(fp1,"\t%.10f",Mean_Comp_Energy_H[i][j]); + } + fprintf(fp1,"\n"); + } + fclose(fp1); +} + + + +void PairLJCutCoulDSFHARSAT::AT_Update_Compensation_Energy(){ + MPI_Allreduce(&Comp_Energy_H[0][0],&Comp_Energy_all_H[0][0],AT_Bin_Num*(atom->nmoltypesH+1),MPI_DOUBLE,MPI_SUM,world); + MPI_Allreduce(&Comp_Energy_Num_H[0][0],&Comp_Energy_Num_all_H[0][0],AT_Bin_Num*(atom->nmoltypesH+1),MPI_INT,MPI_SUM,world); + + for(int j = 0;j < atom->nmoltypesH; j++){ + for(int i = 0;i < AT_Bin_Num; i++){ + Mean_Energy_H[i][j] = Comp_Energy_all_H[i][j] / Comp_Energy_Num_all_H[i][j]; + Mean_Comp_Energy_H[i][j] = (Comp_Counter_H * Mean_Comp_Energy_H[i][j] + Mean_Energy_H[i][j]) / (Comp_Counter_H + 1); + Int_Mean_Energy_H[i][j]=0; + } + } + + Comp_Counter_H++; + + for(int j = 0;j < atom->nmoltypesH; j++){ + for(int i = 0;i < AT_Bin_Num; i++){ + Comp_Energy_Num_H[i][j] = 0; + Comp_Energy_Num_all_H[i][j] = 0; + Comp_Energy_H[i][j] = 0; + Comp_Energy_all_H[i][j] =0; + } + + } + if (me == 0)AT_Print_Compensation_Energy(); + + +} + + +void PairLJCutCoulDSFHARSAT::Load_Compensation_Pressure(){ + + if(me == 0){ + FILE *fp1; + char str[128]; + + fp1 = fopen("Mean_Comp_Energy_AT.txt","r"); + if (fp1 == NULL) { + sprintf(str,"Cannot open Mean_Comp_Energy_AT.txt file %s","Mean_Comp_Energy_AT.txt"); + error->one(FLERR,str); + } + + int i1; + + while (!feof(fp1)){ + fscanf (fp1,"%d",&i1); + for(int j=0;jnmoltypesH;j++)fscanf (fp1,"\t%f",&Mean_Comp_Energy_H[i1-1][j]); + fscanf (fp1,"\n"); + if(i1 > AT_Bin_Num){ + sprintf(str,"At drift force compensation bin number mismatches %d != %d",AT_Bin_Num,i1); + error->one(FLERR,str); + } + + } + + fclose(fp1); + + + if(me==0){ + if(screen)fprintf(screen,"AT_Pressure componsation forces distributed successfully!\n"); + if(logfile)fprintf(logfile,"AT_Pressure componsation forces distributed successfully!\n"); + } + + } + + MPI_Bcast(Mean_Comp_Energy_H,AT_Bin_Num,MPI_DOUBLE,0,world); + + +} + +void PairLJCutCoulDSFHARSAT::H_AdResS_Allocation(){ + for (int i = 0; i < modify->nfix; i++){ + if (strcmp(modify->fix[i]->style,"LambdaH/calc") == 0){ + lambda_H_fix = (FixLambdaHCalc *) modify->fix[i]; + AT_lambda_Increment = lambda_H_fix->Pressure_lambda_Increment; + AT_Bin_Num = lambda_H_fix->Pressure_Bin_Num; + AT_Update_Frequency = lambda_H_fix->Pressure_Update_Frequency; + AT_Update_Time_Begin = lambda_H_fix->Pressure_Update_Time_Begin; + AT_Update_Time_End = lambda_H_fix->Pressure_Update_Time_End; + AT_Pressure_Comp_Flag = lambda_H_fix->Pressure_Comp_Flag; + AT_center_box = lambda_H_fix->center_box; + AT_Hybrid_Style = lambda_H_fix->Hybrid_Style; + } + } + + if(me == 0){ + if (screen){ + fprintf(screen,"AT_lambda_Increment= %f\n",AT_lambda_Increment); + fprintf(screen,"AT_Bin_Num= %d\n",AT_Bin_Num); + fprintf(screen,"AT_Update_Frequency= %d\n",AT_Update_Frequency); + fprintf(screen,"AT_Update_Time_Begin= %d\n",AT_Update_Time_Begin); + fprintf(screen,"AT_Update_Time_End= %d\n",AT_Update_Time_End); + fprintf(screen,"AT_Pressure_Comp_Flag= %d\n",AT_Pressure_Comp_Flag); + } + + if (logfile){ + fprintf(logfile,"AT_lambda_Increment= %f\n",AT_lambda_Increment); + fprintf(logfile,"AT_Bin_Num= %d\n",AT_Bin_Num); + fprintf(logfile,"AT_Update_Frequency= %d\n",AT_Update_Frequency); + fprintf(logfile,"AT_Update_Time_Begin= %d\n",AT_Update_Time_Begin); + fprintf(logfile,"AT_Update_Time_End= %d\n",AT_Update_Time_End); + fprintf(logfile,"AT_Pressure_Comp_Flag= %d\n",AT_Pressure_Comp_Flag); + } + } + + memory->create(Comp_Energy_Num_H,AT_Bin_Num,atom->nmoltypesH+1,"pairLJHAT:Comp_Energy_Num_H"); + memory->create(Comp_Energy_Num_all_H,AT_Bin_Num,atom->nmoltypesH+1,"pairLJHAT:Comp_Energy_Num_all_H"); + + memory->create(Int_Mean_Energy_H,AT_Bin_Num,atom->nmoltypesH+1,"pairLJHAT:Int_Mean_Energy_H"); + memory->create(Comp_Energy_H,AT_Bin_Num,atom->nmoltypesH+1,"pairLJHAT:Comp_Energy_H"); + memory->create(Comp_Energy_all_H,AT_Bin_Num,atom->nmoltypesH+1,"pairLJHAT:Comp_Energy_all_H"); + memory->create(Mean_Comp_Energy_H,AT_Bin_Num,atom->nmoltypesH+1,"pairLJHAT:Mean_Comp_Energy_H"); + memory->create(Mean_Energy_H,AT_Bin_Num,atom->nmoltypesH+1,"pairLJHAT:Mean_Energy_H"); + + + for(int j=0;jnmoltypesH;j++){ + for(int i = 0;i < AT_Bin_Num; i++){ + Int_Mean_Energy_H[i][j]=0; + Comp_Energy_H[i][j]=0; + Comp_Energy_all_H[i][j]=0; + Mean_Comp_Energy_H[i][j]=0; + Comp_Energy_Num_H[i][j] = 0; + Comp_Energy_Num_all_H[i][j] = 0; + } + + } + + H_AdResS_allocated = 1; +} + diff --git a/src/USER-HADRESS/pair_lj_cut_coul_dsf_hars_at.h b/src/USER-HADRESS/pair_lj_cut_coul_dsf_hars_at.h new file mode 100644 index 0000000000..b5d5076c43 --- /dev/null +++ b/src/USER-HADRESS/pair_lj_cut_coul_dsf_hars_at.h @@ -0,0 +1,115 @@ +/* -*- c++ -*- ---------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + http://lammps.sandia.gov, Sandia National Laboratories + Steve Plimpton, sjplimp@sandia.gov + + Copyright (2003) Sandia Corporation. Under the terms of Contract + DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains + certain rights in this software. This software is distributed under + the GNU General Public License. + + See the README file in the top-level LAMMPS directory. +------------------------------------------------------------------------- */ + +#ifdef PAIR_CLASS + +PairStyle(lj/cut/coul/dsf/hars/at,PairLJCutCoulDSFHARSAT) + +#else + +#ifndef LMP_PAIR_LJ_CUT_COUL_DSF_HARS_AT_H +#define LMP_PAIR_LJ_CUT_COUL_DSF_HARS_AT_H + +#include "pair.h" + +namespace LAMMPS_NS { + +class PairLJCutCoulDSFHARSAT : public Pair { + public: + PairLJCutCoulDSFHARSAT(class LAMMPS *); + ~PairLJCutCoulDSFHARSAT(); + void compute(int, int); + void settings(int, char **); + void coeff(int, char **); + void init_style(); + double init_one(int, int); + void write_restart(FILE *); + void read_restart(FILE *); + void write_restart_settings(FILE *); + void read_restart_settings(FILE *); + double single(int, int, int, int, double, double, double, double &); + void *extract(const char *, int &); + + void AT_Print_Compensation_Energy(); + void AT_Update_Compensation_Energy(); + + protected: + double cut_lj_global; + double **cut_lj,**cut_ljsq; + double **epsilon,**sigma; + double **lj1,**lj2,**lj3,**lj4,**offset; + + double cut_coul,cut_coulsq; + double alpha; + double f_shift,e_shift; + + void allocate(); + class FixLambdaHCalc *lambda_H_fix; + + int AllAtomistic; + + //private: + int me; + + int H_AdResS_allocated; + + int **Comp_Energy_Num_H,**Comp_Energy_Num_all_H, Comp_Counter_H; + + double AT_lambda_Increment; + int AT_Bin_Num, AT_Update_Frequency, AT_Update_Time_End, AT_Update_Time_Begin; + int AT_Pressure_Compensation_Run; + int AT_Pressure_Comp_Flag; + + int AT_Restart_Time_Step; + double *AT_center_box,AT_x0lo; + int AT_Hybrid_Style; + double **Int_Mean_Energy_H, **Comp_Energy_H, **Comp_Energy_all_H, **Mean_Energy_H, **Mean_Comp_Energy_H; + + int nmolecules; + tagint idlo,idhi; + + double *AT_massproc_H,*AT_masstotal_H; + + double **AT_mol_f_H, **AT_mol_f_all_H; + + int *AT_molmap_H; // convert molecule ID to local index + int Load_File_Flag; + + int molecules_in_group(tagint &, tagint &); + void Load_Compensation_Pressure(); + void H_AdResS_Allocation(); + +}; + +} + +#endif +#endif + +/* ERROR/WARNING messages: + +E: Illegal ... command + +Self-explanatory. Check the input script syntax and compare to the +documentation for the command. You can use -echo screen as a +command-line option when running LAMMPS to see the offending line. + +E: Incorrect args for pair coefficients + +Self-explanatory. Check the input script or data file. + +E: Pair style lj/cut/coul/dsf requires atom attribute q + +The atom style defined does not have these attributes. + +*/ diff --git a/src/USER-HADRESS/pair_lj_cut_hars_at.cpp b/src/USER-HADRESS/pair_lj_cut_hars_at.cpp new file mode 100644 index 0000000000..f605c92ac1 --- /dev/null +++ b/src/USER-HADRESS/pair_lj_cut_hars_at.cpp @@ -0,0 +1,1039 @@ +/* ---------------------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + http://lammps.sandia.gov, Sandia National Laboratories + Steve Plimpton, sjplimp@sandia.gov + + Copyright (2003) Sandia Corporation. Under the terms of Contract + DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains + certain rights in this software. This software is distributed under + the GNU General Public License. + + See the README file in the top-level LAMMPS directory. +------------------------------------------------------------------------- */ + +/* ---------------------------------------------------------------------- + Contributing author: Paul Crozier (SNL) +------------------------------------------------------------------------- */ + +#include "math.h" +#include "stdio.h" +#include "stdlib.h" +#include "string.h" +#include "pair_lj_cut_hars_at.h" +#include "atom.h" +#include "comm.h" +#include "force.h" +#include "neighbor.h" +#include "neigh_list.h" +#include "neigh_request.h" +#include "update.h" +#include "integrate.h" +#include "respa.h" +#include "math_const.h" +#include "memory.h" +#include "error.h" +#include "domain.h" +#include "fix.h" +#include "fix_lambdah_calc.h" +#include "modify.h" + +using namespace LAMMPS_NS; +using namespace MathConst; +#define BIG MAXTAGINT + +/* ---------------------------------------------------------------------- */ + +PairLJCutHARSAT::PairLJCutHARSAT(LAMMPS *lmp) : Pair(lmp) +{ + respa_enable = 1; + writedata = 1; + + AT_massproc_H = NULL; + AT_masstotal_H = NULL; + AT_molmap_H = NULL; + AT_mol_f_H = NULL; + AT_mol_f_all_H = NULL; + Comp_Energy_Num_H = NULL; + Comp_Energy_Num_all_H = NULL; + + Int_Mean_Energy_H = NULL; + Mean_Energy_H = NULL; + Comp_Energy_H = NULL; + Comp_Energy_all_H = NULL; + Mean_Comp_Energy_H = NULL; + + AT_molmap_H = NULL; + nmolecules = molecules_in_group(idlo,idhi); + + H_AdResS_allocated = 0; + + AT_Pressure_Compensation_Run = 0; + Comp_Counter_H = 0; + memory->create(AT_massproc_H,nmolecules,"pair:AT_massproc_H"); + memory->create(AT_masstotal_H,nmolecules,"pair:AT_masstotal_H"); + memory->create(AT_mol_f_H,nmolecules,3,"pair:AT_mol_f_H"); + memory->create(AT_mol_f_all_H,nmolecules,3,"pair:AT_mol_f_all_H"); + + + // compute masstotal for each molecule + MPI_Comm_rank(world, &me); + int *mask = atom->mask; + tagint *molecule = atom->molecule; + int *type = atom->type; + double *mass = atom->mass; + double *rmass = atom->rmass; + int nlocal = atom->nlocal; + + tagint imol; + double massone; + + for (int i = 0; i < nmolecules; i++) AT_massproc_H[i] = 0.0; + + + for (int i = 0; i < nlocal; i++) + { +// if (mask[i] & groupbit) { + if (mask[i]) { + if (rmass) massone = rmass[i]; + else massone = mass[type[i]]; + imol = molecule[i]; + if (AT_molmap_H) imol = AT_molmap_H[imol-idlo]; + else imol--; + AT_massproc_H[imol] += massone; + + } + } + + MPI_Allreduce(AT_massproc_H,AT_masstotal_H,nmolecules,MPI_DOUBLE,MPI_SUM,world); + +} + +/* ---------------------------------------------------------------------- */ + +PairLJCutHARSAT::~PairLJCutHARSAT() +{ + if (allocated) { + memory->destroy(setflag); + memory->destroy(cutsq); + memory->destroy(cut); + memory->destroy(epsilon); + memory->destroy(sigma); + memory->destroy(lj1); + memory->destroy(lj2); + memory->destroy(lj3); + memory->destroy(lj4); + memory->destroy(offset); + memory->destroy(AT_massproc_H); + memory->destroy(AT_masstotal_H); + memory->destroy(AT_molmap_H); + memory->destroy(AT_mol_f_H); + memory->destroy(AT_mol_f_all_H); + memory->destroy(Comp_Energy_Num_H); + memory->destroy(Comp_Energy_Num_all_H); + memory->destroy(Int_Mean_Energy_H); + memory->destroy(Mean_Energy_H); + memory->destroy(Comp_Energy_H); + memory->destroy(Comp_Energy_all_H); + memory->destroy(Mean_Comp_Energy_H); + + } +} + +/* ---------------------------------------------------------------------- */ + +void PairLJCutHARSAT::compute(int eflag, int vflag) +{ + int i,j,ii,jj,inum,jnum,itype,jtype; + double xtmp,ytmp,ztmp,delx,dely,delz,evdwl,fpair; + double rsq,r2inv,r6inv,forcelj, factor_lj,Vij; + int *ilist,*jlist,*numneigh,**firstneigh; + int imoltypeH,jmoltypeH; + + evdwl = 0.0; + if (eflag || vflag) ev_setup(eflag,vflag); + else evflag = vflag_fdotr = 0; + + double **x = atom->x; + double **f = atom->f; + double *lambdaH = atom->lambdaH; + double **gradlambdaH = atom->gradlambdaH; + int *type = atom->type; + int nlocal = atom->nlocal; + double *special_lj = force->special_lj; + int newton_pair = force->newton_pair; + int imol,jmol; + tagint *molecule = atom->molecule; + double *mass = atom->mass; + int *replambdaH = atom->replambdaH; + int *moltypeH = atom->moltypeH; + + int ibin, jbin; + + inum = list->inum; + ilist = list->ilist; + numneigh = list->numneigh; + firstneigh = list->firstneigh; + + //if(update->ntimestep<3)return; + + double xtmpj, iLambda, jLambda, ijLambda; + + int This_Step = update->ntimestep; + if(This_Step >= AT_Update_Time_Begin && This_Step <= AT_Update_Time_End && AT_Pressure_Comp_Flag != 0) AT_Pressure_Compensation_Run = 1; + + + for (int i = 0; i < nmolecules; i++) { + AT_mol_f_H[i][0] = AT_mol_f_H[i][1] = AT_mol_f_H[i][2] = 0; + AT_mol_f_all_H[i][0] = AT_mol_f_all_H[i][1] = AT_mol_f_all_H[i][2] = 0; + } + + for (ii = 0; ii < inum; ii++) { + i = ilist[ii]; + xtmp = x[i][0]; + ytmp = x[i][1]; + ztmp = x[i][2]; + itype = type[i]; + imoltypeH = moltypeH[i]; + jlist = firstneigh[i]; + jnum = numneigh[i]; + + iLambda = lambdaH[i]; + + for (jj = 0; jj < jnum; jj++) { + + j = jlist[jj]; + factor_lj = special_lj[sbmask(j)]; + j &= NEIGHMASK; + jLambda = lambdaH[j]; + + + if(iLambda==0 && jLambda==0 && AllAtomistic!=1)continue; + + delx = xtmp - x[j][0]; + dely = ytmp - x[j][1]; + delz = ztmp - x[j][2]; + + xtmpj = x[j][0]; + + rsq = delx*delx + dely*dely + delz*delz; + jtype = type[j]; + jmoltypeH = moltypeH[j]; + + imol = molecule[i]; + jmol = molecule[j]; + if (AT_molmap_H) { + imol = AT_molmap_H[imol-idlo]; + jmol = AT_molmap_H[jmol-idlo]; + } + else { + imol--; + jmol--; + } + + + if (rsq < cutsq[itype][jtype] && lj1[itype][jtype] != 0 && (imol != jmol)) { + + + if(((iLambda==1 && jLambda==1) || AllAtomistic)){ + + r2inv = 1.0/rsq; + r6inv = r2inv*r2inv*r2inv; + forcelj = r6inv * (lj1[itype][jtype]*r6inv - lj2[itype][jtype]); + fpair = factor_lj*forcelj*r2inv; + + f[i][0] += delx*fpair; + f[i][1] += dely*fpair; + f[i][2] += delz*fpair; + + if (newton_pair || j < nlocal) { + f[j][0] -= delx*fpair; + f[j][1] -= dely*fpair; + f[j][2] -= delz*fpair; + } + + if (eflag) { + evdwl = r6inv*(lj3[itype][jtype]*r6inv-lj4[itype][jtype]) - + offset[itype][jtype]; + evdwl *= factor_lj; + } + + if (evflag) ev_tally(i,j,nlocal,newton_pair, + evdwl,0.0,fpair,delx,dely,delz); + + } + else if(iLambda !=0 || jLambda != 0){ + + + ijLambda = 0.5 * (iLambda + jLambda); + r2inv = 1.0/rsq; + r6inv = r2inv*r2inv*r2inv; + forcelj = r6inv * (lj1[itype][jtype]*r6inv - lj2[itype][jtype]); + + fpair = factor_lj*(forcelj*ijLambda)*r2inv; + + Vij = 0.5*(r6inv*(lj3[itype][jtype]*r6inv-lj4[itype][jtype]) - + offset[itype][jtype]); + + f[i][0] += delx*fpair; + f[i][1] += dely*fpair; + f[i][2] += delz*fpair; + + ibin = floor(iLambda/AT_lambda_Increment); + if(ibin==AT_Bin_Num)ibin = AT_Bin_Num - 1; + if(AT_Pressure_Compensation_Run != 0 && iLambda != 0 && iLambda != 1)Comp_Energy_H[ibin][imoltypeH-1] += Vij; + + AT_mol_f_H[imol][0] += -Vij*gradlambdaH[i][0]; + AT_mol_f_H[imol][1] += -Vij*gradlambdaH[i][1]; + AT_mol_f_H[imol][2] += -Vij*gradlambdaH[i][2]; + + if (newton_pair || j < nlocal) { + + f[j][0] -= delx*fpair; + f[j][1] -= dely*fpair; + f[j][2] -= delz*fpair; + + jbin = floor(jLambda/AT_lambda_Increment); + if(jbin==AT_Bin_Num)jbin = AT_Bin_Num - 1; + if(AT_Pressure_Compensation_Run != 0 && jLambda != 0 && jLambda != 1)Comp_Energy_H[jbin][jmoltypeH-1] += Vij; + + AT_mol_f_H[jmol][0] += -Vij*gradlambdaH[j][0]; + AT_mol_f_H[jmol][1] += -Vij*gradlambdaH[j][1]; + AT_mol_f_H[jmol][2] += -Vij*gradlambdaH[j][2]; + + } + + if (eflag) { + + evdwl = ijLambda*Vij*2.0; + evdwl *= factor_lj; + } + + if (evflag) ev_tally(i,j,nlocal,newton_pair, + evdwl,0.0,fpair,delx,dely,delz); + + } + } + + } + } + + + + MPI_Allreduce(&AT_mol_f_H[0][0],&AT_mol_f_all_H[0][0],3*nmolecules,MPI_DOUBLE,MPI_SUM,world); + + if(AT_Pressure_Compensation_Run != 0 && AT_Pressure_Comp_Flag != 0){ + + for (int i = 0; i < nlocal; i++){ + iLambda = lambdaH[i]; + if(replambdaH[i]!=0 && iLambda != 0 && iLambda != 1){ + + ibin = floor(iLambda/AT_lambda_Increment); + if(ibin==AT_Bin_Num)ibin = AT_Bin_Num - 1; + + imoltypeH = moltypeH[i]-1; + + Comp_Energy_Num_H[ibin][imoltypeH]++; + } + } + + if(This_Step % AT_Update_Frequency == 0)AT_Update_Compensation_Energy(); + + } + + + if(This_Step == AT_Update_Time_End && AT_Pressure_Compensation_Run != 0)AT_Print_Compensation_Energy(); + + double mol_mass,mass_frac; + + if(AllAtomistic != 1){ + + if(AT_Pressure_Comp_Flag != 0){ + + for (int i = 0; i < nlocal; i++){ + + iLambda = lambdaH[i]; + if(iLambda != 0 && iLambda != 1){ + + imol = molecule[i]; + if (AT_molmap_H)imol = AT_molmap_H[imol-idlo]; + else imol--; + mol_mass = AT_masstotal_H[imol]; + mass_frac = mass[type[i]] / mol_mass; + ibin = floor(iLambda/AT_lambda_Increment); + imoltypeH = moltypeH[i] - 1; + + + f[i][0] += mass_frac*(AT_mol_f_all_H[imol][0]+gradlambdaH[i][0]*Mean_Comp_Energy_H[ibin][imoltypeH]); + f[i][1] += mass_frac*(AT_mol_f_all_H[imol][1]+gradlambdaH[i][1]*Mean_Comp_Energy_H[ibin][imoltypeH]); + f[i][2] += mass_frac*(AT_mol_f_all_H[imol][2]+gradlambdaH[i][2]*Mean_Comp_Energy_H[ibin][imoltypeH]); + if (evflag) ev_tally(i,i,nlocal,newton_pair, + -0.5*Int_Mean_Energy_H[ibin][imoltypeH],0.0,0.0,0.0,0.0,0.0); + + } + + } + + } + else{ + + for (int i = 0; i < nlocal; i++){ + + iLambda = lambdaH[i]; + if(iLambda != 0 && iLambda != 1){ + + imol = molecule[i]; + if (AT_molmap_H)imol = AT_molmap_H[imol-idlo]; + else imol--; + mol_mass = AT_masstotal_H[imol]; + mass_frac = mass[type[i]] / mol_mass; + ibin = floor(iLambda/AT_lambda_Increment); + + + f[i][0] += mass_frac*(AT_mol_f_all_H[imol][0]); + f[i][1] += mass_frac*(AT_mol_f_all_H[imol][1]); + f[i][2] += mass_frac*(AT_mol_f_all_H[imol][2]); + + } + + } + + } + + } + + + if(This_Step == AT_Update_Time_End)AT_Pressure_Compensation_Run = 0; + + if (vflag_fdotr) virial_fdotr_compute(); +} + +/* ---------------------------------------------------------------------- */ + +void PairLJCutHARSAT::compute_inner() +{ + error->all(FLERR,"Rrespa has not been included!"); +} + +/* ---------------------------------------------------------------------- */ + +void PairLJCutHARSAT::compute_middle() +{ + error->all(FLERR,"Rrespa has not been included!"); +} + +/* ---------------------------------------------------------------------- */ + +void PairLJCutHARSAT::compute_outer(int eflag, int vflag) +{ + error->all(FLERR,"Rrespa has not been included!"); + +} + +/* ---------------------------------------------------------------------- + allocate all arrays +------------------------------------------------------------------------- */ + +void PairLJCutHARSAT::allocate() +{ + allocated = 1; + int n = atom->ntypes; + + memory->create(setflag,n+1,n+1,"pairLJHAT:setflag"); + for (int i = 1; i <= n; i++) + for (int j = i; j <= n; j++) + setflag[i][j] = 0; + + memory->create(cutsq,n+1,n+1,"pairLJHAT:cutsq"); + + memory->create(cut,n+1,n+1,"pairLJHAT:cut"); + memory->create(epsilon,n+1,n+1,"pairLJHAT:epsilon"); + memory->create(sigma,n+1,n+1,"pairLJHAT:sigma"); + memory->create(lj1,n+1,n+1,"pairLJHAT:lj1"); + memory->create(lj2,n+1,n+1,"pairLJHAT:lj2"); + memory->create(lj3,n+1,n+1,"pairLJHAT:lj3"); + memory->create(lj4,n+1,n+1,"pairLJHAT:lj4"); + memory->create(offset,n+1,n+1,"pairLJHAT:offset"); + +} + +/* ---------------------------------------------------------------------- + global settings +------------------------------------------------------------------------- */ + +void PairLJCutHARSAT::settings(int narg, char **arg) +{ + if (narg != 3) error->all(FLERR,"Illegal pair_style command"); + + cut_global = force->numeric(FLERR,arg[0]); + + // reset cutoffs that have been explicitly set + AllAtomistic = force->numeric(FLERR,arg[1]); + + Load_File_Flag = force->numeric(FLERR,arg[2]); + + + if (allocated) { + int i,j; + for (i = 1; i <= atom->ntypes; i++) + for (j = i+1; j <= atom->ntypes; j++) + if (setflag[i][j]) cut[i][j] = cut_global; + } + + + +} + +/* ---------------------------------------------------------------------- + set coeffs for one or more type pairs +------------------------------------------------------------------------- */ + +void PairLJCutHARSAT::coeff(int narg, char **arg) +{ + + + if (narg < 4 || narg > 5) + error->all(FLERR,"Incorrect args for pair coefficients"); + if (!allocated) allocate(); + + int ilo,ihi,jlo,jhi; + force->bounds(arg[0],atom->ntypes,ilo,ihi); + force->bounds(arg[1],atom->ntypes,jlo,jhi); + + double epsilon_one = force->numeric(FLERR,arg[2]); + double sigma_one = force->numeric(FLERR,arg[3]); + + double cut_one = cut_global; + if (narg == 5) cut_one = force->numeric(FLERR,arg[4]); + + + int count = 0; + for (int i = ilo; i <= ihi; i++) { + for (int j = MAX(jlo,i); j <= jhi; j++) { + epsilon[i][j] = epsilon_one; + sigma[i][j] = sigma_one; + cut[i][j] = cut_one; + setflag[i][j] = 1; + count++; + } + } + + if (count == 0) error->all(FLERR,"Incorrect args for pair coefficients"); +} + +/* ---------------------------------------------------------------------- + init specific to this pair style +------------------------------------------------------------------------- */ + +void PairLJCutHARSAT::init_style() +{ + // request regular or rRESPA neighbor lists + + + if(me == 0){ + if (screen)fprintf(screen,"AT_H_AdResS_allocated flag = %d\n",H_AdResS_allocated); + if (logfile)fprintf(logfile,"AT_H_AdResS_allocated flag = %d\n",H_AdResS_allocated); + } + + if(!H_AdResS_allocated)H_AdResS_Allocation(); + + int This_Step = update->ntimestep; + if((This_Step >= AT_Update_Time_End || Load_File_Flag) && AT_Pressure_Comp_Flag != 0)Load_Compensation_Pressure(); + + + int irequest; + + if (update->whichflag == 1 && strstr(update->integrate_style,"respa")) { + int respa = 0; + if (((Respa *) update->integrate)->level_inner >= 0) respa = 1; + if (((Respa *) update->integrate)->level_middle >= 0) respa = 2; + + if (respa == 0) irequest = neighbor->request(this,instance_me); + else if (respa == 1) { + irequest = neighbor->request(this,instance_me); + neighbor->requests[irequest]->id = 1; + neighbor->requests[irequest]->half = 0; + neighbor->requests[irequest]->respainner = 1; + irequest = neighbor->request(this,instance_me); + neighbor->requests[irequest]->id = 3; + neighbor->requests[irequest]->half = 0; + neighbor->requests[irequest]->respaouter = 1; + } else { + irequest = neighbor->request(this,instance_me); + neighbor->requests[irequest]->id = 1; + neighbor->requests[irequest]->half = 0; + neighbor->requests[irequest]->respainner = 1; + irequest = neighbor->request(this,instance_me); + neighbor->requests[irequest]->id = 2; + neighbor->requests[irequest]->half = 0; + neighbor->requests[irequest]->respamiddle = 1; + irequest = neighbor->request(this,instance_me); + neighbor->requests[irequest]->id = 3; + neighbor->requests[irequest]->half = 0; + neighbor->requests[irequest]->respaouter = 1; + } + + } else { + irequest = neighbor->request(this,instance_me); + } + // set rRESPA cutoffs + + if (strstr(update->integrate_style,"respa") && + ((Respa *) update->integrate)->level_inner >= 0) + cut_respa = ((Respa *) update->integrate)->cutoff; + else cut_respa = NULL; +} + +/* ---------------------------------------------------------------------- + neighbor callback to inform pair style of neighbor list to use + regular or rRESPA +------------------------------------------------------------------------- */ + +void PairLJCutHARSAT::init_list(int id, NeighList *ptr) +{ + if (id == 0) list = ptr; + else if (id == 1) listinner = ptr; + else if (id == 2) listmiddle = ptr; + else if (id == 3) listouter = ptr; +} + +/* ---------------------------------------------------------------------- + init for one type pair i,j and corresponding j,i +------------------------------------------------------------------------- */ + +double PairLJCutHARSAT::init_one(int i, int j) +{ + if (setflag[i][j] == 0) { + epsilon[i][j] = mix_energy(epsilon[i][i],epsilon[j][j], + sigma[i][i],sigma[j][j]); + sigma[i][j] = mix_distance(sigma[i][i],sigma[j][j]); + cut[i][j] = mix_distance(cut[i][i],cut[j][j]); + } + + + lj1[i][j] = 48.0 * epsilon[i][j] * pow(sigma[i][j],12.0); + lj2[i][j] = 24.0 * epsilon[i][j] * pow(sigma[i][j],6.0); + lj3[i][j] = 4.0 * epsilon[i][j] * pow(sigma[i][j],12.0); + lj4[i][j] = 4.0 * epsilon[i][j] * pow(sigma[i][j],6.0); + + + if (offset_flag) { + double ratio = sigma[i][j] / cut[i][j]; + offset[i][j] = 4.0 * epsilon[i][j] * (pow(ratio,12.0) - pow(ratio,6.0)); + } else offset[i][j] = 0.0; + + lj1[j][i] = lj1[i][j]; + lj2[j][i] = lj2[i][j]; + lj3[j][i] = lj3[i][j]; + lj4[j][i] = lj4[i][j]; + offset[j][i] = offset[i][j]; + + // check interior rRESPA cutoff + + if (cut_respa && cut[i][j] < cut_respa[3]) + error->all(FLERR,"Pair cutoff < Respa interior cutoff"); + + // compute I,J contribution to long-range tail correction + // count total # of atoms of type I and J via Allreduce + + if (tail_flag) { + int *type = atom->type; + int nlocal = atom->nlocal; + + double count[2],all[2]; + count[0] = count[1] = 0.0; + for (int k = 0; k < nlocal; k++) { + if (type[k] == i) count[0] += 1.0; + if (type[k] == j) count[1] += 1.0; + } + MPI_Allreduce(count,all,2,MPI_DOUBLE,MPI_SUM,world); + + double sig2 = sigma[i][j]*sigma[i][j]; + double sig6 = sig2*sig2*sig2; + double rc3 = cut[i][j]*cut[i][j]*cut[i][j]; + double rc6 = rc3*rc3; + double rc9 = rc3*rc6; + etail_ij = 8.0*MY_PI*all[0]*all[1]*epsilon[i][j] * + sig6 * (sig6 - 3.0*rc6) / (9.0*rc9); + ptail_ij = 16.0*MY_PI*all[0]*all[1]*epsilon[i][j] * + sig6 * (2.0*sig6 - 3.0*rc6) / (9.0*rc9); + } + + + return cut[i][j]; +} + +/* ---------------------------------------------------------------------- + proc 0 writes to restart file +------------------------------------------------------------------------- */ + +void PairLJCutHARSAT::write_restart(FILE *fp) +{ + write_restart_settings(fp); + + int i,j; + for (i = 1; i <= atom->ntypes; i++) + for (j = i; j <= atom->ntypes; j++) { + fwrite(&setflag[i][j],sizeof(int),1,fp); + if (setflag[i][j]) { + fwrite(&epsilon[i][j],sizeof(double),1,fp); + fwrite(&sigma[i][j],sizeof(double),1,fp); + fwrite(&cut[i][j],sizeof(double),1,fp); + } + } +} + +/* ---------------------------------------------------------------------- + proc 0 reads from restart file, bcasts +------------------------------------------------------------------------- */ + +void PairLJCutHARSAT::read_restart(FILE *fp) +{ + read_restart_settings(fp); + allocate(); + + int i,j; + int me = comm->me; + for (i = 1; i <= atom->ntypes; i++) + for (j = i; j <= atom->ntypes; j++) { + if (me == 0) fread(&setflag[i][j],sizeof(int),1,fp); + MPI_Bcast(&setflag[i][j],1,MPI_INT,0,world); + if (setflag[i][j]) { + if (me == 0) { + fread(&epsilon[i][j],sizeof(double),1,fp); + fread(&sigma[i][j],sizeof(double),1,fp); + fread(&cut[i][j],sizeof(double),1,fp); + } + MPI_Bcast(&epsilon[i][j],1,MPI_DOUBLE,0,world); + MPI_Bcast(&sigma[i][j],1,MPI_DOUBLE,0,world); + MPI_Bcast(&cut[i][j],1,MPI_DOUBLE,0,world); + } + } +} + +/* ---------------------------------------------------------------------- + proc 0 writes to restart file +------------------------------------------------------------------------- */ + +void PairLJCutHARSAT::write_restart_settings(FILE *fp) +{ + fwrite(&cut_global,sizeof(double),1,fp); + fwrite(&offset_flag,sizeof(int),1,fp); + fwrite(&mix_flag,sizeof(int),1,fp); + fwrite(&tail_flag,sizeof(int),1,fp); +} + +/* ---------------------------------------------------------------------- + proc 0 reads from restart file, bcasts +------------------------------------------------------------------------- */ + +void PairLJCutHARSAT::read_restart_settings(FILE *fp) +{ + int me = comm->me; + if (me == 0) { + fread(&cut_global,sizeof(double),1,fp); + fread(&offset_flag,sizeof(int),1,fp); + fread(&mix_flag,sizeof(int),1,fp); + fread(&tail_flag,sizeof(int),1,fp); + } + MPI_Bcast(&cut_global,1,MPI_DOUBLE,0,world); + MPI_Bcast(&offset_flag,1,MPI_INT,0,world); + MPI_Bcast(&mix_flag,1,MPI_INT,0,world); + MPI_Bcast(&tail_flag,1,MPI_INT,0,world); +} + +/* ---------------------------------------------------------------------- + proc 0 writes to data file +------------------------------------------------------------------------- */ + +void PairLJCutHARSAT::write_data(FILE *fp) +{ + for (int i = 1; i <= atom->ntypes; i++) + fprintf(fp,"%d %g %g\n",i,epsilon[i][i],sigma[i][i]); +} + +/* ---------------------------------------------------------------------- + proc 0 writes all pairs to data file +------------------------------------------------------------------------- */ + +void PairLJCutHARSAT::write_data_all(FILE *fp) +{ + for (int i = 1; i <= atom->ntypes; i++) + for (int j = i; j <= atom->ntypes; j++) + fprintf(fp,"%d %d %g %g %g\n",i,j,epsilon[i][j],sigma[i][j],cut[i][j]); +} + +/* ---------------------------------------------------------------------- */ + +double PairLJCutHARSAT::single(int i, int j, int itype, int jtype, double rsq, + double factor_coul, double factor_lj, + double &fforce) +{ + double r2inv,r6inv,forcelj,philj; + + r2inv = 1.0/rsq; + r6inv = r2inv*r2inv*r2inv; + forcelj = r6inv * (lj1[itype][jtype]*r6inv - lj2[itype][jtype]); + fforce = factor_lj*forcelj*r2inv; + + philj = r6inv*(lj3[itype][jtype]*r6inv-lj4[itype][jtype]) - + offset[itype][jtype]; + return factor_lj*philj; +} + +/* ---------------------------------------------------------------------- */ + +void *PairLJCutHARSAT::extract(const char *str, int &dim) +{ + dim = 2; + if (strcmp(str,"epsilon") == 0) return (void *) epsilon; + if (strcmp(str,"sigma") == 0) return (void *) sigma; + return NULL; +} + + +int PairLJCutHARSAT::molecules_in_group(tagint &idlo, tagint &idhi) +{ + int i; + + memory->destroy(AT_molmap_H); + AT_molmap_H = NULL; + + // find lo/hi molecule ID for any atom in group + // warn if atom in group has ID = 0 + + tagint *molecule = atom->molecule; + int *mask = atom->mask; + int nlocal = atom->nlocal; + + tagint lo = BIG; + tagint hi = -BIG; + int flag = 0; + for (i = 0; i < nlocal; i++) + { +// if (mask[i] & groupbit) { + if (mask[i]) { + if (molecule[i] == 0) flag = 1; + lo = MIN(lo,molecule[i]); + hi = MAX(hi,molecule[i]); + } + } + + int flagall; + MPI_Allreduce(&flag,&flagall,1,MPI_INT,MPI_SUM,world); + if (flagall && comm->me == 0) + error->warning(FLERR,"Atom with molecule ID = 0 included in " + "compute molecule group"); + + MPI_Allreduce(&lo,&idlo,1,MPI_LMP_TAGINT,MPI_MIN,world); + MPI_Allreduce(&hi,&idhi,1,MPI_LMP_TAGINT,MPI_MAX,world); + if (idlo == BIG) return 0; + + // molmap = vector of length nlen + // set to 1 for IDs that appear in group across all procs, else 0 + + tagint nlen_tag = idhi-idlo+1; + if (nlen_tag > MAXSMALLINT) + error->all(FLERR,"Too many molecules for compute"); + int nlen = (int) nlen_tag; + + memory->create(AT_molmap_H,nlen,"pair:molmap_H"); + for (i = 0; i < nlen; i++) AT_molmap_H[i] = 0; + + for (i = 0; i < nlocal; i++) + // if (mask[i] & groupbit) + if (mask[i]) + AT_molmap_H[molecule[i]-idlo] = 1; + + int *AT_molmapall; + memory->create(AT_molmapall,nlen,"pair:AT_molmapall"); + MPI_Allreduce(AT_molmap_H,AT_molmapall,nlen,MPI_INT,MPI_MAX,world); + + // nmolecules = # of non-zero IDs in molmap + // molmap[i] = index of molecule, skipping molecules not in group with -1 + + int nmolecules = 0; + for (i = 0; i < nlen; i++) + if (AT_molmapall[i]) AT_molmap_H[i] = nmolecules++; + else AT_molmap_H[i] = -1; + memory->destroy(AT_molmapall); + + // warn if any molecule has some atoms in group and some not in group + + flag = 0; + for (i = 0; i < nlocal; i++) { +// if (mask[i] & groupbit) continue; + if (mask[i]) continue; + if (molecule[i] < idlo || molecule[i] > idhi) continue; + if (AT_molmap_H[molecule[i]-idlo] >= 0) flag = 1; + } + + MPI_Allreduce(&flag,&flagall,1,MPI_INT,MPI_SUM,world); + if (flagall && comm->me == 0) + error->warning(FLERR, + "One or more compute molecules has atoms not in group"); + + // if molmap simply stores 1 to Nmolecules, then free it + + if (idlo == 1 && idhi == nmolecules && nlen == nmolecules) { + memory->destroy(AT_molmap_H); + AT_molmap_H = NULL; + } + return nmolecules; +} + + +void PairLJCutHARSAT::AT_Print_Compensation_Energy(){ + + FILE *fp1; + fp1 = fopen("Mean_Comp_Energy_AT.txt","w"); + if (fp1 == NULL) { + char str[128]; + sprintf(str,"Cannot open Mean_Comp_Energy_AT.txt file %s","Mean_Comp_Energy_AT.txt"); + error->one(FLERR,str); + } + + for(int i = 0;i < AT_Bin_Num; i++){ + fprintf(fp1,"%d",i+1); + for(int j = 0; j < atom->nmoltypesH; j++){ + fprintf(fp1,"\t%.10f",Mean_Comp_Energy_H[i][j]); + } + fprintf(fp1,"\n"); + } + fclose(fp1); +} + + + +void PairLJCutHARSAT::AT_Update_Compensation_Energy(){ + + MPI_Allreduce(&Comp_Energy_H[0][0],&Comp_Energy_all_H[0][0],AT_Bin_Num*atom->nmoltypesH,MPI_DOUBLE,MPI_SUM,world); + MPI_Allreduce(&Comp_Energy_Num_H[0][0],&Comp_Energy_Num_all_H[0][0],AT_Bin_Num*atom->nmoltypesH,MPI_INT,MPI_SUM,world); + + for(int j = 0;j < atom->nmoltypesH; j++){ + for(int i = 0;i < AT_Bin_Num; i++){ + Mean_Energy_H[i][j] = Comp_Energy_all_H[i][j] / Comp_Energy_Num_all_H[i][j]; + Mean_Comp_Energy_H[i][j] = (Comp_Counter_H * Mean_Comp_Energy_H[i][j] + Mean_Energy_H[i][j]) / (Comp_Counter_H + 1); + Int_Mean_Energy_H[i][j]=0; + } + } + + Comp_Counter_H++; + + for(int j = 0;j < atom->nmoltypesH; j++){ + for(int i = 0;i < AT_Bin_Num; i++){ + Comp_Energy_Num_H[i][j] = 0; + Comp_Energy_Num_all_H[i][j] = 0; + Comp_Energy_H[i][j] = 0; + Comp_Energy_all_H[i][j] =0; + } + + } + if (me == 0)AT_Print_Compensation_Energy(); + + + +} + + +void PairLJCutHARSAT::Load_Compensation_Pressure(){ + + if(me == 0){ + FILE *fp1; + char str[128]; + + fp1 = fopen("Mean_Comp_Energy_AT.txt","r"); + if (fp1 == NULL) { + sprintf(str,"Cannot open fix Mean_Comp_Energy_AT.txt file %s","Mean_Comp_Energy_AT.txt"); + error->one(FLERR,str); + } + + int i1; + + while (!feof(fp1)){ + fscanf (fp1,"%d",&i1); + for(int j=0;jnmoltypesH;j++)fscanf (fp1,"\t%f",&Mean_Comp_Energy_H[i1-1][j]); + fscanf (fp1,"\n"); + if(i1 > AT_Bin_Num){ + sprintf(str,"Pressure bin number mismatches %d != %d",AT_Bin_Num,i1); + error->one(FLERR,str); + } + + } + + fclose(fp1); + + if(me==0){ + if(screen)fprintf(screen,"AT_Pressure componsation forces distributed successfully!\n"); + if(logfile)fprintf(logfile,"AT_Pressure componsation forces distributed successfully!\n"); + } + + } + + MPI_Bcast(Mean_Comp_Energy_H,AT_Bin_Num,MPI_DOUBLE,0,world); + + +} + +void PairLJCutHARSAT::H_AdResS_Allocation(){ + + for (int i = 0; i < modify->nfix; i++){ + if (strcmp(modify->fix[i]->style,"lambdah/calc") == 0){ + lambda_H_fix = (FixLambdaHCalc *) modify->fix[i]; + AT_lambda_Increment = lambda_H_fix->Pressure_lambda_Increment; + AT_Bin_Num = lambda_H_fix->Pressure_Bin_Num; + AT_Update_Frequency = lambda_H_fix->Pressure_Update_Frequency; + AT_Update_Time_Begin = lambda_H_fix->Pressure_Update_Time_Begin; + AT_Update_Time_End = lambda_H_fix->Pressure_Update_Time_End; + + AT_Pressure_Comp_Flag = lambda_H_fix->Pressure_Comp_Flag; + AT_center_box = lambda_H_fix->center_box; + AT_Hybrid_Style = lambda_H_fix->Hybrid_Style; + + + } + } + + if(me == 0){ + if (screen){ + fprintf(screen,"AT_lambda_Increment= %f\n",AT_lambda_Increment); + fprintf(screen,"AT_Bin_Num= %d\n",AT_Bin_Num); + fprintf(screen,"AT_Update_Frequency= %d\n",AT_Update_Frequency); + fprintf(screen,"AT_Update_Time_Begin= %d\n",AT_Update_Time_Begin); + fprintf(screen,"AT_Update_Time_End= %d\n",AT_Update_Time_End); + fprintf(screen,"AT_Pressure_Comp_Flag= %d\n",AT_Pressure_Comp_Flag); + } + + if (logfile){ + fprintf(logfile,"AT_lambda_Increment= %f\n",AT_lambda_Increment); + fprintf(logfile,"AT_Bin_Num= %d\n",AT_Bin_Num); + fprintf(logfile,"AT_Update_Frequency= %d\n",AT_Update_Frequency); + fprintf(logfile,"AT_Update_Time_Begin= %d\n",AT_Update_Time_Begin); + fprintf(logfile,"AT_Update_Time_End= %d\n",AT_Update_Time_End); + fprintf(logfile,"AT_Pressure_Comp_Flag= %d\n",AT_Pressure_Comp_Flag); + } + } + + memory->create(Comp_Energy_Num_H,AT_Bin_Num,atom->nmoltypesH,"pairLJHAT:Comp_Energy_Num_H"); + memory->create(Comp_Energy_Num_all_H,AT_Bin_Num,atom->nmoltypesH,"pairLJHAT:Comp_Energy_Num_all_H"); + + memory->create(Int_Mean_Energy_H,AT_Bin_Num,atom->nmoltypesH,"pairLJHAT:Int_Mean_Energy_H"); + memory->create(Comp_Energy_H,AT_Bin_Num,atom->nmoltypesH,"pairLJHAT:Comp_Energy_H"); + memory->create(Comp_Energy_all_H,AT_Bin_Num,atom->nmoltypesH,"pairLJHAT:Comp_Energy_all_H"); + memory->create(Mean_Comp_Energy_H,AT_Bin_Num,atom->nmoltypesH,"pairLJHAT:Mean_Comp_Energy_H"); + memory->create(Mean_Energy_H,AT_Bin_Num,atom->nmoltypesH,"pairLJHAT:Mean_Energy_H"); + + for(int j=0;jnmoltypesH;j++){ + for(int i = 0;i < AT_Bin_Num; i++){ + Int_Mean_Energy_H[i][j]=0; + Comp_Energy_H[i][j]=0; + Comp_Energy_all_H[i][j]=0; + Mean_Comp_Energy_H[i][j]=0; + Comp_Energy_Num_H[i][j] = 0; + Comp_Energy_Num_all_H[i][j] = 0; + } + + } + + H_AdResS_allocated = 1; +} + diff --git a/src/USER-HADRESS/pair_lj_cut_hars_at.h b/src/USER-HADRESS/pair_lj_cut_hars_at.h new file mode 100644 index 0000000000..04f41cfc90 --- /dev/null +++ b/src/USER-HADRESS/pair_lj_cut_hars_at.h @@ -0,0 +1,119 @@ +/* -*- c++ -*- ---------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + http://lammps.sandia.gov, Sandia National Laboratories + Steve Plimpton, sjplimp@sandia.gov + + Copyright (2003) Sandia Corporation. Under the terms of Contract + DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains + certain rights in this software. This software is distributed under + the GNU General Public License. + + See the README file in the top-level LAMMPS directory. +------------------------------------------------------------------------- */ + +#ifdef PAIR_CLASS + +PairStyle(lj/cut/hars/at,PairLJCutHARSAT) + +#else + +#ifndef LMP_PAIR_LJ_CUT_HARS_AT_H +#define LMP_PAIR_LJ_CUT_HARS_AT_H + +#include "pair.h" + +namespace LAMMPS_NS { + +class PairLJCutHARSAT : public Pair { + public: + PairLJCutHARSAT(class LAMMPS *); + virtual ~PairLJCutHARSAT(); + virtual void compute(int, int); + void settings(int, char **); + void coeff(int, char **); + void init_style(); + void init_list(int, class NeighList *); + double init_one(int, int); + void write_restart(FILE *); + void read_restart(FILE *); + void write_restart_settings(FILE *); + void read_restart_settings(FILE *); + void write_data(FILE *); + void write_data_all(FILE *); + double single(int, int, int, int, double, double, double, double &); + void *extract(const char *, int &); + + void compute_inner(); + void compute_middle(); + void compute_outer(int, int); + + void AT_Print_Compensation_Energy(); + void AT_Update_Compensation_Energy(); + + protected: + double cut_global; + double **cut; + double **epsilon,**sigma; + double **lj1,**lj2,**lj3,**lj4,**offset; + double *cut_respa; + class FixLambdaHCalc *lambda_H_fix; + + int AllAtomistic; + + virtual void allocate(); + +//private: + int me; + + int H_AdResS_allocated; + + int **Comp_Energy_Num_H,**Comp_Energy_Num_all_H, Comp_Counter_H; + + double AT_lambda_Increment; + int AT_Bin_Num, AT_Update_Frequency, AT_Update_Time_End, AT_Update_Time_Begin; + int AT_Pressure_Compensation_Run; + int AT_Pressure_Comp_Flag; + + double *AT_center_box,AT_x0lo; + int AT_Hybrid_Style; + double **Int_Mean_Energy_H, **Comp_Energy_H, **Comp_Energy_all_H, **Mean_Energy_H, **Mean_Comp_Energy_H; + + int nmolecules; + tagint idlo,idhi; + + double *AT_massproc_H,*AT_masstotal_H; + + double **AT_mol_f_H, **AT_mol_f_all_H; + + int *AT_molmap_H; // convert molecule ID to local index + int Load_File_Flag; + + int molecules_in_group(tagint &, tagint &); + void Load_Compensation_Pressure(); + void H_AdResS_Allocation(); + +}; + +} + +#endif +#endif + +/* ERROR/WARNING messages: + +E: Illegal ... command + +Self-explanatory. Check the input script syntax and compare to the +documentation for the command. You can use -echo screen as a +command-line option when running LAMMPS to see the offending line. + +E: Incorrect args for pair coefficients + +Self-explanatory. Check the input script or data file. + +E: Pair cutoff < Respa interior cutoff + +One or more pairwise cutoffs are too short to use with the specified +rRESPA cutoffs. + +*/ diff --git a/src/USER-HADRESS/pair_lj_cut_hars_cg.cpp b/src/USER-HADRESS/pair_lj_cut_hars_cg.cpp new file mode 100644 index 0000000000..86d61d4471 --- /dev/null +++ b/src/USER-HADRESS/pair_lj_cut_hars_cg.cpp @@ -0,0 +1,1120 @@ +/* ---------------------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + http://lammps.sandia.gov, Sandia National Laboratories + Steve Plimpton, sjplimp@sandia.gov + + Copyright (2003) Sandia Corporation. Under the terms of Contract + DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains + certain rights in this software. This software is distributed under + the GNU General Public License. + + See the README file in the top-level LAMMPS directory. +------------------------------------------------------------------------- */ + +/* ---------------------------------------------------------------------- + Contributing author: Paul Crozier (SNL) +------------------------------------------------------------------------- */ +#include "mpi.h" +#include "math.h" +#include "stdio.h" +#include "stdlib.h" +#include "string.h" +#include "pair_lj_cut_hars_cg.h" +#include "atom.h" +#include "atom_vec.h" +#include "comm.h" +#include "force.h" +#include "neighbor.h" +#include "neigh_list.h" +#include "neigh_request.h" +#include "update.h" +#include "integrate.h" +#include "respa.h" +#include "math_const.h" +#include "memory.h" +#include "error.h" +#include "domain.h" +#include "iostream" +#include "fix.h" +#include "fix_lambdah_calc.h" +#include "modify.h" + +using namespace LAMMPS_NS; +using namespace MathConst; + +#define BIG MAXTAGINT + +/* ---------------------------------------------------------------------- */ + +PairLJCutHARSCG::PairLJCutHARSCG(LAMMPS *lmp) : Pair(lmp) +{ + respa_enable = 1; + writedata = 1; + + massproc_H = NULL; + masstotal_H = NULL; + molmap_H = NULL; + mol_f_H = NULL; + mol_f_all_H = NULL; + Comp_Energy_Num_H = NULL; + Comp_Energy_Num_all_H = NULL; + + Int_Mean_Energy_H = NULL; + Mean_Energy_H = NULL; + Comp_Energy_H = NULL; + Comp_Energy_all_H = NULL; + Mean_Comp_Energy_H = NULL; + CG_Mean_grad_Comp_Density_Conv_H = NULL; + + molmap_H = NULL; + nmolecules = molecules_in_group(idlo,idhi); + + H_AdResS_allocated = 0; + + CG_Pressure_Compensation_Run = 0; + Density_Compensation_Run = 0; + Comp_Counter_H = 0; + CG_Density_Comp_Flag = 0; + CG_Pressure_Comp_Flag = 0; + + + memory->create(massproc_H,nmolecules,"pair:massproc_H"); + memory->create(masstotal_H,nmolecules,"pair:masstotal_H"); + memory->create(mol_f_H,nmolecules,3,"pair:mol_f_H"); + memory->create(mol_f_all_H,nmolecules,3,"pair:mol_f_all_H"); + + + // compute masstotal for each molecule + + MPI_Comm_rank(world, &me); + int *mask = atom->mask; + tagint *molecule = atom->molecule; + int *type = atom->type; + double *mass = atom->mass; + double *rmass = atom->rmass; + int nlocal = atom->nlocal; + tagint imol; + double massone; + + for (int i = 0; i < nmolecules; i++) massproc_H[i] = 0.0; + + for (int i = 0; i < nlocal; i++) + { +// if (mask[i] & groupbit) { + if (mask[i]) { + if (rmass) massone = rmass[i]; + else massone = mass[type[i]]; + imol = molecule[i]; + if (molmap_H) imol = molmap_H[imol-idlo]; + else imol--; + massproc_H[imol] += massone; + + } + } + + MPI_Allreduce(massproc_H,masstotal_H,nmolecules,MPI_DOUBLE,MPI_SUM,world); + +} + +/* ---------------------------------------------------------------------- */ + +PairLJCutHARSCG::~PairLJCutHARSCG() +{ + + + if (allocated) { + + memory->destroy(setflag); + memory->destroy(cutsq); + + memory->destroy(cut); + memory->destroy(epsilon); + memory->destroy(sigma); + memory->destroy(lj1); + memory->destroy(lj2); + memory->destroy(lj3); + memory->destroy(lj4); + memory->destroy(offset); + memory->destroy(massproc_H); + memory->destroy(masstotal_H); + memory->destroy(molmap_H); + memory->destroy(mol_f_H); + memory->destroy(mol_f_all_H); + memory->destroy(Comp_Energy_Num_H); + memory->destroy(Comp_Energy_Num_all_H); + memory->destroy(Int_Mean_Energy_H); + memory->destroy(Mean_Energy_H); + memory->destroy(Comp_Energy_H); + memory->destroy(Comp_Energy_all_H); + memory->destroy(Mean_Comp_Energy_H); + // memory->destroy(CG_Mean_grad_Comp_Density_Conv_H); + +// delete lambda_H_fix; +} +} + +/* ---------------------------------------------------------------------- */ + +void PairLJCutHARSCG::compute(int eflag, int vflag) +{ + int i,j,ii,jj,inum,jnum,itype,jtype; + double xtmp,ytmp,ztmp,delx,dely,delz,evdwl,fpair; + double rsq,r2inv,r6inv,forcelj, factor_lj,Vij; + int *ilist,*jlist,*numneigh,**firstneigh; + int imoltype,jmoltype; + + evdwl = 0.0; + if (eflag || vflag) ev_setup(eflag,vflag); + else evflag = vflag_fdotr = 0; + + double **x = atom->x; + double **f = atom->f; + double *lambdaH = atom->lambdaH; + double **gradlambdaH = atom->gradlambdaH; + double **comH = atom->comH; + int *replambdaH = atom->replambdaH; + tagint *molecule = atom->molecule; + double *mass = atom->mass; + int *moltypeH = atom->moltypeH; + int *type = atom->type; + int nlocal = atom->nlocal; + double *special_lj = force->special_lj; + int newton_pair = force->newton_pair; + + int ibin, jbin; + + inum = list->inum; + ilist = list->ilist; + numneigh = list->numneigh; + firstneigh = list->firstneigh; + + double iLambda, jLambda, ijLambda; + int imol,jmol; + + + + int This_Step = update->ntimestep; + if(This_Step >= CG_Update_Time_Begin && This_Step <= CG_Update_Time_End && CG_Pressure_Comp_Flag != 0){ + CG_Pressure_Compensation_Run = 1; + if(me==0 && This_Step == CG_Update_Time_Begin){ + if(screen)fprintf(screen,"\nStart of constant-pressure route\n"); + if(logfile)fprintf(logfile,"\nStart of constant-pressure route\n"); + } + } + + + if(update->ntimestepDensity_Compensation_Run; + + if(Density_Compensation_Run){ + CG_Mean_grad_Comp_Density_Conv_H = lambda_H_fix->Mean_grad_Comp_Density_Conv_H; + } + + for (ii = 0; ii < inum; ii++) { + + i = ilist[ii]; + if(replambdaH[i] == 0)continue; + + xtmp = comH[i][0]; + ytmp = comH[i][1]; + ztmp = comH[i][2]; + +// itype = moltypeH[i]; + itype = type[i]; + jlist = firstneigh[i]; + jnum = numneigh[i]; + imoltype = itype - 1; + + iLambda = 1 - lambdaH[i]; + + for (jj = 0; jj < jnum; jj++) { + + j = jlist[jj]; + factor_lj = special_lj[sbmask(j)]; + j &= NEIGHMASK; + jLambda = 1 - lambdaH[j]; + + if(replambdaH[j] == 0)continue; + + if((iLambda==0 && jLambda==0) && AllCoarseGrained != 1)continue; + + delx = xtmp - comH[j][0]; + dely = ytmp - comH[j][1]; + delz = ztmp - comH[j][2]; + + domain->minimum_image(delx,dely,delz); + + rsq = delx*delx + dely*dely + delz*delz; + jtype = type[j]; + //jtype = moltypeH[j]; + jmoltype = jtype - 1; + +// if (rsq < cutsq[itype][jtype] && lj1[itype][jtype] != 0) { + if (rsq < cutsq[itype][jtype]) { + + + imol = molecule[i]; + jmol = molecule[j]; + if (molmap_H) { + imol = molmap_H[imol-idlo]; + jmol = molmap_H[jmol-idlo]; + } + else { + imol--; + jmol--; + } + + + if(((iLambda==1 && jLambda==1) || AllCoarseGrained)){ + + r2inv = 1.0/rsq; + r6inv = r2inv*r2inv*r2inv; + forcelj = r6inv * (lj1[itype][jtype]*r6inv - lj2[itype][jtype]); + + fpair = factor_lj*forcelj*r2inv; + mol_f_H[imol][0] += delx*fpair; + mol_f_H[imol][1] += dely*fpair; + mol_f_H[imol][2] += delz*fpair; + + if (newton_pair || j < nlocal) { + mol_f_H[jmol][0] -= delx*fpair; + mol_f_H[jmol][1] -= dely*fpair; + mol_f_H[jmol][2] -= delz*fpair; + } + + if (eflag) { + evdwl = r6inv*(lj3[itype][jtype]*r6inv-lj4[itype][jtype]) - + offset[itype][jtype]; + evdwl *= factor_lj; + } + + if (evflag) ev_tally(i,j,nlocal,newton_pair, + evdwl,0.0,fpair,delx,dely,delz); + + } + + else if(iLambda != 0 || jLambda != 0){ + + ijLambda = 0.5 * (iLambda + jLambda); + r2inv = 1.0/rsq; + r6inv = r2inv*r2inv*r2inv; + forcelj = r6inv * (lj1[itype][jtype]*r6inv - lj2[itype][jtype]); + fpair = factor_lj*(forcelj*ijLambda)*r2inv; + + Vij = 0.5*(r6inv*(lj3[itype][jtype]*r6inv-lj4[itype][jtype]) - + offset[itype][jtype]); + + + ibin = floor(iLambda/CG_lambda_Increment); + if(ibin==CG_Bin_Num)ibin = CG_Bin_Num - 1; + + if(CG_Pressure_Compensation_Run != 0 && iLambda != 0 && iLambda != 1)Comp_Energy_H[ibin][imoltype] += Vij; + + mol_f_H[imol][0] += delx*fpair + Vij*gradlambdaH[i][0]; + mol_f_H[imol][1] += dely*fpair + Vij*gradlambdaH[i][1]; + mol_f_H[imol][2] += delz*fpair + Vij*gradlambdaH[i][2]; + + if (newton_pair || j < nlocal) { + + jbin = floor(jLambda/CG_lambda_Increment); + if(jbin==CG_Bin_Num)jbin = CG_Bin_Num - 1; + if(CG_Pressure_Compensation_Run != 0 && jLambda != 0 && jLambda != 1)Comp_Energy_H[jbin][jmoltype] += Vij; + + mol_f_H[jmol][0] -= delx*fpair - Vij*gradlambdaH[j][0]; + mol_f_H[jmol][1] -= dely*fpair - Vij*gradlambdaH[j][1]; + mol_f_H[jmol][2] -= delz*fpair - Vij*gradlambdaH[j][2]; + + } + + if (eflag) { + evdwl = ijLambda*Vij*2.0; + evdwl *= factor_lj; + } + + if (evflag) ev_tally(i,j,nlocal,newton_pair, + evdwl,0.0,fpair,delx,dely,delz); + + } + } + + } + } + + + MPI_Allreduce(&mol_f_H[0][0],&mol_f_all_H[0][0],3*nmolecules,MPI_DOUBLE,MPI_SUM,world); + + if(CG_Pressure_Compensation_Run != 0 && CG_Pressure_Comp_Flag != 0){ + for (int i = 0; i < nlocal; i++){ + iLambda = 1 - lambdaH[i]; + if(replambdaH[i] != 0 && lambdaH[i] != 0 && lambdaH[i] != 1){ + ibin = floor(iLambda/CG_lambda_Increment); + if(ibin==CG_Bin_Num)ibin = CG_Bin_Num - 1; + itype = moltypeH[i] - 1; + Comp_Energy_Num_H[ibin][itype]++; + + } + } + + if(This_Step % CG_Update_Frequency == 0)CG_Update_Compensation_Energy(); + } + + + double mol_mass,mass_frac; + double Grad_Density,r; + if(AllCoarseGrained != 1 && (CG_Density_Comp_Flag != 0 || CG_Pressure_Comp_Flag != 0)){ + + for (int i = 0; i < nlocal; i++){ + imol = molecule[i]; + if (molmap_H)imol = molmap_H[imol-idlo]; + else imol--; + mol_mass = masstotal_H[imol]; + mass_frac = mass[type[i]] / mol_mass; + iLambda = 1 - lambdaH[i]; + + if(iLambda != 0 && iLambda != 1){ + + ibin = floor(iLambda/CG_lambda_Increment); + itype = moltypeH[i] - 1; + + f[i][0] += mass_frac*(mol_f_all_H[imol][0]-gradlambdaH[i][0]*Mean_Comp_Energy_H[ibin][itype]); + f[i][1] += mass_frac*(mol_f_all_H[imol][1]-gradlambdaH[i][1]*Mean_Comp_Energy_H[ibin][itype]); + f[i][2] += mass_frac*(mol_f_all_H[imol][2]-gradlambdaH[i][2]*Mean_Comp_Energy_H[ibin][itype]); + + if (evflag) ev_tally(i,i,nlocal,newton_pair, + -0.5*Int_Mean_Energy_H[ibin][itype],0.0,0.0,0.0,0.0,0.0); + + + if(CG_Density_Comp_Flag != 0){ + + if(CG_Hybrid_Style == 0){ + ibin = floor((comH[i][0]-CG_x0lo)/CG_Density_Bin_Size); + f[i][0] += mass_frac*(-1.0*CG_Mean_grad_Comp_Density_Conv_H[ibin][itype]); + } + else if(CG_Hybrid_Style == 1){ + delx = comH[i][0] - CG_center_box[0]; + dely = comH[i][1] - CG_center_box[1]; + delz = comH[i][2] - CG_center_box[2]; + r = sqrt(delx*delx + dely*dely + delz*delz); + ibin = floor(r/CG_Density_Bin_Size); + + Grad_Density = CG_Mean_grad_Comp_Density_Conv_H[ibin][itype] / r; + f[i][0] += -mass_frac * Grad_Density * delx; + f[i][1] += -mass_frac * Grad_Density * dely; + f[i][2] += -mass_frac * Grad_Density * delz; + } + else if(CG_Hybrid_Style == 2){ + delx = comH[i][0] - CG_center_box[0]; + dely = comH[i][1] - CG_center_box[1]; + r = sqrt(delx*delx + dely*dely); + ibin = floor(r/CG_Density_Bin_Size); + + Grad_Density = CG_Mean_grad_Comp_Density_Conv_H[ibin][itype] / r; + f[i][0] += -mass_frac * Grad_Density * delx; + f[i][1] += -mass_frac * Grad_Density * dely; + } + + } + } + else{ + f[i][0] += mass_frac*mol_f_all_H[imol][0]; + f[i][1] += mass_frac*mol_f_all_H[imol][1]; + f[i][2] += mass_frac*mol_f_all_H[imol][2]; + } + + } + + } + else{ + + for (int i = 0; i < nlocal; i++){ + imol = molecule[i]; + if (molmap_H)imol = molmap_H[imol-idlo]; + else imol--; + mol_mass = masstotal_H[imol]; + mass_frac = mass[type[i]] / mol_mass; + + f[i][0] += mass_frac*mol_f_all_H[imol][0]; + f[i][1] += mass_frac*mol_f_all_H[imol][1]; + f[i][2] += mass_frac*mol_f_all_H[imol][2]; + } + + } + + + + if(This_Step == CG_Update_Time_End){ + CG_Pressure_Compensation_Run = 0; + if(me == 0){ + if(screen)fprintf(screen,"\nEnd of constant-pressure route\n"); + if(logfile)fprintf(logfile,"\nEnd of constant-pressure route\n"); + + } + } + + + if (vflag_fdotr) virial_fdotr_compute(); +} + +/* ---------------------------------------------------------------------- */ + +void PairLJCutHARSCG::compute_inner() +{ + + error->all(FLERR,"Rrespa has not been included!"); + +} + +/* ---------------------------------------------------------------------- */ + +void PairLJCutHARSCG::compute_middle() +{ + error->all(FLERR,"Rrespa has not been included!"); + +} + +/* ---------------------------------------------------------------------- */ + +void PairLJCutHARSCG::compute_outer(int eflag, int vflag) +{ + error->all(FLERR,"Rrespa has not been included!"); +} + +/* ---------------------------------------------------------------------- + allocate all arrays +------------------------------------------------------------------------- */ + +void PairLJCutHARSCG::allocate() +{ + + allocated = 1; + int n = atom->ntypes; + + memory->create(setflag,n+1,n+1,"pairLJHCG:setflag"); + for (int i = 1; i <= n; i++) + for (int j = i; j <= n; j++) + setflag[i][j] = 0; + + memory->create(cutsq,n+1,n+1,"pairLJHCG:cutsq"); + memory->create(cut,n+1,n+1,"pairLJHCG:cut"); + memory->create(epsilon,n+1,n+1,"pairLJHCG:epsilon"); + memory->create(sigma,n+1,n+1,"pairLJHCG:sigma"); + memory->create(lj1,n+1,n+1,"pairLJHCG:lj1"); + memory->create(lj2,n+1,n+1,"pairLJHCG:lj2"); + memory->create(lj3,n+1,n+1,"pairLJHCG:lj3"); + memory->create(lj4,n+1,n+1,"pairLJHCG:lj4"); + memory->create(offset,n+1,n+1,"pairLJHCG:offset"); + + + +} + +/* ---------------------------------------------------------------------- + global settings +------------------------------------------------------------------------- */ + +void PairLJCutHARSCG::settings(int narg, char **arg) +{ + if (narg != 3) error->all(FLERR,"Illegal pair_style command"); + + cut_global = force->numeric(FLERR,arg[0]); + + AllCoarseGrained = force->numeric(FLERR,arg[1]); + + Load_File_Flag = force->numeric(FLERR,arg[2]); + // reset cutoffs that have been explicitly set + + if (allocated) { + int i,j; + for (i = 1; i <= atom->ntypes; i++) + for (j = i+1; j <= atom->ntypes; j++) + if (setflag[i][j]) cut[i][j] = cut_global; + } + +} + +/* ---------------------------------------------------------------------- + set coeffs for one or more type pairs +------------------------------------------------------------------------- */ + +void PairLJCutHARSCG::coeff(int narg, char **arg) +{ + + if (narg < 4 || narg > 5) + error->all(FLERR,"Incorrect args for pair coefficients"); + if (!allocated) allocate(); + + int ilo,ihi,jlo,jhi; + + force->bounds(arg[0],atom->ntypes,ilo,ihi); + force->bounds(arg[1],atom->ntypes,jlo,jhi); + + + + double epsilon_one = force->numeric(FLERR,arg[2]); + double sigma_one = force->numeric(FLERR,arg[3]); + + double cut_one = cut_global; + if (narg == 5) cut_one = force->numeric(FLERR,arg[4]); + + int count = 0; + for (int i = ilo; i <= ihi; i++) { + for (int j = MAX(jlo,i); j <= jhi; j++) { + epsilon[i][j] = epsilon_one; + sigma[i][j] = sigma_one; + cut[i][j] = cut_one; + setflag[i][j] = 1; + count++; + + } + } + + if (count == 0) error->all(FLERR,"Incorrect args for pair coefficients"); +} + +/* ---------------------------------------------------------------------- + init specific to this pair style +------------------------------------------------------------------------- */ + +void PairLJCutHARSCG::init_style() +{ + // request regular or rRESPA neighbor lists + if(me == 0){ + if (screen)fprintf(screen,"CG_H_AdResS_allocated flag = %d\n",H_AdResS_allocated); + if (logfile)fprintf(logfile,"CG_H_AdResS_allocated flag = %d\n",H_AdResS_allocated); + } + + if(!H_AdResS_allocated)H_AdResS_Allocation(); + + + int This_Step = update->ntimestep; + CG_Restart_Time_Step = This_Step; + + if((This_Step >= CG_Update_Time_End || Load_File_Flag) && CG_Pressure_Comp_Flag != 0)Load_Compensation_Pressure(); + + int irequest; + + if (update->whichflag == 1 && strstr(update->integrate_style,"respa")) { + int respa = 0; + if (((Respa *) update->integrate)->level_inner >= 0) respa = 1; + if (((Respa *) update->integrate)->level_middle >= 0) respa = 2; + + if (respa == 0)irequest = neighbor->request(this,instance_me); + else if (respa == 1) { + irequest = neighbor->request(this,instance_me); + neighbor->requests[irequest]->id = 1; + neighbor->requests[irequest]->half = 0; + neighbor->requests[irequest]->respainner = 1; + irequest = neighbor->request(this,instance_me); + neighbor->requests[irequest]->id = 3; + neighbor->requests[irequest]->half = 0; + neighbor->requests[irequest]->respaouter = 1; + } else { + irequest = neighbor->request(this,instance_me); + neighbor->requests[irequest]->id = 1; + neighbor->requests[irequest]->half = 0; + neighbor->requests[irequest]->respainner = 1; + irequest = neighbor->request(this,instance_me); + neighbor->requests[irequest]->id = 2; + neighbor->requests[irequest]->half = 0; + neighbor->requests[irequest]->respamiddle = 1; + irequest = neighbor->request(this,instance_me); + neighbor->requests[irequest]->id = 3; + neighbor->requests[irequest]->half = 0; + neighbor->requests[irequest]->respaouter = 1; + } + + } else irequest = neighbor->request(this,instance_me); + + // set rRESPA cutoffs + + if (strstr(update->integrate_style,"respa") && + ((Respa *) update->integrate)->level_inner >= 0) + cut_respa = ((Respa *) update->integrate)->cutoff; + else cut_respa = NULL; +} + +/* ---------------------------------------------------------------------- + neighbor callback to inform pair style of neighbor list to use + regular or rRESPA +------------------------------------------------------------------------- */ + +void PairLJCutHARSCG::init_list(int id, NeighList *ptr) +{ + if (id == 0) list = ptr; + else if (id == 1) listinner = ptr; + else if (id == 2) listmiddle = ptr; + else if (id == 3) listouter = ptr; +} + +/* ---------------------------------------------------------------------- + init for one type pair i,j and corresponding j,i +------------------------------------------------------------------------- */ + +double PairLJCutHARSCG::init_one(int i, int j) +{ + if (setflag[i][j] == 0) { + epsilon[i][j] = mix_energy(epsilon[i][i],epsilon[j][j], + sigma[i][i],sigma[j][j]); + sigma[i][j] = mix_distance(sigma[i][i],sigma[j][j]); + cut[i][j] = mix_distance(cut[i][i],cut[j][j]); + } + + + lj1[i][j] = 48.0 * epsilon[i][j] * pow(sigma[i][j],12.0); + lj2[i][j] = 24.0 * epsilon[i][j] * pow(sigma[i][j],6.0); + lj3[i][j] = 4.0 * epsilon[i][j] * pow(sigma[i][j],12.0); + lj4[i][j] = 4.0 * epsilon[i][j] * pow(sigma[i][j],6.0); + + + if (offset_flag) { + double ratio = sigma[i][j] / cut[i][j]; + offset[i][j] = 4.0 * epsilon[i][j] * (pow(ratio,12.0) - pow(ratio,6.0)); + } else offset[i][j] = 0.0; + + lj1[j][i] = lj1[i][j]; + lj2[j][i] = lj2[i][j]; + lj3[j][i] = lj3[i][j]; + lj4[j][i] = lj4[i][j]; + offset[j][i] = offset[i][j]; + + // check interior rRESPA cutoff + + if (cut_respa && cut[i][j] < cut_respa[3]) + error->all(FLERR,"Pair cutoff < Respa interior cutoff"); + + // compute I,J contribution to long-range tail correction + // count total # of atoms of type I and J via Allreduce + + if (tail_flag) { + int *type = atom->type; + int nlocal = atom->nlocal; + + double count[2],all[2]; + count[0] = count[1] = 0.0; + for (int k = 0; k < nlocal; k++) { + if (type[k] == i) count[0] += 1.0; + if (type[k] == j) count[1] += 1.0; + } + MPI_Allreduce(count,all,2,MPI_DOUBLE,MPI_SUM,world); + + double sig2 = sigma[i][j]*sigma[i][j]; + double sig6 = sig2*sig2*sig2; + double rc3 = cut[i][j]*cut[i][j]*cut[i][j]; + double rc6 = rc3*rc3; + double rc9 = rc3*rc6; + etail_ij = 8.0*MY_PI*all[0]*all[1]*epsilon[i][j] * + sig6 * (sig6 - 3.0*rc6) / (9.0*rc9); + ptail_ij = 16.0*MY_PI*all[0]*all[1]*epsilon[i][j] * + sig6 * (2.0*sig6 - 3.0*rc6) / (9.0*rc9); + } + + return cut[i][j]; +} + +/* ---------------------------------------------------------------------- + proc 0 writes to restart file +------------------------------------------------------------------------- */ + +void PairLJCutHARSCG::write_restart(FILE *fp) +{ + write_restart_settings(fp); + + int i,j; + for (i = 1; i <= atom->ntypes; i++) + for (j = i; j <= atom->ntypes; j++) { + fwrite(&setflag[i][j],sizeof(int),1,fp); + if (setflag[i][j]) { + fwrite(&epsilon[i][j],sizeof(double),1,fp); + fwrite(&sigma[i][j],sizeof(double),1,fp); + fwrite(&cut[i][j],sizeof(double),1,fp); + } + } +} + +/* ---------------------------------------------------------------------- + proc 0 reads from restart file, bcasts +------------------------------------------------------------------------- */ + +void PairLJCutHARSCG::read_restart(FILE *fp) +{ + read_restart_settings(fp); + allocate(); + + int i,j; + int me = comm->me; + for (i = 1; i <= atom->ntypes; i++) + for (j = i; j <= atom->ntypes; j++) { + if (me == 0) fread(&setflag[i][j],sizeof(int),1,fp); + MPI_Bcast(&setflag[i][j],1,MPI_INT,0,world); + if (setflag[i][j]) { + if (me == 0) { + fread(&epsilon[i][j],sizeof(double),1,fp); + fread(&sigma[i][j],sizeof(double),1,fp); + fread(&cut[i][j],sizeof(double),1,fp); + } + MPI_Bcast(&epsilon[i][j],1,MPI_DOUBLE,0,world); + MPI_Bcast(&sigma[i][j],1,MPI_DOUBLE,0,world); + MPI_Bcast(&cut[i][j],1,MPI_DOUBLE,0,world); + } + } +} + +/* ---------------------------------------------------------------------- + proc 0 writes to restart file +------------------------------------------------------------------------- */ + +void PairLJCutHARSCG::write_restart_settings(FILE *fp) +{ + fwrite(&cut_global,sizeof(double),1,fp); + fwrite(&offset_flag,sizeof(int),1,fp); + fwrite(&mix_flag,sizeof(int),1,fp); + fwrite(&tail_flag,sizeof(int),1,fp); +} + +/* ---------------------------------------------------------------------- + proc 0 reads from restart file, bcasts +------------------------------------------------------------------------- */ + +void PairLJCutHARSCG::read_restart_settings(FILE *fp) +{ + int me = comm->me; + if (me == 0) { + fread(&cut_global,sizeof(double),1,fp); + fread(&offset_flag,sizeof(int),1,fp); + fread(&mix_flag,sizeof(int),1,fp); + fread(&tail_flag,sizeof(int),1,fp); + } + MPI_Bcast(&cut_global,1,MPI_DOUBLE,0,world); + MPI_Bcast(&offset_flag,1,MPI_INT,0,world); + MPI_Bcast(&mix_flag,1,MPI_INT,0,world); + MPI_Bcast(&tail_flag,1,MPI_INT,0,world); +} + +/* ---------------------------------------------------------------------- + proc 0 writes to data file +------------------------------------------------------------------------- */ + +void PairLJCutHARSCG::write_data(FILE *fp) +{ + for (int i = 1; i <= atom->ntypes; i++) + fprintf(fp,"%d %g %g\n",i,epsilon[i][i],sigma[i][i]); +} + +/* ---------------------------------------------------------------------- + proc 0 writes all pairs to data file +------------------------------------------------------------------------- */ + +void PairLJCutHARSCG::write_data_all(FILE *fp) +{ + for (int i = 1; i <= atom->ntypes; i++) + for (int j = i; j <= atom->ntypes; j++) + fprintf(fp,"%d %d %g %g %g\n",i,j,epsilon[i][j],sigma[i][j],cut[i][j]); +} + +/* ---------------------------------------------------------------------- */ + +double PairLJCutHARSCG::single(int i, int j, int itype, int jtype, double rsq, + double factor_coul, double factor_lj, + double &fforce) +{ + double r2inv,r6inv,forcelj,philj; + + r2inv = 1.0/rsq; + r6inv = r2inv*r2inv*r2inv; + forcelj = r6inv * (lj1[itype][jtype]*r6inv - lj2[itype][jtype]); + fforce = factor_lj*forcelj*r2inv; + + philj = r6inv*(lj3[itype][jtype]*r6inv-lj4[itype][jtype]) - + offset[itype][jtype]; + return factor_lj*philj; +} + +/* ---------------------------------------------------------------------- */ + +void *PairLJCutHARSCG::extract(const char *str, int &dim) +{ + dim = 2; + if (strcmp(str,"epsilon") == 0) return (void *) epsilon; + if (strcmp(str,"sigma") == 0) return (void *) sigma; + return NULL; +} + + + +int PairLJCutHARSCG::molecules_in_group(tagint &idlo, tagint &idhi) +{ + int i; + + memory->destroy(molmap_H); + molmap_H = NULL; + + // find lo/hi molecule ID for any atom in group + // warn if atom in group has ID = 0 + + tagint *molecule = atom->molecule; + int *mask = atom->mask; + int nlocal = atom->nlocal; + + tagint lo = BIG; + tagint hi = -BIG; + int flag = 0; + for (i = 0; i < nlocal; i++) + { +// if (mask[i] & groupbit) { + if (mask[i]) { + if (molecule[i] == 0) flag = 1; + lo = MIN(lo,molecule[i]); + hi = MAX(hi,molecule[i]); + } + } + + int flagall; + MPI_Allreduce(&flag,&flagall,1,MPI_INT,MPI_SUM,world); + if (flagall && comm->me == 0) + error->warning(FLERR,"Atom with molecule ID = 0 included in " + "compute molecule group"); + + MPI_Allreduce(&lo,&idlo,1,MPI_LMP_TAGINT,MPI_MIN,world); + MPI_Allreduce(&hi,&idhi,1,MPI_LMP_TAGINT,MPI_MAX,world); + if (idlo == BIG) return 0; + + // molmap = vector of length nlen + // set to 1 for IDs that appear in group across all procs, else 0 + + tagint nlen_tag = idhi-idlo+1; + if (nlen_tag > MAXSMALLINT) + error->all(FLERR,"Too many molecules for compute"); + int nlen = (int) nlen_tag; + + memory->create(molmap_H,nlen,"pair:molmap_H"); + for (i = 0; i < nlen; i++) molmap_H[i] = 0; + + for (i = 0; i < nlocal; i++) + // if (mask[i] & groupbit) + if (mask[i]) + molmap_H[molecule[i]-idlo] = 1; + + int *molmapall; + memory->create(molmapall,nlen,"pair:molmapall"); + MPI_Allreduce(molmap_H,molmapall,nlen,MPI_INT,MPI_MAX,world); + + // nmolecules = # of non-zero IDs in molmap + // molmap[i] = index of molecule, skipping molecules not in group with -1 + + int nmolecules = 0; + for (i = 0; i < nlen; i++) + if (molmapall[i]) molmap_H[i] = nmolecules++; + else molmap_H[i] = -1; + memory->destroy(molmapall); + + // warn if any molecule has some atoms in group and some not in group + + flag = 0; + for (i = 0; i < nlocal; i++) { +// if (mask[i] & groupbit) continue; + if (mask[i]) continue; + if (molecule[i] < idlo || molecule[i] > idhi) continue; + if (molmap_H[molecule[i]-idlo] >= 0) flag = 1; + } + + MPI_Allreduce(&flag,&flagall,1,MPI_INT,MPI_SUM,world); + if (flagall && comm->me == 0) + error->warning(FLERR, + "One or more compute molecules has atoms not in group"); + + // if molmap simply stores 1 to Nmolecules, then free it + + if (idlo == 1 && idhi == nmolecules && nlen == nmolecules) { + memory->destroy(molmap_H); + molmap_H = NULL; + } + return nmolecules; +} + + + +void PairLJCutHARSCG::CG_Print_Compensation_Energy(){ + + FILE *fp1; + + fp1 = fopen("Mean_Comp_Energy_CG.txt","w"); + if (fp1 == NULL) { + char str[128]; + sprintf(str,"Cannot open Mean_Comp_Energy_CG.txt file %s","Mean_Comp_Energy_CG.txt"); + error->one(FLERR,str); + + } + + for(int i = 0;i < CG_Bin_Num; i++){ + fprintf(fp1,"%d",i+1); + for(int k = 0; k < atom->nmoltypesH;k++) + fprintf(fp1,"\t%.10f",Mean_Comp_Energy_H[i][k]); + + fprintf(fp1,"\n"); + } + + fclose(fp1); + +} + + + +void PairLJCutHARSCG::CG_Update_Compensation_Energy(){ + + MPI_Allreduce(&Comp_Energy_H[0][0],&Comp_Energy_all_H[0][0],CG_Bin_Num*(atom->nmoltypesH+1),MPI_DOUBLE,MPI_SUM,world); + MPI_Allreduce(&Comp_Energy_Num_H[0][0],&Comp_Energy_Num_all_H[0][0],CG_Bin_Num*(atom->nmoltypesH+1),MPI_INT,MPI_SUM,world); + + for(int k = 0; k < atom->nmoltypesH;k++)for(int i = 0;i < CG_Bin_Num; i++)Mean_Energy_H[i][k] = Comp_Energy_all_H[i][k] / Comp_Energy_Num_all_H[i][k]; + for(int k = 0; k < atom->nmoltypesH;k++)for(int i = 0;i < CG_Bin_Num; i++)Mean_Comp_Energy_H[i][k] = (Comp_Counter_H * Mean_Comp_Energy_H[i][k] + Mean_Energy_H[i][k]) / (Comp_Counter_H + 1); + for(int k = 0; k < atom->nmoltypesH;k++)for(int i = 0;i < CG_Bin_Num; i++)Int_Mean_Energy_H[i][k]=0; + for(int k = 0; k < atom->nmoltypesH;k++)for(int i = 0;i < CG_Bin_Num; i++)for(int j = 0;j <= i; j++)Int_Mean_Energy_H[i][k] += Mean_Comp_Energy_H[j][k] * CG_lambda_Increment; + + Comp_Counter_H++; + + for(int k = 0; k < atom->nmoltypesH;k++){ + for(int i = 0;i < CG_Bin_Num; i++){ + Comp_Energy_Num_H[i][k] = 0; + Comp_Energy_Num_all_H[i][k] = 0; + Comp_Energy_H[i][k] = 0; + Comp_Energy_all_H[i][k] =0; + } + } + + if (me == 0)CG_Print_Compensation_Energy(); + + +} + + +void PairLJCutHARSCG::Load_Compensation_Pressure(){ + + if(me == 0){ + FILE *fp1; + char str[128]; + + fp1 = fopen("Mean_Comp_Energy_CG.txt","r"); + if (fp1 == NULL) { + sprintf(str,"Cannot open fix Mean_Comp_Energy_CG.txt file %s","Mean_Comp_Energy_CG.txt"); + error->one(FLERR,str); + } + + int i1; + float i2; + + while (!feof(fp1)){ + fscanf (fp1,"%d",&i1); + for(int k = 0; k < atom->nmoltypesH;k++){ + fscanf (fp1,"\t%f",&i2); + Mean_Comp_Energy_H[i1-1][k] = i2; + if(i1 > CG_Bin_Num){ + sprintf(str,"CG drift force compensation bin number mismatches %d != %d",CG_Bin_Num,i1); + error->one(FLERR,str); + } + } + + } + } + + + if(me==0){ + if(screen)fprintf(screen,"CG_Pressure componsation forces distributed successfully!\n"); + if(logfile)fprintf(logfile,"CG_Pressure componsation forces distributed successfully!\n"); + } + + MPI_Bcast(Mean_Comp_Energy_H,CG_Bin_Num*(atom->nmoltypesH+1),MPI_DOUBLE,0,world); +} + + +void PairLJCutHARSCG::H_AdResS_Allocation(){ + + + for (int i = 0; i < modify->nfix; i++){ + + if (strcmp(modify->fix[i]->style,"LambdaH/calc") == 0){ + + lambda_H_fix = (FixLambdaHCalc *) modify->fix[i]; + CG_lambda_Increment = lambda_H_fix->Pressure_lambda_Increment; + CG_Bin_Num = lambda_H_fix->Pressure_Bin_Num; + CG_Update_Frequency = lambda_H_fix->Pressure_Update_Frequency; + CG_Update_Time_Begin = lambda_H_fix->Pressure_Update_Time_Begin; + CG_Update_Time_End = lambda_H_fix->Pressure_Update_Time_End; + + CG_Density_Bin_Num = lambda_H_fix->Density_Bin_Num; + CG_Density_Bin_Size = lambda_H_fix->Density_Bin_Size; + CG_Density_Update_Frequency = lambda_H_fix->Density_Update_Frequency; + CG_Density_Update_Time_Begin = lambda_H_fix->Density_Update_Time_Begin; + CG_Density_Update_Time_End = lambda_H_fix->Density_Update_Time_End; + + CG_Pressure_Comp_Flag = lambda_H_fix->Pressure_Comp_Flag; + CG_Density_Comp_Flag = lambda_H_fix->Density_Comp_Flag; + CG_center_box = lambda_H_fix->center_box; + CG_Hybrid_Style = lambda_H_fix->Hybrid_Style; + CG_x0lo = lambda_H_fix->x0lo; + CG_x0BoxSize = lambda_H_fix->x0BoxSize; + } + } + + if(me == 0){ + if (screen){ + fprintf(screen,"CG_lambda_Increment= %f\n",CG_lambda_Increment); + fprintf(screen,"CG_Bin_Num= %d\n",CG_Bin_Num); + fprintf(screen,"CG_Update_Frequency= %d\n",CG_Update_Frequency); + fprintf(screen,"CG_Update_Time_Begin= %d\n",CG_Update_Time_Begin); + fprintf(screen,"CG_Update_Time_End= %d\n",CG_Update_Time_End); + fprintf(screen,"CG_Pressure_Comp_Flag= %d\n",CG_Pressure_Comp_Flag); + fprintf(screen,"CG_Density_Comp_Flag= %d\n",CG_Density_Comp_Flag); + fprintf(screen,"CG_Hybrid_Style= %d\n",CG_Hybrid_Style); + + } + + if (logfile){ + fprintf(logfile,"CG_lambda_Increment= %f\n",CG_lambda_Increment); + fprintf(logfile,"CG_Bin_Num= %d\n",CG_Bin_Num); + fprintf(logfile,"CG_Update_Frequency= %d\n",CG_Update_Frequency); + fprintf(logfile,"CG_Update_Time_Begin= %d\n",CG_Update_Time_Begin); + fprintf(logfile,"CG_Update_Time_End= %d\n",CG_Update_Time_End); + fprintf(logfile,"CG_Pressure_Comp_Flag= %d\n",CG_Pressure_Comp_Flag); + fprintf(logfile,"CG_Density_Comp_Flag= %d\n",CG_Density_Comp_Flag); + fprintf(logfile,"CG_Hybrid_Style= %d\n",CG_Hybrid_Style); + + } + + + } + + + memory->create(Comp_Energy_Num_H,CG_Bin_Num,atom->nmoltypesH+1,"pairLJHCG:Comp_Energy_Num_H"); + memory->create(Comp_Energy_Num_all_H,CG_Bin_Num,atom->nmoltypesH+1,"pairLJHCG:Comp_Energy_Num_all_H"); + memory->create(Int_Mean_Energy_H,CG_Bin_Num,atom->nmoltypesH+1,"pairLJHCG:Int_Mean_Energy_H"); + memory->create(Comp_Energy_H,CG_Bin_Num,atom->nmoltypesH+1,"pairLJHCG:Comp_Energy_H"); + memory->create(Comp_Energy_all_H,CG_Bin_Num,atom->nmoltypesH+1,"pairLJHCG:Comp_Energy_all_H"); + memory->create(Mean_Comp_Energy_H,CG_Bin_Num,atom->nmoltypesH+1,"pairLJHCG:Mean_Comp_Energy_H"); + memory->create(Mean_Energy_H,CG_Bin_Num,atom->nmoltypesH+1,"pairLJHCG:Mean_Energy_H"); + + memory->create(CG_Mean_grad_Comp_Density_Conv_H,CG_Density_Bin_Num,atom->nmoltypesH+1,"pairLJHCG:CG_Mean_grad_Comp_Density_Conv_H"); + CG_Mean_grad_Comp_Density_Conv_H = lambda_H_fix->Mean_grad_Comp_Density_Conv_H; + + + for(int i = 0;i < CG_Bin_Num; i++){ + for(int j = 0; j < atom->nmoltypesH; j++){ + Int_Mean_Energy_H[i][j] = 0; + Comp_Energy_H[i][j] = 0; + Comp_Energy_all_H[i][j] = 0; + Mean_Comp_Energy_H[i][j] = 0; + Comp_Energy_Num_H[i][j] = 0; + Comp_Energy_Num_all_H[i][j] = 0; + } + } + + + H_AdResS_allocated = 1; + +} diff --git a/src/USER-HADRESS/pair_lj_cut_hars_cg.h b/src/USER-HADRESS/pair_lj_cut_hars_cg.h new file mode 100644 index 0000000000..df47c27ec4 --- /dev/null +++ b/src/USER-HADRESS/pair_lj_cut_hars_cg.h @@ -0,0 +1,123 @@ +/* -*- c++ -*- ---------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + http://lammps.sandia.gov, Sandia National Laboratories + Steve Plimpton, sjplimp@sandia.gov + + Copyright (2003) Sandia Corporation. Under the terms of Contract + DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains + certain rights in this software. This software is distributed under + the GNU General Public License. + + See the README file in the top-level LAMMPS directory. +------------------------------------------------------------------------- */ + +#ifdef PAIR_CLASS + +PairStyle(lj/cut/hars/cg,PairLJCutHARSCG) + +#else + +#ifndef LMP_PAIR_LJ_CUT_HARS_CG_H +#define LMP_PAIR_LJ_CUT_HARS_CG_H + +#include "pair.h" + +namespace LAMMPS_NS { + +class PairLJCutHARSCG : public Pair { + public: + PairLJCutHARSCG(class LAMMPS *); + virtual ~PairLJCutHARSCG(); + virtual void compute(int, int); + void settings(int, char **); + void coeff(int, char **); + void init_style(); + void init_list(int, class NeighList *); + double init_one(int, int); + void write_restart(FILE *); + void read_restart(FILE *); + void write_restart_settings(FILE *); + void read_restart_settings(FILE *); + void write_data(FILE *); + void write_data_all(FILE *); + double single(int, int, int, int, double, double, double, double &); + void *extract(const char *, int &); + + void compute_inner(); + void compute_middle(); + void compute_outer(int, int); + + void CG_Print_Compensation_Energy(); + void CG_Update_Compensation_Energy(); + + protected: + double cut_global; + double **cut; + double **epsilon,**sigma; + double **lj1,**lj2,**lj3,**lj4,**offset; + double *cut_respa; + class FixLambdaHCalc *lambda_H_fix; + int AllCoarseGrained; + + double *CG_Ave_Mean_Density_H,CG_grad_Ave_Mean_Density_H; + //private: + + int me; + virtual void allocate(); + + int H_AdResS_allocated; + int **Comp_Energy_Num_H,**Comp_Energy_Num_all_H, Comp_Counter_H; + + double CG_lambda_Increment; + int CG_Bin_Num, CG_Update_Frequency, CG_Update_Time_End, CG_Update_Time_Begin; + int CG_Pressure_Compensation_Run, Density_Compensation_Run; + + int CG_Pressure_Comp_Flag, CG_Density_Comp_Flag; + + double CG_Density_Bin_Size,**CG_Mean_grad_Comp_Density_Conv_H,CG_x0BoxSize; + int CG_Density_Bin_Num,CG_Density_Update_Frequency,CG_Density_Update_Time_Begin,CG_Density_Update_Time_End; + double **Int_Mean_Energy_H, **Comp_Energy_H, **Comp_Energy_all_H, **Mean_Energy_H, **Mean_Comp_Energy_H; + + double *CG_center_box, CG_x0lo; + int CG_Hybrid_Style; + int nmolecules; + tagint idlo,idhi; + + double *massproc_H,*masstotal_H; + + double **mol_f_H, **mol_f_all_H; + + int CG_Restart_Time_Step; + //double **drift_f_H, **drift_f_all_H; + //int nbin_H; + int *molmap_H; // convert molecule ID to local index + int Load_File_Flag; + + int molecules_in_group(tagint &, tagint &); + void Load_Compensation_Pressure(); + void H_AdResS_Allocation(); +}; + +} + +#endif +#endif + +/* ERROR/WARNING messages: + +E: Illegal ... command + +Self-explanatory. Check the input script syntax and compare to the +documentation for the command. You can use -echo screen as a +command-line option when running LAMMPS to see the offending line. + +E: Incorrect args for pair coefficients + +Self-explanatory. Check the input script or data file. + +E: Pair cutoff < Respa interior cutoff + +One or more pairwise cutoffs are too short to use with the specified +rRESPA cutoffs. + +*/ diff --git a/src/USER-HADRESS/read_data.cpp b/src/USER-HADRESS/read_data.cpp new file mode 100644 index 0000000000..478412ae0d --- /dev/null +++ b/src/USER-HADRESS/read_data.cpp @@ -0,0 +1,2023 @@ +/* ---------------------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + http://lammps.sandia.gov, Sandia National Laboratories + Steve Plimpton, sjplimp@sandia.gov + + Copyright (2003) Sandia Corporation. Under the terms of Contract + DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains + certain rights in this software. This software is distributed under + the GNU General Public License. + + See the README file in the top-level LAMMPS directory. +------------------------------------------------------------------------- */ + +// lmptype.h must be first b/c this file uses MAXBIGINT and includes mpi.h +// due to OpenMPI bug which sets INT64_MAX via its mpi.h +// before lmptype.h can set flags to insure it is done correctly + +#include "lmptype.h" +#include +#include +#include +#include +#include +#include "read_data.h" +#include "atom.h" +#include "atom_vec.h" +#include "atom_vec_ellipsoid.h" +#include "atom_vec_line.h" +#include "atom_vec_tri.h" +#include "force.h" +#include "molecule.h" +#include "group.h" +#include "comm.h" +#include "update.h" +#include "modify.h" +#include "fix.h" +#include "force.h" +#include "pair.h" +#include "domain.h" +#include "bond.h" +#include "angle.h" +#include "dihedral.h" +#include "improper.h" +#include "special.h" +#include "irregular.h" +#include "error.h" +#include "memory.h" + +using namespace LAMMPS_NS; + +#define MAXLINE 256 +#define LB_FACTOR 1.1 +#define CHUNK 1024 +#define DELTA 4 // must be 2 or larger +#define MAXBODY 32 // max # of lines in one body + + // customize for new sections +#define NSECTIONS 25 // change when add to header::section_keywords + +enum{NONE,APPEND,VALUE,MERGE}; + +// pair style suffixes to ignore +// when matching Pair Coeffs comment to currently-defined pair style + +const char *suffixes[] = {"/cuda","/gpu","/opt","/omp","/kk", + "/coul/cut","/coul/long","/coul/msm", + "/coul/dsf","/coul/debye","/coul/charmm", + NULL}; + +/* ---------------------------------------------------------------------- */ + +ReadData::ReadData(LAMMPS *lmp) : Pointers(lmp) +{ + MPI_Comm_rank(world,&me); + line = new char[MAXLINE]; + copy = new char[MAXLINE]; + keyword = new char[MAXLINE]; + style = new char[MAXLINE]; + buffer = new char[CHUNK*MAXLINE]; + narg = maxarg = 0; + arg = NULL; + fp = NULL; + + // customize for new sections + // pointers to atom styles that store extra info + + nellipsoids = 0; + avec_ellipsoid = (AtomVecEllipsoid *) atom->style_match("ellipsoid"); + nlines = 0; + avec_line = (AtomVecLine *) atom->style_match("line"); + ntris = 0; + avec_tri = (AtomVecTri *) atom->style_match("tri"); + nbodies = 0; + avec_body = (AtomVecBody *) atom->style_match("body"); +} + +/* ---------------------------------------------------------------------- */ + +ReadData::~ReadData() +{ + delete [] line; + delete [] copy; + delete [] keyword; + delete [] style; + delete [] buffer; + memory->sfree(arg); + + for (int i = 0; i < nfix; i++) { + delete [] fix_header[i]; + delete [] fix_section[i]; + } + memory->destroy(fix_index); + memory->sfree(fix_header); + memory->sfree(fix_section); +} + +/* ---------------------------------------------------------------------- */ + +void ReadData::command(int narg, char **arg) +{ + if (narg < 1) error->all(FLERR,"Illegal read_data command"); + + // optional args + + addflag = NONE; + coeffflag = 1; + id_offset = 0; + offsetflag = shiftflag = 0; + toffset = boffset = aoffset = doffset = ioffset = 0; + shift[0] = shift[1] = shift[2] = 0.0; + extra_atom_types = extra_bond_types = extra_angle_types = + extra_dihedral_types = extra_improper_types = 0; + + groupbit = 0; + + nfix = 0; + fix_index = NULL; + fix_header = NULL; + fix_section = NULL; + + int iarg = 1; + while (iarg < narg) { + if (strcmp(arg[iarg],"add") == 0) { + if (iarg+2 > narg) error->all(FLERR,"Illegal read_data command"); + if (strcmp(arg[iarg+1],"append") == 0) addflag = APPEND; + else if (strcmp(arg[iarg+1],"merge") == 0) addflag = MERGE; + else { + addflag = VALUE; + bigint offset = force->bnumeric(FLERR,arg[iarg+1]); + if (offset > MAXTAGINT) + error->all(FLERR,"Read data add offset is too big"); + id_offset = offset; + } + iarg += 2; + } else if (strcmp(arg[iarg],"offset") == 0) { + if (iarg+6 > narg) error->all(FLERR,"Illegal read_data command"); + offsetflag = 1; + toffset = force->inumeric(FLERR,arg[iarg+1]); + boffset = force->inumeric(FLERR,arg[iarg+2]); + aoffset = force->inumeric(FLERR,arg[iarg+3]); + doffset = force->inumeric(FLERR,arg[iarg+4]); + ioffset = force->inumeric(FLERR,arg[iarg+5]); + if (toffset < 0 || boffset < 0 || aoffset < 0 || + doffset < 0 || ioffset < 0) + error->all(FLERR,"Illegal read_data command"); + iarg += 6; + } else if (strcmp(arg[iarg],"shift") == 0) { + if (iarg+4 > narg) error->all(FLERR,"Illegal read_data command"); + shiftflag = 1; + shift[0] = force->numeric(FLERR,arg[iarg+1]); + shift[1] = force->numeric(FLERR,arg[iarg+2]); + shift[2] = force->numeric(FLERR,arg[iarg+3]); + if (domain->dimension == 2 && shift[2] != 0.0) + error->all(FLERR,"Non-zero read_data shift z value for 2d simulation"); + iarg += 4; + } else if (strcmp(arg[iarg],"nocoeff") == 0) { + coeffflag = 0; + iarg ++; + } else if (strcmp(arg[iarg],"extra/atom/types") == 0) { + if (iarg+2 > narg) error->all(FLERR,"Illegal read_data command"); + extra_atom_types = force->inumeric(FLERR,arg[iarg+1]); + if (extra_atom_types < 0) error->all(FLERR,"Illegal read_data command"); + iarg += 2; + } else if (strcmp(arg[iarg],"extra/bond/types") == 0) { + if (iarg+2 > narg) error->all(FLERR,"Illegal read_data command"); + if (!atom->avec->bonds_allow) + error->all(FLERR,"No bonds allowed with this atom style"); + extra_bond_types = force->inumeric(FLERR,arg[iarg+1]); + if (extra_bond_types < 0) error->all(FLERR,"Illegal read_data command"); + iarg += 2; + } else if (strcmp(arg[iarg],"extra/angle/types") == 0) { + if (iarg+2 > narg) error->all(FLERR,"Illegal read_data command"); + if (!atom->avec->angles_allow) + error->all(FLERR,"No angles allowed with this atom style"); + extra_angle_types = force->inumeric(FLERR,arg[iarg+1]); + if (extra_angle_types < 0) error->all(FLERR,"Illegal read_data command"); + iarg += 2; + } else if (strcmp(arg[iarg],"extra/dihedral/types") == 0) { + if (iarg+2 > narg) error->all(FLERR,"Illegal read_data command"); + if (!atom->avec->dihedrals_allow) + error->all(FLERR,"No dihedrals allowed with this atom style"); + extra_dihedral_types = force->inumeric(FLERR,arg[iarg+1]); + if (extra_dihedral_types < 0) + error->all(FLERR,"Illegal read_data command"); + iarg += 2; + } else if (strcmp(arg[iarg],"extra/improper/types") == 0) { + if (iarg+2 > narg) error->all(FLERR,"Illegal read_data command"); + if (!atom->avec->impropers_allow) + error->all(FLERR,"No impropers allowed with this atom style"); + extra_improper_types = force->inumeric(FLERR,arg[iarg+1]); + if (extra_improper_types < 0) + error->all(FLERR,"Illegal read_data command"); + iarg += 2; + + } else if (strcmp(arg[iarg],"group") == 0) { + if (iarg+2 > narg) error->all(FLERR,"Illegal read_data command"); + int igroup = group->find_or_create(arg[iarg+1]); + groupbit = group->bitmask[igroup]; + iarg += 2; + + } else if (strcmp(arg[iarg],"fix") == 0) { + if (iarg+4 > narg) + error->all(FLERR,"Illegal read_data command"); + memory->grow(fix_index,nfix+1,"read_data:fix_index"); + fix_header = (char **) + memory->srealloc(fix_header,(nfix+1)*sizeof(char *), + "read_data:fix_header"); + fix_section = (char **) + memory->srealloc(fix_section,(nfix+1)*sizeof(char *), + "read_data:fix_section"); + fix_index[nfix] = modify->find_fix(arg[iarg+1]); + if (fix_index[nfix] < 0) + error->all(FLERR,"Fix ID for read_data does not exist"); + if (strcmp(arg[iarg+2],"NULL") == 0) fix_header[nfix] = NULL; + else { + int n = strlen(arg[iarg+2]) + 1; + fix_header[nfix] = new char[n]; + strcpy(fix_header[nfix],arg[iarg+2]); + } + int n = strlen(arg[iarg+3]) + 1; + fix_section[nfix] = new char[n]; + strcpy(fix_section[nfix],arg[iarg+3]); + nfix++; + iarg += 4; + + } else error->all(FLERR,"Illegal read_data command"); + } + + // error checks + + if (domain->dimension == 2 && domain->zperiodic == 0) + error->all(FLERR,"Cannot run 2d simulation with nonperiodic Z dimension"); + if (domain->box_exist && !addflag) + error->all(FLERR,"Cannot read_data without add keyword " + "after simulation box is defined"); + if (!domain->box_exist && addflag) + error->all(FLERR,"Cannot use read_data add before " + "simulation box is defined"); + if (offsetflag && addflag == NONE) + error->all(FLERR,"Cannot use read_data offset without add flag"); + if (shiftflag && addflag == NONE) + error->all(FLERR,"Cannot use read_data shift without add flag"); + if (addflag != NONE && + (extra_atom_types || extra_bond_types || extra_angle_types || + extra_dihedral_types || extra_improper_types)) + error->all(FLERR,"Cannot use read_data extra with add flag"); + + // first time system initialization + + if (addflag == NONE) { + domain->box_exist = 1; + update->ntimestep = 0; + } + + // compute atomID offset for addflag = MERGE + + if (addflag == APPEND) { + tagint *tag = atom->tag; + int nlocal = atom->nlocal; + tagint max = 0; + for (int i = 0; i < nlocal; i++) max = MAX(max,tag[i]); + MPI_Allreduce(&max,&id_offset,1,MPI_LMP_TAGINT,MPI_MAX,world); + } + + // set up pointer to hold original styles while we replace them with "zero" + Pair *saved_pair = NULL; + Bond *saved_bond = NULL; + Angle *saved_angle = NULL; + Dihedral *saved_dihedral = NULL; + Improper *saved_improper = NULL; + KSpace *saved_kspace = NULL; + + if (coeffflag == 0) { + char *coeffs[2]; + coeffs[0] = (char *) "10.0"; + coeffs[1] = (char *) "nocoeff"; + + saved_pair = force->pair; + force->pair = NULL; + force->create_pair("zero",0); + if (force->pair) force->pair->settings(2,coeffs); + + coeffs[0] = coeffs[1]; + saved_bond = force->bond; + force->bond = NULL; + force->create_bond("zero",0); + if (force->bond) force->bond->settings(1,coeffs); + + saved_angle = force->angle; + force->angle = NULL; + force->create_angle("zero",0); + if (force->angle) force->angle->settings(1,coeffs); + + saved_dihedral = force->dihedral; + force->dihedral = NULL; + force->create_dihedral("zero",0); + if (force->dihedral) force->dihedral->settings(1,coeffs); + + saved_improper = force->improper; + force->improper = NULL; + force->create_improper("zero",0); + if (force->improper) force->improper->settings(1,coeffs); + + saved_kspace = force->kspace; + force->kspace = NULL; + } + + // ----------------------------------------------------------------- + + // perform 1-pass read if no molecular topology in file + // perform 2-pass read if molecular topology, + // first pass calculates max topology/atom + + // flags for this data file + + int atomflag,topoflag; + int bondflag,angleflag,dihedralflag,improperflag; + int ellipsoidflag,lineflag,triflag,bodyflag; + + atomflag = topoflag = 0; + bondflag = angleflag = dihedralflag = improperflag = 0; + ellipsoidflag = lineflag = triflag = bodyflag = 0; + + // values in this data file + + natoms = ntypes = 0; + nbonds = nangles = ndihedrals = nimpropers = 0; + nbondtypes = nangletypes = ndihedraltypes = nimpropertypes = 0; + triclinic = 0; + keyword[0] = '\0'; + + nlocal_previous = atom->nlocal; + int firstpass = 1; + + while (1) { + + // open file on proc 0 + + if (me == 0) { + if (firstpass && screen) fprintf(screen,"Reading data file ...\n"); + open(arg[0]); + } else fp = NULL; + + // read header info + + header(firstpass); + + // problem setup using info from header + // only done once, if firstpass and first data file + // apply extra settings before grow(), even if no topology in file + // deallocate() insures new settings are used for topology arrays + // if per-atom topology is in file, another grow() is done below + + if (firstpass && addflag == NONE) { + atom->bond_per_atom = atom->extra_bond_per_atom; + atom->angle_per_atom = atom->extra_angle_per_atom; + atom->dihedral_per_atom = atom->extra_dihedral_per_atom; + atom->improper_per_atom = atom->extra_improper_per_atom; + + int n; + if (comm->nprocs == 1) n = static_cast (atom->natoms); + else n = static_cast (LB_FACTOR * atom->natoms / comm->nprocs); + + atom->allocate_type_arrays(); + atom->deallocate_topology(); + atom->avec->grow(n); + + domain->boxlo[0] = boxlo[0]; domain->boxhi[0] = boxhi[0]; + domain->boxlo[1] = boxlo[1]; domain->boxhi[1] = boxhi[1]; + domain->boxlo[2] = boxlo[2]; domain->boxhi[2] = boxhi[2]; + + if (triclinic) { + domain->triclinic = 1; + domain->xy = xy; domain->xz = xz; domain->yz = yz; + } + + domain->print_box(" "); + domain->set_initial_box(); + domain->set_global_box(); + comm->set_proc_grid(); + domain->set_local_box(); + } + + // change simulation box to be union of existing box and new box + shift + // only done if firstpass and not first data file + + if (firstpass && addflag != NONE) { + domain->boxlo[0] = MIN(domain->boxlo[0],boxlo[0]+shift[0]); + domain->boxhi[0] = MAX(domain->boxhi[0],boxhi[0]+shift[0]); + domain->boxlo[1] = MIN(domain->boxlo[1],boxlo[1]+shift[1]); + domain->boxhi[1] = MAX(domain->boxhi[1],boxhi[1]+shift[1]); + domain->boxlo[2] = MIN(domain->boxlo[2],boxlo[2]+shift[2]); + domain->boxhi[2] = MAX(domain->boxhi[2],boxhi[2]+shift[2]); + + // NOTE: not sure what to do about tilt value in subsequent data files + //if (triclinic) { + // domain->xy = xy; domain->xz = xz; domain->yz = yz; + // } + + domain->print_box(" "); + domain->set_initial_box(); + domain->set_global_box(); + comm->set_proc_grid(); + domain->set_local_box(); + } + + // customize for new sections + // read rest of file in free format + + while (strlen(keyword)) { + + // if special fix matches, it processes section + + if (nfix) { + int i; + for (i = 0; i < nfix; i++) + if (strcmp(keyword,fix_section[i]) == 0) { + if (firstpass) fix(fix_index[i],keyword); + else skip_lines(modify->fix[fix_index[i]]-> + read_data_skip_lines(keyword)); + parse_keyword(0); + break; + } + if (i < nfix) continue; + } + + if (strcmp(keyword,"Atoms") == 0) { + atomflag = 1; + if (firstpass) { + if (me == 0 && !style_match(style,atom->atom_style)) + error->warning(FLERR,"Atom style in data file differs " + "from currently defined atom style"); + atoms(); + } else skip_lines(natoms); + } else if (strcmp(keyword,"Velocities") == 0) { + if (atomflag == 0) + error->all(FLERR,"Must read Atoms before Velocities"); + if (firstpass) velocities(); + else skip_lines(natoms); + + } else if (strcmp(keyword,"Bonds") == 0) { + topoflag = bondflag = 1; + if (nbonds == 0) + error->all(FLERR,"Invalid data file section: Bonds"); + if (atomflag == 0) error->all(FLERR,"Must read Atoms before Bonds"); + bonds(firstpass); + } else if (strcmp(keyword,"Angles") == 0) { + topoflag = angleflag = 1; + if (nangles == 0) + error->all(FLERR,"Invalid data file section: Angles"); + if (atomflag == 0) error->all(FLERR,"Must read Atoms before Angles"); + angles(firstpass); + } else if (strcmp(keyword,"Dihedrals") == 0) { + topoflag = dihedralflag = 1; + if (ndihedrals == 0) + error->all(FLERR,"Invalid data file section: Dihedrals"); + if (atomflag == 0) error->all(FLERR,"Must read Atoms before Dihedrals"); + dihedrals(firstpass); + } else if (strcmp(keyword,"Impropers") == 0) { + topoflag = improperflag = 1; + if (nimpropers == 0) + error->all(FLERR,"Invalid data file section: Impropers"); + if (atomflag == 0) error->all(FLERR,"Must read Atoms before Impropers"); + impropers(firstpass); + + } else if (strcmp(keyword,"Ellipsoids") == 0) { + ellipsoidflag = 1; + if (!avec_ellipsoid) + error->all(FLERR,"Invalid data file section: Ellipsoids"); + if (atomflag == 0) + error->all(FLERR,"Must read Atoms before Ellipsoids"); + if (firstpass) + bonus(nellipsoids,(AtomVec *) avec_ellipsoid,"ellipsoids"); + else skip_lines(nellipsoids); + } else if (strcmp(keyword,"Lines") == 0) { + lineflag = 1; + if (!avec_line) + error->all(FLERR,"Invalid data file section: Lines"); + if (atomflag == 0) error->all(FLERR,"Must read Atoms before Lines"); + if (firstpass) bonus(nlines,(AtomVec *) avec_line,"lines"); + else skip_lines(nlines); + } else if (strcmp(keyword,"Triangles") == 0) { + triflag = 1; + if (!avec_tri) + error->all(FLERR,"Invalid data file section: Triangles"); + if (atomflag == 0) error->all(FLERR,"Must read Atoms before Triangles"); + if (firstpass) bonus(ntris,(AtomVec *) avec_tri,"triangles"); + else skip_lines(ntris); + } else if (strcmp(keyword,"Bodies") == 0) { + bodyflag = 1; + if (!avec_body) + error->all(FLERR,"Invalid data file section: Bodies"); + if (atomflag == 0) error->all(FLERR,"Must read Atoms before Bodies"); + bodies(firstpass); + + } else if (strcmp(keyword,"Masses") == 0) { + if (firstpass) mass(); + else skip_lines(ntypes); + } else if (strcmp(keyword,"Pair Coeffs") == 0) { + if (force->pair == NULL) + error->all(FLERR,"Must define pair_style before Pair Coeffs"); + if (firstpass) { + if (me == 0 && !style_match(style,force->pair_style)) + error->warning(FLERR,"Pair style in data file differs " + "from currently defined pair style"); + paircoeffs(); + } else skip_lines(ntypes); + } else if (strcmp(keyword,"PairIJ Coeffs") == 0) { + if (force->pair == NULL) + error->all(FLERR,"Must define pair_style before PairIJ Coeffs"); + if (firstpass) { + if (me == 0 && !style_match(style,force->pair_style)) + error->warning(FLERR,"Pair style in data file differs " + "from currently defined pair style"); + pairIJcoeffs(); + } else skip_lines(ntypes*(ntypes+1)/2); + } else if (strcmp(keyword,"Bond Coeffs") == 0) { + if (atom->avec->bonds_allow == 0) + error->all(FLERR,"Invalid data file section: Bond Coeffs"); + if (force->bond == NULL) + error->all(FLERR,"Must define bond_style before Bond Coeffs"); + if (firstpass) { + if (me == 0 && !style_match(style,force->bond_style)) + error->warning(FLERR,"Bond style in data file differs " + "from currently defined bond style"); + bondcoeffs(); + } else skip_lines(nbondtypes); + } else if (strcmp(keyword,"Angle Coeffs") == 0) { + if (atom->avec->angles_allow == 0) + error->all(FLERR,"Invalid data file section: Angle Coeffs"); + if (force->angle == NULL) + error->all(FLERR,"Must define angle_style before Angle Coeffs"); + if (firstpass) { + if (me == 0 && !style_match(style,force->angle_style)) + error->warning(FLERR,"Angle style in data file differs " + "from currently defined angle style"); + anglecoeffs(0); + } else skip_lines(nangletypes); + } else if (strcmp(keyword,"Dihedral Coeffs") == 0) { + if (atom->avec->dihedrals_allow == 0) + error->all(FLERR,"Invalid data file section: Dihedral Coeffs"); + if (force->dihedral == NULL) + error->all(FLERR,"Must define dihedral_style before Dihedral Coeffs"); + if (firstpass) { + if (me == 0 && !style_match(style,force->dihedral_style)) + error->warning(FLERR,"Dihedral style in data file differs " + "from currently defined dihedral style"); + dihedralcoeffs(0); + } else skip_lines(ndihedraltypes); + } else if (strcmp(keyword,"Improper Coeffs") == 0) { + if (atom->avec->impropers_allow == 0) + error->all(FLERR,"Invalid data file section: Improper Coeffs"); + if (force->improper == NULL) + error->all(FLERR,"Must define improper_style before Improper Coeffs"); + if (firstpass) { + if (me == 0 && !style_match(style,force->improper_style)) + error->warning(FLERR,"Improper style in data file differs " + "from currently defined improper style"); + impropercoeffs(0); + } else skip_lines(nimpropertypes); + + } else if (strcmp(keyword,"BondBond Coeffs") == 0) { + if (atom->avec->angles_allow == 0) + error->all(FLERR,"Invalid data file section: BondBond Coeffs"); + if (force->angle == NULL) + error->all(FLERR,"Must define angle_style before BondBond Coeffs"); + if (firstpass) anglecoeffs(1); + else skip_lines(nangletypes); + } else if (strcmp(keyword,"BondAngle Coeffs") == 0) { + if (atom->avec->angles_allow == 0) + error->all(FLERR,"Invalid data file section: BondAngle Coeffs"); + if (force->angle == NULL) + error->all(FLERR,"Must define angle_style before BondAngle Coeffs"); + if (firstpass) anglecoeffs(2); + else skip_lines(nangletypes); + + } else if (strcmp(keyword,"MiddleBondTorsion Coeffs") == 0) { + if (atom->avec->dihedrals_allow == 0) + error->all(FLERR, + "Invalid data file section: MiddleBondTorsion Coeffs"); + if (force->dihedral == NULL) + error->all(FLERR, + "Must define dihedral_style before " + "MiddleBondTorsion Coeffs"); + if (firstpass) dihedralcoeffs(1); + else skip_lines(ndihedraltypes); + } else if (strcmp(keyword,"EndBondTorsion Coeffs") == 0) { + if (atom->avec->dihedrals_allow == 0) + error->all(FLERR,"Invalid data file section: EndBondTorsion Coeffs"); + if (force->dihedral == NULL) + error->all(FLERR, + "Must define dihedral_style before EndBondTorsion Coeffs"); + if (firstpass) dihedralcoeffs(2); + else skip_lines(ndihedraltypes); + } else if (strcmp(keyword,"AngleTorsion Coeffs") == 0) { + if (atom->avec->dihedrals_allow == 0) + error->all(FLERR,"Invalid data file section: AngleTorsion Coeffs"); + if (force->dihedral == NULL) + error->all(FLERR, + "Must define dihedral_style before AngleTorsion Coeffs"); + if (firstpass) dihedralcoeffs(3); + else skip_lines(ndihedraltypes); + } else if (strcmp(keyword,"AngleAngleTorsion Coeffs") == 0) { + if (atom->avec->dihedrals_allow == 0) + error->all(FLERR, + "Invalid data file section: AngleAngleTorsion Coeffs"); + if (force->dihedral == NULL) + error->all(FLERR, + "Must define dihedral_style before " + "AngleAngleTorsion Coeffs"); + if (firstpass) dihedralcoeffs(4); + else skip_lines(ndihedraltypes); + } else if (strcmp(keyword,"BondBond13 Coeffs") == 0) { + if (atom->avec->dihedrals_allow == 0) + error->all(FLERR,"Invalid data file section: BondBond13 Coeffs"); + if (force->dihedral == NULL) + error->all(FLERR, + "Must define dihedral_style before BondBond13 Coeffs"); + if (firstpass) dihedralcoeffs(5); + else skip_lines(ndihedraltypes); + + } else if (strcmp(keyword,"AngleAngle Coeffs") == 0) { + if (atom->avec->impropers_allow == 0) + error->all(FLERR,"Invalid data file section: AngleAngle Coeffs"); + if (force->improper == NULL) + error->all(FLERR, + "Must define improper_style before AngleAngle Coeffs"); + if (firstpass) impropercoeffs(1); + else skip_lines(nimpropertypes); + + } else { + char str[128]; + sprintf(str,"Unknown identifier in data file: %s",keyword); + error->all(FLERR,str); + } + + parse_keyword(0); + } + + // error if natoms > 0 yet no atoms were read + + if (natoms > 0 && atomflag == 0) + error->all(FLERR,"No atoms in data file"); + + // close file + + if (me == 0) { + if (compressed) pclose(fp); + else fclose(fp); + fp = NULL; + } + + // done if this was 2nd pass + + if (!firstpass) break; + + // at end of 1st pass, error check for required sections + // customize for new sections + + if ((nbonds && !bondflag) || (nangles && !angleflag) || + (ndihedrals && !dihedralflag) || (nimpropers && !improperflag)) + error->one(FLERR,"Needed molecular topology not in data file"); + + if ((nellipsoids && !ellipsoidflag) || (nlines && !lineflag) || + (ntris && !triflag) || (nbodies && !bodyflag)) + error->one(FLERR,"Needed bonus data not in data file"); + + // break out of loop if no molecular topology in file + // else make 2nd pass + + if (!topoflag) break; + firstpass = 0; + + // reallocate bond,angle,diehdral,improper arrays via grow() + // will use new bond,angle,dihedral,improper per-atom values from 1st pass + // will also observe extra settings even if bond/etc topology not in file + // leaves other atom arrays unchanged, since already nmax in length + + if (addflag == NONE) atom->deallocate_topology(); + atom->avec->grow(atom->nmax); + } + + // assign atoms added by this data file to specified group + + if (groupbit) { + int *mask = atom->mask; + int nlocal = atom->nlocal; + for (int i = nlocal_previous; i < nlocal; i++) + mask[i] |= groupbit; + } + + // create special bond lists for molecular systems + + if (atom->molecular == 1) { + Special special(lmp); + special.build(); + } + + // for atom style template systems, count total bonds,angles,etc + + if (atom->molecular == 2) { + Molecule **onemols = atom->avec->onemols; + int *molindex = atom->molindex; + int *molatom = atom->molatom; + int nlocal = atom->nlocal; + + int imol,iatom; + bigint nbonds,nangles,ndihedrals,nimpropers; + nbonds = nangles = ndihedrals = nimpropers = 0; + + for (int i = 0; i < nlocal; i++) { + imol = molindex[i]; + iatom = molatom[i]; + nbonds += onemols[imol]->num_bond[iatom]; + nangles += onemols[imol]->num_angle[iatom]; + ndihedrals += onemols[imol]->num_dihedral[iatom]; + nimpropers += onemols[imol]->num_improper[iatom]; + } + + MPI_Allreduce(&nbonds,&atom->nbonds,1,MPI_LMP_BIGINT,MPI_SUM,world); + MPI_Allreduce(&nangles,&atom->nangles,1,MPI_LMP_BIGINT,MPI_SUM,world); + MPI_Allreduce(&ndihedrals,&atom->ndihedrals,1,MPI_LMP_BIGINT,MPI_SUM,world); + MPI_Allreduce(&nimpropers,&atom->nimpropers,1,MPI_LMP_BIGINT,MPI_SUM,world); + + if (!force->newton_bond) { + atom->nbonds /= 2; + atom->nangles /= 3; + atom->ndihedrals /= 4; + atom->nimpropers /= 4; + } + + if (me == 0) { + if (atom->nbonds) { + if (screen) + fprintf(screen," " BIGINT_FORMAT " template bonds\n",atom->nbonds); + if (logfile) + fprintf(logfile," " BIGINT_FORMAT " template bonds\n",atom->nbonds); + } + if (atom->nangles) { + if (screen) + fprintf(screen," " BIGINT_FORMAT " template angles\n", + atom->nangles); + if (logfile) + fprintf(logfile," " BIGINT_FORMAT " template angles\n", + atom->nangles); + } + if (atom->ndihedrals) { + if (screen) + fprintf(screen," " BIGINT_FORMAT " template dihedrals\n", + atom->nbonds); + if (logfile) + fprintf(logfile," " BIGINT_FORMAT " template bonds\n", + atom->ndihedrals); + } + if (atom->nimpropers) { + if (screen) + fprintf(screen," " BIGINT_FORMAT " template impropers\n", + atom->nimpropers); + if (logfile) + fprintf(logfile," " BIGINT_FORMAT " template impropers\n", + atom->nimpropers); + } + } + } + + // for atom style template systems + // insure nbondtypes,etc are still consistent with template molecules, + // in case data file re-defined them + + if (atom->molecular == 2) atom->avec->onemols[0]->check_attributes(1); + + // if adding atoms, migrate atoms to new processors + // use irregular() b/c box size could have changed dramaticaly + // resulting in procs now owning very different subboxes + // with their previously owned atoms now far outside the subbox + + if (addflag != NONE) { + if (domain->triclinic) domain->x2lamda(atom->nlocal); + Irregular *irregular = new Irregular(lmp); + irregular->migrate_atoms(1); + delete irregular; + if (domain->triclinic) domain->lamda2x(atom->nlocal); + } + + // shrink-wrap the box if necessary and move atoms to new procs + // if atoms are lost is b/c data file box was far from shrink-wrapped + // do not use irregular() comm, which would not lose atoms, + // b/c then user could specify data file box as far too big and empty + // do comm->init() but not comm->setup() b/c pair/neigh cutoffs not yet set + // need call to map_set() b/c comm->exchange clears atom map + + if (domain->nonperiodic == 2) { + if (domain->triclinic) domain->x2lamda(atom->nlocal); + domain->reset_box(); + comm->init(); + comm->exchange(); + if (atom->map_style) atom->map_set(); + if (domain->triclinic) domain->lamda2x(atom->nlocal); + + bigint natoms; + bigint nblocal = atom->nlocal; + MPI_Allreduce(&nblocal,&natoms,1,MPI_LMP_BIGINT,MPI_SUM,world); + if (natoms != atom->natoms) + error->all(FLERR, + "Read_data shrink wrap did not assign all atoms correctly"); + } + + // restore old styles, when reading with nocoeff flag given + if (coeffflag == 0) { + if (force->pair) delete force->pair; + force->pair = saved_pair; + + if (force->bond) delete force->bond; + force->bond = saved_bond; + + if (force->angle) delete force->angle; + force->angle = saved_angle; + + if (force->dihedral) delete force->dihedral; + force->dihedral = saved_dihedral; + + if (force->improper) delete force->improper; + force->improper = saved_improper; + + force->kspace = saved_kspace; + } +} + +/* ---------------------------------------------------------------------- + read free-format header of data file + 1st line and blank lines are skipped + non-blank lines are checked for header keywords and leading value is read + header ends with EOF or non-blank line containing no header keyword + if EOF, line is set to blank line + else line has first keyword line for rest of file + some logic differs if adding atoms +------------------------------------------------------------------------- */ + +void ReadData::header(int firstpass) +{ + int n; + char *ptr; + + // customize for new sections + + const char *section_keywords[NSECTIONS] = + {"Atoms","Velocities","Ellipsoids","Lines","Triangles","Bodies", + "Bonds","Angles","Dihedrals","Impropers", + "Masses","Pair Coeffs","PairIJ Coeffs","Bond Coeffs","Angle Coeffs", + "Dihedral Coeffs","Improper Coeffs", + "BondBond Coeffs","BondAngle Coeffs","MiddleBondTorsion Coeffs", + "EndBondTorsion Coeffs","AngleTorsion Coeffs", + "AngleAngleTorsion Coeffs","BondBond13 Coeffs","AngleAngle Coeffs"}; + + // skip 1st line of file + + if (me == 0) { + char *eof = fgets(line,MAXLINE,fp); + if (eof == NULL) error->one(FLERR,"Unexpected end of data file"); + } + + while (1) { + + // read a line and bcast length + + if (me == 0) { + if (fgets(line,MAXLINE,fp) == NULL) n = 0; + else n = strlen(line) + 1; + } + MPI_Bcast(&n,1,MPI_INT,0,world); + + // if n = 0 then end-of-file so return with blank line + + if (n == 0) { + line[0] = '\0'; + return; + } + + MPI_Bcast(line,n,MPI_CHAR,0,world); + + // trim anything from '#' onward + // if line is blank, continue + + if ((ptr = strchr(line,'#'))) *ptr = '\0'; + if (strspn(line," \t\n\r") == strlen(line)) continue; + + // allow special fixes first chance to match and process the line + // if fix matches, continue to next header line + + if (nfix) { + for (n = 0; n < nfix; n++) { + if (!fix_header[n]) continue; + if (strstr(line,fix_header[n])) { + modify->fix[fix_index[n]]->read_data_header(line); + break; + } + } + if (n < nfix) continue; + } + + // search line for header keyword and set corresponding variable + // customize for new header lines + + if (strstr(line,"atoms")) { + sscanf(line,BIGINT_FORMAT,&natoms); + if (addflag == NONE) atom->natoms = natoms; + else if (firstpass) atom->natoms += natoms; + + // check for these first + // otherwise "triangles" will be matched as "angles" + + } else if (strstr(line,"ellipsoids")) { + if (!avec_ellipsoid) + error->all(FLERR,"No ellipsoids allowed with this atom style"); + sscanf(line,BIGINT_FORMAT,&nellipsoids); + } else if (strstr(line,"lines")) { + if (!avec_line) + error->all(FLERR,"No lines allowed with this atom style"); + sscanf(line,BIGINT_FORMAT,&nlines); + } else if (strstr(line,"triangles")) { + if (!avec_tri) + error->all(FLERR,"No triangles allowed with this atom style"); + sscanf(line,BIGINT_FORMAT,&ntris); + } else if (strstr(line,"bodies")) { + if (!avec_body) + error->all(FLERR,"No bodies allowed with this atom style"); + sscanf(line,BIGINT_FORMAT,&nbodies); + + } else if (strstr(line,"bonds")) { + sscanf(line,BIGINT_FORMAT,&nbonds); + if (addflag == NONE) atom->nbonds = nbonds; + else if (firstpass) atom->nbonds += nbonds; + } else if (strstr(line,"angles")) { + sscanf(line,BIGINT_FORMAT,&nangles); + if (addflag == NONE) atom->nangles = nangles; + else if (firstpass) atom->nangles += nangles; + } else if (strstr(line,"dihedrals")) { + sscanf(line,BIGINT_FORMAT,&ndihedrals); + if (addflag == NONE) atom->ndihedrals = ndihedrals; + else if (firstpass) atom->ndihedrals += ndihedrals; + } else if (strstr(line,"impropers")) { + sscanf(line,BIGINT_FORMAT,&nimpropers); + if (addflag == NONE) atom->nimpropers = nimpropers; + else if (firstpass) atom->nimpropers += nimpropers; + + // Atom class type settings are only set by first data file + + } else if (strstr(line,"atom types")) { + sscanf(line,"%d",&ntypes); + if (addflag == NONE) atom->ntypes = ntypes + extra_atom_types; + } else if (strstr(line,"mol_H types")){ + sscanf(line,"%d",&atom->nmoltypesH); + } + else if (strstr(line,"bond types")) { + sscanf(line,"%d",&nbondtypes); + if (addflag == NONE) atom->nbondtypes = nbondtypes + extra_bond_types; + } else if (strstr(line,"angle types")) { + sscanf(line,"%d",&nangletypes); + if (addflag == NONE) atom->nangletypes = nangletypes + extra_angle_types; + } else if (strstr(line,"dihedral types")) { + sscanf(line,"%d",&ndihedraltypes); + if (addflag == NONE) + atom->ndihedraltypes = ndihedraltypes + extra_dihedral_types; + } else if (strstr(line,"improper types")) { + sscanf(line,"%d",&nimpropertypes); + if (addflag == NONE) + atom->nimpropertypes = nimpropertypes + extra_improper_types; + + // these settings only used by first data file + + } else if (strstr(line,"extra bond per atom")) { + if (addflag == NONE) sscanf(line,"%d",&atom->extra_bond_per_atom); + } else if (strstr(line,"extra angle per atom")) { + if (addflag == NONE) sscanf(line,"%d",&atom->extra_angle_per_atom); + } else if (strstr(line,"extra dihedral per atom")) { + if (addflag == NONE) sscanf(line,"%d",&atom->extra_dihedral_per_atom); + } else if (strstr(line,"extra improper per atom")) { + if (addflag == NONE) sscanf(line,"%d",&atom->extra_improper_per_atom); + } else if (strstr(line,"extra special per atom")) { + if (addflag == NONE) sscanf(line,"%d",&force->special_extra); + + // local copy of box info + // so can treat differently for first vs subsequent data files + + } else if (strstr(line,"xlo xhi")) { + sscanf(line,"%lg %lg",&boxlo[0],&boxhi[0]); + } else if (strstr(line,"ylo yhi")) { + sscanf(line,"%lg %lg",&boxlo[1],&boxhi[1]); + } else if (strstr(line,"zlo zhi")) { + sscanf(line,"%lg %lg",&boxlo[2],&boxhi[2]); + } else if (strstr(line,"xy xz yz")) { + triclinic = 1; + sscanf(line,"%lg %lg %lg",&xy,&xz,&yz); + + } else break; + } + + // error check on total system size + + if (atom->natoms < 0 || atom->natoms >= MAXBIGINT || + atom->nbonds < 0 || atom->nbonds >= MAXBIGINT || + atom->nangles < 0 || atom->nangles >= MAXBIGINT || + atom->ndihedrals < 0 || atom->ndihedrals >= MAXBIGINT || + atom->nimpropers < 0 || atom->nimpropers >= MAXBIGINT) + error->all(FLERR,"System in data file is too big"); + + // check that exiting string is a valid section keyword + + parse_keyword(1); + for (n = 0; n < NSECTIONS; n++) + if (strcmp(keyword,section_keywords[n]) == 0) break; + if (n == NSECTIONS) { + char str[128]; + sprintf(str,"Unknown identifier in data file: %s",keyword); + error->all(FLERR,str); + } + + // error checks on header values + // must be consistent with atom style and other header values + + if ((atom->nbonds || atom->nbondtypes) && + atom->avec->bonds_allow == 0) + error->all(FLERR,"No bonds allowed with this atom style"); + if ((atom->nangles || atom->nangletypes) && + atom->avec->angles_allow == 0) + error->all(FLERR,"No angles allowed with this atom style"); + if ((atom->ndihedrals || atom->ndihedraltypes) && + atom->avec->dihedrals_allow == 0) + error->all(FLERR,"No dihedrals allowed with this atom style"); + if ((atom->nimpropers || atom->nimpropertypes) && + atom->avec->impropers_allow == 0) + error->all(FLERR,"No impropers allowed with this atom style"); + + if (atom->nbonds > 0 && atom->nbondtypes <= 0) + error->all(FLERR,"Bonds defined but no bond types"); + if (atom->nangles > 0 && atom->nangletypes <= 0) + error->all(FLERR,"Angles defined but no angle types"); + if (atom->ndihedrals > 0 && atom->ndihedraltypes <= 0) + error->all(FLERR,"Dihedrals defined but no dihedral types"); + if (atom->nimpropers > 0 && atom->nimpropertypes <= 0) + error->all(FLERR,"Impropers defined but no improper types"); + + if (atom->molecular == 2) { + if (atom->nbonds || atom->nangles || atom->ndihedrals || atom->nimpropers) + error->all(FLERR,"No molecule topology allowed with atom style template"); + } +} + +/* ---------------------------------------------------------------------- + read all atoms +------------------------------------------------------------------------- */ + +void ReadData::atoms() +{ + int nchunk,eof; + + if (me == 0) { + if (screen) fprintf(screen," reading atoms ...\n"); + if (logfile) fprintf(logfile," reading atoms ...\n"); + } + + bigint nread = 0; + + while (nread < natoms) { + nchunk = MIN(natoms-nread,CHUNK); + eof = comm->read_lines_from_file(fp,nchunk,MAXLINE,buffer); + if (eof) error->all(FLERR,"Unexpected end of data file"); + atom->data_atoms(nchunk,buffer,id_offset,toffset,shiftflag,shift); + nread += nchunk; + } + + // check that all atoms were assigned correctly + + bigint n = atom->nlocal; + bigint sum; + MPI_Allreduce(&n,&sum,1,MPI_LMP_BIGINT,MPI_SUM,world); + bigint nassign = sum - (atom->natoms - natoms); + + if (me == 0) { + if (screen) fprintf(screen," " BIGINT_FORMAT " atoms\n",nassign); + if (logfile) fprintf(logfile," " BIGINT_FORMAT " atoms\n",nassign); + } + + if (sum != atom->natoms) + error->all(FLERR,"Did not assign all atoms correctly"); + + // check that atom IDs are valid + + atom->tag_check(); + + // create global mapping of atoms + + if (atom->map_style) { + atom->map_init(); + atom->map_set(); + } +} + +/* ---------------------------------------------------------------------- + read all velocities + to find atoms, must build atom map if not a molecular system +------------------------------------------------------------------------- */ + +void ReadData::velocities() +{ + int nchunk,eof; + + if (me == 0) { + if (screen) fprintf(screen," reading velocities ...\n"); + if (logfile) fprintf(logfile," reading velocities ...\n"); + } + + int mapflag = 0; + if (atom->map_style == 0) { + mapflag = 1; + atom->map_init(); + atom->map_set(); + } + + bigint nread = 0; + + while (nread < natoms) { + nchunk = MIN(natoms-nread,CHUNK); + eof = comm->read_lines_from_file(fp,nchunk,MAXLINE,buffer); + if (eof) error->all(FLERR,"Unexpected end of data file"); + atom->data_vels(nchunk,buffer,id_offset); + nread += nchunk; + } + + if (mapflag) { + atom->map_delete(); + atom->map_style = 0; + } + + if (me == 0) { + if (screen) fprintf(screen," " BIGINT_FORMAT " velocities\n",natoms); + if (logfile) fprintf(logfile," " BIGINT_FORMAT " velocities\n",natoms); + } +} + +/* ---------------------------------------------------------------------- + scan or read all bonds +------------------------------------------------------------------------- */ + +void ReadData::bonds(int firstpass) +{ + int nchunk,eof; + + if (me == 0) { + if (firstpass) { + if (screen) fprintf(screen," scanning bonds ...\n"); + if (logfile) fprintf(logfile," scanning bonds ...\n"); + } else { + if (screen) fprintf(screen," reading bonds ...\n"); + if (logfile) fprintf(logfile," reading bonds ...\n"); + } + } + + // allocate count if firstpass + + int nlocal = atom->nlocal; + int *count = NULL; + if (firstpass) { + memory->create(count,nlocal,"read_data:count"); + for (int i = 0; i < nlocal; i++) count[i] = 0; + } + + // read and process bonds + + bigint nread = 0; + + while (nread < nbonds) { + nchunk = MIN(nbonds-nread,CHUNK); + eof = comm->read_lines_from_file(fp,nchunk,MAXLINE,buffer); + if (eof) error->all(FLERR,"Unexpected end of data file"); + atom->data_bonds(nchunk,buffer,count,id_offset,boffset); + nread += nchunk; + } + + // if firstpass: tally max bond/atom and return + // if addflag = NONE, store max bond/atom with extra + // else just check actual max does not exceed existing max + + if (firstpass) { + int max = 0; + for (int i = nlocal_previous; i < nlocal; i++) max = MAX(max,count[i]); + int maxall; + MPI_Allreduce(&max,&maxall,1,MPI_INT,MPI_MAX,world); + if (addflag == NONE) maxall += atom->extra_bond_per_atom; + + if (me == 0) { + if (screen) fprintf(screen," %d = max bonds/atom\n",maxall); + if (logfile) fprintf(logfile," %d = max bonds/atom\n",maxall); + } + + if (addflag != NONE) { + if (maxall > atom->bond_per_atom) + error->all(FLERR,"Subsequent read data induced " + "too many bonds per atom"); + } else atom->bond_per_atom = maxall; + + memory->destroy(count); + return; + } + + // if 2nd pass: check that bonds were assigned correctly + + bigint n = 0; + for (int i = nlocal_previous; i < nlocal; i++) n += atom->num_bond[i]; + bigint sum; + MPI_Allreduce(&n,&sum,1,MPI_LMP_BIGINT,MPI_SUM,world); + int factor = 1; + if (!force->newton_bond) factor = 2; + + if (me == 0) { + if (screen) fprintf(screen," " BIGINT_FORMAT " bonds\n",sum/factor); + if (logfile) fprintf(logfile," " BIGINT_FORMAT " bonds\n",sum/factor); + } + + if (sum != factor*nbonds) + error->all(FLERR,"Bonds assigned incorrectly"); +} + +/* ---------------------------------------------------------------------- + scan or read all angles +------------------------------------------------------------------------- */ + +void ReadData::angles(int firstpass) +{ + int nchunk,eof; + + if (me == 0) { + if (firstpass) { + if (screen) fprintf(screen," scanning angles ...\n"); + if (logfile) fprintf(logfile," scanning angles ...\n"); + } else { + if (screen) fprintf(screen," reading angles ...\n"); + if (logfile) fprintf(logfile," reading angles ...\n"); + } + } + + // allocate count if firstpass + + int nlocal = atom->nlocal; + int *count = NULL; + if (firstpass) { + memory->create(count,nlocal,"read_data:count"); + for (int i = 0; i < nlocal; i++) count[i] = 0; + } + + // read and process angles + + bigint nread = 0; + + while (nread < nangles) { + nchunk = MIN(nangles-nread,CHUNK); + eof = comm->read_lines_from_file(fp,nchunk,MAXLINE,buffer); + if (eof) error->all(FLERR,"Unexpected end of data file"); + atom->data_angles(nchunk,buffer,count,id_offset,aoffset); + nread += nchunk; + } + + // if firstpass: tally max angle/atom and return + // if addflag = NONE, store max angle/atom with extra + // else just check actual max does not exceed existing max + + if (firstpass) { + int max = 0; + for (int i = nlocal_previous; i < nlocal; i++) max = MAX(max,count[i]); + int maxall; + MPI_Allreduce(&max,&maxall,1,MPI_INT,MPI_MAX,world); + if (addflag == NONE) maxall += atom->extra_angle_per_atom; + + if (me == 0) { + if (screen) fprintf(screen," %d = max angles/atom\n",maxall); + if (logfile) fprintf(logfile," %d = max angles/atom\n",maxall); + } + + if (addflag != NONE) { + if (maxall > atom->angle_per_atom) + error->all(FLERR,"Subsequent read data induced " + "too many angles per atom"); + } else atom->angle_per_atom = maxall; + + memory->destroy(count); + return; + } + + // if 2nd pass: check that angles were assigned correctly + + bigint n = 0; + for (int i = nlocal_previous; i < nlocal; i++) n += atom->num_angle[i]; + bigint sum; + MPI_Allreduce(&n,&sum,1,MPI_LMP_BIGINT,MPI_SUM,world); + int factor = 1; + if (!force->newton_bond) factor = 3; + + if (me == 0) { + if (screen) fprintf(screen," " BIGINT_FORMAT " angles\n",sum/factor); + if (logfile) fprintf(logfile," " BIGINT_FORMAT " angles\n",sum/factor); + } + + if (sum != factor*nangles) + error->all(FLERR,"Angles assigned incorrectly"); +} + +/* ---------------------------------------------------------------------- + scan or read all dihedrals +------------------------------------------------------------------------- */ + +void ReadData::dihedrals(int firstpass) +{ + int nchunk,eof; + + if (me == 0) { + if (firstpass) { + if (screen) fprintf(screen," scanning dihedrals ...\n"); + if (logfile) fprintf(logfile," scanning dihedrals ...\n"); + } else { + if (screen) fprintf(screen," reading dihedrals ...\n"); + if (logfile) fprintf(logfile," reading dihedrals ...\n"); + } + } + + // allocate count if firstpass + + int nlocal = atom->nlocal; + int *count = NULL; + if (firstpass) { + memory->create(count,nlocal,"read_data:count"); + for (int i = 0; i < nlocal; i++) count[i] = 0; + } + + // read and process dihedrals + + bigint nread = 0; + + while (nread < ndihedrals) { + nchunk = MIN(ndihedrals-nread,CHUNK); + eof = comm->read_lines_from_file(fp,nchunk,MAXLINE,buffer); + if (eof) error->all(FLERR,"Unexpected end of data file"); + atom->data_dihedrals(nchunk,buffer,count,id_offset,doffset); + nread += nchunk; + } + + // if firstpass: tally max dihedral/atom and return + // if addflag = NONE, store max dihedral/atom with extra + // else just check actual max does not exceed existing max + + if (firstpass) { + int max = 0; + for (int i = 0; i < nlocal; i++) max = MAX(max,count[i]); + int maxall; + MPI_Allreduce(&max,&maxall,1,MPI_INT,MPI_MAX,world); + if (addflag == NONE) maxall += atom->extra_dihedral_per_atom; + + if (me == 0) { + if (screen) fprintf(screen," %d = max dihedrals/atom\n",maxall); + if (logfile) fprintf(logfile," %d = max dihedrals/atom\n",maxall); + } + + if (addflag != NONE) { + if (maxall > atom->dihedral_per_atom) + error->all(FLERR,"Subsequent read data induced " + "too many dihedrals per atom"); + } else atom->dihedral_per_atom = maxall; + + memory->destroy(count); + return; + } + + // if 2nd pass: check that dihedrals were assigned correctly + + bigint n = 0; + for (int i = nlocal_previous; i < nlocal; i++) n += atom->num_dihedral[i]; + bigint sum; + MPI_Allreduce(&n,&sum,1,MPI_LMP_BIGINT,MPI_SUM,world); + int factor = 1; + if (!force->newton_bond) factor = 4; + + if (me == 0) { + if (screen) fprintf(screen," " BIGINT_FORMAT " dihedrals\n",sum/factor); + if (logfile) fprintf(logfile," " BIGINT_FORMAT " dihedrals\n",sum/factor); + } + + if (sum != factor*ndihedrals) + error->all(FLERR,"Dihedrals assigned incorrectly"); +} + +/* ---------------------------------------------------------------------- + scan or read all impropers +------------------------------------------------------------------------- */ + +void ReadData::impropers(int firstpass) +{ + int nchunk,eof; + + if (me == 0) { + if (firstpass) { + if (screen) fprintf(screen," scanning impropers ...\n"); + if (logfile) fprintf(logfile," scanning impropers ...\n"); + } else { + if (screen) fprintf(screen," reading impropers ...\n"); + if (logfile) fprintf(logfile," reading impropers ...\n"); + } + } + + // allocate count if firstpass + + int nlocal = atom->nlocal; + int *count = NULL; + if (firstpass) { + memory->create(count,nlocal,"read_data:count"); + for (int i = 0; i < nlocal; i++) count[i] = 0; + } + + // read and process impropers + + bigint nread = 0; + + while (nread < nimpropers) { + nchunk = MIN(nimpropers-nread,CHUNK); + eof = comm->read_lines_from_file(fp,nchunk,MAXLINE,buffer); + if (eof) error->all(FLERR,"Unexpected end of data file"); + atom->data_impropers(nchunk,buffer,count,id_offset,ioffset); + nread += nchunk; + } + + // if firstpass: tally max improper/atom and return + // if addflag = NONE, store max improper/atom + // else just check it does not exceed existing max + + if (firstpass) { + int max = 0; + for (int i = nlocal_previous; i < nlocal; i++) max = MAX(max,count[i]); + int maxall; + MPI_Allreduce(&max,&maxall,1,MPI_INT,MPI_MAX,world); + if (addflag == NONE) maxall += atom->extra_improper_per_atom; + + if (me == 0) { + if (screen) fprintf(screen," %d = max impropers/atom\n",maxall); + if (logfile) fprintf(logfile," %d = max impropers/atom\n",maxall); + } + + if (addflag != NONE) { + if (maxall > atom->improper_per_atom) + error->all(FLERR,"Subsequent read data induced " + "too many impropers per atom"); + } else atom->improper_per_atom = maxall; + + memory->destroy(count); + return; + } + + // if 2nd pass: check that impropers were assigned correctly + + bigint n = 0; + for (int i = nlocal_previous; i < nlocal; i++) n += atom->num_improper[i]; + bigint sum; + MPI_Allreduce(&n,&sum,1,MPI_LMP_BIGINT,MPI_SUM,world); + int factor = 1; + if (!force->newton_bond) factor = 4; + + if (me == 0) { + if (screen) fprintf(screen," " BIGINT_FORMAT " impropers\n",sum/factor); + if (logfile) fprintf(logfile," " BIGINT_FORMAT " impropers\n",sum/factor); + } + + if (sum != factor*nimpropers) + error->all(FLERR,"Impropers assigned incorrectly"); +} + +/* ---------------------------------------------------------------------- + read all bonus data + to find atoms, must build atom map if not a molecular system +------------------------------------------------------------------------- */ + +void ReadData::bonus(bigint nbonus, AtomVec *ptr, const char *type) +{ + int nchunk,eof; + + int mapflag = 0; + if (atom->map_style == 0) { + mapflag = 1; + atom->map_init(); + atom->map_set(); + } + + bigint nread = 0; + bigint natoms = nbonus; + + while (nread < natoms) { + nchunk = MIN(natoms-nread,CHUNK); + eof = comm->read_lines_from_file(fp,nchunk,MAXLINE,buffer); + if (eof) error->all(FLERR,"Unexpected end of data file"); + atom->data_bonus(nchunk,buffer,ptr,id_offset); + nread += nchunk; + } + + if (mapflag) { + atom->map_delete(); + atom->map_style = 0; + } + + if (me == 0) { + if (screen) fprintf(screen," " BIGINT_FORMAT " %s\n",natoms,type); + if (logfile) fprintf(logfile," " BIGINT_FORMAT " %s\n",natoms,type); + } +} + +/* ---------------------------------------------------------------------- + read all body data + variable amount of info per body, described by ninteger and ndouble + to find atoms, must build atom map if not a molecular system + if not firstpass, just read past data, but no processing of data +------------------------------------------------------------------------- */ + +void ReadData::bodies(int firstpass) +{ + int m,nchunk,nline,nmax,ninteger,ndouble,nword,ncount,onebody,tmp; + char *eof; + + int mapflag = 0; + if (atom->map_style == 0 && firstpass) { + mapflag = 1; + atom->map_init(); + atom->map_set(); + } + + // nmax = max # of bodies to read in this chunk + // nchunk = actual # read + + bigint nread = 0; + bigint natoms = nbodies; + + while (nread < natoms) { + if (natoms-nread > CHUNK) nmax = CHUNK; + else nmax = natoms-nread; + + if (me == 0) { + nchunk = 0; + nline = 0; + m = 0; + + while (nchunk < nmax && nline <= CHUNK-MAXBODY) { + eof = fgets(&buffer[m],MAXLINE,fp); + if (eof == NULL) error->one(FLERR,"Unexpected end of data file"); + sscanf(&buffer[m],"%d %d %d",&tmp,&ninteger,&ndouble); + m += strlen(&buffer[m]); + + // read lines one at a time into buffer and count words + // count to ninteger and ndouble until have enough lines + + onebody = 0; + + nword = 0; + while (nword < ninteger) { + eof = fgets(&buffer[m],MAXLINE,fp); + if (eof == NULL) error->one(FLERR,"Unexpected end of data file"); + ncount = atom->count_words(&buffer[m],copy); + if (ncount == 0) + error->one(FLERR,"Too few values in body lines in data file"); + nword += ncount; + m += strlen(&buffer[m]); + onebody++; + } + if (nword > ninteger) + error->one(FLERR,"Too many values in body lines in data file"); + + nword = 0; + while (nword < ndouble) { + eof = fgets(&buffer[m],MAXLINE,fp); + if (eof == NULL) error->one(FLERR,"Unexpected end of data file"); + ncount = atom->count_words(&buffer[m],copy); + if (ncount == 0) + error->one(FLERR,"Too few values in body lines in data file"); + nword += ncount; + m += strlen(&buffer[m]); + onebody++; + } + if (nword > ndouble) + error->one(FLERR,"Too many values in body lines in data file"); + + if (onebody+1 > MAXBODY) + error->one(FLERR, + "Too many lines in one body in data file - boost MAXBODY"); + + nchunk++; + nline += onebody+1; + } + + if (buffer[m-1] != '\n') strcpy(&buffer[m++],"\n"); + m++; + } + + MPI_Bcast(&nchunk,1,MPI_INT,0,world); + MPI_Bcast(&m,1,MPI_INT,0,world); + MPI_Bcast(buffer,m,MPI_CHAR,0,world); + + if (firstpass) atom->data_bodies(nchunk,buffer,avec_body,id_offset); + nread += nchunk; + } + + if (mapflag && firstpass) { + atom->map_delete(); + atom->map_style = 0; + } + + if (me == 0 && firstpass) { + if (screen) fprintf(screen," " BIGINT_FORMAT " bodies\n",natoms); + if (logfile) fprintf(logfile," " BIGINT_FORMAT " bodies\n",natoms); + } +} + +/* ---------------------------------------------------------------------- */ + +void ReadData::mass() +{ + char *next; + char *buf = new char[ntypes*MAXLINE]; + + int eof = comm->read_lines_from_file(fp,ntypes,MAXLINE,buf); + if (eof) error->all(FLERR,"Unexpected end of data file"); + + char *original = buf; + for (int i = 0; i < ntypes; i++) { + next = strchr(buf,'\n'); + *next = '\0'; + atom->set_mass(buf,toffset); + buf = next + 1; + } + delete [] original; +} + +/* ---------------------------------------------------------------------- */ + +void ReadData::paircoeffs() +{ + char *next; + char *buf = new char[ntypes*MAXLINE]; + + int eof = comm->read_lines_from_file(fp,ntypes,MAXLINE,buf); + if (eof) error->all(FLERR,"Unexpected end of data file"); + + char *original = buf; + for (int i = 0; i < ntypes; i++) { + next = strchr(buf,'\n'); + *next = '\0'; + parse_coeffs(buf,NULL,1,2,toffset); + if (narg == 0) error->all(FLERR,"Unexpected end of PairCoeffs section"); + force->pair->coeff(narg,arg); + buf = next + 1; + } + delete [] original; +} + +/* ---------------------------------------------------------------------- */ + +void ReadData::pairIJcoeffs() +{ + int i,j; + char *next; + + int nsq = ntypes * (ntypes+1) / 2; + char *buf = new char[nsq * MAXLINE]; + + int eof = comm->read_lines_from_file(fp,nsq,MAXLINE,buf); + if (eof) error->all(FLERR,"Unexpected end of data file"); + + char *original = buf; + for (i = 0; i < ntypes; i++) + for (j = i; j < ntypes; j++) { + next = strchr(buf,'\n'); + *next = '\0'; + parse_coeffs(buf,NULL,0,2,toffset); + if (narg == 0) error->all(FLERR,"Unexpected end of PairCoeffs section"); + force->pair->coeff(narg,arg); + buf = next + 1; + } + delete [] original; +} + +/* ---------------------------------------------------------------------- */ + +void ReadData::bondcoeffs() +{ + char *next; + char *buf = new char[nbondtypes*MAXLINE]; + + int eof = comm->read_lines_from_file(fp,nbondtypes,MAXLINE,buf); + if (eof) error->all(FLERR,"Unexpected end of data file"); + + char *original = buf; + for (int i = 0; i < nbondtypes; i++) { + next = strchr(buf,'\n'); + *next = '\0'; + parse_coeffs(buf,NULL,0,1,boffset); + if (narg == 0) error->all(FLERR,"Unexpected end of BondCoeffs section"); + force->bond->coeff(narg,arg); + buf = next + 1; + } + delete [] original; +} + +/* ---------------------------------------------------------------------- */ + +void ReadData::anglecoeffs(int which) +{ + char *next; + char *buf = new char[nangletypes*MAXLINE]; + + int eof = comm->read_lines_from_file(fp,nangletypes,MAXLINE,buf); + if (eof) error->all(FLERR,"Unexpected end of data file"); + + char *original = buf; + for (int i = 0; i < nangletypes; i++) { + next = strchr(buf,'\n'); + *next = '\0'; + if (which == 0) parse_coeffs(buf,NULL,0,1,aoffset); + else if (which == 1) parse_coeffs(buf,"bb",0,1,aoffset); + else if (which == 2) parse_coeffs(buf,"ba",0,1,aoffset); + if (narg == 0) error->all(FLERR,"Unexpected end of AngleCoeffs section"); + force->angle->coeff(narg,arg); + buf = next + 1; + } + delete [] original; +} + +/* ---------------------------------------------------------------------- */ + +void ReadData::dihedralcoeffs(int which) +{ + char *next; + char *buf = new char[ndihedraltypes*MAXLINE]; + + int eof = comm->read_lines_from_file(fp,ndihedraltypes,MAXLINE,buf); + if (eof) error->all(FLERR,"Unexpected end of data file"); + + char *original = buf; + for (int i = 0; i < ndihedraltypes; i++) { + next = strchr(buf,'\n'); + *next = '\0'; + if (which == 0) parse_coeffs(buf,NULL,0,1,doffset); + else if (which == 1) parse_coeffs(buf,"mbt",0,1,doffset); + else if (which == 2) parse_coeffs(buf,"ebt",0,1,doffset); + else if (which == 3) parse_coeffs(buf,"at",0,1,doffset); + else if (which == 4) parse_coeffs(buf,"aat",0,1,doffset); + else if (which == 5) parse_coeffs(buf,"bb13",0,1,doffset); + if (narg == 0) error->all(FLERR,"Unexpected end of DihedralCoeffs section"); + force->dihedral->coeff(narg,arg); + buf = next + 1; + } + delete [] original; +} + +/* ---------------------------------------------------------------------- */ + +void ReadData::impropercoeffs(int which) +{ + char *next; + char *buf = new char[nimpropertypes*MAXLINE]; + + int eof = comm->read_lines_from_file(fp,nimpropertypes,MAXLINE,buf); + if (eof) error->all(FLERR,"Unexpected end of data file"); + + char *original = buf; + for (int i = 0; i < nimpropertypes; i++) { + next = strchr(buf,'\n'); + *next = '\0'; + if (which == 0) parse_coeffs(buf,NULL,0,1,ioffset); + else if (which == 1) parse_coeffs(buf,"aa",0,1,ioffset); + if (narg == 0) error->all(FLERR,"Unexpected end of ImproperCoeffs section"); + force->improper->coeff(narg,arg); + buf = next + 1; + } + delete [] original; +} + +/* ---------------------------------------------------------------------- + read fix section, pass lines to fix to process + n = index of fix +------------------------------------------------------------------------- */ + +void ReadData::fix(int ifix, char *keyword) +{ + int nchunk,eof; + + bigint nline = modify->fix[ifix]->read_data_skip_lines(keyword); + + bigint nread = 0; + while (nread < nline) { + nchunk = MIN(nline-nread,CHUNK); + eof = comm->read_lines_from_file(fp,nchunk,MAXLINE,buffer); + if (eof) error->all(FLERR,"Unexpected end of data file"); + modify->fix[ifix]->read_data_section(keyword,nchunk,buffer,id_offset); + nread += nchunk; + } +} + +/* ---------------------------------------------------------------------- + reallocate the count vector from cmax to amax+1 and return new length + zero new locations +------------------------------------------------------------------------- */ + +int ReadData::reallocate(int **pcount, int cmax, int amax) +{ + int *count = *pcount; + memory->grow(count,amax+1,"read_data:count"); + for (int i = cmax; i <= amax; i++) count[i] = 0; + *pcount = count; + return amax+1; +} + +/* ---------------------------------------------------------------------- + proc 0 opens data file + test if gzipped +------------------------------------------------------------------------- */ + +void ReadData::open(char *file) +{ + compressed = 0; + char *suffix = file + strlen(file) - 3; + if (suffix > file && strcmp(suffix,".gz") == 0) compressed = 1; + if (!compressed) fp = fopen(file,"r"); + else { +#ifdef LAMMPS_GZIP + char gunzip[128]; + sprintf(gunzip,"gzip -c -d %s",file); + +#ifdef _WIN32 + fp = _popen(gunzip,"rb"); +#else + fp = popen(gunzip,"r"); +#endif + +#else + error->one(FLERR,"Cannot open gzipped file"); +#endif + } + + if (fp == NULL) { + char str[128]; + sprintf(str,"Cannot open file %s",file); + error->one(FLERR,str); + } +} + +/* ---------------------------------------------------------------------- + grab next keyword + read lines until one is non-blank + keyword is all text on line w/out leading & trailing white space + optional style can be appended after comment char '#' + read one additional line (assumed blank) + if any read hits EOF, set keyword to empty + if first = 1, line variable holds non-blank line that ended header +------------------------------------------------------------------------- */ + +void ReadData::parse_keyword(int first) +{ + int eof = 0; + int done = 0; + + // proc 0 reads upto non-blank line plus 1 following line + // eof is set to 1 if any read hits end-of-file + + if (me == 0) { + if (!first) { + if (fgets(line,MAXLINE,fp) == NULL) eof = 1; + } + while (eof == 0 && done == 0) { + int blank = strspn(line," \t\n\r"); + if ((blank == strlen(line)) || (line[blank] == '#')) { + if (fgets(line,MAXLINE,fp) == NULL) eof = 1; + } else done = 1; + } + if (fgets(buffer,MAXLINE,fp) == NULL) { + eof = 1; + buffer[0] = '\0'; + } + } + + // if eof, set keyword empty and return + + MPI_Bcast(&eof,1,MPI_INT,0,world); + if (eof) { + keyword[0] = '\0'; + return; + } + + // bcast keyword line to all procs + + int n; + if (me == 0) n = strlen(line) + 1; + MPI_Bcast(&n,1,MPI_INT,0,world); + MPI_Bcast(line,n,MPI_CHAR,0,world); + + // store optional "style" following comment char '#' after keyword + + char *ptr; + if ((ptr = strchr(line,'#'))) { + *ptr++ = '\0'; + while (*ptr == ' ' || *ptr == '\t') ptr++; + int stop = strlen(ptr) - 1; + while (ptr[stop] == ' ' || ptr[stop] == '\t' + || ptr[stop] == '\n' || ptr[stop] == '\r') stop--; + ptr[stop+1] = '\0'; + strcpy(style,ptr); + } else style[0] = '\0'; + + // copy non-whitespace portion of line into keyword + + int start = strspn(line," \t\n\r"); + int stop = strlen(line) - 1; + while (line[stop] == ' ' || line[stop] == '\t' + || line[stop] == '\n' || line[stop] == '\r') stop--; + line[stop+1] = '\0'; + strcpy(keyword,&line[start]); +} + +/* ---------------------------------------------------------------------- + proc 0 reads N lines from file + could be skipping Natoms lines, so use bigints +------------------------------------------------------------------------- */ + +void ReadData::skip_lines(bigint n) +{ + if (me) return; + if (n <= 0) return; + char *eof = NULL; + for (bigint i = 0; i < n; i++) eof = fgets(line,MAXLINE,fp); + if (eof == NULL) error->one(FLERR,"Unexpected end of data file"); +} + +/* ---------------------------------------------------------------------- + parse a line of coeffs into words, storing them in narg,arg + trim anything from '#' onward + word strings remain in line, are not copied + if addstr != NULL, add addstr as extra arg for class2 angle/dihedral/improper + if 2nd word starts with letter, then is hybrid style, add addstr after it + else add addstr before 2nd word + if dupflag, duplicate 1st word, so pair_coeff "2" becomes "2 2" + if noffset, add offset to first noffset args, which are atom/bond/etc types +------------------------------------------------------------------------- */ + +void ReadData::parse_coeffs(char *line, const char *addstr, + int dupflag, int noffset, int offset) +{ + char *ptr; + if ((ptr = strchr(line,'#'))) *ptr = '\0'; + + narg = 0; + char *word = strtok(line," \t\n\r\f"); + while (word) { + if (narg == maxarg) { + maxarg += DELTA; + arg = (char **) + memory->srealloc(arg,maxarg*sizeof(char *),"read_data:arg"); + } + if (addstr && narg == 1 && !islower(word[0])) arg[narg++] = (char *) addstr; + arg[narg++] = word; + if (addstr && narg == 2 && islower(word[0])) arg[narg++] = (char *) addstr; + if (dupflag && narg == 1) arg[narg++] = word; + word = strtok(NULL," \t\n\r\f"); + } + + if (noffset) { + int value = force->inumeric(FLERR,arg[0]); + sprintf(argoffset1,"%d",value+offset); + arg[0] = argoffset1; + if (noffset == 2) { + value = force->inumeric(FLERR,arg[1]); + sprintf(argoffset2,"%d",value+offset); + arg[1] = argoffset2; + } + } +} + +/* ---------------------------------------------------------------------- + compare two style strings if they both exist + one = comment in data file section, two = currently-defined style + ignore suffixes listed in suffixes array at top of file +------------------------------------------------------------------------- */ + +int ReadData::style_match(const char *one, const char *two) +{ + int i,delta,len,len1,len2; + + if ((one == NULL) || (two == NULL)) return 1; + + len1 = strlen(one); + len2 = strlen(two); + + for (i = 0; suffixes[i] != NULL; i++) { + len = strlen(suffixes[i]); + if ((delta = len1 - len) > 0) + if (strcmp(one+delta,suffixes[i]) == 0) len1 = delta; + if ((delta = len2 - len) > 0) + if (strcmp(two+delta,suffixes[i]) == 0) len2 = delta; + } + + if ((len1 == 0) || (len1 == len2) || (strncmp(one,two,len1) == 0)) return 1; + return 0; +} diff --git a/src/USER-HADRESS/read_data.h b/src/USER-HADRESS/read_data.h new file mode 100644 index 0000000000..5463c86f08 --- /dev/null +++ b/src/USER-HADRESS/read_data.h @@ -0,0 +1,560 @@ +/* -*- c++ -*- ---------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + http://lammps.sandia.gov, Sandia National Laboratories + Steve Plimpton, sjplimp@sandia.gov + + Copyright (2003) Sandia Corporation. Under the terms of Contract + DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains + certain rights in this software. This software is distributed under + the GNU General Public License. + + See the README file in the top-level LAMMPS directory. +------------------------------------------------------------------------- */ + +#ifdef COMMAND_CLASS + +CommandStyle(read_data,ReadData) + +#else + +#ifndef LMP_READ_DATA_H +#define LMP_READ_DATA_H + +#include +#include "pointers.h" + +namespace LAMMPS_NS { + +class ReadData : protected Pointers { + public: + ReadData(class LAMMPS *); + ~ReadData(); + void command(int, char **); + + private: + int me,compressed; + char *line,*copy,*keyword,*buffer,*style; + FILE *fp; + char **arg; + int narg,maxarg; + char argoffset1[8],argoffset2[8]; + + bigint id_offset; + + int nlocal_previous; + bigint natoms; + bigint nbonds,nangles,ndihedrals,nimpropers; + int ntypes; + int nbondtypes,nangletypes,ndihedraltypes,nimpropertypes; + + bigint nellipsoids; + class AtomVecEllipsoid *avec_ellipsoid; + bigint nlines; + class AtomVecLine *avec_line; + bigint ntris; + class AtomVecTri *avec_tri; + bigint nbodies; + class AtomVecBody *avec_body; + + // box info + + double boxlo[3],boxhi[3]; + double xy,xz,yz; + int triclinic; + + // optional args + + int addflag,offsetflag,shiftflag,coeffflag; + tagint addvalue; + int toffset,boffset,aoffset,doffset,ioffset; + double shift[3]; + int extra_atom_types,extra_bond_types,extra_angle_types; + int extra_dihedral_types,extra_improper_types; + int groupbit; + + int nfix; + int *fix_index; + char **fix_header; + char **fix_section; + + // methods + + void open(char *); + void scan(int &, int &, int &, int &); + int reallocate(int **, int, int); + void header(int); + void parse_keyword(int); + void skip_lines(bigint); + void parse_coeffs(char *, const char *, int, int, int); + int style_match(const char *, const char *); + + void atoms(); + void velocities(); + + void bonds(int); + void bond_scan(int, char *, int *); + void angles(int); + void dihedrals(int); + void impropers(int); + + void bonus(bigint, class AtomVec *, const char *); + void bodies(int); + + void mass(); + void paircoeffs(); + void pairIJcoeffs(); + void bondcoeffs(); + void anglecoeffs(int); + void dihedralcoeffs(int); + void impropercoeffs(int); + + void fix(int, char *); +}; + +} + +#endif +#endif + +/* ERROR/WARNING messages: + +E: Illegal ... command + +Self-explanatory. Check the input script syntax and compare to the +documentation for the command. You can use -echo screen as a +command-line option when running LAMMPS to see the offending line. + +E: Read data add offset is too big + +It cannot be larger than the size of atom IDs, e.g. the maximum 32-bit +integer. + +E: Non-zero read_data shift z value for 2d simulation + +Self-explanatory. + +E: No bonds allowed with this atom style + +Self-explanatory. + +E: No angles allowed with this atom style + +Self-explanatory. + +E: No dihedrals allowed with this atom style + +Self-explanatory. + +E: No impropers allowed with this atom style + +Self-explanatory. + +E: Fix ID for read_data does not exist + +Self-explanatory. + +E: Cannot run 2d simulation with nonperiodic Z dimension + +Use the boundary command to make the z dimension periodic in order to +run a 2d simulation. + +E: Cannot read_data without add keyword after simulation box is defined + +Self-explanatory. + +E: Cannot use read_data add before simulation box is defined + +Self-explanatory. + +E: Cannot use read_data offset without add flag + +Self-explanatory. + +E: Cannot use read_data shift without add flag + +Self-explanatory. + +E: Cannot use read_data extra with add flag + +Self-explanatory. + +W: Atom style in data file differs from currently defined atom style + +Self-explanatory. + +E: Must read Atoms before Velocities + +The Atoms section of a data file must come before a Velocities +section. + +E: Invalid data file section: Bonds + +Atom style does not allow bonds. + +E: Must read Atoms before Bonds + +The Atoms section of a data file must come before a Bonds section. + +E: Invalid data file section: Angles + +Atom style does not allow angles. + +E: Must read Atoms before Angles + +The Atoms section of a data file must come before an Angles section. + +E: Invalid data file section: Dihedrals + +Atom style does not allow dihedrals. + +E: Must read Atoms before Dihedrals + +The Atoms section of a data file must come before a Dihedrals section. + +E: Invalid data file section: Impropers + +Atom style does not allow impropers. + +E: Must read Atoms before Impropers + +The Atoms section of a data file must come before an Impropers +section. + +E: Invalid data file section: Ellipsoids + +Atom style does not allow ellipsoids. + +E: Must read Atoms before Ellipsoids + +The Atoms section of a data file must come before a Ellipsoids +section. + +E: Invalid data file section: Lines + +Atom style does not allow lines. + +E: Must read Atoms before Lines + +The Atoms section of a data file must come before a Lines section. + +E: Invalid data file section: Triangles + +Atom style does not allow triangles. + +E: Must read Atoms before Triangles + +The Atoms section of a data file must come before a Triangles section. + +E: Invalid data file section: Bodies + +Atom style does not allow bodies. + +E: Must read Atoms before Bodies + +The Atoms section of a data file must come before a Bodies section. + +E: Must define pair_style before Pair Coeffs + +Must use a pair_style command before reading a data file that defines +Pair Coeffs. + +W: Pair style in data file differs from currently defined pair style + +Self-explanatory. + +E: Must define pair_style before PairIJ Coeffs + +Must use a pair_style command before reading a data file that defines +PairIJ Coeffs. + +E: Invalid data file section: Bond Coeffs + +Atom style does not allow bonds. + +E: Must define bond_style before Bond Coeffs + +Must use a bond_style command before reading a data file that +defines Bond Coeffs. + +W: Bond style in data file differs from currently defined bond style + +Self-explanatory. + +E: Invalid data file section: Angle Coeffs + +Atom style does not allow angles. + +E: Must define angle_style before Angle Coeffs + +Must use an angle_style command before reading a data file that +defines Angle Coeffs. + +W: Angle style in data file differs from currently defined angle style + +Self-explanatory. + +E: Invalid data file section: Dihedral Coeffs + +Atom style does not allow dihedrals. + +E: Must define dihedral_style before Dihedral Coeffs + +Must use a dihedral_style command before reading a data file that +defines Dihedral Coeffs. + +W: Dihedral style in data file differs from currently defined dihedral style + +Self-explanatory. + +E: Invalid data file section: Improper Coeffs + +Atom style does not allow impropers. + +E: Must define improper_style before Improper Coeffs + +Must use an improper_style command before reading a data file that +defines Improper Coeffs. + +W: Improper style in data file differs from currently defined improper style + +Self-explanatory. + +E: Invalid data file section: BondBond Coeffs + +Atom style does not allow angles. + +E: Must define angle_style before BondBond Coeffs + +Must use an angle_style command before reading a data file that +defines Angle Coeffs. + +E: Invalid data file section: BondAngle Coeffs + +Atom style does not allow angles. + +E: Must define angle_style before BondAngle Coeffs + +Must use an angle_style command before reading a data file that +defines Angle Coeffs. + +E: Invalid data file section: MiddleBondTorsion Coeffs + +Atom style does not allow dihedrals. + +E: Must define dihedral_style before MiddleBondTorsion Coeffs + +Must use a dihedral_style command before reading a data file that +defines MiddleBondTorsion Coeffs. + +E: Invalid data file section: EndBondTorsion Coeffs + +Atom style does not allow dihedrals. + +E: Must define dihedral_style before EndBondTorsion Coeffs + +Must use a dihedral_style command before reading a data file that +defines EndBondTorsion Coeffs. + +E: Invalid data file section: AngleTorsion Coeffs + +Atom style does not allow dihedrals. + +E: Must define dihedral_style before AngleTorsion Coeffs + +Must use a dihedral_style command before reading a data file that +defines AngleTorsion Coeffs. + +E: Invalid data file section: AngleAngleTorsion Coeffs + +Atom style does not allow dihedrals. + +E: Must define dihedral_style before AngleAngleTorsion Coeffs + +Must use a dihedral_style command before reading a data file that +defines AngleAngleTorsion Coeffs. + +E: Invalid data file section: BondBond13 Coeffs + +Atom style does not allow dihedrals. + +E: Must define dihedral_style before BondBond13 Coeffs + +Must use a dihedral_style command before reading a data file that +defines BondBond13 Coeffs. + +E: Invalid data file section: AngleAngle Coeffs + +Atom style does not allow impropers. + +E: Must define improper_style before AngleAngle Coeffs + +Must use an improper_style command before reading a data file that +defines AngleAngle Coeffs. + +E: Unknown identifier in data file: %s + +A section of the data file cannot be read by LAMMPS. + +E: No atoms in data file + +The header of the data file indicated that atoms would be included, +but they are not present. + +E: Needed molecular topology not in data file + +The header of the data file indicated bonds, angles, etc would be +included, but they are not present. + +E: Needed bonus data not in data file + +Some atom styles require bonus data. See the read_data doc page for +details. + +E: Read_data shrink wrap did not assign all atoms correctly + +This is typically because the box-size specified in the data file is +large compared to the actual extent of atoms in a shrink-wrapped +dimension. When LAMMPS shrink-wraps the box atoms will be lost if the +processor they are re-assigned to is too far away. Choose a box +size closer to the actual extent of the atoms. + +E: Unexpected end of data file + +LAMMPS hit the end of the data file while attempting to read a +section. Something is wrong with the format of the data file. + +E: No ellipsoids allowed with this atom style + +Self-explanatory. Check data file. + +E: No lines allowed with this atom style + +Self-explanatory. Check data file. + +E: No triangles allowed with this atom style + +Self-explanatory. Check data file. + +E: No bodies allowed with this atom style + +Self-explanatory. Check data file. + +E: System in data file is too big + +See the setting for bigint in the src/lmptype.h file. + +E: Bonds defined but no bond types + +The data file header lists bonds but no bond types. + +E: Angles defined but no angle types + +The data file header lists angles but no angle types. + +E: Dihedrals defined but no dihedral types + +The data file header lists dihedrals but no dihedral types. + +E: Impropers defined but no improper types + +The data file header lists improper but no improper types. + +E: No molecule topology allowed with atom style template + +The data file cannot specify the number of bonds, angles, etc, +because this info if inferred from the molecule templates. + +E: Did not assign all atoms correctly + +Atoms read in from a data file were not assigned correctly to +processors. This is likely due to some atom coordinates being +outside a non-periodic simulation box. + +E: Subsequent read data induced too many bonds per atom + +See the create_box extra/bond/per/atom or read_data "extra bond per +atom" header value to set this limit larger. + +E: Bonds assigned incorrectly + +Bonds read in from the data file were not assigned correctly to atoms. +This means there is something invalid about the topology definitions. + +E: Subsequent read data induced too many angles per atom + +See the create_box extra/angle/per/atom or read_data "extra angle per +atom" header value to set this limit larger. + +E: Angles assigned incorrectly + +Angles read in from the data file were not assigned correctly to +atoms. This means there is something invalid about the topology +definitions. + +E: Subsequent read data induced too many dihedrals per atom + +See the create_box extra/dihedral/per/atom or read_data "extra +dihedral per atom" header value to set this limit larger. + +E: Dihedrals assigned incorrectly + +Dihedrals read in from the data file were not assigned correctly to +atoms. This means there is something invalid about the topology +definitions. + +E: Subsequent read data induced too many impropers per atom + +See the create_box extra/improper/per/atom or read_data "extra +improper per atom" header value to set this limit larger. + +E: Impropers assigned incorrectly + +Impropers read in from the data file were not assigned correctly to +atoms. This means there is something invalid about the topology +definitions. + +E: Too few values in body lines in data file + +Self-explanatory. + +E: Too many values in body lines in data file + +Self-explanatory. + +E: Too many lines in one body in data file - boost MAXBODY + +MAXBODY is a setting at the top of the src/read_data.cpp file. +Set it larger and re-compile the code. + +E: Unexpected end of PairCoeffs section + +Read a blank line. + +E: Unexpected end of BondCoeffs section + +Read a blank line. + +E: Unexpected end of AngleCoeffs section + +Read a blank line. + +E: Unexpected end of DihedralCoeffs section + +Read a blank line. + +E: Unexpected end of ImproperCoeffs section + +Read a blank line. + +E: Cannot open gzipped file + +LAMMPS was compiled without support for reading and writing gzipped +files through a pipeline to the gzip program with -DLAMMPS_GZIP. + +E: Cannot open file %s + +The specified file cannot be opened. Check that the path and name are +correct. If the file is a compressed file, also check that the gzip +executable can be found and run. + +*/ From 10435ca8dcc7743c7c75707a8761da17479f8e44 Mon Sep 17 00:00:00 2001 From: MaziarHeidari Date: Mon, 20 Jun 2016 17:49:11 +0200 Subject: [PATCH 02/15] HADRESS_NEW_REVISION --- examples/H-AdResS/H-AdResS/HADRESS_Water | 123 +++++++++++++++++++++++ examples/H-AdResS/Relaxation/LongSetup | 107 ++++++++++++++++++++ examples/H-AdResS/Relaxation/molecule | 70 +++++++++++++ src/USER-HADRESS/README | 18 ++++ 4 files changed, 318 insertions(+) create mode 100644 examples/H-AdResS/H-AdResS/HADRESS_Water create mode 100644 examples/H-AdResS/Relaxation/LongSetup create mode 100644 examples/H-AdResS/Relaxation/molecule create mode 100644 src/USER-HADRESS/README diff --git a/examples/H-AdResS/H-AdResS/HADRESS_Water b/examples/H-AdResS/H-AdResS/HADRESS_Water new file mode 100644 index 0000000000..adbda23f69 --- /dev/null +++ b/examples/H-AdResS/H-AdResS/HADRESS_Water @@ -0,0 +1,123 @@ +# SPC/E water box benchmark +# This is HAdResS setup for simulation of water molecules. +# The water molecules are simulated and coupled into two resolution: +# High resolution in which atomistic SPC/E forcefields are present and +# Low resolution in which coarse-grained WCA forcefield is computed. +# For more information see Documentation and the follwoing paper: +# Heidari et al., Eur. Phys. J. Special Topics, 2016. + +# You need to have the file "restart.waterT300.100" for running the script. +# Thus you need to run first the equillibration script (LongSetup) for 50000 timestep, +# and then set it as the restart file. + +units real +atom_style full/hars +boundary p p p + +#read_data HAdResS_SPC.data +read_restart restart.waterT300.50000 + +variable root index waterT300 +variable Nrun equal 1000000 +variable Nf equal 100 +variable Ne equal 10 +variable Nr equal ${Nf}/${Ne} +variable Ndump equal 500 +variable Nrestart equal 10000 +variable Nr_rdf equal 0.5*${Nrun}/${Ne} + +variable Comp_AT_Size equal 60.0 +variable Comp_HY_Size equal 25.0 +variable Hyb_Shape string slab + +variable Comp_Dens_nMolType equal 1 +variable Comp_Pres_Switch equal 1 +variable Comp_Pres_Start equal 150000 +variable Comp_Pres_End equal 300000 +variable Comp_Pres_Freq equal 1000 +variable Comp_Pres_Lambda_Size equal 0.02 + +variable Comp_Dens_Switch equal 1 +variable Comp_Dens_Start equal 500000 +variable Comp_Dens_End equal 900000 +variable Comp_Dens_Freq equal 1000 +variable Comp_Dens_Alpha equal 4.0 +variable Comp_Dens_Sigma equal 6.0 +variable Comp_Dens_Range_Int equal 2.0 +variable Comp_Dens_Bin_Size equal 1.5 +variable Comp_Dens_Ref_Dens equal 0.1 +variable Load_File_Flag equal 0 + + +variable Text equal 300.0 +variable Pext equal 1.0 + +pair_style hybrid/overlay lj/cut/hars/cg 2.469416506 0 0 lj/cut/coul/dsf/hars/at 0.2 10.0 12.0 0 0 + +pair_coeff * * lj/cut/hars/cg 1.0 2.2 + +pair_coeff 1 1 lj/cut/coul/dsf/hars/at 0.15535 3.166 +pair_coeff * 2 lj/cut/coul/dsf/hars/at 0.0000 0.0000 +pair_modify shift yes + +####################################################################### + +bond_style harmonic +angle_style harmonic +dihedral_style none +improper_style none + +bond_coeff 1 1000.00 1.000 +angle_coeff 1 100.0 109.47 + +#special_bonds lj/cut/coul/dsf/hars/at 0.0 0.0 0.5 +special_bonds lj/coul 0.0 0.0 0.5 + +neighbor 1.0 bin +neigh_modify every 1 delay 10 check yes + +fix LAMBDACALC all lambdah/calc ${Comp_Dens_nMolType} ${Comp_HY_Size} ${Comp_AT_Size} ${Comp_Pres_Switch} ${Comp_Pres_Lambda_Size} ${Comp_Pres_Freq} ${Comp_Pres_Start} ${Comp_Pres_End} ${Hyb_Shape} & + ${Comp_Dens_Switch} ${Comp_Dens_Bin_Size} ${Comp_Dens_Freq} ${Comp_Dens_Start} ${Comp_Dens_End} ${Comp_Dens_Sigma} ${Comp_Dens_Range_Int} ${Comp_Dens_Ref_Dens} ${Comp_Dens_Alpha} ${Load_File_Flag} + +fix 1 all shake 0.0001 20 0 b 1 a 1 +fix 3 all nve +fix 4 all langevin 300.0 300.0 100 9892571 + +timestep 1.0 + +######################################################################## +compute FFX all property/atom fx +compute SumFFX all reduce sum c_FFX + +compute FFY all property/atom fy +compute SumFFY all reduce sum c_FFY + +compute FFZ all property/atom fz +compute SumFFZ all reduce sum c_FFZ + +compute T all temp +fix TempAve all ave/time ${Ne} ${Nr} ${Nf} c_T + +compute Pperatom all stress/atom NULL +variable Patom atom -1.0*c_Pperatom[1]/(3*0.5*(yhi-ylo)*(zhi-zlo)) + +variable P equal press +fix PressAve all ave/time ${Ne} ${Nr} ${Nf} v_P + +fix PressureP all ave/spatial 5 1000 5000 x lower 3.0 v_Patom ave one file Pres.profile +fix DensityD all ave/spatial 5 1000 5000 x lower 3.0 density/number ave one file Dens.profile + +compute rdf all rdf 100 1 1 # oxygen-oxygen +fix rdf all ave/time 10 1000 10000 c_rdf file O.rdf mode vector + +######################################################################## +thermo_style custom step temp f_TempAve press f_PressAve density ke ebond eangle evdwl ecoul etotal c_SumFFX c_SumFFY c_SumFFZ + +thermo_modify flush yes +thermo ${Nf} + +dump 2 all custom 500 wat.lammpstrj id type x y z vx vy vz + +restart ${Nrestart} restart.${root} + +run ${Nrun} diff --git a/examples/H-AdResS/Relaxation/LongSetup b/examples/H-AdResS/Relaxation/LongSetup new file mode 100644 index 0000000000..45d09808dd --- /dev/null +++ b/examples/H-AdResS/Relaxation/LongSetup @@ -0,0 +1,107 @@ +# SPC/E water box benchmark +# HAdResS Relaxation Setup +# Maziar Heidari, Max Planck Institute for Polymer Research +# (heidari@mpip-mainz.mpg.de)) + +units real +atom_style full/hars +boundary p p p + +#read_data HAdResS_SPC.data +#read_restart restart.waterT300.10000 + +variable root index waterT300 +variable Nrun equal 50000 +variable Nf equal 100 +variable Ne equal 10 +variable Nr equal ${Nf}/${Ne} +variable Ndump equal 1000 +variable Nrestart equal 100 +variable Nr_rdf equal 0.5*${Nrun}/${Ne} + +variable Text equal 300.0 +variable Pext equal 1.0 + +variable x index 1 +variable y index 1 +variable z index 1 + +variable xx equal 40*$x +variable yy equal 8*$y +variable zz equal 8*$z + +variable half_xx equal 0.5*${xx} +variable half_yy equal 0.5*${yy} +variable half_zz equal 0.5*${zz} + +####################################################################### +molecule mol1 molecule + +lattice fcc 5.0 +region box block -${half_xx} ${half_xx} -${half_yy} ${half_yy} -${half_zz} ${half_zz} +create_box 2 box bond/types 1 extra/bond/per/atom 2 angle/types 1 extra/angle/per/atom 1 dihedral/types 0 improper/types 0 extra/special/per/atom 2 +create_atoms 0 box mol mol1 10 + +mass 1 15.9994 +mass 2 1.00794 + +pair_style lj/cut/coul/dsf 0.2 10.0 12.0 + +pair_coeff 1 1 0.15535 3.166 +pair_coeff * 2 0.0000 0.0000 +######################################################################## + +bond_style harmonic +angle_style harmonic + +bond_coeff 1 1000.00 1.000 +angle_coeff 1 100.0 109.47 + +special_bonds lj/coul 0.0 0.0 0.5 + +neighbor 1.0 bin +neigh_modify every 1 delay 10 check yes + +fix 1 all shake 0.0001 20 0 b 1 a 1 +fix 2 all npt temp ${Text} ${Text} 100.0 iso ${Pext} ${Pext} 1000.0 + +velocity all create 300 432567 dist uniform + +timestep 1.0 + +######################################################################## +compute FFX all property/atom fx +compute SumFFX all reduce sum c_FFX + +compute FFY all property/atom fy +compute SumFFY all reduce sum c_FFY + +compute FFZ all property/atom fz +compute SumFFZ all reduce sum c_FFZ + +compute T all temp +fix TempAve all ave/time ${Ne} ${Nr} ${Nf} c_T + +compute Pperatom all stress/atom NULL +variable Patom atom -1.0*c_Pperatom[1]/(3*0.5*(yhi-ylo)*(zhi-zlo)) + +variable P equal press +fix PressAve all ave/time ${Ne} ${Nr} ${Nf} v_P + +fix PressureP all ave/spatial 10 1000 10000 x lower 1.0 v_Patom ave one file Pres.profile +fix DensityD all ave/spatial 10 1000 10000 x lower 1.0 density/number ave one file Dens.profile + +compute rdf all rdf 100 1 1 # oxygen-oxygen +fix rdf all ave/time 10 1000 10000 c_rdf file O.rdf mode vector + +######################################################################## +thermo_style custom step temp f_TempAve press f_PressAve density vol ke ebond eangle evdwl ecoul etotal c_SumFFX c_SumFFY c_SumFFZ + +thermo_modify flush yes +thermo ${Nf} + +dump trj all atom ${Ndump} wat.lammpstrj + +restart ${Nrestart} restart.${root} + +run ${Nrun} diff --git a/examples/H-AdResS/Relaxation/molecule b/examples/H-AdResS/Relaxation/molecule new file mode 100644 index 0000000000..8e37ca578a --- /dev/null +++ b/examples/H-AdResS/Relaxation/molecule @@ -0,0 +1,70 @@ +# molecule + +3 atoms +2 bonds +1 angles +0 dihedrals +0 impropers + +Coords + +1 0 0 0 +2 0.790422368 0.612562225 0 +3 -0.790422368 0.612562225 0 + +Types + +1 1 +2 2 +3 2 + +moltypeH +1 1 +2 1 +3 1 + +replambdaH + +1 1 +2 0 +3 0 + +Charges + +1 -0.8472 +2 0.4236 +3 0.4236 + +Masses + +1 15.9994 +2 1.00794 +3 1.00794 + +Diameters + +1 1.563111282 +2 0.622023675 +3 0.622023675 + +Bonds + +1 1 1 2 +2 1 1 3 + +Angles + +1 1 2 1 3 + +Special Bond Counts + +1 2 0 0 +2 1 0 0 +3 1 0 0 + +Special Bonds + +1 2 3 +2 1 +3 1 + diff --git a/src/USER-HADRESS/README b/src/USER-HADRESS/README new file mode 100644 index 0000000000..d4c860100b --- /dev/null +++ b/src/USER-HADRESS/README @@ -0,0 +1,18 @@ +This package contains files that brings the utility of +Hamiltonian Adaptive Resolution Simulations (H-AdResS) to the Lammps package. + + +See the doc page for for detailed usage instructions. + +There is example script for using this package in the folder +"example" + + +The persons who created this package are + +Maziar Heidari (Max Planck Institute for Polymer Research) +Robinson Cortes-Huerto (Max Planck Institute for Polymer Research) +Raffaello Potestio (Max Planck Institute for Polymer Research) +and Davide Donadio ( Department of Chemistry, University of California, Davis) + +Here is a contact information if you have questions. (heidari@mpip-mainz.mpg.de) From d40eaf99429a1fb9d40aa126825f31e8cbbf7ae8 Mon Sep 17 00:00:00 2001 From: MaziarHeidari Date: Mon, 20 Jun 2016 18:11:52 +0200 Subject: [PATCH 03/15] HADRESS_NEW_REVISION --- examples/{H-AdResS => USER/hadress}/H-AdResS/HADRESS_Water | 0 examples/{H-AdResS => USER/hadress}/Relaxation/LongSetup | 0 examples/{H-AdResS => USER/hadress}/Relaxation/molecule | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename examples/{H-AdResS => USER/hadress}/H-AdResS/HADRESS_Water (100%) rename examples/{H-AdResS => USER/hadress}/Relaxation/LongSetup (100%) rename examples/{H-AdResS => USER/hadress}/Relaxation/molecule (100%) diff --git a/examples/H-AdResS/H-AdResS/HADRESS_Water b/examples/USER/hadress/H-AdResS/HADRESS_Water similarity index 100% rename from examples/H-AdResS/H-AdResS/HADRESS_Water rename to examples/USER/hadress/H-AdResS/HADRESS_Water diff --git a/examples/H-AdResS/Relaxation/LongSetup b/examples/USER/hadress/Relaxation/LongSetup similarity index 100% rename from examples/H-AdResS/Relaxation/LongSetup rename to examples/USER/hadress/Relaxation/LongSetup diff --git a/examples/H-AdResS/Relaxation/molecule b/examples/USER/hadress/Relaxation/molecule similarity index 100% rename from examples/H-AdResS/Relaxation/molecule rename to examples/USER/hadress/Relaxation/molecule From 824c0a359638baaa99a396f211ab41035abb08a8 Mon Sep 17 00:00:00 2001 From: MaziarHeidari Date: Fri, 24 Jun 2016 15:49:52 +0200 Subject: [PATCH 04/15] HADRESS_Version_24_Jun_2016 --- examples/USER/hadress/H-AdResS/HADRESS_Water | 2 +- examples/USER/hadress/Relaxation/LongSetup | 2 +- src/USER-HADRESS/fix_lambdah_calc.cpp | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/USER/hadress/H-AdResS/HADRESS_Water b/examples/USER/hadress/H-AdResS/HADRESS_Water index adbda23f69..d33e5b2dda 100644 --- a/examples/USER/hadress/H-AdResS/HADRESS_Water +++ b/examples/USER/hadress/H-AdResS/HADRESS_Water @@ -6,7 +6,7 @@ # For more information see Documentation and the follwoing paper: # Heidari et al., Eur. Phys. J. Special Topics, 2016. -# You need to have the file "restart.waterT300.100" for running the script. +# You need to have the file "restart.waterT300.50000" for running the script. # Thus you need to run first the equillibration script (LongSetup) for 50000 timestep, # and then set it as the restart file. diff --git a/examples/USER/hadress/Relaxation/LongSetup b/examples/USER/hadress/Relaxation/LongSetup index 45d09808dd..386966536e 100644 --- a/examples/USER/hadress/Relaxation/LongSetup +++ b/examples/USER/hadress/Relaxation/LongSetup @@ -16,7 +16,7 @@ variable Nf equal 100 variable Ne equal 10 variable Nr equal ${Nf}/${Ne} variable Ndump equal 1000 -variable Nrestart equal 100 +variable Nrestart equal 10000 variable Nr_rdf equal 0.5*${Nrun}/${Ne} variable Text equal 300.0 diff --git a/src/USER-HADRESS/fix_lambdah_calc.cpp b/src/USER-HADRESS/fix_lambdah_calc.cpp index 17d84032d5..101f3ff830 100644 --- a/src/USER-HADRESS/fix_lambdah_calc.cpp +++ b/src/USER-HADRESS/fix_lambdah_calc.cpp @@ -81,7 +81,7 @@ FixLambdaHCalc::FixLambdaHCalc(LAMMPS *lmp, int narg, char **arg) : me = comm->me; - if (narg < 8) error->all(FLERR,"Illegal fix LambdaH/Calc command"); + if (narg < 8) error->all(FLERR,"Illegal fix lambdah/calc command"); atom->nmoltypesH = force->numeric(FLERR,arg[3]); Length_Hyb = force->numeric(FLERR,arg[4]); @@ -95,7 +95,7 @@ FixLambdaHCalc::FixLambdaHCalc(LAMMPS *lmp, int narg, char **arg) : if (strcmp(arg[11],"slab") == 0) Hybrid_Style = 0; else if (strcmp(arg[11],"sphere") == 0) Hybrid_Style = 1; else if (strcmp(arg[11],"cylinder") == 0) Hybrid_Style = 2; - else error->all(FLERR,"Illegal fix LambdaH/Calc command"); + else error->all(FLERR,"Illegal fix lambdah/calc command"); Density_Comp_Flag = force->numeric(FLERR,arg[12]); Density_Bin_Size = force->numeric(FLERR,arg[13]); @@ -369,7 +369,7 @@ void FixLambdaHCalc::post_integrate() double **comH = atom->comH; int This_Step = update->ntimestep; - if(This_Step >= Density_Update_Time_Begin && This_Step <= Density_Update_Time_End && Density_Comp_Flag == 1){ + if(This_Step >= Density_Update_Time_Begin && This_Step < Density_Update_Time_End && Density_Comp_Flag == 1){ Density_Compensation_Run = 1; if(me==0 && This_Step == Density_Update_Time_Begin){ if(screen)fprintf(screen,"\nStart of constant-density route\n"); @@ -603,7 +603,7 @@ void FixLambdaHCalc::post_integrate() double Density_Bin_Vol, exponent; double Normalization; int jmin, jmax,jj; - if(This_Step % Density_Update_Frequency == 0 && Density_Comp_Flag != 0 && Density_Compensation_Run != 0){ + if(This_Step % Density_Update_Frequency == 0 && This_Step > Density_Update_Time_Begin && Density_Comp_Flag != 0 && Density_Compensation_Run != 0){ // if(atom->nmoltypesH ==1) MPI_Allreduce(&Comp_Density_Num_H[0][0],&Comp_Density_Num_all_H[0][0],Density_Bin_Num,MPI_INT,MPI_SUM,world); MPI_Allreduce(&Comp_Density_Num_H[0][0],&Comp_Density_Num_all_H[0][0],Density_Bin_Num*(atom->nmoltypesH+1),MPI_INT,MPI_SUM,world); From 2e4fdec2869b63d2623cc59ddd50418dc36f285e Mon Sep 17 00:00:00 2001 From: MaziarHeidari Date: Fri, 24 Jun 2016 15:57:56 +0200 Subject: [PATCH 05/15] HADRESS_Version_24_Jun_2016 --- doc/fix_lambdah_calc.html | 244 -------------------------------------- doc/pair_lj_hars.html | 198 ------------------------------- 2 files changed, 442 deletions(-) delete mode 100644 doc/fix_lambdah_calc.html delete mode 100644 doc/pair_lj_hars.html diff --git a/doc/fix_lambdah_calc.html b/doc/fix_lambdah_calc.html deleted file mode 100644 index 269af18ff0..0000000000 --- a/doc/fix_lambdah_calc.html +++ /dev/null @@ -1,244 +0,0 @@ - -
    LAMMPS WWW Site - LAMMPS Documentation - LAMMPS Commands -
    - - - - - - -
    - -

    fix lambdah command -

    -

    Syntax: -

    -
    fix ID group-ID lambdah/calc NH-mol LHY LAT Pflag δλ dTp TpStart TpEnd HYShape Dflag Δx dTd TdStart TdEnd σ R ρ0 c fileflag 
    -
    -
    • ID is documented in fix command - -
    • group-ID has to be all - -
    • lambdaH/calc = style name of this fix command - -
    • NH-mol = Number of molecular types within the low resolution - -
    • LHY = Length of Hybrid region - -
    • LAT = Length of Atomistic (high resolution) region - -
    • Pflag = 0 or 1 - -
        0 Constant-pressure route is off
      -  1 Constant-pressure route is on 
      -
      -
    • δλ = Bin size in constant-pressure route - -
    • dTp = Time step interval of constant-pressure route - -
    • TpStart = Starting time step of constant-pressure route - -
    • TpEnd = Ending time step of constant-pressure route - -
    • HYShape = Shape of Hybrid region : slab, sphere, cylinder - -
        slab is for rectangular hybrid region
      -  sphere is for spherical hybrid region
      -  cylinder is for cylinderical hybrid region 
      -
      -
    • Dflag = 0 or 1 - -
        0 Constant-density route is off 
      -  1 Constant-density route is on 
      -
      -
    • Δx = Bin size in constant-density route (length unit) - -
    • dTd = Time step interval of constant-density route - -
    • TdStart = Starting time step of constant-density route - -
    • TdEnd = Ending time step of constant-density route - -
    • σ = Width of gaussian function in constant-density route (length unit) - -
    • R = Range of gaussian function in constant-density route (length unit) - -
    • ρ0 = Reference number density in constant-density route - -
    • c = Prefactor in constant-density route (energy unit) - -
    • fileflag = 0 or 1 - -
        0 Do not employ density-balancing file 
      -  1 Employ density-balancing file 
      -
      - -
    -

    Examples: -

    -
    fix 1 all lambdah/calc 1 25 60 1 0.02 1000 150000 300000 slab 1 1.5 500 400000 700000 6 2 0.1 2 0
    -fix 1 all lambdah/calc 1 25 60 1 0.02 1000 100000 200000 sphere 1 1.5 500 300000 700000 6 2 0.1 2 0 
    -
    -

    Description: -

    -

    The Hamiltonian adaptive resolution simulation scheme (H-AdResS) is a dual-resolution simulation method that -joins models with different levels of complexity for the same system within a global Hamiltonian framework (Potestio2013_1), (Potestio2013_2), (Heidari2016). -

    -

    Depending on the shape of the Hybrid region which might be either slab, sphere or cynlinder, this fix calculates -the resolution of every atom based on the center of mass of its molecule. -The following switching function is defined for a simulation box whose atomistic region is limited to [-0.5LAT 0.5LAT]: -

    -
    -
    -

    The following switching function is defined for a spherical/cylinderical atomistic region located at the middle of the simulation box: -

    -
    -
    -

    A setup of a Hamiltonian Adaptive Resolution Simulation is shown below. The box is partitioned into three - different region types, namely: Coarse-grained (CG), Hybrid (HY), and Atomistic (AT). In each region, - the resolution of each molecule (here water) is determined by the instantaneous value of the - smooth function λ represented above the simulation snapshot. -

    -
    -
    -

    NH-mol determines the number of molecular types within the low resolution. For instance, for a system containing -coarse-grained water molecules in the coarse-grained region, this number equals one. However, for a sytem containing -water molecules and ions such as Na and Cl and they interact differently in the coarse-grained region, -this number is 3. -

    -

    The LHY specifies the length of the Hybrid region. For the cases of cylinderical or spherical hybrid regions, this quantity denotes rHY. -

    -

    The LAT determines the length of Atomistic region. For the cases of cylinderical or spherical hybrid regions, this quantity denotes rAT. -

    -

    The Pflag switches off and on the constant-pressure route. -

    -

    The δλ denotes the bin size over the hybrid region. In the on-the-fly method of averaging the drift forces, -particles are sorted into uniformly spaced λ bins of δλ side. -

    -

    The dTp denotes the time intervals in constant-pressure route at which the averaged drift forces are applied on the molecules of the hybrid region. -

    -

    The TpStart denotes the time step at which the simulation of the constant-pressure route is started. -

    -

    The TpEnd specifies the ending time step of the constant-pressure route. -

    -

    The HYShape specifies the geometry of the Hybrid region. This could be slab, sphere, cylinder. -

    -

    Dflag switches off and on the constant-pressure route. -

    -

    Δx is the bin size by which the simulation box is descritized in the constant-density route. -

    -

    dTd is the time interval in constant-density route at which the averaged thermodynamic forces are applied. -

    -

    TdStart is the starting time step of constant-density route. -

    -

    TdEnd is the ending time step of constant-density route. -

    -

    σ is the width of Gaussian function in the constant-density route. -

    -

    R is the range of Gaussian function in the constant-density route. -

    -

    ρ0 is the reference density in the constant-density route. -

    -

    c is the prefactor in the constant-density route. -

    -

    fileflag denotes a flag whether the file containing the density-balancing force is employed or not. -

    -
    - -

    Restart, fix_modify, output, run start/stop, minimize info: -

    -

    No information about this fix is written to binary restart -files. -

    -

    This fix creates a file named "Mean_Comp_Density.txt" in which the compensation forces are printed. -This file is created at TdStart and is updated every dTd. -The updating process of the file is finished at time step TdEnd. -For those equillibrated simulations starting at time step larger than TdEnd, -the file "Mean_Comp_Density.txt" is loaded in this fix. -

    -
    - -

    Restrictions: -

    -

    This fix calculates the center of mass of the particles. Thus at the beginning of the calculation, -it is required that all atoms belonging to a molecule are on the same side of the box. -

    -

    To employ the H-AdResS scheme, the full/hars atom style has to be used: -

    -
      atom_style      full/hars 
    -
    -

    To perform HAdResS, Data File should contain the following extra information with respect to the Data File defined in full atom style: -

    -

    [1] mol_H determines the number of molecular types in the low resolution (coarse-grained) region. -

    -

    [2] representative_flag determines which atom carries the molecule's information -(center of mass, molecule's resolution, ...) in the low resolution (coarse-grained) region. -

    -

    [3] mol_type denotes the type of the molecule in the low resolution (coarse-grained) region. -

    -

    The following example is extracted from a Data File in which the simulation box contains water molecules and the ions of sodium and cholorine: -

    -
    30720 atoms
    -20480 bonds
    -10240 angles 
    -
    -
    4 atom types
    -1 mol_H types
    -1 bond types
    -1 angle types 
    -
    -
    -99.968000 99.968000 xlo xhi
    --20.793600 20.793600 ylo yhi
    --20.793600 20.793600 zlo zhi 
    -
    -
    Masses 
    -
    -
    1 15.999400
    -2 1.007940
    -3 22.9898 
    -4 35.453 
    -
    -
    Atoms
    -#atomID molecule-tag atom-type q representative_flag mol_type x y z
    -1 1 1 -0.847200 1 1 -99.654503 -19.897600 -20.192101
    -2 1 2 0.423600 0 1 -100.568001 -19.999300 -20.586599
    -3 1 2 0.423600 0 1 -99.777702 -20.103100 -19.221300
    -4 2 1 -0.847200 1 1 -97.826401 -17.709900 -20.127100
    -5 2 2 0.423600 0 1 -96.938400 -18.071301 -19.842800
    -6 2 2 0.423600 0 1 -97.735100 -16.718800 -20.030100
    -7 3 3 1.0 1 1 -97.429398 -20.402201 -17.494900
    -8 3 4 -1.0 1 1 -96.834000 -19.671400 -17.160999
    -.
    -.
    -. 
    -
    -

    As it is shown, the representative_flag of the oxygen atoms is equal 1, and -since the soldium and cholorine are single atom ions, their representative_flags are also equals 1. -The interactions of water molecules and ions are the same in the coarse-grained region, -thus they all carry the same molecular type (mol_type). -

    -
    - -

    Related commands: -

    -

    pair_lj_hars.html -

    -

    Default: none -

    -
    - - - -

    (Potestio2013_1) R. Potestio, S. Fritsch, P. Espanol, R. Delgado-Buscalioni, K. Kremer, R. Everaers, and D. Donadio, Hamiltonian Adaptive Resolution Simulation for Molecular Liquids, Phys. Rev. Lett. [110], -108301 (2013) -

    - - -

    (Potestio2013_2) R. Potestio, S. Fritsch, P. Espanol, R. Delgado-Buscalioni, K. Kremer, R. Everaers, and D. Donadio, Monte Carlo Adaptive Resolution Simulation of Multicomponent Molecular Liquids, Phys. Rev. Lett. [111], -060601 (2013) -

    - - -

    (Heidari2016) M. Heidari, R. Cortes-Huerto, D. Donadio and R. Potestio, Accurate and general treatment of electrostatic interaction in Hamiltonian adaptive resolution simulations, "EPJST (2016)" -

    - diff --git a/doc/pair_lj_hars.html b/doc/pair_lj_hars.html deleted file mode 100644 index 50596c9d30..0000000000 --- a/doc/pair_lj_hars.html +++ /dev/null @@ -1,198 +0,0 @@ - -
    LAMMPS WWW Site - LAMMPS Documentation - LAMMPS Commands -
    - - - - - - -
    - -

    pair_style lj/cut/hars/at command -

    -

    pair_style lj/cut/coul/dsf/hars/at command -

    -

    pair_style lj/cut/hars/cg command -

    -

    Syntax: -

    -
    pair_style style args 
    -
    -
  • style = - -
    	lj/cut/hars/at or
    -	lj/cut/coul/dsf/hars/at or
    -	lj/cut/hars/cg 
    -
    -
  • args = list of arguments for a particular style - -
      lj/cut/hars/at args = cutoff All_AT Flag_Load_File
    -    cutoff = global cutoff for Lennard Jones interactions (distance units)
    -    All_AT = Fully atomic simulation flag, = 0 or 1
    -      0 Fully atomic simulation is off and HAdResS is on
    -      1 Fully atomic simulation is on and HAdResS is off 
    -    Flag_Load_File = Flag of employing compensation energy file, = 0 or 1
    -      0 Do not employ compensation energy until TpStart
    -      1 Employ compensation energy file immediately 
    -
    -
      lj/cut/coul/dsf/hars/at args = Alpha LJcutoff Coulcutoff All_AT Flag_Load_File
    -    Alpha = Damping coefficient in DSF potential (1.0/distance units)
    -    LJcutoff = global cutoff for Lennard Jones interactions (distance units)
    -    Coulcutoff = global cutoff for DSF coulombic interactions (distance units)
    -    All_AT = Fully atomic simulation flag, = 0 or 1
    -      0 Fully atomic simulation is off and HAdResS is on
    -      1 Fully atomic simulation is on and HAdResS is off 
    -    Flag_Load_File = Flag of employing compensation energy file, = 0 or 1
    -      0 Do not employ compensation energy until TpStart
    -      1 Employ compensation energy file immediately 
    -
    -
      lj/cut/hars/cg args = cutoff All_CG Flag_Load_File
    -    cutoff = global cutoff for Lennard Jones interactions (distance units)
    -    All_CG = Fully coarse-grained simulation flag, = 0 or 1
    -      0 Fully coarse-grained simulation is off and HAdResS is on
    -      1 Fully coarse-grained simulation is on and HAdResS is off
    -    Flag_Load_File = Flag of employing compensation energy file, = 0 or 1
    -      0 Do not employ compensation energy until TpStart
    -      1 Employ compensation energy file immediately 
    -
    -

    Examples: -

    -
    pair_style      hybrid/overlay lj/cut/hars/cg 2.469416506 0 0 lj/cut/hars/at 0.2 10.0 12.0 0 0
    -pair_style      hybrid/overlay lj/cut/hars/cg 1.1224 1 0 lj/cut/hars/at 1.5 1 0 
    -
    -

    Description: -

    -

    In the H-AdResS scheme, the description of the interactions within a system of particles is given in terms -of a global Hamiltonian function H, which has the following form (Potestio2013_1), (Potestio2013_2), (Heidari2016): -

    -
    -
    -

    The term K is the atomistic kinetic energy, and Vint consists of all the intramolecular bonded interactions (e.g. bond stretching). -The value of the switching function is determined by the sizes LAT -LHY of the atomistic and hybrid regions, respectively, and of the specific geometry of the atomistic region. -

    -

    In the Hamiltonian, the non-bonded potential energy contribution of each molecule is given by a weighted sum of two terms -VαCG and VαAT, defined as: -

    -
    -
    -

    The lj/cut/hars/at styles compute the standard 12/6 Lennard-Jones potential for the atoms located in atomistic (high resolution) and hybrid region. -The general formula is given by -

    -
    -
    -

    rc is the cutoff. -

    -

    Style lj/cut/coul/dsf/hars/at computes the standard 12/6 Lennard-Jones and Coulomb interactions for atoms of atomistic (high resolution) and hybrid region. -The Coulombic term is computed via the damped shifted force model introduced by Fennell et al., given by: -

    -
    -
    -

    where alpha is the damping parameter and erfc() is the complementary -error-function. This potential is essentially a short-range, -spherically-truncated, charge-neutralized, shifted, pairwise 1/r -summation. -

    -

    The lj/cut/hars/cg styles compute the standard 12/6 Lennard-Jones potential for the atoms located in the low resolution (coarse-grained) and hybrid region. -The general formula is given by -

    -
    -
    -

    rc is the cutoff. -As mentioned above, the interactions in the coarse-grained region are computed based on the center of mass of the particles. -

    -

    Important Note: For dual resolution simulations, it is required to use hybrid/overlay to include -both resolution pair-styles. -

    -

    For all of dual resolution pair styles, the following coefficients must -be defined for each pair of atoms types via the -pair_coeff command as in the examples below -

    -
  • epsilon (energy units) - -
  • sigma (distance units) - -
  • cutoff (distance units) - -

    For examples: -

    -
      pair_coeff      * * lj/cut/hars/cg 1.0 2.2
    -  pair_coeff      1 1 lj/cut/coul/dsf/hars/at 0.15535 3.166
    -  pair_coeff      * 2 lj/cut/coul/dsf/hars/at 0.0000 0.0000 
    -
    -

    Note that sigma is defined in the LJ formula as the zero-crossing -distance for the potential, not as the energy minimum at 2^(1/6) -sigma. -

    -

    All potentials have to be shifted at the cutoff through the command -

    -
      pair_modify     shift yes 
    -
    -
    - -

    Mixing, shift, table, tail correction, restart, rRESPA info: -

    -

    All of the lj/cut pair styles support the -pair_modify shift option for the energy of the -Lennard-Jones portion of the pair interaction. -

    -

    All of the lj/cut pair styles write their information to binary -restart files, so pair_style and pair_coeff commands do -not need to be specified in an input script that reads a restart file. -

    -

    The pair styles do not support the use of the rRESPA hierarchy. -

    -

    Each pair styles creates a file named as "Mean_Comp_Energy_XX.txt", where the file name's suffix "XX", is replaced by "AT" and "CG" for atomistic and coarse-grained pairwise interactions respectively. -In these files the averaged compensation energy as function of the resolution (λ) is printed. Each file is created at TpStart and is updated every dTp. -The updating process of the files is finished at time step TpEnd. -For those equilibrated simulations starting at time step larger than TpEnd, the file "Mean_Comp_Energy_XX.txt" is loaded in each pair styles. For more information, -see fix_lambdah_calc. -

    -
    - -

    Restrictions: -

    -

    In HAdResS, it is required to include both high resolution (atomistic) -and low resolution (coarse-grained) force fields together through -

    -
      pair_style      hybrid/overlay 
    -
    -

    An example of such setup is given above. -

    -

    To employ the H-AdResS scheme, the full/hars atom style as well as (fix_lambdah_calc) have to be used: -

    -
      atom_style      full/hars 
    -
    -
      fix             ID group-ID lambdah/calc ... 
    -
    -
    - -

    Related commands: -

    -

    fix_lambdah_calc, pair_coeff -

    -

    Default: none -

    -
    - - - -

    (Potestio2013_1) R. Potestio, S. Fritsch, P. Espanol, R. Delgado-Buscalioni, K. Kremer, R. Everaers, and D. Donadio, Hamiltonian Adaptive Resolution Simulation for Molecular Liquids, Phys. Rev. Lett. [110], -108301 (2013) -

    - - -

    (Potestio2013_2) R. Potestio, S. Fritsch, P. Espanol, R. Delgado-Buscalioni, K. Kremer, R. Everaers, and D. Donadio, Monte Carlo Adaptive Resolution Simulation of Multicomponent Molecular Liquids, Phys. Rev. Lett. [111], -060601 (2013) -

    - - -

    (Heidari2016) M. Heidari, R. Cortes-Huerto, D. Donadio and R. Potestio, Accurate and general treatment of electrostatic interaction in Hamiltonian adaptive resolution simulations, "EPJST (2016)" -

    - - -

    (Fennell) C. J. Fennell, J. D. Gezelter, J Chem Phys, 124, -234104 (2006). -

    - From 1f7f7bf12b459a29a5dde6053ddfef032c183be2 Mon Sep 17 00:00:00 2001 From: MaziarHeidari Date: Fri, 24 Jun 2016 16:01:59 +0200 Subject: [PATCH 06/15] HADRESS_Version_24_Jun_2016 --- src/USER-HADRESS/Install.sh | 60 - src/USER-HADRESS/README | 18 - src/USER-HADRESS/atom.cpp | 2206 ----------------- src/USER-HADRESS/atom.h | 519 ---- src/USER-HADRESS/atom_vec_full_hars.cpp | 1352 ---------- src/USER-HADRESS/atom_vec_full_hars.h | 104 - src/USER-HADRESS/fix_lambdah_calc.cpp | 958 ------- src/USER-HADRESS/fix_lambdah_calc.h | 102 - src/USER-HADRESS/molecule.cpp | 1829 -------------- src/USER-HADRESS/molecule.h | 432 ---- .../pair_lj_cut_coul_dsf_hars_at.cpp | 971 -------- .../pair_lj_cut_coul_dsf_hars_at.h | 115 - src/USER-HADRESS/pair_lj_cut_hars_at.cpp | 1039 -------- src/USER-HADRESS/pair_lj_cut_hars_at.h | 119 - src/USER-HADRESS/pair_lj_cut_hars_cg.cpp | 1120 --------- src/USER-HADRESS/pair_lj_cut_hars_cg.h | 123 - src/USER-HADRESS/read_data.cpp | 2023 --------------- src/USER-HADRESS/read_data.h | 560 ----- 18 files changed, 13650 deletions(-) delete mode 100644 src/USER-HADRESS/Install.sh delete mode 100644 src/USER-HADRESS/README delete mode 100644 src/USER-HADRESS/atom.cpp delete mode 100644 src/USER-HADRESS/atom.h delete mode 100644 src/USER-HADRESS/atom_vec_full_hars.cpp delete mode 100644 src/USER-HADRESS/atom_vec_full_hars.h delete mode 100644 src/USER-HADRESS/fix_lambdah_calc.cpp delete mode 100644 src/USER-HADRESS/fix_lambdah_calc.h delete mode 100644 src/USER-HADRESS/molecule.cpp delete mode 100644 src/USER-HADRESS/molecule.h delete mode 100644 src/USER-HADRESS/pair_lj_cut_coul_dsf_hars_at.cpp delete mode 100644 src/USER-HADRESS/pair_lj_cut_coul_dsf_hars_at.h delete mode 100644 src/USER-HADRESS/pair_lj_cut_hars_at.cpp delete mode 100644 src/USER-HADRESS/pair_lj_cut_hars_at.h delete mode 100644 src/USER-HADRESS/pair_lj_cut_hars_cg.cpp delete mode 100644 src/USER-HADRESS/pair_lj_cut_hars_cg.h delete mode 100644 src/USER-HADRESS/read_data.cpp delete mode 100644 src/USER-HADRESS/read_data.h diff --git a/src/USER-HADRESS/Install.sh b/src/USER-HADRESS/Install.sh deleted file mode 100644 index 1b919c4c58..0000000000 --- a/src/USER-HADRESS/Install.sh +++ /dev/null @@ -1,60 +0,0 @@ -# Install/unInstall package files in LAMMPS -# mode = 0/1/2 for uninstall/install/update - -mode=$1 - -# arg1 = file, arg2 = file it depends on - -action () { - if (test $mode = 0) then - rm -f ../$1 - elif (! cmp -s $1 ../$1) then - if (test -z "$2" || test -e ../$2) then - cp $1 .. - if (test $mode = 2) then - echo " updating src/$1" - fi - fi - elif (test -n "$2") then - if (test ! -e ../$2) then - rm -f ../$1 - fi - fi -} - -# all package files with no dependencies - -for file in *.cpp *.h; do - action $file -done - -# edit 2 Makefile.package files to include/exclude package info - -if (test $1 = 1) then - - if (test -e ../Makefile.package) then - sed -i -e 's/[^ \t]*user-hadress[^ \t]* //' ../Makefile.package - sed -i -e 's|^PKG_SYSINC =[ \t]*|&$(user-hadress_SYSINC) |' ../Makefile.package - sed -i -e 's|^PKG_SYSLIB =[ \t]*|&$(user-hadress_SYSLIB) |' ../Makefile.package - sed -i -e 's|^PKG_SYSPATH =[ \t]*|&$(user-hadress_SYSPATH) |' ../Makefile.package - fi - - if (test -e ../Makefile.package.settings) then - sed -i -e '/^include.*user-hadress.*$/d' ../Makefile.package.settings - # multiline form needed for BSD sed on Macs - sed -i -e '4 i \ -include ..\/..\/lib\/user-hadress\/Makefile.lammps -' ../Makefile.package.settings - fi - -elif (test $1 = 0) then - - if (test -e ../Makefile.package) then - sed -i -e 's/[^ \t]*user-hadress[^ \t]* //' ../Makefile.package - fi - - if (test -e ../Makefile.package.settings) then - sed -i -e '/^include.*user-hadress.*$/d' ../Makefile.package.settings - fi - -fi diff --git a/src/USER-HADRESS/README b/src/USER-HADRESS/README deleted file mode 100644 index d4c860100b..0000000000 --- a/src/USER-HADRESS/README +++ /dev/null @@ -1,18 +0,0 @@ -This package contains files that brings the utility of -Hamiltonian Adaptive Resolution Simulations (H-AdResS) to the Lammps package. - - -See the doc page for for detailed usage instructions. - -There is example script for using this package in the folder -"example" - - -The persons who created this package are - -Maziar Heidari (Max Planck Institute for Polymer Research) -Robinson Cortes-Huerto (Max Planck Institute for Polymer Research) -Raffaello Potestio (Max Planck Institute for Polymer Research) -and Davide Donadio ( Department of Chemistry, University of California, Davis) - -Here is a contact information if you have questions. (heidari@mpip-mainz.mpg.de) diff --git a/src/USER-HADRESS/atom.cpp b/src/USER-HADRESS/atom.cpp deleted file mode 100644 index 6ef632683b..0000000000 --- a/src/USER-HADRESS/atom.cpp +++ /dev/null @@ -1,2206 +0,0 @@ -/* ---------------------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - http://lammps.sandia.gov, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - Copyright (2003) Sandia Corporation. Under the terms of Contract - DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains - certain rights in this software. This software is distributed under - the GNU General Public License. - - See the README file in the top-level LAMMPS directory. -------------------------------------------------------------------------- */ - -#include -#include -#include -#include -#include -#include -#include "atom.h" -#include "style_atom.h" -#include "atom_vec.h" -#include "atom_vec_ellipsoid.h" -#include "comm.h" -#include "neighbor.h" -#include "force.h" -#include "modify.h" -#include "fix.h" -#include "output.h" -#include "thermo.h" -#include "update.h" -#include "domain.h" -#include "group.h" -#include "molecule.h" -#include "accelerator_cuda.h" -#include "atom_masks.h" -#include "math_const.h" -#include "memory.h" -#include "error.h" - -using namespace LAMMPS_NS; -using namespace MathConst; - -#define DELTA 1 -#define DELTA_MEMSTR 1024 -#define EPSILON 1.0e-6 -#define CUDA_CHUNK 3000 - -enum{LAYOUT_UNIFORM,LAYOUT_NONUNIFORM,LAYOUT_TILED}; // several files - -/* ---------------------------------------------------------------------- */ - -Atom::Atom(LAMMPS *lmp) : Pointers(lmp) -{ - natoms = 0; - nlocal = nghost = nmax = 0; - ntypes = 0; - nbondtypes = nangletypes = ndihedraltypes = nimpropertypes = 0; - nbonds = nangles = ndihedrals = nimpropers = 0; - - firstgroupname = NULL; - sortfreq = 1000; - nextsort = 0; - userbinsize = 0.0; - maxbin = maxnext = 0; - binhead = NULL; - next = permute = NULL; - - // initialize atom arrays - // customize by adding new array - - tag = NULL; - type = mask = NULL; - image = NULL; - x = v = f = NULL; - - molecule = NULL; - molindex = molatom = NULL; - q = NULL; - mu = NULL; - omega = angmom = torque = NULL; - radius = rmass = NULL; - ellipsoid = line = tri = body = NULL; - - lambdaH = NULL; - gradlambdaH = NULL; - replambdaH = NULL; - moltypeH = NULL; - comH = NULL; - nmoltypesH = 0; - - vfrac = s0 = NULL; - x0 = NULL; - - spin = NULL; - eradius = ervel = erforce = NULL; - cs = csforce = vforce = ervelforce = NULL; - etag = NULL; - - rho = drho = e = de = cv = NULL; - vest = NULL; - - // USER-DPD - - uCond = uMech = uChem = uCG = uCGnew = NULL; - duCond = duMech = duChem = NULL; - dpdTheta = NULL; - - // USER-SMD - - contact_radius = NULL; - smd_data_9 = NULL; - smd_stress = NULL; - eff_plastic_strain = NULL; - eff_plastic_strain_rate = NULL; - damage = NULL; - - // molecular info - - bond_per_atom = extra_bond_per_atom = 0; - num_bond = NULL; - bond_type = NULL; - bond_atom = NULL; - - angle_per_atom = extra_angle_per_atom = 0; - num_angle = NULL; - angle_type = NULL; - angle_atom1 = angle_atom2 = angle_atom3 = NULL; - - dihedral_per_atom = extra_dihedral_per_atom = 0; - num_dihedral = NULL; - dihedral_type = NULL; - dihedral_atom1 = dihedral_atom2 = dihedral_atom3 = dihedral_atom4 = NULL; - - improper_per_atom = extra_improper_per_atom = 0; - num_improper = NULL; - improper_type = NULL; - improper_atom1 = improper_atom2 = improper_atom3 = improper_atom4 = NULL; - - maxspecial = 1; - nspecial = NULL; - special = NULL; - - // user-defined molecules - - nmolecule = 0; - molecules = NULL; - - // custom atom arrays - - nivector = ndvector = 0; - ivector = NULL; - dvector = NULL; - iname = dname = NULL; - - // initialize atom style and array existence flags - // customize by adding new flag - - sphere_flag = peri_flag = electron_flag = 0; - wavepacket_flag = sph_flag = 0; - - molecule_flag = 0; - q_flag = mu_flag = 0; - omega_flag = torque_flag = angmom_flag = 0; - radius_flag = rmass_flag = 0; - ellipsoid_flag = line_flag = tri_flag = body_flag = 0; - - vfrac_flag = 0; - spin_flag = eradius_flag = ervel_flag = erforce_flag = ervelforce_flag = 0; - cs_flag = csforce_flag = vforce_flag = etag_flag = 0; - - rho_flag = e_flag = cv_flag = vest_flag = 0; - dpd_flag = 0; - - // USER-SMD - - smd_flag = 0; - contact_radius_flag = 0; - smd_data_9_flag = 0; - smd_stress_flag = 0; - x0_flag = 0; - eff_plastic_strain_flag = 0; - eff_plastic_strain_rate_flag = 0; - damage_flag = 0; - - // Peridynamic scale factor - - pdscale = 1.0; - - // ntype-length arrays - - mass = NULL; - mass_setflag = NULL; - - // callback lists & extra restart info - - nextra_grow = nextra_restart = nextra_border = 0; - extra_grow = extra_restart = extra_border = NULL; - nextra_grow_max = nextra_restart_max = nextra_border_max = 0; - nextra_store = 0; - extra = NULL; - - // default atom ID and mapping values - - tag_enable = 1; - map_style = map_user = 0; - map_tag_max = -1; - map_maxarray = map_nhash = -1; - - max_same = 0; - sametag = NULL; - map_array = NULL; - map_bucket = NULL; - map_hash = NULL; - - atom_style = NULL; - avec = NULL; - - datamask = ALL_MASK; - datamask_ext = ALL_MASK; -} - -/* ---------------------------------------------------------------------- */ - -Atom::~Atom() -{ - delete [] atom_style; - delete avec; - - delete [] firstgroupname; - memory->destroy(binhead); - memory->destroy(next); - memory->destroy(permute); - - // delete atom arrays - // customize by adding new array - - memory->destroy(tag); - memory->destroy(type); - memory->destroy(mask); - memory->destroy(image); - memory->destroy(x); - memory->destroy(v); - memory->destroy(f); - - memory->destroy(molecule); - memory->destroy(molindex); - memory->destroy(molatom); - - memory->destroy(lambdaH); - memory->destroy(replambdaH); - memory->destroy(moltypeH); - memory->destroy(gradlambdaH); - memory->destroy(comH); - - memory->destroy(q); - memory->destroy(mu); - memory->destroy(omega); - memory->destroy(angmom); - memory->destroy(torque); - memory->destroy(radius); - memory->destroy(rmass); - memory->destroy(ellipsoid); - memory->destroy(line); - memory->destroy(tri); - memory->destroy(body); - - memory->destroy(vfrac); - memory->destroy(s0); - memory->destroy(x0); - - memory->destroy(spin); - memory->destroy(eradius); - memory->destroy(ervel); - memory->destroy(erforce); - memory->destroy(ervelforce); - memory->destroy(cs); - memory->destroy(csforce); - memory->destroy(vforce); - memory->destroy(etag); - - memory->destroy(rho); - memory->destroy(drho); - memory->destroy(e); - memory->destroy(de); - memory->destroy(cv); - memory->destroy(vest); - - memory->destroy(contact_radius); - memory->destroy(smd_data_9); - memory->destroy(smd_stress); - memory->destroy(eff_plastic_strain); - memory->destroy(eff_plastic_strain_rate); - memory->destroy(damage); - - memory->destroy(dpdTheta); - memory->destroy(uCond); - memory->destroy(uMech); - memory->destroy(uChem); - memory->destroy(uCG); - memory->destroy(uCGnew); - memory->destroy(duCond); - memory->destroy(duMech); - memory->destroy(duChem); - - memory->destroy(nspecial); - memory->destroy(special); - - memory->destroy(num_bond); - memory->destroy(bond_type); - memory->destroy(bond_atom); - - memory->destroy(num_angle); - memory->destroy(angle_type); - memory->destroy(angle_atom1); - memory->destroy(angle_atom2); - memory->destroy(angle_atom3); - - memory->destroy(num_dihedral); - memory->destroy(dihedral_type); - memory->destroy(dihedral_atom1); - memory->destroy(dihedral_atom2); - memory->destroy(dihedral_atom3); - memory->destroy(dihedral_atom4); - - memory->destroy(num_improper); - memory->destroy(improper_type); - memory->destroy(improper_atom1); - memory->destroy(improper_atom2); - memory->destroy(improper_atom3); - memory->destroy(improper_atom4); - - // delete custom atom arrays - - for (int i = 0; i < nivector; i++) { - delete [] iname[i]; - memory->destroy(ivector[i]); - } - for (int i = 0; i < ndvector; i++) { - delete [] dname[i]; - memory->destroy(dvector[i]); - } - - memory->sfree(iname); - memory->sfree(dname); - memory->sfree(ivector); - memory->sfree(dvector); - - // delete user-defined molecules - - for (int i = 0; i < nmolecule; i++) delete molecules[i]; - memory->sfree(molecules); - - // delete per-type arrays - - delete [] mass; - delete [] mass_setflag; - - // delete extra arrays - - memory->destroy(extra_grow); - memory->destroy(extra_restart); - memory->destroy(extra_border); - memory->destroy(extra); - - // delete mapping data structures - - map_delete(); -} - -/* ---------------------------------------------------------------------- - copy modify settings from old Atom class to current Atom class -------------------------------------------------------------------------- */ - -void Atom::settings(Atom *old) -{ - tag_enable = old->tag_enable; - map_user = old->map_user; - map_style = old->map_style; - sortfreq = old->sortfreq; - userbinsize = old->userbinsize; - if (old->firstgroupname) { - int n = strlen(old->firstgroupname) + 1; - firstgroupname = new char[n]; - strcpy(firstgroupname,old->firstgroupname); - } -} - -/* ---------------------------------------------------------------------- - create an AtomVec style - called from lammps.cpp, input script, restart file, replicate -------------------------------------------------------------------------- */ - -void Atom::create_avec(const char *style, int narg, char **arg, int trysuffix) -{ - delete [] atom_style; - if (avec) delete avec; - - // unset atom style and array existence flags - // may have been set by old avec - // customize by adding new flag - - sphere_flag = peri_flag = electron_flag = 0; - wavepacket_flag = sph_flag = 0; - - molecule_flag = 0; - q_flag = mu_flag = 0; - replambdaH_flag = 0; - moltypeH_flag = 0; - - omega_flag = torque_flag = angmom_flag = 0; - radius_flag = rmass_flag = 0; - ellipsoid_flag = line_flag = tri_flag = body_flag = 0; - - vfrac_flag = 0; - spin_flag = eradius_flag = ervel_flag = erforce_flag = ervelforce_flag = 0; - cs_flag = csforce_flag = vforce_flag = etag_flag = 0; - - rho_flag = e_flag = cv_flag = vest_flag = 0; - - // create instance of AtomVec - // use grow() to initialize atom-based arrays to length 1 - // so that x[0][0] can always be referenced even if proc has no atoms - - int sflag; - avec = new_avec(style,trysuffix,sflag); - avec->store_args(narg,arg); - avec->process_args(narg,arg); - avec->grow(1); - - if (sflag) { - char estyle[256]; - if (sflag == 1) sprintf(estyle,"%s/%s",style,lmp->suffix); - else sprintf(estyle,"%s/%s",style,lmp->suffix2); - int n = strlen(estyle) + 1; - atom_style = new char[n]; - strcpy(atom_style,estyle); - } else { - int n = strlen(style) + 1; - atom_style = new char[n]; - strcpy(atom_style,style); - } - - // if molecular system: - // atom IDs must be defined - // force atom map to be created - // map style may be reset by map_init() and its call to map_style_set() - - molecular = avec->molecular; - if (molecular && tag_enable == 0) - error->all(FLERR,"Atom IDs must be used for molecular systems"); - if (molecular) map_style = 1; -} - -/* ---------------------------------------------------------------------- - generate an AtomVec class, first with suffix appended -------------------------------------------------------------------------- */ - -AtomVec *Atom::new_avec(const char *style, int trysuffix, int &sflag) -{ - if (trysuffix && lmp->suffix_enable) { - if (lmp->suffix) { - sflag = 1; - char estyle[256]; - sprintf(estyle,"%s/%s",style,lmp->suffix); - - if (0) return NULL; - -#define ATOM_CLASS -#define AtomStyle(key,Class) \ - else if (strcmp(estyle,#key) == 0) return new Class(lmp); -#include "style_atom.h" -#undef AtomStyle -#undef ATOM_CLASS - } - - if (lmp->suffix2) { - sflag = 2; - char estyle[256]; - sprintf(estyle,"%s/%s",style,lmp->suffix2); - - if (0) return NULL; - -#define ATOM_CLASS -#define AtomStyle(key,Class) \ - else if (strcmp(estyle,#key) == 0) return new Class(lmp); -#include "style_atom.h" -#undef AtomStyle -#undef ATOM_CLASS - } - } - - sflag = 0; - if (0) return NULL; - -#define ATOM_CLASS -#define AtomStyle(key,Class) \ - else if (strcmp(style,#key) == 0) return new Class(lmp); -#include "style_atom.h" -#undef ATOM_CLASS - - else error->all(FLERR,"Unknown atom style"); - return NULL; -} - -/* ---------------------------------------------------------------------- */ - -void Atom::init() -{ - // delete extra array since it doesn't persist past first run - - if (nextra_store) { - memory->destroy(extra); - extra = NULL; - nextra_store = 0; - } - - // check arrays that are atom type in length - - check_mass(); - - // setup of firstgroup - - if (firstgroupname) { - firstgroup = group->find(firstgroupname); - if (firstgroup < 0) - error->all(FLERR,"Could not find atom_modify first group ID"); - } else firstgroup = -1; - - // init AtomVec - - avec->init(); -} - -/* ---------------------------------------------------------------------- */ - -void Atom::setup() -{ - // setup bins for sorting - // cannot do this in init() because uses neighbor cutoff - - if (sortfreq > 0) setup_sort_bins(); -} - -/* ---------------------------------------------------------------------- - return ptr to AtomVec class if matches style or to matching hybrid sub-class - return NULL if no match -------------------------------------------------------------------------- */ - -AtomVec *Atom::style_match(const char *style) -{ - if (strcmp(atom_style,style) == 0) return avec; - else if (strcmp(atom_style,"hybrid") == 0) { - AtomVecHybrid *avec_hybrid = (AtomVecHybrid *) avec; - for (int i = 0; i < avec_hybrid->nstyles; i++) - if (strcmp(avec_hybrid->keywords[i],style) == 0) - return avec_hybrid->styles[i]; - } - return NULL; -} - -/* ---------------------------------------------------------------------- - modify parameters of the atom style - some options can only be invoked before simulation box is defined - first and sort options cannot be used together -------------------------------------------------------------------------- */ - -void Atom::modify_params(int narg, char **arg) -{ - if (narg == 0) error->all(FLERR,"Illegal atom_modify command"); - - int iarg = 0; - while (iarg < narg) { - if (strcmp(arg[iarg],"id") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal atom_modify command"); - if (domain->box_exist) - error->all(FLERR, - "Atom_modify id command after simulation box is defined"); - if (strcmp(arg[iarg+1],"yes") == 0) tag_enable = 1; - else if (strcmp(arg[iarg+1],"no") == 0) tag_enable = 0; - else error->all(FLERR,"Illegal atom_modify command"); - iarg += 2; - } else if (strcmp(arg[iarg],"map") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal atom_modify command"); - if (domain->box_exist) - error->all(FLERR, - "Atom_modify map command after simulation box is defined"); - if (strcmp(arg[iarg+1],"array") == 0) map_user = 1; - else if (strcmp(arg[iarg+1],"hash") == 0) map_user = 2; - else error->all(FLERR,"Illegal atom_modify command"); - map_style = map_user; - iarg += 2; - } else if (strcmp(arg[iarg],"first") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal atom_modify command"); - if (strcmp(arg[iarg+1],"all") == 0) { - delete [] firstgroupname; - firstgroupname = NULL; - } else { - int n = strlen(arg[iarg+1]) + 1; - firstgroupname = new char[n]; - strcpy(firstgroupname,arg[iarg+1]); - sortfreq = 0; - } - iarg += 2; - } else if (strcmp(arg[iarg],"sort") == 0) { - if (iarg+3 > narg) error->all(FLERR,"Illegal atom_modify command"); - sortfreq = force->inumeric(FLERR,arg[iarg+1]); - userbinsize = force->numeric(FLERR,arg[iarg+2]); - if (sortfreq < 0 || userbinsize < 0.0) - error->all(FLERR,"Illegal atom_modify command"); - if (sortfreq >= 0 && firstgroupname) - error->all(FLERR,"Atom_modify sort and first options " - "cannot be used together"); - iarg += 3; - } else error->all(FLERR,"Illegal atom_modify command"); - } -} - -/* ---------------------------------------------------------------------- - check that atom IDs are valid - error if any atom ID < 0 or atom ID = MAXTAGINT - if any atom ID > 0, error if any atom ID == 0 - if any atom ID > 0, error if tag_enable = 0 - if all atom IDs = 0, tag_enable must be 0 - if max atom IDs < natoms, must be duplicates - OK if max atom IDs > natoms - NOTE: not fully checking that atom IDs are unique -------------------------------------------------------------------------- */ - -void Atom::tag_check() -{ - tagint min = MAXTAGINT; - tagint max = 0; - - for (int i = 0; i < nlocal; i++) { - min = MIN(min,tag[i]); - max = MAX(max,tag[i]); - } - - tagint minall,maxall; - MPI_Allreduce(&min,&minall,1,MPI_LMP_TAGINT,MPI_MIN,world); - MPI_Allreduce(&max,&maxall,1,MPI_LMP_TAGINT,MPI_MAX,world); - - if (minall < 0) error->all(FLERR,"One or more Atom IDs is negative"); - if (maxall >= MAXTAGINT) error->all(FLERR,"One or more atom IDs is too big"); - if (maxall > 0 && minall == 0) - error->all(FLERR,"One or more atom IDs is zero"); - if (maxall > 0 && tag_enable == 0) - error->all(FLERR,"Non-zero atom IDs with atom_modify id = no"); - if (maxall == 0 && natoms && tag_enable) - error->all(FLERR,"All atom IDs = 0 but atom_modify id = yes"); - if (tag_enable && maxall < natoms) - error->all(FLERR,"Duplicate atom IDs exist"); -} - -/* ---------------------------------------------------------------------- - add unique tags to any atoms with tag = 0 - new tags are grouped by proc and start after max current tag - called after creating new atoms - error if new tags will exceed MAXTAGINT -------------------------------------------------------------------------- */ - -void Atom::tag_extend() -{ - // maxtag_all = max tag for all atoms - - tagint maxtag = 0; - for (int i = 0; i < nlocal; i++) maxtag = MAX(maxtag,tag[i]); - tagint maxtag_all; - MPI_Allreduce(&maxtag,&maxtag_all,1,MPI_LMP_TAGINT,MPI_MAX,world); - - // DEBUG: useful for generating 64-bit IDs even for small systems - // use only when LAMMPS is compiled with BIGBIG - - //maxtag_all += 1000000000000; - - // notag = # of atoms I own with no tag (tag = 0) - // notag_sum = # of total atoms on procs <= me with no tag - - bigint notag = 0; - for (int i = 0; i < nlocal; i++) if (tag[i] == 0) notag++; - - bigint notag_total; - MPI_Allreduce(¬ag,¬ag_total,1,MPI_LMP_BIGINT,MPI_SUM,world); - if (notag_total >= MAXTAGINT) - error->all(FLERR,"New atom IDs exceed maximum allowed ID"); - - bigint notag_sum; - MPI_Scan(¬ag,¬ag_sum,1,MPI_LMP_BIGINT,MPI_SUM,world); - - // itag = 1st new tag that my untagged atoms should use - - tagint itag = maxtag_all + notag_sum - notag + 1; - for (int i = 0; i < nlocal; i++) if (tag[i] == 0) tag[i] = itag++; -} - -/* ---------------------------------------------------------------------- - check that atom IDs span range from 1 to Natoms inclusive - return 0 if mintag != 1 or maxtag != Natoms - return 1 if OK - doesn't actually check if all tag values are used -------------------------------------------------------------------------- */ - -int Atom::tag_consecutive() -{ - tagint idmin = MAXTAGINT; - tagint idmax = 0; - - for (int i = 0; i < nlocal; i++) { - idmin = MIN(idmin,tag[i]); - idmax = MAX(idmax,tag[i]); - } - tagint idminall,idmaxall; - MPI_Allreduce(&idmin,&idminall,1,MPI_LMP_TAGINT,MPI_MIN,world); - MPI_Allreduce(&idmax,&idmaxall,1,MPI_LMP_TAGINT,MPI_MAX,world); - - if (idminall != 1 || idmaxall != natoms) return 0; - return 1; -} - -/* ---------------------------------------------------------------------- - count and return words in a single line - make copy of line before using strtok so as not to change line - trim anything from '#' onward -------------------------------------------------------------------------- */ - -int Atom::count_words(const char *line) -{ - int n = strlen(line) + 1; - char *copy; - memory->create(copy,n,"atom:copy"); - strcpy(copy,line); - - char *ptr; - if ((ptr = strchr(copy,'#'))) *ptr = '\0'; - - if (strtok(copy," \t\n\r\f") == NULL) { - memory->destroy(copy); - return 0; - } - n = 1; - while (strtok(NULL," \t\n\r\f")) n++; - - memory->destroy(copy); - return n; -} - -/* ---------------------------------------------------------------------- - count and return words in a single line using provided copy buf - make copy of line before using strtok so as not to change line - trim anything from '#' onward -------------------------------------------------------------------------- */ - -int Atom::count_words(const char *line, char *copy) -{ - strcpy(copy,line); - - char *ptr; - if ((ptr = strchr(copy,'#'))) *ptr = '\0'; - - if (strtok(copy," \t\n\r\f") == NULL) { - memory->destroy(copy); - return 0; - } - int n = 1; - while (strtok(NULL," \t\n\r\f")) n++; - - return n; -} - -/* ---------------------------------------------------------------------- - deallocate molecular topology arrays - done before realloc with (possibly) new 2nd dimension set to - correctly initialized per-atom values, e.g. bond_per_atom - needs to be called whenever 2nd dimensions are changed - and these arrays are already pre-allocated, - e.g. due to grow(1) in create_avec() -------------------------------------------------------------------------- */ - -void Atom::deallocate_topology() -{ - memory->destroy(atom->bond_type); - memory->destroy(atom->bond_atom); - atom->bond_type = NULL; - atom->bond_atom = NULL; - - memory->destroy(atom->angle_type); - memory->destroy(atom->angle_atom1); - memory->destroy(atom->angle_atom2); - memory->destroy(atom->angle_atom3); - atom->angle_type = NULL; - atom->angle_atom1 = atom->angle_atom2 = atom->angle_atom3 = NULL; - - memory->destroy(atom->dihedral_type); - memory->destroy(atom->dihedral_atom1); - memory->destroy(atom->dihedral_atom2); - memory->destroy(atom->dihedral_atom3); - memory->destroy(atom->dihedral_atom4); - atom->dihedral_type = NULL; - atom->dihedral_atom1 = atom->dihedral_atom2 = - atom->dihedral_atom3 = atom->dihedral_atom4 = NULL; - - memory->destroy(atom->improper_type); - memory->destroy(atom->improper_atom1); - memory->destroy(atom->improper_atom2); - memory->destroy(atom->improper_atom3); - memory->destroy(atom->improper_atom4); - atom->improper_type = NULL; - atom->improper_atom1 = atom->improper_atom2 = - atom->improper_atom3 = atom->improper_atom4 = NULL; -} - -/* ---------------------------------------------------------------------- - unpack N lines from Atom section of data file - call style-specific routine to parse line -------------------------------------------------------------------------- */ - -void Atom::data_atoms(int n, char *buf, tagint id_offset, int type_offset, - int shiftflag, double *shift) -{ - int m,xptr,iptr; - imageint imagedata; - double xdata[3],lamda[3]; - double *coord; - char *next; - - next = strchr(buf,'\n'); - *next = '\0'; - int nwords = count_words(buf); - *next = '\n'; - - if (nwords != avec->size_data_atom && nwords != avec->size_data_atom + 3) - error->all(FLERR,"Incorrect atom format in data file"); - - char **values = new char*[nwords]; - - // set bounds for my proc - // if periodic and I am lo/hi proc, adjust bounds by EPSILON - // insures all data atoms will be owned even with round-off - - int triclinic = domain->triclinic; - - double epsilon[3]; - if (triclinic) epsilon[0] = epsilon[1] = epsilon[2] = EPSILON; - else { - epsilon[0] = domain->prd[0] * EPSILON; - epsilon[1] = domain->prd[1] * EPSILON; - epsilon[2] = domain->prd[2] * EPSILON; - } - - double sublo[3],subhi[3]; - if (triclinic == 0) { - sublo[0] = domain->sublo[0]; subhi[0] = domain->subhi[0]; - sublo[1] = domain->sublo[1]; subhi[1] = domain->subhi[1]; - sublo[2] = domain->sublo[2]; subhi[2] = domain->subhi[2]; - } else { - sublo[0] = domain->sublo_lamda[0]; subhi[0] = domain->subhi_lamda[0]; - sublo[1] = domain->sublo_lamda[1]; subhi[1] = domain->subhi_lamda[1]; - sublo[2] = domain->sublo_lamda[2]; subhi[2] = domain->subhi_lamda[2]; - } - - if (comm->layout != LAYOUT_TILED) { - if (domain->xperiodic) { - if (comm->myloc[0] == 0) sublo[0] -= epsilon[0]; - if (comm->myloc[0] == comm->procgrid[0]-1) subhi[0] += epsilon[0]; - } - if (domain->yperiodic) { - if (comm->myloc[1] == 0) sublo[1] -= epsilon[1]; - if (comm->myloc[1] == comm->procgrid[1]-1) subhi[1] += epsilon[1]; - } - if (domain->zperiodic) { - if (comm->myloc[2] == 0) sublo[2] -= epsilon[2]; - if (comm->myloc[2] == comm->procgrid[2]-1) subhi[2] += epsilon[2]; - } - - } else { - if (domain->xperiodic) { - if (comm->mysplit[0][0] == 0.0) sublo[0] -= epsilon[0]; - if (comm->mysplit[0][1] == 1.0) subhi[0] += epsilon[0]; - } - if (domain->yperiodic) { - if (comm->mysplit[1][0] == 0.0) sublo[1] -= epsilon[1]; - if (comm->mysplit[1][1] == 1.0) subhi[1] += epsilon[1]; - } - if (domain->zperiodic) { - if (comm->mysplit[2][0] == 0.0) sublo[2] -= epsilon[2]; - if (comm->mysplit[2][1] == 1.0) subhi[2] += epsilon[2]; - } - } - - // xptr = which word in line starts xyz coords - // iptr = which word in line starts ix,iy,iz image flags - - xptr = avec->xcol_data - 1; - int imageflag = 0; - if (nwords > avec->size_data_atom) imageflag = 1; - if (imageflag) iptr = nwords - 3; - - // loop over lines of atom data - // tokenize the line into values - // extract xyz coords and image flags - // remap atom into simulation box - // if atom is in my sub-domain, unpack its values - - for (int i = 0; i < n; i++) { - next = strchr(buf,'\n'); - - values[0] = strtok(buf," \t\n\r\f"); - if (values[0] == NULL) - error->all(FLERR,"Incorrect atom format in data file"); - for (m = 1; m < nwords; m++) { - values[m] = strtok(NULL," \t\n\r\f"); - if (values[m] == NULL) - error->all(FLERR,"Incorrect atom format in data file"); - } - - if (imageflag) - imagedata = ((imageint) (atoi(values[iptr]) + IMGMAX) & IMGMASK) | - (((imageint) (atoi(values[iptr+1]) + IMGMAX) & IMGMASK) << IMGBITS) | - (((imageint) (atoi(values[iptr+2]) + IMGMAX) & IMGMASK) << IMG2BITS); - else imagedata = ((imageint) IMGMAX << IMG2BITS) | - ((imageint) IMGMAX << IMGBITS) | IMGMAX; - - xdata[0] = atof(values[xptr]); - xdata[1] = atof(values[xptr+1]); - xdata[2] = atof(values[xptr+2]); - if (shiftflag) { - xdata[0] += shift[0]; - xdata[1] += shift[1]; - xdata[2] += shift[2]; - } - - domain->remap(xdata,imagedata); - if (triclinic) { - domain->x2lamda(xdata,lamda); - coord = lamda; - } else coord = xdata; - - if (coord[0] >= sublo[0] && coord[0] < subhi[0] && - coord[1] >= sublo[1] && coord[1] < subhi[1] && - coord[2] >= sublo[2] && coord[2] < subhi[2]) { - avec->data_atom(xdata,imagedata,values); - if (id_offset) tag[nlocal-1] += id_offset; - if (type_offset) { - type[nlocal-1] += type_offset; - if (type[nlocal-1] > ntypes) - error->one(FLERR,"Invalid atom type in Atoms section of data file"); - } - } - - buf = next + 1; - } - - delete [] values; -} - -/* ---------------------------------------------------------------------- - unpack N lines from Velocity section of data file - check that atom IDs are > 0 and <= map_tag_max - call style-specific routine to parse line -------------------------------------------------------------------------- */ - -void Atom::data_vels(int n, char *buf, tagint id_offset) -{ - int j,m; - tagint tagdata; - char *next; - - next = strchr(buf,'\n'); - *next = '\0'; - int nwords = count_words(buf); - *next = '\n'; - - if (nwords != avec->size_data_vel) - error->all(FLERR,"Incorrect velocity format in data file"); - - char **values = new char*[nwords]; - - // loop over lines of atom velocities - // tokenize the line into values - // if I own atom tag, unpack its values - - for (int i = 0; i < n; i++) { - next = strchr(buf,'\n'); - - values[0] = strtok(buf," \t\n\r\f"); - for (j = 1; j < nwords; j++) - values[j] = strtok(NULL," \t\n\r\f"); - - tagdata = ATOTAGINT(values[0]) + id_offset; - if (tagdata <= 0 || tagdata > map_tag_max) - error->one(FLERR,"Invalid atom ID in Velocities section of data file"); - if ((m = map(tagdata)) >= 0) avec->data_vel(m,&values[1]); - - buf = next + 1; - } - - delete [] values; -} - -/* ---------------------------------------------------------------------- - process N bonds read into buf from data files - if count is non-NULL, just count bonds per atom - else store them with atoms - check that atom IDs are > 0 and <= map_tag_max -------------------------------------------------------------------------- */ - -void Atom::data_bonds(int n, char *buf, int *count, tagint id_offset, - int type_offset) -{ - int m,tmp,itype; - tagint atom1,atom2; - char *next; - int newton_bond = force->newton_bond; - - for (int i = 0; i < n; i++) { - next = strchr(buf,'\n'); - *next = '\0'; - sscanf(buf,"%d %d " TAGINT_FORMAT " " TAGINT_FORMAT, - &tmp,&itype,&atom1,&atom2); - if (id_offset) { - atom1 += id_offset; - atom2 += id_offset; - } - itype += type_offset; - - if (atom1 <= 0 || atom1 > map_tag_max || - atom2 <= 0 || atom2 > map_tag_max) - error->one(FLERR,"Invalid atom ID in Bonds section of data file"); - if (itype <= 0 || itype > nbondtypes) - error->one(FLERR,"Invalid bond type in Bonds section of data file"); - if ((m = map(atom1)) >= 0) { - if (count) count[m]++; - else { - bond_type[m][num_bond[m]] = itype; - bond_atom[m][num_bond[m]] = atom2; - num_bond[m]++; - } - } - if (newton_bond == 0) { - if ((m = map(atom2)) >= 0) { - if (count) count[m]++; - else { - bond_type[m][num_bond[m]] = itype; - bond_atom[m][num_bond[m]] = atom1; - num_bond[m]++; - } - } - } - buf = next + 1; - } -} - -/* ---------------------------------------------------------------------- - process N angles read into buf from data files - if count is non-NULL, just count angles per atom - else store them with atoms - check that atom IDs are > 0 and <= map_tag_max -------------------------------------------------------------------------- */ - -void Atom::data_angles(int n, char *buf, int *count, tagint id_offset, - int type_offset) -{ - int m,tmp,itype; - tagint atom1,atom2,atom3; - char *next; - int newton_bond = force->newton_bond; - - for (int i = 0; i < n; i++) { - next = strchr(buf,'\n'); - *next = '\0'; - sscanf(buf,"%d %d " TAGINT_FORMAT " " TAGINT_FORMAT " " TAGINT_FORMAT, - &tmp,&itype,&atom1,&atom2,&atom3); - if (id_offset) { - atom1 += id_offset; - atom2 += id_offset; - atom3 += id_offset; - } - itype += type_offset; - - if (atom1 <= 0 || atom1 > map_tag_max || - atom2 <= 0 || atom2 > map_tag_max || - atom3 <= 0 || atom3 > map_tag_max) - error->one(FLERR,"Invalid atom ID in Angles section of data file"); - if (itype <= 0 || itype > nangletypes) - error->one(FLERR,"Invalid angle type in Angles section of data file"); - if ((m = map(atom2)) >= 0) { - if (count) count[m]++; - else { - angle_type[m][num_angle[m]] = itype; - angle_atom1[m][num_angle[m]] = atom1; - angle_atom2[m][num_angle[m]] = atom2; - angle_atom3[m][num_angle[m]] = atom3; - num_angle[m]++; - } - } - if (newton_bond == 0) { - if ((m = map(atom1)) >= 0) { - if (count) count[m]++; - else { - angle_type[m][num_angle[m]] = itype; - angle_atom1[m][num_angle[m]] = atom1; - angle_atom2[m][num_angle[m]] = atom2; - angle_atom3[m][num_angle[m]] = atom3; - num_angle[m]++; - } - } - if ((m = map(atom3)) >= 0) { - if (count) count[m]++; - else { - angle_type[m][num_angle[m]] = itype; - angle_atom1[m][num_angle[m]] = atom1; - angle_atom2[m][num_angle[m]] = atom2; - angle_atom3[m][num_angle[m]] = atom3; - num_angle[m]++; - } - } - } - buf = next + 1; - } -} - -/* ---------------------------------------------------------------------- - process N dihedrals read into buf from data files - if count is non-NULL, just count diihedrals per atom - else store them with atoms - check that atom IDs are > 0 and <= map_tag_max -------------------------------------------------------------------------- */ - -void Atom::data_dihedrals(int n, char *buf, int *count, tagint id_offset, - int type_offset) -{ - int m,tmp,itype; - tagint atom1,atom2,atom3,atom4; - char *next; - int newton_bond = force->newton_bond; - - for (int i = 0; i < n; i++) { - next = strchr(buf,'\n'); - *next = '\0'; - sscanf(buf,"%d %d " - TAGINT_FORMAT " " TAGINT_FORMAT " " TAGINT_FORMAT " " TAGINT_FORMAT, - &tmp,&itype,&atom1,&atom2,&atom3,&atom4); - if (id_offset) { - atom1 += id_offset; - atom2 += id_offset; - atom3 += id_offset; - atom4 += id_offset; - } - itype += type_offset; - - if (atom1 <= 0 || atom1 > map_tag_max || - atom2 <= 0 || atom2 > map_tag_max || - atom3 <= 0 || atom3 > map_tag_max || - atom4 <= 0 || atom4 > map_tag_max) - error->one(FLERR,"Invalid atom ID in Dihedrals section of data file"); - if (itype <= 0 || itype > ndihedraltypes) - error->one(FLERR, - "Invalid dihedral type in Dihedrals section of data file"); - if ((m = map(atom2)) >= 0) { - if (count) count[m]++; - else { - dihedral_type[m][num_dihedral[m]] = itype; - dihedral_atom1[m][num_dihedral[m]] = atom1; - dihedral_atom2[m][num_dihedral[m]] = atom2; - dihedral_atom3[m][num_dihedral[m]] = atom3; - dihedral_atom4[m][num_dihedral[m]] = atom4; - num_dihedral[m]++; - } - } - if (newton_bond == 0) { - if ((m = map(atom1)) >= 0) { - if (count) count[m]++; - else { - dihedral_type[m][num_dihedral[m]] = itype; - dihedral_atom1[m][num_dihedral[m]] = atom1; - dihedral_atom2[m][num_dihedral[m]] = atom2; - dihedral_atom3[m][num_dihedral[m]] = atom3; - dihedral_atom4[m][num_dihedral[m]] = atom4; - num_dihedral[m]++; - } - } - if ((m = map(atom3)) >= 0) { - if (count) count[m]++; - else { - dihedral_type[m][num_dihedral[m]] = itype; - dihedral_atom1[m][num_dihedral[m]] = atom1; - dihedral_atom2[m][num_dihedral[m]] = atom2; - dihedral_atom3[m][num_dihedral[m]] = atom3; - dihedral_atom4[m][num_dihedral[m]] = atom4; - num_dihedral[m]++; - } - } - if ((m = map(atom4)) >= 0) { - if (count) count[m]++; - else { - dihedral_type[m][num_dihedral[m]] = itype; - dihedral_atom1[m][num_dihedral[m]] = atom1; - dihedral_atom2[m][num_dihedral[m]] = atom2; - dihedral_atom3[m][num_dihedral[m]] = atom3; - dihedral_atom4[m][num_dihedral[m]] = atom4; - num_dihedral[m]++; - } - } - } - buf = next + 1; - } -} - -/* ---------------------------------------------------------------------- - process N impropers read into buf from data files - if count is non-NULL, just count impropers per atom - else store them with atoms - check that atom IDs are > 0 and <= map_tag_max -------------------------------------------------------------------------- */ - -void Atom::data_impropers(int n, char *buf, int *count, tagint id_offset, - int type_offset) -{ - int m,tmp,itype; - tagint atom1,atom2,atom3,atom4; - char *next; - int newton_bond = force->newton_bond; - - for (int i = 0; i < n; i++) { - next = strchr(buf,'\n'); - *next = '\0'; - sscanf(buf,"%d %d " - TAGINT_FORMAT " " TAGINT_FORMAT " " TAGINT_FORMAT " " TAGINT_FORMAT, - &tmp,&itype,&atom1,&atom2,&atom3,&atom4); - if (id_offset) { - atom1 += id_offset; - atom2 += id_offset; - atom3 += id_offset; - atom4 += id_offset; - } - itype += type_offset; - - if (atom1 <= 0 || atom1 > map_tag_max || - atom2 <= 0 || atom2 > map_tag_max || - atom3 <= 0 || atom3 > map_tag_max || - atom4 <= 0 || atom4 > map_tag_max) - error->one(FLERR,"Invalid atom ID in Impropers section of data file"); - if (itype <= 0 || itype > nimpropertypes) - error->one(FLERR, - "Invalid improper type in Impropers section of data file"); - if ((m = map(atom2)) >= 0) { - if (count) count[m]++; - else { - improper_type[m][num_improper[m]] = itype; - improper_atom1[m][num_improper[m]] = atom1; - improper_atom2[m][num_improper[m]] = atom2; - improper_atom3[m][num_improper[m]] = atom3; - improper_atom4[m][num_improper[m]] = atom4; - num_improper[m]++; - } - } - if (newton_bond == 0) { - if ((m = map(atom1)) >= 0) { - if (count) count[m]++; - else { - improper_type[m][num_improper[m]] = itype; - improper_atom1[m][num_improper[m]] = atom1; - improper_atom2[m][num_improper[m]] = atom2; - improper_atom3[m][num_improper[m]] = atom3; - improper_atom4[m][num_improper[m]] = atom4; - num_improper[m]++; - } - } - if ((m = map(atom3)) >= 0) { - if (count) count[m]++; - else { - improper_type[m][num_improper[m]] = itype; - improper_atom1[m][num_improper[m]] = atom1; - improper_atom2[m][num_improper[m]] = atom2; - improper_atom3[m][num_improper[m]] = atom3; - improper_atom4[m][num_improper[m]] = atom4; - num_improper[m]++; - } - } - if ((m = map(atom4)) >= 0) { - if (count) count[m]++; - else { - improper_type[m][num_improper[m]] = itype; - improper_atom1[m][num_improper[m]] = atom1; - improper_atom2[m][num_improper[m]] = atom2; - improper_atom3[m][num_improper[m]] = atom3; - improper_atom4[m][num_improper[m]] = atom4; - num_improper[m]++; - } - } - } - buf = next + 1; - } -} - -/* ---------------------------------------------------------------------- - unpack N lines from atom-style specific bonus section of data file - check that atom IDs are > 0 and <= map_tag_max - call style-specific routine to parse line -------------------------------------------------------------------------- */ - -void Atom::data_bonus(int n, char *buf, AtomVec *avec_bonus, tagint id_offset) -{ - int j,m,tagdata; - char *next; - - next = strchr(buf,'\n'); - *next = '\0'; - int nwords = count_words(buf); - *next = '\n'; - - if (nwords != avec_bonus->size_data_bonus) - error->all(FLERR,"Incorrect bonus data format in data file"); - - char **values = new char*[nwords]; - - // loop over lines of bonus atom data - // tokenize the line into values - // if I own atom tag, unpack its values - - for (int i = 0; i < n; i++) { - next = strchr(buf,'\n'); - - values[0] = strtok(buf," \t\n\r\f"); - for (j = 1; j < nwords; j++) - values[j] = strtok(NULL," \t\n\r\f"); - - tagdata = ATOTAGINT(values[0]) + id_offset; - if (tagdata <= 0 || tagdata > map_tag_max) - error->one(FLERR,"Invalid atom ID in Bonus section of data file"); - - // ok to call child's data_atom_bonus() method thru parent avec_bonus, - // since data_bonus() was called with child ptr, and method is virtual - - if ((m = map(tagdata)) >= 0) avec_bonus->data_atom_bonus(m,&values[1]); - - buf = next + 1; - } - - delete [] values; -} - -/* ---------------------------------------------------------------------- - unpack N bodies from Bodies section of data file - each body spans multiple lines - check that atom IDs are > 0 and <= map_tag_max - call style-specific routine to parse line -------------------------------------------------------------------------- */ - -void Atom::data_bodies(int n, char *buf, AtomVecBody *avec_body, - tagint id_offset) -{ - int j,m,nvalues,tagdata,ninteger,ndouble; - - int maxint = 0; - int maxdouble = 0; - int *ivalues = NULL; - double *dvalues = NULL; - - // loop over lines of body data - // if I own atom tag, tokenize lines into ivalues/dvalues, call data_body() - // else skip values - - for (int i = 0; i < n; i++) { - if (i == 0) tagdata = ATOTAGINT(strtok(buf," \t\n\r\f")) + id_offset; - else tagdata = ATOTAGINT(strtok(NULL," \t\n\r\f")) + id_offset; - - if (tagdata <= 0 || tagdata > map_tag_max) - error->one(FLERR,"Invalid atom ID in Bodies section of data file"); - - ninteger = force->inumeric(FLERR,strtok(NULL," \t\n\r\f")); - ndouble = force->inumeric(FLERR,strtok(NULL," \t\n\r\f")); - - if ((m = map(tagdata)) >= 0) { - if (ninteger > maxint) { - delete [] ivalues; - maxint = ninteger; - ivalues = new int[maxint]; - } - if (ndouble > maxdouble) { - delete [] dvalues; - maxdouble = ndouble; - dvalues = new double[maxdouble]; - } - - for (j = 0; j < ninteger; j++) - ivalues[j] = force->inumeric(FLERR,strtok(NULL," \t\n\r\f")); - for (j = 0; j < ndouble; j++) - dvalues[j] = force->numeric(FLERR,strtok(NULL," \t\n\r\f")); - - avec_body->data_body(m,ninteger,ndouble,ivalues,dvalues); - - } else { - nvalues = ninteger + ndouble; // number of values to skip - for (j = 0; j < nvalues; j++) - strtok(NULL," \t\n\r\f"); - } - } - - delete [] ivalues; - delete [] dvalues; -} - -/* ---------------------------------------------------------------------- - allocate arrays of length ntypes - only done after ntypes is set -------------------------------------------------------------------------- */ - -void Atom::allocate_type_arrays() -{ - if (avec->mass_type) { - mass = new double[ntypes+1]; - mass_setflag = new int[ntypes+1]; - for (int itype = 1; itype <= ntypes; itype++) mass_setflag[itype] = 0; - } -} - -/* ---------------------------------------------------------------------- - set a mass and flag it as set - called from reading of data file - type_offset may be used when reading multiple data files -------------------------------------------------------------------------- */ - -void Atom::set_mass(const char *str, int type_offset) -{ - if (mass == NULL) error->all(FLERR,"Cannot set mass for this atom style"); - - int itype; - double mass_one; - int n = sscanf(str,"%d %lg",&itype,&mass_one); - if (n != 2) error->all(FLERR,"Invalid mass line in data file"); - itype += type_offset; - - if (itype < 1 || itype > ntypes) - error->all(FLERR,"Invalid type for mass set"); - - mass[itype] = mass_one; - mass_setflag[itype] = 1; - - if (mass[itype] <= 0.0) error->all(FLERR,"Invalid mass value"); -} - -/* ---------------------------------------------------------------------- - set a mass and flag it as set - called from EAM pair routine -------------------------------------------------------------------------- */ - -void Atom::set_mass(int itype, double value) -{ - if (mass == NULL) error->all(FLERR,"Cannot set mass for this atom style"); - if (itype < 1 || itype > ntypes) - error->all(FLERR,"Invalid type for mass set"); - - mass[itype] = value; - mass_setflag[itype] = 1; - - if (mass[itype] <= 0.0) error->all(FLERR,"Invalid mass value"); -} - -/* ---------------------------------------------------------------------- - set one or more masses and flag them as set - called from reading of input script -------------------------------------------------------------------------- */ - -void Atom::set_mass(int narg, char **arg) -{ - if (mass == NULL) error->all(FLERR,"Cannot set mass for this atom style"); - - int lo,hi; - force->bounds(arg[0],ntypes,lo,hi); - if (lo < 1 || hi > ntypes) error->all(FLERR,"Invalid type for mass set"); - - for (int itype = lo; itype <= hi; itype++) { - mass[itype] = atof(arg[1]); - mass_setflag[itype] = 1; - - if (mass[itype] <= 0.0) error->all(FLERR,"Invalid mass value"); - } -} - -/* ---------------------------------------------------------------------- - set all masses as read in from restart file -------------------------------------------------------------------------- */ - -void Atom::set_mass(double *values) -{ - for (int itype = 1; itype <= ntypes; itype++) { - mass[itype] = values[itype]; - mass_setflag[itype] = 1; - } -} - -/* ---------------------------------------------------------------------- - check that all masses have been set -------------------------------------------------------------------------- */ - -void Atom::check_mass() -{ - if (mass == NULL) return; - for (int itype = 1; itype <= ntypes; itype++) - if (mass_setflag[itype] == 0) error->all(FLERR,"All masses are not set"); -} - -/* ---------------------------------------------------------------------- - check that radii of all particles of itype are the same - return 1 if true, else return 0 - also return the radius value for that type -------------------------------------------------------------------------- */ - -int Atom::radius_consistency(int itype, double &rad) -{ - double value = -1.0; - int flag = 0; - for (int i = 0; i < nlocal; i++) { - if (type[i] != itype) continue; - if (value < 0.0) value = radius[i]; - else if (value != radius[i]) flag = 1; - } - - int flagall; - MPI_Allreduce(&flag,&flagall,1,MPI_INT,MPI_SUM,world); - if (flagall) return 0; - - MPI_Allreduce(&value,&rad,1,MPI_DOUBLE,MPI_MAX,world); - return 1; -} - -/* ---------------------------------------------------------------------- - check that shape of all particles of itype are the same - return 1 if true, else return 0 - also return the 3 shape params for itype -------------------------------------------------------------------------- */ - -int Atom::shape_consistency(int itype, - double &shapex, double &shapey, double &shapez) -{ - double zero[3] = {0.0, 0.0, 0.0}; - double one[3] = {-1.0, -1.0, -1.0}; - double *shape; - - AtomVecEllipsoid *avec_ellipsoid = - (AtomVecEllipsoid *) style_match("ellipsoid"); - AtomVecEllipsoid::Bonus *bonus = avec_ellipsoid->bonus; - - int flag = 0; - for (int i = 0; i < nlocal; i++) { - if (type[i] != itype) continue; - if (ellipsoid[i] < 0) shape = zero; - else shape = bonus[ellipsoid[i]].shape; - - if (one[0] < 0.0) { - one[0] = shape[0]; - one[1] = shape[1]; - one[2] = shape[2]; - } else if (one[0] != shape[0] || one[1] != shape[1] || one[2] != shape[2]) - flag = 1; - } - - int flagall; - MPI_Allreduce(&flag,&flagall,1,MPI_INT,MPI_SUM,world); - if (flagall) return 0; - - double oneall[3]; - MPI_Allreduce(one,oneall,3,MPI_DOUBLE,MPI_MAX,world); - shapex = oneall[0]; - shapey = oneall[1]; - shapez = oneall[2]; - return 1; -} - -/* ---------------------------------------------------------------------- - add a new molecule template = set of molecules -------------------------------------------------------------------------- */ - -void Atom::add_molecule(int narg, char **arg) -{ - if (narg < 1) error->all(FLERR,"Illegal molecule command"); - - if (find_molecule(arg[0]) >= 0) - error->all(FLERR,"Reuse of molecule template ID"); - - // 1st molecule in set stores nset = # of mols, others store nset = 0 - // ifile = count of molecules in set - // index = argument index where next molecule starts, updated by constructor - - int ifile = 1; - int index = 1; - while (1) { - molecules = (Molecule **) - memory->srealloc(molecules,(nmolecule+1)*sizeof(Molecule *), - "atom::molecules"); - molecules[nmolecule] = new Molecule(lmp,narg,arg,index); - molecules[nmolecule]->nset = 0; - molecules[nmolecule-ifile+1]->nset++; - nmolecule++; - if (molecules[nmolecule-1]->last) break; - ifile++; - } -} - -/* ---------------------------------------------------------------------- - find first molecule in set with template ID - return -1 if does not exist -------------------------------------------------------------------------- */ - -int Atom::find_molecule(char *id) -{ - int imol; - for (imol = 0; imol < nmolecule; imol++) - if (strcmp(id,molecules[imol]->id) == 0) return imol; - return -1; -} - -/* ---------------------------------------------------------------------- - add info to current atom ilocal from molecule template onemol and its iatom - offset = atom ID preceeding IDs of atoms in this molecule - called by fixes and commands that add molecules -------------------------------------------------------------------------- */ - -void Atom::add_molecule_atom(Molecule *onemol, int iatom, - int ilocal, tagint offset) -{ - if (onemol->qflag && q_flag) q[ilocal] = onemol->q[iatom]; - if (onemol->radiusflag && radius_flag) radius[ilocal] = onemol->radius[iatom]; - if (onemol->rmassflag && rmass_flag) rmass[ilocal] = onemol->rmass[iatom]; - if (onemol->replambdaHflag && replambdaH_flag) replambdaH[ilocal] = onemol->replambdaH[iatom]; - if (onemol->moltypeHflag && moltypeH_flag) moltypeH[ilocal] = onemol->moltypeH[iatom]; - else if (rmass_flag) - rmass[ilocal] = 4.0*MY_PI/3.0 * - radius[ilocal]*radius[ilocal]*radius[ilocal]; - if (onemol->bodyflag) { - body[ilocal] = 0; // as if a body read from data file - onemol->avec_body->data_body(ilocal,onemol->nibody,onemol->ndbody, - onemol->ibodyparams,onemol->dbodyparams); - onemol->avec_body->set_quat(ilocal,onemol->quat_external); - } - - if (molecular != 1) return; - - // add bond topology info - // for molecular atom styles, but not atom style template - - if (avec->bonds_allow) { - num_bond[ilocal] = onemol->num_bond[iatom]; - for (int i = 0; i < num_bond[ilocal]; i++) { - bond_type[ilocal][i] = onemol->bond_type[iatom][i]; - bond_atom[ilocal][i] = onemol->bond_atom[iatom][i] + offset; - } - } - - if (avec->angles_allow) { - num_angle[ilocal] = onemol->num_angle[iatom]; - for (int i = 0; i < num_angle[ilocal]; i++) { - angle_type[ilocal][i] = onemol->angle_type[iatom][i]; - angle_atom1[ilocal][i] = onemol->angle_atom1[iatom][i] + offset; - angle_atom2[ilocal][i] = onemol->angle_atom2[iatom][i] + offset; - angle_atom3[ilocal][i] = onemol->angle_atom3[iatom][i] + offset; - } - } - - if (avec->dihedrals_allow) { - num_dihedral[ilocal] = onemol->num_dihedral[iatom]; - for (int i = 0; i < num_dihedral[ilocal]; i++) { - dihedral_type[ilocal][i] = onemol->dihedral_type[iatom][i]; - dihedral_atom1[ilocal][i] = onemol->dihedral_atom1[iatom][i] + offset; - dihedral_atom2[ilocal][i] = onemol->dihedral_atom2[iatom][i] + offset; - dihedral_atom3[ilocal][i] = onemol->dihedral_atom3[iatom][i] + offset; - dihedral_atom4[ilocal][i] = onemol->dihedral_atom4[iatom][i] + offset; - } - } - - if (avec->impropers_allow) { - num_improper[ilocal] = onemol->num_improper[iatom]; - for (int i = 0; i < num_improper[ilocal]; i++) { - improper_type[ilocal][i] = onemol->improper_type[iatom][i]; - improper_atom1[ilocal][i] = onemol->improper_atom1[iatom][i] + offset; - improper_atom2[ilocal][i] = onemol->improper_atom2[iatom][i] + offset; - improper_atom3[ilocal][i] = onemol->improper_atom3[iatom][i] + offset; - improper_atom4[ilocal][i] = onemol->improper_atom4[iatom][i] + offset; - } - } - - if (onemol->specialflag) { - nspecial[ilocal][0] = onemol->nspecial[iatom][0]; - nspecial[ilocal][1] = onemol->nspecial[iatom][1]; - int n = nspecial[ilocal][2] = onemol->nspecial[iatom][2]; - for (int i = 0; i < n; i++) - special[ilocal][i] = onemol->special[iatom][i] + offset; - } -} - -/* ---------------------------------------------------------------------- - reorder owned atoms so those in firstgroup appear first - called by comm->exchange() if atom_modify first group is set - only owned atoms exist at this point, no ghost atoms -------------------------------------------------------------------------- */ - -void Atom::first_reorder() -{ - // insure there is one extra atom location at end of arrays for swaps - - if (nlocal == nmax) avec->grow(0); - - // loop over owned atoms - // nfirst = index of first atom not in firstgroup - // when find firstgroup atom out of place, swap it with atom nfirst - - int bitmask = group->bitmask[firstgroup]; - nfirst = 0; - while (nfirst < nlocal && mask[nfirst] & bitmask) nfirst++; - - for (int i = 0; i < nlocal; i++) { - if (mask[i] & bitmask && i > nfirst) { - avec->copy(i,nlocal,0); - avec->copy(nfirst,i,0); - avec->copy(nlocal,nfirst,0); - while (nfirst < nlocal && mask[nfirst] & bitmask) nfirst++; - } - } -} - -/* ---------------------------------------------------------------------- - perform spatial sort of atoms within my sub-domain - always called between comm->exchange() and comm->borders() - don't have to worry about clearing/setting atom->map since done in comm -------------------------------------------------------------------------- */ - -void Atom::sort() -{ - int i,m,n,ix,iy,iz,ibin,empty; - - // set next timestep for sorting to take place - - nextsort = (update->ntimestep/sortfreq)*sortfreq + sortfreq; - - // download data from GPU if necessary - - if (lmp->cuda && !lmp->cuda->oncpu) lmp->cuda->downloadAll(); - - // re-setup sort bins if needed - - if (domain->box_change) setup_sort_bins(); - if (nbins == 1) return; - - // reallocate per-atom vectors if needed - - if (nlocal > maxnext) { - memory->destroy(next); - memory->destroy(permute); - maxnext = atom->nmax; - memory->create(next,maxnext,"atom:next"); - memory->create(permute,maxnext,"atom:permute"); - } - - // insure there is one extra atom location at end of arrays for swaps - - if (nlocal == nmax) avec->grow(0); - - // bin atoms in reverse order so linked list will be in forward order - - for (i = 0; i < nbins; i++) binhead[i] = -1; - - for (i = nlocal-1; i >= 0; i--) { - ix = static_cast ((x[i][0]-bboxlo[0])*bininvx); - iy = static_cast ((x[i][1]-bboxlo[1])*bininvy); - iz = static_cast ((x[i][2]-bboxlo[2])*bininvz); - ix = MAX(ix,0); - iy = MAX(iy,0); - iz = MAX(iz,0); - ix = MIN(ix,nbinx-1); - iy = MIN(iy,nbiny-1); - iz = MIN(iz,nbinz-1); - ibin = iz*nbiny*nbinx + iy*nbinx + ix; - next[i] = binhead[ibin]; - binhead[ibin] = i; - } - - // permute = desired permutation of atoms - // permute[I] = J means Ith new atom will be Jth old atom - - n = 0; - for (m = 0; m < nbins; m++) { - i = binhead[m]; - while (i >= 0) { - permute[n++] = i; - i = next[i]; - } - } - - // current = current permutation, just reuse next vector - // current[I] = J means Ith current atom is Jth old atom - - int *current = next; - for (i = 0; i < nlocal; i++) current[i] = i; - - // reorder local atom list, when done, current = permute - // perform "in place" using copy() to extra atom location at end of list - // inner while loop processes one cycle of the permutation - // copy before inner-loop moves an atom to end of atom list - // copy after inner-loop moves atom at end of list back into list - // empty = location in atom list that is currently empty - - for (i = 0; i < nlocal; i++) { - if (current[i] == permute[i]) continue; - avec->copy(i,nlocal,0); - empty = i; - while (permute[empty] != i) { - avec->copy(permute[empty],empty,0); - empty = current[empty] = permute[empty]; - } - avec->copy(nlocal,empty,0); - current[empty] = permute[empty]; - } - - // upload data back to GPU if necessary - - if (lmp->cuda && !lmp->cuda->oncpu) lmp->cuda->uploadAll(); - - // sanity check that current = permute - - //int flag = 0; - //for (i = 0; i < nlocal; i++) - // if (current[i] != permute[i]) flag = 1; - //int flagall; - //MPI_Allreduce(&flag,&flagall,1,MPI_INT,MPI_SUM,world); - //if (flagall) error->all(FLERR,"Atom sort did not operate correctly"); -} - -/* ---------------------------------------------------------------------- - setup bins for spatial sorting of atoms -------------------------------------------------------------------------- */ - -void Atom::setup_sort_bins() -{ - // binsize: - // user setting if explicitly set - // 1/2 of neighbor cutoff for non-CUDA - // CUDA_CHUNK atoms/proc for CUDA - // check if neighbor cutoff = 0.0 - - double binsize; - if (userbinsize > 0.0) binsize = userbinsize; - else if (!lmp->cuda) binsize = 0.5 * neighbor->cutneighmax; - else { - if (domain->dimension == 3) { - double vol = (domain->boxhi[0]-domain->boxlo[0]) * - (domain->boxhi[1]-domain->boxlo[1]) * - (domain->boxhi[2]-domain->boxlo[2]); - binsize = pow(1.0*CUDA_CHUNK/natoms*vol,1.0/3.0); - } else { - double area = (domain->boxhi[0]-domain->boxlo[0]) * - (domain->boxhi[1]-domain->boxlo[1]); - binsize = pow(1.0*CUDA_CHUNK/natoms*area,1.0/2.0); - } - } - if (binsize == 0.0) error->all(FLERR,"Atom sorting has bin size = 0.0"); - - double bininv = 1.0/binsize; - - // nbin xyz = local bins - // bbox lo/hi = bounding box of my sub-domain - - if (domain->triclinic) - domain->bbox(domain->sublo_lamda,domain->subhi_lamda,bboxlo,bboxhi); - else { - bboxlo[0] = domain->sublo[0]; - bboxlo[1] = domain->sublo[1]; - bboxlo[2] = domain->sublo[2]; - bboxhi[0] = domain->subhi[0]; - bboxhi[1] = domain->subhi[1]; - bboxhi[2] = domain->subhi[2]; - } - - nbinx = static_cast ((bboxhi[0]-bboxlo[0]) * bininv); - nbiny = static_cast ((bboxhi[1]-bboxlo[1]) * bininv); - nbinz = static_cast ((bboxhi[2]-bboxlo[2]) * bininv); - if (domain->dimension == 2) nbinz = 1; - - if (nbinx == 0) nbinx = 1; - if (nbiny == 0) nbiny = 1; - if (nbinz == 0) nbinz = 1; - - bininvx = nbinx / (bboxhi[0]-bboxlo[0]); - bininvy = nbiny / (bboxhi[1]-bboxlo[1]); - bininvz = nbinz / (bboxhi[2]-bboxlo[2]); - - if (1.0*nbinx*nbiny*nbinz > INT_MAX) - error->one(FLERR,"Too many atom sorting bins"); - - nbins = nbinx*nbiny*nbinz; - - // reallocate per-bin memory if needed - - if (nbins > maxbin) { - memory->destroy(binhead); - maxbin = nbins; - memory->create(binhead,maxbin,"atom:binhead"); - } -} - -/* ---------------------------------------------------------------------- - register a callback to a fix so it can manage atom-based arrays - happens when fix is created - flag = 0 for grow, 1 for restart, 2 for border comm -------------------------------------------------------------------------- */ - -void Atom::add_callback(int flag) -{ - int ifix; - - // find the fix - // if find NULL ptr: - // it's this one, since it is being replaced and has just been deleted - // at this point in re-creation - // if don't find NULL ptr: - // i is set to nfix = new one currently being added at end of list - - for (ifix = 0; ifix < modify->nfix; ifix++) - if (modify->fix[ifix] == NULL) break; - - // add callback to lists, reallocating if necessary - - if (flag == 0) { - if (nextra_grow == nextra_grow_max) { - nextra_grow_max += DELTA; - memory->grow(extra_grow,nextra_grow_max,"atom:extra_grow"); - } - extra_grow[nextra_grow] = ifix; - nextra_grow++; - } else if (flag == 1) { - if (nextra_restart == nextra_restart_max) { - nextra_restart_max += DELTA; - memory->grow(extra_restart,nextra_restart_max,"atom:extra_restart"); - } - extra_restart[nextra_restart] = ifix; - nextra_restart++; - } else if (flag == 2) { - if (nextra_border == nextra_border_max) { - nextra_border_max += DELTA; - memory->grow(extra_border,nextra_border_max,"atom:extra_border"); - } - extra_border[nextra_border] = ifix; - nextra_border++; - } -} - -/* ---------------------------------------------------------------------- - unregister a callback to a fix - happens when fix is deleted, called by its destructor - flag = 0 for grow, 1 for restart -------------------------------------------------------------------------- */ - -void Atom::delete_callback(const char *id, int flag) -{ - int ifix; - for (ifix = 0; ifix < modify->nfix; ifix++) - if (strcmp(id,modify->fix[ifix]->id) == 0) break; - - // compact the list of callbacks - - if (flag == 0) { - int match; - for (match = 0; match < nextra_grow; match++) - if (extra_grow[match] == ifix) break; - for (int i = match; i < nextra_grow-1; i++) - extra_grow[i] = extra_grow[i+1]; - nextra_grow--; - - } else if (flag == 1) { - int match; - for (match = 0; match < nextra_restart; match++) - if (extra_restart[match] == ifix) break; - for (int i = match; i < nextra_restart-1; i++) - extra_restart[i] = extra_restart[i+1]; - nextra_restart--; - - } else if (flag == 2) { - int match; - for (match = 0; match < nextra_border; match++) - if (extra_border[match] == ifix) break; - for (int i = match; i < nextra_border-1; i++) - extra_border[i] = extra_border[i+1]; - nextra_border--; - } -} - -/* ---------------------------------------------------------------------- - decrement ptrs in callback lists to fixes beyond the deleted ifix - happens after fix is deleted -------------------------------------------------------------------------- */ - -void Atom::update_callback(int ifix) -{ - for (int i = 0; i < nextra_grow; i++) - if (extra_grow[i] > ifix) extra_grow[i]--; - for (int i = 0; i < nextra_restart; i++) - if (extra_restart[i] > ifix) extra_restart[i]--; - for (int i = 0; i < nextra_border; i++) - if (extra_border[i] > ifix) extra_border[i]--; -} - -/* ---------------------------------------------------------------------- - find custom per-atom vector with name - return index if found, and flag = 0/1 for int/double - return -1 if not found -------------------------------------------------------------------------- */ - -int Atom::find_custom(char *name, int &flag) -{ - for (int i = 0; i < nivector; i++) - if (iname[i] && strcmp(iname[i],name) == 0) { - flag = 0; - return i; - } - - for (int i = 0; i < ndvector; i++) - if (dname[i] && strcmp(dname[i],name) == 0) { - flag = 1; - return i; - } - - return -1; -} - -/* ---------------------------------------------------------------------- - add a custom variable with name of type flag = 0/1 for int/double - assumes name does not already exist - return index in ivector or dvector of its location -------------------------------------------------------------------------- */ - -int Atom::add_custom(char *name, int flag) -{ - int index; - - if (flag == 0) { - index = nivector; - nivector++; - iname = (char **) memory->srealloc(iname,nivector*sizeof(char *), - "atom:iname"); - int n = strlen(name) + 1; - iname[index] = new char[n]; - strcpy(iname[index],name); - ivector = (int **) memory->srealloc(ivector,nivector*sizeof(int *), - "atom:ivector"); - memory->create(ivector[index],nmax,"atom:ivector"); - } else { - index = ndvector; - ndvector++; - dname = (char **) memory->srealloc(dname,ndvector*sizeof(char *), - "atom:dname"); - int n = strlen(name) + 1; - dname[index] = new char[n]; - strcpy(dname[index],name); - dvector = (double **) memory->srealloc(dvector,ndvector*sizeof(double *), - "atom:dvector"); - memory->create(dvector[index],nmax,"atom:dvector"); - } - - return index; -} - -/* ---------------------------------------------------------------------- - remove a custom variable of type flag = 0/1 for int/double at index - free memory for vector and name and set ptrs to NULL - ivector/dvector and iname/dname lists never shrink -------------------------------------------------------------------------- */ - -void Atom::remove_custom(int flag, int index) -{ - if (flag == 0) { - memory->destroy(ivector[index]); - ivector[index] = NULL; - delete [] iname[index]; - iname[index] = NULL; - } else { - memory->destroy(dvector[index]); - dvector[index] = NULL; - delete [] dname[index]; - dname[index] = NULL; - } -} - -/* ---------------------------------------------------------------------- - return a pointer to a named internal variable - if don't recognize name, return NULL - customize by adding names -------------------------------------------------------------------------- */ - -void *Atom::extract(char *name) -{ - if (strcmp(name,"mass") == 0) return (void *) mass; - - if (strcmp(name,"id") == 0) return (void *) tag; - if (strcmp(name,"type") == 0) return (void *) type; - if (strcmp(name,"mask") == 0) return (void *) mask; - if (strcmp(name,"image") == 0) return (void *) image; - if (strcmp(name,"x") == 0) return (void *) x; - if (strcmp(name,"v") == 0) return (void *) v; - if (strcmp(name,"f") == 0) return (void *) f; - if (strcmp(name,"molecule") == 0) return (void *) molecule; - if (strcmp(name,"q") == 0) return (void *) q; - if (strcmp(name,"lambdaH") == 0) return (void *) lambdaH; - if (strcmp(name,"gradlambdaH") == 0) return (void *) gradlambdaH; - if (strcmp(name,"replambdaH") == 0) return (void *) replambdaH; - if (strcmp(name,"mu") == 0) return (void *) mu; - if (strcmp(name,"omega") == 0) return (void *) omega; - if (strcmp(name,"angmom") == 0) return (void *) angmom; - if (strcmp(name,"torque") == 0) return (void *) torque; - if (strcmp(name,"radius") == 0) return (void *) radius; - if (strcmp(name,"rmass") == 0) return (void *) rmass; - if (strcmp(name,"ellipsoid") == 0) return (void *) ellipsoid; - if (strcmp(name,"line") == 0) return (void *) line; - if (strcmp(name,"tri") == 0) return (void *) tri; - - if (strcmp(name,"vfrac") == 0) return (void *) vfrac; - if (strcmp(name,"s0") == 0) return (void *) s0; - if (strcmp(name,"x0") == 0) return (void *) x0; - - if (strcmp(name,"spin") == 0) return (void *) spin; - if (strcmp(name,"eradius") == 0) return (void *) eradius; - if (strcmp(name,"ervel") == 0) return (void *) ervel; - if (strcmp(name,"erforce") == 0) return (void *) erforce; - if (strcmp(name,"ervelforce") == 0) return (void *) ervelforce; - if (strcmp(name,"cs") == 0) return (void *) cs; - if (strcmp(name,"csforce") == 0) return (void *) csforce; - if (strcmp(name,"vforce") == 0) return (void *) vforce; - if (strcmp(name,"etag") == 0) return (void *) etag; - - if (strcmp(name,"rho") == 0) return (void *) rho; - if (strcmp(name,"drho") == 0) return (void *) drho; - if (strcmp(name,"e") == 0) return (void *) e; - if (strcmp(name,"de") == 0) return (void *) de; - if (strcmp(name,"cv") == 0) return (void *) cv; - if (strcmp(name,"vest") == 0) return (void *) vest; - - if (strcmp(name, "contact_radius") == 0) return (void *) contact_radius; - if (strcmp(name, "smd_data_9") == 0) return (void *) smd_data_9; - if (strcmp(name, "smd_stress") == 0) return (void *) smd_stress; - if (strcmp(name, "eff_plastic_strain") == 0) - return (void *) eff_plastic_strain; - if (strcmp(name, "eff_plastic_strain_rate") == 0) - return (void *) eff_plastic_strain_rate; - if (strcmp(name, "damage") == 0) return (void *) damage; - - if (strcmp(name,"dpdTheta") == 0) return (void *) dpdTheta; - - return NULL; -} - -/* ---------------------------------------------------------------------- - return # of bytes of allocated memory - call to avec tallies per-atom vectors - add in global to local mapping storage -------------------------------------------------------------------------- */ - -bigint Atom::memory_usage() -{ - memlength = DELTA_MEMSTR; - memory->create(memstr,memlength,"atom:memstr"); - memstr[0] = '\0'; - bigint bytes = avec->memory_usage(); - memory->destroy(memstr); - - bytes += max_same*sizeof(int); - if (map_style == 1 && map_tag_max >= 0) - bytes += memory->usage(map_array,map_maxarray); - else if (map_style == 2 && map_nhash >=0) { - bytes += map_nbucket*sizeof(int); - bytes += map_nhash*sizeof(HashElem); - } - if (maxnext) { - bytes += memory->usage(next,maxnext); - bytes += memory->usage(permute,maxnext); - } - - return bytes; -} - -/* ---------------------------------------------------------------------- - accumulate per-atom vec names in memstr, padded by spaces - return 1 if padded str is not already in memlist, else 0 -------------------------------------------------------------------------- */ - -int Atom::memcheck(const char *str) -{ - int n = strlen(str) + 3; - char *padded = new char[n]; - strcpy(padded," "); - strcat(padded,str); - strcat(padded," "); - - if (strstr(memstr,padded)) { - delete [] padded; - return 0; - } - - if (strlen(memstr) + n >= memlength) { - memlength += DELTA_MEMSTR; - memory->grow(memstr,memlength,"atom:memstr"); - } - - strcat(memstr,padded); - delete [] padded; - return 1; -} diff --git a/src/USER-HADRESS/atom.h b/src/USER-HADRESS/atom.h deleted file mode 100644 index 1675e7fe24..0000000000 --- a/src/USER-HADRESS/atom.h +++ /dev/null @@ -1,519 +0,0 @@ -/* -*- c++ -*- ---------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - http://lammps.sandia.gov, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - Copyright (2003) Sandia Corporation. Under the terms of Contract - DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains - certain rights in this software. This software is distributed under - the GNU General Public License. - - See the README file in the top-level LAMMPS directory. -------------------------------------------------------------------------- */ - -#ifndef LMP_ATOM_H -#define LMP_ATOM_H - -#include "pointers.h" - -namespace LAMMPS_NS { - -class Atom : protected Pointers { - public: - char *atom_style; - class AtomVec *avec; - - // atom counts - - bigint natoms; // total # of atoms in system, could be 0 - // natoms may not be current if atoms lost - int nlocal,nghost; // # of owned and ghost atoms on this proc - int nmax; // max # of owned+ghost in arrays on this proc - int tag_enable; // 0/1 if atom ID tags are defined - int molecular; // 0 = atomic, 1 = standard molecular system, - // 2 = molecule template system - - bigint nbonds,nangles,ndihedrals,nimpropers; - int ntypes,nbondtypes,nangletypes,ndihedraltypes,nimpropertypes; - int bond_per_atom,angle_per_atom,dihedral_per_atom,improper_per_atom; - int extra_bond_per_atom,extra_angle_per_atom; - int extra_dihedral_per_atom,extra_improper_per_atom; - - int firstgroup; // store atoms in this group first, -1 if unset - int nfirst; // # of atoms in first group on this proc - char *firstgroupname; // group-ID to store first, NULL if unset - - // per-atom arrays - // customize by adding new array - - tagint *tag; - int *type,*mask; - imageint *image; - double **x,**v,**f; - - tagint *molecule; - int *molindex,*molatom; - - double *q,**mu; - double *lambdaH,**gradlambdaH; - int *replambdaH; - int *moltypeH; - int nmoltypesH; - double **comH; - - double **omega,**angmom,**torque; - double *radius,*rmass; - int *ellipsoid,*line,*tri,*body; - - // PERI package - - double *vfrac,*s0; - double **x0; - - // USER-EFF and USER-AWPMD packages - - int *spin; - double *eradius,*ervel,*erforce,*ervelforce; - double *cs,*csforce,*vforce; - int *etag; - - // USER-SPH package - - double *rho,*drho,*e,*de,*cv; - double **vest; - - // USER-SMD package - - double *contact_radius; - double **smd_data_9; - double **smd_stress; - double *eff_plastic_strain; - double *eff_plastic_strain_rate; - double *damage; - - // USER-DPD package - - double *uCond, *uMech, *uChem, *uCGnew, *uCG; - double *duCond, *duMech, *duChem; - double *dpdTheta; - - // molecular info - - int **nspecial; // 0,1,2 = cummulative # of 1-2,1-3,1-4 neighs - tagint **special; // IDs of 1-2,1-3,1-4 neighs of each atom - int maxspecial; // special[nlocal][maxspecial] - - int *num_bond; - int **bond_type; - tagint **bond_atom; - - int *num_angle; - int **angle_type; - tagint **angle_atom1,**angle_atom2,**angle_atom3; - - int *num_dihedral; - int **dihedral_type; - tagint **dihedral_atom1,**dihedral_atom2,**dihedral_atom3,**dihedral_atom4; - - int *num_improper; - int **improper_type; - tagint **improper_atom1,**improper_atom2,**improper_atom3,**improper_atom4; - - // custom arrays used by fix property/atom - - int **ivector; - double **dvector; - char **iname,**dname; - int nivector,ndvector; - - // used by USER-CUDA to flag used per-atom arrays - - unsigned int datamask; - unsigned int datamask_ext; - - // atom style and per-atom array existence flags - // customize by adding new flag - - int sphere_flag,ellipsoid_flag,line_flag,tri_flag,body_flag; - int peri_flag,electron_flag; - int ecp_flag; - int wavepacket_flag,sph_flag; - - int molecule_flag,molindex_flag,molatom_flag; - int q_flag,mu_flag; - int replambdaH_flag, moltypeH_flag; - int rmass_flag,radius_flag,omega_flag,torque_flag,angmom_flag; - int vfrac_flag,spin_flag,eradius_flag,ervel_flag,erforce_flag; - int cs_flag,csforce_flag,vforce_flag,ervelforce_flag,etag_flag; - int rho_flag,e_flag,cv_flag,vest_flag; - int dpd_flag; - - // USER-SMD package - - int smd_flag; - int contact_radius_flag; - int smd_data_9_flag; - int smd_stress_flag; - int x0_flag; - int eff_plastic_strain_flag; - int eff_plastic_strain_rate_flag; - int damage_flag; - - // Peridynamics scale factor, used by dump cfg - - double pdscale; - - // molecule templates - // each template can be a set of consecutive molecules - // each with same ID (stored in molecules) - // 1st molecule in template stores nset = # in set - - int nmolecule; - class Molecule **molecules; - - // extra peratom info in restart file destined for fix & diag - - double **extra; - - // per-type arrays - - double *mass; - int *mass_setflag; - - // callback ptrs for atom arrays managed by fix classes - - int nextra_grow,nextra_restart,nextra_border; // # of callbacks of each type - int *extra_grow,*extra_restart,*extra_border; // index of fix to callback to - int nextra_grow_max,nextra_restart_max; // size of callback lists - int nextra_border_max; - int nextra_store; - - int map_style; // style of atom map: 0=none, 1=array, 2=hash - int map_user; // user selected style = same 0,1,2 - tagint map_tag_max; // max atom ID that map() is setup for - - // spatial sorting of atoms - - int sortfreq; // sort atoms every this many steps, 0 = off - bigint nextsort; // next timestep to sort on - double userbinsize; // requested sort bin size - - // indices of atoms with same ID - - int *sametag; // sametag[I] = next atom with same ID, -1 if no more - - // functions - - Atom(class LAMMPS *); - ~Atom(); - - void settings(class Atom *); - void create_avec(const char *, int, char **, int); - virtual class AtomVec *new_avec(const char *, int, int &); - void init(); - void setup(); - - class AtomVec *style_match(const char *); - void modify_params(int, char **); - void tag_check(); - void tag_extend(); - int tag_consecutive(); - - int parse_data(const char *); - int count_words(const char *); - int count_words(const char *, char *); - - void deallocate_topology(); - - void data_atoms(int, char *, tagint, int, int, double *); - void data_vels(int, char *, tagint); - - void data_bonds(int, char *, int *, tagint, int); - void data_angles(int, char *, int *, tagint, int); - void data_dihedrals(int, char *, int *, tagint, int); - void data_impropers(int, char *, int *, tagint, int); - - void data_bonus(int, char *, class AtomVec *, tagint); - void data_bodies(int, char *, class AtomVecBody *, tagint); - - virtual void allocate_type_arrays(); - void set_mass(const char *, int); - void set_mass(int, double); - void set_mass(int, char **); - void set_mass(double *); - void check_mass(); - - int radius_consistency(int, double &); - int shape_consistency(int, double &, double &, double &); - - void add_molecule(int, char **); - int find_molecule(char *); - void add_molecule_atom(class Molecule *, int, int, tagint); - - void first_reorder(); - virtual void sort(); - - void add_callback(int); - void delete_callback(const char *, int); - void update_callback(int); - - int find_custom(char *, int &); - int add_custom(char *, int); - void remove_custom(int, int); - - virtual void sync_modify(ExecutionSpace, unsigned int, unsigned int) {} - - void *extract(char *); - - inline int* get_map_array() {return map_array;}; - inline int get_map_size() {return map_tag_max+1;}; - - bigint memory_usage(); - int memcheck(const char *); - - // functions for global to local ID mapping - // map lookup function inlined for efficiency - // return -1 if no map defined - - inline int map(tagint global) { - if (map_style == 1) return map_array[global]; - else if (map_style == 2) return map_find_hash(global); - else return -1; - }; - - void map_init(int check = 1); - void map_clear(); - void map_set(); - void map_one(tagint, int); - int map_style_set(); - void map_delete(); - int map_find_hash(tagint); - - protected: - - // global to local ID mapping - - int *map_array; // direct map via array that holds map_tag_max - int map_maxarray; // allocated size of map_array (1 larger than this) - - struct HashElem { // hashed map - tagint global; // key to search on = global ID - int local; // value associated with key = local index - int next; // next entry in this bucket, -1 if last - }; - int map_nhash; // # of entries hash table can hold - int map_nused; // # of actual entries in hash table - int map_free; // ptr to 1st unused entry in hash table - int map_nbucket; // # of hash buckets - int *map_bucket; // ptr to 1st entry in each bucket - HashElem *map_hash; // hash table - - int max_same; // allocated size of sametag - - // spatial sorting of atoms - - int nbins; // # of sorting bins - int nbinx,nbiny,nbinz; // bins in each dimension - int maxbin; // max # of bins - int maxnext; // max size of next,permute - int *binhead; // 1st atom in each bin - int *next; // next atom in bin - int *permute; // permutation vector - double bininvx,bininvy,bininvz; // inverse actual bin sizes - double bboxlo[3],bboxhi[3]; // bounding box of my sub-domain - - int memlength; // allocated size of memstr - char *memstr; // string of array names already counted - - void setup_sort_bins(); - int next_prime(int); -}; - -} - -#endif - -/* ERROR/WARNING messages: - -E: Atom IDs must be used for molecular systems - -Atom IDs are used to identify and find partner atoms in bonds. - -E: Unknown atom style - -The choice of atom style is unknown. - -E: Could not find atom_modify first group ID - -Self-explanatory. - -E: Illegal ... command - -Self-explanatory. Check the input script syntax and compare to the -documentation for the command. You can use -echo screen as a -command-line option when running LAMMPS to see the offending line. - -E: Atom_modify id command after simulation box is defined - -The atom_modify id command cannot be used after a read_data, -read_restart, or create_box command. - -E: Atom_modify map command after simulation box is defined - -The atom_modify map command cannot be used after a read_data, -read_restart, or create_box command. - -E: Atom_modify sort and first options cannot be used together - -Self-explanatory. - -E: One or more Atom IDs is negative - -Atom IDs must be positive integers. - -E: One or more atom IDs is too big - -The limit on atom IDs is set by the SMALLBIG, BIGBIG, SMALLSMALL -setting in your Makefile. See Section_start 2.2 of the manual for -more details. - -E: One or more atom IDs is zero - -Either all atoms IDs must be zero or none of them. - -E: Non-zero atom IDs with atom_modify id = no - -Self-explanatory. - -E: All atom IDs = 0 but atom_modify id = yes - -Self-explanatory. - -E: Duplicate atom IDs exist - -Self-explanatory. - -E: New atom IDs exceed maximum allowed ID - -See the setting for tagint in the src/lmptype.h file. - -E: Incorrect atom format in data file - -Number of values per atom line in the data file is not consistent with -the atom style. - -E: Invalid atom type in Atoms section of data file - -Atom types must range from 1 to specified # of types. - -E: Incorrect velocity format in data file - -Each atom style defines a format for the Velocity section -of the data file. The read-in lines do not match. - -E: Invalid atom ID in Velocities section of data file - -Atom IDs must be positive integers and within range of defined -atoms. - -E: Invalid atom ID in Bonds section of data file - -Atom IDs must be positive integers and within range of defined -atoms. - -E: Invalid bond type in Bonds section of data file - -Bond type must be positive integer and within range of specified bond -types. - -E: Invalid atom ID in Angles section of data file - -Atom IDs must be positive integers and within range of defined -atoms. - -E: Invalid angle type in Angles section of data file - -Angle type must be positive integer and within range of specified angle -types. - -E: Invalid atom ID in Dihedrals section of data file - -Atom IDs must be positive integers and within range of defined -atoms. - -E: Invalid dihedral type in Dihedrals section of data file - -Dihedral type must be positive integer and within range of specified -dihedral types. - -E: Invalid atom ID in Impropers section of data file - -Atom IDs must be positive integers and within range of defined -atoms. - -E: Invalid improper type in Impropers section of data file - -Improper type must be positive integer and within range of specified -improper types. - -E: Incorrect bonus data format in data file - -See the read_data doc page for a description of how various kinds of -bonus data must be formatted for certain atom styles. - -E: Invalid atom ID in Bonus section of data file - -Atom IDs must be positive integers and within range of defined -atoms. - -E: Invalid atom ID in Bodies section of data file - -Atom IDs must be positive integers and within range of defined -atoms. - -E: Cannot set mass for this atom style - -This atom style does not support mass settings for each atom type. -Instead they are defined on a per-atom basis in the data file. - -E: Invalid mass line in data file - -Self-explanatory. - -E: Invalid type for mass set - -Mass command must set a type from 1-N where N is the number of atom -types. - -E: Invalid mass value - -Self-explanatory. - -E: All masses are not set - -For atom styles that define masses for each atom type, all masses must -be set in the data file or by the mass command before running a -simulation. They must also be set before using the velocity -command. - -E: Reuse of molecule template ID - -The template IDs must be unique. - -E: Atom sort did not operate correctly - -This is an internal LAMMPS error. Please report it to the -developers. - -E: Atom sorting has bin size = 0.0 - -The neighbor cutoff is being used as the bin size, but it is zero. -Thus you must explicitly list a bin size in the atom_modify sort -command or turn off sorting. - -E: Too many atom sorting bins - -This is likely due to an immense simulation box that has blown up -to a large size. - -*/ diff --git a/src/USER-HADRESS/atom_vec_full_hars.cpp b/src/USER-HADRESS/atom_vec_full_hars.cpp deleted file mode 100644 index fe01c0fa98..0000000000 --- a/src/USER-HADRESS/atom_vec_full_hars.cpp +++ /dev/null @@ -1,1352 +0,0 @@ -/* ---------------------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - http://lammps.sandia.gov, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - Copyright (2003) Sandia Corporation. Under the terms of Contract - DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains - certain rights in this software. This software is distributed under - the GNU General Public License. - - See the README file in the top-level LAMMPS directory. -------------------------------------------------------------------------- */ - -#include "stdlib.h" -#include "atom_vec_full_hars.h" -#include "atom.h" -#include "comm.h" -#include "domain.h" -#include "modify.h" -#include "fix.h" -#include "memory.h" -#include "error.h" - -using namespace LAMMPS_NS; - -/* ---------------------------------------------------------------------- */ - -AtomVecFullHars::AtomVecFullHars(LAMMPS *lmp) : AtomVec(lmp) -{ - molecular = 1; - bonds_allow = angles_allow = dihedrals_allow = impropers_allow = 1; - mass_type = 1; - - comm_x_only = comm_f_only = 0; - size_forward = 10; - size_reverse = 3; - size_border = 17; - size_velocity = 3; - size_data_atom = 9; - size_data_vel = 4; - xcol_data = 7; - - atom->molecule_flag = atom->q_flag = 1; - atom->replambdaH_flag = 1; - atom->moltypeH_flag = 1; - -} - -/* ---------------------------------------------------------------------- - grow atom arrays - n = 0 grows arrays by a chunk - n > 0 allocates arrays to size n -------------------------------------------------------------------------- */ - -void AtomVecFullHars::grow(int n) -{ - if (n == 0) grow_nmax(); - else nmax = n; - atom->nmax = nmax; - if (nmax < 0 || nmax > MAXSMALLINT) - error->one(FLERR,"Per-processor system is too big"); - - tag = memory->grow(atom->tag,nmax,"atom:tag"); - type = memory->grow(atom->type,nmax,"atom:type"); - mask = memory->grow(atom->mask,nmax,"atom:mask"); - image = memory->grow(atom->image,nmax,"atom:image"); - x = memory->grow(atom->x,nmax,3,"atom:x"); - v = memory->grow(atom->v,nmax,3,"atom:v"); - f = memory->grow(atom->f,nmax*comm->nthreads,3,"atom:f"); - - q = memory->grow(atom->q,nmax,"atom:q"); - lambdaH = memory->grow(atom->lambdaH,nmax,"atom:lambdaH"); - gradlambdaH = memory->grow(atom->gradlambdaH,nmax,3,"atom:gradlambdaH"); - replambdaH = memory->grow(atom->replambdaH,nmax,"atom:replambdaH"); - moltypeH = memory->grow(atom->moltypeH,nmax,"atom:moltypeH"); - comH = memory->grow(atom->comH,nmax,3,"atom:comH"); - - molecule = memory->grow(atom->molecule,nmax,"atom:molecule"); - - nspecial = memory->grow(atom->nspecial,nmax,3,"atom:nspecial"); - special = memory->grow(atom->special,nmax,atom->maxspecial,"atom:special"); - - num_bond = memory->grow(atom->num_bond,nmax,"atom:num_bond"); - bond_type = memory->grow(atom->bond_type,nmax,atom->bond_per_atom, - "atom:bond_type"); - bond_atom = memory->grow(atom->bond_atom,nmax,atom->bond_per_atom, - "atom:bond_atom"); - - num_angle = memory->grow(atom->num_angle,nmax,"atom:num_angle"); - angle_type = memory->grow(atom->angle_type,nmax,atom->angle_per_atom, - "atom:angle_type"); - angle_atom1 = memory->grow(atom->angle_atom1,nmax,atom->angle_per_atom, - "atom:angle_atom1"); - angle_atom2 = memory->grow(atom->angle_atom2,nmax,atom->angle_per_atom, - "atom:angle_atom2"); - angle_atom3 = memory->grow(atom->angle_atom3,nmax,atom->angle_per_atom, - "atom:angle_atom3"); - - num_dihedral = memory->grow(atom->num_dihedral,nmax,"atom:num_dihedral"); - dihedral_type = memory->grow(atom->dihedral_type,nmax, - atom->dihedral_per_atom,"atom:dihedral_type"); - dihedral_atom1 = - memory->grow(atom->dihedral_atom1,nmax,atom->dihedral_per_atom, - "atom:dihedral_atom1"); - dihedral_atom2 = - memory->grow(atom->dihedral_atom2,nmax,atom->dihedral_per_atom, - "atom:dihedral_atom2"); - dihedral_atom3 = - memory->grow(atom->dihedral_atom3,nmax,atom->dihedral_per_atom, - "atom:dihedral_atom3"); - dihedral_atom4 = - memory->grow(atom->dihedral_atom4,nmax,atom->dihedral_per_atom, - "atom:dihedral_atom4"); - - num_improper = memory->grow(atom->num_improper,nmax,"atom:num_improper"); - improper_type = - memory->grow(atom->improper_type,nmax,atom->improper_per_atom, - "atom:improper_type"); - improper_atom1 = - memory->grow(atom->improper_atom1,nmax,atom->improper_per_atom, - "atom:improper_atom1"); - improper_atom2 = - memory->grow(atom->improper_atom2,nmax,atom->improper_per_atom, - "atom:improper_atom2"); - improper_atom3 = - memory->grow(atom->improper_atom3,nmax,atom->improper_per_atom, - "atom:improper_atom3"); - improper_atom4 = - memory->grow(atom->improper_atom4,nmax,atom->improper_per_atom, - "atom:improper_atom4"); - - if (atom->nextra_grow) - for (int iextra = 0; iextra < atom->nextra_grow; iextra++) - modify->fix[atom->extra_grow[iextra]]->grow_arrays(nmax); -} - -/* ---------------------------------------------------------------------- - reset local array ptrs -------------------------------------------------------------------------- */ - -void AtomVecFullHars::grow_reset() -{ - tag = atom->tag; type = atom->type; - mask = atom->mask; image = atom->image; - x = atom->x; v = atom->v; f = atom->f; comH = atom->comH; - q = atom->q; lambdaH = atom->lambdaH;gradlambdaH = atom->gradlambdaH; - replambdaH = atom->replambdaH;moltypeH = atom->moltypeH;molecule = atom->molecule; - nspecial = atom->nspecial; special = atom->special; - num_bond = atom->num_bond; bond_type = atom->bond_type; - bond_atom = atom->bond_atom; - num_angle = atom->num_angle; angle_type = atom->angle_type; - angle_atom1 = atom->angle_atom1; angle_atom2 = atom->angle_atom2; - angle_atom3 = atom->angle_atom3; - num_dihedral = atom->num_dihedral; dihedral_type = atom->dihedral_type; - dihedral_atom1 = atom->dihedral_atom1; dihedral_atom2 = atom->dihedral_atom2; - dihedral_atom3 = atom->dihedral_atom3; dihedral_atom4 = atom->dihedral_atom4; - num_improper = atom->num_improper; improper_type = atom->improper_type; - improper_atom1 = atom->improper_atom1; improper_atom2 = atom->improper_atom2; - improper_atom3 = atom->improper_atom3; improper_atom4 = atom->improper_atom4; -} - -/* ---------------------------------------------------------------------- - copy atom I info to atom J -------------------------------------------------------------------------- */ - -void AtomVecFullHars::copy(int i, int j, int delflag) -{ - int k; - - tag[j] = tag[i]; - type[j] = type[i]; - mask[j] = mask[i]; - image[j] = image[i]; - x[j][0] = x[i][0]; - x[j][1] = x[i][1]; - x[j][2] = x[i][2]; - v[j][0] = v[i][0]; - v[j][1] = v[i][1]; - v[j][2] = v[i][2]; - - comH[j][0] = comH[i][0]; - comH[j][1] = comH[i][1]; - comH[j][2] = comH[i][2]; - - q[j] = q[i]; - lambdaH[j] = lambdaH[i]; - gradlambdaH[j][0] = gradlambdaH[i][0]; - gradlambdaH[j][1] = gradlambdaH[i][1]; - gradlambdaH[j][2] = gradlambdaH[i][2]; - replambdaH[j] = replambdaH[i]; - moltypeH[j] = moltypeH[i]; - molecule[j] = molecule[i]; - - - num_bond[j] = num_bond[i]; - for (k = 0; k < num_bond[j]; k++) { - bond_type[j][k] = bond_type[i][k]; - bond_atom[j][k] = bond_atom[i][k]; - } - - num_angle[j] = num_angle[i]; - for (k = 0; k < num_angle[j]; k++) { - angle_type[j][k] = angle_type[i][k]; - angle_atom1[j][k] = angle_atom1[i][k]; - angle_atom2[j][k] = angle_atom2[i][k]; - angle_atom3[j][k] = angle_atom3[i][k]; - } - - num_dihedral[j] = num_dihedral[i]; - for (k = 0; k < num_dihedral[j]; k++) { - dihedral_type[j][k] = dihedral_type[i][k]; - dihedral_atom1[j][k] = dihedral_atom1[i][k]; - dihedral_atom2[j][k] = dihedral_atom2[i][k]; - dihedral_atom3[j][k] = dihedral_atom3[i][k]; - dihedral_atom4[j][k] = dihedral_atom4[i][k]; - } - - num_improper[j] = num_improper[i]; - for (k = 0; k < num_improper[j]; k++) { - improper_type[j][k] = improper_type[i][k]; - improper_atom1[j][k] = improper_atom1[i][k]; - improper_atom2[j][k] = improper_atom2[i][k]; - improper_atom3[j][k] = improper_atom3[i][k]; - improper_atom4[j][k] = improper_atom4[i][k]; - } - - nspecial[j][0] = nspecial[i][0]; - nspecial[j][1] = nspecial[i][1]; - nspecial[j][2] = nspecial[i][2]; - for (k = 0; k < nspecial[j][2]; k++) special[j][k] = special[i][k]; - - if (atom->nextra_grow) - for (int iextra = 0; iextra < atom->nextra_grow; iextra++) - modify->fix[atom->extra_grow[iextra]]->copy_arrays(i,j,delflag); -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecFullHars::pack_comm(int n, int *list, double *buf, - int pbc_flag, int *pbc) -{ - int i,j,m; - double dx,dy,dz; - - m = 0; - if (pbc_flag == 0) { - for (i = 0; i < n; i++) { - j = list[i]; - buf[m++] = x[j][0]; - buf[m++] = x[j][1]; - buf[m++] = x[j][2]; - buf[m++] = lambdaH[j]; - buf[m++] = gradlambdaH[j][0]; - buf[m++] = gradlambdaH[j][1]; - buf[m++] = gradlambdaH[j][2]; - buf[m++] = comH[j][0]; - buf[m++] = comH[j][1]; - buf[m++] = comH[j][2]; - - } - } else { - if (domain->triclinic == 0) { - dx = pbc[0]*domain->xprd; - dy = pbc[1]*domain->yprd; - dz = pbc[2]*domain->zprd; - } else { - dx = pbc[0]*domain->xprd + pbc[5]*domain->xy + pbc[4]*domain->xz; - dy = pbc[1]*domain->yprd + pbc[3]*domain->yz; - dz = pbc[2]*domain->zprd; - } - for (i = 0; i < n; i++) { - j = list[i]; - buf[m++] = x[j][0] + dx; - buf[m++] = x[j][1] + dy; - buf[m++] = x[j][2] + dz; - buf[m++] = lambdaH[j]; - buf[m++] = gradlambdaH[j][0]; - buf[m++] = gradlambdaH[j][1]; - buf[m++] = gradlambdaH[j][2]; - buf[m++] = comH[j][0]; - buf[m++] = comH[j][1]; - buf[m++] = comH[j][2]; - - - } - } - return m; -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecFullHars::pack_comm_vel(int n, int *list, double *buf, - int pbc_flag, int *pbc) -{ - int i,j,m; - double dx,dy,dz,dvx,dvy,dvz; - - m = 0; - if (pbc_flag == 0) { - for (i = 0; i < n; i++) { - j = list[i]; - buf[m++] = x[j][0]; - buf[m++] = x[j][1]; - buf[m++] = x[j][2]; - buf[m++] = lambdaH[j]; - buf[m++] = gradlambdaH[j][0]; - buf[m++] = gradlambdaH[j][1]; - buf[m++] = gradlambdaH[j][2]; - buf[m++] = comH[j][0]; - buf[m++] = comH[j][1]; - buf[m++] = comH[j][2]; - - buf[m++] = v[j][0]; - buf[m++] = v[j][1]; - buf[m++] = v[j][2]; - - } - } else { - if (domain->triclinic == 0) { - dx = pbc[0]*domain->xprd; - dy = pbc[1]*domain->yprd; - dz = pbc[2]*domain->zprd; - } else { - dx = pbc[0]*domain->xprd + pbc[5]*domain->xy + pbc[4]*domain->xz; - dy = pbc[1]*domain->yprd + pbc[3]*domain->yz; - dz = pbc[2]*domain->zprd; - } - if (!deform_vremap) { - for (i = 0; i < n; i++) { - j = list[i]; - buf[m++] = x[j][0] + dx; - buf[m++] = x[j][1] + dy; - buf[m++] = x[j][2] + dz; - buf[m++] = lambdaH[j]; - buf[m++] = gradlambdaH[j][0]; - buf[m++] = gradlambdaH[j][1]; - buf[m++] = gradlambdaH[j][2]; - buf[m++] = comH[j][0]; - buf[m++] = comH[j][1]; - buf[m++] = comH[j][2]; - - buf[m++] = v[j][0]; - buf[m++] = v[j][1]; - buf[m++] = v[j][2]; - } - } else { - dvx = pbc[0]*h_rate[0] + pbc[5]*h_rate[5] + pbc[4]*h_rate[4]; - dvy = pbc[1]*h_rate[1] + pbc[3]*h_rate[3]; - dvz = pbc[2]*h_rate[2]; - for (i = 0; i < n; i++) { - j = list[i]; - buf[m++] = x[j][0] + dx; - buf[m++] = x[j][1] + dy; - buf[m++] = x[j][2] + dz; - buf[m++] = lambdaH[j]; - buf[m++] = gradlambdaH[j][0]; - buf[m++] = gradlambdaH[j][1]; - buf[m++] = gradlambdaH[j][2]; - buf[m++] = comH[j][0]; - buf[m++] = comH[j][1]; - buf[m++] = comH[j][2]; - - - - if (mask[i] & deform_groupbit) { - buf[m++] = v[j][0] + dvx; - buf[m++] = v[j][1] + dvy; - buf[m++] = v[j][2] + dvz; - } else { - buf[m++] = v[j][0]; - buf[m++] = v[j][1]; - buf[m++] = v[j][2]; - } - } - } - } - return m; -} - -/* ---------------------------------------------------------------------- */ - -void AtomVecFullHars::unpack_comm(int n, int first, double *buf) -{ - int i,m,last; - - m = 0; - last = first + n; - for (i = first; i < last; i++) { - x[i][0] = buf[m++]; - x[i][1] = buf[m++]; - x[i][2] = buf[m++]; - lambdaH[i] = buf[m++]; - gradlambdaH[i][0] = buf[m++]; - gradlambdaH[i][1] = buf[m++]; - gradlambdaH[i][2] = buf[m++]; - comH[i][0] = buf[m++]; - comH[i][1] = buf[m++]; - comH[i][2] = buf[m++]; - - - - } -} - -/* ---------------------------------------------------------------------- */ - -void AtomVecFullHars::unpack_comm_vel(int n, int first, double *buf) -{ - int i,m,last; - - m = 0; - last = first + n; - for (i = first; i < last; i++) { - x[i][0] = buf[m++]; - x[i][1] = buf[m++]; - x[i][2] = buf[m++]; - lambdaH[i] = buf[m++]; - gradlambdaH[i][0] = buf[m++]; - gradlambdaH[i][1] = buf[m++]; - gradlambdaH[i][2] = buf[m++]; - comH[i][0] = buf[m++]; - comH[i][1] = buf[m++]; - comH[i][2] = buf[m++]; - - v[i][0] = buf[m++]; - v[i][1] = buf[m++]; - v[i][2] = buf[m++]; - } -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecFullHars::pack_reverse(int n, int first, double *buf) -{ - int i,m,last; - - m = 0; - last = first + n; - for (i = first; i < last; i++) { - buf[m++] = f[i][0]; - buf[m++] = f[i][1]; - buf[m++] = f[i][2]; - - } - return m; -} - -/* ---------------------------------------------------------------------- */ - -void AtomVecFullHars::unpack_reverse(int n, int *list, double *buf) -{ - int i,j,m; - - m = 0; - for (i = 0; i < n; i++) { - j = list[i]; - f[j][0] += buf[m++]; - f[j][1] += buf[m++]; - f[j][2] += buf[m++]; - - - } -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecFullHars::pack_border(int n, int *list, double *buf, - int pbc_flag, int *pbc) -{ - int i,j,m; - double dx,dy,dz; - - m = 0; - if (pbc_flag == 0) { - for (i = 0; i < n; i++) { - j = list[i]; - buf[m++] = x[j][0]; - buf[m++] = x[j][1]; - buf[m++] = x[j][2]; - buf[m++] = ubuf(tag[j]).d; - buf[m++] = ubuf(type[j]).d; - buf[m++] = ubuf(mask[j]).d; - buf[m++] = q[j]; - buf[m++] = lambdaH[j]; - buf[m++] = gradlambdaH[j][0]; - buf[m++] = gradlambdaH[j][1]; - buf[m++] = gradlambdaH[j][2]; - buf[m++] = comH[j][0]; - buf[m++] = comH[j][1]; - buf[m++] = comH[j][2]; - - buf[m++] = ubuf(replambdaH[j]).d; - buf[m++] = ubuf(moltypeH[j]).d; - - buf[m++] = ubuf(molecule[j]).d; - } - } else { - if (domain->triclinic == 0) { - dx = pbc[0]*domain->xprd; - dy = pbc[1]*domain->yprd; - dz = pbc[2]*domain->zprd; - } else { - dx = pbc[0]; - dy = pbc[1]; - dz = pbc[2]; - } - for (i = 0; i < n; i++) { - j = list[i]; - buf[m++] = x[j][0] + dx; - buf[m++] = x[j][1] + dy; - buf[m++] = x[j][2] + dz; - buf[m++] = ubuf(tag[j]).d; - buf[m++] = ubuf(type[j]).d; - buf[m++] = ubuf(mask[j]).d; - buf[m++] = q[j]; - buf[m++] = lambdaH[j]; - buf[m++] = gradlambdaH[j][0]; - buf[m++] = gradlambdaH[j][1]; - buf[m++] = gradlambdaH[j][2]; - buf[m++] = comH[j][0]; - buf[m++] = comH[j][1]; - buf[m++] = comH[j][2]; - - buf[m++] = ubuf(replambdaH[j]).d; - buf[m++] = ubuf(moltypeH[j]).d; - - buf[m++] = ubuf(molecule[j]).d; - } - } - - if (atom->nextra_border) - for (int iextra = 0; iextra < atom->nextra_border; iextra++) - m += modify->fix[atom->extra_border[iextra]]->pack_border(n,list,&buf[m]); - - return m; -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecFullHars::pack_border_vel(int n, int *list, double *buf, - int pbc_flag, int *pbc) -{ - int i,j,m; - double dx,dy,dz,dvx,dvy,dvz; - - m = 0; - if (pbc_flag == 0) { - for (i = 0; i < n; i++) { - j = list[i]; - buf[m++] = x[j][0]; - buf[m++] = x[j][1]; - buf[m++] = x[j][2]; - buf[m++] = ubuf(tag[j]).d; - buf[m++] = ubuf(type[j]).d; - buf[m++] = ubuf(mask[j]).d; - buf[m++] = q[j]; - buf[m++] = lambdaH[j]; - buf[m++] = gradlambdaH[j][0]; - buf[m++] = gradlambdaH[j][1]; - buf[m++] = gradlambdaH[j][2]; - buf[m++] = comH[j][0]; - buf[m++] = comH[j][1]; - buf[m++] = comH[j][2]; - - buf[m++] = ubuf(replambdaH[j]).d; - buf[m++] = ubuf(moltypeH[j]).d; - - buf[m++] = ubuf(molecule[j]).d; - buf[m++] = v[j][0]; - buf[m++] = v[j][1]; - buf[m++] = v[j][2]; - } - } else { - if (domain->triclinic == 0) { - dx = pbc[0]*domain->xprd; - dy = pbc[1]*domain->yprd; - dz = pbc[2]*domain->zprd; - } else { - dx = pbc[0]; - dy = pbc[1]; - dz = pbc[2]; - } - if (!deform_vremap) { - for (i = 0; i < n; i++) { - j = list[i]; - buf[m++] = x[j][0] + dx; - buf[m++] = x[j][1] + dy; - buf[m++] = x[j][2] + dz; - buf[m++] = ubuf(tag[j]).d; - buf[m++] = ubuf(type[j]).d; - buf[m++] = ubuf(mask[j]).d; - buf[m++] = q[j]; - buf[m++] = lambdaH[j]; - buf[m++] = gradlambdaH[j][0]; - buf[m++] = gradlambdaH[j][1]; - buf[m++] = gradlambdaH[j][2]; - buf[m++] = comH[j][0]; - buf[m++] = comH[j][1]; - buf[m++] = comH[j][2]; - - buf[m++] = ubuf(replambdaH[j]).d; - buf[m++] = ubuf(moltypeH[j]).d; - - buf[m++] = ubuf(molecule[j]).d; - buf[m++] = v[j][0]; - buf[m++] = v[j][1]; - buf[m++] = v[j][2]; - } - } else { - dvx = pbc[0]*h_rate[0] + pbc[5]*h_rate[5] + pbc[4]*h_rate[4]; - dvy = pbc[1]*h_rate[1] + pbc[3]*h_rate[3]; - dvz = pbc[2]*h_rate[2]; - for (i = 0; i < n; i++) { - j = list[i]; - buf[m++] = x[j][0] + dx; - buf[m++] = x[j][1] + dy; - buf[m++] = x[j][2] + dz; - buf[m++] = ubuf(tag[j]).d; - buf[m++] = ubuf(type[j]).d; - buf[m++] = ubuf(mask[j]).d; - buf[m++] = q[j]; - buf[m++] = lambdaH[j]; - buf[m++] = gradlambdaH[j][0]; - buf[m++] = gradlambdaH[j][1]; - buf[m++] = gradlambdaH[j][2]; - buf[m++] = comH[j][0]; - buf[m++] = comH[j][1]; - buf[m++] = comH[j][2]; - - buf[m++] = ubuf(replambdaH[j]).d; - buf[m++] = ubuf(moltypeH[j]).d; - - buf[m++] = ubuf(molecule[j]).d; - if (mask[i] & deform_groupbit) { - buf[m++] = v[j][0] + dvx; - buf[m++] = v[j][1] + dvy; - buf[m++] = v[j][2] + dvz; - } else { - buf[m++] = v[j][0]; - buf[m++] = v[j][1]; - buf[m++] = v[j][2]; - } - } - } - } - - if (atom->nextra_border) - for (int iextra = 0; iextra < atom->nextra_border; iextra++) - m += modify->fix[atom->extra_border[iextra]]->pack_border(n,list,&buf[m]); - - return m; -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecFullHars::pack_border_hybrid(int n, int *list, double *buf) -{ - int i,j,m; - - m = 0; - for (i = 0; i < n; i++) { - j = list[i]; - buf[m++] = q[j]; - buf[m++] = ubuf(replambdaH[j]).d; - buf[m++] = ubuf(moltypeH[j]).d; - buf[m++] = ubuf(molecule[j]).d; - } - return m; -} - -/* ---------------------------------------------------------------------- */ - -void AtomVecFullHars::unpack_border(int n, int first, double *buf) -{ - int i,m,last; - - m = 0; - last = first + n; - for (i = first; i < last; i++) { - if (i == nmax) grow(0); - x[i][0] = buf[m++]; - x[i][1] = buf[m++]; - x[i][2] = buf[m++]; - tag[i] = (tagint) ubuf(buf[m++]).i; - type[i] = (int) ubuf(buf[m++]).i; - mask[i] = (int) ubuf(buf[m++]).i; - q[i] = buf[m++]; - lambdaH[i] = buf[m++]; - gradlambdaH[i][0] = buf[m++]; - gradlambdaH[i][1] = buf[m++]; - gradlambdaH[i][2] = buf[m++]; - comH[i][0] = buf[m++]; - comH[i][1] = buf[m++]; - comH[i][2] = buf[m++]; - - replambdaH[i] = (int) ubuf(buf[m++]).i; - moltypeH[i] = (int) ubuf(buf[m++]).i; - - molecule[i] = (tagint) ubuf(buf[m++]).i; - - } - - if (atom->nextra_border) - for (int iextra = 0; iextra < atom->nextra_border; iextra++) - m += modify->fix[atom->extra_border[iextra]]-> - unpack_border(n,first,&buf[m]); -} - -/* ---------------------------------------------------------------------- */ - -void AtomVecFullHars::unpack_border_vel(int n, int first, double *buf) -{ - int i,m,last; - - m = 0; - last = first + n; - for (i = first; i < last; i++) { - if (i == nmax) grow(0); - x[i][0] = buf[m++]; - x[i][1] = buf[m++]; - x[i][2] = buf[m++]; - tag[i] = (tagint) ubuf(buf[m++]).i; - type[i] = (int) ubuf(buf[m++]).i; - mask[i] = (int) ubuf(buf[m++]).i; - q[i] = buf[m++]; - lambdaH[i] = buf[m++]; - gradlambdaH[i][0] = buf[m++]; - gradlambdaH[i][1] = buf[m++]; - gradlambdaH[i][2] = buf[m++]; - comH[i][0] = buf[m++]; - comH[i][1] = buf[m++]; - comH[i][2] = buf[m++]; - - replambdaH[i] = (int) ubuf(buf[m++]).i; - moltypeH[i] = (int) ubuf(buf[m++]).i; - - molecule[i] = (tagint) ubuf(buf[m++]).i; - v[i][0] = buf[m++]; - v[i][1] = buf[m++]; - v[i][2] = buf[m++]; - } - - if (atom->nextra_border) - for (int iextra = 0; iextra < atom->nextra_border; iextra++) - m += modify->fix[atom->extra_border[iextra]]-> - unpack_border(n,first,&buf[m]); -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecFullHars::unpack_border_hybrid(int n, int first, double *buf) -{ - int i,m,last; - - m = 0; - last = first + n; - for (i = first; i < last; i++) { - q[i] = buf[m++]; - replambdaH[i] = (int) ubuf(buf[m++]).i; - moltypeH[i] = (int) ubuf(buf[m++]).i; - molecule[i] = (tagint) ubuf(buf[m++]).i; - } - return m; -} - -/* ---------------------------------------------------------------------- - pack data for atom I for sending to another proc - xyz must be 1st 3 values, so comm::exchange() can test on them -------------------------------------------------------------------------- */ - -int AtomVecFullHars::pack_exchange(int i, double *buf) -{ - int k; - - int m = 1; - buf[m++] = x[i][0]; - buf[m++] = x[i][1]; - buf[m++] = x[i][2]; - buf[m++] = v[i][0]; - buf[m++] = v[i][1]; - buf[m++] = v[i][2]; - buf[m++] = ubuf(tag[i]).d; - buf[m++] = ubuf(type[i]).d; - buf[m++] = ubuf(mask[i]).d; - buf[m++] = ubuf(image[i]).d; - - buf[m++] = q[i]; - buf[m++] = lambdaH[i]; - buf[m++] = gradlambdaH[i][0]; - buf[m++] = gradlambdaH[i][1]; - buf[m++] = gradlambdaH[i][2]; - buf[m++] = comH[i][0]; - buf[m++] = comH[i][1]; - buf[m++] = comH[i][2]; - - buf[m++] = ubuf(replambdaH[i]).d; - buf[m++] = ubuf(moltypeH[i]).d; - - buf[m++] = ubuf(molecule[i]).d; - - buf[m++] = ubuf(num_bond[i]).d; - for (k = 0; k < num_bond[i]; k++) { - buf[m++] = ubuf(bond_type[i][k]).d; - buf[m++] = ubuf(bond_atom[i][k]).d; - } - - buf[m++] = ubuf(num_angle[i]).d; - for (k = 0; k < num_angle[i]; k++) { - buf[m++] = ubuf(angle_type[i][k]).d; - buf[m++] = ubuf(angle_atom1[i][k]).d; - buf[m++] = ubuf(angle_atom2[i][k]).d; - buf[m++] = ubuf(angle_atom3[i][k]).d; - } - - buf[m++] = ubuf(num_dihedral[i]).d; - for (k = 0; k < num_dihedral[i]; k++) { - buf[m++] = ubuf(dihedral_type[i][k]).d; - buf[m++] = ubuf(dihedral_atom1[i][k]).d; - buf[m++] = ubuf(dihedral_atom2[i][k]).d; - buf[m++] = ubuf(dihedral_atom3[i][k]).d; - buf[m++] = ubuf(dihedral_atom4[i][k]).d; - } - - buf[m++] = ubuf(num_improper[i]).d; - for (k = 0; k < num_improper[i]; k++) { - buf[m++] = ubuf(improper_type[i][k]).d; - buf[m++] = ubuf(improper_atom1[i][k]).d; - buf[m++] = ubuf(improper_atom2[i][k]).d; - buf[m++] = ubuf(improper_atom3[i][k]).d; - buf[m++] = ubuf(improper_atom4[i][k]).d; - } - - buf[m++] = ubuf(nspecial[i][0]).d; - buf[m++] = ubuf(nspecial[i][1]).d; - buf[m++] = ubuf(nspecial[i][2]).d; - for (k = 0; k < nspecial[i][2]; k++) buf[m++] = ubuf(special[i][k]).d; - - if (atom->nextra_grow) - for (int iextra = 0; iextra < atom->nextra_grow; iextra++) - m += modify->fix[atom->extra_grow[iextra]]->pack_exchange(i,&buf[m]); - - buf[0] = m; - return m; -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecFullHars::unpack_exchange(double *buf) -{ - int k; - - int nlocal = atom->nlocal; - if (nlocal == nmax) grow(0); - - int m = 1; - x[nlocal][0] = buf[m++]; - x[nlocal][1] = buf[m++]; - x[nlocal][2] = buf[m++]; - v[nlocal][0] = buf[m++]; - v[nlocal][1] = buf[m++]; - v[nlocal][2] = buf[m++]; - tag[nlocal] = (tagint) ubuf(buf[m++]).i; - type[nlocal] = (int) ubuf(buf[m++]).i; - mask[nlocal] = (int) ubuf(buf[m++]).i; - image[nlocal] = (imageint) ubuf(buf[m++]).i; - - q[nlocal] = buf[m++]; - lambdaH[nlocal] = buf[m++]; - gradlambdaH[nlocal][0] = buf[m++]; - gradlambdaH[nlocal][1] = buf[m++]; - gradlambdaH[nlocal][2] = buf[m++]; - comH[nlocal][0] = buf[m++]; - comH[nlocal][1] = buf[m++]; - comH[nlocal][2] = buf[m++]; - - replambdaH[nlocal] = (int) ubuf(buf[m++]).i; - moltypeH[nlocal] = (int) ubuf(buf[m++]).i; - - molecule[nlocal] = (tagint) ubuf(buf[m++]).i; - - num_bond[nlocal] = (int) ubuf(buf[m++]).i; - for (k = 0; k < num_bond[nlocal]; k++) { - bond_type[nlocal][k] = (int) ubuf(buf[m++]).i; - bond_atom[nlocal][k] = (tagint) ubuf(buf[m++]).i; - } - - num_angle[nlocal] = (int) ubuf(buf[m++]).i; - for (k = 0; k < num_angle[nlocal]; k++) { - angle_type[nlocal][k] = (int) ubuf(buf[m++]).i; - angle_atom1[nlocal][k] = (tagint) ubuf(buf[m++]).i; - angle_atom2[nlocal][k] = (tagint) ubuf(buf[m++]).i; - angle_atom3[nlocal][k] = (tagint) ubuf(buf[m++]).i; - } - - num_dihedral[nlocal] = (int) ubuf(buf[m++]).i; - for (k = 0; k < num_dihedral[nlocal]; k++) { - dihedral_type[nlocal][k] = (int) ubuf(buf[m++]).i; - dihedral_atom1[nlocal][k] = (tagint) ubuf(buf[m++]).i; - dihedral_atom2[nlocal][k] = (tagint) ubuf(buf[m++]).i; - dihedral_atom3[nlocal][k] = (tagint) ubuf(buf[m++]).i; - dihedral_atom4[nlocal][k] = (tagint) ubuf(buf[m++]).i; - } - - num_improper[nlocal] = (int) ubuf(buf[m++]).i; - for (k = 0; k < num_improper[nlocal]; k++) { - improper_type[nlocal][k] = (int) ubuf(buf[m++]).i; - improper_atom1[nlocal][k] = (tagint) ubuf(buf[m++]).i; - improper_atom2[nlocal][k] = (tagint) ubuf(buf[m++]).i; - improper_atom3[nlocal][k] = (tagint) ubuf(buf[m++]).i; - improper_atom4[nlocal][k] = (tagint) ubuf(buf[m++]).i; - } - - nspecial[nlocal][0] = (int) ubuf(buf[m++]).i; - nspecial[nlocal][1] = (int) ubuf(buf[m++]).i; - nspecial[nlocal][2] = (int) ubuf(buf[m++]).i; - for (k = 0; k < nspecial[nlocal][2]; k++) - special[nlocal][k] = (tagint) ubuf(buf[m++]).i; - - if (atom->nextra_grow) - for (int iextra = 0; iextra < atom->nextra_grow; iextra++) - m += modify->fix[atom->extra_grow[iextra]]-> - unpack_exchange(nlocal,&buf[m]); - - atom->nlocal++; - return m; -} - -/* ---------------------------------------------------------------------- - size of restart data for all atoms owned by this proc - include extra data stored by fixes -------------------------------------------------------------------------- */ - -int AtomVecFullHars::size_restart() -{ - int i; - - int nlocal = atom->nlocal; - int n = 0; - for (i = 0; i < nlocal; i++) - n += 17 + 2*num_bond[i] + 4*num_angle[i] + - 5*num_dihedral[i] + 5*num_improper[i]+9; - - if (atom->nextra_restart) - for (int iextra = 0; iextra < atom->nextra_restart; iextra++) - for (i = 0; i < nlocal; i++) - n += modify->fix[atom->extra_restart[iextra]]->size_restart(i); - - return n; -} - -/* ---------------------------------------------------------------------- - pack atom I's data for restart file including extra quantities - xyz must be 1st 3 values, so that read_restart can test on them - molecular types may be negative, but write as positive -------------------------------------------------------------------------- */ - -int AtomVecFullHars::pack_restart(int i, double *buf) -{ - int k; - - int m = 1; - buf[m++] = x[i][0]; - buf[m++] = x[i][1]; - buf[m++] = x[i][2]; - buf[m++] = ubuf(tag[i]).d; - buf[m++] = ubuf(type[i]).d; - buf[m++] = ubuf(mask[i]).d; - buf[m++] = ubuf(image[i]).d; - buf[m++] = v[i][0]; - buf[m++] = v[i][1]; - buf[m++] = v[i][2]; - - buf[m++] = q[i]; - buf[m++] = lambdaH[i]; - buf[m++] = gradlambdaH[i][0]; - buf[m++] = gradlambdaH[i][1]; - buf[m++] = gradlambdaH[i][2]; - buf[m++] = comH[i][0]; - buf[m++] = comH[i][1]; - buf[m++] = comH[i][2]; - - buf[m++] = ubuf(replambdaH[i]).d; - buf[m++] = ubuf(moltypeH[i]).d; - buf[m++] = ubuf(molecule[i]).d; - - buf[m++] = ubuf(num_bond[i]).d; - for (k = 0; k < num_bond[i]; k++) { - buf[m++] = ubuf(MAX(bond_type[i][k],-bond_type[i][k])).d; - buf[m++] = ubuf(bond_atom[i][k]).d; - } - - buf[m++] = ubuf(num_angle[i]).d; - for (k = 0; k < num_angle[i]; k++) { - buf[m++] = ubuf(MAX(angle_type[i][k],-angle_type[i][k])).d; - buf[m++] = ubuf(angle_atom1[i][k]).d; - buf[m++] = ubuf(angle_atom2[i][k]).d; - buf[m++] = ubuf(angle_atom3[i][k]).d; - } - - buf[m++] = ubuf(num_dihedral[i]).d; - for (k = 0; k < num_dihedral[i]; k++) { - buf[m++] = ubuf(MAX(dihedral_type[i][k],-dihedral_type[i][k])).d; - buf[m++] = ubuf(dihedral_atom1[i][k]).d; - buf[m++] = ubuf(dihedral_atom2[i][k]).d; - buf[m++] = ubuf(dihedral_atom3[i][k]).d; - buf[m++] = ubuf(dihedral_atom4[i][k]).d; - } - - buf[m++] = ubuf(num_improper[i]).d; - for (k = 0; k < num_improper[i]; k++) { - buf[m++] = ubuf(MAX(improper_type[i][k],-improper_type[i][k])).d; - buf[m++] = ubuf(improper_atom1[i][k]).d; - buf[m++] = ubuf(improper_atom2[i][k]).d; - buf[m++] = ubuf(improper_atom3[i][k]).d; - buf[m++] = ubuf(improper_atom4[i][k]).d; - } - - if (atom->nextra_restart) - for (int iextra = 0; iextra < atom->nextra_restart; iextra++) - m += modify->fix[atom->extra_restart[iextra]]->pack_restart(i,&buf[m]); - - buf[0] = m; - return m; -} - -/* ---------------------------------------------------------------------- - unpack data for one atom from restart file including extra quantities -------------------------------------------------------------------------- */ - -int AtomVecFullHars::unpack_restart(double *buf) -{ - int k; - - int nlocal = atom->nlocal; - if (nlocal == nmax) { - grow(0); - if (atom->nextra_store) - memory->grow(atom->extra,nmax,atom->nextra_store,"atom:extra"); - } - - int m = 1; - x[nlocal][0] = buf[m++]; - x[nlocal][1] = buf[m++]; - x[nlocal][2] = buf[m++]; - tag[nlocal] = (tagint) ubuf(buf[m++]).i; - type[nlocal] = (int) ubuf(buf[m++]).i; - mask[nlocal] = (int) ubuf(buf[m++]).i; - image[nlocal] = (imageint) ubuf(buf[m++]).i; - v[nlocal][0] = buf[m++]; - v[nlocal][1] = buf[m++]; - v[nlocal][2] = buf[m++]; - - q[nlocal] = buf[m++]; - lambdaH[nlocal] = buf[m++]; - gradlambdaH[nlocal][0] = buf[m++]; - gradlambdaH[nlocal][1] = buf[m++]; - gradlambdaH[nlocal][2] = buf[m++]; - comH[nlocal][0] = buf[m++]; - comH[nlocal][1] = buf[m++]; - comH[nlocal][2] = buf[m++]; - replambdaH[nlocal] = (int) ubuf(buf[m++]).i; - moltypeH[nlocal] = (int) ubuf(buf[m++]).i; - - molecule[nlocal] = (tagint) ubuf(buf[m++]).i; - - num_bond[nlocal] = (int) ubuf(buf[m++]).i; - for (k = 0; k < num_bond[nlocal]; k++) { - bond_type[nlocal][k] = (int) ubuf(buf[m++]).i; - bond_atom[nlocal][k] = (tagint) ubuf(buf[m++]).i; - } - - num_angle[nlocal] = (int) ubuf(buf[m++]).i; - for (k = 0; k < num_angle[nlocal]; k++) { - angle_type[nlocal][k] = (int) ubuf(buf[m++]).i; - angle_atom1[nlocal][k] = (tagint) ubuf(buf[m++]).i; - angle_atom2[nlocal][k] = (tagint) ubuf(buf[m++]).i; - angle_atom3[nlocal][k] = (tagint) ubuf(buf[m++]).i; - } - - num_dihedral[nlocal] = (int) ubuf(buf[m++]).i; - for (k = 0; k < num_dihedral[nlocal]; k++) { - dihedral_type[nlocal][k] = (int) ubuf(buf[m++]).i; - dihedral_atom1[nlocal][k] = (tagint) ubuf(buf[m++]).i; - dihedral_atom2[nlocal][k] = (tagint) ubuf(buf[m++]).i; - dihedral_atom3[nlocal][k] = (tagint) ubuf(buf[m++]).i; - dihedral_atom4[nlocal][k] = (tagint) ubuf(buf[m++]).i; - } - - num_improper[nlocal] = (int) ubuf(buf[m++]).i; - for (k = 0; k < num_improper[nlocal]; k++) { - improper_type[nlocal][k] = (int) ubuf(buf[m++]).i; - improper_atom1[nlocal][k] = (tagint) ubuf(buf[m++]).i; - improper_atom2[nlocal][k] = (tagint) ubuf(buf[m++]).i; - improper_atom3[nlocal][k] = (tagint) ubuf(buf[m++]).i; - improper_atom4[nlocal][k] = (tagint) ubuf(buf[m++]).i; - } - - nspecial[nlocal][0] = nspecial[nlocal][1] = nspecial[nlocal][2] = 0; - - double **extra = atom->extra; - if (atom->nextra_store) { - int size = static_cast (buf[0]) - m; - for (int i = 0; i < size; i++) extra[nlocal][i] = buf[m++]; - } - - atom->nlocal++; - return m; -} - -/* ---------------------------------------------------------------------- - create one atom of itype at coord - set other values to defaults -------------------------------------------------------------------------- */ - -void AtomVecFullHars::create_atom(int itype, double *coord) -{ - int nlocal = atom->nlocal; - if (nlocal == nmax) grow(0); - - tag[nlocal] = 0; - type[nlocal] = itype; - x[nlocal][0] = coord[0]; - x[nlocal][1] = coord[1]; - x[nlocal][2] = coord[2]; - mask[nlocal] = 1; - image[nlocal] = ((imageint) IMGMAX << IMG2BITS) | - ((imageint) IMGMAX << IMGBITS) | IMGMAX; - v[nlocal][0] = 0.0; - v[nlocal][1] = 0.0; - v[nlocal][2] = 0.0; - - q[nlocal] = 0.0; - lambdaH[nlocal] = 0.0; - gradlambdaH[nlocal][0] = 0.0; - gradlambdaH[nlocal][1] = 0.0; - gradlambdaH[nlocal][2] = 0.0; - comH[nlocal][0] = 0; - comH[nlocal][1] = 0; - comH[nlocal][2] = 0; - - replambdaH[nlocal] = 0; - moltypeH[nlocal] = 0; - - molecule[nlocal] = 0; - num_bond[nlocal] = 0; - num_angle[nlocal] = 0; - num_dihedral[nlocal] = 0; - num_improper[nlocal] = 0; - nspecial[nlocal][0] = nspecial[nlocal][1] = nspecial[nlocal][2] = 0; - - atom->nlocal++; -} - -/* ---------------------------------------------------------------------- - unpack one line from Atoms section of data file - initialize other atom quantities -------------------------------------------------------------------------- */ - -void AtomVecFullHars::data_atom(double *coord, imageint imagetmp, char **values) -{ - int nlocal = atom->nlocal; - if (nlocal == nmax) grow(0); - - tag[nlocal] = ATOTAGINT(values[0]); - molecule[nlocal] = ATOTAGINT(values[1]); - type[nlocal] = atoi(values[2]); - if (type[nlocal] <= 0 || type[nlocal] > atom->ntypes) - error->one(FLERR,"Invalid atom type in Atoms section of data file"); - - q[nlocal] = atof(values[3]); - replambdaH[nlocal] = atoi(values[4]); - moltypeH[nlocal] = atoi(values[5]); - - - x[nlocal][0] = coord[0]; - x[nlocal][1] = coord[1]; - x[nlocal][2] = coord[2]; - - comH[nlocal][0] = 0; - comH[nlocal][1] = 0; - comH[nlocal][2] = 0; - - image[nlocal] = imagetmp; - - mask[nlocal] = 1; - v[nlocal][0] = 0.0; - v[nlocal][1] = 0.0; - v[nlocal][2] = 0.0; - num_bond[nlocal] = 0; - num_angle[nlocal] = 0; - num_dihedral[nlocal] = 0; - num_improper[nlocal] = 0; - - atom->nlocal++; -} - -/* ---------------------------------------------------------------------- - unpack hybrid quantities from one line in Atoms section of data file - initialize other atom quantities for this sub-style -------------------------------------------------------------------------- */ - -int AtomVecFullHars::data_atom_hybrid(int nlocal, char **values) -{ - molecule[nlocal] = ATOTAGINT(values[0]); - q[nlocal] = atof(values[1]); - replambdaH[nlocal] = atoi(values[2]); - moltypeH[nlocal] = atoi(values[3]); - - num_bond[nlocal] = 0; - num_angle[nlocal] = 0; - num_dihedral[nlocal] = 0; - num_improper[nlocal] = 0; - - return 2; -} - -/* ---------------------------------------------------------------------- - pack atom info for data file including 3 image flags -------------------------------------------------------------------------- */ - -void AtomVecFullHars::pack_data(double **buf) -{ - int nlocal = atom->nlocal; - for (int i = 0; i < nlocal; i++) { - buf[i][0] = ubuf(tag[i]).d; - buf[i][1] = ubuf(molecule[i]).d; - buf[i][2] = ubuf(type[i]).d; - buf[i][3] = q[i]; - buf[i][4] = ubuf(replambdaH[i]).d; - buf[i][5] = ubuf(moltypeH[i]).d; - - buf[i][6] = x[i][0]; - buf[i][7] = x[i][1]; - buf[i][8] = x[i][2]; - buf[i][9] = ubuf((image[i] & IMGMASK) - IMGMAX).d; - buf[i][10] = ubuf((image[i] >> IMGBITS & IMGMASK) - IMGMAX).d; - buf[i][11] = ubuf((image[i] >> IMG2BITS) - IMGMAX).d; - } -} - -/* ---------------------------------------------------------------------- - pack hybrid atom info for data file -------------------------------------------------------------------------- */ - -int AtomVecFullHars::pack_data_hybrid(int i, double *buf) -{ - buf[0] = ubuf(molecule[i]).d; - buf[1] = q[i]; - buf[2] = ubuf(replambdaH[i]).d; - buf[3] = ubuf(moltypeH[i]).d; - - return 2; -} - -/* ---------------------------------------------------------------------- - write atom info to data file including 3 image flags -------------------------------------------------------------------------- */ - -void AtomVecFullHars::write_data(FILE *fp, int n, double **buf) -{ - for (int i = 0; i < n; i++) - fprintf(fp,TAGINT_FORMAT " " TAGINT_FORMAT - " %d %-1.16e %-1.16e %-1.16e %-1.16e %d %d %d\n", - (tagint) ubuf(buf[i][0]).i,(tagint) ubuf(buf[i][1]).i, - (int) ubuf(buf[i][2]).i, - buf[i][3],buf[i][4],buf[i][5],buf[i][6], - (int) ubuf(buf[i][7]).i,(int) ubuf(buf[i][8]).i, - (int) ubuf(buf[i][9]).i); -} - -/* ---------------------------------------------------------------------- - write hybrid atom info to data file -------------------------------------------------------------------------- */ - -int AtomVecFullHars::write_data_hybrid(FILE *fp, double *buf) -{ - fprintf(fp," " TAGINT_FORMAT " %-1.16e",(tagint) ubuf(buf[0]).i,buf[1]); - return 2; -} - -/* ---------------------------------------------------------------------- - return # of bytes of allocated memory -------------------------------------------------------------------------- */ - -bigint AtomVecFullHars::memory_usage() -{ - bigint bytes = 0; - - if (atom->memcheck("tag")) bytes += memory->usage(tag,nmax); - if (atom->memcheck("type")) bytes += memory->usage(type,nmax); - if (atom->memcheck("mask")) bytes += memory->usage(mask,nmax); - if (atom->memcheck("image")) bytes += memory->usage(image,nmax); - if (atom->memcheck("x")) bytes += memory->usage(x,nmax,3); - if (atom->memcheck("v")) bytes += memory->usage(v,nmax,3); - if (atom->memcheck("f")) bytes += memory->usage(f,nmax*comm->nthreads,3); - - if (atom->memcheck("q")) bytes += memory->usage(q,nmax); - if (atom->memcheck("lambdaH")) bytes += memory->usage(lambdaH,nmax); - if (atom->memcheck("gradlambdaH")) bytes += memory->usage(gradlambdaH,nmax,3); - if (atom->memcheck("replambdaH")) bytes += memory->usage(replambdaH,nmax); - if (atom->memcheck("moltypeH")) bytes += memory->usage(moltypeH,nmax); - - if (atom->memcheck("comH")) bytes += memory->usage(comH,nmax,3); - - - if (atom->memcheck("molecule")) bytes += memory->usage(molecule,nmax); - if (atom->memcheck("nspecial")) bytes += memory->usage(nspecial,nmax,3); - if (atom->memcheck("special")) - bytes += memory->usage(special,nmax,atom->maxspecial); - - if (atom->memcheck("num_bond")) bytes += memory->usage(num_bond,nmax); - if (atom->memcheck("bond_type")) - bytes += memory->usage(bond_type,nmax,atom->bond_per_atom); - if (atom->memcheck("bond_atom")) - bytes += memory->usage(bond_atom,nmax,atom->bond_per_atom); - - if (atom->memcheck("num_angle")) bytes += memory->usage(num_angle,nmax); - if (atom->memcheck("angle_type")) - bytes += memory->usage(angle_type,nmax,atom->angle_per_atom); - if (atom->memcheck("angle_atom1")) - bytes += memory->usage(angle_atom1,nmax,atom->angle_per_atom); - if (atom->memcheck("angle_atom2")) - bytes += memory->usage(angle_atom2,nmax,atom->angle_per_atom); - if (atom->memcheck("angle_atom3")) - bytes += memory->usage(angle_atom3,nmax,atom->angle_per_atom); - - if (atom->memcheck("num_dihedral")) bytes += memory->usage(num_dihedral,nmax); - if (atom->memcheck("dihedral_type")) - bytes += memory->usage(dihedral_type,nmax,atom->dihedral_per_atom); - if (atom->memcheck("dihedral_atom1")) - bytes += memory->usage(dihedral_atom1,nmax,atom->dihedral_per_atom); - if (atom->memcheck("dihedral_atom2")) - bytes += memory->usage(dihedral_atom2,nmax,atom->dihedral_per_atom); - if (atom->memcheck("dihedral_atom3")) - bytes += memory->usage(dihedral_atom3,nmax,atom->dihedral_per_atom); - if (atom->memcheck("dihedral_atom4")) - bytes += memory->usage(dihedral_atom4,nmax,atom->dihedral_per_atom); - - if (atom->memcheck("num_improper")) bytes += memory->usage(num_improper,nmax); - if (atom->memcheck("improper_type")) - bytes += memory->usage(improper_type,nmax,atom->improper_per_atom); - if (atom->memcheck("improper_atom1")) - bytes += memory->usage(improper_atom1,nmax,atom->improper_per_atom); - if (atom->memcheck("improper_atom2")) - bytes += memory->usage(improper_atom2,nmax,atom->improper_per_atom); - if (atom->memcheck("improper_atom3")) - bytes += memory->usage(improper_atom3,nmax,atom->improper_per_atom); - if (atom->memcheck("improper_atom4")) - bytes += memory->usage(improper_atom4,nmax,atom->improper_per_atom); - - return bytes; -} diff --git a/src/USER-HADRESS/atom_vec_full_hars.h b/src/USER-HADRESS/atom_vec_full_hars.h deleted file mode 100644 index 59bac9a3b9..0000000000 --- a/src/USER-HADRESS/atom_vec_full_hars.h +++ /dev/null @@ -1,104 +0,0 @@ -/* -*- c++ -*- ---------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - http://lammps.sandia.gov, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - Copyright (2003) Sandia Corporation. Under the terms of Contract - DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains - certain rights in this software. This software is distributed under - the GNU General Public License. - - See the README file in the top-level LAMMPS directory. -------------------------------------------------------------------------- */ - -#ifdef ATOM_CLASS - -AtomStyle(full/hars,AtomVecFullHars) - -#else - -#ifndef LMP_ATOM_VEC_FULL_HARS_H -#define LMP_ATOM_VEC_FULL_HARS_H - -#include "atom_vec.h" - -namespace LAMMPS_NS { - -class AtomVecFullHars : public AtomVec { - public: - AtomVecFullHars(class LAMMPS *); - virtual ~AtomVecFullHars() {} - void grow(int); - void grow_reset(); - void copy(int, int, int); - virtual int pack_comm(int, int *, double *, int, int *); - virtual int pack_comm_vel(int, int *, double *, int, int *); - virtual void unpack_comm(int, int, double *); - virtual void unpack_comm_vel(int, int, double *); - int pack_reverse(int, int, double *); - void unpack_reverse(int, int *, double *); - virtual int pack_border(int, int *, double *, int, int *); - virtual int pack_border_vel(int, int *, double *, int, int *); - int pack_border_hybrid(int, int *, double *); - virtual void unpack_border(int, int, double *); - virtual void unpack_border_vel(int, int, double *); - int unpack_border_hybrid(int, int, double *); - virtual int pack_exchange(int, double *); - virtual int unpack_exchange(double *); - int size_restart(); - int pack_restart(int, double *); - int unpack_restart(double *); - void create_atom(int, double *); - void data_atom(double *, imageint, char **); - int data_atom_hybrid(int, char **); - void pack_data(double **); - int pack_data_hybrid(int, double *); - void write_data(FILE *, int, double **); - int write_data_hybrid(FILE *, double *); - bigint memory_usage(); - - protected: - tagint *tag; - int *type,*mask; - imageint *image; - double **x,**v,**f; - double *q; - double *lambdaH; - double **gradlambdaH; - int *replambdaH; - int *moltypeH; - double **comH; - tagint *molecule; - int **nspecial; - tagint **special; - int *num_bond; - int **bond_type; - tagint **bond_atom; - int *num_angle; - int **angle_type; - tagint **angle_atom1,**angle_atom2,**angle_atom3; - int *num_dihedral; - int **dihedral_type; - tagint **dihedral_atom1,**dihedral_atom2,**dihedral_atom3,**dihedral_atom4; - int *num_improper; - int **improper_type; - tagint **improper_atom1,**improper_atom2,**improper_atom3,**improper_atom4; -}; - -} - -#endif -#endif - -/* ERROR/WARNING messages: - -E: Per-processor system is too big - -The number of owned atoms plus ghost atoms on a single -processor must fit in 32-bit integer. - -E: Invalid atom type in Atoms section of data file - -Atom types must range from 1 to specified # of types. - -*/ diff --git a/src/USER-HADRESS/fix_lambdah_calc.cpp b/src/USER-HADRESS/fix_lambdah_calc.cpp deleted file mode 100644 index 101f3ff830..0000000000 --- a/src/USER-HADRESS/fix_lambdah_calc.cpp +++ /dev/null @@ -1,958 +0,0 @@ -/* ---------------------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - http://lammps.sandia.gov, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - Copyright (2003) Sandia Corporation. Under the terms of Contract - DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains - certain rights in this software. This software is distributed under - the GNU General Public License. - - See the README file in the top-level LAMMPS directory. -------------------------------------------------------------------------- */ - -/* ---------------------------------------------------------------------- - Contributing author: Maziar Heidari (Max Planck Institute for Polymer Research) -------------------------------------------------------------------------- */ - -#include "math.h" -#include "string.h" -#include "stdlib.h" -#include "fix_lambdah_calc.h" -#include "atom.h" -#include "input.h" -#include "variable.h" -#include "domain.h" -#include "lattice.h" -#include "update.h" -#include "modify.h" -#include "output.h" -#include "respa.h" -#include "error.h" -#include "force.h" -#include "math_const.h" -#include "memory.h" -#include "comm.h" -#include "citeme.h" - - -using namespace LAMMPS_NS; -using namespace FixConst; -using namespace MathConst; - -#define BIG MAXTAGINT - -static const char cite_HAdResS[] = - "@Article{Heidari et al.2016\n" - " author = {M. Heidari, R. Cortes-Huerto, D. Donadio and R. Potestio},\n" - " title = {Accurate and general treatment of electrostatic interaction in Hamiltonian adaptive resolution simulations},\n" - " journal = {Eur. Phys. J. Special Topics},\n" - " year = 2016,\n" - " volume = Submitted,\n" - " pages = {}\n" - "}\n\n"; - - -/* ---------------------------------------------------------------------- */ - -FixLambdaHCalc::FixLambdaHCalc(LAMMPS *lmp, int narg, char **arg) : - Fix(lmp, narg, arg) -{ - - - if (lmp->citeme) lmp->citeme->add(cite_HAdResS); - - massproc_H = NULL; - masstotal_H = NULL; - com_H = NULL; - comall_H = NULL; - molmap_H = NULL; - lambdaCM = NULL; - gradlambdaCM = NULL; - Comp_Density_Num_H = NULL; - Comp_Density_Num_all_H = NULL; - Mean_Density_H = NULL; - Int_Mean_Density_H = NULL; - Mean_Comp_Density_Conv_H = NULL; - grad_Comp_Density_Conv_H = NULL; - Mean_grad_Comp_Density_Conv_H = NULL; - - - - me = comm->me; - - if (narg < 8) error->all(FLERR,"Illegal fix lambdah/calc command"); - - atom->nmoltypesH = force->numeric(FLERR,arg[3]); - Length_Hyb = force->numeric(FLERR,arg[4]); - Length_ATRegion = force->numeric(FLERR,arg[5]); - Pressure_Comp_Flag = force->numeric(FLERR,arg[6]); - Pressure_lambda_Increment = force->numeric(FLERR,arg[7]); - Pressure_Update_Frequency = force->numeric(FLERR,arg[8]); - Pressure_Update_Time_Begin = force->numeric(FLERR,arg[9]); - Pressure_Update_Time_End = force->numeric(FLERR,arg[10]); - - if (strcmp(arg[11],"slab") == 0) Hybrid_Style = 0; - else if (strcmp(arg[11],"sphere") == 0) Hybrid_Style = 1; - else if (strcmp(arg[11],"cylinder") == 0) Hybrid_Style = 2; - else error->all(FLERR,"Illegal fix lambdah/calc command"); - - Density_Comp_Flag = force->numeric(FLERR,arg[12]); - Density_Bin_Size = force->numeric(FLERR,arg[13]); - Density_Update_Frequency = force->numeric(FLERR,arg[14]); - Density_Update_Time_Begin = force->numeric(FLERR,arg[15]); - Density_Update_Time_End = force->numeric(FLERR,arg[16]); - Density_Sigma_Gauss = force->numeric(FLERR,arg[17]); - Density_Gauss_Int_Range = force->numeric(FLERR,arg[18]); - Density_Ref = force->numeric(FLERR,arg[19]); - Comp_Density_Scaling_factor_H = force->numeric(FLERR,arg[20]); - Load_File_Flag = force->numeric(FLERR,arg[21]); - - x0lo = domain->boxlo[0]; - x0hi = domain->boxhi[0]; - x1lo = domain->boxlo[1]; - x1hi = domain->boxhi[1]; - x2lo = domain->boxlo[2]; - x2hi = domain->boxhi[2]; - - center_box[0] = (x0hi + x0lo)/2.0; - center_box[1] = (x1hi + x1lo)/2.0; - center_box[2] = (x2hi + x2lo)/2.0; - - - x0BoxSize = x0hi - x0lo; - Length_CGRegion = x0BoxSize - 2*Length_Hyb - Length_ATRegion; - R_Start_Hybrid_1 = x0lo + Length_CGRegion/2.0; - R_Start_Hybrid_2 = x0lo + x0BoxSize - (Length_CGRegion/2.0 + Length_Hyb); - S_Start_Hybrid = Length_ATRegion; - Pressure_Bin_Num = 1.0 / Pressure_lambda_Increment; - xmin_AT = R_Start_Hybrid_1 + Length_Hyb; - xmax_AT= R_Start_Hybrid_1 + Length_Hyb + Length_ATRegion; - if(Hybrid_Style==0)Density_Bin_Num = floor(x0BoxSize / Density_Bin_Size); - else if(Hybrid_Style==1)Density_Bin_Num = floor(sqrt(pow(0.5*(x0hi-x0lo),2.0)+pow(0.5*(x1hi-x1lo),2.0)+pow(0.5*(x2hi-x2lo),2.0)) / Density_Bin_Size); - else if(Hybrid_Style==2)Density_Bin_Num = floor(sqrt(pow(0.5*(x0hi-x0lo),2.0)+pow(0.5*(x1hi-x1lo),2.0)) / Density_Bin_Size); - - - Comp_Counter_H = 0; - Density_Counter_H = 0; - Density_Compensation_Run = 0; - - memory->create(Comp_Density_Num_H,Density_Bin_Num,atom->nmoltypesH+1,"lambdaH/calc:Comp_Density_Num_H"); - memory->create(Comp_Density_Num_all_H,Density_Bin_Num,atom->nmoltypesH+1,"lambdaH/calc:Comp_Density_Num_all_H"); - - if(me==0){ - if (screen){ - fprintf(screen,"nmoltypes= %d\n",atom->nmoltypesH); - fprintf(screen,"Length_Hyb= %f\n",Length_Hyb); - fprintf(screen,"Length_ATRegion= %f\n",Length_ATRegion); - fprintf(screen,"Pressure_Comp_Flag= %d\n",Pressure_Comp_Flag); - fprintf(screen,"Pressure_lambda_Increment= %f\n",Pressure_lambda_Increment); - fprintf(screen,"Pressure_Update_Frequency= %d\n",Pressure_Update_Frequency); - fprintf(screen,"Pressure_Update_Time_Begin= %d\n",Pressure_Update_Time_Begin); - fprintf(screen,"Pressure_Update_Time_End= %d\n",Pressure_Update_Time_End); - fprintf(screen,"Density_Comp_Flag= %d\n",Density_Comp_Flag); - fprintf(screen,"Density_Bin_Size= %f\n",Density_Bin_Size); - fprintf(screen,"Density_Update_Frequency= %d\n",Density_Update_Frequency); - fprintf(screen,"Density_Update_Time_Begin= %d\n",Density_Update_Time_Begin); - fprintf(screen,"Density_Update_Time_End= %d\n",Density_Update_Time_End); - fprintf(screen,"Density_Sigma_Gauss= %f\n",Density_Sigma_Gauss); - fprintf(screen,"Density_Gauss_Int_Range= %d\n",Density_Gauss_Int_Range); - fprintf(screen,"Density_Ref= %f\n",Density_Ref); - fprintf(screen,"Comp_Density_Scaling_factor_H = %f\n",Comp_Density_Scaling_factor_H); - fprintf(screen,"Load_File_Flag = %d\n",Load_File_Flag); - fprintf(screen,"Center_box = %f %f %f\n",center_box[0],center_box[1],center_box[2]); - fprintf(screen,"Density_Bin_Size = %f\n",Density_Bin_Size); - fprintf(screen,"Density_Bin_Num = %d\n",Density_Bin_Num); - fprintf(screen,"x0lo= %f\n",x0lo); - fprintf(screen,"x0hi= %f\n",x0hi); - fprintf(screen,"x0BoxSize= %f\n",x0BoxSize); - fprintf(screen,"d1= %f\n",R_Start_Hybrid_1); - fprintf(screen,"d2= %f\n",R_Start_Hybrid_2); - fprintf(screen,"moltype%d\n",atom->nmoltypesH); - - } - if (logfile){ - fprintf(logfile,"nmoltypes= %d\n",atom->nmoltypesH); - fprintf(logfile,"Length_Hyb= %f\n",Length_Hyb); - fprintf(logfile,"Length_ATRegion= %f\n",Length_ATRegion); - fprintf(logfile,"Pressure_Comp_Flag= %d\n",Pressure_Comp_Flag); - fprintf(logfile,"Pressure_lambda_Increment= %f\n",Pressure_lambda_Increment); - fprintf(logfile,"Pressure_Update_Frequency= %d\n",Pressure_Update_Frequency); - fprintf(logfile,"Pressure_Update_Time_Begin= %d\n",Pressure_Update_Time_Begin); - fprintf(logfile,"Pressure_Update_Time_End= %d\n",Pressure_Update_Time_End); - fprintf(logfile,"Density_Comp_Flag= %d\n",Density_Comp_Flag); - fprintf(logfile,"Density_Bin_Size= %f\n",Density_Bin_Size); - fprintf(logfile,"Density_Update_Frequency= %d\n",Density_Update_Frequency); - fprintf(logfile,"Density_Update_Time_Begin= %d\n",Density_Update_Time_Begin); - fprintf(logfile,"Density_Update_Time_End= %d\n",Density_Update_Time_End); - fprintf(logfile,"Density_Sigma_Gauss= %f\n",Density_Sigma_Gauss); - fprintf(logfile,"Density_Gauss_Int_Range= %d\n",Density_Gauss_Int_Range); - fprintf(logfile,"Density_Ref= %f\n",Density_Ref); - fprintf(logfile,"Comp_Density_Scaling_factor_H = %f\n",Comp_Density_Scaling_factor_H); - fprintf(logfile,"Load_File_Flag = %d\n",Load_File_Flag); - fprintf(logfile,"Center_box = %f %f %f\n",center_box[0],center_box[1],center_box[2]); - fprintf(logfile,"Density_Bin_Size = %f\n",Density_Bin_Size); - fprintf(logfile,"Density_Bin_Num = %d\n",Density_Bin_Num); - fprintf(logfile,"x0lo= %f\n",x0lo); - fprintf(logfile,"x0hi= %f\n",x0hi); - fprintf(logfile,"x0BoxSize= %f\n",x0BoxSize); - fprintf(logfile,"d1= %f\n",R_Start_Hybrid_1); - fprintf(logfile,"d2= %f\n",R_Start_Hybrid_2); - fprintf(logfile,"moltype%d\n",atom->nmoltypesH); - - } - } - - memory->create(Int_Mean_Density_H,Density_Bin_Num,atom->nmoltypesH+1,"lambdaH/calc:Int_Mean_Density_H"); - memory->create(Mean_Density_H,Density_Bin_Num,atom->nmoltypesH+1,"lambdaH/calc:Mean_Density_H"); - memory->create(Mean_Comp_Density_Conv_H,Density_Bin_Num,atom->nmoltypesH+1,"lambdaH/calc:Mean_Comp_Density_Conv_H"); - memory->create(grad_Comp_Density_Conv_H,Density_Bin_Num,atom->nmoltypesH+1,"lambdaH/calc:grad_Comp_Density_Conv_H"); - memory->create(Mean_grad_Comp_Density_Conv_H,Density_Bin_Num,atom->nmoltypesH+1,"lambdaH/calc:Mean_grad_Comp_Density_Conv_H"); - - - int This_Step = update->ntimestep; - - for(int i = 0;i < Density_Bin_Num; i++){ - for(int j = 0; j < atom->nmoltypesH; j++){ - Comp_Density_Num_H[i][j] = 0; - Comp_Density_Num_all_H[i][j] = 0; - Int_Mean_Density_H[i][j] = 0; - Mean_Density_H[i][j] = 0; - Mean_Comp_Density_Conv_H[i][j] = 0; - Mean_grad_Comp_Density_Conv_H[i][j] = 0; - grad_Comp_Density_Conv_H[i][j] = 0; - } - } - - if((This_Step >= Density_Update_Time_End || Load_File_Flag) && Density_Comp_Flag != 0)Load_Compensation_Density(); - - if (atom->molecular == 0) - error->all(FLERR,"Compute com/molecule requires molecular atom style"); - - array_flag = 1; - size_array_cols = 3; - extarray = 0; - // setup molecule-based data - nmolecules = molecules_in_group(idlo,idhi); - size_array_rows = nmolecules; - - //printf("Nmolecules= %d\n",nmolecules); - - memory->create(massproc_H,nmolecules,"lambdaH/calc:massproc_H"); - memory->create(masstotal_H,nmolecules,"lambdaH/calc:masstotal_H"); - memory->create(com_H,nmolecules,3,"lambdaH/calc:com_H"); - memory->create(comall_H,nmolecules,3,"lambdaH/calc:comall_H"); - memory->create(lambdaCM,nmolecules,"lambdaH/calc:lambdaCM"); - memory->create(gradlambdaCM,nmolecules,3,"lambdaH/calc:gradlambdaCM"); - - // compute masstotal for each molecule - - int *mask = atom->mask; - tagint *molecule = atom->molecule; - int *type = atom->type; - double *mass = atom->mass; - double *rmass = atom->rmass; - int nlocal = atom->nlocal; - tagint imol; - double massone; - - for (int i = 0; i < nmolecules; i++) massproc_H[i] = 0.0; - - for (int i = 0; i < nlocal; i++) - { - if (mask[i] & groupbit) { - if (rmass) massone = rmass[i]; - else massone = mass[type[i]]; - imol = molecule[i]; - if (molmap_H) imol = molmap_H[imol-idlo]; - else imol--; - massproc_H[imol] += massone; - } -} - - MPI_Allreduce(massproc_H,masstotal_H,nmolecules,MPI_DOUBLE,MPI_SUM,world); - int *replambdaH = atom->replambdaH; - int pass = 0; - for (int i = 0; i < nlocal; i++) if(replambdaH[i] != 0)pass=1; - if(pass==0) error->all(FLERR,"No representative atom (replambdaH) has been defined!"); - -} - -/* ---------------------------------------------------------------------- */ - -FixLambdaHCalc::~FixLambdaHCalc() -{ - - memory->destroy(massproc_H); - memory->destroy(masstotal_H); - memory->destroy(com_H); - memory->destroy(comall_H); - memory->destroy(molmap_H); - memory->destroy(lambdaCM); - memory->destroy(gradlambdaCM); - memory->destroy(Comp_Density_Num_H); - memory->destroy(Comp_Density_Num_all_H); - memory->destroy(Mean_Density_H); - memory->destroy(Int_Mean_Density_H); - memory->destroy(Mean_Comp_Density_Conv_H); - memory->destroy(grad_Comp_Density_Conv_H); - memory->destroy(Mean_grad_Comp_Density_Conv_H); -} - -/* ---------------------------------------------------------------------- */ - -int FixLambdaHCalc::setmask() -{ - int mask = 0; - //mask |= PRE_FORCE; -// mask |= PRE_NEIGHBOR; - mask |= POST_INTEGRATE; - mask |= THERMO_ENERGY; -// mask |= POST_FORCE_RESPA; - mask |= MIN_PRE_FORCE; - return mask; -} - -/* ---------------------------------------------------------------------- */ - -void FixLambdaHCalc::init() -{ - int ntmp = molecules_in_group(idlo,idhi); - if (ntmp != nmolecules) - error->all(FLERR,"Molecule count changed in compute com/molecule"); - - - -} - -/* ---------------------------------------------------------------------- */ - -void FixLambdaHCalc::setup(int vflag) -{ - -// if (strstr(update->integrate_style,"verlet")) - //pre_force(vflag); - post_integrate(); -// else { -// ((Respa *) update->integrate)->copy_flevel_f(nlevels_respa-1); -// post_force_respa(vflag,nlevels_respa-1,0); - // ((Respa *) update->integrate)->copy_f_flevel(nlevels_respa-1); - // } -} - -/* ---------------------------------------------------------------------- */ - - -void FixLambdaHCalc::post_integrate() -{ - - tagint imol; - double massone; - double unwrap[3]; - - - //invoked_array = update->ntimestep; - for (int i = 0; i < nmolecules; i++) - com_H[i][0] = com_H[i][1] = com_H[i][2] = 0.0; - - double **x = atom->x; - int *mask = atom->mask; - tagint *molecule = atom->molecule; - int *type = atom->type; - imageint *image = atom->image; - double *mass = atom->mass; - double *rmass = atom->rmass; - int nlocal = atom->nlocal; - - double *lambdaH = atom->lambdaH; - double **gradlambdaH = atom->gradlambdaH; - double **comH = atom->comH; - - int This_Step = update->ntimestep; - if(This_Step >= Density_Update_Time_Begin && This_Step < Density_Update_Time_End && Density_Comp_Flag == 1){ - Density_Compensation_Run = 1; - if(me==0 && This_Step == Density_Update_Time_Begin){ - if(screen)fprintf(screen,"\nStart of constant-density route\n"); - if(logfile)fprintf(logfile,"\nStart of constant-density route\n"); - Clear_File_Compensation_Density(); - } - } - - - for (int i = 0; i < nlocal; i++) - if (mask[i] & groupbit) { - - if (rmass) massone = rmass[i]; - else massone = mass[type[i]]; - imol = molecule[i]; - if (molmap_H) imol = molmap_H[imol-idlo]; - else imol--; - domain->unmap(x[i],image[i],unwrap); - massone /= masstotal_H[imol]; - - com_H[imol][0] += unwrap[0] * massone; - com_H[imol][1] += unwrap[1] * massone; - com_H[imol][2] += unwrap[2] * massone; - } - - - MPI_Allreduce(&com_H[0][0],&comall_H[0][0],3*nmolecules,MPI_DOUBLE,MPI_SUM,world); - - - double xtmp,ytmp,ztmp; - double delx,dely,delz; - double Grad_Factor; - double rdiff; - - for (int i = 0; i < nmolecules; i++){ - - - domain->remap(comall_H[i]); - - if(Hybrid_Style==0){ - xtmp = comall_H[i][0]; - - if(xtmp < R_Start_Hybrid_1){ - lambdaCM[i] = 0.0; - gradlambdaCM[i][0] = 0.0; - gradlambdaCM[i][1] = 0.0; - gradlambdaCM[i][2] = 0.0; - - } - else if(xtmp >= R_Start_Hybrid_1 && xtmp < R_Start_Hybrid_1+Length_Hyb){ - cosx=cos(MY_PI*(xtmp-R_Start_Hybrid_1+Length_Hyb)/(2.0*Length_Hyb)); - sinx=sin(MY_PI*(xtmp-R_Start_Hybrid_1+Length_Hyb)/(2.0*Length_Hyb)); - lambdaCM[i] = cosx * cosx; - gradlambdaCM[i][0] = -(MY_PI/Length_Hyb) * sinx * cosx; - gradlambdaCM[i][1] = 0.0; - gradlambdaCM[i][2] = 0.0; - - } - else if(xtmp >=R_Start_Hybrid_1+Length_Hyb && xtmp < R_Start_Hybrid_2){ - lambdaCM[i] = 1.0; - gradlambdaCM[i][0] = 0.0; - gradlambdaCM[i][1] = 0.0; - gradlambdaCM[i][2] = 0.0; - - } - else if(xtmp >= R_Start_Hybrid_2 && xtmp < R_Start_Hybrid_2+Length_Hyb){ - cosx = cos(MY_PI*(xtmp-R_Start_Hybrid_2)/(2.0*Length_Hyb)); - sinx = sin(MY_PI*(xtmp-R_Start_Hybrid_2)/(2.0*Length_Hyb)); - lambdaCM[i] = cosx * cosx; - gradlambdaCM[i][0] = -(MY_PI/Length_Hyb) * sinx * cosx; - gradlambdaCM[i][1] = 0.0; - gradlambdaCM[i][2] = 0.0; - - } - else if(xtmp >=R_Start_Hybrid_2+Length_Hyb){ - lambdaCM[i] = 0.0; - gradlambdaCM[i][0] = 0.0; - gradlambdaCM[i][1] = 0.0; - gradlambdaCM[i][2] = 0.0; - - } - } - - else if(Hybrid_Style==1){ - xtmp = comall_H[i][0]; - ytmp = comall_H[i][1]; - ztmp = comall_H[i][2]; - - delx = (xtmp-center_box[0]); - dely = (ytmp-center_box[1]); - delz = (ztmp-center_box[2]); - - r = sqrt(delx*delx+dely*dely+delz*delz); - - if(r < S_Start_Hybrid){ - lambdaCM[i] = 1.0; - gradlambdaCM[i][0] = 0.0; - gradlambdaCM[i][1] = 0.0; - gradlambdaCM[i][2] = 0.0; - } - else if(r >= S_Start_Hybrid && r < S_Start_Hybrid+Length_Hyb) { - rdiff = MY_PI*(r-S_Start_Hybrid)/(2.0*Length_Hyb); - cosr=cos(rdiff); - sinr=sin(rdiff); - lambdaCM[i] = cosr * cosr; - Grad_Factor = -MY_PI * sinr * cosr / (Length_Hyb * r); - gradlambdaCM[i][0] = Grad_Factor * delx; - gradlambdaCM[i][1] = Grad_Factor * dely; - gradlambdaCM[i][2] = Grad_Factor * delz; - } - else if(r >= S_Start_Hybrid+Length_Hyb){ - lambdaCM[i] = 0.0; - gradlambdaCM[i][0] = 0.0; - gradlambdaCM[i][1] = 0.0; - gradlambdaCM[i][2] = 0.0; - } - } - - else if(Hybrid_Style==2){ - - xtmp = comall_H[i][0]; - ytmp = comall_H[i][1]; - - delx = (xtmp-center_box[0]); - dely = (ytmp-center_box[1]); - - r = sqrt(delx*delx+dely*dely); - - if(r < S_Start_Hybrid){ - lambdaCM[i] = 1.0; - gradlambdaCM[i][0] = 0.0; - gradlambdaCM[i][1] = 0.0; - gradlambdaCM[i][2] = 0.0; - } - else if(r >= S_Start_Hybrid && r < S_Start_Hybrid+Length_Hyb) { - rdiff = MY_PI*(r-S_Start_Hybrid)/(2.0*Length_Hyb); - cosr=cos(rdiff); - sinr=sin(rdiff); - lambdaCM[i] = cosr * cosr; - Grad_Factor = -MY_PI * sinr * cosr / (Length_Hyb * r); - - gradlambdaCM[i][0] = Grad_Factor * delx; - gradlambdaCM[i][1] = Grad_Factor * dely; - gradlambdaCM[i][2] = 0.0; - } - else if(r >= S_Start_Hybrid+Length_Hyb){ - lambdaCM[i] = 0.0; - gradlambdaCM[i][0] = 0.0; - gradlambdaCM[i][1] = 0.0; - gradlambdaCM[i][2] = 0.0; - } - } - - -} - - int ibin,imoltypeH; - int *moltypeH = atom->moltypeH; - - for (int i = 0; i < nlocal; i++) - if (mask[i] & groupbit) - { - imol = molecule[i]; - imoltypeH = moltypeH[i]; - if (molmap_H) imol = molmap_H[imol-idlo]; - else imol--; - lambdaH[i] = lambdaCM[imol]; - gradlambdaH[i][0] = gradlambdaCM[imol][0]; - gradlambdaH[i][1] = gradlambdaCM[imol][1]; - gradlambdaH[i][2] = gradlambdaCM[imol][2]; -// if(gradlambdaH[i][2]!=0) printf("gradlambdaH[i][2] = %f\n",gradlambdaH[i][2]); - -// gradlambdaH[i][2] = 0.0; - //gradlambdaH[i] = 0; -// if(replambdaH[i] == 1){ - comH[i][0] = comall_H[imol][0]; - comH[i][1] = comall_H[imol][1]; - comH[i][2] = comall_H[imol][2]; -// } - - if(Density_Comp_Flag != 0 && Density_Compensation_Run != 0){ - - if(Hybrid_Style==0){ -// xtmp = comall_H[imol][0]-x0lo; - xtmp = comH[i][0]-x0lo; -// if(xtmp <= 0.5*x0BoxSize)ibin = floor(xtmp/Density_Bin_Size); -// else ibin = floor((x0BoxSize-xtmp)/Density_Bin_Size); - - ibin = floor(xtmp/Density_Bin_Size); - - } - - else if(Hybrid_Style==1){ - xtmp = comall_H[imol][0]; - ytmp = comall_H[imol][1]; - ztmp = comall_H[imol][2]; - - delx = (xtmp-center_box[0]); - dely = (ytmp-center_box[1]); - delz = (ztmp-center_box[2]); - - r = sqrt(delx*delx+dely*dely+delz*delz); - ibin = floor(r/Density_Bin_Size); - } - - else if(Hybrid_Style==2){ - - xtmp = comall_H[imol][0]; - ytmp = comall_H[imol][1]; - - delx = (xtmp-center_box[0]); - dely = (ytmp-center_box[1]); - - r = sqrt(delx*delx+dely*dely); - ibin = floor(r/Density_Bin_Size); - } - - if(ibin>=Density_Bin_Num)ibin = Density_Bin_Num - 1; - Comp_Density_Num_H[ibin][imoltypeH-1]++; - - } - - } - - -// int Middle_Bin_Num = (Density_Bin_Num-1) / 2; - -// if(Hybrid_Style == 0)for(int i = Middle_Bin_Num+1;i < Density_Bin_Num; i++)Comp_Density_Num_H[i] = Comp_Density_Num_H[Density_Bin_Num-1-i]; - if(Density_Compensation_Run)Density_Counter_H++; - - double Density_Bin_Vol, exponent; - double Normalization; - int jmin, jmax,jj; - if(This_Step % Density_Update_Frequency == 0 && This_Step > Density_Update_Time_Begin && Density_Comp_Flag != 0 && Density_Compensation_Run != 0){ - - // if(atom->nmoltypesH ==1) MPI_Allreduce(&Comp_Density_Num_H[0][0],&Comp_Density_Num_all_H[0][0],Density_Bin_Num,MPI_INT,MPI_SUM,world); - MPI_Allreduce(&Comp_Density_Num_H[0][0],&Comp_Density_Num_all_H[0][0],Density_Bin_Num*(atom->nmoltypesH+1),MPI_INT,MPI_SUM,world); - - if(Hybrid_Style == 0)Density_Bin_Vol = 1.0*Density_Bin_Size * (x1hi-x1lo) * (x2hi-x2lo); - - for(int i = 0; i < Density_Bin_Num; i++){ - if(Hybrid_Style == 1)Density_Bin_Vol = (4.0/3.0) * MY_PI * (pow(((i+1) * Density_Bin_Size),3.0) - pow((i * Density_Bin_Size),3.0)); - if(Hybrid_Style == 2)Density_Bin_Vol = 4.0 * MY_PI * (x2hi-x2lo) * (pow(((i+1) * Density_Bin_Size),2.0) - pow((i * Density_Bin_Size),2.0)); - for(int j = 0; j < atom->nmoltypesH; j++){ - Mean_Density_H[i][j] = Comp_Density_Num_all_H[i][j] / (Density_Counter_H * Density_Bin_Vol); - } - } - - Density_Counter_H = 0; - - for(int k = 0; k < atom->nmoltypesH;k++){ - for(int i = 0;i < Density_Bin_Num; i++){ - Normalization = 0; - jmin = i - Density_Gauss_Int_Range*floor(Density_Sigma_Gauss / Density_Bin_Size); - jmax = i + Density_Gauss_Int_Range*floor(Density_Sigma_Gauss / Density_Bin_Size); - Mean_Comp_Density_Conv_H[i][k] = 0; - if(Hybrid_Style != 0){ - if(jmin<0)jmin=0; - if(jmax>=Density_Bin_Num)jmax=Density_Bin_Num-1; - } - - for(int j = jmin;j <= jmax; j++){ - jj = j; - if(Hybrid_Style == 0){ - if(j < 0)jj = Density_Bin_Num + j; - if(j >= Density_Bin_Num)jj = j - Density_Bin_Num; - } - exponent = (i-j)*Density_Bin_Size/Density_Sigma_Gauss; - exponent = pow(exponent,2.0); - Normalization += exp(-exponent)*Density_Bin_Size; - Mean_Comp_Density_Conv_H[i][k] += Mean_Density_H[jj][k] * exp(-exponent)*Density_Bin_Size; - // Mean_Comp_Density_Conv_H[i] += Mean_Density_H[j] * exp(-exponent); - } - Mean_Comp_Density_Conv_H[i][k] /= Normalization; - - } - } - - Density_Fluctuation = 0; - for(int k = 0; k < atom->nmoltypesH;k++)for(int i = 0;i < Density_Bin_Num; i++)Density_Fluctuation += (Density_Bin_Size/x0BoxSize)*pow((Mean_Density_H[i][k]-Density_Ref)/Density_Ref,2.0); - for(int k = 0; k < atom->nmoltypesH;k++) - for(int i = 1;i < Density_Bin_Num-1; i++) - grad_Comp_Density_Conv_H[i][k] = Comp_Density_Scaling_factor_H * (Mean_Comp_Density_Conv_H[i+1][k] - Mean_Comp_Density_Conv_H[i-1][k])/(2*Density_Bin_Size*Density_Ref); - - - //for(int i = 1;i < Density_Bin_Num-1; i++)Mean_grad_Comp_Density_Conv_H[i] = (Comp_Counter_H * Mean_grad_Comp_Density_Conv_H[i] + grad_Comp_Density_Conv_H[i]) / (Comp_Counter_H + 1); - for(int k = 0; k < atom->nmoltypesH;k++) - for(int i = 1;i < Density_Bin_Num-1; i++) - Mean_grad_Comp_Density_Conv_H[i][k] += grad_Comp_Density_Conv_H[i][k]; - -// for(int i = Middle_Bin_Num+1;i < Density_Bin_Num; i++)Comp_Density_Num_H[i] = Comp_Density_Num_H[Density_Bin_Num-1-i]; - - for(int k = 0; k < atom->nmoltypesH;k++) - for(int i = 0;i < Density_Bin_Num; i++) - Int_Mean_Density_H[i][k]=0; - - for(int k = 0; k < atom->nmoltypesH;k++) - for(int i = 0;i < Density_Bin_Num; i++) - for(int j = 0;j <= i; j++) - Int_Mean_Density_H[i][k] += Mean_grad_Comp_Density_Conv_H[j][k] * Density_Bin_Size; - - Comp_Counter_H += 1; - - for(int k = 0; k < atom->nmoltypesH;k++) - for(int i = 0;i < Density_Bin_Num; i++){ - Comp_Density_Num_H[i][k] = 0; - Comp_Density_Num_all_H[i][k] = 0; - } - - - } - - if(This_Step == Density_Update_Time_End && Density_Compensation_Run != 0){ - Density_Compensation_Run = 0; - if(me==0){ - if(screen)fprintf(screen,"\nEnd of constant-density route\n"); - if(logfile)fprintf(logfile,"\nEnd of constant-density route\n"); - } - } - - if (me == 0 && This_Step % Density_Update_Frequency == 0 && Density_Compensation_Run != 0) Print_Compensation_Density(); - -} - - -double FixLambdaHCalc::memory_usage() -{ - double bytes = (bigint) nmolecules * 2 * sizeof(double); - if (molmap_H) bytes += (idhi-idlo+1) * sizeof(int); - bytes += (bigint) nmolecules * 2*3 * sizeof(double); - bytes += (bigint) nmolecules * 2*3 * sizeof(double); - return bytes; -} - -/* ---------------------------------------------------------------------- */ - - -int FixLambdaHCalc::molecules_in_group(tagint &idlo, tagint &idhi) -{ - int i; - - memory->destroy(molmap_H); - molmap_H = NULL; - - // find lo/hi molecule ID for any atom in group - // warn if atom in group has ID = 0 - - tagint *molecule = atom->molecule; - int *mask = atom->mask; - int nlocal = atom->nlocal; - - tagint lo = BIG; - tagint hi = -BIG; - int flag = 0; - for (i = 0; i < nlocal; i++) - { - if (mask[i] & groupbit) { - if (molecule[i] == 0) flag = 1; - lo = MIN(lo,molecule[i]); - hi = MAX(hi,molecule[i]); - } - } - - int flagall; - MPI_Allreduce(&flag,&flagall,1,MPI_INT,MPI_SUM,world); - if (flagall && comm->me == 0) - error->warning(FLERR,"Atom with molecule ID = 0 included in " - "compute molecule group"); - - MPI_Allreduce(&lo,&idlo,1,MPI_LMP_TAGINT,MPI_MIN,world); - MPI_Allreduce(&hi,&idhi,1,MPI_LMP_TAGINT,MPI_MAX,world); - if (idlo == BIG) return 0; - - // molmap = vector of length nlen - // set to 1 for IDs that appear in group across all procs, else 0 - - tagint nlen_tag = idhi-idlo+1; - if (nlen_tag > MAXSMALLINT) - error->all(FLERR,"Too many molecules for compute"); - int nlen = (int) nlen_tag; - - memory->create(molmap_H,nlen,"lambdaH/calc:molmap"); - for (i = 0; i < nlen; i++) molmap_H[i] = 0; - - for (i = 0; i < nlocal; i++) - if (mask[i] & groupbit) - molmap_H[molecule[i]-idlo] = 1; - - int *molmapall; - memory->create(molmapall,nlen,"compute:molmapall"); - MPI_Allreduce(molmap_H,molmapall,nlen,MPI_INT,MPI_MAX,world); - - // nmolecules = # of non-zero IDs in molmap - // molmap[i] = index of molecule, skipping molecules not in group with -1 - - int nmolecules = 0; - for (i = 0; i < nlen; i++) - if (molmapall[i]) molmap_H[i] = nmolecules++; - else molmap_H[i] = -1; - memory->destroy(molmapall); - - // warn if any molecule has some atoms in group and some not in group - - flag = 0; - for (i = 0; i < nlocal; i++) { - if (mask[i] & groupbit) continue; - if (molecule[i] < idlo || molecule[i] > idhi) continue; - if (molmap_H[molecule[i]-idlo] >= 0) flag = 1; - } - - MPI_Allreduce(&flag,&flagall,1,MPI_INT,MPI_SUM,world); - if (flagall && comm->me == 0) - error->warning(FLERR, - "One or more compute molecules has atoms not in group"); - - // if molmap simply stores 1 to Nmolecules, then free it - - if (idlo == 1 && idhi == nmolecules && nlen == nmolecules) { - memory->destroy(molmap_H); - molmap_H = NULL; - } - return nmolecules; -} - - -void FixLambdaHCalc::Print_Compensation_Density(){ - - - FILE *fp1; - fp1 = fopen("Mean_Comp_Density.txt","w"); - - if (fp1 == NULL) { - char str[128]; - sprintf(str,"Cannot open fix Mean_Comp_Density file %s","Mean_Comp_Density.txt"); - error->one(FLERR,str); - } - - - for(int i = 0;i < Density_Bin_Num; i++){ - fprintf(fp1,"%d",i+1); - for(int k = 0; k < atom->nmoltypesH;k++) - fprintf(fp1,"\t%.10f",Mean_grad_Comp_Density_Conv_H[i][k]); - fprintf(fp1,"\n"); - } - fclose(fp1); - - /* - FILE *fp2; - - char filename2[1000]; - sprintf(filename2, "Mean_Comp_Density%4.1f_%d.txt", Comp_Density_Scaling_factor_H,Density_Update_Frequency); - - fp2 = fopen(filename2,"a"); - - if (fp2 == NULL) { - char str[128]; - sprintf(str,"Cannot open fix Mean_Comp_Density file %s","Mean_Comp_Density.txt"); - error->one(FLERR,str); - } - - printf("Density_Fluctuation = %f\n",Density_Fluctuation); - - double x0; - if(Hybrid_Style==0)x0=x0lo; - else x0=0; - - for(int i = 0;i < Density_Bin_Num; i++){ - fprintf(fp2,"%d\t %.10f\t",i+1,i*Density_Bin_Size+x0); - for(int k = 0; k < atom->nmoltypesH;k++) - fprintf(fp2,"\t%.10f\t %.10f\t %.10f\t %.10f",Mean_Comp_Density_Conv_H[i][k],grad_Comp_Density_Conv_H[i][k],Mean_grad_Comp_Density_Conv_H[i][k]); - fprintf(fp2,"\n"); - - } - fclose(fp2); - - - FILE *fp3; - char filename3[1000]; - sprintf(filename3, "Density_Fluctuation%4.1f_%d.txt", Comp_Density_Scaling_factor_H,Density_Update_Frequency); - - fp3 = fopen(filename3,"a"); - - if (fp3 == NULL) { - char str[128]; - sprintf(str,"Cannot open fix Density_Fluctuation file %s","Density_Fluctuation.txt"); - error->one(FLERR,str); - } - - int This_Step = update->ntimestep; - fprintf(fp3,"%d %.10f\n",This_Step,Density_Fluctuation); - - fclose(fp3); - -*/ -} - -void FixLambdaHCalc::Clear_File_Compensation_Density(){ - - FILE *fp1; - fp1 = fopen("Mean_Comp_Density.txt","w"); - - if (fp1 == NULL) { - char str[128]; - sprintf(str,"Cannot open fix Mean_Comp_Density file %s","Mean_Comp_Density.txt"); - error->one(FLERR,str); - } - - - fclose(fp1); - - /* - FILE *fp2; - - char filename2[1000]; - sprintf(filename2, "Mean_Comp_Density%4.1f_%d.txt", Comp_Density_Scaling_factor_H,Density_Update_Frequency); - - fp2 = fopen(filename2,"w"); - - if (fp2 == NULL) { - char str[128]; - sprintf(str,"Cannot open fix Mean_Comp_Density file %s","Mean_Comp_Density.txt"); - error->one(FLERR,str); - } - - - fclose(fp2); - - FILE *fp3; - char filename3[1000]; - sprintf(filename3, "Density_Fluctuation%4.1f_%d.txt", Comp_Density_Scaling_factor_H,Density_Update_Frequency); - - fp3 = fopen(filename3,"w"); - - if (fp3 == NULL) { - char str[128]; - sprintf(str,"Cannot open fix Density_Fluctuation file %s","Density_Fluctuation.txt"); - error->one(FLERR,str); - } - - fclose(fp3); - */ - -} - -void FixLambdaHCalc::Load_Compensation_Density(){ - - if(me == 0){ - FILE *fp1; - char str[128]; - - fp1 = fopen("Mean_Comp_Density.txt","r"); - if (fp1 == NULL) { - sprintf(str,"Cannot open fix Mean_Comp_Density.txt file %s","Mean_Comp_Density.txt"); - error->one(FLERR,str); - } - - int i1; - float i2; - - while (!feof(fp1)){ - fscanf (fp1,"%d",&i1); - for(int k = 0; k < atom->nmoltypesH;k++){ - fscanf (fp1,"\t%f",&i2); - Mean_grad_Comp_Density_Conv_H[i1-1][k] = (double) i2; - } - fscanf (fp1,"\n"); - - if(i1 > Density_Bin_Num){ - sprintf(str,"Density bin number mismatches %d != %d",Density_Bin_Num,i1); - error->one(FLERR,str); - } - - } - - fclose(fp1); - - - if(me==0){ - if(screen)fprintf(screen,"\n\nDensity componsation forces distributed successfully!\n\n"); - if(logfile)fprintf(logfile,"\n\nDensity componsation forces distributed successfully!\n\n"); - } - } - - MPI_Bcast(Mean_grad_Comp_Density_Conv_H,Density_Bin_Num*(atom->nmoltypesH+1),MPI_DOUBLE,0,world); - -} diff --git a/src/USER-HADRESS/fix_lambdah_calc.h b/src/USER-HADRESS/fix_lambdah_calc.h deleted file mode 100644 index d3552e17f2..0000000000 --- a/src/USER-HADRESS/fix_lambdah_calc.h +++ /dev/null @@ -1,102 +0,0 @@ -/* -*- c++ -*- ---------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - http://lammps.sandia.gov, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - Copyright (2003) Sandia Corporation. Under the terms of Contract - DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains - certain rights in this software. This software is distributed under - the GNU General Public License. - - See the README file in the top-level LAMMPS directory. -------------------------------------------------------------------------- */ - -#ifdef FIX_CLASS - -FixStyle(lambdah/calc,FixLambdaHCalc) - -#else - -#ifndef LMP_FIX_LAMBDAH_CALC_H -#define LMP_FIX_LAMBDAH_CALC_H - -#include "fix.h" - -namespace LAMMPS_NS { - -class FixLambdaHCalc : public Fix { - public: - FixLambdaHCalc(class LAMMPS *, int, char **); - ~FixLambdaHCalc(); - int setmask(); - void init(); - void setup(int); - - void post_integrate(); - double memory_usage(); - - - double Length_Hyb,Length_ATRegion,Length_CGRegion; - int Hybrid_Style; - int Pressure_Comp_Flag,Pressure_Bin_Num,Pressure_Update_Frequency,Pressure_Update_Time_End, Pressure_Update_Time_Begin; - double Pressure_lambda_Increment; - int Density_Comp_Flag,Density_Compensation_Run,Density_Bin_Num,Density_Update_Frequency,Density_Update_Time_End,Density_Update_Time_Begin; - double Density_Bin_Size; - int Comp_Counter_H,Density_Counter_H; - double **Mean_grad_Comp_Density_Conv_H; - - double Density_Ref; - double center_box[3]; - int me; - double x0lo,x0hi,x1lo,x1hi,x2lo,x2hi,x0BoxSize; - double Density_Sigma_Gauss; - double Comp_Density_Scaling_factor_H; - int Density_Gauss_Int_Range; - - double xmin_AT,xmax_AT; - private: - int nmolecules; - tagint idlo,idhi; - double *massproc_H,*masstotal_H; - double **com_H,**comall_H; - double Density_Fluctuation; - int **Comp_Density_Num_H, **Comp_Density_Num_all_H; - double **Int_Mean_Density_H, **Mean_Density_H, **grad_Comp_Density_Conv_H, **Mean_Comp_Density_Conv_H; - int Load_File_Flag; - double R_Start_Hybrid_1,R_Start_Hybrid_2,S_Start_Hybrid,r,cosr,sinr,sinx,cosx; - double *lambdaCM, **gradlambdaCM; - int *molmap_H; // convert molecule ID to local index - - int molecules_in_group(tagint &, tagint &); - - void Print_Compensation_Density(); - void Load_Compensation_Density(); - void Clear_File_Compensation_Density(); -}; - -} - -#endif -#endif - -/* ERROR/WARNING messages: - -E: Illegal ... command - -Self-explanatory. Check the input script syntax and compare to the -documentation for the command. You can use -echo screen as a -command-line option when running LAMMPS to see the offending line. - -E: Variable name for fix indent does not exist - -Self-explanatory. - -E: Variable for fix indent is invalid style - -Only equal-style variables can be used. - -E: Variable for fix indent is not equal style - -Only equal-style variables can be used. - -*/ diff --git a/src/USER-HADRESS/molecule.cpp b/src/USER-HADRESS/molecule.cpp deleted file mode 100644 index 89ca26d051..0000000000 --- a/src/USER-HADRESS/molecule.cpp +++ /dev/null @@ -1,1829 +0,0 @@ -/* ---------------------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - http://lammps.sandia.gov, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - Copyright (2003) Sandia Corporation. Under the terms of Contract - DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains - certain rights in this software. This software is distributed under - the GNU General Public License. - - See the README file in the top-level LAMMPS directory. -------------------------------------------------------------------------- */ - -#include -#include -#include "molecule.h" -#include "atom.h" -#include "atom_vec.h" -#include "atom_vec_body.h" -#include "force.h" -#include "comm.h" -#include "domain.h" -#include "math_extra.h" -#include "math_const.h" -#include "memory.h" -#include "error.h" - -using namespace LAMMPS_NS; -using namespace MathConst; - -#define MAXLINE 256 -#define EPSILON 1.0e-7 -#define BIG 1.0e20 - -#define SINERTIA 0.4 // moment of inertia prefactor for sphere - -/* ---------------------------------------------------------------------- */ - -Molecule::Molecule(LAMMPS *lmp, int narg, char **arg, int &index) : - Pointers(lmp) -{ - me = comm->me; - - if (index >= narg) error->all(FLERR,"Illegal molecule command"); - - int n = strlen(arg[0]) + 1; - id = new char[n]; - strcpy(id,arg[0]); - - for (int i = 0; i < n-1; i++) - if (!isalnum(id[i]) && id[i] != '_') - error->all(FLERR,"Molecule template ID must be " - "alphanumeric or underscore characters"); - - // parse args until reach unknown arg (next file) - - toffset = 0; - boffset = aoffset = doffset = ioffset = 0; - sizescale = 1.0; - - int ifile = index; - int iarg = ifile+1; - - while (iarg < narg) { - if (strcmp(arg[iarg],"offset") == 0) { - if (iarg+6 > narg) error->all(FLERR,"Illegal molecule command"); - toffset = force->inumeric(FLERR,arg[iarg+1]); - boffset = force->inumeric(FLERR,arg[iarg+2]); - aoffset = force->inumeric(FLERR,arg[iarg+3]); - doffset = force->inumeric(FLERR,arg[iarg+4]); - ioffset = force->inumeric(FLERR,arg[iarg+5]); - if (toffset < 0 || boffset < 0 || aoffset < 0 || - doffset < 0 || ioffset < 0) - error->all(FLERR,"Illegal molecule command"); - iarg += 6; - } else if (strcmp(arg[iarg],"toff") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal molecule command"); - toffset = force->inumeric(FLERR,arg[iarg+1]); - if (toffset < 0) error->all(FLERR,"Illegal molecule command"); - iarg += 2; - } else if (strcmp(arg[iarg],"boff") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal molecule command"); - boffset = force->inumeric(FLERR,arg[iarg+1]); - if (boffset < 0) error->all(FLERR,"Illegal molecule command"); - iarg += 2; - } else if (strcmp(arg[iarg],"aoff") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal molecule command"); - aoffset = force->inumeric(FLERR,arg[iarg+1]); - if (aoffset < 0) error->all(FLERR,"Illegal molecule command"); - iarg += 2; - } else if (strcmp(arg[iarg],"doff") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal molecule command"); - doffset = force->inumeric(FLERR,arg[iarg+1]); - if (doffset < 0) error->all(FLERR,"Illegal molecule command"); - iarg += 2; - } else if (strcmp(arg[iarg],"ioff") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal molecule command"); - ioffset = force->inumeric(FLERR,arg[iarg+1]); - if (ioffset < 0) error->all(FLERR,"Illegal molecule command"); - iarg += 2; - } else if (strcmp(arg[iarg],"scale") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal molecule command"); - sizescale = force->numeric(FLERR,arg[iarg+1]); - if (sizescale <= 0.0) error->all(FLERR,"Illegal molecule command"); - iarg += 2; - } else break; - } - - index = iarg; - - // last molecule if have scanned all args - - if (iarg == narg) last = 1; - else last = 0; - - // initialize all fields to empty - - initialize(); - - // scan file for sizes of all fields and allocate them - - if (me == 0) open(arg[ifile]); - read(0); - if (me == 0) fclose(fp); - allocate(); - - // read file again to populate all fields - - if (me == 0) open(arg[ifile]); - read(1); - if (me == 0) fclose(fp); - - // stats - - if (me == 0) { - if (screen) - fprintf(screen,"Read molecule %s:\n" - " %d atoms with %d types\n %d bonds with %d types\n" - " %d angles with %d types\n %d dihedrals with %d types\n" - " %d impropers with %d types\n", - id,natoms,ntypes, - nbonds,nbondtypes,nangles,nangletypes, - ndihedrals,ndihedraltypes,nimpropers,nimpropertypes); - if (logfile) - fprintf(logfile,"Read molecule %s:\n" - " %d atoms with %d types\n %d bonds with %d types\n" - " %d angles with %d types\n %d dihedrals with %d types\n" - " %d impropers with %d types\n", - id,natoms,ntypes, - nbonds,nbondtypes,nangles,nangletypes, - ndihedrals,ndihedraltypes,nimpropers,nimpropertypes); - } -} - -/* ---------------------------------------------------------------------- */ - -Molecule::~Molecule() -{ - delete [] id; - deallocate(); -} - -/* ---------------------------------------------------------------------- - compute center = geometric center of molecule - also compute: - dx = displacement of each atom from center - molradius = radius of molecule from center - including finite-size particles or body particles -------------------------------------------------------------------------- */ - -void Molecule::compute_center() -{ - if (centerflag) return; - centerflag = 1; - - center[0] = center[1] = center[2] = 0.0; - for (int i = 0; i < natoms; i++) { - center[0] += x[i][0]; - center[1] += x[i][1]; - center[2] += x[i][2]; - } - center[0] /= natoms; - center[1] /= natoms; - center[2] /= natoms; - - memory->destroy(dx); - memory->create(dx,natoms,3,"molecule:dx"); - - for (int i = 0; i < natoms; i++) { - dx[i][0] = x[i][0] - center[0]; - dx[i][1] = x[i][1] - center[1]; - dx[i][2] = x[i][2] - center[2]; - } - - molradius = 0.0; - for (int i = 0; i < natoms; i++) { - double rad = MathExtra::len3(dx[i]); - if (radiusflag) rad += radius[i]; - molradius = MAX(molradius,rad); - } -} - -/* ---------------------------------------------------------------------- - compute masstotal = total mass of molecule - could have been set by user, otherwise calculate it -------------------------------------------------------------------------- */ - -void Molecule::compute_mass() -{ - if (massflag) return; - massflag = 1; - - if (!rmassflag) atom->check_mass(); - - masstotal = 0.0; - for (int i = 0; i < natoms; i++) { - if (rmassflag) masstotal += rmass[i]; - else masstotal += atom->mass[type[i]]; - } -} - -/* ---------------------------------------------------------------------- - compute com = center of mass of molecule - could have been set by user, otherwise calculate it - works for finite size particles assuming no overlap - also compute: - dxcom = displacement of each atom from COM - comatom = which atom (1-Natom) is nearest the COM - maxextent = furthest any atom in molecule is from comatom (not COM) -------------------------------------------------------------------------- */ - -void Molecule::compute_com() -{ - if (!comflag) { - comflag = 1; - - if (!rmassflag) atom->check_mass(); - - double onemass; - com[0] = com[1] = com[2] = 0.0; - for (int i = 0; i < natoms; i++) { - if (rmassflag) onemass = rmass[i]; - else onemass = atom->mass[type[i]]; - com[0] += x[i][0]*onemass; - com[1] += x[i][1]*onemass; - com[2] += x[i][2]*onemass; - } - com[0] /= masstotal; - com[1] /= masstotal; - com[2] /= masstotal; - } - - memory->destroy(dxcom); - memory->create(dxcom,natoms,3,"molecule:dxcom"); - - for (int i = 0; i < natoms; i++) { - dxcom[i][0] = x[i][0] - com[0]; - dxcom[i][1] = x[i][1] - com[1]; - dxcom[i][2] = x[i][2] - com[2]; - } - - double rsqmin = BIG; - for (int i = 0; i < natoms; i++) { - double rsq = MathExtra::lensq3(dxcom[i]); - if (rsq < rsqmin) { - comatom = i; - rsqmin = rsq; - } - } - - double rsqmax = 0.0; - for (int i = 0; i < natoms; i++) { - double dx = x[comatom][0] - x[i][0]; - double dy = x[comatom][1] - x[i][1]; - double dz = x[comatom][2] - x[i][2]; - double rsq = dx*dx + dy*dy + dz*dz; - rsqmax = MAX(rsqmax,rsq); - } - - comatom++; - maxextent = sqrt(rsqmax); -} - -/* ---------------------------------------------------------------------- - compute itensor = 6 moments of inertia of molecule around xyz axes - could have been set by user, otherwise calculate it - accounts for finite size spheres, assuming no overlap - also compute: - inertia = 3 principal components of inertia - ex,ey,ez = principal axes in space coords - quat = quaternion for orientation of molecule - dxbody = displacement of each atom from COM in body frame -------------------------------------------------------------------------- */ - -void Molecule::compute_inertia() -{ - if (!inertiaflag) { - inertiaflag = 1; - - if (!rmassflag) atom->check_mass(); - - double onemass,dx,dy,dz; - for (int i = 0; i < 6; i++) itensor[i] = 0.0; - for (int i = 0; i < natoms; i++) { - if (rmassflag) onemass = rmass[i]; - else onemass = atom->type[type[i]]; - dx = dxcom[i][0]; - dy = dxcom[i][1]; - dz = dxcom[i][2]; - itensor[0] += onemass * (dy*dy + dz*dz); - itensor[1] += onemass * (dx*dx + dz*dz); - itensor[2] += onemass * (dx*dx + dy*dy); - itensor[3] -= onemass * dy*dz; - itensor[4] -= onemass * dx*dz; - itensor[5] -= onemass * dx*dy; - } - - if (radiusflag) { - for (int i = 0; i < natoms; i++) { - if (rmassflag) onemass = rmass[i]; - else onemass = atom->type[type[i]]; - itensor[0] += SINERTIA*onemass * radius[i]*radius[i]; - itensor[1] += SINERTIA*onemass * radius[i]*radius[i]; - itensor[2] += SINERTIA*onemass * radius[i]*radius[i]; - } - } - } - - // diagonalize inertia tensor for each body via Jacobi rotations - // inertia = 3 eigenvalues = principal moments of inertia - // evectors and exzy = 3 evectors = principal axes of rigid body - - double cross[3]; - double tensor[3][3],evectors[3][3]; - - tensor[0][0] = itensor[0]; - tensor[1][1] = itensor[1]; - tensor[2][2] = itensor[2]; - tensor[1][2] = tensor[2][1] = itensor[3]; - tensor[0][2] = tensor[2][0] = itensor[4]; - tensor[0][1] = tensor[1][0] = itensor[5]; - - if (MathExtra::jacobi(tensor,inertia,evectors)) - error->all(FLERR,"Insufficient Jacobi rotations for rigid molecule"); - - ex[0] = evectors[0][0]; - ex[1] = evectors[1][0]; - ex[2] = evectors[2][0]; - ey[0] = evectors[0][1]; - ey[1] = evectors[1][1]; - ey[2] = evectors[2][1]; - ez[0] = evectors[0][2]; - ez[1] = evectors[1][2]; - ez[2] = evectors[2][2]; - - // if any principal moment < scaled EPSILON, set to 0.0 - - double max; - max = MAX(inertia[0],inertia[1]); - max = MAX(max,inertia[2]); - - if (inertia[0] < EPSILON*max) inertia[0] = 0.0; - if (inertia[1] < EPSILON*max) inertia[1] = 0.0; - if (inertia[2] < EPSILON*max) inertia[2] = 0.0; - - // enforce 3 evectors as a right-handed coordinate system - // flip 3rd vector if needed - - MathExtra::cross3(ex,ey,cross); - if (MathExtra::dot3(cross,ez) < 0.0) MathExtra::negate3(ez); - - // create quaternion - - MathExtra::exyz_to_q(ex,ey,ez,quat); - - // compute displacements in body frame defined by quat - - memory->destroy(dxbody); - memory->create(dxbody,natoms,3,"molecule:dxbody"); - - for (int i = 0; i < natoms; i++) - MathExtra::transpose_matvec(ex,ey,ez,dxcom[i],dxbody[i]); -} - -/* ---------------------------------------------------------------------- - read molecule info from file - flag = 0, just scan for sizes of fields - flag = 1, read and store fields -------------------------------------------------------------------------- */ - -void Molecule::read(int flag) -{ - char line[MAXLINE],keyword[MAXLINE]; - char *eof,*ptr; - - // skip 1st line of file - - if (me == 0) { - eof = fgets(line,MAXLINE,fp); - if (eof == NULL) error->one(FLERR,"Unexpected end of molecule file"); - } - - // read header lines - // skip blank lines or lines that start with "#" - // stop when read an unrecognized line - - while (1) { - - readline(line); - - // trim anything from '#' onward - // if line is blank, continue - - if ((ptr = strchr(line,'#'))) *ptr = '\0'; - if (strspn(line," \t\n\r") == strlen(line)) continue; - - // search line for header keywords and set corresponding variable - - if (strstr(line,"atoms")) sscanf(line,"%d",&natoms); - else if (strstr(line,"bonds")) sscanf(line,"%d",&nbonds); - else if (strstr(line,"angles")) sscanf(line,"%d",&nangles); - else if (strstr(line,"dihedrals")) sscanf(line,"%d",&ndihedrals); - else if (strstr(line,"impropers")) sscanf(line,"%d",&nimpropers); - - else if (strstr(line,"mass")) { - massflag = 1; - sscanf(line,"%lg",&masstotal); - masstotal *= sizescale*sizescale*sizescale; - } - else if (strstr(line,"com")) { - comflag = 1; - sscanf(line,"%lg %lg %lg",&com[0],&com[1],&com[2]); - com[0] *= sizescale; - com[1] *= sizescale; - com[2] *= sizescale; - if (domain->dimension == 2 && com[2] != 0.0) - error->all(FLERR,"Molecule file z center-of-mass must be 0.0 for 2d"); - } - else if (strstr(line,"inertia")) { - inertiaflag = 1; - sscanf(line,"%lg %lg %lg %lg %lg %lg", - &itensor[0],&itensor[1],&itensor[2], - &itensor[3],&itensor[4],&itensor[5]); - itensor[0] *= sizescale*sizescale*sizescale*sizescale*sizescale; - itensor[1] *= sizescale*sizescale*sizescale*sizescale*sizescale; - itensor[2] *= sizescale*sizescale*sizescale*sizescale*sizescale; - itensor[3] *= sizescale*sizescale*sizescale*sizescale*sizescale; - itensor[4] *= sizescale*sizescale*sizescale*sizescale*sizescale; - itensor[5] *= sizescale*sizescale*sizescale*sizescale*sizescale; - } - else if (strstr(line,"body")) { - bodyflag = 1; - avec_body = (AtomVecBody *) atom->style_match("body"); - if (!avec_body) - error->all(FLERR,"Molecule file requires atom style body"); - sscanf(line,"%d %d",&nibody,&ndbody); - } - - else break; - } - - // error checks - - if (natoms < 1) error->all(FLERR,"No count or invalid atom count in molecule file"); - if (nbonds < 0) error->all(FLERR,"Invalid bond count in molecule file"); - if (nangles < 0) error->all(FLERR,"Invalid angle count in molecule file"); - if (ndihedrals < 0) - error->all(FLERR,"Invalid dihedral count in molecule file"); - if (nimpropers < 0) - error->all(FLERR,"Invalid improper count in molecule file"); - - // count = vector for tallying bonds,angles,etc per atom - - if (flag == 0) memory->create(count,natoms,"molecule:count"); - else count = NULL; - - // grab keyword and skip next line - - parse_keyword(0,line,keyword); - readline(line); - - // loop over sections of molecule file - - while (strlen(keyword)) { - if (strcmp(keyword,"Coords") == 0) { - xflag = 1; - if (flag) coords(line); - else skip_lines(natoms,line); - } else if (strcmp(keyword,"Types") == 0) { - typeflag = 1; - if (flag) types(line); - else skip_lines(natoms,line); - } else if (strcmp(keyword,"Charges") == 0) { - qflag = 1; - if (flag) charges(line); - else skip_lines(natoms,line); - } else if (strcmp(keyword,"Diameters") == 0) { - radiusflag = 1; - if (flag) diameters(line); - else skip_lines(natoms,line); - } else if (strcmp(keyword,"Masses") == 0) { - rmassflag = 1; - if (flag) masses(line); - else skip_lines(natoms,line); - - } else if (strcmp(keyword,"replambdaH") == 0) { - replambdaHflag = 1; - if (flag) representative_atom(line); - else skip_lines(natoms,line); - } else if (strcmp(keyword,"moltypeH") == 0) { - moltypeHflag = 1; - if (flag) moltype_atom(line); - else skip_lines(natoms,line); - - } else if (strcmp(keyword,"Bonds") == 0) { - if (nbonds == 0) - error->all(FLERR,"Molecule file has bonds but no nbonds setting"); - bondflag = tag_require = 1; - bonds(flag,line); - } else if (strcmp(keyword,"Angles") == 0) { - if (nangles == 0) - error->all(FLERR,"Molecule file has angles but no nangles setting"); - angleflag = tag_require = 1; - angles(flag,line); - } else if (strcmp(keyword,"Dihedrals") == 0) { - if (ndihedrals == 0) error->all(FLERR,"Molecule file has dihedrals " - "but no ndihedrals setting"); - dihedralflag = tag_require = 1; - dihedrals(flag,line); - } else if (strcmp(keyword,"Impropers") == 0) { - if (nimpropers == 0) error->all(FLERR,"Molecule file has impropers " - "but no nimpropers setting"); - improperflag = tag_require = 1; - impropers(flag,line); - - } else if (strcmp(keyword,"Special Bond Counts") == 0) { - nspecialflag = 1; - nspecial_read(flag,line); - } else if (strcmp(keyword,"Special Bonds") == 0) { - specialflag = tag_require = 1; - if (flag) special_read(line); - else skip_lines(natoms,line); - - } else if (strcmp(keyword,"Shake Flags") == 0) { - shakeflagflag = 1; - if (flag) shakeflag_read(line); - else skip_lines(natoms,line); - } else if (strcmp(keyword,"Shake Atoms") == 0) { - shakeatomflag = tag_require = 1; - if (shaketypeflag) shakeflag = 1; - if (!shakeflagflag) - error->all(FLERR,"Molecule file shake flags not before shake atoms"); - if (flag) shakeatom_read(line); - else skip_lines(natoms,line); - } else if (strcmp(keyword,"Shake Bond Types") == 0) { - shaketypeflag = 1; - if (shakeatomflag) shakeflag = 1; - if (!shakeflagflag) - error->all(FLERR,"Molecule file shake flags not before shake bonds"); - if (flag) shaketype_read(line); - else skip_lines(natoms,line); - - } else if (strcmp(keyword,"Body Integers") == 0) { - if (bodyflag == 0 || nibody == 0) - error->all(FLERR,"Molecule file has body params " - "but no setting for them"); - ibodyflag = 1; - body(flag,0,line); - } else if (strcmp(keyword,"Body Doubles") == 0) { - if (bodyflag == 0 || ndbody == 0) - error->all(FLERR,"Molecule file has body params " - "but no setting for them"); - dbodyflag = 1; - body(flag,1,line); - - } else error->one(FLERR,"Unknown section in molecule file"); - - parse_keyword(1,line,keyword); - } - - // clean up - - memory->destroy(count); - - // error check - - if (flag == 0) { - if ((nspecialflag && !specialflag) || (!nspecialflag && specialflag)) - error->all(FLERR,"Molecule file needs both Special Bond sections"); - if (specialflag && !bondflag) - error->all(FLERR,"Molecule file has special flags but no bonds"); - if ((shakeflagflag || shakeatomflag || shaketypeflag) && !shakeflag) - error->all(FLERR,"Molecule file shake info is incomplete"); - if (bodyflag && nibody && ibodyflag == 0) - error->all(FLERR,"Molecule file has no Body Integers section"); - if (bodyflag && ndbody && dbodyflag == 0) - error->all(FLERR,"Molecule file has no Body Doubles section"); - } - - // auto-generate special bonds - - if (bondflag && !specialflag) { - specialflag = 1; - nspecialflag = 1; - maxspecial = atom->maxspecial; - if (flag) special_generate(); - } - - // body particle must have natom = 1 - // set radius by having body class compute its own radius - - if (bodyflag) { - radiusflag = 1; - if (natoms != 1) - error->all(FLERR,"Molecule natoms must be 1 for body particle"); - if (sizescale != 1.0) - error->all(FLERR,"Molecule sizescale must be 1.0 for body particle"); - if (flag) { - radius[0] = avec_body->radius_body(nibody,ndbody,ibodyparams,dbodyparams); - maxradius = radius[0]; - } - } -} - -/* ---------------------------------------------------------------------- - read coords from file -------------------------------------------------------------------------- */ - -void Molecule::coords(char *line) -{ - int tmp; - for (int i = 0; i < natoms; i++) { - readline(line); - if (i == 0) { - int nwords = atom->count_words(line); - if (nwords != 4) - error->all(FLERR,"Invalid Coords section in molecule file"); - } - sscanf(line,"%d %lg %lg %lg",&tmp,&x[i][0],&x[i][1],&x[i][2]); - x[i][0] *= sizescale; - x[i][1] *= sizescale; - x[i][2] *= sizescale; - } - - if (domain->dimension == 2) { - for (int i = 0; i < natoms; i++) - if (x[i][2] != 0.0) - error->all(FLERR,"Molecule file z coord must be 0.0 for 2d"); - } -} - -/* ---------------------------------------------------------------------- - read types from file - set ntypes = max of any atom type -------------------------------------------------------------------------- */ - -void Molecule::types(char *line) -{ - int tmp; - for (int i = 0; i < natoms; i++) { - readline(line); - if (i == 0) { - int nwords = atom->count_words(line); - if (nwords != 2) - error->all(FLERR,"Invalid Types section in molecule file"); - } - sscanf(line,"%d %d",&tmp,&type[i]); - type[i] += toffset; - } - - for (int i = 0; i < natoms; i++) - if (type[i] <= 0) - error->all(FLERR,"Invalid atom type in molecule file"); - - for (int i = 0; i < natoms; i++) - ntypes = MAX(ntypes,type[i]); -} - -/* ---------------------------------------------------------------------- - read charges from file -------------------------------------------------------------------------- */ - -void Molecule::charges(char *line) -{ - int tmp; - for (int i = 0; i < natoms; i++) { - readline(line); - if (i == 0) { - int nwords = atom->count_words(line); - if (nwords != 2) - error->all(FLERR,"Invalid Charges section in molecule file"); - } - sscanf(line,"%d %lg",&tmp,&q[i]); - } -} - -void Molecule::representative_atom(char *line) -{ - int tmp; - for (int i = 0; i < natoms; i++) { - readline(line); - sscanf(line,"%d %d",&tmp,&replambdaH[i]); - printf("i=%d rep = %d",i,replambdaH[i]); - } -} - -void Molecule::moltype_atom(char *line) -{ - int tmp; - for (int i = 0; i < natoms; i++) { - readline(line); - sscanf(line,"%d %d",&tmp,&moltypeH[i]); - printf("i=%d rep = %d",i,moltypeH[i]); - } -} - -/* ---------------------------------------------------------------------- - read diameters from file and set radii -------------------------------------------------------------------------- */ - -void Molecule::diameters(char *line) -{ - int tmp; - maxradius = 0.0; - for (int i = 0; i < natoms; i++) { - readline(line); - if (i == 0) { - int nwords = atom->count_words(line); - if (nwords != 2) - error->all(FLERR,"Invalid Diameters section in molecule file"); - } - sscanf(line,"%d %lg",&tmp,&radius[i]); - radius[i] *= sizescale; - radius[i] *= 0.5; - maxradius = MAX(maxradius,radius[i]); - } - - for (int i = 0; i < natoms; i++) - if (radius[i] < 0.0) - error->all(FLERR,"Invalid atom diameter in molecule file"); -} - -/* ---------------------------------------------------------------------- - read masses from file -------------------------------------------------------------------------- */ - -void Molecule::masses(char *line) -{ - int tmp; - for (int i = 0; i < natoms; i++) { - readline(line); - if (i == 0) { - int nwords = atom->count_words(line); - if (nwords != 2) - error->all(FLERR,"Invalid Masses section in molecule file"); - } - sscanf(line,"%d %lg",&tmp,&rmass[i]); - rmass[i] *= sizescale*sizescale*sizescale; - } - - for (int i = 0; i < natoms; i++) - if (rmass[i] <= 0.0) error->all(FLERR,"Invalid atom mass in molecule file"); -} - -/* ---------------------------------------------------------------------- - read bonds from file - set nbondtypes = max type of any bond - store each with both atoms if newton_bond = 0 - if flag = 0, just count bonds/atom - if flag = 1, store them with atoms -------------------------------------------------------------------------- */ - -void Molecule::bonds(int flag, char *line) -{ - int tmp,itype; - tagint m,atom1,atom2; - int newton_bond = force->newton_bond; - - if (flag == 0) - for (int i = 0; i < natoms; i++) count[i] = 0; - else - for (int i = 0; i < natoms; i++) num_bond[i] = 0; - - for (int i = 0; i < nbonds; i++) { - readline(line); - if (i == 0) { - int nwords = atom->count_words(line); - if (nwords != 4) - error->all(FLERR,"Invalid Bonds section in molecule file"); - } - sscanf(line,"%d %d " TAGINT_FORMAT " " TAGINT_FORMAT, - &tmp,&itype,&atom1,&atom2); - itype += boffset; - - if (atom1 <= 0 || atom1 > natoms || - atom2 <= 0 || atom2 > natoms) - error->one(FLERR,"Invalid atom ID in Bonds section of molecule file"); - if (itype <= 0) - error->one(FLERR,"Invalid bond type in Bonds section of molecule file"); - - if (flag) { - m = atom1-1; - nbondtypes = MAX(nbondtypes,itype); - bond_type[m][num_bond[m]] = itype; - bond_atom[m][num_bond[m]] = atom2; - num_bond[m]++; - if (newton_bond == 0) { - m = atom2-1; - bond_type[m][num_bond[m]] = itype; - bond_atom[m][num_bond[m]] = atom1; - num_bond[m]++; - } - } else { - count[atom1-1]++; - if (newton_bond == 0) count[atom2-1]++; - } - } - - // bond_per_atom = max of count vector - - if (flag == 0) { - bond_per_atom = 0; - for (int i = 0; i < natoms; i++) - bond_per_atom = MAX(bond_per_atom,count[i]); - } -} - -/* ---------------------------------------------------------------------- - read angles from file - store each with all 3 atoms if newton_bond = 0 - if flag = 0, just count angles/atom - if flag = 1, store them with atoms -------------------------------------------------------------------------- */ - -void Molecule::angles(int flag, char *line) -{ - int tmp,itype; - tagint m,atom1,atom2,atom3; - int newton_bond = force->newton_bond; - - if (flag == 0) - for (int i = 0; i < natoms; i++) count[i] = 0; - else - for (int i = 0; i < natoms; i++) num_angle[i] = 0; - - for (int i = 0; i < nangles; i++) { - readline(line); - if (i == 0) { - int nwords = atom->count_words(line); - if (nwords != 5) - error->all(FLERR,"Invalid Angles section in molecule file"); - } - sscanf(line,"%d %d " TAGINT_FORMAT " " TAGINT_FORMAT " " TAGINT_FORMAT, - &tmp,&itype,&atom1,&atom2,&atom3); - itype += aoffset; - - if (atom1 <= 0 || atom1 > natoms || - atom2 <= 0 || atom2 > natoms || - atom3 <= 0 || atom3 > natoms) - error->one(FLERR,"Invalid atom ID in Angles section of molecule file"); - if (itype <= 0) - error->one(FLERR,"Invalid angle type in Angles section of molecule file"); - - if (flag) { - m = atom2-1; - nangletypes = MAX(nangletypes,itype); - angle_type[m][num_angle[m]] = itype; - angle_atom1[m][num_angle[m]] = atom1; - angle_atom2[m][num_angle[m]] = atom2; - angle_atom3[m][num_angle[m]] = atom3; - num_angle[m]++; - if (newton_bond == 0) { - m = atom1-1; - angle_type[m][num_angle[m]] = itype; - angle_atom1[m][num_angle[m]] = atom1; - angle_atom2[m][num_angle[m]] = atom2; - angle_atom3[m][num_angle[m]] = atom3; - num_angle[m]++; - m = atom3-1; - angle_type[m][num_angle[m]] = itype; - angle_atom1[m][num_angle[m]] = atom1; - angle_atom2[m][num_angle[m]] = atom2; - angle_atom3[m][num_angle[m]] = atom3; - num_angle[m]++; - } - } else { - count[atom2-1]++; - if (newton_bond == 0) { - count[atom1-1]++; - count[atom3-1]++; - } - } - } - - // angle_per_atom = max of count vector - - if (flag == 0) { - angle_per_atom = 0; - for (int i = 0; i < natoms; i++) - angle_per_atom = MAX(angle_per_atom,count[i]); - } -} - -/* ---------------------------------------------------------------------- - read dihedrals from file - store each with all 4 atoms if newton_bond = 0 - if flag = 0, just count dihedrals/atom - if flag = 1, store them with atoms -------------------------------------------------------------------------- */ - -void Molecule::dihedrals(int flag, char *line) -{ - int tmp,itype; - tagint m,atom1,atom2,atom3,atom4; - int newton_bond = force->newton_bond; - - if (flag == 0) - for (int i = 0; i < natoms; i++) count[i] = 0; - else - for (int i = 0; i < natoms; i++) num_dihedral[i] = 0; - - for (int i = 0; i < ndihedrals; i++) { - readline(line); - if (i == 0) { - int nwords = atom->count_words(line); - if (nwords != 6) - error->all(FLERR,"Invalid Dihedrals section in molecule file"); - } - sscanf(line,"%d %d " TAGINT_FORMAT " " TAGINT_FORMAT " " - TAGINT_FORMAT " " TAGINT_FORMAT " ", - &tmp,&itype,&atom1,&atom2,&atom3,&atom4); - itype += doffset; - - if (atom1 <= 0 || atom1 > natoms || - atom2 <= 0 || atom2 > natoms || - atom3 <= 0 || atom3 > natoms || - atom4 <= 0 || atom4 > natoms) - error->one(FLERR, - "Invalid atom ID in dihedrals section of molecule file"); - if (itype <= 0) - error->one(FLERR, - "Invalid dihedral type in dihedrals section of molecule file"); - - if (flag) { - m = atom2-1; - ndihedraltypes = MAX(ndihedraltypes,itype); - dihedral_type[m][num_dihedral[m]] = itype; - dihedral_atom1[m][num_dihedral[m]] = atom1; - dihedral_atom2[m][num_dihedral[m]] = atom2; - dihedral_atom3[m][num_dihedral[m]] = atom3; - dihedral_atom4[m][num_dihedral[m]] = atom4; - num_dihedral[m]++; - if (newton_bond == 0) { - m = atom1-1; - dihedral_type[m][num_dihedral[m]] = itype; - dihedral_atom1[m][num_dihedral[m]] = atom1; - dihedral_atom2[m][num_dihedral[m]] = atom2; - dihedral_atom3[m][num_dihedral[m]] = atom3; - dihedral_atom4[m][num_dihedral[m]] = atom4; - num_dihedral[m]++; - m = atom3-1; - dihedral_type[m][num_dihedral[m]] = itype; - dihedral_atom1[m][num_dihedral[m]] = atom1; - dihedral_atom2[m][num_dihedral[m]] = atom2; - dihedral_atom3[m][num_dihedral[m]] = atom3; - dihedral_atom4[m][num_dihedral[m]] = atom4; - num_dihedral[m]++; - m = atom4-1; - dihedral_type[m][num_dihedral[m]] = itype; - dihedral_atom1[m][num_dihedral[m]] = atom1; - dihedral_atom2[m][num_dihedral[m]] = atom2; - dihedral_atom3[m][num_dihedral[m]] = atom3; - dihedral_atom4[m][num_dihedral[m]] = atom4; - num_dihedral[m]++; - } - } else { - count[atom2-1]++; - if (newton_bond == 0) { - count[atom1-1]++; - count[atom3-1]++; - count[atom4-1]++; - } - } - } - - // dihedral_per_atom = max of count vector - - if (flag == 0) { - dihedral_per_atom = 0; - for (int i = 0; i < natoms; i++) - dihedral_per_atom = MAX(dihedral_per_atom,count[i]); - } -} - -/* ---------------------------------------------------------------------- - read impropers from file - store each with all 4 atoms if newton_bond = 0 - if flag = 0, just count impropers/atom - if flag = 1, store them with atoms -------------------------------------------------------------------------- */ - -void Molecule::impropers(int flag, char *line) -{ - int tmp,itype; - tagint m,atom1,atom2,atom3,atom4; - int newton_bond = force->newton_bond; - - if (flag == 0) - for (int i = 0; i < natoms; i++) count[i] = 0; - else - for (int i = 0; i < natoms; i++) num_improper[i] = 0; - - for (int i = 0; i < nimpropers; i++) { - readline(line); - if (i == 0) { - int nwords = atom->count_words(line); - if (nwords != 6) - error->all(FLERR,"Invalid Impropers section in molecule file"); - } - sscanf(line,"%d %d " TAGINT_FORMAT " " TAGINT_FORMAT " " - TAGINT_FORMAT " " TAGINT_FORMAT " ", - &tmp,&itype,&atom1,&atom2,&atom3,&atom4); - itype += ioffset; - - if (atom1 <= 0 || atom1 > natoms || - atom2 <= 0 || atom2 > natoms || - atom3 <= 0 || atom3 > natoms || - atom4 <= 0 || atom4 > natoms) - error->one(FLERR, - "Invalid atom ID in impropers section of molecule file"); - if (itype <= 0) - error->one(FLERR, - "Invalid improper type in impropers section of molecule file"); - - if (flag) { - m = atom2-1; - nimpropertypes = MAX(nimpropertypes,itype); - improper_type[m][num_improper[m]] = itype; - improper_atom1[m][num_improper[m]] = atom1; - improper_atom2[m][num_improper[m]] = atom2; - improper_atom3[m][num_improper[m]] = atom3; - improper_atom4[m][num_improper[m]] = atom4; - num_improper[m]++; - if (newton_bond == 0) { - m = atom1-1; - improper_type[m][num_improper[m]] = itype; - improper_atom1[m][num_improper[m]] = atom1; - improper_atom2[m][num_improper[m]] = atom2; - improper_atom3[m][num_improper[m]] = atom3; - improper_atom4[m][num_improper[m]] = atom4; - num_improper[m]++; - m = atom3-1; - improper_type[m][num_improper[m]] = itype; - improper_atom1[m][num_improper[m]] = atom1; - improper_atom2[m][num_improper[m]] = atom2; - improper_atom3[m][num_improper[m]] = atom3; - improper_atom4[m][num_improper[m]] = atom4; - num_improper[m]++; - m = atom4-1; - improper_type[m][num_improper[m]] = itype; - improper_atom1[m][num_improper[m]] = atom1; - improper_atom2[m][num_improper[m]] = atom2; - improper_atom3[m][num_improper[m]] = atom3; - improper_atom4[m][num_improper[m]] = atom4; - num_improper[m]++; - } - } else { - count[atom2-1]++; - if (newton_bond == 0) { - count[atom1-1]++; - count[atom3-1]++; - count[atom4-1]++; - } - } - } - - // improper_per_atom = max of count vector - - if (flag == 0) { - improper_per_atom = 0; - for (int i = 0; i < natoms; i++) - improper_per_atom = MAX(improper_per_atom,count[i]); - } -} - -/* ---------------------------------------------------------------------- - read 3 special bonds counts from file - if flag = 0, just tally maxspecial - if flag = 1, store them with atoms -------------------------------------------------------------------------- */ - -void Molecule::nspecial_read(int flag, char *line) -{ - int tmp,c1,c2,c3; - - if (flag == 0) maxspecial = 0; - - for (int i = 0; i < natoms; i++) { - readline(line); - if (i == 0) { - int nwords = atom->count_words(line); - if (nwords != 4) - error->all(FLERR,"Invalid Special Bond Counts section in " - "molecule file"); - } - sscanf(line,"%d %d %d %d",&tmp,&c1,&c2,&c3); - - if (flag) { - nspecial[i][0] = c1; - nspecial[i][1] = c1+c2; - nspecial[i][2] = c1+c2+c3; - } else maxspecial = MAX(maxspecial,c1+c2+c3); - } -} - -/* ---------------------------------------------------------------------- - read special bond indices from file -------------------------------------------------------------------------- */ - -void Molecule::special_read(char *line) -{ - int m,nwords; - char **words = new char*[maxspecial+1]; - - for (int i = 0; i < natoms; i++) { - readline(line); - nwords = parse(line,words,maxspecial+1); - if (nwords != nspecial[i][2]+1) - error->all(FLERR,"Molecule file special list " - "does not match special count"); - - for (m = 1; m < nwords; m++) { - special[i][m-1] = ATOTAGINT(words[m]); - if (special[i][m-1] <= 0 || special[i][m-1] > natoms || - special[i][m-1] == i+1) - error->all(FLERR,"Invalid special atom index in molecule file"); - } - } - - delete [] words; -} - -/* ---------------------------------------------------------------------- - auto generate special bond info -------------------------------------------------------------------------- */ - -void Molecule::special_generate() -{ - int newton_bond = force->newton_bond; - tagint atom1,atom2; - int count[natoms]; - - for (int i = 0; i < natoms; i++) count[i] = 0; - - // 1-2 neighbors - - if (newton_bond) { - for (int i = 0; i < natoms; i++) { - for (int j = 0; j < num_bond[i]; j++) { - atom1 = i; - atom2 = bond_atom[i][j]-1; - nspecial[i][0]++; - nspecial[atom2][0]++; - if (count[i] >= maxspecial || count[atom2] >= maxspecial) - error->one(FLERR,"Molecule auto special bond generation overflow"); - special[i][count[i]++] = atom2 + 1; - special[atom2][count[atom2]++] = i + 1; - } - } - } else { - for (int i = 0; i < natoms; i++) { - nspecial[i][0] = num_bond[i]; - for (int j = 0; j < num_bond[i]; j++) { - atom1 = i; - atom2 = bond_atom[i][j]; - if (count[atom1] >= maxspecial) - error->one(FLERR,"Molecule auto special bond generation overflow"); - special[i][count[atom1]++] = atom2; - } - } - } - - // 1-3 neighbors with no duplicates - - for (int i = 0; i < natoms; i++) nspecial[i][1] = nspecial[i][0]; - - int dedup; - for (int i = 0; i < natoms; i++) { - for (int m = 0; m < nspecial[i][0]; m++) { - for (int j = 0; j < nspecial[special[i][m]-1][0]; j++) { - dedup = 0; - for (int k =0; k < count[i]; k++) { - if (special[special[i][m]-1][j] == special[i][k] || - special[special[i][m]-1][j] == i+1) { - dedup = 1; - } - } - if (!dedup) { - if (count[i] >= maxspecial) - error->one(FLERR,"Molecule auto special bond generation overflow"); - special[i][count[i]++] = special[special[i][m]-1][j]; - nspecial[i][1]++; - } - } - } - } - - // 1-4 neighbors with no duplicates - - for (int i = 0; i < natoms; i++) nspecial[i][2] = nspecial[i][1]; - - for (int i = 0; i < natoms; i++) { - for (int m = nspecial[i][0]; m < nspecial[i][1]; m++) { - for (int j = 0; j < nspecial[special[i][m]-1][0]; j++) { - dedup = 0; - for (int k =0; k < count[i]; k++) { - if (special[special[i][m]-1][j] == special[i][k] || - special[special[i][m]-1][j] == i+1) { - dedup = 1; - } - } - if (!dedup) { - if (count[i] >= maxspecial) - error->one(FLERR,"Molecule auto special bond generation overflow"); - special[i][count[i]++] = special[special[i][m]-1][j]; - nspecial[i][2]++; - } - } - } - } -} - -/* ---------------------------------------------------------------------- - read SHAKE flags from file -------------------------------------------------------------------------- */ - -void Molecule::shakeflag_read(char *line) -{ - int tmp; - for (int i = 0; i < natoms; i++) { - readline(line); - sscanf(line,"%d %d",&tmp,&shake_flag[i]); - } - - for (int i = 0; i < natoms; i++) - if (shake_flag[i] < 0 || shake_flag[i] > 4) - error->all(FLERR,"Invalid shake flag in molecule file"); -} - -/* ---------------------------------------------------------------------- - read SHAKE atom info from file -------------------------------------------------------------------------- */ - -void Molecule::shakeatom_read(char *line) -{ - int tmp; - for (int i = 0; i < natoms; i++) { - readline(line); - if (shake_flag[i] == 1) - sscanf(line,"%d " TAGINT_FORMAT " " TAGINT_FORMAT " " TAGINT_FORMAT, - &tmp,&shake_atom[i][0],&shake_atom[i][1],&shake_atom[i][2]); - else if (shake_flag[i] == 2) - sscanf(line,"%d " TAGINT_FORMAT " " TAGINT_FORMAT, - &tmp,&shake_atom[i][0],&shake_atom[i][1]); - else if (shake_flag[i] == 3) - sscanf(line,"%d " TAGINT_FORMAT " " TAGINT_FORMAT " " TAGINT_FORMAT, - &tmp,&shake_atom[i][0],&shake_atom[i][1],&shake_atom[i][2]); - else if (shake_flag[i] == 4) - sscanf(line,"%d " TAGINT_FORMAT " " TAGINT_FORMAT " " - TAGINT_FORMAT " " TAGINT_FORMAT, - &tmp,&shake_atom[i][0],&shake_atom[i][1], - &shake_atom[i][2],&shake_atom[i][3]); - } - - for (int i = 0; i < natoms; i++) { - int m = shake_flag[i]; - if (m == 1) m = 3; - for (int j = 0; j < m; j++) - if (shake_atom[i][j] <= 0 || shake_atom[i][j] > natoms) - error->all(FLERR,"Invalid shake atom in molecule file"); - } -} - -/* ---------------------------------------------------------------------- - read SHAKE bond type info from file -------------------------------------------------------------------------- */ - -void Molecule::shaketype_read(char *line) -{ - int tmp; - for (int i = 0; i < natoms; i++) { - readline(line); - if (shake_flag[i] == 1) - sscanf(line,"%d %d %d %d",&tmp, - &shake_type[i][0],&shake_type[i][1],&shake_type[i][2]); - else if (shake_flag[i] == 2) - sscanf(line,"%d %d",&tmp,&shake_type[i][0]); - else if (shake_flag[i] == 3) - sscanf(line,"%d %d %d",&tmp,&shake_type[i][0],&shake_type[i][1]); - else if (shake_flag[i] == 4) - sscanf(line,"%d %d %d %d",&tmp, - &shake_type[i][0],&shake_type[i][1],&shake_type[i][2]); - } - - for (int i = 0; i < natoms; i++) { - int m = shake_flag[i]; - if (m == 1) m = 3; - for (int j = 0; j < m-1; j++) - if (shake_type[i][j] <= 0) - error->all(FLERR,"Invalid shake bond type in molecule file"); - if (shake_flag[i] == 1) - if (shake_type[i][2] <= 0) - error->all(FLERR,"Invalid shake angle type in molecule file"); - } -} - -/* ---------------------------------------------------------------------- - read body params from file - pflag = 0/1 for integer/double params -------------------------------------------------------------------------- */ - -void Molecule::body(int flag, int pflag, char *line) -{ - int i,ncount; - - int nparam = nibody; - if (pflag) nparam = ndbody; - - int nword = 0; - while (nword < nparam) { - readline(line); - - ncount = atom->count_words(line); - if (ncount == 0) - error->one(FLERR,"Too few values in body section of molecule file"); - if (nword+ncount > nparam) - error->all(FLERR,"Too many values in body section of molecule file"); - - if (flag) { - if (pflag == 0) { - ibodyparams[nword++] = force->inumeric(FLERR,strtok(line," \t\n\r\f")); - for (i = 1; i < ncount; i++) - ibodyparams[nword++] = - force->inumeric(FLERR,strtok(NULL," \t\n\r\f")); - } else { - dbodyparams[nword++] = force->numeric(FLERR,strtok(line," \t\n\r\f")); - for (i = 1; i < ncount; i++) - dbodyparams[nword++] = - force->numeric(FLERR,strtok(NULL," \t\n\r\f")); - } - } else nword += ncount; - } -} - -/* ---------------------------------------------------------------------- - error check molecule attributes and topology against system settings - flag = 0, just check this molecule - flag = 1, check all molecules in set, this is 1st molecule in set -------------------------------------------------------------------------- */ - -void Molecule::check_attributes(int flag) -{ - int n = 1; - if (flag) n = nset; - int imol = atom->find_molecule(id); - - for (int i = imol; i < imol+n; i++) { - Molecule *onemol = atom->molecules[imol]; - - // check per-atom attributes of molecule - // warn if not a match - - int mismatch = 0; - if (onemol->replambdaHflag && !atom->replambdaH_flag) mismatch = 1; - if (onemol->moltypeHflag && !atom->moltypeH_flag) mismatch = 1; - if (onemol->qflag && !atom->q_flag) mismatch = 1; - if (onemol->radiusflag && !atom->radius_flag) mismatch = 1; - if (onemol->rmassflag && !atom->rmass_flag) mismatch = 1; - - if (mismatch && me == 0) - error->warning(FLERR, - "Molecule attributes do not match system attributes"); - - // for all atom styles, check nbondtype,etc - - mismatch = 0; - if (atom->nbondtypes < onemol->nbondtypes) mismatch = 1; - if (atom->nangletypes < onemol->nangletypes) mismatch = 1; - if (atom->ndihedraltypes < onemol->ndihedraltypes) mismatch = 1; - if (atom->nimpropertypes < onemol->nimpropertypes) mismatch = 1; - - if (mismatch) - error->all(FLERR,"Molecule topology type exceeds system topology type"); - - // for molecular atom styles, check bond_per_atom,etc + maxspecial - // do not check for atom style template, since nothing stored per atom - - if (atom->molecular == 1) { - if (atom->avec->bonds_allow && - atom->bond_per_atom < onemol->bond_per_atom) mismatch = 1; - if (atom->avec->angles_allow && - atom->angle_per_atom < onemol->angle_per_atom) mismatch = 1; - if (atom->avec->dihedrals_allow && - atom->dihedral_per_atom < onemol->dihedral_per_atom) mismatch = 1; - if (atom->avec->impropers_allow && - atom->improper_per_atom < onemol->improper_per_atom) mismatch = 1; - if (atom->maxspecial < onemol->maxspecial) mismatch = 1; - - if (mismatch) - error->all(FLERR,"Molecule toplogy/atom exceeds system topology/atom"); - } - - // warn if molecule topology defined but no special settings - - if (onemol->bondflag && !onemol->specialflag) - if (me == 0) error->warning(FLERR,"Molecule has bond topology " - "but no special bond settings"); - } -} - -/* ---------------------------------------------------------------------- - init all data structures to empty -------------------------------------------------------------------------- */ - -void Molecule::initialize() -{ - natoms = 0; - nbonds = nangles = ndihedrals = nimpropers = 0; - ntypes = 0; - nbondtypes = nangletypes = ndihedraltypes = nimpropertypes = 0; - nibody = ndbody = 0; - - bond_per_atom = angle_per_atom = dihedral_per_atom = improper_per_atom = 0; - maxspecial = 0; - - xflag = typeflag = qflag = radiusflag = rmassflag = 0; - bondflag = angleflag = dihedralflag = improperflag = 0; - nspecialflag = specialflag = 0; - shakeflag = shakeflagflag = shakeatomflag = shaketypeflag = 0; - bodyflag = ibodyflag = dbodyflag = 0; - - centerflag = massflag = comflag = inertiaflag = 0; - tag_require = 0; - - x = NULL; - type = NULL; - q = NULL; - radius = NULL; - rmass = NULL; - - num_bond = NULL; - bond_type = NULL; - bond_atom = NULL; - - num_angle = NULL; - angle_type = NULL; - angle_atom1 = angle_atom2 = angle_atom3 = NULL; - - num_dihedral = NULL; - dihedral_type = NULL; - dihedral_atom1 = dihedral_atom2 = dihedral_atom3 = dihedral_atom4 = NULL; - - num_improper = NULL; - improper_type = NULL; - improper_atom1 = improper_atom2 = improper_atom3 = improper_atom4 = NULL; - - nspecial = NULL; - special = NULL; - - shake_flag = NULL; - shake_atom = NULL; - shake_type = NULL; - - ibodyparams = NULL; - dbodyparams = NULL; - - dx = NULL; - dxcom = NULL; - dxbody = NULL; -} - -/* ---------------------------------------------------------------------- - allocate all data structures - also initialize values for data structures that are always allocated -------------------------------------------------------------------------- */ - -void Molecule::allocate() -{ - if (xflag) memory->create(x,natoms,3,"molecule:x"); - if (typeflag) memory->create(type,natoms,"molecule:type"); - if (qflag) memory->create(q,natoms,"molecule:q"); - if (radiusflag) memory->create(radius,natoms,"molecule:radius"); - if (rmassflag) memory->create(rmass,natoms,"molecule:rmass"); - if (replambdaHflag) memory->create(replambdaH,natoms,"molecule:replambdaH"); - if (moltypeHflag) memory->create(moltypeH,natoms,"molecule:moltypeH"); - - // always allocate num_bond,num_angle,etc and special+nspecial - // even if not in molecule file, initialize to 0 - // this is so methods that use these arrays don't have to check they exist - - memory->create(num_bond,natoms,"molecule:num_bond"); - for (int i = 0; i < natoms; i++) num_bond[i] = 0; - memory->create(num_angle,natoms,"molecule:num_angle"); - for (int i = 0; i < natoms; i++) num_angle[i] = 0; - memory->create(num_dihedral,natoms,"molecule:num_dihedral"); - for (int i = 0; i < natoms; i++) num_dihedral[i] = 0; - memory->create(num_improper,natoms,"molecule:num_improper"); - for (int i = 0; i < natoms; i++) num_improper[i] = 0; - - memory->create(special,natoms,maxspecial,"molecule:special"); - - memory->create(nspecial,natoms,3,"molecule:nspecial"); - for (int i = 0; i < natoms; i++) - nspecial[i][0] = nspecial[i][1] = nspecial[i][2] = 0; - - if (bondflag) { - memory->create(bond_type,natoms,bond_per_atom, - "molecule:bond_type"); - memory->create(bond_atom,natoms,bond_per_atom, - "molecule:bond_atom"); - } - - if (angleflag) { - memory->create(angle_type,natoms,angle_per_atom, - "molecule:angle_type"); - memory->create(angle_atom1,natoms,angle_per_atom, - "molecule:angle_atom1"); - memory->create(angle_atom2,natoms,angle_per_atom, - "molecule:angle_atom2"); - memory->create(angle_atom3,natoms,angle_per_atom, - "molecule:angle_atom3"); - } - - if (dihedralflag) { - memory->create(dihedral_type,natoms,dihedral_per_atom, - "molecule:dihedral_type"); - memory->create(dihedral_atom1,natoms,dihedral_per_atom, - "molecule:dihedral_atom1"); - memory->create(dihedral_atom2,natoms,dihedral_per_atom, - "molecule:dihedral_atom2"); - memory->create(dihedral_atom3,natoms,dihedral_per_atom, - "molecule:dihedral_atom3"); - memory->create(dihedral_atom4,natoms,dihedral_per_atom, - "molecule:dihedral_atom4"); - } - - if (improperflag) { - memory->create(improper_type,natoms,improper_per_atom, - "molecule:improper_type"); - memory->create(improper_atom1,natoms,improper_per_atom, - "molecule:improper_atom1"); - memory->create(improper_atom2,natoms,improper_per_atom, - "molecule:improper_atom2"); - memory->create(improper_atom3,natoms,improper_per_atom, - "molecule:improper_atom3"); - memory->create(improper_atom4,natoms,improper_per_atom, - "molecule:improper_atom4"); - } - - if (shakeflag) { - memory->create(shake_flag,natoms,"molecule:shake_flag"); - memory->create(shake_atom,natoms,4,"molecule:shake_flag"); - memory->create(shake_type,natoms,3,"molecule:shake_flag"); - } - - if (bodyflag) { - if (nibody) memory->create(ibodyparams,nibody,"molecule:ibodyparams"); - if (ndbody) memory->create(dbodyparams,ndbody,"molecule:dbodyparams"); - } -} - -/* ---------------------------------------------------------------------- - deallocate all data structures -------------------------------------------------------------------------- */ - -void Molecule::deallocate() -{ - memory->destroy(x); - memory->destroy(type); - memory->destroy(q); - memory->destroy(radius); - memory->destroy(replambdaH); - memory->destroy(moltypeH); - memory->destroy(rmass); - - memory->destroy(num_bond); - memory->destroy(bond_type); - memory->destroy(bond_atom); - - memory->destroy(num_angle); - memory->destroy(angle_type); - memory->destroy(angle_atom1); - memory->destroy(angle_atom2); - memory->destroy(angle_atom3); - - memory->destroy(num_dihedral); - memory->destroy(dihedral_type); - memory->destroy(dihedral_atom1); - memory->destroy(dihedral_atom2); - memory->destroy(dihedral_atom3); - memory->destroy(dihedral_atom4); - - memory->destroy(num_improper); - memory->destroy(improper_type); - memory->destroy(improper_atom1); - memory->destroy(improper_atom2); - memory->destroy(improper_atom3); - memory->destroy(improper_atom4); - - memory->destroy(nspecial); - memory->destroy(special); - - memory->destroy(shake_flag); - memory->destroy(shake_atom); - memory->destroy(shake_type); - - memory->destroy(dx); - memory->destroy(dxcom); - memory->destroy(dxbody); - - memory->destroy(ibodyparams); - memory->destroy(dbodyparams); -} - -/* ---------------------------------------------------------------------- - open molecule file -------------------------------------------------------------------------- */ - -void Molecule::open(char *file) -{ - fp = fopen(file,"r"); - if (fp == NULL) { - char str[128]; - sprintf(str,"Cannot open molecule file %s",file); - error->one(FLERR,str); - } -} - -/* ---------------------------------------------------------------------- - read and bcast a line -------------------------------------------------------------------------- */ - -void Molecule::readline(char *line) -{ - int n; - if (me == 0) { - if (fgets(line,MAXLINE,fp) == NULL) n = 0; - else n = strlen(line) + 1; - } - MPI_Bcast(&n,1,MPI_INT,0,world); - if (n == 0) error->all(FLERR,"Unexpected end of molecule file"); - MPI_Bcast(line,n,MPI_CHAR,0,world); -} - -/* ---------------------------------------------------------------------- - extract keyword from line - flag = 0, read and bcast line - flag = 1, line has already been read -------------------------------------------------------------------------- */ - -void Molecule::parse_keyword(int flag, char *line, char *keyword) -{ - if (flag) { - - // read upto non-blank line plus 1 following line - // eof is set to 1 if any read hits end-of-file - - int eof = 0; - if (me == 0) { - if (fgets(line,MAXLINE,fp) == NULL) eof = 1; - while (eof == 0 && strspn(line," \t\n\r") == strlen(line)) { - if (fgets(line,MAXLINE,fp) == NULL) eof = 1; - } - if (fgets(keyword,MAXLINE,fp) == NULL) eof = 1; - } - - // if eof, set keyword empty and return - - MPI_Bcast(&eof,1,MPI_INT,0,world); - if (eof) { - keyword[0] = '\0'; - return; - } - - // bcast keyword line to all procs - - int n; - if (me == 0) n = strlen(line) + 1; - MPI_Bcast(&n,1,MPI_INT,0,world); - MPI_Bcast(line,n,MPI_CHAR,0,world); - } - - // copy non-whitespace portion of line into keyword - - int start = strspn(line," \t\n\r"); - int stop = strlen(line) - 1; - while (line[stop] == ' ' || line[stop] == '\t' - || line[stop] == '\n' || line[stop] == '\r') stop--; - line[stop+1] = '\0'; - strcpy(keyword,&line[start]); -} - -/* ---------------------------------------------------------------------- - skip N lines of file -------------------------------------------------------------------------- */ - -void Molecule::skip_lines(int n, char *line) -{ - for (int i = 0; i < n; i++) readline(line); -} - -/* ---------------------------------------------------------------------- - parse line into words separated by whitespace - return # of words - max = max pointers storable in words -------------------------------------------------------------------------- */ - -int Molecule::parse(char *line, char **words, int max) -{ - char *ptr; - - int nwords = 0; - words[nwords++] = strtok(line," \t\n\r\f"); - - while ((ptr = strtok(NULL," \t\n\r\f"))) { - if (nwords < max) words[nwords] = ptr; - nwords++; - } - - return nwords; -} - -/* ---------------------------------------------------------------------- - proc 0 prints molecule params -------------------------------------------------------------------------- */ - -/* - -void Molecule::print() -{ - printf("MOLECULE %s\n",id); - printf(" %d natoms\n",natoms); - if (nbonds) printf(" %d nbonds\n",nbonds); - if (nangles) printf(" %d nangles\n",nangles); - if (ndihedrals) printf(" %d ndihedrals\n",ndihedrals); - if (nimpropers) printf(" %d nimpropers\n",nimpropers); - - if (xflag) { - printf( "Coords:\n"); - for (int i = 0; i < natoms; i++) - printf(" %d %g %g %g\n",i+1,x[i][0],x[i][1],x[i][2]); - } - if (typeflag) { - printf( "Types:\n"); - for (int i = 0; i < natoms; i++) - printf(" %d %d\n",i+1,type[i]); - } - if (qflag) { - printf( "Charges:\n"); - for (int i = 0; i < natoms; i++) - printf(" %d %g\n",i+1,q[i]); - } - if (radiusflag) { - printf( "Radii:\n"); - for (int i = 0; i < natoms; i++) - printf(" %d %g\n",i+1,radius[i]); - } - if (rmassflag) { - printf( "Masses:\n"); - for (int i = 0; i < natoms; i++) - printf(" %d %g\n",i+1,rmass[i]); - } - - if (bondflag) { - printf( "Bonds:\n"); - for (int i = 0; i < natoms; i++) { - printf(" %d %d\n",i+1,num_bond[i]); - for (int j = 0; j < num_bond[i]; j++) - printf(" %d %d %d %d\n",j+1,bond_type[i][j],i+1,bond_atom[i][j]); - } - } - if (angleflag) { - printf( "Angles:\n"); - for (int i = 0; i < natoms; i++) { - printf(" %d %d\n",i+1,num_angle[i]); - for (int j = 0; j < num_angle[i]; j++) - printf(" %d %d %d %d %d\n", - j+1,angle_type[i][j], - angle_atom1[i][j],angle_atom2[i][j],angle_atom3[i][j]); - } - } - if (dihedralflag) { - printf( "Dihedrals:\n"); - for (int i = 0; i < natoms; i++) { - printf(" %d %d\n",i+1,num_dihedral[i]); - for (int j = 0; j < num_dihedral[i]; j++) - printf(" %d %d %d %d %d %d\n", - j+1,dihedral_type[i][j], - dihedral_atom1[i][j],dihedral_atom2[i][j], - dihedral_atom3[i][j],dihedral_atom4[i][j]); - } - } - if (improperflag) { - printf( "Impropers:\n"); - for (int i = 0; i < natoms; i++) { - printf(" %d %d\n",i+1,num_improper[i]); - for (int j = 0; j < num_improper[i]; j++) - printf(" %d %d %d %d %d %d\n", - j+1,improper_type[i][j], - improper_atom1[i][j],improper_atom2[i][j], - improper_atom3[i][j],improper_atom4[i][j]); - } - } - - if (specialflag) { - printf( "Special neighs:\n"); - for (int i = 0; i < natoms; i++) { - printf(" %d %d %d %d\n",i+1, - nspecial[i][0],nspecial[i][1]-nspecial[i][0], - nspecial[i][2]-nspecial[i][1]); - printf(" "); - for (int j = 0; j < nspecial[i][2]; j++) - printf(" %d",special[i][j]); - printf("\n"); - } - } -} - -*/ diff --git a/src/USER-HADRESS/molecule.h b/src/USER-HADRESS/molecule.h deleted file mode 100644 index 4521fc45bc..0000000000 --- a/src/USER-HADRESS/molecule.h +++ /dev/null @@ -1,432 +0,0 @@ -/* -*- c++ -*- ---------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - http://lammps.sandia.gov, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - Copyright (2003) Sandia Corporation. Under the terms of Contract - DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains - certain rights in this software. This software is distributed under - the GNU General Public License. - - See the README file in the top-level LAMMPS directory. -------------------------------------------------------------------------- */ - -#ifndef LMP_ONE_MOLECULE_H -#define LMP_ONE_MOLECULE_H - -#include "pointers.h" - -namespace LAMMPS_NS { - -class Molecule : protected Pointers { - public: - char *id; // template id of this molecule, same for all molecules in set - int nset; // if first in set, # of molecules in this set - // else 0 if not first in set - int last; // 1 if last molecule in set, else 0 - - // number of atoms,bonds,etc in molecule - // nibody,ndbody = # of integer/double fields in body - - int natoms; - int nbonds,nangles,ndihedrals,nimpropers; - int ntypes; - int nbondtypes,nangletypes,ndihedraltypes,nimpropertypes; - int nibody,ndbody; - - // max bond,angle,etc per atom - - int bond_per_atom,angle_per_atom,dihedral_per_atom,improper_per_atom; - int maxspecial; - - // 1 if attribute defined in file, 0 if not - - int xflag,typeflag,qflag,radiusflag,rmassflag; - int replambdaHflag,moltypeHflag; - int bondflag,angleflag,dihedralflag,improperflag; - int nspecialflag,specialflag; - int shakeflag,shakeflagflag,shakeatomflag,shaketypeflag; - int bodyflag,ibodyflag,dbodyflag; - - // 1 if attribute defined or computed, 0 if not - - int centerflag,massflag,comflag,inertiaflag; - - // 1 if molecule fields require atom IDs - - int tag_require; - - // attributes - - double **x; // displacement of each atom from origin - int *type; // type of each atom - double *q; // charge on each atom - - int *replambdaH; // replambdaH on each atom - int *moltypeH; // moltypeH on each atom - - double *radius; // radius of each atom - double *rmass; // mass of each atom - - int *num_bond; // bonds, angles, dihedrals, impropers for each atom - int **bond_type; - tagint **bond_atom; - - int *num_angle; - int **angle_type; - tagint **angle_atom1,**angle_atom2,**angle_atom3; - - int *num_dihedral; - int **dihedral_type; - tagint **dihedral_atom1,**dihedral_atom2,**dihedral_atom3,**dihedral_atom4; - - int *num_improper; - int **improper_type; - tagint **improper_atom1,**improper_atom2,**improper_atom3,**improper_atom4; - - int **nspecial; - tagint **special; - - int *shake_flag; - tagint **shake_atom; - int **shake_type; - - class AtomVecBody *avec_body; - int *ibodyparams; // integer and double body params - double *dbodyparams; - - double center[3]; // geometric center of molecule - double masstotal; // total mass of molecule - double com[3]; // center of mass of molecule - double itensor[6]; // moments of inertia of molecule - double inertia[3]; // principal moments of inertia of molecule - double ex[3],ey[3],ez[3]; // principal axes of molecule in space coords - double quat[4]; // quaternion for orientation of molecule - - double maxradius; // max radius of any atom in molecule - double molradius; // radius of molecule from geometric center - // including finite-size particle radii - int comatom; // index (1-Natom) of atom closest to COM - double maxextent; // furthest any atom in molecule is from comatom - - double **dx; // displacement of each atom relative to center - double **dxcom; // displacement of each atom relative to COM - double **dxbody; // displacement of each atom relative to COM - // in body frame (diagonalized interia tensor) - - double *quat_external; // orientation imposed by external class - // e.g. FixPour or CreateAtoms - - Molecule(class LAMMPS *, int, char **, int &); - ~Molecule(); - void compute_center(); - void compute_mass(); - void compute_com(); - void compute_inertia(); - void check_attributes(int); - - private: - int me; - FILE *fp; - int *count; - int toffset,boffset,aoffset,doffset,ioffset; - int autospecial; - double sizescale; - - void read(int); - void coords(char *); - void types(char *); - void charges(char *); - void representative_atom(char *); - void moltype_atom(char *); - void diameters(char *); - void masses(char *); - void bonds(int, char *); - void angles(int, char *); - void dihedrals(int, char *); - void impropers(int, char *); - void nspecial_read(int, char *); - void special_read(char *); - void special_generate(); - void shakeflag_read(char *); - void shakeatom_read(char *); - void shaketype_read(char *); - void body(int, int, char *); - - void initialize(); - void allocate(); - void deallocate(); - - void open(char *); - void readline(char *); - void parse_keyword(int, char *, char *); - void skip_lines(int, char *); - int parse(char *, char **, int); - - // void print(); -}; - -} - -#endif - -/* ERROR/WARNING messages: - -E: Illegal ... command - -Self-explanatory. Check the input script syntax and compare to the -documentation for the command. You can use -echo screen as a -command-line option when running LAMMPS to see the offending line. - -E: Molecule template ID must be alphanumeric or underscore characters - -Self-explanatory. - -E: Insufficient Jacobi rotations for rigid molecule - -Eigensolve for rigid body was not sufficiently accurate. - -E: Unexpected end of molecule file - -Self-explanatory. - -E: Molecule file z center-of-mass must be 0.0 for 2d - -Self-explanatory. - -E: Molecule file requires atom style body - -Self-explanatory. - -E: No count or invalid atom count in molecule file - -The number of atoms must be specified. - -E: Invalid bond count in molecule file - -Self-explanatory. - -E: Invalid angle count in molecule file - -Self-explanatory. - -E: Invalid dihedral count in molecule file - -Self-explanatory. - -E: Invalid improper count in molecule file - -Self-explanatory. - -E: Molecule file has bonds but no nbonds setting - -Self-explanatory. - -E: Molecule file has angles but no nangles setting - -Self-explanatory. - -E: Molecule file has dihedrals but no ndihedrals setting - -Self-explanatory. - -E: Molecule file has impropers but no nimpropers setting - -Self-explanatory. - -E: Molecule file shake flags not before shake atoms - -The order of the two sections is important. - -E: Molecule file shake flags not before shake bonds - -The order of the two sections is important. - -E: Molecule file has body params but no setting for them - -Self-explanatory. - -E: Unknown section in molecule file - -Self-explanatory. - -E: Molecule file needs both Special Bond sections - -Self-explanatory. - -E: Molecule file has special flags but no bonds - -Self-explanatory. - -E: Molecule file shake info is incomplete - -All 3 SHAKE sections are needed. - -E: Molecule file has no Body Integers section - -Self-explanatory. - -E: Molecule file has no Body Doubles section - -Self-explanatory. - -E: Molecule natoms must be 1 for body particle - -Self-explanatory. - -E: Molecule sizescale must be 1.0 for body particle - -Self-explanatory. - -E: Invalid Coords section in molecule file - -Self-explanatory. - -E: Molecule file z coord must be 0.0 for 2d - -Self-explanatory. - -E: Invalid Types section in molecule file - -Self-explanatory. - -E: Invalid atom type in molecule file - -Atom types must range from 1 to specified # of types. - -E: Invalid Charges section in molecule file - -Self-explanatory. - -E: Invalid Diameters section in molecule file - -Self-explanatory. - -E: Invalid atom diameter in molecule file - -Diameters must be >= 0.0. - -E: Invalid Masses section in molecule file - -Self-explanatory. - -E: Invalid atom mass in molecule file - -Masses must be > 0.0. - -E: Invalid Bonds section in molecule file - -Self-explanatory. - -E: Invalid atom ID in Bonds section of molecule file - -Self-explanatory. - -E: Invalid bond type in Bonds section of molecule file - -Self-explanatory. - -E: Invalid Angles section in molecule file - -Self-explanatory. - -E: Invalid atom ID in Angles section of molecule file - -Self-explanatory. - -E: Invalid angle type in Angles section of molecule file - -Self-explanatory. - -E: Invalid Dihedrals section in molecule file - -Self-explanatory. - -E: Invalid atom ID in dihedrals section of molecule file - -Self-explanatory. - -E: Invalid dihedral type in dihedrals section of molecule file - -Self-explanatory. - -E: Invalid Impropers section in molecule file - -Self-explanatory. - -E: Invalid atom ID in impropers section of molecule file - -Self-explanatory. - -E: Invalid improper type in impropers section of molecule file - -Self-explanatory. - -E: Invalid Special Bond Counts section in molecule file - -Self-explanatory. - -E: Molecule file special list does not match special count - -The number of values in an atom's special list does not match count. - -E: Invalid special atom index in molecule file - -Self-explanatory. - -E: Molecule auto special bond generation overflow - -Counts exceed maxspecial setting for other atoms in system. - -E: Invalid shake flag in molecule file - -Self-explanatory. - -E: Invalid shake atom in molecule file - -Self-explanatory. - -E: Invalid shake bond type in molecule file - -Self-explanatory. - -E: Invalid shake angle type in molecule file - -Self-explanatory. - -E: Too few values in body section of molecule file - -Self-explanatory. - -E: Too many values in body section of molecule file - -Self-explanatory. - -W: Molecule attributes do not match system attributes - -An attribute is specified (e.g. diameter, charge) that is -not defined for the specified atom style. - -E: Molecule topology type exceeds system topology type - -The number of bond, angle, etc types in the molecule exceeds the -system setting. See the create_box command for how to specify these -values. - -E: Molecule toplogy/atom exceeds system topology/atom - -The number of bonds, angles, etc per-atom in the molecule exceeds the -system setting. See the create_box command for how to specify these -values. - -W: Molecule has bond topology but no special bond settings - -This means the bonded atoms will not be excluded in pair-wise -interactions. - -E: Cannot open molecule file %s - -The specified file cannot be opened. Check that the path and name are -correct. - -*/ diff --git a/src/USER-HADRESS/pair_lj_cut_coul_dsf_hars_at.cpp b/src/USER-HADRESS/pair_lj_cut_coul_dsf_hars_at.cpp deleted file mode 100644 index 5a60d7ef75..0000000000 --- a/src/USER-HADRESS/pair_lj_cut_coul_dsf_hars_at.cpp +++ /dev/null @@ -1,971 +0,0 @@ -/* ---------------------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - http://lammps.sandia.gov, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - Copyright (2003) Sandia Corporation. Under the terms of Contract - DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains - certain rights in this software. This software is distributed under - the GNU General Public License. - - See the README file in the top-level LAMMPS directory. -------------------------------------------------------------------------- */ - -/* ---------------------------------------------------------------------- - Contributing author: Maziar Heidari, - Robinson Cortes-Huerto, - Davide Donadio and - Raffaello Potestio - (Max Planck Institute for Polymer Research, 2015-2016) -------------------------------------------------------------------------- */ - -#include "math.h" -#include "stdio.h" -#include "stdlib.h" -#include "string.h" -#include "pair_lj_cut_coul_dsf_hars_at.h" -#include "atom.h" -#include "comm.h" -#include "force.h" -#include "neighbor.h" -#include "neigh_list.h" -#include "memory.h" -#include "math_const.h" -#include "error.h" -#include "fix_lambdah_calc.h" -#include "update.h" - - -using namespace LAMMPS_NS; -using namespace MathConst; -#define BIG MAXTAGINT - - -#define EWALD_F 1.12837917 -#define EWALD_P 0.3275911 -#define A1 0.254829592 -#define A2 -0.284496736 -#define A3 1.421413741 -#define A4 -1.453152027 -#define A5 1.061405429 - -/* ---------------------------------------------------------------------- */ - -PairLJCutCoulDSFHARSAT::PairLJCutCoulDSFHARSAT(LAMMPS *lmp) : Pair(lmp) -{ - single_enable = 0; - - AT_molmap_H = NULL; - nmolecules = molecules_in_group(idlo,idhi); - - H_AdResS_allocated = 0; - - AT_Pressure_Compensation_Run = 0; - Comp_Counter_H = 0; - memory->create(AT_massproc_H,nmolecules,"pair:AT_massproc_H"); - memory->create(AT_masstotal_H,nmolecules,"pair:AT_masstotal_H"); - memory->create(AT_mol_f_H,nmolecules,3,"pair:AT_mol_f_H"); - memory->create(AT_mol_f_all_H,nmolecules,3,"pair:AT_mol_f_all_H"); - - - // compute masstotal for each molecule - MPI_Comm_rank(world, &me); - int *mask = atom->mask; - tagint *molecule = atom->molecule; - int *type = atom->type; - double *mass = atom->mass; - double *rmass = atom->rmass; - int nlocal = atom->nlocal; - - tagint imol; - double massone; - - for (int i = 0; i < nmolecules; i++) AT_massproc_H[i] = 0.0; - - - for (int i = 0; i < nlocal; i++) - { -// if (mask[i] & groupbit) { - if (mask[i]) { - if (rmass) massone = rmass[i]; - else massone = mass[type[i]]; - imol = molecule[i]; - if (AT_molmap_H) imol = AT_molmap_H[imol-idlo]; - else imol--; - AT_massproc_H[imol] += massone; - - } - } - - MPI_Allreduce(AT_massproc_H,AT_masstotal_H,nmolecules,MPI_DOUBLE,MPI_SUM,world); - -} - -/* ---------------------------------------------------------------------- */ - -PairLJCutCoulDSFHARSAT::~PairLJCutCoulDSFHARSAT() -{ - if (allocated) { - memory->destroy(setflag); - memory->destroy(cutsq); - - memory->destroy(cut_lj); - memory->destroy(cut_ljsq); - memory->destroy(epsilon); - memory->destroy(sigma); - memory->destroy(lj1); - memory->destroy(lj2); - memory->destroy(lj3); - memory->destroy(lj4); - memory->destroy(offset); - } -} - -/* ---------------------------------------------------------------------- */ - -void PairLJCutCoulDSFHARSAT::compute(int eflag, int vflag) -{ - int i,j,ii,jj,inum,jnum,itype,jtype; - double qtmp,xtmp,ytmp,ztmp,delx,dely,delz,evdwl,ecoul,fpair; - double r,rsq,r2inv,r6inv,forcecoul,forcelj,factor_coul,factor_lj,Vij_Coul,Vij_Lj;; - double prefactor,erfcc,erfcd,t; - int *ilist,*jlist,*numneigh,**firstneigh; - int imoltypeH,jmoltypeH; - - evdwl = ecoul = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; - - double **x = atom->x; - double **f = atom->f; - double *q = atom->q; - double *lambdaH = atom->lambdaH; - double **gradlambdaH = atom->gradlambdaH; - - int *type = atom->type; - int nlocal = atom->nlocal; - double *special_lj = force->special_lj; - double *special_coul = force->special_coul; - int newton_pair = force->newton_pair; - double qqrd2e = force->qqrd2e; - int imol,jmol; - tagint *molecule = atom->molecule; - double *mass = atom->mass; - int *replambdaH = atom->replambdaH; - int *moltypeH = atom->moltypeH; - - int ibin, jbin; - - inum = list->inum; - ilist = list->ilist; - numneigh = list->numneigh; - firstneigh = list->firstneigh; - - double xtmpj, iLambda, jLambda, ijLambda; - - int This_Step = update->ntimestep; - if(This_Step >= AT_Update_Time_Begin && This_Step <= AT_Update_Time_End && AT_Pressure_Comp_Flag != 0) AT_Pressure_Compensation_Run = 1; - - - for (int i = 0; i < nmolecules; i++) { - AT_mol_f_H[i][0] = AT_mol_f_H[i][1] = AT_mol_f_H[i][2] = 0; - AT_mol_f_all_H[i][0] = AT_mol_f_all_H[i][1] = AT_mol_f_all_H[i][2] = 0; - } - - // loop over neighbors of my atoms -// if(update->ntimestepntypes; - - memory->create(setflag,n+1,n+1,"pair:setflag"); - for (int i = 1; i <= n; i++) - for (int j = i; j <= n; j++) - setflag[i][j] = 0; - - memory->create(cutsq,n+1,n+1,"pair:cutsq"); - - memory->create(cut_lj,n+1,n+1,"pair:cut_lj"); - memory->create(cut_ljsq,n+1,n+1,"pair:cut_ljsq"); - memory->create(epsilon,n+1,n+1,"pair:epsilon"); - memory->create(sigma,n+1,n+1,"pair:sigma"); - memory->create(lj1,n+1,n+1,"pair:lj1"); - memory->create(lj2,n+1,n+1,"pair:lj2"); - memory->create(lj3,n+1,n+1,"pair:lj3"); - memory->create(lj4,n+1,n+1,"pair:lj4"); - memory->create(offset,n+1,n+1,"pair:offset"); -} - -/* ---------------------------------------------------------------------- - global settings -------------------------------------------------------------------------- */ - -void PairLJCutCoulDSFHARSAT::settings(int narg, char **arg) -{ - if (narg != 5) error->all(FLERR,"Illegal pair_style command"); - - alpha = force->numeric(FLERR,arg[0]); - cut_lj_global = force->numeric(FLERR,arg[1]); - cut_coul = force->numeric(FLERR,arg[2]); - - AllAtomistic = force->numeric(FLERR,arg[3]); - Load_File_Flag = force->numeric(FLERR,arg[4]); - // reset cutoffs that have been explicitly set - - if (allocated) { - int i,j; - for (i = 1; i <= atom->ntypes; i++) - for (j = i+1; j <= atom->ntypes; j++) - if (setflag[i][j]) - cut_lj[i][j] = cut_lj_global; - } -} - -/* ---------------------------------------------------------------------- - set coeffs for one or more type pairs -------------------------------------------------------------------------- */ - -void PairLJCutCoulDSFHARSAT::coeff(int narg, char **arg) -{ - if (narg < 4 || narg > 5) - error->all(FLERR,"Incorrect args for pair coefficients"); - if (!allocated) allocate(); - - int ilo,ihi,jlo,jhi; - force->bounds(arg[0],atom->ntypes,ilo,ihi); - force->bounds(arg[1],atom->ntypes,jlo,jhi); - - double epsilon_one = force->numeric(FLERR,arg[2]); - double sigma_one = force->numeric(FLERR,arg[3]); - - double cut_lj_one = cut_lj_global; - if (narg == 5) cut_lj_one = force->numeric(FLERR,arg[4]); - - int count = 0; - for (int i = ilo; i <= ihi; i++) { - for (int j = MAX(jlo,i); j <= jhi; j++) { - epsilon[i][j] = epsilon_one; - sigma[i][j] = sigma_one; - cut_lj[i][j] = cut_lj_one; - setflag[i][j] = 1; - - count++; - } - } - - if (count == 0) error->all(FLERR,"Incorrect args for pair coefficients"); -} - -/* ---------------------------------------------------------------------- - init specific to this pair style -------------------------------------------------------------------------- */ - -void PairLJCutCoulDSFHARSAT::init_style() -{ - if (!atom->q_flag) - error->all(FLERR,"Pair style lj/cut/coul/dsf requires atom attribute q"); - - if(me == 0){ - if (screen)fprintf(screen,"AT_H_AdResS_allocated flag = %d\n",H_AdResS_allocated); - if (logfile)fprintf(logfile,"AT_H_AdResS_allocated flag = %d\n",H_AdResS_allocated); - } - - if(!H_AdResS_allocated)H_AdResS_Allocation(); - - int This_Step = update->ntimestep; - AT_Restart_Time_Step = This_Step; - - if((This_Step >= AT_Update_Time_End || Load_File_Flag) && AT_Pressure_Comp_Flag != 0)Load_Compensation_Pressure(); - - neighbor->request(this,instance_me); - - cut_coulsq = cut_coul * cut_coul; - double erfcc = erfc(alpha*cut_coul); - double erfcd = exp(-alpha*alpha*cut_coul*cut_coul); - f_shift = -(erfcc/cut_coulsq + 2.0/MY_PIS*alpha*erfcd/cut_coul); - e_shift = erfcc/cut_coul - f_shift*cut_coul; - -} - -/* ---------------------------------------------------------------------- - init for one type pair i,j and corresponding j,i -------------------------------------------------------------------------- */ - -double PairLJCutCoulDSFHARSAT::init_one(int i, int j) -{ - if (setflag[i][j] == 0) { - epsilon[i][j] = mix_energy(epsilon[i][i],epsilon[j][j], - sigma[i][i],sigma[j][j]); - sigma[i][j] = mix_distance(sigma[i][i],sigma[j][j]); - cut_lj[i][j] = mix_distance(cut_lj[i][i],cut_lj[j][j]); - } - - double cut = MAX(cut_lj[i][j],cut_coul); - cut_ljsq[i][j] = cut_lj[i][j] * cut_lj[i][j]; - - lj1[i][j] = 48.0 * epsilon[i][j] * pow(sigma[i][j],12.0); - lj2[i][j] = 24.0 * epsilon[i][j] * pow(sigma[i][j],6.0); - lj3[i][j] = 4.0 * epsilon[i][j] * pow(sigma[i][j],12.0); - lj4[i][j] = 4.0 * epsilon[i][j] * pow(sigma[i][j],6.0); - - if (offset_flag) { - double ratio = sigma[i][j] / cut_lj[i][j]; - offset[i][j] = 4.0 * epsilon[i][j] * (pow(ratio,12.0) - pow(ratio,6.0)); - } else offset[i][j] = 0.0; - - cut_ljsq[j][i] = cut_ljsq[i][j]; - lj1[j][i] = lj1[i][j]; - lj2[j][i] = lj2[i][j]; - lj3[j][i] = lj3[i][j]; - lj4[j][i] = lj4[i][j]; - offset[j][i] = offset[i][j]; - - // compute I,J contribution to long-range tail correction - // count total # of atoms of type I and J via Allreduce - - if (tail_flag) { - int *type = atom->type; - int nlocal = atom->nlocal; - - double count[2],all[2]; - count[0] = count[1] = 0.0; - for (int k = 0; k < nlocal; k++) { - if (type[k] == i) count[0] += 1.0; - if (type[k] == j) count[1] += 1.0; - } - MPI_Allreduce(count,all,2,MPI_DOUBLE,MPI_SUM,world); - - double sig2 = sigma[i][j]*sigma[i][j]; - double sig6 = sig2*sig2*sig2; - double rc3 = cut_lj[i][j]*cut_lj[i][j]*cut_lj[i][j]; - double rc6 = rc3*rc3; - double rc9 = rc3*rc6; - etail_ij = 8.0*MY_PI*all[0]*all[1]*epsilon[i][j] * - sig6 * (sig6 - 3.0*rc6) / (9.0*rc9); - ptail_ij = 16.0*MY_PI*all[0]*all[1]*epsilon[i][j] * - sig6 * (2.0*sig6 - 3.0*rc6) / (9.0*rc9); - } - - return cut; -} - -/* ---------------------------------------------------------------------- - proc 0 writes to restart file -------------------------------------------------------------------------- */ - -void PairLJCutCoulDSFHARSAT::write_restart(FILE *fp) -{ - write_restart_settings(fp); - - int i,j; - for (i = 1; i <= atom->ntypes; i++) - for (j = i; j <= atom->ntypes; j++) { - fwrite(&setflag[i][j],sizeof(int),1,fp); - if (setflag[i][j]) { - fwrite(&epsilon[i][j],sizeof(double),1,fp); - fwrite(&sigma[i][j],sizeof(double),1,fp); - fwrite(&cut_lj[i][j],sizeof(double),1,fp); - } - } -} - -/* ---------------------------------------------------------------------- - proc 0 reads from restart file, bcasts -------------------------------------------------------------------------- */ - -void PairLJCutCoulDSFHARSAT::read_restart(FILE *fp) -{ - read_restart_settings(fp); - allocate(); - - int i,j; - int me = comm->me; - for (i = 1; i <= atom->ntypes; i++) - for (j = i; j <= atom->ntypes; j++) { - if (me == 0) fread(&setflag[i][j],sizeof(int),1,fp); - MPI_Bcast(&setflag[i][j],1,MPI_INT,0,world); - if (setflag[i][j]) { - if (me == 0) { - fread(&epsilon[i][j],sizeof(double),1,fp); - fread(&sigma[i][j],sizeof(double),1,fp); - fread(&cut_lj[i][j],sizeof(double),1,fp); - } - MPI_Bcast(&epsilon[i][j],1,MPI_DOUBLE,0,world); - MPI_Bcast(&sigma[i][j],1,MPI_DOUBLE,0,world); - MPI_Bcast(&cut_lj[i][j],1,MPI_DOUBLE,0,world); - } - } -} - -/* ---------------------------------------------------------------------- - proc 0 writes to restart file -------------------------------------------------------------------------- */ - -void PairLJCutCoulDSFHARSAT::write_restart_settings(FILE *fp) -{ - fwrite(&alpha,sizeof(double),1,fp); - fwrite(&cut_lj_global,sizeof(double),1,fp); - fwrite(&cut_coul,sizeof(double),1,fp); - fwrite(&offset_flag,sizeof(int),1,fp); - fwrite(&mix_flag,sizeof(int),1,fp); - fwrite(&tail_flag,sizeof(int),1,fp); -} - -/* ---------------------------------------------------------------------- - proc 0 reads from restart file, bcasts -------------------------------------------------------------------------- */ - -void PairLJCutCoulDSFHARSAT::read_restart_settings(FILE *fp) -{ - if (comm->me == 0) { - fread(&alpha,sizeof(double),1,fp); - fread(&cut_lj_global,sizeof(double),1,fp); - fread(&cut_coul,sizeof(double),1,fp); - fread(&offset_flag,sizeof(int),1,fp); - fread(&mix_flag,sizeof(int),1,fp); - fread(&tail_flag,sizeof(int),1,fp); - } - MPI_Bcast(&alpha,1,MPI_DOUBLE,0,world); - MPI_Bcast(&cut_lj_global,1,MPI_DOUBLE,0,world); - MPI_Bcast(&cut_coul,1,MPI_DOUBLE,0,world); - MPI_Bcast(&offset_flag,1,MPI_INT,0,world); - MPI_Bcast(&mix_flag,1,MPI_INT,0,world); - MPI_Bcast(&tail_flag,1,MPI_INT,0,world); -} - -/* ---------------------------------------------------------------------- */ - -double PairLJCutCoulDSFHARSAT::single(int i, int j, int itype, int jtype, double rsq, - double factor_coul, double factor_lj, - double &fforce) -{ - double r2inv,r6inv,r,erfcc,erfcd,prefactor; - double forcecoul,forcelj,phicoul,philj; - - r2inv = 1.0/rsq; - if (rsq < cut_ljsq[itype][jtype]) { - r6inv = r2inv*r2inv*r2inv; - forcelj = r6inv * (lj1[itype][jtype]*r6inv - lj2[itype][jtype]); - } else forcelj = 0.0; - - if (rsq < cut_coulsq) { - r = sqrt(rsq); - prefactor = factor_coul * force->qqrd2e * atom->q[i]*atom->q[j]/r; - erfcc = erfc(alpha*r); - erfcd = exp(-alpha*alpha*r*r); - forcecoul = prefactor * (erfcc/r + 2.0*alpha/MY_PIS * erfcd + - r*f_shift) * r; - } else forcecoul = 0.0; - - fforce = (forcecoul + factor_lj*forcelj) * r2inv; - - double eng = 0.0; - if (rsq < cut_ljsq[itype][jtype]) { - philj = r6inv*(lj3[itype][jtype]*r6inv-lj4[itype][jtype]) - - offset[itype][jtype]; - eng += factor_lj*philj; - } - - if (rsq < cut_coulsq) { - phicoul = prefactor * (erfcc - r*e_shift - rsq*f_shift); - eng += phicoul; - } - - eng=0; - return eng; -} - -/* ---------------------------------------------------------------------- */ - -void *PairLJCutCoulDSFHARSAT::extract(const char *str, int &dim) -{ - if (strcmp(str,"cut_coul") == 0) { - dim = 0; - return (void *) &cut_coul; - } - return NULL; -} - - -int PairLJCutCoulDSFHARSAT::molecules_in_group(tagint &idlo, tagint &idhi) -{ - int i; - - memory->destroy(AT_molmap_H); - AT_molmap_H = NULL; - - // find lo/hi molecule ID for any atom in group - // warn if atom in group has ID = 0 - - tagint *molecule = atom->molecule; - int *mask = atom->mask; - int nlocal = atom->nlocal; - - tagint lo = BIG; - tagint hi = -BIG; - int flag = 0; - for (i = 0; i < nlocal; i++) - { -// if (mask[i] & groupbit) { - if (mask[i]) { - if (molecule[i] == 0) flag = 1; - lo = MIN(lo,molecule[i]); - hi = MAX(hi,molecule[i]); - } - } - - int flagall; - MPI_Allreduce(&flag,&flagall,1,MPI_INT,MPI_SUM,world); - if (flagall && comm->me == 0) - error->warning(FLERR,"Atom with molecule ID = 0 included in " - "compute molecule group"); - - MPI_Allreduce(&lo,&idlo,1,MPI_LMP_TAGINT,MPI_MIN,world); - MPI_Allreduce(&hi,&idhi,1,MPI_LMP_TAGINT,MPI_MAX,world); - if (idlo == BIG) return 0; - - // molmap = vector of length nlen - // set to 1 for IDs that appear in group across all procs, else 0 - - tagint nlen_tag = idhi-idlo+1; - if (nlen_tag > MAXSMALLINT) - error->all(FLERR,"Too many molecules for compute"); - int nlen = (int) nlen_tag; - - memory->create(AT_molmap_H,nlen,"pair:molmap_H"); - for (i = 0; i < nlen; i++) AT_molmap_H[i] = 0; - - for (i = 0; i < nlocal; i++) - // if (mask[i] & groupbit) - if (mask[i]) - AT_molmap_H[molecule[i]-idlo] = 1; - - int *AT_molmapall; - memory->create(AT_molmapall,nlen,"pair:AT_molmapall"); - MPI_Allreduce(AT_molmap_H,AT_molmapall,nlen,MPI_INT,MPI_MAX,world); - - // nmolecules = # of non-zero IDs in molmap - // molmap[i] = index of molecule, skipping molecules not in group with -1 - - int nmolecules = 0; - for (i = 0; i < nlen; i++) - if (AT_molmapall[i]) AT_molmap_H[i] = nmolecules++; - else AT_molmap_H[i] = -1; - memory->destroy(AT_molmapall); - - // warn if any molecule has some atoms in group and some not in group - - flag = 0; - for (i = 0; i < nlocal; i++) { -// if (mask[i] & groupbit) continue; - if (mask[i]) continue; - if (molecule[i] < idlo || molecule[i] > idhi) continue; - if (AT_molmap_H[molecule[i]-idlo] >= 0) flag = 1; - } - - MPI_Allreduce(&flag,&flagall,1,MPI_INT,MPI_SUM,world); - if (flagall && comm->me == 0) - error->warning(FLERR, - "One or more compute molecules has atoms not in group"); - - // if molmap simply stores 1 to Nmolecules, then free it - - if (idlo == 1 && idhi == nmolecules && nlen == nmolecules) { - memory->destroy(AT_molmap_H); - AT_molmap_H = NULL; - } - return nmolecules; -} - - -void PairLJCutCoulDSFHARSAT::AT_Print_Compensation_Energy(){ - - FILE *fp1; - fp1 = fopen("Mean_Comp_Energy_AT.txt","w"); - if (fp1 == NULL) { - char str[128]; - sprintf(str,"Cannot open Mean_Comp_Energy_AT.txt file %s","Mean_Comp_Energy_AT.txt"); - error->one(FLERR,str); - } - - for(int i = 0;i < AT_Bin_Num; i++){ - fprintf(fp1,"%d",i+1); - for(int j = 0; j < atom->nmoltypesH; j++){ - fprintf(fp1,"\t%.10f",Mean_Comp_Energy_H[i][j]); - } - fprintf(fp1,"\n"); - } - fclose(fp1); -} - - - -void PairLJCutCoulDSFHARSAT::AT_Update_Compensation_Energy(){ - MPI_Allreduce(&Comp_Energy_H[0][0],&Comp_Energy_all_H[0][0],AT_Bin_Num*(atom->nmoltypesH+1),MPI_DOUBLE,MPI_SUM,world); - MPI_Allreduce(&Comp_Energy_Num_H[0][0],&Comp_Energy_Num_all_H[0][0],AT_Bin_Num*(atom->nmoltypesH+1),MPI_INT,MPI_SUM,world); - - for(int j = 0;j < atom->nmoltypesH; j++){ - for(int i = 0;i < AT_Bin_Num; i++){ - Mean_Energy_H[i][j] = Comp_Energy_all_H[i][j] / Comp_Energy_Num_all_H[i][j]; - Mean_Comp_Energy_H[i][j] = (Comp_Counter_H * Mean_Comp_Energy_H[i][j] + Mean_Energy_H[i][j]) / (Comp_Counter_H + 1); - Int_Mean_Energy_H[i][j]=0; - } - } - - Comp_Counter_H++; - - for(int j = 0;j < atom->nmoltypesH; j++){ - for(int i = 0;i < AT_Bin_Num; i++){ - Comp_Energy_Num_H[i][j] = 0; - Comp_Energy_Num_all_H[i][j] = 0; - Comp_Energy_H[i][j] = 0; - Comp_Energy_all_H[i][j] =0; - } - - } - if (me == 0)AT_Print_Compensation_Energy(); - - -} - - -void PairLJCutCoulDSFHARSAT::Load_Compensation_Pressure(){ - - if(me == 0){ - FILE *fp1; - char str[128]; - - fp1 = fopen("Mean_Comp_Energy_AT.txt","r"); - if (fp1 == NULL) { - sprintf(str,"Cannot open Mean_Comp_Energy_AT.txt file %s","Mean_Comp_Energy_AT.txt"); - error->one(FLERR,str); - } - - int i1; - - while (!feof(fp1)){ - fscanf (fp1,"%d",&i1); - for(int j=0;jnmoltypesH;j++)fscanf (fp1,"\t%f",&Mean_Comp_Energy_H[i1-1][j]); - fscanf (fp1,"\n"); - if(i1 > AT_Bin_Num){ - sprintf(str,"At drift force compensation bin number mismatches %d != %d",AT_Bin_Num,i1); - error->one(FLERR,str); - } - - } - - fclose(fp1); - - - if(me==0){ - if(screen)fprintf(screen,"AT_Pressure componsation forces distributed successfully!\n"); - if(logfile)fprintf(logfile,"AT_Pressure componsation forces distributed successfully!\n"); - } - - } - - MPI_Bcast(Mean_Comp_Energy_H,AT_Bin_Num,MPI_DOUBLE,0,world); - - -} - -void PairLJCutCoulDSFHARSAT::H_AdResS_Allocation(){ - for (int i = 0; i < modify->nfix; i++){ - if (strcmp(modify->fix[i]->style,"LambdaH/calc") == 0){ - lambda_H_fix = (FixLambdaHCalc *) modify->fix[i]; - AT_lambda_Increment = lambda_H_fix->Pressure_lambda_Increment; - AT_Bin_Num = lambda_H_fix->Pressure_Bin_Num; - AT_Update_Frequency = lambda_H_fix->Pressure_Update_Frequency; - AT_Update_Time_Begin = lambda_H_fix->Pressure_Update_Time_Begin; - AT_Update_Time_End = lambda_H_fix->Pressure_Update_Time_End; - AT_Pressure_Comp_Flag = lambda_H_fix->Pressure_Comp_Flag; - AT_center_box = lambda_H_fix->center_box; - AT_Hybrid_Style = lambda_H_fix->Hybrid_Style; - } - } - - if(me == 0){ - if (screen){ - fprintf(screen,"AT_lambda_Increment= %f\n",AT_lambda_Increment); - fprintf(screen,"AT_Bin_Num= %d\n",AT_Bin_Num); - fprintf(screen,"AT_Update_Frequency= %d\n",AT_Update_Frequency); - fprintf(screen,"AT_Update_Time_Begin= %d\n",AT_Update_Time_Begin); - fprintf(screen,"AT_Update_Time_End= %d\n",AT_Update_Time_End); - fprintf(screen,"AT_Pressure_Comp_Flag= %d\n",AT_Pressure_Comp_Flag); - } - - if (logfile){ - fprintf(logfile,"AT_lambda_Increment= %f\n",AT_lambda_Increment); - fprintf(logfile,"AT_Bin_Num= %d\n",AT_Bin_Num); - fprintf(logfile,"AT_Update_Frequency= %d\n",AT_Update_Frequency); - fprintf(logfile,"AT_Update_Time_Begin= %d\n",AT_Update_Time_Begin); - fprintf(logfile,"AT_Update_Time_End= %d\n",AT_Update_Time_End); - fprintf(logfile,"AT_Pressure_Comp_Flag= %d\n",AT_Pressure_Comp_Flag); - } - } - - memory->create(Comp_Energy_Num_H,AT_Bin_Num,atom->nmoltypesH+1,"pairLJHAT:Comp_Energy_Num_H"); - memory->create(Comp_Energy_Num_all_H,AT_Bin_Num,atom->nmoltypesH+1,"pairLJHAT:Comp_Energy_Num_all_H"); - - memory->create(Int_Mean_Energy_H,AT_Bin_Num,atom->nmoltypesH+1,"pairLJHAT:Int_Mean_Energy_H"); - memory->create(Comp_Energy_H,AT_Bin_Num,atom->nmoltypesH+1,"pairLJHAT:Comp_Energy_H"); - memory->create(Comp_Energy_all_H,AT_Bin_Num,atom->nmoltypesH+1,"pairLJHAT:Comp_Energy_all_H"); - memory->create(Mean_Comp_Energy_H,AT_Bin_Num,atom->nmoltypesH+1,"pairLJHAT:Mean_Comp_Energy_H"); - memory->create(Mean_Energy_H,AT_Bin_Num,atom->nmoltypesH+1,"pairLJHAT:Mean_Energy_H"); - - - for(int j=0;jnmoltypesH;j++){ - for(int i = 0;i < AT_Bin_Num; i++){ - Int_Mean_Energy_H[i][j]=0; - Comp_Energy_H[i][j]=0; - Comp_Energy_all_H[i][j]=0; - Mean_Comp_Energy_H[i][j]=0; - Comp_Energy_Num_H[i][j] = 0; - Comp_Energy_Num_all_H[i][j] = 0; - } - - } - - H_AdResS_allocated = 1; -} - diff --git a/src/USER-HADRESS/pair_lj_cut_coul_dsf_hars_at.h b/src/USER-HADRESS/pair_lj_cut_coul_dsf_hars_at.h deleted file mode 100644 index b5d5076c43..0000000000 --- a/src/USER-HADRESS/pair_lj_cut_coul_dsf_hars_at.h +++ /dev/null @@ -1,115 +0,0 @@ -/* -*- c++ -*- ---------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - http://lammps.sandia.gov, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - Copyright (2003) Sandia Corporation. Under the terms of Contract - DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains - certain rights in this software. This software is distributed under - the GNU General Public License. - - See the README file in the top-level LAMMPS directory. -------------------------------------------------------------------------- */ - -#ifdef PAIR_CLASS - -PairStyle(lj/cut/coul/dsf/hars/at,PairLJCutCoulDSFHARSAT) - -#else - -#ifndef LMP_PAIR_LJ_CUT_COUL_DSF_HARS_AT_H -#define LMP_PAIR_LJ_CUT_COUL_DSF_HARS_AT_H - -#include "pair.h" - -namespace LAMMPS_NS { - -class PairLJCutCoulDSFHARSAT : public Pair { - public: - PairLJCutCoulDSFHARSAT(class LAMMPS *); - ~PairLJCutCoulDSFHARSAT(); - void compute(int, int); - void settings(int, char **); - void coeff(int, char **); - void init_style(); - double init_one(int, int); - void write_restart(FILE *); - void read_restart(FILE *); - void write_restart_settings(FILE *); - void read_restart_settings(FILE *); - double single(int, int, int, int, double, double, double, double &); - void *extract(const char *, int &); - - void AT_Print_Compensation_Energy(); - void AT_Update_Compensation_Energy(); - - protected: - double cut_lj_global; - double **cut_lj,**cut_ljsq; - double **epsilon,**sigma; - double **lj1,**lj2,**lj3,**lj4,**offset; - - double cut_coul,cut_coulsq; - double alpha; - double f_shift,e_shift; - - void allocate(); - class FixLambdaHCalc *lambda_H_fix; - - int AllAtomistic; - - //private: - int me; - - int H_AdResS_allocated; - - int **Comp_Energy_Num_H,**Comp_Energy_Num_all_H, Comp_Counter_H; - - double AT_lambda_Increment; - int AT_Bin_Num, AT_Update_Frequency, AT_Update_Time_End, AT_Update_Time_Begin; - int AT_Pressure_Compensation_Run; - int AT_Pressure_Comp_Flag; - - int AT_Restart_Time_Step; - double *AT_center_box,AT_x0lo; - int AT_Hybrid_Style; - double **Int_Mean_Energy_H, **Comp_Energy_H, **Comp_Energy_all_H, **Mean_Energy_H, **Mean_Comp_Energy_H; - - int nmolecules; - tagint idlo,idhi; - - double *AT_massproc_H,*AT_masstotal_H; - - double **AT_mol_f_H, **AT_mol_f_all_H; - - int *AT_molmap_H; // convert molecule ID to local index - int Load_File_Flag; - - int molecules_in_group(tagint &, tagint &); - void Load_Compensation_Pressure(); - void H_AdResS_Allocation(); - -}; - -} - -#endif -#endif - -/* ERROR/WARNING messages: - -E: Illegal ... command - -Self-explanatory. Check the input script syntax and compare to the -documentation for the command. You can use -echo screen as a -command-line option when running LAMMPS to see the offending line. - -E: Incorrect args for pair coefficients - -Self-explanatory. Check the input script or data file. - -E: Pair style lj/cut/coul/dsf requires atom attribute q - -The atom style defined does not have these attributes. - -*/ diff --git a/src/USER-HADRESS/pair_lj_cut_hars_at.cpp b/src/USER-HADRESS/pair_lj_cut_hars_at.cpp deleted file mode 100644 index f605c92ac1..0000000000 --- a/src/USER-HADRESS/pair_lj_cut_hars_at.cpp +++ /dev/null @@ -1,1039 +0,0 @@ -/* ---------------------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - http://lammps.sandia.gov, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - Copyright (2003) Sandia Corporation. Under the terms of Contract - DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains - certain rights in this software. This software is distributed under - the GNU General Public License. - - See the README file in the top-level LAMMPS directory. -------------------------------------------------------------------------- */ - -/* ---------------------------------------------------------------------- - Contributing author: Paul Crozier (SNL) -------------------------------------------------------------------------- */ - -#include "math.h" -#include "stdio.h" -#include "stdlib.h" -#include "string.h" -#include "pair_lj_cut_hars_at.h" -#include "atom.h" -#include "comm.h" -#include "force.h" -#include "neighbor.h" -#include "neigh_list.h" -#include "neigh_request.h" -#include "update.h" -#include "integrate.h" -#include "respa.h" -#include "math_const.h" -#include "memory.h" -#include "error.h" -#include "domain.h" -#include "fix.h" -#include "fix_lambdah_calc.h" -#include "modify.h" - -using namespace LAMMPS_NS; -using namespace MathConst; -#define BIG MAXTAGINT - -/* ---------------------------------------------------------------------- */ - -PairLJCutHARSAT::PairLJCutHARSAT(LAMMPS *lmp) : Pair(lmp) -{ - respa_enable = 1; - writedata = 1; - - AT_massproc_H = NULL; - AT_masstotal_H = NULL; - AT_molmap_H = NULL; - AT_mol_f_H = NULL; - AT_mol_f_all_H = NULL; - Comp_Energy_Num_H = NULL; - Comp_Energy_Num_all_H = NULL; - - Int_Mean_Energy_H = NULL; - Mean_Energy_H = NULL; - Comp_Energy_H = NULL; - Comp_Energy_all_H = NULL; - Mean_Comp_Energy_H = NULL; - - AT_molmap_H = NULL; - nmolecules = molecules_in_group(idlo,idhi); - - H_AdResS_allocated = 0; - - AT_Pressure_Compensation_Run = 0; - Comp_Counter_H = 0; - memory->create(AT_massproc_H,nmolecules,"pair:AT_massproc_H"); - memory->create(AT_masstotal_H,nmolecules,"pair:AT_masstotal_H"); - memory->create(AT_mol_f_H,nmolecules,3,"pair:AT_mol_f_H"); - memory->create(AT_mol_f_all_H,nmolecules,3,"pair:AT_mol_f_all_H"); - - - // compute masstotal for each molecule - MPI_Comm_rank(world, &me); - int *mask = atom->mask; - tagint *molecule = atom->molecule; - int *type = atom->type; - double *mass = atom->mass; - double *rmass = atom->rmass; - int nlocal = atom->nlocal; - - tagint imol; - double massone; - - for (int i = 0; i < nmolecules; i++) AT_massproc_H[i] = 0.0; - - - for (int i = 0; i < nlocal; i++) - { -// if (mask[i] & groupbit) { - if (mask[i]) { - if (rmass) massone = rmass[i]; - else massone = mass[type[i]]; - imol = molecule[i]; - if (AT_molmap_H) imol = AT_molmap_H[imol-idlo]; - else imol--; - AT_massproc_H[imol] += massone; - - } - } - - MPI_Allreduce(AT_massproc_H,AT_masstotal_H,nmolecules,MPI_DOUBLE,MPI_SUM,world); - -} - -/* ---------------------------------------------------------------------- */ - -PairLJCutHARSAT::~PairLJCutHARSAT() -{ - if (allocated) { - memory->destroy(setflag); - memory->destroy(cutsq); - memory->destroy(cut); - memory->destroy(epsilon); - memory->destroy(sigma); - memory->destroy(lj1); - memory->destroy(lj2); - memory->destroy(lj3); - memory->destroy(lj4); - memory->destroy(offset); - memory->destroy(AT_massproc_H); - memory->destroy(AT_masstotal_H); - memory->destroy(AT_molmap_H); - memory->destroy(AT_mol_f_H); - memory->destroy(AT_mol_f_all_H); - memory->destroy(Comp_Energy_Num_H); - memory->destroy(Comp_Energy_Num_all_H); - memory->destroy(Int_Mean_Energy_H); - memory->destroy(Mean_Energy_H); - memory->destroy(Comp_Energy_H); - memory->destroy(Comp_Energy_all_H); - memory->destroy(Mean_Comp_Energy_H); - - } -} - -/* ---------------------------------------------------------------------- */ - -void PairLJCutHARSAT::compute(int eflag, int vflag) -{ - int i,j,ii,jj,inum,jnum,itype,jtype; - double xtmp,ytmp,ztmp,delx,dely,delz,evdwl,fpair; - double rsq,r2inv,r6inv,forcelj, factor_lj,Vij; - int *ilist,*jlist,*numneigh,**firstneigh; - int imoltypeH,jmoltypeH; - - evdwl = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; - - double **x = atom->x; - double **f = atom->f; - double *lambdaH = atom->lambdaH; - double **gradlambdaH = atom->gradlambdaH; - int *type = atom->type; - int nlocal = atom->nlocal; - double *special_lj = force->special_lj; - int newton_pair = force->newton_pair; - int imol,jmol; - tagint *molecule = atom->molecule; - double *mass = atom->mass; - int *replambdaH = atom->replambdaH; - int *moltypeH = atom->moltypeH; - - int ibin, jbin; - - inum = list->inum; - ilist = list->ilist; - numneigh = list->numneigh; - firstneigh = list->firstneigh; - - //if(update->ntimestep<3)return; - - double xtmpj, iLambda, jLambda, ijLambda; - - int This_Step = update->ntimestep; - if(This_Step >= AT_Update_Time_Begin && This_Step <= AT_Update_Time_End && AT_Pressure_Comp_Flag != 0) AT_Pressure_Compensation_Run = 1; - - - for (int i = 0; i < nmolecules; i++) { - AT_mol_f_H[i][0] = AT_mol_f_H[i][1] = AT_mol_f_H[i][2] = 0; - AT_mol_f_all_H[i][0] = AT_mol_f_all_H[i][1] = AT_mol_f_all_H[i][2] = 0; - } - - for (ii = 0; ii < inum; ii++) { - i = ilist[ii]; - xtmp = x[i][0]; - ytmp = x[i][1]; - ztmp = x[i][2]; - itype = type[i]; - imoltypeH = moltypeH[i]; - jlist = firstneigh[i]; - jnum = numneigh[i]; - - iLambda = lambdaH[i]; - - for (jj = 0; jj < jnum; jj++) { - - j = jlist[jj]; - factor_lj = special_lj[sbmask(j)]; - j &= NEIGHMASK; - jLambda = lambdaH[j]; - - - if(iLambda==0 && jLambda==0 && AllAtomistic!=1)continue; - - delx = xtmp - x[j][0]; - dely = ytmp - x[j][1]; - delz = ztmp - x[j][2]; - - xtmpj = x[j][0]; - - rsq = delx*delx + dely*dely + delz*delz; - jtype = type[j]; - jmoltypeH = moltypeH[j]; - - imol = molecule[i]; - jmol = molecule[j]; - if (AT_molmap_H) { - imol = AT_molmap_H[imol-idlo]; - jmol = AT_molmap_H[jmol-idlo]; - } - else { - imol--; - jmol--; - } - - - if (rsq < cutsq[itype][jtype] && lj1[itype][jtype] != 0 && (imol != jmol)) { - - - if(((iLambda==1 && jLambda==1) || AllAtomistic)){ - - r2inv = 1.0/rsq; - r6inv = r2inv*r2inv*r2inv; - forcelj = r6inv * (lj1[itype][jtype]*r6inv - lj2[itype][jtype]); - fpair = factor_lj*forcelj*r2inv; - - f[i][0] += delx*fpair; - f[i][1] += dely*fpair; - f[i][2] += delz*fpair; - - if (newton_pair || j < nlocal) { - f[j][0] -= delx*fpair; - f[j][1] -= dely*fpair; - f[j][2] -= delz*fpair; - } - - if (eflag) { - evdwl = r6inv*(lj3[itype][jtype]*r6inv-lj4[itype][jtype]) - - offset[itype][jtype]; - evdwl *= factor_lj; - } - - if (evflag) ev_tally(i,j,nlocal,newton_pair, - evdwl,0.0,fpair,delx,dely,delz); - - } - else if(iLambda !=0 || jLambda != 0){ - - - ijLambda = 0.5 * (iLambda + jLambda); - r2inv = 1.0/rsq; - r6inv = r2inv*r2inv*r2inv; - forcelj = r6inv * (lj1[itype][jtype]*r6inv - lj2[itype][jtype]); - - fpair = factor_lj*(forcelj*ijLambda)*r2inv; - - Vij = 0.5*(r6inv*(lj3[itype][jtype]*r6inv-lj4[itype][jtype]) - - offset[itype][jtype]); - - f[i][0] += delx*fpair; - f[i][1] += dely*fpair; - f[i][2] += delz*fpair; - - ibin = floor(iLambda/AT_lambda_Increment); - if(ibin==AT_Bin_Num)ibin = AT_Bin_Num - 1; - if(AT_Pressure_Compensation_Run != 0 && iLambda != 0 && iLambda != 1)Comp_Energy_H[ibin][imoltypeH-1] += Vij; - - AT_mol_f_H[imol][0] += -Vij*gradlambdaH[i][0]; - AT_mol_f_H[imol][1] += -Vij*gradlambdaH[i][1]; - AT_mol_f_H[imol][2] += -Vij*gradlambdaH[i][2]; - - if (newton_pair || j < nlocal) { - - f[j][0] -= delx*fpair; - f[j][1] -= dely*fpair; - f[j][2] -= delz*fpair; - - jbin = floor(jLambda/AT_lambda_Increment); - if(jbin==AT_Bin_Num)jbin = AT_Bin_Num - 1; - if(AT_Pressure_Compensation_Run != 0 && jLambda != 0 && jLambda != 1)Comp_Energy_H[jbin][jmoltypeH-1] += Vij; - - AT_mol_f_H[jmol][0] += -Vij*gradlambdaH[j][0]; - AT_mol_f_H[jmol][1] += -Vij*gradlambdaH[j][1]; - AT_mol_f_H[jmol][2] += -Vij*gradlambdaH[j][2]; - - } - - if (eflag) { - - evdwl = ijLambda*Vij*2.0; - evdwl *= factor_lj; - } - - if (evflag) ev_tally(i,j,nlocal,newton_pair, - evdwl,0.0,fpair,delx,dely,delz); - - } - } - - } - } - - - - MPI_Allreduce(&AT_mol_f_H[0][0],&AT_mol_f_all_H[0][0],3*nmolecules,MPI_DOUBLE,MPI_SUM,world); - - if(AT_Pressure_Compensation_Run != 0 && AT_Pressure_Comp_Flag != 0){ - - for (int i = 0; i < nlocal; i++){ - iLambda = lambdaH[i]; - if(replambdaH[i]!=0 && iLambda != 0 && iLambda != 1){ - - ibin = floor(iLambda/AT_lambda_Increment); - if(ibin==AT_Bin_Num)ibin = AT_Bin_Num - 1; - - imoltypeH = moltypeH[i]-1; - - Comp_Energy_Num_H[ibin][imoltypeH]++; - } - } - - if(This_Step % AT_Update_Frequency == 0)AT_Update_Compensation_Energy(); - - } - - - if(This_Step == AT_Update_Time_End && AT_Pressure_Compensation_Run != 0)AT_Print_Compensation_Energy(); - - double mol_mass,mass_frac; - - if(AllAtomistic != 1){ - - if(AT_Pressure_Comp_Flag != 0){ - - for (int i = 0; i < nlocal; i++){ - - iLambda = lambdaH[i]; - if(iLambda != 0 && iLambda != 1){ - - imol = molecule[i]; - if (AT_molmap_H)imol = AT_molmap_H[imol-idlo]; - else imol--; - mol_mass = AT_masstotal_H[imol]; - mass_frac = mass[type[i]] / mol_mass; - ibin = floor(iLambda/AT_lambda_Increment); - imoltypeH = moltypeH[i] - 1; - - - f[i][0] += mass_frac*(AT_mol_f_all_H[imol][0]+gradlambdaH[i][0]*Mean_Comp_Energy_H[ibin][imoltypeH]); - f[i][1] += mass_frac*(AT_mol_f_all_H[imol][1]+gradlambdaH[i][1]*Mean_Comp_Energy_H[ibin][imoltypeH]); - f[i][2] += mass_frac*(AT_mol_f_all_H[imol][2]+gradlambdaH[i][2]*Mean_Comp_Energy_H[ibin][imoltypeH]); - if (evflag) ev_tally(i,i,nlocal,newton_pair, - -0.5*Int_Mean_Energy_H[ibin][imoltypeH],0.0,0.0,0.0,0.0,0.0); - - } - - } - - } - else{ - - for (int i = 0; i < nlocal; i++){ - - iLambda = lambdaH[i]; - if(iLambda != 0 && iLambda != 1){ - - imol = molecule[i]; - if (AT_molmap_H)imol = AT_molmap_H[imol-idlo]; - else imol--; - mol_mass = AT_masstotal_H[imol]; - mass_frac = mass[type[i]] / mol_mass; - ibin = floor(iLambda/AT_lambda_Increment); - - - f[i][0] += mass_frac*(AT_mol_f_all_H[imol][0]); - f[i][1] += mass_frac*(AT_mol_f_all_H[imol][1]); - f[i][2] += mass_frac*(AT_mol_f_all_H[imol][2]); - - } - - } - - } - - } - - - if(This_Step == AT_Update_Time_End)AT_Pressure_Compensation_Run = 0; - - if (vflag_fdotr) virial_fdotr_compute(); -} - -/* ---------------------------------------------------------------------- */ - -void PairLJCutHARSAT::compute_inner() -{ - error->all(FLERR,"Rrespa has not been included!"); -} - -/* ---------------------------------------------------------------------- */ - -void PairLJCutHARSAT::compute_middle() -{ - error->all(FLERR,"Rrespa has not been included!"); -} - -/* ---------------------------------------------------------------------- */ - -void PairLJCutHARSAT::compute_outer(int eflag, int vflag) -{ - error->all(FLERR,"Rrespa has not been included!"); - -} - -/* ---------------------------------------------------------------------- - allocate all arrays -------------------------------------------------------------------------- */ - -void PairLJCutHARSAT::allocate() -{ - allocated = 1; - int n = atom->ntypes; - - memory->create(setflag,n+1,n+1,"pairLJHAT:setflag"); - for (int i = 1; i <= n; i++) - for (int j = i; j <= n; j++) - setflag[i][j] = 0; - - memory->create(cutsq,n+1,n+1,"pairLJHAT:cutsq"); - - memory->create(cut,n+1,n+1,"pairLJHAT:cut"); - memory->create(epsilon,n+1,n+1,"pairLJHAT:epsilon"); - memory->create(sigma,n+1,n+1,"pairLJHAT:sigma"); - memory->create(lj1,n+1,n+1,"pairLJHAT:lj1"); - memory->create(lj2,n+1,n+1,"pairLJHAT:lj2"); - memory->create(lj3,n+1,n+1,"pairLJHAT:lj3"); - memory->create(lj4,n+1,n+1,"pairLJHAT:lj4"); - memory->create(offset,n+1,n+1,"pairLJHAT:offset"); - -} - -/* ---------------------------------------------------------------------- - global settings -------------------------------------------------------------------------- */ - -void PairLJCutHARSAT::settings(int narg, char **arg) -{ - if (narg != 3) error->all(FLERR,"Illegal pair_style command"); - - cut_global = force->numeric(FLERR,arg[0]); - - // reset cutoffs that have been explicitly set - AllAtomistic = force->numeric(FLERR,arg[1]); - - Load_File_Flag = force->numeric(FLERR,arg[2]); - - - if (allocated) { - int i,j; - for (i = 1; i <= atom->ntypes; i++) - for (j = i+1; j <= atom->ntypes; j++) - if (setflag[i][j]) cut[i][j] = cut_global; - } - - - -} - -/* ---------------------------------------------------------------------- - set coeffs for one or more type pairs -------------------------------------------------------------------------- */ - -void PairLJCutHARSAT::coeff(int narg, char **arg) -{ - - - if (narg < 4 || narg > 5) - error->all(FLERR,"Incorrect args for pair coefficients"); - if (!allocated) allocate(); - - int ilo,ihi,jlo,jhi; - force->bounds(arg[0],atom->ntypes,ilo,ihi); - force->bounds(arg[1],atom->ntypes,jlo,jhi); - - double epsilon_one = force->numeric(FLERR,arg[2]); - double sigma_one = force->numeric(FLERR,arg[3]); - - double cut_one = cut_global; - if (narg == 5) cut_one = force->numeric(FLERR,arg[4]); - - - int count = 0; - for (int i = ilo; i <= ihi; i++) { - for (int j = MAX(jlo,i); j <= jhi; j++) { - epsilon[i][j] = epsilon_one; - sigma[i][j] = sigma_one; - cut[i][j] = cut_one; - setflag[i][j] = 1; - count++; - } - } - - if (count == 0) error->all(FLERR,"Incorrect args for pair coefficients"); -} - -/* ---------------------------------------------------------------------- - init specific to this pair style -------------------------------------------------------------------------- */ - -void PairLJCutHARSAT::init_style() -{ - // request regular or rRESPA neighbor lists - - - if(me == 0){ - if (screen)fprintf(screen,"AT_H_AdResS_allocated flag = %d\n",H_AdResS_allocated); - if (logfile)fprintf(logfile,"AT_H_AdResS_allocated flag = %d\n",H_AdResS_allocated); - } - - if(!H_AdResS_allocated)H_AdResS_Allocation(); - - int This_Step = update->ntimestep; - if((This_Step >= AT_Update_Time_End || Load_File_Flag) && AT_Pressure_Comp_Flag != 0)Load_Compensation_Pressure(); - - - int irequest; - - if (update->whichflag == 1 && strstr(update->integrate_style,"respa")) { - int respa = 0; - if (((Respa *) update->integrate)->level_inner >= 0) respa = 1; - if (((Respa *) update->integrate)->level_middle >= 0) respa = 2; - - if (respa == 0) irequest = neighbor->request(this,instance_me); - else if (respa == 1) { - irequest = neighbor->request(this,instance_me); - neighbor->requests[irequest]->id = 1; - neighbor->requests[irequest]->half = 0; - neighbor->requests[irequest]->respainner = 1; - irequest = neighbor->request(this,instance_me); - neighbor->requests[irequest]->id = 3; - neighbor->requests[irequest]->half = 0; - neighbor->requests[irequest]->respaouter = 1; - } else { - irequest = neighbor->request(this,instance_me); - neighbor->requests[irequest]->id = 1; - neighbor->requests[irequest]->half = 0; - neighbor->requests[irequest]->respainner = 1; - irequest = neighbor->request(this,instance_me); - neighbor->requests[irequest]->id = 2; - neighbor->requests[irequest]->half = 0; - neighbor->requests[irequest]->respamiddle = 1; - irequest = neighbor->request(this,instance_me); - neighbor->requests[irequest]->id = 3; - neighbor->requests[irequest]->half = 0; - neighbor->requests[irequest]->respaouter = 1; - } - - } else { - irequest = neighbor->request(this,instance_me); - } - // set rRESPA cutoffs - - if (strstr(update->integrate_style,"respa") && - ((Respa *) update->integrate)->level_inner >= 0) - cut_respa = ((Respa *) update->integrate)->cutoff; - else cut_respa = NULL; -} - -/* ---------------------------------------------------------------------- - neighbor callback to inform pair style of neighbor list to use - regular or rRESPA -------------------------------------------------------------------------- */ - -void PairLJCutHARSAT::init_list(int id, NeighList *ptr) -{ - if (id == 0) list = ptr; - else if (id == 1) listinner = ptr; - else if (id == 2) listmiddle = ptr; - else if (id == 3) listouter = ptr; -} - -/* ---------------------------------------------------------------------- - init for one type pair i,j and corresponding j,i -------------------------------------------------------------------------- */ - -double PairLJCutHARSAT::init_one(int i, int j) -{ - if (setflag[i][j] == 0) { - epsilon[i][j] = mix_energy(epsilon[i][i],epsilon[j][j], - sigma[i][i],sigma[j][j]); - sigma[i][j] = mix_distance(sigma[i][i],sigma[j][j]); - cut[i][j] = mix_distance(cut[i][i],cut[j][j]); - } - - - lj1[i][j] = 48.0 * epsilon[i][j] * pow(sigma[i][j],12.0); - lj2[i][j] = 24.0 * epsilon[i][j] * pow(sigma[i][j],6.0); - lj3[i][j] = 4.0 * epsilon[i][j] * pow(sigma[i][j],12.0); - lj4[i][j] = 4.0 * epsilon[i][j] * pow(sigma[i][j],6.0); - - - if (offset_flag) { - double ratio = sigma[i][j] / cut[i][j]; - offset[i][j] = 4.0 * epsilon[i][j] * (pow(ratio,12.0) - pow(ratio,6.0)); - } else offset[i][j] = 0.0; - - lj1[j][i] = lj1[i][j]; - lj2[j][i] = lj2[i][j]; - lj3[j][i] = lj3[i][j]; - lj4[j][i] = lj4[i][j]; - offset[j][i] = offset[i][j]; - - // check interior rRESPA cutoff - - if (cut_respa && cut[i][j] < cut_respa[3]) - error->all(FLERR,"Pair cutoff < Respa interior cutoff"); - - // compute I,J contribution to long-range tail correction - // count total # of atoms of type I and J via Allreduce - - if (tail_flag) { - int *type = atom->type; - int nlocal = atom->nlocal; - - double count[2],all[2]; - count[0] = count[1] = 0.0; - for (int k = 0; k < nlocal; k++) { - if (type[k] == i) count[0] += 1.0; - if (type[k] == j) count[1] += 1.0; - } - MPI_Allreduce(count,all,2,MPI_DOUBLE,MPI_SUM,world); - - double sig2 = sigma[i][j]*sigma[i][j]; - double sig6 = sig2*sig2*sig2; - double rc3 = cut[i][j]*cut[i][j]*cut[i][j]; - double rc6 = rc3*rc3; - double rc9 = rc3*rc6; - etail_ij = 8.0*MY_PI*all[0]*all[1]*epsilon[i][j] * - sig6 * (sig6 - 3.0*rc6) / (9.0*rc9); - ptail_ij = 16.0*MY_PI*all[0]*all[1]*epsilon[i][j] * - sig6 * (2.0*sig6 - 3.0*rc6) / (9.0*rc9); - } - - - return cut[i][j]; -} - -/* ---------------------------------------------------------------------- - proc 0 writes to restart file -------------------------------------------------------------------------- */ - -void PairLJCutHARSAT::write_restart(FILE *fp) -{ - write_restart_settings(fp); - - int i,j; - for (i = 1; i <= atom->ntypes; i++) - for (j = i; j <= atom->ntypes; j++) { - fwrite(&setflag[i][j],sizeof(int),1,fp); - if (setflag[i][j]) { - fwrite(&epsilon[i][j],sizeof(double),1,fp); - fwrite(&sigma[i][j],sizeof(double),1,fp); - fwrite(&cut[i][j],sizeof(double),1,fp); - } - } -} - -/* ---------------------------------------------------------------------- - proc 0 reads from restart file, bcasts -------------------------------------------------------------------------- */ - -void PairLJCutHARSAT::read_restart(FILE *fp) -{ - read_restart_settings(fp); - allocate(); - - int i,j; - int me = comm->me; - for (i = 1; i <= atom->ntypes; i++) - for (j = i; j <= atom->ntypes; j++) { - if (me == 0) fread(&setflag[i][j],sizeof(int),1,fp); - MPI_Bcast(&setflag[i][j],1,MPI_INT,0,world); - if (setflag[i][j]) { - if (me == 0) { - fread(&epsilon[i][j],sizeof(double),1,fp); - fread(&sigma[i][j],sizeof(double),1,fp); - fread(&cut[i][j],sizeof(double),1,fp); - } - MPI_Bcast(&epsilon[i][j],1,MPI_DOUBLE,0,world); - MPI_Bcast(&sigma[i][j],1,MPI_DOUBLE,0,world); - MPI_Bcast(&cut[i][j],1,MPI_DOUBLE,0,world); - } - } -} - -/* ---------------------------------------------------------------------- - proc 0 writes to restart file -------------------------------------------------------------------------- */ - -void PairLJCutHARSAT::write_restart_settings(FILE *fp) -{ - fwrite(&cut_global,sizeof(double),1,fp); - fwrite(&offset_flag,sizeof(int),1,fp); - fwrite(&mix_flag,sizeof(int),1,fp); - fwrite(&tail_flag,sizeof(int),1,fp); -} - -/* ---------------------------------------------------------------------- - proc 0 reads from restart file, bcasts -------------------------------------------------------------------------- */ - -void PairLJCutHARSAT::read_restart_settings(FILE *fp) -{ - int me = comm->me; - if (me == 0) { - fread(&cut_global,sizeof(double),1,fp); - fread(&offset_flag,sizeof(int),1,fp); - fread(&mix_flag,sizeof(int),1,fp); - fread(&tail_flag,sizeof(int),1,fp); - } - MPI_Bcast(&cut_global,1,MPI_DOUBLE,0,world); - MPI_Bcast(&offset_flag,1,MPI_INT,0,world); - MPI_Bcast(&mix_flag,1,MPI_INT,0,world); - MPI_Bcast(&tail_flag,1,MPI_INT,0,world); -} - -/* ---------------------------------------------------------------------- - proc 0 writes to data file -------------------------------------------------------------------------- */ - -void PairLJCutHARSAT::write_data(FILE *fp) -{ - for (int i = 1; i <= atom->ntypes; i++) - fprintf(fp,"%d %g %g\n",i,epsilon[i][i],sigma[i][i]); -} - -/* ---------------------------------------------------------------------- - proc 0 writes all pairs to data file -------------------------------------------------------------------------- */ - -void PairLJCutHARSAT::write_data_all(FILE *fp) -{ - for (int i = 1; i <= atom->ntypes; i++) - for (int j = i; j <= atom->ntypes; j++) - fprintf(fp,"%d %d %g %g %g\n",i,j,epsilon[i][j],sigma[i][j],cut[i][j]); -} - -/* ---------------------------------------------------------------------- */ - -double PairLJCutHARSAT::single(int i, int j, int itype, int jtype, double rsq, - double factor_coul, double factor_lj, - double &fforce) -{ - double r2inv,r6inv,forcelj,philj; - - r2inv = 1.0/rsq; - r6inv = r2inv*r2inv*r2inv; - forcelj = r6inv * (lj1[itype][jtype]*r6inv - lj2[itype][jtype]); - fforce = factor_lj*forcelj*r2inv; - - philj = r6inv*(lj3[itype][jtype]*r6inv-lj4[itype][jtype]) - - offset[itype][jtype]; - return factor_lj*philj; -} - -/* ---------------------------------------------------------------------- */ - -void *PairLJCutHARSAT::extract(const char *str, int &dim) -{ - dim = 2; - if (strcmp(str,"epsilon") == 0) return (void *) epsilon; - if (strcmp(str,"sigma") == 0) return (void *) sigma; - return NULL; -} - - -int PairLJCutHARSAT::molecules_in_group(tagint &idlo, tagint &idhi) -{ - int i; - - memory->destroy(AT_molmap_H); - AT_molmap_H = NULL; - - // find lo/hi molecule ID for any atom in group - // warn if atom in group has ID = 0 - - tagint *molecule = atom->molecule; - int *mask = atom->mask; - int nlocal = atom->nlocal; - - tagint lo = BIG; - tagint hi = -BIG; - int flag = 0; - for (i = 0; i < nlocal; i++) - { -// if (mask[i] & groupbit) { - if (mask[i]) { - if (molecule[i] == 0) flag = 1; - lo = MIN(lo,molecule[i]); - hi = MAX(hi,molecule[i]); - } - } - - int flagall; - MPI_Allreduce(&flag,&flagall,1,MPI_INT,MPI_SUM,world); - if (flagall && comm->me == 0) - error->warning(FLERR,"Atom with molecule ID = 0 included in " - "compute molecule group"); - - MPI_Allreduce(&lo,&idlo,1,MPI_LMP_TAGINT,MPI_MIN,world); - MPI_Allreduce(&hi,&idhi,1,MPI_LMP_TAGINT,MPI_MAX,world); - if (idlo == BIG) return 0; - - // molmap = vector of length nlen - // set to 1 for IDs that appear in group across all procs, else 0 - - tagint nlen_tag = idhi-idlo+1; - if (nlen_tag > MAXSMALLINT) - error->all(FLERR,"Too many molecules for compute"); - int nlen = (int) nlen_tag; - - memory->create(AT_molmap_H,nlen,"pair:molmap_H"); - for (i = 0; i < nlen; i++) AT_molmap_H[i] = 0; - - for (i = 0; i < nlocal; i++) - // if (mask[i] & groupbit) - if (mask[i]) - AT_molmap_H[molecule[i]-idlo] = 1; - - int *AT_molmapall; - memory->create(AT_molmapall,nlen,"pair:AT_molmapall"); - MPI_Allreduce(AT_molmap_H,AT_molmapall,nlen,MPI_INT,MPI_MAX,world); - - // nmolecules = # of non-zero IDs in molmap - // molmap[i] = index of molecule, skipping molecules not in group with -1 - - int nmolecules = 0; - for (i = 0; i < nlen; i++) - if (AT_molmapall[i]) AT_molmap_H[i] = nmolecules++; - else AT_molmap_H[i] = -1; - memory->destroy(AT_molmapall); - - // warn if any molecule has some atoms in group and some not in group - - flag = 0; - for (i = 0; i < nlocal; i++) { -// if (mask[i] & groupbit) continue; - if (mask[i]) continue; - if (molecule[i] < idlo || molecule[i] > idhi) continue; - if (AT_molmap_H[molecule[i]-idlo] >= 0) flag = 1; - } - - MPI_Allreduce(&flag,&flagall,1,MPI_INT,MPI_SUM,world); - if (flagall && comm->me == 0) - error->warning(FLERR, - "One or more compute molecules has atoms not in group"); - - // if molmap simply stores 1 to Nmolecules, then free it - - if (idlo == 1 && idhi == nmolecules && nlen == nmolecules) { - memory->destroy(AT_molmap_H); - AT_molmap_H = NULL; - } - return nmolecules; -} - - -void PairLJCutHARSAT::AT_Print_Compensation_Energy(){ - - FILE *fp1; - fp1 = fopen("Mean_Comp_Energy_AT.txt","w"); - if (fp1 == NULL) { - char str[128]; - sprintf(str,"Cannot open Mean_Comp_Energy_AT.txt file %s","Mean_Comp_Energy_AT.txt"); - error->one(FLERR,str); - } - - for(int i = 0;i < AT_Bin_Num; i++){ - fprintf(fp1,"%d",i+1); - for(int j = 0; j < atom->nmoltypesH; j++){ - fprintf(fp1,"\t%.10f",Mean_Comp_Energy_H[i][j]); - } - fprintf(fp1,"\n"); - } - fclose(fp1); -} - - - -void PairLJCutHARSAT::AT_Update_Compensation_Energy(){ - - MPI_Allreduce(&Comp_Energy_H[0][0],&Comp_Energy_all_H[0][0],AT_Bin_Num*atom->nmoltypesH,MPI_DOUBLE,MPI_SUM,world); - MPI_Allreduce(&Comp_Energy_Num_H[0][0],&Comp_Energy_Num_all_H[0][0],AT_Bin_Num*atom->nmoltypesH,MPI_INT,MPI_SUM,world); - - for(int j = 0;j < atom->nmoltypesH; j++){ - for(int i = 0;i < AT_Bin_Num; i++){ - Mean_Energy_H[i][j] = Comp_Energy_all_H[i][j] / Comp_Energy_Num_all_H[i][j]; - Mean_Comp_Energy_H[i][j] = (Comp_Counter_H * Mean_Comp_Energy_H[i][j] + Mean_Energy_H[i][j]) / (Comp_Counter_H + 1); - Int_Mean_Energy_H[i][j]=0; - } - } - - Comp_Counter_H++; - - for(int j = 0;j < atom->nmoltypesH; j++){ - for(int i = 0;i < AT_Bin_Num; i++){ - Comp_Energy_Num_H[i][j] = 0; - Comp_Energy_Num_all_H[i][j] = 0; - Comp_Energy_H[i][j] = 0; - Comp_Energy_all_H[i][j] =0; - } - - } - if (me == 0)AT_Print_Compensation_Energy(); - - - -} - - -void PairLJCutHARSAT::Load_Compensation_Pressure(){ - - if(me == 0){ - FILE *fp1; - char str[128]; - - fp1 = fopen("Mean_Comp_Energy_AT.txt","r"); - if (fp1 == NULL) { - sprintf(str,"Cannot open fix Mean_Comp_Energy_AT.txt file %s","Mean_Comp_Energy_AT.txt"); - error->one(FLERR,str); - } - - int i1; - - while (!feof(fp1)){ - fscanf (fp1,"%d",&i1); - for(int j=0;jnmoltypesH;j++)fscanf (fp1,"\t%f",&Mean_Comp_Energy_H[i1-1][j]); - fscanf (fp1,"\n"); - if(i1 > AT_Bin_Num){ - sprintf(str,"Pressure bin number mismatches %d != %d",AT_Bin_Num,i1); - error->one(FLERR,str); - } - - } - - fclose(fp1); - - if(me==0){ - if(screen)fprintf(screen,"AT_Pressure componsation forces distributed successfully!\n"); - if(logfile)fprintf(logfile,"AT_Pressure componsation forces distributed successfully!\n"); - } - - } - - MPI_Bcast(Mean_Comp_Energy_H,AT_Bin_Num,MPI_DOUBLE,0,world); - - -} - -void PairLJCutHARSAT::H_AdResS_Allocation(){ - - for (int i = 0; i < modify->nfix; i++){ - if (strcmp(modify->fix[i]->style,"lambdah/calc") == 0){ - lambda_H_fix = (FixLambdaHCalc *) modify->fix[i]; - AT_lambda_Increment = lambda_H_fix->Pressure_lambda_Increment; - AT_Bin_Num = lambda_H_fix->Pressure_Bin_Num; - AT_Update_Frequency = lambda_H_fix->Pressure_Update_Frequency; - AT_Update_Time_Begin = lambda_H_fix->Pressure_Update_Time_Begin; - AT_Update_Time_End = lambda_H_fix->Pressure_Update_Time_End; - - AT_Pressure_Comp_Flag = lambda_H_fix->Pressure_Comp_Flag; - AT_center_box = lambda_H_fix->center_box; - AT_Hybrid_Style = lambda_H_fix->Hybrid_Style; - - - } - } - - if(me == 0){ - if (screen){ - fprintf(screen,"AT_lambda_Increment= %f\n",AT_lambda_Increment); - fprintf(screen,"AT_Bin_Num= %d\n",AT_Bin_Num); - fprintf(screen,"AT_Update_Frequency= %d\n",AT_Update_Frequency); - fprintf(screen,"AT_Update_Time_Begin= %d\n",AT_Update_Time_Begin); - fprintf(screen,"AT_Update_Time_End= %d\n",AT_Update_Time_End); - fprintf(screen,"AT_Pressure_Comp_Flag= %d\n",AT_Pressure_Comp_Flag); - } - - if (logfile){ - fprintf(logfile,"AT_lambda_Increment= %f\n",AT_lambda_Increment); - fprintf(logfile,"AT_Bin_Num= %d\n",AT_Bin_Num); - fprintf(logfile,"AT_Update_Frequency= %d\n",AT_Update_Frequency); - fprintf(logfile,"AT_Update_Time_Begin= %d\n",AT_Update_Time_Begin); - fprintf(logfile,"AT_Update_Time_End= %d\n",AT_Update_Time_End); - fprintf(logfile,"AT_Pressure_Comp_Flag= %d\n",AT_Pressure_Comp_Flag); - } - } - - memory->create(Comp_Energy_Num_H,AT_Bin_Num,atom->nmoltypesH,"pairLJHAT:Comp_Energy_Num_H"); - memory->create(Comp_Energy_Num_all_H,AT_Bin_Num,atom->nmoltypesH,"pairLJHAT:Comp_Energy_Num_all_H"); - - memory->create(Int_Mean_Energy_H,AT_Bin_Num,atom->nmoltypesH,"pairLJHAT:Int_Mean_Energy_H"); - memory->create(Comp_Energy_H,AT_Bin_Num,atom->nmoltypesH,"pairLJHAT:Comp_Energy_H"); - memory->create(Comp_Energy_all_H,AT_Bin_Num,atom->nmoltypesH,"pairLJHAT:Comp_Energy_all_H"); - memory->create(Mean_Comp_Energy_H,AT_Bin_Num,atom->nmoltypesH,"pairLJHAT:Mean_Comp_Energy_H"); - memory->create(Mean_Energy_H,AT_Bin_Num,atom->nmoltypesH,"pairLJHAT:Mean_Energy_H"); - - for(int j=0;jnmoltypesH;j++){ - for(int i = 0;i < AT_Bin_Num; i++){ - Int_Mean_Energy_H[i][j]=0; - Comp_Energy_H[i][j]=0; - Comp_Energy_all_H[i][j]=0; - Mean_Comp_Energy_H[i][j]=0; - Comp_Energy_Num_H[i][j] = 0; - Comp_Energy_Num_all_H[i][j] = 0; - } - - } - - H_AdResS_allocated = 1; -} - diff --git a/src/USER-HADRESS/pair_lj_cut_hars_at.h b/src/USER-HADRESS/pair_lj_cut_hars_at.h deleted file mode 100644 index 04f41cfc90..0000000000 --- a/src/USER-HADRESS/pair_lj_cut_hars_at.h +++ /dev/null @@ -1,119 +0,0 @@ -/* -*- c++ -*- ---------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - http://lammps.sandia.gov, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - Copyright (2003) Sandia Corporation. Under the terms of Contract - DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains - certain rights in this software. This software is distributed under - the GNU General Public License. - - See the README file in the top-level LAMMPS directory. -------------------------------------------------------------------------- */ - -#ifdef PAIR_CLASS - -PairStyle(lj/cut/hars/at,PairLJCutHARSAT) - -#else - -#ifndef LMP_PAIR_LJ_CUT_HARS_AT_H -#define LMP_PAIR_LJ_CUT_HARS_AT_H - -#include "pair.h" - -namespace LAMMPS_NS { - -class PairLJCutHARSAT : public Pair { - public: - PairLJCutHARSAT(class LAMMPS *); - virtual ~PairLJCutHARSAT(); - virtual void compute(int, int); - void settings(int, char **); - void coeff(int, char **); - void init_style(); - void init_list(int, class NeighList *); - double init_one(int, int); - void write_restart(FILE *); - void read_restart(FILE *); - void write_restart_settings(FILE *); - void read_restart_settings(FILE *); - void write_data(FILE *); - void write_data_all(FILE *); - double single(int, int, int, int, double, double, double, double &); - void *extract(const char *, int &); - - void compute_inner(); - void compute_middle(); - void compute_outer(int, int); - - void AT_Print_Compensation_Energy(); - void AT_Update_Compensation_Energy(); - - protected: - double cut_global; - double **cut; - double **epsilon,**sigma; - double **lj1,**lj2,**lj3,**lj4,**offset; - double *cut_respa; - class FixLambdaHCalc *lambda_H_fix; - - int AllAtomistic; - - virtual void allocate(); - -//private: - int me; - - int H_AdResS_allocated; - - int **Comp_Energy_Num_H,**Comp_Energy_Num_all_H, Comp_Counter_H; - - double AT_lambda_Increment; - int AT_Bin_Num, AT_Update_Frequency, AT_Update_Time_End, AT_Update_Time_Begin; - int AT_Pressure_Compensation_Run; - int AT_Pressure_Comp_Flag; - - double *AT_center_box,AT_x0lo; - int AT_Hybrid_Style; - double **Int_Mean_Energy_H, **Comp_Energy_H, **Comp_Energy_all_H, **Mean_Energy_H, **Mean_Comp_Energy_H; - - int nmolecules; - tagint idlo,idhi; - - double *AT_massproc_H,*AT_masstotal_H; - - double **AT_mol_f_H, **AT_mol_f_all_H; - - int *AT_molmap_H; // convert molecule ID to local index - int Load_File_Flag; - - int molecules_in_group(tagint &, tagint &); - void Load_Compensation_Pressure(); - void H_AdResS_Allocation(); - -}; - -} - -#endif -#endif - -/* ERROR/WARNING messages: - -E: Illegal ... command - -Self-explanatory. Check the input script syntax and compare to the -documentation for the command. You can use -echo screen as a -command-line option when running LAMMPS to see the offending line. - -E: Incorrect args for pair coefficients - -Self-explanatory. Check the input script or data file. - -E: Pair cutoff < Respa interior cutoff - -One or more pairwise cutoffs are too short to use with the specified -rRESPA cutoffs. - -*/ diff --git a/src/USER-HADRESS/pair_lj_cut_hars_cg.cpp b/src/USER-HADRESS/pair_lj_cut_hars_cg.cpp deleted file mode 100644 index 86d61d4471..0000000000 --- a/src/USER-HADRESS/pair_lj_cut_hars_cg.cpp +++ /dev/null @@ -1,1120 +0,0 @@ -/* ---------------------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - http://lammps.sandia.gov, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - Copyright (2003) Sandia Corporation. Under the terms of Contract - DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains - certain rights in this software. This software is distributed under - the GNU General Public License. - - See the README file in the top-level LAMMPS directory. -------------------------------------------------------------------------- */ - -/* ---------------------------------------------------------------------- - Contributing author: Paul Crozier (SNL) -------------------------------------------------------------------------- */ -#include "mpi.h" -#include "math.h" -#include "stdio.h" -#include "stdlib.h" -#include "string.h" -#include "pair_lj_cut_hars_cg.h" -#include "atom.h" -#include "atom_vec.h" -#include "comm.h" -#include "force.h" -#include "neighbor.h" -#include "neigh_list.h" -#include "neigh_request.h" -#include "update.h" -#include "integrate.h" -#include "respa.h" -#include "math_const.h" -#include "memory.h" -#include "error.h" -#include "domain.h" -#include "iostream" -#include "fix.h" -#include "fix_lambdah_calc.h" -#include "modify.h" - -using namespace LAMMPS_NS; -using namespace MathConst; - -#define BIG MAXTAGINT - -/* ---------------------------------------------------------------------- */ - -PairLJCutHARSCG::PairLJCutHARSCG(LAMMPS *lmp) : Pair(lmp) -{ - respa_enable = 1; - writedata = 1; - - massproc_H = NULL; - masstotal_H = NULL; - molmap_H = NULL; - mol_f_H = NULL; - mol_f_all_H = NULL; - Comp_Energy_Num_H = NULL; - Comp_Energy_Num_all_H = NULL; - - Int_Mean_Energy_H = NULL; - Mean_Energy_H = NULL; - Comp_Energy_H = NULL; - Comp_Energy_all_H = NULL; - Mean_Comp_Energy_H = NULL; - CG_Mean_grad_Comp_Density_Conv_H = NULL; - - molmap_H = NULL; - nmolecules = molecules_in_group(idlo,idhi); - - H_AdResS_allocated = 0; - - CG_Pressure_Compensation_Run = 0; - Density_Compensation_Run = 0; - Comp_Counter_H = 0; - CG_Density_Comp_Flag = 0; - CG_Pressure_Comp_Flag = 0; - - - memory->create(massproc_H,nmolecules,"pair:massproc_H"); - memory->create(masstotal_H,nmolecules,"pair:masstotal_H"); - memory->create(mol_f_H,nmolecules,3,"pair:mol_f_H"); - memory->create(mol_f_all_H,nmolecules,3,"pair:mol_f_all_H"); - - - // compute masstotal for each molecule - - MPI_Comm_rank(world, &me); - int *mask = atom->mask; - tagint *molecule = atom->molecule; - int *type = atom->type; - double *mass = atom->mass; - double *rmass = atom->rmass; - int nlocal = atom->nlocal; - tagint imol; - double massone; - - for (int i = 0; i < nmolecules; i++) massproc_H[i] = 0.0; - - for (int i = 0; i < nlocal; i++) - { -// if (mask[i] & groupbit) { - if (mask[i]) { - if (rmass) massone = rmass[i]; - else massone = mass[type[i]]; - imol = molecule[i]; - if (molmap_H) imol = molmap_H[imol-idlo]; - else imol--; - massproc_H[imol] += massone; - - } - } - - MPI_Allreduce(massproc_H,masstotal_H,nmolecules,MPI_DOUBLE,MPI_SUM,world); - -} - -/* ---------------------------------------------------------------------- */ - -PairLJCutHARSCG::~PairLJCutHARSCG() -{ - - - if (allocated) { - - memory->destroy(setflag); - memory->destroy(cutsq); - - memory->destroy(cut); - memory->destroy(epsilon); - memory->destroy(sigma); - memory->destroy(lj1); - memory->destroy(lj2); - memory->destroy(lj3); - memory->destroy(lj4); - memory->destroy(offset); - memory->destroy(massproc_H); - memory->destroy(masstotal_H); - memory->destroy(molmap_H); - memory->destroy(mol_f_H); - memory->destroy(mol_f_all_H); - memory->destroy(Comp_Energy_Num_H); - memory->destroy(Comp_Energy_Num_all_H); - memory->destroy(Int_Mean_Energy_H); - memory->destroy(Mean_Energy_H); - memory->destroy(Comp_Energy_H); - memory->destroy(Comp_Energy_all_H); - memory->destroy(Mean_Comp_Energy_H); - // memory->destroy(CG_Mean_grad_Comp_Density_Conv_H); - -// delete lambda_H_fix; -} -} - -/* ---------------------------------------------------------------------- */ - -void PairLJCutHARSCG::compute(int eflag, int vflag) -{ - int i,j,ii,jj,inum,jnum,itype,jtype; - double xtmp,ytmp,ztmp,delx,dely,delz,evdwl,fpair; - double rsq,r2inv,r6inv,forcelj, factor_lj,Vij; - int *ilist,*jlist,*numneigh,**firstneigh; - int imoltype,jmoltype; - - evdwl = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; - - double **x = atom->x; - double **f = atom->f; - double *lambdaH = atom->lambdaH; - double **gradlambdaH = atom->gradlambdaH; - double **comH = atom->comH; - int *replambdaH = atom->replambdaH; - tagint *molecule = atom->molecule; - double *mass = atom->mass; - int *moltypeH = atom->moltypeH; - int *type = atom->type; - int nlocal = atom->nlocal; - double *special_lj = force->special_lj; - int newton_pair = force->newton_pair; - - int ibin, jbin; - - inum = list->inum; - ilist = list->ilist; - numneigh = list->numneigh; - firstneigh = list->firstneigh; - - double iLambda, jLambda, ijLambda; - int imol,jmol; - - - - int This_Step = update->ntimestep; - if(This_Step >= CG_Update_Time_Begin && This_Step <= CG_Update_Time_End && CG_Pressure_Comp_Flag != 0){ - CG_Pressure_Compensation_Run = 1; - if(me==0 && This_Step == CG_Update_Time_Begin){ - if(screen)fprintf(screen,"\nStart of constant-pressure route\n"); - if(logfile)fprintf(logfile,"\nStart of constant-pressure route\n"); - } - } - - - if(update->ntimestepDensity_Compensation_Run; - - if(Density_Compensation_Run){ - CG_Mean_grad_Comp_Density_Conv_H = lambda_H_fix->Mean_grad_Comp_Density_Conv_H; - } - - for (ii = 0; ii < inum; ii++) { - - i = ilist[ii]; - if(replambdaH[i] == 0)continue; - - xtmp = comH[i][0]; - ytmp = comH[i][1]; - ztmp = comH[i][2]; - -// itype = moltypeH[i]; - itype = type[i]; - jlist = firstneigh[i]; - jnum = numneigh[i]; - imoltype = itype - 1; - - iLambda = 1 - lambdaH[i]; - - for (jj = 0; jj < jnum; jj++) { - - j = jlist[jj]; - factor_lj = special_lj[sbmask(j)]; - j &= NEIGHMASK; - jLambda = 1 - lambdaH[j]; - - if(replambdaH[j] == 0)continue; - - if((iLambda==0 && jLambda==0) && AllCoarseGrained != 1)continue; - - delx = xtmp - comH[j][0]; - dely = ytmp - comH[j][1]; - delz = ztmp - comH[j][2]; - - domain->minimum_image(delx,dely,delz); - - rsq = delx*delx + dely*dely + delz*delz; - jtype = type[j]; - //jtype = moltypeH[j]; - jmoltype = jtype - 1; - -// if (rsq < cutsq[itype][jtype] && lj1[itype][jtype] != 0) { - if (rsq < cutsq[itype][jtype]) { - - - imol = molecule[i]; - jmol = molecule[j]; - if (molmap_H) { - imol = molmap_H[imol-idlo]; - jmol = molmap_H[jmol-idlo]; - } - else { - imol--; - jmol--; - } - - - if(((iLambda==1 && jLambda==1) || AllCoarseGrained)){ - - r2inv = 1.0/rsq; - r6inv = r2inv*r2inv*r2inv; - forcelj = r6inv * (lj1[itype][jtype]*r6inv - lj2[itype][jtype]); - - fpair = factor_lj*forcelj*r2inv; - mol_f_H[imol][0] += delx*fpair; - mol_f_H[imol][1] += dely*fpair; - mol_f_H[imol][2] += delz*fpair; - - if (newton_pair || j < nlocal) { - mol_f_H[jmol][0] -= delx*fpair; - mol_f_H[jmol][1] -= dely*fpair; - mol_f_H[jmol][2] -= delz*fpair; - } - - if (eflag) { - evdwl = r6inv*(lj3[itype][jtype]*r6inv-lj4[itype][jtype]) - - offset[itype][jtype]; - evdwl *= factor_lj; - } - - if (evflag) ev_tally(i,j,nlocal,newton_pair, - evdwl,0.0,fpair,delx,dely,delz); - - } - - else if(iLambda != 0 || jLambda != 0){ - - ijLambda = 0.5 * (iLambda + jLambda); - r2inv = 1.0/rsq; - r6inv = r2inv*r2inv*r2inv; - forcelj = r6inv * (lj1[itype][jtype]*r6inv - lj2[itype][jtype]); - fpair = factor_lj*(forcelj*ijLambda)*r2inv; - - Vij = 0.5*(r6inv*(lj3[itype][jtype]*r6inv-lj4[itype][jtype]) - - offset[itype][jtype]); - - - ibin = floor(iLambda/CG_lambda_Increment); - if(ibin==CG_Bin_Num)ibin = CG_Bin_Num - 1; - - if(CG_Pressure_Compensation_Run != 0 && iLambda != 0 && iLambda != 1)Comp_Energy_H[ibin][imoltype] += Vij; - - mol_f_H[imol][0] += delx*fpair + Vij*gradlambdaH[i][0]; - mol_f_H[imol][1] += dely*fpair + Vij*gradlambdaH[i][1]; - mol_f_H[imol][2] += delz*fpair + Vij*gradlambdaH[i][2]; - - if (newton_pair || j < nlocal) { - - jbin = floor(jLambda/CG_lambda_Increment); - if(jbin==CG_Bin_Num)jbin = CG_Bin_Num - 1; - if(CG_Pressure_Compensation_Run != 0 && jLambda != 0 && jLambda != 1)Comp_Energy_H[jbin][jmoltype] += Vij; - - mol_f_H[jmol][0] -= delx*fpair - Vij*gradlambdaH[j][0]; - mol_f_H[jmol][1] -= dely*fpair - Vij*gradlambdaH[j][1]; - mol_f_H[jmol][2] -= delz*fpair - Vij*gradlambdaH[j][2]; - - } - - if (eflag) { - evdwl = ijLambda*Vij*2.0; - evdwl *= factor_lj; - } - - if (evflag) ev_tally(i,j,nlocal,newton_pair, - evdwl,0.0,fpair,delx,dely,delz); - - } - } - - } - } - - - MPI_Allreduce(&mol_f_H[0][0],&mol_f_all_H[0][0],3*nmolecules,MPI_DOUBLE,MPI_SUM,world); - - if(CG_Pressure_Compensation_Run != 0 && CG_Pressure_Comp_Flag != 0){ - for (int i = 0; i < nlocal; i++){ - iLambda = 1 - lambdaH[i]; - if(replambdaH[i] != 0 && lambdaH[i] != 0 && lambdaH[i] != 1){ - ibin = floor(iLambda/CG_lambda_Increment); - if(ibin==CG_Bin_Num)ibin = CG_Bin_Num - 1; - itype = moltypeH[i] - 1; - Comp_Energy_Num_H[ibin][itype]++; - - } - } - - if(This_Step % CG_Update_Frequency == 0)CG_Update_Compensation_Energy(); - } - - - double mol_mass,mass_frac; - double Grad_Density,r; - if(AllCoarseGrained != 1 && (CG_Density_Comp_Flag != 0 || CG_Pressure_Comp_Flag != 0)){ - - for (int i = 0; i < nlocal; i++){ - imol = molecule[i]; - if (molmap_H)imol = molmap_H[imol-idlo]; - else imol--; - mol_mass = masstotal_H[imol]; - mass_frac = mass[type[i]] / mol_mass; - iLambda = 1 - lambdaH[i]; - - if(iLambda != 0 && iLambda != 1){ - - ibin = floor(iLambda/CG_lambda_Increment); - itype = moltypeH[i] - 1; - - f[i][0] += mass_frac*(mol_f_all_H[imol][0]-gradlambdaH[i][0]*Mean_Comp_Energy_H[ibin][itype]); - f[i][1] += mass_frac*(mol_f_all_H[imol][1]-gradlambdaH[i][1]*Mean_Comp_Energy_H[ibin][itype]); - f[i][2] += mass_frac*(mol_f_all_H[imol][2]-gradlambdaH[i][2]*Mean_Comp_Energy_H[ibin][itype]); - - if (evflag) ev_tally(i,i,nlocal,newton_pair, - -0.5*Int_Mean_Energy_H[ibin][itype],0.0,0.0,0.0,0.0,0.0); - - - if(CG_Density_Comp_Flag != 0){ - - if(CG_Hybrid_Style == 0){ - ibin = floor((comH[i][0]-CG_x0lo)/CG_Density_Bin_Size); - f[i][0] += mass_frac*(-1.0*CG_Mean_grad_Comp_Density_Conv_H[ibin][itype]); - } - else if(CG_Hybrid_Style == 1){ - delx = comH[i][0] - CG_center_box[0]; - dely = comH[i][1] - CG_center_box[1]; - delz = comH[i][2] - CG_center_box[2]; - r = sqrt(delx*delx + dely*dely + delz*delz); - ibin = floor(r/CG_Density_Bin_Size); - - Grad_Density = CG_Mean_grad_Comp_Density_Conv_H[ibin][itype] / r; - f[i][0] += -mass_frac * Grad_Density * delx; - f[i][1] += -mass_frac * Grad_Density * dely; - f[i][2] += -mass_frac * Grad_Density * delz; - } - else if(CG_Hybrid_Style == 2){ - delx = comH[i][0] - CG_center_box[0]; - dely = comH[i][1] - CG_center_box[1]; - r = sqrt(delx*delx + dely*dely); - ibin = floor(r/CG_Density_Bin_Size); - - Grad_Density = CG_Mean_grad_Comp_Density_Conv_H[ibin][itype] / r; - f[i][0] += -mass_frac * Grad_Density * delx; - f[i][1] += -mass_frac * Grad_Density * dely; - } - - } - } - else{ - f[i][0] += mass_frac*mol_f_all_H[imol][0]; - f[i][1] += mass_frac*mol_f_all_H[imol][1]; - f[i][2] += mass_frac*mol_f_all_H[imol][2]; - } - - } - - } - else{ - - for (int i = 0; i < nlocal; i++){ - imol = molecule[i]; - if (molmap_H)imol = molmap_H[imol-idlo]; - else imol--; - mol_mass = masstotal_H[imol]; - mass_frac = mass[type[i]] / mol_mass; - - f[i][0] += mass_frac*mol_f_all_H[imol][0]; - f[i][1] += mass_frac*mol_f_all_H[imol][1]; - f[i][2] += mass_frac*mol_f_all_H[imol][2]; - } - - } - - - - if(This_Step == CG_Update_Time_End){ - CG_Pressure_Compensation_Run = 0; - if(me == 0){ - if(screen)fprintf(screen,"\nEnd of constant-pressure route\n"); - if(logfile)fprintf(logfile,"\nEnd of constant-pressure route\n"); - - } - } - - - if (vflag_fdotr) virial_fdotr_compute(); -} - -/* ---------------------------------------------------------------------- */ - -void PairLJCutHARSCG::compute_inner() -{ - - error->all(FLERR,"Rrespa has not been included!"); - -} - -/* ---------------------------------------------------------------------- */ - -void PairLJCutHARSCG::compute_middle() -{ - error->all(FLERR,"Rrespa has not been included!"); - -} - -/* ---------------------------------------------------------------------- */ - -void PairLJCutHARSCG::compute_outer(int eflag, int vflag) -{ - error->all(FLERR,"Rrespa has not been included!"); -} - -/* ---------------------------------------------------------------------- - allocate all arrays -------------------------------------------------------------------------- */ - -void PairLJCutHARSCG::allocate() -{ - - allocated = 1; - int n = atom->ntypes; - - memory->create(setflag,n+1,n+1,"pairLJHCG:setflag"); - for (int i = 1; i <= n; i++) - for (int j = i; j <= n; j++) - setflag[i][j] = 0; - - memory->create(cutsq,n+1,n+1,"pairLJHCG:cutsq"); - memory->create(cut,n+1,n+1,"pairLJHCG:cut"); - memory->create(epsilon,n+1,n+1,"pairLJHCG:epsilon"); - memory->create(sigma,n+1,n+1,"pairLJHCG:sigma"); - memory->create(lj1,n+1,n+1,"pairLJHCG:lj1"); - memory->create(lj2,n+1,n+1,"pairLJHCG:lj2"); - memory->create(lj3,n+1,n+1,"pairLJHCG:lj3"); - memory->create(lj4,n+1,n+1,"pairLJHCG:lj4"); - memory->create(offset,n+1,n+1,"pairLJHCG:offset"); - - - -} - -/* ---------------------------------------------------------------------- - global settings -------------------------------------------------------------------------- */ - -void PairLJCutHARSCG::settings(int narg, char **arg) -{ - if (narg != 3) error->all(FLERR,"Illegal pair_style command"); - - cut_global = force->numeric(FLERR,arg[0]); - - AllCoarseGrained = force->numeric(FLERR,arg[1]); - - Load_File_Flag = force->numeric(FLERR,arg[2]); - // reset cutoffs that have been explicitly set - - if (allocated) { - int i,j; - for (i = 1; i <= atom->ntypes; i++) - for (j = i+1; j <= atom->ntypes; j++) - if (setflag[i][j]) cut[i][j] = cut_global; - } - -} - -/* ---------------------------------------------------------------------- - set coeffs for one or more type pairs -------------------------------------------------------------------------- */ - -void PairLJCutHARSCG::coeff(int narg, char **arg) -{ - - if (narg < 4 || narg > 5) - error->all(FLERR,"Incorrect args for pair coefficients"); - if (!allocated) allocate(); - - int ilo,ihi,jlo,jhi; - - force->bounds(arg[0],atom->ntypes,ilo,ihi); - force->bounds(arg[1],atom->ntypes,jlo,jhi); - - - - double epsilon_one = force->numeric(FLERR,arg[2]); - double sigma_one = force->numeric(FLERR,arg[3]); - - double cut_one = cut_global; - if (narg == 5) cut_one = force->numeric(FLERR,arg[4]); - - int count = 0; - for (int i = ilo; i <= ihi; i++) { - for (int j = MAX(jlo,i); j <= jhi; j++) { - epsilon[i][j] = epsilon_one; - sigma[i][j] = sigma_one; - cut[i][j] = cut_one; - setflag[i][j] = 1; - count++; - - } - } - - if (count == 0) error->all(FLERR,"Incorrect args for pair coefficients"); -} - -/* ---------------------------------------------------------------------- - init specific to this pair style -------------------------------------------------------------------------- */ - -void PairLJCutHARSCG::init_style() -{ - // request regular or rRESPA neighbor lists - if(me == 0){ - if (screen)fprintf(screen,"CG_H_AdResS_allocated flag = %d\n",H_AdResS_allocated); - if (logfile)fprintf(logfile,"CG_H_AdResS_allocated flag = %d\n",H_AdResS_allocated); - } - - if(!H_AdResS_allocated)H_AdResS_Allocation(); - - - int This_Step = update->ntimestep; - CG_Restart_Time_Step = This_Step; - - if((This_Step >= CG_Update_Time_End || Load_File_Flag) && CG_Pressure_Comp_Flag != 0)Load_Compensation_Pressure(); - - int irequest; - - if (update->whichflag == 1 && strstr(update->integrate_style,"respa")) { - int respa = 0; - if (((Respa *) update->integrate)->level_inner >= 0) respa = 1; - if (((Respa *) update->integrate)->level_middle >= 0) respa = 2; - - if (respa == 0)irequest = neighbor->request(this,instance_me); - else if (respa == 1) { - irequest = neighbor->request(this,instance_me); - neighbor->requests[irequest]->id = 1; - neighbor->requests[irequest]->half = 0; - neighbor->requests[irequest]->respainner = 1; - irequest = neighbor->request(this,instance_me); - neighbor->requests[irequest]->id = 3; - neighbor->requests[irequest]->half = 0; - neighbor->requests[irequest]->respaouter = 1; - } else { - irequest = neighbor->request(this,instance_me); - neighbor->requests[irequest]->id = 1; - neighbor->requests[irequest]->half = 0; - neighbor->requests[irequest]->respainner = 1; - irequest = neighbor->request(this,instance_me); - neighbor->requests[irequest]->id = 2; - neighbor->requests[irequest]->half = 0; - neighbor->requests[irequest]->respamiddle = 1; - irequest = neighbor->request(this,instance_me); - neighbor->requests[irequest]->id = 3; - neighbor->requests[irequest]->half = 0; - neighbor->requests[irequest]->respaouter = 1; - } - - } else irequest = neighbor->request(this,instance_me); - - // set rRESPA cutoffs - - if (strstr(update->integrate_style,"respa") && - ((Respa *) update->integrate)->level_inner >= 0) - cut_respa = ((Respa *) update->integrate)->cutoff; - else cut_respa = NULL; -} - -/* ---------------------------------------------------------------------- - neighbor callback to inform pair style of neighbor list to use - regular or rRESPA -------------------------------------------------------------------------- */ - -void PairLJCutHARSCG::init_list(int id, NeighList *ptr) -{ - if (id == 0) list = ptr; - else if (id == 1) listinner = ptr; - else if (id == 2) listmiddle = ptr; - else if (id == 3) listouter = ptr; -} - -/* ---------------------------------------------------------------------- - init for one type pair i,j and corresponding j,i -------------------------------------------------------------------------- */ - -double PairLJCutHARSCG::init_one(int i, int j) -{ - if (setflag[i][j] == 0) { - epsilon[i][j] = mix_energy(epsilon[i][i],epsilon[j][j], - sigma[i][i],sigma[j][j]); - sigma[i][j] = mix_distance(sigma[i][i],sigma[j][j]); - cut[i][j] = mix_distance(cut[i][i],cut[j][j]); - } - - - lj1[i][j] = 48.0 * epsilon[i][j] * pow(sigma[i][j],12.0); - lj2[i][j] = 24.0 * epsilon[i][j] * pow(sigma[i][j],6.0); - lj3[i][j] = 4.0 * epsilon[i][j] * pow(sigma[i][j],12.0); - lj4[i][j] = 4.0 * epsilon[i][j] * pow(sigma[i][j],6.0); - - - if (offset_flag) { - double ratio = sigma[i][j] / cut[i][j]; - offset[i][j] = 4.0 * epsilon[i][j] * (pow(ratio,12.0) - pow(ratio,6.0)); - } else offset[i][j] = 0.0; - - lj1[j][i] = lj1[i][j]; - lj2[j][i] = lj2[i][j]; - lj3[j][i] = lj3[i][j]; - lj4[j][i] = lj4[i][j]; - offset[j][i] = offset[i][j]; - - // check interior rRESPA cutoff - - if (cut_respa && cut[i][j] < cut_respa[3]) - error->all(FLERR,"Pair cutoff < Respa interior cutoff"); - - // compute I,J contribution to long-range tail correction - // count total # of atoms of type I and J via Allreduce - - if (tail_flag) { - int *type = atom->type; - int nlocal = atom->nlocal; - - double count[2],all[2]; - count[0] = count[1] = 0.0; - for (int k = 0; k < nlocal; k++) { - if (type[k] == i) count[0] += 1.0; - if (type[k] == j) count[1] += 1.0; - } - MPI_Allreduce(count,all,2,MPI_DOUBLE,MPI_SUM,world); - - double sig2 = sigma[i][j]*sigma[i][j]; - double sig6 = sig2*sig2*sig2; - double rc3 = cut[i][j]*cut[i][j]*cut[i][j]; - double rc6 = rc3*rc3; - double rc9 = rc3*rc6; - etail_ij = 8.0*MY_PI*all[0]*all[1]*epsilon[i][j] * - sig6 * (sig6 - 3.0*rc6) / (9.0*rc9); - ptail_ij = 16.0*MY_PI*all[0]*all[1]*epsilon[i][j] * - sig6 * (2.0*sig6 - 3.0*rc6) / (9.0*rc9); - } - - return cut[i][j]; -} - -/* ---------------------------------------------------------------------- - proc 0 writes to restart file -------------------------------------------------------------------------- */ - -void PairLJCutHARSCG::write_restart(FILE *fp) -{ - write_restart_settings(fp); - - int i,j; - for (i = 1; i <= atom->ntypes; i++) - for (j = i; j <= atom->ntypes; j++) { - fwrite(&setflag[i][j],sizeof(int),1,fp); - if (setflag[i][j]) { - fwrite(&epsilon[i][j],sizeof(double),1,fp); - fwrite(&sigma[i][j],sizeof(double),1,fp); - fwrite(&cut[i][j],sizeof(double),1,fp); - } - } -} - -/* ---------------------------------------------------------------------- - proc 0 reads from restart file, bcasts -------------------------------------------------------------------------- */ - -void PairLJCutHARSCG::read_restart(FILE *fp) -{ - read_restart_settings(fp); - allocate(); - - int i,j; - int me = comm->me; - for (i = 1; i <= atom->ntypes; i++) - for (j = i; j <= atom->ntypes; j++) { - if (me == 0) fread(&setflag[i][j],sizeof(int),1,fp); - MPI_Bcast(&setflag[i][j],1,MPI_INT,0,world); - if (setflag[i][j]) { - if (me == 0) { - fread(&epsilon[i][j],sizeof(double),1,fp); - fread(&sigma[i][j],sizeof(double),1,fp); - fread(&cut[i][j],sizeof(double),1,fp); - } - MPI_Bcast(&epsilon[i][j],1,MPI_DOUBLE,0,world); - MPI_Bcast(&sigma[i][j],1,MPI_DOUBLE,0,world); - MPI_Bcast(&cut[i][j],1,MPI_DOUBLE,0,world); - } - } -} - -/* ---------------------------------------------------------------------- - proc 0 writes to restart file -------------------------------------------------------------------------- */ - -void PairLJCutHARSCG::write_restart_settings(FILE *fp) -{ - fwrite(&cut_global,sizeof(double),1,fp); - fwrite(&offset_flag,sizeof(int),1,fp); - fwrite(&mix_flag,sizeof(int),1,fp); - fwrite(&tail_flag,sizeof(int),1,fp); -} - -/* ---------------------------------------------------------------------- - proc 0 reads from restart file, bcasts -------------------------------------------------------------------------- */ - -void PairLJCutHARSCG::read_restart_settings(FILE *fp) -{ - int me = comm->me; - if (me == 0) { - fread(&cut_global,sizeof(double),1,fp); - fread(&offset_flag,sizeof(int),1,fp); - fread(&mix_flag,sizeof(int),1,fp); - fread(&tail_flag,sizeof(int),1,fp); - } - MPI_Bcast(&cut_global,1,MPI_DOUBLE,0,world); - MPI_Bcast(&offset_flag,1,MPI_INT,0,world); - MPI_Bcast(&mix_flag,1,MPI_INT,0,world); - MPI_Bcast(&tail_flag,1,MPI_INT,0,world); -} - -/* ---------------------------------------------------------------------- - proc 0 writes to data file -------------------------------------------------------------------------- */ - -void PairLJCutHARSCG::write_data(FILE *fp) -{ - for (int i = 1; i <= atom->ntypes; i++) - fprintf(fp,"%d %g %g\n",i,epsilon[i][i],sigma[i][i]); -} - -/* ---------------------------------------------------------------------- - proc 0 writes all pairs to data file -------------------------------------------------------------------------- */ - -void PairLJCutHARSCG::write_data_all(FILE *fp) -{ - for (int i = 1; i <= atom->ntypes; i++) - for (int j = i; j <= atom->ntypes; j++) - fprintf(fp,"%d %d %g %g %g\n",i,j,epsilon[i][j],sigma[i][j],cut[i][j]); -} - -/* ---------------------------------------------------------------------- */ - -double PairLJCutHARSCG::single(int i, int j, int itype, int jtype, double rsq, - double factor_coul, double factor_lj, - double &fforce) -{ - double r2inv,r6inv,forcelj,philj; - - r2inv = 1.0/rsq; - r6inv = r2inv*r2inv*r2inv; - forcelj = r6inv * (lj1[itype][jtype]*r6inv - lj2[itype][jtype]); - fforce = factor_lj*forcelj*r2inv; - - philj = r6inv*(lj3[itype][jtype]*r6inv-lj4[itype][jtype]) - - offset[itype][jtype]; - return factor_lj*philj; -} - -/* ---------------------------------------------------------------------- */ - -void *PairLJCutHARSCG::extract(const char *str, int &dim) -{ - dim = 2; - if (strcmp(str,"epsilon") == 0) return (void *) epsilon; - if (strcmp(str,"sigma") == 0) return (void *) sigma; - return NULL; -} - - - -int PairLJCutHARSCG::molecules_in_group(tagint &idlo, tagint &idhi) -{ - int i; - - memory->destroy(molmap_H); - molmap_H = NULL; - - // find lo/hi molecule ID for any atom in group - // warn if atom in group has ID = 0 - - tagint *molecule = atom->molecule; - int *mask = atom->mask; - int nlocal = atom->nlocal; - - tagint lo = BIG; - tagint hi = -BIG; - int flag = 0; - for (i = 0; i < nlocal; i++) - { -// if (mask[i] & groupbit) { - if (mask[i]) { - if (molecule[i] == 0) flag = 1; - lo = MIN(lo,molecule[i]); - hi = MAX(hi,molecule[i]); - } - } - - int flagall; - MPI_Allreduce(&flag,&flagall,1,MPI_INT,MPI_SUM,world); - if (flagall && comm->me == 0) - error->warning(FLERR,"Atom with molecule ID = 0 included in " - "compute molecule group"); - - MPI_Allreduce(&lo,&idlo,1,MPI_LMP_TAGINT,MPI_MIN,world); - MPI_Allreduce(&hi,&idhi,1,MPI_LMP_TAGINT,MPI_MAX,world); - if (idlo == BIG) return 0; - - // molmap = vector of length nlen - // set to 1 for IDs that appear in group across all procs, else 0 - - tagint nlen_tag = idhi-idlo+1; - if (nlen_tag > MAXSMALLINT) - error->all(FLERR,"Too many molecules for compute"); - int nlen = (int) nlen_tag; - - memory->create(molmap_H,nlen,"pair:molmap_H"); - for (i = 0; i < nlen; i++) molmap_H[i] = 0; - - for (i = 0; i < nlocal; i++) - // if (mask[i] & groupbit) - if (mask[i]) - molmap_H[molecule[i]-idlo] = 1; - - int *molmapall; - memory->create(molmapall,nlen,"pair:molmapall"); - MPI_Allreduce(molmap_H,molmapall,nlen,MPI_INT,MPI_MAX,world); - - // nmolecules = # of non-zero IDs in molmap - // molmap[i] = index of molecule, skipping molecules not in group with -1 - - int nmolecules = 0; - for (i = 0; i < nlen; i++) - if (molmapall[i]) molmap_H[i] = nmolecules++; - else molmap_H[i] = -1; - memory->destroy(molmapall); - - // warn if any molecule has some atoms in group and some not in group - - flag = 0; - for (i = 0; i < nlocal; i++) { -// if (mask[i] & groupbit) continue; - if (mask[i]) continue; - if (molecule[i] < idlo || molecule[i] > idhi) continue; - if (molmap_H[molecule[i]-idlo] >= 0) flag = 1; - } - - MPI_Allreduce(&flag,&flagall,1,MPI_INT,MPI_SUM,world); - if (flagall && comm->me == 0) - error->warning(FLERR, - "One or more compute molecules has atoms not in group"); - - // if molmap simply stores 1 to Nmolecules, then free it - - if (idlo == 1 && idhi == nmolecules && nlen == nmolecules) { - memory->destroy(molmap_H); - molmap_H = NULL; - } - return nmolecules; -} - - - -void PairLJCutHARSCG::CG_Print_Compensation_Energy(){ - - FILE *fp1; - - fp1 = fopen("Mean_Comp_Energy_CG.txt","w"); - if (fp1 == NULL) { - char str[128]; - sprintf(str,"Cannot open Mean_Comp_Energy_CG.txt file %s","Mean_Comp_Energy_CG.txt"); - error->one(FLERR,str); - - } - - for(int i = 0;i < CG_Bin_Num; i++){ - fprintf(fp1,"%d",i+1); - for(int k = 0; k < atom->nmoltypesH;k++) - fprintf(fp1,"\t%.10f",Mean_Comp_Energy_H[i][k]); - - fprintf(fp1,"\n"); - } - - fclose(fp1); - -} - - - -void PairLJCutHARSCG::CG_Update_Compensation_Energy(){ - - MPI_Allreduce(&Comp_Energy_H[0][0],&Comp_Energy_all_H[0][0],CG_Bin_Num*(atom->nmoltypesH+1),MPI_DOUBLE,MPI_SUM,world); - MPI_Allreduce(&Comp_Energy_Num_H[0][0],&Comp_Energy_Num_all_H[0][0],CG_Bin_Num*(atom->nmoltypesH+1),MPI_INT,MPI_SUM,world); - - for(int k = 0; k < atom->nmoltypesH;k++)for(int i = 0;i < CG_Bin_Num; i++)Mean_Energy_H[i][k] = Comp_Energy_all_H[i][k] / Comp_Energy_Num_all_H[i][k]; - for(int k = 0; k < atom->nmoltypesH;k++)for(int i = 0;i < CG_Bin_Num; i++)Mean_Comp_Energy_H[i][k] = (Comp_Counter_H * Mean_Comp_Energy_H[i][k] + Mean_Energy_H[i][k]) / (Comp_Counter_H + 1); - for(int k = 0; k < atom->nmoltypesH;k++)for(int i = 0;i < CG_Bin_Num; i++)Int_Mean_Energy_H[i][k]=0; - for(int k = 0; k < atom->nmoltypesH;k++)for(int i = 0;i < CG_Bin_Num; i++)for(int j = 0;j <= i; j++)Int_Mean_Energy_H[i][k] += Mean_Comp_Energy_H[j][k] * CG_lambda_Increment; - - Comp_Counter_H++; - - for(int k = 0; k < atom->nmoltypesH;k++){ - for(int i = 0;i < CG_Bin_Num; i++){ - Comp_Energy_Num_H[i][k] = 0; - Comp_Energy_Num_all_H[i][k] = 0; - Comp_Energy_H[i][k] = 0; - Comp_Energy_all_H[i][k] =0; - } - } - - if (me == 0)CG_Print_Compensation_Energy(); - - -} - - -void PairLJCutHARSCG::Load_Compensation_Pressure(){ - - if(me == 0){ - FILE *fp1; - char str[128]; - - fp1 = fopen("Mean_Comp_Energy_CG.txt","r"); - if (fp1 == NULL) { - sprintf(str,"Cannot open fix Mean_Comp_Energy_CG.txt file %s","Mean_Comp_Energy_CG.txt"); - error->one(FLERR,str); - } - - int i1; - float i2; - - while (!feof(fp1)){ - fscanf (fp1,"%d",&i1); - for(int k = 0; k < atom->nmoltypesH;k++){ - fscanf (fp1,"\t%f",&i2); - Mean_Comp_Energy_H[i1-1][k] = i2; - if(i1 > CG_Bin_Num){ - sprintf(str,"CG drift force compensation bin number mismatches %d != %d",CG_Bin_Num,i1); - error->one(FLERR,str); - } - } - - } - } - - - if(me==0){ - if(screen)fprintf(screen,"CG_Pressure componsation forces distributed successfully!\n"); - if(logfile)fprintf(logfile,"CG_Pressure componsation forces distributed successfully!\n"); - } - - MPI_Bcast(Mean_Comp_Energy_H,CG_Bin_Num*(atom->nmoltypesH+1),MPI_DOUBLE,0,world); -} - - -void PairLJCutHARSCG::H_AdResS_Allocation(){ - - - for (int i = 0; i < modify->nfix; i++){ - - if (strcmp(modify->fix[i]->style,"LambdaH/calc") == 0){ - - lambda_H_fix = (FixLambdaHCalc *) modify->fix[i]; - CG_lambda_Increment = lambda_H_fix->Pressure_lambda_Increment; - CG_Bin_Num = lambda_H_fix->Pressure_Bin_Num; - CG_Update_Frequency = lambda_H_fix->Pressure_Update_Frequency; - CG_Update_Time_Begin = lambda_H_fix->Pressure_Update_Time_Begin; - CG_Update_Time_End = lambda_H_fix->Pressure_Update_Time_End; - - CG_Density_Bin_Num = lambda_H_fix->Density_Bin_Num; - CG_Density_Bin_Size = lambda_H_fix->Density_Bin_Size; - CG_Density_Update_Frequency = lambda_H_fix->Density_Update_Frequency; - CG_Density_Update_Time_Begin = lambda_H_fix->Density_Update_Time_Begin; - CG_Density_Update_Time_End = lambda_H_fix->Density_Update_Time_End; - - CG_Pressure_Comp_Flag = lambda_H_fix->Pressure_Comp_Flag; - CG_Density_Comp_Flag = lambda_H_fix->Density_Comp_Flag; - CG_center_box = lambda_H_fix->center_box; - CG_Hybrid_Style = lambda_H_fix->Hybrid_Style; - CG_x0lo = lambda_H_fix->x0lo; - CG_x0BoxSize = lambda_H_fix->x0BoxSize; - } - } - - if(me == 0){ - if (screen){ - fprintf(screen,"CG_lambda_Increment= %f\n",CG_lambda_Increment); - fprintf(screen,"CG_Bin_Num= %d\n",CG_Bin_Num); - fprintf(screen,"CG_Update_Frequency= %d\n",CG_Update_Frequency); - fprintf(screen,"CG_Update_Time_Begin= %d\n",CG_Update_Time_Begin); - fprintf(screen,"CG_Update_Time_End= %d\n",CG_Update_Time_End); - fprintf(screen,"CG_Pressure_Comp_Flag= %d\n",CG_Pressure_Comp_Flag); - fprintf(screen,"CG_Density_Comp_Flag= %d\n",CG_Density_Comp_Flag); - fprintf(screen,"CG_Hybrid_Style= %d\n",CG_Hybrid_Style); - - } - - if (logfile){ - fprintf(logfile,"CG_lambda_Increment= %f\n",CG_lambda_Increment); - fprintf(logfile,"CG_Bin_Num= %d\n",CG_Bin_Num); - fprintf(logfile,"CG_Update_Frequency= %d\n",CG_Update_Frequency); - fprintf(logfile,"CG_Update_Time_Begin= %d\n",CG_Update_Time_Begin); - fprintf(logfile,"CG_Update_Time_End= %d\n",CG_Update_Time_End); - fprintf(logfile,"CG_Pressure_Comp_Flag= %d\n",CG_Pressure_Comp_Flag); - fprintf(logfile,"CG_Density_Comp_Flag= %d\n",CG_Density_Comp_Flag); - fprintf(logfile,"CG_Hybrid_Style= %d\n",CG_Hybrid_Style); - - } - - - } - - - memory->create(Comp_Energy_Num_H,CG_Bin_Num,atom->nmoltypesH+1,"pairLJHCG:Comp_Energy_Num_H"); - memory->create(Comp_Energy_Num_all_H,CG_Bin_Num,atom->nmoltypesH+1,"pairLJHCG:Comp_Energy_Num_all_H"); - memory->create(Int_Mean_Energy_H,CG_Bin_Num,atom->nmoltypesH+1,"pairLJHCG:Int_Mean_Energy_H"); - memory->create(Comp_Energy_H,CG_Bin_Num,atom->nmoltypesH+1,"pairLJHCG:Comp_Energy_H"); - memory->create(Comp_Energy_all_H,CG_Bin_Num,atom->nmoltypesH+1,"pairLJHCG:Comp_Energy_all_H"); - memory->create(Mean_Comp_Energy_H,CG_Bin_Num,atom->nmoltypesH+1,"pairLJHCG:Mean_Comp_Energy_H"); - memory->create(Mean_Energy_H,CG_Bin_Num,atom->nmoltypesH+1,"pairLJHCG:Mean_Energy_H"); - - memory->create(CG_Mean_grad_Comp_Density_Conv_H,CG_Density_Bin_Num,atom->nmoltypesH+1,"pairLJHCG:CG_Mean_grad_Comp_Density_Conv_H"); - CG_Mean_grad_Comp_Density_Conv_H = lambda_H_fix->Mean_grad_Comp_Density_Conv_H; - - - for(int i = 0;i < CG_Bin_Num; i++){ - for(int j = 0; j < atom->nmoltypesH; j++){ - Int_Mean_Energy_H[i][j] = 0; - Comp_Energy_H[i][j] = 0; - Comp_Energy_all_H[i][j] = 0; - Mean_Comp_Energy_H[i][j] = 0; - Comp_Energy_Num_H[i][j] = 0; - Comp_Energy_Num_all_H[i][j] = 0; - } - } - - - H_AdResS_allocated = 1; - -} diff --git a/src/USER-HADRESS/pair_lj_cut_hars_cg.h b/src/USER-HADRESS/pair_lj_cut_hars_cg.h deleted file mode 100644 index df47c27ec4..0000000000 --- a/src/USER-HADRESS/pair_lj_cut_hars_cg.h +++ /dev/null @@ -1,123 +0,0 @@ -/* -*- c++ -*- ---------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - http://lammps.sandia.gov, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - Copyright (2003) Sandia Corporation. Under the terms of Contract - DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains - certain rights in this software. This software is distributed under - the GNU General Public License. - - See the README file in the top-level LAMMPS directory. -------------------------------------------------------------------------- */ - -#ifdef PAIR_CLASS - -PairStyle(lj/cut/hars/cg,PairLJCutHARSCG) - -#else - -#ifndef LMP_PAIR_LJ_CUT_HARS_CG_H -#define LMP_PAIR_LJ_CUT_HARS_CG_H - -#include "pair.h" - -namespace LAMMPS_NS { - -class PairLJCutHARSCG : public Pair { - public: - PairLJCutHARSCG(class LAMMPS *); - virtual ~PairLJCutHARSCG(); - virtual void compute(int, int); - void settings(int, char **); - void coeff(int, char **); - void init_style(); - void init_list(int, class NeighList *); - double init_one(int, int); - void write_restart(FILE *); - void read_restart(FILE *); - void write_restart_settings(FILE *); - void read_restart_settings(FILE *); - void write_data(FILE *); - void write_data_all(FILE *); - double single(int, int, int, int, double, double, double, double &); - void *extract(const char *, int &); - - void compute_inner(); - void compute_middle(); - void compute_outer(int, int); - - void CG_Print_Compensation_Energy(); - void CG_Update_Compensation_Energy(); - - protected: - double cut_global; - double **cut; - double **epsilon,**sigma; - double **lj1,**lj2,**lj3,**lj4,**offset; - double *cut_respa; - class FixLambdaHCalc *lambda_H_fix; - int AllCoarseGrained; - - double *CG_Ave_Mean_Density_H,CG_grad_Ave_Mean_Density_H; - //private: - - int me; - virtual void allocate(); - - int H_AdResS_allocated; - int **Comp_Energy_Num_H,**Comp_Energy_Num_all_H, Comp_Counter_H; - - double CG_lambda_Increment; - int CG_Bin_Num, CG_Update_Frequency, CG_Update_Time_End, CG_Update_Time_Begin; - int CG_Pressure_Compensation_Run, Density_Compensation_Run; - - int CG_Pressure_Comp_Flag, CG_Density_Comp_Flag; - - double CG_Density_Bin_Size,**CG_Mean_grad_Comp_Density_Conv_H,CG_x0BoxSize; - int CG_Density_Bin_Num,CG_Density_Update_Frequency,CG_Density_Update_Time_Begin,CG_Density_Update_Time_End; - double **Int_Mean_Energy_H, **Comp_Energy_H, **Comp_Energy_all_H, **Mean_Energy_H, **Mean_Comp_Energy_H; - - double *CG_center_box, CG_x0lo; - int CG_Hybrid_Style; - int nmolecules; - tagint idlo,idhi; - - double *massproc_H,*masstotal_H; - - double **mol_f_H, **mol_f_all_H; - - int CG_Restart_Time_Step; - //double **drift_f_H, **drift_f_all_H; - //int nbin_H; - int *molmap_H; // convert molecule ID to local index - int Load_File_Flag; - - int molecules_in_group(tagint &, tagint &); - void Load_Compensation_Pressure(); - void H_AdResS_Allocation(); -}; - -} - -#endif -#endif - -/* ERROR/WARNING messages: - -E: Illegal ... command - -Self-explanatory. Check the input script syntax and compare to the -documentation for the command. You can use -echo screen as a -command-line option when running LAMMPS to see the offending line. - -E: Incorrect args for pair coefficients - -Self-explanatory. Check the input script or data file. - -E: Pair cutoff < Respa interior cutoff - -One or more pairwise cutoffs are too short to use with the specified -rRESPA cutoffs. - -*/ diff --git a/src/USER-HADRESS/read_data.cpp b/src/USER-HADRESS/read_data.cpp deleted file mode 100644 index 478412ae0d..0000000000 --- a/src/USER-HADRESS/read_data.cpp +++ /dev/null @@ -1,2023 +0,0 @@ -/* ---------------------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - http://lammps.sandia.gov, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - Copyright (2003) Sandia Corporation. Under the terms of Contract - DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains - certain rights in this software. This software is distributed under - the GNU General Public License. - - See the README file in the top-level LAMMPS directory. -------------------------------------------------------------------------- */ - -// lmptype.h must be first b/c this file uses MAXBIGINT and includes mpi.h -// due to OpenMPI bug which sets INT64_MAX via its mpi.h -// before lmptype.h can set flags to insure it is done correctly - -#include "lmptype.h" -#include -#include -#include -#include -#include -#include "read_data.h" -#include "atom.h" -#include "atom_vec.h" -#include "atom_vec_ellipsoid.h" -#include "atom_vec_line.h" -#include "atom_vec_tri.h" -#include "force.h" -#include "molecule.h" -#include "group.h" -#include "comm.h" -#include "update.h" -#include "modify.h" -#include "fix.h" -#include "force.h" -#include "pair.h" -#include "domain.h" -#include "bond.h" -#include "angle.h" -#include "dihedral.h" -#include "improper.h" -#include "special.h" -#include "irregular.h" -#include "error.h" -#include "memory.h" - -using namespace LAMMPS_NS; - -#define MAXLINE 256 -#define LB_FACTOR 1.1 -#define CHUNK 1024 -#define DELTA 4 // must be 2 or larger -#define MAXBODY 32 // max # of lines in one body - - // customize for new sections -#define NSECTIONS 25 // change when add to header::section_keywords - -enum{NONE,APPEND,VALUE,MERGE}; - -// pair style suffixes to ignore -// when matching Pair Coeffs comment to currently-defined pair style - -const char *suffixes[] = {"/cuda","/gpu","/opt","/omp","/kk", - "/coul/cut","/coul/long","/coul/msm", - "/coul/dsf","/coul/debye","/coul/charmm", - NULL}; - -/* ---------------------------------------------------------------------- */ - -ReadData::ReadData(LAMMPS *lmp) : Pointers(lmp) -{ - MPI_Comm_rank(world,&me); - line = new char[MAXLINE]; - copy = new char[MAXLINE]; - keyword = new char[MAXLINE]; - style = new char[MAXLINE]; - buffer = new char[CHUNK*MAXLINE]; - narg = maxarg = 0; - arg = NULL; - fp = NULL; - - // customize for new sections - // pointers to atom styles that store extra info - - nellipsoids = 0; - avec_ellipsoid = (AtomVecEllipsoid *) atom->style_match("ellipsoid"); - nlines = 0; - avec_line = (AtomVecLine *) atom->style_match("line"); - ntris = 0; - avec_tri = (AtomVecTri *) atom->style_match("tri"); - nbodies = 0; - avec_body = (AtomVecBody *) atom->style_match("body"); -} - -/* ---------------------------------------------------------------------- */ - -ReadData::~ReadData() -{ - delete [] line; - delete [] copy; - delete [] keyword; - delete [] style; - delete [] buffer; - memory->sfree(arg); - - for (int i = 0; i < nfix; i++) { - delete [] fix_header[i]; - delete [] fix_section[i]; - } - memory->destroy(fix_index); - memory->sfree(fix_header); - memory->sfree(fix_section); -} - -/* ---------------------------------------------------------------------- */ - -void ReadData::command(int narg, char **arg) -{ - if (narg < 1) error->all(FLERR,"Illegal read_data command"); - - // optional args - - addflag = NONE; - coeffflag = 1; - id_offset = 0; - offsetflag = shiftflag = 0; - toffset = boffset = aoffset = doffset = ioffset = 0; - shift[0] = shift[1] = shift[2] = 0.0; - extra_atom_types = extra_bond_types = extra_angle_types = - extra_dihedral_types = extra_improper_types = 0; - - groupbit = 0; - - nfix = 0; - fix_index = NULL; - fix_header = NULL; - fix_section = NULL; - - int iarg = 1; - while (iarg < narg) { - if (strcmp(arg[iarg],"add") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal read_data command"); - if (strcmp(arg[iarg+1],"append") == 0) addflag = APPEND; - else if (strcmp(arg[iarg+1],"merge") == 0) addflag = MERGE; - else { - addflag = VALUE; - bigint offset = force->bnumeric(FLERR,arg[iarg+1]); - if (offset > MAXTAGINT) - error->all(FLERR,"Read data add offset is too big"); - id_offset = offset; - } - iarg += 2; - } else if (strcmp(arg[iarg],"offset") == 0) { - if (iarg+6 > narg) error->all(FLERR,"Illegal read_data command"); - offsetflag = 1; - toffset = force->inumeric(FLERR,arg[iarg+1]); - boffset = force->inumeric(FLERR,arg[iarg+2]); - aoffset = force->inumeric(FLERR,arg[iarg+3]); - doffset = force->inumeric(FLERR,arg[iarg+4]); - ioffset = force->inumeric(FLERR,arg[iarg+5]); - if (toffset < 0 || boffset < 0 || aoffset < 0 || - doffset < 0 || ioffset < 0) - error->all(FLERR,"Illegal read_data command"); - iarg += 6; - } else if (strcmp(arg[iarg],"shift") == 0) { - if (iarg+4 > narg) error->all(FLERR,"Illegal read_data command"); - shiftflag = 1; - shift[0] = force->numeric(FLERR,arg[iarg+1]); - shift[1] = force->numeric(FLERR,arg[iarg+2]); - shift[2] = force->numeric(FLERR,arg[iarg+3]); - if (domain->dimension == 2 && shift[2] != 0.0) - error->all(FLERR,"Non-zero read_data shift z value for 2d simulation"); - iarg += 4; - } else if (strcmp(arg[iarg],"nocoeff") == 0) { - coeffflag = 0; - iarg ++; - } else if (strcmp(arg[iarg],"extra/atom/types") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal read_data command"); - extra_atom_types = force->inumeric(FLERR,arg[iarg+1]); - if (extra_atom_types < 0) error->all(FLERR,"Illegal read_data command"); - iarg += 2; - } else if (strcmp(arg[iarg],"extra/bond/types") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal read_data command"); - if (!atom->avec->bonds_allow) - error->all(FLERR,"No bonds allowed with this atom style"); - extra_bond_types = force->inumeric(FLERR,arg[iarg+1]); - if (extra_bond_types < 0) error->all(FLERR,"Illegal read_data command"); - iarg += 2; - } else if (strcmp(arg[iarg],"extra/angle/types") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal read_data command"); - if (!atom->avec->angles_allow) - error->all(FLERR,"No angles allowed with this atom style"); - extra_angle_types = force->inumeric(FLERR,arg[iarg+1]); - if (extra_angle_types < 0) error->all(FLERR,"Illegal read_data command"); - iarg += 2; - } else if (strcmp(arg[iarg],"extra/dihedral/types") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal read_data command"); - if (!atom->avec->dihedrals_allow) - error->all(FLERR,"No dihedrals allowed with this atom style"); - extra_dihedral_types = force->inumeric(FLERR,arg[iarg+1]); - if (extra_dihedral_types < 0) - error->all(FLERR,"Illegal read_data command"); - iarg += 2; - } else if (strcmp(arg[iarg],"extra/improper/types") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal read_data command"); - if (!atom->avec->impropers_allow) - error->all(FLERR,"No impropers allowed with this atom style"); - extra_improper_types = force->inumeric(FLERR,arg[iarg+1]); - if (extra_improper_types < 0) - error->all(FLERR,"Illegal read_data command"); - iarg += 2; - - } else if (strcmp(arg[iarg],"group") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal read_data command"); - int igroup = group->find_or_create(arg[iarg+1]); - groupbit = group->bitmask[igroup]; - iarg += 2; - - } else if (strcmp(arg[iarg],"fix") == 0) { - if (iarg+4 > narg) - error->all(FLERR,"Illegal read_data command"); - memory->grow(fix_index,nfix+1,"read_data:fix_index"); - fix_header = (char **) - memory->srealloc(fix_header,(nfix+1)*sizeof(char *), - "read_data:fix_header"); - fix_section = (char **) - memory->srealloc(fix_section,(nfix+1)*sizeof(char *), - "read_data:fix_section"); - fix_index[nfix] = modify->find_fix(arg[iarg+1]); - if (fix_index[nfix] < 0) - error->all(FLERR,"Fix ID for read_data does not exist"); - if (strcmp(arg[iarg+2],"NULL") == 0) fix_header[nfix] = NULL; - else { - int n = strlen(arg[iarg+2]) + 1; - fix_header[nfix] = new char[n]; - strcpy(fix_header[nfix],arg[iarg+2]); - } - int n = strlen(arg[iarg+3]) + 1; - fix_section[nfix] = new char[n]; - strcpy(fix_section[nfix],arg[iarg+3]); - nfix++; - iarg += 4; - - } else error->all(FLERR,"Illegal read_data command"); - } - - // error checks - - if (domain->dimension == 2 && domain->zperiodic == 0) - error->all(FLERR,"Cannot run 2d simulation with nonperiodic Z dimension"); - if (domain->box_exist && !addflag) - error->all(FLERR,"Cannot read_data without add keyword " - "after simulation box is defined"); - if (!domain->box_exist && addflag) - error->all(FLERR,"Cannot use read_data add before " - "simulation box is defined"); - if (offsetflag && addflag == NONE) - error->all(FLERR,"Cannot use read_data offset without add flag"); - if (shiftflag && addflag == NONE) - error->all(FLERR,"Cannot use read_data shift without add flag"); - if (addflag != NONE && - (extra_atom_types || extra_bond_types || extra_angle_types || - extra_dihedral_types || extra_improper_types)) - error->all(FLERR,"Cannot use read_data extra with add flag"); - - // first time system initialization - - if (addflag == NONE) { - domain->box_exist = 1; - update->ntimestep = 0; - } - - // compute atomID offset for addflag = MERGE - - if (addflag == APPEND) { - tagint *tag = atom->tag; - int nlocal = atom->nlocal; - tagint max = 0; - for (int i = 0; i < nlocal; i++) max = MAX(max,tag[i]); - MPI_Allreduce(&max,&id_offset,1,MPI_LMP_TAGINT,MPI_MAX,world); - } - - // set up pointer to hold original styles while we replace them with "zero" - Pair *saved_pair = NULL; - Bond *saved_bond = NULL; - Angle *saved_angle = NULL; - Dihedral *saved_dihedral = NULL; - Improper *saved_improper = NULL; - KSpace *saved_kspace = NULL; - - if (coeffflag == 0) { - char *coeffs[2]; - coeffs[0] = (char *) "10.0"; - coeffs[1] = (char *) "nocoeff"; - - saved_pair = force->pair; - force->pair = NULL; - force->create_pair("zero",0); - if (force->pair) force->pair->settings(2,coeffs); - - coeffs[0] = coeffs[1]; - saved_bond = force->bond; - force->bond = NULL; - force->create_bond("zero",0); - if (force->bond) force->bond->settings(1,coeffs); - - saved_angle = force->angle; - force->angle = NULL; - force->create_angle("zero",0); - if (force->angle) force->angle->settings(1,coeffs); - - saved_dihedral = force->dihedral; - force->dihedral = NULL; - force->create_dihedral("zero",0); - if (force->dihedral) force->dihedral->settings(1,coeffs); - - saved_improper = force->improper; - force->improper = NULL; - force->create_improper("zero",0); - if (force->improper) force->improper->settings(1,coeffs); - - saved_kspace = force->kspace; - force->kspace = NULL; - } - - // ----------------------------------------------------------------- - - // perform 1-pass read if no molecular topology in file - // perform 2-pass read if molecular topology, - // first pass calculates max topology/atom - - // flags for this data file - - int atomflag,topoflag; - int bondflag,angleflag,dihedralflag,improperflag; - int ellipsoidflag,lineflag,triflag,bodyflag; - - atomflag = topoflag = 0; - bondflag = angleflag = dihedralflag = improperflag = 0; - ellipsoidflag = lineflag = triflag = bodyflag = 0; - - // values in this data file - - natoms = ntypes = 0; - nbonds = nangles = ndihedrals = nimpropers = 0; - nbondtypes = nangletypes = ndihedraltypes = nimpropertypes = 0; - triclinic = 0; - keyword[0] = '\0'; - - nlocal_previous = atom->nlocal; - int firstpass = 1; - - while (1) { - - // open file on proc 0 - - if (me == 0) { - if (firstpass && screen) fprintf(screen,"Reading data file ...\n"); - open(arg[0]); - } else fp = NULL; - - // read header info - - header(firstpass); - - // problem setup using info from header - // only done once, if firstpass and first data file - // apply extra settings before grow(), even if no topology in file - // deallocate() insures new settings are used for topology arrays - // if per-atom topology is in file, another grow() is done below - - if (firstpass && addflag == NONE) { - atom->bond_per_atom = atom->extra_bond_per_atom; - atom->angle_per_atom = atom->extra_angle_per_atom; - atom->dihedral_per_atom = atom->extra_dihedral_per_atom; - atom->improper_per_atom = atom->extra_improper_per_atom; - - int n; - if (comm->nprocs == 1) n = static_cast (atom->natoms); - else n = static_cast (LB_FACTOR * atom->natoms / comm->nprocs); - - atom->allocate_type_arrays(); - atom->deallocate_topology(); - atom->avec->grow(n); - - domain->boxlo[0] = boxlo[0]; domain->boxhi[0] = boxhi[0]; - domain->boxlo[1] = boxlo[1]; domain->boxhi[1] = boxhi[1]; - domain->boxlo[2] = boxlo[2]; domain->boxhi[2] = boxhi[2]; - - if (triclinic) { - domain->triclinic = 1; - domain->xy = xy; domain->xz = xz; domain->yz = yz; - } - - domain->print_box(" "); - domain->set_initial_box(); - domain->set_global_box(); - comm->set_proc_grid(); - domain->set_local_box(); - } - - // change simulation box to be union of existing box and new box + shift - // only done if firstpass and not first data file - - if (firstpass && addflag != NONE) { - domain->boxlo[0] = MIN(domain->boxlo[0],boxlo[0]+shift[0]); - domain->boxhi[0] = MAX(domain->boxhi[0],boxhi[0]+shift[0]); - domain->boxlo[1] = MIN(domain->boxlo[1],boxlo[1]+shift[1]); - domain->boxhi[1] = MAX(domain->boxhi[1],boxhi[1]+shift[1]); - domain->boxlo[2] = MIN(domain->boxlo[2],boxlo[2]+shift[2]); - domain->boxhi[2] = MAX(domain->boxhi[2],boxhi[2]+shift[2]); - - // NOTE: not sure what to do about tilt value in subsequent data files - //if (triclinic) { - // domain->xy = xy; domain->xz = xz; domain->yz = yz; - // } - - domain->print_box(" "); - domain->set_initial_box(); - domain->set_global_box(); - comm->set_proc_grid(); - domain->set_local_box(); - } - - // customize for new sections - // read rest of file in free format - - while (strlen(keyword)) { - - // if special fix matches, it processes section - - if (nfix) { - int i; - for (i = 0; i < nfix; i++) - if (strcmp(keyword,fix_section[i]) == 0) { - if (firstpass) fix(fix_index[i],keyword); - else skip_lines(modify->fix[fix_index[i]]-> - read_data_skip_lines(keyword)); - parse_keyword(0); - break; - } - if (i < nfix) continue; - } - - if (strcmp(keyword,"Atoms") == 0) { - atomflag = 1; - if (firstpass) { - if (me == 0 && !style_match(style,atom->atom_style)) - error->warning(FLERR,"Atom style in data file differs " - "from currently defined atom style"); - atoms(); - } else skip_lines(natoms); - } else if (strcmp(keyword,"Velocities") == 0) { - if (atomflag == 0) - error->all(FLERR,"Must read Atoms before Velocities"); - if (firstpass) velocities(); - else skip_lines(natoms); - - } else if (strcmp(keyword,"Bonds") == 0) { - topoflag = bondflag = 1; - if (nbonds == 0) - error->all(FLERR,"Invalid data file section: Bonds"); - if (atomflag == 0) error->all(FLERR,"Must read Atoms before Bonds"); - bonds(firstpass); - } else if (strcmp(keyword,"Angles") == 0) { - topoflag = angleflag = 1; - if (nangles == 0) - error->all(FLERR,"Invalid data file section: Angles"); - if (atomflag == 0) error->all(FLERR,"Must read Atoms before Angles"); - angles(firstpass); - } else if (strcmp(keyword,"Dihedrals") == 0) { - topoflag = dihedralflag = 1; - if (ndihedrals == 0) - error->all(FLERR,"Invalid data file section: Dihedrals"); - if (atomflag == 0) error->all(FLERR,"Must read Atoms before Dihedrals"); - dihedrals(firstpass); - } else if (strcmp(keyword,"Impropers") == 0) { - topoflag = improperflag = 1; - if (nimpropers == 0) - error->all(FLERR,"Invalid data file section: Impropers"); - if (atomflag == 0) error->all(FLERR,"Must read Atoms before Impropers"); - impropers(firstpass); - - } else if (strcmp(keyword,"Ellipsoids") == 0) { - ellipsoidflag = 1; - if (!avec_ellipsoid) - error->all(FLERR,"Invalid data file section: Ellipsoids"); - if (atomflag == 0) - error->all(FLERR,"Must read Atoms before Ellipsoids"); - if (firstpass) - bonus(nellipsoids,(AtomVec *) avec_ellipsoid,"ellipsoids"); - else skip_lines(nellipsoids); - } else if (strcmp(keyword,"Lines") == 0) { - lineflag = 1; - if (!avec_line) - error->all(FLERR,"Invalid data file section: Lines"); - if (atomflag == 0) error->all(FLERR,"Must read Atoms before Lines"); - if (firstpass) bonus(nlines,(AtomVec *) avec_line,"lines"); - else skip_lines(nlines); - } else if (strcmp(keyword,"Triangles") == 0) { - triflag = 1; - if (!avec_tri) - error->all(FLERR,"Invalid data file section: Triangles"); - if (atomflag == 0) error->all(FLERR,"Must read Atoms before Triangles"); - if (firstpass) bonus(ntris,(AtomVec *) avec_tri,"triangles"); - else skip_lines(ntris); - } else if (strcmp(keyword,"Bodies") == 0) { - bodyflag = 1; - if (!avec_body) - error->all(FLERR,"Invalid data file section: Bodies"); - if (atomflag == 0) error->all(FLERR,"Must read Atoms before Bodies"); - bodies(firstpass); - - } else if (strcmp(keyword,"Masses") == 0) { - if (firstpass) mass(); - else skip_lines(ntypes); - } else if (strcmp(keyword,"Pair Coeffs") == 0) { - if (force->pair == NULL) - error->all(FLERR,"Must define pair_style before Pair Coeffs"); - if (firstpass) { - if (me == 0 && !style_match(style,force->pair_style)) - error->warning(FLERR,"Pair style in data file differs " - "from currently defined pair style"); - paircoeffs(); - } else skip_lines(ntypes); - } else if (strcmp(keyword,"PairIJ Coeffs") == 0) { - if (force->pair == NULL) - error->all(FLERR,"Must define pair_style before PairIJ Coeffs"); - if (firstpass) { - if (me == 0 && !style_match(style,force->pair_style)) - error->warning(FLERR,"Pair style in data file differs " - "from currently defined pair style"); - pairIJcoeffs(); - } else skip_lines(ntypes*(ntypes+1)/2); - } else if (strcmp(keyword,"Bond Coeffs") == 0) { - if (atom->avec->bonds_allow == 0) - error->all(FLERR,"Invalid data file section: Bond Coeffs"); - if (force->bond == NULL) - error->all(FLERR,"Must define bond_style before Bond Coeffs"); - if (firstpass) { - if (me == 0 && !style_match(style,force->bond_style)) - error->warning(FLERR,"Bond style in data file differs " - "from currently defined bond style"); - bondcoeffs(); - } else skip_lines(nbondtypes); - } else if (strcmp(keyword,"Angle Coeffs") == 0) { - if (atom->avec->angles_allow == 0) - error->all(FLERR,"Invalid data file section: Angle Coeffs"); - if (force->angle == NULL) - error->all(FLERR,"Must define angle_style before Angle Coeffs"); - if (firstpass) { - if (me == 0 && !style_match(style,force->angle_style)) - error->warning(FLERR,"Angle style in data file differs " - "from currently defined angle style"); - anglecoeffs(0); - } else skip_lines(nangletypes); - } else if (strcmp(keyword,"Dihedral Coeffs") == 0) { - if (atom->avec->dihedrals_allow == 0) - error->all(FLERR,"Invalid data file section: Dihedral Coeffs"); - if (force->dihedral == NULL) - error->all(FLERR,"Must define dihedral_style before Dihedral Coeffs"); - if (firstpass) { - if (me == 0 && !style_match(style,force->dihedral_style)) - error->warning(FLERR,"Dihedral style in data file differs " - "from currently defined dihedral style"); - dihedralcoeffs(0); - } else skip_lines(ndihedraltypes); - } else if (strcmp(keyword,"Improper Coeffs") == 0) { - if (atom->avec->impropers_allow == 0) - error->all(FLERR,"Invalid data file section: Improper Coeffs"); - if (force->improper == NULL) - error->all(FLERR,"Must define improper_style before Improper Coeffs"); - if (firstpass) { - if (me == 0 && !style_match(style,force->improper_style)) - error->warning(FLERR,"Improper style in data file differs " - "from currently defined improper style"); - impropercoeffs(0); - } else skip_lines(nimpropertypes); - - } else if (strcmp(keyword,"BondBond Coeffs") == 0) { - if (atom->avec->angles_allow == 0) - error->all(FLERR,"Invalid data file section: BondBond Coeffs"); - if (force->angle == NULL) - error->all(FLERR,"Must define angle_style before BondBond Coeffs"); - if (firstpass) anglecoeffs(1); - else skip_lines(nangletypes); - } else if (strcmp(keyword,"BondAngle Coeffs") == 0) { - if (atom->avec->angles_allow == 0) - error->all(FLERR,"Invalid data file section: BondAngle Coeffs"); - if (force->angle == NULL) - error->all(FLERR,"Must define angle_style before BondAngle Coeffs"); - if (firstpass) anglecoeffs(2); - else skip_lines(nangletypes); - - } else if (strcmp(keyword,"MiddleBondTorsion Coeffs") == 0) { - if (atom->avec->dihedrals_allow == 0) - error->all(FLERR, - "Invalid data file section: MiddleBondTorsion Coeffs"); - if (force->dihedral == NULL) - error->all(FLERR, - "Must define dihedral_style before " - "MiddleBondTorsion Coeffs"); - if (firstpass) dihedralcoeffs(1); - else skip_lines(ndihedraltypes); - } else if (strcmp(keyword,"EndBondTorsion Coeffs") == 0) { - if (atom->avec->dihedrals_allow == 0) - error->all(FLERR,"Invalid data file section: EndBondTorsion Coeffs"); - if (force->dihedral == NULL) - error->all(FLERR, - "Must define dihedral_style before EndBondTorsion Coeffs"); - if (firstpass) dihedralcoeffs(2); - else skip_lines(ndihedraltypes); - } else if (strcmp(keyword,"AngleTorsion Coeffs") == 0) { - if (atom->avec->dihedrals_allow == 0) - error->all(FLERR,"Invalid data file section: AngleTorsion Coeffs"); - if (force->dihedral == NULL) - error->all(FLERR, - "Must define dihedral_style before AngleTorsion Coeffs"); - if (firstpass) dihedralcoeffs(3); - else skip_lines(ndihedraltypes); - } else if (strcmp(keyword,"AngleAngleTorsion Coeffs") == 0) { - if (atom->avec->dihedrals_allow == 0) - error->all(FLERR, - "Invalid data file section: AngleAngleTorsion Coeffs"); - if (force->dihedral == NULL) - error->all(FLERR, - "Must define dihedral_style before " - "AngleAngleTorsion Coeffs"); - if (firstpass) dihedralcoeffs(4); - else skip_lines(ndihedraltypes); - } else if (strcmp(keyword,"BondBond13 Coeffs") == 0) { - if (atom->avec->dihedrals_allow == 0) - error->all(FLERR,"Invalid data file section: BondBond13 Coeffs"); - if (force->dihedral == NULL) - error->all(FLERR, - "Must define dihedral_style before BondBond13 Coeffs"); - if (firstpass) dihedralcoeffs(5); - else skip_lines(ndihedraltypes); - - } else if (strcmp(keyword,"AngleAngle Coeffs") == 0) { - if (atom->avec->impropers_allow == 0) - error->all(FLERR,"Invalid data file section: AngleAngle Coeffs"); - if (force->improper == NULL) - error->all(FLERR, - "Must define improper_style before AngleAngle Coeffs"); - if (firstpass) impropercoeffs(1); - else skip_lines(nimpropertypes); - - } else { - char str[128]; - sprintf(str,"Unknown identifier in data file: %s",keyword); - error->all(FLERR,str); - } - - parse_keyword(0); - } - - // error if natoms > 0 yet no atoms were read - - if (natoms > 0 && atomflag == 0) - error->all(FLERR,"No atoms in data file"); - - // close file - - if (me == 0) { - if (compressed) pclose(fp); - else fclose(fp); - fp = NULL; - } - - // done if this was 2nd pass - - if (!firstpass) break; - - // at end of 1st pass, error check for required sections - // customize for new sections - - if ((nbonds && !bondflag) || (nangles && !angleflag) || - (ndihedrals && !dihedralflag) || (nimpropers && !improperflag)) - error->one(FLERR,"Needed molecular topology not in data file"); - - if ((nellipsoids && !ellipsoidflag) || (nlines && !lineflag) || - (ntris && !triflag) || (nbodies && !bodyflag)) - error->one(FLERR,"Needed bonus data not in data file"); - - // break out of loop if no molecular topology in file - // else make 2nd pass - - if (!topoflag) break; - firstpass = 0; - - // reallocate bond,angle,diehdral,improper arrays via grow() - // will use new bond,angle,dihedral,improper per-atom values from 1st pass - // will also observe extra settings even if bond/etc topology not in file - // leaves other atom arrays unchanged, since already nmax in length - - if (addflag == NONE) atom->deallocate_topology(); - atom->avec->grow(atom->nmax); - } - - // assign atoms added by this data file to specified group - - if (groupbit) { - int *mask = atom->mask; - int nlocal = atom->nlocal; - for (int i = nlocal_previous; i < nlocal; i++) - mask[i] |= groupbit; - } - - // create special bond lists for molecular systems - - if (atom->molecular == 1) { - Special special(lmp); - special.build(); - } - - // for atom style template systems, count total bonds,angles,etc - - if (atom->molecular == 2) { - Molecule **onemols = atom->avec->onemols; - int *molindex = atom->molindex; - int *molatom = atom->molatom; - int nlocal = atom->nlocal; - - int imol,iatom; - bigint nbonds,nangles,ndihedrals,nimpropers; - nbonds = nangles = ndihedrals = nimpropers = 0; - - for (int i = 0; i < nlocal; i++) { - imol = molindex[i]; - iatom = molatom[i]; - nbonds += onemols[imol]->num_bond[iatom]; - nangles += onemols[imol]->num_angle[iatom]; - ndihedrals += onemols[imol]->num_dihedral[iatom]; - nimpropers += onemols[imol]->num_improper[iatom]; - } - - MPI_Allreduce(&nbonds,&atom->nbonds,1,MPI_LMP_BIGINT,MPI_SUM,world); - MPI_Allreduce(&nangles,&atom->nangles,1,MPI_LMP_BIGINT,MPI_SUM,world); - MPI_Allreduce(&ndihedrals,&atom->ndihedrals,1,MPI_LMP_BIGINT,MPI_SUM,world); - MPI_Allreduce(&nimpropers,&atom->nimpropers,1,MPI_LMP_BIGINT,MPI_SUM,world); - - if (!force->newton_bond) { - atom->nbonds /= 2; - atom->nangles /= 3; - atom->ndihedrals /= 4; - atom->nimpropers /= 4; - } - - if (me == 0) { - if (atom->nbonds) { - if (screen) - fprintf(screen," " BIGINT_FORMAT " template bonds\n",atom->nbonds); - if (logfile) - fprintf(logfile," " BIGINT_FORMAT " template bonds\n",atom->nbonds); - } - if (atom->nangles) { - if (screen) - fprintf(screen," " BIGINT_FORMAT " template angles\n", - atom->nangles); - if (logfile) - fprintf(logfile," " BIGINT_FORMAT " template angles\n", - atom->nangles); - } - if (atom->ndihedrals) { - if (screen) - fprintf(screen," " BIGINT_FORMAT " template dihedrals\n", - atom->nbonds); - if (logfile) - fprintf(logfile," " BIGINT_FORMAT " template bonds\n", - atom->ndihedrals); - } - if (atom->nimpropers) { - if (screen) - fprintf(screen," " BIGINT_FORMAT " template impropers\n", - atom->nimpropers); - if (logfile) - fprintf(logfile," " BIGINT_FORMAT " template impropers\n", - atom->nimpropers); - } - } - } - - // for atom style template systems - // insure nbondtypes,etc are still consistent with template molecules, - // in case data file re-defined them - - if (atom->molecular == 2) atom->avec->onemols[0]->check_attributes(1); - - // if adding atoms, migrate atoms to new processors - // use irregular() b/c box size could have changed dramaticaly - // resulting in procs now owning very different subboxes - // with their previously owned atoms now far outside the subbox - - if (addflag != NONE) { - if (domain->triclinic) domain->x2lamda(atom->nlocal); - Irregular *irregular = new Irregular(lmp); - irregular->migrate_atoms(1); - delete irregular; - if (domain->triclinic) domain->lamda2x(atom->nlocal); - } - - // shrink-wrap the box if necessary and move atoms to new procs - // if atoms are lost is b/c data file box was far from shrink-wrapped - // do not use irregular() comm, which would not lose atoms, - // b/c then user could specify data file box as far too big and empty - // do comm->init() but not comm->setup() b/c pair/neigh cutoffs not yet set - // need call to map_set() b/c comm->exchange clears atom map - - if (domain->nonperiodic == 2) { - if (domain->triclinic) domain->x2lamda(atom->nlocal); - domain->reset_box(); - comm->init(); - comm->exchange(); - if (atom->map_style) atom->map_set(); - if (domain->triclinic) domain->lamda2x(atom->nlocal); - - bigint natoms; - bigint nblocal = atom->nlocal; - MPI_Allreduce(&nblocal,&natoms,1,MPI_LMP_BIGINT,MPI_SUM,world); - if (natoms != atom->natoms) - error->all(FLERR, - "Read_data shrink wrap did not assign all atoms correctly"); - } - - // restore old styles, when reading with nocoeff flag given - if (coeffflag == 0) { - if (force->pair) delete force->pair; - force->pair = saved_pair; - - if (force->bond) delete force->bond; - force->bond = saved_bond; - - if (force->angle) delete force->angle; - force->angle = saved_angle; - - if (force->dihedral) delete force->dihedral; - force->dihedral = saved_dihedral; - - if (force->improper) delete force->improper; - force->improper = saved_improper; - - force->kspace = saved_kspace; - } -} - -/* ---------------------------------------------------------------------- - read free-format header of data file - 1st line and blank lines are skipped - non-blank lines are checked for header keywords and leading value is read - header ends with EOF or non-blank line containing no header keyword - if EOF, line is set to blank line - else line has first keyword line for rest of file - some logic differs if adding atoms -------------------------------------------------------------------------- */ - -void ReadData::header(int firstpass) -{ - int n; - char *ptr; - - // customize for new sections - - const char *section_keywords[NSECTIONS] = - {"Atoms","Velocities","Ellipsoids","Lines","Triangles","Bodies", - "Bonds","Angles","Dihedrals","Impropers", - "Masses","Pair Coeffs","PairIJ Coeffs","Bond Coeffs","Angle Coeffs", - "Dihedral Coeffs","Improper Coeffs", - "BondBond Coeffs","BondAngle Coeffs","MiddleBondTorsion Coeffs", - "EndBondTorsion Coeffs","AngleTorsion Coeffs", - "AngleAngleTorsion Coeffs","BondBond13 Coeffs","AngleAngle Coeffs"}; - - // skip 1st line of file - - if (me == 0) { - char *eof = fgets(line,MAXLINE,fp); - if (eof == NULL) error->one(FLERR,"Unexpected end of data file"); - } - - while (1) { - - // read a line and bcast length - - if (me == 0) { - if (fgets(line,MAXLINE,fp) == NULL) n = 0; - else n = strlen(line) + 1; - } - MPI_Bcast(&n,1,MPI_INT,0,world); - - // if n = 0 then end-of-file so return with blank line - - if (n == 0) { - line[0] = '\0'; - return; - } - - MPI_Bcast(line,n,MPI_CHAR,0,world); - - // trim anything from '#' onward - // if line is blank, continue - - if ((ptr = strchr(line,'#'))) *ptr = '\0'; - if (strspn(line," \t\n\r") == strlen(line)) continue; - - // allow special fixes first chance to match and process the line - // if fix matches, continue to next header line - - if (nfix) { - for (n = 0; n < nfix; n++) { - if (!fix_header[n]) continue; - if (strstr(line,fix_header[n])) { - modify->fix[fix_index[n]]->read_data_header(line); - break; - } - } - if (n < nfix) continue; - } - - // search line for header keyword and set corresponding variable - // customize for new header lines - - if (strstr(line,"atoms")) { - sscanf(line,BIGINT_FORMAT,&natoms); - if (addflag == NONE) atom->natoms = natoms; - else if (firstpass) atom->natoms += natoms; - - // check for these first - // otherwise "triangles" will be matched as "angles" - - } else if (strstr(line,"ellipsoids")) { - if (!avec_ellipsoid) - error->all(FLERR,"No ellipsoids allowed with this atom style"); - sscanf(line,BIGINT_FORMAT,&nellipsoids); - } else if (strstr(line,"lines")) { - if (!avec_line) - error->all(FLERR,"No lines allowed with this atom style"); - sscanf(line,BIGINT_FORMAT,&nlines); - } else if (strstr(line,"triangles")) { - if (!avec_tri) - error->all(FLERR,"No triangles allowed with this atom style"); - sscanf(line,BIGINT_FORMAT,&ntris); - } else if (strstr(line,"bodies")) { - if (!avec_body) - error->all(FLERR,"No bodies allowed with this atom style"); - sscanf(line,BIGINT_FORMAT,&nbodies); - - } else if (strstr(line,"bonds")) { - sscanf(line,BIGINT_FORMAT,&nbonds); - if (addflag == NONE) atom->nbonds = nbonds; - else if (firstpass) atom->nbonds += nbonds; - } else if (strstr(line,"angles")) { - sscanf(line,BIGINT_FORMAT,&nangles); - if (addflag == NONE) atom->nangles = nangles; - else if (firstpass) atom->nangles += nangles; - } else if (strstr(line,"dihedrals")) { - sscanf(line,BIGINT_FORMAT,&ndihedrals); - if (addflag == NONE) atom->ndihedrals = ndihedrals; - else if (firstpass) atom->ndihedrals += ndihedrals; - } else if (strstr(line,"impropers")) { - sscanf(line,BIGINT_FORMAT,&nimpropers); - if (addflag == NONE) atom->nimpropers = nimpropers; - else if (firstpass) atom->nimpropers += nimpropers; - - // Atom class type settings are only set by first data file - - } else if (strstr(line,"atom types")) { - sscanf(line,"%d",&ntypes); - if (addflag == NONE) atom->ntypes = ntypes + extra_atom_types; - } else if (strstr(line,"mol_H types")){ - sscanf(line,"%d",&atom->nmoltypesH); - } - else if (strstr(line,"bond types")) { - sscanf(line,"%d",&nbondtypes); - if (addflag == NONE) atom->nbondtypes = nbondtypes + extra_bond_types; - } else if (strstr(line,"angle types")) { - sscanf(line,"%d",&nangletypes); - if (addflag == NONE) atom->nangletypes = nangletypes + extra_angle_types; - } else if (strstr(line,"dihedral types")) { - sscanf(line,"%d",&ndihedraltypes); - if (addflag == NONE) - atom->ndihedraltypes = ndihedraltypes + extra_dihedral_types; - } else if (strstr(line,"improper types")) { - sscanf(line,"%d",&nimpropertypes); - if (addflag == NONE) - atom->nimpropertypes = nimpropertypes + extra_improper_types; - - // these settings only used by first data file - - } else if (strstr(line,"extra bond per atom")) { - if (addflag == NONE) sscanf(line,"%d",&atom->extra_bond_per_atom); - } else if (strstr(line,"extra angle per atom")) { - if (addflag == NONE) sscanf(line,"%d",&atom->extra_angle_per_atom); - } else if (strstr(line,"extra dihedral per atom")) { - if (addflag == NONE) sscanf(line,"%d",&atom->extra_dihedral_per_atom); - } else if (strstr(line,"extra improper per atom")) { - if (addflag == NONE) sscanf(line,"%d",&atom->extra_improper_per_atom); - } else if (strstr(line,"extra special per atom")) { - if (addflag == NONE) sscanf(line,"%d",&force->special_extra); - - // local copy of box info - // so can treat differently for first vs subsequent data files - - } else if (strstr(line,"xlo xhi")) { - sscanf(line,"%lg %lg",&boxlo[0],&boxhi[0]); - } else if (strstr(line,"ylo yhi")) { - sscanf(line,"%lg %lg",&boxlo[1],&boxhi[1]); - } else if (strstr(line,"zlo zhi")) { - sscanf(line,"%lg %lg",&boxlo[2],&boxhi[2]); - } else if (strstr(line,"xy xz yz")) { - triclinic = 1; - sscanf(line,"%lg %lg %lg",&xy,&xz,&yz); - - } else break; - } - - // error check on total system size - - if (atom->natoms < 0 || atom->natoms >= MAXBIGINT || - atom->nbonds < 0 || atom->nbonds >= MAXBIGINT || - atom->nangles < 0 || atom->nangles >= MAXBIGINT || - atom->ndihedrals < 0 || atom->ndihedrals >= MAXBIGINT || - atom->nimpropers < 0 || atom->nimpropers >= MAXBIGINT) - error->all(FLERR,"System in data file is too big"); - - // check that exiting string is a valid section keyword - - parse_keyword(1); - for (n = 0; n < NSECTIONS; n++) - if (strcmp(keyword,section_keywords[n]) == 0) break; - if (n == NSECTIONS) { - char str[128]; - sprintf(str,"Unknown identifier in data file: %s",keyword); - error->all(FLERR,str); - } - - // error checks on header values - // must be consistent with atom style and other header values - - if ((atom->nbonds || atom->nbondtypes) && - atom->avec->bonds_allow == 0) - error->all(FLERR,"No bonds allowed with this atom style"); - if ((atom->nangles || atom->nangletypes) && - atom->avec->angles_allow == 0) - error->all(FLERR,"No angles allowed with this atom style"); - if ((atom->ndihedrals || atom->ndihedraltypes) && - atom->avec->dihedrals_allow == 0) - error->all(FLERR,"No dihedrals allowed with this atom style"); - if ((atom->nimpropers || atom->nimpropertypes) && - atom->avec->impropers_allow == 0) - error->all(FLERR,"No impropers allowed with this atom style"); - - if (atom->nbonds > 0 && atom->nbondtypes <= 0) - error->all(FLERR,"Bonds defined but no bond types"); - if (atom->nangles > 0 && atom->nangletypes <= 0) - error->all(FLERR,"Angles defined but no angle types"); - if (atom->ndihedrals > 0 && atom->ndihedraltypes <= 0) - error->all(FLERR,"Dihedrals defined but no dihedral types"); - if (atom->nimpropers > 0 && atom->nimpropertypes <= 0) - error->all(FLERR,"Impropers defined but no improper types"); - - if (atom->molecular == 2) { - if (atom->nbonds || atom->nangles || atom->ndihedrals || atom->nimpropers) - error->all(FLERR,"No molecule topology allowed with atom style template"); - } -} - -/* ---------------------------------------------------------------------- - read all atoms -------------------------------------------------------------------------- */ - -void ReadData::atoms() -{ - int nchunk,eof; - - if (me == 0) { - if (screen) fprintf(screen," reading atoms ...\n"); - if (logfile) fprintf(logfile," reading atoms ...\n"); - } - - bigint nread = 0; - - while (nread < natoms) { - nchunk = MIN(natoms-nread,CHUNK); - eof = comm->read_lines_from_file(fp,nchunk,MAXLINE,buffer); - if (eof) error->all(FLERR,"Unexpected end of data file"); - atom->data_atoms(nchunk,buffer,id_offset,toffset,shiftflag,shift); - nread += nchunk; - } - - // check that all atoms were assigned correctly - - bigint n = atom->nlocal; - bigint sum; - MPI_Allreduce(&n,&sum,1,MPI_LMP_BIGINT,MPI_SUM,world); - bigint nassign = sum - (atom->natoms - natoms); - - if (me == 0) { - if (screen) fprintf(screen," " BIGINT_FORMAT " atoms\n",nassign); - if (logfile) fprintf(logfile," " BIGINT_FORMAT " atoms\n",nassign); - } - - if (sum != atom->natoms) - error->all(FLERR,"Did not assign all atoms correctly"); - - // check that atom IDs are valid - - atom->tag_check(); - - // create global mapping of atoms - - if (atom->map_style) { - atom->map_init(); - atom->map_set(); - } -} - -/* ---------------------------------------------------------------------- - read all velocities - to find atoms, must build atom map if not a molecular system -------------------------------------------------------------------------- */ - -void ReadData::velocities() -{ - int nchunk,eof; - - if (me == 0) { - if (screen) fprintf(screen," reading velocities ...\n"); - if (logfile) fprintf(logfile," reading velocities ...\n"); - } - - int mapflag = 0; - if (atom->map_style == 0) { - mapflag = 1; - atom->map_init(); - atom->map_set(); - } - - bigint nread = 0; - - while (nread < natoms) { - nchunk = MIN(natoms-nread,CHUNK); - eof = comm->read_lines_from_file(fp,nchunk,MAXLINE,buffer); - if (eof) error->all(FLERR,"Unexpected end of data file"); - atom->data_vels(nchunk,buffer,id_offset); - nread += nchunk; - } - - if (mapflag) { - atom->map_delete(); - atom->map_style = 0; - } - - if (me == 0) { - if (screen) fprintf(screen," " BIGINT_FORMAT " velocities\n",natoms); - if (logfile) fprintf(logfile," " BIGINT_FORMAT " velocities\n",natoms); - } -} - -/* ---------------------------------------------------------------------- - scan or read all bonds -------------------------------------------------------------------------- */ - -void ReadData::bonds(int firstpass) -{ - int nchunk,eof; - - if (me == 0) { - if (firstpass) { - if (screen) fprintf(screen," scanning bonds ...\n"); - if (logfile) fprintf(logfile," scanning bonds ...\n"); - } else { - if (screen) fprintf(screen," reading bonds ...\n"); - if (logfile) fprintf(logfile," reading bonds ...\n"); - } - } - - // allocate count if firstpass - - int nlocal = atom->nlocal; - int *count = NULL; - if (firstpass) { - memory->create(count,nlocal,"read_data:count"); - for (int i = 0; i < nlocal; i++) count[i] = 0; - } - - // read and process bonds - - bigint nread = 0; - - while (nread < nbonds) { - nchunk = MIN(nbonds-nread,CHUNK); - eof = comm->read_lines_from_file(fp,nchunk,MAXLINE,buffer); - if (eof) error->all(FLERR,"Unexpected end of data file"); - atom->data_bonds(nchunk,buffer,count,id_offset,boffset); - nread += nchunk; - } - - // if firstpass: tally max bond/atom and return - // if addflag = NONE, store max bond/atom with extra - // else just check actual max does not exceed existing max - - if (firstpass) { - int max = 0; - for (int i = nlocal_previous; i < nlocal; i++) max = MAX(max,count[i]); - int maxall; - MPI_Allreduce(&max,&maxall,1,MPI_INT,MPI_MAX,world); - if (addflag == NONE) maxall += atom->extra_bond_per_atom; - - if (me == 0) { - if (screen) fprintf(screen," %d = max bonds/atom\n",maxall); - if (logfile) fprintf(logfile," %d = max bonds/atom\n",maxall); - } - - if (addflag != NONE) { - if (maxall > atom->bond_per_atom) - error->all(FLERR,"Subsequent read data induced " - "too many bonds per atom"); - } else atom->bond_per_atom = maxall; - - memory->destroy(count); - return; - } - - // if 2nd pass: check that bonds were assigned correctly - - bigint n = 0; - for (int i = nlocal_previous; i < nlocal; i++) n += atom->num_bond[i]; - bigint sum; - MPI_Allreduce(&n,&sum,1,MPI_LMP_BIGINT,MPI_SUM,world); - int factor = 1; - if (!force->newton_bond) factor = 2; - - if (me == 0) { - if (screen) fprintf(screen," " BIGINT_FORMAT " bonds\n",sum/factor); - if (logfile) fprintf(logfile," " BIGINT_FORMAT " bonds\n",sum/factor); - } - - if (sum != factor*nbonds) - error->all(FLERR,"Bonds assigned incorrectly"); -} - -/* ---------------------------------------------------------------------- - scan or read all angles -------------------------------------------------------------------------- */ - -void ReadData::angles(int firstpass) -{ - int nchunk,eof; - - if (me == 0) { - if (firstpass) { - if (screen) fprintf(screen," scanning angles ...\n"); - if (logfile) fprintf(logfile," scanning angles ...\n"); - } else { - if (screen) fprintf(screen," reading angles ...\n"); - if (logfile) fprintf(logfile," reading angles ...\n"); - } - } - - // allocate count if firstpass - - int nlocal = atom->nlocal; - int *count = NULL; - if (firstpass) { - memory->create(count,nlocal,"read_data:count"); - for (int i = 0; i < nlocal; i++) count[i] = 0; - } - - // read and process angles - - bigint nread = 0; - - while (nread < nangles) { - nchunk = MIN(nangles-nread,CHUNK); - eof = comm->read_lines_from_file(fp,nchunk,MAXLINE,buffer); - if (eof) error->all(FLERR,"Unexpected end of data file"); - atom->data_angles(nchunk,buffer,count,id_offset,aoffset); - nread += nchunk; - } - - // if firstpass: tally max angle/atom and return - // if addflag = NONE, store max angle/atom with extra - // else just check actual max does not exceed existing max - - if (firstpass) { - int max = 0; - for (int i = nlocal_previous; i < nlocal; i++) max = MAX(max,count[i]); - int maxall; - MPI_Allreduce(&max,&maxall,1,MPI_INT,MPI_MAX,world); - if (addflag == NONE) maxall += atom->extra_angle_per_atom; - - if (me == 0) { - if (screen) fprintf(screen," %d = max angles/atom\n",maxall); - if (logfile) fprintf(logfile," %d = max angles/atom\n",maxall); - } - - if (addflag != NONE) { - if (maxall > atom->angle_per_atom) - error->all(FLERR,"Subsequent read data induced " - "too many angles per atom"); - } else atom->angle_per_atom = maxall; - - memory->destroy(count); - return; - } - - // if 2nd pass: check that angles were assigned correctly - - bigint n = 0; - for (int i = nlocal_previous; i < nlocal; i++) n += atom->num_angle[i]; - bigint sum; - MPI_Allreduce(&n,&sum,1,MPI_LMP_BIGINT,MPI_SUM,world); - int factor = 1; - if (!force->newton_bond) factor = 3; - - if (me == 0) { - if (screen) fprintf(screen," " BIGINT_FORMAT " angles\n",sum/factor); - if (logfile) fprintf(logfile," " BIGINT_FORMAT " angles\n",sum/factor); - } - - if (sum != factor*nangles) - error->all(FLERR,"Angles assigned incorrectly"); -} - -/* ---------------------------------------------------------------------- - scan or read all dihedrals -------------------------------------------------------------------------- */ - -void ReadData::dihedrals(int firstpass) -{ - int nchunk,eof; - - if (me == 0) { - if (firstpass) { - if (screen) fprintf(screen," scanning dihedrals ...\n"); - if (logfile) fprintf(logfile," scanning dihedrals ...\n"); - } else { - if (screen) fprintf(screen," reading dihedrals ...\n"); - if (logfile) fprintf(logfile," reading dihedrals ...\n"); - } - } - - // allocate count if firstpass - - int nlocal = atom->nlocal; - int *count = NULL; - if (firstpass) { - memory->create(count,nlocal,"read_data:count"); - for (int i = 0; i < nlocal; i++) count[i] = 0; - } - - // read and process dihedrals - - bigint nread = 0; - - while (nread < ndihedrals) { - nchunk = MIN(ndihedrals-nread,CHUNK); - eof = comm->read_lines_from_file(fp,nchunk,MAXLINE,buffer); - if (eof) error->all(FLERR,"Unexpected end of data file"); - atom->data_dihedrals(nchunk,buffer,count,id_offset,doffset); - nread += nchunk; - } - - // if firstpass: tally max dihedral/atom and return - // if addflag = NONE, store max dihedral/atom with extra - // else just check actual max does not exceed existing max - - if (firstpass) { - int max = 0; - for (int i = 0; i < nlocal; i++) max = MAX(max,count[i]); - int maxall; - MPI_Allreduce(&max,&maxall,1,MPI_INT,MPI_MAX,world); - if (addflag == NONE) maxall += atom->extra_dihedral_per_atom; - - if (me == 0) { - if (screen) fprintf(screen," %d = max dihedrals/atom\n",maxall); - if (logfile) fprintf(logfile," %d = max dihedrals/atom\n",maxall); - } - - if (addflag != NONE) { - if (maxall > atom->dihedral_per_atom) - error->all(FLERR,"Subsequent read data induced " - "too many dihedrals per atom"); - } else atom->dihedral_per_atom = maxall; - - memory->destroy(count); - return; - } - - // if 2nd pass: check that dihedrals were assigned correctly - - bigint n = 0; - for (int i = nlocal_previous; i < nlocal; i++) n += atom->num_dihedral[i]; - bigint sum; - MPI_Allreduce(&n,&sum,1,MPI_LMP_BIGINT,MPI_SUM,world); - int factor = 1; - if (!force->newton_bond) factor = 4; - - if (me == 0) { - if (screen) fprintf(screen," " BIGINT_FORMAT " dihedrals\n",sum/factor); - if (logfile) fprintf(logfile," " BIGINT_FORMAT " dihedrals\n",sum/factor); - } - - if (sum != factor*ndihedrals) - error->all(FLERR,"Dihedrals assigned incorrectly"); -} - -/* ---------------------------------------------------------------------- - scan or read all impropers -------------------------------------------------------------------------- */ - -void ReadData::impropers(int firstpass) -{ - int nchunk,eof; - - if (me == 0) { - if (firstpass) { - if (screen) fprintf(screen," scanning impropers ...\n"); - if (logfile) fprintf(logfile," scanning impropers ...\n"); - } else { - if (screen) fprintf(screen," reading impropers ...\n"); - if (logfile) fprintf(logfile," reading impropers ...\n"); - } - } - - // allocate count if firstpass - - int nlocal = atom->nlocal; - int *count = NULL; - if (firstpass) { - memory->create(count,nlocal,"read_data:count"); - for (int i = 0; i < nlocal; i++) count[i] = 0; - } - - // read and process impropers - - bigint nread = 0; - - while (nread < nimpropers) { - nchunk = MIN(nimpropers-nread,CHUNK); - eof = comm->read_lines_from_file(fp,nchunk,MAXLINE,buffer); - if (eof) error->all(FLERR,"Unexpected end of data file"); - atom->data_impropers(nchunk,buffer,count,id_offset,ioffset); - nread += nchunk; - } - - // if firstpass: tally max improper/atom and return - // if addflag = NONE, store max improper/atom - // else just check it does not exceed existing max - - if (firstpass) { - int max = 0; - for (int i = nlocal_previous; i < nlocal; i++) max = MAX(max,count[i]); - int maxall; - MPI_Allreduce(&max,&maxall,1,MPI_INT,MPI_MAX,world); - if (addflag == NONE) maxall += atom->extra_improper_per_atom; - - if (me == 0) { - if (screen) fprintf(screen," %d = max impropers/atom\n",maxall); - if (logfile) fprintf(logfile," %d = max impropers/atom\n",maxall); - } - - if (addflag != NONE) { - if (maxall > atom->improper_per_atom) - error->all(FLERR,"Subsequent read data induced " - "too many impropers per atom"); - } else atom->improper_per_atom = maxall; - - memory->destroy(count); - return; - } - - // if 2nd pass: check that impropers were assigned correctly - - bigint n = 0; - for (int i = nlocal_previous; i < nlocal; i++) n += atom->num_improper[i]; - bigint sum; - MPI_Allreduce(&n,&sum,1,MPI_LMP_BIGINT,MPI_SUM,world); - int factor = 1; - if (!force->newton_bond) factor = 4; - - if (me == 0) { - if (screen) fprintf(screen," " BIGINT_FORMAT " impropers\n",sum/factor); - if (logfile) fprintf(logfile," " BIGINT_FORMAT " impropers\n",sum/factor); - } - - if (sum != factor*nimpropers) - error->all(FLERR,"Impropers assigned incorrectly"); -} - -/* ---------------------------------------------------------------------- - read all bonus data - to find atoms, must build atom map if not a molecular system -------------------------------------------------------------------------- */ - -void ReadData::bonus(bigint nbonus, AtomVec *ptr, const char *type) -{ - int nchunk,eof; - - int mapflag = 0; - if (atom->map_style == 0) { - mapflag = 1; - atom->map_init(); - atom->map_set(); - } - - bigint nread = 0; - bigint natoms = nbonus; - - while (nread < natoms) { - nchunk = MIN(natoms-nread,CHUNK); - eof = comm->read_lines_from_file(fp,nchunk,MAXLINE,buffer); - if (eof) error->all(FLERR,"Unexpected end of data file"); - atom->data_bonus(nchunk,buffer,ptr,id_offset); - nread += nchunk; - } - - if (mapflag) { - atom->map_delete(); - atom->map_style = 0; - } - - if (me == 0) { - if (screen) fprintf(screen," " BIGINT_FORMAT " %s\n",natoms,type); - if (logfile) fprintf(logfile," " BIGINT_FORMAT " %s\n",natoms,type); - } -} - -/* ---------------------------------------------------------------------- - read all body data - variable amount of info per body, described by ninteger and ndouble - to find atoms, must build atom map if not a molecular system - if not firstpass, just read past data, but no processing of data -------------------------------------------------------------------------- */ - -void ReadData::bodies(int firstpass) -{ - int m,nchunk,nline,nmax,ninteger,ndouble,nword,ncount,onebody,tmp; - char *eof; - - int mapflag = 0; - if (atom->map_style == 0 && firstpass) { - mapflag = 1; - atom->map_init(); - atom->map_set(); - } - - // nmax = max # of bodies to read in this chunk - // nchunk = actual # read - - bigint nread = 0; - bigint natoms = nbodies; - - while (nread < natoms) { - if (natoms-nread > CHUNK) nmax = CHUNK; - else nmax = natoms-nread; - - if (me == 0) { - nchunk = 0; - nline = 0; - m = 0; - - while (nchunk < nmax && nline <= CHUNK-MAXBODY) { - eof = fgets(&buffer[m],MAXLINE,fp); - if (eof == NULL) error->one(FLERR,"Unexpected end of data file"); - sscanf(&buffer[m],"%d %d %d",&tmp,&ninteger,&ndouble); - m += strlen(&buffer[m]); - - // read lines one at a time into buffer and count words - // count to ninteger and ndouble until have enough lines - - onebody = 0; - - nword = 0; - while (nword < ninteger) { - eof = fgets(&buffer[m],MAXLINE,fp); - if (eof == NULL) error->one(FLERR,"Unexpected end of data file"); - ncount = atom->count_words(&buffer[m],copy); - if (ncount == 0) - error->one(FLERR,"Too few values in body lines in data file"); - nword += ncount; - m += strlen(&buffer[m]); - onebody++; - } - if (nword > ninteger) - error->one(FLERR,"Too many values in body lines in data file"); - - nword = 0; - while (nword < ndouble) { - eof = fgets(&buffer[m],MAXLINE,fp); - if (eof == NULL) error->one(FLERR,"Unexpected end of data file"); - ncount = atom->count_words(&buffer[m],copy); - if (ncount == 0) - error->one(FLERR,"Too few values in body lines in data file"); - nword += ncount; - m += strlen(&buffer[m]); - onebody++; - } - if (nword > ndouble) - error->one(FLERR,"Too many values in body lines in data file"); - - if (onebody+1 > MAXBODY) - error->one(FLERR, - "Too many lines in one body in data file - boost MAXBODY"); - - nchunk++; - nline += onebody+1; - } - - if (buffer[m-1] != '\n') strcpy(&buffer[m++],"\n"); - m++; - } - - MPI_Bcast(&nchunk,1,MPI_INT,0,world); - MPI_Bcast(&m,1,MPI_INT,0,world); - MPI_Bcast(buffer,m,MPI_CHAR,0,world); - - if (firstpass) atom->data_bodies(nchunk,buffer,avec_body,id_offset); - nread += nchunk; - } - - if (mapflag && firstpass) { - atom->map_delete(); - atom->map_style = 0; - } - - if (me == 0 && firstpass) { - if (screen) fprintf(screen," " BIGINT_FORMAT " bodies\n",natoms); - if (logfile) fprintf(logfile," " BIGINT_FORMAT " bodies\n",natoms); - } -} - -/* ---------------------------------------------------------------------- */ - -void ReadData::mass() -{ - char *next; - char *buf = new char[ntypes*MAXLINE]; - - int eof = comm->read_lines_from_file(fp,ntypes,MAXLINE,buf); - if (eof) error->all(FLERR,"Unexpected end of data file"); - - char *original = buf; - for (int i = 0; i < ntypes; i++) { - next = strchr(buf,'\n'); - *next = '\0'; - atom->set_mass(buf,toffset); - buf = next + 1; - } - delete [] original; -} - -/* ---------------------------------------------------------------------- */ - -void ReadData::paircoeffs() -{ - char *next; - char *buf = new char[ntypes*MAXLINE]; - - int eof = comm->read_lines_from_file(fp,ntypes,MAXLINE,buf); - if (eof) error->all(FLERR,"Unexpected end of data file"); - - char *original = buf; - for (int i = 0; i < ntypes; i++) { - next = strchr(buf,'\n'); - *next = '\0'; - parse_coeffs(buf,NULL,1,2,toffset); - if (narg == 0) error->all(FLERR,"Unexpected end of PairCoeffs section"); - force->pair->coeff(narg,arg); - buf = next + 1; - } - delete [] original; -} - -/* ---------------------------------------------------------------------- */ - -void ReadData::pairIJcoeffs() -{ - int i,j; - char *next; - - int nsq = ntypes * (ntypes+1) / 2; - char *buf = new char[nsq * MAXLINE]; - - int eof = comm->read_lines_from_file(fp,nsq,MAXLINE,buf); - if (eof) error->all(FLERR,"Unexpected end of data file"); - - char *original = buf; - for (i = 0; i < ntypes; i++) - for (j = i; j < ntypes; j++) { - next = strchr(buf,'\n'); - *next = '\0'; - parse_coeffs(buf,NULL,0,2,toffset); - if (narg == 0) error->all(FLERR,"Unexpected end of PairCoeffs section"); - force->pair->coeff(narg,arg); - buf = next + 1; - } - delete [] original; -} - -/* ---------------------------------------------------------------------- */ - -void ReadData::bondcoeffs() -{ - char *next; - char *buf = new char[nbondtypes*MAXLINE]; - - int eof = comm->read_lines_from_file(fp,nbondtypes,MAXLINE,buf); - if (eof) error->all(FLERR,"Unexpected end of data file"); - - char *original = buf; - for (int i = 0; i < nbondtypes; i++) { - next = strchr(buf,'\n'); - *next = '\0'; - parse_coeffs(buf,NULL,0,1,boffset); - if (narg == 0) error->all(FLERR,"Unexpected end of BondCoeffs section"); - force->bond->coeff(narg,arg); - buf = next + 1; - } - delete [] original; -} - -/* ---------------------------------------------------------------------- */ - -void ReadData::anglecoeffs(int which) -{ - char *next; - char *buf = new char[nangletypes*MAXLINE]; - - int eof = comm->read_lines_from_file(fp,nangletypes,MAXLINE,buf); - if (eof) error->all(FLERR,"Unexpected end of data file"); - - char *original = buf; - for (int i = 0; i < nangletypes; i++) { - next = strchr(buf,'\n'); - *next = '\0'; - if (which == 0) parse_coeffs(buf,NULL,0,1,aoffset); - else if (which == 1) parse_coeffs(buf,"bb",0,1,aoffset); - else if (which == 2) parse_coeffs(buf,"ba",0,1,aoffset); - if (narg == 0) error->all(FLERR,"Unexpected end of AngleCoeffs section"); - force->angle->coeff(narg,arg); - buf = next + 1; - } - delete [] original; -} - -/* ---------------------------------------------------------------------- */ - -void ReadData::dihedralcoeffs(int which) -{ - char *next; - char *buf = new char[ndihedraltypes*MAXLINE]; - - int eof = comm->read_lines_from_file(fp,ndihedraltypes,MAXLINE,buf); - if (eof) error->all(FLERR,"Unexpected end of data file"); - - char *original = buf; - for (int i = 0; i < ndihedraltypes; i++) { - next = strchr(buf,'\n'); - *next = '\0'; - if (which == 0) parse_coeffs(buf,NULL,0,1,doffset); - else if (which == 1) parse_coeffs(buf,"mbt",0,1,doffset); - else if (which == 2) parse_coeffs(buf,"ebt",0,1,doffset); - else if (which == 3) parse_coeffs(buf,"at",0,1,doffset); - else if (which == 4) parse_coeffs(buf,"aat",0,1,doffset); - else if (which == 5) parse_coeffs(buf,"bb13",0,1,doffset); - if (narg == 0) error->all(FLERR,"Unexpected end of DihedralCoeffs section"); - force->dihedral->coeff(narg,arg); - buf = next + 1; - } - delete [] original; -} - -/* ---------------------------------------------------------------------- */ - -void ReadData::impropercoeffs(int which) -{ - char *next; - char *buf = new char[nimpropertypes*MAXLINE]; - - int eof = comm->read_lines_from_file(fp,nimpropertypes,MAXLINE,buf); - if (eof) error->all(FLERR,"Unexpected end of data file"); - - char *original = buf; - for (int i = 0; i < nimpropertypes; i++) { - next = strchr(buf,'\n'); - *next = '\0'; - if (which == 0) parse_coeffs(buf,NULL,0,1,ioffset); - else if (which == 1) parse_coeffs(buf,"aa",0,1,ioffset); - if (narg == 0) error->all(FLERR,"Unexpected end of ImproperCoeffs section"); - force->improper->coeff(narg,arg); - buf = next + 1; - } - delete [] original; -} - -/* ---------------------------------------------------------------------- - read fix section, pass lines to fix to process - n = index of fix -------------------------------------------------------------------------- */ - -void ReadData::fix(int ifix, char *keyword) -{ - int nchunk,eof; - - bigint nline = modify->fix[ifix]->read_data_skip_lines(keyword); - - bigint nread = 0; - while (nread < nline) { - nchunk = MIN(nline-nread,CHUNK); - eof = comm->read_lines_from_file(fp,nchunk,MAXLINE,buffer); - if (eof) error->all(FLERR,"Unexpected end of data file"); - modify->fix[ifix]->read_data_section(keyword,nchunk,buffer,id_offset); - nread += nchunk; - } -} - -/* ---------------------------------------------------------------------- - reallocate the count vector from cmax to amax+1 and return new length - zero new locations -------------------------------------------------------------------------- */ - -int ReadData::reallocate(int **pcount, int cmax, int amax) -{ - int *count = *pcount; - memory->grow(count,amax+1,"read_data:count"); - for (int i = cmax; i <= amax; i++) count[i] = 0; - *pcount = count; - return amax+1; -} - -/* ---------------------------------------------------------------------- - proc 0 opens data file - test if gzipped -------------------------------------------------------------------------- */ - -void ReadData::open(char *file) -{ - compressed = 0; - char *suffix = file + strlen(file) - 3; - if (suffix > file && strcmp(suffix,".gz") == 0) compressed = 1; - if (!compressed) fp = fopen(file,"r"); - else { -#ifdef LAMMPS_GZIP - char gunzip[128]; - sprintf(gunzip,"gzip -c -d %s",file); - -#ifdef _WIN32 - fp = _popen(gunzip,"rb"); -#else - fp = popen(gunzip,"r"); -#endif - -#else - error->one(FLERR,"Cannot open gzipped file"); -#endif - } - - if (fp == NULL) { - char str[128]; - sprintf(str,"Cannot open file %s",file); - error->one(FLERR,str); - } -} - -/* ---------------------------------------------------------------------- - grab next keyword - read lines until one is non-blank - keyword is all text on line w/out leading & trailing white space - optional style can be appended after comment char '#' - read one additional line (assumed blank) - if any read hits EOF, set keyword to empty - if first = 1, line variable holds non-blank line that ended header -------------------------------------------------------------------------- */ - -void ReadData::parse_keyword(int first) -{ - int eof = 0; - int done = 0; - - // proc 0 reads upto non-blank line plus 1 following line - // eof is set to 1 if any read hits end-of-file - - if (me == 0) { - if (!first) { - if (fgets(line,MAXLINE,fp) == NULL) eof = 1; - } - while (eof == 0 && done == 0) { - int blank = strspn(line," \t\n\r"); - if ((blank == strlen(line)) || (line[blank] == '#')) { - if (fgets(line,MAXLINE,fp) == NULL) eof = 1; - } else done = 1; - } - if (fgets(buffer,MAXLINE,fp) == NULL) { - eof = 1; - buffer[0] = '\0'; - } - } - - // if eof, set keyword empty and return - - MPI_Bcast(&eof,1,MPI_INT,0,world); - if (eof) { - keyword[0] = '\0'; - return; - } - - // bcast keyword line to all procs - - int n; - if (me == 0) n = strlen(line) + 1; - MPI_Bcast(&n,1,MPI_INT,0,world); - MPI_Bcast(line,n,MPI_CHAR,0,world); - - // store optional "style" following comment char '#' after keyword - - char *ptr; - if ((ptr = strchr(line,'#'))) { - *ptr++ = '\0'; - while (*ptr == ' ' || *ptr == '\t') ptr++; - int stop = strlen(ptr) - 1; - while (ptr[stop] == ' ' || ptr[stop] == '\t' - || ptr[stop] == '\n' || ptr[stop] == '\r') stop--; - ptr[stop+1] = '\0'; - strcpy(style,ptr); - } else style[0] = '\0'; - - // copy non-whitespace portion of line into keyword - - int start = strspn(line," \t\n\r"); - int stop = strlen(line) - 1; - while (line[stop] == ' ' || line[stop] == '\t' - || line[stop] == '\n' || line[stop] == '\r') stop--; - line[stop+1] = '\0'; - strcpy(keyword,&line[start]); -} - -/* ---------------------------------------------------------------------- - proc 0 reads N lines from file - could be skipping Natoms lines, so use bigints -------------------------------------------------------------------------- */ - -void ReadData::skip_lines(bigint n) -{ - if (me) return; - if (n <= 0) return; - char *eof = NULL; - for (bigint i = 0; i < n; i++) eof = fgets(line,MAXLINE,fp); - if (eof == NULL) error->one(FLERR,"Unexpected end of data file"); -} - -/* ---------------------------------------------------------------------- - parse a line of coeffs into words, storing them in narg,arg - trim anything from '#' onward - word strings remain in line, are not copied - if addstr != NULL, add addstr as extra arg for class2 angle/dihedral/improper - if 2nd word starts with letter, then is hybrid style, add addstr after it - else add addstr before 2nd word - if dupflag, duplicate 1st word, so pair_coeff "2" becomes "2 2" - if noffset, add offset to first noffset args, which are atom/bond/etc types -------------------------------------------------------------------------- */ - -void ReadData::parse_coeffs(char *line, const char *addstr, - int dupflag, int noffset, int offset) -{ - char *ptr; - if ((ptr = strchr(line,'#'))) *ptr = '\0'; - - narg = 0; - char *word = strtok(line," \t\n\r\f"); - while (word) { - if (narg == maxarg) { - maxarg += DELTA; - arg = (char **) - memory->srealloc(arg,maxarg*sizeof(char *),"read_data:arg"); - } - if (addstr && narg == 1 && !islower(word[0])) arg[narg++] = (char *) addstr; - arg[narg++] = word; - if (addstr && narg == 2 && islower(word[0])) arg[narg++] = (char *) addstr; - if (dupflag && narg == 1) arg[narg++] = word; - word = strtok(NULL," \t\n\r\f"); - } - - if (noffset) { - int value = force->inumeric(FLERR,arg[0]); - sprintf(argoffset1,"%d",value+offset); - arg[0] = argoffset1; - if (noffset == 2) { - value = force->inumeric(FLERR,arg[1]); - sprintf(argoffset2,"%d",value+offset); - arg[1] = argoffset2; - } - } -} - -/* ---------------------------------------------------------------------- - compare two style strings if they both exist - one = comment in data file section, two = currently-defined style - ignore suffixes listed in suffixes array at top of file -------------------------------------------------------------------------- */ - -int ReadData::style_match(const char *one, const char *two) -{ - int i,delta,len,len1,len2; - - if ((one == NULL) || (two == NULL)) return 1; - - len1 = strlen(one); - len2 = strlen(two); - - for (i = 0; suffixes[i] != NULL; i++) { - len = strlen(suffixes[i]); - if ((delta = len1 - len) > 0) - if (strcmp(one+delta,suffixes[i]) == 0) len1 = delta; - if ((delta = len2 - len) > 0) - if (strcmp(two+delta,suffixes[i]) == 0) len2 = delta; - } - - if ((len1 == 0) || (len1 == len2) || (strncmp(one,two,len1) == 0)) return 1; - return 0; -} diff --git a/src/USER-HADRESS/read_data.h b/src/USER-HADRESS/read_data.h deleted file mode 100644 index 5463c86f08..0000000000 --- a/src/USER-HADRESS/read_data.h +++ /dev/null @@ -1,560 +0,0 @@ -/* -*- c++ -*- ---------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - http://lammps.sandia.gov, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - Copyright (2003) Sandia Corporation. Under the terms of Contract - DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains - certain rights in this software. This software is distributed under - the GNU General Public License. - - See the README file in the top-level LAMMPS directory. -------------------------------------------------------------------------- */ - -#ifdef COMMAND_CLASS - -CommandStyle(read_data,ReadData) - -#else - -#ifndef LMP_READ_DATA_H -#define LMP_READ_DATA_H - -#include -#include "pointers.h" - -namespace LAMMPS_NS { - -class ReadData : protected Pointers { - public: - ReadData(class LAMMPS *); - ~ReadData(); - void command(int, char **); - - private: - int me,compressed; - char *line,*copy,*keyword,*buffer,*style; - FILE *fp; - char **arg; - int narg,maxarg; - char argoffset1[8],argoffset2[8]; - - bigint id_offset; - - int nlocal_previous; - bigint natoms; - bigint nbonds,nangles,ndihedrals,nimpropers; - int ntypes; - int nbondtypes,nangletypes,ndihedraltypes,nimpropertypes; - - bigint nellipsoids; - class AtomVecEllipsoid *avec_ellipsoid; - bigint nlines; - class AtomVecLine *avec_line; - bigint ntris; - class AtomVecTri *avec_tri; - bigint nbodies; - class AtomVecBody *avec_body; - - // box info - - double boxlo[3],boxhi[3]; - double xy,xz,yz; - int triclinic; - - // optional args - - int addflag,offsetflag,shiftflag,coeffflag; - tagint addvalue; - int toffset,boffset,aoffset,doffset,ioffset; - double shift[3]; - int extra_atom_types,extra_bond_types,extra_angle_types; - int extra_dihedral_types,extra_improper_types; - int groupbit; - - int nfix; - int *fix_index; - char **fix_header; - char **fix_section; - - // methods - - void open(char *); - void scan(int &, int &, int &, int &); - int reallocate(int **, int, int); - void header(int); - void parse_keyword(int); - void skip_lines(bigint); - void parse_coeffs(char *, const char *, int, int, int); - int style_match(const char *, const char *); - - void atoms(); - void velocities(); - - void bonds(int); - void bond_scan(int, char *, int *); - void angles(int); - void dihedrals(int); - void impropers(int); - - void bonus(bigint, class AtomVec *, const char *); - void bodies(int); - - void mass(); - void paircoeffs(); - void pairIJcoeffs(); - void bondcoeffs(); - void anglecoeffs(int); - void dihedralcoeffs(int); - void impropercoeffs(int); - - void fix(int, char *); -}; - -} - -#endif -#endif - -/* ERROR/WARNING messages: - -E: Illegal ... command - -Self-explanatory. Check the input script syntax and compare to the -documentation for the command. You can use -echo screen as a -command-line option when running LAMMPS to see the offending line. - -E: Read data add offset is too big - -It cannot be larger than the size of atom IDs, e.g. the maximum 32-bit -integer. - -E: Non-zero read_data shift z value for 2d simulation - -Self-explanatory. - -E: No bonds allowed with this atom style - -Self-explanatory. - -E: No angles allowed with this atom style - -Self-explanatory. - -E: No dihedrals allowed with this atom style - -Self-explanatory. - -E: No impropers allowed with this atom style - -Self-explanatory. - -E: Fix ID for read_data does not exist - -Self-explanatory. - -E: Cannot run 2d simulation with nonperiodic Z dimension - -Use the boundary command to make the z dimension periodic in order to -run a 2d simulation. - -E: Cannot read_data without add keyword after simulation box is defined - -Self-explanatory. - -E: Cannot use read_data add before simulation box is defined - -Self-explanatory. - -E: Cannot use read_data offset without add flag - -Self-explanatory. - -E: Cannot use read_data shift without add flag - -Self-explanatory. - -E: Cannot use read_data extra with add flag - -Self-explanatory. - -W: Atom style in data file differs from currently defined atom style - -Self-explanatory. - -E: Must read Atoms before Velocities - -The Atoms section of a data file must come before a Velocities -section. - -E: Invalid data file section: Bonds - -Atom style does not allow bonds. - -E: Must read Atoms before Bonds - -The Atoms section of a data file must come before a Bonds section. - -E: Invalid data file section: Angles - -Atom style does not allow angles. - -E: Must read Atoms before Angles - -The Atoms section of a data file must come before an Angles section. - -E: Invalid data file section: Dihedrals - -Atom style does not allow dihedrals. - -E: Must read Atoms before Dihedrals - -The Atoms section of a data file must come before a Dihedrals section. - -E: Invalid data file section: Impropers - -Atom style does not allow impropers. - -E: Must read Atoms before Impropers - -The Atoms section of a data file must come before an Impropers -section. - -E: Invalid data file section: Ellipsoids - -Atom style does not allow ellipsoids. - -E: Must read Atoms before Ellipsoids - -The Atoms section of a data file must come before a Ellipsoids -section. - -E: Invalid data file section: Lines - -Atom style does not allow lines. - -E: Must read Atoms before Lines - -The Atoms section of a data file must come before a Lines section. - -E: Invalid data file section: Triangles - -Atom style does not allow triangles. - -E: Must read Atoms before Triangles - -The Atoms section of a data file must come before a Triangles section. - -E: Invalid data file section: Bodies - -Atom style does not allow bodies. - -E: Must read Atoms before Bodies - -The Atoms section of a data file must come before a Bodies section. - -E: Must define pair_style before Pair Coeffs - -Must use a pair_style command before reading a data file that defines -Pair Coeffs. - -W: Pair style in data file differs from currently defined pair style - -Self-explanatory. - -E: Must define pair_style before PairIJ Coeffs - -Must use a pair_style command before reading a data file that defines -PairIJ Coeffs. - -E: Invalid data file section: Bond Coeffs - -Atom style does not allow bonds. - -E: Must define bond_style before Bond Coeffs - -Must use a bond_style command before reading a data file that -defines Bond Coeffs. - -W: Bond style in data file differs from currently defined bond style - -Self-explanatory. - -E: Invalid data file section: Angle Coeffs - -Atom style does not allow angles. - -E: Must define angle_style before Angle Coeffs - -Must use an angle_style command before reading a data file that -defines Angle Coeffs. - -W: Angle style in data file differs from currently defined angle style - -Self-explanatory. - -E: Invalid data file section: Dihedral Coeffs - -Atom style does not allow dihedrals. - -E: Must define dihedral_style before Dihedral Coeffs - -Must use a dihedral_style command before reading a data file that -defines Dihedral Coeffs. - -W: Dihedral style in data file differs from currently defined dihedral style - -Self-explanatory. - -E: Invalid data file section: Improper Coeffs - -Atom style does not allow impropers. - -E: Must define improper_style before Improper Coeffs - -Must use an improper_style command before reading a data file that -defines Improper Coeffs. - -W: Improper style in data file differs from currently defined improper style - -Self-explanatory. - -E: Invalid data file section: BondBond Coeffs - -Atom style does not allow angles. - -E: Must define angle_style before BondBond Coeffs - -Must use an angle_style command before reading a data file that -defines Angle Coeffs. - -E: Invalid data file section: BondAngle Coeffs - -Atom style does not allow angles. - -E: Must define angle_style before BondAngle Coeffs - -Must use an angle_style command before reading a data file that -defines Angle Coeffs. - -E: Invalid data file section: MiddleBondTorsion Coeffs - -Atom style does not allow dihedrals. - -E: Must define dihedral_style before MiddleBondTorsion Coeffs - -Must use a dihedral_style command before reading a data file that -defines MiddleBondTorsion Coeffs. - -E: Invalid data file section: EndBondTorsion Coeffs - -Atom style does not allow dihedrals. - -E: Must define dihedral_style before EndBondTorsion Coeffs - -Must use a dihedral_style command before reading a data file that -defines EndBondTorsion Coeffs. - -E: Invalid data file section: AngleTorsion Coeffs - -Atom style does not allow dihedrals. - -E: Must define dihedral_style before AngleTorsion Coeffs - -Must use a dihedral_style command before reading a data file that -defines AngleTorsion Coeffs. - -E: Invalid data file section: AngleAngleTorsion Coeffs - -Atom style does not allow dihedrals. - -E: Must define dihedral_style before AngleAngleTorsion Coeffs - -Must use a dihedral_style command before reading a data file that -defines AngleAngleTorsion Coeffs. - -E: Invalid data file section: BondBond13 Coeffs - -Atom style does not allow dihedrals. - -E: Must define dihedral_style before BondBond13 Coeffs - -Must use a dihedral_style command before reading a data file that -defines BondBond13 Coeffs. - -E: Invalid data file section: AngleAngle Coeffs - -Atom style does not allow impropers. - -E: Must define improper_style before AngleAngle Coeffs - -Must use an improper_style command before reading a data file that -defines AngleAngle Coeffs. - -E: Unknown identifier in data file: %s - -A section of the data file cannot be read by LAMMPS. - -E: No atoms in data file - -The header of the data file indicated that atoms would be included, -but they are not present. - -E: Needed molecular topology not in data file - -The header of the data file indicated bonds, angles, etc would be -included, but they are not present. - -E: Needed bonus data not in data file - -Some atom styles require bonus data. See the read_data doc page for -details. - -E: Read_data shrink wrap did not assign all atoms correctly - -This is typically because the box-size specified in the data file is -large compared to the actual extent of atoms in a shrink-wrapped -dimension. When LAMMPS shrink-wraps the box atoms will be lost if the -processor they are re-assigned to is too far away. Choose a box -size closer to the actual extent of the atoms. - -E: Unexpected end of data file - -LAMMPS hit the end of the data file while attempting to read a -section. Something is wrong with the format of the data file. - -E: No ellipsoids allowed with this atom style - -Self-explanatory. Check data file. - -E: No lines allowed with this atom style - -Self-explanatory. Check data file. - -E: No triangles allowed with this atom style - -Self-explanatory. Check data file. - -E: No bodies allowed with this atom style - -Self-explanatory. Check data file. - -E: System in data file is too big - -See the setting for bigint in the src/lmptype.h file. - -E: Bonds defined but no bond types - -The data file header lists bonds but no bond types. - -E: Angles defined but no angle types - -The data file header lists angles but no angle types. - -E: Dihedrals defined but no dihedral types - -The data file header lists dihedrals but no dihedral types. - -E: Impropers defined but no improper types - -The data file header lists improper but no improper types. - -E: No molecule topology allowed with atom style template - -The data file cannot specify the number of bonds, angles, etc, -because this info if inferred from the molecule templates. - -E: Did not assign all atoms correctly - -Atoms read in from a data file were not assigned correctly to -processors. This is likely due to some atom coordinates being -outside a non-periodic simulation box. - -E: Subsequent read data induced too many bonds per atom - -See the create_box extra/bond/per/atom or read_data "extra bond per -atom" header value to set this limit larger. - -E: Bonds assigned incorrectly - -Bonds read in from the data file were not assigned correctly to atoms. -This means there is something invalid about the topology definitions. - -E: Subsequent read data induced too many angles per atom - -See the create_box extra/angle/per/atom or read_data "extra angle per -atom" header value to set this limit larger. - -E: Angles assigned incorrectly - -Angles read in from the data file were not assigned correctly to -atoms. This means there is something invalid about the topology -definitions. - -E: Subsequent read data induced too many dihedrals per atom - -See the create_box extra/dihedral/per/atom or read_data "extra -dihedral per atom" header value to set this limit larger. - -E: Dihedrals assigned incorrectly - -Dihedrals read in from the data file were not assigned correctly to -atoms. This means there is something invalid about the topology -definitions. - -E: Subsequent read data induced too many impropers per atom - -See the create_box extra/improper/per/atom or read_data "extra -improper per atom" header value to set this limit larger. - -E: Impropers assigned incorrectly - -Impropers read in from the data file were not assigned correctly to -atoms. This means there is something invalid about the topology -definitions. - -E: Too few values in body lines in data file - -Self-explanatory. - -E: Too many values in body lines in data file - -Self-explanatory. - -E: Too many lines in one body in data file - boost MAXBODY - -MAXBODY is a setting at the top of the src/read_data.cpp file. -Set it larger and re-compile the code. - -E: Unexpected end of PairCoeffs section - -Read a blank line. - -E: Unexpected end of BondCoeffs section - -Read a blank line. - -E: Unexpected end of AngleCoeffs section - -Read a blank line. - -E: Unexpected end of DihedralCoeffs section - -Read a blank line. - -E: Unexpected end of ImproperCoeffs section - -Read a blank line. - -E: Cannot open gzipped file - -LAMMPS was compiled without support for reading and writing gzipped -files through a pipeline to the gzip program with -DLAMMPS_GZIP. - -E: Cannot open file %s - -The specified file cannot be opened. Check that the path and name are -correct. If the file is a compressed file, also check that the gzip -executable can be found and run. - -*/ From 7e4cd4643459b37b268fcf092fb67762a1500b65 Mon Sep 17 00:00:00 2001 From: MaziarHeidari Date: Fri, 24 Jun 2016 16:03:38 +0200 Subject: [PATCH 07/15] HADRESS_Version_24_Jun_2016 --- src/USER-HADRESS/Install.sh | 60 + src/USER-HADRESS/README | 18 + src/USER-HADRESS/atom_vec_full_hars.cpp | 1352 +++++++++++++++++ src/USER-HADRESS/atom_vec_full_hars.h | 104 ++ src/USER-HADRESS/fix_lambdah_calc.cpp | 958 ++++++++++++ src/USER-HADRESS/fix_lambdah_calc.h | 102 ++ .../pair_lj_cut_coul_dsf_hars_at.cpp | 981 ++++++++++++ .../pair_lj_cut_coul_dsf_hars_at.h | 115 ++ src/USER-HADRESS/pair_lj_cut_hars_at.cpp | 1050 +++++++++++++ src/USER-HADRESS/pair_lj_cut_hars_at.h | 119 ++ src/USER-HADRESS/pair_lj_cut_hars_cg.cpp | 1127 ++++++++++++++ src/USER-HADRESS/pair_lj_cut_hars_cg.h | 123 ++ 12 files changed, 6109 insertions(+) create mode 100644 src/USER-HADRESS/Install.sh create mode 100644 src/USER-HADRESS/README create mode 100644 src/USER-HADRESS/atom_vec_full_hars.cpp create mode 100644 src/USER-HADRESS/atom_vec_full_hars.h create mode 100644 src/USER-HADRESS/fix_lambdah_calc.cpp create mode 100644 src/USER-HADRESS/fix_lambdah_calc.h create mode 100644 src/USER-HADRESS/pair_lj_cut_coul_dsf_hars_at.cpp create mode 100644 src/USER-HADRESS/pair_lj_cut_coul_dsf_hars_at.h create mode 100644 src/USER-HADRESS/pair_lj_cut_hars_at.cpp create mode 100644 src/USER-HADRESS/pair_lj_cut_hars_at.h create mode 100644 src/USER-HADRESS/pair_lj_cut_hars_cg.cpp create mode 100644 src/USER-HADRESS/pair_lj_cut_hars_cg.h diff --git a/src/USER-HADRESS/Install.sh b/src/USER-HADRESS/Install.sh new file mode 100644 index 0000000000..0224cf3928 --- /dev/null +++ b/src/USER-HADRESS/Install.sh @@ -0,0 +1,60 @@ +# Install/unInstall package files in LAMMPS +# mode = 0/1/2 for uninstall/install/update + +mode=$1 + +# arg1 = file, arg2 = file it depends on + +action () { + if (test $mode = 0) then + rm -f ../$1 + elif (! cmp -s $1 ../$1) then + if (test -z "$2" || test -e ../$2) then + cp $1 .. + if (test $mode = 2) then + echo " updating src/$1" + fi + fi + elif (test -n "$2") then + if (test ! -e ../$2) then + rm -f ../$1 + fi + fi +} + +# all package files with no dependencies + +for file in *.cpp *.h; do + action $file +done + +# edit 2 Makefile.package files to include/exclude package info + +if (test $1 = 1) then + + if (test -e ../Makefile.package) then + sed -i -e 's/[^ \t]*USER-HADRESS[^ \t]* //' ../Makefile.package + sed -i -e 's|^PKG_SYSINC =[ \t]*|&$(USER-HADRESS_SYSINC) |' ../Makefile.package + sed -i -e 's|^PKG_SYSLIB =[ \t]*|&$(USER-HADRESS_SYSLIB) |' ../Makefile.package + sed -i -e 's|^PKG_SYSPATH =[ \t]*|&$(USER-HADRESS_SYSPATH) |' ../Makefile.package + fi + + if (test -e ../Makefile.package.settings) then + sed -i -e '/^include.*USER-HADRESS.*$/d' ../Makefile.package.settings + # multiline form needed for BSD sed on Macs + sed -i -e '4 i \ +include ..\/..\/lib\/USER-HADRESS\/Makefile.lammps +' ../Makefile.package.settings + fi + +elif (test $1 = 0) then + + if (test -e ../Makefile.package) then + sed -i -e 's/[^ \t]*USER-HADRESS[^ \t]* //' ../Makefile.package + fi + + if (test -e ../Makefile.package.settings) then + sed -i -e '/^include.*USER-HADRESS.*$/d' ../Makefile.package.settings + fi + +fi diff --git a/src/USER-HADRESS/README b/src/USER-HADRESS/README new file mode 100644 index 0000000000..d4c860100b --- /dev/null +++ b/src/USER-HADRESS/README @@ -0,0 +1,18 @@ +This package contains files that brings the utility of +Hamiltonian Adaptive Resolution Simulations (H-AdResS) to the Lammps package. + + +See the doc page for for detailed usage instructions. + +There is example script for using this package in the folder +"example" + + +The persons who created this package are + +Maziar Heidari (Max Planck Institute for Polymer Research) +Robinson Cortes-Huerto (Max Planck Institute for Polymer Research) +Raffaello Potestio (Max Planck Institute for Polymer Research) +and Davide Donadio ( Department of Chemistry, University of California, Davis) + +Here is a contact information if you have questions. (heidari@mpip-mainz.mpg.de) diff --git a/src/USER-HADRESS/atom_vec_full_hars.cpp b/src/USER-HADRESS/atom_vec_full_hars.cpp new file mode 100644 index 0000000000..fe01c0fa98 --- /dev/null +++ b/src/USER-HADRESS/atom_vec_full_hars.cpp @@ -0,0 +1,1352 @@ +/* ---------------------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + http://lammps.sandia.gov, Sandia National Laboratories + Steve Plimpton, sjplimp@sandia.gov + + Copyright (2003) Sandia Corporation. Under the terms of Contract + DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains + certain rights in this software. This software is distributed under + the GNU General Public License. + + See the README file in the top-level LAMMPS directory. +------------------------------------------------------------------------- */ + +#include "stdlib.h" +#include "atom_vec_full_hars.h" +#include "atom.h" +#include "comm.h" +#include "domain.h" +#include "modify.h" +#include "fix.h" +#include "memory.h" +#include "error.h" + +using namespace LAMMPS_NS; + +/* ---------------------------------------------------------------------- */ + +AtomVecFullHars::AtomVecFullHars(LAMMPS *lmp) : AtomVec(lmp) +{ + molecular = 1; + bonds_allow = angles_allow = dihedrals_allow = impropers_allow = 1; + mass_type = 1; + + comm_x_only = comm_f_only = 0; + size_forward = 10; + size_reverse = 3; + size_border = 17; + size_velocity = 3; + size_data_atom = 9; + size_data_vel = 4; + xcol_data = 7; + + atom->molecule_flag = atom->q_flag = 1; + atom->replambdaH_flag = 1; + atom->moltypeH_flag = 1; + +} + +/* ---------------------------------------------------------------------- + grow atom arrays + n = 0 grows arrays by a chunk + n > 0 allocates arrays to size n +------------------------------------------------------------------------- */ + +void AtomVecFullHars::grow(int n) +{ + if (n == 0) grow_nmax(); + else nmax = n; + atom->nmax = nmax; + if (nmax < 0 || nmax > MAXSMALLINT) + error->one(FLERR,"Per-processor system is too big"); + + tag = memory->grow(atom->tag,nmax,"atom:tag"); + type = memory->grow(atom->type,nmax,"atom:type"); + mask = memory->grow(atom->mask,nmax,"atom:mask"); + image = memory->grow(atom->image,nmax,"atom:image"); + x = memory->grow(atom->x,nmax,3,"atom:x"); + v = memory->grow(atom->v,nmax,3,"atom:v"); + f = memory->grow(atom->f,nmax*comm->nthreads,3,"atom:f"); + + q = memory->grow(atom->q,nmax,"atom:q"); + lambdaH = memory->grow(atom->lambdaH,nmax,"atom:lambdaH"); + gradlambdaH = memory->grow(atom->gradlambdaH,nmax,3,"atom:gradlambdaH"); + replambdaH = memory->grow(atom->replambdaH,nmax,"atom:replambdaH"); + moltypeH = memory->grow(atom->moltypeH,nmax,"atom:moltypeH"); + comH = memory->grow(atom->comH,nmax,3,"atom:comH"); + + molecule = memory->grow(atom->molecule,nmax,"atom:molecule"); + + nspecial = memory->grow(atom->nspecial,nmax,3,"atom:nspecial"); + special = memory->grow(atom->special,nmax,atom->maxspecial,"atom:special"); + + num_bond = memory->grow(atom->num_bond,nmax,"atom:num_bond"); + bond_type = memory->grow(atom->bond_type,nmax,atom->bond_per_atom, + "atom:bond_type"); + bond_atom = memory->grow(atom->bond_atom,nmax,atom->bond_per_atom, + "atom:bond_atom"); + + num_angle = memory->grow(atom->num_angle,nmax,"atom:num_angle"); + angle_type = memory->grow(atom->angle_type,nmax,atom->angle_per_atom, + "atom:angle_type"); + angle_atom1 = memory->grow(atom->angle_atom1,nmax,atom->angle_per_atom, + "atom:angle_atom1"); + angle_atom2 = memory->grow(atom->angle_atom2,nmax,atom->angle_per_atom, + "atom:angle_atom2"); + angle_atom3 = memory->grow(atom->angle_atom3,nmax,atom->angle_per_atom, + "atom:angle_atom3"); + + num_dihedral = memory->grow(atom->num_dihedral,nmax,"atom:num_dihedral"); + dihedral_type = memory->grow(atom->dihedral_type,nmax, + atom->dihedral_per_atom,"atom:dihedral_type"); + dihedral_atom1 = + memory->grow(atom->dihedral_atom1,nmax,atom->dihedral_per_atom, + "atom:dihedral_atom1"); + dihedral_atom2 = + memory->grow(atom->dihedral_atom2,nmax,atom->dihedral_per_atom, + "atom:dihedral_atom2"); + dihedral_atom3 = + memory->grow(atom->dihedral_atom3,nmax,atom->dihedral_per_atom, + "atom:dihedral_atom3"); + dihedral_atom4 = + memory->grow(atom->dihedral_atom4,nmax,atom->dihedral_per_atom, + "atom:dihedral_atom4"); + + num_improper = memory->grow(atom->num_improper,nmax,"atom:num_improper"); + improper_type = + memory->grow(atom->improper_type,nmax,atom->improper_per_atom, + "atom:improper_type"); + improper_atom1 = + memory->grow(atom->improper_atom1,nmax,atom->improper_per_atom, + "atom:improper_atom1"); + improper_atom2 = + memory->grow(atom->improper_atom2,nmax,atom->improper_per_atom, + "atom:improper_atom2"); + improper_atom3 = + memory->grow(atom->improper_atom3,nmax,atom->improper_per_atom, + "atom:improper_atom3"); + improper_atom4 = + memory->grow(atom->improper_atom4,nmax,atom->improper_per_atom, + "atom:improper_atom4"); + + if (atom->nextra_grow) + for (int iextra = 0; iextra < atom->nextra_grow; iextra++) + modify->fix[atom->extra_grow[iextra]]->grow_arrays(nmax); +} + +/* ---------------------------------------------------------------------- + reset local array ptrs +------------------------------------------------------------------------- */ + +void AtomVecFullHars::grow_reset() +{ + tag = atom->tag; type = atom->type; + mask = atom->mask; image = atom->image; + x = atom->x; v = atom->v; f = atom->f; comH = atom->comH; + q = atom->q; lambdaH = atom->lambdaH;gradlambdaH = atom->gradlambdaH; + replambdaH = atom->replambdaH;moltypeH = atom->moltypeH;molecule = atom->molecule; + nspecial = atom->nspecial; special = atom->special; + num_bond = atom->num_bond; bond_type = atom->bond_type; + bond_atom = atom->bond_atom; + num_angle = atom->num_angle; angle_type = atom->angle_type; + angle_atom1 = atom->angle_atom1; angle_atom2 = atom->angle_atom2; + angle_atom3 = atom->angle_atom3; + num_dihedral = atom->num_dihedral; dihedral_type = atom->dihedral_type; + dihedral_atom1 = atom->dihedral_atom1; dihedral_atom2 = atom->dihedral_atom2; + dihedral_atom3 = atom->dihedral_atom3; dihedral_atom4 = atom->dihedral_atom4; + num_improper = atom->num_improper; improper_type = atom->improper_type; + improper_atom1 = atom->improper_atom1; improper_atom2 = atom->improper_atom2; + improper_atom3 = atom->improper_atom3; improper_atom4 = atom->improper_atom4; +} + +/* ---------------------------------------------------------------------- + copy atom I info to atom J +------------------------------------------------------------------------- */ + +void AtomVecFullHars::copy(int i, int j, int delflag) +{ + int k; + + tag[j] = tag[i]; + type[j] = type[i]; + mask[j] = mask[i]; + image[j] = image[i]; + x[j][0] = x[i][0]; + x[j][1] = x[i][1]; + x[j][2] = x[i][2]; + v[j][0] = v[i][0]; + v[j][1] = v[i][1]; + v[j][2] = v[i][2]; + + comH[j][0] = comH[i][0]; + comH[j][1] = comH[i][1]; + comH[j][2] = comH[i][2]; + + q[j] = q[i]; + lambdaH[j] = lambdaH[i]; + gradlambdaH[j][0] = gradlambdaH[i][0]; + gradlambdaH[j][1] = gradlambdaH[i][1]; + gradlambdaH[j][2] = gradlambdaH[i][2]; + replambdaH[j] = replambdaH[i]; + moltypeH[j] = moltypeH[i]; + molecule[j] = molecule[i]; + + + num_bond[j] = num_bond[i]; + for (k = 0; k < num_bond[j]; k++) { + bond_type[j][k] = bond_type[i][k]; + bond_atom[j][k] = bond_atom[i][k]; + } + + num_angle[j] = num_angle[i]; + for (k = 0; k < num_angle[j]; k++) { + angle_type[j][k] = angle_type[i][k]; + angle_atom1[j][k] = angle_atom1[i][k]; + angle_atom2[j][k] = angle_atom2[i][k]; + angle_atom3[j][k] = angle_atom3[i][k]; + } + + num_dihedral[j] = num_dihedral[i]; + for (k = 0; k < num_dihedral[j]; k++) { + dihedral_type[j][k] = dihedral_type[i][k]; + dihedral_atom1[j][k] = dihedral_atom1[i][k]; + dihedral_atom2[j][k] = dihedral_atom2[i][k]; + dihedral_atom3[j][k] = dihedral_atom3[i][k]; + dihedral_atom4[j][k] = dihedral_atom4[i][k]; + } + + num_improper[j] = num_improper[i]; + for (k = 0; k < num_improper[j]; k++) { + improper_type[j][k] = improper_type[i][k]; + improper_atom1[j][k] = improper_atom1[i][k]; + improper_atom2[j][k] = improper_atom2[i][k]; + improper_atom3[j][k] = improper_atom3[i][k]; + improper_atom4[j][k] = improper_atom4[i][k]; + } + + nspecial[j][0] = nspecial[i][0]; + nspecial[j][1] = nspecial[i][1]; + nspecial[j][2] = nspecial[i][2]; + for (k = 0; k < nspecial[j][2]; k++) special[j][k] = special[i][k]; + + if (atom->nextra_grow) + for (int iextra = 0; iextra < atom->nextra_grow; iextra++) + modify->fix[atom->extra_grow[iextra]]->copy_arrays(i,j,delflag); +} + +/* ---------------------------------------------------------------------- */ + +int AtomVecFullHars::pack_comm(int n, int *list, double *buf, + int pbc_flag, int *pbc) +{ + int i,j,m; + double dx,dy,dz; + + m = 0; + if (pbc_flag == 0) { + for (i = 0; i < n; i++) { + j = list[i]; + buf[m++] = x[j][0]; + buf[m++] = x[j][1]; + buf[m++] = x[j][2]; + buf[m++] = lambdaH[j]; + buf[m++] = gradlambdaH[j][0]; + buf[m++] = gradlambdaH[j][1]; + buf[m++] = gradlambdaH[j][2]; + buf[m++] = comH[j][0]; + buf[m++] = comH[j][1]; + buf[m++] = comH[j][2]; + + } + } else { + if (domain->triclinic == 0) { + dx = pbc[0]*domain->xprd; + dy = pbc[1]*domain->yprd; + dz = pbc[2]*domain->zprd; + } else { + dx = pbc[0]*domain->xprd + pbc[5]*domain->xy + pbc[4]*domain->xz; + dy = pbc[1]*domain->yprd + pbc[3]*domain->yz; + dz = pbc[2]*domain->zprd; + } + for (i = 0; i < n; i++) { + j = list[i]; + buf[m++] = x[j][0] + dx; + buf[m++] = x[j][1] + dy; + buf[m++] = x[j][2] + dz; + buf[m++] = lambdaH[j]; + buf[m++] = gradlambdaH[j][0]; + buf[m++] = gradlambdaH[j][1]; + buf[m++] = gradlambdaH[j][2]; + buf[m++] = comH[j][0]; + buf[m++] = comH[j][1]; + buf[m++] = comH[j][2]; + + + } + } + return m; +} + +/* ---------------------------------------------------------------------- */ + +int AtomVecFullHars::pack_comm_vel(int n, int *list, double *buf, + int pbc_flag, int *pbc) +{ + int i,j,m; + double dx,dy,dz,dvx,dvy,dvz; + + m = 0; + if (pbc_flag == 0) { + for (i = 0; i < n; i++) { + j = list[i]; + buf[m++] = x[j][0]; + buf[m++] = x[j][1]; + buf[m++] = x[j][2]; + buf[m++] = lambdaH[j]; + buf[m++] = gradlambdaH[j][0]; + buf[m++] = gradlambdaH[j][1]; + buf[m++] = gradlambdaH[j][2]; + buf[m++] = comH[j][0]; + buf[m++] = comH[j][1]; + buf[m++] = comH[j][2]; + + buf[m++] = v[j][0]; + buf[m++] = v[j][1]; + buf[m++] = v[j][2]; + + } + } else { + if (domain->triclinic == 0) { + dx = pbc[0]*domain->xprd; + dy = pbc[1]*domain->yprd; + dz = pbc[2]*domain->zprd; + } else { + dx = pbc[0]*domain->xprd + pbc[5]*domain->xy + pbc[4]*domain->xz; + dy = pbc[1]*domain->yprd + pbc[3]*domain->yz; + dz = pbc[2]*domain->zprd; + } + if (!deform_vremap) { + for (i = 0; i < n; i++) { + j = list[i]; + buf[m++] = x[j][0] + dx; + buf[m++] = x[j][1] + dy; + buf[m++] = x[j][2] + dz; + buf[m++] = lambdaH[j]; + buf[m++] = gradlambdaH[j][0]; + buf[m++] = gradlambdaH[j][1]; + buf[m++] = gradlambdaH[j][2]; + buf[m++] = comH[j][0]; + buf[m++] = comH[j][1]; + buf[m++] = comH[j][2]; + + buf[m++] = v[j][0]; + buf[m++] = v[j][1]; + buf[m++] = v[j][2]; + } + } else { + dvx = pbc[0]*h_rate[0] + pbc[5]*h_rate[5] + pbc[4]*h_rate[4]; + dvy = pbc[1]*h_rate[1] + pbc[3]*h_rate[3]; + dvz = pbc[2]*h_rate[2]; + for (i = 0; i < n; i++) { + j = list[i]; + buf[m++] = x[j][0] + dx; + buf[m++] = x[j][1] + dy; + buf[m++] = x[j][2] + dz; + buf[m++] = lambdaH[j]; + buf[m++] = gradlambdaH[j][0]; + buf[m++] = gradlambdaH[j][1]; + buf[m++] = gradlambdaH[j][2]; + buf[m++] = comH[j][0]; + buf[m++] = comH[j][1]; + buf[m++] = comH[j][2]; + + + + if (mask[i] & deform_groupbit) { + buf[m++] = v[j][0] + dvx; + buf[m++] = v[j][1] + dvy; + buf[m++] = v[j][2] + dvz; + } else { + buf[m++] = v[j][0]; + buf[m++] = v[j][1]; + buf[m++] = v[j][2]; + } + } + } + } + return m; +} + +/* ---------------------------------------------------------------------- */ + +void AtomVecFullHars::unpack_comm(int n, int first, double *buf) +{ + int i,m,last; + + m = 0; + last = first + n; + for (i = first; i < last; i++) { + x[i][0] = buf[m++]; + x[i][1] = buf[m++]; + x[i][2] = buf[m++]; + lambdaH[i] = buf[m++]; + gradlambdaH[i][0] = buf[m++]; + gradlambdaH[i][1] = buf[m++]; + gradlambdaH[i][2] = buf[m++]; + comH[i][0] = buf[m++]; + comH[i][1] = buf[m++]; + comH[i][2] = buf[m++]; + + + + } +} + +/* ---------------------------------------------------------------------- */ + +void AtomVecFullHars::unpack_comm_vel(int n, int first, double *buf) +{ + int i,m,last; + + m = 0; + last = first + n; + for (i = first; i < last; i++) { + x[i][0] = buf[m++]; + x[i][1] = buf[m++]; + x[i][2] = buf[m++]; + lambdaH[i] = buf[m++]; + gradlambdaH[i][0] = buf[m++]; + gradlambdaH[i][1] = buf[m++]; + gradlambdaH[i][2] = buf[m++]; + comH[i][0] = buf[m++]; + comH[i][1] = buf[m++]; + comH[i][2] = buf[m++]; + + v[i][0] = buf[m++]; + v[i][1] = buf[m++]; + v[i][2] = buf[m++]; + } +} + +/* ---------------------------------------------------------------------- */ + +int AtomVecFullHars::pack_reverse(int n, int first, double *buf) +{ + int i,m,last; + + m = 0; + last = first + n; + for (i = first; i < last; i++) { + buf[m++] = f[i][0]; + buf[m++] = f[i][1]; + buf[m++] = f[i][2]; + + } + return m; +} + +/* ---------------------------------------------------------------------- */ + +void AtomVecFullHars::unpack_reverse(int n, int *list, double *buf) +{ + int i,j,m; + + m = 0; + for (i = 0; i < n; i++) { + j = list[i]; + f[j][0] += buf[m++]; + f[j][1] += buf[m++]; + f[j][2] += buf[m++]; + + + } +} + +/* ---------------------------------------------------------------------- */ + +int AtomVecFullHars::pack_border(int n, int *list, double *buf, + int pbc_flag, int *pbc) +{ + int i,j,m; + double dx,dy,dz; + + m = 0; + if (pbc_flag == 0) { + for (i = 0; i < n; i++) { + j = list[i]; + buf[m++] = x[j][0]; + buf[m++] = x[j][1]; + buf[m++] = x[j][2]; + buf[m++] = ubuf(tag[j]).d; + buf[m++] = ubuf(type[j]).d; + buf[m++] = ubuf(mask[j]).d; + buf[m++] = q[j]; + buf[m++] = lambdaH[j]; + buf[m++] = gradlambdaH[j][0]; + buf[m++] = gradlambdaH[j][1]; + buf[m++] = gradlambdaH[j][2]; + buf[m++] = comH[j][0]; + buf[m++] = comH[j][1]; + buf[m++] = comH[j][2]; + + buf[m++] = ubuf(replambdaH[j]).d; + buf[m++] = ubuf(moltypeH[j]).d; + + buf[m++] = ubuf(molecule[j]).d; + } + } else { + if (domain->triclinic == 0) { + dx = pbc[0]*domain->xprd; + dy = pbc[1]*domain->yprd; + dz = pbc[2]*domain->zprd; + } else { + dx = pbc[0]; + dy = pbc[1]; + dz = pbc[2]; + } + for (i = 0; i < n; i++) { + j = list[i]; + buf[m++] = x[j][0] + dx; + buf[m++] = x[j][1] + dy; + buf[m++] = x[j][2] + dz; + buf[m++] = ubuf(tag[j]).d; + buf[m++] = ubuf(type[j]).d; + buf[m++] = ubuf(mask[j]).d; + buf[m++] = q[j]; + buf[m++] = lambdaH[j]; + buf[m++] = gradlambdaH[j][0]; + buf[m++] = gradlambdaH[j][1]; + buf[m++] = gradlambdaH[j][2]; + buf[m++] = comH[j][0]; + buf[m++] = comH[j][1]; + buf[m++] = comH[j][2]; + + buf[m++] = ubuf(replambdaH[j]).d; + buf[m++] = ubuf(moltypeH[j]).d; + + buf[m++] = ubuf(molecule[j]).d; + } + } + + if (atom->nextra_border) + for (int iextra = 0; iextra < atom->nextra_border; iextra++) + m += modify->fix[atom->extra_border[iextra]]->pack_border(n,list,&buf[m]); + + return m; +} + +/* ---------------------------------------------------------------------- */ + +int AtomVecFullHars::pack_border_vel(int n, int *list, double *buf, + int pbc_flag, int *pbc) +{ + int i,j,m; + double dx,dy,dz,dvx,dvy,dvz; + + m = 0; + if (pbc_flag == 0) { + for (i = 0; i < n; i++) { + j = list[i]; + buf[m++] = x[j][0]; + buf[m++] = x[j][1]; + buf[m++] = x[j][2]; + buf[m++] = ubuf(tag[j]).d; + buf[m++] = ubuf(type[j]).d; + buf[m++] = ubuf(mask[j]).d; + buf[m++] = q[j]; + buf[m++] = lambdaH[j]; + buf[m++] = gradlambdaH[j][0]; + buf[m++] = gradlambdaH[j][1]; + buf[m++] = gradlambdaH[j][2]; + buf[m++] = comH[j][0]; + buf[m++] = comH[j][1]; + buf[m++] = comH[j][2]; + + buf[m++] = ubuf(replambdaH[j]).d; + buf[m++] = ubuf(moltypeH[j]).d; + + buf[m++] = ubuf(molecule[j]).d; + buf[m++] = v[j][0]; + buf[m++] = v[j][1]; + buf[m++] = v[j][2]; + } + } else { + if (domain->triclinic == 0) { + dx = pbc[0]*domain->xprd; + dy = pbc[1]*domain->yprd; + dz = pbc[2]*domain->zprd; + } else { + dx = pbc[0]; + dy = pbc[1]; + dz = pbc[2]; + } + if (!deform_vremap) { + for (i = 0; i < n; i++) { + j = list[i]; + buf[m++] = x[j][0] + dx; + buf[m++] = x[j][1] + dy; + buf[m++] = x[j][2] + dz; + buf[m++] = ubuf(tag[j]).d; + buf[m++] = ubuf(type[j]).d; + buf[m++] = ubuf(mask[j]).d; + buf[m++] = q[j]; + buf[m++] = lambdaH[j]; + buf[m++] = gradlambdaH[j][0]; + buf[m++] = gradlambdaH[j][1]; + buf[m++] = gradlambdaH[j][2]; + buf[m++] = comH[j][0]; + buf[m++] = comH[j][1]; + buf[m++] = comH[j][2]; + + buf[m++] = ubuf(replambdaH[j]).d; + buf[m++] = ubuf(moltypeH[j]).d; + + buf[m++] = ubuf(molecule[j]).d; + buf[m++] = v[j][0]; + buf[m++] = v[j][1]; + buf[m++] = v[j][2]; + } + } else { + dvx = pbc[0]*h_rate[0] + pbc[5]*h_rate[5] + pbc[4]*h_rate[4]; + dvy = pbc[1]*h_rate[1] + pbc[3]*h_rate[3]; + dvz = pbc[2]*h_rate[2]; + for (i = 0; i < n; i++) { + j = list[i]; + buf[m++] = x[j][0] + dx; + buf[m++] = x[j][1] + dy; + buf[m++] = x[j][2] + dz; + buf[m++] = ubuf(tag[j]).d; + buf[m++] = ubuf(type[j]).d; + buf[m++] = ubuf(mask[j]).d; + buf[m++] = q[j]; + buf[m++] = lambdaH[j]; + buf[m++] = gradlambdaH[j][0]; + buf[m++] = gradlambdaH[j][1]; + buf[m++] = gradlambdaH[j][2]; + buf[m++] = comH[j][0]; + buf[m++] = comH[j][1]; + buf[m++] = comH[j][2]; + + buf[m++] = ubuf(replambdaH[j]).d; + buf[m++] = ubuf(moltypeH[j]).d; + + buf[m++] = ubuf(molecule[j]).d; + if (mask[i] & deform_groupbit) { + buf[m++] = v[j][0] + dvx; + buf[m++] = v[j][1] + dvy; + buf[m++] = v[j][2] + dvz; + } else { + buf[m++] = v[j][0]; + buf[m++] = v[j][1]; + buf[m++] = v[j][2]; + } + } + } + } + + if (atom->nextra_border) + for (int iextra = 0; iextra < atom->nextra_border; iextra++) + m += modify->fix[atom->extra_border[iextra]]->pack_border(n,list,&buf[m]); + + return m; +} + +/* ---------------------------------------------------------------------- */ + +int AtomVecFullHars::pack_border_hybrid(int n, int *list, double *buf) +{ + int i,j,m; + + m = 0; + for (i = 0; i < n; i++) { + j = list[i]; + buf[m++] = q[j]; + buf[m++] = ubuf(replambdaH[j]).d; + buf[m++] = ubuf(moltypeH[j]).d; + buf[m++] = ubuf(molecule[j]).d; + } + return m; +} + +/* ---------------------------------------------------------------------- */ + +void AtomVecFullHars::unpack_border(int n, int first, double *buf) +{ + int i,m,last; + + m = 0; + last = first + n; + for (i = first; i < last; i++) { + if (i == nmax) grow(0); + x[i][0] = buf[m++]; + x[i][1] = buf[m++]; + x[i][2] = buf[m++]; + tag[i] = (tagint) ubuf(buf[m++]).i; + type[i] = (int) ubuf(buf[m++]).i; + mask[i] = (int) ubuf(buf[m++]).i; + q[i] = buf[m++]; + lambdaH[i] = buf[m++]; + gradlambdaH[i][0] = buf[m++]; + gradlambdaH[i][1] = buf[m++]; + gradlambdaH[i][2] = buf[m++]; + comH[i][0] = buf[m++]; + comH[i][1] = buf[m++]; + comH[i][2] = buf[m++]; + + replambdaH[i] = (int) ubuf(buf[m++]).i; + moltypeH[i] = (int) ubuf(buf[m++]).i; + + molecule[i] = (tagint) ubuf(buf[m++]).i; + + } + + if (atom->nextra_border) + for (int iextra = 0; iextra < atom->nextra_border; iextra++) + m += modify->fix[atom->extra_border[iextra]]-> + unpack_border(n,first,&buf[m]); +} + +/* ---------------------------------------------------------------------- */ + +void AtomVecFullHars::unpack_border_vel(int n, int first, double *buf) +{ + int i,m,last; + + m = 0; + last = first + n; + for (i = first; i < last; i++) { + if (i == nmax) grow(0); + x[i][0] = buf[m++]; + x[i][1] = buf[m++]; + x[i][2] = buf[m++]; + tag[i] = (tagint) ubuf(buf[m++]).i; + type[i] = (int) ubuf(buf[m++]).i; + mask[i] = (int) ubuf(buf[m++]).i; + q[i] = buf[m++]; + lambdaH[i] = buf[m++]; + gradlambdaH[i][0] = buf[m++]; + gradlambdaH[i][1] = buf[m++]; + gradlambdaH[i][2] = buf[m++]; + comH[i][0] = buf[m++]; + comH[i][1] = buf[m++]; + comH[i][2] = buf[m++]; + + replambdaH[i] = (int) ubuf(buf[m++]).i; + moltypeH[i] = (int) ubuf(buf[m++]).i; + + molecule[i] = (tagint) ubuf(buf[m++]).i; + v[i][0] = buf[m++]; + v[i][1] = buf[m++]; + v[i][2] = buf[m++]; + } + + if (atom->nextra_border) + for (int iextra = 0; iextra < atom->nextra_border; iextra++) + m += modify->fix[atom->extra_border[iextra]]-> + unpack_border(n,first,&buf[m]); +} + +/* ---------------------------------------------------------------------- */ + +int AtomVecFullHars::unpack_border_hybrid(int n, int first, double *buf) +{ + int i,m,last; + + m = 0; + last = first + n; + for (i = first; i < last; i++) { + q[i] = buf[m++]; + replambdaH[i] = (int) ubuf(buf[m++]).i; + moltypeH[i] = (int) ubuf(buf[m++]).i; + molecule[i] = (tagint) ubuf(buf[m++]).i; + } + return m; +} + +/* ---------------------------------------------------------------------- + pack data for atom I for sending to another proc + xyz must be 1st 3 values, so comm::exchange() can test on them +------------------------------------------------------------------------- */ + +int AtomVecFullHars::pack_exchange(int i, double *buf) +{ + int k; + + int m = 1; + buf[m++] = x[i][0]; + buf[m++] = x[i][1]; + buf[m++] = x[i][2]; + buf[m++] = v[i][0]; + buf[m++] = v[i][1]; + buf[m++] = v[i][2]; + buf[m++] = ubuf(tag[i]).d; + buf[m++] = ubuf(type[i]).d; + buf[m++] = ubuf(mask[i]).d; + buf[m++] = ubuf(image[i]).d; + + buf[m++] = q[i]; + buf[m++] = lambdaH[i]; + buf[m++] = gradlambdaH[i][0]; + buf[m++] = gradlambdaH[i][1]; + buf[m++] = gradlambdaH[i][2]; + buf[m++] = comH[i][0]; + buf[m++] = comH[i][1]; + buf[m++] = comH[i][2]; + + buf[m++] = ubuf(replambdaH[i]).d; + buf[m++] = ubuf(moltypeH[i]).d; + + buf[m++] = ubuf(molecule[i]).d; + + buf[m++] = ubuf(num_bond[i]).d; + for (k = 0; k < num_bond[i]; k++) { + buf[m++] = ubuf(bond_type[i][k]).d; + buf[m++] = ubuf(bond_atom[i][k]).d; + } + + buf[m++] = ubuf(num_angle[i]).d; + for (k = 0; k < num_angle[i]; k++) { + buf[m++] = ubuf(angle_type[i][k]).d; + buf[m++] = ubuf(angle_atom1[i][k]).d; + buf[m++] = ubuf(angle_atom2[i][k]).d; + buf[m++] = ubuf(angle_atom3[i][k]).d; + } + + buf[m++] = ubuf(num_dihedral[i]).d; + for (k = 0; k < num_dihedral[i]; k++) { + buf[m++] = ubuf(dihedral_type[i][k]).d; + buf[m++] = ubuf(dihedral_atom1[i][k]).d; + buf[m++] = ubuf(dihedral_atom2[i][k]).d; + buf[m++] = ubuf(dihedral_atom3[i][k]).d; + buf[m++] = ubuf(dihedral_atom4[i][k]).d; + } + + buf[m++] = ubuf(num_improper[i]).d; + for (k = 0; k < num_improper[i]; k++) { + buf[m++] = ubuf(improper_type[i][k]).d; + buf[m++] = ubuf(improper_atom1[i][k]).d; + buf[m++] = ubuf(improper_atom2[i][k]).d; + buf[m++] = ubuf(improper_atom3[i][k]).d; + buf[m++] = ubuf(improper_atom4[i][k]).d; + } + + buf[m++] = ubuf(nspecial[i][0]).d; + buf[m++] = ubuf(nspecial[i][1]).d; + buf[m++] = ubuf(nspecial[i][2]).d; + for (k = 0; k < nspecial[i][2]; k++) buf[m++] = ubuf(special[i][k]).d; + + if (atom->nextra_grow) + for (int iextra = 0; iextra < atom->nextra_grow; iextra++) + m += modify->fix[atom->extra_grow[iextra]]->pack_exchange(i,&buf[m]); + + buf[0] = m; + return m; +} + +/* ---------------------------------------------------------------------- */ + +int AtomVecFullHars::unpack_exchange(double *buf) +{ + int k; + + int nlocal = atom->nlocal; + if (nlocal == nmax) grow(0); + + int m = 1; + x[nlocal][0] = buf[m++]; + x[nlocal][1] = buf[m++]; + x[nlocal][2] = buf[m++]; + v[nlocal][0] = buf[m++]; + v[nlocal][1] = buf[m++]; + v[nlocal][2] = buf[m++]; + tag[nlocal] = (tagint) ubuf(buf[m++]).i; + type[nlocal] = (int) ubuf(buf[m++]).i; + mask[nlocal] = (int) ubuf(buf[m++]).i; + image[nlocal] = (imageint) ubuf(buf[m++]).i; + + q[nlocal] = buf[m++]; + lambdaH[nlocal] = buf[m++]; + gradlambdaH[nlocal][0] = buf[m++]; + gradlambdaH[nlocal][1] = buf[m++]; + gradlambdaH[nlocal][2] = buf[m++]; + comH[nlocal][0] = buf[m++]; + comH[nlocal][1] = buf[m++]; + comH[nlocal][2] = buf[m++]; + + replambdaH[nlocal] = (int) ubuf(buf[m++]).i; + moltypeH[nlocal] = (int) ubuf(buf[m++]).i; + + molecule[nlocal] = (tagint) ubuf(buf[m++]).i; + + num_bond[nlocal] = (int) ubuf(buf[m++]).i; + for (k = 0; k < num_bond[nlocal]; k++) { + bond_type[nlocal][k] = (int) ubuf(buf[m++]).i; + bond_atom[nlocal][k] = (tagint) ubuf(buf[m++]).i; + } + + num_angle[nlocal] = (int) ubuf(buf[m++]).i; + for (k = 0; k < num_angle[nlocal]; k++) { + angle_type[nlocal][k] = (int) ubuf(buf[m++]).i; + angle_atom1[nlocal][k] = (tagint) ubuf(buf[m++]).i; + angle_atom2[nlocal][k] = (tagint) ubuf(buf[m++]).i; + angle_atom3[nlocal][k] = (tagint) ubuf(buf[m++]).i; + } + + num_dihedral[nlocal] = (int) ubuf(buf[m++]).i; + for (k = 0; k < num_dihedral[nlocal]; k++) { + dihedral_type[nlocal][k] = (int) ubuf(buf[m++]).i; + dihedral_atom1[nlocal][k] = (tagint) ubuf(buf[m++]).i; + dihedral_atom2[nlocal][k] = (tagint) ubuf(buf[m++]).i; + dihedral_atom3[nlocal][k] = (tagint) ubuf(buf[m++]).i; + dihedral_atom4[nlocal][k] = (tagint) ubuf(buf[m++]).i; + } + + num_improper[nlocal] = (int) ubuf(buf[m++]).i; + for (k = 0; k < num_improper[nlocal]; k++) { + improper_type[nlocal][k] = (int) ubuf(buf[m++]).i; + improper_atom1[nlocal][k] = (tagint) ubuf(buf[m++]).i; + improper_atom2[nlocal][k] = (tagint) ubuf(buf[m++]).i; + improper_atom3[nlocal][k] = (tagint) ubuf(buf[m++]).i; + improper_atom4[nlocal][k] = (tagint) ubuf(buf[m++]).i; + } + + nspecial[nlocal][0] = (int) ubuf(buf[m++]).i; + nspecial[nlocal][1] = (int) ubuf(buf[m++]).i; + nspecial[nlocal][2] = (int) ubuf(buf[m++]).i; + for (k = 0; k < nspecial[nlocal][2]; k++) + special[nlocal][k] = (tagint) ubuf(buf[m++]).i; + + if (atom->nextra_grow) + for (int iextra = 0; iextra < atom->nextra_grow; iextra++) + m += modify->fix[atom->extra_grow[iextra]]-> + unpack_exchange(nlocal,&buf[m]); + + atom->nlocal++; + return m; +} + +/* ---------------------------------------------------------------------- + size of restart data for all atoms owned by this proc + include extra data stored by fixes +------------------------------------------------------------------------- */ + +int AtomVecFullHars::size_restart() +{ + int i; + + int nlocal = atom->nlocal; + int n = 0; + for (i = 0; i < nlocal; i++) + n += 17 + 2*num_bond[i] + 4*num_angle[i] + + 5*num_dihedral[i] + 5*num_improper[i]+9; + + if (atom->nextra_restart) + for (int iextra = 0; iextra < atom->nextra_restart; iextra++) + for (i = 0; i < nlocal; i++) + n += modify->fix[atom->extra_restart[iextra]]->size_restart(i); + + return n; +} + +/* ---------------------------------------------------------------------- + pack atom I's data for restart file including extra quantities + xyz must be 1st 3 values, so that read_restart can test on them + molecular types may be negative, but write as positive +------------------------------------------------------------------------- */ + +int AtomVecFullHars::pack_restart(int i, double *buf) +{ + int k; + + int m = 1; + buf[m++] = x[i][0]; + buf[m++] = x[i][1]; + buf[m++] = x[i][2]; + buf[m++] = ubuf(tag[i]).d; + buf[m++] = ubuf(type[i]).d; + buf[m++] = ubuf(mask[i]).d; + buf[m++] = ubuf(image[i]).d; + buf[m++] = v[i][0]; + buf[m++] = v[i][1]; + buf[m++] = v[i][2]; + + buf[m++] = q[i]; + buf[m++] = lambdaH[i]; + buf[m++] = gradlambdaH[i][0]; + buf[m++] = gradlambdaH[i][1]; + buf[m++] = gradlambdaH[i][2]; + buf[m++] = comH[i][0]; + buf[m++] = comH[i][1]; + buf[m++] = comH[i][2]; + + buf[m++] = ubuf(replambdaH[i]).d; + buf[m++] = ubuf(moltypeH[i]).d; + buf[m++] = ubuf(molecule[i]).d; + + buf[m++] = ubuf(num_bond[i]).d; + for (k = 0; k < num_bond[i]; k++) { + buf[m++] = ubuf(MAX(bond_type[i][k],-bond_type[i][k])).d; + buf[m++] = ubuf(bond_atom[i][k]).d; + } + + buf[m++] = ubuf(num_angle[i]).d; + for (k = 0; k < num_angle[i]; k++) { + buf[m++] = ubuf(MAX(angle_type[i][k],-angle_type[i][k])).d; + buf[m++] = ubuf(angle_atom1[i][k]).d; + buf[m++] = ubuf(angle_atom2[i][k]).d; + buf[m++] = ubuf(angle_atom3[i][k]).d; + } + + buf[m++] = ubuf(num_dihedral[i]).d; + for (k = 0; k < num_dihedral[i]; k++) { + buf[m++] = ubuf(MAX(dihedral_type[i][k],-dihedral_type[i][k])).d; + buf[m++] = ubuf(dihedral_atom1[i][k]).d; + buf[m++] = ubuf(dihedral_atom2[i][k]).d; + buf[m++] = ubuf(dihedral_atom3[i][k]).d; + buf[m++] = ubuf(dihedral_atom4[i][k]).d; + } + + buf[m++] = ubuf(num_improper[i]).d; + for (k = 0; k < num_improper[i]; k++) { + buf[m++] = ubuf(MAX(improper_type[i][k],-improper_type[i][k])).d; + buf[m++] = ubuf(improper_atom1[i][k]).d; + buf[m++] = ubuf(improper_atom2[i][k]).d; + buf[m++] = ubuf(improper_atom3[i][k]).d; + buf[m++] = ubuf(improper_atom4[i][k]).d; + } + + if (atom->nextra_restart) + for (int iextra = 0; iextra < atom->nextra_restart; iextra++) + m += modify->fix[atom->extra_restart[iextra]]->pack_restart(i,&buf[m]); + + buf[0] = m; + return m; +} + +/* ---------------------------------------------------------------------- + unpack data for one atom from restart file including extra quantities +------------------------------------------------------------------------- */ + +int AtomVecFullHars::unpack_restart(double *buf) +{ + int k; + + int nlocal = atom->nlocal; + if (nlocal == nmax) { + grow(0); + if (atom->nextra_store) + memory->grow(atom->extra,nmax,atom->nextra_store,"atom:extra"); + } + + int m = 1; + x[nlocal][0] = buf[m++]; + x[nlocal][1] = buf[m++]; + x[nlocal][2] = buf[m++]; + tag[nlocal] = (tagint) ubuf(buf[m++]).i; + type[nlocal] = (int) ubuf(buf[m++]).i; + mask[nlocal] = (int) ubuf(buf[m++]).i; + image[nlocal] = (imageint) ubuf(buf[m++]).i; + v[nlocal][0] = buf[m++]; + v[nlocal][1] = buf[m++]; + v[nlocal][2] = buf[m++]; + + q[nlocal] = buf[m++]; + lambdaH[nlocal] = buf[m++]; + gradlambdaH[nlocal][0] = buf[m++]; + gradlambdaH[nlocal][1] = buf[m++]; + gradlambdaH[nlocal][2] = buf[m++]; + comH[nlocal][0] = buf[m++]; + comH[nlocal][1] = buf[m++]; + comH[nlocal][2] = buf[m++]; + replambdaH[nlocal] = (int) ubuf(buf[m++]).i; + moltypeH[nlocal] = (int) ubuf(buf[m++]).i; + + molecule[nlocal] = (tagint) ubuf(buf[m++]).i; + + num_bond[nlocal] = (int) ubuf(buf[m++]).i; + for (k = 0; k < num_bond[nlocal]; k++) { + bond_type[nlocal][k] = (int) ubuf(buf[m++]).i; + bond_atom[nlocal][k] = (tagint) ubuf(buf[m++]).i; + } + + num_angle[nlocal] = (int) ubuf(buf[m++]).i; + for (k = 0; k < num_angle[nlocal]; k++) { + angle_type[nlocal][k] = (int) ubuf(buf[m++]).i; + angle_atom1[nlocal][k] = (tagint) ubuf(buf[m++]).i; + angle_atom2[nlocal][k] = (tagint) ubuf(buf[m++]).i; + angle_atom3[nlocal][k] = (tagint) ubuf(buf[m++]).i; + } + + num_dihedral[nlocal] = (int) ubuf(buf[m++]).i; + for (k = 0; k < num_dihedral[nlocal]; k++) { + dihedral_type[nlocal][k] = (int) ubuf(buf[m++]).i; + dihedral_atom1[nlocal][k] = (tagint) ubuf(buf[m++]).i; + dihedral_atom2[nlocal][k] = (tagint) ubuf(buf[m++]).i; + dihedral_atom3[nlocal][k] = (tagint) ubuf(buf[m++]).i; + dihedral_atom4[nlocal][k] = (tagint) ubuf(buf[m++]).i; + } + + num_improper[nlocal] = (int) ubuf(buf[m++]).i; + for (k = 0; k < num_improper[nlocal]; k++) { + improper_type[nlocal][k] = (int) ubuf(buf[m++]).i; + improper_atom1[nlocal][k] = (tagint) ubuf(buf[m++]).i; + improper_atom2[nlocal][k] = (tagint) ubuf(buf[m++]).i; + improper_atom3[nlocal][k] = (tagint) ubuf(buf[m++]).i; + improper_atom4[nlocal][k] = (tagint) ubuf(buf[m++]).i; + } + + nspecial[nlocal][0] = nspecial[nlocal][1] = nspecial[nlocal][2] = 0; + + double **extra = atom->extra; + if (atom->nextra_store) { + int size = static_cast (buf[0]) - m; + for (int i = 0; i < size; i++) extra[nlocal][i] = buf[m++]; + } + + atom->nlocal++; + return m; +} + +/* ---------------------------------------------------------------------- + create one atom of itype at coord + set other values to defaults +------------------------------------------------------------------------- */ + +void AtomVecFullHars::create_atom(int itype, double *coord) +{ + int nlocal = atom->nlocal; + if (nlocal == nmax) grow(0); + + tag[nlocal] = 0; + type[nlocal] = itype; + x[nlocal][0] = coord[0]; + x[nlocal][1] = coord[1]; + x[nlocal][2] = coord[2]; + mask[nlocal] = 1; + image[nlocal] = ((imageint) IMGMAX << IMG2BITS) | + ((imageint) IMGMAX << IMGBITS) | IMGMAX; + v[nlocal][0] = 0.0; + v[nlocal][1] = 0.0; + v[nlocal][2] = 0.0; + + q[nlocal] = 0.0; + lambdaH[nlocal] = 0.0; + gradlambdaH[nlocal][0] = 0.0; + gradlambdaH[nlocal][1] = 0.0; + gradlambdaH[nlocal][2] = 0.0; + comH[nlocal][0] = 0; + comH[nlocal][1] = 0; + comH[nlocal][2] = 0; + + replambdaH[nlocal] = 0; + moltypeH[nlocal] = 0; + + molecule[nlocal] = 0; + num_bond[nlocal] = 0; + num_angle[nlocal] = 0; + num_dihedral[nlocal] = 0; + num_improper[nlocal] = 0; + nspecial[nlocal][0] = nspecial[nlocal][1] = nspecial[nlocal][2] = 0; + + atom->nlocal++; +} + +/* ---------------------------------------------------------------------- + unpack one line from Atoms section of data file + initialize other atom quantities +------------------------------------------------------------------------- */ + +void AtomVecFullHars::data_atom(double *coord, imageint imagetmp, char **values) +{ + int nlocal = atom->nlocal; + if (nlocal == nmax) grow(0); + + tag[nlocal] = ATOTAGINT(values[0]); + molecule[nlocal] = ATOTAGINT(values[1]); + type[nlocal] = atoi(values[2]); + if (type[nlocal] <= 0 || type[nlocal] > atom->ntypes) + error->one(FLERR,"Invalid atom type in Atoms section of data file"); + + q[nlocal] = atof(values[3]); + replambdaH[nlocal] = atoi(values[4]); + moltypeH[nlocal] = atoi(values[5]); + + + x[nlocal][0] = coord[0]; + x[nlocal][1] = coord[1]; + x[nlocal][2] = coord[2]; + + comH[nlocal][0] = 0; + comH[nlocal][1] = 0; + comH[nlocal][2] = 0; + + image[nlocal] = imagetmp; + + mask[nlocal] = 1; + v[nlocal][0] = 0.0; + v[nlocal][1] = 0.0; + v[nlocal][2] = 0.0; + num_bond[nlocal] = 0; + num_angle[nlocal] = 0; + num_dihedral[nlocal] = 0; + num_improper[nlocal] = 0; + + atom->nlocal++; +} + +/* ---------------------------------------------------------------------- + unpack hybrid quantities from one line in Atoms section of data file + initialize other atom quantities for this sub-style +------------------------------------------------------------------------- */ + +int AtomVecFullHars::data_atom_hybrid(int nlocal, char **values) +{ + molecule[nlocal] = ATOTAGINT(values[0]); + q[nlocal] = atof(values[1]); + replambdaH[nlocal] = atoi(values[2]); + moltypeH[nlocal] = atoi(values[3]); + + num_bond[nlocal] = 0; + num_angle[nlocal] = 0; + num_dihedral[nlocal] = 0; + num_improper[nlocal] = 0; + + return 2; +} + +/* ---------------------------------------------------------------------- + pack atom info for data file including 3 image flags +------------------------------------------------------------------------- */ + +void AtomVecFullHars::pack_data(double **buf) +{ + int nlocal = atom->nlocal; + for (int i = 0; i < nlocal; i++) { + buf[i][0] = ubuf(tag[i]).d; + buf[i][1] = ubuf(molecule[i]).d; + buf[i][2] = ubuf(type[i]).d; + buf[i][3] = q[i]; + buf[i][4] = ubuf(replambdaH[i]).d; + buf[i][5] = ubuf(moltypeH[i]).d; + + buf[i][6] = x[i][0]; + buf[i][7] = x[i][1]; + buf[i][8] = x[i][2]; + buf[i][9] = ubuf((image[i] & IMGMASK) - IMGMAX).d; + buf[i][10] = ubuf((image[i] >> IMGBITS & IMGMASK) - IMGMAX).d; + buf[i][11] = ubuf((image[i] >> IMG2BITS) - IMGMAX).d; + } +} + +/* ---------------------------------------------------------------------- + pack hybrid atom info for data file +------------------------------------------------------------------------- */ + +int AtomVecFullHars::pack_data_hybrid(int i, double *buf) +{ + buf[0] = ubuf(molecule[i]).d; + buf[1] = q[i]; + buf[2] = ubuf(replambdaH[i]).d; + buf[3] = ubuf(moltypeH[i]).d; + + return 2; +} + +/* ---------------------------------------------------------------------- + write atom info to data file including 3 image flags +------------------------------------------------------------------------- */ + +void AtomVecFullHars::write_data(FILE *fp, int n, double **buf) +{ + for (int i = 0; i < n; i++) + fprintf(fp,TAGINT_FORMAT " " TAGINT_FORMAT + " %d %-1.16e %-1.16e %-1.16e %-1.16e %d %d %d\n", + (tagint) ubuf(buf[i][0]).i,(tagint) ubuf(buf[i][1]).i, + (int) ubuf(buf[i][2]).i, + buf[i][3],buf[i][4],buf[i][5],buf[i][6], + (int) ubuf(buf[i][7]).i,(int) ubuf(buf[i][8]).i, + (int) ubuf(buf[i][9]).i); +} + +/* ---------------------------------------------------------------------- + write hybrid atom info to data file +------------------------------------------------------------------------- */ + +int AtomVecFullHars::write_data_hybrid(FILE *fp, double *buf) +{ + fprintf(fp," " TAGINT_FORMAT " %-1.16e",(tagint) ubuf(buf[0]).i,buf[1]); + return 2; +} + +/* ---------------------------------------------------------------------- + return # of bytes of allocated memory +------------------------------------------------------------------------- */ + +bigint AtomVecFullHars::memory_usage() +{ + bigint bytes = 0; + + if (atom->memcheck("tag")) bytes += memory->usage(tag,nmax); + if (atom->memcheck("type")) bytes += memory->usage(type,nmax); + if (atom->memcheck("mask")) bytes += memory->usage(mask,nmax); + if (atom->memcheck("image")) bytes += memory->usage(image,nmax); + if (atom->memcheck("x")) bytes += memory->usage(x,nmax,3); + if (atom->memcheck("v")) bytes += memory->usage(v,nmax,3); + if (atom->memcheck("f")) bytes += memory->usage(f,nmax*comm->nthreads,3); + + if (atom->memcheck("q")) bytes += memory->usage(q,nmax); + if (atom->memcheck("lambdaH")) bytes += memory->usage(lambdaH,nmax); + if (atom->memcheck("gradlambdaH")) bytes += memory->usage(gradlambdaH,nmax,3); + if (atom->memcheck("replambdaH")) bytes += memory->usage(replambdaH,nmax); + if (atom->memcheck("moltypeH")) bytes += memory->usage(moltypeH,nmax); + + if (atom->memcheck("comH")) bytes += memory->usage(comH,nmax,3); + + + if (atom->memcheck("molecule")) bytes += memory->usage(molecule,nmax); + if (atom->memcheck("nspecial")) bytes += memory->usage(nspecial,nmax,3); + if (atom->memcheck("special")) + bytes += memory->usage(special,nmax,atom->maxspecial); + + if (atom->memcheck("num_bond")) bytes += memory->usage(num_bond,nmax); + if (atom->memcheck("bond_type")) + bytes += memory->usage(bond_type,nmax,atom->bond_per_atom); + if (atom->memcheck("bond_atom")) + bytes += memory->usage(bond_atom,nmax,atom->bond_per_atom); + + if (atom->memcheck("num_angle")) bytes += memory->usage(num_angle,nmax); + if (atom->memcheck("angle_type")) + bytes += memory->usage(angle_type,nmax,atom->angle_per_atom); + if (atom->memcheck("angle_atom1")) + bytes += memory->usage(angle_atom1,nmax,atom->angle_per_atom); + if (atom->memcheck("angle_atom2")) + bytes += memory->usage(angle_atom2,nmax,atom->angle_per_atom); + if (atom->memcheck("angle_atom3")) + bytes += memory->usage(angle_atom3,nmax,atom->angle_per_atom); + + if (atom->memcheck("num_dihedral")) bytes += memory->usage(num_dihedral,nmax); + if (atom->memcheck("dihedral_type")) + bytes += memory->usage(dihedral_type,nmax,atom->dihedral_per_atom); + if (atom->memcheck("dihedral_atom1")) + bytes += memory->usage(dihedral_atom1,nmax,atom->dihedral_per_atom); + if (atom->memcheck("dihedral_atom2")) + bytes += memory->usage(dihedral_atom2,nmax,atom->dihedral_per_atom); + if (atom->memcheck("dihedral_atom3")) + bytes += memory->usage(dihedral_atom3,nmax,atom->dihedral_per_atom); + if (atom->memcheck("dihedral_atom4")) + bytes += memory->usage(dihedral_atom4,nmax,atom->dihedral_per_atom); + + if (atom->memcheck("num_improper")) bytes += memory->usage(num_improper,nmax); + if (atom->memcheck("improper_type")) + bytes += memory->usage(improper_type,nmax,atom->improper_per_atom); + if (atom->memcheck("improper_atom1")) + bytes += memory->usage(improper_atom1,nmax,atom->improper_per_atom); + if (atom->memcheck("improper_atom2")) + bytes += memory->usage(improper_atom2,nmax,atom->improper_per_atom); + if (atom->memcheck("improper_atom3")) + bytes += memory->usage(improper_atom3,nmax,atom->improper_per_atom); + if (atom->memcheck("improper_atom4")) + bytes += memory->usage(improper_atom4,nmax,atom->improper_per_atom); + + return bytes; +} diff --git a/src/USER-HADRESS/atom_vec_full_hars.h b/src/USER-HADRESS/atom_vec_full_hars.h new file mode 100644 index 0000000000..59bac9a3b9 --- /dev/null +++ b/src/USER-HADRESS/atom_vec_full_hars.h @@ -0,0 +1,104 @@ +/* -*- c++ -*- ---------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + http://lammps.sandia.gov, Sandia National Laboratories + Steve Plimpton, sjplimp@sandia.gov + + Copyright (2003) Sandia Corporation. Under the terms of Contract + DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains + certain rights in this software. This software is distributed under + the GNU General Public License. + + See the README file in the top-level LAMMPS directory. +------------------------------------------------------------------------- */ + +#ifdef ATOM_CLASS + +AtomStyle(full/hars,AtomVecFullHars) + +#else + +#ifndef LMP_ATOM_VEC_FULL_HARS_H +#define LMP_ATOM_VEC_FULL_HARS_H + +#include "atom_vec.h" + +namespace LAMMPS_NS { + +class AtomVecFullHars : public AtomVec { + public: + AtomVecFullHars(class LAMMPS *); + virtual ~AtomVecFullHars() {} + void grow(int); + void grow_reset(); + void copy(int, int, int); + virtual int pack_comm(int, int *, double *, int, int *); + virtual int pack_comm_vel(int, int *, double *, int, int *); + virtual void unpack_comm(int, int, double *); + virtual void unpack_comm_vel(int, int, double *); + int pack_reverse(int, int, double *); + void unpack_reverse(int, int *, double *); + virtual int pack_border(int, int *, double *, int, int *); + virtual int pack_border_vel(int, int *, double *, int, int *); + int pack_border_hybrid(int, int *, double *); + virtual void unpack_border(int, int, double *); + virtual void unpack_border_vel(int, int, double *); + int unpack_border_hybrid(int, int, double *); + virtual int pack_exchange(int, double *); + virtual int unpack_exchange(double *); + int size_restart(); + int pack_restart(int, double *); + int unpack_restart(double *); + void create_atom(int, double *); + void data_atom(double *, imageint, char **); + int data_atom_hybrid(int, char **); + void pack_data(double **); + int pack_data_hybrid(int, double *); + void write_data(FILE *, int, double **); + int write_data_hybrid(FILE *, double *); + bigint memory_usage(); + + protected: + tagint *tag; + int *type,*mask; + imageint *image; + double **x,**v,**f; + double *q; + double *lambdaH; + double **gradlambdaH; + int *replambdaH; + int *moltypeH; + double **comH; + tagint *molecule; + int **nspecial; + tagint **special; + int *num_bond; + int **bond_type; + tagint **bond_atom; + int *num_angle; + int **angle_type; + tagint **angle_atom1,**angle_atom2,**angle_atom3; + int *num_dihedral; + int **dihedral_type; + tagint **dihedral_atom1,**dihedral_atom2,**dihedral_atom3,**dihedral_atom4; + int *num_improper; + int **improper_type; + tagint **improper_atom1,**improper_atom2,**improper_atom3,**improper_atom4; +}; + +} + +#endif +#endif + +/* ERROR/WARNING messages: + +E: Per-processor system is too big + +The number of owned atoms plus ghost atoms on a single +processor must fit in 32-bit integer. + +E: Invalid atom type in Atoms section of data file + +Atom types must range from 1 to specified # of types. + +*/ diff --git a/src/USER-HADRESS/fix_lambdah_calc.cpp b/src/USER-HADRESS/fix_lambdah_calc.cpp new file mode 100644 index 0000000000..101f3ff830 --- /dev/null +++ b/src/USER-HADRESS/fix_lambdah_calc.cpp @@ -0,0 +1,958 @@ +/* ---------------------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + http://lammps.sandia.gov, Sandia National Laboratories + Steve Plimpton, sjplimp@sandia.gov + + Copyright (2003) Sandia Corporation. Under the terms of Contract + DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains + certain rights in this software. This software is distributed under + the GNU General Public License. + + See the README file in the top-level LAMMPS directory. +------------------------------------------------------------------------- */ + +/* ---------------------------------------------------------------------- + Contributing author: Maziar Heidari (Max Planck Institute for Polymer Research) +------------------------------------------------------------------------- */ + +#include "math.h" +#include "string.h" +#include "stdlib.h" +#include "fix_lambdah_calc.h" +#include "atom.h" +#include "input.h" +#include "variable.h" +#include "domain.h" +#include "lattice.h" +#include "update.h" +#include "modify.h" +#include "output.h" +#include "respa.h" +#include "error.h" +#include "force.h" +#include "math_const.h" +#include "memory.h" +#include "comm.h" +#include "citeme.h" + + +using namespace LAMMPS_NS; +using namespace FixConst; +using namespace MathConst; + +#define BIG MAXTAGINT + +static const char cite_HAdResS[] = + "@Article{Heidari et al.2016\n" + " author = {M. Heidari, R. Cortes-Huerto, D. Donadio and R. Potestio},\n" + " title = {Accurate and general treatment of electrostatic interaction in Hamiltonian adaptive resolution simulations},\n" + " journal = {Eur. Phys. J. Special Topics},\n" + " year = 2016,\n" + " volume = Submitted,\n" + " pages = {}\n" + "}\n\n"; + + +/* ---------------------------------------------------------------------- */ + +FixLambdaHCalc::FixLambdaHCalc(LAMMPS *lmp, int narg, char **arg) : + Fix(lmp, narg, arg) +{ + + + if (lmp->citeme) lmp->citeme->add(cite_HAdResS); + + massproc_H = NULL; + masstotal_H = NULL; + com_H = NULL; + comall_H = NULL; + molmap_H = NULL; + lambdaCM = NULL; + gradlambdaCM = NULL; + Comp_Density_Num_H = NULL; + Comp_Density_Num_all_H = NULL; + Mean_Density_H = NULL; + Int_Mean_Density_H = NULL; + Mean_Comp_Density_Conv_H = NULL; + grad_Comp_Density_Conv_H = NULL; + Mean_grad_Comp_Density_Conv_H = NULL; + + + + me = comm->me; + + if (narg < 8) error->all(FLERR,"Illegal fix lambdah/calc command"); + + atom->nmoltypesH = force->numeric(FLERR,arg[3]); + Length_Hyb = force->numeric(FLERR,arg[4]); + Length_ATRegion = force->numeric(FLERR,arg[5]); + Pressure_Comp_Flag = force->numeric(FLERR,arg[6]); + Pressure_lambda_Increment = force->numeric(FLERR,arg[7]); + Pressure_Update_Frequency = force->numeric(FLERR,arg[8]); + Pressure_Update_Time_Begin = force->numeric(FLERR,arg[9]); + Pressure_Update_Time_End = force->numeric(FLERR,arg[10]); + + if (strcmp(arg[11],"slab") == 0) Hybrid_Style = 0; + else if (strcmp(arg[11],"sphere") == 0) Hybrid_Style = 1; + else if (strcmp(arg[11],"cylinder") == 0) Hybrid_Style = 2; + else error->all(FLERR,"Illegal fix lambdah/calc command"); + + Density_Comp_Flag = force->numeric(FLERR,arg[12]); + Density_Bin_Size = force->numeric(FLERR,arg[13]); + Density_Update_Frequency = force->numeric(FLERR,arg[14]); + Density_Update_Time_Begin = force->numeric(FLERR,arg[15]); + Density_Update_Time_End = force->numeric(FLERR,arg[16]); + Density_Sigma_Gauss = force->numeric(FLERR,arg[17]); + Density_Gauss_Int_Range = force->numeric(FLERR,arg[18]); + Density_Ref = force->numeric(FLERR,arg[19]); + Comp_Density_Scaling_factor_H = force->numeric(FLERR,arg[20]); + Load_File_Flag = force->numeric(FLERR,arg[21]); + + x0lo = domain->boxlo[0]; + x0hi = domain->boxhi[0]; + x1lo = domain->boxlo[1]; + x1hi = domain->boxhi[1]; + x2lo = domain->boxlo[2]; + x2hi = domain->boxhi[2]; + + center_box[0] = (x0hi + x0lo)/2.0; + center_box[1] = (x1hi + x1lo)/2.0; + center_box[2] = (x2hi + x2lo)/2.0; + + + x0BoxSize = x0hi - x0lo; + Length_CGRegion = x0BoxSize - 2*Length_Hyb - Length_ATRegion; + R_Start_Hybrid_1 = x0lo + Length_CGRegion/2.0; + R_Start_Hybrid_2 = x0lo + x0BoxSize - (Length_CGRegion/2.0 + Length_Hyb); + S_Start_Hybrid = Length_ATRegion; + Pressure_Bin_Num = 1.0 / Pressure_lambda_Increment; + xmin_AT = R_Start_Hybrid_1 + Length_Hyb; + xmax_AT= R_Start_Hybrid_1 + Length_Hyb + Length_ATRegion; + if(Hybrid_Style==0)Density_Bin_Num = floor(x0BoxSize / Density_Bin_Size); + else if(Hybrid_Style==1)Density_Bin_Num = floor(sqrt(pow(0.5*(x0hi-x0lo),2.0)+pow(0.5*(x1hi-x1lo),2.0)+pow(0.5*(x2hi-x2lo),2.0)) / Density_Bin_Size); + else if(Hybrid_Style==2)Density_Bin_Num = floor(sqrt(pow(0.5*(x0hi-x0lo),2.0)+pow(0.5*(x1hi-x1lo),2.0)) / Density_Bin_Size); + + + Comp_Counter_H = 0; + Density_Counter_H = 0; + Density_Compensation_Run = 0; + + memory->create(Comp_Density_Num_H,Density_Bin_Num,atom->nmoltypesH+1,"lambdaH/calc:Comp_Density_Num_H"); + memory->create(Comp_Density_Num_all_H,Density_Bin_Num,atom->nmoltypesH+1,"lambdaH/calc:Comp_Density_Num_all_H"); + + if(me==0){ + if (screen){ + fprintf(screen,"nmoltypes= %d\n",atom->nmoltypesH); + fprintf(screen,"Length_Hyb= %f\n",Length_Hyb); + fprintf(screen,"Length_ATRegion= %f\n",Length_ATRegion); + fprintf(screen,"Pressure_Comp_Flag= %d\n",Pressure_Comp_Flag); + fprintf(screen,"Pressure_lambda_Increment= %f\n",Pressure_lambda_Increment); + fprintf(screen,"Pressure_Update_Frequency= %d\n",Pressure_Update_Frequency); + fprintf(screen,"Pressure_Update_Time_Begin= %d\n",Pressure_Update_Time_Begin); + fprintf(screen,"Pressure_Update_Time_End= %d\n",Pressure_Update_Time_End); + fprintf(screen,"Density_Comp_Flag= %d\n",Density_Comp_Flag); + fprintf(screen,"Density_Bin_Size= %f\n",Density_Bin_Size); + fprintf(screen,"Density_Update_Frequency= %d\n",Density_Update_Frequency); + fprintf(screen,"Density_Update_Time_Begin= %d\n",Density_Update_Time_Begin); + fprintf(screen,"Density_Update_Time_End= %d\n",Density_Update_Time_End); + fprintf(screen,"Density_Sigma_Gauss= %f\n",Density_Sigma_Gauss); + fprintf(screen,"Density_Gauss_Int_Range= %d\n",Density_Gauss_Int_Range); + fprintf(screen,"Density_Ref= %f\n",Density_Ref); + fprintf(screen,"Comp_Density_Scaling_factor_H = %f\n",Comp_Density_Scaling_factor_H); + fprintf(screen,"Load_File_Flag = %d\n",Load_File_Flag); + fprintf(screen,"Center_box = %f %f %f\n",center_box[0],center_box[1],center_box[2]); + fprintf(screen,"Density_Bin_Size = %f\n",Density_Bin_Size); + fprintf(screen,"Density_Bin_Num = %d\n",Density_Bin_Num); + fprintf(screen,"x0lo= %f\n",x0lo); + fprintf(screen,"x0hi= %f\n",x0hi); + fprintf(screen,"x0BoxSize= %f\n",x0BoxSize); + fprintf(screen,"d1= %f\n",R_Start_Hybrid_1); + fprintf(screen,"d2= %f\n",R_Start_Hybrid_2); + fprintf(screen,"moltype%d\n",atom->nmoltypesH); + + } + if (logfile){ + fprintf(logfile,"nmoltypes= %d\n",atom->nmoltypesH); + fprintf(logfile,"Length_Hyb= %f\n",Length_Hyb); + fprintf(logfile,"Length_ATRegion= %f\n",Length_ATRegion); + fprintf(logfile,"Pressure_Comp_Flag= %d\n",Pressure_Comp_Flag); + fprintf(logfile,"Pressure_lambda_Increment= %f\n",Pressure_lambda_Increment); + fprintf(logfile,"Pressure_Update_Frequency= %d\n",Pressure_Update_Frequency); + fprintf(logfile,"Pressure_Update_Time_Begin= %d\n",Pressure_Update_Time_Begin); + fprintf(logfile,"Pressure_Update_Time_End= %d\n",Pressure_Update_Time_End); + fprintf(logfile,"Density_Comp_Flag= %d\n",Density_Comp_Flag); + fprintf(logfile,"Density_Bin_Size= %f\n",Density_Bin_Size); + fprintf(logfile,"Density_Update_Frequency= %d\n",Density_Update_Frequency); + fprintf(logfile,"Density_Update_Time_Begin= %d\n",Density_Update_Time_Begin); + fprintf(logfile,"Density_Update_Time_End= %d\n",Density_Update_Time_End); + fprintf(logfile,"Density_Sigma_Gauss= %f\n",Density_Sigma_Gauss); + fprintf(logfile,"Density_Gauss_Int_Range= %d\n",Density_Gauss_Int_Range); + fprintf(logfile,"Density_Ref= %f\n",Density_Ref); + fprintf(logfile,"Comp_Density_Scaling_factor_H = %f\n",Comp_Density_Scaling_factor_H); + fprintf(logfile,"Load_File_Flag = %d\n",Load_File_Flag); + fprintf(logfile,"Center_box = %f %f %f\n",center_box[0],center_box[1],center_box[2]); + fprintf(logfile,"Density_Bin_Size = %f\n",Density_Bin_Size); + fprintf(logfile,"Density_Bin_Num = %d\n",Density_Bin_Num); + fprintf(logfile,"x0lo= %f\n",x0lo); + fprintf(logfile,"x0hi= %f\n",x0hi); + fprintf(logfile,"x0BoxSize= %f\n",x0BoxSize); + fprintf(logfile,"d1= %f\n",R_Start_Hybrid_1); + fprintf(logfile,"d2= %f\n",R_Start_Hybrid_2); + fprintf(logfile,"moltype%d\n",atom->nmoltypesH); + + } + } + + memory->create(Int_Mean_Density_H,Density_Bin_Num,atom->nmoltypesH+1,"lambdaH/calc:Int_Mean_Density_H"); + memory->create(Mean_Density_H,Density_Bin_Num,atom->nmoltypesH+1,"lambdaH/calc:Mean_Density_H"); + memory->create(Mean_Comp_Density_Conv_H,Density_Bin_Num,atom->nmoltypesH+1,"lambdaH/calc:Mean_Comp_Density_Conv_H"); + memory->create(grad_Comp_Density_Conv_H,Density_Bin_Num,atom->nmoltypesH+1,"lambdaH/calc:grad_Comp_Density_Conv_H"); + memory->create(Mean_grad_Comp_Density_Conv_H,Density_Bin_Num,atom->nmoltypesH+1,"lambdaH/calc:Mean_grad_Comp_Density_Conv_H"); + + + int This_Step = update->ntimestep; + + for(int i = 0;i < Density_Bin_Num; i++){ + for(int j = 0; j < atom->nmoltypesH; j++){ + Comp_Density_Num_H[i][j] = 0; + Comp_Density_Num_all_H[i][j] = 0; + Int_Mean_Density_H[i][j] = 0; + Mean_Density_H[i][j] = 0; + Mean_Comp_Density_Conv_H[i][j] = 0; + Mean_grad_Comp_Density_Conv_H[i][j] = 0; + grad_Comp_Density_Conv_H[i][j] = 0; + } + } + + if((This_Step >= Density_Update_Time_End || Load_File_Flag) && Density_Comp_Flag != 0)Load_Compensation_Density(); + + if (atom->molecular == 0) + error->all(FLERR,"Compute com/molecule requires molecular atom style"); + + array_flag = 1; + size_array_cols = 3; + extarray = 0; + // setup molecule-based data + nmolecules = molecules_in_group(idlo,idhi); + size_array_rows = nmolecules; + + //printf("Nmolecules= %d\n",nmolecules); + + memory->create(massproc_H,nmolecules,"lambdaH/calc:massproc_H"); + memory->create(masstotal_H,nmolecules,"lambdaH/calc:masstotal_H"); + memory->create(com_H,nmolecules,3,"lambdaH/calc:com_H"); + memory->create(comall_H,nmolecules,3,"lambdaH/calc:comall_H"); + memory->create(lambdaCM,nmolecules,"lambdaH/calc:lambdaCM"); + memory->create(gradlambdaCM,nmolecules,3,"lambdaH/calc:gradlambdaCM"); + + // compute masstotal for each molecule + + int *mask = atom->mask; + tagint *molecule = atom->molecule; + int *type = atom->type; + double *mass = atom->mass; + double *rmass = atom->rmass; + int nlocal = atom->nlocal; + tagint imol; + double massone; + + for (int i = 0; i < nmolecules; i++) massproc_H[i] = 0.0; + + for (int i = 0; i < nlocal; i++) + { + if (mask[i] & groupbit) { + if (rmass) massone = rmass[i]; + else massone = mass[type[i]]; + imol = molecule[i]; + if (molmap_H) imol = molmap_H[imol-idlo]; + else imol--; + massproc_H[imol] += massone; + } +} + + MPI_Allreduce(massproc_H,masstotal_H,nmolecules,MPI_DOUBLE,MPI_SUM,world); + int *replambdaH = atom->replambdaH; + int pass = 0; + for (int i = 0; i < nlocal; i++) if(replambdaH[i] != 0)pass=1; + if(pass==0) error->all(FLERR,"No representative atom (replambdaH) has been defined!"); + +} + +/* ---------------------------------------------------------------------- */ + +FixLambdaHCalc::~FixLambdaHCalc() +{ + + memory->destroy(massproc_H); + memory->destroy(masstotal_H); + memory->destroy(com_H); + memory->destroy(comall_H); + memory->destroy(molmap_H); + memory->destroy(lambdaCM); + memory->destroy(gradlambdaCM); + memory->destroy(Comp_Density_Num_H); + memory->destroy(Comp_Density_Num_all_H); + memory->destroy(Mean_Density_H); + memory->destroy(Int_Mean_Density_H); + memory->destroy(Mean_Comp_Density_Conv_H); + memory->destroy(grad_Comp_Density_Conv_H); + memory->destroy(Mean_grad_Comp_Density_Conv_H); +} + +/* ---------------------------------------------------------------------- */ + +int FixLambdaHCalc::setmask() +{ + int mask = 0; + //mask |= PRE_FORCE; +// mask |= PRE_NEIGHBOR; + mask |= POST_INTEGRATE; + mask |= THERMO_ENERGY; +// mask |= POST_FORCE_RESPA; + mask |= MIN_PRE_FORCE; + return mask; +} + +/* ---------------------------------------------------------------------- */ + +void FixLambdaHCalc::init() +{ + int ntmp = molecules_in_group(idlo,idhi); + if (ntmp != nmolecules) + error->all(FLERR,"Molecule count changed in compute com/molecule"); + + + +} + +/* ---------------------------------------------------------------------- */ + +void FixLambdaHCalc::setup(int vflag) +{ + +// if (strstr(update->integrate_style,"verlet")) + //pre_force(vflag); + post_integrate(); +// else { +// ((Respa *) update->integrate)->copy_flevel_f(nlevels_respa-1); +// post_force_respa(vflag,nlevels_respa-1,0); + // ((Respa *) update->integrate)->copy_f_flevel(nlevels_respa-1); + // } +} + +/* ---------------------------------------------------------------------- */ + + +void FixLambdaHCalc::post_integrate() +{ + + tagint imol; + double massone; + double unwrap[3]; + + + //invoked_array = update->ntimestep; + for (int i = 0; i < nmolecules; i++) + com_H[i][0] = com_H[i][1] = com_H[i][2] = 0.0; + + double **x = atom->x; + int *mask = atom->mask; + tagint *molecule = atom->molecule; + int *type = atom->type; + imageint *image = atom->image; + double *mass = atom->mass; + double *rmass = atom->rmass; + int nlocal = atom->nlocal; + + double *lambdaH = atom->lambdaH; + double **gradlambdaH = atom->gradlambdaH; + double **comH = atom->comH; + + int This_Step = update->ntimestep; + if(This_Step >= Density_Update_Time_Begin && This_Step < Density_Update_Time_End && Density_Comp_Flag == 1){ + Density_Compensation_Run = 1; + if(me==0 && This_Step == Density_Update_Time_Begin){ + if(screen)fprintf(screen,"\nStart of constant-density route\n"); + if(logfile)fprintf(logfile,"\nStart of constant-density route\n"); + Clear_File_Compensation_Density(); + } + } + + + for (int i = 0; i < nlocal; i++) + if (mask[i] & groupbit) { + + if (rmass) massone = rmass[i]; + else massone = mass[type[i]]; + imol = molecule[i]; + if (molmap_H) imol = molmap_H[imol-idlo]; + else imol--; + domain->unmap(x[i],image[i],unwrap); + massone /= masstotal_H[imol]; + + com_H[imol][0] += unwrap[0] * massone; + com_H[imol][1] += unwrap[1] * massone; + com_H[imol][2] += unwrap[2] * massone; + } + + + MPI_Allreduce(&com_H[0][0],&comall_H[0][0],3*nmolecules,MPI_DOUBLE,MPI_SUM,world); + + + double xtmp,ytmp,ztmp; + double delx,dely,delz; + double Grad_Factor; + double rdiff; + + for (int i = 0; i < nmolecules; i++){ + + + domain->remap(comall_H[i]); + + if(Hybrid_Style==0){ + xtmp = comall_H[i][0]; + + if(xtmp < R_Start_Hybrid_1){ + lambdaCM[i] = 0.0; + gradlambdaCM[i][0] = 0.0; + gradlambdaCM[i][1] = 0.0; + gradlambdaCM[i][2] = 0.0; + + } + else if(xtmp >= R_Start_Hybrid_1 && xtmp < R_Start_Hybrid_1+Length_Hyb){ + cosx=cos(MY_PI*(xtmp-R_Start_Hybrid_1+Length_Hyb)/(2.0*Length_Hyb)); + sinx=sin(MY_PI*(xtmp-R_Start_Hybrid_1+Length_Hyb)/(2.0*Length_Hyb)); + lambdaCM[i] = cosx * cosx; + gradlambdaCM[i][0] = -(MY_PI/Length_Hyb) * sinx * cosx; + gradlambdaCM[i][1] = 0.0; + gradlambdaCM[i][2] = 0.0; + + } + else if(xtmp >=R_Start_Hybrid_1+Length_Hyb && xtmp < R_Start_Hybrid_2){ + lambdaCM[i] = 1.0; + gradlambdaCM[i][0] = 0.0; + gradlambdaCM[i][1] = 0.0; + gradlambdaCM[i][2] = 0.0; + + } + else if(xtmp >= R_Start_Hybrid_2 && xtmp < R_Start_Hybrid_2+Length_Hyb){ + cosx = cos(MY_PI*(xtmp-R_Start_Hybrid_2)/(2.0*Length_Hyb)); + sinx = sin(MY_PI*(xtmp-R_Start_Hybrid_2)/(2.0*Length_Hyb)); + lambdaCM[i] = cosx * cosx; + gradlambdaCM[i][0] = -(MY_PI/Length_Hyb) * sinx * cosx; + gradlambdaCM[i][1] = 0.0; + gradlambdaCM[i][2] = 0.0; + + } + else if(xtmp >=R_Start_Hybrid_2+Length_Hyb){ + lambdaCM[i] = 0.0; + gradlambdaCM[i][0] = 0.0; + gradlambdaCM[i][1] = 0.0; + gradlambdaCM[i][2] = 0.0; + + } + } + + else if(Hybrid_Style==1){ + xtmp = comall_H[i][0]; + ytmp = comall_H[i][1]; + ztmp = comall_H[i][2]; + + delx = (xtmp-center_box[0]); + dely = (ytmp-center_box[1]); + delz = (ztmp-center_box[2]); + + r = sqrt(delx*delx+dely*dely+delz*delz); + + if(r < S_Start_Hybrid){ + lambdaCM[i] = 1.0; + gradlambdaCM[i][0] = 0.0; + gradlambdaCM[i][1] = 0.0; + gradlambdaCM[i][2] = 0.0; + } + else if(r >= S_Start_Hybrid && r < S_Start_Hybrid+Length_Hyb) { + rdiff = MY_PI*(r-S_Start_Hybrid)/(2.0*Length_Hyb); + cosr=cos(rdiff); + sinr=sin(rdiff); + lambdaCM[i] = cosr * cosr; + Grad_Factor = -MY_PI * sinr * cosr / (Length_Hyb * r); + gradlambdaCM[i][0] = Grad_Factor * delx; + gradlambdaCM[i][1] = Grad_Factor * dely; + gradlambdaCM[i][2] = Grad_Factor * delz; + } + else if(r >= S_Start_Hybrid+Length_Hyb){ + lambdaCM[i] = 0.0; + gradlambdaCM[i][0] = 0.0; + gradlambdaCM[i][1] = 0.0; + gradlambdaCM[i][2] = 0.0; + } + } + + else if(Hybrid_Style==2){ + + xtmp = comall_H[i][0]; + ytmp = comall_H[i][1]; + + delx = (xtmp-center_box[0]); + dely = (ytmp-center_box[1]); + + r = sqrt(delx*delx+dely*dely); + + if(r < S_Start_Hybrid){ + lambdaCM[i] = 1.0; + gradlambdaCM[i][0] = 0.0; + gradlambdaCM[i][1] = 0.0; + gradlambdaCM[i][2] = 0.0; + } + else if(r >= S_Start_Hybrid && r < S_Start_Hybrid+Length_Hyb) { + rdiff = MY_PI*(r-S_Start_Hybrid)/(2.0*Length_Hyb); + cosr=cos(rdiff); + sinr=sin(rdiff); + lambdaCM[i] = cosr * cosr; + Grad_Factor = -MY_PI * sinr * cosr / (Length_Hyb * r); + + gradlambdaCM[i][0] = Grad_Factor * delx; + gradlambdaCM[i][1] = Grad_Factor * dely; + gradlambdaCM[i][2] = 0.0; + } + else if(r >= S_Start_Hybrid+Length_Hyb){ + lambdaCM[i] = 0.0; + gradlambdaCM[i][0] = 0.0; + gradlambdaCM[i][1] = 0.0; + gradlambdaCM[i][2] = 0.0; + } + } + + +} + + int ibin,imoltypeH; + int *moltypeH = atom->moltypeH; + + for (int i = 0; i < nlocal; i++) + if (mask[i] & groupbit) + { + imol = molecule[i]; + imoltypeH = moltypeH[i]; + if (molmap_H) imol = molmap_H[imol-idlo]; + else imol--; + lambdaH[i] = lambdaCM[imol]; + gradlambdaH[i][0] = gradlambdaCM[imol][0]; + gradlambdaH[i][1] = gradlambdaCM[imol][1]; + gradlambdaH[i][2] = gradlambdaCM[imol][2]; +// if(gradlambdaH[i][2]!=0) printf("gradlambdaH[i][2] = %f\n",gradlambdaH[i][2]); + +// gradlambdaH[i][2] = 0.0; + //gradlambdaH[i] = 0; +// if(replambdaH[i] == 1){ + comH[i][0] = comall_H[imol][0]; + comH[i][1] = comall_H[imol][1]; + comH[i][2] = comall_H[imol][2]; +// } + + if(Density_Comp_Flag != 0 && Density_Compensation_Run != 0){ + + if(Hybrid_Style==0){ +// xtmp = comall_H[imol][0]-x0lo; + xtmp = comH[i][0]-x0lo; +// if(xtmp <= 0.5*x0BoxSize)ibin = floor(xtmp/Density_Bin_Size); +// else ibin = floor((x0BoxSize-xtmp)/Density_Bin_Size); + + ibin = floor(xtmp/Density_Bin_Size); + + } + + else if(Hybrid_Style==1){ + xtmp = comall_H[imol][0]; + ytmp = comall_H[imol][1]; + ztmp = comall_H[imol][2]; + + delx = (xtmp-center_box[0]); + dely = (ytmp-center_box[1]); + delz = (ztmp-center_box[2]); + + r = sqrt(delx*delx+dely*dely+delz*delz); + ibin = floor(r/Density_Bin_Size); + } + + else if(Hybrid_Style==2){ + + xtmp = comall_H[imol][0]; + ytmp = comall_H[imol][1]; + + delx = (xtmp-center_box[0]); + dely = (ytmp-center_box[1]); + + r = sqrt(delx*delx+dely*dely); + ibin = floor(r/Density_Bin_Size); + } + + if(ibin>=Density_Bin_Num)ibin = Density_Bin_Num - 1; + Comp_Density_Num_H[ibin][imoltypeH-1]++; + + } + + } + + +// int Middle_Bin_Num = (Density_Bin_Num-1) / 2; + +// if(Hybrid_Style == 0)for(int i = Middle_Bin_Num+1;i < Density_Bin_Num; i++)Comp_Density_Num_H[i] = Comp_Density_Num_H[Density_Bin_Num-1-i]; + if(Density_Compensation_Run)Density_Counter_H++; + + double Density_Bin_Vol, exponent; + double Normalization; + int jmin, jmax,jj; + if(This_Step % Density_Update_Frequency == 0 && This_Step > Density_Update_Time_Begin && Density_Comp_Flag != 0 && Density_Compensation_Run != 0){ + + // if(atom->nmoltypesH ==1) MPI_Allreduce(&Comp_Density_Num_H[0][0],&Comp_Density_Num_all_H[0][0],Density_Bin_Num,MPI_INT,MPI_SUM,world); + MPI_Allreduce(&Comp_Density_Num_H[0][0],&Comp_Density_Num_all_H[0][0],Density_Bin_Num*(atom->nmoltypesH+1),MPI_INT,MPI_SUM,world); + + if(Hybrid_Style == 0)Density_Bin_Vol = 1.0*Density_Bin_Size * (x1hi-x1lo) * (x2hi-x2lo); + + for(int i = 0; i < Density_Bin_Num; i++){ + if(Hybrid_Style == 1)Density_Bin_Vol = (4.0/3.0) * MY_PI * (pow(((i+1) * Density_Bin_Size),3.0) - pow((i * Density_Bin_Size),3.0)); + if(Hybrid_Style == 2)Density_Bin_Vol = 4.0 * MY_PI * (x2hi-x2lo) * (pow(((i+1) * Density_Bin_Size),2.0) - pow((i * Density_Bin_Size),2.0)); + for(int j = 0; j < atom->nmoltypesH; j++){ + Mean_Density_H[i][j] = Comp_Density_Num_all_H[i][j] / (Density_Counter_H * Density_Bin_Vol); + } + } + + Density_Counter_H = 0; + + for(int k = 0; k < atom->nmoltypesH;k++){ + for(int i = 0;i < Density_Bin_Num; i++){ + Normalization = 0; + jmin = i - Density_Gauss_Int_Range*floor(Density_Sigma_Gauss / Density_Bin_Size); + jmax = i + Density_Gauss_Int_Range*floor(Density_Sigma_Gauss / Density_Bin_Size); + Mean_Comp_Density_Conv_H[i][k] = 0; + if(Hybrid_Style != 0){ + if(jmin<0)jmin=0; + if(jmax>=Density_Bin_Num)jmax=Density_Bin_Num-1; + } + + for(int j = jmin;j <= jmax; j++){ + jj = j; + if(Hybrid_Style == 0){ + if(j < 0)jj = Density_Bin_Num + j; + if(j >= Density_Bin_Num)jj = j - Density_Bin_Num; + } + exponent = (i-j)*Density_Bin_Size/Density_Sigma_Gauss; + exponent = pow(exponent,2.0); + Normalization += exp(-exponent)*Density_Bin_Size; + Mean_Comp_Density_Conv_H[i][k] += Mean_Density_H[jj][k] * exp(-exponent)*Density_Bin_Size; + // Mean_Comp_Density_Conv_H[i] += Mean_Density_H[j] * exp(-exponent); + } + Mean_Comp_Density_Conv_H[i][k] /= Normalization; + + } + } + + Density_Fluctuation = 0; + for(int k = 0; k < atom->nmoltypesH;k++)for(int i = 0;i < Density_Bin_Num; i++)Density_Fluctuation += (Density_Bin_Size/x0BoxSize)*pow((Mean_Density_H[i][k]-Density_Ref)/Density_Ref,2.0); + for(int k = 0; k < atom->nmoltypesH;k++) + for(int i = 1;i < Density_Bin_Num-1; i++) + grad_Comp_Density_Conv_H[i][k] = Comp_Density_Scaling_factor_H * (Mean_Comp_Density_Conv_H[i+1][k] - Mean_Comp_Density_Conv_H[i-1][k])/(2*Density_Bin_Size*Density_Ref); + + + //for(int i = 1;i < Density_Bin_Num-1; i++)Mean_grad_Comp_Density_Conv_H[i] = (Comp_Counter_H * Mean_grad_Comp_Density_Conv_H[i] + grad_Comp_Density_Conv_H[i]) / (Comp_Counter_H + 1); + for(int k = 0; k < atom->nmoltypesH;k++) + for(int i = 1;i < Density_Bin_Num-1; i++) + Mean_grad_Comp_Density_Conv_H[i][k] += grad_Comp_Density_Conv_H[i][k]; + +// for(int i = Middle_Bin_Num+1;i < Density_Bin_Num; i++)Comp_Density_Num_H[i] = Comp_Density_Num_H[Density_Bin_Num-1-i]; + + for(int k = 0; k < atom->nmoltypesH;k++) + for(int i = 0;i < Density_Bin_Num; i++) + Int_Mean_Density_H[i][k]=0; + + for(int k = 0; k < atom->nmoltypesH;k++) + for(int i = 0;i < Density_Bin_Num; i++) + for(int j = 0;j <= i; j++) + Int_Mean_Density_H[i][k] += Mean_grad_Comp_Density_Conv_H[j][k] * Density_Bin_Size; + + Comp_Counter_H += 1; + + for(int k = 0; k < atom->nmoltypesH;k++) + for(int i = 0;i < Density_Bin_Num; i++){ + Comp_Density_Num_H[i][k] = 0; + Comp_Density_Num_all_H[i][k] = 0; + } + + + } + + if(This_Step == Density_Update_Time_End && Density_Compensation_Run != 0){ + Density_Compensation_Run = 0; + if(me==0){ + if(screen)fprintf(screen,"\nEnd of constant-density route\n"); + if(logfile)fprintf(logfile,"\nEnd of constant-density route\n"); + } + } + + if (me == 0 && This_Step % Density_Update_Frequency == 0 && Density_Compensation_Run != 0) Print_Compensation_Density(); + +} + + +double FixLambdaHCalc::memory_usage() +{ + double bytes = (bigint) nmolecules * 2 * sizeof(double); + if (molmap_H) bytes += (idhi-idlo+1) * sizeof(int); + bytes += (bigint) nmolecules * 2*3 * sizeof(double); + bytes += (bigint) nmolecules * 2*3 * sizeof(double); + return bytes; +} + +/* ---------------------------------------------------------------------- */ + + +int FixLambdaHCalc::molecules_in_group(tagint &idlo, tagint &idhi) +{ + int i; + + memory->destroy(molmap_H); + molmap_H = NULL; + + // find lo/hi molecule ID for any atom in group + // warn if atom in group has ID = 0 + + tagint *molecule = atom->molecule; + int *mask = atom->mask; + int nlocal = atom->nlocal; + + tagint lo = BIG; + tagint hi = -BIG; + int flag = 0; + for (i = 0; i < nlocal; i++) + { + if (mask[i] & groupbit) { + if (molecule[i] == 0) flag = 1; + lo = MIN(lo,molecule[i]); + hi = MAX(hi,molecule[i]); + } + } + + int flagall; + MPI_Allreduce(&flag,&flagall,1,MPI_INT,MPI_SUM,world); + if (flagall && comm->me == 0) + error->warning(FLERR,"Atom with molecule ID = 0 included in " + "compute molecule group"); + + MPI_Allreduce(&lo,&idlo,1,MPI_LMP_TAGINT,MPI_MIN,world); + MPI_Allreduce(&hi,&idhi,1,MPI_LMP_TAGINT,MPI_MAX,world); + if (idlo == BIG) return 0; + + // molmap = vector of length nlen + // set to 1 for IDs that appear in group across all procs, else 0 + + tagint nlen_tag = idhi-idlo+1; + if (nlen_tag > MAXSMALLINT) + error->all(FLERR,"Too many molecules for compute"); + int nlen = (int) nlen_tag; + + memory->create(molmap_H,nlen,"lambdaH/calc:molmap"); + for (i = 0; i < nlen; i++) molmap_H[i] = 0; + + for (i = 0; i < nlocal; i++) + if (mask[i] & groupbit) + molmap_H[molecule[i]-idlo] = 1; + + int *molmapall; + memory->create(molmapall,nlen,"compute:molmapall"); + MPI_Allreduce(molmap_H,molmapall,nlen,MPI_INT,MPI_MAX,world); + + // nmolecules = # of non-zero IDs in molmap + // molmap[i] = index of molecule, skipping molecules not in group with -1 + + int nmolecules = 0; + for (i = 0; i < nlen; i++) + if (molmapall[i]) molmap_H[i] = nmolecules++; + else molmap_H[i] = -1; + memory->destroy(molmapall); + + // warn if any molecule has some atoms in group and some not in group + + flag = 0; + for (i = 0; i < nlocal; i++) { + if (mask[i] & groupbit) continue; + if (molecule[i] < idlo || molecule[i] > idhi) continue; + if (molmap_H[molecule[i]-idlo] >= 0) flag = 1; + } + + MPI_Allreduce(&flag,&flagall,1,MPI_INT,MPI_SUM,world); + if (flagall && comm->me == 0) + error->warning(FLERR, + "One or more compute molecules has atoms not in group"); + + // if molmap simply stores 1 to Nmolecules, then free it + + if (idlo == 1 && idhi == nmolecules && nlen == nmolecules) { + memory->destroy(molmap_H); + molmap_H = NULL; + } + return nmolecules; +} + + +void FixLambdaHCalc::Print_Compensation_Density(){ + + + FILE *fp1; + fp1 = fopen("Mean_Comp_Density.txt","w"); + + if (fp1 == NULL) { + char str[128]; + sprintf(str,"Cannot open fix Mean_Comp_Density file %s","Mean_Comp_Density.txt"); + error->one(FLERR,str); + } + + + for(int i = 0;i < Density_Bin_Num; i++){ + fprintf(fp1,"%d",i+1); + for(int k = 0; k < atom->nmoltypesH;k++) + fprintf(fp1,"\t%.10f",Mean_grad_Comp_Density_Conv_H[i][k]); + fprintf(fp1,"\n"); + } + fclose(fp1); + + /* + FILE *fp2; + + char filename2[1000]; + sprintf(filename2, "Mean_Comp_Density%4.1f_%d.txt", Comp_Density_Scaling_factor_H,Density_Update_Frequency); + + fp2 = fopen(filename2,"a"); + + if (fp2 == NULL) { + char str[128]; + sprintf(str,"Cannot open fix Mean_Comp_Density file %s","Mean_Comp_Density.txt"); + error->one(FLERR,str); + } + + printf("Density_Fluctuation = %f\n",Density_Fluctuation); + + double x0; + if(Hybrid_Style==0)x0=x0lo; + else x0=0; + + for(int i = 0;i < Density_Bin_Num; i++){ + fprintf(fp2,"%d\t %.10f\t",i+1,i*Density_Bin_Size+x0); + for(int k = 0; k < atom->nmoltypesH;k++) + fprintf(fp2,"\t%.10f\t %.10f\t %.10f\t %.10f",Mean_Comp_Density_Conv_H[i][k],grad_Comp_Density_Conv_H[i][k],Mean_grad_Comp_Density_Conv_H[i][k]); + fprintf(fp2,"\n"); + + } + fclose(fp2); + + + FILE *fp3; + char filename3[1000]; + sprintf(filename3, "Density_Fluctuation%4.1f_%d.txt", Comp_Density_Scaling_factor_H,Density_Update_Frequency); + + fp3 = fopen(filename3,"a"); + + if (fp3 == NULL) { + char str[128]; + sprintf(str,"Cannot open fix Density_Fluctuation file %s","Density_Fluctuation.txt"); + error->one(FLERR,str); + } + + int This_Step = update->ntimestep; + fprintf(fp3,"%d %.10f\n",This_Step,Density_Fluctuation); + + fclose(fp3); + +*/ +} + +void FixLambdaHCalc::Clear_File_Compensation_Density(){ + + FILE *fp1; + fp1 = fopen("Mean_Comp_Density.txt","w"); + + if (fp1 == NULL) { + char str[128]; + sprintf(str,"Cannot open fix Mean_Comp_Density file %s","Mean_Comp_Density.txt"); + error->one(FLERR,str); + } + + + fclose(fp1); + + /* + FILE *fp2; + + char filename2[1000]; + sprintf(filename2, "Mean_Comp_Density%4.1f_%d.txt", Comp_Density_Scaling_factor_H,Density_Update_Frequency); + + fp2 = fopen(filename2,"w"); + + if (fp2 == NULL) { + char str[128]; + sprintf(str,"Cannot open fix Mean_Comp_Density file %s","Mean_Comp_Density.txt"); + error->one(FLERR,str); + } + + + fclose(fp2); + + FILE *fp3; + char filename3[1000]; + sprintf(filename3, "Density_Fluctuation%4.1f_%d.txt", Comp_Density_Scaling_factor_H,Density_Update_Frequency); + + fp3 = fopen(filename3,"w"); + + if (fp3 == NULL) { + char str[128]; + sprintf(str,"Cannot open fix Density_Fluctuation file %s","Density_Fluctuation.txt"); + error->one(FLERR,str); + } + + fclose(fp3); + */ + +} + +void FixLambdaHCalc::Load_Compensation_Density(){ + + if(me == 0){ + FILE *fp1; + char str[128]; + + fp1 = fopen("Mean_Comp_Density.txt","r"); + if (fp1 == NULL) { + sprintf(str,"Cannot open fix Mean_Comp_Density.txt file %s","Mean_Comp_Density.txt"); + error->one(FLERR,str); + } + + int i1; + float i2; + + while (!feof(fp1)){ + fscanf (fp1,"%d",&i1); + for(int k = 0; k < atom->nmoltypesH;k++){ + fscanf (fp1,"\t%f",&i2); + Mean_grad_Comp_Density_Conv_H[i1-1][k] = (double) i2; + } + fscanf (fp1,"\n"); + + if(i1 > Density_Bin_Num){ + sprintf(str,"Density bin number mismatches %d != %d",Density_Bin_Num,i1); + error->one(FLERR,str); + } + + } + + fclose(fp1); + + + if(me==0){ + if(screen)fprintf(screen,"\n\nDensity componsation forces distributed successfully!\n\n"); + if(logfile)fprintf(logfile,"\n\nDensity componsation forces distributed successfully!\n\n"); + } + } + + MPI_Bcast(Mean_grad_Comp_Density_Conv_H,Density_Bin_Num*(atom->nmoltypesH+1),MPI_DOUBLE,0,world); + +} diff --git a/src/USER-HADRESS/fix_lambdah_calc.h b/src/USER-HADRESS/fix_lambdah_calc.h new file mode 100644 index 0000000000..d3552e17f2 --- /dev/null +++ b/src/USER-HADRESS/fix_lambdah_calc.h @@ -0,0 +1,102 @@ +/* -*- c++ -*- ---------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + http://lammps.sandia.gov, Sandia National Laboratories + Steve Plimpton, sjplimp@sandia.gov + + Copyright (2003) Sandia Corporation. Under the terms of Contract + DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains + certain rights in this software. This software is distributed under + the GNU General Public License. + + See the README file in the top-level LAMMPS directory. +------------------------------------------------------------------------- */ + +#ifdef FIX_CLASS + +FixStyle(lambdah/calc,FixLambdaHCalc) + +#else + +#ifndef LMP_FIX_LAMBDAH_CALC_H +#define LMP_FIX_LAMBDAH_CALC_H + +#include "fix.h" + +namespace LAMMPS_NS { + +class FixLambdaHCalc : public Fix { + public: + FixLambdaHCalc(class LAMMPS *, int, char **); + ~FixLambdaHCalc(); + int setmask(); + void init(); + void setup(int); + + void post_integrate(); + double memory_usage(); + + + double Length_Hyb,Length_ATRegion,Length_CGRegion; + int Hybrid_Style; + int Pressure_Comp_Flag,Pressure_Bin_Num,Pressure_Update_Frequency,Pressure_Update_Time_End, Pressure_Update_Time_Begin; + double Pressure_lambda_Increment; + int Density_Comp_Flag,Density_Compensation_Run,Density_Bin_Num,Density_Update_Frequency,Density_Update_Time_End,Density_Update_Time_Begin; + double Density_Bin_Size; + int Comp_Counter_H,Density_Counter_H; + double **Mean_grad_Comp_Density_Conv_H; + + double Density_Ref; + double center_box[3]; + int me; + double x0lo,x0hi,x1lo,x1hi,x2lo,x2hi,x0BoxSize; + double Density_Sigma_Gauss; + double Comp_Density_Scaling_factor_H; + int Density_Gauss_Int_Range; + + double xmin_AT,xmax_AT; + private: + int nmolecules; + tagint idlo,idhi; + double *massproc_H,*masstotal_H; + double **com_H,**comall_H; + double Density_Fluctuation; + int **Comp_Density_Num_H, **Comp_Density_Num_all_H; + double **Int_Mean_Density_H, **Mean_Density_H, **grad_Comp_Density_Conv_H, **Mean_Comp_Density_Conv_H; + int Load_File_Flag; + double R_Start_Hybrid_1,R_Start_Hybrid_2,S_Start_Hybrid,r,cosr,sinr,sinx,cosx; + double *lambdaCM, **gradlambdaCM; + int *molmap_H; // convert molecule ID to local index + + int molecules_in_group(tagint &, tagint &); + + void Print_Compensation_Density(); + void Load_Compensation_Density(); + void Clear_File_Compensation_Density(); +}; + +} + +#endif +#endif + +/* ERROR/WARNING messages: + +E: Illegal ... command + +Self-explanatory. Check the input script syntax and compare to the +documentation for the command. You can use -echo screen as a +command-line option when running LAMMPS to see the offending line. + +E: Variable name for fix indent does not exist + +Self-explanatory. + +E: Variable for fix indent is invalid style + +Only equal-style variables can be used. + +E: Variable for fix indent is not equal style + +Only equal-style variables can be used. + +*/ diff --git a/src/USER-HADRESS/pair_lj_cut_coul_dsf_hars_at.cpp b/src/USER-HADRESS/pair_lj_cut_coul_dsf_hars_at.cpp new file mode 100644 index 0000000000..a29aeaf187 --- /dev/null +++ b/src/USER-HADRESS/pair_lj_cut_coul_dsf_hars_at.cpp @@ -0,0 +1,981 @@ +/* ---------------------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + http://lammps.sandia.gov, Sandia National Laboratories + Steve Plimpton, sjplimp@sandia.gov + + Copyright (2003) Sandia Corporation. Under the terms of Contract + DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains + certain rights in this software. This software is distributed under + the GNU General Public License. + + See the README file in the top-level LAMMPS directory. +------------------------------------------------------------------------- */ + +/* ---------------------------------------------------------------------- + Contributing author: Maziar Heidari, + Robinson Cortes-Huerto, + Davide Donadio and + Raffaello Potestio + (Max Planck Institute for Polymer Research, 2015-2016) +------------------------------------------------------------------------- */ + +#include "math.h" +#include "stdio.h" +#include "stdlib.h" +#include "string.h" +#include "pair_lj_cut_coul_dsf_hars_at.h" +#include "atom.h" +#include "comm.h" +#include "force.h" +#include "neighbor.h" +#include "neigh_list.h" +#include "memory.h" +#include "math_const.h" +#include "error.h" +#include "fix_lambdah_calc.h" +#include "update.h" + + +using namespace LAMMPS_NS; +using namespace MathConst; +#define BIG MAXTAGINT + + +#define EWALD_F 1.12837917 +#define EWALD_P 0.3275911 +#define A1 0.254829592 +#define A2 -0.284496736 +#define A3 1.421413741 +#define A4 -1.453152027 +#define A5 1.061405429 + +/* ---------------------------------------------------------------------- */ + +PairLJCutCoulDSFHARSAT::PairLJCutCoulDSFHARSAT(LAMMPS *lmp) : Pair(lmp) +{ + single_enable = 0; + + AT_molmap_H = NULL; + nmolecules = molecules_in_group(idlo,idhi); + + H_AdResS_allocated = 0; + + AT_Pressure_Compensation_Run = 0; + Comp_Counter_H = 0; + memory->create(AT_massproc_H,nmolecules,"pair:AT_massproc_H"); + memory->create(AT_masstotal_H,nmolecules,"pair:AT_masstotal_H"); + memory->create(AT_mol_f_H,nmolecules,3,"pair:AT_mol_f_H"); + memory->create(AT_mol_f_all_H,nmolecules,3,"pair:AT_mol_f_all_H"); + + + // compute masstotal for each molecule + MPI_Comm_rank(world, &me); + int *mask = atom->mask; + tagint *molecule = atom->molecule; + int *type = atom->type; + double *mass = atom->mass; + double *rmass = atom->rmass; + int nlocal = atom->nlocal; + + tagint imol; + double massone; + + for (int i = 0; i < nmolecules; i++) AT_massproc_H[i] = 0.0; + + + for (int i = 0; i < nlocal; i++) + { +// if (mask[i] & groupbit) { + if (mask[i]) { + if (rmass) massone = rmass[i]; + else massone = mass[type[i]]; + imol = molecule[i]; + if (AT_molmap_H) imol = AT_molmap_H[imol-idlo]; + else imol--; + AT_massproc_H[imol] += massone; + + } + } + + MPI_Allreduce(AT_massproc_H,AT_masstotal_H,nmolecules,MPI_DOUBLE,MPI_SUM,world); + +} + +/* ---------------------------------------------------------------------- */ + +PairLJCutCoulDSFHARSAT::~PairLJCutCoulDSFHARSAT() +{ + if (allocated) { + memory->destroy(setflag); + memory->destroy(cutsq); + + memory->destroy(cut_lj); + memory->destroy(cut_ljsq); + memory->destroy(epsilon); + memory->destroy(sigma); + memory->destroy(lj1); + memory->destroy(lj2); + memory->destroy(lj3); + memory->destroy(lj4); + memory->destroy(offset); + } +} + +/* ---------------------------------------------------------------------- */ + +void PairLJCutCoulDSFHARSAT::compute(int eflag, int vflag) +{ + int i,j,ii,jj,inum,jnum,itype,jtype; + double qtmp,xtmp,ytmp,ztmp,delx,dely,delz,evdwl,ecoul,fpair; + double r,rsq,r2inv,r6inv,forcecoul,forcelj,factor_coul,factor_lj,Vij_Coul,Vij_Lj;; + double prefactor,erfcc,erfcd,t; + int *ilist,*jlist,*numneigh,**firstneigh; + int imoltypeH,jmoltypeH; + + evdwl = ecoul = 0.0; + if (eflag || vflag) ev_setup(eflag,vflag); + else evflag = vflag_fdotr = 0; + + double **x = atom->x; + double **f = atom->f; + double *q = atom->q; + double *lambdaH = atom->lambdaH; + double **gradlambdaH = atom->gradlambdaH; + + int *type = atom->type; + int nlocal = atom->nlocal; + double *special_lj = force->special_lj; + double *special_coul = force->special_coul; + int newton_pair = force->newton_pair; + double qqrd2e = force->qqrd2e; + int imol,jmol; + tagint *molecule = atom->molecule; + double *mass = atom->mass; + int *replambdaH = atom->replambdaH; + int *moltypeH = atom->moltypeH; + + int ibin, jbin; + + inum = list->inum; + ilist = list->ilist; + numneigh = list->numneigh; + firstneigh = list->firstneigh; + + double xtmpj, iLambda, jLambda, ijLambda; + + int This_Step = update->ntimestep; + if(This_Step >= AT_Update_Time_Begin && This_Step < AT_Update_Time_End && AT_Pressure_Comp_Flag != 0) AT_Pressure_Compensation_Run = 1; + + + for (int i = 0; i < nmolecules; i++) { + AT_mol_f_H[i][0] = AT_mol_f_H[i][1] = AT_mol_f_H[i][2] = 0; + AT_mol_f_all_H[i][0] = AT_mol_f_all_H[i][1] = AT_mol_f_all_H[i][2] = 0; + } + + // loop over neighbors of my atoms +// if(update->ntimestep AT_Update_Time_Begin)AT_Update_Compensation_Energy(); + + } + + + if(This_Step == AT_Update_Time_End && AT_Pressure_Compensation_Run != 0)AT_Print_Compensation_Energy(); + + double mol_mass,mass_frac; + + if(AllAtomistic != 1){ + if(AT_Pressure_Comp_Flag != 0){ + for (int i = 0; i < nlocal; i++){ + iLambda = lambdaH[i]; + if(iLambda != 0 && iLambda != 1){ + imol = molecule[i]; + if (AT_molmap_H)imol = AT_molmap_H[imol-idlo]; + else imol--; + mol_mass = AT_masstotal_H[imol]; + mass_frac = mass[type[i]] / mol_mass; + ibin = floor(iLambda/AT_lambda_Increment); + imoltypeH = moltypeH[i] - 1; + + f[i][0] += mass_frac*(AT_mol_f_all_H[imol][0]+gradlambdaH[i][0]*Mean_Comp_Energy_H[ibin][imoltypeH]); + f[i][1] += mass_frac*(AT_mol_f_all_H[imol][1]+gradlambdaH[i][1]*Mean_Comp_Energy_H[ibin][imoltypeH]); + f[i][2] += mass_frac*(AT_mol_f_all_H[imol][2]+gradlambdaH[i][2]*Mean_Comp_Energy_H[ibin][imoltypeH]); + if (evflag) ev_tally(i,i,nlocal,newton_pair, + -0.5*Int_Mean_Energy_H[ibin][imoltypeH],0.0,0.0,0.0,0.0,0.0); + + } + + } + + } + else{ + + for (int i = 0; i < nlocal; i++){ + + iLambda = lambdaH[i]; + if(iLambda != 0 && iLambda != 1){ + + imol = molecule[i]; + if (AT_molmap_H)imol = AT_molmap_H[imol-idlo]; + else imol--; + mol_mass = AT_masstotal_H[imol]; + mass_frac = mass[type[i]] / mol_mass; + ibin = floor(iLambda/AT_lambda_Increment); + + f[i][0] += mass_frac*(AT_mol_f_all_H[imol][0]); + f[i][1] += mass_frac*(AT_mol_f_all_H[imol][1]); + f[i][2] += mass_frac*(AT_mol_f_all_H[imol][2]); + + } + + } + + } + + } + + + + if(This_Step == AT_Update_Time_End)AT_Pressure_Compensation_Run = 0; + + if (vflag_fdotr) virial_fdotr_compute(); +} + +/* ---------------------------------------------------------------------- + allocate all arrays +------------------------------------------------------------------------- */ + +void PairLJCutCoulDSFHARSAT::allocate() +{ + allocated = 1; + int n = atom->ntypes; + + memory->create(setflag,n+1,n+1,"pair:setflag"); + for (int i = 1; i <= n; i++) + for (int j = i; j <= n; j++) + setflag[i][j] = 0; + + memory->create(cutsq,n+1,n+1,"pair:cutsq"); + + memory->create(cut_lj,n+1,n+1,"pair:cut_lj"); + memory->create(cut_ljsq,n+1,n+1,"pair:cut_ljsq"); + memory->create(epsilon,n+1,n+1,"pair:epsilon"); + memory->create(sigma,n+1,n+1,"pair:sigma"); + memory->create(lj1,n+1,n+1,"pair:lj1"); + memory->create(lj2,n+1,n+1,"pair:lj2"); + memory->create(lj3,n+1,n+1,"pair:lj3"); + memory->create(lj4,n+1,n+1,"pair:lj4"); + memory->create(offset,n+1,n+1,"pair:offset"); +} + +/* ---------------------------------------------------------------------- + global settings +------------------------------------------------------------------------- */ + +void PairLJCutCoulDSFHARSAT::settings(int narg, char **arg) +{ + if (narg != 5) error->all(FLERR,"Illegal pair_style command"); + + alpha = force->numeric(FLERR,arg[0]); + cut_lj_global = force->numeric(FLERR,arg[1]); + cut_coul = force->numeric(FLERR,arg[2]); + + AllAtomistic = force->numeric(FLERR,arg[3]); + Load_File_Flag = force->numeric(FLERR,arg[4]); + // reset cutoffs that have been explicitly set + + if (allocated) { + int i,j; + for (i = 1; i <= atom->ntypes; i++) + for (j = i+1; j <= atom->ntypes; j++) + if (setflag[i][j]) + cut_lj[i][j] = cut_lj_global; + } +} + +/* ---------------------------------------------------------------------- + set coeffs for one or more type pairs +------------------------------------------------------------------------- */ + +void PairLJCutCoulDSFHARSAT::coeff(int narg, char **arg) +{ + if (narg < 4 || narg > 5) + error->all(FLERR,"Incorrect args for pair coefficients"); + if (!allocated) allocate(); + + int ilo,ihi,jlo,jhi; + force->bounds(arg[0],atom->ntypes,ilo,ihi); + force->bounds(arg[1],atom->ntypes,jlo,jhi); + + double epsilon_one = force->numeric(FLERR,arg[2]); + double sigma_one = force->numeric(FLERR,arg[3]); + + double cut_lj_one = cut_lj_global; + if (narg == 5) cut_lj_one = force->numeric(FLERR,arg[4]); + + int count = 0; + for (int i = ilo; i <= ihi; i++) { + for (int j = MAX(jlo,i); j <= jhi; j++) { + epsilon[i][j] = epsilon_one; + sigma[i][j] = sigma_one; + cut_lj[i][j] = cut_lj_one; + setflag[i][j] = 1; + + count++; + } + } + + if (count == 0) error->all(FLERR,"Incorrect args for pair coefficients"); +} + +/* ---------------------------------------------------------------------- + init specific to this pair style +------------------------------------------------------------------------- */ + +void PairLJCutCoulDSFHARSAT::init_style() +{ + if (!atom->q_flag) + error->all(FLERR,"Pair style lj/cut/coul/dsf requires atom attribute q"); + + if(me == 0){ + if (screen)fprintf(screen,"AT_H_AdResS_allocated flag = %d\n",H_AdResS_allocated); + if (logfile)fprintf(logfile,"AT_H_AdResS_allocated flag = %d\n",H_AdResS_allocated); + } + + if(!H_AdResS_allocated)H_AdResS_Allocation(); + + int This_Step = update->ntimestep; + AT_Restart_Time_Step = This_Step; + + if((This_Step > AT_Update_Time_Begin || Load_File_Flag) && AT_Pressure_Comp_Flag != 0)Load_Compensation_Pressure(); + + if(This_Step < AT_Update_Time_End && This_Step >= AT_Update_Time_Begin)Comp_Counter_H = floor((This_Step-AT_Update_Time_Begin)/AT_Update_Frequency); + + if(me==0 && This_Step < AT_Update_Time_End && This_Step > AT_Update_Time_Begin){ + if(screen)fprintf(screen,"AT_Pressure componsation forces are again being updated after previous %d times\n",Comp_Counter_H); + if(logfile)fprintf(logfile,"AT_Pressure componsation forces are again being updated after previous %d times\n",Comp_Counter_H); + } + + neighbor->request(this,instance_me); + + cut_coulsq = cut_coul * cut_coul; + double erfcc = erfc(alpha*cut_coul); + double erfcd = exp(-alpha*alpha*cut_coul*cut_coul); + f_shift = -(erfcc/cut_coulsq + 2.0/MY_PIS*alpha*erfcd/cut_coul); + e_shift = erfcc/cut_coul - f_shift*cut_coul; + +} + +/* ---------------------------------------------------------------------- + init for one type pair i,j and corresponding j,i +------------------------------------------------------------------------- */ + +double PairLJCutCoulDSFHARSAT::init_one(int i, int j) +{ + if (setflag[i][j] == 0) { + epsilon[i][j] = mix_energy(epsilon[i][i],epsilon[j][j], + sigma[i][i],sigma[j][j]); + sigma[i][j] = mix_distance(sigma[i][i],sigma[j][j]); + cut_lj[i][j] = mix_distance(cut_lj[i][i],cut_lj[j][j]); + } + + double cut = MAX(cut_lj[i][j],cut_coul); + cut_ljsq[i][j] = cut_lj[i][j] * cut_lj[i][j]; + + lj1[i][j] = 48.0 * epsilon[i][j] * pow(sigma[i][j],12.0); + lj2[i][j] = 24.0 * epsilon[i][j] * pow(sigma[i][j],6.0); + lj3[i][j] = 4.0 * epsilon[i][j] * pow(sigma[i][j],12.0); + lj4[i][j] = 4.0 * epsilon[i][j] * pow(sigma[i][j],6.0); + + if (offset_flag) { + double ratio = sigma[i][j] / cut_lj[i][j]; + offset[i][j] = 4.0 * epsilon[i][j] * (pow(ratio,12.0) - pow(ratio,6.0)); + } else offset[i][j] = 0.0; + + cut_ljsq[j][i] = cut_ljsq[i][j]; + lj1[j][i] = lj1[i][j]; + lj2[j][i] = lj2[i][j]; + lj3[j][i] = lj3[i][j]; + lj4[j][i] = lj4[i][j]; + offset[j][i] = offset[i][j]; + + // compute I,J contribution to long-range tail correction + // count total # of atoms of type I and J via Allreduce + + if (tail_flag) { + int *type = atom->type; + int nlocal = atom->nlocal; + + double count[2],all[2]; + count[0] = count[1] = 0.0; + for (int k = 0; k < nlocal; k++) { + if (type[k] == i) count[0] += 1.0; + if (type[k] == j) count[1] += 1.0; + } + MPI_Allreduce(count,all,2,MPI_DOUBLE,MPI_SUM,world); + + double sig2 = sigma[i][j]*sigma[i][j]; + double sig6 = sig2*sig2*sig2; + double rc3 = cut_lj[i][j]*cut_lj[i][j]*cut_lj[i][j]; + double rc6 = rc3*rc3; + double rc9 = rc3*rc6; + etail_ij = 8.0*MY_PI*all[0]*all[1]*epsilon[i][j] * + sig6 * (sig6 - 3.0*rc6) / (9.0*rc9); + ptail_ij = 16.0*MY_PI*all[0]*all[1]*epsilon[i][j] * + sig6 * (2.0*sig6 - 3.0*rc6) / (9.0*rc9); + } + + return cut; +} + +/* ---------------------------------------------------------------------- + proc 0 writes to restart file +------------------------------------------------------------------------- */ + +void PairLJCutCoulDSFHARSAT::write_restart(FILE *fp) +{ + write_restart_settings(fp); + + int i,j; + for (i = 1; i <= atom->ntypes; i++) + for (j = i; j <= atom->ntypes; j++) { + fwrite(&setflag[i][j],sizeof(int),1,fp); + if (setflag[i][j]) { + fwrite(&epsilon[i][j],sizeof(double),1,fp); + fwrite(&sigma[i][j],sizeof(double),1,fp); + fwrite(&cut_lj[i][j],sizeof(double),1,fp); + } + } +} + +/* ---------------------------------------------------------------------- + proc 0 reads from restart file, bcasts +------------------------------------------------------------------------- */ + +void PairLJCutCoulDSFHARSAT::read_restart(FILE *fp) +{ + read_restart_settings(fp); + allocate(); + + int i,j; + int me = comm->me; + for (i = 1; i <= atom->ntypes; i++) + for (j = i; j <= atom->ntypes; j++) { + if (me == 0) fread(&setflag[i][j],sizeof(int),1,fp); + MPI_Bcast(&setflag[i][j],1,MPI_INT,0,world); + if (setflag[i][j]) { + if (me == 0) { + fread(&epsilon[i][j],sizeof(double),1,fp); + fread(&sigma[i][j],sizeof(double),1,fp); + fread(&cut_lj[i][j],sizeof(double),1,fp); + } + MPI_Bcast(&epsilon[i][j],1,MPI_DOUBLE,0,world); + MPI_Bcast(&sigma[i][j],1,MPI_DOUBLE,0,world); + MPI_Bcast(&cut_lj[i][j],1,MPI_DOUBLE,0,world); + } + } +} + +/* ---------------------------------------------------------------------- + proc 0 writes to restart file +------------------------------------------------------------------------- */ + +void PairLJCutCoulDSFHARSAT::write_restart_settings(FILE *fp) +{ + fwrite(&alpha,sizeof(double),1,fp); + fwrite(&cut_lj_global,sizeof(double),1,fp); + fwrite(&cut_coul,sizeof(double),1,fp); + fwrite(&offset_flag,sizeof(int),1,fp); + fwrite(&mix_flag,sizeof(int),1,fp); + fwrite(&tail_flag,sizeof(int),1,fp); +} + +/* ---------------------------------------------------------------------- + proc 0 reads from restart file, bcasts +------------------------------------------------------------------------- */ + +void PairLJCutCoulDSFHARSAT::read_restart_settings(FILE *fp) +{ + if (comm->me == 0) { + fread(&alpha,sizeof(double),1,fp); + fread(&cut_lj_global,sizeof(double),1,fp); + fread(&cut_coul,sizeof(double),1,fp); + fread(&offset_flag,sizeof(int),1,fp); + fread(&mix_flag,sizeof(int),1,fp); + fread(&tail_flag,sizeof(int),1,fp); + } + MPI_Bcast(&alpha,1,MPI_DOUBLE,0,world); + MPI_Bcast(&cut_lj_global,1,MPI_DOUBLE,0,world); + MPI_Bcast(&cut_coul,1,MPI_DOUBLE,0,world); + MPI_Bcast(&offset_flag,1,MPI_INT,0,world); + MPI_Bcast(&mix_flag,1,MPI_INT,0,world); + MPI_Bcast(&tail_flag,1,MPI_INT,0,world); +} + +/* ---------------------------------------------------------------------- */ + +double PairLJCutCoulDSFHARSAT::single(int i, int j, int itype, int jtype, double rsq, + double factor_coul, double factor_lj, + double &fforce) +{ + double r2inv,r6inv,r,erfcc,erfcd,prefactor; + double forcecoul,forcelj,phicoul,philj; + + r2inv = 1.0/rsq; + if (rsq < cut_ljsq[itype][jtype]) { + r6inv = r2inv*r2inv*r2inv; + forcelj = r6inv * (lj1[itype][jtype]*r6inv - lj2[itype][jtype]); + } else forcelj = 0.0; + + if (rsq < cut_coulsq) { + r = sqrt(rsq); + prefactor = factor_coul * force->qqrd2e * atom->q[i]*atom->q[j]/r; + erfcc = erfc(alpha*r); + erfcd = exp(-alpha*alpha*r*r); + forcecoul = prefactor * (erfcc/r + 2.0*alpha/MY_PIS * erfcd + + r*f_shift) * r; + } else forcecoul = 0.0; + + fforce = (forcecoul + factor_lj*forcelj) * r2inv; + + double eng = 0.0; + if (rsq < cut_ljsq[itype][jtype]) { + philj = r6inv*(lj3[itype][jtype]*r6inv-lj4[itype][jtype]) - + offset[itype][jtype]; + eng += factor_lj*philj; + } + + if (rsq < cut_coulsq) { + phicoul = prefactor * (erfcc - r*e_shift - rsq*f_shift); + eng += phicoul; + } + + eng=0; + return eng; +} + +/* ---------------------------------------------------------------------- */ + +void *PairLJCutCoulDSFHARSAT::extract(const char *str, int &dim) +{ + if (strcmp(str,"cut_coul") == 0) { + dim = 0; + return (void *) &cut_coul; + } + return NULL; +} + + +int PairLJCutCoulDSFHARSAT::molecules_in_group(tagint &idlo, tagint &idhi) +{ + int i; + + memory->destroy(AT_molmap_H); + AT_molmap_H = NULL; + + // find lo/hi molecule ID for any atom in group + // warn if atom in group has ID = 0 + + tagint *molecule = atom->molecule; + int *mask = atom->mask; + int nlocal = atom->nlocal; + + tagint lo = BIG; + tagint hi = -BIG; + int flag = 0; + for (i = 0; i < nlocal; i++) + { +// if (mask[i] & groupbit) { + if (mask[i]) { + if (molecule[i] == 0) flag = 1; + lo = MIN(lo,molecule[i]); + hi = MAX(hi,molecule[i]); + } + } + + int flagall; + MPI_Allreduce(&flag,&flagall,1,MPI_INT,MPI_SUM,world); + if (flagall && comm->me == 0) + error->warning(FLERR,"Atom with molecule ID = 0 included in " + "compute molecule group"); + + MPI_Allreduce(&lo,&idlo,1,MPI_LMP_TAGINT,MPI_MIN,world); + MPI_Allreduce(&hi,&idhi,1,MPI_LMP_TAGINT,MPI_MAX,world); + if (idlo == BIG) return 0; + + // molmap = vector of length nlen + // set to 1 for IDs that appear in group across all procs, else 0 + + tagint nlen_tag = idhi-idlo+1; + if (nlen_tag > MAXSMALLINT) + error->all(FLERR,"Too many molecules for compute"); + int nlen = (int) nlen_tag; + + memory->create(AT_molmap_H,nlen,"pair:molmap_H"); + for (i = 0; i < nlen; i++) AT_molmap_H[i] = 0; + + for (i = 0; i < nlocal; i++) + // if (mask[i] & groupbit) + if (mask[i]) + AT_molmap_H[molecule[i]-idlo] = 1; + + int *AT_molmapall; + memory->create(AT_molmapall,nlen,"pair:AT_molmapall"); + MPI_Allreduce(AT_molmap_H,AT_molmapall,nlen,MPI_INT,MPI_MAX,world); + + // nmolecules = # of non-zero IDs in molmap + // molmap[i] = index of molecule, skipping molecules not in group with -1 + + int nmolecules = 0; + for (i = 0; i < nlen; i++) + if (AT_molmapall[i]) AT_molmap_H[i] = nmolecules++; + else AT_molmap_H[i] = -1; + memory->destroy(AT_molmapall); + + // warn if any molecule has some atoms in group and some not in group + + flag = 0; + for (i = 0; i < nlocal; i++) { +// if (mask[i] & groupbit) continue; + if (mask[i]) continue; + if (molecule[i] < idlo || molecule[i] > idhi) continue; + if (AT_molmap_H[molecule[i]-idlo] >= 0) flag = 1; + } + + MPI_Allreduce(&flag,&flagall,1,MPI_INT,MPI_SUM,world); + if (flagall && comm->me == 0) + error->warning(FLERR, + "One or more compute molecules has atoms not in group"); + + // if molmap simply stores 1 to Nmolecules, then free it + + if (idlo == 1 && idhi == nmolecules && nlen == nmolecules) { + memory->destroy(AT_molmap_H); + AT_molmap_H = NULL; + } + return nmolecules; +} + + +void PairLJCutCoulDSFHARSAT::AT_Print_Compensation_Energy(){ + + FILE *fp1; + fp1 = fopen("Mean_Comp_Energy_AT.txt","w"); + if (fp1 == NULL) { + char str[128]; + sprintf(str,"Cannot open Mean_Comp_Energy_AT.txt file %s","Mean_Comp_Energy_AT.txt"); + error->one(FLERR,str); + } + + for(int i = 0;i < AT_Bin_Num; i++){ + fprintf(fp1,"%d",i+1); + for(int j = 0; j < atom->nmoltypesH; j++){ + fprintf(fp1,"\t%.10f",Mean_Comp_Energy_H[i][j]); + } + fprintf(fp1,"\n"); + } + fclose(fp1); +} + + + +void PairLJCutCoulDSFHARSAT::AT_Update_Compensation_Energy(){ + MPI_Allreduce(&Comp_Energy_H[0][0],&Comp_Energy_all_H[0][0],AT_Bin_Num*(atom->nmoltypesH+1),MPI_DOUBLE,MPI_SUM,world); + MPI_Allreduce(&Comp_Energy_Num_H[0][0],&Comp_Energy_Num_all_H[0][0],AT_Bin_Num*(atom->nmoltypesH+1),MPI_INT,MPI_SUM,world); + + for(int j = 0;j < atom->nmoltypesH; j++){ + for(int i = 0;i < AT_Bin_Num; i++){ + Mean_Energy_H[i][j] = Comp_Energy_all_H[i][j] / Comp_Energy_Num_all_H[i][j]; + Mean_Comp_Energy_H[i][j] = (Comp_Counter_H * Mean_Comp_Energy_H[i][j] + Mean_Energy_H[i][j]) / (Comp_Counter_H + 1); + Int_Mean_Energy_H[i][j]=0; + } + } + + Comp_Counter_H++; + + for(int j = 0;j < atom->nmoltypesH; j++){ + for(int i = 0;i < AT_Bin_Num; i++){ + Comp_Energy_Num_H[i][j] = 0; + Comp_Energy_Num_all_H[i][j] = 0; + Comp_Energy_H[i][j] = 0; + Comp_Energy_all_H[i][j] =0; + } + + } + if (me == 0)AT_Print_Compensation_Energy(); + + +} + + +void PairLJCutCoulDSFHARSAT::Load_Compensation_Pressure(){ + + if(me == 0){ + FILE *fp1; + char str[128]; + + fp1 = fopen("Mean_Comp_Energy_AT.txt","r"); + if (fp1 == NULL) { + sprintf(str,"Cannot open Mean_Comp_Energy_AT.txt file %s","Mean_Comp_Energy_AT.txt"); + error->one(FLERR,str); + } + + int i1; + float f1; + + while (!feof(fp1)){ + fscanf (fp1,"%d",&i1); + for(int j=0;jnmoltypesH;j++){ + fscanf (fp1,"\t%f",&f1); + Mean_Comp_Energy_H[i1-1][j] = f1; + } + if(i1 > AT_Bin_Num){ + sprintf(str,"At drift force compensation bin number mismatches %d != %d",AT_Bin_Num,i1); + error->one(FLERR,str); + } + + } + + fclose(fp1); + + + if(me==0){ + if(screen)fprintf(screen,"AT_Pressure componsation forces distributed successfully!\n"); + if(logfile)fprintf(logfile,"AT_Pressure componsation forces distributed successfully!\n"); + } + + } + + MPI_Bcast(Mean_Comp_Energy_H,AT_Bin_Num,MPI_DOUBLE,0,world); + + +} + +void PairLJCutCoulDSFHARSAT::H_AdResS_Allocation(){ + for (int i = 0; i < modify->nfix; i++){ + if (strcmp(modify->fix[i]->style,"lambdah/calc") == 0){ + lambda_H_fix = (FixLambdaHCalc *) modify->fix[i]; + AT_lambda_Increment = lambda_H_fix->Pressure_lambda_Increment; + AT_Bin_Num = lambda_H_fix->Pressure_Bin_Num; + AT_Update_Frequency = lambda_H_fix->Pressure_Update_Frequency; + AT_Update_Time_Begin = lambda_H_fix->Pressure_Update_Time_Begin; + AT_Update_Time_End = lambda_H_fix->Pressure_Update_Time_End; + AT_Pressure_Comp_Flag = lambda_H_fix->Pressure_Comp_Flag; + AT_center_box = lambda_H_fix->center_box; + AT_Hybrid_Style = lambda_H_fix->Hybrid_Style; + } + } + + if(me == 0){ + if (screen){ + fprintf(screen,"AT_lambda_Increment= %f\n",AT_lambda_Increment); + fprintf(screen,"AT_Bin_Num= %d\n",AT_Bin_Num); + fprintf(screen,"AT_Update_Frequency= %d\n",AT_Update_Frequency); + fprintf(screen,"AT_Update_Time_Begin= %d\n",AT_Update_Time_Begin); + fprintf(screen,"AT_Update_Time_End= %d\n",AT_Update_Time_End); + fprintf(screen,"AT_Pressure_Comp_Flag= %d\n",AT_Pressure_Comp_Flag); + } + + if (logfile){ + fprintf(logfile,"AT_lambda_Increment= %f\n",AT_lambda_Increment); + fprintf(logfile,"AT_Bin_Num= %d\n",AT_Bin_Num); + fprintf(logfile,"AT_Update_Frequency= %d\n",AT_Update_Frequency); + fprintf(logfile,"AT_Update_Time_Begin= %d\n",AT_Update_Time_Begin); + fprintf(logfile,"AT_Update_Time_End= %d\n",AT_Update_Time_End); + fprintf(logfile,"AT_Pressure_Comp_Flag= %d\n",AT_Pressure_Comp_Flag); + } + } + + memory->create(Comp_Energy_Num_H,AT_Bin_Num,atom->nmoltypesH+1,"pairLJHAT:Comp_Energy_Num_H"); + memory->create(Comp_Energy_Num_all_H,AT_Bin_Num,atom->nmoltypesH+1,"pairLJHAT:Comp_Energy_Num_all_H"); + + memory->create(Int_Mean_Energy_H,AT_Bin_Num,atom->nmoltypesH+1,"pairLJHAT:Int_Mean_Energy_H"); + memory->create(Comp_Energy_H,AT_Bin_Num,atom->nmoltypesH+1,"pairLJHAT:Comp_Energy_H"); + memory->create(Comp_Energy_all_H,AT_Bin_Num,atom->nmoltypesH+1,"pairLJHAT:Comp_Energy_all_H"); + memory->create(Mean_Comp_Energy_H,AT_Bin_Num,atom->nmoltypesH+1,"pairLJHAT:Mean_Comp_Energy_H"); + memory->create(Mean_Energy_H,AT_Bin_Num,atom->nmoltypesH+1,"pairLJHAT:Mean_Energy_H"); + + + for(int j=0;jnmoltypesH;j++){ + for(int i = 0;i < AT_Bin_Num; i++){ + Int_Mean_Energy_H[i][j]=0; + Comp_Energy_H[i][j]=0; + Comp_Energy_all_H[i][j]=0; + Mean_Comp_Energy_H[i][j]=0; + Comp_Energy_Num_H[i][j] = 0; + Comp_Energy_Num_all_H[i][j] = 0; + } + + } + + H_AdResS_allocated = 1; +} + diff --git a/src/USER-HADRESS/pair_lj_cut_coul_dsf_hars_at.h b/src/USER-HADRESS/pair_lj_cut_coul_dsf_hars_at.h new file mode 100644 index 0000000000..b5d5076c43 --- /dev/null +++ b/src/USER-HADRESS/pair_lj_cut_coul_dsf_hars_at.h @@ -0,0 +1,115 @@ +/* -*- c++ -*- ---------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + http://lammps.sandia.gov, Sandia National Laboratories + Steve Plimpton, sjplimp@sandia.gov + + Copyright (2003) Sandia Corporation. Under the terms of Contract + DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains + certain rights in this software. This software is distributed under + the GNU General Public License. + + See the README file in the top-level LAMMPS directory. +------------------------------------------------------------------------- */ + +#ifdef PAIR_CLASS + +PairStyle(lj/cut/coul/dsf/hars/at,PairLJCutCoulDSFHARSAT) + +#else + +#ifndef LMP_PAIR_LJ_CUT_COUL_DSF_HARS_AT_H +#define LMP_PAIR_LJ_CUT_COUL_DSF_HARS_AT_H + +#include "pair.h" + +namespace LAMMPS_NS { + +class PairLJCutCoulDSFHARSAT : public Pair { + public: + PairLJCutCoulDSFHARSAT(class LAMMPS *); + ~PairLJCutCoulDSFHARSAT(); + void compute(int, int); + void settings(int, char **); + void coeff(int, char **); + void init_style(); + double init_one(int, int); + void write_restart(FILE *); + void read_restart(FILE *); + void write_restart_settings(FILE *); + void read_restart_settings(FILE *); + double single(int, int, int, int, double, double, double, double &); + void *extract(const char *, int &); + + void AT_Print_Compensation_Energy(); + void AT_Update_Compensation_Energy(); + + protected: + double cut_lj_global; + double **cut_lj,**cut_ljsq; + double **epsilon,**sigma; + double **lj1,**lj2,**lj3,**lj4,**offset; + + double cut_coul,cut_coulsq; + double alpha; + double f_shift,e_shift; + + void allocate(); + class FixLambdaHCalc *lambda_H_fix; + + int AllAtomistic; + + //private: + int me; + + int H_AdResS_allocated; + + int **Comp_Energy_Num_H,**Comp_Energy_Num_all_H, Comp_Counter_H; + + double AT_lambda_Increment; + int AT_Bin_Num, AT_Update_Frequency, AT_Update_Time_End, AT_Update_Time_Begin; + int AT_Pressure_Compensation_Run; + int AT_Pressure_Comp_Flag; + + int AT_Restart_Time_Step; + double *AT_center_box,AT_x0lo; + int AT_Hybrid_Style; + double **Int_Mean_Energy_H, **Comp_Energy_H, **Comp_Energy_all_H, **Mean_Energy_H, **Mean_Comp_Energy_H; + + int nmolecules; + tagint idlo,idhi; + + double *AT_massproc_H,*AT_masstotal_H; + + double **AT_mol_f_H, **AT_mol_f_all_H; + + int *AT_molmap_H; // convert molecule ID to local index + int Load_File_Flag; + + int molecules_in_group(tagint &, tagint &); + void Load_Compensation_Pressure(); + void H_AdResS_Allocation(); + +}; + +} + +#endif +#endif + +/* ERROR/WARNING messages: + +E: Illegal ... command + +Self-explanatory. Check the input script syntax and compare to the +documentation for the command. You can use -echo screen as a +command-line option when running LAMMPS to see the offending line. + +E: Incorrect args for pair coefficients + +Self-explanatory. Check the input script or data file. + +E: Pair style lj/cut/coul/dsf requires atom attribute q + +The atom style defined does not have these attributes. + +*/ diff --git a/src/USER-HADRESS/pair_lj_cut_hars_at.cpp b/src/USER-HADRESS/pair_lj_cut_hars_at.cpp new file mode 100644 index 0000000000..5d6e95d91d --- /dev/null +++ b/src/USER-HADRESS/pair_lj_cut_hars_at.cpp @@ -0,0 +1,1050 @@ +/* ---------------------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + http://lammps.sandia.gov, Sandia National Laboratories + Steve Plimpton, sjplimp@sandia.gov + + Copyright (2003) Sandia Corporation. Under the terms of Contract + DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains + certain rights in this software. This software is distributed under + the GNU General Public License. + + See the README file in the top-level LAMMPS directory. +------------------------------------------------------------------------- */ + +/* ---------------------------------------------------------------------- + Contributing author: Paul Crozier (SNL) +------------------------------------------------------------------------- */ + +#include "math.h" +#include "stdio.h" +#include "stdlib.h" +#include "string.h" +#include "pair_lj_cut_hars_at.h" +#include "atom.h" +#include "comm.h" +#include "force.h" +#include "neighbor.h" +#include "neigh_list.h" +#include "neigh_request.h" +#include "update.h" +#include "integrate.h" +#include "respa.h" +#include "math_const.h" +#include "memory.h" +#include "error.h" +#include "domain.h" +#include "fix.h" +#include "fix_lambdah_calc.h" +#include "modify.h" + +using namespace LAMMPS_NS; +using namespace MathConst; +#define BIG MAXTAGINT + +/* ---------------------------------------------------------------------- */ + +PairLJCutHARSAT::PairLJCutHARSAT(LAMMPS *lmp) : Pair(lmp) +{ + respa_enable = 1; + writedata = 1; + + AT_massproc_H = NULL; + AT_masstotal_H = NULL; + AT_molmap_H = NULL; + AT_mol_f_H = NULL; + AT_mol_f_all_H = NULL; + Comp_Energy_Num_H = NULL; + Comp_Energy_Num_all_H = NULL; + + Int_Mean_Energy_H = NULL; + Mean_Energy_H = NULL; + Comp_Energy_H = NULL; + Comp_Energy_all_H = NULL; + Mean_Comp_Energy_H = NULL; + + AT_molmap_H = NULL; + nmolecules = molecules_in_group(idlo,idhi); + + H_AdResS_allocated = 0; + + AT_Pressure_Compensation_Run = 0; + Comp_Counter_H = 0; + memory->create(AT_massproc_H,nmolecules,"pair:AT_massproc_H"); + memory->create(AT_masstotal_H,nmolecules,"pair:AT_masstotal_H"); + memory->create(AT_mol_f_H,nmolecules,3,"pair:AT_mol_f_H"); + memory->create(AT_mol_f_all_H,nmolecules,3,"pair:AT_mol_f_all_H"); + + + // compute masstotal for each molecule + MPI_Comm_rank(world, &me); + int *mask = atom->mask; + tagint *molecule = atom->molecule; + int *type = atom->type; + double *mass = atom->mass; + double *rmass = atom->rmass; + int nlocal = atom->nlocal; + + tagint imol; + double massone; + + for (int i = 0; i < nmolecules; i++) AT_massproc_H[i] = 0.0; + + + for (int i = 0; i < nlocal; i++) + { +// if (mask[i] & groupbit) { + if (mask[i]) { + if (rmass) massone = rmass[i]; + else massone = mass[type[i]]; + imol = molecule[i]; + if (AT_molmap_H) imol = AT_molmap_H[imol-idlo]; + else imol--; + AT_massproc_H[imol] += massone; + + } + } + + MPI_Allreduce(AT_massproc_H,AT_masstotal_H,nmolecules,MPI_DOUBLE,MPI_SUM,world); + +} + +/* ---------------------------------------------------------------------- */ + +PairLJCutHARSAT::~PairLJCutHARSAT() +{ + if (allocated) { + memory->destroy(setflag); + memory->destroy(cutsq); + memory->destroy(cut); + memory->destroy(epsilon); + memory->destroy(sigma); + memory->destroy(lj1); + memory->destroy(lj2); + memory->destroy(lj3); + memory->destroy(lj4); + memory->destroy(offset); + memory->destroy(AT_massproc_H); + memory->destroy(AT_masstotal_H); + memory->destroy(AT_molmap_H); + memory->destroy(AT_mol_f_H); + memory->destroy(AT_mol_f_all_H); + memory->destroy(Comp_Energy_Num_H); + memory->destroy(Comp_Energy_Num_all_H); + memory->destroy(Int_Mean_Energy_H); + memory->destroy(Mean_Energy_H); + memory->destroy(Comp_Energy_H); + memory->destroy(Comp_Energy_all_H); + memory->destroy(Mean_Comp_Energy_H); + + } +} + +/* ---------------------------------------------------------------------- */ + +void PairLJCutHARSAT::compute(int eflag, int vflag) +{ + int i,j,ii,jj,inum,jnum,itype,jtype; + double xtmp,ytmp,ztmp,delx,dely,delz,evdwl,fpair; + double rsq,r2inv,r6inv,forcelj, factor_lj,Vij; + int *ilist,*jlist,*numneigh,**firstneigh; + int imoltypeH,jmoltypeH; + + evdwl = 0.0; + if (eflag || vflag) ev_setup(eflag,vflag); + else evflag = vflag_fdotr = 0; + + double **x = atom->x; + double **f = atom->f; + double *lambdaH = atom->lambdaH; + double **gradlambdaH = atom->gradlambdaH; + int *type = atom->type; + int nlocal = atom->nlocal; + double *special_lj = force->special_lj; + int newton_pair = force->newton_pair; + int imol,jmol; + tagint *molecule = atom->molecule; + double *mass = atom->mass; + int *replambdaH = atom->replambdaH; + int *moltypeH = atom->moltypeH; + + int ibin, jbin; + + inum = list->inum; + ilist = list->ilist; + numneigh = list->numneigh; + firstneigh = list->firstneigh; + + //if(update->ntimestep<3)return; + + double xtmpj, iLambda, jLambda, ijLambda; + + int This_Step = update->ntimestep; + if(This_Step >= AT_Update_Time_Begin && This_Step < AT_Update_Time_End && AT_Pressure_Comp_Flag != 0) AT_Pressure_Compensation_Run = 1; + + + for (int i = 0; i < nmolecules; i++) { + AT_mol_f_H[i][0] = AT_mol_f_H[i][1] = AT_mol_f_H[i][2] = 0; + AT_mol_f_all_H[i][0] = AT_mol_f_all_H[i][1] = AT_mol_f_all_H[i][2] = 0; + } + + for (ii = 0; ii < inum; ii++) { + i = ilist[ii]; + xtmp = x[i][0]; + ytmp = x[i][1]; + ztmp = x[i][2]; + itype = type[i]; + imoltypeH = moltypeH[i]; + jlist = firstneigh[i]; + jnum = numneigh[i]; + + iLambda = lambdaH[i]; + + for (jj = 0; jj < jnum; jj++) { + + j = jlist[jj]; + factor_lj = special_lj[sbmask(j)]; + j &= NEIGHMASK; + jLambda = lambdaH[j]; + + + if(iLambda==0 && jLambda==0 && AllAtomistic!=1)continue; + + delx = xtmp - x[j][0]; + dely = ytmp - x[j][1]; + delz = ztmp - x[j][2]; + + xtmpj = x[j][0]; + + rsq = delx*delx + dely*dely + delz*delz; + jtype = type[j]; + jmoltypeH = moltypeH[j]; + + imol = molecule[i]; + jmol = molecule[j]; + if (AT_molmap_H) { + imol = AT_molmap_H[imol-idlo]; + jmol = AT_molmap_H[jmol-idlo]; + } + else { + imol--; + jmol--; + } + + + if (rsq < cutsq[itype][jtype] && lj1[itype][jtype] != 0 && (imol != jmol)) { + + + if(((iLambda==1 && jLambda==1) || AllAtomistic)){ + + r2inv = 1.0/rsq; + r6inv = r2inv*r2inv*r2inv; + forcelj = r6inv * (lj1[itype][jtype]*r6inv - lj2[itype][jtype]); + fpair = factor_lj*forcelj*r2inv; + + f[i][0] += delx*fpair; + f[i][1] += dely*fpair; + f[i][2] += delz*fpair; + + if (newton_pair || j < nlocal) { + f[j][0] -= delx*fpair; + f[j][1] -= dely*fpair; + f[j][2] -= delz*fpair; + } + + if (eflag) { + evdwl = r6inv*(lj3[itype][jtype]*r6inv-lj4[itype][jtype]) - + offset[itype][jtype]; + evdwl *= factor_lj; + } + + if (evflag) ev_tally(i,j,nlocal,newton_pair, + evdwl,0.0,fpair,delx,dely,delz); + + } + else if(iLambda !=0 || jLambda != 0){ + + + ijLambda = 0.5 * (iLambda + jLambda); + r2inv = 1.0/rsq; + r6inv = r2inv*r2inv*r2inv; + forcelj = r6inv * (lj1[itype][jtype]*r6inv - lj2[itype][jtype]); + + fpair = factor_lj*(forcelj*ijLambda)*r2inv; + + Vij = 0.5*(r6inv*(lj3[itype][jtype]*r6inv-lj4[itype][jtype]) - + offset[itype][jtype]); + + f[i][0] += delx*fpair; + f[i][1] += dely*fpair; + f[i][2] += delz*fpair; + + ibin = floor(iLambda/AT_lambda_Increment); + if(ibin==AT_Bin_Num)ibin = AT_Bin_Num - 1; + if(AT_Pressure_Compensation_Run != 0 && iLambda != 0 && iLambda != 1)Comp_Energy_H[ibin][imoltypeH-1] += Vij; + + AT_mol_f_H[imol][0] += -Vij*gradlambdaH[i][0]; + AT_mol_f_H[imol][1] += -Vij*gradlambdaH[i][1]; + AT_mol_f_H[imol][2] += -Vij*gradlambdaH[i][2]; + + if (newton_pair || j < nlocal) { + + f[j][0] -= delx*fpair; + f[j][1] -= dely*fpair; + f[j][2] -= delz*fpair; + + jbin = floor(jLambda/AT_lambda_Increment); + if(jbin==AT_Bin_Num)jbin = AT_Bin_Num - 1; + if(AT_Pressure_Compensation_Run != 0 && jLambda != 0 && jLambda != 1)Comp_Energy_H[jbin][jmoltypeH-1] += Vij; + + AT_mol_f_H[jmol][0] += -Vij*gradlambdaH[j][0]; + AT_mol_f_H[jmol][1] += -Vij*gradlambdaH[j][1]; + AT_mol_f_H[jmol][2] += -Vij*gradlambdaH[j][2]; + + } + + if (eflag) { + + evdwl = ijLambda*Vij*2.0; + evdwl *= factor_lj; + } + + if (evflag) ev_tally(i,j,nlocal,newton_pair, + evdwl,0.0,fpair,delx,dely,delz); + + } + } + + } + } + + + + MPI_Allreduce(&AT_mol_f_H[0][0],&AT_mol_f_all_H[0][0],3*nmolecules,MPI_DOUBLE,MPI_SUM,world); + + if(AT_Pressure_Compensation_Run != 0 && AT_Pressure_Comp_Flag != 0){ + + for (int i = 0; i < nlocal; i++){ + iLambda = lambdaH[i]; + if(replambdaH[i]!=0 && iLambda != 0 && iLambda != 1){ + + ibin = floor(iLambda/AT_lambda_Increment); + if(ibin==AT_Bin_Num)ibin = AT_Bin_Num - 1; + + imoltypeH = moltypeH[i]-1; + + Comp_Energy_Num_H[ibin][imoltypeH]++; + } + } + + if(This_Step % AT_Update_Frequency == 0 && This_Step > AT_Update_Time_Begin)AT_Update_Compensation_Energy(); + + } + + + if(This_Step == AT_Update_Time_End && AT_Pressure_Compensation_Run != 0)AT_Print_Compensation_Energy(); + + double mol_mass,mass_frac; + + if(AllAtomistic != 1){ + + if(AT_Pressure_Comp_Flag != 0){ + + for (int i = 0; i < nlocal; i++){ + + iLambda = lambdaH[i]; + if(iLambda != 0 && iLambda != 1){ + + imol = molecule[i]; + if (AT_molmap_H)imol = AT_molmap_H[imol-idlo]; + else imol--; + mol_mass = AT_masstotal_H[imol]; + mass_frac = mass[type[i]] / mol_mass; + ibin = floor(iLambda/AT_lambda_Increment); + imoltypeH = moltypeH[i] - 1; + + + f[i][0] += mass_frac*(AT_mol_f_all_H[imol][0]+gradlambdaH[i][0]*Mean_Comp_Energy_H[ibin][imoltypeH]); + f[i][1] += mass_frac*(AT_mol_f_all_H[imol][1]+gradlambdaH[i][1]*Mean_Comp_Energy_H[ibin][imoltypeH]); + f[i][2] += mass_frac*(AT_mol_f_all_H[imol][2]+gradlambdaH[i][2]*Mean_Comp_Energy_H[ibin][imoltypeH]); + if (evflag) ev_tally(i,i,nlocal,newton_pair, + -0.5*Int_Mean_Energy_H[ibin][imoltypeH],0.0,0.0,0.0,0.0,0.0); + + } + + } + + } + else{ + + for (int i = 0; i < nlocal; i++){ + + iLambda = lambdaH[i]; + if(iLambda != 0 && iLambda != 1){ + + imol = molecule[i]; + if (AT_molmap_H)imol = AT_molmap_H[imol-idlo]; + else imol--; + mol_mass = AT_masstotal_H[imol]; + mass_frac = mass[type[i]] / mol_mass; + ibin = floor(iLambda/AT_lambda_Increment); + + + f[i][0] += mass_frac*(AT_mol_f_all_H[imol][0]); + f[i][1] += mass_frac*(AT_mol_f_all_H[imol][1]); + f[i][2] += mass_frac*(AT_mol_f_all_H[imol][2]); + + } + + } + + } + + } + + + if(This_Step == AT_Update_Time_End)AT_Pressure_Compensation_Run = 0; + + if (vflag_fdotr) virial_fdotr_compute(); +} + +/* ---------------------------------------------------------------------- */ + +void PairLJCutHARSAT::compute_inner() +{ + error->all(FLERR,"Rrespa has not been included!"); +} + +/* ---------------------------------------------------------------------- */ + +void PairLJCutHARSAT::compute_middle() +{ + error->all(FLERR,"Rrespa has not been included!"); +} + +/* ---------------------------------------------------------------------- */ + +void PairLJCutHARSAT::compute_outer(int eflag, int vflag) +{ + error->all(FLERR,"Rrespa has not been included!"); + +} + +/* ---------------------------------------------------------------------- + allocate all arrays +------------------------------------------------------------------------- */ + +void PairLJCutHARSAT::allocate() +{ + allocated = 1; + int n = atom->ntypes; + + memory->create(setflag,n+1,n+1,"pairLJHAT:setflag"); + for (int i = 1; i <= n; i++) + for (int j = i; j <= n; j++) + setflag[i][j] = 0; + + memory->create(cutsq,n+1,n+1,"pairLJHAT:cutsq"); + + memory->create(cut,n+1,n+1,"pairLJHAT:cut"); + memory->create(epsilon,n+1,n+1,"pairLJHAT:epsilon"); + memory->create(sigma,n+1,n+1,"pairLJHAT:sigma"); + memory->create(lj1,n+1,n+1,"pairLJHAT:lj1"); + memory->create(lj2,n+1,n+1,"pairLJHAT:lj2"); + memory->create(lj3,n+1,n+1,"pairLJHAT:lj3"); + memory->create(lj4,n+1,n+1,"pairLJHAT:lj4"); + memory->create(offset,n+1,n+1,"pairLJHAT:offset"); + +} + +/* ---------------------------------------------------------------------- + global settings +------------------------------------------------------------------------- */ + +void PairLJCutHARSAT::settings(int narg, char **arg) +{ + if (narg != 3) error->all(FLERR,"Illegal pair_style command"); + + cut_global = force->numeric(FLERR,arg[0]); + + // reset cutoffs that have been explicitly set + AllAtomistic = force->numeric(FLERR,arg[1]); + + Load_File_Flag = force->numeric(FLERR,arg[2]); + + + if (allocated) { + int i,j; + for (i = 1; i <= atom->ntypes; i++) + for (j = i+1; j <= atom->ntypes; j++) + if (setflag[i][j]) cut[i][j] = cut_global; + } + + + +} + +/* ---------------------------------------------------------------------- + set coeffs for one or more type pairs +------------------------------------------------------------------------- */ + +void PairLJCutHARSAT::coeff(int narg, char **arg) +{ + + + if (narg < 4 || narg > 5) + error->all(FLERR,"Incorrect args for pair coefficients"); + if (!allocated) allocate(); + + int ilo,ihi,jlo,jhi; + force->bounds(arg[0],atom->ntypes,ilo,ihi); + force->bounds(arg[1],atom->ntypes,jlo,jhi); + + double epsilon_one = force->numeric(FLERR,arg[2]); + double sigma_one = force->numeric(FLERR,arg[3]); + + double cut_one = cut_global; + if (narg == 5) cut_one = force->numeric(FLERR,arg[4]); + + + int count = 0; + for (int i = ilo; i <= ihi; i++) { + for (int j = MAX(jlo,i); j <= jhi; j++) { + epsilon[i][j] = epsilon_one; + sigma[i][j] = sigma_one; + cut[i][j] = cut_one; + setflag[i][j] = 1; + count++; + } + } + + if (count == 0) error->all(FLERR,"Incorrect args for pair coefficients"); +} + +/* ---------------------------------------------------------------------- + init specific to this pair style +------------------------------------------------------------------------- */ + +void PairLJCutHARSAT::init_style() +{ + // request regular or rRESPA neighbor lists + + + if(me == 0){ + if (screen)fprintf(screen,"AT_H_AdResS_allocated flag = %d\n",H_AdResS_allocated); + if (logfile)fprintf(logfile,"AT_H_AdResS_allocated flag = %d\n",H_AdResS_allocated); + } + + if(!H_AdResS_allocated)H_AdResS_Allocation(); + + int This_Step = update->ntimestep; + if((This_Step > AT_Update_Time_Begin || Load_File_Flag) && AT_Pressure_Comp_Flag != 0)Load_Compensation_Pressure(); + + if(This_Step < AT_Update_Time_End && This_Step >= AT_Update_Time_Begin)Comp_Counter_H = floor((This_Step-AT_Update_Time_Begin)/AT_Update_Frequency); + + if(me==0 && This_Step < AT_Update_Time_End && This_Step > AT_Update_Time_Begin){ + if(screen)fprintf(screen,"AT_Pressure componsation forces are again being updated after previous %d times\n",Comp_Counter_H); + if(logfile)fprintf(logfile,"AT_Pressure componsation forces are again being updated after previous %d times\n",Comp_Counter_H); + } + + + int irequest; + + if (update->whichflag == 1 && strstr(update->integrate_style,"respa")) { + int respa = 0; + if (((Respa *) update->integrate)->level_inner >= 0) respa = 1; + if (((Respa *) update->integrate)->level_middle >= 0) respa = 2; + + if (respa == 0) irequest = neighbor->request(this,instance_me); + else if (respa == 1) { + irequest = neighbor->request(this,instance_me); + neighbor->requests[irequest]->id = 1; + neighbor->requests[irequest]->half = 0; + neighbor->requests[irequest]->respainner = 1; + irequest = neighbor->request(this,instance_me); + neighbor->requests[irequest]->id = 3; + neighbor->requests[irequest]->half = 0; + neighbor->requests[irequest]->respaouter = 1; + } else { + irequest = neighbor->request(this,instance_me); + neighbor->requests[irequest]->id = 1; + neighbor->requests[irequest]->half = 0; + neighbor->requests[irequest]->respainner = 1; + irequest = neighbor->request(this,instance_me); + neighbor->requests[irequest]->id = 2; + neighbor->requests[irequest]->half = 0; + neighbor->requests[irequest]->respamiddle = 1; + irequest = neighbor->request(this,instance_me); + neighbor->requests[irequest]->id = 3; + neighbor->requests[irequest]->half = 0; + neighbor->requests[irequest]->respaouter = 1; + } + + } else { + irequest = neighbor->request(this,instance_me); + } + // set rRESPA cutoffs + + if (strstr(update->integrate_style,"respa") && + ((Respa *) update->integrate)->level_inner >= 0) + cut_respa = ((Respa *) update->integrate)->cutoff; + else cut_respa = NULL; +} + +/* ---------------------------------------------------------------------- + neighbor callback to inform pair style of neighbor list to use + regular or rRESPA +------------------------------------------------------------------------- */ + +void PairLJCutHARSAT::init_list(int id, NeighList *ptr) +{ + if (id == 0) list = ptr; + else if (id == 1) listinner = ptr; + else if (id == 2) listmiddle = ptr; + else if (id == 3) listouter = ptr; +} + +/* ---------------------------------------------------------------------- + init for one type pair i,j and corresponding j,i +------------------------------------------------------------------------- */ + +double PairLJCutHARSAT::init_one(int i, int j) +{ + if (setflag[i][j] == 0) { + epsilon[i][j] = mix_energy(epsilon[i][i],epsilon[j][j], + sigma[i][i],sigma[j][j]); + sigma[i][j] = mix_distance(sigma[i][i],sigma[j][j]); + cut[i][j] = mix_distance(cut[i][i],cut[j][j]); + } + + + lj1[i][j] = 48.0 * epsilon[i][j] * pow(sigma[i][j],12.0); + lj2[i][j] = 24.0 * epsilon[i][j] * pow(sigma[i][j],6.0); + lj3[i][j] = 4.0 * epsilon[i][j] * pow(sigma[i][j],12.0); + lj4[i][j] = 4.0 * epsilon[i][j] * pow(sigma[i][j],6.0); + + + if (offset_flag) { + double ratio = sigma[i][j] / cut[i][j]; + offset[i][j] = 4.0 * epsilon[i][j] * (pow(ratio,12.0) - pow(ratio,6.0)); + } else offset[i][j] = 0.0; + + lj1[j][i] = lj1[i][j]; + lj2[j][i] = lj2[i][j]; + lj3[j][i] = lj3[i][j]; + lj4[j][i] = lj4[i][j]; + offset[j][i] = offset[i][j]; + + // check interior rRESPA cutoff + + if (cut_respa && cut[i][j] < cut_respa[3]) + error->all(FLERR,"Pair cutoff < Respa interior cutoff"); + + // compute I,J contribution to long-range tail correction + // count total # of atoms of type I and J via Allreduce + + if (tail_flag) { + int *type = atom->type; + int nlocal = atom->nlocal; + + double count[2],all[2]; + count[0] = count[1] = 0.0; + for (int k = 0; k < nlocal; k++) { + if (type[k] == i) count[0] += 1.0; + if (type[k] == j) count[1] += 1.0; + } + MPI_Allreduce(count,all,2,MPI_DOUBLE,MPI_SUM,world); + + double sig2 = sigma[i][j]*sigma[i][j]; + double sig6 = sig2*sig2*sig2; + double rc3 = cut[i][j]*cut[i][j]*cut[i][j]; + double rc6 = rc3*rc3; + double rc9 = rc3*rc6; + etail_ij = 8.0*MY_PI*all[0]*all[1]*epsilon[i][j] * + sig6 * (sig6 - 3.0*rc6) / (9.0*rc9); + ptail_ij = 16.0*MY_PI*all[0]*all[1]*epsilon[i][j] * + sig6 * (2.0*sig6 - 3.0*rc6) / (9.0*rc9); + } + + + return cut[i][j]; +} + +/* ---------------------------------------------------------------------- + proc 0 writes to restart file +------------------------------------------------------------------------- */ + +void PairLJCutHARSAT::write_restart(FILE *fp) +{ + write_restart_settings(fp); + + int i,j; + for (i = 1; i <= atom->ntypes; i++) + for (j = i; j <= atom->ntypes; j++) { + fwrite(&setflag[i][j],sizeof(int),1,fp); + if (setflag[i][j]) { + fwrite(&epsilon[i][j],sizeof(double),1,fp); + fwrite(&sigma[i][j],sizeof(double),1,fp); + fwrite(&cut[i][j],sizeof(double),1,fp); + } + } +} + +/* ---------------------------------------------------------------------- + proc 0 reads from restart file, bcasts +------------------------------------------------------------------------- */ + +void PairLJCutHARSAT::read_restart(FILE *fp) +{ + read_restart_settings(fp); + allocate(); + + int i,j; + int me = comm->me; + for (i = 1; i <= atom->ntypes; i++) + for (j = i; j <= atom->ntypes; j++) { + if (me == 0) fread(&setflag[i][j],sizeof(int),1,fp); + MPI_Bcast(&setflag[i][j],1,MPI_INT,0,world); + if (setflag[i][j]) { + if (me == 0) { + fread(&epsilon[i][j],sizeof(double),1,fp); + fread(&sigma[i][j],sizeof(double),1,fp); + fread(&cut[i][j],sizeof(double),1,fp); + } + MPI_Bcast(&epsilon[i][j],1,MPI_DOUBLE,0,world); + MPI_Bcast(&sigma[i][j],1,MPI_DOUBLE,0,world); + MPI_Bcast(&cut[i][j],1,MPI_DOUBLE,0,world); + } + } +} + +/* ---------------------------------------------------------------------- + proc 0 writes to restart file +------------------------------------------------------------------------- */ + +void PairLJCutHARSAT::write_restart_settings(FILE *fp) +{ + fwrite(&cut_global,sizeof(double),1,fp); + fwrite(&offset_flag,sizeof(int),1,fp); + fwrite(&mix_flag,sizeof(int),1,fp); + fwrite(&tail_flag,sizeof(int),1,fp); +} + +/* ---------------------------------------------------------------------- + proc 0 reads from restart file, bcasts +------------------------------------------------------------------------- */ + +void PairLJCutHARSAT::read_restart_settings(FILE *fp) +{ + int me = comm->me; + if (me == 0) { + fread(&cut_global,sizeof(double),1,fp); + fread(&offset_flag,sizeof(int),1,fp); + fread(&mix_flag,sizeof(int),1,fp); + fread(&tail_flag,sizeof(int),1,fp); + } + MPI_Bcast(&cut_global,1,MPI_DOUBLE,0,world); + MPI_Bcast(&offset_flag,1,MPI_INT,0,world); + MPI_Bcast(&mix_flag,1,MPI_INT,0,world); + MPI_Bcast(&tail_flag,1,MPI_INT,0,world); +} + +/* ---------------------------------------------------------------------- + proc 0 writes to data file +------------------------------------------------------------------------- */ + +void PairLJCutHARSAT::write_data(FILE *fp) +{ + for (int i = 1; i <= atom->ntypes; i++) + fprintf(fp,"%d %g %g\n",i,epsilon[i][i],sigma[i][i]); +} + +/* ---------------------------------------------------------------------- + proc 0 writes all pairs to data file +------------------------------------------------------------------------- */ + +void PairLJCutHARSAT::write_data_all(FILE *fp) +{ + for (int i = 1; i <= atom->ntypes; i++) + for (int j = i; j <= atom->ntypes; j++) + fprintf(fp,"%d %d %g %g %g\n",i,j,epsilon[i][j],sigma[i][j],cut[i][j]); +} + +/* ---------------------------------------------------------------------- */ + +double PairLJCutHARSAT::single(int i, int j, int itype, int jtype, double rsq, + double factor_coul, double factor_lj, + double &fforce) +{ + double r2inv,r6inv,forcelj,philj; + + r2inv = 1.0/rsq; + r6inv = r2inv*r2inv*r2inv; + forcelj = r6inv * (lj1[itype][jtype]*r6inv - lj2[itype][jtype]); + fforce = factor_lj*forcelj*r2inv; + + philj = r6inv*(lj3[itype][jtype]*r6inv-lj4[itype][jtype]) - + offset[itype][jtype]; + return factor_lj*philj; +} + +/* ---------------------------------------------------------------------- */ + +void *PairLJCutHARSAT::extract(const char *str, int &dim) +{ + dim = 2; + if (strcmp(str,"epsilon") == 0) return (void *) epsilon; + if (strcmp(str,"sigma") == 0) return (void *) sigma; + return NULL; +} + + +int PairLJCutHARSAT::molecules_in_group(tagint &idlo, tagint &idhi) +{ + int i; + + memory->destroy(AT_molmap_H); + AT_molmap_H = NULL; + + // find lo/hi molecule ID for any atom in group + // warn if atom in group has ID = 0 + + tagint *molecule = atom->molecule; + int *mask = atom->mask; + int nlocal = atom->nlocal; + + tagint lo = BIG; + tagint hi = -BIG; + int flag = 0; + for (i = 0; i < nlocal; i++) + { +// if (mask[i] & groupbit) { + if (mask[i]) { + if (molecule[i] == 0) flag = 1; + lo = MIN(lo,molecule[i]); + hi = MAX(hi,molecule[i]); + } + } + + int flagall; + MPI_Allreduce(&flag,&flagall,1,MPI_INT,MPI_SUM,world); + if (flagall && comm->me == 0) + error->warning(FLERR,"Atom with molecule ID = 0 included in " + "compute molecule group"); + + MPI_Allreduce(&lo,&idlo,1,MPI_LMP_TAGINT,MPI_MIN,world); + MPI_Allreduce(&hi,&idhi,1,MPI_LMP_TAGINT,MPI_MAX,world); + if (idlo == BIG) return 0; + + // molmap = vector of length nlen + // set to 1 for IDs that appear in group across all procs, else 0 + + tagint nlen_tag = idhi-idlo+1; + if (nlen_tag > MAXSMALLINT) + error->all(FLERR,"Too many molecules for compute"); + int nlen = (int) nlen_tag; + + memory->create(AT_molmap_H,nlen,"pair:molmap_H"); + for (i = 0; i < nlen; i++) AT_molmap_H[i] = 0; + + for (i = 0; i < nlocal; i++) + // if (mask[i] & groupbit) + if (mask[i]) + AT_molmap_H[molecule[i]-idlo] = 1; + + int *AT_molmapall; + memory->create(AT_molmapall,nlen,"pair:AT_molmapall"); + MPI_Allreduce(AT_molmap_H,AT_molmapall,nlen,MPI_INT,MPI_MAX,world); + + // nmolecules = # of non-zero IDs in molmap + // molmap[i] = index of molecule, skipping molecules not in group with -1 + + int nmolecules = 0; + for (i = 0; i < nlen; i++) + if (AT_molmapall[i]) AT_molmap_H[i] = nmolecules++; + else AT_molmap_H[i] = -1; + memory->destroy(AT_molmapall); + + // warn if any molecule has some atoms in group and some not in group + + flag = 0; + for (i = 0; i < nlocal; i++) { +// if (mask[i] & groupbit) continue; + if (mask[i]) continue; + if (molecule[i] < idlo || molecule[i] > idhi) continue; + if (AT_molmap_H[molecule[i]-idlo] >= 0) flag = 1; + } + + MPI_Allreduce(&flag,&flagall,1,MPI_INT,MPI_SUM,world); + if (flagall && comm->me == 0) + error->warning(FLERR, + "One or more compute molecules has atoms not in group"); + + // if molmap simply stores 1 to Nmolecules, then free it + + if (idlo == 1 && idhi == nmolecules && nlen == nmolecules) { + memory->destroy(AT_molmap_H); + AT_molmap_H = NULL; + } + return nmolecules; +} + + +void PairLJCutHARSAT::AT_Print_Compensation_Energy(){ + + FILE *fp1; + fp1 = fopen("Mean_Comp_Energy_AT.txt","w"); + if (fp1 == NULL) { + char str[128]; + sprintf(str,"Cannot open Mean_Comp_Energy_AT.txt file %s","Mean_Comp_Energy_AT.txt"); + error->one(FLERR,str); + } + + for(int i = 0;i < AT_Bin_Num; i++){ + fprintf(fp1,"%d",i+1); + for(int j = 0; j < atom->nmoltypesH; j++){ + fprintf(fp1,"\t%.10f",Mean_Comp_Energy_H[i][j]); + } + fprintf(fp1,"\n"); + } + fclose(fp1); +} + + + +void PairLJCutHARSAT::AT_Update_Compensation_Energy(){ + + MPI_Allreduce(&Comp_Energy_H[0][0],&Comp_Energy_all_H[0][0],AT_Bin_Num*atom->nmoltypesH,MPI_DOUBLE,MPI_SUM,world); + MPI_Allreduce(&Comp_Energy_Num_H[0][0],&Comp_Energy_Num_all_H[0][0],AT_Bin_Num*atom->nmoltypesH,MPI_INT,MPI_SUM,world); + + for(int j = 0;j < atom->nmoltypesH; j++){ + for(int i = 0;i < AT_Bin_Num; i++){ + Mean_Energy_H[i][j] = Comp_Energy_all_H[i][j] / Comp_Energy_Num_all_H[i][j]; + Mean_Comp_Energy_H[i][j] = (Comp_Counter_H * Mean_Comp_Energy_H[i][j] + Mean_Energy_H[i][j]) / (Comp_Counter_H + 1); + Int_Mean_Energy_H[i][j]=0; + } + } + + Comp_Counter_H++; + + for(int j = 0;j < atom->nmoltypesH; j++){ + for(int i = 0;i < AT_Bin_Num; i++){ + Comp_Energy_Num_H[i][j] = 0; + Comp_Energy_Num_all_H[i][j] = 0; + Comp_Energy_H[i][j] = 0; + Comp_Energy_all_H[i][j] =0; + } + + } + if (me == 0)AT_Print_Compensation_Energy(); + + + +} + + +void PairLJCutHARSAT::Load_Compensation_Pressure(){ + + if(me == 0){ + FILE *fp1; + char str[128]; + + fp1 = fopen("Mean_Comp_Energy_AT.txt","r"); + if (fp1 == NULL) { + sprintf(str,"Cannot open fix Mean_Comp_Energy_AT.txt file %s","Mean_Comp_Energy_AT.txt"); + error->one(FLERR,str); + } + + int i1; + + float f1; + while (!feof(fp1)){ + fscanf (fp1,"%d",&i1); + for(int j=0;jnmoltypesH;j++){ + fscanf (fp1,"\t%f",&f1); + Mean_Comp_Energy_H[i1-1][j] = f1; + } + fscanf (fp1,"\n"); + if(i1 > AT_Bin_Num){ + sprintf(str,"At drift force compensation bin number mismatches %d != %d",AT_Bin_Num,i1); + error->one(FLERR,str); + } + + } + + fclose(fp1); + + if(me==0){ + if(screen)fprintf(screen,"AT_Pressure componsation forces distributed successfully!\n"); + if(logfile)fprintf(logfile,"AT_Pressure componsation forces distributed successfully!\n"); + } + + } + + MPI_Bcast(Mean_Comp_Energy_H,AT_Bin_Num,MPI_DOUBLE,0,world); + + +} + +void PairLJCutHARSAT::H_AdResS_Allocation(){ + + for (int i = 0; i < modify->nfix; i++){ + if (strcmp(modify->fix[i]->style,"lambdah/calc") == 0){ + lambda_H_fix = (FixLambdaHCalc *) modify->fix[i]; + AT_lambda_Increment = lambda_H_fix->Pressure_lambda_Increment; + AT_Bin_Num = lambda_H_fix->Pressure_Bin_Num; + AT_Update_Frequency = lambda_H_fix->Pressure_Update_Frequency; + AT_Update_Time_Begin = lambda_H_fix->Pressure_Update_Time_Begin; + AT_Update_Time_End = lambda_H_fix->Pressure_Update_Time_End; + + AT_Pressure_Comp_Flag = lambda_H_fix->Pressure_Comp_Flag; + AT_center_box = lambda_H_fix->center_box; + AT_Hybrid_Style = lambda_H_fix->Hybrid_Style; + + + } + } + + if(me == 0){ + if (screen){ + fprintf(screen,"AT_lambda_Increment= %f\n",AT_lambda_Increment); + fprintf(screen,"AT_Bin_Num= %d\n",AT_Bin_Num); + fprintf(screen,"AT_Update_Frequency= %d\n",AT_Update_Frequency); + fprintf(screen,"AT_Update_Time_Begin= %d\n",AT_Update_Time_Begin); + fprintf(screen,"AT_Update_Time_End= %d\n",AT_Update_Time_End); + fprintf(screen,"AT_Pressure_Comp_Flag= %d\n",AT_Pressure_Comp_Flag); + } + + if (logfile){ + fprintf(logfile,"AT_lambda_Increment= %f\n",AT_lambda_Increment); + fprintf(logfile,"AT_Bin_Num= %d\n",AT_Bin_Num); + fprintf(logfile,"AT_Update_Frequency= %d\n",AT_Update_Frequency); + fprintf(logfile,"AT_Update_Time_Begin= %d\n",AT_Update_Time_Begin); + fprintf(logfile,"AT_Update_Time_End= %d\n",AT_Update_Time_End); + fprintf(logfile,"AT_Pressure_Comp_Flag= %d\n",AT_Pressure_Comp_Flag); + } + } + + memory->create(Comp_Energy_Num_H,AT_Bin_Num,atom->nmoltypesH,"pairLJHAT:Comp_Energy_Num_H"); + memory->create(Comp_Energy_Num_all_H,AT_Bin_Num,atom->nmoltypesH,"pairLJHAT:Comp_Energy_Num_all_H"); + + memory->create(Int_Mean_Energy_H,AT_Bin_Num,atom->nmoltypesH,"pairLJHAT:Int_Mean_Energy_H"); + memory->create(Comp_Energy_H,AT_Bin_Num,atom->nmoltypesH,"pairLJHAT:Comp_Energy_H"); + memory->create(Comp_Energy_all_H,AT_Bin_Num,atom->nmoltypesH,"pairLJHAT:Comp_Energy_all_H"); + memory->create(Mean_Comp_Energy_H,AT_Bin_Num,atom->nmoltypesH,"pairLJHAT:Mean_Comp_Energy_H"); + memory->create(Mean_Energy_H,AT_Bin_Num,atom->nmoltypesH,"pairLJHAT:Mean_Energy_H"); + + for(int j=0;jnmoltypesH;j++){ + for(int i = 0;i < AT_Bin_Num; i++){ + Int_Mean_Energy_H[i][j]=0; + Comp_Energy_H[i][j]=0; + Comp_Energy_all_H[i][j]=0; + Mean_Comp_Energy_H[i][j]=0; + Comp_Energy_Num_H[i][j] = 0; + Comp_Energy_Num_all_H[i][j] = 0; + } + + } + + H_AdResS_allocated = 1; +} + diff --git a/src/USER-HADRESS/pair_lj_cut_hars_at.h b/src/USER-HADRESS/pair_lj_cut_hars_at.h new file mode 100644 index 0000000000..04f41cfc90 --- /dev/null +++ b/src/USER-HADRESS/pair_lj_cut_hars_at.h @@ -0,0 +1,119 @@ +/* -*- c++ -*- ---------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + http://lammps.sandia.gov, Sandia National Laboratories + Steve Plimpton, sjplimp@sandia.gov + + Copyright (2003) Sandia Corporation. Under the terms of Contract + DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains + certain rights in this software. This software is distributed under + the GNU General Public License. + + See the README file in the top-level LAMMPS directory. +------------------------------------------------------------------------- */ + +#ifdef PAIR_CLASS + +PairStyle(lj/cut/hars/at,PairLJCutHARSAT) + +#else + +#ifndef LMP_PAIR_LJ_CUT_HARS_AT_H +#define LMP_PAIR_LJ_CUT_HARS_AT_H + +#include "pair.h" + +namespace LAMMPS_NS { + +class PairLJCutHARSAT : public Pair { + public: + PairLJCutHARSAT(class LAMMPS *); + virtual ~PairLJCutHARSAT(); + virtual void compute(int, int); + void settings(int, char **); + void coeff(int, char **); + void init_style(); + void init_list(int, class NeighList *); + double init_one(int, int); + void write_restart(FILE *); + void read_restart(FILE *); + void write_restart_settings(FILE *); + void read_restart_settings(FILE *); + void write_data(FILE *); + void write_data_all(FILE *); + double single(int, int, int, int, double, double, double, double &); + void *extract(const char *, int &); + + void compute_inner(); + void compute_middle(); + void compute_outer(int, int); + + void AT_Print_Compensation_Energy(); + void AT_Update_Compensation_Energy(); + + protected: + double cut_global; + double **cut; + double **epsilon,**sigma; + double **lj1,**lj2,**lj3,**lj4,**offset; + double *cut_respa; + class FixLambdaHCalc *lambda_H_fix; + + int AllAtomistic; + + virtual void allocate(); + +//private: + int me; + + int H_AdResS_allocated; + + int **Comp_Energy_Num_H,**Comp_Energy_Num_all_H, Comp_Counter_H; + + double AT_lambda_Increment; + int AT_Bin_Num, AT_Update_Frequency, AT_Update_Time_End, AT_Update_Time_Begin; + int AT_Pressure_Compensation_Run; + int AT_Pressure_Comp_Flag; + + double *AT_center_box,AT_x0lo; + int AT_Hybrid_Style; + double **Int_Mean_Energy_H, **Comp_Energy_H, **Comp_Energy_all_H, **Mean_Energy_H, **Mean_Comp_Energy_H; + + int nmolecules; + tagint idlo,idhi; + + double *AT_massproc_H,*AT_masstotal_H; + + double **AT_mol_f_H, **AT_mol_f_all_H; + + int *AT_molmap_H; // convert molecule ID to local index + int Load_File_Flag; + + int molecules_in_group(tagint &, tagint &); + void Load_Compensation_Pressure(); + void H_AdResS_Allocation(); + +}; + +} + +#endif +#endif + +/* ERROR/WARNING messages: + +E: Illegal ... command + +Self-explanatory. Check the input script syntax and compare to the +documentation for the command. You can use -echo screen as a +command-line option when running LAMMPS to see the offending line. + +E: Incorrect args for pair coefficients + +Self-explanatory. Check the input script or data file. + +E: Pair cutoff < Respa interior cutoff + +One or more pairwise cutoffs are too short to use with the specified +rRESPA cutoffs. + +*/ diff --git a/src/USER-HADRESS/pair_lj_cut_hars_cg.cpp b/src/USER-HADRESS/pair_lj_cut_hars_cg.cpp new file mode 100644 index 0000000000..19db437179 --- /dev/null +++ b/src/USER-HADRESS/pair_lj_cut_hars_cg.cpp @@ -0,0 +1,1127 @@ +/* ---------------------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + http://lammps.sandia.gov, Sandia National Laboratories + Steve Plimpton, sjplimp@sandia.gov + + Copyright (2003) Sandia Corporation. Under the terms of Contract + DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains + certain rights in this software. This software is distributed under + the GNU General Public License. + + See the README file in the top-level LAMMPS directory. +------------------------------------------------------------------------- */ + +/* ---------------------------------------------------------------------- + Contributing author: Paul Crozier (SNL) +------------------------------------------------------------------------- */ +#include "mpi.h" +#include "math.h" +#include "stdio.h" +#include "stdlib.h" +#include "string.h" +#include "pair_lj_cut_hars_cg.h" +#include "atom.h" +#include "atom_vec.h" +#include "comm.h" +#include "force.h" +#include "neighbor.h" +#include "neigh_list.h" +#include "neigh_request.h" +#include "update.h" +#include "integrate.h" +#include "respa.h" +#include "math_const.h" +#include "memory.h" +#include "error.h" +#include "domain.h" +#include "iostream" +#include "fix.h" +#include "fix_lambdah_calc.h" +#include "modify.h" + +using namespace LAMMPS_NS; +using namespace MathConst; + +#define BIG MAXTAGINT + +/* ---------------------------------------------------------------------- */ + +PairLJCutHARSCG::PairLJCutHARSCG(LAMMPS *lmp) : Pair(lmp) +{ + respa_enable = 1; + writedata = 1; + + massproc_H = NULL; + masstotal_H = NULL; + molmap_H = NULL; + mol_f_H = NULL; + mol_f_all_H = NULL; + Comp_Energy_Num_H = NULL; + Comp_Energy_Num_all_H = NULL; + + Int_Mean_Energy_H = NULL; + Mean_Energy_H = NULL; + Comp_Energy_H = NULL; + Comp_Energy_all_H = NULL; + Mean_Comp_Energy_H = NULL; + CG_Mean_grad_Comp_Density_Conv_H = NULL; + + molmap_H = NULL; + nmolecules = molecules_in_group(idlo,idhi); + + H_AdResS_allocated = 0; + + CG_Pressure_Compensation_Run = 0; + Density_Compensation_Run = 0; + Comp_Counter_H = 0; + CG_Density_Comp_Flag = 0; + CG_Pressure_Comp_Flag = 0; + + + memory->create(massproc_H,nmolecules,"pair:massproc_H"); + memory->create(masstotal_H,nmolecules,"pair:masstotal_H"); + memory->create(mol_f_H,nmolecules,3,"pair:mol_f_H"); + memory->create(mol_f_all_H,nmolecules,3,"pair:mol_f_all_H"); + + + // compute masstotal for each molecule + + MPI_Comm_rank(world, &me); + int *mask = atom->mask; + tagint *molecule = atom->molecule; + int *type = atom->type; + double *mass = atom->mass; + double *rmass = atom->rmass; + int nlocal = atom->nlocal; + tagint imol; + double massone; + + for (int i = 0; i < nmolecules; i++) massproc_H[i] = 0.0; + + for (int i = 0; i < nlocal; i++) + { +// if (mask[i] & groupbit) { + if (mask[i]) { + if (rmass) massone = rmass[i]; + else massone = mass[type[i]]; + imol = molecule[i]; + if (molmap_H) imol = molmap_H[imol-idlo]; + else imol--; + massproc_H[imol] += massone; + + } + } + + MPI_Allreduce(massproc_H,masstotal_H,nmolecules,MPI_DOUBLE,MPI_SUM,world); + +} + +/* ---------------------------------------------------------------------- */ + +PairLJCutHARSCG::~PairLJCutHARSCG() +{ + + + if (allocated) { + + memory->destroy(setflag); + memory->destroy(cutsq); + + memory->destroy(cut); + memory->destroy(epsilon); + memory->destroy(sigma); + memory->destroy(lj1); + memory->destroy(lj2); + memory->destroy(lj3); + memory->destroy(lj4); + memory->destroy(offset); + memory->destroy(massproc_H); + memory->destroy(masstotal_H); + memory->destroy(molmap_H); + memory->destroy(mol_f_H); + memory->destroy(mol_f_all_H); + memory->destroy(Comp_Energy_Num_H); + memory->destroy(Comp_Energy_Num_all_H); + memory->destroy(Int_Mean_Energy_H); + memory->destroy(Mean_Energy_H); + memory->destroy(Comp_Energy_H); + memory->destroy(Comp_Energy_all_H); + memory->destroy(Mean_Comp_Energy_H); + // memory->destroy(CG_Mean_grad_Comp_Density_Conv_H); + +// delete lambda_H_fix; +} +} + +/* ---------------------------------------------------------------------- */ + +void PairLJCutHARSCG::compute(int eflag, int vflag) +{ + int i,j,ii,jj,inum,jnum,itype,jtype; + double xtmp,ytmp,ztmp,delx,dely,delz,evdwl,fpair; + double rsq,r2inv,r6inv,forcelj, factor_lj,Vij; + int *ilist,*jlist,*numneigh,**firstneigh; + int imoltype,jmoltype; + + evdwl = 0.0; + if (eflag || vflag) ev_setup(eflag,vflag); + else evflag = vflag_fdotr = 0; + + double **x = atom->x; + double **f = atom->f; + double *lambdaH = atom->lambdaH; + double **gradlambdaH = atom->gradlambdaH; + double **comH = atom->comH; + int *replambdaH = atom->replambdaH; + tagint *molecule = atom->molecule; + double *mass = atom->mass; + int *moltypeH = atom->moltypeH; + int *type = atom->type; + int nlocal = atom->nlocal; + double *special_lj = force->special_lj; + int newton_pair = force->newton_pair; + + int ibin, jbin; + + inum = list->inum; + ilist = list->ilist; + numneigh = list->numneigh; + firstneigh = list->firstneigh; + + double iLambda, jLambda, ijLambda; + int imol,jmol; + + + + int This_Step = update->ntimestep; + if(This_Step >= CG_Update_Time_Begin && This_Step < CG_Update_Time_End && CG_Pressure_Comp_Flag != 0){ + CG_Pressure_Compensation_Run = 1; + if(me==0 && This_Step == CG_Update_Time_Begin){ + if(screen)fprintf(screen,"\nStart of constant-pressure route\n"); + if(logfile)fprintf(logfile,"\nStart of constant-pressure route\n"); + } + } + + + if(update->ntimestepDensity_Compensation_Run; + + if(Density_Compensation_Run){ + CG_Mean_grad_Comp_Density_Conv_H = lambda_H_fix->Mean_grad_Comp_Density_Conv_H; + } + + for (ii = 0; ii < inum; ii++) { + + i = ilist[ii]; + if(replambdaH[i] == 0)continue; + + xtmp = comH[i][0]; + ytmp = comH[i][1]; + ztmp = comH[i][2]; + +// itype = moltypeH[i]; + itype = type[i]; + jlist = firstneigh[i]; + jnum = numneigh[i]; + imoltype = itype - 1; + + iLambda = 1 - lambdaH[i]; + + for (jj = 0; jj < jnum; jj++) { + + j = jlist[jj]; + factor_lj = special_lj[sbmask(j)]; + j &= NEIGHMASK; + jLambda = 1 - lambdaH[j]; + + if(replambdaH[j] == 0)continue; + + if((iLambda==0 && jLambda==0) && AllCoarseGrained != 1)continue; + + delx = xtmp - comH[j][0]; + dely = ytmp - comH[j][1]; + delz = ztmp - comH[j][2]; + + domain->minimum_image(delx,dely,delz); + + rsq = delx*delx + dely*dely + delz*delz; + jtype = type[j]; + //jtype = moltypeH[j]; + jmoltype = jtype - 1; + +// if (rsq < cutsq[itype][jtype] && lj1[itype][jtype] != 0) { + if (rsq < cutsq[itype][jtype]) { + + + imol = molecule[i]; + jmol = molecule[j]; + if (molmap_H) { + imol = molmap_H[imol-idlo]; + jmol = molmap_H[jmol-idlo]; + } + else { + imol--; + jmol--; + } + + + if(((iLambda==1 && jLambda==1) || AllCoarseGrained)){ + + r2inv = 1.0/rsq; + r6inv = r2inv*r2inv*r2inv; + forcelj = r6inv * (lj1[itype][jtype]*r6inv - lj2[itype][jtype]); + + fpair = factor_lj*forcelj*r2inv; + mol_f_H[imol][0] += delx*fpair; + mol_f_H[imol][1] += dely*fpair; + mol_f_H[imol][2] += delz*fpair; + + if (newton_pair || j < nlocal) { + mol_f_H[jmol][0] -= delx*fpair; + mol_f_H[jmol][1] -= dely*fpair; + mol_f_H[jmol][2] -= delz*fpair; + } + + if (eflag) { + evdwl = r6inv*(lj3[itype][jtype]*r6inv-lj4[itype][jtype]) - + offset[itype][jtype]; + evdwl *= factor_lj; + } + + if (evflag) ev_tally(i,j,nlocal,newton_pair, + evdwl,0.0,fpair,delx,dely,delz); + + } + + else if(iLambda != 0 || jLambda != 0){ + + ijLambda = 0.5 * (iLambda + jLambda); + r2inv = 1.0/rsq; + r6inv = r2inv*r2inv*r2inv; + forcelj = r6inv * (lj1[itype][jtype]*r6inv - lj2[itype][jtype]); + fpair = factor_lj*(forcelj*ijLambda)*r2inv; + + Vij = 0.5*(r6inv*(lj3[itype][jtype]*r6inv-lj4[itype][jtype]) - + offset[itype][jtype]); + + + ibin = floor(iLambda/CG_lambda_Increment); + if(ibin==CG_Bin_Num)ibin = CG_Bin_Num - 1; + + if(CG_Pressure_Compensation_Run != 0 && iLambda != 0 && iLambda != 1)Comp_Energy_H[ibin][imoltype] += Vij; + + mol_f_H[imol][0] += delx*fpair + Vij*gradlambdaH[i][0]; + mol_f_H[imol][1] += dely*fpair + Vij*gradlambdaH[i][1]; + mol_f_H[imol][2] += delz*fpair + Vij*gradlambdaH[i][2]; + + if (newton_pair || j < nlocal) { + + jbin = floor(jLambda/CG_lambda_Increment); + if(jbin==CG_Bin_Num)jbin = CG_Bin_Num - 1; + if(CG_Pressure_Compensation_Run != 0 && jLambda != 0 && jLambda != 1)Comp_Energy_H[jbin][jmoltype] += Vij; + + mol_f_H[jmol][0] -= delx*fpair - Vij*gradlambdaH[j][0]; + mol_f_H[jmol][1] -= dely*fpair - Vij*gradlambdaH[j][1]; + mol_f_H[jmol][2] -= delz*fpair - Vij*gradlambdaH[j][2]; + + } + + if (eflag) { + evdwl = ijLambda*Vij*2.0; + evdwl *= factor_lj; + } + + if (evflag) ev_tally(i,j,nlocal,newton_pair, + evdwl,0.0,fpair,delx,dely,delz); + + } + } + + } + } + + + MPI_Allreduce(&mol_f_H[0][0],&mol_f_all_H[0][0],3*nmolecules,MPI_DOUBLE,MPI_SUM,world); + + if(CG_Pressure_Compensation_Run != 0 && CG_Pressure_Comp_Flag != 0){ + for (int i = 0; i < nlocal; i++){ + iLambda = 1 - lambdaH[i]; + if(replambdaH[i] != 0 && lambdaH[i] != 0 && lambdaH[i] != 1){ + ibin = floor(iLambda/CG_lambda_Increment); + if(ibin==CG_Bin_Num)ibin = CG_Bin_Num - 1; + itype = moltypeH[i] - 1; + Comp_Energy_Num_H[ibin][itype]++; + + } + } + + if(This_Step % CG_Update_Frequency == 0 && This_Step > CG_Update_Time_Begin)CG_Update_Compensation_Energy(); + } + + + double mol_mass,mass_frac; + double Grad_Density,r; + if(AllCoarseGrained != 1 && (CG_Density_Comp_Flag != 0 || CG_Pressure_Comp_Flag != 0)){ + + for (int i = 0; i < nlocal; i++){ + imol = molecule[i]; + if (molmap_H)imol = molmap_H[imol-idlo]; + else imol--; + mol_mass = masstotal_H[imol]; + mass_frac = mass[type[i]] / mol_mass; + iLambda = 1 - lambdaH[i]; + + if(iLambda != 0 && iLambda != 1){ + + ibin = floor(iLambda/CG_lambda_Increment); + itype = moltypeH[i] - 1; + + f[i][0] += mass_frac*(mol_f_all_H[imol][0]-gradlambdaH[i][0]*Mean_Comp_Energy_H[ibin][itype]); + f[i][1] += mass_frac*(mol_f_all_H[imol][1]-gradlambdaH[i][1]*Mean_Comp_Energy_H[ibin][itype]); + f[i][2] += mass_frac*(mol_f_all_H[imol][2]-gradlambdaH[i][2]*Mean_Comp_Energy_H[ibin][itype]); + + if (evflag) ev_tally(i,i,nlocal,newton_pair, + -0.5*Int_Mean_Energy_H[ibin][itype],0.0,0.0,0.0,0.0,0.0); + + + if(CG_Density_Comp_Flag != 0){ + + if(CG_Hybrid_Style == 0){ + ibin = floor((comH[i][0]-CG_x0lo)/CG_Density_Bin_Size); + f[i][0] += mass_frac*(-1.0*CG_Mean_grad_Comp_Density_Conv_H[ibin][itype]); + } + else if(CG_Hybrid_Style == 1){ + delx = comH[i][0] - CG_center_box[0]; + dely = comH[i][1] - CG_center_box[1]; + delz = comH[i][2] - CG_center_box[2]; + r = sqrt(delx*delx + dely*dely + delz*delz); + ibin = floor(r/CG_Density_Bin_Size); + + Grad_Density = CG_Mean_grad_Comp_Density_Conv_H[ibin][itype] / r; + f[i][0] += -mass_frac * Grad_Density * delx; + f[i][1] += -mass_frac * Grad_Density * dely; + f[i][2] += -mass_frac * Grad_Density * delz; + } + else if(CG_Hybrid_Style == 2){ + delx = comH[i][0] - CG_center_box[0]; + dely = comH[i][1] - CG_center_box[1]; + r = sqrt(delx*delx + dely*dely); + ibin = floor(r/CG_Density_Bin_Size); + + Grad_Density = CG_Mean_grad_Comp_Density_Conv_H[ibin][itype] / r; + f[i][0] += -mass_frac * Grad_Density * delx; + f[i][1] += -mass_frac * Grad_Density * dely; + } + + } + } + else{ + f[i][0] += mass_frac*mol_f_all_H[imol][0]; + f[i][1] += mass_frac*mol_f_all_H[imol][1]; + f[i][2] += mass_frac*mol_f_all_H[imol][2]; + } + + } + + } + else{ + + for (int i = 0; i < nlocal; i++){ + imol = molecule[i]; + if (molmap_H)imol = molmap_H[imol-idlo]; + else imol--; + mol_mass = masstotal_H[imol]; + mass_frac = mass[type[i]] / mol_mass; + + f[i][0] += mass_frac*mol_f_all_H[imol][0]; + f[i][1] += mass_frac*mol_f_all_H[imol][1]; + f[i][2] += mass_frac*mol_f_all_H[imol][2]; + } + + } + + + + if(This_Step == CG_Update_Time_End){ + CG_Pressure_Compensation_Run = 0; + if(me == 0){ + if(screen)fprintf(screen,"\nEnd of constant-pressure route\n"); + if(logfile)fprintf(logfile,"\nEnd of constant-pressure route\n"); + + } + } + + + if (vflag_fdotr) virial_fdotr_compute(); +} + +/* ---------------------------------------------------------------------- */ + +void PairLJCutHARSCG::compute_inner() +{ + + error->all(FLERR,"Rrespa has not been included!"); + +} + +/* ---------------------------------------------------------------------- */ + +void PairLJCutHARSCG::compute_middle() +{ + error->all(FLERR,"Rrespa has not been included!"); + +} + +/* ---------------------------------------------------------------------- */ + +void PairLJCutHARSCG::compute_outer(int eflag, int vflag) +{ + error->all(FLERR,"Rrespa has not been included!"); +} + +/* ---------------------------------------------------------------------- + allocate all arrays +------------------------------------------------------------------------- */ + +void PairLJCutHARSCG::allocate() +{ + + allocated = 1; + int n = atom->ntypes; + + memory->create(setflag,n+1,n+1,"pairLJHCG:setflag"); + for (int i = 1; i <= n; i++) + for (int j = i; j <= n; j++) + setflag[i][j] = 0; + + memory->create(cutsq,n+1,n+1,"pairLJHCG:cutsq"); + memory->create(cut,n+1,n+1,"pairLJHCG:cut"); + memory->create(epsilon,n+1,n+1,"pairLJHCG:epsilon"); + memory->create(sigma,n+1,n+1,"pairLJHCG:sigma"); + memory->create(lj1,n+1,n+1,"pairLJHCG:lj1"); + memory->create(lj2,n+1,n+1,"pairLJHCG:lj2"); + memory->create(lj3,n+1,n+1,"pairLJHCG:lj3"); + memory->create(lj4,n+1,n+1,"pairLJHCG:lj4"); + memory->create(offset,n+1,n+1,"pairLJHCG:offset"); + + + +} + +/* ---------------------------------------------------------------------- + global settings +------------------------------------------------------------------------- */ + +void PairLJCutHARSCG::settings(int narg, char **arg) +{ + if (narg != 3) error->all(FLERR,"Illegal pair_style command"); + + cut_global = force->numeric(FLERR,arg[0]); + + AllCoarseGrained = force->numeric(FLERR,arg[1]); + + Load_File_Flag = force->numeric(FLERR,arg[2]); + // reset cutoffs that have been explicitly set + + if (allocated) { + int i,j; + for (i = 1; i <= atom->ntypes; i++) + for (j = i+1; j <= atom->ntypes; j++) + if (setflag[i][j]) cut[i][j] = cut_global; + } + +} + +/* ---------------------------------------------------------------------- + set coeffs for one or more type pairs +------------------------------------------------------------------------- */ + +void PairLJCutHARSCG::coeff(int narg, char **arg) +{ + + if (narg < 4 || narg > 5) + error->all(FLERR,"Incorrect args for pair coefficients"); + if (!allocated) allocate(); + + int ilo,ihi,jlo,jhi; + + force->bounds(arg[0],atom->ntypes,ilo,ihi); + force->bounds(arg[1],atom->ntypes,jlo,jhi); + + + + double epsilon_one = force->numeric(FLERR,arg[2]); + double sigma_one = force->numeric(FLERR,arg[3]); + + double cut_one = cut_global; + if (narg == 5) cut_one = force->numeric(FLERR,arg[4]); + + int count = 0; + for (int i = ilo; i <= ihi; i++) { + for (int j = MAX(jlo,i); j <= jhi; j++) { + epsilon[i][j] = epsilon_one; + sigma[i][j] = sigma_one; + cut[i][j] = cut_one; + setflag[i][j] = 1; + count++; + + } + } + + if (count == 0) error->all(FLERR,"Incorrect args for pair coefficients"); +} + +/* ---------------------------------------------------------------------- + init specific to this pair style +------------------------------------------------------------------------- */ + +void PairLJCutHARSCG::init_style() +{ + // request regular or rRESPA neighbor lists + if(me == 0){ + if (screen)fprintf(screen,"CG_H_AdResS_allocated flag = %d\n",H_AdResS_allocated); + if (logfile)fprintf(logfile,"CG_H_AdResS_allocated flag = %d\n",H_AdResS_allocated); + } + + if(!H_AdResS_allocated)H_AdResS_Allocation(); + + + int This_Step = update->ntimestep; + CG_Restart_Time_Step = This_Step; + + if((This_Step > CG_Update_Time_Begin || Load_File_Flag) && CG_Pressure_Comp_Flag != 0)Load_Compensation_Pressure(); + + if(This_Step < CG_Update_Time_End && This_Step >= CG_Update_Time_Begin)Comp_Counter_H = floor((This_Step-CG_Update_Time_Begin)/CG_Update_Frequency); + + if(me==0 && This_Step < CG_Update_Time_End && This_Step > CG_Update_Time_Begin){ + if(screen)fprintf(screen,"CG_Pressure componsation forces are again being updated after previous %d times\n",Comp_Counter_H); + if(logfile)fprintf(logfile,"CG_Pressure componsation forces are again being updated after previous %d times\n",Comp_Counter_H); + } + + int irequest; + + if (update->whichflag == 1 && strstr(update->integrate_style,"respa")) { + int respa = 0; + if (((Respa *) update->integrate)->level_inner >= 0) respa = 1; + if (((Respa *) update->integrate)->level_middle >= 0) respa = 2; + + if (respa == 0)irequest = neighbor->request(this,instance_me); + else if (respa == 1) { + irequest = neighbor->request(this,instance_me); + neighbor->requests[irequest]->id = 1; + neighbor->requests[irequest]->half = 0; + neighbor->requests[irequest]->respainner = 1; + irequest = neighbor->request(this,instance_me); + neighbor->requests[irequest]->id = 3; + neighbor->requests[irequest]->half = 0; + neighbor->requests[irequest]->respaouter = 1; + } else { + irequest = neighbor->request(this,instance_me); + neighbor->requests[irequest]->id = 1; + neighbor->requests[irequest]->half = 0; + neighbor->requests[irequest]->respainner = 1; + irequest = neighbor->request(this,instance_me); + neighbor->requests[irequest]->id = 2; + neighbor->requests[irequest]->half = 0; + neighbor->requests[irequest]->respamiddle = 1; + irequest = neighbor->request(this,instance_me); + neighbor->requests[irequest]->id = 3; + neighbor->requests[irequest]->half = 0; + neighbor->requests[irequest]->respaouter = 1; + } + + } else irequest = neighbor->request(this,instance_me); + + // set rRESPA cutoffs + + if (strstr(update->integrate_style,"respa") && + ((Respa *) update->integrate)->level_inner >= 0) + cut_respa = ((Respa *) update->integrate)->cutoff; + else cut_respa = NULL; +} + +/* ---------------------------------------------------------------------- + neighbor callback to inform pair style of neighbor list to use + regular or rRESPA +------------------------------------------------------------------------- */ + +void PairLJCutHARSCG::init_list(int id, NeighList *ptr) +{ + if (id == 0) list = ptr; + else if (id == 1) listinner = ptr; + else if (id == 2) listmiddle = ptr; + else if (id == 3) listouter = ptr; +} + +/* ---------------------------------------------------------------------- + init for one type pair i,j and corresponding j,i +------------------------------------------------------------------------- */ + +double PairLJCutHARSCG::init_one(int i, int j) +{ + if (setflag[i][j] == 0) { + epsilon[i][j] = mix_energy(epsilon[i][i],epsilon[j][j], + sigma[i][i],sigma[j][j]); + sigma[i][j] = mix_distance(sigma[i][i],sigma[j][j]); + cut[i][j] = mix_distance(cut[i][i],cut[j][j]); + } + + + lj1[i][j] = 48.0 * epsilon[i][j] * pow(sigma[i][j],12.0); + lj2[i][j] = 24.0 * epsilon[i][j] * pow(sigma[i][j],6.0); + lj3[i][j] = 4.0 * epsilon[i][j] * pow(sigma[i][j],12.0); + lj4[i][j] = 4.0 * epsilon[i][j] * pow(sigma[i][j],6.0); + + + if (offset_flag) { + double ratio = sigma[i][j] / cut[i][j]; + offset[i][j] = 4.0 * epsilon[i][j] * (pow(ratio,12.0) - pow(ratio,6.0)); + } else offset[i][j] = 0.0; + + lj1[j][i] = lj1[i][j]; + lj2[j][i] = lj2[i][j]; + lj3[j][i] = lj3[i][j]; + lj4[j][i] = lj4[i][j]; + offset[j][i] = offset[i][j]; + + // check interior rRESPA cutoff + + if (cut_respa && cut[i][j] < cut_respa[3]) + error->all(FLERR,"Pair cutoff < Respa interior cutoff"); + + // compute I,J contribution to long-range tail correction + // count total # of atoms of type I and J via Allreduce + + if (tail_flag) { + int *type = atom->type; + int nlocal = atom->nlocal; + + double count[2],all[2]; + count[0] = count[1] = 0.0; + for (int k = 0; k < nlocal; k++) { + if (type[k] == i) count[0] += 1.0; + if (type[k] == j) count[1] += 1.0; + } + MPI_Allreduce(count,all,2,MPI_DOUBLE,MPI_SUM,world); + + double sig2 = sigma[i][j]*sigma[i][j]; + double sig6 = sig2*sig2*sig2; + double rc3 = cut[i][j]*cut[i][j]*cut[i][j]; + double rc6 = rc3*rc3; + double rc9 = rc3*rc6; + etail_ij = 8.0*MY_PI*all[0]*all[1]*epsilon[i][j] * + sig6 * (sig6 - 3.0*rc6) / (9.0*rc9); + ptail_ij = 16.0*MY_PI*all[0]*all[1]*epsilon[i][j] * + sig6 * (2.0*sig6 - 3.0*rc6) / (9.0*rc9); + } + + return cut[i][j]; +} + +/* ---------------------------------------------------------------------- + proc 0 writes to restart file +------------------------------------------------------------------------- */ + +void PairLJCutHARSCG::write_restart(FILE *fp) +{ + write_restart_settings(fp); + + int i,j; + for (i = 1; i <= atom->ntypes; i++) + for (j = i; j <= atom->ntypes; j++) { + fwrite(&setflag[i][j],sizeof(int),1,fp); + if (setflag[i][j]) { + fwrite(&epsilon[i][j],sizeof(double),1,fp); + fwrite(&sigma[i][j],sizeof(double),1,fp); + fwrite(&cut[i][j],sizeof(double),1,fp); + } + } +} + +/* ---------------------------------------------------------------------- + proc 0 reads from restart file, bcasts +------------------------------------------------------------------------- */ + +void PairLJCutHARSCG::read_restart(FILE *fp) +{ + read_restart_settings(fp); + allocate(); + + int i,j; + int me = comm->me; + for (i = 1; i <= atom->ntypes; i++) + for (j = i; j <= atom->ntypes; j++) { + if (me == 0) fread(&setflag[i][j],sizeof(int),1,fp); + MPI_Bcast(&setflag[i][j],1,MPI_INT,0,world); + if (setflag[i][j]) { + if (me == 0) { + fread(&epsilon[i][j],sizeof(double),1,fp); + fread(&sigma[i][j],sizeof(double),1,fp); + fread(&cut[i][j],sizeof(double),1,fp); + } + MPI_Bcast(&epsilon[i][j],1,MPI_DOUBLE,0,world); + MPI_Bcast(&sigma[i][j],1,MPI_DOUBLE,0,world); + MPI_Bcast(&cut[i][j],1,MPI_DOUBLE,0,world); + } + } +} + +/* ---------------------------------------------------------------------- + proc 0 writes to restart file +------------------------------------------------------------------------- */ + +void PairLJCutHARSCG::write_restart_settings(FILE *fp) +{ + fwrite(&cut_global,sizeof(double),1,fp); + fwrite(&offset_flag,sizeof(int),1,fp); + fwrite(&mix_flag,sizeof(int),1,fp); + fwrite(&tail_flag,sizeof(int),1,fp); +} + +/* ---------------------------------------------------------------------- + proc 0 reads from restart file, bcasts +------------------------------------------------------------------------- */ + +void PairLJCutHARSCG::read_restart_settings(FILE *fp) +{ + int me = comm->me; + if (me == 0) { + fread(&cut_global,sizeof(double),1,fp); + fread(&offset_flag,sizeof(int),1,fp); + fread(&mix_flag,sizeof(int),1,fp); + fread(&tail_flag,sizeof(int),1,fp); + } + MPI_Bcast(&cut_global,1,MPI_DOUBLE,0,world); + MPI_Bcast(&offset_flag,1,MPI_INT,0,world); + MPI_Bcast(&mix_flag,1,MPI_INT,0,world); + MPI_Bcast(&tail_flag,1,MPI_INT,0,world); +} + +/* ---------------------------------------------------------------------- + proc 0 writes to data file +------------------------------------------------------------------------- */ + +void PairLJCutHARSCG::write_data(FILE *fp) +{ + for (int i = 1; i <= atom->ntypes; i++) + fprintf(fp,"%d %g %g\n",i,epsilon[i][i],sigma[i][i]); +} + +/* ---------------------------------------------------------------------- + proc 0 writes all pairs to data file +------------------------------------------------------------------------- */ + +void PairLJCutHARSCG::write_data_all(FILE *fp) +{ + for (int i = 1; i <= atom->ntypes; i++) + for (int j = i; j <= atom->ntypes; j++) + fprintf(fp,"%d %d %g %g %g\n",i,j,epsilon[i][j],sigma[i][j],cut[i][j]); +} + +/* ---------------------------------------------------------------------- */ + +double PairLJCutHARSCG::single(int i, int j, int itype, int jtype, double rsq, + double factor_coul, double factor_lj, + double &fforce) +{ + double r2inv,r6inv,forcelj,philj; + + r2inv = 1.0/rsq; + r6inv = r2inv*r2inv*r2inv; + forcelj = r6inv * (lj1[itype][jtype]*r6inv - lj2[itype][jtype]); + fforce = factor_lj*forcelj*r2inv; + + philj = r6inv*(lj3[itype][jtype]*r6inv-lj4[itype][jtype]) - + offset[itype][jtype]; + return factor_lj*philj; +} + +/* ---------------------------------------------------------------------- */ + +void *PairLJCutHARSCG::extract(const char *str, int &dim) +{ + dim = 2; + if (strcmp(str,"epsilon") == 0) return (void *) epsilon; + if (strcmp(str,"sigma") == 0) return (void *) sigma; + return NULL; +} + + + +int PairLJCutHARSCG::molecules_in_group(tagint &idlo, tagint &idhi) +{ + int i; + + memory->destroy(molmap_H); + molmap_H = NULL; + + // find lo/hi molecule ID for any atom in group + // warn if atom in group has ID = 0 + + tagint *molecule = atom->molecule; + int *mask = atom->mask; + int nlocal = atom->nlocal; + + tagint lo = BIG; + tagint hi = -BIG; + int flag = 0; + for (i = 0; i < nlocal; i++) + { +// if (mask[i] & groupbit) { + if (mask[i]) { + if (molecule[i] == 0) flag = 1; + lo = MIN(lo,molecule[i]); + hi = MAX(hi,molecule[i]); + } + } + + int flagall; + MPI_Allreduce(&flag,&flagall,1,MPI_INT,MPI_SUM,world); + if (flagall && comm->me == 0) + error->warning(FLERR,"Atom with molecule ID = 0 included in " + "compute molecule group"); + + MPI_Allreduce(&lo,&idlo,1,MPI_LMP_TAGINT,MPI_MIN,world); + MPI_Allreduce(&hi,&idhi,1,MPI_LMP_TAGINT,MPI_MAX,world); + if (idlo == BIG) return 0; + + // molmap = vector of length nlen + // set to 1 for IDs that appear in group across all procs, else 0 + + tagint nlen_tag = idhi-idlo+1; + if (nlen_tag > MAXSMALLINT) + error->all(FLERR,"Too many molecules for compute"); + int nlen = (int) nlen_tag; + + memory->create(molmap_H,nlen,"pair:molmap_H"); + for (i = 0; i < nlen; i++) molmap_H[i] = 0; + + for (i = 0; i < nlocal; i++) + // if (mask[i] & groupbit) + if (mask[i]) + molmap_H[molecule[i]-idlo] = 1; + + int *molmapall; + memory->create(molmapall,nlen,"pair:molmapall"); + MPI_Allreduce(molmap_H,molmapall,nlen,MPI_INT,MPI_MAX,world); + + // nmolecules = # of non-zero IDs in molmap + // molmap[i] = index of molecule, skipping molecules not in group with -1 + + int nmolecules = 0; + for (i = 0; i < nlen; i++) + if (molmapall[i]) molmap_H[i] = nmolecules++; + else molmap_H[i] = -1; + memory->destroy(molmapall); + + // warn if any molecule has some atoms in group and some not in group + + flag = 0; + for (i = 0; i < nlocal; i++) { +// if (mask[i] & groupbit) continue; + if (mask[i]) continue; + if (molecule[i] < idlo || molecule[i] > idhi) continue; + if (molmap_H[molecule[i]-idlo] >= 0) flag = 1; + } + + MPI_Allreduce(&flag,&flagall,1,MPI_INT,MPI_SUM,world); + if (flagall && comm->me == 0) + error->warning(FLERR, + "One or more compute molecules has atoms not in group"); + + // if molmap simply stores 1 to Nmolecules, then free it + + if (idlo == 1 && idhi == nmolecules && nlen == nmolecules) { + memory->destroy(molmap_H); + molmap_H = NULL; + } + return nmolecules; +} + + + +void PairLJCutHARSCG::CG_Print_Compensation_Energy(){ + + FILE *fp1; + + fp1 = fopen("Mean_Comp_Energy_CG.txt","w"); + if (fp1 == NULL) { + char str[128]; + sprintf(str,"Cannot open Mean_Comp_Energy_CG.txt file %s","Mean_Comp_Energy_CG.txt"); + error->one(FLERR,str); + + } + + for(int i = 0;i < CG_Bin_Num; i++){ + fprintf(fp1,"%d",i+1); + for(int k = 0; k < atom->nmoltypesH;k++) + fprintf(fp1,"\t%.10f",Mean_Comp_Energy_H[i][k]); + + fprintf(fp1,"\n"); + } + + fclose(fp1); + +} + + + +void PairLJCutHARSCG::CG_Update_Compensation_Energy(){ + + MPI_Allreduce(&Comp_Energy_H[0][0],&Comp_Energy_all_H[0][0],CG_Bin_Num*(atom->nmoltypesH+1),MPI_DOUBLE,MPI_SUM,world); + MPI_Allreduce(&Comp_Energy_Num_H[0][0],&Comp_Energy_Num_all_H[0][0],CG_Bin_Num*(atom->nmoltypesH+1),MPI_INT,MPI_SUM,world); + + for(int k = 0; k < atom->nmoltypesH;k++)for(int i = 0;i < CG_Bin_Num; i++)Mean_Energy_H[i][k] = Comp_Energy_all_H[i][k] / Comp_Energy_Num_all_H[i][k]; + for(int k = 0; k < atom->nmoltypesH;k++)for(int i = 0;i < CG_Bin_Num; i++)Mean_Comp_Energy_H[i][k] = (Comp_Counter_H * Mean_Comp_Energy_H[i][k] + Mean_Energy_H[i][k]) / (Comp_Counter_H + 1); + for(int k = 0; k < atom->nmoltypesH;k++)for(int i = 0;i < CG_Bin_Num; i++)Int_Mean_Energy_H[i][k]=0; + for(int k = 0; k < atom->nmoltypesH;k++)for(int i = 0;i < CG_Bin_Num; i++)for(int j = 0;j <= i; j++)Int_Mean_Energy_H[i][k] += Mean_Comp_Energy_H[j][k] * CG_lambda_Increment; + + Comp_Counter_H++; + + for(int k = 0; k < atom->nmoltypesH;k++){ + for(int i = 0;i < CG_Bin_Num; i++){ + Comp_Energy_Num_H[i][k] = 0; + Comp_Energy_Num_all_H[i][k] = 0; + Comp_Energy_H[i][k] = 0; + Comp_Energy_all_H[i][k] =0; + } + } + + if (me == 0)CG_Print_Compensation_Energy(); + + +} + + +void PairLJCutHARSCG::Load_Compensation_Pressure(){ + + if(me == 0){ + FILE *fp1; + char str[128]; + + fp1 = fopen("Mean_Comp_Energy_CG.txt","r"); + if (fp1 == NULL) { + sprintf(str,"Cannot open fix Mean_Comp_Energy_CG.txt file %s","Mean_Comp_Energy_CG.txt"); + error->one(FLERR,str); + } + + int i1; + float i2; + + while (!feof(fp1)){ + fscanf (fp1,"%d",&i1); + for(int k = 0; k < atom->nmoltypesH;k++){ + fscanf (fp1,"\t%f",&i2); + Mean_Comp_Energy_H[i1-1][k] = i2; + if(i1 > CG_Bin_Num){ + sprintf(str,"CG drift force compensation bin number mismatches %d != %d",CG_Bin_Num,i1); + error->one(FLERR,str); + } + } + + } + } + + + if(me==0){ + if(screen)fprintf(screen,"CG_Pressure componsation forces distributed successfully!\n"); + if(logfile)fprintf(logfile,"CG_Pressure componsation forces distributed successfully!\n"); + } + + MPI_Bcast(Mean_Comp_Energy_H,CG_Bin_Num*(atom->nmoltypesH+1),MPI_DOUBLE,0,world); +} + + +void PairLJCutHARSCG::H_AdResS_Allocation(){ + + + for (int i = 0; i < modify->nfix; i++){ + + if (strcmp(modify->fix[i]->style,"lambdah/calc") == 0){ + + lambda_H_fix = (FixLambdaHCalc *) modify->fix[i]; + CG_lambda_Increment = lambda_H_fix->Pressure_lambda_Increment; + CG_Bin_Num = lambda_H_fix->Pressure_Bin_Num; + CG_Update_Frequency = lambda_H_fix->Pressure_Update_Frequency; + CG_Update_Time_Begin = lambda_H_fix->Pressure_Update_Time_Begin; + CG_Update_Time_End = lambda_H_fix->Pressure_Update_Time_End; + + CG_Density_Bin_Num = lambda_H_fix->Density_Bin_Num; + CG_Density_Bin_Size = lambda_H_fix->Density_Bin_Size; + CG_Density_Update_Frequency = lambda_H_fix->Density_Update_Frequency; + CG_Density_Update_Time_Begin = lambda_H_fix->Density_Update_Time_Begin; + CG_Density_Update_Time_End = lambda_H_fix->Density_Update_Time_End; + + CG_Pressure_Comp_Flag = lambda_H_fix->Pressure_Comp_Flag; + CG_Density_Comp_Flag = lambda_H_fix->Density_Comp_Flag; + CG_center_box = lambda_H_fix->center_box; + CG_Hybrid_Style = lambda_H_fix->Hybrid_Style; + CG_x0lo = lambda_H_fix->x0lo; + CG_x0BoxSize = lambda_H_fix->x0BoxSize; + } + } + + if(me == 0){ + if (screen){ + fprintf(screen,"CG_lambda_Increment= %f\n",CG_lambda_Increment); + fprintf(screen,"CG_Bin_Num= %d\n",CG_Bin_Num); + fprintf(screen,"CG_Update_Frequency= %d\n",CG_Update_Frequency); + fprintf(screen,"CG_Update_Time_Begin= %d\n",CG_Update_Time_Begin); + fprintf(screen,"CG_Update_Time_End= %d\n",CG_Update_Time_End); + fprintf(screen,"CG_Pressure_Comp_Flag= %d\n",CG_Pressure_Comp_Flag); + fprintf(screen,"CG_Density_Comp_Flag= %d\n",CG_Density_Comp_Flag); + fprintf(screen,"CG_Hybrid_Style= %d\n",CG_Hybrid_Style); + + } + + if (logfile){ + fprintf(logfile,"CG_lambda_Increment= %f\n",CG_lambda_Increment); + fprintf(logfile,"CG_Bin_Num= %d\n",CG_Bin_Num); + fprintf(logfile,"CG_Update_Frequency= %d\n",CG_Update_Frequency); + fprintf(logfile,"CG_Update_Time_Begin= %d\n",CG_Update_Time_Begin); + fprintf(logfile,"CG_Update_Time_End= %d\n",CG_Update_Time_End); + fprintf(logfile,"CG_Pressure_Comp_Flag= %d\n",CG_Pressure_Comp_Flag); + fprintf(logfile,"CG_Density_Comp_Flag= %d\n",CG_Density_Comp_Flag); + fprintf(logfile,"CG_Hybrid_Style= %d\n",CG_Hybrid_Style); + + } + + + } + + + memory->create(Comp_Energy_Num_H,CG_Bin_Num,atom->nmoltypesH+1,"pairLJHCG:Comp_Energy_Num_H"); + memory->create(Comp_Energy_Num_all_H,CG_Bin_Num,atom->nmoltypesH+1,"pairLJHCG:Comp_Energy_Num_all_H"); + memory->create(Int_Mean_Energy_H,CG_Bin_Num,atom->nmoltypesH+1,"pairLJHCG:Int_Mean_Energy_H"); + memory->create(Comp_Energy_H,CG_Bin_Num,atom->nmoltypesH+1,"pairLJHCG:Comp_Energy_H"); + memory->create(Comp_Energy_all_H,CG_Bin_Num,atom->nmoltypesH+1,"pairLJHCG:Comp_Energy_all_H"); + memory->create(Mean_Comp_Energy_H,CG_Bin_Num,atom->nmoltypesH+1,"pairLJHCG:Mean_Comp_Energy_H"); + memory->create(Mean_Energy_H,CG_Bin_Num,atom->nmoltypesH+1,"pairLJHCG:Mean_Energy_H"); + + memory->create(CG_Mean_grad_Comp_Density_Conv_H,CG_Density_Bin_Num,atom->nmoltypesH+1,"pairLJHCG:CG_Mean_grad_Comp_Density_Conv_H"); + CG_Mean_grad_Comp_Density_Conv_H = lambda_H_fix->Mean_grad_Comp_Density_Conv_H; + + + for(int i = 0;i < CG_Bin_Num; i++){ + for(int j = 0; j < atom->nmoltypesH; j++){ + Int_Mean_Energy_H[i][j] = 0; + Comp_Energy_H[i][j] = 0; + Comp_Energy_all_H[i][j] = 0; + Mean_Comp_Energy_H[i][j] = 0; + Comp_Energy_Num_H[i][j] = 0; + Comp_Energy_Num_all_H[i][j] = 0; + } + } + + + H_AdResS_allocated = 1; + +} diff --git a/src/USER-HADRESS/pair_lj_cut_hars_cg.h b/src/USER-HADRESS/pair_lj_cut_hars_cg.h new file mode 100644 index 0000000000..df47c27ec4 --- /dev/null +++ b/src/USER-HADRESS/pair_lj_cut_hars_cg.h @@ -0,0 +1,123 @@ +/* -*- c++ -*- ---------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + http://lammps.sandia.gov, Sandia National Laboratories + Steve Plimpton, sjplimp@sandia.gov + + Copyright (2003) Sandia Corporation. Under the terms of Contract + DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains + certain rights in this software. This software is distributed under + the GNU General Public License. + + See the README file in the top-level LAMMPS directory. +------------------------------------------------------------------------- */ + +#ifdef PAIR_CLASS + +PairStyle(lj/cut/hars/cg,PairLJCutHARSCG) + +#else + +#ifndef LMP_PAIR_LJ_CUT_HARS_CG_H +#define LMP_PAIR_LJ_CUT_HARS_CG_H + +#include "pair.h" + +namespace LAMMPS_NS { + +class PairLJCutHARSCG : public Pair { + public: + PairLJCutHARSCG(class LAMMPS *); + virtual ~PairLJCutHARSCG(); + virtual void compute(int, int); + void settings(int, char **); + void coeff(int, char **); + void init_style(); + void init_list(int, class NeighList *); + double init_one(int, int); + void write_restart(FILE *); + void read_restart(FILE *); + void write_restart_settings(FILE *); + void read_restart_settings(FILE *); + void write_data(FILE *); + void write_data_all(FILE *); + double single(int, int, int, int, double, double, double, double &); + void *extract(const char *, int &); + + void compute_inner(); + void compute_middle(); + void compute_outer(int, int); + + void CG_Print_Compensation_Energy(); + void CG_Update_Compensation_Energy(); + + protected: + double cut_global; + double **cut; + double **epsilon,**sigma; + double **lj1,**lj2,**lj3,**lj4,**offset; + double *cut_respa; + class FixLambdaHCalc *lambda_H_fix; + int AllCoarseGrained; + + double *CG_Ave_Mean_Density_H,CG_grad_Ave_Mean_Density_H; + //private: + + int me; + virtual void allocate(); + + int H_AdResS_allocated; + int **Comp_Energy_Num_H,**Comp_Energy_Num_all_H, Comp_Counter_H; + + double CG_lambda_Increment; + int CG_Bin_Num, CG_Update_Frequency, CG_Update_Time_End, CG_Update_Time_Begin; + int CG_Pressure_Compensation_Run, Density_Compensation_Run; + + int CG_Pressure_Comp_Flag, CG_Density_Comp_Flag; + + double CG_Density_Bin_Size,**CG_Mean_grad_Comp_Density_Conv_H,CG_x0BoxSize; + int CG_Density_Bin_Num,CG_Density_Update_Frequency,CG_Density_Update_Time_Begin,CG_Density_Update_Time_End; + double **Int_Mean_Energy_H, **Comp_Energy_H, **Comp_Energy_all_H, **Mean_Energy_H, **Mean_Comp_Energy_H; + + double *CG_center_box, CG_x0lo; + int CG_Hybrid_Style; + int nmolecules; + tagint idlo,idhi; + + double *massproc_H,*masstotal_H; + + double **mol_f_H, **mol_f_all_H; + + int CG_Restart_Time_Step; + //double **drift_f_H, **drift_f_all_H; + //int nbin_H; + int *molmap_H; // convert molecule ID to local index + int Load_File_Flag; + + int molecules_in_group(tagint &, tagint &); + void Load_Compensation_Pressure(); + void H_AdResS_Allocation(); +}; + +} + +#endif +#endif + +/* ERROR/WARNING messages: + +E: Illegal ... command + +Self-explanatory. Check the input script syntax and compare to the +documentation for the command. You can use -echo screen as a +command-line option when running LAMMPS to see the offending line. + +E: Incorrect args for pair coefficients + +Self-explanatory. Check the input script or data file. + +E: Pair cutoff < Respa interior cutoff + +One or more pairwise cutoffs are too short to use with the specified +rRESPA cutoffs. + +*/ From 1ed74de9a87f4303b50cbf55604fc38a5673ea53 Mon Sep 17 00:00:00 2001 From: MaziarHeidari Date: Fri, 24 Jun 2016 16:05:27 +0200 Subject: [PATCH 08/15] HADRESS_Version_24_Jun_2016 --- src/atom.cpp | 26 ++++++++++++++++++++++++++ src/atom.h | 12 ++++++++++++ src/molecule.cpp | 45 ++++++++++++++++++++++++++++++++++++++++++++- src/molecule.h | 9 +++++++++ src/read_data.cpp | 8 +++++++- 5 files changed, 98 insertions(+), 2 deletions(-) diff --git a/src/atom.cpp b/src/atom.cpp index 8df360221c..4da03147b5 100644 --- a/src/atom.cpp +++ b/src/atom.cpp @@ -93,6 +93,15 @@ Atom::Atom(LAMMPS *lmp) : Pointers(lmp) rho = drho = e = de = cv = NULL; vest = NULL; + // USER-HAdResS package + + lambdaH = NULL; + gradlambdaH = NULL; + replambdaH = NULL; + moltypeH = NULL; + comH = NULL; + nmoltypesH = 0; + // USER-DPD uCond = uMech = uChem = uCG = uCGnew = NULL; @@ -240,6 +249,12 @@ Atom::~Atom() memory->destroy(molindex); memory->destroy(molatom); + memory->destroy(lambdaH); + memory->destroy(replambdaH); + memory->destroy(moltypeH); + memory->destroy(gradlambdaH); + memory->destroy(comH); + memory->destroy(q); memory->destroy(mu); memory->destroy(omega); @@ -392,6 +407,12 @@ void Atom::create_avec(const char *style, int narg, char **arg, int trysuffix) molecule_flag = 0; q_flag = mu_flag = 0; + + // USER-HAdResS + + replambdaH_flag = 0; + moltypeH_flag = 0; + omega_flag = torque_flag = angmom_flag = 0; radius_flag = rmass_flag = 0; ellipsoid_flag = line_flag = tri_flag = body_flag = 0; @@ -1608,6 +1629,8 @@ void Atom::add_molecule_atom(Molecule *onemol, int iatom, if (onemol->qflag && q_flag) q[ilocal] = onemol->q[iatom]; if (onemol->radiusflag && radius_flag) radius[ilocal] = onemol->radius[iatom]; if (onemol->rmassflag && rmass_flag) rmass[ilocal] = onemol->rmass[iatom]; + if (onemol->replambdaHflag && replambdaH_flag) replambdaH[ilocal] = onemol->replambdaH[iatom]; + if (onemol->moltypeHflag && moltypeH_flag) moltypeH[ilocal] = onemol->moltypeH[iatom]; else if (rmass_flag) rmass[ilocal] = 4.0*MY_PI/3.0 * radius[ilocal]*radius[ilocal]*radius[ilocal]; @@ -2082,6 +2105,9 @@ void *Atom::extract(char *name) if (strcmp(name,"f") == 0) return (void *) f; if (strcmp(name,"molecule") == 0) return (void *) molecule; if (strcmp(name,"q") == 0) return (void *) q; + if (strcmp(name,"lambdaH") == 0) return (void *) lambdaH; + if (strcmp(name,"gradlambdaH") == 0) return (void *) gradlambdaH; + if (strcmp(name,"replambdaH") == 0) return (void *) replambdaH; if (strcmp(name,"mu") == 0) return (void *) mu; if (strcmp(name,"omega") == 0) return (void *) omega; if (strcmp(name,"angmom") == 0) return (void *) angmom; diff --git a/src/atom.h b/src/atom.h index f2415e1db5..55ff0518e5 100644 --- a/src/atom.h +++ b/src/atom.h @@ -59,6 +59,14 @@ class Atom : protected Pointers { double *radius,*rmass; int *ellipsoid,*line,*tri,*body; + //USER-HAdResS package + + double *lambdaH,**gradlambdaH; + int *replambdaH; + int *moltypeH; + int nmoltypesH; + double **comH; + // PERI package double *vfrac,*s0; @@ -141,6 +149,10 @@ class Atom : protected Pointers { int rho_flag,e_flag,cv_flag,vest_flag; int dpd_flag; + // USER-HAdResS + + int replambdaH_flag, moltypeH_flag; + // USER-SMD package int smd_flag; diff --git a/src/molecule.cpp b/src/molecule.cpp index 64ebf2f4ae..8b954a97b3 100644 --- a/src/molecule.cpp +++ b/src/molecule.cpp @@ -503,7 +503,20 @@ void Molecule::read(int flag) if (flag) masses(line); else skip_lines(natoms,line); - } else if (strcmp(keyword,"Bonds") == 0) { + } else if (strcmp(keyword,"replambdaH") == 0) { + // USER-HAdResS Package + + replambdaHflag = 1; + if (flag) representative_atom(line); + else skip_lines(natoms,line); + } else if (strcmp(keyword,"moltypeH") == 0) { + // USER-HAdResS Package + + moltypeHflag = 1; + if (flag) moltype_atom(line); + else skip_lines(natoms,line); + + } else if (strcmp(keyword,"Bonds") == 0) { if (nbonds == 0) error->all(FLERR,"Molecule file has bonds but no nbonds setting"); bondflag = tag_require = 1; @@ -685,6 +698,30 @@ void Molecule::charges(char *line) } } +// USER-HAdResS Package + +void Molecule::representative_atom(char *line) +{ + int tmp; + for (int i = 0; i < natoms; i++) { + readline(line); + sscanf(line,"%d %d",&tmp,&replambdaH[i]); + printf("i=%d rep = %d",i,replambdaH[i]); + } +} + +// USER-HAdResS Package + +void Molecule::moltype_atom(char *line) +{ + int tmp; + for (int i = 0; i < natoms; i++) { + readline(line); + sscanf(line,"%d %d",&tmp,&moltypeH[i]); + printf("i=%d rep = %d",i,moltypeH[i]); + } +} + /* ---------------------------------------------------------------------- read diameters from file and set radii ------------------------------------------------------------------------- */ @@ -1342,6 +1379,8 @@ void Molecule::check_attributes(int flag) // warn if not a match int mismatch = 0; + if (onemol->replambdaHflag && !atom->replambdaH_flag) mismatch = 1; + if (onemol->moltypeHflag && !atom->moltypeH_flag) mismatch = 1; if (onemol->qflag && !atom->q_flag) mismatch = 1; if (onemol->radiusflag && !atom->radius_flag) mismatch = 1; if (onemol->rmassflag && !atom->rmass_flag) mismatch = 1; @@ -1460,6 +1499,8 @@ void Molecule::allocate() if (qflag) memory->create(q,natoms,"molecule:q"); if (radiusflag) memory->create(radius,natoms,"molecule:radius"); if (rmassflag) memory->create(rmass,natoms,"molecule:rmass"); + if (replambdaHflag) memory->create(replambdaH,natoms,"molecule:replambdaH"); + if (moltypeHflag) memory->create(moltypeH,natoms,"molecule:moltypeH"); // always allocate num_bond,num_angle,etc and special+nspecial // even if not in molecule file, initialize to 0 @@ -1546,6 +1587,8 @@ void Molecule::deallocate() memory->destroy(type); memory->destroy(q); memory->destroy(radius); + memory->destroy(replambdaH); + memory->destroy(moltypeH); memory->destroy(rmass); memory->destroy(num_bond); diff --git a/src/molecule.h b/src/molecule.h index 0bbe684636..fb7f86622e 100644 --- a/src/molecule.h +++ b/src/molecule.h @@ -42,6 +42,7 @@ class Molecule : protected Pointers { // 1 if attribute defined in file, 0 if not int xflag,typeflag,qflag,radiusflag,rmassflag; + int replambdaHflag,moltypeHflag; int bondflag,angleflag,dihedralflag,improperflag; int nspecialflag,specialflag; int shakeflag,shakeflagflag,shakeatomflag,shaketypeflag; @@ -60,6 +61,12 @@ class Molecule : protected Pointers { double **x; // displacement of each atom from origin int *type; // type of each atom double *q; // charge on each atom + + // USER-HAdResS Package + + int *replambdaH; // replambdaH on each atom + int *moltypeH; // moltypeH on each atom + double *radius; // radius of each atom double *rmass; // mass of each atom @@ -132,6 +139,8 @@ class Molecule : protected Pointers { void coords(char *); void types(char *); void charges(char *); + void representative_atom(char *); + void moltype_atom(char *); void diameters(char *); void masses(char *); void bonds(int, char *); diff --git a/src/read_data.cpp b/src/read_data.cpp index 39afcfbcf8..e8a44fb267 100644 --- a/src/read_data.cpp +++ b/src/read_data.cpp @@ -968,7 +968,13 @@ void ReadData::header(int firstpass) } else if (strstr(line,"atom types")) { sscanf(line,"%d",&ntypes); if (addflag == NONE) atom->ntypes = ntypes + extra_atom_types; - } else if (strstr(line,"bond types")) { + } else if (strstr(line,"mol_H types")){ + + // Number of molecule types in Coarse-grain regions, USER-HADRESS Package + + sscanf(line,"%d",&atom->nmoltypesH); + } + else if (strstr(line,"bond types")) { sscanf(line,"%d",&nbondtypes); if (addflag == NONE) atom->nbondtypes = nbondtypes + extra_bond_types; } else if (strstr(line,"angle types")) { From 3424786a4779bb5af632b46d7b08a41610f1be12 Mon Sep 17 00:00:00 2001 From: MaziarHeidari Date: Fri, 24 Jun 2016 16:06:24 +0200 Subject: [PATCH 09/15] HADRESS_Version_24_Jun_2016 --- src/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Makefile b/src/Makefile index 1b566fc5f0..4a3d9e44a4 100644 --- a/src/Makefile +++ b/src/Makefile @@ -51,7 +51,7 @@ PACKUSER = user-atc user-awpmd user-cg-cmm user-colvars user-cuda \ user-intel user-lb user-manifold user-mgpt \ user-misc user-molfile user-omp user-phonon user-qmmm user-qtb \ user-quip user-reaxc user-smd user-smtbq user-sph user-tally \ - user-vtk + user-vtk user-hadress PACKLIB = compress gpu kim kokkos meam mpiio poems python voronoi \ user-atc user-awpmd user-colvars user-cuda user-h5md user-intel \ From b69f79ca1b98d4e34ec6cbf8d78a6ff08f117561 Mon Sep 17 00:00:00 2001 From: MaziarHeidari Date: Fri, 24 Jun 2016 18:26:23 +0200 Subject: [PATCH 10/15] HADRESS_Version_24_Jun_2016 --- src/USER-HADRESS/Install.sh | 60 ------------------------------------- 1 file changed, 60 deletions(-) delete mode 100644 src/USER-HADRESS/Install.sh diff --git a/src/USER-HADRESS/Install.sh b/src/USER-HADRESS/Install.sh deleted file mode 100644 index 0224cf3928..0000000000 --- a/src/USER-HADRESS/Install.sh +++ /dev/null @@ -1,60 +0,0 @@ -# Install/unInstall package files in LAMMPS -# mode = 0/1/2 for uninstall/install/update - -mode=$1 - -# arg1 = file, arg2 = file it depends on - -action () { - if (test $mode = 0) then - rm -f ../$1 - elif (! cmp -s $1 ../$1) then - if (test -z "$2" || test -e ../$2) then - cp $1 .. - if (test $mode = 2) then - echo " updating src/$1" - fi - fi - elif (test -n "$2") then - if (test ! -e ../$2) then - rm -f ../$1 - fi - fi -} - -# all package files with no dependencies - -for file in *.cpp *.h; do - action $file -done - -# edit 2 Makefile.package files to include/exclude package info - -if (test $1 = 1) then - - if (test -e ../Makefile.package) then - sed -i -e 's/[^ \t]*USER-HADRESS[^ \t]* //' ../Makefile.package - sed -i -e 's|^PKG_SYSINC =[ \t]*|&$(USER-HADRESS_SYSINC) |' ../Makefile.package - sed -i -e 's|^PKG_SYSLIB =[ \t]*|&$(USER-HADRESS_SYSLIB) |' ../Makefile.package - sed -i -e 's|^PKG_SYSPATH =[ \t]*|&$(USER-HADRESS_SYSPATH) |' ../Makefile.package - fi - - if (test -e ../Makefile.package.settings) then - sed -i -e '/^include.*USER-HADRESS.*$/d' ../Makefile.package.settings - # multiline form needed for BSD sed on Macs - sed -i -e '4 i \ -include ..\/..\/lib\/USER-HADRESS\/Makefile.lammps -' ../Makefile.package.settings - fi - -elif (test $1 = 0) then - - if (test -e ../Makefile.package) then - sed -i -e 's/[^ \t]*USER-HADRESS[^ \t]* //' ../Makefile.package - fi - - if (test -e ../Makefile.package.settings) then - sed -i -e '/^include.*USER-HADRESS.*$/d' ../Makefile.package.settings - fi - -fi From bc8c50615c6d6adfa881d9ae997218252814f947 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Fri, 24 Jun 2016 13:50:06 -0400 Subject: [PATCH 11/15] include patch from trung that addresses issues when using manybody potentials in pair hybrid closes #69 --- lib/gpu/Makefile.linux | 2 +- lib/gpu/lal_base_three.cpp | 52 +++++++------ lib/gpu/lal_base_three.h | 31 ++++---- lib/gpu/lal_neighbor.cpp | 119 +++++++++++++++------------- lib/gpu/lal_neighbor.h | 62 +++++++-------- lib/gpu/lal_sw.cpp | 64 ++++++++-------- lib/gpu/lal_sw.cu | 128 ++++++++++++++----------------- lib/gpu/lal_sw.h | 12 +-- lib/gpu/lal_tersoff.cpp | 6 +- lib/gpu/lal_tersoff.cu | 22 ++++-- lib/gpu/lal_tersoff_mod.cpp | 6 +- lib/gpu/lal_tersoff_mod.cu | 22 ++++-- lib/gpu/lal_tersoff_zbl.cpp | 6 +- lib/gpu/lal_tersoff_zbl.cu | 22 ++++-- src/GPU/pair_sw_gpu.cpp | 2 +- src/GPU/pair_tersoff_gpu.cpp | 2 +- src/GPU/pair_tersoff_mod_gpu.cpp | 2 +- src/GPU/pair_tersoff_zbl_gpu.cpp | 2 +- 18 files changed, 306 insertions(+), 256 deletions(-) diff --git a/lib/gpu/Makefile.linux b/lib/gpu/Makefile.linux index d77487648e..1d40d4b21d 100644 --- a/lib/gpu/Makefile.linux +++ b/lib/gpu/Makefile.linux @@ -7,7 +7,7 @@ EXTRAMAKE = Makefile.lammps.standard -ifeq($(CUDA_HOME),) +ifeq ($(CUDA_HOME),) CUDA_HOME = /usr/local/cuda endif diff --git a/lib/gpu/lal_base_three.cpp b/lib/gpu/lal_base_three.cpp index c41aad7b58..14f642e55b 100644 --- a/lib/gpu/lal_base_three.cpp +++ b/lib/gpu/lal_base_three.cpp @@ -12,7 +12,7 @@ begin : Tue April 2, 2013 email : brownw@ornl.gov ***************************************************************************/ - + #include "lal_base_three.h" using namespace LAMMPS_AL; #define BaseThreeT BaseThree @@ -45,7 +45,7 @@ int BaseThreeT::bytes_per_atom_atomic(const int max_nbors) const { #ifdef THREE_CONCURRENT b+=ans2->bytes_per_atom(); #endif - return b; + return b; } template @@ -62,6 +62,7 @@ int BaseThreeT::init_three(const int nlocal, const int nall, gpu_nbor=1; else if (device->gpu_mode()==Device::GPU_HYB_NEIGH) gpu_nbor=2; + _gpu_nbor=gpu_nbor; int _gpu_host=0; int host_nlocal=hd_balancer.first_host_count(nlocal,gpu_split,gpu_nbor); @@ -76,7 +77,7 @@ int BaseThreeT::init_three(const int nlocal, const int nall, _nbor_data=&(nbor->dev_nbor); if (_threads_per_atom*_threads_per_atom>device->warp_size()) return -10; - + int success=device->init(*ans,false,false,nlocal,host_nlocal,nall,nbor, maxspecial,_gpu_host,max_nbors,cell_size,false, _threads_per_atom); @@ -93,7 +94,7 @@ int BaseThreeT::init_three(const int nlocal, const int nall, return -3; ans2->cq(_end_command_queue); #endif - + _block_pair=device->pair_block_size(); _block_size=device->block_ellipse(); compile_kernels(*ucl_device,pair_program,k_two,k_three_center,k_three_end); @@ -111,7 +112,7 @@ int BaseThreeT::init_three(const int nlocal, const int nall, #ifdef THREE_CONCURRENT _max_an_bytes+=ans2->gpu_bytes(); #endif - + return 0; } @@ -158,7 +159,7 @@ void BaseThreeT::clear_atomic() { // --------------------------------------------------------------------------- template int * BaseThreeT::reset_nbors(const int nall, const int inum, const int nlist, - int *ilist, int *numj, int **firstneigh, + int *ilist, int *numj, int **firstneigh, bool &success) { success=true; @@ -168,7 +169,12 @@ int * BaseThreeT::reset_nbors(const int nall, const int inum, const int nlist, if (!success) return NULL; - nbor->get_host3(nall,nlist,ilist,numj,firstneigh,block_size()); + // originally the requirement that nall == nlist was enforced + // to allow direct indexing neighbors of neighbors after re-arrangement +// nbor->get_host3(nall,nlist,ilist,numj,firstneigh,block_size()); + + // now the requirement is removed, allowing to work within pair hybrid + nbor->get_host(nlist,ilist,numj,firstneigh,block_size()); double bytes=ans->gpu_bytes()+nbor->gpu_bytes(); #ifdef THREE_CONCURRENT @@ -176,7 +182,7 @@ int * BaseThreeT::reset_nbors(const int nall, const int inum, const int nlist, #endif if (bytes>_max_an_bytes) _max_an_bytes=bytes; - + return ilist; } @@ -185,11 +191,11 @@ int * BaseThreeT::reset_nbors(const int nall, const int inum, const int nlist, // --------------------------------------------------------------------------- template inline int BaseThreeT::build_nbor_list(const int inum, const int host_inum, - const int nall, double **host_x, - int *host_type, double *sublo, - double *subhi, tagint *tag, - int **nspecial, tagint **special, - bool &success) { + const int nall, double **host_x, + int *host_type, double *sublo, + double *subhi, tagint *tag, + int **nspecial, tagint **special, + bool &success) { success=true; resize_atom(inum,nall,success); resize_local(nall,host_inum,nbor->max_nbors(),success); @@ -214,11 +220,11 @@ inline int BaseThreeT::build_nbor_list(const int inum, const int host_inum, // Copy nbor list from host if necessary and then calculate forces, virials,.. // --------------------------------------------------------------------------- template -void BaseThreeT::compute(const int f_ago, const int nlocal, const int nall, +void BaseThreeT::compute(const int f_ago, const int inum_full, const int nall, const int nlist, double **host_x, int *host_type, - int *ilist, int *numj, int **firstneigh, + int *ilist, int *numj, int **firstneigh, const bool eflag, const bool vflag, const bool eatom, - const bool vatom, int &host_start, + const bool vatom, int &host_start, const double cpu_time, bool &success) { acc_timers(); if (nlist==0) { @@ -228,9 +234,9 @@ void BaseThreeT::compute(const int f_ago, const int nlocal, const int nall, zero_timers(); return; } - + int ago=hd_balancer.ago_first(f_ago); - int inum=hd_balancer.balance(ago,nlocal,cpu_time); + int inum=hd_balancer.balance(ago,inum_full,cpu_time); ans->inum(inum); #ifdef THREE_CONCURRENT ans2->inum(inum); @@ -270,7 +276,7 @@ template int ** BaseThreeT::compute(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, double *sublo, double *subhi, tagint *tag, - int **nspecial, tagint **special, const bool eflag, + int **nspecial, tagint **special, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, int **ilist, int **jnum, @@ -283,7 +289,7 @@ int ** BaseThreeT::compute(const int ago, const int inum_full, zero_timers(); return NULL; } - + hd_balancer.balance(cpu_time); int inum=hd_balancer.get_gpu_count(ago,inum_full); ans->inum(inum); @@ -291,7 +297,7 @@ int ** BaseThreeT::compute(const int ago, const int inum_full, ans2->inum(inum); #endif host_start=inum; - + // Build neighbor list on GPU if necessary if (ago==0) { build_nbor_list(inum, inum_full-inum, nall, host_x, host_type, @@ -321,7 +327,7 @@ int ** BaseThreeT::compute(const int ago, const int inum_full, device->add_ans_object(ans2); #endif hd_balancer.stop_timer(); - + return nbor->host_jlist.begin()-host_start; } @@ -352,7 +358,7 @@ void BaseThreeT::compile_kernels(UCL_Device &dev, const void *pair_str, k_three_end.cq(ucl_device->cq(_end_command_queue)); k_three_end_vatom.cq(ucl_device->cq(_end_command_queue)); #endif - + _compiled=true; } diff --git a/lib/gpu/lal_base_three.h b/lib/gpu/lal_base_three.h index 0af290469a..4f27ecdf92 100644 --- a/lib/gpu/lal_base_three.h +++ b/lib/gpu/lal_base_three.h @@ -44,7 +44,7 @@ class BaseThree { * \param gpu_split fraction of particles handled by device * \param k_two name for the kernel for 2-body force calculation * \param k_three name for the kernel for 3-body force calculation - * + * * Returns: * - 0 if successfull * - -1 if fix gpu not found @@ -53,8 +53,8 @@ class BaseThree { * - -5 Double precision is not supported on card * - -10 if invalid thread_per_atom setting **/ int init_three(const int nlocal, const int nall, const int max_nbors, - const int maxspecial, const double cell_size, - const double gpu_split, FILE *screen, + const int maxspecial, const double cell_size, + const double gpu_split, FILE *screen, const void *pair_program, const char *k_two, const char *k_three_center, const char *k_three_end); @@ -88,7 +88,7 @@ class BaseThree { * \note host_inum is 0 if the host is performing neighboring * \note nlocal+host_inum=total number local particles * \note olist_size=0 **/ - inline void resize_local(const int inum, const int host_inum, + inline void resize_local(const int inum, const int host_inum, const int max_nbors, bool &success) { nbor->resize(inum,host_inum,max_nbors,success); } @@ -133,33 +133,33 @@ class BaseThree { /// Build neighbor list on device int build_nbor_list(const int inum, const int host_inum, const int nall, double **host_x, int *host_type, - double *sublo, double *subhi, tagint *tag, int **nspecial, + double *sublo, double *subhi, tagint *tag, int **nspecial, tagint **special, bool &success); /// Pair loop with host neighboring - void compute(const int f_ago, const int inum_full, const int nall, + void compute(const int f_ago, const int inum_full, const int nall, const int nlist, double **host_x, int *host_type, int *ilist, int *numj, int **firstneigh, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, const double cpu_time, bool &success); /// Pair loop with device neighboring - int * compute(const int ago, const int inum_full, const int nall, + int * compute(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, double *sublo, double *subhi, tagint *tag, int **nspecial, - tagint **special, const bool eflag, const bool vflag, - const bool eatom, const bool vatom, int &host_start, + tagint **special, const bool eflag, const bool vflag, + const bool eatom, const bool vatom, int &host_start, const double cpu_time, bool &success); /// Pair loop with device neighboring int ** compute(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, double *sublo, double *subhi, tagint *tag, int **nspecial, - tagint **special, const bool eflag, const bool vflag, - const bool eatom, const bool vatom, int &host_start, + tagint **special, const bool eflag, const bool vflag, + const bool eatom, const bool vatom, int &host_start, int **ilist, int **numj, const double cpu_time, bool &success); - // -------------------------- DEVICE DATA ------------------------- + // -------------------------- DEVICE DATA ------------------------- /// Device Properties and Atom and Neighbor storage Device *device; @@ -186,7 +186,7 @@ class BaseThree { Answer *ans; #ifdef THREE_CONCURRENT Answer *ans2; - #endif + #endif // --------------------------- NBOR DATA ---------------------------- @@ -205,15 +205,16 @@ class BaseThree { protected: bool _compiled; int _block_pair, _block_size, _threads_per_atom, _end_command_queue; + int _gpu_nbor; double _max_bytes, _max_an_bytes; double _gpu_overhead, _driver_overhead; UCL_D_Vec *_nbor_data; - void compile_kernels(UCL_Device &dev, const void *pair_string, + void compile_kernels(UCL_Device &dev, const void *pair_string, const char *k_two, const char *k_three_center, const char *k_three_end); - virtual void loop(const bool _eflag, const bool _vflag, + virtual void loop(const bool _eflag, const bool _vflag, const int evatom) = 0; }; diff --git a/lib/gpu/lal_neighbor.cpp b/lib/gpu/lal_neighbor.cpp index 074eaa842b..0a9933a6c0 100644 --- a/lib/gpu/lal_neighbor.cpp +++ b/lib/gpu/lal_neighbor.cpp @@ -10,7 +10,7 @@ This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) __________________________________________________________________________ - begin : + begin : email : brownw@ornl.gov, penwang@nvidia.com ***************************************************************************/ @@ -32,13 +32,13 @@ int Neighbor::bytes_per_atom(const int max_nbors) const { } bool Neighbor::init(NeighborShared *shared, const int inum, - const int host_inum, const int max_nbors, - const int maxspecial, UCL_Device &devi, - const int gpu_nbor, const int gpu_host, + const int host_inum, const int max_nbors, + const int maxspecial, UCL_Device &devi, + const int gpu_nbor, const int gpu_host, const bool pre_cut, const int block_cell_2d, const int block_cell_id, const int block_nbor_build, const int threads_per_atom, const int warp_size, - const bool time_device, + const bool time_device, const std::string compile_flags) { clear(); @@ -56,10 +56,10 @@ bool Neighbor::init(NeighborShared *shared, const int inum, _gpu_host=false; else if (gpu_host==1) _gpu_host=true; - else + else // Not yet implemented assert(0==1); - + if (pre_cut || gpu_nbor==0) _alloc_packed=true; else @@ -71,7 +71,7 @@ bool Neighbor::init(NeighborShared *shared, const int inum, _packed_permissions=UCL_READ_ONLY; bool success=true; - + // Initialize timers for the selected GPU _nbor_time_avail=false; time_nbor.init(*dev); @@ -88,7 +88,7 @@ bool Neighbor::init(NeighborShared *shared, const int inum, _max_atoms=static_cast(static_cast(inum)*1.10); if (_max_atoms==0) _max_atoms=1000; - + _max_host=static_cast(static_cast(host_inum)*1.10); _max_nbors=(max_nbors/threads_per_atom+1)*threads_per_atom; @@ -102,21 +102,21 @@ bool Neighbor::init(NeighborShared *shared, const int inum, alloc(success); if (!success) return false; - + if (_use_packing==false) _shared->compile_kernels(devi,gpu_nbor,compile_flags); return success; } -void Neighbor::alloc(bool &success) { +void Neighbor::alloc(bool &success) { dev_nbor.clear(); host_acc.clear(); int nt=_max_atoms+_max_host; - if (_use_packing==false || _gpu_nbor>0) - success=success && + if (_use_packing==false || _gpu_nbor>0) + success=success && (dev_nbor.alloc((_max_nbors+2)*_max_atoms,*dev)==UCL_SUCCESS); - else + else success=success && (dev_nbor.alloc(3*_max_atoms,*dev, UCL_READ_ONLY)==UCL_SUCCESS); success=success && (host_acc.alloc(nt*2,*dev, @@ -127,14 +127,17 @@ void Neighbor::alloc(bool &success) { dev_packed.clear(); success=success && (dev_packed.alloc((_max_nbors+2)*_max_atoms,*dev, _packed_permissions)==UCL_SUCCESS); - _c_bytes+=dev_packed.row_bytes(); - } + dev_acc.clear(); + success=success && (dev_acc.alloc(_max_atoms,*dev, + UCL_READ_WRITE)==UCL_SUCCESS); + _c_bytes+=dev_packed.row_bytes()+dev_acc.row_bytes(); + } if (_max_host>0) { nbor_host.clear(); dev_numj_host.clear(); host_ilist.clear(); host_jlist.clear(); - + success=(nbor_host.alloc(_max_nbors*_max_host,*dev,UCL_READ_WRITE, UCL_READ_WRITE)==UCL_SUCCESS) && success; success=success && (dev_numj_host.alloc(_max_host,*dev, @@ -152,7 +155,7 @@ void Neighbor::alloc(bool &success) { for (int i=0; i<_max_host; i++) { host_jlist[i]=ptr; ptr+=_max_nbors; - } + } _c_bytes+=nbor_host.device.row_bytes()+dev_numj_host.row_bytes(); } else { // Some OpenCL implementations return errors for NULL pointers as args @@ -176,7 +179,7 @@ void Neighbor::alloc(bool &success) { _allocated=true; } - + void Neighbor::clear() { _gpu_bytes=0.0; _cell_bytes=0.0; @@ -194,6 +197,7 @@ void Neighbor::clear() { host_packed.clear(); host_acc.clear(); + dev_acc.clear(); dev_nbor.clear(); nbor_host.clear(); dev_packed.clear(); @@ -219,13 +223,13 @@ double Neighbor::host_memory_usage() const { host_ilist.row_bytes()+host_jlist.row_bytes(); else return 0; - } else + } else return host_packed.row_bytes()*host_packed.rows()+host_acc.row_bytes()+ sizeof(Neighbor); } void Neighbor::get_host(const int inum, int *ilist, int *numj, - int **firstneigh, const int block_size) { + int **firstneigh, const int block_size) { _nbor_time_avail=true; time_nbor.start(); @@ -242,7 +246,7 @@ void Neighbor::get_host(const int inum, int *ilist, int *numj, int dev_count=0; int *h_ptr=host_packed.begin(); _nbor_pitch=inum; - + for (int ii=0; ii acc_view; acc_view.view_offset(inum,dev_nbor,inum*2); ucl_copy(acc_view,host_acc,true); + + UCL_H_Vec host_view; + host_view.alloc(_max_atoms,*dev,UCL_READ_WRITE); + for (int ii=0; ii(ceil(static_cast(inum)*_threads_per_atom/ @@ -294,7 +307,7 @@ void Neighbor::get_host(const int inum, int *ilist, int *numj, // inum=nlocal is forced to be true to allow direct indexing of neighbors of // neighbors void Neighbor::get_host3(const int inum, const int nlist, int *ilist, int *numj, - int **firstneigh, const int block_size) { + int **firstneigh, const int block_size) { _nbor_time_avail=true; time_nbor.start(); @@ -311,7 +324,7 @@ void Neighbor::get_host3(const int inum, const int nlist, int *ilist, int *numj, int dev_count=0; int *h_ptr=host_packed.begin(); _nbor_pitch=inum; - + if (nlist!=inum) host_acc.zero(inum); @@ -322,7 +335,7 @@ void Neighbor::get_host3(const int inum, const int nlist, int *ilist, int *numj, host_acc[i+inum]=acc_count; acc_count+=nj; } - + for (int i=0; i(ceil(static_cast(inum)*_threads_per_atom/ @@ -366,7 +379,7 @@ void Neighbor::get_host3(const int inum, const int nlist, int *ilist, int *numj, template void Neighbor::resize_max_neighbors(const int maxn, bool &success) { - if (maxn>_max_nbors) { + if (maxn>_max_nbors) { int mn=static_cast(static_cast(maxn)*1.10); mn=(mn/_threads_per_atom+1)*_threads_per_atom; success=success && (dev_nbor.resize((mn+1)*_max_atoms)==UCL_SUCCESS); @@ -377,7 +390,7 @@ void Neighbor::resize_max_neighbors(const int maxn, bool &success) { for (int i=0; i<_max_host; i++) { host_jlist[i]=ptr; ptr+=mn; - } + } _gpu_bytes+=nbor_host.row_bytes(); } else { nbor_host.device.view(dev_nbor); @@ -393,8 +406,8 @@ void Neighbor::resize_max_neighbors(const int maxn, bool &success) { template void Neighbor::build_nbor_list(double **x, const int inum, const int host_inum, - const int nall, Atom &atom, - double *sublo, double *subhi, tagint *tag, + const int nall, Atom &atom, + double *sublo, double *subhi, tagint *tag, int **nspecial, tagint **special, bool &success, int &mn) { _nbor_time_avail=true; @@ -409,7 +422,7 @@ void Neighbor::build_nbor_list(double **x, const int inum, const int host_inum, ncell_3d = ncellx * ncelly * ncellz; if (ncell_3d+1>_ncells) { cell_counts.clear(); - + if (_gpu_nbor==2) { if (_ncells>0) delete [] cell_iter; @@ -419,7 +432,7 @@ void Neighbor::build_nbor_list(double **x, const int inum, const int host_inum, cell_counts.device.clear(); cell_counts.device.alloc(ncell_3d+1,dev_nbor); } - + _ncells=ncell_3d+1; _cell_bytes=cell_counts.device.row_bytes(); } @@ -445,17 +458,17 @@ void Neighbor::build_nbor_list(double **x, const int inum, const int host_inum, const int g2x=static_cast(ceil(static_cast(_maxspecial)/b2x)); const int g2y=static_cast(ceil(static_cast(nt)/b2y)); _shared->k_transpose.set_size(g2x,g2y,b2x,b2y); - _shared->k_transpose.run(&dev_special,&dev_special_t,&_maxspecial,&nt); + _shared->k_transpose.run(&dev_special,&dev_special_t,&_maxspecial,&nt); time_transpose.stop(); } - + // If binning on CPU, do this now if (_gpu_nbor==2) { double stime = MPI_Wtime(); int *cell_id=atom.host_cell_id.begin(); int *particle_id=atom.host_particle_id.begin(); - - // Build cell list on CPU + + // Build cell list on CPU cell_counts.host.zero(); double i_cell_size=1.0/_cell_size; @@ -475,12 +488,12 @@ void Neighbor::build_nbor_list(double **x, const int inum, const int host_inum, int iz = static_cast(pz*i_cell_size+1); iz = std::max(iz,_cells_in_cutoff); iz = std::min(iz,ncellz-offset_hi); - + int id = ix+iy*ncellx+iz*ncellx*ncelly; cell_id[i] = id; cell_counts[id+1]++; } - + for (int i=nt; i(pz*i_cell_size+1); iz = std::max(iz,0); iz = std::min(iz,ncellz-1); - + int id = ix+iy*ncellx+iz*ncellx*ncelly; cell_id[i] = id; cell_counts[id+1]++; } - + mn=0; for (int i=0; i<_ncells; i++) mn=std::max(mn,cell_counts[i]); @@ -531,7 +544,7 @@ void Neighbor::build_nbor_list(double **x, const int inum, const int host_inum, ucl_copy(atom.dev_particle_id,atom.host_particle_id,true); time_hybrid2.stop(); _bin_time+=MPI_Wtime()-stime; - } + } time_kernel.start(); @@ -547,7 +560,7 @@ void Neighbor::build_nbor_list(double **x, const int inum, const int host_inum, const numtyp sublo1=static_cast(sublo[1]); const numtyp sublo2=static_cast(sublo[2]); _shared->k_cell_id.set_size(GX,neigh_block); - _shared->k_cell_id.run(&atom.x, &atom.dev_cell_id, + _shared->k_cell_id.run(&atom.x, &atom.dev_cell_id, &atom.dev_particle_id, &sublo0, &sublo1, &sublo2, &i_cell_size, &ncellx, &ncelly, &ncellz, &nt, &nall, &_cells_in_cutoff); @@ -556,10 +569,10 @@ void Neighbor::build_nbor_list(double **x, const int inum, const int host_inum, /* calculate cell count */ _shared->k_cell_counts.set_size(GX,neigh_block); - _shared->k_cell_counts.run(&atom.dev_cell_id, &cell_counts, &nall, + _shared->k_cell_counts.run(&atom.dev_cell_id, &cell_counts, &nall, &ncell_3d); - } - + } + /* build the neighbor list */ const int cell_block=_block_nbor_build; _shared->k_build_nbor.set_size(ncellx-ghost_cells,(ncelly-ghost_cells)* @@ -579,7 +592,7 @@ void Neighbor::build_nbor_list(double **x, const int inum, const int host_inum, host_offset.view_offset(inum,host_acc,nt-inum); ucl_copy(host_offset,dev_numj_host,nt-inum,true); } - + if (_gpu_nbor!=2) { host_acc.sync(); mn=host_acc[0]; @@ -587,7 +600,7 @@ void Neighbor::build_nbor_list(double **x, const int inum, const int host_inum, mn=std::max(mn,host_acc[i]); set_nbor_block_size(mn); - if (mn>_max_nbors) { + if (mn>_max_nbors) { resize_max_neighbors(mn,success); if (!success) return; @@ -599,13 +612,13 @@ void Neighbor::build_nbor_list(double **x, const int inum, const int host_inum, return; } } - + if (_maxspecial>0) { const int GX2=static_cast(ceil(static_cast (nt*_threads_per_atom)/cell_block)); _shared->k_special.set_size(GX2,cell_block); _shared->k_special.run(&dev_nbor, &nbor_host, &dev_numj_host, - &atom.dev_tag, &dev_nspecial, &dev_special, + &atom.dev_tag, &dev_nspecial, &dev_special, &inum, &nt, &_max_nbors, &_threads_per_atom); } time_kernel.stop(); diff --git a/lib/gpu/lal_neighbor.h b/lib/gpu/lal_neighbor.h index 7653291bbb..05168834c6 100644 --- a/lib/gpu/lal_neighbor.h +++ b/lib/gpu/lal_neighbor.h @@ -10,7 +10,7 @@ This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) __________________________________________________________________________ - begin : + begin : email : brownw@ornl.gov, penwang@nvidia.com ***************************************************************************/ @@ -28,12 +28,12 @@ class Neighbor { public: Neighbor() : _allocated(false), _use_packing(false), _ncells(0) {} ~Neighbor() { clear(); } - + /// Determine whether neighbor unpacking should be used - /** If false, twice as much memory is reserved to allow unpacking neighbors by + /** If false, twice as much memory is reserved to allow unpacking neighbors by * atom for coalesced access. **/ void packing(const bool use_packing) { _use_packing=use_packing; } - + /// Clear any old data and setup for new LAMMPS run /** \param inum Initial number of particles whose neighbors stored on device * \param host_inum Initial number of particles whose nbors copied to host @@ -45,20 +45,20 @@ class Neighbor { * 1 if gpu_nbor is true, and host needs a half nbor list, * 2 if gpu_nbor is true, and host needs a full nbor list * \param pre_cut True if cutoff test will be performed in separate kernel - * than the force kernel + * than the force kernel * \param threads_per_atom Number of threads used per atom for force - * calculation + * calculation * \param compile_flags Flags for JIT compiling **/ bool init(NeighborShared *shared, const int inum, const int host_inum, const int max_nbors, const int maxspecial, UCL_Device &dev, const int gpu_nbor, const int gpu_host, const bool pre_cut, - const int block_cell_2d, const int block_cell_id, + const int block_cell_2d, const int block_cell_id, const int block_nbor_build, const int threads_per_atom, - const int warp_size, const bool time_device, + const int warp_size, const bool time_device, const std::string compile_flags); /// Set the size of the cutoff+skin - inline void cell_size(const double size, const double cutoff) { + inline void cell_size(const double size, const double cutoff) { _cell_size=size; _cutoff=cutoff; if (cutoff>size) @@ -66,7 +66,7 @@ class Neighbor { else _cells_in_cutoff=1; } - + /// Get the size of the cutoff+skin inline double cell_size() const { return _cell_size; } @@ -88,7 +88,7 @@ class Neighbor { * \param host_inum Number of particles whose nbors will be copied to host * \param max_nbor Current max number of neighbors for a particle * \param success False if insufficient memory **/ - inline void resize(const int inum, const int host_inum, const int max_nbor, + inline void resize(const int inum, const int host_inum, const int max_nbor, bool &success) { if (inum>_max_atoms || max_nbor>_max_nbors || host_inum>_max_host) { _max_atoms=static_cast(static_cast(inum)*1.10); @@ -124,40 +124,40 @@ class Neighbor { /// Free all memory on host and device void clear(); - + /// Bytes per atom used on device int bytes_per_atom(const int max_nbors) const; - + /// Total host memory used by class double host_memory_usage() const; - + /// Returns the type of neighboring: /** - 0 if neighboring will be performed on host * - 1 if neighboring will be performed on device * - 2 if binning on host and neighboring on device **/ inline int gpu_nbor() const { return _gpu_nbor; } - + /// Make a copy of unpacked nbor lists in the packed storage area (for gb) - inline void copy_unpacked(const int inum, const int maxj) + inline void copy_unpacked(const int inum, const int maxj) { ucl_copy(dev_packed,dev_nbor,inum*(maxj+2),true); } - /// Copy neighbor list from host (first time or from a rebuild) - void get_host(const int inum, int *ilist, int *numj, + /// Copy neighbor list from host (first time or from a rebuild) + void get_host(const int inum, int *ilist, int *numj, int **firstneigh, const int block_size); - - /// Copy neighbor list from host for 3-body (first time or from a rebuild) - void get_host3(const int inum, const int nlist, int *ilist, int *numj, + + /// Copy neighbor list from host for 3-body (first time or from a rebuild) + void get_host3(const int inum, const int nlist, int *ilist, int *numj, int **firstneigh, const int block_size); - + /// Return the stride in elements for each nbor row inline int nbor_pitch() const { return _nbor_pitch; } - + /// Return the maximum number of atoms that can currently be stored inline int max_atoms() const { return _max_atoms; } /// Return the maximum number of nbors for a particle based on current alloc inline int max_nbors() const { return _max_nbors; } - + /// Return the time spent binning on the CPU for hybrid neighbor builds inline double bin_time() const { return _bin_time; } @@ -171,9 +171,9 @@ class Neighbor { /// Build nbor list on the device template - void build_nbor_list(double **x, const int inum, const int host_inum, + void build_nbor_list(double **x, const int inum, const int host_inum, const int nall, Atom &atom, double *sublo, - double *subhi, tagint *tag, int **nspecial, tagint **special, + double *subhi, tagint *tag, int **nspecial, tagint **special, bool &success, int &max_nbors); /// Return the number of bytes used on device @@ -184,7 +184,7 @@ class Neighbor { return res; } - + // ------------------------------- Data ------------------------------- /// Device neighbor matrix @@ -199,6 +199,8 @@ class Neighbor { UCL_H_Vec host_packed; /// Host storage for nbor counts (row 1) & accumulated neighbor counts (row2) UCL_H_Vec host_acc; + /// Device storage for accessing atom indices from the neighbor list (3-body) + UCL_D_Vec dev_acc; // ----------------- Data for GPU Neighbor Calculation --------------- @@ -219,7 +221,7 @@ class Neighbor { /// Device timers UCL_Timer time_nbor, time_kernel, time_hybrid1, time_hybrid2, time_transpose; - + private: NeighborShared *_shared; UCL_Device *dev; @@ -231,14 +233,14 @@ class Neighbor { double _gpu_bytes, _c_bytes, _cell_bytes; void alloc(bool &success); - + int _block_cell_2d, _block_cell_id, _max_block_nbor_build, _block_nbor_build; int _ncells, _threads_per_atom, _total_atoms; int _cells_in_cutoff; template inline void resize_max_neighbors(const int maxn, bool &success); - + int _warp_size; inline void set_nbor_block_size(const int mn) { int desired=mn/(2*_warp_size); diff --git a/lib/gpu/lal_sw.cpp b/lib/gpu/lal_sw.cpp index 1f68616b0e..3492d7030e 100644 --- a/lib/gpu/lal_sw.cpp +++ b/lib/gpu/lal_sw.cpp @@ -33,10 +33,10 @@ SWT::SW() : BaseThree(), _allocated(false) { } template -SWT::~SW() { +SWT::~SW() { clear(); } - + template int SWT::bytes_per_atom(const int max_nbors) const { return this->bytes_per_atom_atomic(max_nbors); @@ -45,7 +45,7 @@ int SWT::bytes_per_atom(const int max_nbors) const { template int SWT::init(const int ntypes, const int nlocal, const int nall, const int max_nbors, const double cell_size, const double gpu_split, FILE *_screen, - int* host_map, const int nelements, int*** host_elem2param, const int nparams, + int* host_map, const int nelements, int*** host_elem2param, const int nparams, const double* epsilon, const double* sigma, const double* lambda, const double* gamma, const double* costheta, const double* biga, @@ -76,41 +76,41 @@ int SWT::init(const int ntypes, const int nlocal, const int nall, const int max_ UCL_WRITE_ONLY); for (int i=0; iucl_device),UCL_READ_ONLY); - + for (int i=0; i(epsilon[i]); dview[i].y=static_cast(sigma[i]); dview[i].z=static_cast(lambda[i]); dview[i].w=static_cast(gamma[i]); } - + ucl_copy(sw1,dview,false); sw1_tex.get_texture(*(this->pair_program),"sw1_tex"); sw1_tex.bind_float(sw1,4); sw2.alloc(nparams,*(this->ucl_device),UCL_READ_ONLY); - + for (int i=0; i(biga[i]); dview[i].y=static_cast(bigb[i]); dview[i].z=static_cast(powerp[i]); dview[i].w=static_cast(powerq[i]); } - + ucl_copy(sw2,dview,false); sw2_tex.get_texture(*(this->pair_program),"sw2_tex"); sw2_tex.bind_float(sw2,4); sw3.alloc(nparams,*(this->ucl_device),UCL_READ_ONLY); - + for (int i=0; i(costheta[i]); dview[i].w=(numtyp)0; } - + ucl_copy(sw3,dview,false); sw3_tex.get_texture(*(this->pair_program),"sw3_tex"); sw3_tex.bind_float(sw3,4); @@ -192,31 +192,32 @@ void SWT::loop(const bool _eflag, const bool _vflag, const int evatom) { vflag=1; else vflag=0; - + int GX=static_cast(ceil(static_cast(this->ans->inum())/ (BX/this->_threads_per_atom))); - // this->_nbor_data == nbor->dev_packed for gpu_nbor == 0 and tpa == 1 - // this->_nbor_data == nbor->dev_nbor for gpu_nbor == 1 + // this->_nbor_data == nbor->dev_packed for gpu_nbor == 0 and tpa > 1 + // this->_nbor_data == nbor->dev_nbor for gpu_nbor == 1 or tpa == 1 int ainum=this->ans->inum(); int nbor_pitch=this->nbor->nbor_pitch(); this->time_pair.start(); + this->k_pair.set_size(GX,BX); - this->k_pair.run(&this->atom->x, &sw1, &sw2, &sw3, + this->k_pair.run(&this->atom->x, &sw1, &sw2, &sw3, &map, &elem2param, &_nelements, &this->nbor->dev_nbor, &this->_nbor_data->begin(), - &this->ans->force, &this->ans->engv, - &eflag, &vflag, &ainum, &nbor_pitch, + &this->ans->force, &this->ans->engv, + &eflag, &vflag, &ainum, &nbor_pitch, &this->_threads_per_atom); BX=this->block_size(); GX=static_cast(ceil(static_cast(this->ans->inum())/ - (BX/(KTHREADS*JTHREADS)))); + (BX/(KTHREADS*JTHREADS)))); this->k_three_center.set_size(GX,BX); - this->k_three_center.run(&this->atom->x, &sw1, &sw2, &sw3, + this->k_three_center.run(&this->atom->x, &sw1, &sw2, &sw3, &map, &elem2param, &_nelements, - &this->nbor->dev_nbor, &this->_nbor_data->begin(), - &this->ans->force, &this->ans->engv, &eflag, &vflag, &ainum, + &this->nbor->dev_nbor, &this->_nbor_data->begin(), + &this->ans->force, &this->ans->engv, &eflag, &vflag, &ainum, &nbor_pitch, &this->_threads_per_atom, &evatom); Answer *end_ans; @@ -227,21 +228,24 @@ void SWT::loop(const bool _eflag, const bool _vflag, const int evatom) { #endif if (evatom!=0) { this->k_three_end_vatom.set_size(GX,BX); - this->k_three_end_vatom.run(&this->atom->x, &sw1, &sw2, &sw3, - &map, &elem2param, &_nelements, - &this->nbor->dev_nbor, &this->_nbor_data->begin(), + this->k_three_end_vatom.run(&this->atom->x, &sw1, &sw2, &sw3, + &map, &elem2param, &_nelements, + &this->nbor->dev_nbor, &this->_nbor_data->begin(), + &this->nbor->dev_acc, &end_ans->force, &end_ans->engv, &eflag, &vflag, &ainum, - &nbor_pitch, &this->_threads_per_atom); + &nbor_pitch, &this->_threads_per_atom, &this->_gpu_nbor); } else { this->k_three_end.set_size(GX,BX); - this->k_three_end.run(&this->atom->x, &sw1, &sw2, &sw3, - &map, &elem2param, &_nelements, - &this->nbor->dev_nbor, &this->_nbor_data->begin(), - &end_ans->force, &end_ans->engv, &eflag, &vflag, &ainum, - &nbor_pitch, &this->_threads_per_atom); + this->k_three_end.run(&this->atom->x, &sw1, &sw2, &sw3, + &map, &elem2param, &_nelements, + &this->nbor->dev_nbor, &this->_nbor_data->begin(), + &this->nbor->dev_acc, + &end_ans->force, &end_ans->engv, &eflag, &vflag, &ainum, + &nbor_pitch, &this->_threads_per_atom, &this->_gpu_nbor); } + this->time_pair.stop(); } diff --git a/lib/gpu/lal_sw.cu b/lib/gpu/lal_sw.cu index 1e358fb6f7..46330c59e4 100644 --- a/lib/gpu/lal_sw.cu +++ b/lib/gpu/lal_sw.cu @@ -138,16 +138,16 @@ __kernel void k_sw(const __global numtyp4 *restrict x_, const __global int *restrict map, const __global int *restrict elem2param, const int nelements, - const __global int * dev_nbor, - const __global int * dev_packed, - __global acctyp4 *restrict ans, - __global acctyp *restrict engv, - const int eflag, const int vflag, const int inum, + const __global int * dev_nbor, + const __global int * dev_packed, + __global acctyp4 *restrict ans, + __global acctyp *restrict engv, + const int eflag, const int vflag, const int inum, const int nbor_pitch, const int t_per_atom) { __local int n_stride; int tid, ii, offset; atom_info(t_per_atom,ii,tid,offset); - + acctyp energy=(acctyp)0; acctyp4 f; f.x=(acctyp)0; f.y=(acctyp)0; f.z=(acctyp)0; @@ -166,9 +166,9 @@ __kernel void k_sw(const __global numtyp4 *restrict x_, numtyp4 ix; fetch4(ix,i,pos_tex); //x_[i]; int itype=ix.w; itype=map[itype]; - + for ( ; nbor0) - energy+=(pre_sw_c5*rp - pre_sw_c6*rq) * expsrainv; + if (eflag>0) + energy+=(pre_sw_c5*rp - pre_sw_c6*rq) * expsrainv; if (vflag>0) { virial[0] += delx*delx*force; @@ -329,29 +328,28 @@ __kernel void k_sw(const __global numtyp4 *restrict x_, fjz = delr1z*(frad1+csfac1)-delr2z*facang12; \ } -__kernel void k_sw_three_center(const __global numtyp4 *restrict x_, +__kernel void k_sw_three_center(const __global numtyp4 *restrict x_, const __global numtyp4 *restrict sw1, const __global numtyp4 *restrict sw2, const __global numtyp4 *restrict sw3, const __global int *restrict map, const __global int *restrict elem2param, const int nelements, - const __global int * dev_nbor, - const __global int * dev_packed, - __global acctyp4 *restrict ans, - __global acctyp *restrict engv, - const int eflag, const int vflag, - const int inum, const int nbor_pitch, + const __global int * dev_nbor, + const __global int * dev_packed, + __global acctyp4 *restrict ans, + __global acctyp *restrict engv, + const int eflag, const int vflag, + const int inum, const int nbor_pitch, const int t_per_atom, const int evatom) { __local int tpa_sq, n_stride; tpa_sq=fast_mul(t_per_atom,t_per_atom); - numtyp sw_epsilon, sw_sigma, sw_lambda, sw_gamma; numtyp sw_sigma_gamma_ij, sw_cut_ij, sw_sigma_gamma_ik, sw_cut_ik; numtyp sw_costheta_ijk, sw_lambda_epsilon_ijk, sw_lambda_epsilon2_ijk; int tid, ii, offset; atom_info(tpa_sq,ii,tid,offset); - + acctyp energy=(acctyp)0; acctyp4 f; f.x=(acctyp)0; f.y=(acctyp)0; f.z=(acctyp)0; @@ -360,7 +358,7 @@ __kernel void k_sw_three_center(const __global numtyp4 *restrict x_, virial[i]=(acctyp)0; __syncthreads(); - + if (ii sw3_ijparam.y) continue; numtyp4 sw1_ijparam; fetch4(sw1_ijparam,ijparam,sw1_tex); - sw_sigma=sw1_ijparam.y; - sw_gamma=sw1_ijparam.w; sw_sigma_gamma_ij=sw1_ijparam.y*sw1_ijparam.w; //sw_sigma*sw_gamma; sw_cut_ij=sw3_ijparam.x; @@ -419,15 +415,11 @@ __kernel void k_sw_three_center(const __global numtyp4 *restrict x_, numtyp rsq2 = delr2x*delr2x + delr2y*delr2y + delr2z*delr2z; if (rsq2 < sw3_ikparam.y) { // sw_cutsq=sw3[ikparam].y; numtyp4 sw1_ikparam; fetch4(sw1_ikparam,ikparam,sw1_tex); - sw_sigma=sw1_ikparam.y; - sw_gamma=sw1_ikparam.w; sw_sigma_gamma_ik=sw1_ikparam.y*sw1_ikparam.w; //sw_sigma*sw_gamma; sw_cut_ik=sw3_ikparam.x; int ijkparam=elem2param[itype*nelements*nelements+jtype*nelements+ktype]; numtyp4 sw1_ijkparam; fetch4(sw1_ijkparam,ijkparam,sw1_tex); - sw_epsilon=sw1_ijkparam.x; - sw_lambda=sw1_ijkparam.z; sw_lambda_epsilon_ijk=sw1_ijkparam.x*sw1_ijkparam.z; //sw_lambda*sw_epsilon; sw_lambda_epsilon2_ijk=(numtyp)2.0*sw_lambda_epsilon_ijk; numtyp4 sw3_ijkparam; fetch4(sw3_ijkparam,ijkparam,sw3_tex); @@ -439,7 +431,7 @@ __kernel void k_sw_three_center(const __global numtyp4 *restrict x_, f.x -= fjx + fkx; f.y -= fjy + fky; f.z -= fjz + fkz; - } + } } } // for nbor @@ -458,29 +450,29 @@ __kernel void k_sw_three_center(const __global numtyp4 *restrict x_, } // if ii } -__kernel void k_sw_three_end(const __global numtyp4 *restrict x_, +__kernel void k_sw_three_end(const __global numtyp4 *restrict x_, const __global numtyp4 *restrict sw1, const __global numtyp4 *restrict sw2, const __global numtyp4 *restrict sw3, const __global int *restrict map, const __global int *restrict elem2param, const int nelements, - const __global int * dev_nbor, - const __global int * dev_packed, - __global acctyp4 *restrict ans, - __global acctyp *restrict engv, - const int eflag, const int vflag, - const int inum, const int nbor_pitch, - const int t_per_atom) { + const __global int * dev_nbor, + const __global int * dev_packed, + const __global int * dev_acc, + __global acctyp4 *restrict ans, + __global acctyp *restrict engv, + const int eflag, const int vflag, + const int inum, const int nbor_pitch, + const int t_per_atom, const int gpu_nbor) { __local int tpa_sq, n_stride; tpa_sq=fast_mul(t_per_atom,t_per_atom); - numtyp sw_epsilon, sw_sigma, sw_lambda, sw_gamma; numtyp sw_sigma_gamma_ij, sw_cut_ij, sw_sigma_gamma_ik, sw_cut_ik; numtyp sw_costheta_ijk, sw_lambda_epsilon_ijk, sw_lambda_epsilon2_ijk; int tid, ii, offset; atom_info(tpa_sq,ii,tid,offset); - + acctyp energy=(acctyp)0; acctyp4 f; f.x=(acctyp)0; f.y=(acctyp)0; f.z=(acctyp)0; @@ -489,7 +481,7 @@ __kernel void k_sw_three_end(const __global numtyp4 *restrict x_, virial[i]=(acctyp)0; __syncthreads(); - + if (ii sw3_ijparam.y) continue; numtyp4 sw1_ijparam; fetch4(sw1_ijparam,ijparam,sw1_tex); - sw_sigma=sw1_ijparam.y; - sw_gamma=sw1_ijparam.w; sw_sigma_gamma_ij=sw1_ijparam.y*sw1_ijparam.w; //sw_sigma*sw_gamma; sw_cut_ij=sw3_ijparam.x; - int nbor_k=j+nbor_pitch; - int numk=dev_nbor[nbor_k]; + int nbor_k,numk; if (dev_nbor==dev_packed) { + if (gpu_nbor) nbor_k=j+nbor_pitch; + else nbor_k=dev_acc[j]+nbor_pitch; + numk=dev_nbor[nbor_k]; nbor_k+=nbor_pitch+fast_mul(j,t_per_atom-1); k_end=nbor_k+fast_mul(numk/t_per_atom,n_stride)+(numk & (t_per_atom-1)); nbor_k+=offset_k; } else { + nbor_k=dev_acc[j]+nbor_pitch; + numk=dev_nbor[nbor_k]; nbor_k+=nbor_pitch; nbor_k=dev_nbor[nbor_k]; k_end=nbor_k+numk; @@ -559,15 +553,11 @@ __kernel void k_sw_three_end(const __global numtyp4 *restrict x_, if (rsq2 < sw3_ikparam.y) { numtyp4 sw1_ikparam; fetch4(sw1_ikparam,ikparam,sw1_tex); - sw_sigma=sw1_ikparam.y; - sw_gamma=sw1_ikparam.w; sw_sigma_gamma_ik=sw1_ikparam.y*sw1_ikparam.w; //sw_sigma*sw_gamma; sw_cut_ik=sw3_ikparam.x; int ijkparam=elem2param[jtype*nelements*nelements+itype*nelements+ktype]; //jik numtyp4 sw1_ijkparam; fetch4(sw1_ijkparam,ijkparam,sw1_tex); - sw_epsilon=sw1_ijkparam.x; - sw_lambda=sw1_ijkparam.z; sw_lambda_epsilon_ijk=sw1_ijkparam.x*sw1_ijkparam.z; //sw_lambda*sw_epsilon; sw_lambda_epsilon2_ijk=(numtyp)2.0*sw_lambda_epsilon_ijk; numtyp4 sw3_ijkparam; fetch4(sw3_ijkparam,ijkparam,sw3_tex); @@ -605,22 +595,22 @@ __kernel void k_sw_three_end_vatom(const __global numtyp4 *restrict x_, const __global int *restrict map, const __global int *restrict elem2param, const int nelements, - const __global int * dev_nbor, - const __global int * dev_packed, - __global acctyp4 *restrict ans, - __global acctyp *restrict engv, - const int eflag, const int vflag, - const int inum, const int nbor_pitch, - const int t_per_atom) { + const __global int * dev_nbor, + const __global int * dev_packed, + const __global int * dev_acc, + __global acctyp4 *restrict ans, + __global acctyp *restrict engv, + const int eflag, const int vflag, + const int inum, const int nbor_pitch, + const int t_per_atom, const int gpu_nbor) { __local int tpa_sq, n_stride; tpa_sq=fast_mul(t_per_atom,t_per_atom); - numtyp sw_epsilon, sw_sigma, sw_lambda, sw_gamma; numtyp sw_sigma_gamma_ij, sw_cut_ij, sw_sigma_gamma_ik, sw_cut_ik; numtyp sw_costheta_ijk, sw_lambda_epsilon_ijk, sw_lambda_epsilon2_ijk; int tid, ii, offset; atom_info(tpa_sq,ii,tid,offset); - + acctyp energy=(acctyp)0; acctyp4 f; f.x=(acctyp)0; f.y=(acctyp)0; f.z=(acctyp)0; @@ -629,7 +619,7 @@ __kernel void k_sw_three_end_vatom(const __global numtyp4 *restrict x_, virial[i]=(acctyp)0; __syncthreads(); - + if (ii sw3_ijparam.y) continue; numtyp4 sw1_ijparam; fetch4(sw1_ijparam,ijparam,sw1_tex); - sw_sigma=sw1_ijparam.y; - sw_gamma=sw1_ijparam.w; sw_sigma_gamma_ij=sw1_ijparam.y*sw1_ijparam.w; //sw_sigma*sw_gamma; sw_cut_ij=sw3_ijparam.x; - - int nbor_k=j+nbor_pitch; - int numk=dev_nbor[nbor_k]; + + int nbor_k,numk; if (dev_nbor==dev_packed) { + if (gpu_nbor) nbor_k=j+nbor_pitch; + else nbor_k=dev_acc[j]+nbor_pitch; + numk=dev_nbor[nbor_k]; nbor_k+=nbor_pitch+fast_mul(j,t_per_atom-1); k_end=nbor_k+fast_mul(numk/t_per_atom,n_stride)+(numk & (t_per_atom-1)); nbor_k+=offset_k; } else { + nbor_k=dev_acc[j]+nbor_pitch; + numk=dev_nbor[nbor_k]; nbor_k+=nbor_pitch; nbor_k=dev_nbor[nbor_k]; k_end=nbor_k+numk; @@ -699,15 +691,11 @@ __kernel void k_sw_three_end_vatom(const __global numtyp4 *restrict x_, if (rsq2 < sw3_ikparam.y) { numtyp4 sw1_ikparam; fetch4(sw1_ikparam,ikparam,sw1_tex); - sw_sigma=sw1_ikparam.y; - sw_gamma=sw1_ikparam.w; sw_sigma_gamma_ik=sw1_ikparam.y*sw1_ikparam.w; //sw_sigma*sw_gamma; sw_cut_ik=sw3_ikparam.x; int ijkparam=elem2param[jtype*nelements*nelements+itype*nelements+ktype]; // jik numtyp4 sw1_ijkparam; fetch4(sw1_ijkparam,ijkparam,sw1_tex); - sw_epsilon=sw1_ijkparam.x; - sw_lambda=sw1_ijkparam.z; sw_lambda_epsilon_ijk=sw1_ijkparam.x*sw1_ijkparam.z; //sw_lambda*sw_epsilon; sw_lambda_epsilon2_ijk=(numtyp)2.0*sw_lambda_epsilon_ijk; numtyp4 sw3_ijkparam; fetch4(sw3_ijkparam,ijkparam,sw3_tex); diff --git a/lib/gpu/lal_sw.h b/lib/gpu/lal_sw.h index 66b36a90b0..3546f02eb7 100644 --- a/lib/gpu/lal_sw.h +++ b/lib/gpu/lal_sw.h @@ -24,28 +24,28 @@ template class SW : public BaseThree { public: SW(); - ~SW(); + ~SW(); /// Clear any previous data and set up for a new LAMMPS run /** \param max_nbors initial number of rows in the neighbor matrix * \param cell_size cutoff + skin * \param gpu_split fraction of particles handled by device - * + * * Returns: * - 0 if successfull * - -1 if fix gpu not found * - -3 if there is an out of memory error * - -4 if the GPU library was not compiled for GPU * - -5 Double precision is not supported on card **/ - int init(const int ntypes, const int nlocal, const int nall, const int max_nbors, + int init(const int ntypes, const int nlocal, const int nall, const int max_nbors, const double cell_size, const double gpu_split, FILE *screen, - int* host_map, const int nelements, int*** host_elem2param, const int nparams, + int* host_map, const int nelements, int*** host_elem2param, const int nparams, const double* epsilon, const double* sigma, const double* lambda, const double* gamma, const double* costheta, const double* biga, const double* bigb, const double* powerp, const double* powerq, const double* cut, const double* cutsq); - + /// Clear all host and device data /** \note This is called at the beginning of the init() routine **/ void clear(); @@ -61,7 +61,7 @@ class SW : public BaseThree { /// If atom type constants fit in shared memory, use fast kernels bool shared_types; - /// Number of atom types + /// Number of atom types int _lj_types; /// sw1.x = epsilon, sw1.y = sigma, sw1.z = lambda, sw1.w = gamma diff --git a/lib/gpu/lal_tersoff.cpp b/lib/gpu/lal_tersoff.cpp index bc89c53765..8805a6f433 100644 --- a/lib/gpu/lal_tersoff.cpp +++ b/lib/gpu/lal_tersoff.cpp @@ -437,16 +437,18 @@ void TersoffT::loop(const bool _eflag, const bool _vflag, const int evatom) { this->k_three_end_vatom.run(&this->atom->x, &ts1, &ts2, &ts4, &cutsq, &map, &elem2param, &_nelements, &_nparams, &_zetaij, &this->nbor->dev_nbor, &this->_nbor_data->begin(), + &this->nbor->dev_acc, &end_ans->force, &end_ans->engv, &eflag, &vflag, &ainum, - &nbor_pitch, &this->_threads_per_atom); + &nbor_pitch, &this->_threads_per_atom, &this->_gpu_nbor); } else { this->k_three_end.set_size(GX,BX); this->k_three_end.run(&this->atom->x, &ts1, &ts2, &ts4, &cutsq, &map, &elem2param, &_nelements, &_nparams, &_zetaij, &this->nbor->dev_nbor, &this->_nbor_data->begin(), + &this->nbor->dev_acc, &end_ans->force, &end_ans->engv, &eflag, &vflag, &ainum, - &nbor_pitch, &this->_threads_per_atom); + &nbor_pitch, &this->_threads_per_atom, &this->_gpu_nbor); } this->time_pair.stop(); diff --git a/lib/gpu/lal_tersoff.cu b/lib/gpu/lal_tersoff.cu index e98a454f58..4a71518b53 100644 --- a/lib/gpu/lal_tersoff.cu +++ b/lib/gpu/lal_tersoff.cu @@ -597,11 +597,12 @@ __kernel void k_tersoff_three_end(const __global numtyp4 *restrict x_, const __global acctyp4 *restrict zetaij, const __global int * dev_nbor, const __global int * dev_packed, + const __global int * dev_acc, __global acctyp4 *restrict ans, __global acctyp *restrict engv, const int eflag, const int vflag, const int inum, const int nbor_pitch, - const int t_per_atom) { + const int t_per_atom, const int gpu_nbor) { __local int tpa_sq, n_stride; tpa_sq=fast_mul(t_per_atom,t_per_atom); numtyp lam3, powermint, bigr, bigd, c, d, h, gamma; @@ -666,13 +667,17 @@ __kernel void k_tersoff_three_end(const __global numtyp4 *restrict x_, mdelr1[1] = -delr1[1]; mdelr1[2] = -delr1[2]; - int nbor_k=j+nbor_pitch; - int numk=dev_nbor[nbor_k]; + int nbor_k,numk; if (dev_nbor==dev_packed) { + if (gpu_nbor) nbor_k=j+nbor_pitch; + else nbor_k=dev_acc[j]+nbor_pitch; + numk=dev_nbor[nbor_k]; nbor_k+=nbor_pitch+fast_mul(j,t_per_atom-1); k_end=nbor_k+fast_mul(numk/t_per_atom,n_stride)+(numk & (t_per_atom-1)); nbor_k+=offset_k; } else { + nbor_k=dev_acc[j]+nbor_pitch; + numk=dev_nbor[nbor_k]; nbor_k+=nbor_pitch; nbor_k=dev_nbor[nbor_k]; k_end=nbor_k+numk; @@ -818,11 +823,12 @@ __kernel void k_tersoff_three_end_vatom(const __global numtyp4 *restrict x_, const __global acctyp4 *restrict zetaij, const __global int * dev_nbor, const __global int * dev_packed, + const __global int * dev_acc, __global acctyp4 *restrict ans, __global acctyp *restrict engv, const int eflag, const int vflag, const int inum, const int nbor_pitch, - const int t_per_atom) { + const int t_per_atom, const int gpu_nbor) { __local int tpa_sq, n_stride; tpa_sq=fast_mul(t_per_atom,t_per_atom); numtyp lam3, powermint, bigr, bigd, c, d, h, gamma; @@ -887,13 +893,17 @@ __kernel void k_tersoff_three_end_vatom(const __global numtyp4 *restrict x_, mdelr1[1] = -delr1[1]; mdelr1[2] = -delr1[2]; - int nbor_k=j+nbor_pitch; - int numk=dev_nbor[nbor_k]; + int nbor_k,numk; if (dev_nbor==dev_packed) { + if (gpu_nbor) nbor_k=j+nbor_pitch; + else nbor_k=dev_acc[j]+nbor_pitch; + numk=dev_nbor[nbor_k]; nbor_k+=nbor_pitch+fast_mul(j,t_per_atom-1); k_end=nbor_k+fast_mul(numk/t_per_atom,n_stride)+(numk & (t_per_atom-1)); nbor_k+=offset_k; } else { + nbor_k=dev_acc[j]+nbor_pitch; + numk=dev_nbor[nbor_k]; nbor_k+=nbor_pitch; nbor_k=dev_nbor[nbor_k]; k_end=nbor_k+numk; diff --git a/lib/gpu/lal_tersoff_mod.cpp b/lib/gpu/lal_tersoff_mod.cpp index bfcc9c3bd3..04baa4ee47 100644 --- a/lib/gpu/lal_tersoff_mod.cpp +++ b/lib/gpu/lal_tersoff_mod.cpp @@ -437,16 +437,18 @@ void TersoffMT::loop(const bool _eflag, const bool _vflag, const int evatom) { this->k_three_end_vatom.run(&this->atom->x, &ts1, &ts2, &ts4, &ts5, &cutsq, &map, &elem2param, &_nelements, &_nparams, &_zetaij, &this->nbor->dev_nbor, &this->_nbor_data->begin(), + &this->nbor->dev_acc, &end_ans->force, &end_ans->engv, &eflag, &vflag, &ainum, - &nbor_pitch, &this->_threads_per_atom); + &nbor_pitch, &this->_threads_per_atom, &this->_gpu_nbor); } else { this->k_three_end.set_size(GX,BX); this->k_three_end.run(&this->atom->x, &ts1, &ts2, &ts4, &ts5, &cutsq, &map, &elem2param, &_nelements, &_nparams, &_zetaij, &this->nbor->dev_nbor, &this->_nbor_data->begin(), + &this->nbor->dev_acc, &end_ans->force, &end_ans->engv, &eflag, &vflag, &ainum, - &nbor_pitch, &this->_threads_per_atom); + &nbor_pitch, &this->_threads_per_atom, &this->_gpu_nbor); } this->time_pair.stop(); diff --git a/lib/gpu/lal_tersoff_mod.cu b/lib/gpu/lal_tersoff_mod.cu index ba4ad32005..13c8147d99 100644 --- a/lib/gpu/lal_tersoff_mod.cu +++ b/lib/gpu/lal_tersoff_mod.cu @@ -605,11 +605,12 @@ __kernel void k_tersoff_mod_three_end(const __global numtyp4 *restrict x_, const __global acctyp4 *restrict zetaij, const __global int * dev_nbor, const __global int * dev_packed, + const __global int * dev_acc, __global acctyp4 *restrict ans, __global acctyp *restrict engv, const int eflag, const int vflag, const int inum, const int nbor_pitch, - const int t_per_atom) { + const int t_per_atom, const int gpu_nbor) { __local int tpa_sq, n_stride; tpa_sq=fast_mul(t_per_atom,t_per_atom); numtyp lam3, powermint, bigr, bigd, c1, c2, c3, c4, c5, h; @@ -676,13 +677,17 @@ __kernel void k_tersoff_mod_three_end(const __global numtyp4 *restrict x_, mdelr1[1] = -delr1[1]; mdelr1[2] = -delr1[2]; - int nbor_k=j+nbor_pitch; - int numk=dev_nbor[nbor_k]; + int nbor_k,numk; if (dev_nbor==dev_packed) { + if (gpu_nbor) nbor_k=j+nbor_pitch; + else nbor_k=dev_acc[j]+nbor_pitch; + numk=dev_nbor[nbor_k]; nbor_k+=nbor_pitch+fast_mul(j,t_per_atom-1); k_end=nbor_k+fast_mul(numk/t_per_atom,n_stride)+(numk & (t_per_atom-1)); nbor_k+=offset_k; } else { + nbor_k=dev_acc[j]+nbor_pitch; + numk=dev_nbor[nbor_k]; nbor_k+=nbor_pitch; nbor_k=dev_nbor[nbor_k]; k_end=nbor_k+numk; @@ -835,11 +840,12 @@ __kernel void k_tersoff_mod_three_end_vatom(const __global numtyp4 *restrict x_, const __global acctyp4 *restrict zetaij, const __global int * dev_nbor, const __global int * dev_packed, + const __global int * dev_acc, __global acctyp4 *restrict ans, __global acctyp *restrict engv, const int eflag, const int vflag, const int inum, const int nbor_pitch, - const int t_per_atom) { + const int t_per_atom, const int gpu_nbor) { __local int tpa_sq, n_stride; tpa_sq=fast_mul(t_per_atom,t_per_atom); numtyp lam3, powermint, bigr, bigd, c1, c2, c3, c4, c5, h; @@ -906,13 +912,17 @@ __kernel void k_tersoff_mod_three_end_vatom(const __global numtyp4 *restrict x_, mdelr1[1] = -delr1[1]; mdelr1[2] = -delr1[2]; - int nbor_k=j+nbor_pitch; - int numk=dev_nbor[nbor_k]; + int nbor_k,numk; if (dev_nbor==dev_packed) { + if (gpu_nbor) nbor_k=j+nbor_pitch; + else nbor_k=dev_acc[j]+nbor_pitch; + numk=dev_nbor[nbor_k]; nbor_k+=nbor_pitch+fast_mul(j,t_per_atom-1); k_end=nbor_k+fast_mul(numk/t_per_atom,n_stride)+(numk & (t_per_atom-1)); nbor_k+=offset_k; } else { + nbor_k=dev_acc[j]+nbor_pitch; + numk=dev_nbor[nbor_k]; nbor_k+=nbor_pitch; nbor_k=dev_nbor[nbor_k]; k_end=nbor_k+numk; diff --git a/lib/gpu/lal_tersoff_zbl.cpp b/lib/gpu/lal_tersoff_zbl.cpp index 57688f53ab..9193d9a8d8 100644 --- a/lib/gpu/lal_tersoff_zbl.cpp +++ b/lib/gpu/lal_tersoff_zbl.cpp @@ -463,16 +463,18 @@ void TersoffZT::loop(const bool _eflag, const bool _vflag, const int evatom) { this->k_three_end_vatom.run(&this->atom->x, &ts1, &ts2, &ts4, &cutsq, &map, &elem2param, &_nelements, &_nparams, &_zetaij, &this->nbor->dev_nbor, &this->_nbor_data->begin(), + &this->nbor->dev_acc, &end_ans->force, &end_ans->engv, &eflag, &vflag, &ainum, - &nbor_pitch, &this->_threads_per_atom); + &nbor_pitch, &this->_threads_per_atom, &this->_gpu_nbor); } else { this->k_three_end.set_size(GX,BX); this->k_three_end.run(&this->atom->x, &ts1, &ts2, &ts4, &cutsq, &map, &elem2param, &_nelements, &_nparams, &_zetaij, &this->nbor->dev_nbor, &this->_nbor_data->begin(), + &this->nbor->dev_acc, &end_ans->force, &end_ans->engv, &eflag, &vflag, &ainum, - &nbor_pitch, &this->_threads_per_atom); + &nbor_pitch, &this->_threads_per_atom, &this->_gpu_nbor); } this->time_pair.stop(); diff --git a/lib/gpu/lal_tersoff_zbl.cu b/lib/gpu/lal_tersoff_zbl.cu index 0d6c5a38d6..97eb72b04f 100644 --- a/lib/gpu/lal_tersoff_zbl.cu +++ b/lib/gpu/lal_tersoff_zbl.cu @@ -617,11 +617,12 @@ __kernel void k_tersoff_zbl_three_end(const __global numtyp4 *restrict x_, const __global acctyp4 *restrict zetaij, const __global int * dev_nbor, const __global int * dev_packed, + const __global int * dev_acc, __global acctyp4 *restrict ans, __global acctyp *restrict engv, const int eflag, const int vflag, const int inum, const int nbor_pitch, - const int t_per_atom) { + const int t_per_atom, const int gpu_nbor) { __local int tpa_sq, n_stride; tpa_sq=fast_mul(t_per_atom,t_per_atom); numtyp lam3, powermint, bigr, bigd, c, d, h, gamma; @@ -686,13 +687,17 @@ __kernel void k_tersoff_zbl_three_end(const __global numtyp4 *restrict x_, mdelr1[1] = -delr1[1]; mdelr1[2] = -delr1[2]; - int nbor_k=j+nbor_pitch; - int numk=dev_nbor[nbor_k]; + int nbor_k,numk; if (dev_nbor==dev_packed) { + if (gpu_nbor) nbor_k=j+nbor_pitch; + else nbor_k=dev_acc[j]+nbor_pitch; + numk=dev_nbor[nbor_k]; nbor_k+=nbor_pitch+fast_mul(j,t_per_atom-1); k_end=nbor_k+fast_mul(numk/t_per_atom,n_stride)+(numk & (t_per_atom-1)); nbor_k+=offset_k; } else { + nbor_k=dev_acc[j]+nbor_pitch; + numk=dev_nbor[nbor_k]; nbor_k+=nbor_pitch; nbor_k=dev_nbor[nbor_k]; k_end=nbor_k+numk; @@ -838,11 +843,12 @@ __kernel void k_tersoff_zbl_three_end_vatom(const __global numtyp4 *restrict x_, const __global acctyp4 *restrict zetaij, const __global int * dev_nbor, const __global int * dev_packed, + const __global int * dev_acc, __global acctyp4 *restrict ans, __global acctyp *restrict engv, const int eflag, const int vflag, const int inum, const int nbor_pitch, - const int t_per_atom) { + const int t_per_atom, const int gpu_nbor) { __local int tpa_sq, n_stride; tpa_sq=fast_mul(t_per_atom,t_per_atom); numtyp lam3, powermint, bigr, bigd, c, d, h, gamma; @@ -907,13 +913,17 @@ __kernel void k_tersoff_zbl_three_end_vatom(const __global numtyp4 *restrict x_, mdelr1[1] = -delr1[1]; mdelr1[2] = -delr1[2]; - int nbor_k=j+nbor_pitch; - int numk=dev_nbor[nbor_k]; + int nbor_k,numk; if (dev_nbor==dev_packed) { + if (gpu_nbor) nbor_k=j+nbor_pitch; + else nbor_k=dev_acc[j]+nbor_pitch; + numk=dev_nbor[nbor_k]; nbor_k+=nbor_pitch+fast_mul(j,t_per_atom-1); k_end=nbor_k+fast_mul(numk/t_per_atom,n_stride)+(numk & (t_per_atom-1)); nbor_k+=offset_k; } else { + nbor_k=dev_acc[j]+nbor_pitch; + numk=dev_nbor[nbor_k]; nbor_k+=nbor_pitch; nbor_k=dev_nbor[nbor_k]; k_end=nbor_k+numk; diff --git a/src/GPU/pair_sw_gpu.cpp b/src/GPU/pair_sw_gpu.cpp index 67faf98da4..d2d21a131a 100644 --- a/src/GPU/pair_sw_gpu.cpp +++ b/src/GPU/pair_sw_gpu.cpp @@ -115,7 +115,7 @@ void PairSWGPU::compute(int eflag, int vflag) numneigh = list->numneigh; firstneigh = list->firstneigh; - sw_gpu_compute(neighbor->ago, atom->nlocal, nall, inum+list->gnum, + sw_gpu_compute(neighbor->ago, inum, nall, inum+list->gnum, atom->x, atom->type, ilist, numneigh, firstneigh, eflag, vflag, eflag_atom, vflag_atom, host_start, cpu_time, success); diff --git a/src/GPU/pair_tersoff_gpu.cpp b/src/GPU/pair_tersoff_gpu.cpp index 7b225de729..41d8e6b751 100644 --- a/src/GPU/pair_tersoff_gpu.cpp +++ b/src/GPU/pair_tersoff_gpu.cpp @@ -119,7 +119,7 @@ void PairTersoffGPU::compute(int eflag, int vflag) numneigh = list->numneigh; firstneigh = list->firstneigh; - tersoff_gpu_compute(neighbor->ago, atom->nlocal, nall, inum+list->gnum, + tersoff_gpu_compute(neighbor->ago, inum, nall, inum+list->gnum, atom->x, atom->type, ilist, numneigh, firstneigh, eflag, vflag, eflag_atom, vflag_atom, host_start, cpu_time, success); diff --git a/src/GPU/pair_tersoff_mod_gpu.cpp b/src/GPU/pair_tersoff_mod_gpu.cpp index 3313904d16..25ea2cb99f 100644 --- a/src/GPU/pair_tersoff_mod_gpu.cpp +++ b/src/GPU/pair_tersoff_mod_gpu.cpp @@ -112,7 +112,7 @@ void PairTersoffMODGPU::compute(int eflag, int vflag) numneigh = list->numneigh; firstneigh = list->firstneigh; - tersoff_mod_gpu_compute(neighbor->ago, atom->nlocal, nall, inum+list->gnum, + tersoff_mod_gpu_compute(neighbor->ago, inum, nall, inum+list->gnum, atom->x, atom->type, ilist, numneigh, firstneigh, eflag, vflag, eflag_atom, vflag_atom, host_start, cpu_time, success); diff --git a/src/GPU/pair_tersoff_zbl_gpu.cpp b/src/GPU/pair_tersoff_zbl_gpu.cpp index 86f02e49ef..b4b679b7d0 100644 --- a/src/GPU/pair_tersoff_zbl_gpu.cpp +++ b/src/GPU/pair_tersoff_zbl_gpu.cpp @@ -120,7 +120,7 @@ void PairTersoffZBLGPU::compute(int eflag, int vflag) numneigh = list->numneigh; firstneigh = list->firstneigh; - tersoff_zbl_gpu_compute(neighbor->ago, atom->nlocal, nall, inum+list->gnum, + tersoff_zbl_gpu_compute(neighbor->ago, inum, nall, inum+list->gnum, atom->x, atom->type, ilist, numneigh, firstneigh, eflag, vflag, eflag_atom, vflag_atom, host_start, cpu_time, success); From b56bdd2d7bf3dac72bd98e713433ffa0152ac115 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Fri, 24 Jun 2016 13:55:14 -0400 Subject: [PATCH 12/15] remove trailing whitespace in gpu library --- lib/gpu/lal_answer.cpp | 46 ++-- lib/gpu/lal_atom.cpp | 46 ++-- lib/gpu/lal_atom.cu | 6 +- lib/gpu/lal_atom.h | 60 +++--- lib/gpu/lal_balance.h | 18 +- lib/gpu/lal_base_atomic.cpp | 20 +- lib/gpu/lal_base_atomic.h | 22 +- lib/gpu/lal_base_charge.cpp | 16 +- lib/gpu/lal_base_charge.h | 12 +- lib/gpu/lal_base_dipole.cpp | 18 +- lib/gpu/lal_base_dipole.h | 12 +- lib/gpu/lal_base_dpd.cpp | 18 +- lib/gpu/lal_base_dpd.h | 12 +- lib/gpu/lal_base_ellipsoid.cpp | 34 +-- lib/gpu/lal_base_ellipsoid.h | 28 +-- lib/gpu/lal_beck.cpp | 10 +- lib/gpu/lal_beck.cu | 26 +-- lib/gpu/lal_beck.h | 12 +- lib/gpu/lal_beck_ext.cpp | 6 +- lib/gpu/lal_born.cpp | 22 +- lib/gpu/lal_born.cu | 58 ++--- lib/gpu/lal_born.h | 20 +- lib/gpu/lal_born_coul_long.cpp | 26 +-- lib/gpu/lal_born_coul_long.cu | 268 +++++++++++------------ lib/gpu/lal_born_coul_long.h | 20 +- lib/gpu/lal_born_coul_long_ext.cpp | 30 +-- lib/gpu/lal_born_coul_wolf.cpp | 28 +-- lib/gpu/lal_born_coul_wolf.cu | 64 +++--- lib/gpu/lal_born_coul_wolf.h | 20 +- lib/gpu/lal_born_coul_wolf_ext.cpp | 22 +- lib/gpu/lal_born_ext.cpp | 28 +-- lib/gpu/lal_buck.cpp | 28 +-- lib/gpu/lal_buck.cu | 54 ++--- lib/gpu/lal_buck.h | 18 +- lib/gpu/lal_buck_coul.cpp | 28 +-- lib/gpu/lal_buck_coul.cu | 80 +++---- lib/gpu/lal_buck_coul.h | 20 +- lib/gpu/lal_buck_coul_ext.cpp | 22 +- lib/gpu/lal_buck_coul_long.cpp | 24 +-- lib/gpu/lal_buck_coul_long.cu | 276 ++++++++++++------------ lib/gpu/lal_buck_coul_long.h | 14 +- lib/gpu/lal_buck_coul_long_ext.cpp | 18 +- lib/gpu/lal_buck_ext.cpp | 22 +- lib/gpu/lal_cg_cmm.cpp | 22 +- lib/gpu/lal_cg_cmm.cu | 44 ++-- lib/gpu/lal_cg_cmm.h | 10 +- lib/gpu/lal_cg_cmm_ext.cpp | 12 +- lib/gpu/lal_cg_cmm_long.cpp | 24 +-- lib/gpu/lal_cg_cmm_long.cu | 38 ++-- lib/gpu/lal_cg_cmm_long.h | 12 +- lib/gpu/lal_cg_cmm_long_ext.cpp | 14 +- lib/gpu/lal_charmm_long.cpp | 20 +- lib/gpu/lal_charmm_long.cu | 42 ++-- lib/gpu/lal_charmm_long.h | 12 +- lib/gpu/lal_charmm_long_ext.cpp | 10 +- lib/gpu/lal_colloid.cpp | 30 +-- lib/gpu/lal_colloid.cu | 112 +++++----- lib/gpu/lal_colloid.h | 20 +- lib/gpu/lal_colloid_ext.cpp | 20 +- lib/gpu/lal_coul.cpp | 18 +- lib/gpu/lal_coul.cu | 38 ++-- lib/gpu/lal_coul.h | 12 +- lib/gpu/lal_coul_debye.cpp | 16 +- lib/gpu/lal_coul_debye.cu | 26 +-- lib/gpu/lal_coul_debye.h | 12 +- lib/gpu/lal_coul_debye_ext.cpp | 14 +- lib/gpu/lal_coul_dsf.cpp | 18 +- lib/gpu/lal_coul_dsf.cu | 56 ++--- lib/gpu/lal_coul_dsf.h | 10 +- lib/gpu/lal_coul_dsf_ext.cpp | 20 +- lib/gpu/lal_coul_ext.cpp | 16 +- lib/gpu/lal_coul_long.cpp | 12 +- lib/gpu/lal_coul_long.cu | 18 +- lib/gpu/lal_coul_long.h | 6 +- lib/gpu/lal_coul_long_ext.cpp | 8 +- lib/gpu/lal_device.cpp | 108 +++++----- lib/gpu/lal_device.cu | 6 +- lib/gpu/lal_device.h | 68 +++--- lib/gpu/lal_dipole_lj.cpp | 16 +- lib/gpu/lal_dipole_lj.cu | 88 ++++---- lib/gpu/lal_dipole_lj.h | 8 +- lib/gpu/lal_dipole_lj_ext.cpp | 10 +- lib/gpu/lal_dipole_lj_sf.cpp | 20 +- lib/gpu/lal_dipole_lj_sf.cu | 122 +++++------ lib/gpu/lal_dipole_lj_sf.h | 8 +- lib/gpu/lal_dipole_lj_sf_ext.cpp | 10 +- lib/gpu/lal_dpd.cpp | 26 +-- lib/gpu/lal_dpd.cu | 84 ++++---- lib/gpu/lal_dpd.h | 18 +- lib/gpu/lal_dpd_ext.cpp | 20 +- lib/gpu/lal_eam.cpp | 134 ++++++------ lib/gpu/lal_eam.cu | 136 ++++++------ lib/gpu/lal_eam.h | 54 ++--- lib/gpu/lal_eam_alloy_ext.cpp | 32 +-- lib/gpu/lal_eam_ext.cpp | 32 +-- lib/gpu/lal_eam_fs_ext.cpp | 32 +-- lib/gpu/lal_ellipsoid_extra.h | 14 +- lib/gpu/lal_ellipsoid_nbor.cu | 34 +-- lib/gpu/lal_gauss.cpp | 18 +- lib/gpu/lal_gauss.cu | 60 +++--- lib/gpu/lal_gauss.h | 18 +- lib/gpu/lal_gauss_ext.cpp | 22 +- lib/gpu/lal_gayberne.cpp | 66 +++--- lib/gpu/lal_gayberne.cu | 72 +++---- lib/gpu/lal_gayberne.h | 26 +-- lib/gpu/lal_gayberne_ext.cpp | 20 +- lib/gpu/lal_gayberne_lj.cu | 130 ++++++------ lib/gpu/lal_lj.cpp | 26 +-- lib/gpu/lal_lj.cu | 60 +++--- lib/gpu/lal_lj.h | 16 +- lib/gpu/lal_lj96.cpp | 14 +- lib/gpu/lal_lj96.cu | 50 ++--- lib/gpu/lal_lj96.h | 10 +- lib/gpu/lal_lj96_ext.cpp | 6 +- lib/gpu/lal_lj_class2_long.cpp | 12 +- lib/gpu/lal_lj_class2_long.cu | 42 ++-- lib/gpu/lal_lj_class2_long.h | 8 +- lib/gpu/lal_lj_class2_long_ext.cpp | 6 +- lib/gpu/lal_lj_coul.cpp | 20 +- lib/gpu/lal_lj_coul.cu | 46 ++-- lib/gpu/lal_lj_coul.h | 8 +- lib/gpu/lal_lj_coul_debye.cpp | 18 +- lib/gpu/lal_lj_coul_debye.cu | 42 ++-- lib/gpu/lal_lj_coul_debye.h | 8 +- lib/gpu/lal_lj_coul_debye_ext.cpp | 10 +- lib/gpu/lal_lj_coul_ext.cpp | 8 +- lib/gpu/lal_lj_coul_long.cpp | 18 +- lib/gpu/lal_lj_coul_long.cu | 38 ++-- lib/gpu/lal_lj_coul_long.h | 10 +- lib/gpu/lal_lj_coul_long_ext.cpp | 16 +- lib/gpu/lal_lj_coul_msm.cpp | 20 +- lib/gpu/lal_lj_coul_msm.cu | 30 +-- lib/gpu/lal_lj_coul_msm.h | 14 +- lib/gpu/lal_lj_coul_msm_ext.cpp | 8 +- lib/gpu/lal_lj_cubic.cpp | 22 +- lib/gpu/lal_lj_cubic.cu | 64 +++--- lib/gpu/lal_lj_cubic.h | 16 +- lib/gpu/lal_lj_cubic_ext.cpp | 14 +- lib/gpu/lal_lj_dsf.cpp | 20 +- lib/gpu/lal_lj_dsf.cu | 46 ++-- lib/gpu/lal_lj_dsf.h | 8 +- lib/gpu/lal_lj_dsf_ext.cpp | 8 +- lib/gpu/lal_lj_expand.cpp | 24 +-- lib/gpu/lal_lj_expand.cu | 58 ++--- lib/gpu/lal_lj_expand.h | 14 +- lib/gpu/lal_lj_expand_ext.cpp | 12 +- lib/gpu/lal_lj_ext.cpp | 12 +- lib/gpu/lal_lj_gromacs.cpp | 22 +- lib/gpu/lal_lj_gromacs.cu | 26 +-- lib/gpu/lal_lj_gromacs.h | 12 +- lib/gpu/lal_lj_gromacs_ext.cpp | 12 +- lib/gpu/lal_mie.cpp | 12 +- lib/gpu/lal_mie.cu | 42 ++-- lib/gpu/lal_mie.h | 12 +- lib/gpu/lal_mie_ext.cpp | 6 +- lib/gpu/lal_morse.cpp | 24 +-- lib/gpu/lal_morse.cu | 48 ++--- lib/gpu/lal_morse.h | 12 +- lib/gpu/lal_morse_ext.cpp | 12 +- lib/gpu/lal_neighbor_cpu.cu | 6 +- lib/gpu/lal_neighbor_gpu.cu | 72 +++---- lib/gpu/lal_neighbor_shared.cpp | 2 +- lib/gpu/lal_neighbor_shared.h | 6 +- lib/gpu/lal_pppm.cpp | 44 ++-- lib/gpu/lal_pppm.cu | 50 ++--- lib/gpu/lal_pppm.h | 28 +-- lib/gpu/lal_pppm_ext.cpp | 18 +- lib/gpu/lal_precision.h | 8 +- lib/gpu/lal_preprocessor.h | 20 +- lib/gpu/lal_re_squared.cpp | 52 ++--- lib/gpu/lal_re_squared.cu | 40 ++-- lib/gpu/lal_re_squared.h | 20 +- lib/gpu/lal_re_squared_ext.cpp | 20 +- lib/gpu/lal_re_squared_lj.cu | 140 ++++++------ lib/gpu/lal_soft.cpp | 14 +- lib/gpu/lal_soft.cu | 32 +-- lib/gpu/lal_soft.h | 14 +- lib/gpu/lal_soft_ext.cpp | 14 +- lib/gpu/lal_sw_ext.cpp | 24 +-- lib/gpu/lal_table.cpp | 88 ++++---- lib/gpu/lal_table.cu | 328 ++++++++++++++--------------- lib/gpu/lal_table.h | 36 ++-- lib/gpu/lal_table_ext.cpp | 12 +- lib/gpu/lal_yukawa.cpp | 16 +- lib/gpu/lal_yukawa.cu | 52 ++--- lib/gpu/lal_yukawa.h | 16 +- lib/gpu/lal_yukawa_colloid.cpp | 62 +++--- lib/gpu/lal_yukawa_colloid.cu | 62 +++--- lib/gpu/lal_yukawa_colloid.h | 28 +-- lib/gpu/lal_yukawa_colloid_ext.cpp | 24 +-- lib/gpu/lal_yukawa_ext.cpp | 20 +- lib/gpu/lal_zbl.cpp | 24 +-- lib/gpu/lal_zbl.cu | 76 +++---- lib/gpu/lal_zbl.h | 20 +- lib/gpu/lal_zbl_ext.cpp | 18 +- 195 files changed, 3257 insertions(+), 3257 deletions(-) diff --git a/lib/gpu/lal_answer.cpp b/lib/gpu/lal_answer.cpp index dd0b5d2424..bd8c7ef843 100644 --- a/lib/gpu/lal_answer.cpp +++ b/lib/gpu/lal_answer.cpp @@ -9,7 +9,7 @@ This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) __________________________________________________________________________ - begin : + begin : email : brownw@ornl.gov ***************************************************************************/ @@ -24,7 +24,7 @@ AnswerT::Answer() : _allocated(false),_eflag(false),_vflag(false), } template -int AnswerT::bytes_per_atom() const { +int AnswerT::bytes_per_atom() const { int bytes=11*sizeof(acctyp); if (_rot) bytes+=4*sizeof(acctyp); @@ -38,19 +38,19 @@ bool AnswerT::alloc(const int inum) { _max_local=static_cast(static_cast(inum)*1.10); bool success=true; - + _ans_fields=4; if (_rot) _ans_fields+=4; - + // --------------------------- Device allocations success=success && (engv.alloc(_ev_fields*_max_local,*dev,UCL_READ_ONLY, UCL_READ_WRITE)==UCL_SUCCESS); success=success && (force.alloc(_ans_fields*_max_local,*dev,UCL_READ_ONLY, UCL_READ_WRITE)==UCL_SUCCESS); _gpu_bytes=engv.device.row_bytes()+force.device.row_bytes(); - - _allocated=true; + + _allocated=true; return success; } @@ -69,21 +69,21 @@ bool AnswerT::init(const int inum, const bool charge, const bool rot, if (_charge) _e_fields++; _ev_fields=6+_e_fields; - + // Initialize atom and nbor data int ef_inum=inum; if (ef_inum==0) ef_inum=1000; - + // Initialize timers for the selected device time_answer.init(*dev); time_answer.zero(); _time_cast=0.0; _time_cpu_idle=0.0; - + return success && alloc(ef_inum); } - + template bool AnswerT::add_fields(const bool charge, const bool rot) { bool realloc=false; @@ -127,15 +127,15 @@ void AnswerT::clear() { template double AnswerT::host_memory_usage() const { int atom_bytes=4; - if (_charge) + if (_charge) atom_bytes+=1; - if (_rot) + if (_rot) atom_bytes+=4; int ans_bytes=atom_bytes+_ev_fields; return ans_bytes*(_max_local)*sizeof(acctyp)+ sizeof(Answer); } - + template void AnswerT::copy_answers(const bool eflag, const bool vflag, const bool ef_atom, const bool vf_atom) { @@ -144,8 +144,8 @@ void AnswerT::copy_answers(const bool eflag, const bool vflag, _vflag=vflag; _ef_atom=ef_atom; _vf_atom=vf_atom; - - int csize=_ev_fields; + + int csize=_ev_fields; if (!eflag) csize-=_e_fields; if (!vflag) @@ -180,7 +180,7 @@ double AnswerT::energy_virial(double *eatom, double **vatom, for (int i=0; i<_inum; i++) evdwl+=engv[i]; if (_ef_atom) - if (_ilist==NULL) + if (_ilist==NULL) for (int i=0; i<_inum; i++) eatom[i]+=engv[i]; else @@ -196,18 +196,18 @@ double AnswerT::energy_virial(double *eatom, double **vatom, if (_vf_atom) if (_ilist==NULL) { int ii=0; - for (int i=vstart; i -int AtomT::bytes_per_atom() const { +int AtomT::bytes_per_atom() const { int id_space=0; if (_gpu_nbor==1) id_space=2; @@ -51,7 +51,7 @@ bool AtomT::alloc(const int nall) { _max_atoms=static_cast(static_cast(nall)*1.10); bool success=true; - + // Ignore host/device transfers? _host_view=false; if (dev->shared_memory() && sizeof(numtyp)==sizeof(double)) { @@ -60,11 +60,11 @@ bool AtomT::alloc(const int nall) { assert(0==1); #endif } - + // Allocate storage for CUDPP sort #ifdef USE_CUDPP if (_gpu_nbor==1) { - CUDPPResult result = cudppPlan(&sort_plan, sort_config, _max_atoms, 1, 0); + CUDPPResult result = cudppPlan(&sort_plan, sort_config, _max_atoms, 1, 0); if (CUDPP_SUCCESS != result) return false; } @@ -110,7 +110,7 @@ bool AtomT::alloc(const int nall) { } else { success=success && (host_particle_id.alloc(_max_atoms,*dev, UCL_WRITE_ONLY)==UCL_SUCCESS); - success=success && + success=success && (host_cell_id.alloc(_max_atoms,*dev,UCL_NOT_PINNED)==UCL_SUCCESS); } if (_gpu_nbor==2 && _host_view) @@ -124,8 +124,8 @@ bool AtomT::alloc(const int nall) { gpu_bytes+=x.device.row_bytes(); if (gpu_bytes>_max_gpu_bytes) _max_gpu_bytes=gpu_bytes; - - _allocated=true; + + _allocated=true; return success; } @@ -135,7 +135,7 @@ bool AtomT::add_fields(const bool charge, const bool rot, bool success=true; // Ignore host/device transfers? int gpu_bytes=0; - + if (charge && _charge==false) { _charge=true; _other=true; @@ -179,7 +179,7 @@ bool AtomT::add_fields(const bool charge, const bool rot, _gpu_nbor=gpu_nbor; #ifdef USE_CUDPP if (_gpu_nbor==1) { - CUDPPResult result = cudppPlan(&sort_plan, sort_config, _max_atoms, 1, 0); + CUDPPResult result = cudppPlan(&sort_plan, sort_config, _max_atoms, 1, 0); if (CUDPP_SUCCESS != result) return false; } @@ -198,9 +198,9 @@ bool AtomT::add_fields(const bool charge, const bool rot, } else { success=success && (host_particle_id.alloc(_max_atoms,*dev, UCL_WRITE_ONLY)==UCL_SUCCESS); - success=success && + success=success && (host_cell_id.alloc(_max_atoms,*dev,UCL_NOT_PINNED)==UCL_SUCCESS); - } + } } return success; @@ -230,7 +230,7 @@ bool AtomT::init(const int nall, const bool charge, const bool rot, int ef_nall=nall; if (ef_nall==0) ef_nall=2000; - + // Initialize timers for the selected device time_pos.init(*dev); time_q.init(*dev); @@ -241,14 +241,14 @@ bool AtomT::init(const int nall, const bool charge, const bool rot, time_quat.zero(); time_vel.zero(); _time_cast=0.0; - + #ifdef GPU_CAST compile_kernels(*dev); #endif - + return success && alloc(ef_nall); } - + template void AtomT::clear_resize() { if (!_allocated) @@ -274,7 +274,7 @@ void AtomT::clear_resize() { #ifdef USE_CUDPP if (_gpu_nbor==1) cudppDestroyPlan(sort_plan); #endif - + if (_gpu_nbor==2) { host_particle_id.clear(); host_cell_id.clear(); @@ -305,21 +305,21 @@ void AtomT::clear() { template double AtomT::host_memory_usage() const { int atom_bytes=4; - if (_charge) + if (_charge) atom_bytes+=1; - if (_rot) + if (_rot) atom_bytes+=4; - if (_vel) + if (_vel) atom_bytes+=4; return _max_atoms*atom_bytes*sizeof(numtyp)+sizeof(Atom); } - + // Sort arrays for neighbor list calculation template void AtomT::sort_neighbor(const int num_atoms) { #ifdef USE_CUDPP - CUDPPResult result = cudppSort(sort_plan, (unsigned *)dev_cell_id.begin(), - (int *)dev_particle_id.begin(), + CUDPPResult result = cudppSort(sort_plan, (unsigned *)dev_cell_id.begin(), + (int *)dev_particle_id.begin(), 8*sizeof(unsigned), num_atoms); if (CUDPP_SUCCESS != result) { printf("Error in cudppSort\n"); diff --git a/lib/gpu/lal_atom.cu b/lib/gpu/lal_atom.cu index 2a78719ffb..28ff31c566 100644 --- a/lib/gpu/lal_atom.cu +++ b/lib/gpu/lal_atom.cu @@ -9,7 +9,7 @@ // This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) // __________________________________________________________________________ // -// begin : +// begin : // email : brownw@ornl.gov // ***************************************************************************/ @@ -17,9 +17,9 @@ #include "lal_preprocessor.h" #endif -__kernel void kernel_cast_x(__global numtyp4 *restrict x_type, +__kernel void kernel_cast_x(__global numtyp4 *restrict x_type, const __global double *restrict x, - const __global int *restrict type, + const __global int *restrict type, const int nall) { int ii=GLOBAL_ID_X; diff --git a/lib/gpu/lal_atom.h b/lib/gpu/lal_atom.h index 23112fe712..1b4e17d972 100644 --- a/lib/gpu/lal_atom.h +++ b/lib/gpu/lal_atom.h @@ -9,7 +9,7 @@ This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) __________________________________________________________________________ - begin : + begin : email : brownw@ornl.gov ***************************************************************************/ @@ -57,19 +57,19 @@ class Atom { /// Set number of local+ghost atoms for future copy operations inline void nall(const int n) { _nall=n; } - + /// Memory usage per atom in this class - int bytes_per_atom() const; + int bytes_per_atom() const; /// Clear any previous data and set up for a new LAMMPS run /** \param rot True if atom storage needs quaternions * \param gpu_nbor 0 if neighboring will be performed on host * gpu_nbor 1 if neighboring will be performed on device * gpu_nbor 2 if binning on host and neighboring on device **/ - bool init(const int nall, const bool charge, const bool rot, - UCL_Device &dev, const int gpu_nbor=0, const bool bonds=false, + bool init(const int nall, const bool charge, const bool rot, + UCL_Device &dev, const int gpu_nbor=0, const bool bonds=false, const bool vel=false); - + /// Check if we have enough device storage and realloc if not /** Returns true if resized with any call during this timestep **/ inline bool resize(const int nall, bool &success) { @@ -81,7 +81,7 @@ class Atom { } return _resized; } - + /// If already initialized by another LAMMPS style, add fields as necessary /** \param rot True if atom storage needs quaternions * \param gpu_nbor 0 if neighboring will be performed on host @@ -89,28 +89,28 @@ class Atom { * gpu_nbor 2 if binning on host and neighboring on device **/ bool add_fields(const bool charge, const bool rot, const int gpu_nbor, const bool bonds, const bool vel=false); - + /// Returns true if GPU is using charges bool charge() { return _charge; } - + /// Returns true if GPU is using quaternions bool quaternion() { return _rot; } - + /// Returns true if GPU is using velocities bool velocity() { return _vel; } /// Only free matrices of length inum or nall for resizing void clear_resize(); - + /// Free all memory on host and device void clear(); - + /// Return the total amount of host memory used by class in bytes double host_memory_usage() const; /// Sort arrays for neighbor list calculation on device void sort_neighbor(const int num_atoms); - + /// Add copy times to timers inline void acc_timers() { time_pos.add_to_total(); @@ -150,18 +150,18 @@ class Atom { total+=time_vel.total_seconds(); time_vel.zero_total(); } - + return total+_time_transfer/1000.0; } - + /// Return the total time for data cast/pack /** Zeros the time so that atom times are only included once **/ - inline double cast_time() + inline double cast_time() { double t=_time_cast; _time_cast=0.0; return t; } /// Pack LAMMPS atom type constants into matrix and copy to device template - inline void type_pack1(const int n, const int m_size, + inline void type_pack1(const int n, const int m_size, UCL_D_Vec &dev_v, UCL_H_Vec &buffer, t1 **one) { int ii=0; @@ -215,7 +215,7 @@ class Atom { view.view((dev_typ*)buffer.begin(),m_size*m_size,*dev); ucl_copy(dev_v,view,false); } - + /// Pack LAMMPS atom type constants (4) into 4 vectors and copy to device template inline void type_pack4(const int n, const int m_size, @@ -239,7 +239,7 @@ class Atom { /// Pack LAMMPS atom "self" type constants into 2 vectors and copy to device template - inline void self_pack2(const int n, UCL_D_Vec &dev_v, + inline void self_pack2(const int n, UCL_D_Vec &dev_v, UCL_H_Vec &buffer, t1 **one, t2 **two) { for (int i=0; i(one[i][i]); @@ -279,7 +279,7 @@ class Atom { /// Copy positions and types to device asynchronously /** Copies nall() elements **/ - inline void add_x_data(double **host_ptr, int *host_type) { + inline void add_x_data(double **host_ptr, int *host_type) { time_pos.start(); if (_x_avail==false) { #ifdef GPU_CAST @@ -376,7 +376,7 @@ class Atom { /// Copy velocities and tags to device asynchronously /** Copies nall() elements **/ - inline void add_v_data(double **host_ptr, tagint *host_tag) { + inline void add_v_data(double **host_ptr, tagint *host_tag) { time_vel.start(); if (_v_avail==false) { #ifdef GPU_CAST @@ -407,8 +407,8 @@ class Atom { inline void add_transfer_time(double t) { _time_transfer+=t; } /// Return number of bytes used on device - inline double max_gpu_bytes() - { double m=_max_gpu_bytes; _max_gpu_bytes=0.0; return m; } + inline double max_gpu_bytes() + { double m=_max_gpu_bytes; _max_gpu_bytes=0.0; return m; } /// Returns true if the device is addressing memory on the host inline bool host_view() { return _host_view; } @@ -422,7 +422,7 @@ class Atom { /// Quaterions UCL_Vector quat; /// Velocities - UCL_Vector v; + UCL_Vector v; #ifdef GPU_CAST UCL_Vector x_cast; @@ -436,7 +436,7 @@ class Atom { /// Atom tag information for device nbor builds UCL_D_Vec dev_tag; - + /// Cell list identifiers for hybrid nbor builds UCL_H_Vec host_cell_id; /// Cell list identifiers for hybrid nbor builds @@ -444,7 +444,7 @@ class Atom { /// Device timers UCL_Timer time_pos, time_q, time_quat, time_vel; - + /// Geryon device UCL_Device *dev; @@ -456,19 +456,19 @@ class Atom { #endif bool _compiled; - + // True if data has been copied to device already bool _x_avail, _q_avail, _quat_avail, _v_avail, _resized; bool alloc(const int nall); - + bool _allocated, _rot, _charge, _bonds, _vel, _other; int _max_atoms, _nall, _gpu_nbor; bool _host_view; double _time_cast, _time_transfer; - + double _max_gpu_bytes; - + #ifdef USE_CUDPP CUDPPConfiguration sort_config; CUDPPHandle sort_plan; diff --git a/lib/gpu/lal_balance.h b/lib/gpu/lal_balance.h index cf09cf86fb..e90e94bee1 100644 --- a/lib/gpu/lal_balance.h +++ b/lib/gpu/lal_balance.h @@ -9,7 +9,7 @@ This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) __________________________________________________________________________ - begin : + begin : email : brownw@ornl.gov ***************************************************************************/ @@ -44,7 +44,7 @@ class Balance { _init_done=false; } } - + /// Return the timestep since initialization inline int timestep() { return _timestep; } @@ -96,7 +96,7 @@ class Balance { inline void stop_timer() { if (_measure_this_step) { _device_time.stop(); } } /// Calculate the new host/device split based on the cpu and device times - /** \note Only does calculation every _HD_BALANCE_EVERY timesteps + /** \note Only does calculation every _HD_BALANCE_EVERY timesteps (and first 10) **/ inline void balance(const double cpu_time); @@ -105,13 +105,13 @@ class Balance { balance(cpu_time); return get_gpu_count(ago,inum_full); } - + private: Device *_device; UCL_Timer _device_time; bool _init_done; int _gpu_nbor; - + bool _load_balance; double _actual_split, _avg_split, _desired_split, _max_split; int _avg_count; @@ -123,15 +123,15 @@ class Balance { #define BalanceT Balance template -void BalanceT::init(Device *gpu, +void BalanceT::init(Device *gpu, const int gpu_nbor, const double split) { clear(); _gpu_nbor=gpu_nbor; _init_done=true; - + _device=gpu; _device_time.init(*gpu->gpu); - + if (split<0.0) { _load_balance=true; _desired_split=0.90; @@ -163,7 +163,7 @@ int BalanceT::get_gpu_count(const int ago, const int inum_full) { _timestep++; return _inum; } - + template void BalanceT::balance(const double cpu_time) { if (_measure_this_step) { diff --git a/lib/gpu/lal_base_atomic.cpp b/lib/gpu/lal_base_atomic.cpp index 191f218bd8..e59dae1a6f 100644 --- a/lib/gpu/lal_base_atomic.cpp +++ b/lib/gpu/lal_base_atomic.cpp @@ -9,10 +9,10 @@ This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) __________________________________________________________________________ - begin : + begin : email : brownw@ornl.gov ***************************************************************************/ - + #include "lal_base_atomic.h" using namespace LAMMPS_AL; #define BaseAtomicT BaseAtomic @@ -63,13 +63,13 @@ int BaseAtomicT::init_atomic(const int nlocal, const int nall, _nbor_data=&(nbor->dev_packed); } else _nbor_data=&(nbor->dev_nbor); - + int success=device->init(*ans,false,false,nlocal,host_nlocal,nall,nbor, maxspecial,_gpu_host,max_nbors,cell_size,false, _threads_per_atom); if (success!=0) return success; - + ucl_device=device->gpu; atom=&device->atom; @@ -139,7 +139,7 @@ int * BaseAtomicT::reset_nbors(const int nall, const int inum, int *ilist, double bytes=ans->gpu_bytes()+nbor->gpu_bytes(); if (bytes>_max_an_bytes) _max_an_bytes=bytes; - + return ilist; } @@ -188,7 +188,7 @@ void BaseAtomicT::compute(const int f_ago, const int inum_full, zero_timers(); return; } - + int ago=hd_balancer.ago_first(f_ago); int inum=hd_balancer.balance(ago,inum_full,cpu_time); ans->inum(inum); @@ -217,7 +217,7 @@ template int ** BaseAtomicT::compute(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, double *sublo, double *subhi, tagint *tag, - int **nspecial, tagint **special, const bool eflag, + int **nspecial, tagint **special, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, int **ilist, int **jnum, @@ -230,12 +230,12 @@ int ** BaseAtomicT::compute(const int ago, const int inum_full, zero_timers(); return NULL; } - + hd_balancer.balance(cpu_time); int inum=hd_balancer.get_gpu_count(ago,inum_full); ans->inum(inum); host_start=inum; - + // Build neighbor list on GPU if necessary if (ago==0) { build_nbor_list(inum, inum_full-inum, nall, host_x, host_type, @@ -255,7 +255,7 @@ int ** BaseAtomicT::compute(const int ago, const int inum_full, ans->copy_answers(eflag,vflag,eatom,vatom); device->add_ans_object(ans); hd_balancer.stop_timer(); - + return nbor->host_jlist.begin()-host_start; } diff --git a/lib/gpu/lal_base_atomic.h b/lib/gpu/lal_base_atomic.h index eaf55f46e2..e3e9829abc 100644 --- a/lib/gpu/lal_base_atomic.h +++ b/lib/gpu/lal_base_atomic.h @@ -9,7 +9,7 @@ This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) __________________________________________________________________________ - begin : + begin : email : brownw@ornl.gov ***************************************************************************/ @@ -41,7 +41,7 @@ class BaseAtomic { * \param cell_size cutoff + skin * \param gpu_split fraction of particles handled by device * \param k_name name for the kernel for force calculation - * + * * Returns: * - 0 if successfull * - -1 if fix gpu not found @@ -49,8 +49,8 @@ class BaseAtomic { * - -4 if the GPU library was not compiled for GPU * - -5 Double precision is not supported on card **/ int init_atomic(const int nlocal, const int nall, const int max_nbors, - const int maxspecial, const double cell_size, - const double gpu_split, FILE *screen, + const int maxspecial, const double cell_size, + const double gpu_split, FILE *screen, const void *pair_program, const char *k_name); /// Estimate the overhead for GPU context changes and CPU driver @@ -80,7 +80,7 @@ class BaseAtomic { * \note host_inum is 0 if the host is performing neighboring * \note nlocal+host_inum=total number local particles * \note olist_size=0 **/ - inline void resize_local(const int inum, const int host_inum, + inline void resize_local(const int inum, const int host_inum, const int max_nbors, bool &success) { nbor->resize(inum,host_inum,max_nbors,success); } @@ -119,7 +119,7 @@ class BaseAtomic { /// Build neighbor list on device void build_nbor_list(const int inum, const int host_inum, const int nall, double **host_x, int *host_type, - double *sublo, double *subhi, tagint *tag, int **nspecial, + double *sublo, double *subhi, tagint *tag, int **nspecial, tagint **special, bool &success); /// Pair loop with host neighboring @@ -133,19 +133,19 @@ class BaseAtomic { int * compute(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, double *sublo, double *subhi, tagint *tag, int **nspecial, - tagint **special, const bool eflag, const bool vflag, - const bool eatom, const bool vatom, int &host_start, + tagint **special, const bool eflag, const bool vflag, + const bool eatom, const bool vatom, int &host_start, const double cpu_time, bool &success); /// Pair loop with device neighboring int ** compute(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, double *sublo, double *subhi, tagint *tag, int **nspecial, - tagint **special, const bool eflag, const bool vflag, - const bool eatom, const bool vatom, int &host_start, + tagint **special, const bool eflag, const bool vflag, + const bool eatom, const bool vatom, int &host_start, int **ilist, int **numj, const double cpu_time, bool &success); - // -------------------------- DEVICE DATA ------------------------- + // -------------------------- DEVICE DATA ------------------------- /// Device Properties and Atom and Neighbor storage Device *device; diff --git a/lib/gpu/lal_base_charge.cpp b/lib/gpu/lal_base_charge.cpp index e7fe2b62f4..c6341f7d57 100644 --- a/lib/gpu/lal_base_charge.cpp +++ b/lib/gpu/lal_base_charge.cpp @@ -10,7 +10,7 @@ This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) __________________________________________________________________________ - begin : + begin : email : brownw@ornl.gov ***************************************************************************/ @@ -64,7 +64,7 @@ int BaseChargeT::init_atomic(const int nlocal, const int nall, _nbor_data=&(nbor->dev_packed); } else _nbor_data=&(nbor->dev_nbor); - + int success=device->init(*ans,true,false,nlocal,host_nlocal,nall,nbor, maxspecial,_gpu_host,max_nbors,cell_size,false, _threads_per_atom); @@ -153,7 +153,7 @@ template inline void BaseChargeT::build_nbor_list(const int inum, const int host_inum, const int nall, double **host_x, int *host_type, double *sublo, - double *subhi, tagint *tag, + double *subhi, tagint *tag, int **nspecial, tagint **special, bool &success) { success=true; @@ -192,7 +192,7 @@ void BaseChargeT::compute(const int f_ago, const int inum_full, zero_timers(); return; } - + int ago=hd_balancer.ago_first(f_ago); int inum=hd_balancer.balance(ago,inum_full,cpu_time); ans->inum(inum); @@ -226,7 +226,7 @@ template int** BaseChargeT::compute(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, double *sublo, double *subhi, tagint *tag, - int **nspecial, tagint **special, const bool eflag, + int **nspecial, tagint **special, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, int **ilist, int **jnum, @@ -240,12 +240,12 @@ int** BaseChargeT::compute(const int ago, const int inum_full, zero_timers(); return NULL; } - + hd_balancer.balance(cpu_time); int inum=hd_balancer.get_gpu_count(ago,inum_full); ans->inum(inum); host_start=inum; - + // Build neighbor list on GPU if necessary if (ago==0) { build_nbor_list(inum, inum_full-inum, nall, host_x, host_type, @@ -271,7 +271,7 @@ int** BaseChargeT::compute(const int ago, const int inum_full, ans->copy_answers(eflag,vflag,eatom,vatom); device->add_ans_object(ans); hd_balancer.stop_timer(); - + return nbor->host_jlist.begin()-host_start; } diff --git a/lib/gpu/lal_base_charge.h b/lib/gpu/lal_base_charge.h index e791507432..64c19554b9 100644 --- a/lib/gpu/lal_base_charge.h +++ b/lib/gpu/lal_base_charge.h @@ -10,7 +10,7 @@ This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) __________________________________________________________________________ - begin : + begin : email : brownw@ornl.gov ***************************************************************************/ @@ -42,7 +42,7 @@ class BaseCharge { * \param cell_size cutoff + skin * \param gpu_split fraction of particles handled by device * \param k_name name for the kernel for force calculation - * + * * Returns: * - 0 if successfull * - -1 if fix gpu not found @@ -83,7 +83,7 @@ class BaseCharge { * \note host_inum is 0 if the host is performing neighboring * \note nlocal+host_inum=total number local particles * \note olist_size=0 **/ - inline void resize_local(const int inum, const int host_inum, + inline void resize_local(const int inum, const int host_inum, const int max_nbors, bool &success) { nbor->resize(inum,host_inum,max_nbors,success); } @@ -137,12 +137,12 @@ class BaseCharge { int** compute(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, double *sublo, double *subhi, tagint *tag, int **nspecial, - tagint **special, const bool eflag, const bool vflag, - const bool eatom, const bool vatom, int &host_start, + tagint **special, const bool eflag, const bool vflag, + const bool eatom, const bool vatom, int &host_start, int **ilist, int **numj, const double cpu_time, bool &success, double *charge, double *boxlo, double *prd); - // -------------------------- DEVICE DATA ------------------------- + // -------------------------- DEVICE DATA ------------------------- /// Device Properties and Atom and Neighbor storage Device *device; diff --git a/lib/gpu/lal_base_dipole.cpp b/lib/gpu/lal_base_dipole.cpp index 12e3b20d96..478f0092c7 100644 --- a/lib/gpu/lal_base_dipole.cpp +++ b/lib/gpu/lal_base_dipole.cpp @@ -10,7 +10,7 @@ This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) __________________________________________________________________________ - begin : + begin : email : nguyentd@ornl.gov ***************************************************************************/ @@ -65,7 +65,7 @@ int BaseDipoleT::init_atomic(const int nlocal, const int nall, _nbor_data=&(nbor->dev_packed); } else _nbor_data=&(nbor->dev_nbor); - + int success=device->init(*ans,true,true,nlocal,host_nlocal,nall,nbor, maxspecial,_gpu_host,max_nbors,cell_size,false, _threads_per_atom); @@ -155,7 +155,7 @@ template inline void BaseDipoleT::build_nbor_list(const int inum, const int host_inum, const int nall, double **host_x, int *host_type, double *sublo, - double *subhi, tagint *tag, + double *subhi, tagint *tag, int **nspecial, tagint **special, bool &success) { success=true; @@ -194,7 +194,7 @@ void BaseDipoleT::compute(const int f_ago, const int inum_full, zero_timers(); return; } - + int ago=hd_balancer.ago_first(f_ago); int inum=hd_balancer.balance(ago,inum_full,cpu_time); ans->inum(inum); @@ -230,12 +230,12 @@ template int** BaseDipoleT::compute(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, double *sublo, double *subhi, tagint *tag, - int **nspecial, tagint **special, const bool eflag, + int **nspecial, tagint **special, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, int **ilist, int **jnum, const double cpu_time, bool &success, - double *host_q, double **host_mu, + double *host_q, double **host_mu, double *boxlo, double *prd) { acc_timers(); if (inum_full==0) { @@ -245,12 +245,12 @@ int** BaseDipoleT::compute(const int ago, const int inum_full, zero_timers(); return NULL; } - + hd_balancer.balance(cpu_time); int inum=hd_balancer.get_gpu_count(ago,inum_full); ans->inum(inum); host_start=inum; - + // Build neighbor list on GPU if necessary if (ago==0) { build_nbor_list(inum, inum_full-inum, nall, host_x, host_type, @@ -279,7 +279,7 @@ int** BaseDipoleT::compute(const int ago, const int inum_full, ans->copy_answers(eflag,vflag,eatom,vatom); device->add_ans_object(ans); hd_balancer.stop_timer(); - + return nbor->host_jlist.begin()-host_start; } diff --git a/lib/gpu/lal_base_dipole.h b/lib/gpu/lal_base_dipole.h index 2e495c8747..b51c4303cf 100644 --- a/lib/gpu/lal_base_dipole.h +++ b/lib/gpu/lal_base_dipole.h @@ -10,7 +10,7 @@ This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) __________________________________________________________________________ - begin : + begin : email : nguyentd@ornl.gov ***************************************************************************/ @@ -40,7 +40,7 @@ class BaseDipole { * \param cell_size cutoff + skin * \param gpu_split fraction of particles handled by device * \param k_name name for the kernel for force calculation - * + * * Returns: * - 0 if successfull * - -1 if fix gpu not found @@ -82,7 +82,7 @@ class BaseDipole { * \note host_inum is 0 if the host is performing neighboring * \note nlocal+host_inum=total number local particles * \note olist_size=0 **/ - inline void resize_local(const int inum, const int host_inum, + inline void resize_local(const int inum, const int host_inum, const int max_nbors, bool &success) { nbor->resize(inum,host_inum,max_nbors,success); } @@ -136,12 +136,12 @@ class BaseDipole { int** compute(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, double *sublo, double *subhi, tagint *tag, int **nspecial, - tagint **special, const bool eflag, const bool vflag, - const bool eatom, const bool vatom, int &host_start, + tagint **special, const bool eflag, const bool vflag, + const bool eatom, const bool vatom, int &host_start, int **ilist, int **numj, const double cpu_time, bool &success, double *charge, double **mu, double *boxlo, double *prd); - // -------------------------- DEVICE DATA ------------------------- + // -------------------------- DEVICE DATA ------------------------- /// Device Properties and Atom and Neighbor storage Device *device; diff --git a/lib/gpu/lal_base_dpd.cpp b/lib/gpu/lal_base_dpd.cpp index 0efb68a9fb..941f463b14 100644 --- a/lib/gpu/lal_base_dpd.cpp +++ b/lib/gpu/lal_base_dpd.cpp @@ -64,7 +64,7 @@ int BaseDPDT::init_atomic(const int nlocal, const int nall, _nbor_data=&(nbor->dev_packed); } else _nbor_data=&(nbor->dev_nbor); - + int success=device->init(*ans,false,false,nlocal,host_nlocal,nall,nbor, maxspecial,_gpu_host,max_nbors,cell_size,false, _threads_per_atom,true); @@ -153,7 +153,7 @@ template inline void BaseDPDT::build_nbor_list(const int inum, const int host_inum, const int nall, double **host_x, int *host_type, double *sublo, - double *subhi, tagint *tag, + double *subhi, tagint *tag, int **nspecial, tagint **special, bool &success) { success=true; @@ -182,7 +182,7 @@ void BaseDPDT::compute(const int f_ago, const int inum_full, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, const double cpu_time, - bool &success, tagint *tag, double **host_v, + bool &success, tagint *tag, double **host_v, const double dtinvsqrt, const int seed, const int timestep, const int nlocal, double *boxlo, double *prd) { acc_timers(); @@ -193,7 +193,7 @@ void BaseDPDT::compute(const int f_ago, const int inum_full, zero_timers(); return; } - + int ago=hd_balancer.ago_first(f_ago); int inum=hd_balancer.balance(ago,inum_full,cpu_time); ans->inum(inum); @@ -228,12 +228,12 @@ template int** BaseDPDT::compute(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, double *sublo, double *subhi, tagint *tag, - int **nspecial, tagint **special, const bool eflag, + int **nspecial, tagint **special, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, int **ilist, int **jnum, const double cpu_time, bool &success, - double **host_v, const double dtinvsqrt, + double **host_v, const double dtinvsqrt, const int seed, const int timestep, double *boxlo, double *prd) { acc_timers(); @@ -244,12 +244,12 @@ int** BaseDPDT::compute(const int ago, const int inum_full, zero_timers(); return NULL; } - + hd_balancer.balance(cpu_time); int inum=hd_balancer.get_gpu_count(ago,inum_full); ans->inum(inum); host_start=inum; - + // Build neighbor list on GPU if necessary if (ago==0) { build_nbor_list(inum, inum_full-inum, nall, host_x, host_type, @@ -276,7 +276,7 @@ int** BaseDPDT::compute(const int ago, const int inum_full, ans->copy_answers(eflag,vflag,eatom,vatom); device->add_ans_object(ans); hd_balancer.stop_timer(); - + return nbor->host_jlist.begin()-host_start; } diff --git a/lib/gpu/lal_base_dpd.h b/lib/gpu/lal_base_dpd.h index 97640ed40e..7a75282d0a 100644 --- a/lib/gpu/lal_base_dpd.h +++ b/lib/gpu/lal_base_dpd.h @@ -40,7 +40,7 @@ class BaseDPD { * \param cell_size cutoff + skin * \param gpu_split fraction of particles handled by device * \param k_name name for the kernel for force calculation - * + * * Returns: * - 0 if successfull * - -1 if fix gpu not found @@ -81,7 +81,7 @@ class BaseDPD { * \note host_inum is 0 if the host is performing neighboring * \note nlocal+host_inum=total number local particles * \note olist_size=0 **/ - inline void resize_local(const int inum, const int host_inum, + inline void resize_local(const int inum, const int host_inum, const int max_nbors, bool &success) { nbor->resize(inum,host_inum,max_nbors,success); } @@ -129,20 +129,20 @@ class BaseDPD { int **firstneigh, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, const double cpu_time, bool &success, tagint *tag, - double **v, const double dtinvsqrt, const int seed, + double **v, const double dtinvsqrt, const int seed, const int timestep, const int nlocal, double *boxlo, double *prd); /// Pair loop with device neighboring int** compute(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, double *sublo, double *subhi, tagint *tag, int **nspecial, - tagint **special, const bool eflag, const bool vflag, - const bool eatom, const bool vatom, int &host_start, + tagint **special, const bool eflag, const bool vflag, + const bool eatom, const bool vatom, int &host_start, int **ilist, int **numj, const double cpu_time, bool &success, double **v, const double dtinvsqrt, const int seed, const int timestep, double *boxlo, double *prd); - // -------------------------- DEVICE DATA ------------------------- + // -------------------------- DEVICE DATA ------------------------- /// Device Properties and Atom and Neighbor storage Device *device; diff --git a/lib/gpu/lal_base_ellipsoid.cpp b/lib/gpu/lal_base_ellipsoid.cpp index 4200c02e1c..8918a3140c 100644 --- a/lib/gpu/lal_base_ellipsoid.cpp +++ b/lib/gpu/lal_base_ellipsoid.cpp @@ -70,7 +70,7 @@ int BaseEllipsoidT::init_base(const int nlocal, const int nall, _gpu_host=1; _threads_per_atom=device->threads_per_atom(); - + int success=device->init(*ans,false,true,nlocal,host_nlocal,nall,nbor, maxspecial,_gpu_host,max_nbors,cell_size,true, 1); @@ -113,7 +113,7 @@ int BaseEllipsoidT::init_base(const int nlocal, const int nall, return -8; if (_multiple_forms && gpu_nbor!=0) return -9; - + if (_multiple_forms) ans->force.zero(); @@ -142,7 +142,7 @@ void BaseEllipsoidT::clear_base() { // Output any timing information output_times(); host_olist.clear(); - + if (_compiled) { k_nbor_fast.clear(); k_nbor.clear(); @@ -156,7 +156,7 @@ void BaseEllipsoidT::clear_base() { delete lj_program; _compiled=false; } - + time_nbor1.clear(); time_ellipsoid.clear(); time_nbor2.clear(); @@ -230,7 +230,7 @@ void BaseEllipsoidT::output_times() { if (times[6]>0) fprintf(screen,"Device Overhead: %.4f s.\n",times[6]/replica_size); fprintf(screen,"Average split: %.4f.\n",avg_split); - fprintf(screen,"Threads / atom: %d.\n",_threads_per_atom); + fprintf(screen,"Threads / atom: %d.\n",_threads_per_atom); fprintf(screen,"Max Mem / Proc: %.2f MB.\n",max_mb); fprintf(screen,"CPU Driver_Time: %.4f s.\n",times[7]/replica_size); fprintf(screen,"CPU Idle_Time: %.4f s.\n",times[8]/replica_size); @@ -241,10 +241,10 @@ void BaseEllipsoidT::output_times() { } // --------------------------------------------------------------------------- -// Pack neighbors to limit thread divergence for lj-lj and ellipse +// Pack neighbors to limit thread divergence for lj-lj and ellipse // --------------------------------------------------------------------------- template -void BaseEllipsoidT::pack_nbors(const int GX, const int BX, const int start, +void BaseEllipsoidT::pack_nbors(const int GX, const int BX, const int start, const int inum, const int form_low, const int form_high, const bool shared_types, int ntypes) { @@ -264,18 +264,18 @@ void BaseEllipsoidT::pack_nbors(const int GX, const int BX, const int start, // Copy neighbor list from host // --------------------------------------------------------------------------- template -void BaseEllipsoidT::reset_nbors(const int nall, const int inum, +void BaseEllipsoidT::reset_nbors(const int nall, const int inum, const int osize, int *ilist, int *numj, int *type, int **firstneigh, bool &success) { success=true; - + int mn=nbor->max_nbor_loop(osize,numj,ilist); resize_atom(nall,success); resize_local(inum,0,mn,osize,success); if (!success) return; - + if (_multiple_forms) { int p=0; for (int i=0; i inline void BaseEllipsoidT::build_nbor_list(const int inum, const int host_inum, const int nall, double **host_x, int *host_type, double *sublo, - double *subhi, tagint *tag, + double *subhi, tagint *tag, int **nspecial, tagint **special, bool &success) { success=true; @@ -354,7 +354,7 @@ int* BaseEllipsoidT::compute(const int f_ago, const int inum_full, zero_timers(); return NULL; } - + int ago=hd_balancer.ago_first(f_ago); int inum=hd_balancer.balance(ago,inum_full,cpu_time); ans->inum(inum); @@ -394,7 +394,7 @@ int** BaseEllipsoidT::compute(const int ago, const int inum_full, const int nall double **host_x, int *host_type, double *sublo, double *subhi, tagint *tag, int **nspecial, tagint **special, const bool eflag, const bool vflag, - const bool eatom, const bool vatom, + const bool eatom, const bool vatom, int &host_start, int **ilist, int **jnum, const double cpu_time, bool &success, double **host_quat) { @@ -410,7 +410,7 @@ int** BaseEllipsoidT::compute(const int ago, const int inum_full, const int nall ans->inum(inum); _last_ellipse=std::min(inum,_max_last_ellipse); host_start=inum; - + // Build neighbor list on GPU if necessary if (ago==0) { build_nbor_list(inum, inum_full-inum, nall, host_x, host_type, @@ -419,7 +419,7 @@ int** BaseEllipsoidT::compute(const int ago, const int inum_full, const int nall return NULL; atom->cast_quat_data(host_quat[0]); hd_balancer.start_timer(); - } else { + } else { atom->cast_x_data(host_x,host_type); atom->cast_quat_data(host_quat[0]); hd_balancer.start_timer(); @@ -444,9 +444,9 @@ double BaseEllipsoidT::host_memory_usage_base() const { } template -void BaseEllipsoidT::compile_kernels(UCL_Device &dev, +void BaseEllipsoidT::compile_kernels(UCL_Device &dev, const void *ellipsoid_string, - const void *lj_string, + const void *lj_string, const char *kname, const bool e_s) { if (_compiled) return; diff --git a/lib/gpu/lal_base_ellipsoid.h b/lib/gpu/lal_base_ellipsoid.h index e289430f43..7deeccbf44 100644 --- a/lib/gpu/lal_base_ellipsoid.h +++ b/lib/gpu/lal_base_ellipsoid.h @@ -42,7 +42,7 @@ class BaseEllipsoid { * \param gpu_split fraction of particles handled by device * \param ellipsoid_sphere true if ellipsoid-sphere case handled separately * \param k_name name for the kernel for force calculation - * + * * Returns: * - 0 if successfull * - -1 if fix gpu not found @@ -68,7 +68,7 @@ class BaseEllipsoid { quat_tex.bind_float(atom->quat,4); lj_pos_tex.bind_float(atom->x,4); lj_quat_tex.bind_float(atom->quat,4); - } + } } /// Check if there is enough storage for neighbors and realloc if not @@ -78,7 +78,7 @@ class BaseEllipsoid { * \param olist_size size of list of particles from CPU neighboring * \note host_inum is 0 if the host is performing neighboring * \note if GPU is neighboring nlocal+host_inum=total number local particles - * \note if CPU is neighboring olist_size=total number of local particles + * \note if CPU is neighboring olist_size=total number of local particles * \note if GPU is neighboring olist_size=0 **/ inline void resize_local(const int nlocal, const int host_inum, const int max_nbors, const int olist_size, @@ -101,7 +101,7 @@ class BaseEllipsoid { /// Clear all host and device data /** \note This is called at the beginning of the init() routine **/ void clear_base(); - + /// Output any timing information void output_times(); @@ -130,7 +130,7 @@ class BaseEllipsoid { ans->acc_timers(); } } - + /// Zero timers inline void zero_timers() { time_nbor1.zero(); @@ -148,9 +148,9 @@ class BaseEllipsoid { ans->zero_timers(); } - /// Pack neighbors to limit thread divergence for lj-lj and ellipse + /// Pack neighbors to limit thread divergence for lj-lj and ellipse void pack_nbors(const int GX, const int BX, const int start, const int inum, - const int form_low, const int form_high, + const int form_low, const int form_high, const bool shared_types, int ntypes); /// Copy neighbor list from host @@ -174,17 +174,17 @@ class BaseEllipsoid { int** compute(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, double *sublo, double *subhi, tagint *tag, int **nspecial, - tagint **special, const bool eflag, const bool vflag, - const bool eatom, const bool vatom, int &host_start, + tagint **special, const bool eflag, const bool vflag, + const bool eatom, const bool vatom, int &host_start, int **ilist, int **numj, const double cpu_time, bool &success, double **host_quat); /// Build neighbor list on accelerator - void build_nbor_list(const int inum, const int host_inum, const int nall, + void build_nbor_list(const int inum, const int host_inum, const int nall, double **host_x, int *host_type, double *sublo, double *subhi, bool &success); - - // -------------------------- DEVICE DATA ------------------------- + + // -------------------------- DEVICE DATA ------------------------- /// Device Properties and Atom and Neighbor storage Device *device; @@ -207,7 +207,7 @@ class BaseEllipsoid { /// Atom Data Atom *atom; - // --------------------------- TYPE DATA -------------------------- + // --------------------------- TYPE DATA -------------------------- /// cut_form.x = cutsq, cut_form.y = form UCL_D_Vec cut_form; @@ -240,7 +240,7 @@ class BaseEllipsoid { double _gpu_overhead, _driver_overhead; UCL_D_Vec *_nbor_data; - // True if we want to use fast GB-sphere or sphere-sphere calculations + // True if we want to use fast GB-sphere or sphere-sphere calculations bool _multiple_forms; int **_host_form; int _last_ellipse, _max_last_ellipse; diff --git a/lib/gpu/lal_beck.cpp b/lib/gpu/lal_beck.cpp index 062c095957..165a02b71a 100644 --- a/lib/gpu/lal_beck.cpp +++ b/lib/gpu/lal_beck.cpp @@ -9,7 +9,7 @@ This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) __________________________________________________________________________ - begin : + begin : email : nguyentd@ornl.gov ***************************************************************************/ @@ -33,17 +33,17 @@ BeckT::Beck() : BaseAtomic(), _allocated(false) { } template -BeckT::~Beck() { +BeckT::~Beck() { clear(); } - + template int BeckT::bytes_per_atom(const int max_nbors) const { return this->bytes_per_atom_atomic(max_nbors); } template -int BeckT::init(const int ntypes, +int BeckT::init(const int ntypes, double **host_cutsq, double **host_aa, double **host_alpha, double **host_beta, double **host_AA, double **host_BB, @@ -126,7 +126,7 @@ void BeckT::loop(const bool _eflag, const bool _vflag) { vflag=1; else vflag=0; - + int GX=static_cast(ceil(static_cast(this->ans->inum())/ (BX/this->_threads_per_atom))); diff --git a/lib/gpu/lal_beck.cu b/lib/gpu/lal_beck.cu index 7ccefd8859..7d72128b5f 100644 --- a/lib/gpu/lal_beck.cu +++ b/lib/gpu/lal_beck.cu @@ -9,7 +9,7 @@ // This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) // __________________________________________________________________________ // -// begin : +// begin : // email : nguyentd@ornl.gov // ***************************************************************************/ @@ -24,7 +24,7 @@ texture pos_tex; #define pos_tex x_ #endif -__kernel void k_beck(const __global numtyp4 *restrict x_, +__kernel void k_beck(const __global numtyp4 *restrict x_, const __global numtyp4 *restrict beck1, const __global numtyp4 *restrict beck2, const int lj_types, @@ -50,20 +50,20 @@ __kernel void k_beck(const __global numtyp4 *restrict x_, acctyp virial[6]; for (int i=0; i<6; i++) virial[i]=(acctyp)0; - + if (ii0) { virial[0] += delx*delx*force; @@ -133,7 +133,7 @@ __kernel void k_beck_fast(const __global numtyp4 *restrict x_, const int nbor_pitch, const int t_per_atom) { int tid, ii, offset; atom_info(t_per_atom,ii,tid,offset); - + __local numtyp4 beck1[MAX_SHARED_TYPES*MAX_SHARED_TYPES]; __local numtyp4 beck2[MAX_SHARED_TYPES*MAX_SHARED_TYPES]; __local numtyp sp_lj[4]; @@ -143,7 +143,7 @@ __kernel void k_beck_fast(const __global numtyp4 *restrict x_, beck1[tid]=beck1_in[tid]; beck2[tid]=beck2_in[tid]; } - + acctyp energy=(acctyp)0; acctyp4 f; f.x=(acctyp)0; f.y=(acctyp)0; f.z=(acctyp)0; @@ -152,7 +152,7 @@ __kernel void k_beck_fast(const __global numtyp4 *restrict x_, virial[i]=(acctyp)0; __syncthreads(); - + if (ii0) { virial[0] += delx*delx*force; diff --git a/lib/gpu/lal_beck.h b/lib/gpu/lal_beck.h index fa56db2402..db26bebeb0 100644 --- a/lib/gpu/lal_beck.h +++ b/lib/gpu/lal_beck.h @@ -9,7 +9,7 @@ This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) __________________________________________________________________________ - begin : + begin : email : nguyentd@ornl.gov ***************************************************************************/ @@ -24,13 +24,13 @@ template class Beck : public BaseAtomic { public: Beck(); - ~Beck(); + ~Beck(); /// Clear any previous data and set up for a new LAMMPS run /** \param max_nbors initial number of rows in the neighbor matrix * \param cell_size cutoff + skin * \param gpu_split fraction of particles handled by device - * + * * Returns: * - 0 if successfull * - -1 if fix gpu not found @@ -41,8 +41,8 @@ class Beck : public BaseAtomic { double **host_aa, double **host_alpha, double **host_beta, double **host_AA, double **host_BB, double *host_special_lj, - const int nlocal, const int nall, const int max_nbors, - const int maxspecial, const double cell_size, + const int nlocal, const int nall, const int max_nbors, + const int maxspecial, const double cell_size, const double gpu_split, FILE *screen); /// Clear all host and device data @@ -67,7 +67,7 @@ class Beck : public BaseAtomic { /// If atom type constants fit in shared memory, use fast kernels bool shared_types; - /// Number of atom types + /// Number of atom types int _lj_types; private: diff --git a/lib/gpu/lal_beck_ext.cpp b/lib/gpu/lal_beck_ext.cpp index 28ca0df346..1552b640e8 100644 --- a/lib/gpu/lal_beck_ext.cpp +++ b/lib/gpu/lal_beck_ext.cpp @@ -9,7 +9,7 @@ This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) __________________________________________________________________________ - begin : + begin : email : nguyentd@ornl.gov ***************************************************************************/ @@ -77,7 +77,7 @@ int beck_gpu_init(const int ntypes, double **cutsq, double **aa, cell_size, gpu_split, screen); BLMF.device->gpu_barrier(); - if (message) + if (message) fprintf(screen,"Done.\n"); } if (message) @@ -102,7 +102,7 @@ int ** beck_gpu_compute_n(const int ago, const int inum_full, return BLMF.compute(ago, inum_full, nall, host_x, host_type, sublo, subhi, tag, nspecial, special, eflag, vflag, eatom, vatom, host_start, ilist, jnum, cpu_time, success); -} +} void beck_gpu_compute(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, int *ilist, int *numj, diff --git a/lib/gpu/lal_born.cpp b/lib/gpu/lal_born.cpp index 55cb24d3b0..36898b3910 100644 --- a/lib/gpu/lal_born.cpp +++ b/lib/gpu/lal_born.cpp @@ -9,7 +9,7 @@ This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) __________________________________________________________________________ - begin : + begin : email : nguyentd@ornl.gov ***************************************************************************/ @@ -33,10 +33,10 @@ BornT::Born() : BaseAtomic(), _allocated(false) { } template -BornT::~Born() { +BornT::~Born() { clear(); } - + template int BornT::bytes_per_atom(const int max_nbors) const { return this->bytes_per_atom_atomic(max_nbors); @@ -44,12 +44,12 @@ int BornT::bytes_per_atom(const int max_nbors) const { template int BornT::init(const int ntypes, double **host_cutsq, - double **host_rhoinv, double **host_born1, double **host_born2, + double **host_rhoinv, double **host_born1, double **host_born2, double **host_born3, double **host_a, double **host_c, double **host_d, double **host_sigma, double **host_offset, double *host_special_lj, - const int nlocal, const int nall, const int max_nbors, - const int maxspecial, const double cell_size, + const int nlocal, const int nall, const int max_nbors, + const int maxspecial, const double cell_size, const double gpu_split, FILE *_screen) { int success; success=this->init_atomic(nlocal,nall,max_nbors,maxspecial,cell_size,gpu_split, @@ -102,14 +102,14 @@ void BornT::reinit(const int ntypes, double **host_rhoinv, double **host_born1, double **host_born2, double **host_born3, double **host_a, double **host_c, double **host_d, double **host_offset) { - + // Allocate a host write buffer for data initialization UCL_H_Vec host_write(_lj_types*_lj_types*32,*(this->ucl_device), UCL_WRITE_ONLY); - + for (int i=0; i<_lj_types*_lj_types; i++) host_write[i]=0.0; - + this->atom->type_pack4(ntypes,_lj_types,coeff1,host_write,host_rhoinv, host_born1,host_born2,host_born3); this->atom->type_pack4(ntypes,_lj_types,coeff2,host_write,host_a,host_c, @@ -151,7 +151,7 @@ void BornT::loop(const bool _eflag, const bool _vflag) { vflag=1; else vflag=0; - + int GX=static_cast(ceil(static_cast(this->ans->inum())/ (BX/this->_threads_per_atom))); @@ -169,7 +169,7 @@ void BornT::loop(const bool _eflag, const bool _vflag) { } else { this->k_pair.set_size(GX,BX); this->k_pair.run(&this->atom->x, &coeff1, &coeff2, - &cutsq_sigma, &_lj_types, &sp_lj, + &cutsq_sigma, &_lj_types, &sp_lj, &this->nbor->dev_nbor, &this->_nbor_data->begin(), &this->ans->force, &this->ans->engv, &eflag, &vflag, &ainum, diff --git a/lib/gpu/lal_born.cu b/lib/gpu/lal_born.cu index 5f917be846..0ca7fea5fe 100644 --- a/lib/gpu/lal_born.cu +++ b/lib/gpu/lal_born.cu @@ -9,7 +9,7 @@ // This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) // __________________________________________________________________________ // -// begin : +// begin : // email : nguyentd@ornl.gov // ***************************************************************************/ @@ -24,16 +24,16 @@ texture pos_tex; #define pos_tex x_ #endif -__kernel void k_born(const __global numtyp4 *restrict x_, +__kernel void k_born(const __global numtyp4 *restrict x_, const __global numtyp4 *restrict coeff1, - const __global numtyp4 *restrict coeff2, + const __global numtyp4 *restrict coeff2, const __global numtyp2 *restrict cutsq_sigma, - const int lj_types, - const __global numtyp *restrict sp_lj_in, + const int lj_types, + const __global numtyp *restrict sp_lj_in, const __global int *dev_nbor, - const __global int *dev_packed, + const __global int *dev_packed, __global acctyp4 *restrict ans, - __global acctyp *restrict engv, + __global acctyp *restrict engv, const int eflag, const int vflag, const int inum, const int nbor_pitch, const int t_per_atom) { int tid, ii, offset; @@ -51,20 +51,20 @@ __kernel void k_born(const __global numtyp4 *restrict x_, acctyp virial[6]; for (int i=0; i<6; i++) virial[i]=(acctyp)0; - + if (ii0) { numtyp e=coeff2[mtype].x*rexp - coeff2[mtype].y*r6inv + coeff2[mtype].z*r2inv*r6inv; - energy+=factor_lj*(e-coeff2[mtype].w); + energy+=factor_lj*(e-coeff2[mtype].w); } if (vflag>0) { virial[0] += delx*delx*force; @@ -113,20 +113,20 @@ __kernel void k_born(const __global numtyp4 *restrict x_, } // if ii } -__kernel void k_born_fast(const __global numtyp4 *restrict x_, +__kernel void k_born_fast(const __global numtyp4 *restrict x_, const __global numtyp4 *restrict coeff1_in, - const __global numtyp4 *restrict coeff2_in, + const __global numtyp4 *restrict coeff2_in, const __global numtyp2 *restrict cutsq_sigma, - const __global numtyp *restrict sp_lj_in, - const __global int *dev_nbor, - const __global int *dev_packed, - __global acctyp4 *restrict ans, - __global acctyp *restrict engv, - const int eflag, const int vflag, const int inum, + const __global numtyp *restrict sp_lj_in, + const __global int *dev_nbor, + const __global int *dev_packed, + __global acctyp4 *restrict ans, + __global acctyp *restrict engv, + const int eflag, const int vflag, const int inum, const int nbor_pitch, const int t_per_atom) { int tid, ii, offset; atom_info(t_per_atom,ii,tid,offset); - + __local numtyp4 coeff1[MAX_SHARED_TYPES*MAX_SHARED_TYPES]; __local numtyp4 coeff2[MAX_SHARED_TYPES*MAX_SHARED_TYPES]; __local numtyp sp_lj[4]; @@ -137,7 +137,7 @@ __kernel void k_born_fast(const __global numtyp4 *restrict x_, if (eflag>0) coeff2[tid]=coeff2_in[tid]; } - + acctyp energy=(acctyp)0; acctyp4 f; f.x=(acctyp)0; f.y=(acctyp)0; f.z=(acctyp)0; @@ -146,7 +146,7 @@ __kernel void k_born_fast(const __global numtyp4 *restrict x_, virial[i]=(acctyp)0; __syncthreads(); - + if (ii0) { numtyp e=coeff2[mtype].x*rexp - coeff2[mtype].y*r6inv + coeff2[mtype].z*r2inv*r6inv; - energy+=factor_lj*(e-coeff2[mtype].w); + energy+=factor_lj*(e-coeff2[mtype].w); } if (vflag>0) { virial[0] += delx*delx*force; diff --git a/lib/gpu/lal_born.h b/lib/gpu/lal_born.h index 6fed6461d2..685f4d87a9 100644 --- a/lib/gpu/lal_born.h +++ b/lib/gpu/lal_born.h @@ -9,7 +9,7 @@ This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) __________________________________________________________________________ - begin : + begin : email : nguyentd@ornl.gov ***************************************************************************/ @@ -24,13 +24,13 @@ template class Born : public BaseAtomic { public: Born(); - ~Born(); + ~Born(); /// Clear any previous data and set up for a new LAMMPS run /** \param max_nbors initial number of rows in the neighbor matrix * \param cell_size cutoff + skin * \param gpu_split fraction of particles handled by device - * + * * Returns: * - 0 if successfull * - -1 if fix gpu not found @@ -38,20 +38,20 @@ class Born : public BaseAtomic { * - -4 if the GPU library was not compiled for GPU * - -5 Double precision is not supported on card **/ int init(const int ntypes, double **host_cutsq, - double **host_rhoinv, double **host_born1, double **host_born2, + double **host_rhoinv, double **host_born1, double **host_born2, double **host_born3, double **host_a, double **host_c, - double **host_d, double **host_sigma, + double **host_d, double **host_sigma, double **host_offset, double *host_special_lj, - const int nlocal, const int nall, const int max_nbors, - const int maxspecial, const double cell_size, + const int nlocal, const int nall, const int max_nbors, + const int maxspecial, const double cell_size, const double gpu_split, FILE *screen); - + /// Send updated coeffs from host to device (to be compatible with fix adapt) void reinit(const int ntypes, double **host_rhoinv, double **host_born1, double **host_born2, double **host_born3, double **host_a, double **host_c, double **host_d, double **host_offset); - + /// Clear all host and device data /** \note This is called at the beginning of the init() routine **/ void clear(); @@ -77,7 +77,7 @@ class Born : public BaseAtomic { /// If atom type constants fit in shared memory, use fast kernels bool shared_types; - /// Number of atom types + /// Number of atom types int _lj_types; private: diff --git a/lib/gpu/lal_born_coul_long.cpp b/lib/gpu/lal_born_coul_long.cpp index 94becf8c69..242961e80c 100644 --- a/lib/gpu/lal_born_coul_long.cpp +++ b/lib/gpu/lal_born_coul_long.cpp @@ -9,7 +9,7 @@ This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) __________________________________________________________________________ - begin : + begin : email : nguyentd@ornl.gov ***************************************************************************/ @@ -37,17 +37,17 @@ template BornCoulLongT::~BornCoulLongT() { clear(); } - + template int BornCoulLongT::bytes_per_atom(const int max_nbors) const { return this->bytes_per_atom_atomic(max_nbors); } template -int BornCoulLongT::init(const int ntypes, double **host_cutsq, double **host_rhoinv, - double **host_born1, double **host_born2, double **host_born3, - double **host_a, double **host_c, double **host_d, - double **host_sigma, double **host_offset, +int BornCoulLongT::init(const int ntypes, double **host_cutsq, double **host_rhoinv, + double **host_born1, double **host_born2, double **host_born3, + double **host_a, double **host_c, double **host_d, + double **host_sigma, double **host_offset, double *host_special_lj, const int nlocal, const int nall, const int max_nbors, const int maxspecial, const double cell_size, @@ -85,11 +85,11 @@ int BornCoulLongT::init(const int ntypes, double **host_cutsq, double **host_rho coeff2.alloc(lj_types*lj_types,*(this->ucl_device),UCL_READ_ONLY); this->atom->type_pack4(ntypes,lj_types,coeff2,host_write,host_a,host_c, host_d,host_offset); - + cutsq_sigma.alloc(lj_types*lj_types,*(this->ucl_device),UCL_READ_ONLY); this->atom->type_pack4(ntypes,lj_types,cutsq_sigma,host_write,host_cutsq, host_cut_ljsq,host_sigma); - + sp_lj.alloc(8,*(this->ucl_device),UCL_READ_ONLY); for (int i=0; i<4; i++) { host_write[i]=host_special_lj[i]; @@ -142,7 +142,7 @@ void BornCoulLongT::loop(const bool _eflag, const bool _vflag) { vflag=1; else vflag=0; - + int GX=static_cast(ceil(static_cast(this->ans->inum())/ (BX/this->_threads_per_atom))); @@ -157,15 +157,15 @@ void BornCoulLongT::loop(const bool _eflag, const bool _vflag) { &this->ans->force, &this->ans->engv, &eflag, &vflag, &ainum, &nbor_pitch, &this->atom->q, - &cutsq_sigma, &_cut_coulsq, &_qqrd2e, + &cutsq_sigma, &_cut_coulsq, &_qqrd2e, &_g_ewald, &this->_threads_per_atom); } else { this->k_pair.set_size(GX,BX); - this->k_pair.run(&this->atom->x, &coeff1, &coeff2, &_lj_types, &sp_lj, + this->k_pair.run(&this->atom->x, &coeff1, &coeff2, &_lj_types, &sp_lj, &this->nbor->dev_nbor, &this->_nbor_data->begin(), - &this->ans->force, &this->ans->engv, + &this->ans->force, &this->ans->engv, &eflag, &vflag, &ainum, - &nbor_pitch, &this->atom->q, + &nbor_pitch, &this->atom->q, &cutsq_sigma, &_cut_coulsq, &_qqrd2e, &_g_ewald, &this->_threads_per_atom); } diff --git a/lib/gpu/lal_born_coul_long.cu b/lib/gpu/lal_born_coul_long.cu index 3d74f2087a..4cb4ea448f 100644 --- a/lib/gpu/lal_born_coul_long.cu +++ b/lib/gpu/lal_born_coul_long.cu @@ -9,7 +9,7 @@ // This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) // __________________________________________________________________________ // -// begin : +// begin : // email : nguyentd@ornl.gov // ***************************************************************************/ @@ -29,19 +29,19 @@ texture q_tex; #define q_tex q_ #endif -__kernel void k_born_long(const __global numtyp4 *restrict x_, +__kernel void k_born_long(const __global numtyp4 *restrict x_, const __global numtyp4 *restrict coeff1, const __global numtyp4 *restrict coeff2, - const int lj_types, - const __global numtyp *restrict sp_lj_in, - const __global int *dev_nbor, - const __global int *dev_packed, + const int lj_types, + const __global numtyp *restrict sp_lj_in, + const __global int *dev_nbor, + const __global int *dev_packed, __global acctyp4 *restrict ans, - __global acctyp *restrict engv, + __global acctyp *restrict engv, const int eflag, const int vflag, const int inum, - const int nbor_pitch, + const int nbor_pitch, const __global numtyp *restrict q_, - const __global numtyp4 *restrict cutsq_sigma, + const __global numtyp4 *restrict cutsq_sigma, const numtyp cut_coulsq, const numtyp qqrd2e, const numtyp g_ewald, const int t_per_atom) { int tid, ii, offset; @@ -64,14 +64,14 @@ __kernel void k_born_long(const __global numtyp4 *restrict x_, acctyp virial[6]; for (int i=0; i<6; i++) virial[i]=(acctyp)0; - + if (ii0) { - if (rsq < cut_coulsq) - e_coul += prefactor*(_erfc-factor_coul); - if (rsq < coeff1[mtype].w) { - numtyp e=coeff2[mtype].x*rexp - coeff2[mtype].y*r6inv - + coeff2[mtype].z*r2inv*r6inv; - energy+=factor_lj*(e-coeff2[mtype].w); - } - } - if (vflag>0) { - virial[0] += delx*delx*force; - virial[1] += dely*dely*force; - virial[2] += delz*delz*force; - virial[3] += delx*dely*force; - virial[4] += delx*delz*force; - virial[5] += dely*delz*force; - } - } - - } // for nbor - store_answers_q(f,energy,e_coul,virial,ii,inum,tid,t_per_atom,offset,eflag, - vflag,ans,engv); - } // if ii -} - -__kernel void k_born_long_fast(const __global numtyp4 *restrict x_, - const __global numtyp4 *restrict coeff1_in, - const __global numtyp4 *restrict coeff2_in, - const __global numtyp *restrict sp_lj_in, - const __global int *dev_nbor, - const __global int *dev_packed, - __global acctyp4 *restrict ans, - __global acctyp *restrict engv, - const int eflag, const int vflag, const int inum, - const int nbor_pitch, - const __global numtyp *restrict q_, - const __global numtyp4 *restrict cutsq_sigma, - const numtyp cut_coulsq, const numtyp qqrd2e, - const numtyp g_ewald, const int t_per_atom) { - int tid, ii, offset; - atom_info(t_per_atom,ii,tid,offset); - - __local numtyp4 coeff1[MAX_SHARED_TYPES*MAX_SHARED_TYPES]; - __local numtyp4 coeff2[MAX_SHARED_TYPES*MAX_SHARED_TYPES]; - __local numtyp sp_lj[8]; - if (tid<8) - sp_lj[tid]=sp_lj_in[tid]; - if (tid0) - coeff2[tid]=coeff2_in[tid]; - } - - acctyp energy=(acctyp)0; - acctyp e_coul=(acctyp)0; - acctyp4 f; - f.x=(acctyp)0; f.y=(acctyp)0; f.z=(acctyp)0; - acctyp virial[6]; - for (int i=0; i<6; i++) - virial[i]=(acctyp)0; - - __syncthreads(); - - if (ii0) { + if (rsq < cut_coulsq) + e_coul += prefactor*(_erfc-factor_coul); + if (rsq < coeff1[mtype].w) { + numtyp e=coeff2[mtype].x*rexp - coeff2[mtype].y*r6inv + + coeff2[mtype].z*r2inv*r6inv; + energy+=factor_lj*(e-coeff2[mtype].w); + } + } + if (vflag>0) { + virial[0] += delx*delx*force; + virial[1] += dely*dely*force; + virial[2] += delz*delz*force; + virial[3] += delx*dely*force; + virial[4] += delx*delz*force; + virial[5] += dely*delz*force; + } + } + + } // for nbor + store_answers_q(f,energy,e_coul,virial,ii,inum,tid,t_per_atom,offset,eflag, + vflag,ans,engv); + } // if ii +} + +__kernel void k_born_long_fast(const __global numtyp4 *restrict x_, + const __global numtyp4 *restrict coeff1_in, + const __global numtyp4 *restrict coeff2_in, + const __global numtyp *restrict sp_lj_in, + const __global int *dev_nbor, + const __global int *dev_packed, + __global acctyp4 *restrict ans, + __global acctyp *restrict engv, + const int eflag, const int vflag, const int inum, + const int nbor_pitch, + const __global numtyp *restrict q_, + const __global numtyp4 *restrict cutsq_sigma, + const numtyp cut_coulsq, const numtyp qqrd2e, + const numtyp g_ewald, const int t_per_atom) { + int tid, ii, offset; + atom_info(t_per_atom,ii,tid,offset); + + __local numtyp4 coeff1[MAX_SHARED_TYPES*MAX_SHARED_TYPES]; + __local numtyp4 coeff2[MAX_SHARED_TYPES*MAX_SHARED_TYPES]; + __local numtyp sp_lj[8]; + if (tid<8) + sp_lj[tid]=sp_lj_in[tid]; + if (tid0) + coeff2[tid]=coeff2_in[tid]; + } + + acctyp energy=(acctyp)0; + acctyp e_coul=(acctyp)0; + acctyp4 f; + f.x=(acctyp)0; f.y=(acctyp)0; f.z=(acctyp)0; + acctyp virial[6]; + for (int i=0; i<6; i++) + virial[i]=(acctyp)0; + + __syncthreads(); + + if (ii { /** \param max_nbors initial number of rows in the neighbor matrix * \param cell_size cutoff + skin * \param gpu_split fraction of particles handled by device - * + * * Returns: * - 0 if successfull * - -1 if fix gpu not found * - -3 if there is an out of memory error * - -4 if the GPU library was not compiled for GPU * - -5 Double precision is not supported on card **/ - int init(const int ntypes, double **host_cutsq, double **host_rhoinv, - double **host_born1, double **host_born2, double **host_born3, - double **host_a, double **host_c, double **host_d, + int init(const int ntypes, double **host_cutsq, double **host_rhoinv, + double **host_born1, double **host_born2, double **host_born3, + double **host_a, double **host_c, double **host_d, double **host_sigma, double **host_offset, double *host_special_lj, - const int nlocal, const int nall, const int max_nbors, - const int maxspecial, const double cell_size, + const int nlocal, const int nall, const int max_nbors, + const int maxspecial, const double cell_size, const double gpu_split, FILE *screen, double **host_cut_ljsq, const double host_cut_coulsq, double *host_special_coul, const double qqrd2e, const double g_ewald); @@ -59,12 +59,12 @@ class BornCoulLong : public BaseCharge { // --------------------------- TYPE DATA -------------------------- - /// coeff1.x = rhoinv, coeff1.y = born1, coeff1.z = born2, + /// coeff1.x = rhoinv, coeff1.y = born1, coeff1.z = born2, /// coeff1.w = born3 UCL_D_Vec coeff1; /// coeff2.x = a, coeff2.y = c, coeff2.z = d, coeff2.w = offset UCL_D_Vec coeff2; - /// cutsq_sigma.x = cutsq, cutsq_sigma.y = cutsq_lj, + /// cutsq_sigma.x = cutsq, cutsq_sigma.y = cutsq_lj, /// cutsq_sigma.z = sigma UCL_D_Vec cutsq_sigma; /// Special LJ values [0-3] and Special Coul values [4-7] @@ -73,7 +73,7 @@ class BornCoulLong : public BaseCharge { /// If atom type constants fit in shared memory, use fast kernels bool shared_types; - /// Number of atom types + /// Number of atom types int _lj_types; numtyp _cut_coulsq, _qqrd2e, _g_ewald; diff --git a/lib/gpu/lal_born_coul_long_ext.cpp b/lib/gpu/lal_born_coul_long_ext.cpp index 382e9a2b2c..8c1ff0413f 100644 --- a/lib/gpu/lal_born_coul_long_ext.cpp +++ b/lib/gpu/lal_born_coul_long_ext.cpp @@ -9,7 +9,7 @@ This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) __________________________________________________________________________ - begin : + begin : email : nguyentd@ornl.gov ***************************************************************************/ @@ -30,9 +30,9 @@ static BornCoulLong BORNCLMF; int borncl_gpu_init(const int ntypes, double **cutsq, double **host_rhoinv, double **host_born1, double **host_born2, double **host_born3, double **host_a, double **host_c, double **host_d, - double **sigma, double **offset, double *special_lj, - const int inum, const int nall, const int max_nbors, - const int maxspecial, const double cell_size, int &gpu_mode, + double **sigma, double **offset, double *special_lj, + const int inum, const int nall, const int max_nbors, + const int maxspecial, const double cell_size, int &gpu_mode, FILE *screen, double **host_cut_ljsq, double host_cut_coulsq, double *host_special_coul, const double qqrd2e, const double g_ewald) { @@ -58,10 +58,10 @@ int borncl_gpu_init(const int ntypes, double **cutsq, double **host_rhoinv, int init_ok=0; if (world_me==0) - init_ok=BORNCLMF.init(ntypes, cutsq, host_rhoinv, host_born1, host_born2, - host_born3, host_a, host_c, host_d, sigma, offset, - special_lj, inum, nall, 300, maxspecial, cell_size, - gpu_split, screen, host_cut_ljsq, host_cut_coulsq, + init_ok=BORNCLMF.init(ntypes, cutsq, host_rhoinv, host_born1, host_born2, + host_born3, host_a, host_c, host_d, sigma, offset, + special_lj, inum, nall, 300, maxspecial, cell_size, + gpu_split, screen, host_cut_ljsq, host_cut_coulsq, host_special_coul, qqrd2e, g_ewald); BORNCLMF.device->world_barrier(); @@ -78,14 +78,14 @@ int borncl_gpu_init(const int ntypes, double **cutsq, double **host_rhoinv, fflush(screen); } if (gpu_rank==i && world_me!=0) - init_ok=BORNCLMF.init(ntypes, cutsq, host_rhoinv, host_born1, host_born2, - host_born3, host_a, host_c, host_d, sigma, offset, - special_lj, inum, nall, 300, maxspecial, cell_size, - gpu_split, screen, host_cut_ljsq, host_cut_coulsq, + init_ok=BORNCLMF.init(ntypes, cutsq, host_rhoinv, host_born1, host_born2, + host_born3, host_a, host_c, host_d, sigma, offset, + special_lj, inum, nall, 300, maxspecial, cell_size, + gpu_split, screen, host_cut_ljsq, host_cut_coulsq, host_special_coul, qqrd2e, g_ewald); BORNCLMF.device->gpu_barrier(); - if (message) + if (message) fprintf(screen,"Done.\n"); } if (message) @@ -102,7 +102,7 @@ void borncl_gpu_clear() { int** borncl_gpu_compute_n(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, - double *sublo, double *subhi, tagint *tag, int **nspecial, + double *sublo, double *subhi, tagint *tag, int **nspecial, tagint **special, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, int **ilist, int **jnum, const double cpu_time, @@ -112,7 +112,7 @@ int** borncl_gpu_compute_n(const int ago, const int inum_full, subhi, tag, nspecial, special, eflag, vflag, eatom, vatom, host_start, ilist, jnum, cpu_time, success, host_q, boxlo, prd); -} +} void borncl_gpu_compute(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, int *ilist, int *numj, diff --git a/lib/gpu/lal_born_coul_wolf.cpp b/lib/gpu/lal_born_coul_wolf.cpp index 7615c1dd53..fa832206ee 100644 --- a/lib/gpu/lal_born_coul_wolf.cpp +++ b/lib/gpu/lal_born_coul_wolf.cpp @@ -9,7 +9,7 @@ This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) __________________________________________________________________________ - begin : + begin : email : nguyentd@ornl.gov ***************************************************************************/ @@ -37,17 +37,17 @@ template BornCoulWolfT::~BornCoulWolfT() { clear(); } - + template int BornCoulWolfT::bytes_per_atom(const int max_nbors) const { return this->bytes_per_atom_atomic(max_nbors); } template -int BornCoulWolfT::init(const int ntypes, double **host_cutsq, double **host_rhoinv, - double **host_born1, double **host_born2, double **host_born3, - double **host_a, double **host_c, double **host_d, - double **host_sigma, double **host_offset, +int BornCoulWolfT::init(const int ntypes, double **host_cutsq, double **host_rhoinv, + double **host_born1, double **host_born2, double **host_born3, + double **host_a, double **host_c, double **host_d, + double **host_sigma, double **host_offset, double *host_special_lj, const int nlocal, const int nall, const int max_nbors, const int maxspecial, const double cell_size, @@ -85,11 +85,11 @@ int BornCoulWolfT::init(const int ntypes, double **host_cutsq, double **host_rho coeff2.alloc(lj_types*lj_types,*(this->ucl_device),UCL_READ_ONLY); this->atom->type_pack4(ntypes,lj_types,coeff2,host_write,host_a,host_c, host_d,host_offset); - + cutsq_sigma.alloc(lj_types*lj_types,*(this->ucl_device),UCL_READ_ONLY); this->atom->type_pack4(ntypes,lj_types,cutsq_sigma,host_write,host_cutsq, host_cut_ljsq,host_sigma); - + sp_lj.alloc(8,*(this->ucl_device),UCL_READ_ONLY); for (int i=0; i<4; i++) { host_write[i]=host_special_lj[i]; @@ -144,7 +144,7 @@ void BornCoulWolfT::loop(const bool _eflag, const bool _vflag) { vflag=1; else vflag=0; - + int GX=static_cast(ceil(static_cast(this->ans->inum())/ (BX/this->_threads_per_atom))); @@ -157,17 +157,17 @@ void BornCoulWolfT::loop(const bool _eflag, const bool _vflag) { &this->nbor->dev_nbor, &this->_nbor_data->begin(), &this->ans->force, &this->ans->engv, &eflag, &vflag, &ainum, &nbor_pitch, &this->atom->q, - &cutsq_sigma, &_cut_coulsq, &_qqrd2e, - &_alf, &_e_shift, &_f_shift, + &cutsq_sigma, &_cut_coulsq, &_qqrd2e, + &_alf, &_e_shift, &_f_shift, &this->_threads_per_atom); } else { this->k_pair.set_size(GX,BX); - this->k_pair.run(&this->atom->x, &coeff1, &coeff2, &_lj_types, &sp_lj, - &this->nbor->dev_nbor, &this->_nbor_data->begin(), + this->k_pair.run(&this->atom->x, &coeff1, &coeff2, &_lj_types, &sp_lj, + &this->nbor->dev_nbor, &this->_nbor_data->begin(), &this->ans->force, &this->ans->engv, &eflag, &vflag, &ainum, &nbor_pitch, &this->atom->q, &cutsq_sigma, &_cut_coulsq, - &_qqrd2e, &_alf, &_e_shift, &_f_shift, + &_qqrd2e, &_alf, &_e_shift, &_f_shift, &this->_threads_per_atom); } this->time_pair.stop(); diff --git a/lib/gpu/lal_born_coul_wolf.cu b/lib/gpu/lal_born_coul_wolf.cu index e7706b408a..0dc7d08c63 100644 --- a/lib/gpu/lal_born_coul_wolf.cu +++ b/lib/gpu/lal_born_coul_wolf.cu @@ -9,7 +9,7 @@ // This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) // __________________________________________________________________________ // -// begin : +// begin : // email : nguyentd@ornl.gov // ***************************************************************************/ @@ -31,21 +31,21 @@ texture q_tex; #define MY_PIS (acctyp)1.77245385090551602729 -__kernel void k_born_wolf(const __global numtyp4 *restrict x_, +__kernel void k_born_wolf(const __global numtyp4 *restrict x_, const __global numtyp4 *restrict coeff1, - const __global numtyp4 *restrict coeff2, - const int lj_types, - const __global numtyp *restrict sp_lj_in, - const __global int *dev_nbor, - const __global int *dev_packed, + const __global numtyp4 *restrict coeff2, + const int lj_types, + const __global numtyp *restrict sp_lj_in, + const __global int *dev_nbor, + const __global int *dev_packed, __global acctyp4 *restrict ans, - __global acctyp *restrict engv, + __global acctyp *restrict engv, const int eflag, const int vflag, const int inum, - const int nbor_pitch, + const int nbor_pitch, const __global numtyp *restrict q_, - const __global numtyp4 *restrict cutsq_sigma, + const __global numtyp4 *restrict cutsq_sigma, const numtyp cut_coulsq, const numtyp qqrd2e, - const numtyp alf, const numtyp e_shift, + const numtyp alf, const numtyp e_shift, const numtyp f_shift, const int t_per_atom) { int tid, ii, offset; atom_info(t_per_atom,ii,tid,offset); @@ -67,20 +67,20 @@ __kernel void k_born_wolf(const __global numtyp4 *restrict x_, acctyp virial[6]; for (int i=0; i<6; i++) virial[i]=(acctyp)0; - + if (ii0) { - acctyp e_self = -((acctyp)0.5*e_shift + alf/MY_PIS) * + acctyp e_self = -((acctyp)0.5*e_shift + alf/MY_PIS) * qtmp*qtmp*qqrd2e/(acctyp)t_per_atom; e_coul += (acctyp)2.0*e_self; } @@ -108,12 +108,12 @@ __kernel void k_born_wolf(const __global numtyp4 *restrict x_, numtyp forcecoul, forceborn, force, r6inv, prefactor; numtyp v_sh = (numtyp)0.0; numtyp rexp = (numtyp)0.0; - + if (rsq < cutsq_sigma[mtype].y) { // cut_ljsq numtyp r = ucl_sqrt(rsq); rexp = ucl_exp((cutsq_sigma[mtype].z-r)*coeff1[mtype].x); r6inv = r2inv*r2inv*r2inv; - forceborn = (coeff1[mtype].y*r*rexp - coeff1[mtype].z*r6inv + forceborn = (coeff1[mtype].y*r*rexp - coeff1[mtype].z*r6inv + coeff1[mtype].w*r2inv*r6inv)*factor_lj; } else forceborn = (numtyp)0.0; @@ -147,7 +147,7 @@ __kernel void k_born_wolf(const __global numtyp4 *restrict x_, numtyp e=coeff2[mtype].x*rexp - coeff2[mtype].y*r6inv + coeff2[mtype].z*r2inv*r6inv; energy+=factor_lj*(e-coeff2[mtype].w); - } + } } if (vflag>0) { virial[0] += delx*delx*force; @@ -165,20 +165,20 @@ __kernel void k_born_wolf(const __global numtyp4 *restrict x_, } // if ii } -__kernel void k_born_wolf_fast(const __global numtyp4 *restrict x_, +__kernel void k_born_wolf_fast(const __global numtyp4 *restrict x_, const __global numtyp4 *restrict coeff1_in, - const __global numtyp4 *restrict coeff2_in, + const __global numtyp4 *restrict coeff2_in, const __global numtyp *restrict sp_lj_in, - const __global int *dev_nbor, + const __global int *dev_nbor, const __global int *dev_packed, - __global acctyp4 *restrict ans, - __global acctyp *restrict engv, - const int eflag, const int vflag, const int inum, - const int nbor_pitch, + __global acctyp4 *restrict ans, + __global acctyp *restrict engv, + const int eflag, const int vflag, const int inum, + const int nbor_pitch, const __global numtyp *restrict q_, const __global numtyp4 *restrict cutsq_sigma, const numtyp cut_coulsq, const numtyp qqrd2e, - const numtyp alf, const numtyp e_shift, + const numtyp alf, const numtyp e_shift, const numtyp f_shift, const int t_per_atom) { int tid, ii, offset; atom_info(t_per_atom,ii,tid,offset); @@ -193,7 +193,7 @@ __kernel void k_born_wolf_fast(const __global numtyp4 *restrict x_, if (eflag>0) coeff2[tid]=coeff2_in[tid]; } - + acctyp energy=(acctyp)0; acctyp e_coul=(acctyp)0; acctyp4 f; @@ -201,23 +201,23 @@ __kernel void k_born_wolf_fast(const __global numtyp4 *restrict x_, acctyp virial[6]; for (int i=0; i<6; i++) virial[i]=(acctyp)0; - + __syncthreads(); - + if (ii0) { - acctyp e_self = -((acctyp)0.5*e_shift + alf/MY_PIS) * + acctyp e_self = -((acctyp)0.5*e_shift + alf/MY_PIS) * qtmp*qtmp*qqrd2e/(acctyp)t_per_atom; e_coul += (acctyp)2.0*e_self; } @@ -244,12 +244,12 @@ __kernel void k_born_wolf_fast(const __global numtyp4 *restrict x_, numtyp forcecoul, forceborn, force, r6inv, prefactor; numtyp v_sh = (numtyp)0.0; numtyp rexp = (numtyp)0.0; - + if (rsq < cutsq_sigma[mtype].y) { numtyp r = ucl_sqrt(rsq); rexp = ucl_exp((cutsq_sigma[mtype].z-r)*coeff1[mtype].x); r6inv = r2inv*r2inv*r2inv; - forceborn = (coeff1[mtype].y*r*rexp - coeff1[mtype].z*r6inv + forceborn = (coeff1[mtype].y*r*rexp - coeff1[mtype].z*r6inv + coeff1[mtype].w*r2inv*r6inv)*factor_lj; } else forceborn = (numtyp)0.0; diff --git a/lib/gpu/lal_born_coul_wolf.h b/lib/gpu/lal_born_coul_wolf.h index 9e02d23233..4b2406b989 100644 --- a/lib/gpu/lal_born_coul_wolf.h +++ b/lib/gpu/lal_born_coul_wolf.h @@ -9,7 +9,7 @@ This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) __________________________________________________________________________ - begin : + begin : email : nguyentd@ornl.gov ***************************************************************************/ @@ -30,19 +30,19 @@ class BornCoulWolf : public BaseCharge { /** \param max_nbors initial number of rows in the neighbor matrix * \param cell_size cutoff + skin * \param gpu_split fraction of particles handled by device - * + * * Returns: * - 0 if successfull * - -1 if fix gpu not found * - -3 if there is an out of memory error * - -4 if the GPU library was not compiled for GPU * - -5 Double precision is not supported on card **/ - int init(const int ntypes, double **host_cutsq, double **host_rhoinv, - double **host_born1, double **host_born2, double **host_born3, - double **host_a, double **host_c, double **host_d, + int init(const int ntypes, double **host_cutsq, double **host_rhoinv, + double **host_born1, double **host_born2, double **host_born3, + double **host_a, double **host_c, double **host_d, double **host_sigma, double **host_offset, double *host_special_lj, - const int nlocal, const int nall, const int max_nbors, - const int maxspecial, const double cell_size, + const int nlocal, const int nall, const int max_nbors, + const int maxspecial, const double cell_size, const double gpu_split, FILE *screen, double **host_cut_ljsq, const double host_cut_coulsq, double *host_special_coul, const double qqrd2e, const double alf, const double e_shift, @@ -60,12 +60,12 @@ class BornCoulWolf : public BaseCharge { // --------------------------- TYPE DATA -------------------------- - /// coeff1.x = rhoinv, coeff1.y = born1, coeff1.z = born2, + /// coeff1.x = rhoinv, coeff1.y = born1, coeff1.z = born2, /// coeff1.w = born3 UCL_D_Vec coeff1; /// coeff2.x = a, coeff2.y = c, coeff2.z = d, coeff2.w = offset UCL_D_Vec coeff2; - /// cutsq_sigma.x = cutsq, cutsq_sigma.y = cutsq_lj, + /// cutsq_sigma.x = cutsq, cutsq_sigma.y = cutsq_lj, /// cutsq_sigma.z = sigma UCL_D_Vec cutsq_sigma; /// Special LJ values [0-3] and Special Coul values [4-7] @@ -74,7 +74,7 @@ class BornCoulWolf : public BaseCharge { /// If atom type constants fit in shared memory, use fast kernels bool shared_types; - /// Number of atom types + /// Number of atom types int _lj_types; numtyp _cut_coulsq,_qqrd2e,_alf,_e_shift,_f_shift; diff --git a/lib/gpu/lal_born_coul_wolf_ext.cpp b/lib/gpu/lal_born_coul_wolf_ext.cpp index b56c526119..5083afe0c4 100644 --- a/lib/gpu/lal_born_coul_wolf_ext.cpp +++ b/lib/gpu/lal_born_coul_wolf_ext.cpp @@ -9,7 +9,7 @@ This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) __________________________________________________________________________ - begin : + begin : email : nguyentd@ornl.gov ***************************************************************************/ @@ -28,7 +28,7 @@ static BornCoulWolf BORNCWMF; // Allocate memory on host and device and copy constants to device // --------------------------------------------------------------------------- int borncw_gpu_init(const int ntypes, double **cutsq, double **host_rhoinv, - double **host_born1, double **host_born2, double **host_born3, + double **host_born1, double **host_born2, double **host_born3, double **host_a, double **host_c, double **host_d, double **sigma, double **offset, double *special_lj, const int inum, const int nall, const int max_nbors, const int maxspecial, @@ -60,9 +60,9 @@ int borncw_gpu_init(const int ntypes, double **cutsq, double **host_rhoinv, if (world_me==0) init_ok=BORNCWMF.init(ntypes, cutsq, host_rhoinv, host_born1, host_born2, host_born3, host_a, host_c, host_d, sigma, - offset, special_lj, inum, nall, 300, + offset, special_lj, inum, nall, 300, maxspecial, cell_size, gpu_split, screen, host_cut_ljsq, - host_cut_coulsq, host_special_coul, qqrd2e, + host_cut_coulsq, host_special_coul, qqrd2e, alf, e_shift, f_shift); BORNCWMF.device->world_barrier(); @@ -79,15 +79,15 @@ int borncw_gpu_init(const int ntypes, double **cutsq, double **host_rhoinv, fflush(screen); } if (gpu_rank==i && world_me!=0) - init_ok=BORNCWMF.init(ntypes, cutsq, host_rhoinv, host_born1, host_born2, - host_born3, host_a, host_c, host_d, sigma, - offset, special_lj, inum, nall, 300, + init_ok=BORNCWMF.init(ntypes, cutsq, host_rhoinv, host_born1, host_born2, + host_born3, host_a, host_c, host_d, sigma, + offset, special_lj, inum, nall, 300, maxspecial, cell_size, gpu_split, screen, host_cut_ljsq, - host_cut_coulsq, host_special_coul, qqrd2e, + host_cut_coulsq, host_special_coul, qqrd2e, alf, e_shift, f_shift); BORNCWMF.device->gpu_barrier(); - if (message) + if (message) fprintf(screen,"Done.\n"); } if (message) @@ -104,7 +104,7 @@ void borncw_gpu_clear() { int** borncw_gpu_compute_n(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, - double *sublo, double *subhi, tagint *tag, int **nspecial, + double *sublo, double *subhi, tagint *tag, int **nspecial, tagint **special, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, int **ilist, int **jnum, const double cpu_time, @@ -114,7 +114,7 @@ int** borncw_gpu_compute_n(const int ago, const int inum_full, subhi, tag, nspecial, special, eflag, vflag, eatom, vatom, host_start, ilist, jnum, cpu_time, success, host_q, boxlo, prd); -} +} void borncw_gpu_compute(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, int *ilist, int *numj, diff --git a/lib/gpu/lal_born_ext.cpp b/lib/gpu/lal_born_ext.cpp index 6bd51e6d68..171020e769 100644 --- a/lib/gpu/lal_born_ext.cpp +++ b/lib/gpu/lal_born_ext.cpp @@ -9,7 +9,7 @@ This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) __________________________________________________________________________ - begin : + begin : email : nguyentd@ornl.gov ***************************************************************************/ @@ -28,9 +28,9 @@ static Born BORNMF; // Allocate memory on host and device and copy constants to device // --------------------------------------------------------------------------- int born_gpu_init(const int ntypes, double **cutsq, double **host_rhoinv, - double **host_born1, double **host_born2, - double **host_born3, double **host_a, double **host_c, - double **host_d, double **sigma, + double **host_born1, double **host_born2, + double **host_born3, double **host_a, double **host_c, + double **host_d, double **sigma, double **offset, double *special_lj, const int inum, const int nall, const int max_nbors, const int maxspecial, const double cell_size, int &gpu_mode, FILE *screen) { @@ -56,7 +56,7 @@ int born_gpu_init(const int ntypes, double **cutsq, double **host_rhoinv, int init_ok=0; if (world_me==0) - init_ok=BORNMF.init(ntypes, cutsq, host_rhoinv, host_born1, host_born2, + init_ok=BORNMF.init(ntypes, cutsq, host_rhoinv, host_born1, host_born2, host_born3, host_a, host_c, host_d, sigma, offset, special_lj, inum, nall, 300, maxspecial, cell_size, gpu_split, screen); @@ -75,13 +75,13 @@ int born_gpu_init(const int ntypes, double **cutsq, double **host_rhoinv, fflush(screen); } if (gpu_rank==i && world_me!=0) - init_ok=BORNMF.init(ntypes, cutsq, host_rhoinv, host_born1, host_born2, - host_born3, host_a, host_c, host_d, sigma, + init_ok=BORNMF.init(ntypes, cutsq, host_rhoinv, host_born1, host_born2, + host_born3, host_a, host_c, host_d, sigma, offset, special_lj, inum, nall, 300, maxspecial, cell_size, gpu_split, screen); BORNMF.device->gpu_barrier(); - if (message) + if (message) fprintf(screen,"Done.\n"); } if (message) @@ -102,24 +102,24 @@ void born_gpu_reinit(const int ntypes, double **host_rhoinv, int world_me=BORNMF.device->world_me(); int gpu_rank=BORNMF.device->gpu_rank(); int procs_per_gpu=BORNMF.device->procs_per_gpu(); - + if (world_me==0) BORNMF.reinit(ntypes, host_rhoinv, host_born1, host_born2, host_born3, host_a, host_c, host_d, offset); - + BORNMF.device->world_barrier(); - + for (int i=0; igpu_barrier(); } } void born_gpu_clear() { - BORNMF.clear(); + BORNMF.clear(); } int ** born_gpu_compute_n(const int ago, const int inum_full, @@ -132,7 +132,7 @@ int ** born_gpu_compute_n(const int ago, const int inum_full, return BORNMF.compute(ago, inum_full, nall, host_x, host_type, sublo, subhi, tag, nspecial, special, eflag, vflag, eatom, vatom, host_start, ilist, jnum, cpu_time, success); -} +} void born_gpu_compute(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, int *ilist, int *numj, diff --git a/lib/gpu/lal_buck.cpp b/lib/gpu/lal_buck.cpp index f66759ee3a..aa82f0014d 100644 --- a/lib/gpu/lal_buck.cpp +++ b/lib/gpu/lal_buck.cpp @@ -9,7 +9,7 @@ This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) __________________________________________________________________________ - begin : + begin : email : nguyentd@ornl.gov ***************************************************************************/ @@ -33,10 +33,10 @@ BuckT::Buck() : BaseAtomic(), _allocated(false) { } template -BuckT::~Buck() { +BuckT::~Buck() { clear(); } - + template int BuckT::bytes_per_atom(const int max_nbors) const { return this->bytes_per_atom_atomic(max_nbors); @@ -44,11 +44,11 @@ int BuckT::bytes_per_atom(const int max_nbors) const { template int BuckT::init(const int ntypes, double **host_cutsq, - double **host_rhoinv, double **host_buck1, double **host_buck2, - double **host_a, double **host_c, + double **host_rhoinv, double **host_buck1, double **host_buck2, + double **host_a, double **host_c, double **host_offset, double *host_special_lj, - const int nlocal, const int nall, const int max_nbors, - const int maxspecial, const double cell_size, + const int nlocal, const int nall, const int max_nbors, + const int maxspecial, const double cell_size, const double gpu_split, FILE *_screen) { int success; success=this->init_atomic(nlocal,nall,max_nbors,maxspecial,cell_size,gpu_split, @@ -95,14 +95,14 @@ template void BuckT::reinit(const int ntypes, double **host_cutsq, double **host_rhoinv, double **host_buck1, double **host_buck2, double **host_a, double **host_c, double **host_offset) { - + // Allocate a host write buffer for data initialization UCL_H_Vec host_write(_lj_types*_lj_types*32,*(this->ucl_device), UCL_WRITE_ONLY); - + for (int i=0; i<_lj_types*_lj_types; i++) host_write[i]=0.0; - + this->atom->type_pack4(ntypes,_lj_types,coeff1,host_write,host_rhoinv, host_buck1,host_buck2,host_cutsq); this->atom->type_pack4(ntypes,_lj_types,coeff2,host_write,host_a,host_c, @@ -143,7 +143,7 @@ void BuckT::loop(const bool _eflag, const bool _vflag) { vflag=1; else vflag=0; - + int GX=static_cast(ceil(static_cast(this->ans->inum())/ (BX/this->_threads_per_atom))); @@ -154,13 +154,13 @@ void BuckT::loop(const bool _eflag, const bool _vflag) { this->k_pair_fast.set_size(GX,BX); this->k_pair_fast.run(&this->atom->x, &coeff1, &coeff2, &sp_lj, &this->nbor->dev_nbor, &this->_nbor_data->begin(), - &this->ans->force, &this->ans->engv, &eflag, - &vflag, &ainum, &nbor_pitch, + &this->ans->force, &this->ans->engv, &eflag, + &vflag, &ainum, &nbor_pitch, &this->_threads_per_atom); } else { this->k_pair.set_size(GX,BX); this->k_pair.run(&this->atom->x, &coeff1, &coeff2, &_lj_types, &sp_lj, - &this->nbor->dev_nbor, &this->_nbor_data->begin(), + &this->nbor->dev_nbor, &this->_nbor_data->begin(), &this->ans->force, &this->ans->engv, &eflag, &vflag, &ainum, &nbor_pitch, &this->_threads_per_atom); } diff --git a/lib/gpu/lal_buck.cu b/lib/gpu/lal_buck.cu index 955547e598..c1e1c7d7e2 100644 --- a/lib/gpu/lal_buck.cu +++ b/lib/gpu/lal_buck.cu @@ -9,7 +9,7 @@ // This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) // __________________________________________________________________________ // -// begin : +// begin : // email : nguyentd@ornl.gov // ***************************************************************************/ @@ -24,15 +24,15 @@ texture pos_tex; #define pos_tex x_ #endif -__kernel void k_buck(const __global numtyp4 *restrict x_, +__kernel void k_buck(const __global numtyp4 *restrict x_, const __global numtyp4 *restrict coeff1, - const __global numtyp4 *restrict coeff2, - const int lj_types, + const __global numtyp4 *restrict coeff2, + const int lj_types, const __global numtyp *restrict sp_lj_in, - const __global int *dev_nbor, + const __global int *dev_nbor, const __global int *dev_packed, __global acctyp4 *restrict ans, - __global acctyp *restrict engv, + __global acctyp *restrict engv, const int eflag, const int vflag, const int inum, const int nbor_pitch, const int t_per_atom) { int tid, ii, offset; @@ -50,20 +50,20 @@ __kernel void k_buck(const __global numtyp4 *restrict x_, acctyp virial[6]; for (int i=0; i<6; i++) virial[i]=(acctyp)0; - + if (ii0) { numtyp e=coeff2[mtype].x*rexp - coeff2[mtype].y*r6inv; - energy+=factor_lj*(e-coeff2[mtype].z); + energy+=factor_lj*(e-coeff2[mtype].z); } if (vflag>0) { virial[0] += delx*delx*force; @@ -111,19 +111,19 @@ __kernel void k_buck(const __global numtyp4 *restrict x_, } // if ii } -__kernel void k_buck_fast(const __global numtyp4 *restrict x_, +__kernel void k_buck_fast(const __global numtyp4 *restrict x_, const __global numtyp4 *restrict coeff1_in, - const __global numtyp4 *restrict coeff2_in, - const __global numtyp *restrict sp_lj_in, - const __global int *dev_nbor, - const __global int *dev_packed, + const __global numtyp4 *restrict coeff2_in, + const __global numtyp *restrict sp_lj_in, + const __global int *dev_nbor, + const __global int *dev_packed, __global acctyp4 *restrict ans, - __global acctyp *restrict engv, - const int eflag, const int vflag, const int inum, + __global acctyp *restrict engv, + const int eflag, const int vflag, const int inum, const int nbor_pitch, const int t_per_atom) { int tid, ii, offset; atom_info(t_per_atom,ii,tid,offset); - + __local numtyp4 coeff1[MAX_SHARED_TYPES*MAX_SHARED_TYPES]; __local numtyp4 coeff2[MAX_SHARED_TYPES*MAX_SHARED_TYPES]; __local numtyp sp_lj[4]; @@ -134,7 +134,7 @@ __kernel void k_buck_fast(const __global numtyp4 *restrict x_, if (eflag>0) coeff2[tid]=coeff2_in[tid]; } - + acctyp energy=(acctyp)0; acctyp4 f; f.x=(acctyp)0; f.y=(acctyp)0; f.z=(acctyp)0; @@ -143,7 +143,7 @@ __kernel void k_buck_fast(const __global numtyp4 *restrict x_, virial[i]=(acctyp)0; __syncthreads(); - + if (ii0) { numtyp e=coeff2[mtype].x*rexp - coeff2[mtype].y*r6inv; - energy+=factor_lj*(e-coeff2[mtype].z); + energy+=factor_lj*(e-coeff2[mtype].z); } if (vflag>0) { virial[0] += delx*delx*force; diff --git a/lib/gpu/lal_buck.h b/lib/gpu/lal_buck.h index ebcd72d990..3b84066355 100644 --- a/lib/gpu/lal_buck.h +++ b/lib/gpu/lal_buck.h @@ -9,7 +9,7 @@ This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) __________________________________________________________________________ - begin : + begin : email : nguyentd@ornl.gov ***************************************************************************/ @@ -24,13 +24,13 @@ template class Buck : public BaseAtomic { public: Buck(); - ~Buck(); + ~Buck(); /// Clear any previous data and set up for a new LAMMPS run /** \param max_nbors initial number of rows in the neighbor matrix * \param cell_size cutoff + skin * \param gpu_split fraction of particles handled by device - * + * * Returns: * - 0 if successfull * - -1 if fix gpu not found @@ -38,18 +38,18 @@ class Buck : public BaseAtomic { * - -4 if the GPU library was not compiled for GPU * - -5 Double precision is not supported on card **/ int init(const int ntypes, double **host_cutsq, - double **host_rhoinv, double **host_buck1, double **host_buck2, - double **host_a, double **host_c, + double **host_rhoinv, double **host_buck1, double **host_buck2, + double **host_a, double **host_c, double **host_offset, double *host_special_lj, - const int nlocal, const int nall, const int max_nbors, - const int maxspecial, const double cell_size, + const int nlocal, const int nall, const int max_nbors, + const int maxspecial, const double cell_size, const double gpu_split, FILE *screen); /// Send updated coeffs from host to device (to be compatible with fix adapt) void reinit(const int ntypes, double **host_cutsq, double **host_rhoinv, double **host_buck1, double **host_buck2, double **host_a, double **host_c, double **host_offset); - + /// Clear all host and device data /** \note This is called at the beginning of the init() routine **/ void clear(); @@ -72,7 +72,7 @@ class Buck : public BaseAtomic { /// If atom type constants fit in shared memory, use fast kernels bool shared_types; - /// Number of atom types + /// Number of atom types int _lj_types; private: diff --git a/lib/gpu/lal_buck_coul.cpp b/lib/gpu/lal_buck_coul.cpp index bec640e7a6..9de019d871 100644 --- a/lib/gpu/lal_buck_coul.cpp +++ b/lib/gpu/lal_buck_coul.cpp @@ -9,7 +9,7 @@ This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) __________________________________________________________________________ - begin : + begin : email : nguyentd@ornl.gov ***************************************************************************/ @@ -33,10 +33,10 @@ BuckCoulT::BuckCoul() : BaseCharge(), _allocated(false) { } template -BuckCoulT::~BuckCoul() { +BuckCoulT::~BuckCoul() { clear(); } - + template int BuckCoulT::bytes_per_atom(const int max_nbors) const { return this->bytes_per_atom_atomic(max_nbors); @@ -44,11 +44,11 @@ int BuckCoulT::bytes_per_atom(const int max_nbors) const { template int BuckCoulT::init(const int ntypes, double **host_cutsq, - double **host_rhoinv, double **host_buck1, double **host_buck2, - double **host_a, double **host_c, + double **host_rhoinv, double **host_buck1, double **host_buck2, + double **host_a, double **host_c, double **host_offset, double *host_special_lj, - const int nlocal, const int nall, const int max_nbors, - const int maxspecial, const double cell_size, + const int nlocal, const int nall, const int max_nbors, + const int maxspecial, const double cell_size, const double gpu_split, FILE *_screen, double **host_cut_ljsq, double **host_cut_coulsq, double *host_special_coul, const double qqrd2e) { @@ -82,20 +82,20 @@ int BuckCoulT::init(const int ntypes, double **host_cutsq, coeff2.alloc(lj_types*lj_types,*(this->ucl_device),UCL_READ_ONLY); this->atom->type_pack4(ntypes,lj_types,coeff2,host_write,host_a,host_c, host_offset); - + cutsq.alloc(lj_types*lj_types,*(this->ucl_device),UCL_READ_ONLY); this->atom->type_pack4(ntypes,lj_types,cutsq,host_write,host_cutsq, host_cut_ljsq, host_cut_coulsq); - + sp_lj.alloc(8,*(this->ucl_device),UCL_READ_ONLY); for (int i=0; i<4; i++) { host_write[i]=host_special_lj[i]; host_write[i+4]=host_special_coul[i]; } ucl_copy(sp_lj,host_write,8,false); - + _qqrd2e = qqrd2e; - + _allocated=true; this->_max_bytes=coeff1.row_bytes()+coeff2.row_bytes()+sp_lj.row_bytes(); return 0; @@ -135,7 +135,7 @@ void BuckCoulT::loop(const bool _eflag, const bool _vflag) { vflag=1; else vflag=0; - + int GX=static_cast(ceil(static_cast(this->ans->inum())/ (BX/this->_threads_per_atom))); @@ -147,12 +147,12 @@ void BuckCoulT::loop(const bool _eflag, const bool _vflag) { this->k_pair_fast.run(&this->atom->x, &coeff1, &coeff2, &sp_lj, &this->nbor->dev_nbor, &this->_nbor_data->begin(), &this->ans->force, &this->ans->engv, &eflag, - &vflag, &ainum, &nbor_pitch, &this->atom->q, + &vflag, &ainum, &nbor_pitch, &this->atom->q, &cutsq, &_qqrd2e, &this->_threads_per_atom); } else { this->k_pair.set_size(GX,BX); this->k_pair.run(&this->atom->x, &coeff1, &coeff2, &_lj_types, &sp_lj, - &this->nbor->dev_nbor, &this->_nbor_data->begin(), + &this->nbor->dev_nbor, &this->_nbor_data->begin(), &this->ans->force, &this->ans->engv, &eflag, &vflag, &ainum, &nbor_pitch, &this->atom->q, &cutsq, &_qqrd2e, &this->_threads_per_atom); diff --git a/lib/gpu/lal_buck_coul.cu b/lib/gpu/lal_buck_coul.cu index 87604a02ea..6f0d414825 100644 --- a/lib/gpu/lal_buck_coul.cu +++ b/lib/gpu/lal_buck_coul.cu @@ -9,7 +9,7 @@ // This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) // __________________________________________________________________________ // -// begin : +// begin : // email : nguyentd@ornl.gov // ***************************************************************************/ @@ -29,19 +29,19 @@ texture q_tex; #define q_tex q_ #endif -__kernel void k_buck_coul(const __global numtyp4 *restrict x_, +__kernel void k_buck_coul(const __global numtyp4 *restrict x_, const __global numtyp4 *restrict coeff1, - const __global numtyp4 *restrict coeff2, - const int lj_types, - const __global numtyp *restrict sp_lj_in, - const __global int *dev_nbor, - const __global int *dev_packed, + const __global numtyp4 *restrict coeff2, + const int lj_types, + const __global numtyp *restrict sp_lj_in, + const __global int *dev_nbor, + const __global int *dev_packed, __global acctyp4 *restrict ans, - __global acctyp *restrict engv, + __global acctyp *restrict engv, const int eflag, const int vflag, const int inum, - const int nbor_pitch, + const int nbor_pitch, const __global numtyp *restrict q_ , - const __global numtyp4 *restrict cutsq, + const __global numtyp4 *restrict cutsq, const numtyp qqrd2e, const int t_per_atom) { int tid, ii, offset; atom_info(t_per_atom,ii,tid,offset); @@ -63,21 +63,21 @@ __kernel void k_buck_coul(const __global numtyp4 *restrict x_, acctyp virial[6]; for (int i=0; i<6; i++) virial[i]=(acctyp)0; - + if (ii0) coeff2[tid]=coeff2_in[tid]; } - + acctyp energy=(acctyp)0; acctyp e_coul=(acctyp)0; acctyp4 f; @@ -180,7 +180,7 @@ __kernel void k_buck_coul_fast(const __global numtyp4 *restrict x_, virial[i]=(acctyp)0; __syncthreads(); - + if (ii0) { virial[0] += delx*delx*force; diff --git a/lib/gpu/lal_buck_coul.h b/lib/gpu/lal_buck_coul.h index e4bf59107c..3f8428bfe1 100644 --- a/lib/gpu/lal_buck_coul.h +++ b/lib/gpu/lal_buck_coul.h @@ -9,7 +9,7 @@ This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) __________________________________________________________________________ - begin : + begin : email : nguyentd@ornl.gov ***************************************************************************/ @@ -24,13 +24,13 @@ template class BuckCoul : public BaseCharge { public: BuckCoul(); - ~BuckCoul(); + ~BuckCoul(); /// Clear any previous data and set up for a new LAMMPS run /** \param max_nbors initial number of rows in the neighbor matrix * \param cell_size cutoff + skin * \param gpu_split fraction of particles handled by device - * + * * Returns: * - 0 if successfull * - -1 if fix gpu not found @@ -38,11 +38,11 @@ class BuckCoul : public BaseCharge { * - -4 if the GPU library was not compiled for GPU * - -5 Double precision is not supported on card **/ int init(const int ntypes, double **host_cutsq, - double **host_rhoinv, double **host_buck1, double **host_buck2, - double **host_a, double **host_c, + double **host_rhoinv, double **host_buck1, double **host_buck2, + double **host_a, double **host_c, double **host_offset, double *host_special_lj, - const int nlocal, const int nall, const int max_nbors, - const int maxspecial, const double cell_size, + const int nlocal, const int nall, const int max_nbors, + const int maxspecial, const double cell_size, const double gpu_split, FILE *screen, double **host_cut_ljsq, double **host_cut_coulsq, double *host_special_coul, const double qqrd2e); @@ -71,11 +71,11 @@ class BuckCoul : public BaseCharge { /// If atom type constants fit in shared memory, use fast kernels bool shared_types; - /// Number of atom types + /// Number of atom types int _lj_types; - + numtyp _qqrd2e; - + private: bool _allocated; void loop(const bool _eflag, const bool _vflag); diff --git a/lib/gpu/lal_buck_coul_ext.cpp b/lib/gpu/lal_buck_coul_ext.cpp index dd696fc6bb..3335f4ba47 100644 --- a/lib/gpu/lal_buck_coul_ext.cpp +++ b/lib/gpu/lal_buck_coul_ext.cpp @@ -9,7 +9,7 @@ This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) __________________________________________________________________________ - begin : + begin : email : nguyentd@ornl.gov ***************************************************************************/ @@ -28,8 +28,8 @@ static BuckCoul BUCKCMF; // Allocate memory on host and device and copy constants to device // --------------------------------------------------------------------------- int buckc_gpu_init(const int ntypes, double **cutsq, double **host_rhoinv, - double **host_buck1, double **host_buck2, - double **host_a, double **host_c, + double **host_buck1, double **host_buck2, + double **host_a, double **host_c, double **offset, double *special_lj, const int inum, const int nall, const int max_nbors, const int maxspecial, const double cell_size, int &gpu_mode, FILE *screen, @@ -57,9 +57,9 @@ int buckc_gpu_init(const int ntypes, double **cutsq, double **host_rhoinv, int init_ok=0; if (world_me==0) - init_ok=BUCKCMF.init(ntypes, cutsq, host_rhoinv, host_buck1, host_buck2, + init_ok=BUCKCMF.init(ntypes, cutsq, host_rhoinv, host_buck1, host_buck2, host_a, host_c, offset, special_lj, inum, nall, 300, - maxspecial, cell_size, gpu_split, screen, + maxspecial, cell_size, gpu_split, screen, host_cut_ljsq, host_cut_coulsq, host_special_coul, qqrd2e); @@ -77,14 +77,14 @@ int buckc_gpu_init(const int ntypes, double **cutsq, double **host_rhoinv, fflush(screen); } if (gpu_rank==i && world_me!=0) - init_ok=BUCKCMF.init(ntypes, cutsq, host_rhoinv, host_buck1, host_buck2, + init_ok=BUCKCMF.init(ntypes, cutsq, host_rhoinv, host_buck1, host_buck2, host_a, host_c, offset, special_lj, inum, nall, 300, - maxspecial, cell_size, gpu_split, screen, + maxspecial, cell_size, gpu_split, screen, host_cut_ljsq, host_cut_coulsq, host_special_coul, qqrd2e); BUCKCMF.device->gpu_barrier(); - if (message) + if (message) fprintf(screen,"Done.\n"); } if (message) @@ -96,12 +96,12 @@ int buckc_gpu_init(const int ntypes, double **cutsq, double **host_rhoinv, } void buckc_gpu_clear() { - BUCKCMF.clear(); + BUCKCMF.clear(); } int ** buckc_gpu_compute_n(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, - double *sublo, double *subhi, tagint *tag, int **nspecial, + double *sublo, double *subhi, tagint *tag, int **nspecial, tagint **special, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, int **ilist, int **jnum, const double cpu_time, @@ -111,7 +111,7 @@ int ** buckc_gpu_compute_n(const int ago, const int inum_full, subhi, tag, nspecial, special, eflag, vflag, eatom, vatom, host_start, ilist, jnum, cpu_time, success, host_q, boxlo, prd); -} +} void buckc_gpu_compute(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, int *ilist, int *numj, diff --git a/lib/gpu/lal_buck_coul_long.cpp b/lib/gpu/lal_buck_coul_long.cpp index 4aa720132a..bf9b5fb101 100644 --- a/lib/gpu/lal_buck_coul_long.cpp +++ b/lib/gpu/lal_buck_coul_long.cpp @@ -9,7 +9,7 @@ This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) __________________________________________________________________________ - begin : + begin : email : nguyentd@ornl.gov ***************************************************************************/ @@ -37,7 +37,7 @@ template BuckCoulLongT::~BuckCoulLongT() { clear(); } - + template int BuckCoulLongT::bytes_per_atom(const int max_nbors) const { return this->bytes_per_atom_atomic(max_nbors); @@ -45,8 +45,8 @@ int BuckCoulLongT::bytes_per_atom(const int max_nbors) const { template int BuckCoulLongT::init(const int ntypes, double **host_cutsq, - double **host_rhoinv, double **host_buck1, double **host_buck2, - double **host_a, double **host_c, double **host_offset, + double **host_rhoinv, double **host_buck1, double **host_buck2, + double **host_a, double **host_c, double **host_offset, double *host_special_lj, const int nlocal, const int nall, const int max_nbors, const int maxspecial, const double cell_size, @@ -84,10 +84,10 @@ int BuckCoulLongT::init(const int ntypes, double **host_cutsq, coeff2.alloc(lj_types*lj_types,*(this->ucl_device),UCL_READ_ONLY); this->atom->type_pack4(ntypes,lj_types,coeff2,host_write,host_a,host_c, host_offset); - + cutsq.alloc(lj_types*lj_types,*(this->ucl_device),UCL_READ_ONLY); this->atom->type_pack1(ntypes,lj_types,cutsq,host_write,host_cutsq); - + sp_lj.alloc(8,*(this->ucl_device),UCL_READ_ONLY); for (int i=0; i<4; i++) { host_write[i]=host_special_lj[i]; @@ -139,7 +139,7 @@ void BuckCoulLongT::loop(const bool _eflag, const bool _vflag) { vflag=1; else vflag=0; - + int GX=static_cast(ceil(static_cast(this->ans->inum())/ (BX/this->_threads_per_atom))); @@ -150,16 +150,16 @@ void BuckCoulLongT::loop(const bool _eflag, const bool _vflag) { this->k_pair_fast.set_size(GX,BX); this->k_pair_fast.run(&this->atom->x, &coeff1, &coeff2, &sp_lj, &this->nbor->dev_nbor, &this->_nbor_data->begin(), - &this->ans->force, &this->ans->engv, &eflag, + &this->ans->force, &this->ans->engv, &eflag, &vflag, &ainum, &nbor_pitch, &this->atom->q, - &cutsq, &_cut_coulsq, &_qqrd2e, + &cutsq, &_cut_coulsq, &_qqrd2e, &_g_ewald, &this->_threads_per_atom); } else { this->k_pair.set_size(GX,BX); - this->k_pair.run(&this->atom->x, &coeff1, &coeff2, &_lj_types, &sp_lj, - &this->nbor->dev_nbor, &this->_nbor_data->begin(), + this->k_pair.run(&this->atom->x, &coeff1, &coeff2, &_lj_types, &sp_lj, + &this->nbor->dev_nbor, &this->_nbor_data->begin(), &this->ans->force, &this->ans->engv, &eflag, &vflag, - &ainum, &nbor_pitch, &this->atom->q, &cutsq, + &ainum, &nbor_pitch, &this->atom->q, &cutsq, &_cut_coulsq, &_qqrd2e, &_g_ewald, &this->_threads_per_atom); } this->time_pair.stop(); diff --git a/lib/gpu/lal_buck_coul_long.cu b/lib/gpu/lal_buck_coul_long.cu index fc68d12471..da3237a31f 100644 --- a/lib/gpu/lal_buck_coul_long.cu +++ b/lib/gpu/lal_buck_coul_long.cu @@ -9,7 +9,7 @@ // This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) // __________________________________________________________________________ // -// begin : +// begin : // email : nguyentd@ornl.gov // ***************************************************************************/ @@ -29,19 +29,19 @@ texture q_tex; #define q_tex q_ #endif -__kernel void k_buck_coul_long(const __global numtyp4 *restrict x_, +__kernel void k_buck_coul_long(const __global numtyp4 *restrict x_, const __global numtyp4 *restrict coeff1, - const __global numtyp4 *restrict coeff2, - const int lj_types, - const __global numtyp *restrict sp_lj_in, - const __global int *dev_nbor, - const __global int *dev_packed, + const __global numtyp4 *restrict coeff2, + const int lj_types, + const __global numtyp *restrict sp_lj_in, + const __global int *dev_nbor, + const __global int *dev_packed, __global acctyp4 *restrict ans, - __global acctyp *restrict engv, + __global acctyp *restrict engv, const int eflag, const int vflag, const int inum, - const int nbor_pitch, + const int nbor_pitch, const __global numtyp *restrict q_, - const __global numtyp *restrict cutsq, + const __global numtyp *restrict cutsq, const numtyp cut_coulsq, const numtyp qqrd2e, const numtyp g_ewald, const int t_per_atom) { int tid, ii, offset; @@ -64,14 +64,14 @@ __kernel void k_buck_coul_long(const __global numtyp4 *restrict x_, acctyp virial[6]; for (int i=0; i<6; i++) virial[i]=(acctyp)0; - + if (ii0) { - if (rsq < cut_coulsq) - e_coul += prefactor*(_erfc-factor_coul); - if (rsq < coeff1[mtype].w) { - numtyp e=coeff2[mtype].x*rexp - coeff2[mtype].y*r6inv; - energy+=factor_lj*(e-coeff2[mtype].z); - } - } - if (vflag>0) { - virial[0] += delx*delx*force; - virial[1] += dely*dely*force; - virial[2] += delz*delz*force; - virial[3] += delx*dely*force; - virial[4] += delx*delz*force; - virial[5] += dely*delz*force; - } - } - - } // for nbor - store_answers_q(f,energy,e_coul,virial,ii,inum,tid,t_per_atom,offset,eflag, - vflag,ans,engv); - } // if ii -} - -__kernel void k_buck_coul_long_fast(const __global numtyp4 *restrict x_, - const __global numtyp4 *restrict coeff1_in, - const __global numtyp4 *restrict coeff2_in, - const __global numtyp *restrict sp_lj_in, - const __global int *dev_nbor, - const __global int *dev_packed, - __global acctyp4 *restrict ans, - __global acctyp *restrict engv, - const int eflag, const int vflag, - const int inum, const int nbor_pitch, - const __global numtyp *restrict q_, - const __global numtyp *restrict cutsq, - const numtyp cut_coulsq, - const numtyp qqrd2e, const numtyp g_ewald, - const int t_per_atom) { - int tid, ii, offset; - atom_info(t_per_atom,ii,tid,offset); - - __local numtyp4 coeff1[MAX_SHARED_TYPES*MAX_SHARED_TYPES]; - __local numtyp4 coeff2[MAX_SHARED_TYPES*MAX_SHARED_TYPES]; - __local numtyp sp_lj[8]; - if (tid<8) - sp_lj[tid]=sp_lj_in[tid]; - if (tid0) - coeff2[tid]=coeff2_in[tid]; - } - - acctyp energy=(acctyp)0; - acctyp e_coul=(acctyp)0; - acctyp4 f; - f.x=(acctyp)0; f.y=(acctyp)0; f.z=(acctyp)0; - acctyp virial[6]; - for (int i=0; i<6; i++) - virial[i]=(acctyp)0; - - __syncthreads(); - - if (ii0) { + if (rsq < cut_coulsq) + e_coul += prefactor*(_erfc-factor_coul); + if (rsq < coeff1[mtype].w) { + numtyp e=coeff2[mtype].x*rexp - coeff2[mtype].y*r6inv; + energy+=factor_lj*(e-coeff2[mtype].z); + } + } + if (vflag>0) { + virial[0] += delx*delx*force; + virial[1] += dely*dely*force; + virial[2] += delz*delz*force; + virial[3] += delx*dely*force; + virial[4] += delx*delz*force; + virial[5] += dely*delz*force; + } + } + + } // for nbor + store_answers_q(f,energy,e_coul,virial,ii,inum,tid,t_per_atom,offset,eflag, + vflag,ans,engv); + } // if ii +} + +__kernel void k_buck_coul_long_fast(const __global numtyp4 *restrict x_, + const __global numtyp4 *restrict coeff1_in, + const __global numtyp4 *restrict coeff2_in, + const __global numtyp *restrict sp_lj_in, + const __global int *dev_nbor, + const __global int *dev_packed, + __global acctyp4 *restrict ans, + __global acctyp *restrict engv, + const int eflag, const int vflag, + const int inum, const int nbor_pitch, + const __global numtyp *restrict q_, + const __global numtyp *restrict cutsq, + const numtyp cut_coulsq, + const numtyp qqrd2e, const numtyp g_ewald, + const int t_per_atom) { + int tid, ii, offset; + atom_info(t_per_atom,ii,tid,offset); + + __local numtyp4 coeff1[MAX_SHARED_TYPES*MAX_SHARED_TYPES]; + __local numtyp4 coeff2[MAX_SHARED_TYPES*MAX_SHARED_TYPES]; + __local numtyp sp_lj[8]; + if (tid<8) + sp_lj[tid]=sp_lj_in[tid]; + if (tid0) + coeff2[tid]=coeff2_in[tid]; + } + + acctyp energy=(acctyp)0; + acctyp e_coul=(acctyp)0; + acctyp4 f; + f.x=(acctyp)0; f.y=(acctyp)0; f.z=(acctyp)0; + acctyp virial[6]; + for (int i=0; i<6; i++) + virial[i]=(acctyp)0; + + __syncthreads(); + + if (ii { /** \param max_nbors initial number of rows in the neighbor matrix * \param cell_size cutoff + skin * \param gpu_split fraction of particles handled by device - * + * * Returns: * - 0 if successfull * - -1 if fix gpu not found @@ -38,11 +38,11 @@ class BuckCoulLong : public BaseCharge { * - -4 if the GPU library was not compiled for GPU * - -5 Double precision is not supported on card **/ int init(const int ntypes, double **host_cutsq, - double **host_rhoinv, double **host_buck1, double **host_buck2, - double **host_a, double **host_c, + double **host_rhoinv, double **host_buck1, double **host_buck2, + double **host_a, double **host_c, double **host_offset, double *host_special_lj, - const int nlocal, const int nall, const int max_nbors, - const int maxspecial, const double cell_size, + const int nlocal, const int nall, const int max_nbors, + const int maxspecial, const double cell_size, const double gpu_split, FILE *screen, double **host_cut_ljsq, const double host_cut_coulsq, double *host_special_coul, const double qqrd2e, const double g_ewald); @@ -71,7 +71,7 @@ class BuckCoulLong : public BaseCharge { /// If atom type constants fit in shared memory, use fast kernels bool shared_types; - /// Number of atom types + /// Number of atom types int _lj_types; numtyp _cut_coulsq, _qqrd2e, _g_ewald; diff --git a/lib/gpu/lal_buck_coul_long_ext.cpp b/lib/gpu/lal_buck_coul_long_ext.cpp index 9c0c331ee1..51e0d233d3 100644 --- a/lib/gpu/lal_buck_coul_long_ext.cpp +++ b/lib/gpu/lal_buck_coul_long_ext.cpp @@ -9,7 +9,7 @@ This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) __________________________________________________________________________ - begin : + begin : email : nguyentd@ornl.gov ***************************************************************************/ @@ -28,7 +28,7 @@ static BuckCoulLong BUCKCLMF; // Allocate memory on host and device and copy constants to device // --------------------------------------------------------------------------- int buckcl_gpu_init(const int ntypes, double **cutsq, double **host_rhoinv, - double **host_buck1, double **host_buck2, + double **host_buck1, double **host_buck2, double **host_a, double **host_c, double **offset, double *special_lj, const int inum, const int nall, const int max_nbors, const int maxspecial, @@ -58,8 +58,8 @@ int buckcl_gpu_init(const int ntypes, double **cutsq, double **host_rhoinv, int init_ok=0; if (world_me==0) - init_ok=BUCKCLMF.init(ntypes, cutsq, host_rhoinv, host_buck1, host_buck2, - host_a, host_c, offset, special_lj, inum, nall, 300, + init_ok=BUCKCLMF.init(ntypes, cutsq, host_rhoinv, host_buck1, host_buck2, + host_a, host_c, offset, special_lj, inum, nall, 300, maxspecial, cell_size, gpu_split, screen, host_cut_ljsq, host_cut_coulsq, host_special_coul, qqrd2e, g_ewald); @@ -77,13 +77,13 @@ int buckcl_gpu_init(const int ntypes, double **cutsq, double **host_rhoinv, fflush(screen); } if (gpu_rank==i && world_me!=0) - init_ok=BUCKCLMF.init(ntypes, cutsq, host_rhoinv, host_buck1, host_buck2, - host_a, host_c, offset, special_lj, inum, nall, 300, + init_ok=BUCKCLMF.init(ntypes, cutsq, host_rhoinv, host_buck1, host_buck2, + host_a, host_c, offset, special_lj, inum, nall, 300, maxspecial, cell_size, gpu_split, screen, host_cut_ljsq, host_cut_coulsq, host_special_coul, qqrd2e, g_ewald); BUCKCLMF.device->gpu_barrier(); - if (message) + if (message) fprintf(screen,"Done.\n"); } if (message) @@ -100,7 +100,7 @@ void buckcl_gpu_clear() { int** buckcl_gpu_compute_n(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, - double *sublo, double *subhi, tagint *tag, int **nspecial, + double *sublo, double *subhi, tagint *tag, int **nspecial, tagint **special, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, int **ilist, int **jnum, const double cpu_time, @@ -110,7 +110,7 @@ int** buckcl_gpu_compute_n(const int ago, const int inum_full, subhi, tag, nspecial, special, eflag, vflag, eatom, vatom, host_start, ilist, jnum, cpu_time, success, host_q, boxlo, prd); -} +} void buckcl_gpu_compute(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, int *ilist, int *numj, diff --git a/lib/gpu/lal_buck_ext.cpp b/lib/gpu/lal_buck_ext.cpp index 75c88e8dbe..36a780426c 100644 --- a/lib/gpu/lal_buck_ext.cpp +++ b/lib/gpu/lal_buck_ext.cpp @@ -9,7 +9,7 @@ This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) __________________________________________________________________________ - begin : + begin : email : nguyentd@ornl.gov ***************************************************************************/ @@ -28,8 +28,8 @@ static Buck BUCKMF; // Allocate memory on host and device and copy constants to device // --------------------------------------------------------------------------- int buck_gpu_init(const int ntypes, double **cutsq, double **host_rhoinv, - double **host_buck1, double **host_buck2, - double **host_a, double **host_c, + double **host_buck1, double **host_buck2, + double **host_a, double **host_c, double **offset, double *special_lj, const int inum, const int nall, const int max_nbors, const int maxspecial, const double cell_size, int &gpu_mode, FILE *screen) { @@ -55,7 +55,7 @@ int buck_gpu_init(const int ntypes, double **cutsq, double **host_rhoinv, int init_ok=0; if (world_me==0) - init_ok=BUCKMF.init(ntypes, cutsq, host_rhoinv, host_buck1, host_buck2, + init_ok=BUCKMF.init(ntypes, cutsq, host_rhoinv, host_buck1, host_buck2, host_a, host_c, offset, special_lj, inum, nall, 300, maxspecial, cell_size, gpu_split, screen); @@ -73,12 +73,12 @@ int buck_gpu_init(const int ntypes, double **cutsq, double **host_rhoinv, fflush(screen); } if (gpu_rank==i && world_me!=0) - init_ok=BUCKMF.init(ntypes, cutsq, host_rhoinv, host_buck1, host_buck2, + init_ok=BUCKMF.init(ntypes, cutsq, host_rhoinv, host_buck1, host_buck2, host_a, host_c, offset, special_lj, inum, nall, 300, maxspecial, cell_size, gpu_split, screen); BUCKMF.device->gpu_barrier(); - if (message) + if (message) fprintf(screen,"Done.\n"); } if (message) @@ -98,24 +98,24 @@ void buck_gpu_reinit(const int ntypes, double **cutsq, double **host_rhoinv, int world_me=BUCKMF.device->world_me(); int gpu_rank=BUCKMF.device->gpu_rank(); int procs_per_gpu=BUCKMF.device->procs_per_gpu(); - + if (world_me==0) BUCKMF.reinit(ntypes, cutsq, host_rhoinv, host_buck1, host_buck2, host_a, host_c, offset); - + BUCKMF.device->world_barrier(); for (int i=0; igpu_barrier(); } } void buck_gpu_clear() { - BUCKMF.clear(); + BUCKMF.clear(); } int ** buck_gpu_compute_n(const int ago, const int inum_full, @@ -128,7 +128,7 @@ int ** buck_gpu_compute_n(const int ago, const int inum_full, return BUCKMF.compute(ago, inum_full, nall, host_x, host_type, sublo, subhi, tag, nspecial, special, eflag, vflag, eatom, vatom, host_start, ilist, jnum, cpu_time, success); -} +} void buck_gpu_compute(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, int *ilist, int *numj, diff --git a/lib/gpu/lal_cg_cmm.cpp b/lib/gpu/lal_cg_cmm.cpp index 96455888f0..11974e05e0 100644 --- a/lib/gpu/lal_cg_cmm.cpp +++ b/lib/gpu/lal_cg_cmm.cpp @@ -9,7 +9,7 @@ This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) __________________________________________________________________________ - begin : + begin : email : brownw@ornl.gov ***************************************************************************/ @@ -33,23 +33,23 @@ CGCMMT::CGCMM() : BaseAtomic(), _allocated(false) { } template -CGCMMT::~CGCMM() { +CGCMMT::~CGCMM() { clear(); } - + template int CGCMMT::bytes_per_atom(const int max_nbors) const { return this->bytes_per_atom_atomic(max_nbors); } template -int CGCMMT::init(const int ntypes, double **host_cutsq, - int **host_cg_type, double **host_lj1, - double **host_lj2, double **host_lj3, - double **host_lj4, double **host_offset, +int CGCMMT::init(const int ntypes, double **host_cutsq, + int **host_cg_type, double **host_lj1, + double **host_lj2, double **host_lj3, + double **host_lj4, double **host_offset, double *host_special_lj, const int nlocal, const int nall, const int max_nbors, - const int maxspecial, const double cell_size, + const int maxspecial, const double cell_size, const double gpu_split, FILE *_screen) { int success; success=this->init_atomic(nlocal,nall,max_nbors,maxspecial,cell_size,gpu_split, @@ -75,7 +75,7 @@ int CGCMMT::init(const int ntypes, double **host_cutsq, host_write[i]=0.0; lj1.alloc(cmm_types*cmm_types,*(this->ucl_device),UCL_READ_ONLY); - this->atom->type_pack4(ntypes,cmm_types,lj1,host_write,host_cutsq, + this->atom->type_pack4(ntypes,cmm_types,lj1,host_write,host_cutsq, host_cg_type,host_lj1,host_lj2); lj3.alloc(cmm_types*cmm_types,*(this->ucl_device),UCL_READ_ONLY); @@ -126,7 +126,7 @@ void CGCMMT::loop(const bool _eflag, const bool _vflag) { vflag=1; else vflag=0; - + int GX=static_cast(ceil(static_cast(this->ans->inum())/ (BX/this->_threads_per_atom))); @@ -138,7 +138,7 @@ void CGCMMT::loop(const bool _eflag, const bool _vflag) { this->k_pair_fast.run(&this->atom->x, &lj1, &lj3, &sp_lj, &this->nbor->dev_nbor, &this->_nbor_data->begin(), &this->ans->force, &this->ans->engv, &eflag, - &vflag, &ainum, &nbor_pitch, + &vflag, &ainum, &nbor_pitch, &this->_threads_per_atom); } else { this->k_pair.set_size(GX,BX); diff --git a/lib/gpu/lal_cg_cmm.cu b/lib/gpu/lal_cg_cmm.cu index 8f89f74d22..70d2ab6092 100644 --- a/lib/gpu/lal_cg_cmm.cu +++ b/lib/gpu/lal_cg_cmm.cu @@ -9,7 +9,7 @@ // This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) // __________________________________________________________________________ // -// begin : +// begin : // email : brownw@ornl.gov // ***************************************************************************/ @@ -24,15 +24,15 @@ texture pos_tex; #define pos_tex x_ #endif -__kernel void k_cg_cmm(const __global numtyp4 *restrict x_, +__kernel void k_cg_cmm(const __global numtyp4 *restrict x_, const __global numtyp4 *restrict lj1, - const __global numtyp4 *restrict lj3, - const int lj_types, + const __global numtyp4 *restrict lj3, + const int lj_types, const __global numtyp *restrict sp_lj_in, - const __global int *dev_nbor, + const __global int *dev_nbor, const __global int *dev_packed, __global acctyp4 *restrict ans, - __global acctyp *restrict engv, + __global acctyp *restrict engv, const int eflag, const int vflag, const int inum, const int nbor_pitch, const int t_per_atom) { int tid, ii, offset; @@ -50,20 +50,20 @@ __kernel void k_cg_cmm(const __global numtyp4 *restrict x_, acctyp virial[6]; for (int i=0; i<6; i++) virial[i]=(acctyp)0; - + if (ii0) lj3[tid]=lj3_in[tid]; } - + acctyp energy=(acctyp)0; acctyp4 f; f.x=(acctyp)0; f.y=(acctyp)0; f.z=(acctyp)0; acctyp virial[6]; for (int i=0; i<6; i++) virial[i]=(acctyp)0; - + __syncthreads(); - + if (ii class CGCMM : public BaseAtomic { public: CGCMM(); - ~CGCMM(); + ~CGCMM(); /// Clear any previous data and set up for a new LAMMPS run /** \param max_nbors initial number of rows in the neighbor matrix * \param cell_size cutoff + skin * \param gpu_split fraction of particles handled by device - * + * * Returns: * - 0 if successfull * - -1 if fix gpu not found @@ -40,7 +40,7 @@ class CGCMM : public BaseAtomic { int init(const int ntypes, double **host_cutsq, int **host_cg_type, double **host_lj1, double **host_lj2, double **host_lj3, double **host_lj4, double **host_offset, double *host_special_lj, - const int nlocal, const int nall, const int max_nbors, + const int nlocal, const int nall, const int max_nbors, const int maxspecial, const double cell_size, const double gpu_split, FILE *screen); @@ -66,7 +66,7 @@ class CGCMM : public BaseAtomic { /// If atom type constants fit in shared memory, use fast kernels bool shared_types; - /// Number of atom types + /// Number of atom types int _cmm_types; private: diff --git a/lib/gpu/lal_cg_cmm_ext.cpp b/lib/gpu/lal_cg_cmm_ext.cpp index 0d2c3d8fbf..2a00271736 100644 --- a/lib/gpu/lal_cg_cmm_ext.cpp +++ b/lib/gpu/lal_cg_cmm_ext.cpp @@ -9,7 +9,7 @@ This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) __________________________________________________________________________ - begin : + begin : email : brownw@ornl.gov ***************************************************************************/ @@ -28,9 +28,9 @@ static CGCMM CMMMF; // Allocate memory on host and device and copy constants to device // --------------------------------------------------------------------------- int cmm_gpu_init(const int ntypes, double **cutsq, int **cg_types, - double **host_lj1, double **host_lj2, double **host_lj3, + double **host_lj1, double **host_lj2, double **host_lj3, double **host_lj4, double **offset, double *special_lj, - const int inum, const int nall, const int max_nbors, + const int inum, const int nall, const int max_nbors, const int maxspecial, const double cell_size, int &gpu_mode, FILE *screen) { CMMMF.clear(); @@ -55,7 +55,7 @@ int cmm_gpu_init(const int ntypes, double **cutsq, int **cg_types, int init_ok=0; if (world_me==0) - init_ok=CMMMF.init(ntypes,cutsq,cg_types,host_lj1,host_lj2,host_lj3, + init_ok=CMMMF.init(ntypes,cutsq,cg_types,host_lj1,host_lj2,host_lj3, host_lj4, offset, special_lj, inum, nall, 300, maxspecial, cell_size, gpu_split, screen); @@ -78,7 +78,7 @@ int cmm_gpu_init(const int ntypes, double **cutsq, int **cg_types, maxspecial, cell_size, gpu_split, screen); CMMMF.device->gpu_barrier(); - if (message) + if (message) fprintf(screen,"Done.\n"); } if (message) @@ -103,7 +103,7 @@ int** cmm_gpu_compute_n(const int ago, const int inum_full, return CMMMF.compute(ago, inum_full, nall, host_x, host_type, sublo, subhi, tag, nspecial, special, eflag, vflag, eatom, vatom, host_start, ilist, jnum, cpu_time, success); -} +} void cmm_gpu_compute(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, int *ilist, int *numj, diff --git a/lib/gpu/lal_cg_cmm_long.cpp b/lib/gpu/lal_cg_cmm_long.cpp index 92e6bd04b5..14b5b7622c 100644 --- a/lib/gpu/lal_cg_cmm_long.cpp +++ b/lib/gpu/lal_cg_cmm_long.cpp @@ -9,7 +9,7 @@ This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) __________________________________________________________________________ - begin : + begin : email : brownw@ornl.gov ***************************************************************************/ @@ -37,22 +37,22 @@ template CGCMMLongT::~CGCMMLong() { clear(); } - + template int CGCMMLongT::bytes_per_atom(const int max_nbors) const { return this->bytes_per_atom_atomic(max_nbors); } template -int CGCMMLongT::init(const int ntypes, double **host_cutsq, - int **host_cg_type, double **host_lj1, - double **host_lj2, double **host_lj3, - double **host_lj4, double **host_offset, +int CGCMMLongT::init(const int ntypes, double **host_cutsq, + int **host_cg_type, double **host_lj1, + double **host_lj2, double **host_lj3, + double **host_lj4, double **host_offset, double *host_special_lj, const int nlocal, const int nall, const int max_nbors, const int maxspecial, const double cell_size, const double gpu_split, FILE *_screen, - double **host_cut_ljsq, + double **host_cut_ljsq, const double host_cut_coulsq, double *host_special_coul, const double qqrd2e, const double g_ewald) { @@ -137,7 +137,7 @@ void CGCMMLongT::loop(const bool _eflag, const bool _vflag) { vflag=1; else vflag=0; - + int GX=static_cast(ceil(static_cast(this->ans->inum())/ (BX/this->_threads_per_atom))); @@ -149,13 +149,13 @@ void CGCMMLongT::loop(const bool _eflag, const bool _vflag) { this->k_pair_fast.run(&this->atom->x, &lj1, &lj3, &sp_lj, &this->nbor->dev_nbor, &this->_nbor_data->begin(), &this->ans->force, &this->ans->engv, &eflag, - &vflag, &ainum, &nbor_pitch, &this->atom->q, - &_cut_coulsq, &_qqrd2e, &_g_ewald, + &vflag, &ainum, &nbor_pitch, &this->atom->q, + &_cut_coulsq, &_qqrd2e, &_g_ewald, &this->_threads_per_atom); } else { this->k_pair.set_size(GX,BX); - this->k_pair.run(&this->atom->x, &lj1, &lj3, &_lj_types, &sp_lj, - &this->nbor->dev_nbor, &this->_nbor_data->begin(), + this->k_pair.run(&this->atom->x, &lj1, &lj3, &_lj_types, &sp_lj, + &this->nbor->dev_nbor, &this->_nbor_data->begin(), &this->ans->force, &this->ans->engv, &eflag, &vflag, &ainum, &nbor_pitch, &this->atom->q, &_cut_coulsq, &_qqrd2e, &_g_ewald, &this->_threads_per_atom); diff --git a/lib/gpu/lal_cg_cmm_long.cu b/lib/gpu/lal_cg_cmm_long.cu index ae8b6cda47..f6942d1809 100644 --- a/lib/gpu/lal_cg_cmm_long.cu +++ b/lib/gpu/lal_cg_cmm_long.cu @@ -9,7 +9,7 @@ // This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) // __________________________________________________________________________ // -// begin : +// begin : // email : brownw@ornl.gov // ***************************************************************************/ @@ -29,12 +29,12 @@ texture q_tex; #define q_tex q_ #endif -__kernel void k_cg_cmm_long(const __global numtyp4 *restrict x_, +__kernel void k_cg_cmm_long(const __global numtyp4 *restrict x_, const __global numtyp4 *restrict lj1, - const __global numtyp4 *restrict lj3, - const int lj_types, + const __global numtyp4 *restrict lj3, + const int lj_types, const __global numtyp *restrict sp_lj_in, - const __global int *dev_nbor, + const __global int *dev_nbor, const __global int *dev_packed, __global acctyp4 *restrict ans, __global acctyp *restrict engv, @@ -70,7 +70,7 @@ __kernel void k_cg_cmm_long(const __global numtyp4 *restrict x_, __local int n_stride; nbor_info(dev_nbor,dev_packed,nbor_pitch,t_per_atom,ii,offset,i,numj, n_stride,nbor_end,nbor); - + numtyp4 ix; fetch4(ix,i,pos_tex); //x_[i]; numtyp qtmp; fetch(qtmp,i,q_tex); int itype=ix.w; @@ -136,7 +136,7 @@ __kernel void k_cg_cmm_long(const __global numtyp4 *restrict x_, if (rsq < lj1[mtype].y) { energy += factor_lj*inv1*(lj3[mtype].y*inv2-lj3[mtype].z)- lj3[mtype].w; - } + } } if (vflag>0) { virial[0] += delx*delx*force; @@ -154,17 +154,17 @@ __kernel void k_cg_cmm_long(const __global numtyp4 *restrict x_, } // if ii } -__kernel void k_cg_cmm_long_fast(const __global numtyp4 *restrict x_, +__kernel void k_cg_cmm_long_fast(const __global numtyp4 *restrict x_, const __global numtyp4 *restrict lj1_in, - const __global numtyp4 *restrict lj3_in, - const __global numtyp *restrict sp_lj_in, - const __global int *dev_nbor, + const __global numtyp4 *restrict lj3_in, + const __global numtyp *restrict sp_lj_in, + const __global int *dev_nbor, const __global int *dev_packed, __global acctyp4 *restrict ans, - __global acctyp *restrict engv, - const int eflag, const int vflag, + __global acctyp *restrict engv, + const int eflag, const int vflag, const int inum, const int nbor_pitch, - const __global numtyp *restrict q_, + const __global numtyp *restrict q_, const numtyp cut_coulsq, const numtyp qqrd2e, const numtyp g_ewald, const int t_per_atom) { int tid, ii, offset; @@ -179,7 +179,7 @@ __kernel void k_cg_cmm_long_fast(const __global numtyp4 *restrict x_, lj1[tid]=lj1_in[tid]; lj3[tid]=lj3_in[tid]; } - + acctyp energy=(acctyp)0; acctyp e_coul=(acctyp)0; acctyp4 f; @@ -187,16 +187,16 @@ __kernel void k_cg_cmm_long_fast(const __global numtyp4 *restrict x_, acctyp virial[6]; for (int i=0; i<6; i++) virial[i]=(acctyp)0; - + __syncthreads(); - + if (ii0) { virial[0] += delx*delx*force; diff --git a/lib/gpu/lal_cg_cmm_long.h b/lib/gpu/lal_cg_cmm_long.h index bde5c79c74..aa0cbfbaf0 100644 --- a/lib/gpu/lal_cg_cmm_long.h +++ b/lib/gpu/lal_cg_cmm_long.h @@ -9,7 +9,7 @@ This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) __________________________________________________________________________ - begin : + begin : email : brownw@ornl.gov ***************************************************************************/ @@ -30,7 +30,7 @@ class CGCMMLong : public BaseCharge { /** \param max_nbors initial number of rows in the neighbor matrix * \param cell_size cutoff + skin * \param gpu_split fraction of particles handled by device - * + * * Returns: * - 0 if successfull * - -1 if fix gpu not found @@ -40,8 +40,8 @@ class CGCMMLong : public BaseCharge { int init(const int ntypes, double **host_cutsq, int ** cg_type, double **host_lj1, double **host_lj2, double **host_lj3, double **host_lj4, double **host_offset, double *host_special_lj, - const int nlocal, const int nall, const int max_nbors, - const int maxspecial, const double cell_size, + const int nlocal, const int nall, const int max_nbors, + const int maxspecial, const double cell_size, const double gpu_split, FILE *screen, double **host_cut_ljsq, const double host_cut_coulsq, double *host_special_coul, const double qqrd2e, const double g_ewald); @@ -58,7 +58,7 @@ class CGCMMLong : public BaseCharge { // --------------------------- TYPE DATA -------------------------- - /// lj1.x = cutsq, lj1.y = cutsq_vdw, lj1.z = lj1, lj1.w = lj2, + /// lj1.x = cutsq, lj1.y = cutsq_vdw, lj1.z = lj1, lj1.w = lj2, UCL_D_Vec lj1; /// lj3.x = cg_type, lj3.y = lj3, lj3.z = lj4, lj3.w = offset UCL_D_Vec lj3; @@ -68,7 +68,7 @@ class CGCMMLong : public BaseCharge { /// If atom type constants fit in shared memory, use fast kernels bool shared_types; - /// Number of atom types + /// Number of atom types int _lj_types; numtyp _cut_coulsq, _qqrd2e, _g_ewald; diff --git a/lib/gpu/lal_cg_cmm_long_ext.cpp b/lib/gpu/lal_cg_cmm_long_ext.cpp index 966588bf9b..2fa3f2aead 100644 --- a/lib/gpu/lal_cg_cmm_long_ext.cpp +++ b/lib/gpu/lal_cg_cmm_long_ext.cpp @@ -9,7 +9,7 @@ This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) __________________________________________________________________________ - begin : + begin : email : brownw@ornl.gov ***************************************************************************/ @@ -28,9 +28,9 @@ static CGCMMLong CMMLMF; // Allocate memory on host and device and copy constants to device // --------------------------------------------------------------------------- int cmml_gpu_init(const int ntypes, double **cutsq, int **cg_type, - double **host_lj1, double **host_lj2, double **host_lj3, + double **host_lj1, double **host_lj2, double **host_lj3, double **host_lj4, double **offset, double *special_lj, - const int inum, const int nall, const int max_nbors, + const int inum, const int nall, const int max_nbors, const int maxspecial, const double cell_size, int &gpu_mode, FILE *screen, double **host_cut_ljsq, double host_cut_coulsq, double *host_special_coul, const double qqrd2e, @@ -58,7 +58,7 @@ int cmml_gpu_init(const int ntypes, double **cutsq, int **cg_type, int init_ok=0; if (world_me==0) init_ok=CMMLMF.init(ntypes, cutsq, cg_type, host_lj1, host_lj2, host_lj3, - host_lj4, offset, special_lj, inum, nall, 300, + host_lj4, offset, special_lj, inum, nall, 300, maxspecial, cell_size, gpu_split, screen, host_cut_ljsq, host_cut_coulsq, host_special_coul, qqrd2e,g_ewald); @@ -82,7 +82,7 @@ int cmml_gpu_init(const int ntypes, double **cutsq, int **cg_type, host_cut_ljsq, host_cut_coulsq, host_special_coul, qqrd2e, g_ewald); CMMLMF.device->gpu_barrier(); - if (message) + if (message) fprintf(screen,"Done.\n"); } if (message) @@ -99,7 +99,7 @@ void cmml_gpu_clear() { int** cmml_gpu_compute_n(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, - double *sublo, double *subhi, tagint *tag, int **nspecial, + double *sublo, double *subhi, tagint *tag, int **nspecial, tagint **special, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, int **ilist, int **jnum, const double cpu_time, @@ -109,7 +109,7 @@ int** cmml_gpu_compute_n(const int ago, const int inum_full, subhi, tag, nspecial, special, eflag, vflag, eatom, vatom, host_start, ilist, jnum, cpu_time, success, host_q,boxlo,prd); -} +} void cmml_gpu_compute(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, int *ilist, int *numj, diff --git a/lib/gpu/lal_charmm_long.cpp b/lib/gpu/lal_charmm_long.cpp index 157072dc22..9cd032b3c6 100644 --- a/lib/gpu/lal_charmm_long.cpp +++ b/lib/gpu/lal_charmm_long.cpp @@ -9,7 +9,7 @@ This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) __________________________________________________________________________ - begin : + begin : email : brownw@ornl.gov ***************************************************************************/ @@ -37,7 +37,7 @@ template CHARMMLongT::~CHARMMLong() { clear(); } - + template int CHARMMLongT::bytes_per_atom(const int max_nbors) const { return this->bytes_per_atom_atomic(max_nbors); @@ -45,9 +45,9 @@ int CHARMMLongT::bytes_per_atom(const int max_nbors) const { template int CHARMMLongT::init(const int ntypes, - double host_cut_bothsq, double **host_lj1, - double **host_lj2, double **host_lj3, - double **host_lj4, double **host_offset, + double host_cut_bothsq, double **host_lj1, + double **host_lj2, double **host_lj3, + double **host_lj4, double **host_offset, double *host_special_lj, const int nlocal, const int nall, const int max_nbors, const int maxspecial, const double cell_size, @@ -144,7 +144,7 @@ void CHARMMLongT::loop(const bool _eflag, const bool _vflag) { vflag=1; else vflag=0; - + int GX=static_cast(ceil(static_cast(this->ans->inum())/ (BX/this->_threads_per_atom))); @@ -153,17 +153,17 @@ void CHARMMLongT::loop(const bool _eflag, const bool _vflag) { this->time_pair.start(); if (shared_types) { this->k_pair_fast.set_size(GX,BX); - this->k_pair_fast.run(&this->atom->x, &ljd, &sp_lj, + this->k_pair_fast.run(&this->atom->x, &ljd, &sp_lj, &this->nbor->dev_nbor, &this->_nbor_data->begin(), &this->ans->force, &this->ans->engv, &eflag, &vflag, &ainum, &nbor_pitch, &this->atom->q, &_cut_coulsq, &_qqrd2e, &_g_ewald, &_denom_lj, - &_cut_bothsq, &_cut_ljsq, &_cut_lj_innersq, + &_cut_bothsq, &_cut_ljsq, &_cut_lj_innersq, &this->_threads_per_atom); } else { this->k_pair.set_size(GX,BX); - this->k_pair.run(&this->atom->x, &lj1, &_lj_types, &sp_lj, - &this->nbor->dev_nbor, &this->_nbor_data->begin(), + this->k_pair.run(&this->atom->x, &lj1, &_lj_types, &sp_lj, + &this->nbor->dev_nbor, &this->_nbor_data->begin(), &this->ans->force, &this->ans->engv, &eflag, &vflag, &ainum, &nbor_pitch, &this->atom->q, &_cut_coulsq, &_qqrd2e, &_g_ewald, &_denom_lj, diff --git a/lib/gpu/lal_charmm_long.cu b/lib/gpu/lal_charmm_long.cu index dde50da300..244131f833 100644 --- a/lib/gpu/lal_charmm_long.cu +++ b/lib/gpu/lal_charmm_long.cu @@ -9,7 +9,7 @@ // This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) // __________________________________________________________________________ // -// begin : +// begin : // email : brownw@ornl.gov // ***************************************************************************/ @@ -31,14 +31,14 @@ texture q_tex; __kernel void k_charmm_long(const __global numtyp4 *restrict x_, const __global numtyp4 *restrict lj1, - const int lj_types, + const int lj_types, const __global numtyp *restrict sp_lj, const __global int *dev_nbor, const __global int *dev_packed, __global acctyp4 *restrict ans, - __global acctyp *restrict engv, - const int eflag, const int vflag, const int inum, - const int nbor_pitch, + __global acctyp *restrict engv, + const int eflag, const int vflag, const int inum, + const int nbor_pitch, const __global numtyp *restrict q_, const numtyp cut_coulsq, const numtyp qqrd2e, const numtyp g_ewald, const numtyp denom_lj, @@ -61,7 +61,7 @@ __kernel void k_charmm_long(const __global numtyp4 *restrict x_, __local int n_stride; nbor_info(dev_nbor,dev_packed,nbor_pitch,t_per_atom,ii,offset,i,numj, n_stride,nbor_end,nbor); - + numtyp4 ix; fetch4(ix,i,pos_tex); //x_[i]; numtyp qtmp; fetch(qtmp,i,q_tex); int itype=ix.w; @@ -93,7 +93,7 @@ __kernel void k_charmm_long(const __global numtyp4 *restrict x_, force_lj = factor_lj*r6inv*(lj1[mtype].x*r6inv-lj1[mtype].y); if (rsq > cut_lj_innersq) { switch1 = (cut_ljsq-rsq); - numtyp switch2 = (numtyp)12.0*rsq*switch1*(rsq-cut_lj_innersq)/ + numtyp switch2 = (numtyp)12.0*rsq*switch1*(rsq-cut_lj_innersq)/ denom_lj; switch1 *= switch1; switch1 *= (cut_ljsq+(numtyp)2.0*rsq-(numtyp)3.0*cut_lj_innersq)/ @@ -130,7 +130,7 @@ __kernel void k_charmm_long(const __global numtyp4 *restrict x_, if (rsq > cut_lj_innersq) e *= switch1; energy+=factor_lj*e; - } + } } if (vflag>0) { virial[0] += delx*delx*force; @@ -148,19 +148,19 @@ __kernel void k_charmm_long(const __global numtyp4 *restrict x_, } // if ii } -__kernel void k_charmm_long_fast(const __global numtyp4 *restrict x_, +__kernel void k_charmm_long_fast(const __global numtyp4 *restrict x_, const __global numtyp2 *restrict ljd_in, - const __global numtyp *restrict sp_lj_in, - const __global int *dev_nbor, - const __global int *dev_packed, + const __global numtyp *restrict sp_lj_in, + const __global int *dev_nbor, + const __global int *dev_packed, __global acctyp4 *restrict ans, - __global acctyp *restrict engv, - const int eflag, const int vflag, - const int inum, const int nbor_pitch, + __global acctyp *restrict engv, + const int eflag, const int vflag, + const int inum, const int nbor_pitch, const __global numtyp *restrict q_, const numtyp cut_coulsq, const numtyp qqrd2e, const numtyp g_ewald, const numtyp denom_lj, - const numtyp cut_bothsq, const numtyp cut_ljsq, + const numtyp cut_bothsq, const numtyp cut_ljsq, const numtyp cut_lj_innersq, const int t_per_atom) { int tid, ii, offset; @@ -174,7 +174,7 @@ __kernel void k_charmm_long_fast(const __global numtyp4 *restrict x_, ljd[tid]=ljd_in[tid]; if (tid+BLOCK_BIO_PAIR cut_lj_innersq) { switch1 = (cut_ljsq-rsq); - numtyp switch2 = (numtyp)12.0*rsq*switch1*(rsq-cut_lj_innersq)/ + numtyp switch2 = (numtyp)12.0*rsq*switch1*(rsq-cut_lj_innersq)/ denom_lj; switch1 *= switch1; switch1 *= (cut_ljsq+(numtyp)2.0*rsq-(numtyp)3.0*cut_lj_innersq)/ diff --git a/lib/gpu/lal_charmm_long.h b/lib/gpu/lal_charmm_long.h index 201a5c3694..011083db13 100644 --- a/lib/gpu/lal_charmm_long.h +++ b/lib/gpu/lal_charmm_long.h @@ -9,7 +9,7 @@ This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) __________________________________________________________________________ - begin : + begin : email : brownw@ornl.gov ***************************************************************************/ @@ -30,7 +30,7 @@ class CHARMMLong : public BaseCharge { /** \param max_nbors initial number of rows in the neighbor matrix * \param cell_size cutoff + skin * \param gpu_split fraction of particles handled by device - * + * * Returns: * - 0 if successfull * - -1 if fix gpu not found @@ -40,12 +40,12 @@ class CHARMMLong : public BaseCharge { int init(const int ntypes, double host_cut_bothsq, double **host_lj1, double **host_lj2, double **host_lj3, double **host_lj4, double **host_offset, double *host_special_lj, - const int nlocal, const int nall, const int max_nbors, - const int maxspecial, const double cell_size, + const int nlocal, const int nall, const int max_nbors, + const int maxspecial, const double cell_size, const double gpu_split, FILE *screen, double host_cut_ljsq, const double host_cut_coulsq, double *host_special_coul, const double qqrd2e, const double g_ewald, - const double cut_lj_innersq, const double denom_lj, + const double cut_lj_innersq, const double denom_lj, double **epsilon, double **sigma, const bool mix_arithmetic); /// Clear all host and device data @@ -70,7 +70,7 @@ class CHARMMLong : public BaseCharge { /// If atom type constants fit in shared memory, use fast kernels bool shared_types; - /// Number of atom types + /// Number of atom types int _lj_types; numtyp _qqrd2e, _g_ewald, _denom_lj; diff --git a/lib/gpu/lal_charmm_long_ext.cpp b/lib/gpu/lal_charmm_long_ext.cpp index 807988a3e8..3f7445f306 100644 --- a/lib/gpu/lal_charmm_long_ext.cpp +++ b/lib/gpu/lal_charmm_long_ext.cpp @@ -9,7 +9,7 @@ This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) __________________________________________________________________________ - begin : + begin : email : brownw@ornl.gov ***************************************************************************/ @@ -87,7 +87,7 @@ int crml_gpu_init(const int ntypes, double cut_bothsq, double **host_lj1, sigma, mix_arithmetic); CRMLMF.device->gpu_barrier(); - if (message) + if (message) fprintf(screen,"Done.\n"); } if (message) @@ -104,7 +104,7 @@ void crml_gpu_clear() { int** crml_gpu_compute_n(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, - double *sublo, double *subhi, tagint *tag, int **nspecial, + double *sublo, double *subhi, tagint *tag, int **nspecial, tagint **special, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, int **ilist, int **jnum, const double cpu_time, @@ -114,14 +114,14 @@ int** crml_gpu_compute_n(const int ago, const int inum_full, subhi, tag, nspecial, special, eflag, vflag, eatom, vatom, host_start, ilist, jnum, cpu_time, success, host_q, boxlo, prd); -} +} void crml_gpu_compute(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, int *ilist, int *numj, int **firstneigh, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, const double cpu_time, - bool &success, double *host_q, const int nlocal, + bool &success, double *host_q, const int nlocal, double *boxlo, double *prd) { CRMLMF.compute(ago,inum_full,nall,host_x,host_type,ilist,numj,firstneigh, eflag,vflag,eatom,vatom,host_start,cpu_time,success,host_q, diff --git a/lib/gpu/lal_colloid.cpp b/lib/gpu/lal_colloid.cpp index 28045217d3..fb2b643e5e 100644 --- a/lib/gpu/lal_colloid.cpp +++ b/lib/gpu/lal_colloid.cpp @@ -9,7 +9,7 @@ This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) __________________________________________________________________________ - begin : + begin : email : nguyentd@ornl.gov ***************************************************************************/ @@ -33,23 +33,23 @@ ColloidT::Colloid() : BaseAtomic(), _allocated(false) { } template -ColloidT::~Colloid() { +ColloidT::~Colloid() { clear(); } - + template int ColloidT::bytes_per_atom(const int max_nbors) const { return this->bytes_per_atom_atomic(max_nbors); } template -int ColloidT::init(const int ntypes, - double **host_cutsq, double **host_lj1, - double **host_lj2, double **host_lj3, - double **host_lj4, double **host_offset, - double *host_special_lj, double **host_a12, - double **host_a1, double **host_a2, - double **host_d1, double **host_d2, +int ColloidT::init(const int ntypes, + double **host_cutsq, double **host_lj1, + double **host_lj2, double **host_lj3, + double **host_lj4, double **host_offset, + double *host_special_lj, double **host_a12, + double **host_a1, double **host_a2, + double **host_d1, double **host_d2, double **host_sigma3, double **host_sigma6, int **host_form, const int nlocal, const int nall, const int max_nbors, @@ -97,7 +97,7 @@ int ColloidT::init(const int ntypes, UCL_H_Vec dview_form(lj_types*lj_types,*(this->ucl_device), UCL_WRITE_ONLY); for (int i=0; iucl_device),UCL_READ_ONLY); for (int i=0; i(ceil(static_cast(this->ans->inum())/ (BX/this->_threads_per_atom))); @@ -170,9 +170,9 @@ void ColloidT::loop(const bool _eflag, const bool _vflag) { } else { this->k_pair.set_size(GX,BX); this->k_pair.run(&this->atom->x, &lj1, &lj3, &_lj_types, &sp_lj, - &colloid1, &colloid2, &form, - &this->nbor->dev_nbor, &this->_nbor_data->begin(), - &this->ans->force, &this->ans->engv, &eflag, &vflag, + &colloid1, &colloid2, &form, + &this->nbor->dev_nbor, &this->_nbor_data->begin(), + &this->ans->force, &this->ans->engv, &eflag, &vflag, &ainum, &nbor_pitch, &this->_threads_per_atom); } this->time_pair.stop(); diff --git a/lib/gpu/lal_colloid.cu b/lib/gpu/lal_colloid.cu index a4d6c8bf33..89ba71deef 100644 --- a/lib/gpu/lal_colloid.cu +++ b/lib/gpu/lal_colloid.cu @@ -9,7 +9,7 @@ // This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) // __________________________________________________________________________ // -// begin : +// begin : // email : nguyentd@ornl.gov // ***************************************************************************/ @@ -24,18 +24,18 @@ texture pos_tex; #define pos_tex x_ #endif -__kernel void k_colloid(const __global numtyp4 *restrict x_, +__kernel void k_colloid(const __global numtyp4 *restrict x_, const __global numtyp4 *restrict lj1, - const __global numtyp4 *restrict lj3, - const int lj_types, - const __global numtyp *restrict sp_lj_in, - const __global numtyp4 *restrict colloid1, + const __global numtyp4 *restrict lj3, + const int lj_types, + const __global numtyp *restrict sp_lj_in, + const __global numtyp4 *restrict colloid1, const __global numtyp4 *restrict colloid2, - const __global int *form, - const __global int *dev_nbor, - const __global int *dev_packed, + const __global int *form, + const __global int *dev_nbor, + const __global int *dev_packed, __global acctyp4 *restrict ans, - __global acctyp *restrict engv, + __global acctyp *restrict engv, const int eflag, const int vflag, const int inum, const int nbor_pitch, const int t_per_atom) { int tid, ii, offset; @@ -53,20 +53,20 @@ __kernel void k_colloid(const __global numtyp4 *restrict x_, acctyp virial[6]; for (int i=0; i<6; i++) virial[i]=(acctyp)0; - + if (ii0) { virial[0] += delx*delx*force; @@ -176,22 +176,22 @@ __kernel void k_colloid(const __global numtyp4 *restrict x_, } // if ii } -__kernel void k_colloid_fast(const __global numtyp4 *restrict x_, +__kernel void k_colloid_fast(const __global numtyp4 *restrict x_, const __global numtyp4 *restrict lj1_in, - const __global numtyp4 *restrict lj3_in, + const __global numtyp4 *restrict lj3_in, const __global numtyp *restrict sp_lj_in, - const __global numtyp4 *restrict colloid1_in, + const __global numtyp4 *restrict colloid1_in, const __global numtyp4 *restrict colloid2_in, - const __global int *form_in, - const __global int *dev_nbor, - const __global int *dev_packed, - __global acctyp4 *restrict ans, - __global acctyp *restrict engv, - const int eflag, const int vflag, const int inum, + const __global int *form_in, + const __global int *dev_nbor, + const __global int *dev_packed, + __global acctyp4 *restrict ans, + __global acctyp *restrict engv, + const int eflag, const int vflag, const int inum, const int nbor_pitch, const int t_per_atom) { int tid, ii, offset; atom_info(t_per_atom,ii,tid,offset); - + __local numtyp4 lj1[MAX_SHARED_TYPES*MAX_SHARED_TYPES]; __local numtyp4 lj3[MAX_SHARED_TYPES*MAX_SHARED_TYPES]; __local numtyp4 colloid1[MAX_SHARED_TYPES*MAX_SHARED_TYPES]; @@ -208,7 +208,7 @@ __kernel void k_colloid_fast(const __global numtyp4 *restrict x_, if (eflag>0) lj3[tid]=lj3_in[tid]; } - + acctyp energy=(acctyp)0; acctyp4 f; f.x=(acctyp)0; f.y=(acctyp)0; f.z=(acctyp)0; @@ -217,7 +217,7 @@ __kernel void k_colloid_fast(const __global numtyp4 *restrict x_, virial[i]=(acctyp)0; __syncthreads(); - + if (ii0) { virial[0] += delx*delx*force; diff --git a/lib/gpu/lal_colloid.h b/lib/gpu/lal_colloid.h index 416beabcdf..dfbd4dbadd 100644 --- a/lib/gpu/lal_colloid.h +++ b/lib/gpu/lal_colloid.h @@ -9,7 +9,7 @@ This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) __________________________________________________________________________ - begin : + begin : email : nguyentd@ornl.gov ***************************************************************************/ @@ -24,13 +24,13 @@ template class Colloid : public BaseAtomic { public: Colloid(); - ~Colloid(); + ~Colloid(); /// Clear any previous data and set up for a new LAMMPS run /** \param max_nbors initial number of rows in the neighbor matrix * \param cell_size cutoff + skin * \param gpu_split fraction of particles handled by device - * + * * Returns: * - 0 if successfull * - -1 if fix gpu not found @@ -40,11 +40,11 @@ class Colloid : public BaseAtomic { int init(const int ntypes, double **host_cutsq, double **host_lj1, double **host_lj2, double **host_lj3, double **host_lj4, double **host_offset, double *host_special_lj, - double **host_a12, double **host_a1, double **host_a2, - double **host_d1, double **host_d2, double **host_sigma3, - double **host_sigma6, int **host_form, - const int nlocal, const int nall, const int max_nbors, - const int maxspecial, const double cell_size, + double **host_a12, double **host_a1, double **host_a2, + double **host_d1, double **host_d2, double **host_sigma3, + double **host_sigma6, int **host_form, + const int nlocal, const int nall, const int max_nbors, + const int maxspecial, const double cell_size, const double gpu_split, FILE *screen); /// Clear all host and device data @@ -65,7 +65,7 @@ class Colloid : public BaseAtomic { UCL_D_Vec lj3; /// colloid1.x = a12, colloid1.y = a1, colloid1.z = a2 UCL_D_Vec colloid1; - /// colloid2.x = d1, colloid2.y = d2, colloid2.z = sigma3, + /// colloid2.x = d1, colloid2.y = d2, colloid2.z = sigma3, /// colloid2.w = sigma6 UCL_D_Vec colloid2; /// form @@ -76,7 +76,7 @@ class Colloid : public BaseAtomic { /// If atom type constants fit in shared memory, use fast kernels bool shared_types; - /// Number of atom types + /// Number of atom types int _lj_types; private: diff --git a/lib/gpu/lal_colloid_ext.cpp b/lib/gpu/lal_colloid_ext.cpp index ea83cb6417..f88ced8443 100644 --- a/lib/gpu/lal_colloid_ext.cpp +++ b/lib/gpu/lal_colloid_ext.cpp @@ -9,7 +9,7 @@ This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) __________________________________________________________________________ - begin : + begin : email : nguyentd@ornl.gov ***************************************************************************/ @@ -29,9 +29,9 @@ static Colloid COLLMF; // --------------------------------------------------------------------------- int colloid_gpu_init(const int ntypes, double **cutsq, double **host_lj1, double **host_lj2, double **host_lj3, double **host_lj4, - double **offset, double *special_lj, - double **host_a12, double **host_a1, double **host_a2, - double **host_d1, double **host_d2, double **host_sigma3, + double **offset, double *special_lj, + double **host_a12, double **host_a1, double **host_a2, + double **host_d1, double **host_d2, double **host_sigma3, double **host_sigma6, int **host_form, const int inum, const int nall, const int max_nbors, const int maxspecial, const double cell_size, int &gpu_mode, FILE *screen) { @@ -57,9 +57,9 @@ int colloid_gpu_init(const int ntypes, double **cutsq, double **host_lj1, int init_ok=0; if (world_me==0) - init_ok=COLLMF.init(ntypes, cutsq, host_lj1, host_lj2, host_lj3, + init_ok=COLLMF.init(ntypes, cutsq, host_lj1, host_lj2, host_lj3, host_lj4, offset, special_lj, host_a12, host_a1, - host_a2, host_d1, host_d2, host_sigma3, + host_a2, host_d1, host_d2, host_sigma3, host_sigma6, host_form, inum, nall, 300, maxspecial, cell_size, gpu_split, screen); @@ -78,13 +78,13 @@ int colloid_gpu_init(const int ntypes, double **cutsq, double **host_lj1, } if (gpu_rank==i && world_me!=0) init_ok=COLLMF.init(ntypes, cutsq, host_lj1, host_lj2, host_lj3, host_lj4, - offset, special_lj, host_a12, host_a1, host_a2, - host_d1, host_d2, host_sigma3, host_sigma6, host_form, + offset, special_lj, host_a12, host_a1, host_a2, + host_d1, host_d2, host_sigma3, host_sigma6, host_form, inum, nall, 300, maxspecial, cell_size, gpu_split, screen); COLLMF.device->gpu_barrier(); - if (message) + if (message) fprintf(screen,"Done.\n"); } if (message) @@ -109,7 +109,7 @@ int ** colloid_gpu_compute_n(const int ago, const int inum_full, return COLLMF.compute(ago, inum_full, nall, host_x, host_type, sublo, subhi, tag, nspecial, special, eflag, vflag, eatom, vatom, host_start, ilist, jnum, cpu_time, success); -} +} void colloid_gpu_compute(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, int *ilist, int *numj, diff --git a/lib/gpu/lal_coul.cpp b/lib/gpu/lal_coul.cpp index 53fb3dae82..a06a29e610 100644 --- a/lib/gpu/lal_coul.cpp +++ b/lib/gpu/lal_coul.cpp @@ -9,7 +9,7 @@ This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) __________________________________________________________________________ - begin : + begin : email : ndtrung@umich.edu ***************************************************************************/ @@ -37,7 +37,7 @@ template CoulT::~Coul() { clear(); } - + template int CoulT::bytes_per_atom(const int max_nbors) const { return this->bytes_per_atom_atomic(max_nbors); @@ -75,7 +75,7 @@ int CoulT::init(const int ntypes, double **host_scale, double **host_cutsq, scale.alloc(lj_types*lj_types,*(this->ucl_device),UCL_READ_ONLY); this->atom->type_pack1(ntypes,lj_types,scale,host_write,host_scale); - + cutsq.alloc(lj_types*lj_types,*(this->ucl_device),UCL_READ_ONLY); this->atom->type_pack1(ntypes,lj_types,cutsq,host_write,host_cutsq); @@ -97,10 +97,10 @@ void CoulT::reinit(const int ntypes, double **host_scale) { // Allocate a host write buffer for data initialization UCL_H_Vec host_write(_lj_types*_lj_types*32,*(this->ucl_device), UCL_WRITE_ONLY); - + for (int i=0; i<_lj_types*_lj_types; i++) host_write[i]=0.0; - + this->atom->type_pack1(ntypes,_lj_types,scale,host_write,host_scale); } @@ -138,7 +138,7 @@ void CoulT::loop(const bool _eflag, const bool _vflag) { vflag=1; else vflag=0; - + int GX=static_cast(ceil(static_cast(this->ans->inum())/ (BX/this->_threads_per_atom))); @@ -149,14 +149,14 @@ void CoulT::loop(const bool _eflag, const bool _vflag) { this->k_pair_fast.set_size(GX,BX); this->k_pair_fast.run(&this->atom->x, &scale, &sp_cl, &this->nbor->dev_nbor, &this->_nbor_data->begin(), - &this->ans->force, &this->ans->engv, &eflag, + &this->ans->force, &this->ans->engv, &eflag, &vflag, &ainum, &nbor_pitch, &this->atom->q, &cutsq, &_qqrd2e, &this->_threads_per_atom); } else { this->k_pair.set_size(GX,BX); this->k_pair.run(&this->atom->x, &scale, &_lj_types, &sp_cl, - &this->nbor->dev_nbor, &this->_nbor_data->begin(), - &this->ans->force, &this->ans->engv, + &this->nbor->dev_nbor, &this->_nbor_data->begin(), + &this->ans->force, &this->ans->engv, &eflag, &vflag, &ainum, &nbor_pitch, &this->atom->q, &cutsq, &_qqrd2e, &this->_threads_per_atom); } diff --git a/lib/gpu/lal_coul.cu b/lib/gpu/lal_coul.cu index e955922a7c..503e674c81 100644 --- a/lib/gpu/lal_coul.cu +++ b/lib/gpu/lal_coul.cu @@ -9,7 +9,7 @@ // This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) // __________________________________________________________________________ // -// begin : +// begin : // email : ndtrung@umich.edu // ***************************************************************************/ @@ -33,14 +33,14 @@ __kernel void k_coul(const __global numtyp4 *restrict x_, const __global numtyp *restrict scale, const int lj_types, const __global numtyp *restrict sp_cl_in, - const __global int *dev_nbor, - const __global int *dev_packed, + const __global int *dev_nbor, + const __global int *dev_packed, __global acctyp4 *restrict ans, - __global acctyp *restrict engv, + __global acctyp *restrict engv, const int eflag, const int vflag, const int inum, - const int nbor_pitch, - const __global numtyp *restrict q_, - const __global numtyp *restrict cutsq, + const int nbor_pitch, + const __global numtyp *restrict q_, + const __global numtyp *restrict cutsq, const numtyp qqrd2e, const int t_per_atom) { int tid, ii, offset; atom_info(t_per_atom,ii,tid,offset); @@ -50,7 +50,7 @@ __kernel void k_coul(const __global numtyp4 *restrict x_, sp_cl[1]=sp_cl_in[1]; sp_cl[2]=sp_cl_in[2]; sp_cl[3]=sp_cl_in[3]; - + acctyp energy=(acctyp)0; acctyp e_coul=(acctyp)0; acctyp4 f; @@ -58,13 +58,13 @@ __kernel void k_coul(const __global numtyp4 *restrict x_, acctyp virial[6]; for (int i=0; i<6; i++) virial[i]=(acctyp)0; - + if (ii { /** \param max_nbors initial number of rows in the neighbor matrix * \param cell_size cutoff + skin * \param gpu_split fraction of particles handled by device - * + * * Returns: * - 0 if successfull * - -1 if fix gpu not found @@ -39,13 +39,13 @@ class Coul : public BaseCharge { * - -5 Double precision is not supported on card **/ int init(const int ntypes, double **host_scale, double **host_cutsq, double *host_special_coul, - const int nlocal, const int nall, const int max_nbors, + const int nlocal, const int nall, const int max_nbors, const int maxspecial, const double cell_size, const double gpu_split, FILE *screen, const double qqrd2e); - + /// Send updated coeffs from host to device (to be compatible with fix adapt) void reinit(const int ntypes, double **host_scale); - + /// Clear all host and device data /** \note This is called at the beginning of the init() routine **/ void clear(); @@ -68,7 +68,7 @@ class Coul : public BaseCharge { /// If atom type constants fit in shared memory, use fast kernels bool shared_types; - /// Number of atom types + /// Number of atom types int _lj_types; numtyp _qqrd2e; diff --git a/lib/gpu/lal_coul_debye.cpp b/lib/gpu/lal_coul_debye.cpp index 990dff6db9..9098aeacb1 100644 --- a/lib/gpu/lal_coul_debye.cpp +++ b/lib/gpu/lal_coul_debye.cpp @@ -9,7 +9,7 @@ This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) __________________________________________________________________________ - begin : + begin : email : ndtrung@umich.edu ***************************************************************************/ @@ -37,7 +37,7 @@ template CoulDebyeT::~CoulDebye() { clear(); } - + template int CoulDebyeT::bytes_per_atom(const int max_nbors) const { return this->bytes_per_atom_atomic(max_nbors); @@ -87,7 +87,7 @@ int CoulDebyeT::init(const int ntypes, double **host_scale, _qqrd2e=qqrd2e; _kappa=kappa; - + _allocated=true; this->_max_bytes=cutsq.row_bytes()+scale.row_bytes()+sp_cl.row_bytes(); return 0; @@ -98,10 +98,10 @@ void CoulDebyeT::reinit(const int ntypes, double **host_scale) { // Allocate a host write buffer for data initialization UCL_H_Vec host_write(_lj_types*_lj_types*32,*(this->ucl_device), UCL_WRITE_ONLY); - + for (int i=0; i<_lj_types*_lj_types; i++) host_write[i]=0.0; - + this->atom->type_pack1(ntypes,_lj_types,scale,host_write,host_scale); } @@ -139,7 +139,7 @@ void CoulDebyeT::loop(const bool _eflag, const bool _vflag) { vflag=1; else vflag=0; - + int GX=static_cast(ceil(static_cast(this->ans->inum())/ (BX/this->_threads_per_atom))); @@ -156,9 +156,9 @@ void CoulDebyeT::loop(const bool _eflag, const bool _vflag) { } else { this->k_pair.set_size(GX,BX); this->k_pair.run(&this->atom->x, &scale, &_lj_types, &sp_cl, - &this->nbor->dev_nbor, &this->_nbor_data->begin(), + &this->nbor->dev_nbor, &this->_nbor_data->begin(), &this->ans->force, &this->ans->engv, &eflag, &vflag, - &ainum, &nbor_pitch, &this->atom->q, &cutsq, + &ainum, &nbor_pitch, &this->atom->q, &cutsq, &_qqrd2e, &_kappa, &this->_threads_per_atom); } this->time_pair.stop(); diff --git a/lib/gpu/lal_coul_debye.cu b/lib/gpu/lal_coul_debye.cu index 0e4c0ea2d0..464a1b18de 100644 --- a/lib/gpu/lal_coul_debye.cu +++ b/lib/gpu/lal_coul_debye.cu @@ -9,7 +9,7 @@ // This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) // __________________________________________________________________________ // -// begin : +// begin : // email : ndtrung@umich.edu // ***************************************************************************/ @@ -31,16 +31,16 @@ texture q_tex; __kernel void k_coul_debye(const __global numtyp4 *restrict x_, const __global numtyp *restrict scale, - const int lj_types, + const int lj_types, const __global numtyp *restrict sp_cl_in, - const __global int *dev_nbor, - const __global int *dev_packed, + const __global int *dev_nbor, + const __global int *dev_packed, __global acctyp4 *restrict ans, __global acctyp *restrict engv, const int eflag, const int vflag, const int inum, const int nbor_pitch, const __global numtyp *restrict q_ , - const __global numtyp *restrict cutsq, + const __global numtyp *restrict cutsq, const numtyp qqrd2e, const numtyp kappa, const int t_per_atom) { int tid, ii, offset; @@ -59,27 +59,27 @@ __kernel void k_coul_debye(const __global numtyp4 *restrict x_, acctyp virial[6]; for (int i=0; i<6; i++) virial[i]=(acctyp)0; - + if (ii { /** \param max_nbors initial number of rows in the neighbor matrix * \param cell_size cutoff + skin * \param gpu_split fraction of particles handled by device - * + * * Returns: * - 0 if successfull * - -1 if fix gpu not found @@ -39,14 +39,14 @@ class CoulDebye : public BaseCharge { * - -5 Double precision is not supported on card **/ int init(const int ntypes, double **host_scale, double **host_cutsq, double *host_special_coul, - const int nlocal, const int nall, const int max_nbors, + const int nlocal, const int nall, const int max_nbors, const int maxspecial, const double cell_size, const double gpu_split, FILE *screen, const double qqrd2e, const double kappa); - + /// Send updated coeffs from host to device (to be compatible with fix adapt) void reinit(const int ntypes, double **host_scale); - + /// Clear all host and device data /** \note This is called at the beginning of the init() routine **/ void clear(); @@ -69,7 +69,7 @@ class CoulDebye : public BaseCharge { /// If atom type constants fit in shared memory, use fast kernels bool shared_types; - /// Number of atom types + /// Number of atom types int _lj_types; numtyp _qqrd2e,_kappa; diff --git a/lib/gpu/lal_coul_debye_ext.cpp b/lib/gpu/lal_coul_debye_ext.cpp index ced08b63e4..f205cd6adf 100644 --- a/lib/gpu/lal_coul_debye_ext.cpp +++ b/lib/gpu/lal_coul_debye_ext.cpp @@ -9,7 +9,7 @@ This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) __________________________________________________________________________ - begin : + begin : email : ndtrung@umich.edu ***************************************************************************/ @@ -75,7 +75,7 @@ int cdebye_gpu_init(const int ntypes, double **host_scale, double **cutsq, maxspecial, cell_size, gpu_split, screen, qqrd2e, kappa); CDEMF.device->gpu_barrier(); - if (message) + if (message) fprintf(screen,"Done.\n"); } if (message) @@ -93,16 +93,16 @@ void cdebye_gpu_reinit(const int ntypes, double **host_scale) { int world_me=CDEMF.device->world_me(); int gpu_rank=CDEMF.device->gpu_rank(); int procs_per_gpu=CDEMF.device->procs_per_gpu(); - + if (world_me==0) CDEMF.reinit(ntypes, host_scale); - + CDEMF.device->world_barrier(); - + for (int i=0; igpu_barrier(); } } @@ -123,7 +123,7 @@ int** cdebye_gpu_compute_n(const int ago, const int inum_full, subhi, tag, nspecial, special, eflag, vflag, eatom, vatom, host_start, ilist, jnum, cpu_time, success, host_q, boxlo, prd); -} +} void cdebye_gpu_compute(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, int *ilist, int *numj, diff --git a/lib/gpu/lal_coul_dsf.cpp b/lib/gpu/lal_coul_dsf.cpp index ca81d32b2d..32c4342fbe 100644 --- a/lib/gpu/lal_coul_dsf.cpp +++ b/lib/gpu/lal_coul_dsf.cpp @@ -37,18 +37,18 @@ template CoulDSFT::~CoulDSF() { clear(); } - + template int CoulDSFT::bytes_per_atom(const int max_nbors) const { return this->bytes_per_atom_atomic(max_nbors); } template -int CoulDSFT::init(const int ntypes, const int nlocal, const int nall, - const int max_nbors, const int maxspecial, +int CoulDSFT::init(const int ntypes, const int nlocal, const int nall, + const int max_nbors, const int maxspecial, const double cell_size, const double gpu_split, FILE *_screen, const double host_cut_coulsq, double *host_special_coul, - const double qqrd2e, const double e_shift, const double f_shift, + const double qqrd2e, const double e_shift, const double f_shift, const double alpha) { int success; success=this->init_atomic(nlocal,nall,max_nbors,maxspecial,cell_size,gpu_split, @@ -123,7 +123,7 @@ void CoulDSFT::loop(const bool _eflag, const bool _vflag) { vflag=1; else vflag=0; - + int GX=static_cast(ceil(static_cast(this->ans->inum())/ (BX/this->_threads_per_atom))); @@ -134,15 +134,15 @@ void CoulDSFT::loop(const bool _eflag, const bool _vflag) { this->k_pair_fast.set_size(GX,BX); this->k_pair_fast.run(&this->atom->x, &sp_lj, &this->nbor->dev_nbor, &this->_nbor_data->begin(), - &this->ans->force, &this->ans->engv, &eflag, + &this->ans->force, &this->ans->engv, &eflag, &vflag, &ainum, &nbor_pitch, &this->atom->q, &_cut_coulsq, &_qqrd2e, &_e_shift, &_f_shift, &_alpha, &this->_threads_per_atom); } else { this->k_pair.set_size(GX,BX); - this->k_pair.run(&this->atom->x, &_lj_types, &sp_lj, - &this->nbor->dev_nbor, &this->_nbor_data->begin(), - &this->ans->force, &this->ans->engv, + this->k_pair.run(&this->atom->x, &_lj_types, &sp_lj, + &this->nbor->dev_nbor, &this->_nbor_data->begin(), + &this->ans->force, &this->ans->engv, &eflag, &vflag, &ainum, &nbor_pitch, &this->atom->q, &_cut_coulsq, &_qqrd2e, &_e_shift, &_f_shift, &_alpha, &this->_threads_per_atom); diff --git a/lib/gpu/lal_coul_dsf.cu b/lib/gpu/lal_coul_dsf.cu index fc5bf5f138..82c44cd382 100644 --- a/lib/gpu/lal_coul_dsf.cu +++ b/lib/gpu/lal_coul_dsf.cu @@ -31,18 +31,18 @@ texture q_tex; #define MY_PIS (acctyp)1.77245385090551602729 -__kernel void k_coul_dsf(const __global numtyp4 *restrict x_, - const int lj_types, - const __global numtyp *restrict sp_lj_in, - const __global int *dev_nbor, - const __global int *dev_packed, +__kernel void k_coul_dsf(const __global numtyp4 *restrict x_, + const int lj_types, + const __global numtyp *restrict sp_lj_in, + const __global int *dev_nbor, + const __global int *dev_packed, __global acctyp4 *restrict ans, - __global acctyp *restrict engv, + __global acctyp *restrict engv, const int eflag, const int vflag, const int inum, - const int nbor_pitch, + const int nbor_pitch, const __global numtyp *restrict q_ , const numtyp cut_coulsq, const numtyp qqrd2e, - const numtyp e_shift, const numtyp f_shift, + const numtyp e_shift, const numtyp f_shift, const numtyp alpha, const int t_per_atom) { int tid, ii, offset; atom_info(t_per_atom,ii,tid,offset); @@ -60,19 +60,19 @@ __kernel void k_coul_dsf(const __global numtyp4 *restrict x_, acctyp virial[6]; for (int i=0; i<6; i++) virial[i]=(acctyp)0; - + if (ii0) { - acctyp e_self = -((acctyp)0.5*e_shift + alpha/MY_PIS) * + acctyp e_self = -((acctyp)0.5*e_shift + alpha/MY_PIS) * qtmp*qtmp*qqrd2e/(acctyp)t_per_atom; e_coul += (acctyp)2.0*e_self; } @@ -102,9 +102,9 @@ __kernel void k_coul_dsf(const __global numtyp4 *restrict x_, numtyp erfcd = ucl_exp(-alpha*alpha*rsq); numtyp t = ucl_recip((numtyp)1.0 + EWALD_P*alpha*r); erfcc = t * (A1+t*(A2+t*(A3+t*(A4+t*A5)))) * erfcd; - forcecoul = prefactor * (erfcc + (numtyp)2.0*alpha/MY_PIS*r*erfcd + + forcecoul = prefactor * (erfcc + (numtyp)2.0*alpha/MY_PIS*r*erfcd + rsq*f_shift-factor_coul); - + force = forcecoul * r2inv; f.x+=delx*force; @@ -131,17 +131,17 @@ __kernel void k_coul_dsf(const __global numtyp4 *restrict x_, } // if ii } -__kernel void k_coul_dsf_fast(const __global numtyp4 *restrict x_, +__kernel void k_coul_dsf_fast(const __global numtyp4 *restrict x_, const __global numtyp *restrict sp_lj_in, - const __global int *dev_nbor, + const __global int *dev_nbor, const __global int *dev_packed, - __global acctyp4 *restrict ans, - __global acctyp *restrict engv, - const int eflag, const int vflag, const int inum, - const int nbor_pitch, + __global acctyp4 *restrict ans, + __global acctyp *restrict engv, + const int eflag, const int vflag, const int inum, + const int nbor_pitch, const __global numtyp *restrict q_, const numtyp cut_coulsq, const numtyp qqrd2e, - const numtyp e_shift, const numtyp f_shift, + const numtyp e_shift, const numtyp f_shift, const numtyp alpha, const int t_per_atom) { int tid, ii, offset; atom_info(t_per_atom,ii,tid,offset); @@ -149,7 +149,7 @@ __kernel void k_coul_dsf_fast(const __global numtyp4 *restrict x_, __local numtyp sp_lj[4]; if (tid<4) sp_lj[tid]=sp_lj_in[tid]; - + acctyp energy=(acctyp)0; acctyp e_coul=(acctyp)0; acctyp4 f; @@ -157,25 +157,25 @@ __kernel void k_coul_dsf_fast(const __global numtyp4 *restrict x_, acctyp virial[6]; for (int i=0; i<6; i++) virial[i]=(acctyp)0; - + __syncthreads(); - + if (ii0) { - acctyp e_self = -((acctyp)0.5*e_shift + alpha/MY_PIS) * + acctyp e_self = -((acctyp)0.5*e_shift + alpha/MY_PIS) * qtmp*qtmp*qqrd2e/(acctyp)t_per_atom; e_coul += (acctyp)2.0*e_self; } - + for ( ; nbor { /** \param max_nbors initial number of rows in the neighbor matrix * \param cell_size cutoff + skin * \param gpu_split fraction of particles handled by device - * + * * Returns: * - 0 if successfull * - -1 if fix gpu not found * - -3 if there is an out of memory error * - -4 if the GPU library was not compiled for GPU * - -5 Double precision is not supported on card **/ - int init(const int ntypes, const int nlocal, const int nall, - const int max_nbors, const int maxspecial, + int init(const int ntypes, const int nlocal, const int nall, + const int max_nbors, const int maxspecial, const double cell_size, const double gpu_split, FILE *screen, const double host_cut_coulsq, double *host_special_coul, - const double qqrd2e, const double e_shift, const double f_shift, + const double qqrd2e, const double e_shift, const double f_shift, const double alpha); /// Clear all host and device data @@ -62,7 +62,7 @@ class CoulDSF : public BaseCharge { /// If atom type constants fit in shared memory, use fast kernels bool shared_types; - /// Number of atom types + /// Number of atom types int _lj_types; numtyp _qqrd2e; diff --git a/lib/gpu/lal_coul_dsf_ext.cpp b/lib/gpu/lal_coul_dsf_ext.cpp index e65a090a16..174ec0d839 100644 --- a/lib/gpu/lal_coul_dsf_ext.cpp +++ b/lib/gpu/lal_coul_dsf_ext.cpp @@ -27,11 +27,11 @@ static CoulDSF CDMF; // --------------------------------------------------------------------------- // Allocate memory on host and device and copy constants to device // --------------------------------------------------------------------------- -int cdsf_gpu_init(const int ntypes, const int inum, const int nall, +int cdsf_gpu_init(const int ntypes, const int inum, const int nall, const int max_nbors, const int maxspecial, const double cell_size, int &gpu_mode, FILE *screen, - const double host_cut_coulsq, double *host_special_coul, - const double qqrd2e, const double e_shift, const double f_shift, + const double host_cut_coulsq, double *host_special_coul, + const double qqrd2e, const double e_shift, const double f_shift, const double alpha) { CDMF.clear(); gpu_mode=CDMF.device->gpu_mode(); @@ -55,8 +55,8 @@ int cdsf_gpu_init(const int ntypes, const int inum, const int nall, int init_ok=0; if (world_me==0) - init_ok=CDMF.init(ntypes, inum, nall, 300, maxspecial, cell_size, - gpu_split, screen, host_cut_coulsq, host_special_coul, + init_ok=CDMF.init(ntypes, inum, nall, 300, maxspecial, cell_size, + gpu_split, screen, host_cut_coulsq, host_special_coul, qqrd2e, e_shift, f_shift, alpha); CDMF.device->world_barrier(); @@ -73,12 +73,12 @@ int cdsf_gpu_init(const int ntypes, const int inum, const int nall, fflush(screen); } if (gpu_rank==i && world_me!=0) - init_ok=CDMF.init(ntypes, inum, nall, 300, maxspecial, cell_size, - gpu_split, screen, host_cut_coulsq, host_special_coul, + init_ok=CDMF.init(ntypes, inum, nall, 300, maxspecial, cell_size, + gpu_split, screen, host_cut_coulsq, host_special_coul, qqrd2e, e_shift, f_shift, alpha); CDMF.device->gpu_barrier(); - if (message) + if (message) fprintf(screen,"Done.\n"); } if (message) @@ -95,7 +95,7 @@ void cdsf_gpu_clear() { int** cdsf_gpu_compute_n(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, - double *sublo, double *subhi, tagint *tag, int **nspecial, + double *sublo, double *subhi, tagint *tag, int **nspecial, tagint **special, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, int **ilist, int **jnum, const double cpu_time, @@ -105,7 +105,7 @@ int** cdsf_gpu_compute_n(const int ago, const int inum_full, subhi, tag, nspecial, special, eflag, vflag, eatom, vatom, host_start, ilist, jnum, cpu_time, success, host_q, boxlo, prd); -} +} void cdsf_gpu_compute(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, int *ilist, int *numj, diff --git a/lib/gpu/lal_coul_ext.cpp b/lib/gpu/lal_coul_ext.cpp index 291546d5b1..c124622cee 100644 --- a/lib/gpu/lal_coul_ext.cpp +++ b/lib/gpu/lal_coul_ext.cpp @@ -9,7 +9,7 @@ This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) __________________________________________________________________________ - begin : + begin : email : ndtrung@umich.edu ***************************************************************************/ @@ -75,7 +75,7 @@ int coul_gpu_init(const int ntypes, double **host_scale, maxspecial, cell_size, gpu_split, screen, qqrd2e); COULMF.device->gpu_barrier(); - if (message) + if (message) fprintf(screen,"Done.\n"); } if (message) @@ -93,16 +93,16 @@ void coul_gpu_reinit(const int ntypes, double **host_scale) { int world_me=COULMF.device->world_me(); int gpu_rank=COULMF.device->gpu_rank(); int procs_per_gpu=COULMF.device->procs_per_gpu(); - + if (world_me==0) COULMF.reinit(ntypes, host_scale); - + COULMF.device->world_barrier(); - + for (int i=0; igpu_barrier(); } } @@ -113,7 +113,7 @@ void coul_gpu_clear() { int** coul_gpu_compute_n(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, - double *sublo, double *subhi, tagint *tag, int **nspecial, + double *sublo, double *subhi, tagint *tag, int **nspecial, tagint **special, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, int **ilist, int **jnum, const double cpu_time, @@ -123,7 +123,7 @@ int** coul_gpu_compute_n(const int ago, const int inum_full, subhi, tag, nspecial, special, eflag, vflag, eatom, vatom, host_start, ilist, jnum, cpu_time, success, host_q, boxlo, prd); -} +} void coul_gpu_compute(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, int *ilist, int *numj, diff --git a/lib/gpu/lal_coul_long.cpp b/lib/gpu/lal_coul_long.cpp index d6e16a9668..513e6d074d 100644 --- a/lib/gpu/lal_coul_long.cpp +++ b/lib/gpu/lal_coul_long.cpp @@ -36,7 +36,7 @@ template CoulLongT::~CoulLong() { clear(); } - + template int CoulLongT::bytes_per_atom(const int max_nbors) const { return this->bytes_per_atom_atomic(max_nbors); @@ -67,13 +67,13 @@ int CoulLongT::init(const int ntypes, double **host_scale, // Allocate a host write buffer for data initialization UCL_H_Vec host_write(lj_types*lj_types*32,*(this->ucl_device), UCL_WRITE_ONLY); - + for (int i=0; iucl_device),UCL_READ_ONLY); this->atom->type_pack1(ntypes,lj_types,scale,host_write,host_scale); - + sp_cl.alloc(4,*(this->ucl_device),UCL_READ_ONLY); for (int i=0; i<4; i++) { host_write[i]=host_special_coul[i]; @@ -129,7 +129,7 @@ void CoulLongT::loop(const bool _eflag, const bool _vflag) { vflag=1; else vflag=0; - + int GX=static_cast(ceil(static_cast(this->ans->inum())/ (BX/this->_threads_per_atom))); @@ -141,13 +141,13 @@ void CoulLongT::loop(const bool _eflag, const bool _vflag) { this->k_pair_fast.run(&this->atom->x, &scale, &sp_cl, &this->nbor->dev_nbor, &this->_nbor_data->begin(), &this->ans->force, &this->ans->engv, - &eflag, &vflag, &ainum, &nbor_pitch, + &eflag, &vflag, &ainum, &nbor_pitch, &this->atom->q, &_cut_coulsq, &_qqrd2e, &_g_ewald, &this->_threads_per_atom); } else { this->k_pair.set_size(GX,BX); this->k_pair.run(&this->atom->x, &scale, &_lj_types, &sp_cl, - &this->nbor->dev_nbor, &this->_nbor_data->begin(), + &this->nbor->dev_nbor, &this->_nbor_data->begin(), &this->ans->force, &this->ans->engv, &eflag, &vflag, &ainum, &nbor_pitch, &this->atom->q, &_cut_coulsq, &_qqrd2e, &_g_ewald, &this->_threads_per_atom); diff --git a/lib/gpu/lal_coul_long.cu b/lib/gpu/lal_coul_long.cu index 12bbbee7d2..365195e00c 100644 --- a/lib/gpu/lal_coul_long.cu +++ b/lib/gpu/lal_coul_long.cu @@ -123,16 +123,16 @@ texture q_tex; #endif -__kernel void k_coul_long(const __global numtyp4 *restrict x_, +__kernel void k_coul_long(const __global numtyp4 *restrict x_, const __global numtyp *restrict scale, const int lj_types, - const __global numtyp *restrict sp_cl_in, + const __global numtyp *restrict sp_cl_in, const __global int *dev_nbor, - const __global int *dev_packed, + const __global int *dev_packed, __global acctyp4 *restrict ans, - __global acctyp *restrict engv, + __global acctyp *restrict engv, const int eflag, const int vflag, const int inum, - const int nbor_pitch, + const int nbor_pitch, const __global numtyp *restrict q_, const numtyp cut_coulsq, const numtyp qqrd2e, const numtyp g_ewald, const int t_per_atom) { @@ -216,15 +216,15 @@ __kernel void k_coul_long(const __global numtyp4 *restrict x_, } // if ii } -__kernel void k_coul_long_fast(const __global numtyp4 *restrict x_, +__kernel void k_coul_long_fast(const __global numtyp4 *restrict x_, const __global numtyp *restrict scale_in, const __global numtyp *restrict sp_cl_in, - const __global int *dev_nbor, + const __global int *dev_nbor, const __global int *dev_packed, - __global acctyp4 *restrict ans, + __global acctyp4 *restrict ans, __global acctyp *restrict engv, const int eflag, const int vflag, const int inum, - const int nbor_pitch, + const int nbor_pitch, const __global numtyp *restrict q_, const numtyp cut_coulsq, const numtyp qqrd2e, const numtyp g_ewald, const int t_per_atom) { diff --git a/lib/gpu/lal_coul_long.h b/lib/gpu/lal_coul_long.h index 52ed60111b..6ed9c1a018 100644 --- a/lib/gpu/lal_coul_long.h +++ b/lib/gpu/lal_coul_long.h @@ -30,7 +30,7 @@ class CoulLong : public BaseCharge { /** \param max_nbors initial number of rows in the neighbor matrix * \param cell_size cutoff + skin * \param gpu_split fraction of particles handled by device - * + * * Returns: * - 0 if successfull * - -1 if fix gpu not found @@ -43,10 +43,10 @@ class CoulLong : public BaseCharge { const double gpu_split, FILE *screen, const double host_cut_coulsq, double *host_special_coul, const double qqrd2e, const double g_ewald); - + /// Send updated coeffs from host to device (to be compatible with fix adapt) void reinit(const int ntypes, double **scale); - + /// Clear all host and device data /** \note This is called at the beginning of the init() routine **/ void clear(); diff --git a/lib/gpu/lal_coul_long_ext.cpp b/lib/gpu/lal_coul_long_ext.cpp index 5552dc2437..2bc2af082e 100644 --- a/lib/gpu/lal_coul_long_ext.cpp +++ b/lib/gpu/lal_coul_long_ext.cpp @@ -95,16 +95,16 @@ void cl_gpu_reinit(const int ntypes, double **host_scale) { int world_me=CLMF.device->world_me(); int gpu_rank=CLMF.device->gpu_rank(); int procs_per_gpu=CLMF.device->procs_per_gpu(); - + if (world_me==0) CLMF.reinit(ntypes, host_scale); - + CLMF.device->world_barrier(); - + for (int i=0; igpu_barrier(); } } diff --git a/lib/gpu/lal_device.cpp b/lib/gpu/lal_device.cpp index f326657e31..1943de64c6 100644 --- a/lib/gpu/lal_device.cpp +++ b/lib/gpu/lal_device.cpp @@ -9,7 +9,7 @@ This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) __________________________________________________________________________ - begin : + begin : email : brownw@ornl.gov ***************************************************************************/ @@ -45,8 +45,8 @@ DeviceT::~Device() { template int DeviceT::init_device(MPI_Comm world, MPI_Comm replica, const int first_gpu, - const int last_gpu, const int gpu_mode, - const double p_split, const int nthreads, + const int last_gpu, const int gpu_mode, + const double p_split, const int nthreads, const int t_per_atom, const double cell_size, char *ocl_vendor, const int block_pair) { _nthreads=nthreads; @@ -83,8 +83,8 @@ int DeviceT::init_device(MPI_Comm world, MPI_Comm replica, const int first_gpu, MPI_Allgather(&node_name,MPI_MAX_PROCESSOR_NAME,MPI_CHAR,&node_names, MPI_MAX_PROCESSOR_NAME,MPI_CHAR,_comm_world); std::string node_string=std::string(node_name); - - // Get the number of procs per node + + // Get the number of procs per node std::map name_map; std::map::iterator np; for (int i=0; i<_world_size; i++) { @@ -104,12 +104,12 @@ int DeviceT::init_device(MPI_Comm world, MPI_Comm replica, const int first_gpu, split_id=split_num; split_num++; } - + // Set up a per node communicator and find rank within MPI_Comm node_comm; - MPI_Comm_split(_comm_world, split_id, 0, &node_comm); + MPI_Comm_split(_comm_world, split_id, 0, &node_comm); int node_rank; - MPI_Comm_rank(node_comm,&node_rank); + MPI_Comm_rank(node_comm,&node_rank); // set the device ID _procs_per_gpu=static_cast(ceil(static_cast(procs_per_node)/ @@ -120,7 +120,7 @@ int DeviceT::init_device(MPI_Comm world, MPI_Comm replica, const int first_gpu, _time_device=true; if (_procs_per_gpu>1) _time_device=false; - + // Set up a per device communicator MPI_Comm_split(node_comm,my_gpu,0,&_comm_gpu); MPI_Comm_rank(_comm_gpu,&_gpu_rank); @@ -128,12 +128,12 @@ int DeviceT::init_device(MPI_Comm world, MPI_Comm replica, const int first_gpu, gpu=new UCL_Device(); if (my_gpu>=gpu->num_devices()) return -2; - + #ifndef CUDA_PROXY if (_procs_per_gpu>1 && gpu->sharing_supported(my_gpu)==false) return -7; #endif - + if (gpu->set(my_gpu)!=UCL_SUCCESS) return -6; @@ -144,7 +144,7 @@ int DeviceT::init_device(MPI_Comm world, MPI_Comm replica, const int first_gpu, if (set_ocl_params(ocl_vendor)!=0) return -11; - + int flag=0; for (int i=0; i<_procs_per_gpu; i++) { if (_gpu_rank==i) @@ -162,7 +162,7 @@ int DeviceT::set_ocl_params(char *ocl_vendor) { s_vendor=ocl_vendor; if (s_vendor=="none") s_vendor="generic"; - + if (s_vendor=="kepler") { _ocl_vendor_name="NVIDIA Kepler"; #if defined (__APPLE__) || defined(MACOSX) @@ -170,19 +170,19 @@ int DeviceT::set_ocl_params(char *ocl_vendor) { #else _ocl_vendor_string="-DKEPLER_OCL"; #endif - } else if (s_vendor=="fermi") { + } else if (s_vendor=="fermi") { _ocl_vendor_name="NVIDIA Fermi"; _ocl_vendor_string="-DFERMI_OCL"; - } else if (s_vendor=="cypress") { + } else if (s_vendor=="cypress") { _ocl_vendor_name="AMD Cypress"; _ocl_vendor_string="-DCYPRESS_OCL"; - } else if (s_vendor=="phi") { + } else if (s_vendor=="phi") { _ocl_vendor_name="Intel Phi"; _ocl_vendor_string="-DPHI_OCL"; - } else if (s_vendor=="intel") { + } else if (s_vendor=="intel") { _ocl_vendor_name="Intel CPU"; _ocl_vendor_string="-DINTEL_OCL"; - } else if (s_vendor=="generic") { + } else if (s_vendor=="generic") { _ocl_vendor_name="GENERIC"; _ocl_vendor_string="-DGENERIC_OCL"; } else { @@ -220,10 +220,10 @@ int DeviceT::set_ocl_params(char *ocl_vendor) { template int DeviceT::init(Answer &ans, const bool charge, - const bool rot, const int nlocal, + const bool rot, const int nlocal, const int host_nlocal, const int nall, Neighbor *nbor, const int maxspecial, - const int gpu_host, const int max_nbors, + const int gpu_host, const int max_nbors, const double cell_size, const bool pre_cut, const int threads_per_atom, const bool vel) { if (!_device_init) @@ -254,7 +254,7 @@ int DeviceT::init(Answer &ans, const bool charge, // Initialize atom and nbor data if (!atom.init(nall,charge,rot,*gpu,gpu_nbor,gpu_nbor>0 && maxspecial>0,vel)) return -3; - + _data_in_estimate++; if (charge) _data_in_estimate++; @@ -272,12 +272,12 @@ int DeviceT::init(Answer &ans, const bool charge, if (!atom.add_fields(charge,rot,gpu_nbor,gpu_nbor>0 && maxspecial,vel)) return -3; } - + if (!ans.init(ef_nlocal,charge,rot,*gpu)) return -3; if (!nbor->init(&_neighbor_shared,ef_nlocal,host_nlocal,max_nbors,maxspecial, - *gpu,gpu_nbor,gpu_host,pre_cut, _block_cell_2d, + *gpu,gpu_nbor,gpu_host,pre_cut, _block_cell_2d, _block_cell_id, _block_nbor_build, threads_per_atom, _warp_size, _time_device, compile_string())) return -3; @@ -294,7 +294,7 @@ template int DeviceT::init(Answer &ans, const int nlocal, const int nall) { if (!_device_init) - return -1; + return -1; if (sizeof(acctyp)==sizeof(double) && gpu->double_precision()==false) return -5; @@ -361,7 +361,7 @@ void DeviceT::init_message(FILE *screen, const char *name, if (i==first_gpu) sname=gpu->name(i)+", "+toa(gpu->cus(i))+" CUs, "+fs+ toa(gpu->gigabytes(i))+" GB, "+toa(gpu->clock_rate(i))+" GHZ ("; - else + else sname=gpu->name(i)+", "+toa(gpu->cus(i))+" CUs, "+ toa(gpu->clock_rate(i))+" GHZ ("; if (sizeof(PRECISION)==4) { @@ -381,7 +381,7 @@ void DeviceT::init_message(FILE *screen, const char *name, } template -void DeviceT::estimate_gpu_overhead(const int kernel_calls, +void DeviceT::estimate_gpu_overhead(const int kernel_calls, double &gpu_overhead, double &gpu_driver_overhead) { UCL_H_Vec *host_data_in=NULL, *host_data_out=NULL; @@ -394,38 +394,38 @@ void DeviceT::estimate_gpu_overhead(const int kernel_calls, dev_data_in=new UCL_D_Vec[_data_in_estimate]; timers_in=new UCL_Timer[_data_in_estimate]; } - + if (_data_out_estimate>0) { host_data_out=new UCL_H_Vec[_data_out_estimate]; dev_data_out=new UCL_D_Vec[_data_out_estimate]; timers_out=new UCL_Timer[_data_out_estimate]; } - + if (kernel_calls>0) { kernel_data=new UCL_D_Vec[kernel_calls]; timers_kernel=new UCL_Timer[kernel_calls]; } - + for (int i=0; i<_data_in_estimate; i++) { host_data_in[i].alloc(1,*gpu); dev_data_in[i].alloc(1,*gpu); timers_in[i].init(*gpu); - } - + } + for (int i=0; i<_data_out_estimate; i++) { host_data_out[i].alloc(1,*gpu); dev_data_out[i].alloc(1,*gpu); timers_out[i].init(*gpu); - } - + } + for (int i=0; isync(); gpu_barrier(); @@ -439,7 +439,7 @@ void DeviceT::estimate_gpu_overhead(const int kernel_calls, ucl_copy(dev_data_in[i],host_data_in[i],true); timers_in[i].stop(); } - + for (int i=0; i0) { delete [] host_data_out; delete [] dev_data_out; delete [] timers_out; } - + if (kernel_calls>0) { delete [] kernel_data; delete [] timers_kernel; } -} +} template -void DeviceT::output_times(UCL_Timer &time_pair, Answer &ans, - Neighbor &nbor, const double avg_split, +void DeviceT::output_times(UCL_Timer &time_pair, Answer &ans, + Neighbor &nbor, const double avg_split, const double max_bytes, const double gpu_overhead, - const double driver_overhead, + const double driver_overhead, const int threads_per_atom, FILE *screen) { double single[9], times[9]; int post_final=0; @@ -557,14 +557,14 @@ void DeviceT::output_times(UCL_Timer &time_pair, Answer &ans, } template -void DeviceT::output_kspace_times(UCL_Timer &time_in, +void DeviceT::output_kspace_times(UCL_Timer &time_in, UCL_Timer &time_out, UCL_Timer &time_map, UCL_Timer &time_rho, UCL_Timer &time_interp, - Answer &ans, - const double max_bytes, - const double cpu_time, + Answer &ans, + const double max_bytes, + const double cpu_time, const double idle_time, FILE *screen) { double single[8], times[8]; @@ -664,7 +664,7 @@ int DeviceT::compile_kernels() { k_info.set_size(1,1); k_info.run(&gpu_lib_data); gpu_lib_data.update_host(false); - + _ptx_arch=static_cast(gpu_lib_data[0])/100.0; #ifndef USE_OPENCL if (_ptx_arch>gpu->arch() || floor(_ptx_arch)arch())) @@ -705,7 +705,7 @@ int DeviceT::compile_kernels() { if (_threads_per_charge & (_threads_per_charge - 1)) _threads_per_charge=1; - return flag; + return flag; } template @@ -718,12 +718,12 @@ template class Device; Device global_device; int lmp_init_device(MPI_Comm world, MPI_Comm replica, const int first_gpu, - const int last_gpu, const int gpu_mode, + const int last_gpu, const int gpu_mode, const double particle_split, const int nthreads, - const int t_per_atom, const double cell_size, + const int t_per_atom, const double cell_size, char *opencl_vendor, const int block_pair) { return global_device.init_device(world,replica,first_gpu,last_gpu,gpu_mode, - particle_split,nthreads,t_per_atom, + particle_split,nthreads,t_per_atom, cell_size,opencl_vendor,block_pair); } diff --git a/lib/gpu/lal_device.cu b/lib/gpu/lal_device.cu index 28b58f7760..6761b23fbb 100644 --- a/lib/gpu/lal_device.cu +++ b/lib/gpu/lal_device.cu @@ -9,7 +9,7 @@ // This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) // __________________________________________________________________________ // -// begin : +// begin : // email : brownw@ornl.gov // ***************************************************************************/ @@ -17,10 +17,10 @@ #include "lal_preprocessor.h" #endif -__kernel void kernel_zero(__global int *restrict mem, +__kernel void kernel_zero(__global int *restrict mem, int numel) { int ii=GLOBAL_ID_X; - + if (ii class PPPM; template class Device { public: Device(); - ~Device(); - + ~Device(); + /// Initialize the device for use by this process /** Sets up a per-device MPI communicator for load balancing and initializes - * the device (>=first_gpu and <=last_gpu) that this proc will be using + * the device (>=first_gpu and <=last_gpu) that this proc will be using * Returns: * - 0 if successfull * - -2 if GPU not found * - -4 if GPU library not compiled for GPU * - -6 if GPU could not be initialized for use - * - -7 if accelerator sharing is not currently allowed on system + * - -7 if accelerator sharing is not currently allowed on system * - -11 if vendor_string has the wrong number of parameters **/ - int init_device(MPI_Comm world, MPI_Comm replica, const int first_gpu, - const int last_gpu, const int gpu_mode, + int init_device(MPI_Comm world, MPI_Comm replica, const int first_gpu, + const int last_gpu, const int gpu_mode, const double particle_split, const int nthreads, - const int t_per_atom, const double cell_size, + const int t_per_atom, const double cell_size, char *vendor_string, const int block_pair); /// Initialize the device for Atom and Neighbor storage @@ -62,9 +62,9 @@ class Device { * 1 if gpu_nbor is true, and host needs a half nbor list, * 2 if gpu_nbor is true, and host needs a full nbor list * \param max_nbors Initial number of rows in the neighbor matrix - * \param cell_size cutoff+skin + * \param cell_size cutoff+skin * \param pre_cut True if cutoff test will be performed in separate kernel - * than the force kernel + * than the force kernel * \param threads_per_atom value to be used by the neighbor list only * * Returns: @@ -113,25 +113,25 @@ class Device { /// Returns true if double precision is supported on card inline bool double_precision() { return gpu->double_precision(); } - + /// Output a message with timing information - void output_times(UCL_Timer &time_pair, Answer &ans, - Neighbor &nbor, const double avg_split, + void output_times(UCL_Timer &time_pair, Answer &ans, + Neighbor &nbor, const double avg_split, const double max_bytes, const double gpu_overhead, - const double driver_overhead, + const double driver_overhead, const int threads_per_atom, FILE *screen); /// Output a message with timing information void output_kspace_times(UCL_Timer &time_in, UCL_Timer &time_out, UCL_Timer & time_map, UCL_Timer & time_rho, - UCL_Timer &time_interp, - Answer &ans, + UCL_Timer &time_interp, + Answer &ans, const double max_bytes, const double cpu_time, const double cpu_idle_time, FILE *screen); /// Clear all memory on host and device associated with atom and nbor data void clear(); - + /// Clear all memory on host and device void clear_device(); @@ -149,24 +149,24 @@ class Device { while (ans_queue.empty()==false) { evdw+=ans_queue.front()->get_answers(f,tor,eatom,vatom,virial,ecoul); ans_queue.pop(); - } + } return evdw; } return 0.0; } /// Start timer on host - inline void start_host_timer() + inline void start_host_timer() { _cpu_full=MPI_Wtime(); _host_timer_started=true; } - + /// Stop timer on host - inline void stop_host_timer() { + inline void stop_host_timer() { if (_host_timer_started) { - _cpu_full=MPI_Wtime()-_cpu_full; + _cpu_full=MPI_Wtime()-_cpu_full; _host_timer_started=false; } } - + /// Return host time inline double host_time() { return _cpu_full; } @@ -239,8 +239,8 @@ class Device { /// Number of threads executing concurrently on same multiproc inline int warp_size() const { return _warp_size; } - // -------------------- SHARED DEVICE ROUTINES -------------------- - // Perform asynchronous zero of integer array + // -------------------- SHARED DEVICE ROUTINES -------------------- + // Perform asynchronous zero of integer array void zero(UCL_D_Vec &mem, const int numel) { int num_blocks=static_cast(ceil(static_cast(numel)/ _block_pair)); @@ -248,25 +248,25 @@ class Device { k_zero.run(&mem,&numel); } - // -------------------------- DEVICE DATA ------------------------- + // -------------------------- DEVICE DATA ------------------------- /// Geryon Device UCL_Device *gpu; enum{GPU_FORCE, GPU_NEIGH, GPU_HYB_NEIGH}; - // --------------------------- ATOM DATA -------------------------- + // --------------------------- ATOM DATA -------------------------- /// Atom Data Atom atom; // --------------------------- NBOR DATA ---------------------------- - + /// Neighbor Data NeighborShared _neighbor_shared; // ------------------------ LONG RANGE DATA ------------------------- - + // Long Range Data int _long_range_precompute; PPPM *pppm_single; @@ -282,7 +282,7 @@ class Device { pppm_double->precompute(ago,nlocal,nall,host_x,host_type,success,charge, boxlo,prd); } - + inline std::string compile_string() { return _ocl_compile_string; } private: @@ -290,7 +290,7 @@ class Device { int _init_count; bool _device_init, _host_timer_started, _time_device; MPI_Comm _comm_world, _comm_replica, _comm_gpu; - int _procs_per_gpu, _gpu_rank, _world_me, _world_size, _replica_me, + int _procs_per_gpu, _gpu_rank, _world_me, _world_size, _replica_me, _replica_size; int _gpu_mode, _first_device, _last_device, _nthreads; double _particle_split; @@ -310,10 +310,10 @@ class Device { int compile_kernels(); int _data_in_estimate, _data_out_estimate; - + std::string _ocl_vendor_name, _ocl_vendor_string, _ocl_compile_string; int set_ocl_params(char *); - + template inline std::string toa(const t& in) { std::ostringstream o; diff --git a/lib/gpu/lal_dipole_lj.cpp b/lib/gpu/lal_dipole_lj.cpp index e96e15eaf9..c97b76c820 100644 --- a/lib/gpu/lal_dipole_lj.cpp +++ b/lib/gpu/lal_dipole_lj.cpp @@ -9,7 +9,7 @@ This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) __________________________________________________________________________ - begin : + begin : email : nguyentd@ornl.gov ***************************************************************************/ @@ -37,7 +37,7 @@ template DipoleLJT::~DipoleLJ() { clear(); } - + template int DipoleLJT::bytes_per_atom(const int max_nbors) const { return this->bytes_per_atom_atomic(max_nbors); @@ -45,8 +45,8 @@ int DipoleLJT::bytes_per_atom(const int max_nbors) const { template int DipoleLJT::init(const int ntypes, - double **host_cutsq, double **host_lj1, - double **host_lj2, double **host_lj3, + double **host_cutsq, double **host_lj1, + double **host_lj2, double **host_lj3, double **host_lj4, double **host_offset, double *host_special_lj, const int nlocal, const int nall, const int max_nbors, @@ -138,7 +138,7 @@ void DipoleLJT::loop(const bool _eflag, const bool _vflag) { vflag=1; else vflag=0; - + int GX=static_cast(ceil(static_cast(this->ans->inum())/ (BX/this->_threads_per_atom))); @@ -151,7 +151,7 @@ void DipoleLJT::loop(const bool _eflag, const bool _vflag) { &this->nbor->dev_nbor, &this->_nbor_data->begin(), &this->ans->force, &this->ans->engv, &eflag, &vflag, - &ainum, &nbor_pitch, &this->atom->q, + &ainum, &nbor_pitch, &this->atom->q, &this->atom->quat, &cutsq, &_qqrd2e, &this->_threads_per_atom); } else { @@ -160,8 +160,8 @@ void DipoleLJT::loop(const bool _eflag, const bool _vflag) { &_lj_types, &sp_lj, &this->nbor->dev_nbor, &this->_nbor_data->begin(), &this->ans->force, &this->ans->engv, &eflag, &vflag, &ainum, - &nbor_pitch, &this->atom->q, - &this->atom->quat, &cutsq, + &nbor_pitch, &this->atom->q, + &this->atom->quat, &cutsq, &_qqrd2e, &this->_threads_per_atom); } this->time_pair.stop(); diff --git a/lib/gpu/lal_dipole_lj.cu b/lib/gpu/lal_dipole_lj.cu index b6483d1ef8..42c2bde144 100644 --- a/lib/gpu/lal_dipole_lj.cu +++ b/lib/gpu/lal_dipole_lj.cu @@ -9,7 +9,7 @@ // This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) // __________________________________________________________________________ // -// begin : +// begin : // email : nguyentd@ornl.gov // ***************************************************************************/ @@ -132,17 +132,17 @@ texture mu_tex; #endif -__kernel void k_dipole_lj(const __global numtyp4 *restrict x_, +__kernel void k_dipole_lj(const __global numtyp4 *restrict x_, const __global numtyp4 *restrict lj1, - const __global numtyp4 *restrict lj3, - const int lj_types, - const __global numtyp *restrict sp_lj_in, - const __global int *dev_nbor, - const __global int *dev_packed, + const __global numtyp4 *restrict lj3, + const int lj_types, + const __global numtyp *restrict sp_lj_in, + const __global int *dev_nbor, + const __global int *dev_packed, __global acctyp4 *restrict ans, - __global acctyp *restrict engv, + __global acctyp *restrict engv, const int eflag, const int vflag, const int inum, - const int nbor_pitch, + const int nbor_pitch, const __global numtyp *restrict q_, const __global numtyp4 *restrict mu_, const __global numtyp *restrict cutsq, @@ -171,14 +171,14 @@ __kernel void k_dipole_lj(const __global numtyp4 *restrict x_, acctyp virial[6]; for (int i=0; i<6; i++) virial[i]=(acctyp)0; - + if (ii (numtyp)0.0 && muj.w > (numtyp)0.0) { - r3inv = r2inv*rinv; + r3inv = r2inv*rinv; r5inv = r3inv*r2inv; r7inv = r5inv*r2inv; pdotp = mui.x*muj.x + mui.y*muj.y + mui.z*muj.z; @@ -251,7 +251,7 @@ __kernel void k_dipole_lj(const __global numtyp4 *restrict x_, forcecoul.x += pre1*delx + pre2*mui.x + pre3*muj.x; forcecoul.y += pre1*dely + pre2*mui.y + pre3*muj.y; forcecoul.z += pre1*delz + pre2*mui.z + pre3*muj.z; - + numtyp crossx = pre4 * (mui.y*muj.z - mui.z*muj.y); numtyp crossy = pre4 * (mui.z*muj.x - mui.x*muj.z); numtyp crossz = pre4 * (mui.x*muj.y - mui.y*muj.x); @@ -263,12 +263,12 @@ __kernel void k_dipole_lj(const __global numtyp4 *restrict x_, // dipole-charge if (mui.w > (numtyp)0.0 && qj != (numtyp)0.0) { - r3inv = r2inv*rinv; + r3inv = r2inv*rinv; r5inv = r3inv*r2inv; pidotr = mui.x*delx + mui.y*dely + mui.z*delz; pre1 = (numtyp)3.0*qj*r5inv * pidotr; pre2 = qj*r3inv; - + forcecoul.x += pre2*mui.x - pre1*delx; forcecoul.y += pre2*mui.y - pre1*dely; forcecoul.z += pre2*mui.z - pre1*delz; @@ -276,7 +276,7 @@ __kernel void k_dipole_lj(const __global numtyp4 *restrict x_, ticoul.y += pre2 * (mui.z*delx - mui.x*delz); ticoul.z += pre2 * (mui.x*dely - mui.y*delx); } - + // charge-dipole if (muj.w > (numtyp)0.0 && qtmp != (numtyp)0.0) { r3inv = r2inv*rinv; @@ -284,7 +284,7 @@ __kernel void k_dipole_lj(const __global numtyp4 *restrict x_, pjdotr = muj.x*delx + muj.y*dely + muj.z*delz; pre1 = (numtyp)3.0*qtmp*r5inv * pjdotr; pre2 = qtmp*r3inv; - + forcecoul.x += pre1*delx - pre2*muj.x; forcecoul.y += pre1*dely - pre2*muj.y; forcecoul.z += pre1*delz - pre2*muj.z; @@ -306,12 +306,12 @@ __kernel void k_dipole_lj(const __global numtyp4 *restrict x_, tor.z+=fq*ticoul.z; if (eflag>0) { - acctyp e = (acctyp)0.0; + acctyp e = (acctyp)0.0; if (rsq < lj1[mtype].w) { e = qtmp*qj*rinv; if (mui.w > (numtyp)0.0 && muj.w > (numtyp)0.0) e += r3inv*pdotp - (numtyp)3.0*r5inv*pidotr*pjdotr; - if (mui.w > (numtyp)0.0 && qj != (numtyp)0.0) + if (mui.w > (numtyp)0.0 && qj != (numtyp)0.0) e += -qj*r3inv*pidotr; if (muj.w > (numtyp)0.0 && qtmp != (numtyp)0.0) e += qtmp*r3inv*pjdotr; @@ -322,7 +322,7 @@ __kernel void k_dipole_lj(const __global numtyp4 *restrict x_, if (rsq < lj1[mtype].z) { e=r6inv*(lj3[mtype].x*r6inv-lj3[mtype].y); energy+=factor_lj*(e-lj3[mtype].z); - } + } } if (vflag>0) { virial[0] += delx*force.x; @@ -340,19 +340,19 @@ __kernel void k_dipole_lj(const __global numtyp4 *restrict x_, } // if ii } -__kernel void k_dipole_lj_fast(const __global numtyp4 *restrict x_, +__kernel void k_dipole_lj_fast(const __global numtyp4 *restrict x_, const __global numtyp4 *restrict lj1_in, - const __global numtyp4 *restrict lj3_in, + const __global numtyp4 *restrict lj3_in, const __global numtyp *restrict sp_lj_in, - const __global int *dev_nbor, + const __global int *dev_nbor, const __global int *dev_packed, - __global acctyp4 *restrict ans, - __global acctyp *restrict engv, - const int eflag, const int vflag, const int inum, - const int nbor_pitch, + __global acctyp4 *restrict ans, + __global acctyp *restrict engv, + const int eflag, const int vflag, const int inum, + const int nbor_pitch, const __global numtyp *restrict q_, const __global numtyp4 *restrict mu_, - const __global numtyp *restrict _cutsq, + const __global numtyp *restrict _cutsq, const numtyp qqrd2e, const int t_per_atom) { int tid, ii, offset; atom_info(t_per_atom,ii,tid,offset); @@ -369,7 +369,7 @@ __kernel void k_dipole_lj_fast(const __global numtyp4 *restrict x_, if (eflag>0) lj3[tid]=lj3_in[tid]; } - + acctyp energy=(acctyp)0; acctyp e_coul=(acctyp)0; acctyp4 f; @@ -381,16 +381,16 @@ __kernel void k_dipole_lj_fast(const __global numtyp4 *restrict x_, acctyp virial[6]; for (int i=0; i<6; i++) virial[i]=(acctyp)0; - + __syncthreads(); - + if (ii (numtyp)0.0 && muj.w > (numtyp)0.0) { - r3inv = r2inv*rinv; + r3inv = r2inv*rinv; r5inv = r3inv*r2inv; r7inv = r5inv*r2inv; pdotp = mui.x*muj.x + mui.y*muj.y + mui.z*muj.z; @@ -463,7 +463,7 @@ __kernel void k_dipole_lj_fast(const __global numtyp4 *restrict x_, forcecoul.x += pre1*delx + pre2*mui.x + pre3*muj.x; forcecoul.y += pre1*dely + pre2*mui.y + pre3*muj.y; forcecoul.z += pre1*delz + pre2*mui.z + pre3*muj.z; - + numtyp crossx = pre4 * (mui.y*muj.z - mui.z*muj.y); numtyp crossy = pre4 * (mui.z*muj.x - mui.x*muj.z); numtyp crossz = pre4 * (mui.x*muj.y - mui.y*muj.x); @@ -474,13 +474,13 @@ __kernel void k_dipole_lj_fast(const __global numtyp4 *restrict x_, } // dipole-charge - if (mui.w > (numtyp)0.0 && qj != (numtyp)0.0) { + if (mui.w > (numtyp)0.0 && qj != (numtyp)0.0) { r3inv = r2inv*rinv; r5inv = r3inv*r2inv; pidotr = mui.x*delx + mui.y*dely + mui.z*delz; pre1 = (numtyp)3.0*qj*r5inv * pidotr; pre2 = qj*r3inv; - + forcecoul.x += pre2*mui.x - pre1*delx; forcecoul.y += pre2*mui.y - pre1*dely; forcecoul.z += pre2*mui.z - pre1*delz; @@ -488,7 +488,7 @@ __kernel void k_dipole_lj_fast(const __global numtyp4 *restrict x_, ticoul.y += pre2 * (mui.z*delx - mui.x*delz); ticoul.z += pre2 * (mui.x*dely - mui.y*delx); } - + // charge-dipole if (muj.w > (numtyp)0.0 && qtmp != (numtyp)0.0) { r3inv = r2inv*rinv; @@ -496,7 +496,7 @@ __kernel void k_dipole_lj_fast(const __global numtyp4 *restrict x_, pjdotr = muj.x*delx + muj.y*dely + muj.z*delz; pre1 = (numtyp)3.0*qtmp*r5inv * pjdotr; pre2 = qtmp*r3inv; - + forcecoul.x += pre1*delx - pre2*muj.x; forcecoul.y += pre1*dely - pre2*muj.y; forcecoul.z += pre1*delz - pre2*muj.z; @@ -519,12 +519,12 @@ __kernel void k_dipole_lj_fast(const __global numtyp4 *restrict x_, tor.z+=fq*ticoul.z; if (eflag>0) { - acctyp e = (acctyp)0; + acctyp e = (acctyp)0; if (rsq < lj1[mtype].w) { e = qtmp*qj*rinv; if (mui.w > (numtyp)0.0 && muj.w > (numtyp)0.0) e += r3inv*pdotp - (numtyp)3.0*r5inv*pidotr*pjdotr; - if (mui.w > (numtyp)0.0 && qj != (numtyp)0.0) + if (mui.w > (numtyp)0.0 && qj != (numtyp)0.0) e += -qj*r3inv*pidotr; if (muj.w > (numtyp)0.0 && qtmp != (numtyp)0.0) e += qtmp*r3inv*pjdotr; diff --git a/lib/gpu/lal_dipole_lj.h b/lib/gpu/lal_dipole_lj.h index b08b7a8669..615784ee8b 100644 --- a/lib/gpu/lal_dipole_lj.h +++ b/lib/gpu/lal_dipole_lj.h @@ -9,7 +9,7 @@ This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) __________________________________________________________________________ - begin : + begin : email : nguyentd@ornl.gov ***************************************************************************/ @@ -30,7 +30,7 @@ class DipoleLJ : public BaseDipole { /** \param max_nbors initial number of rows in the neighbor matrix * \param cell_size cutoff + skin * \param gpu_split fraction of particles handled by device - * + * * Returns: * - 0 if successfull * - -1 if fix gpu not found @@ -40,7 +40,7 @@ class DipoleLJ : public BaseDipole { int init(const int ntypes, double **host_cutsq, double **host_lj1, double **host_lj2, double **host_lj3, double **host_lj4, double **host_offset, double *host_special_lj, - const int nlocal, const int nall, const int max_nbors, + const int nlocal, const int nall, const int max_nbors, const int maxspecial, const double cell_size, const double gpu_split, FILE *screen, double **host_cut_ljsq, double **host_cut_coulsq, double *host_special_coul, @@ -70,7 +70,7 @@ class DipoleLJ : public BaseDipole { /// If atom type constants fit in shared memory, use fast kernels bool shared_types; - /// Number of atom types + /// Number of atom types int _lj_types; numtyp _qqrd2e; diff --git a/lib/gpu/lal_dipole_lj_ext.cpp b/lib/gpu/lal_dipole_lj_ext.cpp index 55bbe0b804..2591d3c0ed 100644 --- a/lib/gpu/lal_dipole_lj_ext.cpp +++ b/lib/gpu/lal_dipole_lj_ext.cpp @@ -9,7 +9,7 @@ This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) __________________________________________________________________________ - begin : + begin : email : nguyentd@ornl.gov ***************************************************************************/ @@ -81,7 +81,7 @@ int dpl_gpu_init(const int ntypes, double **cutsq, double **host_lj1, host_cut_coulsq, host_special_coul, qqrd2e); DPLMF.device->gpu_barrier(); - if (message) + if (message) fprintf(screen,"Done.\n"); } if (message) @@ -98,17 +98,17 @@ void dpl_gpu_clear() { int** dpl_gpu_compute_n(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, - double *sublo, double *subhi, tagint *tag, int **nspecial, + double *sublo, double *subhi, tagint *tag, int **nspecial, tagint **special, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, int **ilist, int **jnum, const double cpu_time, - bool &success, double *host_q, double **host_mu, + bool &success, double *host_q, double **host_mu, double *boxlo, double *prd) { return DPLMF.compute(ago, inum_full, nall, host_x, host_type, sublo, subhi, tag, nspecial, special, eflag, vflag, eatom, vatom, host_start, ilist, jnum, cpu_time, success, host_q, host_mu, boxlo, prd); -} +} void dpl_gpu_compute(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, int *ilist, int *numj, diff --git a/lib/gpu/lal_dipole_lj_sf.cpp b/lib/gpu/lal_dipole_lj_sf.cpp index 5a145dc762..a33f38084f 100644 --- a/lib/gpu/lal_dipole_lj_sf.cpp +++ b/lib/gpu/lal_dipole_lj_sf.cpp @@ -9,7 +9,7 @@ This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) __________________________________________________________________________ - begin : + begin : email : nguyentd@ornl.gov ***************************************************************************/ @@ -37,7 +37,7 @@ template DipoleLJSFT::~DipoleLJSF() { clear(); } - + template int DipoleLJSFT::bytes_per_atom(const int max_nbors) const { return this->bytes_per_atom_atomic(max_nbors); @@ -45,8 +45,8 @@ int DipoleLJSFT::bytes_per_atom(const int max_nbors) const { template int DipoleLJSFT::init(const int ntypes, - double **host_cutsq, double **host_lj1, - double **host_lj2, double **host_lj3, + double **host_cutsq, double **host_lj1, + double **host_lj2, double **host_lj3, double **host_lj4, double *host_special_lj, const int nlocal, const int nall, const int max_nbors, @@ -138,7 +138,7 @@ void DipoleLJSFT::loop(const bool _eflag, const bool _vflag) { vflag=1; else vflag=0; - + int GX=static_cast(ceil(static_cast(this->ans->inum())/ (BX/this->_threads_per_atom))); @@ -151,17 +151,17 @@ void DipoleLJSFT::loop(const bool _eflag, const bool _vflag) { &this->nbor->dev_nbor, &this->_nbor_data->begin(), &this->ans->force, &this->ans->engv, &eflag, &vflag, - &ainum, &nbor_pitch, &this->atom->q, + &ainum, &nbor_pitch, &this->atom->q, &this->atom->quat, &cutsq, &_qqrd2e, &this->_threads_per_atom); } else { this->k_pair.set_size(GX,BX); this->k_pair.run(&this->atom->x, &lj1, &lj3, &_lj_types, &sp_lj, &this->nbor->dev_nbor, - &this->_nbor_data->begin(), - &this->ans->force, &this->ans->engv, &eflag, &vflag, - &ainum, &nbor_pitch, &this->atom->q, - &this->atom->quat, &cutsq, + &this->_nbor_data->begin(), + &this->ans->force, &this->ans->engv, &eflag, &vflag, + &ainum, &nbor_pitch, &this->atom->q, + &this->atom->quat, &cutsq, &_qqrd2e, &this->_threads_per_atom); } this->time_pair.stop(); diff --git a/lib/gpu/lal_dipole_lj_sf.cu b/lib/gpu/lal_dipole_lj_sf.cu index 8469ed9ac9..5769c3a1a1 100644 --- a/lib/gpu/lal_dipole_lj_sf.cu +++ b/lib/gpu/lal_dipole_lj_sf.cu @@ -9,7 +9,7 @@ // This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) // __________________________________________________________________________ // -// begin : +// begin : // email : nguyentd@ornl.gov // ***************************************************************************/ @@ -133,20 +133,20 @@ texture mu_tex; #endif -__kernel void k_dipole_lj_sf(const __global numtyp4 *restrict x_, +__kernel void k_dipole_lj_sf(const __global numtyp4 *restrict x_, const __global numtyp4 *restrict lj1, - const __global numtyp4 *restrict lj3, - const int lj_types, - const __global numtyp *restrict sp_lj_in, - const __global int *dev_nbor, - const __global int *dev_packed, + const __global numtyp4 *restrict lj3, + const int lj_types, + const __global numtyp *restrict sp_lj_in, + const __global int *dev_nbor, + const __global int *dev_packed, __global acctyp4 *restrict ans, - __global acctyp *restrict engv, + __global acctyp *restrict engv, const int eflag, const int vflag, const int inum, - const int nbor_pitch, + const int nbor_pitch, const __global numtyp *restrict q_ , const __global numtyp4 *restrict mu_, - const __global numtyp *restrict cutsq, + const __global numtyp *restrict cutsq, const numtyp qqrd2e, const int t_per_atom) { int tid, ii, offset; atom_info(t_per_atom,ii,tid,offset); @@ -172,14 +172,14 @@ __kernel void k_dipole_lj_sf(const __global numtyp4 *restrict x_, acctyp virial[6]; for (int i=0; i<6; i++) virial[i]=(acctyp)0; - + if (ii (numtyp)0.0 && muj.w > (numtyp)0.0) { - r3inv = r2inv*rinv; + r3inv = r2inv*rinv; r5inv = r3inv*r2inv; - + pdotp = mui.x*muj.x + mui.y*muj.y + mui.z*muj.z; pidotr = mui.x*delx + mui.y*dely + mui.z*delz; pjdotr = muj.x*delx + muj.y*dely + muj.z*delz; - + afac = (numtyp)1.0 - rsq*rsq * rcutcoul2inv*rcutcoul2inv; pre1 = afac * (pdotp - (numtyp)3.0*r2inv*pidotr*pjdotr); aforcecoul.x = pre1*delx; aforcecoul.y = pre1*dely; aforcecoul.z = pre1*delz; - + bfac = (numtyp)1.0-(numtyp)4.0*rsq*ucl_sqrt(rsq)*rcutcoul2inv*ucl_sqrt(rcutcoul2inv)+ (numtyp)3.0*rsq*rsq*rcutcoul2inv*rcutcoul2inv; presf = (numtyp)2.0*r2inv*pidotr*pjdotr; bforcecoul.x = bfac * (pjdotr*mui.x+pidotr*muj.x-presf*delx); bforcecoul.y = bfac * (pjdotr*mui.y+pidotr*muj.y-presf*dely); bforcecoul.z = bfac * (pjdotr*mui.z+pidotr*muj.z-presf*delz); - + forcecoul.x += (numtyp)3.0*r5inv*(aforcecoul.x + bforcecoul.x); forcecoul.y += (numtyp)3.0*r5inv*(aforcecoul.y + bforcecoul.y); forcecoul.z += (numtyp)3.0*r5inv*(aforcecoul.z + bforcecoul.z); - + pre2 = (numtyp)3.0*bfac*r5inv*pjdotr; pre4 = -bfac*r3inv; numtyp crossx = pre4 * (mui.y*muj.z - mui.z*muj.y); numtyp crossy = pre4 * (mui.z*muj.x - mui.x*muj.z); numtyp crossz = pre4 * (mui.x*muj.y - mui.y*muj.x); - + ticoul.x += crossx + pre2 * (mui.y*delz - mui.z*dely); ticoul.y += crossy + pre2 * (mui.z*delx - mui.x*delz); ticoul.z += crossz + pre2 * (mui.x*dely - mui.y*delx); @@ -285,12 +285,12 @@ __kernel void k_dipole_lj_sf(const __global numtyp4 *restrict x_, // dipole-charge if (mui.w > (numtyp)0.0 && qj != (numtyp)0.0) { - r3inv = r2inv*rinv; + r3inv = r2inv*rinv; r5inv = r3inv*r2inv; pidotr = mui.x*delx + mui.y*dely + mui.z*delz; rcutcoul2inv=ucl_recip(lj1[mtype].w); pre1 = (numtyp)3.0*qj*r5inv * pidotr*((numtyp)1.0-rsq*rcutcoul2inv); - pqfac = (numtyp)1.0 - (numtyp)3.0*rsq*rcutcoul2inv + + pqfac = (numtyp)1.0 - (numtyp)3.0*rsq*rcutcoul2inv + (numtyp)2.0*rsq*ucl_sqrt(rsq)*rcutcoul2inv*ucl_sqrt(rcutcoul2inv); pre2 = qj*r3inv * pqfac; @@ -301,7 +301,7 @@ __kernel void k_dipole_lj_sf(const __global numtyp4 *restrict x_, ticoul.y += pre2 * (mui.z*delx - mui.x*delz); ticoul.z += pre2 * (mui.x*dely - mui.y*delx); } - + // charge-dipole if (muj.w > (numtyp)0.0 && qtmp != (numtyp)0.0) { r3inv = r2inv*rinv; @@ -309,10 +309,10 @@ __kernel void k_dipole_lj_sf(const __global numtyp4 *restrict x_, pjdotr = muj.x*delx + muj.y*dely + muj.z*delz; rcutcoul2inv=ucl_recip(lj1[mtype].w); pre1 = (numtyp)3.0*qtmp*r5inv * pjdotr*((numtyp)1.0-rsq*rcutcoul2inv); - qpfac = (numtyp)1.0 - (numtyp)3.0*rsq*rcutcoul2inv + + qpfac = (numtyp)1.0 - (numtyp)3.0*rsq*rcutcoul2inv + (numtyp)2.0*rsq*ucl_sqrt(rsq)*rcutcoul2inv*ucl_sqrt(rcutcoul2inv); pre2 = qtmp*r3inv * qpfac; - + forcecoul.x += pre1*delx - pre2*muj.x; forcecoul.y += pre1*dely - pre2*muj.y; forcecoul.z += pre1*delz - pre2*muj.z; @@ -334,13 +334,13 @@ __kernel void k_dipole_lj_sf(const __global numtyp4 *restrict x_, tor.z+=fq*ticoul.z; if (eflag>0) { - acctyp e = (acctyp)0.0; + acctyp e = (acctyp)0.0; if (rsq < lj1[mtype].w) { numtyp fac = (numtyp)1.0-ucl_sqrt(rsq*rcutcoul2inv); e = qtmp*qj*rinv*fac*fac; if (mui.w > (numtyp)0.0 && muj.w > (numtyp)0.0) e += bfac* (r3inv*pdotp - (numtyp)3.0*r5inv*pidotr*pjdotr); - if (mui.w > (numtyp)0.0 && qj != (numtyp)0.0) + if (mui.w > (numtyp)0.0 && qj != (numtyp)0.0) e += -qj*r3inv*pidotr * pqfac; if (muj.w > (numtyp)0.0 && qtmp != (numtyp)0.0) e += qtmp*r3inv*pjdotr * qpfac; @@ -350,12 +350,12 @@ __kernel void k_dipole_lj_sf(const __global numtyp4 *restrict x_, if (rsq < lj1[mtype].z) { e=r6inv*(lj3[mtype].x*r6inv-lj3[mtype].y) + - rcutlj6inv*((numtyp)6.0*lj3[mtype].x*rcutlj6inv - + rcutlj6inv*((numtyp)6.0*lj3[mtype].x*rcutlj6inv - (numtyp)3.0*lj3[mtype].y)*rsq*rcutlj2inv + - rcutlj6inv*((numtyp)(-7.0)*lj3[mtype].x*rcutlj6inv + + rcutlj6inv*((numtyp)(-7.0)*lj3[mtype].x*rcutlj6inv + (numtyp)4.0*lj3[mtype].y); energy+=factor_lj*e; - } + } } if (vflag>0) { virial[0] += delx*force.x; @@ -372,19 +372,19 @@ __kernel void k_dipole_lj_sf(const __global numtyp4 *restrict x_, } // if ii } -__kernel void k_dipole_lj_sf_fast(const __global numtyp4 *restrict x_, +__kernel void k_dipole_lj_sf_fast(const __global numtyp4 *restrict x_, const __global numtyp4 *restrict lj1_in, - const __global numtyp4 *restrict lj3_in, + const __global numtyp4 *restrict lj3_in, const __global numtyp *restrict sp_lj_in, - const __global int *dev_nbor, + const __global int *dev_nbor, const __global int *dev_packed, - __global acctyp4 *restrict ans, - __global acctyp *restrict engv, - const int eflag, const int vflag, - const int inum, const int nbor_pitch, + __global acctyp4 *restrict ans, + __global acctyp *restrict engv, + const int eflag, const int vflag, + const int inum, const int nbor_pitch, const __global numtyp *restrict q_, const __global numtyp4 *restrict mu_, - const __global numtyp *restrict _cutsq, + const __global numtyp *restrict _cutsq, const numtyp qqrd2e, const int t_per_atom) { int tid, ii, offset; @@ -402,7 +402,7 @@ __kernel void k_dipole_lj_sf_fast(const __global numtyp4 *restrict x_, if (eflag>0) lj3[tid]=lj3_in[tid]; } - + acctyp energy=(acctyp)0; acctyp e_coul=(acctyp)0; acctyp4 f; @@ -414,16 +414,16 @@ __kernel void k_dipole_lj_sf_fast(const __global numtyp4 *restrict x_, acctyp virial[6]; for (int i=0; i<6; i++) virial[i]=(acctyp)0; - + __syncthreads(); - + if (ii (numtyp)0.0 && muj.w > (numtyp)0.0) { - r3inv = r2inv*rinv; + r3inv = r2inv*rinv; r5inv = r3inv*r2inv; - + pdotp = mui.x*muj.x + mui.y*muj.y + mui.z*muj.z; pidotr = mui.x*delx + mui.y*dely + mui.z*delz; pjdotr = muj.x*delx + muj.y*dely + muj.z*delz; - + afac = (numtyp)1.0 - rsq*rsq * rcutcoul2inv*rcutcoul2inv; pre1 = afac * (pdotp - (numtyp)3.0*r2inv*pidotr*pjdotr); aforcecoul.x = pre1*delx; aforcecoul.y = pre1*dely; aforcecoul.z = pre1*delz; - + bfac = (numtyp)1.0-(numtyp)4.0*rsq*ucl_sqrt(rsq)*rcutcoul2inv*ucl_sqrt(rcutcoul2inv)+ (numtyp)3.0*rsq*rsq*rcutcoul2inv*rcutcoul2inv; presf = (numtyp)2.0*r2inv*pidotr*pjdotr; bforcecoul.x = bfac * (pjdotr*mui.x+pidotr*muj.x-presf*delx); bforcecoul.y = bfac * (pjdotr*mui.y+pidotr*muj.y-presf*dely); bforcecoul.z = bfac * (pjdotr*mui.z+pidotr*muj.z-presf*delz); - + forcecoul.x += (numtyp)3.0*r5inv*(aforcecoul.x + bforcecoul.x); forcecoul.y += (numtyp)3.0*r5inv*(aforcecoul.y + bforcecoul.y); forcecoul.z += (numtyp)3.0*r5inv*(aforcecoul.z + bforcecoul.z); - + pre2 = (numtyp)3.0*bfac*r5inv*pjdotr; pre4 = -bfac*r3inv; @@ -529,11 +529,11 @@ __kernel void k_dipole_lj_sf_fast(const __global numtyp4 *restrict x_, // dipole-charge if (mui.w > (numtyp)0.0 && qj != (numtyp)0.0) { - r3inv = r2inv*rinv; + r3inv = r2inv*rinv; r5inv = r3inv*r2inv; pidotr = mui.x*delx + mui.y*dely + mui.z*delz; pre1 = (numtyp)3.0*qj*r5inv * pidotr*((numtyp)1.0-rsq*rcutcoul2inv); - pqfac = (numtyp)1.0 - (numtyp)3.0*rsq*rcutcoul2inv + + pqfac = (numtyp)1.0 - (numtyp)3.0*rsq*rcutcoul2inv + (numtyp)2.0*rsq*ucl_sqrt(rsq)*rcutcoul2inv*ucl_sqrt(rcutcoul2inv); pre2 = qj*r3inv * pqfac; @@ -544,7 +544,7 @@ __kernel void k_dipole_lj_sf_fast(const __global numtyp4 *restrict x_, ticoul.y += pre2 * (mui.z*delx - mui.x*delz); ticoul.z += pre2 * (mui.x*dely - mui.y*delx); } - + // charge-dipole if (muj.w > (numtyp)0.0 && qtmp != (numtyp)0.0) { r3inv = r2inv*rinv; @@ -552,10 +552,10 @@ __kernel void k_dipole_lj_sf_fast(const __global numtyp4 *restrict x_, pjdotr = muj.x*delx + muj.y*dely + muj.z*delz; pre1 = (numtyp)3.0*qtmp*r5inv * pjdotr*((numtyp)1.0-rsq*rcutcoul2inv); - qpfac = (numtyp)1.0 - (numtyp)3.0*rsq*rcutcoul2inv + + qpfac = (numtyp)1.0 - (numtyp)3.0*rsq*rcutcoul2inv + (numtyp)2.0*rsq*ucl_sqrt(rsq)*rcutcoul2inv*ucl_sqrt(rcutcoul2inv); pre2 = qtmp*r3inv * qpfac; - + forcecoul.x += pre1*delx - pre2*muj.x; forcecoul.y += pre1*dely - pre2*muj.y; forcecoul.z += pre1*delz - pre2*muj.z; @@ -577,13 +577,13 @@ __kernel void k_dipole_lj_sf_fast(const __global numtyp4 *restrict x_, tor.z+=fq*ticoul.z; if (eflag>0) { - acctyp e = (acctyp)0.0; + acctyp e = (acctyp)0.0; if (rsq < lj1[mtype].w) { numtyp fac = (numtyp)1.0-ucl_sqrt(rsq*rcutcoul2inv); e = qtmp*qj*rinv*fac*fac; if (mui.w > (numtyp)0.0 && muj.w > (numtyp)0.0) e += bfac* (r3inv*pdotp - (numtyp)3.0*r5inv*pidotr*pjdotr); - if (mui.w > (numtyp)0.0 && qj != (numtyp)0.0) + if (mui.w > (numtyp)0.0 && qj != (numtyp)0.0) e += -qj*r3inv*pidotr * pqfac; if (muj.w > (numtyp)0.0 && qtmp != (numtyp)0.0) e += qtmp*r3inv*pjdotr * qpfac; @@ -593,12 +593,12 @@ __kernel void k_dipole_lj_sf_fast(const __global numtyp4 *restrict x_, if (rsq < lj1[mtype].z) { e=r6inv*(lj3[mtype].x*r6inv-lj3[mtype].y) + - rcutlj6inv*((numtyp)6.0*lj3[mtype].x*rcutlj6inv - + rcutlj6inv*((numtyp)6.0*lj3[mtype].x*rcutlj6inv - (numtyp)3.0*lj3[mtype].y)*rsq*rcutlj2inv + - rcutlj6inv*((numtyp)(-7.0)*lj3[mtype].x*rcutlj6inv + + rcutlj6inv*((numtyp)(-7.0)*lj3[mtype].x*rcutlj6inv + (numtyp)4.0*lj3[mtype].y); energy+=factor_lj*e; - } + } } if (vflag>0) { virial[0] += delx*force.x; diff --git a/lib/gpu/lal_dipole_lj_sf.h b/lib/gpu/lal_dipole_lj_sf.h index 83cea4c2a4..20357385a2 100644 --- a/lib/gpu/lal_dipole_lj_sf.h +++ b/lib/gpu/lal_dipole_lj_sf.h @@ -9,7 +9,7 @@ This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) __________________________________________________________________________ - begin : + begin : email : nguyentd@ornl.gov ***************************************************************************/ @@ -30,7 +30,7 @@ class DipoleLJSF : public BaseDipole { /** \param max_nbors initial number of rows in the neighbor matrix * \param cell_size cutoff + skin * \param gpu_split fraction of particles handled by device - * + * * Returns: * - 0 if successfull * - -1 if fix gpu not found @@ -40,7 +40,7 @@ class DipoleLJSF : public BaseDipole { int init(const int ntypes, double **host_cutsq, double **host_lj1, double **host_lj2, double **host_lj3, double **host_lj4, double *host_special_lj, - const int nlocal, const int nall, const int max_nbors, + const int nlocal, const int nall, const int max_nbors, const int maxspecial, const double cell_size, const double gpu_split, FILE *screen, double **host_cut_ljsq, double **host_cut_coulsq, double *host_special_coul, @@ -70,7 +70,7 @@ class DipoleLJSF : public BaseDipole { /// If atom type constants fit in shared memory, use fast kernels bool shared_types; - /// Number of atom types + /// Number of atom types int _lj_types; numtyp _qqrd2e; diff --git a/lib/gpu/lal_dipole_lj_sf_ext.cpp b/lib/gpu/lal_dipole_lj_sf_ext.cpp index 8abf78c903..840afbe1c2 100644 --- a/lib/gpu/lal_dipole_lj_sf_ext.cpp +++ b/lib/gpu/lal_dipole_lj_sf_ext.cpp @@ -9,7 +9,7 @@ This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) __________________________________________________________________________ - begin : + begin : email : nguyentd@ornl.gov ***************************************************************************/ @@ -81,7 +81,7 @@ int dplsf_gpu_init(const int ntypes, double **cutsq, double **host_lj1, host_cut_coulsq, host_special_coul, qqrd2e); DPLSFMF.device->gpu_barrier(); - if (message) + if (message) fprintf(screen,"Done.\n"); } if (message) @@ -98,17 +98,17 @@ void dplsf_gpu_clear() { int** dplsf_gpu_compute_n(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, - double *sublo, double *subhi, tagint *tag, int **nspecial, + double *sublo, double *subhi, tagint *tag, int **nspecial, tagint **special, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, int **ilist, int **jnum, const double cpu_time, - bool &success, double *host_q, double **host_mu, + bool &success, double *host_q, double **host_mu, double *boxlo, double *prd) { return DPLSFMF.compute(ago, inum_full, nall, host_x, host_type, sublo, subhi, tag, nspecial, special, eflag, vflag, eatom, vatom, host_start, ilist, jnum, cpu_time, success, host_q, host_mu, boxlo, prd); -} +} void dplsf_gpu_compute(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, int *ilist, int *numj, diff --git a/lib/gpu/lal_dpd.cpp b/lib/gpu/lal_dpd.cpp index 3736f89323..f05707ef1d 100644 --- a/lib/gpu/lal_dpd.cpp +++ b/lib/gpu/lal_dpd.cpp @@ -33,23 +33,23 @@ DPDT::DPD() : BaseDPD(), _allocated(false) { } template -DPDT::~DPD() { +DPDT::~DPD() { clear(); } - + template int DPDT::bytes_per_atom(const int max_nbors) const { return this->bytes_per_atom_atomic(max_nbors); } template -int DPDT::init(const int ntypes, - double **host_cutsq, double **host_a0, - double **host_gamma, double **host_sigma, +int DPDT::init(const int ntypes, + double **host_cutsq, double **host_a0, + double **host_gamma, double **host_sigma, double **host_cut, double *host_special_lj, - const bool tstat_only, - const int nlocal, const int nall, - const int max_nbors, const int maxspecial, + const bool tstat_only, + const int nlocal, const int nall, + const int max_nbors, const int maxspecial, const double cell_size, const double gpu_split, FILE *_screen) { int success; @@ -90,7 +90,7 @@ int DPDT::init(const int ntypes, _tstat_only = 0; if (tstat_only) _tstat_only=1; - + _allocated=true; this->_max_bytes=coeff.row_bytes()+cutsq.row_bytes()+sp_lj.row_bytes(); return 0; @@ -130,7 +130,7 @@ void DPDT::loop(const bool _eflag, const bool _vflag) { vflag=1; else vflag=0; - + int GX=static_cast(ceil(static_cast(this->ans->inum())/ (BX/this->_threads_per_atom))); @@ -147,8 +147,8 @@ void DPDT::loop(const bool _eflag, const bool _vflag) { &this->_tstat_only, &this->_threads_per_atom); } else { this->k_pair.set_size(GX,BX); - this->k_pair.run(&this->atom->x, &coeff, &_lj_types, &sp_lj, - &this->nbor->dev_nbor, &this->_nbor_data->begin(), + this->k_pair.run(&this->atom->x, &coeff, &_lj_types, &sp_lj, + &this->nbor->dev_nbor, &this->_nbor_data->begin(), &this->ans->force, &this->ans->engv, &eflag, &vflag, &ainum, &nbor_pitch, &this->atom->v, &cutsq, &this->_dtinvsqrt, &this->_seed, &this->_timestep, &this->_tstat_only, @@ -166,5 +166,5 @@ void DPDT::update_coeff(int ntypes, double **host_a0, double **host_gamma, this->atom->type_pack4(ntypes,_lj_types,coeff,host_write,host_a0,host_gamma, host_sigma,host_cut); } - + template class DPD; diff --git a/lib/gpu/lal_dpd.cu b/lib/gpu/lal_dpd.cu index 209bc0233e..e32404ff5c 100644 --- a/lib/gpu/lal_dpd.cu +++ b/lib/gpu/lal_dpd.cu @@ -37,7 +37,7 @@ texture vel_tex; #define _USE_UNIFORM_SARU_LCG #endif -// References: +// References: // 1. Y. Afshar, F. Schmid, A. Pishevar, S. Worley, Comput. Phys. Comm. 184 (2013), 1119–1128. // 2. C. L. Phillips, J. A. Anderson, S. C. Glotzer, Comput. Phys. Comm. 230 (2011), 7191-7201. // PRNG period = 3666320093*2^32 ~ 2^64 ~ 10^19 @@ -49,9 +49,9 @@ texture vel_tex; #define TWO_N32 0.232830643653869628906250e-9f /* 2^-32 */ // specifically implemented for steps = 1; high = 1.0; low = -1.0 -// returns uniformly distributed random numbers u in [-1.0;1.0] -// using the inherent LCG, then multiply u with sqrt(3) to "match" -// with a normal random distribution. +// returns uniformly distributed random numbers u in [-1.0;1.0] +// using the inherent LCG, then multiply u with sqrt(3) to "match" +// with a normal random distribution. // Afshar et al. mutlplies u in [-0.5;0.5] with sqrt(12) // Curly brackets to make variables local to the scope. #ifdef _USE_UNIFORM_SARU_LCG @@ -80,8 +80,8 @@ texture vel_tex; #endif // specifically implemented for steps = 1; high = 1.0; low = -1.0 -// returns uniformly distributed random numbers u in [-1.0;1.0] using TEA8 -// then multiply u with sqrt(3) to "match" with a normal random distribution +// returns uniformly distributed random numbers u in [-1.0;1.0] using TEA8 +// then multiply u with sqrt(3) to "match" with a normal random distribution // Afshar et al. mutlplies u in [-0.5;0.5] with sqrt(12) #ifdef _USE_UNIFORM_SARU_TEA8 #define SQRT3 (numtyp)1.7320508075688772935274463 @@ -119,7 +119,7 @@ texture vel_tex; #endif // specifically implemented for steps = 1; high = 1.0; low = -1.0 -// returns two uniformly distributed random numbers r1 and r2 in [-1.0;1.0], +// returns two uniformly distributed random numbers r1 and r2 in [-1.0;1.0], // and uses the polar method (Marsaglia's) to transform to a normal random value // This is used to compared with CPU DPD using RandMars::gaussian() #ifdef _USE_GAUSSIAN_SARU_LCG @@ -160,20 +160,20 @@ texture vel_tex; randnum = r2*fac; \ } #endif - -__kernel void k_dpd(const __global numtyp4 *restrict x_, + +__kernel void k_dpd(const __global numtyp4 *restrict x_, const __global numtyp4 *restrict coeff, - const int lj_types, - const __global numtyp *restrict sp_lj, - const __global int * dev_nbor, - const __global int * dev_packed, - __global acctyp4 *restrict ans, - __global acctyp *restrict engv, + const int lj_types, + const __global numtyp *restrict sp_lj, + const __global int * dev_nbor, + const __global int * dev_packed, + __global acctyp4 *restrict ans, + __global acctyp *restrict engv, const int eflag, const int vflag, const int inum, - const int nbor_pitch, + const int nbor_pitch, const __global numtyp4 *restrict v_, const __global numtyp *restrict cutsq, - const numtyp dtinvsqrt, const int seed, + const numtyp dtinvsqrt, const int seed, const int timestep, const int tstat_only, const int t_per_atom) { int tid, ii, offset; @@ -185,13 +185,13 @@ __kernel void k_dpd(const __global numtyp4 *restrict x_, acctyp virial[6]; for (int i=0; i<6; i++) virial[i]=(acctyp)0; - + if (ii tag2) { tag1 = jtag; tag2 = itag; } - - numtyp randnum = (numtyp)0.0; + + numtyp randnum = (numtyp)0.0; saru(tag1, tag2, seed, timestep, randnum); // conservative force = a0 * wd, or 0 if tstat only @@ -244,7 +244,7 @@ __kernel void k_dpd(const __global numtyp4 *restrict x_, force -= coeff[mtype].y*wd*wd*dot*rinv; force += coeff[mtype].z*wd*randnum*dtinvsqrt; force*=factor_dpd*rinv; - + f.x+=delx*force; f.y+=dely*force; f.z+=delz*force; @@ -254,7 +254,7 @@ __kernel void k_dpd(const __global numtyp4 *restrict x_, // evdwl = -a0[itype][jtype]*r * (1.0-0.5*r/cut[itype][jtype]); // eng shifted to 0.0 at cutoff numtyp e = (numtyp)0.5*coeff[mtype].x*coeff[mtype].w * wd*wd; - energy+=factor_dpd*e; + energy+=factor_dpd*e; } if (vflag>0) { virial[0] += delx*delx*force; @@ -272,23 +272,23 @@ __kernel void k_dpd(const __global numtyp4 *restrict x_, } // if ii } -__kernel void k_dpd_fast(const __global numtyp4 *restrict x_, +__kernel void k_dpd_fast(const __global numtyp4 *restrict x_, const __global numtyp4 *restrict coeff_in, - const __global numtyp *restrict sp_lj_in, - const __global int * dev_nbor, - const __global int * dev_packed, - __global acctyp4 *restrict ans, - __global acctyp *restrict engv, - const int eflag, const int vflag, const int inum, + const __global numtyp *restrict sp_lj_in, + const __global int * dev_nbor, + const __global int * dev_packed, + __global acctyp4 *restrict ans, + __global acctyp *restrict engv, + const int eflag, const int vflag, const int inum, const int nbor_pitch, const __global numtyp4 *restrict v_, const __global numtyp *restrict cutsq, - const numtyp dtinvsqrt, const int seed, + const numtyp dtinvsqrt, const int seed, const int timestep, const int tstat_only, const int t_per_atom) { int tid, ii, offset; atom_info(t_per_atom,ii,tid,offset); - + __local numtyp4 coeff[MAX_SHARED_TYPES*MAX_SHARED_TYPES]; __local numtyp sp_lj[4]; if (tid<4) @@ -296,7 +296,7 @@ __kernel void k_dpd_fast(const __global numtyp4 *restrict x_, if (tid tag2) { tag1 = jtag; tag2 = itag; } - - numtyp randnum = (numtyp)0.0; + + numtyp randnum = (numtyp)0.0; saru(tag1, tag2, seed, timestep, randnum); // conservative force = a0 * wd, or 0 if tstat only @@ -364,7 +364,7 @@ __kernel void k_dpd_fast(const __global numtyp4 *restrict x_, force -= coeff[mtype].y*wd*wd*dot*rinv; force += coeff[mtype].z*wd*randnum*dtinvsqrt; force*=factor_dpd*rinv; - + f.x+=delx*force; f.y+=dely*force; f.z+=delz*force; @@ -374,7 +374,7 @@ __kernel void k_dpd_fast(const __global numtyp4 *restrict x_, // evdwl = -a0[itype][jtype]*r * (1.0-0.5*r/cut[itype][jtype]); // eng shifted to 0.0 at cutoff numtyp e = (numtyp)0.5*coeff[mtype].x*coeff[mtype].w * wd*wd; - energy+=factor_dpd*e; + energy+=factor_dpd*e; } if (vflag>0) { virial[0] += delx*delx*force; diff --git a/lib/gpu/lal_dpd.h b/lib/gpu/lal_dpd.h index 449d7b1d8c..42ef854522 100644 --- a/lib/gpu/lal_dpd.h +++ b/lib/gpu/lal_dpd.h @@ -24,23 +24,23 @@ template class DPD : public BaseDPD { public: DPD(); - ~DPD(); + ~DPD(); /// Clear any previous data and set up for a new LAMMPS run /** \param max_nbors initial number of rows in the neighbor matrix * \param cell_size cutoff + skin * \param gpu_split fraction of particles handled by device - * + * * Returns: * - 0 if successfull * - -1 if fix gpu not found * - -3 if there is an out of memory error * - -4 if the GPU library was not compiled for GPU * - -5 Double precision is not supported on card **/ - int init(const int ntypes, double **host_cutsq, double **host_a0, + int init(const int ntypes, double **host_cutsq, double **host_a0, double **host_gamma, double **host_sigma, double **host_cut, double *host_special_lj, bool tstat_only, const int nlocal, - const int nall, const int max_nbors, const int maxspecial, + const int nall, const int max_nbors, const int maxspecial, const double cell_size, const double gpu_split, FILE *screen); /// Clear all host and device data @@ -52,11 +52,11 @@ class DPD : public BaseDPD { /// Total host memory used by library for pair style double host_memory_usage() const; - + /// Update coeff if needed (tstat only) void update_coeff(int ntypes, double **host_a0, double **host_gamma, double **host_sigma, double **host_cut); - + // --------------------------- TYPE DATA -------------------------- /// coeff.x = a0, coeff.y = gamma, coeff.z = sigma, coeff.w = cut @@ -70,12 +70,12 @@ class DPD : public BaseDPD { /// If atom type constants fit in shared memory, use fast kernels bool shared_types; - /// Number of atom types + /// Number of atom types int _lj_types; - + /// Only used for thermostat int _tstat_only; - + private: bool _allocated; void loop(const bool _eflag, const bool _vflag); diff --git a/lib/gpu/lal_dpd_ext.cpp b/lib/gpu/lal_dpd_ext.cpp index 327074d087..792f638cd8 100644 --- a/lib/gpu/lal_dpd_ext.cpp +++ b/lib/gpu/lal_dpd_ext.cpp @@ -54,7 +54,7 @@ int dpd_gpu_init(const int ntypes, double **cutsq, double **host_a0, int init_ok=0; if (world_me==0) - init_ok=DPDMF.init(ntypes, cutsq, host_a0, host_gamma, host_sigma, + init_ok=DPDMF.init(ntypes, cutsq, host_a0, host_gamma, host_sigma, host_cut, special_lj, tstat_only, inum, nall, 300, maxspecial, cell_size, gpu_split, screen); @@ -72,12 +72,12 @@ int dpd_gpu_init(const int ntypes, double **cutsq, double **host_a0, fflush(screen); } if (gpu_rank==i && world_me!=0) - init_ok=DPDMF.init(ntypes, cutsq, host_a0, host_gamma, host_sigma, + init_ok=DPDMF.init(ntypes, cutsq, host_a0, host_gamma, host_sigma, host_cut, special_lj, tstat_only, inum, nall, 300, maxspecial, cell_size, gpu_split, screen); DPDMF.device->gpu_barrier(); - if (message) + if (message) fprintf(screen,"Done.\n"); } if (message) @@ -95,25 +95,25 @@ void dpd_gpu_clear() { int ** dpd_gpu_compute_n(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, double *sublo, double *subhi, tagint *tag, int **nspecial, - tagint **special, const bool eflag, const bool vflag, - const bool eatom, const bool vatom, int &host_start, + tagint **special, const bool eflag, const bool vflag, + const bool eatom, const bool vatom, int &host_start, int **ilist, int **jnum, const double cpu_time, bool &success, - double **host_v, const double dtinvsqrt, + double **host_v, const double dtinvsqrt, const int seed, const int timestep, double *boxlo, double *prd) { return DPDMF.compute(ago, inum_full, nall, host_x, host_type, sublo, subhi, tag, nspecial, special, eflag, vflag, eatom, - vatom, host_start, ilist, jnum, cpu_time, success, + vatom, host_start, ilist, jnum, cpu_time, success, host_v, dtinvsqrt, seed, timestep, boxlo, prd); -} +} void dpd_gpu_compute(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, int *ilist, int *numj, int **firstneigh, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, const double cpu_time, bool &success, tagint *tag, - double **host_v, const double dtinvsqrt, - const int seed, const int timestep, + double **host_v, const double dtinvsqrt, + const int seed, const int timestep, const int nlocal, double *boxlo, double *prd) { DPDMF.compute(ago, inum_full, nall, host_x, host_type, ilist, numj, firstneigh, eflag, vflag, eatom, vatom, host_start, cpu_time, success, diff --git a/lib/gpu/lal_eam.cpp b/lib/gpu/lal_eam.cpp index c856a8e667..b83972f4db 100644 --- a/lib/gpu/lal_eam.cpp +++ b/lib/gpu/lal_eam.cpp @@ -9,10 +9,10 @@ This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) __________________________________________________________________________ - begin : + begin : email : brownw@ornl.gov nguyentd@ornl.gov ***************************************************************************/ - + #if defined(USE_OPENCL) #include "eam_cl.h" #elif defined(USE_CUDART) @@ -33,7 +33,7 @@ using namespace LAMMPS_AL; extern Device device; template -EAMT::EAM() : BaseAtomic(), +EAMT::EAM() : BaseAtomic(), _compiled_energy(false), _allocated(false) { } @@ -41,46 +41,46 @@ template EAMT::~EAM() { clear(); } - + template int EAMT::init(const int ntypes, double host_cutforcesq, int **host_type2rhor, int **host_type2z2r, int *host_type2frho, double ***host_rhor_spline, double ***host_z2r_spline, - double ***host_frho_spline, double rdr, double rdrho, + double ***host_frho_spline, double rdr, double rdrho, double rhomax, int nrhor, int nrho, int nz2r, int nfrho, int nr, const int nlocal, const int nall, const int max_nbors, - const int maxspecial, const double cell_size, - const double gpu_split, FILE *_screen) + const int maxspecial, const double cell_size, + const double gpu_split, FILE *_screen) { int success; success=this->init_atomic(nlocal,nall,max_nbors,maxspecial,cell_size, gpu_split,_screen,eam,"k_eam"); - + if (success!=0) return success; - + // allocate fp - + int ef_nall=nall; if (ef_nall==0) ef_nall=2000; _max_fp_size=static_cast(static_cast(ef_nall)*1.10); _fp.alloc(_max_fp_size,*(this->ucl_device),UCL_READ_WRITE,UCL_READ_WRITE); - + k_energy.set_function(*(this->pair_program),"k_energy"); k_energy_fast.set_function(*(this->pair_program),"k_energy_fast"); fp_tex.get_texture(*(this->pair_program),"fp_tex"); fp_tex.bind_float(_fp,1); _compiled_energy = true; - + // Initialize timers for selected GPU time_pair2.init(*(this->ucl_device)); time_pair2.zero(); - + time_fp1.init(*(this->ucl_device)); time_fp1.zero(); - + time_fp2.init(*(this->ucl_device)); time_fp2.zero(); @@ -93,7 +93,7 @@ int EAMT::init(const int ntypes, double host_cutforcesq, int **host_type2rhor, lj_types=max_shared_types; shared_types=true; } - + _ntypes=lj_types; _cutforcesq=host_cutforcesq; _rdr=rdr; @@ -104,26 +104,26 @@ int EAMT::init(const int ntypes, double host_cutforcesq, int **host_type2rhor, _nz2r=nz2r; _nfrho=nfrho; _nr=nr; - + UCL_H_Vec dview_type(lj_types*lj_types,*(this->ucl_device), UCL_WRITE_ONLY); - + for (int i=0; iucl_device),UCL_READ_ONLY); - + for (int i=0; i dview_type2frho(lj_types,*(this->ucl_device), UCL_WRITE_ONLY); @@ -136,7 +136,7 @@ int EAMT::init(const int ntypes, double host_cutforcesq, int **host_type2rhor, // pack frho_spline UCL_H_Vec dview_frho_spline(nfrho*(nrho+1),*(this->ucl_device), UCL_WRITE_ONLY); - + for (int ix=0; ix dview_rhor_spline(nrhor*(nr+1),*(this->ucl_device), UCL_WRITE_ONLY); - + for (int ix=0; ix dview_z2r_spline(nz2r*(nr+1),*(this->ucl_device), UCL_WRITE_ONLY); - + for (int ix=0; ixucl_device),UCL_READ_ONLY); ucl_copy(z2r_spline1,dview_z2r_spline,false); z2r_spline1_tex.get_texture(*(this->pair_program),"z2r_sp1_tex"); z2r_spline1_tex.bind_float(z2r_spline1,4); - + for (int ix=0; ixucl_device),UCL_READ_ONLY); ucl_copy(z2r_spline2,dview_z2r_spline,false); z2r_spline2_tex.get_texture(*(this->pair_program),"z2r_sp2_tex"); @@ -241,7 +241,7 @@ void EAMT::clear() { if (!_allocated) return; _allocated=false; - + type2rhor_z2r.clear(); type2frho.clear(); rhor_spline1.clear(); @@ -250,13 +250,13 @@ void EAMT::clear() { frho_spline2.clear(); z2r_spline1.clear(); z2r_spline2.clear(); - + _fp.clear(); - + time_pair2.clear(); time_fp1.clear(); time_fp2.clear(); - + if (_compiled_energy) { k_energy_fast.clear(); k_energy.clear(); @@ -283,20 +283,20 @@ void EAMT::compute(const int f_ago, const int inum_full, const int nlocal, int &host_start, const double cpu_time, bool &success, void **fp_ptr) { this->acc_timers(); - + if (this->device->time_device()) { // Put time from the second part to the total time_pair this->time_pair.add_time_to_total(time_pair2.time()); - + // Add transfer time from device -> host after part 1 this->atom->add_transfer_time(time_fp1.time()); - + // Add transfer time from host -> device before part 2 this->atom->add_transfer_time(time_fp2.time()); } - + // ------------------- Resize FP Array for EAM -------------------- - + if (nall>_max_fp_size) { _max_fp_size=static_cast(static_cast(nall)*1.10); _fp.resize(_max_fp_size); @@ -313,7 +313,7 @@ void EAMT::compute(const int f_ago, const int inum_full, const int nlocal, this->zero_timers(); return; } - + int ago=this->hd_balancer.ago_first(f_ago); int inum=this->hd_balancer.balance(ago,inum_full,cpu_time); this->ans->inum(inum); @@ -326,7 +326,7 @@ void EAMT::compute(const int f_ago, const int inum_full, const int nlocal, if (!success) return; } - + this->atom->cast_x_data(host_x,host_type); this->atom->add_x_data(host_x,host_type); @@ -345,36 +345,36 @@ void EAMT::compute(const int f_ago, const int inum_full, const int nlocal, // --------------------------------------------------------------------------- template int** EAMT::compute(const int ago, const int inum_full, const int nall, - double **host_x, int *host_type, double *sublo, + double **host_x, int *host_type, double *sublo, double *subhi, tagint *tag, int **nspecial, tagint **special, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, int **ilist, int **jnum, - const double cpu_time, bool &success, int &inum, + const double cpu_time, bool &success, int &inum, void **fp_ptr) { this->acc_timers(); - + if (this->device->time_device()) { // Put time from the second part to the total time_pair this->time_pair.add_time_to_total(time_pair2.time()); - + // Add transfer time from device -> host after part 1 this->atom->add_transfer_time(time_fp1.time()); - + // Add transfer time from host -> device before part 2 this->atom->add_transfer_time(time_fp2.time()); } // ------------------- Resize FP Array for EAM -------------------- - + if (nall>_max_fp_size) { _max_fp_size=static_cast(static_cast(nall)*1.10); _fp.resize(_max_fp_size); fp_tex.bind_float(_fp,1); - } - *fp_ptr=_fp.host.begin(); + } + *fp_ptr=_fp.host.begin(); // ----------------------------------------------------------------- - + if (inum_full==0) { host_start=0; // Make sure textures are correct if realloc by a different hybrid style @@ -382,14 +382,14 @@ int** EAMT::compute(const int ago, const int inum_full, const int nall, this->zero_timers(); return NULL; } - + // load balance, returning the atom count on the device (inum) this->hd_balancer.balance(cpu_time); inum=this->hd_balancer.get_gpu_count(ago,inum_full); this->ans->inum(inum); host_start=inum; - - // Build neighbor list on GPU if necessary + + // Build neighbor list on GPU if necessary if (ago==0) { this->build_nbor_list(inum, inum_full-inum, nall, host_x, host_type, sublo, subhi, tag, nspecial, special, success); @@ -403,14 +403,14 @@ int** EAMT::compute(const int ago, const int inum_full, const int nall, *jnum=this->nbor->host_acc.begin(); loop(eflag,vflag); - + // copy fp from device to host for comm _nlocal=inum_full; time_fp1.start(); _fp.update_host(inum_full,true); time_fp1.stop(); time_fp1.sync_stop(); - + return this->nbor->host_jlist.begin()-host_start; } @@ -420,20 +420,20 @@ int** EAMT::compute(const int ago, const int inum_full, const int nall, template void EAMT::compute2(int *ilist, const bool eflag, const bool vflag, const bool eatom, const bool vatom) { - if (this->ans->inum()==0) + if (this->ans->inum()==0) return; - + this->hd_balancer.start_timer(); time_fp2.start(); this->add_fp_data(); time_fp2.stop(); - + loop2(eflag,vflag); if (ilist == NULL) this->ans->copy_answers(eflag,vflag,eatom,vatom); else this->ans->copy_answers(eflag,vflag,eatom,vatom, ilist); - + this->device->add_ans_object(this->ans); this->hd_balancer.stop_timer(); } @@ -455,27 +455,27 @@ void EAMT::loop(const bool _eflag, const bool _vflag) { vflag=1; else vflag=0; - + int GX=static_cast(ceil(static_cast(this->ans->inum())/ (BX/this->_threads_per_atom))); int ainum=this->ans->inum(); int nbor_pitch=this->nbor->nbor_pitch(); this->time_pair.start(); - + if (shared_types) { this->k_energy_fast.set_size(GX,BX); this->k_energy_fast.run(&this->atom->x, &type2rhor_z2r, &type2frho, - &rhor_spline2, &frho_spline1,&frho_spline2, - &this->nbor->dev_nbor, &this->_nbor_data->begin(), + &rhor_spline2, &frho_spline1,&frho_spline2, + &this->nbor->dev_nbor, &this->_nbor_data->begin(), &_fp, &this->ans->engv, &eflag, &ainum, &nbor_pitch, &_ntypes, &_cutforcesq, &_rdr, &_rdrho, &_rhomax, &_nrho, &_nr, &this->_threads_per_atom); } else { this->k_energy.set_size(GX,BX); this->k_energy.run(&this->atom->x, &type2rhor_z2r, &type2frho, - &rhor_spline2, &frho_spline1, &frho_spline2, - &this->nbor->dev_nbor, &this->_nbor_data->begin(), &_fp, + &rhor_spline2, &frho_spline1, &frho_spline2, + &this->nbor->dev_nbor, &this->_nbor_data->begin(), &_fp, &this->ans->engv,&eflag, &ainum, &nbor_pitch, &_ntypes, &_cutforcesq, &_rdr, &_rdrho, &_rhomax, &_nrho, &_nr, &this->_threads_per_atom); @@ -501,25 +501,25 @@ void EAMT::loop2(const bool _eflag, const bool _vflag) { vflag=1; else vflag=0; - + int GX=static_cast(ceil(static_cast(this->ans->inum())/ (BX/this->_threads_per_atom))); int ainum=this->ans->inum(); int nbor_pitch=this->nbor->nbor_pitch(); this->time_pair2.start(); - + if (shared_types) { this->k_pair_fast.set_size(GX,BX); this->k_pair_fast.run(&this->atom->x, &_fp, &type2rhor_z2r, - &rhor_spline1, &z2r_spline1, &z2r_spline2, - &this->nbor->dev_nbor, &this->_nbor_data->begin(), + &rhor_spline1, &z2r_spline1, &z2r_spline2, + &this->nbor->dev_nbor, &this->_nbor_data->begin(), &this->ans->force, &this->ans->engv, &eflag, &vflag, &ainum, &nbor_pitch, &_cutforcesq, &_rdr, &_nr, &this->_threads_per_atom); } else { this->k_pair.set_size(GX,BX); - this->k_pair.run(&this->atom->x, &_fp, &type2rhor_z2r, &rhor_spline1, + this->k_pair.run(&this->atom->x, &_fp, &type2rhor_z2r, &rhor_spline1, &z2r_spline1, &z2r_spline2, &this->nbor->dev_nbor, &this->_nbor_data->begin(), &this->ans->force, &this->ans->engv, &eflag, &vflag, &ainum, &nbor_pitch, diff --git a/lib/gpu/lal_eam.cu b/lib/gpu/lal_eam.cu index 054b3ca6db..13440b7d45 100644 --- a/lib/gpu/lal_eam.cu +++ b/lib/gpu/lal_eam.cu @@ -9,7 +9,7 @@ // This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) // __________________________________________________________________________ // -// begin : +// begin : // email : brownw@ornl.gov nguyentd@ornl.gov // ***************************************************************************/ @@ -82,7 +82,7 @@ texture z2r_sp2_tex; engv[ii]=energy; \ } \ } - + #define store_answers_eam(f, energy, virial, ii, inum, tid, t_per_atom, \ offset, elag, vflag, ans, engv) \ if (t_per_atom>1) { \ @@ -188,37 +188,37 @@ texture z2r_sp2_tex; #endif -__kernel void k_energy(const __global numtyp4 *restrict x_, +__kernel void k_energy(const __global numtyp4 *restrict x_, const __global int2 *restrict type2rhor_z2r, - const __global int *restrict type2frho, - const __global numtyp4 *restrict rhor_spline2, + const __global int *restrict type2frho, + const __global numtyp4 *restrict rhor_spline2, const __global numtyp4 *restrict frho_spline1, const __global numtyp4 *restrict frho_spline2, - const __global int *dev_nbor, + const __global int *dev_nbor, const __global int *dev_packed, - __global numtyp *restrict fp_, - __global acctyp *restrict engv, + __global numtyp *restrict fp_, + __global acctyp *restrict engv, const int eflag, const int inum, const int nbor_pitch, - const int ntypes, const numtyp cutforcesq, - const numtyp rdr, const numtyp rdrho, + const int ntypes, const numtyp cutforcesq, + const numtyp rdr, const numtyp rdrho, const numtyp rhomax, const int nrho, const int nr, const int t_per_atom) { int tid, ii, offset; atom_info(t_per_atom,ii,tid,offset); - + acctyp rho = (acctyp)0; acctyp energy = (acctyp)0; - + if (ii { public: EAM(); ~EAM(); - + /// Clear any previous data and set up for a new LAMMPS run /** \param max_nbors initial number of rows in the neighbor matrix * \param cell_size cutoff + skin * \param gpu_split fraction of particles handled by device - * + * * Returns: * - 0 if successfull * - -1 if fix gpu not found @@ -41,11 +41,11 @@ class EAM : public BaseAtomic { int init(const int ntypes, double host_cutforcesq, int **host_type2rhor, int **host_type2z2r, int *host_type2frho, double ***host_rhor_spline, double ***host_z2r_spline, double ***host_frho_spline, double rdr, - double rdrho, double rhomax, int nrhor, int nrho, int nz2r, - int nfrho, int nr, const int nlocal, const int nall, + double rdrho, double rhomax, int nrhor, int nrho, int nz2r, + int nfrho, int nr, const int nlocal, const int nall, const int max_nbors, const int maxspecial, const double cell_size, const double gpu_split, FILE *_screen); - + // Copy charges to device asynchronously inline void add_fp_data() { int nghost=this->atom->nall()-_nlocal; @@ -57,7 +57,7 @@ class EAM : public BaseAtomic { ucl_copy(dev_view,host_view,nghost,true); } } - + /// Clear all host and device data /** \note This is called at the beginning of the init() routine **/ void clear(); @@ -67,7 +67,7 @@ class EAM : public BaseAtomic { /// Total host memory used by library for pair style double host_memory_usage() const; - + /// Pair loop with host neighboring void compute(const int f_ago, const int inum_full, const int, const int nall, double **host_x, int *host_type, int *ilist, int *numj, @@ -75,23 +75,23 @@ class EAM : public BaseAtomic { const bool eatom, const bool vatom, int &host_start, const double cpu_time, bool &success, void **fp_ptr); - + /// Pair loop with device neighboring int** compute(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, double *sublo, double *subhi, tagint *tag, int **nspecial, - tagint **special, const bool eflag, const bool vflag, - const bool eatom, const bool vatom, int &host_start, + tagint **special, const bool eflag, const bool vflag, + const bool eatom, const bool vatom, int &host_start, int **ilist, int **numj, const double cpu_time, bool &success, int &inum, void **fp_ptr); /// Pair loop with host neighboring - void compute2(int *ilist, const bool eflag, const bool vflag, + void compute2(int *ilist, const bool eflag, const bool vflag, const bool eatom, const bool vatom); - + // ------------------------- DEVICE KERNELS ------------------------- UCL_Kernel k_energy, k_energy_fast; - + // --------------------------- TEXTURES ----------------------------- UCL_Texture fp_tex; UCL_Texture rhor_spline1_tex, rhor_spline2_tex; @@ -99,37 +99,37 @@ class EAM : public BaseAtomic { UCL_Texture z2r_spline1_tex, z2r_spline2_tex; // --------------------------- DEVICE DATA -------------------------- - + /// Device Timers UCL_Timer time_pair2, time_fp1, time_fp2; - + // --------------------------- TYPE DATA -------------------------- - + UCL_D_Vec type2rhor_z2r; UCL_D_Vec type2frho; - + UCL_D_Vec z2r_spline1, z2r_spline2; UCL_D_Vec frho_spline1, frho_spline2; UCL_D_Vec rhor_spline1, rhor_spline2; - + numtyp _cutforcesq,_rdr,_rdrho, _rhomax; - + int _nfrho,_nrhor,_nrho,_nz2r,_nr; - + /// If atom type constants fit in shared memory, use fast kernels bool shared_types; - - /// Number of atom types + + /// Number of atom types int _ntypes; - + int _max_fp_size; - + /// True of energy kernels are compiled bool _compiled_energy; - + /// Per-atom arrays UCL_Vector _fp; - + protected: bool _allocated; int _nlocal; diff --git a/lib/gpu/lal_eam_alloy_ext.cpp b/lib/gpu/lal_eam_alloy_ext.cpp index 282f93afeb..9209ed5c26 100644 --- a/lib/gpu/lal_eam_alloy_ext.cpp +++ b/lib/gpu/lal_eam_alloy_ext.cpp @@ -9,7 +9,7 @@ This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) __________________________________________________________________________ - begin : + begin : email : brownw@ornl.gov nguyentd@ornl.gov ***************************************************************************/ @@ -27,14 +27,14 @@ static EAM EAMALMF; // --------------------------------------------------------------------------- // Allocate memory on host and device and copy constants to device // --------------------------------------------------------------------------- -int eam_alloy_gpu_init(const int ntypes, double host_cutforcesq, +int eam_alloy_gpu_init(const int ntypes, double host_cutforcesq, int **host_type2rhor, int **host_type2z2r, int *host_type2frho, double ***host_rhor_spline, double ***host_z2r_spline, double ***host_frho_spline, - double rdr, double rdrho, double rhomax, int nrhor, - int nrho, int nz2r, int nfrho, int nr, - const int nlocal, const int nall, const int max_nbors, - const int maxspecial, const double cell_size, + double rdr, double rdrho, double rhomax, int nrhor, + int nrho, int nz2r, int nfrho, int nr, + const int nlocal, const int nall, const int max_nbors, + const int maxspecial, const double cell_size, int &gpu_mode, FILE *screen, int &fp_size) { EAMALMF.clear(); gpu_mode=EAMALMF.device->gpu_mode(); @@ -46,11 +46,11 @@ int eam_alloy_gpu_init(const int ntypes, double host_cutforcesq, int procs_per_gpu=EAMALMF.device->procs_per_gpu(); // disable host/device split for now - if (gpu_split != 1.0) + if (gpu_split != 1.0) return -8; - + fp_size=sizeof(PRECISION); - + EAMALMF.device->init_message(screen,"eam/alloy",first_gpu,last_gpu); bool message=false; @@ -66,7 +66,7 @@ int eam_alloy_gpu_init(const int ntypes, double host_cutforcesq, if (world_me==0) init_ok=EAMALMF.init(ntypes, host_cutforcesq, host_type2rhor, host_type2z2r, host_type2frho, host_rhor_spline, host_z2r_spline, - host_frho_spline, rdr, rdrho, rhomax, nrhor, nrho, nz2r, + host_frho_spline, rdr, rdrho, rhomax, nrhor, nrho, nz2r, nfrho, nr, nlocal, nall, 300, maxspecial, cell_size, gpu_split, screen); @@ -86,12 +86,12 @@ int eam_alloy_gpu_init(const int ntypes, double host_cutforcesq, if (gpu_rank==i && world_me!=0) init_ok=EAMALMF.init(ntypes, host_cutforcesq, host_type2rhor, host_type2z2r, host_type2frho, host_rhor_spline, host_z2r_spline, - host_frho_spline, rdr, rdrho, rhomax, nrhor, nrho, + host_frho_spline, rdr, rdrho, rhomax, nrhor, nrho, nz2r, nfrho, nr, nlocal, nall, 300, maxspecial, cell_size, gpu_split, screen); EAMALMF.device->gpu_barrier(); - if (message) + if (message) fprintf(screen,"Done.\n"); } if (message) @@ -108,7 +108,7 @@ void eam_alloy_gpu_clear() { int ** eam_alloy_gpu_compute_n(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, - double *sublo, double *subhi, tagint *tag, int **nspecial, + double *sublo, double *subhi, tagint *tag, int **nspecial, tagint **special, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, int **ilist, int **jnum, const double cpu_time, @@ -117,10 +117,10 @@ int ** eam_alloy_gpu_compute_n(const int ago, const int inum_full, subhi, tag, nspecial, special, eflag, vflag, eatom, vatom, host_start, ilist, jnum, cpu_time, success, inum, fp_ptr); -} +} -void eam_alloy_gpu_compute(const int ago, const int inum_full, const int nlocal, - const int nall, double **host_x, int *host_type, +void eam_alloy_gpu_compute(const int ago, const int inum_full, const int nlocal, + const int nall, double **host_x, int *host_type, int *ilist, int *numj, int **firstneigh, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, const double cpu_time, bool &success, diff --git a/lib/gpu/lal_eam_ext.cpp b/lib/gpu/lal_eam_ext.cpp index d56f750e2f..1b5602f808 100644 --- a/lib/gpu/lal_eam_ext.cpp +++ b/lib/gpu/lal_eam_ext.cpp @@ -9,7 +9,7 @@ This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) __________________________________________________________________________ - begin : + begin : email : brownw@ornl.gov nguyentd@ornl.gov ***************************************************************************/ @@ -27,14 +27,14 @@ static EAM EAMMF; // --------------------------------------------------------------------------- // Allocate memory on host and device and copy constants to device // --------------------------------------------------------------------------- -int eam_gpu_init(const int ntypes, double host_cutforcesq, +int eam_gpu_init(const int ntypes, double host_cutforcesq, int **host_type2rhor, int **host_type2z2r, int *host_type2frho, double ***host_rhor_spline, double ***host_z2r_spline, double ***host_frho_spline, - double rdr, double rdrho, double rhomax, int nrhor, - int nrho, int nz2r, int nfrho, int nr, - const int nlocal, const int nall, const int max_nbors, - const int maxspecial, const double cell_size, + double rdr, double rdrho, double rhomax, int nrhor, + int nrho, int nz2r, int nfrho, int nr, + const int nlocal, const int nall, const int max_nbors, + const int maxspecial, const double cell_size, int &gpu_mode, FILE *screen, int &fp_size) { EAMMF.clear(); gpu_mode=EAMMF.device->gpu_mode(); @@ -46,11 +46,11 @@ int eam_gpu_init(const int ntypes, double host_cutforcesq, int procs_per_gpu=EAMMF.device->procs_per_gpu(); // disable host/device split for now - if (gpu_split != 1.0) + if (gpu_split != 1.0) return -8; - + fp_size=sizeof(PRECISION); - + EAMMF.device->init_message(screen,"eam",first_gpu,last_gpu); bool message=false; @@ -66,7 +66,7 @@ int eam_gpu_init(const int ntypes, double host_cutforcesq, if (world_me==0) init_ok=EAMMF.init(ntypes, host_cutforcesq, host_type2rhor, host_type2z2r, host_type2frho, host_rhor_spline, host_z2r_spline, - host_frho_spline, rdr, rdrho, rhomax, nrhor, nrho, nz2r, + host_frho_spline, rdr, rdrho, rhomax, nrhor, nrho, nz2r, nfrho, nr, nlocal, nall, 300, maxspecial, cell_size, gpu_split, screen); @@ -86,12 +86,12 @@ int eam_gpu_init(const int ntypes, double host_cutforcesq, if (gpu_rank==i && world_me!=0) init_ok=EAMMF.init(ntypes, host_cutforcesq, host_type2rhor, host_type2z2r, host_type2frho, host_rhor_spline, host_z2r_spline, - host_frho_spline, rdr, rdrho, rhomax, nrhor, nrho, + host_frho_spline, rdr, rdrho, rhomax, nrhor, nrho, nz2r, nfrho, nr, nlocal, nall, 300, maxspecial, cell_size, gpu_split, screen); EAMMF.device->gpu_barrier(); - if (message) + if (message) fprintf(screen,"Done.\n"); } if (message) @@ -108,7 +108,7 @@ void eam_gpu_clear() { int ** eam_gpu_compute_n(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, - double *sublo, double *subhi, tagint *tag, int **nspecial, + double *sublo, double *subhi, tagint *tag, int **nspecial, tagint **special, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, int **ilist, int **jnum, const double cpu_time, @@ -117,10 +117,10 @@ int ** eam_gpu_compute_n(const int ago, const int inum_full, subhi, tag, nspecial, special, eflag, vflag, eatom, vatom, host_start, ilist, jnum, cpu_time, success, inum, fp_ptr); -} +} -void eam_gpu_compute(const int ago, const int inum_full, const int nlocal, - const int nall, double **host_x, int *host_type, +void eam_gpu_compute(const int ago, const int inum_full, const int nlocal, + const int nall, double **host_x, int *host_type, int *ilist, int *numj, int **firstneigh, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, const double cpu_time, bool &success, diff --git a/lib/gpu/lal_eam_fs_ext.cpp b/lib/gpu/lal_eam_fs_ext.cpp index 4992f3ab98..b9e25466aa 100644 --- a/lib/gpu/lal_eam_fs_ext.cpp +++ b/lib/gpu/lal_eam_fs_ext.cpp @@ -9,7 +9,7 @@ This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) __________________________________________________________________________ - begin : + begin : email : brownw@ornl.gov nguyentd@ornl.gov ***************************************************************************/ @@ -27,14 +27,14 @@ static EAM EAMFSMF; // --------------------------------------------------------------------------- // Allocate memory on host and device and copy constants to device // --------------------------------------------------------------------------- -int eam_fs_gpu_init(const int ntypes, double host_cutforcesq, +int eam_fs_gpu_init(const int ntypes, double host_cutforcesq, int **host_type2rhor, int **host_type2z2r, int *host_type2frho, double ***host_rhor_spline, double ***host_z2r_spline, double ***host_frho_spline, - double rdr, double rdrho, double rhomax, int nrhor, - int nrho, int nz2r, int nfrho, int nr, - const int nlocal, const int nall, const int max_nbors, - const int maxspecial, const double cell_size, + double rdr, double rdrho, double rhomax, int nrhor, + int nrho, int nz2r, int nfrho, int nr, + const int nlocal, const int nall, const int max_nbors, + const int maxspecial, const double cell_size, int &gpu_mode, FILE *screen, int &fp_size) { EAMFSMF.clear(); gpu_mode=EAMFSMF.device->gpu_mode(); @@ -46,11 +46,11 @@ int eam_fs_gpu_init(const int ntypes, double host_cutforcesq, int procs_per_gpu=EAMFSMF.device->procs_per_gpu(); // disable host/device split for now - if (gpu_split != 1.0) + if (gpu_split != 1.0) return -8; - + fp_size=sizeof(PRECISION); - + EAMFSMF.device->init_message(screen,"eam/fs",first_gpu,last_gpu); bool message=false; @@ -66,7 +66,7 @@ int eam_fs_gpu_init(const int ntypes, double host_cutforcesq, if (world_me==0) init_ok=EAMFSMF.init(ntypes, host_cutforcesq, host_type2rhor, host_type2z2r, host_type2frho, host_rhor_spline, host_z2r_spline, - host_frho_spline, rdr, rdrho, rhomax, nrhor, nrho, nz2r, + host_frho_spline, rdr, rdrho, rhomax, nrhor, nrho, nz2r, nfrho, nr, nlocal, nall, 300, maxspecial, cell_size, gpu_split, screen); @@ -86,12 +86,12 @@ int eam_fs_gpu_init(const int ntypes, double host_cutforcesq, if (gpu_rank==i && world_me!=0) init_ok=EAMFSMF.init(ntypes, host_cutforcesq, host_type2rhor, host_type2z2r, host_type2frho, host_rhor_spline, host_z2r_spline, - host_frho_spline, rdr, rdrho, rhomax, nrhor, nrho, + host_frho_spline, rdr, rdrho, rhomax, nrhor, nrho, nz2r, nfrho, nr, nlocal, nall, 300, maxspecial, cell_size, gpu_split, screen); EAMFSMF.device->gpu_barrier(); - if (message) + if (message) fprintf(screen,"Done.\n"); } if (message) @@ -108,7 +108,7 @@ void eam_fs_gpu_clear() { int ** eam_fs_gpu_compute_n(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, - double *sublo, double *subhi, tagint *tag, int **nspecial, + double *sublo, double *subhi, tagint *tag, int **nspecial, tagint **special, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, int **ilist, int **jnum, const double cpu_time, @@ -117,10 +117,10 @@ int ** eam_fs_gpu_compute_n(const int ago, const int inum_full, subhi, tag, nspecial, special, eflag, vflag, eatom, vatom, host_start, ilist, jnum, cpu_time, success, inum, fp_ptr); -} +} -void eam_fs_gpu_compute(const int ago, const int inum_full, const int nlocal, - const int nall, double **host_x, int *host_type, +void eam_fs_gpu_compute(const int ago, const int inum_full, const int nlocal, + const int nall, double **host_x, int *host_type, int *ilist, int *numj, int **firstneigh, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, const double cpu_time, bool &success, diff --git a/lib/gpu/lal_ellipsoid_extra.h b/lib/gpu/lal_ellipsoid_extra.h index b33f087212..51f785b905 100644 --- a/lib/gpu/lal_ellipsoid_extra.h +++ b/lib/gpu/lal_ellipsoid_extra.h @@ -245,8 +245,8 @@ ucl_inline void gpu_cross3(const numtyp *v1, const numtyp *v2, numtyp *ans) ucl_inline numtyp gpu_det3(const numtyp m[9]) { - numtyp ans = m[0]*m[4]*m[8] - m[0]*m[5]*m[7] - - m[3]*m[1]*m[8] + m[3]*m[2]*m[7] + + numtyp ans = m[0]*m[4]*m[8] - m[0]*m[5]*m[7] - + m[3]*m[1]*m[8] + m[3]*m[2]*m[7] + m[6]*m[1]*m[5] - m[6]*m[2]*m[4]; return ans; }; @@ -255,7 +255,7 @@ ucl_inline numtyp gpu_det3(const numtyp m[9]) diagonal matrix times a full matrix ------------------------------------------------------------------------- */ -ucl_inline void gpu_diag_times3(const numtyp4 shape, const numtyp m[9], +ucl_inline void gpu_diag_times3(const numtyp4 shape, const numtyp m[9], numtyp ans[9]) { ans[0] = shape.x*m[0]; @@ -421,7 +421,7 @@ ucl_inline void gpu_mldivide3(const numtyp m[9], const numtyp *v, numtyp *ans, t = aug[9]/aug[5]; aug[10]-=t*aug[6]; aug[11]-=t*aug[7]; - + if (aug[10] == (numtyp)0.0) *error_flag=2; @@ -440,11 +440,11 @@ ucl_inline void gpu_mldivide3(const numtyp m[9], const numtyp *v, numtyp *ans, quat = [w i j k] ------------------------------------------------------------------------- */ -ucl_inline void gpu_quat_to_mat_trans(__global const numtyp4 *qif, const int qi, +ucl_inline void gpu_quat_to_mat_trans(__global const numtyp4 *qif, const int qi, numtyp mat[9]) { numtyp4 q; fetch4(q,qi,quat_tex); - + numtyp w2 = q.x*q.x; numtyp i2 = q.y*q.y; numtyp j2 = q.z*q.z; @@ -561,7 +561,7 @@ ucl_inline void gpu_rotation_generator_z(const numtyp m[9], numtyp ans[9]) ------------------------------------------------------------------------- */ ucl_inline void gpu_times_column3(const numtyp m[9], const numtyp v[3], - numtyp ans[3]) + numtyp ans[3]) { ans[0] = m[0]*v[0] + m[1]*v[1] + m[2]*v[2]; ans[1] = m[3]*v[0] + m[4]*v[1] + m[5]*v[2]; diff --git a/lib/gpu/lal_ellipsoid_nbor.cu b/lib/gpu/lal_ellipsoid_nbor.cu index 30d864aecc..cac77f5dd3 100644 --- a/lib/gpu/lal_ellipsoid_nbor.cu +++ b/lib/gpu/lal_ellipsoid_nbor.cu @@ -29,14 +29,14 @@ texture pos_tex; // -- Only unpack neighbors matching the specified inclusive range of forms // -- Only unpack neighbors within cutoff // --------------------------------------------------------------------------- -__kernel void kernel_nbor(const __global numtyp4 *restrict x_, - const __global numtyp2 *restrict cut_form, - const int ntypes, +__kernel void kernel_nbor(const __global numtyp4 *restrict x_, + const __global numtyp2 *restrict cut_form, + const int ntypes, __global int *dev_nbor, - const int nbor_pitch, const int start, const int inum, - const __global int *dev_ij, + const int nbor_pitch, const int start, const int inum, + const __global int *dev_ij, const int form_low, const int form_high) { - + // ii indexes the two interacting particles in gi int ii=GLOBAL_ID_X+start; @@ -47,11 +47,11 @@ __kernel void kernel_nbor(const __global numtyp4 *restrict x_, nbor+=nbor_pitch; int nbor_end=nbor+fast_mul(numj,nbor_pitch); int packed=ii+nbor_pitch+nbor_pitch; - + numtyp4 ix; fetch4(ix,i,pos_tex); //x_[i]; int iw=ix.w; int itype=fast_mul(iw,ntypes); - int newj=0; + int newj=0; for ( ; nbor=form_low && form[mtype]<=form_high) { // Compute r12; numtyp rsq=jx.x-ix.x; diff --git a/lib/gpu/lal_gauss.cpp b/lib/gpu/lal_gauss.cpp index 342ec4ecda..ef1559c5b6 100644 --- a/lib/gpu/lal_gauss.cpp +++ b/lib/gpu/lal_gauss.cpp @@ -9,7 +9,7 @@ This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) __________________________________________________________________________ - begin : + begin : email : nguyentd@ornl.gov ***************************************************************************/ @@ -33,19 +33,19 @@ GaussT::Gauss() : BaseAtomic(), _allocated(false) { } template -GaussT::~Gauss() { +GaussT::~Gauss() { clear(); } - + template int GaussT::bytes_per_atom(const int max_nbors) const { return this->bytes_per_atom_atomic(max_nbors); } template -int GaussT::init(const int ntypes, - double **host_cutsq, double **host_a, - double **host_b, double **host_offset, +int GaussT::init(const int ntypes, + double **host_cutsq, double **host_a, + double **host_b, double **host_offset, double *host_special_lj, const int nlocal, const int nall, const int max_nbors, const int maxspecial, const double cell_size, @@ -94,10 +94,10 @@ void GaussT::reinit(const int ntypes, double **host_cutsq, double **host_a, // Allocate a host write buffer for data initialization UCL_H_Vec host_write(_lj_types*_lj_types*32,*(this->ucl_device), UCL_WRITE_ONLY); - + for (int i=0; i<_lj_types*_lj_types; i++) host_write[i]=0.0; - + this->atom->type_pack4(ntypes,_lj_types,gauss1,host_write,host_a,host_b, host_cutsq,host_offset); } @@ -135,7 +135,7 @@ void GaussT::loop(const bool _eflag, const bool _vflag) { vflag=1; else vflag=0; - + int GX=static_cast(ceil(static_cast(this->ans->inum())/ (BX/this->_threads_per_atom))); diff --git a/lib/gpu/lal_gauss.cu b/lib/gpu/lal_gauss.cu index 6accf36a06..98e71ea413 100644 --- a/lib/gpu/lal_gauss.cu +++ b/lib/gpu/lal_gauss.cu @@ -9,7 +9,7 @@ // This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) // __________________________________________________________________________ // -// begin : +// begin : // email : nguyentd@ornl.gov // ***************************************************************************/ @@ -24,14 +24,14 @@ texture pos_tex; #define pos_tex x_ #endif -__kernel void k_gauss(const __global numtyp4 *restrict x_, +__kernel void k_gauss(const __global numtyp4 *restrict x_, const __global numtyp4 *restrict gauss1, - const int lj_types, - const __global numtyp *restrict sp_lj_in, - const __global int *dev_nbor, - const __global int *dev_packed, + const int lj_types, + const __global numtyp *restrict sp_lj_in, + const __global int *dev_nbor, + const __global int *dev_packed, __global acctyp4 *restrict ans, - __global acctyp *restrict engv, + __global acctyp *restrict engv, const int eflag, const int vflag, const int inum, const int nbor_pitch, const int t_per_atom) { int tid, ii, offset; @@ -49,20 +49,20 @@ __kernel void k_gauss(const __global numtyp4 *restrict x_, acctyp virial[6]; for (int i=0; i<6; i++) virial[i]=(acctyp)0; - + if (ii0) { - numtyp e=-(gauss1[mtype].x*ucl_exp(-gauss1[mtype].y*rsq) - + numtyp e=-(gauss1[mtype].x*ucl_exp(-gauss1[mtype].y*rsq) - gauss1[mtype].w); - energy+=factor_lj*e; + energy+=factor_lj*e; } if (vflag>0) { virial[0] += delx*delx*force; @@ -108,18 +108,18 @@ __kernel void k_gauss(const __global numtyp4 *restrict x_, } // if ii } -__kernel void k_gauss_fast(const __global numtyp4 *restrict x_, +__kernel void k_gauss_fast(const __global numtyp4 *restrict x_, const __global numtyp4 *restrict gauss1_in, - const __global numtyp *restrict sp_lj_in, + const __global numtyp *restrict sp_lj_in, const __global int *dev_nbor, - const __global int *dev_packed, + const __global int *dev_packed, __global acctyp4 *restrict ans, - __global acctyp *restrict engv, - const int eflag, const int vflag, const int inum, + __global acctyp *restrict engv, + const int eflag, const int vflag, const int inum, const int nbor_pitch, const int t_per_atom) { int tid, ii, offset; atom_info(t_per_atom,ii,tid,offset); - + __local numtyp4 gauss1[MAX_SHARED_TYPES*MAX_SHARED_TYPES]; __local numtyp sp_lj[4]; if (tid<4) @@ -127,7 +127,7 @@ __kernel void k_gauss_fast(const __global numtyp4 *restrict x_, if (tid0) { - numtyp e=-(gauss1[mtype].x*ucl_exp(-gauss1[mtype].y*rsq) - + numtyp e=-(gauss1[mtype].x*ucl_exp(-gauss1[mtype].y*rsq) - gauss1[mtype].w); - energy+=factor_lj*e; + energy+=factor_lj*e; } if (vflag>0) { virial[0] += delx*delx*force; diff --git a/lib/gpu/lal_gauss.h b/lib/gpu/lal_gauss.h index 1fd58adae5..d023310c6d 100644 --- a/lib/gpu/lal_gauss.h +++ b/lib/gpu/lal_gauss.h @@ -9,7 +9,7 @@ This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) __________________________________________________________________________ - begin : + begin : email : nguyentd@ornl.gov ***************************************************************************/ @@ -24,13 +24,13 @@ template class Gauss : public BaseAtomic { public: Gauss(); - ~Gauss(); + ~Gauss(); /// Clear any previous data and set up for a new LAMMPS run /** \param max_nbors initial number of rows in the neighbor matrix * \param cell_size cutoff + skin * \param gpu_split fraction of particles handled by device - * + * * Returns: * - 0 if successfull * - -1 if fix gpu not found @@ -38,16 +38,16 @@ class Gauss : public BaseAtomic { * - -4 if the GPU library was not compiled for GPU * - -5 Double precision is not supported on card **/ int init(const int ntypes, double **host_cutsq, - double **host_a, double **host_b, double **host_offset, + double **host_a, double **host_b, double **host_offset, double *host_special_lj, - const int nlocal, const int nall, const int max_nbors, - const int maxspecial, const double cell_size, + const int nlocal, const int nall, const int max_nbors, + const int maxspecial, const double cell_size, const double gpu_split, FILE *screen); - + /// Send updated coeffs from host to device (to be compatible with fix adapt) void reinit(const int ntypes, double **host_cutsq, double **host_a, double **host_b, double **host_offset); - + /// Clear all host and device data /** \note This is called at the beginning of the init() routine **/ void clear(); @@ -68,7 +68,7 @@ class Gauss : public BaseAtomic { /// If atom type constants fit in shared memory, use fast kernels bool shared_types; - /// Number of atom types + /// Number of atom types int _lj_types; private: diff --git a/lib/gpu/lal_gauss_ext.cpp b/lib/gpu/lal_gauss_ext.cpp index 7c15a12591..834c03cf64 100644 --- a/lib/gpu/lal_gauss_ext.cpp +++ b/lib/gpu/lal_gauss_ext.cpp @@ -9,7 +9,7 @@ This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) __________________________________________________________________________ - begin : + begin : email : nguyentd@ornl.gov ***************************************************************************/ @@ -27,9 +27,9 @@ static Gauss GLMF; // --------------------------------------------------------------------------- // Allocate memory on host and device and copy constants to device // --------------------------------------------------------------------------- -int gauss_gpu_init(const int ntypes, double **cutsq, double **host_a, - double **host_b, double **offset, double *special_lj, - const int inum, const int nall, const int max_nbors, +int gauss_gpu_init(const int ntypes, double **cutsq, double **host_a, + double **host_b, double **offset, double *special_lj, + const int inum, const int nall, const int max_nbors, const int maxspecial, const double cell_size, int &gpu_mode, FILE *screen) { GLMF.clear(); @@ -54,7 +54,7 @@ int gauss_gpu_init(const int ntypes, double **cutsq, double **host_a, int init_ok=0; if (world_me==0) - init_ok=GLMF.init(ntypes, cutsq, host_a, host_b, + init_ok=GLMF.init(ntypes, cutsq, host_a, host_b, offset, special_lj, inum, nall, 300, maxspecial, cell_size, gpu_split, screen); @@ -77,7 +77,7 @@ int gauss_gpu_init(const int ntypes, double **cutsq, double **host_a, cell_size, gpu_split, screen); GLMF.device->gpu_barrier(); - if (message) + if (message) fprintf(screen,"Done.\n"); } if (message) @@ -96,16 +96,16 @@ void gauss_gpu_reinit(const int ntypes, double **cutsq, double **host_a, int world_me=GLMF.device->world_me(); int gpu_rank=GLMF.device->gpu_rank(); int procs_per_gpu=GLMF.device->procs_per_gpu(); - + if (world_me==0) GLMF.reinit(ntypes, cutsq, host_a, host_b, offset); - + GLMF.device->world_barrier(); - + for (int i=0; igpu_barrier(); } } @@ -124,7 +124,7 @@ int ** gauss_gpu_compute_n(const int ago, const int inum_full, return GLMF.compute(ago, inum_full, nall, host_x, host_type, sublo, subhi, tag, nspecial, special, eflag, vflag, eatom, vatom, host_start, ilist, jnum, cpu_time, success); -} +} void gauss_gpu_compute(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, int *ilist, int *numj, diff --git a/lib/gpu/lal_gayberne.cpp b/lib/gpu/lal_gayberne.cpp index 1d38810ae8..5abef659b6 100644 --- a/lib/gpu/lal_gayberne.cpp +++ b/lib/gpu/lal_gayberne.cpp @@ -37,21 +37,21 @@ GayBerneT::GayBerne() : BaseEllipsoid(), } template -GayBerneT::~GayBerne() { +GayBerneT::~GayBerne() { clear(); } - + template int GayBerneT::bytes_per_atom(const int max_nbors) const { return this->bytes_per_atom(max_nbors); } template -int GayBerneT::init(const int ntypes, const double gamma, - const double upsilon, const double mu, - double **host_shape, double **host_well, - double **host_cutsq, double **host_sigma, - double **host_epsilon, double *host_lshape, +int GayBerneT::init(const int ntypes, const double gamma, + const double upsilon, const double mu, + double **host_shape, double **host_well, + double **host_cutsq, double **host_sigma, + double **host_epsilon, double *host_lshape, int **h_form, double **host_lj1, double **host_lj2, double **host_lj3, double **host_lj4, double **host_offset, const double *host_special_lj, @@ -100,11 +100,11 @@ int GayBerneT::init(const int ntypes, const double gamma, dev_error.alloc(1,*(this->ucl_device),UCL_WRITE_ONLY); dev_error.zero(); - + // Allocate, cast and asynchronous memcpy of constant data // Copy data for bonded interactions gamma_upsilon_mu.alloc(7,*(this->ucl_device),UCL_READ_ONLY); - host_write[0]=static_cast(gamma); + host_write[0]=static_cast(gamma); host_write[1]=static_cast(upsilon); host_write[2]=static_cast(mu); host_write[3]=static_cast(host_special_lj[0]); @@ -117,7 +117,7 @@ int GayBerneT::init(const int ntypes, const double gamma, UCL_H_Vec d_view; d_view.view(host_lshape,lshape.numel(),*(this->ucl_device)); ucl_copy(lshape,d_view,false); - + // Copy shape, well, sigma, epsilon, and cutsq onto GPU // - cast if necessary shape.alloc(ntypes,*(this->ucl_device),UCL_READ_ONLY); @@ -138,7 +138,7 @@ int GayBerneT::init(const int ntypes, const double gamma, } view4.view((numtyp4*)host_write.begin(),well.numel(),*(this->ucl_device)); ucl_copy(well,view4,false); - + _allocated=true; this->_max_bytes=sigma_epsilon.row_bytes()+this->cut_form.row_bytes()+ lj1.row_bytes()+lj3.row_bytes()+gamma_upsilon_mu.row_bytes()+ @@ -155,7 +155,7 @@ void GayBerneT::clear() { UCL_H_Vec err_flag(1,*(this->ucl_device)); ucl_copy(err_flag,dev_error,false); if (err_flag[0] == 2) - std::cerr << "BAD MATRIX INVERSION IN FORCE COMPUTATION.\n"; + std::cerr << "BAD MATRIX INVERSION IN FORCE COMPUTATION.\n"; err_flag.clear(); _allocated=false; @@ -170,7 +170,7 @@ void GayBerneT::clear() { well.clear(); lshape.clear(); gamma_upsilon_mu.clear(); - + this->clear_base(); } @@ -196,7 +196,7 @@ void GayBerneT::loop(const bool _eflag, const bool _vflag) { vflag=1; else vflag=0; - + int GX=0, NGX; int stride=this->nbor->nbor_pitch(); int ainum=this->ans->inum(); @@ -214,12 +214,12 @@ void GayBerneT::loop(const bool _eflag, const bool _vflag) { this->time_ellipsoid.start(); this->k_ellipsoid.set_size(GX,BX); - this->k_ellipsoid.run(&this->atom->x, &this->atom->quat, + this->k_ellipsoid.run(&this->atom->x, &this->atom->quat, &this->shape, &this->well, &this->gamma_upsilon_mu, - &this->sigma_epsilon, &this->_lj_types, - &this->lshape, &this->nbor->dev_nbor, &stride, + &this->sigma_epsilon, &this->_lj_types, + &this->lshape, &this->nbor->dev_nbor, &stride, &this->ans->force, &ainum, &this->ans->engv, - &this->dev_error, &eflag, &vflag, + &this->dev_error, &eflag, &vflag, &this->_last_ellipse, &this->_threads_per_atom); this->time_ellipsoid.stop(); @@ -248,12 +248,12 @@ void GayBerneT::loop(const bool _eflag, const bool _vflag) { this->time_ellipsoid2.start(); this->k_sphere_ellipsoid.set_size(GX,BX); this->k_sphere_ellipsoid.run(&this->atom->x, &this->atom->quat, - &this->shape, &this->well, - &this->gamma_upsilon_mu, - &this->sigma_epsilon, &this->_lj_types, - &this->lshape, &this->nbor->dev_nbor, - &stride, &this->ans->force, - &this->ans->engv, &this->dev_error, + &this->shape, &this->well, + &this->gamma_upsilon_mu, + &this->sigma_epsilon, &this->_lj_types, + &this->lshape, &this->nbor->dev_nbor, + &stride, &this->ans->force, + &this->ans->engv, &this->dev_error, &eflag, &vflag, &this->_last_ellipse, &ainum, &this->_threads_per_atom); this->time_ellipsoid2.stop(); @@ -264,28 +264,28 @@ void GayBerneT::loop(const bool _eflag, const bool _vflag) { this->ans->force.zero(); this->ans->engv.zero(); this->time_nbor1.stop(); - this->time_ellipsoid.start(); + this->time_ellipsoid.start(); this->time_ellipsoid.stop(); this->time_nbor2.start(); this->time_nbor2.stop(); this->time_ellipsoid2.start(); this->time_ellipsoid2.stop(); } - + // ------------ LJ --------------- this->time_lj.start(); if (this->_last_ellipseans->inum()) { if (this->_shared_types) { this->k_lj_fast.set_size(GX,BX); - this->k_lj_fast.run(&this->atom->x, &this->lj1, &this->lj3, - &this->gamma_upsilon_mu, &stride, + this->k_lj_fast.run(&this->atom->x, &this->lj1, &this->lj3, + &this->gamma_upsilon_mu, &stride, &this->nbor->dev_packed, &this->ans->force, - &this->ans->engv, &this->dev_error, &eflag, + &this->ans->engv, &this->dev_error, &eflag, &vflag, &this->_last_ellipse, &ainum, &this->_threads_per_atom); } else { this->k_lj.set_size(GX,BX); - this->k_lj.run(&this->atom->x, &this->lj1, &this->lj3, + this->k_lj.run(&this->atom->x, &this->lj1, &this->lj3, &this->_lj_types, &this->gamma_upsilon_mu, &stride, &this->nbor->dev_packed, &this->ans->force, &this->ans->engv, &this->dev_error, &eflag, @@ -302,10 +302,10 @@ void GayBerneT::loop(const bool _eflag, const bool _vflag) { this->pack_nbors(NGX, BX, 0, this->ans->inum(),SPHERE_SPHERE, ELLIPSE_ELLIPSE,_shared_types,_lj_types); this->time_nbor1.stop(); - this->time_ellipsoid.start(); + this->time_ellipsoid.start(); this->k_ellipsoid.set_size(GX,BX); - this->k_ellipsoid.run(&this->atom->x, &this->atom->quat, - &this->shape, &this->well, &this->gamma_upsilon_mu, + this->k_ellipsoid.run(&this->atom->x, &this->atom->quat, + &this->shape, &this->well, &this->gamma_upsilon_mu, &this->sigma_epsilon, &this->_lj_types, &this->lshape, &this->nbor->dev_nbor, &stride, &this->ans->force, &ainum, &this->ans->engv, &this->dev_error, diff --git a/lib/gpu/lal_gayberne.cu b/lib/gpu/lal_gayberne.cu index 1a7e69eeba..71f29c2742 100644 --- a/lib/gpu/lal_gayberne.cu +++ b/lib/gpu/lal_gayberne.cu @@ -17,62 +17,62 @@ #include "lal_ellipsoid_extra.h" #endif -ucl_inline void compute_eta_torque(numtyp m[9],numtyp m2[9], const numtyp4 shape, +ucl_inline void compute_eta_torque(numtyp m[9],numtyp m2[9], const numtyp4 shape, numtyp ans[9]) { numtyp den = m[3]*m[2]*m[7]-m[0]*m[5]*m[7]- m[2]*m[6]*m[4]+m[1]*m[6]*m[5]- m[3]*m[1]*m[8]+m[0]*m[4]*m[8]; den = ucl_recip(den); - + ans[0] = shape.x*(m[5]*m[1]*m2[2]+(numtyp)2.0*m[4]*m[8]*m2[0]- m[4]*m2[2]*m[2]-(numtyp)2.0*m[5]*m2[0]*m[7]+ m2[1]*m[2]*m[7]-m2[1]*m[1]*m[8]- m[3]*m[8]*m2[1]+m[6]*m[5]*m2[1]+ m[3]*m2[2]*m[7]-m2[2]*m[6]*m[4])*den; - + ans[1] = shape.x*(m[2]*m2[0]*m[7]-m[8]*m2[0]*m[1]+ (numtyp)2.0*m[0]*m[8]*m2[1]-m[0]*m2[2]*m[5]- (numtyp)2.0*m[6]*m[2]*m2[1]+m2[2]*m[3]*m[2]- m[8]*m[3]*m2[0]+m[6]*m2[0]*m[5]+ m[6]*m2[2]*m[1]-m2[2]*m[0]*m[7])*den; - + ans[2] = shape.x*(m[1]*m[5]*m2[0]-m[2]*m2[0]*m[4]- m[0]*m[5]*m2[1]+m[3]*m[2]*m2[1]- m2[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6]+m[3]*m2[6]*m[8]- m[3]*m[2]*m2[8]-m[5]*m[6]*m2[6]+ m[0]*m2[8]*m[7]-m2[8]*m[1]*m[6])*den; - + ans[8] = shape.z*(m[1]*m[5]*m2[6]-m[2]*m2[6]*m[4]- m[0]*m[5]*m2[7]+m[3]*m[2]*m2[7]- m[4]*m[6]*m2[6]-m[7]*m2[7]*m[0]+ @@ -82,28 +82,28 @@ ucl_inline void compute_eta_torque(numtyp m[9],numtyp m2[9], const numtyp4 shape __kernel void k_gayberne(const __global numtyp4 *restrict x_, const __global numtyp4 *restrict q, - const __global numtyp4 *restrict shape, - const __global numtyp4 *restrict well, - const __global numtyp *restrict gum, - const __global numtyp2 *restrict sig_eps, - const int ntypes, - const __global numtyp *restrict lshape, - const __global int *dev_nbor, - const int stride, - __global acctyp4 *restrict ans, - const int astride, - __global acctyp *restrict engv, - __global int *restrict err_flag, + const __global numtyp4 *restrict shape, + const __global numtyp4 *restrict well, + const __global numtyp *restrict gum, + const __global numtyp2 *restrict sig_eps, + const int ntypes, + const __global numtyp *restrict lshape, + const __global int *dev_nbor, + const int stride, + __global acctyp4 *restrict ans, + const int astride, + __global acctyp *restrict engv, + __global int *restrict err_flag, const int eflag, const int vflag, const int inum, const int t_per_atom) { int tid, ii, offset; atom_info(t_per_atom,ii,tid,offset); __local numtyp sp_lj[4]; - sp_lj[0]=gum[3]; - sp_lj[1]=gum[4]; - sp_lj[2]=gum[5]; - sp_lj[3]=gum[6]; + sp_lj[0]=gum[3]; + sp_lj[1]=gum[4]; + sp_lj[2]=gum[5]; + sp_lj[3]=gum[6]; acctyp energy=(acctyp)0; acctyp4 f; @@ -124,7 +124,7 @@ __kernel void k_gayberne(const __global numtyp4 *restrict x_, __local int n_stride; nbor_info_e(dev_nbor,stride,t_per_atom,ii,offset,i,numj, n_stride,nbor_end,nbor); - + numtyp4 ix; fetch4(ix,i,pos_tex); int itype=ix.w; numtyp a1[9], b1[9], g1[9]; @@ -159,7 +159,7 @@ __kernel void k_gayberne(const __global numtyp4 *restrict x_, numtyp a2[9]; gpu_quat_to_mat_trans(q,j,a2); - + numtyp u_r, dUr[3], tUr[3], eta, teta[3]; { // Compute U_r, dUr, eta, and teta // Compute g12 @@ -173,7 +173,7 @@ __kernel void k_gayberne(const __global numtyp4 *restrict x_, } { // Compute U_r and dUr - + // Compute kappa numtyp kappa[3]; gpu_mldivide3(g12,r12,kappa,err_flag); @@ -189,7 +189,7 @@ __kernel void k_gayberne(const __global numtyp4 *restrict x_, kappa[2]*=ir; // energy - + // compute u_r and dUr numtyp uslj_rsq; { @@ -203,7 +203,7 @@ __kernel void k_gayberne(const __global numtyp4 *restrict x_, kappa[0]*=r; kappa[1]*=r; kappa[2]*=r; - + int mtype=fast_mul(ntypes,itype)+jtype; numtyp sigma = sig_eps[mtype].x; numtyp epsilon = sig_eps[mtype].y; @@ -235,14 +235,14 @@ __kernel void k_gayberne(const __global numtyp4 *restrict x_, } } } - + // Compute eta { eta = (numtyp)2.0*lshape[itype]*lshape[jtype]; numtyp det_g12 = gpu_det3(g12); eta = ucl_powr(eta/det_g12,gum[1]); } - + // Compute teta numtyp temp[9], tempv[3], tempv2[3]; compute_eta_torque(g12,a1,ishape,temp); @@ -255,7 +255,7 @@ __kernel void k_gayberne(const __global numtyp4 *restrict x_, teta[0] = tempv2[0]; teta[1] = tempv2[1]; teta[2] = tempv2[2]; - + tempv[0] = temp1*temp[3]; tempv[1] = temp1*temp[4]; tempv[2] = temp1*temp[5]; @@ -272,7 +272,7 @@ __kernel void k_gayberne(const __global numtyp4 *restrict x_, teta[1] += tempv2[1]; teta[2] += tempv2[2]; } - + numtyp chi, dchi[3], tchi[3]; { // Compute chi and dchi @@ -355,7 +355,7 @@ __kernel void k_gayberne(const __global numtyp4 *restrict x_, tor.x+=temp1*tchi[0]+temp2*teta[0]+temp3*tUr[0]; tor.y+=temp1*tchi[1]+temp2*teta[1]+temp3*tUr[1]; tor.z+=temp1*tchi[2]+temp2*teta[2]+temp3*tUr[2]; - + } // for nbor store_answers_t(f,tor,energy,virial,ii,astride,tid,t_per_atom,offset,eflag, vflag,ans,engv); diff --git a/lib/gpu/lal_gayberne.h b/lib/gpu/lal_gayberne.h index dacaf74282..8792f1f1db 100644 --- a/lib/gpu/lal_gayberne.h +++ b/lib/gpu/lal_gayberne.h @@ -25,14 +25,14 @@ template class GayBerne : public BaseEllipsoid { public: GayBerne(); - ~GayBerne(); + ~GayBerne(); /// Clear any previous data and set up for a new LAMMPS run /** \param max_nbors initial number of rows in the neighbor matrix * \param cell_size cutoff + skin - * \param gpu_split fraction of particles handled by device + * \param gpu_split fraction of particles handled by device * \return false if there is not sufficient memory or device init prob - * + * * Returns: * - 0 if successfull * - -1 if fix gpu not found @@ -41,18 +41,18 @@ class GayBerne : public BaseEllipsoid { * - -5 Double precision is not supported on card **/ int init(const int ntypes, const double gamma, const double upsilon, const double mu, double **host_shape, - double **host_well, double **host_cutsq, double **host_sigma, + double **host_well, double **host_cutsq, double **host_sigma, double **host_epsilon, double *host_lshape, int **h_form, - double **host_lj1, double **host_lj2, double **host_lj3, - double **host_lj4, double **host_offset, - const double *host_special_lj, const int nlocal, const int nall, + double **host_lj1, double **host_lj2, double **host_lj3, + double **host_lj4, double **host_offset, + const double *host_special_lj, const int nlocal, const int nall, const int max_nbors, const int maxspecial, const double cell_size, const double gpu_split, FILE *screen); /// Clear all host and device data /** \note This is called at the beginning of the init() routine **/ void clear(); - + /// Returns memory usage on device per atom int bytes_per_atom(const int max_nbors) const; @@ -61,8 +61,8 @@ class GayBerne : public BaseEllipsoid { /// Device Error Flag - Set if a bad matrix inversion occurs UCL_D_Vec dev_error; - - // --------------------------- TYPE DATA -------------------------- + + // --------------------------- TYPE DATA -------------------------- /// lj1.x = lj1, lj1.y = lj2, lj1.z = cutsq, lj1.w = form UCL_D_Vec lj1; @@ -72,12 +72,12 @@ class GayBerne : public BaseEllipsoid { UCL_D_Vec sigma_epsilon; // 0 - gamma, 1-upsilon, 2-mu, 3-special_lj[0], 4-special_lj[1], ... UCL_D_Vec gamma_upsilon_mu; - + /// If atom type constants fit in shared memory, use fast kernels bool _shared_types; int _lj_types; - - // --------------------------- ATOM DATA -------------------------- + + // --------------------------- ATOM DATA -------------------------- /// Aspherical Const Data for Atoms UCL_D_Vec shape, well; diff --git a/lib/gpu/lal_gayberne_ext.cpp b/lib/gpu/lal_gayberne_ext.cpp index e674fb376b..451550e7ef 100644 --- a/lib/gpu/lal_gayberne_ext.cpp +++ b/lib/gpu/lal_gayberne_ext.cpp @@ -33,7 +33,7 @@ int gb_gpu_init(const int ntypes, const double gamma, double **epsilon, double *host_lshape, int **form, double **host_lj1, double **host_lj2, double **host_lj3, double **host_lj4, double **offset, double *special_lj, - const int inum, const int nall, const int max_nbors, + const int inum, const int nall, const int max_nbors, const int maxspecial, const double cell_size, int &gpu_mode, FILE *screen) { GBMF.clear(); @@ -58,16 +58,16 @@ int gb_gpu_init(const int ntypes, const double gamma, int init_ok=0; if (world_me==0) - init_ok=GBMF.init(ntypes, gamma, upsilon, mu, shape, well, cutsq, - sigma, epsilon, host_lshape, form, host_lj1, - host_lj2, host_lj3, host_lj4, offset, special_lj, + init_ok=GBMF.init(ntypes, gamma, upsilon, mu, shape, well, cutsq, + sigma, epsilon, host_lshape, form, host_lj1, + host_lj2, host_lj3, host_lj4, offset, special_lj, inum, nall, max_nbors, maxspecial, cell_size, gpu_split, screen); GBMF.device->world_barrier(); if (message) fprintf(screen,"Done.\n"); - + for (int i=0; igpu_barrier(); - if (message) + if (message) fprintf(screen,"Done.\n"); } if (message) @@ -105,8 +105,8 @@ void gb_gpu_clear() { int** compute(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, double *sublo, double *subhi, tagint *tag, int **nspecial, - tagint **special, const bool eflag, const bool vflag, - const bool eatom, const bool vatom, int &host_start, + tagint **special, const bool eflag, const bool vflag, + const bool eatom, const bool vatom, int &host_start, int **ilist, int **numj, const double cpu_time, bool &success, double **host_quat); @@ -117,8 +117,8 @@ int** gb_gpu_compute_n(const int ago, const int inum_full, const int nall, const bool vatom, int &host_start, int **ilist, int **jnum, const double cpu_time, bool &success, double **host_quat) { - return GBMF.compute(ago, inum_full, nall, host_x, host_type, sublo, subhi, - tag, nspecial, special, eflag, vflag, eatom, vatom, + return GBMF.compute(ago, inum_full, nall, host_x, host_type, sublo, subhi, + tag, nspecial, special, eflag, vflag, eatom, vatom, host_start, ilist, jnum, cpu_time, success, host_quat); } diff --git a/lib/gpu/lal_gayberne_lj.cu b/lib/gpu/lal_gayberne_lj.cu index 9b33b5f7f3..7925b72784 100644 --- a/lib/gpu/lal_gayberne_lj.cu +++ b/lib/gpu/lal_gayberne_lj.cu @@ -18,30 +18,30 @@ #endif __kernel void k_gayberne_sphere_ellipsoid(const __global numtyp4 *restrict x_, - const __global numtyp4 *restrict q, + const __global numtyp4 *restrict q, const __global numtyp4 *restrict shape, - const __global numtyp4 *restrict well, - const __global numtyp *restrict gum, + const __global numtyp4 *restrict well, + const __global numtyp *restrict gum, const __global numtyp2 *restrict sig_eps, - const int ntypes, + const int ntypes, const __global numtyp *restrict lshape, - const __global int *dev_nbor, + const __global int *dev_nbor, const int stride, - __global acctyp4 *restrict ans, + __global acctyp4 *restrict ans, __global acctyp *restrict engv, - __global int *restrict err_flag, + __global int *restrict err_flag, const int eflag, const int vflag, - const int start, const int inum, + const int start, const int inum, const int t_per_atom) { int tid, ii, offset; atom_info(t_per_atom,ii,tid,offset); ii+=start; __local numtyp sp_lj[4]; - sp_lj[0]=gum[3]; - sp_lj[1]=gum[4]; - sp_lj[2]=gum[5]; - sp_lj[3]=gum[6]; + sp_lj[0]=gum[3]; + sp_lj[1]=gum[4]; + sp_lj[2]=gum[5]; + sp_lj[3]=gum[6]; acctyp energy=(acctyp)0; acctyp4 f; @@ -58,16 +58,16 @@ __kernel void k_gayberne_sphere_ellipsoid(const __global numtyp4 *restrict x_, __local int n_stride; nbor_info_e(dev_nbor,stride,t_per_atom,ii,offset,i,numj, n_stride,nbor_end,nbor); - + numtyp4 ix; fetch4(ix,i,pos_tex); int itype=ix.w; - + numtyp oner=shape[itype].x; numtyp one_well=well[itype].x; - + numtyp factor_lj; for ( ; nbor0) { numtyp e=r6inv*(lj3[ii].x*r6inv-lj3[ii].y); - energy+=factor_lj*(e-lj3[ii].z); + energy+=factor_lj*(e-lj3[ii].z); } if (vflag>0) { virial[0] += delx*delx*force; @@ -332,33 +332,33 @@ __kernel void k_gayberne_lj(const __global numtyp4 *restrict x_, } // if ii } -__kernel void k_gayberne_lj_fast(const __global numtyp4 *restrict x_, - const __global numtyp4 *restrict lj1_in, - const __global numtyp4 *restrict lj3_in, - const __global numtyp *restrict gum, - const int stride, +__kernel void k_gayberne_lj_fast(const __global numtyp4 *restrict x_, + const __global numtyp4 *restrict lj1_in, + const __global numtyp4 *restrict lj3_in, + const __global numtyp *restrict gum, + const int stride, const __global int *dev_ij, - __global acctyp4 *restrict ans, + __global acctyp4 *restrict ans, __global acctyp *restrict engv, - __global int *restrict err_flag, - const int eflag, const int vflag, - const int start, const int inum, + __global int *restrict err_flag, + const int eflag, const int vflag, + const int start, const int inum, const int t_per_atom) { int tid, ii, offset; atom_info(t_per_atom,ii,tid,offset); ii+=start; - __local numtyp sp_lj[4]; + __local numtyp sp_lj[4]; __local numtyp4 lj1[MAX_SHARED_TYPES*MAX_SHARED_TYPES]; __local numtyp4 lj3[MAX_SHARED_TYPES*MAX_SHARED_TYPES]; if (tid<4) - sp_lj[tid]=gum[tid+3]; + sp_lj[tid]=gum[tid+3]; if (tid0) lj3[tid]=lj3_in[tid]; } - + acctyp energy=(acctyp)0; acctyp4 f; f.x=(acctyp)0; @@ -367,9 +367,9 @@ __kernel void k_gayberne_lj_fast(const __global numtyp4 *restrict x_, acctyp virial[6]; for (int i=0; i<6; i++) virial[i]=(acctyp)0; - + __syncthreads(); - + if (ii0) { numtyp e=r6inv*(lj3[mtype].x*r6inv-lj3[mtype].y); - energy+=factor_lj*(e-lj3[mtype].z); + energy+=factor_lj*(e-lj3[mtype].z); } if (vflag>0) { virial[0] += delx*delx*force; diff --git a/lib/gpu/lal_lj.cpp b/lib/gpu/lal_lj.cpp index 6c6e145319..2190e40516 100644 --- a/lib/gpu/lal_lj.cpp +++ b/lib/gpu/lal_lj.cpp @@ -9,7 +9,7 @@ This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) __________________________________________________________________________ - begin : + begin : email : brownw@ornl.gov ***************************************************************************/ @@ -33,20 +33,20 @@ LJT::LJ() : BaseAtomic(), _allocated(false) { } template -LJT::~LJ() { +LJT::~LJ() { clear(); } - + template int LJT::bytes_per_atom(const int max_nbors) const { return this->bytes_per_atom_atomic(max_nbors); } template -int LJT::init(const int ntypes, - double **host_cutsq, double **host_lj1, - double **host_lj2, double **host_lj3, - double **host_lj4, double **host_offset, +int LJT::init(const int ntypes, + double **host_cutsq, double **host_lj1, + double **host_lj2, double **host_lj3, + double **host_lj4, double **host_offset, double *host_special_lj, const int nlocal, const int nall, const int max_nbors, const int maxspecial, const double cell_size, @@ -99,10 +99,10 @@ void LJT::reinit(const int ntypes, double **host_cutsq, double **host_lj1, // Allocate a host write buffer for data initialization UCL_H_Vec host_write(_lj_types*_lj_types*32,*(this->ucl_device), UCL_WRITE_ONLY); - + for (int i=0; i<_lj_types*_lj_types; i++) host_write[i]=0.0; - + this->atom->type_pack4(ntypes,_lj_types,lj1,host_write,host_lj1,host_lj2, host_cutsq); this->atom->type_pack4(ntypes,_lj_types,lj3,host_write,host_lj3,host_lj4, @@ -143,7 +143,7 @@ void LJT::loop(const bool _eflag, const bool _vflag) { vflag=1; else vflag=0; - + int GX=static_cast(ceil(static_cast(this->ans->inum())/ (BX/this->_threads_per_atom))); @@ -155,12 +155,12 @@ void LJT::loop(const bool _eflag, const bool _vflag) { this->k_pair_fast.run(&this->atom->x, &lj1, &lj3, &sp_lj, &this->nbor->dev_nbor, &this->_nbor_data->begin(), &this->ans->force, &this->ans->engv, &eflag, - &vflag, &ainum, &nbor_pitch, + &vflag, &ainum, &nbor_pitch, &this->_threads_per_atom); } else { this->k_pair.set_size(GX,BX); - this->k_pair.run(&this->atom->x, &lj1, &lj3, &_lj_types, &sp_lj, - &this->nbor->dev_nbor, &this->_nbor_data->begin(), + this->k_pair.run(&this->atom->x, &lj1, &lj3, &_lj_types, &sp_lj, + &this->nbor->dev_nbor, &this->_nbor_data->begin(), &this->ans->force, &this->ans->engv, &eflag, &vflag, &ainum, &nbor_pitch, &this->_threads_per_atom); } diff --git a/lib/gpu/lal_lj.cu b/lib/gpu/lal_lj.cu index 9569cb0fd7..5838ac95cf 100644 --- a/lib/gpu/lal_lj.cu +++ b/lib/gpu/lal_lj.cu @@ -9,7 +9,7 @@ // This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) // __________________________________________________________________________ // -// begin : +// begin : // email : brownw@ornl.gov // ***************************************************************************/ @@ -24,15 +24,15 @@ texture pos_tex; #define pos_tex x_ #endif -__kernel void k_lj(const __global numtyp4 *restrict x_, +__kernel void k_lj(const __global numtyp4 *restrict x_, const __global numtyp4 *restrict lj1, - const __global numtyp4 *restrict lj3, - const int lj_types, - const __global numtyp *restrict sp_lj, - const __global int * dev_nbor, - const __global int * dev_packed, - __global acctyp4 *restrict ans, - __global acctyp *restrict engv, + const __global numtyp4 *restrict lj3, + const int lj_types, + const __global numtyp *restrict sp_lj, + const __global int * dev_nbor, + const __global int * dev_packed, + __global acctyp4 *restrict ans, + __global acctyp *restrict engv, const int eflag, const int vflag, const int inum, const int nbor_pitch, const int t_per_atom) { int tid, ii, offset; @@ -44,19 +44,19 @@ __kernel void k_lj(const __global numtyp4 *restrict x_, acctyp virial[6]; for (int i=0; i<6; i++) virial[i]=(acctyp)0; - + if (ii0) { numtyp e=r6inv*(lj3[mtype].x*r6inv-lj3[mtype].y); - energy+=factor_lj*(e-lj3[mtype].z); + energy+=factor_lj*(e-lj3[mtype].z); } if (vflag>0) { virial[0] += delx*delx*force; @@ -101,19 +101,19 @@ __kernel void k_lj(const __global numtyp4 *restrict x_, } // if ii } -__kernel void k_lj_fast(const __global numtyp4 *restrict x_, +__kernel void k_lj_fast(const __global numtyp4 *restrict x_, const __global numtyp4 *restrict lj1_in, - const __global numtyp4 *restrict lj3_in, - const __global numtyp *restrict sp_lj_in, - const __global int * dev_nbor, - const __global int * dev_packed, - __global acctyp4 *restrict ans, - __global acctyp *restrict engv, - const int eflag, const int vflag, const int inum, + const __global numtyp4 *restrict lj3_in, + const __global numtyp *restrict sp_lj_in, + const __global int * dev_nbor, + const __global int * dev_packed, + __global acctyp4 *restrict ans, + __global acctyp *restrict engv, + const int eflag, const int vflag, const int inum, const int nbor_pitch, const int t_per_atom) { int tid, ii, offset; atom_info(t_per_atom,ii,tid,offset); - + __local numtyp4 lj1[MAX_SHARED_TYPES*MAX_SHARED_TYPES]; __local numtyp4 lj3[MAX_SHARED_TYPES*MAX_SHARED_TYPES]; __local numtyp sp_lj[4]; @@ -124,7 +124,7 @@ __kernel void k_lj_fast(const __global numtyp4 *restrict x_, if (eflag>0) lj3[tid]=lj3_in[tid]; } - + acctyp energy=(acctyp)0; acctyp4 f; f.x=(acctyp)0; f.y=(acctyp)0; f.z=(acctyp)0; @@ -133,7 +133,7 @@ __kernel void k_lj_fast(const __global numtyp4 *restrict x_, virial[i]=(acctyp)0; __syncthreads(); - + if (ii0) { numtyp e=r6inv*(lj3[mtype].x*r6inv-lj3[mtype].y); - energy+=factor_lj*(e-lj3[mtype].z); + energy+=factor_lj*(e-lj3[mtype].z); } if (vflag>0) { virial[0] += delx*delx*force; diff --git a/lib/gpu/lal_lj.h b/lib/gpu/lal_lj.h index 63a3e8a6c9..01ce85c8ea 100644 --- a/lib/gpu/lal_lj.h +++ b/lib/gpu/lal_lj.h @@ -9,7 +9,7 @@ This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) __________________________________________________________________________ - begin : + begin : email : brownw@ornl.gov ***************************************************************************/ @@ -24,13 +24,13 @@ template class LJ : public BaseAtomic { public: LJ(); - ~LJ(); + ~LJ(); /// Clear any previous data and set up for a new LAMMPS run /** \param max_nbors initial number of rows in the neighbor matrix * \param cell_size cutoff + skin * \param gpu_split fraction of particles handled by device - * + * * Returns: * - 0 if successfull * - -1 if fix gpu not found @@ -40,15 +40,15 @@ class LJ : public BaseAtomic { int init(const int ntypes, double **host_cutsq, double **host_lj1, double **host_lj2, double **host_lj3, double **host_lj4, double **host_offset, double *host_special_lj, - const int nlocal, const int nall, const int max_nbors, - const int maxspecial, const double cell_size, + const int nlocal, const int nall, const int max_nbors, + const int maxspecial, const double cell_size, const double gpu_split, FILE *screen); - + /// Send updated coeffs from host to device (to be compatible with fix adapt) void reinit(const int ntypes, double **host_cutsq, double **host_lj1, double **host_lj2, double **host_lj3, double **host_lj4, double **host_offset); - + /// Clear all host and device data /** \note This is called at the beginning of the init() routine **/ void clear(); @@ -71,7 +71,7 @@ class LJ : public BaseAtomic { /// If atom type constants fit in shared memory, use fast kernels bool shared_types; - /// Number of atom types + /// Number of atom types int _lj_types; private: diff --git a/lib/gpu/lal_lj96.cpp b/lib/gpu/lal_lj96.cpp index 70e46b9fe1..b59495c41a 100644 --- a/lib/gpu/lal_lj96.cpp +++ b/lib/gpu/lal_lj96.cpp @@ -9,7 +9,7 @@ This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) __________________________________________________________________________ - begin : + begin : email : brownw@ornl.gov ***************************************************************************/ @@ -36,7 +36,7 @@ template LJ96T::~LJ96() { clear(); } - + template int LJ96T::bytes_per_atom(const int max_nbors) const { return this->bytes_per_atom_atomic(max_nbors); @@ -44,9 +44,9 @@ int LJ96T::bytes_per_atom(const int max_nbors) const { template int LJ96T::init(const int ntypes, - double **host_cutsq, double **host_lj1, - double **host_lj2, double **host_lj3, - double **host_lj4, double **host_offset, + double **host_cutsq, double **host_lj1, + double **host_lj2, double **host_lj3, + double **host_lj4, double **host_offset, double *host_special_lj, const int nlocal, const int nall, const int max_nbors, const int maxspecial, const double cell_size, @@ -126,7 +126,7 @@ void LJ96T::loop(const bool _eflag, const bool _vflag) { vflag=1; else vflag=0; - + int GX=static_cast(ceil(static_cast(this->ans->inum())/ (BX/this->_threads_per_atom))); @@ -138,7 +138,7 @@ void LJ96T::loop(const bool _eflag, const bool _vflag) { this->k_pair_fast.run(&this->atom->x, &lj1, &lj3, &sp_lj, &this->nbor->dev_nbor, &this->_nbor_data->begin(), &this->ans->force, &this->ans->engv, &eflag, - &vflag, &ainum, &nbor_pitch, + &vflag, &ainum, &nbor_pitch, &this->_threads_per_atom); } else { this->k_pair.set_size(GX,BX); diff --git a/lib/gpu/lal_lj96.cu b/lib/gpu/lal_lj96.cu index b219b8bf0d..3bb7750022 100644 --- a/lib/gpu/lal_lj96.cu +++ b/lib/gpu/lal_lj96.cu @@ -9,7 +9,7 @@ // This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) // __________________________________________________________________________ // -// begin : +// begin : // email : brownw@ornl.gov // ***************************************************************************/ @@ -26,13 +26,13 @@ texture pos_tex; __kernel void k_lj96(const __global numtyp4 *restrict x_, const __global numtyp4 *restrict lj1, - const __global numtyp4 *restrict lj3, - const int lj_types, - const __global numtyp *restrict sp_lj_in, - const __global int *dev_nbor, - const __global int *dev_packed, + const __global numtyp4 *restrict lj3, + const int lj_types, + const __global numtyp *restrict sp_lj_in, + const __global int *dev_nbor, + const __global int *dev_packed, __global acctyp4 *restrict ans, - __global acctyp *restrict engv, + __global acctyp *restrict engv, const int eflag, const int vflag, const int inum, const int nbor_pitch, const int t_per_atom) { int tid, ii, offset; @@ -50,20 +50,20 @@ __kernel void k_lj96(const __global numtyp4 *restrict x_, acctyp virial[6]; for (int i=0; i<6; i++) virial[i]=(acctyp)0; - + if (ii0) { numtyp e=r6inv*(lj3[mtype].x*r3inv-lj3[mtype].y); - energy+=factor_lj*(e-lj3[mtype].z); + energy+=factor_lj*(e-lj3[mtype].z); } if (vflag>0) { virial[0] += delx*delx*force; @@ -109,15 +109,15 @@ __kernel void k_lj96(const __global numtyp4 *restrict x_, } // if ii } -__kernel void k_lj96_fast(const __global numtyp4 *restrict x_, +__kernel void k_lj96_fast(const __global numtyp4 *restrict x_, const __global numtyp4 *restrict lj1_in, - const __global numtyp4 *restrict lj3_in, + const __global numtyp4 *restrict lj3_in, const __global numtyp *restrict sp_lj_in, const __global int *dev_nbor, const __global int *dev_packed, __global acctyp4 *restrict ans, - __global acctyp *restrict engv, - const int eflag, const int vflag, const int inum, + __global acctyp *restrict engv, + const int eflag, const int vflag, const int inum, const int nbor_pitch, const int t_per_atom) { int tid, ii, offset; atom_info(t_per_atom,ii,tid,offset); @@ -132,30 +132,30 @@ __kernel void k_lj96_fast(const __global numtyp4 *restrict x_, if (eflag>0) lj3[tid]=lj3_in[tid]; } - + acctyp energy=(acctyp)0; acctyp4 f; f.x=(acctyp)0; f.y=(acctyp)0; f.z=(acctyp)0; acctyp virial[6]; for (int i=0; i<6; i++) virial[i]=(acctyp)0; - + __syncthreads(); - + if (ii0) { numtyp e=r6inv*(lj3[mtype].x*r3inv-lj3[mtype].y); - energy+=factor_lj*(e-lj3[mtype].z); + energy+=factor_lj*(e-lj3[mtype].z); } if (vflag>0) { virial[0] += delx*delx*force; diff --git a/lib/gpu/lal_lj96.h b/lib/gpu/lal_lj96.h index 7d51e287d3..3fdea5265e 100644 --- a/lib/gpu/lal_lj96.h +++ b/lib/gpu/lal_lj96.h @@ -9,7 +9,7 @@ This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) __________________________________________________________________________ - begin : + begin : email : brownw@ornl.gov ***************************************************************************/ @@ -30,7 +30,7 @@ class LJ96 : public BaseAtomic { /** \param max_nbors initial number of rows in the neighbor matrix * \param cell_size cutoff + skin * \param gpu_split fraction of particles handled by device - * + * * Returns: * - 0 if successfull * - -1 if fix gpu not found @@ -40,8 +40,8 @@ class LJ96 : public BaseAtomic { int init(const int ntypes, double **host_cutsq, double **host_lj1, double **host_lj2, double **host_lj3, double **host_lj4, double **host_offset, double *host_special_lj, - const int nlocal, const int nall, const int max_nbors, - const int maxspecial, const double cell_size, + const int nlocal, const int nall, const int max_nbors, + const int maxspecial, const double cell_size, const double gpu_split, FILE *screen); /// Clear all host and device data @@ -66,7 +66,7 @@ class LJ96 : public BaseAtomic { /// If atom type constants fit in shared memory, use fast kernels bool shared_types; - /// Number of atom types + /// Number of atom types int _lj_types; private: diff --git a/lib/gpu/lal_lj96_ext.cpp b/lib/gpu/lal_lj96_ext.cpp index 14c32ef95e..c7ec9f4448 100644 --- a/lib/gpu/lal_lj96_ext.cpp +++ b/lib/gpu/lal_lj96_ext.cpp @@ -9,7 +9,7 @@ This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) __________________________________________________________________________ - begin : + begin : email : brownw@ornl.gov ***************************************************************************/ @@ -77,7 +77,7 @@ int lj96_gpu_init(const int ntypes, double **cutsq, double **host_lj1, cell_size, gpu_split, screen); LJ96MF.device->gpu_barrier(); - if (message) + if (message) fprintf(screen,"Done.\n"); } if (message) @@ -102,7 +102,7 @@ int** lj96_gpu_compute_n(const int ago, const int inum_full, return LJ96MF.compute(ago, inum_full, nall, host_x, host_type, sublo, subhi, tag, nspecial, special, eflag, vflag, eatom, vatom, host_start, ilist, jnum, cpu_time, success); -} +} void lj96_gpu_compute(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, int *ilist, int *numj, diff --git a/lib/gpu/lal_lj_class2_long.cpp b/lib/gpu/lal_lj_class2_long.cpp index ef59843c4a..0109446b95 100644 --- a/lib/gpu/lal_lj_class2_long.cpp +++ b/lib/gpu/lal_lj_class2_long.cpp @@ -38,7 +38,7 @@ template LJClass2LongT::~LJClass2Long() { clear(); } - + template int LJClass2LongT::bytes_per_atom(const int max_nbors) const { return this->bytes_per_atom_atomic(max_nbors); @@ -46,8 +46,8 @@ int LJClass2LongT::bytes_per_atom(const int max_nbors) const { template int LJClass2LongT::init(const int ntypes, double **host_cutsq, - double **host_lj1, double **host_lj2, double **host_lj3, - double **host_lj4, double **host_offset, + double **host_lj1, double **host_lj2, double **host_lj3, + double **host_lj4, double **host_offset, double *host_special_lj, const int nlocal, const int nall, const int max_nbors, const int maxspecial, const double cell_size, @@ -136,7 +136,7 @@ void LJClass2LongT::loop(const bool _eflag, const bool _vflag) { vflag=1; else vflag=0; - + int GX=static_cast(ceil(static_cast(this->ans->inum())/ (BX/this->_threads_per_atom))); @@ -145,11 +145,11 @@ void LJClass2LongT::loop(const bool _eflag, const bool _vflag) { this->time_pair.start(); if (shared_types) { this->k_pair_fast.set_size(GX,BX); - this->k_pair_fast.run(&this->atom->x, &lj1, &lj3, &sp_lj, + this->k_pair_fast.run(&this->atom->x, &lj1, &lj3, &sp_lj, &this->nbor->dev_nbor, &this->_nbor_data->begin(), &this->ans->force, &this->ans->engv, &eflag, &vflag, &ainum, &nbor_pitch, &this->atom->q, - &_cut_coulsq, &_qqrd2e, &_g_ewald, + &_cut_coulsq, &_qqrd2e, &_g_ewald, &this->_threads_per_atom); } else { this->k_pair.set_size(GX,BX); diff --git a/lib/gpu/lal_lj_class2_long.cu b/lib/gpu/lal_lj_class2_long.cu index e16de3a327..41ceca35d7 100644 --- a/lib/gpu/lal_lj_class2_long.cu +++ b/lib/gpu/lal_lj_class2_long.cu @@ -32,15 +32,15 @@ texture q_tex; __kernel void k_lj_class2_long(const __global numtyp4 *restrict x_, const __global numtyp4 *restrict lj1, const __global numtyp4 *restrict lj3, - const int lj_types, + const int lj_types, const __global numtyp *restrict sp_lj_in, - const __global int *dev_nbor, + const __global int *dev_nbor, const __global int *dev_packed, __global acctyp4 *restrict ans, __global acctyp *restrict engv, - const int eflag, const int vflag, - const int inum, const int nbor_pitch, - const __global numtyp *restrict q_, + const int eflag, const int vflag, + const int inum, const int nbor_pitch, + const __global numtyp *restrict q_, const numtyp cut_coulsq, const numtyp qqrd2e, const numtyp g_ewald, const int t_per_atom) { int tid, ii, offset; @@ -63,14 +63,14 @@ __kernel void k_lj_class2_long(const __global numtyp4 *restrict x_, acctyp virial[6]; for (int i=0; i<6; i++) virial[i]=(acctyp)0; - + if (ii0) { virial[0] += delx*delx*force; @@ -147,20 +147,20 @@ __kernel void k_lj_class2_long(const __global numtyp4 *restrict x_, } // if ii } -__kernel void k_lj_class2_long_fast(const __global numtyp4 *restrict x_, +__kernel void k_lj_class2_long_fast(const __global numtyp4 *restrict x_, const __global numtyp4 *restrict lj1_in, - const __global numtyp4 *restrict lj3_in, + const __global numtyp4 *restrict lj3_in, const __global numtyp *restrict sp_lj_in, - const __global int *dev_nbor, + const __global int *dev_nbor, const __global int *dev_packed, - __global acctyp4 *restrict ans, - __global acctyp *restrict engv, - const int eflag, const int vflag, - const int inum, const int nbor_pitch, + __global acctyp4 *restrict ans, + __global acctyp *restrict engv, + const int eflag, const int vflag, + const int inum, const int nbor_pitch, const __global numtyp *restrict q_, - const numtyp cut_coulsq, + const numtyp cut_coulsq, const numtyp qqrd2e, - const numtyp g_ewald, + const numtyp g_ewald, const int t_per_atom) { int tid, ii, offset; atom_info(t_per_atom,ii,tid,offset); @@ -175,7 +175,7 @@ __kernel void k_lj_class2_long_fast(const __global numtyp4 *restrict x_, if (eflag>0) lj3[tid]=lj3_in[tid]; } - + acctyp energy=(acctyp)0; acctyp e_coul=(acctyp)0; acctyp4 f; @@ -183,16 +183,16 @@ __kernel void k_lj_class2_long_fast(const __global numtyp4 *restrict x_, acctyp virial[6]; for (int i=0; i<6; i++) virial[i]=(acctyp)0; - + __syncthreads(); - + if (ii { /** \param max_nbors initial number of rows in the neighbor matrix * \param cell_size cutoff + skin * \param gpu_split fraction of particles handled by device - * + * * Returns: * - 0 if successfull * - -1 if fix gpu not found @@ -40,8 +40,8 @@ class LJClass2Long : public BaseCharge { int init(const int ntypes, double **host_cutsq, double **host_lj1, double **host_lj2, double **host_lj3, double **host_lj4, double **host_offset, double *host_special_lj, - const int nlocal, const int nall, const int max_nbors, - const int maxspecial, const double cell_size, + const int nlocal, const int nall, const int max_nbors, + const int maxspecial, const double cell_size, const double gpu_split, FILE *screen, double **host_cut_ljsq, const double host_cut_coulsq, double *host_special_coul, const double qqrd2e, const double g_ewald); @@ -68,7 +68,7 @@ class LJClass2Long : public BaseCharge { /// If atom type constants fit in shared memory, use fast kernels bool shared_types; - /// Number of atom types + /// Number of atom types int _lj_types; numtyp _cut_coulsq, _qqrd2e, _g_ewald; diff --git a/lib/gpu/lal_lj_class2_long_ext.cpp b/lib/gpu/lal_lj_class2_long_ext.cpp index 4bb3aad7ad..fa3e95f1f2 100644 --- a/lib/gpu/lal_lj_class2_long_ext.cpp +++ b/lib/gpu/lal_lj_class2_long_ext.cpp @@ -82,7 +82,7 @@ int c2cl_gpu_init(const int ntypes, double **cutsq, double **host_lj1, host_cut_coulsq, host_special_coul, qqrd2e, g_ewald); C2CLMF.device->gpu_barrier(); - if (message) + if (message) fprintf(screen,"Done.\n"); } if (message) @@ -99,7 +99,7 @@ void c2cl_gpu_clear() { int** c2cl_gpu_compute_n(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, - double *sublo, double *subhi, tagint *tag, int **nspecial, + double *sublo, double *subhi, tagint *tag, int **nspecial, tagint **special, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, int **ilist, int **jnum, const double cpu_time, @@ -109,7 +109,7 @@ int** c2cl_gpu_compute_n(const int ago, const int inum_full, subhi, tag, nspecial, special, eflag, vflag, eatom, vatom, host_start, ilist, jnum, cpu_time, success, host_q, boxlo, prd); -} +} void c2cl_gpu_compute(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, int *ilist, int *numj, diff --git a/lib/gpu/lal_lj_coul.cpp b/lib/gpu/lal_lj_coul.cpp index 8030f3cfc2..00a5c108d9 100644 --- a/lib/gpu/lal_lj_coul.cpp +++ b/lib/gpu/lal_lj_coul.cpp @@ -9,7 +9,7 @@ This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) __________________________________________________________________________ - begin : + begin : email : brownw@ornl.gov ***************************************************************************/ @@ -37,7 +37,7 @@ template LJCoulT::~LJCoul() { clear(); } - + template int LJCoulT::bytes_per_atom(const int max_nbors) const { return this->bytes_per_atom_atomic(max_nbors); @@ -45,9 +45,9 @@ int LJCoulT::bytes_per_atom(const int max_nbors) const { template int LJCoulT::init(const int ntypes, - double **host_cutsq, double **host_lj1, - double **host_lj2, double **host_lj3, - double **host_lj4, double **host_offset, + double **host_cutsq, double **host_lj1, + double **host_lj2, double **host_lj3, + double **host_lj4, double **host_offset, double *host_special_lj, const int nlocal, const int nall, const int max_nbors, const int maxspecial, const double cell_size, @@ -138,7 +138,7 @@ void LJCoulT::loop(const bool _eflag, const bool _vflag) { vflag=1; else vflag=0; - + int GX=static_cast(ceil(static_cast(this->ans->inum())/ (BX/this->_threads_per_atom))); @@ -149,14 +149,14 @@ void LJCoulT::loop(const bool _eflag, const bool _vflag) { this->k_pair_fast.set_size(GX,BX); this->k_pair_fast.run(&this->atom->x, &lj1, &lj3, &sp_lj, &this->nbor->dev_nbor, &this->_nbor_data->begin(), - &this->ans->force, &this->ans->engv, &eflag, + &this->ans->force, &this->ans->engv, &eflag, &vflag, &ainum, &nbor_pitch, &this->atom->q, &cutsq, &_qqrd2e, &this->_threads_per_atom); } else { this->k_pair.set_size(GX,BX); - this->k_pair.run(&this->atom->x, &lj1, &lj3, &_lj_types, &sp_lj, - &this->nbor->dev_nbor, &this->_nbor_data->begin(), - &this->ans->force, &this->ans->engv, + this->k_pair.run(&this->atom->x, &lj1, &lj3, &_lj_types, &sp_lj, + &this->nbor->dev_nbor, &this->_nbor_data->begin(), + &this->ans->force, &this->ans->engv, &eflag, &vflag, &ainum, &nbor_pitch, &this->atom->q, &cutsq, &_qqrd2e, &this->_threads_per_atom); } diff --git a/lib/gpu/lal_lj_coul.cu b/lib/gpu/lal_lj_coul.cu index 364203db22..5c7f0da46f 100644 --- a/lib/gpu/lal_lj_coul.cu +++ b/lib/gpu/lal_lj_coul.cu @@ -9,7 +9,7 @@ // This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) // __________________________________________________________________________ // -// begin : +// begin : // email : brownw@ornl.gov // ***************************************************************************/ @@ -29,19 +29,19 @@ texture q_tex; #define q_tex q_ #endif -__kernel void k_lj_coul(const __global numtyp4 *restrict x_, +__kernel void k_lj_coul(const __global numtyp4 *restrict x_, const __global numtyp4 *restrict lj1, - const __global numtyp4 *restrict lj3, - const int lj_types, + const __global numtyp4 *restrict lj3, + const int lj_types, const __global numtyp *restrict sp_lj_in, - const __global int *dev_nbor, - const __global int *dev_packed, + const __global int *dev_nbor, + const __global int *dev_packed, __global acctyp4 *restrict ans, - __global acctyp *restrict engv, + __global acctyp *restrict engv, const int eflag, const int vflag, const int inum, - const int nbor_pitch, - const __global numtyp *restrict q_, - const __global numtyp *restrict cutsq, + const int nbor_pitch, + const __global numtyp *restrict q_, + const __global numtyp *restrict cutsq, const numtyp qqrd2e, const int t_per_atom) { int tid, ii, offset; atom_info(t_per_atom,ii,tid,offset); @@ -63,14 +63,14 @@ __kernel void k_lj_coul(const __global numtyp4 *restrict x_, acctyp virial[6]; for (int i=0; i<6; i++) virial[i]=(acctyp)0; - + if (ii0) { virial[0] += delx*delx*force; @@ -140,16 +140,16 @@ __kernel void k_lj_coul(const __global numtyp4 *restrict x_, __kernel void k_lj_coul_fast(const __global numtyp4 *restrict x_, const __global numtyp4 *restrict lj1_in, - const __global numtyp4 *restrict lj3_in, + const __global numtyp4 *restrict lj3_in, const __global numtyp *restrict sp_lj_in, - const __global int *dev_nbor, + const __global int *dev_nbor, const __global int *dev_packed, __global acctyp4 *restrict ans, - __global acctyp *restrict engv, - const int eflag, const int vflag, const int inum, - const int nbor_pitch, + __global acctyp *restrict engv, + const int eflag, const int vflag, const int inum, + const int nbor_pitch, const __global numtyp *restrict q_, - const __global numtyp *restrict _cutsq, + const __global numtyp *restrict _cutsq, const numtyp qqrd2e, const int t_per_atom) { int tid, ii, offset; atom_info(t_per_atom,ii,tid,offset); @@ -166,7 +166,7 @@ __kernel void k_lj_coul_fast(const __global numtyp4 *restrict x_, if (eflag>0) lj3[tid]=lj3_in[tid]; } - + acctyp energy=(acctyp)0; acctyp e_coul=(acctyp)0; acctyp4 f; @@ -174,16 +174,16 @@ __kernel void k_lj_coul_fast(const __global numtyp4 *restrict x_, acctyp virial[6]; for (int i=0; i<6; i++) virial[i]=(acctyp)0; - + __syncthreads(); - + if (ii { /** \param max_nbors initial number of rows in the neighbor matrix * \param cell_size cutoff + skin * \param gpu_split fraction of particles handled by device - * + * * Returns: * - 0 if successfull * - -1 if fix gpu not found @@ -40,7 +40,7 @@ class LJCoul : public BaseCharge { int init(const int ntypes, double **host_cutsq, double **host_lj1, double **host_lj2, double **host_lj3, double **host_lj4, double **host_offset, double *host_special_lj, - const int nlocal, const int nall, const int max_nbors, + const int nlocal, const int nall, const int max_nbors, const int maxspecial, const double cell_size, const double gpu_split, FILE *screen, double **host_cut_ljsq, double **host_cut_coulsq, double *host_special_coul, @@ -70,7 +70,7 @@ class LJCoul : public BaseCharge { /// If atom type constants fit in shared memory, use fast kernels bool shared_types; - /// Number of atom types + /// Number of atom types int _lj_types; numtyp _qqrd2e; diff --git a/lib/gpu/lal_lj_coul_debye.cpp b/lib/gpu/lal_lj_coul_debye.cpp index 135a4dfd9d..1b230096a4 100644 --- a/lib/gpu/lal_lj_coul_debye.cpp +++ b/lib/gpu/lal_lj_coul_debye.cpp @@ -9,7 +9,7 @@ This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) __________________________________________________________________________ - begin : + begin : email : nguyentd@ornl.gov ***************************************************************************/ @@ -37,7 +37,7 @@ template LJCoulDebyeT::~LJCoulDebye() { clear(); } - + template int LJCoulDebyeT::bytes_per_atom(const int max_nbors) const { return this->bytes_per_atom_atomic(max_nbors); @@ -45,9 +45,9 @@ int LJCoulDebyeT::bytes_per_atom(const int max_nbors) const { template int LJCoulDebyeT::init(const int ntypes, - double **host_cutsq, double **host_lj1, - double **host_lj2, double **host_lj3, - double **host_lj4, double **host_offset, + double **host_cutsq, double **host_lj1, + double **host_lj2, double **host_lj3, + double **host_lj4, double **host_offset, double *host_special_lj, const int nlocal, const int nall, const int max_nbors, const int maxspecial, const double cell_size, @@ -98,7 +98,7 @@ int LJCoulDebyeT::init(const int ntypes, _qqrd2e=qqrd2e; _kappa=kappa; - + _allocated=true; this->_max_bytes=lj1.row_bytes()+lj3.row_bytes()+cutsq.row_bytes()+ sp_lj.row_bytes(); @@ -140,7 +140,7 @@ void LJCoulDebyeT::loop(const bool _eflag, const bool _vflag) { vflag=1; else vflag=0; - + int GX=static_cast(ceil(static_cast(this->ans->inum())/ (BX/this->_threads_per_atom))); @@ -157,9 +157,9 @@ void LJCoulDebyeT::loop(const bool _eflag, const bool _vflag) { } else { this->k_pair.set_size(GX,BX); this->k_pair.run(&this->atom->x, &lj1, &lj3, &_lj_types, &sp_lj, - &this->nbor->dev_nbor, &this->_nbor_data->begin(), + &this->nbor->dev_nbor, &this->_nbor_data->begin(), &this->ans->force, &this->ans->engv, &eflag, &vflag, - &ainum, &nbor_pitch, &this->atom->q, &cutsq, + &ainum, &nbor_pitch, &this->atom->q, &cutsq, &_qqrd2e, &_kappa, &this->_threads_per_atom); } this->time_pair.stop(); diff --git a/lib/gpu/lal_lj_coul_debye.cu b/lib/gpu/lal_lj_coul_debye.cu index 308504c6c8..91b105b3da 100644 --- a/lib/gpu/lal_lj_coul_debye.cu +++ b/lib/gpu/lal_lj_coul_debye.cu @@ -9,7 +9,7 @@ // This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) // __________________________________________________________________________ // -// begin : +// begin : // email : nguyentd@ornl.gov // ***************************************************************************/ @@ -29,19 +29,19 @@ texture q_tex; #define q_tex q_ #endif -__kernel void k_lj_debye(const __global numtyp4 *restrict x_, +__kernel void k_lj_debye(const __global numtyp4 *restrict x_, const __global numtyp4 *restrict lj1, - const __global numtyp4 *restrict lj3, - const int lj_types, - const __global numtyp *restrict sp_lj_in, - const __global int *dev_nbor, - const __global int *dev_packed, + const __global numtyp4 *restrict lj3, + const int lj_types, + const __global numtyp *restrict sp_lj_in, + const __global int *dev_nbor, + const __global int *dev_packed, __global acctyp4 *restrict ans, __global acctyp *restrict engv, const int eflag, const int vflag, const int inum, const int nbor_pitch, const __global numtyp *restrict q_ , - const __global numtyp *restrict cutsq, + const __global numtyp *restrict cutsq, const numtyp qqrd2e, const numtyp kappa, const int t_per_atom) { int tid, ii, offset; @@ -64,14 +64,14 @@ __kernel void k_lj_debye(const __global numtyp4 *restrict x_, acctyp virial[6]; for (int i=0; i<6; i++) virial[i]=(acctyp)0; - + if (ii0) { virial[0] += delx*delx*force; @@ -147,15 +147,15 @@ __kernel void k_lj_debye(const __global numtyp4 *restrict x_, __kernel void k_lj_debye_fast(const __global numtyp4 *restrict x_, const __global numtyp4 *restrict lj1_in, - const __global numtyp4 *restrict lj3_in, + const __global numtyp4 *restrict lj3_in, const __global numtyp *restrict sp_lj_in, const __global int *dev_nbor, const __global int *dev_packed, __global acctyp4 *restrict ans, - __global acctyp *restrict engv, - const int eflag, const int vflag, const int inum, - const int nbor_pitch, - const __global numtyp *restrict q_, + __global acctyp *restrict engv, + const int eflag, const int vflag, const int inum, + const int nbor_pitch, + const __global numtyp *restrict q_, const __global numtyp *restrict _cutsq, const numtyp qqrd2e, const numtyp kappa, const int t_per_atom) { @@ -174,7 +174,7 @@ __kernel void k_lj_debye_fast(const __global numtyp4 *restrict x_, if (eflag>0) lj3[tid]=lj3_in[tid]; } - + acctyp energy=(acctyp)0; acctyp e_coul=(acctyp)0; acctyp4 f; @@ -182,16 +182,16 @@ __kernel void k_lj_debye_fast(const __global numtyp4 *restrict x_, acctyp virial[6]; for (int i=0; i<6; i++) virial[i]=(acctyp)0; - + __syncthreads(); - + if (ii { /** \param max_nbors initial number of rows in the neighbor matrix * \param cell_size cutoff + skin * \param gpu_split fraction of particles handled by device - * + * * Returns: * - 0 if successfull * - -1 if fix gpu not found @@ -40,7 +40,7 @@ class LJCoulDebye : public BaseCharge { int init(const int ntypes, double **host_cutsq, double **host_lj1, double **host_lj2, double **host_lj3, double **host_lj4, double **host_offset, double *host_special_lj, - const int nlocal, const int nall, const int max_nbors, + const int nlocal, const int nall, const int max_nbors, const int maxspecial, const double cell_size, const double gpu_split, FILE *screen, double **host_cut_ljsq, double **host_cut_coulsq, double *host_special_coul, @@ -70,7 +70,7 @@ class LJCoulDebye : public BaseCharge { /// If atom type constants fit in shared memory, use fast kernels bool shared_types; - /// Number of atom types + /// Number of atom types int _lj_types; numtyp _qqrd2e,_kappa; diff --git a/lib/gpu/lal_lj_coul_debye_ext.cpp b/lib/gpu/lal_lj_coul_debye_ext.cpp index 67f5a0075f..8ec189a764 100644 --- a/lib/gpu/lal_lj_coul_debye_ext.cpp +++ b/lib/gpu/lal_lj_coul_debye_ext.cpp @@ -9,7 +9,7 @@ This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) __________________________________________________________________________ - begin : + begin : email : nguyentd@ornl.gov ***************************************************************************/ @@ -33,7 +33,7 @@ int ljcd_gpu_init(const int ntypes, double **cutsq, double **host_lj1, const int nall, const int max_nbors, const int maxspecial, const double cell_size, int &gpu_mode, FILE *screen, double **host_cut_ljsq, double **host_cut_coulsq, - double *host_special_coul, const double qqrd2e, + double *host_special_coul, const double qqrd2e, const double kappa) { LJCDMF.clear(); gpu_mode=LJCDMF.device->gpu_mode(); @@ -82,7 +82,7 @@ int ljcd_gpu_init(const int ntypes, double **cutsq, double **host_lj1, host_cut_coulsq, host_special_coul, qqrd2e, kappa); LJCDMF.device->gpu_barrier(); - if (message) + if (message) fprintf(screen,"Done.\n"); } if (message) @@ -99,7 +99,7 @@ void ljcd_gpu_clear() { int** ljcd_gpu_compute_n(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, - double *sublo, double *subhi, tagint *tag, int **nspecial, + double *sublo, double *subhi, tagint *tag, int **nspecial, tagint **special, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, int **ilist, int **jnum, const double cpu_time, @@ -109,7 +109,7 @@ int** ljcd_gpu_compute_n(const int ago, const int inum_full, subhi, tag, nspecial, special, eflag, vflag, eatom, vatom, host_start, ilist, jnum, cpu_time, success, host_q, boxlo, prd); -} +} void ljcd_gpu_compute(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, int *ilist, int *numj, diff --git a/lib/gpu/lal_lj_coul_ext.cpp b/lib/gpu/lal_lj_coul_ext.cpp index 3b5cc09805..297ac7414e 100644 --- a/lib/gpu/lal_lj_coul_ext.cpp +++ b/lib/gpu/lal_lj_coul_ext.cpp @@ -9,7 +9,7 @@ This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) __________________________________________________________________________ - begin : + begin : email : brownw@ornl.gov ***************************************************************************/ @@ -81,7 +81,7 @@ int ljc_gpu_init(const int ntypes, double **cutsq, double **host_lj1, host_cut_coulsq, host_special_coul, qqrd2e); LJCMF.device->gpu_barrier(); - if (message) + if (message) fprintf(screen,"Done.\n"); } if (message) @@ -98,7 +98,7 @@ void ljc_gpu_clear() { int** ljc_gpu_compute_n(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, - double *sublo, double *subhi, tagint *tag, int **nspecial, + double *sublo, double *subhi, tagint *tag, int **nspecial, tagint **special, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, int **ilist, int **jnum, const double cpu_time, @@ -108,7 +108,7 @@ int** ljc_gpu_compute_n(const int ago, const int inum_full, subhi, tag, nspecial, special, eflag, vflag, eatom, vatom, host_start, ilist, jnum, cpu_time, success, host_q, boxlo, prd); -} +} void ljc_gpu_compute(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, int *ilist, int *numj, diff --git a/lib/gpu/lal_lj_coul_long.cpp b/lib/gpu/lal_lj_coul_long.cpp index 03f32a5fd0..71205af0ea 100644 --- a/lib/gpu/lal_lj_coul_long.cpp +++ b/lib/gpu/lal_lj_coul_long.cpp @@ -9,7 +9,7 @@ This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) __________________________________________________________________________ - begin : + begin : email : brownw@ornl.gov ***************************************************************************/ @@ -37,7 +37,7 @@ template LJCoulLongT::~LJCoulLong() { clear(); } - + template int LJCoulLongT::bytes_per_atom(const int max_nbors) const { return this->bytes_per_atom_atomic(max_nbors); @@ -45,9 +45,9 @@ int LJCoulLongT::bytes_per_atom(const int max_nbors) const { template int LJCoulLongT::init(const int ntypes, - double **host_cutsq, double **host_lj1, - double **host_lj2, double **host_lj3, - double **host_lj4, double **host_offset, + double **host_cutsq, double **host_lj1, + double **host_lj2, double **host_lj3, + double **host_lj4, double **host_offset, double *host_special_lj, const int nlocal, const int nall, const int max_nbors, const int maxspecial, const double cell_size, @@ -109,10 +109,10 @@ void LJCoulLongT::reinit(const int ntypes, double **host_cutsq, double **host_lj // Allocate a host write buffer for data initialization UCL_H_Vec host_write(_lj_types*_lj_types*32,*(this->ucl_device), UCL_WRITE_ONLY); - + for (int i=0; i<_lj_types*_lj_types; i++) host_write[i]=0.0; - + this->atom->type_pack4(ntypes,_lj_types,lj1,host_write,host_lj1,host_lj2, host_cutsq, host_cut_ljsq); this->atom->type_pack4(ntypes,_lj_types,lj3,host_write,host_lj3,host_lj4, @@ -153,7 +153,7 @@ void LJCoulLongT::loop(const bool _eflag, const bool _vflag) { vflag=1; else vflag=0; - + int GX=static_cast(ceil(static_cast(this->ans->inum())/ (BX/this->_threads_per_atom))); @@ -162,7 +162,7 @@ void LJCoulLongT::loop(const bool _eflag, const bool _vflag) { this->time_pair.start(); if (shared_types) { this->k_pair_fast.set_size(GX,BX); - this->k_pair_fast.run(&this->atom->x, &lj1, &lj3, &sp_lj, + this->k_pair_fast.run(&this->atom->x, &lj1, &lj3, &sp_lj, &this->nbor->dev_nbor, &this->_nbor_data->begin(), &this->ans->force, &this->ans->engv, &eflag, &vflag, &ainum, &nbor_pitch, &this->atom->q, diff --git a/lib/gpu/lal_lj_coul_long.cu b/lib/gpu/lal_lj_coul_long.cu index e0aa2e8a58..0e25bb2dbc 100644 --- a/lib/gpu/lal_lj_coul_long.cu +++ b/lib/gpu/lal_lj_coul_long.cu @@ -9,7 +9,7 @@ // This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) // __________________________________________________________________________ // -// begin : +// begin : // email : brownw@ornl.gov // ***************************************************************************/ @@ -29,17 +29,17 @@ texture q_tex; #define q_tex q_ #endif -__kernel void k_lj_coul_long(const __global numtyp4 *restrict x_, +__kernel void k_lj_coul_long(const __global numtyp4 *restrict x_, const __global numtyp4 *restrict lj1, - const __global numtyp4 *restrict lj3, - const int lj_types, - const __global numtyp *restrict sp_lj_in, - const __global int *dev_nbor, + const __global numtyp4 *restrict lj3, + const int lj_types, + const __global numtyp *restrict sp_lj_in, + const __global int *dev_nbor, const __global int *dev_packed, __global acctyp4 *restrict ans, __global acctyp *restrict engv, const int eflag, const int vflag, const int inum, - const int nbor_pitch, + const int nbor_pitch, const __global numtyp *restrict q_, const numtyp cut_coulsq, const numtyp qqrd2e, const numtyp g_ewald, const int t_per_atom) { @@ -63,14 +63,14 @@ __kernel void k_lj_coul_long(const __global numtyp4 *restrict x_, acctyp virial[6]; for (int i=0; i<6; i++) virial[i]=(acctyp)0; - + if (ii0) { virial[0] += delx*delx*force; @@ -145,14 +145,14 @@ __kernel void k_lj_coul_long(const __global numtyp4 *restrict x_, } // if ii } -__kernel void k_lj_coul_long_fast(const __global numtyp4 *restrict x_, +__kernel void k_lj_coul_long_fast(const __global numtyp4 *restrict x_, const __global numtyp4 *restrict lj1_in, - const __global numtyp4 *restrict lj3_in, + const __global numtyp4 *restrict lj3_in, const __global numtyp *restrict sp_lj_in, - const __global int *dev_nbor, + const __global int *dev_nbor, const __global int *dev_packed, - __global acctyp4 *restrict ans, - __global acctyp *restrict engv, + __global acctyp4 *restrict ans, + __global acctyp *restrict engv, const int eflag, const int vflag, const int inum, const int nbor_pitch, const __global numtyp *restrict q_, @@ -171,7 +171,7 @@ __kernel void k_lj_coul_long_fast(const __global numtyp4 *restrict x_, if (eflag>0) lj3[tid]=lj3_in[tid]; } - + acctyp energy=(acctyp)0; acctyp e_coul=(acctyp)0; acctyp4 f; @@ -179,16 +179,16 @@ __kernel void k_lj_coul_long_fast(const __global numtyp4 *restrict x_, acctyp virial[6]; for (int i=0; i<6; i++) virial[i]=(acctyp)0; - + __syncthreads(); - + if (ii { /** \param max_nbors initial number of rows in the neighbor matrix * \param cell_size cutoff + skin * \param gpu_split fraction of particles handled by device - * + * * Returns: * - 0 if successfull * - -1 if fix gpu not found @@ -40,8 +40,8 @@ class LJCoulLong : public BaseCharge { int init(const int ntypes, double **host_cutsq, double **host_lj1, double **host_lj2, double **host_lj3, double **host_lj4, double **host_offset, double *host_special_lj, - const int nlocal, const int nall, const int max_nbors, - const int maxspecial, const double cell_size, + const int nlocal, const int nall, const int max_nbors, + const int maxspecial, const double cell_size, const double gpu_split, FILE *screen, double **host_cut_ljsq, const double host_cut_coulsq, double *host_special_coul, const double qqrd2e, const double g_ewald); @@ -73,7 +73,7 @@ class LJCoulLong : public BaseCharge { /// If atom type constants fit in shared memory, use fast kernels bool shared_types; - /// Number of atom types + /// Number of atom types int _lj_types; numtyp _cut_coulsq, _qqrd2e, _g_ewald; diff --git a/lib/gpu/lal_lj_coul_long_ext.cpp b/lib/gpu/lal_lj_coul_long_ext.cpp index dc93365f22..95bd369336 100644 --- a/lib/gpu/lal_lj_coul_long_ext.cpp +++ b/lib/gpu/lal_lj_coul_long_ext.cpp @@ -9,7 +9,7 @@ This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) __________________________________________________________________________ - begin : + begin : email : brownw@ornl.gov ***************************************************************************/ @@ -82,7 +82,7 @@ int ljcl_gpu_init(const int ntypes, double **cutsq, double **host_lj1, host_cut_coulsq, host_special_coul, qqrd2e, g_ewald); LJCLMF.device->gpu_barrier(); - if (message) + if (message) fprintf(screen,"Done.\n"); } if (message) @@ -102,15 +102,15 @@ void ljcl_gpu_reinit(const int ntypes, double **cutsq, double **host_lj1, int world_me=LJCLMF.device->world_me(); int gpu_rank=LJCLMF.device->gpu_rank(); int procs_per_gpu=LJCLMF.device->procs_per_gpu(); - + if (world_me==0) - LJCLMF.reinit(ntypes, cutsq, host_lj1, host_lj2, host_lj3, host_lj4, + LJCLMF.reinit(ntypes, cutsq, host_lj1, host_lj2, host_lj3, host_lj4, offset, host_cut_ljsq); LJCLMF.device->world_barrier(); - + for (int i=0; igpu_barrier(); } @@ -122,7 +122,7 @@ void ljcl_gpu_clear() { int** ljcl_gpu_compute_n(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, - double *sublo, double *subhi, tagint *tag, int **nspecial, + double *sublo, double *subhi, tagint *tag, int **nspecial, tagint **special, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, int **ilist, int **jnum, const double cpu_time, @@ -132,7 +132,7 @@ int** ljcl_gpu_compute_n(const int ago, const int inum_full, subhi, tag, nspecial, special, eflag, vflag, eatom, vatom, host_start, ilist, jnum, cpu_time, success, host_q, boxlo, prd); -} +} void ljcl_gpu_compute(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, int *ilist, int *numj, diff --git a/lib/gpu/lal_lj_coul_msm.cpp b/lib/gpu/lal_lj_coul_msm.cpp index dd045b7970..7559a93b90 100644 --- a/lib/gpu/lal_lj_coul_msm.cpp +++ b/lib/gpu/lal_lj_coul_msm.cpp @@ -9,7 +9,7 @@ This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) __________________________________________________________________________ - begin : + begin : email : brownw@ornl.gov ***************************************************************************/ @@ -37,7 +37,7 @@ template LJCoulMSMT::~LJCoulMSM() { clear(); } - + template int LJCoulMSMT::bytes_per_atom(const int max_nbors) const { return this->bytes_per_atom_atomic(max_nbors); @@ -45,8 +45,8 @@ int LJCoulMSMT::bytes_per_atom(const int max_nbors) const { template int LJCoulMSMT::init(const int ntypes, - double **host_cutsq, double **host_lj1, - double **host_lj2, double **host_lj3, + double **host_cutsq, double **host_lj1, + double **host_lj2, double **host_lj3, double **host_lj4, double **host_gcons, double **host_dgcons, double **host_offset, double *host_special_lj, const int nlocal, @@ -93,11 +93,11 @@ int LJCoulMSMT::init(const int ntypes, ncols = 7; UCL_H_Vec dview_gcons(nrows*ncols,*(this->ucl_device), UCL_WRITE_ONLY); - + for (int ix=0; ixucl_device),UCL_READ_ONLY); ucl_copy(gcons,dview_gcons,false); gcons_tex.get_texture(*(this->pair_program),"gcons_tex"); @@ -107,11 +107,11 @@ int LJCoulMSMT::init(const int ntypes, ncols = 6; UCL_H_Vec dview_dgcons(nrows*ncols,*(this->ucl_device), UCL_WRITE_ONLY); - + for (int ix=0; ixucl_device),UCL_READ_ONLY); ucl_copy(dgcons,dview_dgcons,false); dgcons_tex.get_texture(*(this->pair_program),"dgcons_tex"); @@ -170,7 +170,7 @@ void LJCoulMSMT::loop(const bool _eflag, const bool _vflag) { vflag=1; else vflag=0; - + int GX=static_cast(ceil(static_cast(this->ans->inum())/ (BX/this->_threads_per_atom))); @@ -179,7 +179,7 @@ void LJCoulMSMT::loop(const bool _eflag, const bool _vflag) { this->time_pair.start(); if (shared_types) { this->k_pair_fast.set_size(GX,BX); - this->k_pair_fast.run(&this->atom->x, &lj1, &lj3, &gcons, &dgcons, &sp_lj, + this->k_pair_fast.run(&this->atom->x, &lj1, &lj3, &gcons, &dgcons, &sp_lj, &this->nbor->dev_nbor, &this->_nbor_data->begin(), &this->ans->force, &this->ans->engv, &eflag, &vflag, &ainum, &nbor_pitch, &this->atom->q, diff --git a/lib/gpu/lal_lj_coul_msm.cu b/lib/gpu/lal_lj_coul_msm.cu index 0c7c3cdace..3f73c6f47d 100644 --- a/lib/gpu/lal_lj_coul_msm.cu +++ b/lib/gpu/lal_lj_coul_msm.cu @@ -9,7 +9,7 @@ // This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) // __________________________________________________________________________ // -// begin : +// begin : // email : nguyentd@ornl.gov // ***************************************************************************/ @@ -80,19 +80,19 @@ ucl_inline numtyp dgamma(const numtyp rho, const int order, return ((numtyp)-1.0/rho/rho); } -__kernel void k_lj_coul_msm(const __global numtyp4 *restrict x_, +__kernel void k_lj_coul_msm(const __global numtyp4 *restrict x_, const __global numtyp4 *restrict lj1, const __global numtyp4 *restrict lj3, const __global numtyp *restrict gcons, const __global numtyp *restrict dgcons, const int lj_types, - const __global numtyp *restrict sp_lj_in, - const __global int *dev_nbor, + const __global numtyp *restrict sp_lj_in, + const __global int *dev_nbor, const __global int *dev_packed, __global acctyp4 *restrict ans, __global acctyp *restrict engv, const int eflag, const int vflag, const int inum, - const int nbor_pitch, + const int nbor_pitch, const __global numtyp *restrict q_, const numtyp cut_coulsq, const numtyp qqrd2e, const int order, const int t_per_atom) { @@ -116,20 +116,20 @@ __kernel void k_lj_coul_msm(const __global numtyp4 *restrict x_, acctyp virial[6]; for (int i=0; i<6; i++) virial[i]=(acctyp)0; - + if (ii0) { virial[0] += delx*delx*force; @@ -199,7 +199,7 @@ __kernel void k_lj_coul_msm(const __global numtyp4 *restrict x_, } // if ii } -__kernel void k_lj_coul_msm_fast(const __global numtyp4 *restrict x_, +__kernel void k_lj_coul_msm_fast(const __global numtyp4 *restrict x_, const __global numtyp4 *restrict lj1_in, const __global numtyp4 *restrict lj3_in, const __global numtyp *restrict gcons, @@ -227,7 +227,7 @@ __kernel void k_lj_coul_msm_fast(const __global numtyp4 *restrict x_, if (eflag>0) lj3[tid]=lj3_in[tid]; } - + acctyp energy=(acctyp)0; acctyp e_coul=(acctyp)0; acctyp4 f; @@ -235,16 +235,16 @@ __kernel void k_lj_coul_msm_fast(const __global numtyp4 *restrict x_, acctyp virial[6]; for (int i=0; i<6; i++) virial[i]=(acctyp)0; - + __syncthreads(); - + if (ii { /** \param max_nbors initial number of rows in the neighbor matrix * \param cell_size cutoff + skin * \param gpu_split fraction of particles handled by device - * + * * Returns: * - 0 if successfull * - -1 if fix gpu not found @@ -41,8 +41,8 @@ class LJCoulMSM : public BaseCharge { double **host_lj1, double **host_lj2, double **host_lj3, double **host_lj4, double **host_gcons, double **host_dgcons, double **host_offset, double *host_special_lj, - const int nlocal, const int nall, const int max_nbors, - const int maxspecial, const double cell_size, + const int nlocal, const int nall, const int max_nbors, + const int maxspecial, const double cell_size, const double gpu_split, FILE *screen, double **host_cut_ljsq, const double host_cut_coulsq, double *host_special_coul, const int order, const double qqrd2e); @@ -65,14 +65,14 @@ class LJCoulMSM : public BaseCharge { UCL_D_Vec lj3; /// Special LJ values [0-3] and Special Coul values [4-7] UCL_D_Vec sp_lj; - + UCL_D_Vec gcons, dgcons; UCL_Texture gcons_tex, dgcons_tex; - + /// If atom type constants fit in shared memory, use fast kernels bool shared_types; - /// Number of atom types + /// Number of atom types int _lj_types; numtyp _cut_coulsq, _qqrd2e; diff --git a/lib/gpu/lal_lj_coul_msm_ext.cpp b/lib/gpu/lal_lj_coul_msm_ext.cpp index ecf3254cf9..ceff1f7c66 100644 --- a/lib/gpu/lal_lj_coul_msm_ext.cpp +++ b/lib/gpu/lal_lj_coul_msm_ext.cpp @@ -9,7 +9,7 @@ This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) __________________________________________________________________________ - begin : + begin : email : brownw@ornl.gov ***************************************************************************/ @@ -84,7 +84,7 @@ int ljcm_gpu_init(const int ntypes, double **cutsq, double **host_lj1, host_cut_coulsq, host_special_coul, order, qqrd2e); LJCMLMF.device->gpu_barrier(); - if (message) + if (message) fprintf(screen,"Done.\n"); } if (message) @@ -101,7 +101,7 @@ void ljcm_gpu_clear() { int** ljcm_gpu_compute_n(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, - double *sublo, double *subhi, tagint *tag, int **nspecial, + double *sublo, double *subhi, tagint *tag, int **nspecial, tagint **special, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, int **ilist, int **jnum, const double cpu_time, @@ -111,7 +111,7 @@ int** ljcm_gpu_compute_n(const int ago, const int inum_full, subhi, tag, nspecial, special, eflag, vflag, eatom, vatom, host_start, ilist, jnum, cpu_time, success, host_q, boxlo, prd); -} +} void ljcm_gpu_compute(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, int *ilist, int *numj, diff --git a/lib/gpu/lal_lj_cubic.cpp b/lib/gpu/lal_lj_cubic.cpp index 25f83166e1..933795a8f6 100644 --- a/lib/gpu/lal_lj_cubic.cpp +++ b/lib/gpu/lal_lj_cubic.cpp @@ -9,7 +9,7 @@ This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) __________________________________________________________________________ - begin : + begin : email : ndactrung@gmail.com ***************************************************************************/ @@ -33,21 +33,21 @@ LJCubicT::LJCubic() : BaseAtomic(), _allocated(false) { } template -LJCubicT::~LJCubic() { +LJCubicT::~LJCubic() { clear(); } - + template int LJCubicT::bytes_per_atom(const int max_nbors) const { return this->bytes_per_atom_atomic(max_nbors); } template -int LJCubicT::init(const int ntypes, +int LJCubicT::init(const int ntypes, double **host_cutsq, double **host_cut_inner_sq, - double **host_cut_inner, double **host_sigma, - double **host_epsilon, double **host_lj1, - double **host_lj2, double **host_lj3, double **host_lj4, + double **host_cut_inner, double **host_sigma, + double **host_epsilon, double **host_lj1, + double **host_lj2, double **host_lj3, double **host_lj4, double *host_special_lj, const int nlocal, const int nall, const int max_nbors, const int maxspecial, const double cell_size, @@ -132,7 +132,7 @@ void LJCubicT::loop(const bool _eflag, const bool _vflag) { vflag=1; else vflag=0; - + int GX=static_cast(ceil(static_cast(this->ans->inum())/ (BX/this->_threads_per_atom))); @@ -144,12 +144,12 @@ void LJCubicT::loop(const bool _eflag, const bool _vflag) { this->k_pair_fast.run(&this->atom->x, &lj1, &lj2, &lj3, &sp_lj, &this->nbor->dev_nbor, &this->_nbor_data->begin(), &this->ans->force, &this->ans->engv, &eflag, - &vflag, &ainum, &nbor_pitch, + &vflag, &ainum, &nbor_pitch, &this->_threads_per_atom); } else { this->k_pair.set_size(GX,BX); - this->k_pair.run(&this->atom->x, &lj1, &lj2, &lj3, &_lj_types, &sp_lj, - &this->nbor->dev_nbor, &this->_nbor_data->begin(), + this->k_pair.run(&this->atom->x, &lj1, &lj2, &lj3, &_lj_types, &sp_lj, + &this->nbor->dev_nbor, &this->_nbor_data->begin(), &this->ans->force, &this->ans->engv, &eflag, &vflag, &ainum, &nbor_pitch, &this->_threads_per_atom); } diff --git a/lib/gpu/lal_lj_cubic.cu b/lib/gpu/lal_lj_cubic.cu index 420689383f..a4b1992f33 100644 --- a/lib/gpu/lal_lj_cubic.cu +++ b/lib/gpu/lal_lj_cubic.cu @@ -9,7 +9,7 @@ // This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) // __________________________________________________________________________ // -// begin : +// begin : // email : ndactrung@gmail.com // ***************************************************************************/ @@ -31,16 +31,16 @@ texture pos_tex; #define _DPHIDS (numtyp)2.6899009 // gradient at s #define _A3 (numtyp)27.93357 // cubic coefficient -__kernel void k_lj_cubic(const __global numtyp4 *restrict x_, +__kernel void k_lj_cubic(const __global numtyp4 *restrict x_, const __global numtyp4 *restrict lj1, const __global numtyp4 *restrict lj2, - const __global numtyp2 *restrict lj3, - const int lj_types, - const __global numtyp *restrict sp_lj, - const __global int * dev_nbor, - const __global int * dev_packed, - __global acctyp4 *restrict ans, - __global acctyp *restrict engv, + const __global numtyp2 *restrict lj3, + const int lj_types, + const __global numtyp *restrict sp_lj, + const __global int * dev_nbor, + const __global int * dev_packed, + __global acctyp4 *restrict ans, + __global acctyp *restrict engv, const int eflag, const int vflag, const int inum, const int nbor_pitch, const int t_per_atom) { int tid, ii, offset; @@ -52,19 +52,19 @@ __kernel void k_lj_cubic(const __global numtyp4 *restrict x_, acctyp virial[6]; for (int i=0; i<6; i++) virial[i]=(acctyp)0; - + if (ii0) { numtyp e; - if (rsq <= lj2[mtype].x) + if (rsq <= lj2[mtype].x) e = r6inv*(lj3[mtype].x*r6inv-lj3[mtype].y); else e = lj2[mtype].w*(_PHIS + _DPHIDS*t - _A3*t*t*t/6.0); - energy+=factor_lj*e; + energy+=factor_lj*e; } if (vflag>0) { virial[0] += delx*delx*force; @@ -122,20 +122,20 @@ __kernel void k_lj_cubic(const __global numtyp4 *restrict x_, } // if ii } -__kernel void k_lj_cubic_fast(const __global numtyp4 *restrict x_, +__kernel void k_lj_cubic_fast(const __global numtyp4 *restrict x_, const __global numtyp4 *restrict lj1_in, const __global numtyp4 *restrict lj2_in, - const __global numtyp2 *restrict lj3_in, - const __global numtyp *restrict sp_lj_in, - const __global int * dev_nbor, - const __global int * dev_packed, - __global acctyp4 *restrict ans, - __global acctyp *restrict engv, - const int eflag, const int vflag, const int inum, + const __global numtyp2 *restrict lj3_in, + const __global numtyp *restrict sp_lj_in, + const __global int * dev_nbor, + const __global int * dev_packed, + __global acctyp4 *restrict ans, + __global acctyp *restrict engv, + const int eflag, const int vflag, const int inum, const int nbor_pitch, const int t_per_atom) { int tid, ii, offset; atom_info(t_per_atom,ii,tid,offset); - + __local numtyp4 lj1[MAX_SHARED_TYPES*MAX_SHARED_TYPES]; __local numtyp4 lj2[MAX_SHARED_TYPES*MAX_SHARED_TYPES]; __local numtyp2 lj3[MAX_SHARED_TYPES*MAX_SHARED_TYPES]; @@ -148,7 +148,7 @@ __kernel void k_lj_cubic_fast(const __global numtyp4 *restrict x_, if (eflag>0) lj3[tid]=lj3_in[tid]; } - + acctyp energy=(acctyp)0; acctyp4 f; f.x=(acctyp)0; f.y=(acctyp)0; f.z=(acctyp)0; @@ -157,7 +157,7 @@ __kernel void k_lj_cubic_fast(const __global numtyp4 *restrict x_, virial[i]=(acctyp)0; __syncthreads(); - + if (ii0) { numtyp e; - if (rsq <= lj2[mtype].x) + if (rsq <= lj2[mtype].x) e = r6inv*(lj3[mtype].x*r6inv-lj3[mtype].y); else e = lj2[mtype].w*(_PHIS + _DPHIDS*t - _A3*t*t*t/6.0); - energy+=factor_lj*e; + energy+=factor_lj*e; } if (vflag>0) { virial[0] += delx*delx*force; diff --git a/lib/gpu/lal_lj_cubic.h b/lib/gpu/lal_lj_cubic.h index 0fefc727eb..818fb3581b 100644 --- a/lib/gpu/lal_lj_cubic.h +++ b/lib/gpu/lal_lj_cubic.h @@ -9,7 +9,7 @@ This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) __________________________________________________________________________ - begin : + begin : email : ndactrung@gmail.com ***************************************************************************/ @@ -24,13 +24,13 @@ template class LJCubic : public BaseAtomic { public: LJCubic(); - ~LJCubic(); + ~LJCubic(); /// Clear any previous data and set up for a new LAMMPS run /** \param max_nbors initial number of rows in the neighbor matrix * \param cell_size cutoff + skin * \param gpu_split fraction of particles handled by device - * + * * Returns: * - 0 if successfull * - -1 if fix gpu not found @@ -39,11 +39,11 @@ class LJCubic : public BaseAtomic { * - -5 Double precision is not supported on card **/ int init(const int ntypes, double **host_cutsq, double **host_cut_inner_sq, double **host_cut_inner, double **host_sigma, double **host_epsilon, - double **host_lj1, double **host_lj2, double **host_lj3, - double **host_lj4, double *host_special_lj, const int nlocal, - const int nall, const int max_nbors, const int maxspecial, + double **host_lj1, double **host_lj2, double **host_lj3, + double **host_lj4, double *host_special_lj, const int nlocal, + const int nall, const int max_nbors, const int maxspecial, const double cell_size, const double gpu_split, FILE *screen); - + /// Clear all host and device data /** \note This is called at the beginning of the init() routine **/ void clear(); @@ -68,7 +68,7 @@ class LJCubic : public BaseAtomic { /// If atom type constants fit in shared memory, use fast kernels bool shared_types; - /// Number of atom types + /// Number of atom types int _lj_types; private: diff --git a/lib/gpu/lal_lj_cubic_ext.cpp b/lib/gpu/lal_lj_cubic_ext.cpp index 518f706781..a45d02a8ca 100644 --- a/lib/gpu/lal_lj_cubic_ext.cpp +++ b/lib/gpu/lal_lj_cubic_ext.cpp @@ -9,7 +9,7 @@ This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) __________________________________________________________________________ - begin : + begin : email : ndactrung@gmail.com ***************************************************************************/ @@ -27,11 +27,11 @@ static LJCubic LJCubicLMF; // --------------------------------------------------------------------------- // Allocate memory on host and device and copy constants to device // --------------------------------------------------------------------------- -int ljcb_gpu_init(const int ntypes, double **cutsq, double **cut_inner_sq, +int ljcb_gpu_init(const int ntypes, double **cutsq, double **cut_inner_sq, double **cut_inner, double **sigma, double **epsilon, - double **host_lj1, double **host_lj2, double **host_lj3, - double **host_lj4, double *special_lj, - const int inum, const int nall, const int max_nbors, + double **host_lj1, double **host_lj2, double **host_lj3, + double **host_lj4, double *special_lj, + const int inum, const int nall, const int max_nbors, const int maxspecial, const double cell_size, int &gpu_mode, FILE *screen) { LJCubicLMF.clear(); @@ -81,7 +81,7 @@ int ljcb_gpu_init(const int ntypes, double **cutsq, double **cut_inner_sq, cell_size, gpu_split, screen); LJCubicLMF.device->gpu_barrier(); - if (message) + if (message) fprintf(screen,"Done.\n"); } if (message) @@ -106,7 +106,7 @@ int ** ljcb_gpu_compute_n(const int ago, const int inum_full, return LJCubicLMF.compute(ago, inum_full, nall, host_x, host_type, sublo, subhi, tag, nspecial, special, eflag, vflag, eatom, vatom, host_start, ilist, jnum, cpu_time, success); -} +} void ljcb_gpu_compute(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, int *ilist, int *numj, diff --git a/lib/gpu/lal_lj_dsf.cpp b/lib/gpu/lal_lj_dsf.cpp index 1b8fdeabb0..384cf75d1f 100644 --- a/lib/gpu/lal_lj_dsf.cpp +++ b/lib/gpu/lal_lj_dsf.cpp @@ -37,22 +37,22 @@ template LJDSFT::~LJDSF() { clear(); } - + template int LJDSFT::bytes_per_atom(const int max_nbors) const { return this->bytes_per_atom_atomic(max_nbors); } template -int LJDSFT::init(const int ntypes, double **host_cutsq, double **host_lj1, +int LJDSFT::init(const int ntypes, double **host_cutsq, double **host_lj1, double **host_lj2, double **host_lj3, double **host_lj4, - double **host_offset, double *host_special_lj, + double **host_offset, double *host_special_lj, const int nlocal, const int nall, const int max_nbors, - const int maxspecial, const double cell_size, + const int maxspecial, const double cell_size, const double gpu_split, FILE *_screen, double **host_cut_ljsq, const double host_cut_coulsq, double *host_special_coul, const double qqrd2e, - const double e_shift, const double f_shift, + const double e_shift, const double f_shift, const double alpha) { int success; success=this->init_atomic(nlocal,nall,max_nbors,maxspecial,cell_size,gpu_split, @@ -138,7 +138,7 @@ void LJDSFT::loop(const bool _eflag, const bool _vflag) { vflag=1; else vflag=0; - + int GX=static_cast(ceil(static_cast(this->ans->inum())/ (BX/this->_threads_per_atom))); @@ -149,15 +149,15 @@ void LJDSFT::loop(const bool _eflag, const bool _vflag) { this->k_pair_fast.set_size(GX,BX); this->k_pair_fast.run(&this->atom->x, &lj1, &lj3, &sp_lj, &this->nbor->dev_nbor, &this->_nbor_data->begin(), - &this->ans->force, &this->ans->engv, &eflag, + &this->ans->force, &this->ans->engv, &eflag, &vflag, &ainum, &nbor_pitch, &this->atom->q, &_cut_coulsq, &_qqrd2e, &_e_shift, &_f_shift, &_alpha, &this->_threads_per_atom); } else { this->k_pair.set_size(GX,BX); - this->k_pair.run(&this->atom->x, &lj1, &lj3, &_lj_types, &sp_lj, - &this->nbor->dev_nbor, &this->_nbor_data->begin(), - &this->ans->force, &this->ans->engv, + this->k_pair.run(&this->atom->x, &lj1, &lj3, &_lj_types, &sp_lj, + &this->nbor->dev_nbor, &this->_nbor_data->begin(), + &this->ans->force, &this->ans->engv, &eflag, &vflag, &ainum, &nbor_pitch, &this->atom->q, &_cut_coulsq, &_qqrd2e, &_e_shift, &_f_shift, &_alpha, &this->_threads_per_atom); diff --git a/lib/gpu/lal_lj_dsf.cu b/lib/gpu/lal_lj_dsf.cu index 5e0cd4aca9..323576fe77 100644 --- a/lib/gpu/lal_lj_dsf.cu +++ b/lib/gpu/lal_lj_dsf.cu @@ -31,20 +31,20 @@ texture q_tex; #define MY_PIS (acctyp)1.77245385090551602729 -__kernel void k_lj_dsf(const __global numtyp4 *restrict x_, +__kernel void k_lj_dsf(const __global numtyp4 *restrict x_, const __global numtyp4 *restrict lj1, - const __global numtyp4 *restrict lj3, - const int lj_types, - const __global numtyp *restrict sp_lj_in, - const __global int *dev_nbor, - const __global int *dev_packed, + const __global numtyp4 *restrict lj3, + const int lj_types, + const __global numtyp *restrict sp_lj_in, + const __global int *dev_nbor, + const __global int *dev_packed, __global acctyp4 *restrict ans, - __global acctyp *restrict engv, + __global acctyp *restrict engv, const int eflag, const int vflag, const int inum, - const int nbor_pitch, + const int nbor_pitch, const __global numtyp *restrict q_ , const numtyp cut_coulsq, const numtyp qqrd2e, - const numtyp e_shift, const numtyp f_shift, + const numtyp e_shift, const numtyp f_shift, const numtyp alpha, const int t_per_atom) { int tid, ii, offset; atom_info(t_per_atom,ii,tid,offset); @@ -66,20 +66,20 @@ __kernel void k_lj_dsf(const __global numtyp4 *restrict x_, acctyp virial[6]; for (int i=0; i<6; i++) virial[i]=(acctyp)0; - + if (ii0) { - acctyp e_self = -((acctyp)0.5*e_shift + alpha/MY_PIS) * + acctyp e_self = -((acctyp)0.5*e_shift + alpha/MY_PIS) * qtmp*qtmp*qqrd2e/(acctyp)t_per_atom; e_coul += (acctyp)2.0*e_self; } @@ -119,7 +119,7 @@ __kernel void k_lj_dsf(const __global numtyp4 *restrict x_, numtyp erfcd = ucl_exp(-alpha*alpha*rsq); numtyp t = ucl_recip((numtyp)1.0 + EWALD_P*alpha*r); erfcc = t * (A1+t*(A2+t*(A3+t*(A4+t*A5)))) * erfcd; - forcecoul = prefactor * (erfcc + (numtyp)2.0*alpha/MY_PIS*r*erfcd + + forcecoul = prefactor * (erfcc + (numtyp)2.0*alpha/MY_PIS*r*erfcd + rsq*f_shift-factor_coul); } else forcecoul = (numtyp)0.0; @@ -156,19 +156,19 @@ __kernel void k_lj_dsf(const __global numtyp4 *restrict x_, } // if ii } -__kernel void k_lj_dsf_fast(const __global numtyp4 *restrict x_, +__kernel void k_lj_dsf_fast(const __global numtyp4 *restrict x_, const __global numtyp4 *restrict lj1_in, const __global numtyp4 *restrict lj3_in, const __global numtyp *restrict sp_lj_in, const __global int *dev_nbor, const __global int *dev_packed, __global acctyp4 *restrict ans, - __global acctyp *restrict engv, - const int eflag, const int vflag, const int inum, + __global acctyp *restrict engv, + const int eflag, const int vflag, const int inum, const int nbor_pitch, const __global numtyp *restrict q_, const numtyp cut_coulsq, const numtyp qqrd2e, - const numtyp e_shift, const numtyp f_shift, + const numtyp e_shift, const numtyp f_shift, const numtyp alpha, const int t_per_atom) { int tid, ii, offset; atom_info(t_per_atom,ii,tid,offset); @@ -183,7 +183,7 @@ __kernel void k_lj_dsf_fast(const __global numtyp4 *restrict x_, if (eflag>0) lj3[tid]=lj3_in[tid]; } - + acctyp energy=(acctyp)0; acctyp e_coul=(acctyp)0; acctyp4 f; @@ -191,23 +191,23 @@ __kernel void k_lj_dsf_fast(const __global numtyp4 *restrict x_, acctyp virial[6]; for (int i=0; i<6; i++) virial[i]=(acctyp)0; - + __syncthreads(); - + if (ii0) { - acctyp e_self = -((acctyp)0.5*e_shift + alpha/MY_PIS) * + acctyp e_self = -((acctyp)0.5*e_shift + alpha/MY_PIS) * qtmp*qtmp*qqrd2e/(acctyp)t_per_atom; e_coul += (acctyp)2.0*e_self; } @@ -246,7 +246,7 @@ __kernel void k_lj_dsf_fast(const __global numtyp4 *restrict x_, numtyp erfcd = ucl_exp(-alpha*alpha*rsq); numtyp t = ucl_recip((numtyp)1.0 + EWALD_P*alpha*r); erfcc = t * (A1+t*(A2+t*(A3+t*(A4+t*A5)))) * erfcd; - forcecoul = prefactor * (erfcc + (numtyp)2.0*alpha/MY_PIS*r*erfcd + + forcecoul = prefactor * (erfcc + (numtyp)2.0*alpha/MY_PIS*r*erfcd + rsq*f_shift-factor_coul); } else forcecoul = (numtyp)0.0; diff --git a/lib/gpu/lal_lj_dsf.h b/lib/gpu/lal_lj_dsf.h index 5badf543c4..0195898ca4 100644 --- a/lib/gpu/lal_lj_dsf.h +++ b/lib/gpu/lal_lj_dsf.h @@ -30,7 +30,7 @@ class LJDSF : public BaseCharge { /** \param max_nbors initial number of rows in the neighbor matrix * \param cell_size cutoff + skin * \param gpu_split fraction of particles handled by device - * + * * Returns: * - 0 if successfull * - -1 if fix gpu not found @@ -40,11 +40,11 @@ class LJDSF : public BaseCharge { int init(const int ntypes, double **host_cutsq, double **host_lj1, double **host_lj2, double **host_lj3, double **host_lj4, double **host_offset, double *host_special_lj, - const int nlocal, const int nall, const int max_nbors, + const int nlocal, const int nall, const int max_nbors, const int maxspecial, const double cell_size, const double gpu_split, FILE *screen, double **host_cut_ljsq, const double host_cut_coulsq, double *host_special_coul, - const double qqrd2e, const double e_shift, const double f_shift, + const double qqrd2e, const double e_shift, const double f_shift, const double alpha); /// Clear all host and device data @@ -69,7 +69,7 @@ class LJDSF : public BaseCharge { /// If atom type constants fit in shared memory, use fast kernels bool shared_types; - /// Number of atom types + /// Number of atom types int _lj_types; numtyp _qqrd2e; diff --git a/lib/gpu/lal_lj_dsf_ext.cpp b/lib/gpu/lal_lj_dsf_ext.cpp index 719a792d7f..f516da6622 100644 --- a/lib/gpu/lal_lj_dsf_ext.cpp +++ b/lib/gpu/lal_lj_dsf_ext.cpp @@ -34,7 +34,7 @@ int ljd_gpu_init(const int ntypes, double **cutsq, double **host_lj1, const double cell_size, int &gpu_mode, FILE *screen, double **host_cut_ljsq, const double host_cut_coulsq, double *host_special_coul, const double qqrd2e, - const double e_shift, const double f_shift, + const double e_shift, const double f_shift, const double alpha) { LJDMF.clear(); gpu_mode=LJDMF.device->gpu_mode(); @@ -85,7 +85,7 @@ int ljd_gpu_init(const int ntypes, double **cutsq, double **host_lj1, f_shift, alpha); LJDMF.device->gpu_barrier(); - if (message) + if (message) fprintf(screen,"Done.\n"); } if (message) @@ -102,7 +102,7 @@ void ljd_gpu_clear() { int** ljd_gpu_compute_n(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, - double *sublo, double *subhi, tagint *tag, int **nspecial, + double *sublo, double *subhi, tagint *tag, int **nspecial, tagint **special, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, int **ilist, int **jnum, const double cpu_time, @@ -112,7 +112,7 @@ int** ljd_gpu_compute_n(const int ago, const int inum_full, subhi, tag, nspecial, special, eflag, vflag, eatom, vatom, host_start, ilist, jnum, cpu_time, success, host_q, boxlo, prd); -} +} void ljd_gpu_compute(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, int *ilist, int *numj, diff --git a/lib/gpu/lal_lj_expand.cpp b/lib/gpu/lal_lj_expand.cpp index 03526bc095..c6d8a92e96 100644 --- a/lib/gpu/lal_lj_expand.cpp +++ b/lib/gpu/lal_lj_expand.cpp @@ -9,7 +9,7 @@ This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) __________________________________________________________________________ - begin : + begin : email : ibains@nvidia.com ***************************************************************************/ @@ -36,7 +36,7 @@ template LJExpandT::~LJExpand() { clear(); } - + template int LJExpandT::bytes_per_atom(const int max_nbors) const { return this->bytes_per_atom_atomic(max_nbors); @@ -97,17 +97,17 @@ void LJExpandT::reinit(const int ntypes, double **host_cutsq, double **host_lj1, double **host_lj2, double **host_lj3, double **host_lj4, double **host_offset, double **host_shift) { - + // Allocate a host write buffer for data initialization UCL_H_Vec host_write(_lj_types*_lj_types*32,*(this->ucl_device), UCL_WRITE_ONLY); - + for (int i=0; i<_lj_types*_lj_types; i++) host_write[i]=0.0; - + this->atom->type_pack4(ntypes,_lj_types,lj1,host_write,host_lj1,host_lj2, host_cutsq, host_shift); - + this->atom->type_pack4(ntypes,_lj_types,lj3,host_write,host_lj3,host_lj4, host_offset); } @@ -146,7 +146,7 @@ void LJExpandT::loop(const bool _eflag, const bool _vflag) { vflag=1; else vflag=0; - + int GX=static_cast(ceil(static_cast(this->ans->inum())/ (BX/this->_threads_per_atom))); @@ -155,15 +155,15 @@ void LJExpandT::loop(const bool _eflag, const bool _vflag) { this->time_pair.start(); if (shared_types) { this->k_pair_fast.set_size(GX,BX); - this->k_pair_fast.run(&this->atom->x, &lj1, &lj3, &sp_lj, + this->k_pair_fast.run(&this->atom->x, &lj1, &lj3, &sp_lj, &this->nbor->dev_nbor, &this->_nbor_data->begin(), - &this->ans->force, &this->ans->engv, &eflag, - &vflag, &ainum, &nbor_pitch, + &this->ans->force, &this->ans->engv, &eflag, + &vflag, &ainum, &nbor_pitch, &this->_threads_per_atom); } else { this->k_pair.set_size(GX,BX); - this->k_pair.run(&this->atom->x, &lj1, &lj3, &_lj_types, &sp_lj, - &this->nbor->dev_nbor, &this->_nbor_data->begin(), + this->k_pair.run(&this->atom->x, &lj1, &lj3, &_lj_types, &sp_lj, + &this->nbor->dev_nbor, &this->_nbor_data->begin(), &this->ans->force, &this->ans->engv, &eflag, &vflag, &ainum, &nbor_pitch, &this->_threads_per_atom); } diff --git a/lib/gpu/lal_lj_expand.cu b/lib/gpu/lal_lj_expand.cu index 6b79db2323..a951b4107a 100644 --- a/lib/gpu/lal_lj_expand.cu +++ b/lib/gpu/lal_lj_expand.cu @@ -9,7 +9,7 @@ // This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) // __________________________________________________________________________ // -// begin : +// begin : // email : ibains@nvidia.com // ***************************************************************************/ @@ -26,15 +26,15 @@ texture pos_tex; #define pos_tex x_ #endif -__kernel void k_lj_expand(const __global numtyp4 *restrict x_, +__kernel void k_lj_expand(const __global numtyp4 *restrict x_, const __global numtyp4 *restrict lj1, - const __global numtyp4 *restrict lj3, - const int lj_types, - const __global numtyp *restrict sp_lj_in, - const __global int *dev_nbor, - const __global int *dev_packed, + const __global numtyp4 *restrict lj3, + const int lj_types, + const __global numtyp *restrict sp_lj_in, + const __global int *dev_nbor, + const __global int *dev_packed, __global acctyp4 *restrict ans, - __global acctyp *restrict engv, + __global acctyp *restrict engv, const int eflag, const int vflag, const int inum, const int nbor_pitch, const int t_per_atom) { int tid, ii, offset; @@ -52,20 +52,20 @@ __kernel void k_lj_expand(const __global numtyp4 *restrict x_, acctyp virial[6]; for (int i=0; i<6; i++) virial[i]=(acctyp)0; - + if (ii0) { numtyp e=r6inv*(lj3[mtype].x*r6inv-lj3[mtype].y); - energy+=factor_lj*(e-lj3[mtype].z); + energy+=factor_lj*(e-lj3[mtype].z); } if (vflag>0) { virial[0] += delx*delx*force; @@ -113,15 +113,15 @@ __kernel void k_lj_expand(const __global numtyp4 *restrict x_, } // if ii } -__kernel void k_lj_expand_fast(const __global numtyp4 *restrict x_, +__kernel void k_lj_expand_fast(const __global numtyp4 *restrict x_, const __global numtyp4 *restrict lj1_in, - const __global numtyp4 *restrict lj3_in, - const __global numtyp *restrict sp_lj_in, - const __global int *dev_nbor, + const __global numtyp4 *restrict lj3_in, + const __global numtyp *restrict sp_lj_in, + const __global int *dev_nbor, const __global int *dev_packed, - __global acctyp4 *restrict ans, - __global acctyp *restrict engv, - const int eflag, const int vflag, const int inum, + __global acctyp4 *restrict ans, + __global acctyp *restrict engv, + const int eflag, const int vflag, const int inum, const int nbor_pitch, const int t_per_atom) { int tid, ii, offset; atom_info(t_per_atom,ii,tid,offset); @@ -136,30 +136,30 @@ __kernel void k_lj_expand_fast(const __global numtyp4 *restrict x_, if (eflag>0) lj3[tid]=lj3_in[tid]; } - + acctyp energy=(acctyp)0; acctyp4 f; f.x=(acctyp)0; f.y=(acctyp)0; f.z=(acctyp)0; acctyp virial[6]; for (int i=0; i<6; i++) virial[i]=(numtyp)0; - + __syncthreads(); - + if (ii0) { numtyp e=r6inv*(lj3[mtype].x*r6inv-lj3[mtype].y); - energy+=factor_lj*(e-lj3[mtype].z); + energy+=factor_lj*(e-lj3[mtype].z); } if (vflag>0) { virial[0] += delx*delx*force; diff --git a/lib/gpu/lal_lj_expand.h b/lib/gpu/lal_lj_expand.h index 0d0ae0b2e6..a732a3a686 100644 --- a/lib/gpu/lal_lj_expand.h +++ b/lib/gpu/lal_lj_expand.h @@ -9,7 +9,7 @@ This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) __________________________________________________________________________ - begin : + begin : email : ibains@nvidia.com ***************************************************************************/ @@ -30,7 +30,7 @@ class LJExpand : public BaseAtomic { /** \param max_nbors initial number of rows in the neighbor matrix * \param cell_size cutoff + skin * \param gpu_split fraction of particles handled by device - * + * * Returns: * - 0 if successfull * - -1 if fix gpu not found @@ -40,15 +40,15 @@ class LJExpand : public BaseAtomic { int init(const int ntypes, double **host_cutsq, double **host_lj1, double **host_lj2, double **host_lj3, double **host_lj4, double **host_offset, double **host_shift, double *host_special_lj, - const int nlocal, const int nall, const int max_nbors, - const int maxspecial, const double cell_size, + const int nlocal, const int nall, const int max_nbors, + const int maxspecial, const double cell_size, const double gpu_split, FILE *screen); - + /// Send updated coeffs from host to device (to be compatible with fix adapt) void reinit(const int ntypes, double **host_cutsq, double **host_lj1, double **host_lj2, double **host_lj3, double **host_lj4, double **host_offset, double **host_shift); - + /// Clear all host and device data /** \note This is called at the beginning of the init() routine **/ void clear(); @@ -71,7 +71,7 @@ class LJExpand : public BaseAtomic { /// If atom type constants fit in shared memory, use fast kernels bool shared_types; - /// Number of atom types + /// Number of atom types int _lj_types; private: diff --git a/lib/gpu/lal_lj_expand_ext.cpp b/lib/gpu/lal_lj_expand_ext.cpp index 5303149d1f..d6ea4a9200 100644 --- a/lib/gpu/lal_lj_expand_ext.cpp +++ b/lib/gpu/lal_lj_expand_ext.cpp @@ -9,7 +9,7 @@ This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) __________________________________________________________________________ - begin : + begin : email : ibains@nvidia.com ***************************************************************************/ @@ -30,7 +30,7 @@ static LJExpand LJEMF; int lje_gpu_init(const int ntypes, double **cutsq, double **host_lj1, double **host_lj2, double **host_lj3, double **host_lj4, double **offset, double **shift, double *special_lj, - const int inum, const int nall, const int max_nbors, + const int inum, const int nall, const int max_nbors, const int maxspecial, const double cell_size, int &gpu_mode, FILE *screen) { LJEMF.clear(); @@ -78,7 +78,7 @@ int lje_gpu_init(const int ntypes, double **cutsq, double **host_lj1, cell_size, gpu_split,screen); LJEMF.device->world_barrier(); - if (message) + if (message) fprintf(screen,"Done.\n"); } if (message) @@ -98,12 +98,12 @@ int lje_gpu_reinit(const int ntypes, double **cutsq, double **host_lj1, int world_me=LJEMF.device->world_me(); int gpu_rank=LJEMF.device->gpu_rank(); int procs_per_gpu=LJEMF.device->procs_per_gpu(); - + if (world_me==0) LJEMF.reinit(ntypes, cutsq, host_lj1, host_lj2, host_lj3, host_lj4, offset, shift); LJEMF.device->world_barrier(); - + for (int i=0; igpu_barrier(); - if (message) + if (message) fprintf(screen,"Done.\n"); } if (message) @@ -97,11 +97,11 @@ void ljl_gpu_reinit(const int ntypes, double **cutsq, double **host_lj1, int world_me=LJLMF.device->world_me(); int gpu_rank=LJLMF.device->gpu_rank(); int procs_per_gpu=LJLMF.device->procs_per_gpu(); - + if (world_me==0) LJLMF.reinit(ntypes, cutsq, host_lj1, host_lj2, host_lj3, host_lj4, offset); LJLMF.device->world_barrier(); - + for (int i=0; i LJGROMACST::~LJGROMACS() { clear(); } - + template int LJGROMACST::bytes_per_atom(const int max_nbors) const { return this->bytes_per_atom_atomic(max_nbors); @@ -47,11 +47,11 @@ template int LJGROMACST::init(const int ntypes, double **host_cutsq, double **host_lj1, double **host_lj2, double **host_lj3, double **host_lj4, double *host_special_lj, - const int nlocal, const int nall, const int max_nbors, - const int maxspecial, const double cell_size, + const int nlocal, const int nall, const int max_nbors, + const int maxspecial, const double cell_size, const double gpu_split, FILE *_screen, double **host_ljsw1, double **host_ljsw2, double **host_ljsw3, - double **host_ljsw4, double **host_ljsw5, + double **host_ljsw4, double **host_ljsw5, double **cut_inner, double **cut_inner_sq) { int success; success=this->init_atomic(nlocal,nall,max_nbors,maxspecial,cell_size,gpu_split, @@ -134,7 +134,7 @@ void LJGROMACST::loop(const bool _eflag, const bool _vflag) { vflag=1; else vflag=0; - + int GX=static_cast(ceil(static_cast(this->ans->inum())/ (BX/this->_threads_per_atom))); @@ -146,16 +146,16 @@ void LJGROMACST::loop(const bool _eflag, const bool _vflag) { this->k_pair_fast.run(&this->atom->x, &lj1, &lj3, &ljsw, &sp_lj, &this->nbor->dev_nbor, &this->_nbor_data->begin(), - &this->ans->force, &this->ans->engv, + &this->ans->force, &this->ans->engv, &eflag, &vflag, &ainum, &nbor_pitch, &this->_threads_per_atom); } else { this->k_pair.set_size(GX,BX); - this->k_pair.run(&this->atom->x, &lj1, &lj3, &ljsw, &_lj_types, + this->k_pair.run(&this->atom->x, &lj1, &lj3, &ljsw, &_lj_types, &sp_lj, &this->nbor->dev_nbor, - &this->_nbor_data->begin(), - &this->ans->force, &this->ans->engv, - &eflag, &vflag, &ainum, &nbor_pitch, + &this->_nbor_data->begin(), + &this->ans->force, &this->ans->engv, + &eflag, &vflag, &ainum, &nbor_pitch, &this->_threads_per_atom); } this->time_pair.stop(); diff --git a/lib/gpu/lal_lj_gromacs.cu b/lib/gpu/lal_lj_gromacs.cu index f20d8634a5..93dc3d9456 100644 --- a/lib/gpu/lal_lj_gromacs.cu +++ b/lib/gpu/lal_lj_gromacs.cu @@ -9,7 +9,7 @@ // This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) // __________________________________________________________________________ // -// begin : +// begin : // email : nguyentd@ornl.gov // ***************************************************************************/ @@ -35,8 +35,8 @@ __kernel void k_lj_gromacs(const __global numtyp4 *restrict x_, const __global int *dev_nbor, const __global int *dev_packed, __global acctyp4 *restrict ans, - __global acctyp *restrict engv, - const int eflag, const int vflag, const int inum, + __global acctyp *restrict engv, + const int eflag, const int vflag, const int inum, const int nbor_pitch, const int t_per_atom) { int tid, ii, offset; atom_info(t_per_atom,ii,tid,offset); @@ -59,7 +59,7 @@ __kernel void k_lj_gromacs(const __global numtyp4 *restrict x_, __local int n_stride; nbor_info(dev_nbor,dev_packed,nbor_pitch,t_per_atom,ii,offset,i,numj, n_stride,nbor_end,nbor); - + numtyp4 ix; fetch4(ix,i,pos_tex); //x_[i]; int itype=ix.w; @@ -83,7 +83,7 @@ __kernel void k_lj_gromacs(const __global numtyp4 *restrict x_, if (rsq lj1[mtype].w) { @@ -91,7 +91,7 @@ __kernel void k_lj_gromacs(const __global numtyp4 *restrict x_, t = r - lj3[mtype].z; numtyp fswitch = r*t*t*(ljsw[mtype].x + ljsw[mtype].y*t); force_lj += fswitch; - } + } force = factor_lj*force_lj * r2inv; @@ -149,22 +149,22 @@ __kernel void k_lj_gromacs_fast(const __global numtyp4 *restrict x_, lj3[tid]=lj3_in[tid]; ljsw[tid]=ljsw_in[tid]; } - + acctyp energy=(acctyp)0; acctyp4 f; f.x=(acctyp)0; f.y=(acctyp)0; f.z=(acctyp)0; acctyp virial[6]; for (int i=0; i<6; i++) virial[i]=(acctyp)0; - + __syncthreads(); - + if (ii lj1[mtype].w) { @@ -196,7 +196,7 @@ __kernel void k_lj_gromacs_fast(const __global numtyp4 *restrict x_, t = r - lj3[mtype].z; numtyp fswitch = r*t*t*(ljsw[mtype].x + ljsw[mtype].y*t); force_lj += fswitch; - } + } force = factor_lj*force_lj * r2inv; diff --git a/lib/gpu/lal_lj_gromacs.h b/lib/gpu/lal_lj_gromacs.h index dc949be4a9..1e0f72dafc 100644 --- a/lib/gpu/lal_lj_gromacs.h +++ b/lib/gpu/lal_lj_gromacs.h @@ -9,7 +9,7 @@ This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) __________________________________________________________________________ - begin : + begin : email : nguyentd@ornl.gov ***************************************************************************/ @@ -30,7 +30,7 @@ class LJGROMACS : public BaseAtomic { /** \param max_nbors initial number of rows in the neighbor matrix * \param cell_size cutoff + skin * \param gpu_split fraction of particles handled by device - * + * * Returns: * - 0 if successfull * - -1 if fix gpu not found @@ -40,11 +40,11 @@ class LJGROMACS : public BaseAtomic { int init(const int ntypes, double **host_cutsq, double **host_lj1, double **host_lj2, double **host_lj3, double **host_lj4, double *host_special_lj, - const int nlocal, const int nall, const int max_nbors, - const int maxspecial, const double cell_size, + const int nlocal, const int nall, const int max_nbors, + const int maxspecial, const double cell_size, const double gpu_split, FILE *screen, double **host_ljsw1, double **host_ljsw2, double **host_ljsw3, - double **host_ljsw4, double **host_ljsw5, + double **host_ljsw4, double **host_ljsw5, double **cut_inner, double **cut_inner_sq); /// Clear all host and device data @@ -71,7 +71,7 @@ class LJGROMACS : public BaseAtomic { /// If atom type constants fit in shared memory, use fast kernels bool shared_types; - /// Number of atom types + /// Number of atom types int _lj_types; private: diff --git a/lib/gpu/lal_lj_gromacs_ext.cpp b/lib/gpu/lal_lj_gromacs_ext.cpp index b5eb0038b7..83f0ffc403 100644 --- a/lib/gpu/lal_lj_gromacs_ext.cpp +++ b/lib/gpu/lal_lj_gromacs_ext.cpp @@ -9,7 +9,7 @@ This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) __________________________________________________________________________ - begin : + begin : email : nguyentd@ornl.gov ***************************************************************************/ @@ -33,7 +33,7 @@ int ljgrm_gpu_init(const int ntypes, double **cutsq, double **host_lj1, const int nall, const int max_nbors, const int maxspecial, const double cell_size, int &gpu_mode, FILE *screen, double **host_ljsw1, double **host_ljsw2, double **host_ljsw3, - double **host_ljsw4, double **host_ljsw5, + double **host_ljsw4, double **host_ljsw5, double **cut_inner, double **cut_inner_sq) { LJGRMMF.clear(); gpu_mode=LJGRMMF.device->gpu_mode(); @@ -59,7 +59,7 @@ int ljgrm_gpu_init(const int ntypes, double **cutsq, double **host_lj1, if (world_me==0) LJGRMMF.init(ntypes, cutsq, host_lj1, host_lj2, host_lj3, host_lj4, special_lj, inum, nall, 300, maxspecial, cell_size, - gpu_split, screen, host_ljsw1, host_ljsw2, host_ljsw3, + gpu_split, screen, host_ljsw1, host_ljsw2, host_ljsw3, host_ljsw4, host_ljsw5, cut_inner, cut_inner_sq); LJGRMMF.device->world_barrier(); @@ -78,11 +78,11 @@ int ljgrm_gpu_init(const int ntypes, double **cutsq, double **host_lj1, if (gpu_rank==i && world_me!=0) init_ok=LJGRMMF.init(ntypes, cutsq, host_lj1, host_lj2, host_lj3, host_lj4, special_lj, inum, nall, 300, maxspecial, cell_size, - gpu_split, screen, host_ljsw1, host_ljsw2, host_ljsw3, + gpu_split, screen, host_ljsw1, host_ljsw2, host_ljsw3, host_ljsw4, host_ljsw5, cut_inner, cut_inner_sq); LJGRMMF.device->gpu_barrier(); - if (message) + if (message) fprintf(screen,"Done.\n"); } if (message) @@ -107,7 +107,7 @@ int ** ljgrm_gpu_compute_n(const int ago, const int inum_full, return LJGRMMF.compute(ago, inum_full, nall, host_x, host_type, sublo, subhi, tag, nspecial, special, eflag, vflag, eatom, vatom, host_start, ilist, jnum, cpu_time, success); -} +} void ljgrm_gpu_compute(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, int *ilist, int *numj, diff --git a/lib/gpu/lal_mie.cpp b/lib/gpu/lal_mie.cpp index 2ab7cb8d14..a87771e9bb 100644 --- a/lib/gpu/lal_mie.cpp +++ b/lib/gpu/lal_mie.cpp @@ -9,7 +9,7 @@ This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) __________________________________________________________________________ - begin : + begin : email : nguyentd@ornl.gov ***************************************************************************/ @@ -33,17 +33,17 @@ MieT::Mie() : BaseAtomic(), _allocated(false) { } template -MieT::~Mie() { +MieT::~Mie() { clear(); } - + template int MieT::bytes_per_atom(const int max_nbors) const { return this->bytes_per_atom_atomic(max_nbors); } template -int MieT::init(const int ntypes, double **host_cutsq, +int MieT::init(const int ntypes, double **host_cutsq, double **host_mie1, double **host_mie2, double **host_mie3, double **host_mie4, double **host_gamA, double **host_gamR, @@ -81,7 +81,7 @@ int MieT::init(const int ntypes, double **host_cutsq, mie3.alloc(lj_types*lj_types,*(this->ucl_device),UCL_READ_ONLY); this->atom->type_pack4(ntypes,lj_types,mie3,host_write,host_mie3,host_mie4, host_offset,host_cutsq); - + UCL_H_Vec dview; sp_lj.alloc(4,*(this->ucl_device),UCL_READ_ONLY); dview.view(host_special_lj,4,*(this->ucl_device)); @@ -126,7 +126,7 @@ void MieT::loop(const bool _eflag, const bool _vflag) { vflag=1; else vflag=0; - + int GX=static_cast(ceil(static_cast(this->ans->inum())/ (BX/this->_threads_per_atom))); diff --git a/lib/gpu/lal_mie.cu b/lib/gpu/lal_mie.cu index 4d718897eb..33018566eb 100644 --- a/lib/gpu/lal_mie.cu +++ b/lib/gpu/lal_mie.cu @@ -9,7 +9,7 @@ // This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) // __________________________________________________________________________ // -// begin : +// begin : // email : nguyentd@ornl.gov // ***************************************************************************/ @@ -24,15 +24,15 @@ texture pos_tex; #define pos_tex x_ #endif -__kernel void k_mie(const __global numtyp4 *restrict x_, +__kernel void k_mie(const __global numtyp4 *restrict x_, const __global numtyp4 *restrict mie1, const __global numtyp4 *restrict mie3, - const int lj_types, - const __global numtyp *restrict sp_lj_in, - const __global int *dev_nbor, - const __global int *dev_packed, + const int lj_types, + const __global numtyp *restrict sp_lj_in, + const __global int *dev_nbor, + const __global int *dev_packed, __global acctyp4 *restrict ans, - __global acctyp *restrict engv, + __global acctyp *restrict engv, const int eflag, const int vflag, const int inum, const int nbor_pitch, const int t_per_atom) { int tid, ii, offset; @@ -50,20 +50,20 @@ __kernel void k_mie(const __global numtyp4 *restrict x_, acctyp virial[6]; for (int i=0; i<6; i++) virial[i]=(acctyp)0; - + if (ii class Mie : public BaseAtomic { public: Mie(); - ~Mie(); + ~Mie(); /// Clear any previous data and set up for a new LAMMPS run /** \param max_nbors initial number of rows in the neighbor matrix * \param cell_size cutoff + skin * \param gpu_split fraction of particles handled by device - * + * * Returns: * - 0 if successfull * - -1 if fix gpu not found @@ -41,8 +41,8 @@ class Mie : public BaseAtomic { double **host_mie1, double **host_mie2, double **host_mie3, double **host_mie4, double **host_gamA, double **host_gamR, double **host_offset, double *host_special_lj, - const int nlocal, const int nall, const int max_nbors, - const int maxspecial, const double cell_size, + const int nlocal, const int nall, const int max_nbors, + const int maxspecial, const double cell_size, const double gpu_split, FILE *screen); /// Clear all host and device data @@ -67,7 +67,7 @@ class Mie : public BaseAtomic { /// If atom type constants fit in shared memory, use fast kernels bool shared_types; - /// Number of atom types + /// Number of atom types int _lj_types; private: diff --git a/lib/gpu/lal_mie_ext.cpp b/lib/gpu/lal_mie_ext.cpp index d7c4187a42..f43cde2650 100644 --- a/lib/gpu/lal_mie_ext.cpp +++ b/lib/gpu/lal_mie_ext.cpp @@ -9,7 +9,7 @@ This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) __________________________________________________________________________ - begin : + begin : email : nguyentd@ornl.gov ***************************************************************************/ @@ -81,7 +81,7 @@ int mie_gpu_init(const int ntypes, double **cutsq, double **host_mie1, cell_size, gpu_split, screen); MLMF.device->gpu_barrier(); - if (message) + if (message) fprintf(screen,"Done.\n"); } if (message) @@ -106,7 +106,7 @@ int ** mie_gpu_compute_n(const int ago, const int inum_full, return MLMF.compute(ago, inum_full, nall, host_x, host_type, sublo, subhi, tag, nspecial, special, eflag, vflag, eatom, vatom, host_start, ilist, jnum, cpu_time, success); -} +} void mie_gpu_compute(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, int *ilist, int *numj, diff --git a/lib/gpu/lal_morse.cpp b/lib/gpu/lal_morse.cpp index ddf7d843e6..cbdf928863 100644 --- a/lib/gpu/lal_morse.cpp +++ b/lib/gpu/lal_morse.cpp @@ -9,7 +9,7 @@ This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) __________________________________________________________________________ - begin : + begin : email : brownw@ornl.gov ***************************************************************************/ @@ -33,20 +33,20 @@ MorseT::Morse() : BaseAtomic(), _allocated(false) { } template -MorseT::~Morse() { +MorseT::~Morse() { clear(); } - + template int MorseT::bytes_per_atom(const int max_nbors) const { return this->bytes_per_atom_atomic(max_nbors); } template -int MorseT::init(const int ntypes, - double **host_cutsq, double **host_morse1, - double **host_r0, double **host_alpha, - double **host_d0, double **host_offset, +int MorseT::init(const int ntypes, + double **host_cutsq, double **host_morse1, + double **host_r0, double **host_alpha, + double **host_d0, double **host_offset, double *host_special_lj, const int nlocal, const int nall, const int max_nbors, const int maxspecial, const double cell_size, @@ -125,7 +125,7 @@ void MorseT::loop(const bool _eflag, const bool _vflag) { vflag=1; else vflag=0; - + int GX=static_cast(ceil(static_cast(this->ans->inum())/ (BX/this->_threads_per_atom))); @@ -135,14 +135,14 @@ void MorseT::loop(const bool _eflag, const bool _vflag) { if (shared_types) { this->k_pair_fast.set_size(GX,BX); this->k_pair_fast.run(&this->atom->x, &mor1, &mor2, &sp_lj, - &this->nbor->dev_nbor, &this->_nbor_data->begin(), + &this->nbor->dev_nbor, &this->_nbor_data->begin(), &this->ans->force, &this->ans->engv, &eflag, - &vflag, &ainum, &nbor_pitch, + &vflag, &ainum, &nbor_pitch, &this->_threads_per_atom); } else { this->k_pair.set_size(GX,BX); - this->k_pair.run(&this->atom->x, &mor1, &mor2, &_types, &sp_lj, - &this->nbor->dev_nbor, &this->_nbor_data->begin(), + this->k_pair.run(&this->atom->x, &mor1, &mor2, &_types, &sp_lj, + &this->nbor->dev_nbor, &this->_nbor_data->begin(), &this->ans->force, &this->ans->engv, &eflag, &vflag, &ainum, &nbor_pitch, &this->_threads_per_atom); } diff --git a/lib/gpu/lal_morse.cu b/lib/gpu/lal_morse.cu index 2015c71cb2..0a14071d19 100644 --- a/lib/gpu/lal_morse.cu +++ b/lib/gpu/lal_morse.cu @@ -9,7 +9,7 @@ // This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) // __________________________________________________________________________ // -// begin : +// begin : // email : brownw@ornl.gov // ***************************************************************************/ @@ -26,13 +26,13 @@ texture pos_tex; #define pos_tex x_ #endif -__kernel void k_morse(const __global numtyp4 *restrict x_, +__kernel void k_morse(const __global numtyp4 *restrict x_, const __global numtyp4 *restrict mor1, - const __global numtyp2 *restrict mor2, - const int lj_types, - const __global numtyp *restrict sp_lj_in, - const __global int *dev_nbor, - const __global int *dev_packed, + const __global numtyp2 *restrict mor2, + const int lj_types, + const __global numtyp *restrict sp_lj_in, + const __global int *dev_nbor, + const __global int *dev_packed, __global acctyp4 *restrict ans, __global acctyp *restrict engv, const int eflag, const int vflag, const int inum, @@ -59,13 +59,13 @@ __kernel void k_morse(const __global numtyp4 *restrict x_, __local int n_stride; nbor_info(dev_nbor,dev_packed,nbor_pitch,t_per_atom,ii,offset,i,numj, n_stride,nbor_end,nbor); - + numtyp4 ix; fetch4(ix,i,pos_tex); //x_[i]; int itype=ix.w; numtyp factor_lj; for ( ; nbor0) { numtyp e=mor2[mtype].x*(dexp*dexp - 2.0*dexp) - mor2[mtype].y; - energy+=e*factor_lj; + energy+=e*factor_lj; } if (vflag>0) { virial[0] += delx*delx*force; @@ -111,15 +111,15 @@ __kernel void k_morse(const __global numtyp4 *restrict x_, } // if ii } -__kernel void k_morse_fast(const __global numtyp4 *restrict x_, +__kernel void k_morse_fast(const __global numtyp4 *restrict x_, const __global numtyp4 *restrict mor1_in, - const __global numtyp2 *restrict mor2_in, + const __global numtyp2 *restrict mor2_in, const __global numtyp *restrict sp_lj_in, const __global int *dev_nbor, const __global int *dev_packed, __global acctyp4 *restrict ans, - __global acctyp *restrict engv, - const int eflag, const int vflag, const int inum, + __global acctyp *restrict engv, + const int eflag, const int vflag, const int inum, const int nbor_pitch, const int t_per_atom) { int tid, ii, offset; atom_info(t_per_atom,ii,tid,offset); @@ -134,30 +134,30 @@ __kernel void k_morse_fast(const __global numtyp4 *restrict x_, if (eflag>0) mor2[tid]=mor2_in[tid]; } - + acctyp energy=(acctyp)0; acctyp4 f; f.x=(acctyp)0; f.y=(acctyp)0; f.z=(acctyp)0; acctyp virial[6]; for (int i=0; i<6; i++) virial[i]=(acctyp)0; - + __syncthreads(); - + if (ii0) { numtyp e=mor2[mtype].x*(dm-dexp)-mor2[mtype].y; - energy+=e*factor_lj; + energy+=e*factor_lj; } if (vflag>0) { virial[0] += delx*delx*force; diff --git a/lib/gpu/lal_morse.h b/lib/gpu/lal_morse.h index e64852f315..ef80fb4235 100644 --- a/lib/gpu/lal_morse.h +++ b/lib/gpu/lal_morse.h @@ -9,7 +9,7 @@ This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) __________________________________________________________________________ - begin : + begin : email : brownw@ornl.gov ***************************************************************************/ @@ -24,13 +24,13 @@ template class Morse : public BaseAtomic { public: Morse(); - ~Morse(); + ~Morse(); /// Clear any previous data and set up for a new LAMMPS run /** \param max_nbors initial number of rows in the neighbor matrix * \param cell_size cutoff + skin * \param gpu_split fraction of particles handled by device - * + * * Returns: * - 0 if successfull * - -1 if fix gpu not found @@ -40,8 +40,8 @@ class Morse : public BaseAtomic { int init(const int ntypes, double **host_cutsq, double **host_morse1, double **host_r0, double **host_alpha, double **host_d0, double **host_offset, double *host_special_lj, - const int nlocal, const int nall, const int max_nbors, - const int maxspecial, const double cell_size, + const int nlocal, const int nall, const int max_nbors, + const int maxspecial, const double cell_size, const double gpu_split, FILE *screen); /// Clear all host and device data @@ -66,7 +66,7 @@ class Morse : public BaseAtomic { /// If atom type constants fit in shared memory, use fast kernels bool shared_types; - /// Number of atom types + /// Number of atom types int _types; private: diff --git a/lib/gpu/lal_morse_ext.cpp b/lib/gpu/lal_morse_ext.cpp index 3994473fd3..d07a83cd34 100644 --- a/lib/gpu/lal_morse_ext.cpp +++ b/lib/gpu/lal_morse_ext.cpp @@ -9,7 +9,7 @@ This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) __________________________________________________________________________ - begin : + begin : email : brownw@ornl.gov ***************************************************************************/ @@ -28,9 +28,9 @@ static Morse MORMF; // Allocate memory on host and device and copy constants to device // --------------------------------------------------------------------------- int mor_gpu_init(const int ntypes, double **cutsq, - double **host_lj1, double **host_lj2, double **host_lj3, + double **host_lj1, double **host_lj2, double **host_lj3, double **host_lj4, double **offset, double *special_lj, - const int inum, const int nall, const int max_nbors, + const int inum, const int nall, const int max_nbors, const int maxspecial, const double cell_size, int &gpu_mode, FILE *screen) { MORMF.clear(); @@ -55,7 +55,7 @@ int mor_gpu_init(const int ntypes, double **cutsq, int init_ok=0; if (world_me==0) - init_ok=MORMF.init(ntypes, cutsq, host_lj1, host_lj2, host_lj3, + init_ok=MORMF.init(ntypes, cutsq, host_lj1, host_lj2, host_lj3, host_lj4, offset, special_lj, inum, nall, 300, maxspecial, cell_size, gpu_split, screen); @@ -78,7 +78,7 @@ int mor_gpu_init(const int ntypes, double **cutsq, cell_size, gpu_split, screen); MORMF.device->gpu_barrier(); - if (message) + if (message) fprintf(screen,"Done.\n"); } if (message) @@ -103,7 +103,7 @@ int** mor_gpu_compute_n(const int ago, const int inum_full, return MORMF.compute(ago, inum_full, nall, host_x, host_type, sublo, subhi, tag, nspecial, special, eflag, vflag, eatom, vatom, host_start, ilist, jnum, cpu_time, success); -} +} void mor_gpu_compute(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, int *ilist, int *numj, diff --git a/lib/gpu/lal_neighbor_cpu.cu b/lib/gpu/lal_neighbor_cpu.cu index 384b88d9de..d005eb9f97 100644 --- a/lib/gpu/lal_neighbor_cpu.cu +++ b/lib/gpu/lal_neighbor_cpu.cu @@ -9,7 +9,7 @@ // This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) // __________________________________________________________________________ // -// begin : +// begin : // email : brownw@ornl.gov // ***************************************************************************/ @@ -17,7 +17,7 @@ #include "lal_preprocessor.h" #endif -__kernel void kernel_unpack(__global int *dev_nbor, +__kernel void kernel_unpack(__global int *dev_nbor, const __global int *dev_ij, const int inum, const int t_per_atom) { int tid=THREAD_ID_X; @@ -33,7 +33,7 @@ __kernel void kernel_unpack(__global int *dev_nbor, list+=offset; nbor+=fast_mul(ii,t_per_atom-1)+offset; int stride=fast_mul(t_per_atom,inum); - + for ( ; list pos_tex; texture pos_tex; #endif -__kernel void calc_cell_id(const numtyp4 *restrict pos, - unsigned *restrict cell_id, +__kernel void calc_cell_id(const numtyp4 *restrict pos, + unsigned *restrict cell_id, int *restrict particle_id, - numtyp boxlo0, numtyp boxlo1, numtyp boxlo2, - numtyp i_cell_size, int ncellx, int ncelly, - int ncellz, int inum, int nall, + numtyp boxlo0, numtyp boxlo1, numtyp boxlo2, + numtyp i_cell_size, int ncellx, int ncelly, + int ncellz, int inum, int nall, int cells_in_cutoff) { int i = threadIdx.x + blockIdx.x*blockDim.x; @@ -48,11 +48,11 @@ __kernel void calc_cell_id(const numtyp4 *restrict pos, p.x -= boxlo0; p.y -= boxlo1; p.z -= boxlo2; - + int ix = int(p.x*i_cell_size+cells_in_cutoff); int iy = int(p.y*i_cell_size+cells_in_cutoff); int iz = int(p.z*i_cell_size+cells_in_cutoff); - + int offset_lo, offset_hi; if (i 0 && idx < nall) { int id_l = cell_id[idx-1]; if (id != id_l) { - for (int i = id_l+1; i <= id; i++) + for (int i = id_l+1; i <= id; i++) cell_counts[i] = idx; } } @@ -114,8 +114,8 @@ __kernel void kernel_calc_cell_counts(const unsigned *restrict cell_id, #endif #endif -__kernel void transpose(__global tagint *restrict out, - const __global tagint *restrict in, +__kernel void transpose(__global tagint *restrict out, + const __global tagint *restrict in, int columns_in, int rows_in) { __local tagint block[BLOCK_CELL_2D][BLOCK_CELL_2D+1]; @@ -138,12 +138,12 @@ __kernel void transpose(__global tagint *restrict out, out[j*rows_in+i] = block[ti][tj]; } -__kernel void calc_neigh_list_cell(const __global numtyp4 *restrict x_, - const __global int *restrict cell_particle_id, - const __global int *restrict cell_counts, +__kernel void calc_neigh_list_cell(const __global numtyp4 *restrict x_, + const __global int *restrict cell_particle_id, + const __global int *restrict cell_counts, __global int *nbor_list, - __global int *host_nbor_list, - __global int *host_numj, + __global int *host_nbor_list, + __global int *host_numj, int neigh_bin_size, numtyp cell_size, int ncellx, int ncelly, int ncellz, int inum, int nt, int nall, int t_per_atom, @@ -154,7 +154,7 @@ __kernel void calc_neigh_list_cell(const __global numtyp4 *restrict x_, int iy = BLOCK_ID_Y % (ncelly - cells_in_cutoff*2) + cells_in_cutoff; int iz = BLOCK_ID_Y / (ncelly - cells_in_cutoff*2) + cells_in_cutoff; int bsx = BLOCK_SIZE_X; - + int icell = ix + iy*ncellx + iz*ncellx*ncelly; __local int cell_list_sh[BLOCK_NBOR_BUILD]; @@ -163,7 +163,7 @@ __kernel void calc_neigh_list_cell(const __global numtyp4 *restrict x_, int icell_begin = cell_counts[icell]; int icell_end = cell_counts[icell+1]; - int nborz0 = iz-cells_in_cutoff, nborz1 = iz+cells_in_cutoff, + int nborz0 = iz-cells_in_cutoff, nborz1 = iz+cells_in_cutoff, nbory0 = iy-cells_in_cutoff, nbory1 = iy+cells_in_cutoff, nborx0 = ix-cells_in_cutoff, nborx1 = ix+cells_in_cutoff; @@ -174,9 +174,9 @@ __kernel void calc_neigh_list_cell(const __global numtyp4 *restrict x_, int i = icell_begin + tid + ii*bsx; int pid_i = nall, pid_j, stride; numtyp4 atom_i, atom_j; - int cnt = 0; + int cnt = 0; __global int *neigh_counts, *neigh_list; - + if (i < icell_end) pid_i = cell_particle_id[i]; @@ -194,7 +194,7 @@ __kernel void calc_neigh_list_cell(const __global numtyp4 *restrict x_, neigh_counts=host_numj+pid_i-inum; neigh_list=host_nbor_list+(pid_i-inum)*neigh_bin_size; } - + // loop through neighbors for (int nborz = nborz0; nborz <= nborz1; nborz++) { @@ -206,13 +206,13 @@ __kernel void calc_neigh_list_cell(const __global numtyp4 *restrict x_, int jcell_begin = cell_counts[jcell]; int jcell_end = cell_counts[jcell+1]; int num_atom_cell = jcell_end - jcell_begin; - + // load jcell to shared memory int num_iter = ucl_ceil((numtyp)num_atom_cell/bsx); for (int k = 0; k < num_iter; k++) { int end_idx = min(bsx, num_atom_cell-k*bsx); - + if (tid < end_idx) { pid_j = cell_particle_id[tid+k*bsx+jcell_begin]; cell_list_sh[tid] = pid_j; @@ -222,9 +222,9 @@ __kernel void calc_neigh_list_cell(const __global numtyp4 *restrict x_, pos_sh[tid].z = atom_j.z; } __syncthreads(); - + if (pid_i < nt) { - + for (int j = 0; j < end_idx; j++) { int pid_j = cell_list_sh[j]; // gather from shared memory diff.x = atom_i.x - pos_sh[j].x; @@ -253,11 +253,11 @@ __kernel void calc_neigh_list_cell(const __global numtyp4 *restrict x_, } // for (i) } -__kernel void kernel_special(__global int *dev_nbor, - __global int *host_nbor_list, - const __global int *host_numj, +__kernel void kernel_special(__global int *dev_nbor, + __global int *host_nbor_list, + const __global int *host_numj, const __global tagint *restrict tag, - const __global int *restrict nspecial, + const __global int *restrict nspecial, const __global tagint *restrict special, int inum, int nt, int max_nbors, int t_per_atom) { int tid=THREAD_ID_X; @@ -268,7 +268,7 @@ __kernel void kernel_special(__global int *dev_nbor, if (iigpu_bytes(); - + _order=order; _order_m_1=order-1; _order2=_order_m_1*_order; @@ -130,7 +130,7 @@ grdtyp * PPPMT::init(const int nlocal, const int nall, FILE *_screen, view.view(rho_coeff[0]+n2lo,numel,*ucl_device); ucl_copy(d_rho_coeff,view,true); _max_bytes+=d_rho_coeff.row_bytes(); - + // Allocate storage for grid _npts_x=nxhi_out-nxlo_out+1; _npts_y=nyhi_out-nylo_out+1; @@ -165,10 +165,10 @@ grdtyp * PPPMT::init(const int nlocal, const int nall, FILE *_screen, flag=-3; return 0; } - + error_flag.device.zero(); _max_bytes+=1; - + _cpu_idle_time=0.0; return brick.host.begin(); @@ -180,13 +180,13 @@ void PPPMT::clear(const double cpu_time) { return; _allocated=false; _precompute_done=false; - + brick.clear(); vd_brick.clear(); d_brick_counts.clear(); error_flag.clear(); d_brick_atoms.clear(); - + acc_timers(); device->output_kspace_times(time_in,time_out,time_map,time_rho,time_interp, *ans,_max_bytes+_max_an_bytes,cpu_time, @@ -216,7 +216,7 @@ void PPPMT::clear(const double cpu_time) { template void PPPMT::_precompute(const int ago, const int nlocal, const int nall, double **host_x, int *host_type, bool &success, - double *host_q, double *boxlo, + double *host_q, double *boxlo, const double delxinv, const double delyinv, const double delzinv) { acc_timers(); @@ -224,7 +224,7 @@ void PPPMT::_precompute(const int ago, const int nlocal, const int nall, zero_timers(); return; } - + ans->inum(nlocal); if (ago==0) { @@ -250,7 +250,7 @@ void PPPMT::_precompute(const int ago, const int nlocal, const int nall, int GX=static_cast(ceil(static_cast(this->ans->inum())/BX)); int ainum=this->ans->inum(); - + // Boxlo adjusted to be upper left brick and shift for even spline order double shift=0.0; if (_order % 2) @@ -258,7 +258,7 @@ void PPPMT::_precompute(const int ago, const int nlocal, const int nall, _brick_x=boxlo[0]+(_nxlo_out-_nlower-shift)/delxinv; _brick_y=boxlo[1]+(_nylo_out-_nlower-shift)/delyinv; _brick_z=boxlo[2]+(_nzlo_out-_nlower-shift)/delzinv; - + _delxinv=delxinv; _delyinv=delyinv; _delzinv=delzinv; @@ -268,7 +268,7 @@ void PPPMT::_precompute(const int ago, const int nlocal, const int nall, device->zero(d_brick_counts,d_brick_counts.numel()); k_particle_map.set_size(GX,BX); k_particle_map.run(&atom->x, &atom->q, &f_delvolinv, &ainum, - &d_brick_counts, &d_brick_atoms, &_brick_x, &_brick_y, + &d_brick_counts, &d_brick_atoms, &_brick_x, &_brick_y, &_brick_z, &_delxinv, &_delyinv, &_delzinv, &_nlocal_x, &_nlocal_y, &_nlocal_z, &_atom_stride, &_max_brick_atoms, &error_flag); @@ -299,7 +299,7 @@ void PPPMT::_precompute(const int ago, const int nlocal, const int nall, template int PPPMT::spread(const int ago, const int nlocal, const int nall, double **host_x, int *host_type, bool &success, - double *host_q, double *boxlo, + double *host_q, double *boxlo, const double delxinv, const double delyinv, const double delzinv) { if (_precompute_done==false) { @@ -309,10 +309,10 @@ int PPPMT::spread(const int ago, const int nlocal, const int nall, } device->stop_host_timer(); - + if (!success || nlocal==0) return 0; - + double t=MPI_Wtime(); time_out.sync_stop(); _cpu_idle_time+=MPI_Wtime()-t; @@ -325,10 +325,10 @@ int PPPMT::spread(const int ago, const int nlocal, const int nall, error_flag.device.zero(); d_brick_atoms.resize(_atom_stride*_max_brick_atoms); _max_bytes+=d_brick_atoms.row_bytes(); - return spread(ago,nlocal,nall,host_x,host_type,success,host_q,boxlo, + return spread(ago,nlocal,nall,host_x,host_type,success,host_q,boxlo, delxinv,delyinv,delzinv); } - + return error_flag[0]; } @@ -340,18 +340,18 @@ void PPPMT::interp(const grdtyp qqrd2e_scale) { time_in.start(); vd_brick.update_device(true); time_in.stop(); - + time_interp.start(); // Compute the block size and grid size to keep all cores busy int BX=this->block_size(); int GX=static_cast(ceil(static_cast(this->ans->inum())/BX)); int ainum=this->ans->inum(); - + k_interp.set_size(GX,BX); k_interp.run(&atom->x, &atom->q, &ainum, &vd_brick, &d_rho_coeff, &_npts_x, &_npts_yx, &_brick_x, &_brick_y, &_brick_z, &_delxinv, - &_delyinv, &_delzinv, &_order, &_order2, &qqrd2e_scale, + &_delyinv, &_delzinv, &_order, &_order2, &qqrd2e_scale, &ans->force); time_interp.stop(); @@ -381,7 +381,7 @@ void PPPMT::compile_kernels(UCL_Device &dev) { #endif pppm_program=new UCL_Program(dev); - + #ifdef USE_OPENCL pppm_program->load_string(pppm,flags.c_str()); #else diff --git a/lib/gpu/lal_pppm.cu b/lib/gpu/lal_pppm.cu index 99fe655dfd..11703d6d2a 100644 --- a/lib/gpu/lal_pppm.cu +++ b/lib/gpu/lal_pppm.cu @@ -9,7 +9,7 @@ // This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) // __________________________________________________________________________ // -// begin : +// begin : // email : brownw@ornl.gov // ***************************************************************************/ @@ -48,17 +48,17 @@ texture q_tex; // Number of pencils per block for charge spread #define BLOCK_PENCILS (PPPM_BLOCK_1D/PENCIL_SIZE) -__kernel void particle_map(const __global numtyp4 *restrict x_, +__kernel void particle_map(const __global numtyp4 *restrict x_, const __global numtyp *restrict q_, - const grdtyp delvolinv, const int nlocal, - __global int *restrict counts, - __global grdtyp4 *restrict ans, + const grdtyp delvolinv, const int nlocal, + __global int *restrict counts, + __global grdtyp4 *restrict ans, const grdtyp b_lo_x, const grdtyp b_lo_y, const grdtyp b_lo_z, const grdtyp delxinv, const grdtyp delyinv, const grdtyp delzinv, const int nlocal_x, const int nlocal_y, const int nlocal_z, const int atom_stride, - const int max_atoms, + const int max_atoms, __global int *restrict error) { // ii indexes the two interacting particles in gi int ii=GLOBAL_ID_X; @@ -76,7 +76,7 @@ __kernel void particle_map(const __global numtyp4 *restrict x_, grdtyp4 delta; fetch(delta.w,ii,q_tex); delta.w*=delvolinv; - + if (delta.w!=(grdtyp)0.0) { delta.x=(p.x-b_lo_x)*delxinv; nx=delta.x; @@ -85,14 +85,14 @@ __kernel void particle_map(const __global numtyp4 *restrict x_, delta.z=(p.z-b_lo_z)*delzinv; nz=delta.z; - if (delta.x<(grdtyp)0 || delta.y<(grdtyp)0 || delta.z<(grdtyp)0 || + if (delta.x<(grdtyp)0 || delta.y<(grdtyp)0 || delta.z<(grdtyp)0 || nx>=nlocal_x || ny>=nlocal_y || nz>=nlocal_z) *error=1; else { delta.x=nx+(grdtyp)0.5-delta.x; delta.y=ny+(grdtyp)0.5-delta.y; delta.z=nz+(grdtyp)0.5-delta.z; - + int i=nz*nlocal_y*nlocal_x+ny*nlocal_x+nx; int old=atom_add(counts+i, 1); if (old>=max_atoms) { @@ -107,9 +107,9 @@ __kernel void particle_map(const __global numtyp4 *restrict x_, /* --------------------------- */ -__kernel void make_rho(const __global int *restrict counts, +__kernel void make_rho(const __global int *restrict counts, const __global grdtyp4 *restrict atoms, - __global grdtyp *restrict brick, + __global grdtyp *restrict brick, const __global grdtyp *restrict _rho_coeff, const int atom_stride, const int npts_x, const int npts_y, const int npts_z, const int nlocal_x, @@ -118,15 +118,15 @@ __kernel void make_rho(const __global int *restrict counts, __local grdtyp rho_coeff[PPPM_MAX_SPLINE*PPPM_MAX_SPLINE]; __local grdtyp front[BLOCK_PENCILS][PENCIL_SIZE+PPPM_MAX_SPLINE]; __local grdtyp ans[PPPM_MAX_SPLINE][PPPM_BLOCK_1D]; - + int tid=THREAD_ID_X; if (tid -1; k-=order) { @@ -184,14 +184,14 @@ __kernel void make_rho(const __global int *restrict counts, z_pos+=z_stride; } } - + __syncthreads(); if (fid *device; @@ -142,21 +142,21 @@ class PPPM { UCL_Vector brick; UCL_Vector vd_brick; - + // Count of number of atoms assigned to each grid point UCL_D_Vec d_brick_counts; // Atoms assigned to each grid point UCL_D_Vec d_brick_atoms; - + // Error checking for out of bounds atoms UCL_Vector error_flag; - + // Number of grid points in brick (including ghost) int _npts_x, _npts_y, _npts_z, _npts_yx; - + // Number of local grid points in brick int _nlocal_x, _nlocal_y, _nlocal_z, _nlocal_yx, _atom_stride; - + // -------------------------- SPLINE DATA ------------------------- UCL_D_Vec d_rho_coeff; int _order, _nlower, _nupper, _order_m_1, _order2; @@ -180,12 +180,12 @@ class PPPM { int _block_size, _block_pencils, _pencil_size, _max_brick_atoms, _max_atoms; double _max_bytes, _max_an_bytes; double _cpu_idle_time; - - grdtyp _brick_x, _brick_y, _brick_z, _delxinv, _delyinv, _delzinv; + + grdtyp _brick_x, _brick_y, _brick_z, _delxinv, _delyinv, _delzinv; double _slab_volfactor; int _nx_pppm, _ny_pppm, _nz_pppm; - + void compile_kernels(UCL_Device &dev); void _precompute(const int ago, const int nlocal, const int nall, double **host_x, int *host_type, bool &success, diff --git a/lib/gpu/lal_pppm_ext.cpp b/lib/gpu/lal_pppm_ext.cpp index 6e5a82af5b..7e07d6c87b 100644 --- a/lib/gpu/lal_pppm_ext.cpp +++ b/lib/gpu/lal_pppm_ext.cpp @@ -9,7 +9,7 @@ This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) __________________________________________________________________________ - begin : + begin : email : brownw@ornl.gov ***************************************************************************/ @@ -30,7 +30,7 @@ static PPPM PPPMD; // --------------------------------------------------------------------------- template grdtyp * pppm_gpu_init(memtyp &pppm, const int nlocal, const int nall, - FILE *screen, const int order, const int nxlo_out, + FILE *screen, const int order, const int nxlo_out, const int nylo_out, const int nzlo_out, const int nxhi_out, const int nyhi_out, const int nzhi_out, grdtyp **rho_coeff, @@ -82,7 +82,7 @@ grdtyp * pppm_gpu_init(memtyp &pppm, const int nlocal, const int nall, split,success); pppm.device->gpu_barrier(); - if (message) + if (message) fprintf(screen,"Done.\n"); } if (message) @@ -91,7 +91,7 @@ grdtyp * pppm_gpu_init(memtyp &pppm, const int nlocal, const int nall, } float * pppm_gpu_init_f(const int nlocal, const int nall, FILE *screen, - const int order, const int nxlo_out, + const int order, const int nxlo_out, const int nylo_out, const int nzlo_out, const int nxhi_out, const int nyhi_out, const int nzhi_out, float **rho_coeff, @@ -102,7 +102,7 @@ float * pppm_gpu_init_f(const int nlocal, const int nall, FILE *screen, nzlo_out,nxhi_out,nyhi_out,nzhi_out,rho_coeff,vd_brick, slab_volfactor,nx_pppm,ny_pppm,nz_pppm,split,success); if (split==false && respa==false) - PPPMF.device->set_single_precompute(&PPPMF); + PPPMF.device->set_single_precompute(&PPPMF); return b; } @@ -133,20 +133,20 @@ void pppm_gpu_forces_f(double **f) { } double * pppm_gpu_init_d(const int nlocal, const int nall, FILE *screen, - const int order, const int nxlo_out, + const int order, const int nxlo_out, const int nylo_out, const int nzlo_out, const int nxhi_out, const int nyhi_out, const int nzhi_out, double **rho_coeff, double **vd_brick, const double slab_volfactor, const int nx_pppm, const int ny_pppm, - const int nz_pppm, const bool split, + const int nz_pppm, const bool split, const bool respa, int &success) { double *b=pppm_gpu_init(PPPMD,nlocal,nall,screen,order,nxlo_out,nylo_out, nzlo_out,nxhi_out,nyhi_out,nzhi_out,rho_coeff, vd_brick,slab_volfactor,nx_pppm,ny_pppm,nz_pppm, - split,success); + split,success); if (split==false && respa==false) - PPPMD.device->set_double_precompute(&PPPMD); + PPPMD.device->set_double_precompute(&PPPMD); return b; } diff --git a/lib/gpu/lal_precision.h b/lib/gpu/lal_precision.h index 810afb4c88..d5b1b9b6c0 100644 --- a/lib/gpu/lal_precision.h +++ b/lib/gpu/lal_precision.h @@ -9,7 +9,7 @@ This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) __________________________________________________________________________ - begin : + begin : email : brownw@ornl.gov ***************************************************************************/ @@ -49,17 +49,17 @@ inline std::ostream & operator<<(std::ostream &out, const _lgpu_float2 &v) { out << v.x << " " << v.y; return out; } - + inline std::ostream & operator<<(std::ostream &out, const _lgpu_float4 &v) { out << v.x << " " << v.y << " " << v.z; return out; } - + inline std::ostream & operator<<(std::ostream &out, const _lgpu_double2 &v) { out << v.x << " " << v.y; return out; } - + inline std::ostream & operator<<(std::ostream &out, const _lgpu_double4 &v) { out << v.x << " " << v.y << " " << v.z; return out; diff --git a/lib/gpu/lal_preprocessor.h b/lib/gpu/lal_preprocessor.h index 9dbb3c5944..69a8e61bd4 100644 --- a/lib/gpu/lal_preprocessor.h +++ b/lib/gpu/lal_preprocessor.h @@ -9,16 +9,16 @@ // This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) // __________________________________________________________________________ // -// begin : +// begin : // email : brownw@ornl.gov // ***************************************************************************/ //************************************************************************* // Preprocessor Definitions -// +// // Note: It is assumed that constants with the same names are defined with // the same values in all files. -// +// // ARCH // Definition: Architecture number for accelerator // MEM_THREADS @@ -35,22 +35,22 @@ // Restructions: Must be power of 2; THREADS_PER_ATOM<=WARP_SIZE // PPPM_MAX_SPLINE // Definition: Maximum order for splines in PPPM -// PPPM_BLOCK_1D +// PPPM_BLOCK_1D // Definition: Thread block size for PPPM kernels // Restrictions: PPPM_BLOCK_1D>=PPPM_MAX_SPLINE*PPPM_MAX_SPLINE -// PPPM_BLOCK_1D%32==0 +// PPPM_BLOCK_1D%32==0 // BLOCK_PAIR // Definition: Default thread block size for pair styles // Restrictions: // MAX_SHARED_TYPES 8 // Definition: Max # of atom type params can be stored in shared memory // Restrictions: MAX_SHARED_TYPES*MAX_SHARED_TYPES<=BLOCK_PAIR -// BLOCK_CELL_2D +// BLOCK_CELL_2D // Definition: Default block size in each dimension for cell list builds // and matrix transpose -// BLOCK_CELL_ID +// BLOCK_CELL_ID // Definition: Default block size for binning atoms in cell list builds -// BLOCK_NBOR_BUILD +// BLOCK_NBOR_BUILD // Definition: Default block size for neighbor list builds // BLOCK_BIO_PAIR // Definition: Default thread block size for "bio" pair styles @@ -78,10 +78,10 @@ #define BLOCK_SIZE_Y blockDim.y #define __kernel extern "C" __global__ #define __local __shared__ -#define __global +#define __global #define restrict __restrict__ #define atom_add atomicAdd -#define ucl_inline static __inline__ __device__ +#define ucl_inline static __inline__ __device__ #ifdef __CUDA_ARCH__ #define ARCH __CUDA_ARCH__ diff --git a/lib/gpu/lal_re_squared.cpp b/lib/gpu/lal_re_squared.cpp index cbf50fab7d..55034aaf03 100644 --- a/lib/gpu/lal_re_squared.cpp +++ b/lib/gpu/lal_re_squared.cpp @@ -37,18 +37,18 @@ RESquaredT::RESquared() : BaseEllipsoid(), } template -RESquaredT::~RESquared() { +RESquaredT::~RESquared() { clear(); } - + template int RESquaredT::bytes_per_atom(const int max_nbors) const { return this->bytes_per_atom(max_nbors); } template -int RESquaredT::init(const int ntypes, double **host_shape, double **host_well, - double **host_cutsq, double **host_sigma, +int RESquaredT::init(const int ntypes, double **host_shape, double **host_well, + double **host_cutsq, double **host_sigma, double **host_epsilon, int **h_form, double **host_lj1, double **host_lj2, double **host_lj3, double **host_lj4, double **host_offset, const double *host_special_lj, @@ -97,7 +97,7 @@ int RESquaredT::init(const int ntypes, double **host_shape, double **host_well, dev_error.alloc(1,*(this->ucl_device),UCL_WRITE_ONLY); dev_error.zero(); - + // Allocate, cast and asynchronous memcpy of constant data // Copy data for bonded interactions special_lj.alloc(4,*(this->ucl_device),UCL_READ_ONLY); @@ -127,7 +127,7 @@ int RESquaredT::init(const int ntypes, double **host_shape, double **host_well, } view4.view((numtyp4*)host_write.begin(),well.numel(),*(this->ucl_device)); ucl_copy(well,view4,false); - + _allocated=true; this->_max_bytes=sigma_epsilon.row_bytes()+this->cut_form.row_bytes()+ lj1.row_bytes()+lj3.row_bytes()+special_lj.row_bytes()+ @@ -144,7 +144,7 @@ void RESquaredT::clear() { UCL_H_Vec err_flag(1,*(this->ucl_device)); ucl_copy(err_flag,dev_error,false); if (err_flag[0] == 2) - std::cerr << "BAD MATRIX INVERSION IN FORCE COMPUTATION.\n"; + std::cerr << "BAD MATRIX INVERSION IN FORCE COMPUTATION.\n"; err_flag.clear(); _allocated=false; @@ -158,7 +158,7 @@ void RESquaredT::clear() { shape.clear(); well.clear(); special_lj.clear(); - + this->clear_base(); } @@ -184,7 +184,7 @@ void RESquaredT::loop(const bool _eflag, const bool _vflag) { vflag=1; else vflag=0; - + int GX=0, NGX; int stride=this->nbor->nbor_pitch(); int ainum=this->ans->inum(); @@ -204,10 +204,10 @@ void RESquaredT::loop(const bool _eflag, const bool _vflag) { this->k_ellipsoid.set_size(GX,BX); this->k_ellipsoid.run(&this->atom->x, &this->atom->quat, &this->shape, &this->well, &this->special_lj, - &this->sigma_epsilon, &this->_lj_types, - &this->nbor->dev_nbor, &stride, + &this->sigma_epsilon, &this->_lj_types, + &this->nbor->dev_nbor, &stride, &this->ans->force,&ainum, &this->ans->engv, - &this->dev_error, &eflag, &vflag, + &this->dev_error, &eflag, &vflag, &this->_last_ellipse, &this->_threads_per_atom); this->time_ellipsoid.stop(); @@ -219,12 +219,12 @@ void RESquaredT::loop(const bool _eflag, const bool _vflag) { this->time_ellipsoid2.start(); this->k_ellipsoid_sphere.set_size(GX,BX); - this->k_ellipsoid_sphere.run(&this->atom->x, &this->atom->quat, + this->k_ellipsoid_sphere.run(&this->atom->x, &this->atom->quat, &this->shape, &this->well, &this->special_lj, - &this->sigma_epsilon, &this->_lj_types, + &this->sigma_epsilon, &this->_lj_types, &this->nbor->dev_nbor, &stride, &this->ans->force,&ainum, - &this->ans->engv, &this->dev_error, + &this->ans->engv, &this->dev_error, &eflag, &vflag, &this->_last_ellipse, &this->_threads_per_atom); this->time_ellipsoid2.stop(); @@ -251,12 +251,12 @@ void RESquaredT::loop(const bool _eflag, const bool _vflag) { this->time_ellipsoid3.start(); this->k_sphere_ellipsoid.set_size(GX,BX); this->k_sphere_ellipsoid.run(&this->atom->x, &this->atom->quat, - &this->shape, &this->well, &this->special_lj, + &this->shape, &this->well, &this->special_lj, &this->sigma_epsilon, &this->_lj_types, - &this->nbor->dev_nbor, &stride, + &this->nbor->dev_nbor, &stride, &this->ans->force, &this->ans->engv, &this->dev_error, &eflag, &vflag, - &this->_last_ellipse, &ainum, + &this->_last_ellipse, &ainum, &this->_threads_per_atom); this->time_ellipsoid3.stop(); } else { @@ -266,13 +266,13 @@ void RESquaredT::loop(const bool _eflag, const bool _vflag) { this->ans->force.zero(); this->ans->engv.zero(); this->time_nbor1.zero(); - this->time_ellipsoid.zero(); + this->time_ellipsoid.zero(); this->time_nbor2.zero(); this->time_ellipsoid2.zero(); this->time_nbor3.zero(); this->time_ellipsoid3.zero(); } - + // ------------ LJ --------------- this->time_lj.start(); if (this->_last_ellipseans->inum()) { @@ -287,7 +287,7 @@ void RESquaredT::loop(const bool _eflag, const bool _vflag) { } else { this->k_lj.set_size(GX,BX); this->k_lj.run(&this->atom->x, &this->lj1, &this->lj3, - &this->_lj_types, &this->special_lj, &stride, + &this->_lj_types, &this->special_lj, &stride, &this->nbor->dev_packed, &this->ans->force, &this->ans->engv, &this->dev_error, &eflag, &vflag, &this->_last_ellipse, &ainum, &this->_threads_per_atom); @@ -302,13 +302,13 @@ void RESquaredT::loop(const bool _eflag, const bool _vflag) { this->pack_nbors(NGX, BX, 0, this->ans->inum(),SPHERE_SPHERE, ELLIPSE_ELLIPSE,_shared_types,_lj_types); this->time_nbor1.stop(); - this->time_ellipsoid.start(); + this->time_ellipsoid.start(); this->k_ellipsoid.set_size(GX,BX); - this->k_ellipsoid.run(&this->atom->x, &this->atom->quat, - &this->shape, &this->well, &this->special_lj, - &this->sigma_epsilon, &this->_lj_types, + this->k_ellipsoid.run(&this->atom->x, &this->atom->quat, + &this->shape, &this->well, &this->special_lj, + &this->sigma_epsilon, &this->_lj_types, &this->nbor->dev_nbor, &stride, &this->ans->force, - &ainum, &this->ans->engv, &this->dev_error, + &ainum, &this->ans->engv, &this->dev_error, &eflag, &vflag, &ainum, &this->_threads_per_atom); this->time_ellipsoid.stop(); } diff --git a/lib/gpu/lal_re_squared.cu b/lib/gpu/lal_re_squared.cu index 3a65ce14ce..e238734074 100644 --- a/lib/gpu/lal_re_squared.cu +++ b/lib/gpu/lal_re_squared.cu @@ -34,31 +34,31 @@ ucl_inline numtyp det_prime(const numtyp m[9], const numtyp m2[9]) __kernel void k_resquared(const __global numtyp4 *restrict x_, const __global numtyp4 *restrict q, - const __global numtyp4 *restrict shape, - const __global numtyp4 *restrict well, - const __global numtyp *restrict splj, - const __global numtyp2 *restrict sig_eps, - const int ntypes, + const __global numtyp4 *restrict shape, + const __global numtyp4 *restrict well, + const __global numtyp *restrict splj, + const __global numtyp2 *restrict sig_eps, + const int ntypes, const __global int *dev_nbor, - const int stride, + const int stride, __global acctyp4 *restrict ans, - const int astride, + const int astride, __global acctyp *restrict engv, - __global int *restrict err_flag, + __global int *restrict err_flag, const int eflag, const int vflag, const int inum, const int t_per_atom) { int tid, ii, offset; atom_info(t_per_atom,ii,tid,offset); __local numtyp sp_lj[4]; - sp_lj[0]=splj[0]; - sp_lj[1]=splj[1]; - sp_lj[2]=splj[2]; + sp_lj[0]=splj[0]; + sp_lj[1]=splj[1]; + sp_lj[2]=splj[2]; sp_lj[3]=splj[3]; - + __local numtyp b_alpha, cr60; b_alpha=(numtyp)45.0/(numtyp)56.0; - cr60=ucl_cbrt((numtyp)60.0); + cr60=ucl_cbrt((numtyp)60.0); acctyp energy=(acctyp)0; acctyp4 f; @@ -79,7 +79,7 @@ __kernel void k_resquared(const __global numtyp4 *restrict x_, __local int n_stride; nbor_info_e(dev_nbor,stride,t_per_atom,ii,offset,i,numj, n_stride,nbor_end,nbor); - + numtyp4 ix; fetch4(ix,i,pos_tex); int itype=ix.w; @@ -91,14 +91,14 @@ __kernel void k_resquared(const __global numtyp4 *restrict x_, numtyp lAtwo1_0[9], lAtwo1_1[9], lAtwo1_2[9]; // A'*S^2*lA numtyp lAsa1_0[9], lAsa1_1[9], lAsa1_2[9]; // lAtwo+lA'*sa numtyp4 ishape; - + ishape=shape[itype]; numtyp4 ishape2; ishape2.x=ishape.x*ishape.x; ishape2.y=ishape.y*ishape.y; ishape2.z=ishape.z*ishape.z; numtyp ilshape = ishape.x*ishape.y*ishape.z; - + { numtyp aTs[9]; // A1'*S1^2 gpu_quat_to_mat_trans(q,i,a1); @@ -148,7 +148,7 @@ __kernel void k_resquared(const __global numtyp4 *restrict x_, numtyp a2[9]; // Rotation matrix (lab->body) numtyp gamma2[9]; // A'*S^2*A numtyp4 jshape; - + jshape=shape[jtype]; numtyp4 jshape2; jshape2.x=jshape.x*jshape.x; @@ -189,7 +189,7 @@ __kernel void k_resquared(const __global numtyp4 *restrict x_, H12[7] = gamma1[7]*sigma1+gamma2[7]*sigma2; H12[8] = gamma1[8]*sigma1+gamma2[8]*sigma2; dH=gpu_det3(H12); - + numtyp sigma1p2, sigma2p2, lambda, nu; sigma1p2 = sigma1*sigma1; sigma2p2 = sigma2*sigma2; @@ -299,7 +299,7 @@ __kernel void k_resquared(const __global numtyp4 *restrict x_, hsec = ucl_recip(h12+(numtyp)3.0*sec); dspu = ucl_recip(h12)-hsec+stemp; pbsu = (numtyp)3.0*sigma*hsec; - + numtyp dspr, pbsr; stemp = ucl_recip(ishape.x*cr60+h12)+ ucl_recip(ishape.y*cr60+h12)+ @@ -310,7 +310,7 @@ __kernel void k_resquared(const __global numtyp4 *restrict x_, hsec = ucl_recip(h12+b_alpha*sec); dspr = (numtyp)7.0/h12-hsec+stemp; pbsr = b_alpha*sigma*hsec; - + numtyp dH12[9]; numtyp dUa, dUr, deta, dchi, ddH, dh12; numtyp dsigma1, dsigma2; diff --git a/lib/gpu/lal_re_squared.h b/lib/gpu/lal_re_squared.h index c7441ed83e..8dc137d829 100644 --- a/lib/gpu/lal_re_squared.h +++ b/lib/gpu/lal_re_squared.h @@ -25,14 +25,14 @@ template class RESquared : public BaseEllipsoid { public: RESquared(); - ~RESquared(); + ~RESquared(); /// Clear any previous data and set up for a new LAMMPS run /** \param max_nbors initial number of rows in the neighbor matrix * \param cell_size cutoff + skin - * \param gpu_split fraction of particles handled by device + * \param gpu_split fraction of particles handled by device * \return false if there is not sufficient memory or device init prob - * + * * Returns: * - 0 if successfull * - -1 if fix gpu not found @@ -41,7 +41,7 @@ class RESquared : public BaseEllipsoid { * - -5 Double precision is not supported on card **/ int init(const int ntypes, double **host_shape, double **host_well, double **host_cutsq, double **host_sigma, double **host_epsilon, - int **h_form, double **host_lj1, double **host_lj2, + int **h_form, double **host_lj1, double **host_lj2, double **host_lj3, double **host_lj4, double **host_offset, const double *host_special_lj, const int nlocal, const int nall, const int max_nbors, const int maxspecial, const double cell_size, @@ -50,7 +50,7 @@ class RESquared : public BaseEllipsoid { /// Clear all host and device data /** \note This is called at the beginning of the init() routine **/ void clear(); - + /// Returns memory usage on device per atom int bytes_per_atom(const int max_nbors) const; @@ -59,8 +59,8 @@ class RESquared : public BaseEllipsoid { /// Device Error Flag - Set if a bad matrix inversion occurs UCL_D_Vec dev_error; - - // --------------------------- TYPE DATA -------------------------- + + // --------------------------- TYPE DATA -------------------------- /// lj1.x = lj1, lj1.y = lj2, lj1.z = cutsq, lj1.w = form UCL_D_Vec lj1; @@ -70,12 +70,12 @@ class RESquared : public BaseEllipsoid { UCL_D_Vec sigma_epsilon; /// special lj 0-4 UCL_D_Vec special_lj; - + /// If atom type constants fit in shared memory, use fast kernels bool _shared_types; int _lj_types; - - // --------------------------- ATOM DATA -------------------------- + + // --------------------------- ATOM DATA -------------------------- /// Aspherical Const Data for Atoms UCL_D_Vec shape, well; diff --git a/lib/gpu/lal_re_squared_ext.cpp b/lib/gpu/lal_re_squared_ext.cpp index e1d8fffb8f..b719dfe05f 100644 --- a/lib/gpu/lal_re_squared_ext.cpp +++ b/lib/gpu/lal_re_squared_ext.cpp @@ -28,8 +28,8 @@ static RESquared REMF; // Allocate memory on host and device and copy constants to device // --------------------------------------------------------------------------- int re_gpu_init(const int ntypes, double **shape, double **well, double **cutsq, - double **sigma, double **epsilon, - int **form, double **host_lj1, double **host_lj2, + double **sigma, double **epsilon, + int **form, double **host_lj1, double **host_lj2, double **host_lj3, double **host_lj4, double **offset, double *special_lj, const int inum, const int nall, const int max_nbors, const int maxspecial, @@ -56,7 +56,7 @@ int re_gpu_init(const int ntypes, double **shape, double **well, double **cutsq, int init_ok=0; if (world_me==0) - init_ok=REMF.init(ntypes, shape, well, cutsq, sigma, epsilon, + init_ok=REMF.init(ntypes, shape, well, cutsq, sigma, epsilon, form, host_lj1, host_lj2, host_lj3, host_lj4, offset, special_lj, inum, nall, max_nbors, maxspecial, cell_size, gpu_split, screen); @@ -64,7 +64,7 @@ int re_gpu_init(const int ntypes, double **shape, double **well, double **cutsq, REMF.device->world_barrier(); if (message) fprintf(screen,"Done.\n"); - + for (int i=0; igpu_barrier(); - if (message) + if (message) fprintf(screen,"Done.\n"); } if (message) @@ -102,8 +102,8 @@ void re_gpu_clear() { int** compute(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, double *sublo, double *subhi, tagint *tag, int **nspecial, - tagint **special, const bool eflag, const bool vflag, - const bool eatom, const bool vatom, int &host_start, + tagint **special, const bool eflag, const bool vflag, + const bool eatom, const bool vatom, int &host_start, int **ilist, int **numj, const double cpu_time, bool &success, double **host_quat); @@ -114,8 +114,8 @@ int** re_gpu_compute_n(const int ago, const int inum_full, const int nall, const bool vatom, int &host_start, int **ilist, int **jnum, const double cpu_time, bool &success, double **host_quat) { - return REMF.compute(ago, inum_full, nall, host_x, host_type, sublo, subhi, - tag, nspecial, special, eflag, vflag, eatom, vatom, + return REMF.compute(ago, inum_full, nall, host_x, host_type, sublo, subhi, + tag, nspecial, special, eflag, vflag, eatom, vatom, host_start, ilist, jnum, cpu_time, success, host_quat); } diff --git a/lib/gpu/lal_re_squared_lj.cu b/lib/gpu/lal_re_squared_lj.cu index 4742e5bd8e..d69dae2461 100644 --- a/lib/gpu/lal_re_squared_lj.cu +++ b/lib/gpu/lal_re_squared_lj.cu @@ -129,32 +129,32 @@ __kernel void k_resquared_ellipsoid_sphere(const __global numtyp4 *restrict x_, const __global numtyp4 *restrict q, - const __global numtyp4 *restrict shape, + const __global numtyp4 *restrict shape, const __global numtyp4 *restrict well, - const __global numtyp *restrict splj, + const __global numtyp *restrict splj, const __global numtyp2 *restrict sig_eps, - const int ntypes, + const int ntypes, const __global int *dev_nbor, - const int stride, + const int stride, __global acctyp4 *restrict ans, - const int astride, - __global acctyp *restrict engv, - __global int *restrict err_flag, - const int eflag, const int vflag, - const int inum, + const int astride, + __global acctyp *restrict engv, + __global int *restrict err_flag, + const int eflag, const int vflag, + const int inum, const int t_per_atom) { int tid, ii, offset; atom_info(t_per_atom,ii,tid,offset); __local numtyp sp_lj[4]; - sp_lj[0]=splj[0]; - sp_lj[1]=splj[1]; - sp_lj[2]=splj[2]; + sp_lj[0]=splj[0]; + sp_lj[1]=splj[1]; + sp_lj[2]=splj[2]; sp_lj[3]=splj[3]; - + __local numtyp b_alpha, cr60, solv_f_a, solv_f_r; b_alpha=(numtyp)45.0/(numtyp)56.0; - cr60=ucl_cbrt((numtyp)60.0); + cr60=ucl_cbrt((numtyp)60.0); solv_f_a = (numtyp)3.0/((numtyp)16.0*ucl_atan((numtyp)1.0)*-(numtyp)36.0); solv_f_r = (numtyp)3.0/((numtyp)16.0*ucl_atan((numtyp)1.0)*(numtyp)2025.0); @@ -177,7 +177,7 @@ __kernel void k_resquared_ellipsoid_sphere(const __global numtyp4 *restrict x_, __local int n_stride; nbor_info_e(dev_nbor,stride,t_per_atom,ii,offset,i,numj, n_stride,nbor_end,nbor); - + numtyp4 ix; fetch4(ix,i,pos_tex); int itype=ix.w; @@ -223,7 +223,7 @@ __kernel void k_resquared_ellipsoid_sphere(const __global numtyp4 *restrict x_, sigma = sig_eps[mtype].x; epsilon = sig_eps[mtype].y*factor_lj; - numtyp aTs[9]; + numtyp aTs[9]; numtyp4 scorrect; numtyp half_sigma=sigma*(numtyp)0.5; scorrect.x = ishape.x+half_sigma; @@ -260,7 +260,7 @@ __kernel void k_resquared_ellipsoid_sphere(const __global numtyp4 *restrict x_, Ua = (ishape.x+stemp)*(ishape.y+stemp)*(ishape.z+stemp)*h12p3/(numtyp)8.0; Ua = ((numtyp)1.0+(numtyp)3.0*tprod)*ilshape/Ua; Ua = epsilon*Ua*sigmap3*solv_f_a; - + stemp = h12/cr60; Ur = (ishape.x+stemp)*(ishape.y+stemp)*(ishape.z+stemp)*h12p3/ (numtyp)60.0; @@ -290,7 +290,7 @@ __kernel void k_resquared_ellipsoid_sphere(const __global numtyp4 *restrict x_, numtyp hsec = ucl_recip(h12+(numtyp)3.0*sec); numtyp dspu = ucl_recip(h12)-hsec+stemp; numtyp pbsu = (numtyp)3.0*sigma*hsec; - + stemp = ucl_recip(ishape.x*cr60+h12)+ ucl_recip(ishape.y*cr60+h12)+ ucl_recip(ishape.z*cr60+h12)+ @@ -298,7 +298,7 @@ __kernel void k_resquared_ellipsoid_sphere(const __global numtyp4 *restrict x_, hsec = ucl_recip(h12+b_alpha*sec); numtyp dspr = (numtyp)7.0/h12-hsec+stemp; numtyp pbsr = b_alpha*sigma*hsec; - + #pragma unroll for (int i=0; i<3; i++) { numtyp u[3]; @@ -334,7 +334,7 @@ __kernel void k_resquared_ellipsoid_sphere(const __global numtyp4 *restrict x_, } } - + // torque on i numtyp fwae[3]; gpu_row_times3(fourw,aTe,fwae); @@ -384,33 +384,33 @@ __kernel void k_resquared_ellipsoid_sphere(const __global numtyp4 *restrict x_, } __kernel void k_resquared_sphere_ellipsoid(const __global numtyp4 *restrict x_, - const __global numtyp4 *restrict q, + const __global numtyp4 *restrict q, const __global numtyp4 *restrict shape, const __global numtyp4 *restrict well, const __global numtyp *restrict splj, const __global numtyp2 *restrict sig_eps, - const int ntypes, + const int ntypes, const __global int *dev_nbor, - const int stride, + const int stride, __global acctyp4 *restrict ans, - __global acctyp *restrict engv, + __global acctyp *restrict engv, __global int *restrict err_flag, const int eflag, const int vflag, - const int start, const int inum, + const int start, const int inum, const int t_per_atom) { int tid, ii, offset; atom_info(t_per_atom,ii,tid,offset); ii+=start; __local numtyp sp_lj[4]; - sp_lj[0]=splj[0]; - sp_lj[1]=splj[1]; - sp_lj[2]=splj[2]; + sp_lj[0]=splj[0]; + sp_lj[1]=splj[1]; + sp_lj[2]=splj[2]; sp_lj[3]=splj[3]; - + __local numtyp b_alpha, cr60, solv_f_a, solv_f_r; b_alpha=(numtyp)45.0/(numtyp)56.0; - cr60=ucl_cbrt((numtyp)60.0); + cr60=ucl_cbrt((numtyp)60.0); solv_f_a = (numtyp)3.0/((numtyp)16.0*ucl_atan((numtyp)1.0)*-(numtyp)36.0); solv_f_r = (numtyp)3.0/((numtyp)16.0*ucl_atan((numtyp)1.0)*(numtyp)2025.0); @@ -429,7 +429,7 @@ __kernel void k_resquared_sphere_ellipsoid(const __global numtyp4 *restrict x_, __local int n_stride; nbor_info_e(dev_nbor,stride,t_per_atom,ii,offset,j,numj, n_stride,nbor_end,nbor); - + numtyp4 jx; fetch4(jx,j,pos_tex); int jtype=jx.w; @@ -445,7 +445,7 @@ __kernel void k_resquared_sphere_ellipsoid(const __global numtyp4 *restrict x_, numtyp a[9]; // Rotation matrix (lab->body) numtyp aTe[9]; // A'*E numtyp4 ishape; - + ishape=shape[itype]; gpu_quat_to_mat_trans(q,i,a); gpu_transpose_times_diag3(a,well[itype],aTe); @@ -467,7 +467,7 @@ __kernel void k_resquared_sphere_ellipsoid(const __global numtyp4 *restrict x_, sigma = sig_eps[mtype].x; epsilon = sig_eps[mtype].y*factor_lj; - numtyp aTs[9]; + numtyp aTs[9]; numtyp4 scorrect; numtyp half_sigma=sigma * (numtyp)0.5; scorrect.x = ishape.x+half_sigma; @@ -477,7 +477,7 @@ __kernel void k_resquared_sphere_ellipsoid(const __global numtyp4 *restrict x_, scorrect.y = scorrect.y * scorrect.y * (numtyp)0.5; scorrect.z = scorrect.z * scorrect.z * (numtyp)0.5; gpu_transpose_times_diag3(a,scorrect,aTs); - + // energy numtyp gamma[9], s[3]; @@ -505,7 +505,7 @@ __kernel void k_resquared_sphere_ellipsoid(const __global numtyp4 *restrict x_, numtyp ilshape=ishape.x*ishape.y*ishape.z; Ua = ((numtyp)1.0+(numtyp)3.0*tprod)*ilshape/Ua; Ua = epsilon*Ua*sigmap3*solv_f_a; - + stemp = h12/cr60; Ur = (ishape.x+stemp)*(ishape.y+stemp)*(ishape.z+stemp)*h12p3/ (numtyp)60.0; @@ -535,7 +535,7 @@ __kernel void k_resquared_sphere_ellipsoid(const __global numtyp4 *restrict x_, numtyp hsec = ucl_recip(h12+(numtyp)3.0*sec); numtyp dspu = ucl_recip(h12)-hsec+stemp; numtyp pbsu = (numtyp)3.0*sigma*hsec; - + stemp = ucl_recip(ishape.x*cr60+h12)+ ucl_recip(ishape.y*cr60+h12)+ ucl_recip(ishape.z*cr60+h12)+ @@ -543,7 +543,7 @@ __kernel void k_resquared_sphere_ellipsoid(const __global numtyp4 *restrict x_, hsec = ucl_recip(h12+b_alpha*sec); numtyp dspr = (numtyp)7.0/h12-hsec+stemp; numtyp pbsr = b_alpha*sigma*hsec; - + #pragma unroll for (int i=0; i<3; i++) { numtyp u[3]; @@ -584,15 +584,15 @@ __kernel void k_resquared_sphere_ellipsoid(const __global numtyp4 *restrict x_, } // if ii } -__kernel void k_resquared_lj(const __global numtyp4 *restrict x_, - const __global numtyp4 *restrict lj1, - const __global numtyp4 *restrict lj3, - const int lj_types, - const __global numtyp *restrict gum, - const int stride, - const __global int *dev_ij, +__kernel void k_resquared_lj(const __global numtyp4 *restrict x_, + const __global numtyp4 *restrict lj1, + const __global numtyp4 *restrict lj3, + const int lj_types, + const __global numtyp *restrict gum, + const int stride, + const __global int *dev_ij, __global acctyp4 *restrict ans, - __global acctyp *restrict engv, + __global acctyp *restrict engv, __global int *restrict err_flag, const int eflag, const int vflag, const int start, const int inum, const int t_per_atom) { @@ -601,10 +601,10 @@ __kernel void k_resquared_lj(const __global numtyp4 *restrict x_, ii+=start; __local numtyp sp_lj[4]; - sp_lj[0]=gum[0]; - sp_lj[1]=gum[1]; - sp_lj[2]=gum[2]; - sp_lj[3]=gum[3]; + sp_lj[0]=gum[0]; + sp_lj[1]=gum[1]; + sp_lj[2]=gum[2]; + sp_lj[3]=gum[3]; acctyp energy=(acctyp)0; acctyp4 f; @@ -614,20 +614,20 @@ __kernel void k_resquared_lj(const __global numtyp4 *restrict x_, acctyp virial[6]; for (int i=0; i<6; i++) virial[i]=(acctyp)0; - + if (ii0) { numtyp e=r6inv*(lj3[ii].x*r6inv-lj3[ii].y); - energy+=factor_lj*(e-lj3[ii].z); + energy+=factor_lj*(e-lj3[ii].z); } if (vflag>0) { virial[0] += delx*delx*force; @@ -671,33 +671,33 @@ __kernel void k_resquared_lj(const __global numtyp4 *restrict x_, } // if ii } -__kernel void k_resquared_lj_fast(const __global numtyp4 *restrict x_, - const __global numtyp4 *restrict lj1_in, - const __global numtyp4 *restrict lj3_in, - const __global numtyp *restrict gum, +__kernel void k_resquared_lj_fast(const __global numtyp4 *restrict x_, + const __global numtyp4 *restrict lj1_in, + const __global numtyp4 *restrict lj3_in, + const __global numtyp *restrict gum, const int stride, const __global int *dev_ij, __global acctyp4 *restrict ans, - __global acctyp *restrict engv, + __global acctyp *restrict engv, __global int *restrict err_flag, const int eflag, const int vflag, - const int start, const int inum, + const int start, const int inum, const int t_per_atom) { int tid, ii, offset; atom_info(t_per_atom,ii,tid,offset); ii+=start; - __local numtyp sp_lj[4]; + __local numtyp sp_lj[4]; __local numtyp4 lj1[MAX_SHARED_TYPES*MAX_SHARED_TYPES]; __local numtyp4 lj3[MAX_SHARED_TYPES*MAX_SHARED_TYPES]; if (tid<4) - sp_lj[tid]=gum[tid]; + sp_lj[tid]=gum[tid]; if (tid0) lj3[tid]=lj3_in[tid]; } - + acctyp energy=(acctyp)0; acctyp4 f; f.x=(acctyp)0; @@ -706,9 +706,9 @@ __kernel void k_resquared_lj_fast(const __global numtyp4 *restrict x_, acctyp virial[6]; for (int i=0; i<6; i++) virial[i]=(acctyp)0; - + __syncthreads(); - + if (ii0) { numtyp e=r6inv*(lj3[mtype].x*r6inv-lj3[mtype].y); - energy+=factor_lj*(e-lj3[mtype].z); + energy+=factor_lj*(e-lj3[mtype].z); } if (vflag>0) { virial[0] += delx*delx*force; diff --git a/lib/gpu/lal_soft.cpp b/lib/gpu/lal_soft.cpp index c206a997a9..337bdd6738 100644 --- a/lib/gpu/lal_soft.cpp +++ b/lib/gpu/lal_soft.cpp @@ -9,7 +9,7 @@ This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) __________________________________________________________________________ - begin : + begin : email : nguyentd@ornl.gov ***************************************************************************/ @@ -33,10 +33,10 @@ SoftT::Soft() : BaseAtomic(), _allocated(false) { } template -SoftT::~Soft() { +SoftT::~Soft() { clear(); } - + template int SoftT::bytes_per_atom(const int max_nbors) const { return this->bytes_per_atom_atomic(max_nbors); @@ -89,14 +89,14 @@ int SoftT::init(const int ntypes, double **host_cutsq, template void SoftT::reinit(const int ntypes, double **host_cutsq, double **host_prefactor, double **host_cut) { - + // Allocate a host write buffer for data initialization UCL_H_Vec host_write(_lj_types*_lj_types*32,*(this->ucl_device), UCL_WRITE_ONLY); - + for (int i=0; i<_lj_types*_lj_types; i++) host_write[i]=0.0; - + this->atom->type_pack4(ntypes,_lj_types,coeff,host_write,host_prefactor, host_cut,host_cutsq); } @@ -134,7 +134,7 @@ void SoftT::loop(const bool _eflag, const bool _vflag) { vflag=1; else vflag=0; - + int GX=static_cast(ceil(static_cast(this->ans->inum())/ (BX/this->_threads_per_atom))); diff --git a/lib/gpu/lal_soft.cu b/lib/gpu/lal_soft.cu index b7c32b6879..831b986725 100644 --- a/lib/gpu/lal_soft.cu +++ b/lib/gpu/lal_soft.cu @@ -9,7 +9,7 @@ // This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) // __________________________________________________________________________ // -// begin : +// begin : // email : nguyentd@ornl.gov // ***************************************************************************/ @@ -26,7 +26,7 @@ texture pos_tex; #define MY_PI (acctyp)3.14159265358979323846 -__kernel void k_soft(const __global numtyp4 *restrict x_, +__kernel void k_soft(const __global numtyp4 *restrict x_, const __global numtyp4 *restrict coeff, const int lj_types, const __global numtyp *restrict sp_lj_in, @@ -51,20 +51,20 @@ __kernel void k_soft(const __global numtyp4 *restrict x_, acctyp virial[6]; for (int i=0; i<6; i++) virial[i]=(acctyp)0; - + if (ii (numtyp)0.0) force = factor_lj * coeff[mtype].x * sin(arg) * MY_PI/coeff[mtype].y*ucl_recip(r); else force = (numtyp)0.0; - + f.x+=delx*force; f.y+=dely*force; f.z+=delz*force; if (eflag>0) { numtyp e=coeff[mtype].x * ((numtyp)1.0+cos(arg)); - energy+=factor_lj*e; + energy+=factor_lj*e; } if (vflag>0) { virial[0] += delx*delx*force; @@ -111,7 +111,7 @@ __kernel void k_soft(const __global numtyp4 *restrict x_, } // if ii } -__kernel void k_soft_fast(const __global numtyp4 *restrict x_, +__kernel void k_soft_fast(const __global numtyp4 *restrict x_, const __global numtyp4 *restrict coeff_in, const __global numtyp *restrict sp_lj_in, const __global int *dev_nbor, @@ -122,7 +122,7 @@ __kernel void k_soft_fast(const __global numtyp4 *restrict x_, const int nbor_pitch, const int t_per_atom) { int tid, ii, offset; atom_info(t_per_atom,ii,tid,offset); - + __local numtyp4 coeff[MAX_SHARED_TYPES*MAX_SHARED_TYPES]; __local numtyp sp_lj[4]; if (tid<4) @@ -130,7 +130,7 @@ __kernel void k_soft_fast(const __global numtyp4 *restrict x_, if (tid (numtyp)0.0) force = factor_lj * coeff[mtype].x * sin(arg) * MY_PI/coeff[mtype].y*ucl_recip(r); else force = (numtyp)0.0; - + f.x+=delx*force; f.y+=dely*force; f.z+=delz*force; if (eflag>0) { numtyp e=coeff[mtype].x * ((numtyp)1.0+cos(arg)); - energy+=factor_lj*e; + energy+=factor_lj*e; } if (vflag>0) { virial[0] += delx*delx*force; diff --git a/lib/gpu/lal_soft.h b/lib/gpu/lal_soft.h index 7fa529c4f5..e72673248c 100644 --- a/lib/gpu/lal_soft.h +++ b/lib/gpu/lal_soft.h @@ -9,7 +9,7 @@ This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) __________________________________________________________________________ - begin : + begin : email : nguyentd@ornl.gov ***************************************************************************/ @@ -24,13 +24,13 @@ template class Soft : public BaseAtomic { public: Soft(); - ~Soft(); + ~Soft(); /// Clear any previous data and set up for a new LAMMPS run /** \param max_nbors initial number of rows in the neighbor matrix * \param cell_size cutoff + skin * \param gpu_split fraction of particles handled by device - * + * * Returns: * - 0 if successfull * - -1 if fix gpu not found @@ -40,14 +40,14 @@ class Soft : public BaseAtomic { int init(const int ntypes, double **host_cutsq, double **host_prefactor, double **host_cut, double *host_special_lj, - const int nlocal, const int nall, const int max_nbors, - const int maxspecial, const double cell_size, + const int nlocal, const int nall, const int max_nbors, + const int maxspecial, const double cell_size, const double gpu_split, FILE *screen); /// Send updated coeffs from host to device (to be compatible with fix adapt) void reinit(const int ntypes, double **host_cutsq, double **host_prefactor, double **host_cut); - + /// Clear all host and device data /** \note This is called at the beginning of the init() routine **/ void clear(); @@ -68,7 +68,7 @@ class Soft : public BaseAtomic { /// If atom type constants fit in shared memory, use fast kßernels bool shared_types; - /// Number of atom types + /// Number of atom types int _lj_types; private: diff --git a/lib/gpu/lal_soft_ext.cpp b/lib/gpu/lal_soft_ext.cpp index 9591923965..441fe35839 100644 --- a/lib/gpu/lal_soft_ext.cpp +++ b/lib/gpu/lal_soft_ext.cpp @@ -9,7 +9,7 @@ This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) __________________________________________________________________________ - begin : + begin : email : nguyentd@ornl.gov ***************************************************************************/ @@ -77,7 +77,7 @@ int soft_gpu_init(const int ntypes, double **cutsq, double **host_prefactor, cell_size, gpu_split, screen); SLMF.device->gpu_barrier(); - if (message) + if (message) fprintf(screen,"Done.\n"); } if (message) @@ -96,16 +96,16 @@ void soft_gpu_reinit(const int ntypes, double **cutsq, double **host_prefactor, int world_me=SLMF.device->world_me(); int gpu_rank=SLMF.device->gpu_rank(); int procs_per_gpu=SLMF.device->procs_per_gpu(); - + if (world_me==0) SLMF.reinit(ntypes, cutsq, host_prefactor, host_cut); - + SLMF.device->world_barrier(); - + for (int i=0; igpu_barrier(); } } @@ -124,7 +124,7 @@ int ** soft_gpu_compute_n(const int ago, const int inum_full, return SLMF.compute(ago, inum_full, nall, host_x, host_type, sublo, subhi, tag, nspecial, special, eflag, vflag, eatom, vatom, host_start, ilist, jnum, cpu_time, success); -} +} void soft_gpu_compute(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, int *ilist, int *numj, diff --git a/lib/gpu/lal_sw_ext.cpp b/lib/gpu/lal_sw_ext.cpp index e2d1b5e4dd..8cb51307a1 100644 --- a/lib/gpu/lal_sw_ext.cpp +++ b/lib/gpu/lal_sw_ext.cpp @@ -27,14 +27,14 @@ static SW SWMF; // --------------------------------------------------------------------------- // Allocate memory on host and device and copy constants to device // --------------------------------------------------------------------------- -int sw_gpu_init(const int ntypes, const int inum, const int nall, const int max_nbors, +int sw_gpu_init(const int ntypes, const int inum, const int nall, const int max_nbors, const double cell_size, int &gpu_mode, FILE *screen, int* host_map, const int nelements, int*** host_elem2param, const int nparams, const double* sw_epsilon, const double* sw_sigma, const double* sw_lambda, const double* sw_gamma, const double* sw_costheta, const double* sw_biga, const double* sw_bigb, const double* sw_powerp, - const double* sw_powerq, const double* sw_cut, + const double* sw_powerq, const double* sw_cut, const double* sw_cutsq) { SWMF.clear(); gpu_mode=SWMF.device->gpu_mode(); @@ -46,7 +46,7 @@ int sw_gpu_init(const int ntypes, const int inum, const int nall, const int max_ int procs_per_gpu=SWMF.device->procs_per_gpu(); // disable host/device split for now - if (gpu_split != 1.0) + if (gpu_split != 1.0) return -8; SWMF.device->init_message(screen,"sw/gpu",first_gpu,last_gpu); @@ -64,7 +64,7 @@ int sw_gpu_init(const int ntypes, const int inum, const int nall, const int max_ if (world_me==0) init_ok=SWMF.init(ntypes, inum, nall, 300, cell_size, gpu_split, screen, host_map, nelements, host_elem2param, nparams, - sw_epsilon, sw_sigma, sw_lambda, sw_gamma, sw_costheta, + sw_epsilon, sw_sigma, sw_lambda, sw_gamma, sw_costheta, sw_biga, sw_bigb, sw_powerp, sw_powerq, sw_cut, sw_cutsq); SWMF.device->world_barrier(); @@ -83,12 +83,12 @@ int sw_gpu_init(const int ntypes, const int inum, const int nall, const int max_ if (gpu_rank==i && world_me!=0) init_ok=SWMF.init(ntypes, inum, nall, 300, cell_size, gpu_split, screen, host_map, nelements, host_elem2param, nparams, - sw_epsilon, sw_sigma, sw_lambda, sw_gamma, sw_costheta, - sw_biga, sw_bigb, sw_powerp, sw_powerq, sw_cut, + sw_epsilon, sw_sigma, sw_lambda, sw_gamma, sw_costheta, + sw_biga, sw_bigb, sw_powerp, sw_powerq, sw_cut, sw_cutsq); SWMF.device->gpu_barrier(); - if (message) + if (message) fprintf(screen,"Done.\n"); } if (message) @@ -113,12 +113,12 @@ int ** sw_gpu_compute_n(const int ago, const int inum_full, return SWMF.compute(ago, inum_full, nall, host_x, host_type, sublo, subhi, tag, nspecial, special, eflag, vflag, eatom, vatom, host_start, ilist, jnum, cpu_time, success); -} +} -void sw_gpu_compute(const int ago, const int nlocal, const int nall, - const int nlist, double **host_x, int *host_type, - int *ilist, int *numj, int **firstneigh, const bool eflag, - const bool vflag, const bool eatom, const bool vatom, +void sw_gpu_compute(const int ago, const int nlocal, const int nall, + const int nlist, double **host_x, int *host_type, + int *ilist, int *numj, int **firstneigh, const bool eflag, + const bool vflag, const bool eatom, const bool vatom, int &host_start, const double cpu_time, bool &success) { SWMF.compute(ago,nlocal,nall,nlist,host_x,host_type,ilist,numj, firstneigh,eflag,vflag,eatom,vatom,host_start,cpu_time,success); diff --git a/lib/gpu/lal_table.cpp b/lib/gpu/lal_table.cpp index c99bf85815..0de59c84b2 100644 --- a/lib/gpu/lal_table.cpp +++ b/lib/gpu/lal_table.cpp @@ -9,7 +9,7 @@ This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) __________________________________________________________________________ - begin : + begin : email : nguyentd@ornl.gov ***************************************************************************/ @@ -34,35 +34,35 @@ using namespace LAMMPS_AL; extern Device device; template -TableT::Table() : BaseAtomic(), +TableT::Table() : BaseAtomic(), _allocated(false), _compiled_styles(false) { } template -TableT::~Table() { +TableT::~Table() { clear(); } - + template int TableT::bytes_per_atom(const int max_nbors) const { return this->bytes_per_atom_atomic(max_nbors); } template -int TableT::init(const int ntypes, +int TableT::init(const int ntypes, double **host_cutsq, double ***host_table_coeffs, double **host_table_data, double *host_special_lj, const int nlocal, const int nall, const int max_nbors, const int maxspecial, const double cell_size, - const double gpu_split, FILE *_screen, + const double gpu_split, FILE *_screen, int tabstyle, int ntables, int tablength) { int success; success=this->init_atomic(nlocal,nall,max_nbors,maxspecial,cell_size, gpu_split,_screen,table,"k_table"); if (success!=0) return success; - + k_pair_linear.set_function(*(this->pair_program),"k_table_linear"); k_pair_linear_fast.set_function(*(this->pair_program),"k_table_linear_fast"); k_pair_spline.set_function(*(this->pair_program),"k_table_spline"); @@ -80,38 +80,38 @@ int TableT::init(const int ntypes, shared_types=true; } _lj_types=lj_types; - + _tabstyle = tabstyle; _ntables = ntables; if (tabstyle != BITMAP) _tablength = tablength; else _tablength = 1 << tablength; - + // Allocate a host write buffer for data initialization UCL_H_Vec host_write_int(lj_types*lj_types,*(this->ucl_device), UCL_WRITE_ONLY); - for (int i=0; iucl_device),UCL_READ_ONLY); nshiftbits.alloc(lj_types*lj_types,*(this->ucl_device),UCL_READ_ONLY); nmask.alloc(lj_types*lj_types,*(this->ucl_device),UCL_READ_ONLY); for (int ix=1; ix host_write(lj_types*lj_types,*(this->ucl_device), UCL_WRITE_ONLY); @@ -151,7 +151,7 @@ int TableT::init(const int ntypes, host_write2[n*_tablength+k].z = host_table_data[n][6*k+2]; // f host_write2[n*_tablength+k].w = (numtyp)0; } - } + } } ucl_copy(coeff3,host_write2,false); @@ -166,21 +166,21 @@ int TableT::init(const int ntypes, for (int n=0; n<_ntables; n++) { if (tabstyle == LINEAR) { for (int k=0; k<_tablength-1; k++) { - host_write2[n*_tablength+k].x = (numtyp)0; + host_write2[n*_tablength+k].x = (numtyp)0; host_write2[n*_tablength+k].y = host_table_data[n][6*k+3]; // de host_write2[n*_tablength+k].z = host_table_data[n][6*k+4]; // df host_write2[n*_tablength+k].w = (numtyp)0; } } else if (tabstyle == SPLINE) { for (int k=0; k<_tablength; k++) { - host_write2[n*_tablength+k].x = (numtyp)0; + host_write2[n*_tablength+k].x = (numtyp)0; host_write2[n*_tablength+k].y = host_table_data[n][6*k+3]; // e2 host_write2[n*_tablength+k].z = host_table_data[n][6*k+4]; // f2 host_write2[n*_tablength+k].w = (numtyp)0; } } else if (tabstyle == BITMAP) { for (int k=0; k<_tablength; k++) { - host_write2[n*_tablength+k].x = (numtyp)0; + host_write2[n*_tablength+k].x = (numtyp)0; host_write2[n*_tablength+k].y = host_table_data[n][6*k+3]; // de host_write2[n*_tablength+k].z = host_table_data[n][6*k+4]; // df host_write2[n*_tablength+k].w = host_table_data[n][6*k+5]; // drsq @@ -188,12 +188,12 @@ int TableT::init(const int ntypes, } } ucl_copy(coeff4,host_write2,false); - + UCL_H_Vec host_rsq(lj_types*lj_types,*(this->ucl_device), UCL_WRITE_ONLY); cutsq.alloc(lj_types*lj_types,*(this->ucl_device),UCL_READ_ONLY); this->atom->type_pack1(ntypes,lj_types,cutsq,host_rsq,host_cutsq); - + UCL_H_Vec dview; sp_lj.alloc(4,*(this->ucl_device),UCL_READ_ONLY); dview.view(host_special_lj,4,*(this->ucl_device)); @@ -220,7 +220,7 @@ void TableT::clear() { coeff3.clear(); coeff4.clear(); sp_lj.clear(); - + if (_compiled_styles) { k_pair_linear_fast.clear(); k_pair_linear.clear(); @@ -230,7 +230,7 @@ void TableT::clear() { k_pair_bitmap.clear(); _compiled_styles=false; } - + this->clear_atomic(); } @@ -256,7 +256,7 @@ void TableT::loop(const bool _eflag, const bool _vflag) { vflag=1; else vflag=0; - + int GX=static_cast(ceil(static_cast(this->ans->inum())/ (BX/this->_threads_per_atom))); @@ -269,67 +269,67 @@ void TableT::loop(const bool _eflag, const bool _vflag) { this->k_pair_fast.run(&this->atom->x, &tabindex, &coeff2, &coeff3, &coeff4, &cutsq, &sp_lj, &this->nbor->dev_nbor, &this->_nbor_data->begin(), &this->ans->force, - &this->ans->engv, &eflag, &vflag, &ainum, + &this->ans->engv, &eflag, &vflag, &ainum, &nbor_pitch, &this->_threads_per_atom, &_tablength); } else if (_tabstyle == LINEAR) { this->k_pair_linear_fast.set_size(GX,BX); - this->k_pair_linear_fast.run(&this->atom->x, &tabindex, &coeff2, + this->k_pair_linear_fast.run(&this->atom->x, &tabindex, &coeff2, &coeff3, &coeff4, &cutsq, &sp_lj, &this->nbor->dev_nbor, &this->_nbor_data->begin(), &this->ans->force, &this->ans->engv, - &eflag, &vflag, &ainum, &nbor_pitch, + &eflag, &vflag, &ainum, &nbor_pitch, &this->_threads_per_atom, &_tablength); } else if (_tabstyle == SPLINE) { this->k_pair_spline_fast.set_size(GX,BX); - this->k_pair_spline_fast.run(&this->atom->x, &tabindex, &coeff2, + this->k_pair_spline_fast.run(&this->atom->x, &tabindex, &coeff2, &coeff3, &coeff4, &cutsq, &sp_lj, &this->nbor->dev_nbor, &this->_nbor_data->begin(), &this->ans->force, &this->ans->engv, - &eflag, &vflag, &ainum, &nbor_pitch, + &eflag, &vflag, &ainum, &nbor_pitch, &this->_threads_per_atom, &_tablength); } else if (_tabstyle == BITMAP) { this->k_pair_bitmap_fast.set_size(GX,BX); this->k_pair_bitmap_fast.run(&this->atom->x, &tabindex, &nshiftbits, &nmask, &coeff2, &coeff3, &coeff4, &cutsq, - &sp_lj, &this->nbor->dev_nbor, + &sp_lj, &this->nbor->dev_nbor, &this->_nbor_data->begin(), &this->ans->force, &this->ans->engv, &eflag, &vflag, - &ainum, &nbor_pitch, + &ainum, &nbor_pitch, &this->_threads_per_atom, &_tablength); - } + } } else { if (_tabstyle == LOOKUP) { this->k_pair.set_size(GX,BX); - this->k_pair.run(&this->atom->x, &tabindex, &coeff2, &coeff3, - &coeff4, &_lj_types, &cutsq, &sp_lj, + this->k_pair.run(&this->atom->x, &tabindex, &coeff2, &coeff3, + &coeff4, &_lj_types, &cutsq, &sp_lj, &this->nbor->dev_nbor, &this->_nbor_data->begin(), - &this->ans->force, &this->ans->engv, &eflag, + &this->ans->force, &this->ans->engv, &eflag, &vflag, &ainum, &nbor_pitch, &this->_threads_per_atom, &_tablength); } else if (_tabstyle == LINEAR) { this->k_pair_linear.set_size(GX,BX); this->k_pair_linear.run(&this->atom->x, &tabindex, &coeff2, &coeff3, - &coeff4, &_lj_types, &cutsq, &sp_lj, + &coeff4, &_lj_types, &cutsq, &sp_lj, &this->nbor->dev_nbor, &this->_nbor_data->begin(), &this->ans->force, &this->ans->engv, &eflag, - &vflag, &ainum, &nbor_pitch, + &vflag, &ainum, &nbor_pitch, &this->_threads_per_atom, &_tablength); } else if (_tabstyle == SPLINE) { this->k_pair_spline.set_size(GX,BX); this->k_pair_spline.run(&this->atom->x, &tabindex, &coeff2, &coeff3, - &coeff4, &_lj_types, &cutsq, &sp_lj, - &this->nbor->dev_nbor, &this->_nbor_data->begin(), + &coeff4, &_lj_types, &cutsq, &sp_lj, + &this->nbor->dev_nbor, &this->_nbor_data->begin(), &this->ans->force, &this->ans->engv, &eflag, - &vflag, &ainum, &nbor_pitch, + &vflag, &ainum, &nbor_pitch, &this->_threads_per_atom, &_tablength); } else if (_tabstyle == BITMAP) { this->k_pair_bitmap.set_size(GX,BX); - this->k_pair_bitmap.run(&this->atom->x, &tabindex, &nshiftbits, + this->k_pair_bitmap.run(&this->atom->x, &tabindex, &nshiftbits, &nmask, &coeff2, &coeff3, &coeff4, &_lj_types, &cutsq, &sp_lj, &this->nbor->dev_nbor, &this->_nbor_data->begin(), &this->ans->force, &this->ans->engv, &eflag, &vflag, &ainum, - &nbor_pitch, &this->_threads_per_atom, + &nbor_pitch, &this->_threads_per_atom, &_tablength); } } diff --git a/lib/gpu/lal_table.cu b/lib/gpu/lal_table.cu index 1033b7fbb8..971b56d96e 100644 --- a/lib/gpu/lal_table.cu +++ b/lib/gpu/lal_table.cu @@ -9,7 +9,7 @@ // This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) // __________________________________________________________________________ // -// begin : +// begin : // email : nguyentd@ornl.gov // ***************************************************************************/ @@ -39,39 +39,39 @@ typedef union { /// ---------------- LOOKUP ------------------------------------------------- -__kernel void k_table(const __global numtyp4 *restrict x_, +__kernel void k_table(const __global numtyp4 *restrict x_, const __global int *restrict tabindex, - const __global numtyp4 *restrict coeff2, + const __global numtyp4 *restrict coeff2, const __global numtyp4 *restrict coeff3, const __global numtyp4 *restrict coeff4, const int lj_types, const __global numtyp *restrict cutsq, - const __global numtyp *restrict sp_lj_in, - const __global int *dev_nbor, - const __global int *dev_packed, - __global acctyp4 *restrict ans, - __global acctyp *restrict engv, - const int eflag, const int vflag, const int inum, - const int nbor_pitch, const int t_per_atom, + const __global numtyp *restrict sp_lj_in, + const __global int *dev_nbor, + const __global int *dev_packed, + __global acctyp4 *restrict ans, + __global acctyp *restrict engv, + const int eflag, const int vflag, const int inum, + const int nbor_pitch, const int t_per_atom, int tablength) { int tid, ii, offset; atom_info(t_per_atom,ii,tid,offset); - + __local numtyp sp_lj[4]; sp_lj[0]=sp_lj_in[0]; sp_lj[1]=sp_lj_in[1]; sp_lj[2]=sp_lj_in[2]; sp_lj[3]=sp_lj_in[3]; - + acctyp energy=(acctyp)0; acctyp4 f; f.x=(acctyp)0; f.y=(acctyp)0; f.z=(acctyp)0; acctyp virial[6]; for (int i=0; i<6; i++) virial[i]=(acctyp)0; - + int tlm1 = tablength - 1; - + if (ii0) { numtyp e = (numtyp)0.0; - if (itable < tlm1) + if (itable < tlm1) e = coeff3[idx].y; energy+=factor_lj*e; } @@ -136,21 +136,21 @@ __kernel void k_table(const __global numtyp4 *restrict x_, __kernel void k_table_fast(const __global numtyp4 *restrict x_, const __global int *restrict tabindex, - const __global numtyp4 *restrict coeff2, + const __global numtyp4 *restrict coeff2, const __global numtyp4 *restrict coeff3, const __global numtyp4 *restrict coeff4, const __global numtyp *restrict cutsq_in, - const __global numtyp *restrict sp_lj_in, - const __global int *dev_nbor, - const __global int *dev_packed, - __global acctyp4 *restrict ans, - __global acctyp *restrict engv, - const int eflag, const int vflag, const int inum, - const int nbor_pitch, const int t_per_atom, + const __global numtyp *restrict sp_lj_in, + const __global int *dev_nbor, + const __global int *dev_packed, + __global acctyp4 *restrict ans, + __global acctyp *restrict engv, + const int eflag, const int vflag, const int inum, + const int nbor_pitch, const int t_per_atom, int tablength) { int tid, ii, offset; atom_info(t_per_atom,ii,tid,offset); - + __local numtyp cutsq[MAX_SHARED_TYPES*MAX_SHARED_TYPES]; __local numtyp sp_lj[4]; if (tid<4) @@ -158,18 +158,18 @@ __kernel void k_table_fast(const __global numtyp4 *restrict x_, if (tid0) { numtyp e = (numtyp)0.0; - if (itable < tlm1) + if (itable < tlm1) e = coeff3[idx].y; energy+=factor_lj*e; } @@ -235,24 +235,24 @@ __kernel void k_table_fast(const __global numtyp4 *restrict x_, /// ---------------- LINEAR ------------------------------------------------- -__kernel void k_table_linear(const __global numtyp4 *restrict x_, +__kernel void k_table_linear(const __global numtyp4 *restrict x_, const __global int *restrict tabindex, - const __global numtyp4 *restrict coeff2, + const __global numtyp4 *restrict coeff2, const __global numtyp4 *restrict coeff3, const __global numtyp4 *restrict coeff4, const int lj_types, const __global numtyp *restrict cutsq, - const __global numtyp *restrict sp_lj_in, - const __global int *dev_nbor, - const __global int *dev_packed, - __global acctyp4 *restrict ans, - __global acctyp *restrict engv, - const int eflag, const int vflag, const int inum, - const int nbor_pitch, const int t_per_atom, + const __global numtyp *restrict sp_lj_in, + const __global int *dev_nbor, + const __global int *dev_packed, + __global acctyp4 *restrict ans, + __global acctyp *restrict engv, + const int eflag, const int vflag, const int inum, + const int nbor_pitch, const int t_per_atom, int tablength) { int tid, ii, offset; atom_info(t_per_atom,ii,tid,offset); - + __local numtyp sp_lj[4]; sp_lj[0]=sp_lj_in[0]; sp_lj[1]=sp_lj_in[1]; @@ -265,9 +265,9 @@ __kernel void k_table_linear(const __global numtyp4 *restrict x_, acctyp virial[6]; for (int i=0; i<6; i++) virial[i]=(acctyp)0; - + int tlm1 = tablength - 1; - + if (ii0) { numtyp e = (numtyp)0.0; - if (itable < tlm1) + if (itable < tlm1) e = coeff3[idx].y + fraction*coeff4[idx].y; energy+=factor_lj*e; } @@ -334,23 +334,23 @@ __kernel void k_table_linear(const __global numtyp4 *restrict x_, } // if ii } -__kernel void k_table_linear_fast(const __global numtyp4 *restrict x_, +__kernel void k_table_linear_fast(const __global numtyp4 *restrict x_, const __global int *restrict tabindex, - const __global numtyp4 *restrict coeff2, + const __global numtyp4 *restrict coeff2, const __global numtyp4 *restrict coeff3, const __global numtyp4 *restrict coeff4, const __global numtyp *restrict cutsq_in, - const __global numtyp *restrict sp_lj_in, - const __global int *dev_nbor, - const __global int *dev_packed, - __global acctyp4 *restrict ans, - __global acctyp *restrict engv, - const int eflag, const int vflag, - const int inum, const int nbor_pitch, + const __global numtyp *restrict sp_lj_in, + const __global int *dev_nbor, + const __global int *dev_packed, + __global acctyp4 *restrict ans, + __global acctyp *restrict engv, + const int eflag, const int vflag, + const int inum, const int nbor_pitch, const int t_per_atom, int tablength) { int tid, ii, offset; atom_info(t_per_atom,ii,tid,offset); - + __local numtyp cutsq[MAX_SHARED_TYPES*MAX_SHARED_TYPES]; __local numtyp sp_lj[4]; if (tid<4) @@ -358,7 +358,7 @@ __kernel void k_table_linear_fast(const __global numtyp4 *restrict x_, if (tid0) { numtyp e = (numtyp)0.0; - if (itable < tlm1) + if (itable < tlm1) e = coeff3[idx].y + fraction*coeff4[idx].y; energy+=factor_lj*e; } @@ -439,39 +439,39 @@ __kernel void k_table_linear_fast(const __global numtyp4 *restrict x_, /// ---------------- SPLINE ------------------------------------------------- -__kernel void k_table_spline(const __global numtyp4 *restrict x_, +__kernel void k_table_spline(const __global numtyp4 *restrict x_, const __global int *restrict tabindex, - const __global numtyp4 *restrict coeff2, + const __global numtyp4 *restrict coeff2, const __global numtyp4 *restrict coeff3, const __global numtyp4 *restrict coeff4, const int lj_types, const __global numtyp *restrict cutsq, - const __global numtyp *restrict sp_lj_in, - const __global int *dev_nbor, - const __global int *dev_packed, - __global acctyp4 *restrict ans, - __global acctyp *restrict engv, - const int eflag, const int vflag, const int inum, - const int nbor_pitch, const int t_per_atom, + const __global numtyp *restrict sp_lj_in, + const __global int *dev_nbor, + const __global int *dev_packed, + __global acctyp4 *restrict ans, + __global acctyp *restrict engv, + const int eflag, const int vflag, const int inum, + const int nbor_pitch, const int t_per_atom, int tablength) { int tid, ii, offset; atom_info(t_per_atom,ii,tid,offset); - + __local numtyp sp_lj[4]; sp_lj[0]=sp_lj_in[0]; sp_lj[1]=sp_lj_in[1]; sp_lj[2]=sp_lj_in[2]; sp_lj[3]=sp_lj_in[3]; - + acctyp energy=(acctyp)0; acctyp4 f; f.x=(acctyp)0; f.y=(acctyp)0; f.z=(acctyp)0; acctyp virial[6]; for (int i=0; i<6; i++) virial[i]=(acctyp)0; - + int tlm1 = tablength - 1; - + if (ii0) { numtyp e = (numtyp)0.0; if (itable < tlm1) { - e = a * coeff3[idx].y + b * coeff3[idx+1].y + - ((a*a*a-a)*coeff4[idx].y + (b*b*b-b)*coeff4[idx+1].y) * + e = a * coeff3[idx].y + b * coeff3[idx+1].y + + ((a*a*a-a)*coeff4[idx].y + (b*b*b-b)*coeff4[idx+1].y) * coeff2[mtype].z; - } + } energy+=factor_lj*e; } if (vflag>0) { @@ -545,23 +545,23 @@ __kernel void k_table_spline(const __global numtyp4 *restrict x_, } // if ii } -__kernel void k_table_spline_fast(const __global numtyp4 *x_, +__kernel void k_table_spline_fast(const __global numtyp4 *x_, const __global int *tabindex, - const __global numtyp4* coeff2, + const __global numtyp4* coeff2, const __global numtyp4 *coeff3, const __global numtyp4 *coeff4, const __global numtyp *cutsq_in, - const __global numtyp* sp_lj_in, - const __global int *dev_nbor, - const __global int *dev_packed, - __global acctyp4 *ans, - __global acctyp *engv, - const int eflag, const int vflag, - const int inum, const int nbor_pitch, + const __global numtyp* sp_lj_in, + const __global int *dev_nbor, + const __global int *dev_packed, + __global acctyp4 *ans, + __global acctyp *engv, + const int eflag, const int vflag, + const int inum, const int nbor_pitch, const int t_per_atom, int tablength) { int tid, ii, offset; atom_info(t_per_atom,ii,tid,offset); - + __local numtyp cutsq[MAX_SHARED_TYPES*MAX_SHARED_TYPES]; __local numtyp sp_lj[4]; if (tid<4) @@ -569,7 +569,7 @@ __kernel void k_table_spline_fast(const __global numtyp4 *x_, if (tid0) { numtyp e = (numtyp)0.0; if (itable < tlm1) { - e = a * coeff3[idx].y + b * coeff3[idx+1].y + - ((a*a*a-a)*coeff4[idx].y + (b*b*b-b)*coeff4[idx+1].y) * + e = a * coeff3[idx].y + b * coeff3[idx+1].y + + ((a*a*a-a)*coeff4[idx].y + (b*b*b-b)*coeff4[idx+1].y) * coeff2[mtype].z; - } + } energy+=factor_lj*e; } if (vflag>0) { @@ -657,41 +657,41 @@ __kernel void k_table_spline_fast(const __global numtyp4 *x_, /// ---------------- BITMAP ------------------------------------------------- -__kernel void k_table_bitmap(const __global numtyp4 *x_, +__kernel void k_table_bitmap(const __global numtyp4 *x_, const __global int *tabindex, - const __global int *nshiftbits, + const __global int *nshiftbits, const __global int *nmask, - const __global numtyp4* coeff2, + const __global numtyp4* coeff2, const __global numtyp4 *coeff3, const __global numtyp4 *coeff4, const int lj_types, const __global numtyp *cutsq, - const __global numtyp* sp_lj_in, - const __global int *dev_nbor, - const __global int *dev_packed, - __global acctyp4 *ans, - __global acctyp *engv, - const int eflag, const int vflag, const int inum, - const int nbor_pitch, const int t_per_atom, + const __global numtyp* sp_lj_in, + const __global int *dev_nbor, + const __global int *dev_packed, + __global acctyp4 *ans, + __global acctyp *engv, + const int eflag, const int vflag, const int inum, + const int nbor_pitch, const int t_per_atom, int tablength) { int tid, ii, offset; atom_info(t_per_atom,ii,tid,offset); - + __local numtyp sp_lj[4]; sp_lj[0]=sp_lj_in[0]; sp_lj[1]=sp_lj_in[1]; sp_lj[2]=sp_lj_in[2]; sp_lj[3]=sp_lj_in[3]; - + acctyp energy=(acctyp)0; acctyp4 f; f.x=(acctyp)0; f.y=(acctyp)0; f.z=(acctyp)0; acctyp virial[6]; for (int i=0; i<6; i++) virial[i]=(acctyp)0; - + int tlm1 = tablength - 1; - + if (ii>= nshiftbits[mtype]; @@ -734,14 +734,14 @@ __kernel void k_table_bitmap(const __global numtyp4 *x_, value = coeff3[idx].z + fraction*coeff4[idx].z; force = factor_lj * value; } else force = (numtyp)0.0; - + f.x+=delx*force; f.y+=dely*force; f.z+=delz*force; if (eflag>0) { numtyp e = (numtyp)0.0; - if (itable <= tlm1) + if (itable <= tlm1) e = coeff3[idx].y + fraction*coeff4[idx].y; energy+=factor_lj*e; } @@ -761,25 +761,25 @@ __kernel void k_table_bitmap(const __global numtyp4 *x_, } // if ii } -__kernel void k_table_bitmap_fast(const __global numtyp4 *x_, +__kernel void k_table_bitmap_fast(const __global numtyp4 *x_, const __global int *tabindex, - const __global int *nshiftbits, + const __global int *nshiftbits, const __global int *nmask, - const __global numtyp4* coeff2, + const __global numtyp4* coeff2, const __global numtyp4 *coeff3, const __global numtyp4 *coeff4, const __global numtyp *cutsq_in, - const __global numtyp* sp_lj_in, - const __global int *dev_nbor, - const __global int *dev_packed, - __global acctyp4 *ans, - __global acctyp *engv, - const int eflag, const int vflag, - const int inum, const int nbor_pitch, + const __global numtyp* sp_lj_in, + const __global int *dev_nbor, + const __global int *dev_packed, + __global acctyp4 *ans, + __global acctyp *engv, + const int eflag, const int vflag, + const int inum, const int nbor_pitch, const int t_per_atom, int tablength) { int tid, ii, offset; atom_info(t_per_atom,ii,tid,offset); - + __local numtyp cutsq[MAX_SHARED_TYPES*MAX_SHARED_TYPES]; __local numtyp sp_lj[4]; if (tid<4) @@ -787,18 +787,18 @@ __kernel void k_table_bitmap_fast(const __global numtyp4 *x_, if (tid>= nshiftbits[mtype]; @@ -842,14 +842,14 @@ __kernel void k_table_bitmap_fast(const __global numtyp4 *x_, value = coeff3[idx].z + fraction*coeff4[idx].z; force = factor_lj * value; } else force = (numtyp)0.0; - + f.x+=delx*force; f.y+=dely*force; f.z+=delz*force; if (eflag>0) { numtyp e = (numtyp)0.0; - if (itable <= tlm1) + if (itable <= tlm1) e = coeff3[idx].y + fraction*coeff4[idx].y; energy+=factor_lj*e; } diff --git a/lib/gpu/lal_table.h b/lib/gpu/lal_table.h index 0e04737d27..f667336679 100644 --- a/lib/gpu/lal_table.h +++ b/lib/gpu/lal_table.h @@ -9,7 +9,7 @@ This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) __________________________________________________________________________ - begin : + begin : email : nguyentd@ornl.gov ***************************************************************************/ @@ -24,13 +24,13 @@ template class Table : public BaseAtomic { public: Table(); - ~Table(); + ~Table(); /// Clear any previous data and set up for a new LAMMPS run /** \param max_nbors initial number of rows in the neighbor matrix * \param cell_size cutoff + skin * \param gpu_split fraction of particles handled by device - * + * * Returns: * - 0 if successfull * - -1 if fix gpu not found @@ -38,10 +38,10 @@ class Table : public BaseAtomic { * - -4 if the GPU library was not compiled for GPU * - -5 Double precision is not supported on card **/ int init(const int ntypes, double** cutsq, double ***host_table_coeffs, - double **host_table_data, + double **host_table_data, double *host_special_lj, - const int nlocal, const int nall, const int max_nbors, - const int maxspecial, const double cell_size, + const int nlocal, const int nall, const int max_nbors, + const int maxspecial, const double cell_size, const double gpu_split, FILE *screen, int tabstyle, int ntables, int tablength); @@ -54,42 +54,42 @@ class Table : public BaseAtomic { /// Total host memory used by library for pair style double host_memory_usage() const; - + // ------------------------- DEVICE KERNELS ------------------------- UCL_Kernel k_pair_linear, k_pair_linear_fast; UCL_Kernel k_pair_spline, k_pair_spline_fast; UCL_Kernel k_pair_bitmap, k_pair_bitmap_fast; - + // --------------------------- TYPE DATA -------------------------- UCL_D_Vec tabindex, nshiftbits, nmask; - - /// coeff2.x = innersq, coeff2.y = invdelta, coeff2.z = deltasq6, + + /// coeff2.x = innersq, coeff2.y = invdelta, coeff2.z = deltasq6, UCL_D_Vec coeff2; - + /// coeff3.x = rsq, coeff3.y = e, coeff3.z = f UCL_D_Vec coeff3; - + /// coeff4.x = de, coeff4.y = df UCL_D_Vec coeff4; - + UCL_D_Vec cutsq; - + /// Special LJ values UCL_D_Vec sp_lj; /// If atom type constants fit in shared memory, use fast kernels bool shared_types; - /// Number of atom types + /// Number of atom types int _lj_types; - + /// Table style, length and number of tables int _tabstyle,_tablength,_ntables; - + private: bool _allocated, _compiled_styles; - + void loop(const bool _eflag, const bool _vflag); }; diff --git a/lib/gpu/lal_table_ext.cpp b/lib/gpu/lal_table_ext.cpp index 172acb7d39..4eb7e0ce1b 100644 --- a/lib/gpu/lal_table_ext.cpp +++ b/lib/gpu/lal_table_ext.cpp @@ -9,7 +9,7 @@ This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) __________________________________________________________________________ - begin : + begin : email : nguyentd@ornl.gov ***************************************************************************/ @@ -30,7 +30,7 @@ static Table TBMF; int table_gpu_init(const int ntypes, double **cutsq, double ***table_coeffs, double **table_data, double *special_lj, const int inum, const int nall, const int max_nbors, const int maxspecial, - const double cell_size, int &gpu_mode, FILE *screen, + const double cell_size, int &gpu_mode, FILE *screen, int tabstyle, int ntables, int tablength) { TBMF.clear(); gpu_mode=TBMF.device->gpu_mode(); @@ -55,7 +55,7 @@ int table_gpu_init(const int ntypes, double **cutsq, double ***table_coeffs, int init_ok=0; if (world_me==0) init_ok=TBMF.init(ntypes, cutsq, table_coeffs, table_data, - special_lj, inum, nall, 300, maxspecial, cell_size, + special_lj, inum, nall, 300, maxspecial, cell_size, gpu_split, screen, tabstyle, ntables, tablength); TBMF.device->world_barrier(); @@ -73,11 +73,11 @@ int table_gpu_init(const int ntypes, double **cutsq, double ***table_coeffs, } if (gpu_rank==i && world_me!=0) init_ok=TBMF.init(ntypes, cutsq, table_coeffs, table_data, - special_lj, inum, nall, 300, maxspecial, cell_size, + special_lj, inum, nall, 300, maxspecial, cell_size, gpu_split, screen, tabstyle, ntables, tablength); TBMF.device->gpu_barrier(); - if (message) + if (message) fprintf(screen,"Done.\n"); } if (message) @@ -102,7 +102,7 @@ int ** table_gpu_compute_n(const int ago, const int inum_full, return TBMF.compute(ago, inum_full, nall, host_x, host_type, sublo, subhi, tag, nspecial, special, eflag, vflag, eatom, vatom, host_start, ilist, jnum, cpu_time, success); -} +} void table_gpu_compute(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, int *ilist, int *numj, diff --git a/lib/gpu/lal_yukawa.cpp b/lib/gpu/lal_yukawa.cpp index 585dc069a0..88cb8cdb3c 100644 --- a/lib/gpu/lal_yukawa.cpp +++ b/lib/gpu/lal_yukawa.cpp @@ -9,7 +9,7 @@ This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) __________________________________________________________________________ - begin : + begin : email : nguyentd@ornl.gov ***************************************************************************/ @@ -33,19 +33,19 @@ YukawaT::Yukawa() : BaseAtomic(), _allocated(false) { } template -YukawaT::~Yukawa() { +YukawaT::~Yukawa() { clear(); } - + template int YukawaT::bytes_per_atom(const int max_nbors) const { return this->bytes_per_atom_atomic(max_nbors); } template -int YukawaT::init(const int ntypes, +int YukawaT::init(const int ntypes, double **host_cutsq, double kappa, - double **host_a, double **host_offset, + double **host_a, double **host_offset, double *host_special_lj, const int nlocal, const int nall, const int max_nbors, const int maxspecial, const double cell_size, @@ -83,7 +83,7 @@ int YukawaT::init(const int ntypes, ucl_copy(sp_lj,dview,false); _kappa = kappa; - + _allocated=true; this->_max_bytes=coeff.row_bytes()+sp_lj.row_bytes(); return 0; @@ -122,7 +122,7 @@ void YukawaT::loop(const bool _eflag, const bool _vflag) { vflag=1; else vflag=0; - + int GX=static_cast(ceil(static_cast(this->ans->inum())/ (BX/this->_threads_per_atom))); @@ -134,7 +134,7 @@ void YukawaT::loop(const bool _eflag, const bool _vflag) { this->k_pair_fast.run(&this->atom->x, &coeff, &_kappa, &sp_lj, &this->nbor->dev_nbor, &this->_nbor_data->begin(), &this->ans->force, &this->ans->engv, &eflag, - &vflag, &ainum, &nbor_pitch, + &vflag, &ainum, &nbor_pitch, &this->_threads_per_atom); } else { this->k_pair.set_size(GX,BX); diff --git a/lib/gpu/lal_yukawa.cu b/lib/gpu/lal_yukawa.cu index b0c3b9978d..a8d637ec97 100644 --- a/lib/gpu/lal_yukawa.cu +++ b/lib/gpu/lal_yukawa.cu @@ -9,7 +9,7 @@ // This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) // __________________________________________________________________________ // -// begin : +// begin : // email : nguyentd@ornl.gov // ***************************************************************************/ @@ -24,14 +24,14 @@ texture pos_tex; #define pos_tex x_ #endif -__kernel void k_yukawa(const __global numtyp4 *restrict x_, +__kernel void k_yukawa(const __global numtyp4 *restrict x_, const __global numtyp4 *restrict coeff, const numtyp kappa, const int lj_types, - const __global numtyp *restrict sp_lj_in, - const __global int *dev_nbor, - const __global int *dev_packed, + const __global numtyp *restrict sp_lj_in, + const __global int *dev_nbor, + const __global int *dev_packed, __global acctyp4 *restrict ans, - __global acctyp *restrict engv, + __global acctyp *restrict engv, const int eflag, const int vflag, const int inum, const int nbor_pitch, const int t_per_atom) { int tid, ii, offset; @@ -49,20 +49,20 @@ __kernel void k_yukawa(const __global numtyp4 *restrict x_, acctyp virial[6]; for (int i=0; i<6; i++) virial[i]=(acctyp)0; - + if (ii0) { numtyp e=coeff[mtype].x*screening*rinv; - energy+=factor_lj*(e-coeff[mtype].y); + energy+=factor_lj*(e-coeff[mtype].y); } if (vflag>0) { virial[0] += delx*delx*force; @@ -109,19 +109,19 @@ __kernel void k_yukawa(const __global numtyp4 *restrict x_, } // if ii } -__kernel void k_yukawa_fast(const __global numtyp4 *restrict x_, +__kernel void k_yukawa_fast(const __global numtyp4 *restrict x_, const __global numtyp4 *restrict coeff_in, - const numtyp kappa, - const __global numtyp *restrict sp_lj_in, - const __global int *dev_nbor, - const __global int *dev_packed, - __global acctyp4 *restrict ans, - __global acctyp *restrict engv, - const int eflag, const int vflag, const int inum, + const numtyp kappa, + const __global numtyp *restrict sp_lj_in, + const __global int *dev_nbor, + const __global int *dev_packed, + __global acctyp4 *restrict ans, + __global acctyp *restrict engv, + const int eflag, const int vflag, const int inum, const int nbor_pitch, const int t_per_atom) { int tid, ii, offset; atom_info(t_per_atom,ii,tid,offset); - + __local numtyp4 coeff[MAX_SHARED_TYPES*MAX_SHARED_TYPES]; __local numtyp sp_lj[4]; if (tid<4) @@ -129,7 +129,7 @@ __kernel void k_yukawa_fast(const __global numtyp4 *restrict x_, if (tid0) { numtyp e=coeff[mtype].x*screening*rinv; - energy+=factor_lj*(e-coeff[mtype].y); + energy+=factor_lj*(e-coeff[mtype].y); } if (vflag>0) { virial[0] += delx*delx*force; diff --git a/lib/gpu/lal_yukawa.h b/lib/gpu/lal_yukawa.h index 720dc903d0..4cc23c03e9 100644 --- a/lib/gpu/lal_yukawa.h +++ b/lib/gpu/lal_yukawa.h @@ -9,7 +9,7 @@ This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) __________________________________________________________________________ - begin : + begin : email : nguyentd@ornl.gov ***************************************************************************/ @@ -24,13 +24,13 @@ template class Yukawa : public BaseAtomic { public: Yukawa(); - ~Yukawa(); + ~Yukawa(); /// Clear any previous data and set up for a new LAMMPS run /** \param max_nbors initial number of rows in the neighbor matrix * \param cell_size cutoff + skin * \param gpu_split fraction of particles handled by device - * + * * Returns: * - 0 if successfull * - -1 if fix gpu not found @@ -39,8 +39,8 @@ class Yukawa : public BaseAtomic { * - -5 Double precision is not supported on card **/ int init(const int ntypes, double **host_cutsq, double kappa, double **host_a, double **host_offset, double *host_special_lj, - const int nlocal, const int nall, const int max_nbors, - const int maxspecial, const double cell_size, + const int nlocal, const int nall, const int max_nbors, + const int maxspecial, const double cell_size, const double gpu_split, FILE *screen); /// Clear all host and device data @@ -57,16 +57,16 @@ class Yukawa : public BaseAtomic { /// coeff.x = a, coeff.y = offset, coeff.z = cutsq UCL_D_Vec coeff; - + /// Special LJ values UCL_D_Vec sp_lj; /// If atom type constants fit in shared memory, use fast kernels bool shared_types; - /// Number of atom types + /// Number of atom types int _lj_types; - + /// kappa numtyp _kappa; diff --git a/lib/gpu/lal_yukawa_colloid.cpp b/lib/gpu/lal_yukawa_colloid.cpp index 70282a7117..bfe398c62e 100644 --- a/lib/gpu/lal_yukawa_colloid.cpp +++ b/lib/gpu/lal_yukawa_colloid.cpp @@ -9,7 +9,7 @@ This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) __________________________________________________________________________ - begin : + begin : email : nguyentd@ornl.gov ***************************************************************************/ @@ -29,23 +29,23 @@ using namespace LAMMPS_AL; extern Device device; template -YukawaColloidT::YukawaColloid() : BaseAtomic(), +YukawaColloidT::YukawaColloid() : BaseAtomic(), _max_rad_size(0), _allocated(false) { } template -YukawaColloidT::~YukawaColloid() { +YukawaColloidT::~YukawaColloid() { clear(); } - + template int YukawaColloidT::bytes_per_atom(const int max_nbors) const { return this->bytes_per_atom_atomic(max_nbors); } template -int YukawaColloidT::init(const int ntypes, - double **host_cutsq, double **host_a, +int YukawaColloidT::init(const int ntypes, + double **host_cutsq, double **host_a, double **host_offset, double *host_special_lj, const int nlocal, const int nall, const int max_nbors, const int maxspecial, const double cell_size, @@ -62,16 +62,16 @@ int YukawaColloidT::init(const int ntypes, _shared_view=false; // allocate rad - + int ef_nall=nall; if (ef_nall==0) ef_nall=2000; - + _max_rad_size=static_cast(static_cast(ef_nall)*1.10); - + if (_shared_view==false) c_rad.alloc(_max_rad_size,*(this->ucl_device),UCL_WRITE_ONLY,UCL_READ_ONLY); - + rad_tex.get_texture(*(this->pair_program),"rad_tex"); rad_tex.bind_float(c_rad,1); @@ -102,7 +102,7 @@ int YukawaColloidT::init(const int ntypes, sp_lj.alloc(4,*(this->ucl_device),UCL_READ_ONLY); dview.view(host_special_lj,4,*(this->ucl_device)); ucl_copy(sp_lj,dview,false); - + _allocated=true; this->_max_bytes=coeff.row_bytes()+sp_lj.row_bytes(); return 0; @@ -131,15 +131,15 @@ double YukawaColloidT::host_memory_usage() const { // Copy nbor list from host if necessary and then compute atom energies/forces // --------------------------------------------------------------------------- template -void YukawaColloidT::compute(const int f_ago, const int inum_full, - const int nall, double **host_x, int *host_type, int *ilist, +void YukawaColloidT::compute(const int f_ago, const int inum_full, + const int nall, double **host_x, int *host_type, int *ilist, int *numj, int **firstneigh, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, const double cpu_time, bool &success, double *rad) { this->acc_timers(); - + // ------------------- Resize rad array -------------------------- - + if (nall>_max_rad_size) { _max_rad_size=static_cast(static_cast(nall)*1.10); if (_shared_view==false) { @@ -157,7 +157,7 @@ void YukawaColloidT::compute(const int f_ago, const int inum_full, this->zero_timers(); return; } - + int ago=this->hd_balancer.ago_first(f_ago); int inum=this->hd_balancer.balance(ago,inum_full,cpu_time); this->ans->inum(inum); @@ -170,7 +170,7 @@ void YukawaColloidT::compute(const int f_ago, const int inum_full, if (!success) return; } - + this->atom->cast_x_data(host_x,host_type); this->cast_rad_data(rad); this->hd_balancer.start_timer(); @@ -182,7 +182,7 @@ void YukawaColloidT::compute(const int f_ago, const int inum_full, this->device->add_ans_object(this->ans); this->hd_balancer.stop_timer(); } - + // --------------------------------------------------------------------------- // Reneighbor on GPU and then compute per-atom densities // --------------------------------------------------------------------------- @@ -190,24 +190,24 @@ template int** YukawaColloidT::compute(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, double *sublo, double *subhi, tagint *tag, int **nspecial, - tagint **special, const bool eflag, const bool vflag, - const bool eatom, const bool vatom, int &host_start, + tagint **special, const bool eflag, const bool vflag, + const bool eatom, const bool vatom, int &host_start, int **ilist, int **jnum, const double cpu_time, bool &success, double *rad) { this->acc_timers(); - + // ------------------- Resize rad array ---------------------------- - + if (nall>_max_rad_size) { _max_rad_size=static_cast(static_cast(nall)*1.10); if (_shared_view==false) { c_rad.resize(_max_rad_size); rad_tex.bind_float(c_rad,1); } - } + } // ----------------------------------------------------------------- - + if (inum_full==0) { host_start=0; // Make sure textures are correct if realloc by a different hybrid style @@ -215,21 +215,21 @@ int** YukawaColloidT::compute(const int ago, const int inum_full, const int nall this->zero_timers(); return NULL; } - + // load balance, returning the atom count on the device (inum) this->hd_balancer.balance(cpu_time); int inum=this->hd_balancer.get_gpu_count(ago,inum_full); this->ans->inum(inum); host_start=inum; - - // Build neighbor list on GPU if necessary + + // Build neighbor list on GPU if necessary if (ago==0) { this->build_nbor_list(inum, inum_full-inum, nall, host_x, host_type, sublo, subhi, tag, nspecial, special, success); if (!success) return NULL; this->cast_rad_data(rad); - this->hd_balancer.start_timer(); + this->hd_balancer.start_timer(); } else { this->atom->cast_x_data(host_x,host_type); this->cast_rad_data(rad); @@ -265,7 +265,7 @@ void YukawaColloidT::loop(const bool _eflag, const bool _vflag) { vflag=1; else vflag=0; - + int GX=static_cast(ceil(static_cast(this->ans->inum())/ (BX/this->_threads_per_atom))); @@ -280,8 +280,8 @@ void YukawaColloidT::loop(const bool _eflag, const bool _vflag) { &ainum, &nbor_pitch, &this->_threads_per_atom, &_kappa); } else { this->k_pair.set_size(GX,BX); - this->k_pair.run(&this->atom->x, &c_rad, &coeff, &_lj_types, &sp_lj, - &this->nbor->dev_nbor, &this->_nbor_data->begin(), + this->k_pair.run(&this->atom->x, &c_rad, &coeff, &_lj_types, &sp_lj, + &this->nbor->dev_nbor, &this->_nbor_data->begin(), &this->ans->force, &this->ans->engv, &eflag, &vflag, &ainum, &nbor_pitch, &this->_threads_per_atom, &_kappa); } diff --git a/lib/gpu/lal_yukawa_colloid.cu b/lib/gpu/lal_yukawa_colloid.cu index f9f4767123..ad02f202a3 100644 --- a/lib/gpu/lal_yukawa_colloid.cu +++ b/lib/gpu/lal_yukawa_colloid.cu @@ -9,7 +9,7 @@ // This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) // __________________________________________________________________________ // -// begin : +// begin : // email : nguyentd@ornl.gov // ***************************************************************************/ @@ -29,15 +29,15 @@ texture rad_tex; #define rad_tex rad_ #endif -__kernel void k_yukawa_colloid(const __global numtyp4 *restrict x_, +__kernel void k_yukawa_colloid(const __global numtyp4 *restrict x_, const __global numtyp *restrict rad_, - const __global numtyp4 *restrict coeff, - const int lj_types, - const __global numtyp *restrict sp_lj_in, - const __global int *dev_nbor, - const __global int *dev_packed, + const __global numtyp4 *restrict coeff, + const int lj_types, + const __global numtyp *restrict sp_lj_in, + const __global int *dev_nbor, + const __global int *dev_packed, __global acctyp4 *restrict ans, - __global acctyp *restrict engv, + __global acctyp *restrict engv, const int eflag, const int vflag, const int inum, const int nbor_pitch, const int t_per_atom, const numtyp kappa) { @@ -56,21 +56,21 @@ __kernel void k_yukawa_colloid(const __global numtyp4 *restrict x_, acctyp virial[6]; for (int i=0; i<6; i++) virial[i]=(acctyp)0; - + if (ii0) { numtyp e=coeff[mtype].x/kappa * screening; - energy+=factor_lj*(e-coeff[mtype].y); + energy+=factor_lj*(e-coeff[mtype].y); } if (vflag>0) { virial[0] += delx*delx*force; @@ -118,20 +118,20 @@ __kernel void k_yukawa_colloid(const __global numtyp4 *restrict x_, } // if ii } -__kernel void k_yukawa_colloid_fast(const __global numtyp4 *restrict x_, +__kernel void k_yukawa_colloid_fast(const __global numtyp4 *restrict x_, const __global numtyp *restrict rad_, - const __global numtyp4 *restrict coeff_in, + const __global numtyp4 *restrict coeff_in, const __global numtyp *restrict sp_lj_in, - const __global int *dev_nbor, - const __global int *dev_packed, - __global acctyp4 *restrict ans, - __global acctyp *restrict engv, - const int eflag, const int vflag, - const int inum, const int nbor_pitch, + const __global int *dev_nbor, + const __global int *dev_packed, + __global acctyp4 *restrict ans, + __global acctyp *restrict engv, + const int eflag, const int vflag, + const int inum, const int nbor_pitch, const int t_per_atom, const numtyp kappa) { int tid, ii, offset; atom_info(t_per_atom,ii,tid,offset); - + __local numtyp4 coeff[MAX_SHARED_TYPES*MAX_SHARED_TYPES]; __local numtyp sp_lj[4]; if (tid<4) @@ -139,7 +139,7 @@ __kernel void k_yukawa_colloid_fast(const __global numtyp4 *restrict x_, if (tid0) { numtyp e=coeff[mtype].x/kappa * screening; - energy+=factor_lj*(e-coeff[mtype].y); + energy+=factor_lj*(e-coeff[mtype].y); } if (vflag>0) { virial[0] += delx*delx*force; diff --git a/lib/gpu/lal_yukawa_colloid.h b/lib/gpu/lal_yukawa_colloid.h index 5a9ee7ae6e..ba69bc4bae 100644 --- a/lib/gpu/lal_yukawa_colloid.h +++ b/lib/gpu/lal_yukawa_colloid.h @@ -9,7 +9,7 @@ This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) __________________________________________________________________________ - begin : + begin : email : nguyentd@ornl.gov ***************************************************************************/ @@ -24,13 +24,13 @@ template class YukawaColloid : public BaseAtomic { public: YukawaColloid(); - ~YukawaColloid(); + ~YukawaColloid(); /// Clear any previous data and set up for a new LAMMPS run /** \param max_nbors initial number of rows in the neighbor matrix * \param cell_size cutoff + skin * \param gpu_split fraction of particles handled by device - * + * * Returns: * - 0 if successfull * - -1 if fix gpu not found @@ -39,8 +39,8 @@ class YukawaColloid : public BaseAtomic { * - -5 Double precision is not supported on card **/ int init(const int ntypes, double **host_cutsq, double **host_a, double **host_offset, double *host_special_lj, - const int nlocal, const int nall, const int max_nbors, - const int maxspecial, const double cell_size, + const int nlocal, const int nall, const int max_nbors, + const int maxspecial, const double cell_size, const double gpu_split, FILE *screen, const double kappa); inline void cast_rad_data(double* rad) { @@ -70,22 +70,22 @@ class YukawaColloid : public BaseAtomic { /// Total host memory used by library for pair style double host_memory_usage() const; - + /// Pair loop with host neighboring - void compute(const int f_ago, const int inum_full, - const int nall, double **host_x, int *host_type, - int *ilist, int *numj, int **firstneigh, + void compute(const int f_ago, const int inum_full, + const int nall, double **host_x, int *host_type, + int *ilist, int *numj, int **firstneigh, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, const double cpu_time, bool &success, double *rad); - + /// Pair loop with device neighboring int** compute(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, double *sublo, double *subhi, tagint *tag, int **nspecial, - tagint **special, const bool eflag, const bool vflag, - const bool eatom, const bool vatom, int &host_start, - int **ilist, int **jnum, const double cpu_time, + tagint **special, const bool eflag, const bool vflag, + const bool eatom, const bool vatom, int &host_start, + int **ilist, int **jnum, const double cpu_time, bool &success, double *rad); // --------------------------- TEXTURES ----------------------------- @@ -101,7 +101,7 @@ class YukawaColloid : public BaseAtomic { /// If atom type constants fit in shared memory, use fast kernels bool shared_types; - /// Number of atom types + /// Number of atom types int _lj_types; int _max_rad_size; diff --git a/lib/gpu/lal_yukawa_colloid_ext.cpp b/lib/gpu/lal_yukawa_colloid_ext.cpp index 0e3c653e06..b9ce51e522 100644 --- a/lib/gpu/lal_yukawa_colloid_ext.cpp +++ b/lib/gpu/lal_yukawa_colloid_ext.cpp @@ -9,7 +9,7 @@ This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) __________________________________________________________________________ - begin : + begin : email : nguyentd@ornl.gov ***************************************************************************/ @@ -27,10 +27,10 @@ static YukawaColloid YKCOLLMF; // --------------------------------------------------------------------------- // Allocate memory on host and device and copy constants to device // --------------------------------------------------------------------------- -int ykcolloid_gpu_init(const int ntypes, double **cutsq, double **host_a, +int ykcolloid_gpu_init(const int ntypes, double **cutsq, double **host_a, double **host_offset, double *special_lj, const int inum, const int nall, const int max_nbors, const int maxspecial, - const double cell_size, int &gpu_mode, FILE *screen, + const double cell_size, int &gpu_mode, FILE *screen, const double kappa) { YKCOLLMF.clear(); gpu_mode=YKCOLLMF.device->gpu_mode(); @@ -54,8 +54,8 @@ int ykcolloid_gpu_init(const int ntypes, double **cutsq, double **host_a, int init_ok=0; if (world_me==0) - init_ok=YKCOLLMF.init(ntypes, cutsq, host_a, host_offset, special_lj, - inum, nall, 300, maxspecial, cell_size, gpu_split, + init_ok=YKCOLLMF.init(ntypes, cutsq, host_a, host_offset, special_lj, + inum, nall, 300, maxspecial, cell_size, gpu_split, screen, kappa); YKCOLLMF.device->world_barrier(); @@ -72,12 +72,12 @@ int ykcolloid_gpu_init(const int ntypes, double **cutsq, double **host_a, fflush(screen); } if (gpu_rank==i && world_me!=0) - init_ok=YKCOLLMF.init(ntypes, cutsq, host_a, host_offset, special_lj, - inum, nall, 300, maxspecial, cell_size, gpu_split, + init_ok=YKCOLLMF.init(ntypes, cutsq, host_a, host_offset, special_lj, + inum, nall, 300, maxspecial, cell_size, gpu_split, screen, kappa); YKCOLLMF.device->gpu_barrier(); - if (message) + if (message) fprintf(screen,"Done.\n"); } if (message) @@ -103,11 +103,11 @@ int ** ykcolloid_gpu_compute_n(const int ago, const int inum_full, subhi, tag, nspecial, special, eflag, vflag, eatom, vatom, host_start, ilist, jnum, cpu_time, success, host_rad); -} +} -void ykcolloid_gpu_compute(const int ago, const int inum_full, - const int nall, double **host_x, int *host_type, - int *ilist, int *numj, int **firstneigh, +void ykcolloid_gpu_compute(const int ago, const int inum_full, + const int nall, double **host_x, int *host_type, + int *ilist, int *numj, int **firstneigh, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, const double cpu_time, bool &success, double *host_rad) { diff --git a/lib/gpu/lal_yukawa_ext.cpp b/lib/gpu/lal_yukawa_ext.cpp index 1cc89885aa..5136e3ea53 100644 --- a/lib/gpu/lal_yukawa_ext.cpp +++ b/lib/gpu/lal_yukawa_ext.cpp @@ -9,7 +9,7 @@ This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) __________________________________________________________________________ - begin : + begin : email : nguyentd@ornl.gov ***************************************************************************/ @@ -28,9 +28,9 @@ static Yukawa YKMF; // Allocate memory on host and device and copy constants to device // --------------------------------------------------------------------------- int yukawa_gpu_init(const int ntypes, double **cutsq, double kappa, - double **host_a, double **offset, double *special_lj, - const int inum, const int nall, const int max_nbors, - const int maxspecial, const double cell_size, + double **host_a, double **offset, double *special_lj, + const int inum, const int nall, const int max_nbors, + const int maxspecial, const double cell_size, int &gpu_mode, FILE *screen) { YKMF.clear(); gpu_mode=YKMF.device->gpu_mode(); @@ -54,8 +54,8 @@ int yukawa_gpu_init(const int ntypes, double **cutsq, double kappa, int init_ok=0; if (world_me==0) - init_ok=YKMF.init(ntypes, cutsq, kappa, host_a, offset, special_lj, - inum, nall, 300, maxspecial, cell_size, + init_ok=YKMF.init(ntypes, cutsq, kappa, host_a, offset, special_lj, + inum, nall, 300, maxspecial, cell_size, gpu_split, screen); YKMF.device->world_barrier(); @@ -72,12 +72,12 @@ int yukawa_gpu_init(const int ntypes, double **cutsq, double kappa, fflush(screen); } if (gpu_rank==i && world_me!=0) - init_ok=YKMF.init(ntypes, cutsq, kappa, host_a, offset, special_lj, - inum, nall, 300, maxspecial, cell_size, + init_ok=YKMF.init(ntypes, cutsq, kappa, host_a, offset, special_lj, + inum, nall, 300, maxspecial, cell_size, gpu_split, screen); YKMF.device->gpu_barrier(); - if (message) + if (message) fprintf(screen,"Done.\n"); } if (message) @@ -102,7 +102,7 @@ int ** yukawa_gpu_compute_n(const int ago, const int inum_full, return YKMF.compute(ago, inum_full, nall, host_x, host_type, sublo, subhi, tag, nspecial, special, eflag, vflag, eatom, vatom, host_start, ilist, jnum, cpu_time, success); -} +} void yukawa_gpu_compute(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, int *ilist, int *numj, diff --git a/lib/gpu/lal_zbl.cpp b/lib/gpu/lal_zbl.cpp index e172d48b33..a45faf01c3 100644 --- a/lib/gpu/lal_zbl.cpp +++ b/lib/gpu/lal_zbl.cpp @@ -9,7 +9,7 @@ This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) __________________________________________________________________________ - begin : + begin : email : ndactrung@gmail.com ***************************************************************************/ @@ -33,10 +33,10 @@ ZBLT::ZBL() : BaseAtomic(), _allocated(false) { } template -ZBLT::~ZBL() { +ZBLT::~ZBL() { clear(); } - + template int ZBLT::bytes_per_atom(const int max_nbors) const { return this->bytes_per_atom_atomic(max_nbors); @@ -44,15 +44,15 @@ int ZBLT::bytes_per_atom(const int max_nbors) const { template int ZBLT::init(const int ntypes, double **host_cutsq, - double **host_sw1, double **host_sw2, - double **host_sw3, double **host_sw4, + double **host_sw1, double **host_sw2, + double **host_sw3, double **host_sw4, double **host_sw5, - double **host_d1a, double **host_d2a, - double **host_d3a, double **host_d4a, - double **host_zze, double cut_globalsq, + double **host_d1a, double **host_d2a, + double **host_d3a, double **host_d4a, + double **host_zze, double cut_globalsq, double cut_innersq, double cut_inner, - const int nlocal, const int nall, const int max_nbors, - const int maxspecial, const double cell_size, + const int nlocal, const int nall, const int max_nbors, + const int maxspecial, const double cell_size, const double gpu_split, FILE *_screen) { int success; success=this->init_atomic(nlocal,nall,max_nbors,maxspecial,cell_size,gpu_split, @@ -88,7 +88,7 @@ int ZBLT::init(const int ntypes, double **host_cutsq, coeff3.alloc(lj_types*lj_types,*(this->ucl_device),UCL_READ_ONLY); this->atom->type_pack4(ntypes,lj_types,coeff3,host_write,host_sw3,host_sw4,host_sw5); - _cut_globalsq = cut_globalsq; + _cut_globalsq = cut_globalsq; _cut_innersq = cut_innersq; _cut_inner = cut_inner; @@ -131,7 +131,7 @@ void ZBLT::loop(const bool _eflag, const bool _vflag) { vflag=1; else vflag=0; - + int GX=static_cast(ceil(static_cast(this->ans->inum())/ (BX/this->_threads_per_atom))); diff --git a/lib/gpu/lal_zbl.cu b/lib/gpu/lal_zbl.cu index b14753b5fa..30bbc8aa2e 100644 --- a/lib/gpu/lal_zbl.cu +++ b/lib/gpu/lal_zbl.cu @@ -9,7 +9,7 @@ // This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) // __________________________________________________________________________ // -// begin : +// begin : // email : ndactrung@gmail.com // ***************************************************************************/ @@ -35,9 +35,9 @@ texture pos_tex; compute ZBL pair energy ------------------------------------------------------------------------- */ -ucl_inline numtyp e_zbl(numtyp r, numtyp d1aij, numtyp d2aij, +ucl_inline numtyp e_zbl(numtyp r, numtyp d1aij, numtyp d2aij, numtyp d3aij, numtyp d4aij, numtyp zzeij) { - + numtyp rinv = ucl_recip(r); numtyp sum = c1*ucl_exp(-d1aij*r); @@ -54,7 +54,7 @@ ucl_inline numtyp e_zbl(numtyp r, numtyp d1aij, numtyp d2aij, compute ZBL first derivative ------------------------------------------------------------------------- */ -ucl_inline numtyp dzbldr(numtyp r, numtyp d1aij, numtyp d2aij, +ucl_inline numtyp dzbldr(numtyp r, numtyp d1aij, numtyp d2aij, numtyp d3aij, numtyp d4aij, numtyp zzeij) { numtyp rinv = ucl_recip(r); @@ -72,24 +72,24 @@ ucl_inline numtyp dzbldr(numtyp r, numtyp d1aij, numtyp d2aij, sum_p -= c2*d2aij*e2; sum_p -= c3*d3aij*e3; sum_p -= c4*d4aij*e4; - + numtyp result = zzeij*(sum_p - sum*rinv)*rinv; - + return result; }; -__kernel void k_zbl(const __global numtyp4 *restrict x_, +__kernel void k_zbl(const __global numtyp4 *restrict x_, const __global numtyp4 *restrict coeff1, const __global numtyp4 *restrict coeff2, const __global numtyp4 *restrict coeff3, - const double cut_globalsq, - const double cut_innersq, - const double cut_inner, - const int lj_types, - const __global int *dev_nbor, - const __global int *dev_packed, + const double cut_globalsq, + const double cut_innersq, + const double cut_inner, + const int lj_types, + const __global int *dev_nbor, + const __global int *dev_packed, __global acctyp4 *restrict ans, - __global acctyp *restrict engv, + __global acctyp *restrict engv, const int eflag, const int vflag, const int inum, const int nbor_pitch, const int t_per_atom) { int tid, ii, offset; @@ -101,19 +101,19 @@ __kernel void k_zbl(const __global numtyp4 *restrict x_, acctyp virial[6]; for (int i=0; i<6; i++) virial[i]=(acctyp)0; - + if (iicut_innersq) { t = r - cut_inner; force = t*t * (coeff1[mtype].x + coeff1[mtype].y*t); @@ -146,14 +146,14 @@ __kernel void k_zbl(const __global numtyp4 *restrict x_, f.z+=delz*force; if (eflag>0) { - numtyp e=e_zbl(r, coeff2[mtype].x, coeff2[mtype].y, + numtyp e=e_zbl(r, coeff2[mtype].x, coeff2[mtype].y, coeff2[mtype].z, coeff2[mtype].w, coeff1[mtype].z); e += coeff3[mtype].z; if (rsq > cut_innersq) { e += t*t*t * (coeff3[mtype].x + coeff3[mtype].y*t); } - energy+=e; + energy+=e; } if (vflag>0) { virial[0] += delx*delx*force; @@ -171,22 +171,22 @@ __kernel void k_zbl(const __global numtyp4 *restrict x_, } // if ii } -__kernel void k_zbl_fast(const __global numtyp4 *restrict x_, +__kernel void k_zbl_fast(const __global numtyp4 *restrict x_, const __global numtyp4 *restrict coeff1_in, const __global numtyp4 *restrict coeff2_in, const __global numtyp4 *restrict coeff3_in, - const double cut_globalsq, - const double cut_innersq, - const double cut_inner, + const double cut_globalsq, + const double cut_innersq, + const double cut_inner, const __global int *dev_nbor, - const __global int *dev_packed, + const __global int *dev_packed, __global acctyp4 *restrict ans, - __global acctyp *restrict engv, - const int eflag, const int vflag, const int inum, + __global acctyp *restrict engv, + const int eflag, const int vflag, const int inum, const int nbor_pitch, const int t_per_atom) { int tid, ii, offset; atom_info(t_per_atom,ii,tid,offset); - + __local numtyp4 coeff1[MAX_SHARED_TYPES*MAX_SHARED_TYPES]; __local numtyp4 coeff2[MAX_SHARED_TYPES*MAX_SHARED_TYPES]; __local numtyp4 coeff3[MAX_SHARED_TYPES*MAX_SHARED_TYPES]; @@ -195,7 +195,7 @@ __kernel void k_zbl_fast(const __global numtyp4 *restrict x_, coeff2[tid]=coeff2_in[tid]; coeff3[tid]=coeff3_in[tid]; } - + acctyp energy=(acctyp)0; acctyp4 f; f.x=(acctyp)0; f.y=(acctyp)0; f.z=(acctyp)0; @@ -204,7 +204,7 @@ __kernel void k_zbl_fast(const __global numtyp4 *restrict x_, virial[i]=(acctyp)0; __syncthreads(); - + if (iicut_innersq) { t = r - cut_inner; force += t*t * (coeff1[mtype].x + coeff1[mtype].y*t); @@ -249,14 +249,14 @@ __kernel void k_zbl_fast(const __global numtyp4 *restrict x_, f.z+=delz*force; if (eflag>0) { - numtyp e=e_zbl(r, coeff2[mtype].x, coeff2[mtype].y, + numtyp e=e_zbl(r, coeff2[mtype].x, coeff2[mtype].y, coeff2[mtype].z, coeff2[mtype].w, coeff1[mtype].z); e += coeff3[mtype].z; if (rsq > cut_innersq) { e += t*t*t * (coeff3[mtype].x + coeff3[mtype].y*t); } - energy+=e; + energy+=e; } if (vflag>0) { virial[0] += delx*delx*force; diff --git a/lib/gpu/lal_zbl.h b/lib/gpu/lal_zbl.h index 2996d90a5c..9885fcedf2 100644 --- a/lib/gpu/lal_zbl.h +++ b/lib/gpu/lal_zbl.h @@ -9,7 +9,7 @@ This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) __________________________________________________________________________ - begin : + begin : email : ndactrung@gmail.com ***************************************************************************/ @@ -24,27 +24,27 @@ template class ZBL : public BaseAtomic { public: ZBL(); - ~ZBL(); + ~ZBL(); /// Clear any previous data and set up for a new LAMMPS run /** \param max_nbors initial number of rows in the neighbor matrix * \param cell_size cutoff + skin * \param gpu_split fraction of particles handled by device - * + * * Returns: * - 0 if successfull * - -1 if fix gpu not found * - -3 if there is an out of memory error * - -4 if the GPU library was not compiled for GPU * - -5 Double precision is not supported on card **/ - int init(const int ntypes, double **host_cutsq, double **host_sw1, + int init(const int ntypes, double **host_cutsq, double **host_sw1, double **host_sw2, double **host_sw3, double **host_sw4, double **host_sw5, - double **host_d1a, double **host_d2a, double **host_d3a, double **host_d4a, + double **host_d1a, double **host_d2a, double **host_d3a, double **host_d4a, double **host_zze, double cut_globalsq, double cut_innersq, double cut_inner, - const int nlocal, const int nall, const int max_nbors, - const int maxspecial, const double cell_size, + const int nlocal, const int nall, const int max_nbors, + const int maxspecial, const double cell_size, const double gpu_split, FILE *screen); - + /// Clear all host and device data /** \note This is called at the beginning of the init() routine **/ void clear(); @@ -70,8 +70,8 @@ class ZBL : public BaseAtomic { double _cut_globalsq; double _cut_innersq; double _cut_inner; - - /// Number of atom types + + /// Number of atom types int _lj_types; private: diff --git a/lib/gpu/lal_zbl_ext.cpp b/lib/gpu/lal_zbl_ext.cpp index ddce858076..5fd003b8ca 100644 --- a/lib/gpu/lal_zbl_ext.cpp +++ b/lib/gpu/lal_zbl_ext.cpp @@ -9,7 +9,7 @@ This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) __________________________________________________________________________ - begin : + begin : email : ndactrung@gmail.com ***************************************************************************/ @@ -27,11 +27,11 @@ static ZBL ZBLMF; // --------------------------------------------------------------------------- // Allocate memory on host and device and copy constants to device // --------------------------------------------------------------------------- -int zbl_gpu_init(const int ntypes, double **cutsq, double **host_sw1, +int zbl_gpu_init(const int ntypes, double **cutsq, double **host_sw1, double **host_sw2, double **host_sw3, double **host_sw4, double **host_sw5, - double **host_d1a, double **host_d2a, double **host_d3a, double **host_d4a, + double **host_d1a, double **host_d2a, double **host_d3a, double **host_d4a, double **host_zze, double cut_globalsq, double cut_innersq, double cut_inner, - const int inum, const int nall, const int max_nbors, + const int inum, const int nall, const int max_nbors, const int maxspecial, const double cell_size, int &gpu_mode, FILE *screen) { ZBLMF.clear(); gpu_mode=ZBLMF.device->gpu_mode(); @@ -55,7 +55,7 @@ int zbl_gpu_init(const int ntypes, double **cutsq, double **host_sw1, int init_ok=0; if (world_me==0) - init_ok=ZBLMF.init(ntypes, cutsq, host_sw1, host_sw2, host_sw3, host_sw4, + init_ok=ZBLMF.init(ntypes, cutsq, host_sw1, host_sw2, host_sw3, host_sw4, host_sw5, host_d1a, host_d2a, host_d3a, host_d4a, host_zze, cut_globalsq, cut_innersq, cut_inner, inum, nall, 300, maxspecial, cell_size, gpu_split, screen); @@ -74,13 +74,13 @@ int zbl_gpu_init(const int ntypes, double **cutsq, double **host_sw1, fflush(screen); } if (gpu_rank==i && world_me!=0) - init_ok=ZBLMF.init(ntypes, cutsq, host_sw1, host_sw2, host_sw3, host_sw4, + init_ok=ZBLMF.init(ntypes, cutsq, host_sw1, host_sw2, host_sw3, host_sw4, host_sw5, host_d1a, host_d2a, host_d3a, host_d4a, host_zze, - cut_globalsq, cut_innersq, cut_inner, + cut_globalsq, cut_innersq, cut_inner, inum, nall, 300, maxspecial, cell_size, gpu_split, screen); ZBLMF.device->gpu_barrier(); - if (message) + if (message) fprintf(screen,"Done.\n"); } if (message) @@ -105,7 +105,7 @@ int ** zbl_gpu_compute_n(const int ago, const int inum_full, return ZBLMF.compute(ago, inum_full, nall, host_x, host_type, sublo, subhi, tag, nspecial, special, eflag, vflag, eatom, vatom, host_start, ilist, jnum, cpu_time, success); -} +} void zbl_gpu_compute(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, int *ilist, int *numj, From 7c016aee735ef771e71f8717888d35653f4e21c3 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Fri, 24 Jun 2016 13:59:47 -0400 Subject: [PATCH 13/15] remove trailing whitespace and replace tabs with spaces in gpu library and package --- lib/gpu/geryon/nvd_device.h | 92 +++---- lib/gpu/geryon/nvd_kernel.h | 126 +++++----- lib/gpu/geryon/nvd_mat.h | 6 +- lib/gpu/geryon/nvd_memory.h | 106 ++++---- lib/gpu/geryon/nvd_texture.h | 24 +- lib/gpu/geryon/nvd_timer.h | 30 +-- lib/gpu/geryon/ocl_device.h | 120 ++++----- lib/gpu/geryon/ocl_kernel.h | 132 +++++----- lib/gpu/geryon/ocl_mat.h | 6 +- lib/gpu/geryon/ocl_memory.h | 116 ++++----- lib/gpu/geryon/ocl_texture.h | 8 +- lib/gpu/geryon/ocl_timer.h | 30 +-- lib/gpu/geryon/ucl_arg_kludge.h | 372 ++++++++++++++-------------- lib/gpu/geryon/ucl_basemat.h | 16 +- lib/gpu/geryon/ucl_copy.h | 162 ++++++------ lib/gpu/geryon/ucl_d_mat.h | 112 ++++----- lib/gpu/geryon/ucl_d_vec.h | 98 ++++---- lib/gpu/geryon/ucl_h_mat.h | 164 ++++++------ lib/gpu/geryon/ucl_h_vec.h | 144 +++++------ lib/gpu/geryon/ucl_matrix.h | 48 ++-- lib/gpu/geryon/ucl_nv_kernel.h | 6 +- lib/gpu/geryon/ucl_print.h | 64 ++--- lib/gpu/geryon/ucl_s_obj_help.h | 30 +-- lib/gpu/geryon/ucl_types.h | 78 +++--- lib/gpu/geryon/ucl_vector.h | 48 ++-- lib/gpu/lal_beck_ext.cpp | 2 +- lib/gpu/lal_born.cpp | 4 +- lib/gpu/lal_born_coul_long.cpp | 2 +- lib/gpu/lal_born_coul_long_ext.cpp | 2 +- lib/gpu/lal_born_coul_wolf.cpp | 2 +- lib/gpu/lal_born_coul_wolf_ext.cpp | 2 +- lib/gpu/lal_born_ext.cpp | 2 +- lib/gpu/lal_buck.cpp | 2 +- lib/gpu/lal_buck_coul.cpp | 2 +- lib/gpu/lal_buck_coul_ext.cpp | 2 +- lib/gpu/lal_buck_coul_long.cpp | 2 +- lib/gpu/lal_buck_coul_long_ext.cpp | 2 +- lib/gpu/lal_buck_ext.cpp | 2 +- lib/gpu/lal_cg_cmm.cpp | 2 +- lib/gpu/lal_cg_cmm_ext.cpp | 2 +- lib/gpu/lal_cg_cmm_long_ext.cpp | 2 +- lib/gpu/lal_charmm_long_ext.cpp | 6 +- lib/gpu/lal_colloid.cu | 4 +- lib/gpu/lal_colloid_ext.cpp | 2 +- lib/gpu/lal_coul_debye_ext.cpp | 2 +- lib/gpu/lal_coul_dsf_ext.cpp | 2 +- lib/gpu/lal_coul_ext.cpp | 2 +- lib/gpu/lal_coul_long.cpp | 2 +- lib/gpu/lal_coul_long.h | 6 +- lib/gpu/lal_coul_long_ext.cpp | 34 +-- lib/gpu/lal_device.cpp | 4 +- lib/gpu/lal_dipole_lj.cu | 6 +- lib/gpu/lal_dipole_lj_ext.cpp | 2 +- lib/gpu/lal_dipole_lj_sf.cu | 10 +- lib/gpu/lal_dipole_lj_sf_ext.cpp | 2 +- lib/gpu/lal_dpd.cpp | 4 +- lib/gpu/lal_dpd_ext.cpp | 2 +- lib/gpu/lal_ellipsoid_extra.h | 2 +- lib/gpu/lal_gauss.cpp | 4 +- lib/gpu/lal_gauss_ext.cpp | 2 +- lib/gpu/lal_gayberne.cpp | 14 +- lib/gpu/lal_gayberne.cu | 72 +++--- lib/gpu/lal_lj.cpp | 4 +- lib/gpu/lal_lj96.cpp | 4 +- lib/gpu/lal_lj96_ext.cpp | 2 +- lib/gpu/lal_lj_class2_long.cpp | 4 +- lib/gpu/lal_lj_class2_long_ext.cpp | 2 +- lib/gpu/lal_lj_coul.cpp | 4 +- lib/gpu/lal_lj_coul_debye.cpp | 4 +- lib/gpu/lal_lj_coul_debye_ext.cpp | 2 +- lib/gpu/lal_lj_coul_ext.cpp | 2 +- lib/gpu/lal_lj_coul_long.cpp | 4 +- lib/gpu/lal_lj_coul_long_ext.cpp | 2 +- lib/gpu/lal_lj_coul_msm.cpp | 4 +- lib/gpu/lal_lj_coul_msm_ext.cpp | 2 +- lib/gpu/lal_lj_cubic.cpp | 4 +- lib/gpu/lal_lj_cubic_ext.cpp | 2 +- lib/gpu/lal_lj_dsf.cpp | 4 +- lib/gpu/lal_lj_dsf_ext.cpp | 2 +- lib/gpu/lal_lj_expand.cpp | 4 +- lib/gpu/lal_lj_expand.cu | 12 +- lib/gpu/lal_lj_expand_ext.cpp | 2 +- lib/gpu/lal_lj_ext.cpp | 2 +- lib/gpu/lal_lj_gromacs_ext.cpp | 4 +- lib/gpu/lal_mie.cpp | 4 +- lib/gpu/lal_mie_ext.cpp | 2 +- lib/gpu/lal_morse_ext.cpp | 2 +- lib/gpu/lal_neighbor_gpu.cu | 56 ++--- lib/gpu/lal_neighbor_shared.cpp | 4 +- lib/gpu/lal_pppm.cu | 18 +- lib/gpu/lal_re_squared.cpp | 16 +- lib/gpu/lal_soft.cpp | 4 +- lib/gpu/lal_soft_ext.cpp | 2 +- lib/gpu/lal_sw_ext.cpp | 2 +- lib/gpu/lal_table_ext.cpp | 2 +- lib/gpu/lal_tersoff.cu | 4 +- lib/gpu/lal_tersoff_ext.cpp | 2 +- lib/gpu/lal_tersoff_extra.h | 2 +- lib/gpu/lal_tersoff_mod.cu | 6 +- lib/gpu/lal_tersoff_mod_ext.cpp | 2 +- lib/gpu/lal_tersoff_mod_extra.h | 4 +- lib/gpu/lal_tersoff_zbl.cu | 4 +- lib/gpu/lal_tersoff_zbl_ext.cpp | 2 +- lib/gpu/lal_tersoff_zbl_extra.h | 2 +- lib/gpu/lal_yukawa.cpp | 2 +- lib/gpu/lal_yukawa_colloid.cpp | 2 +- lib/gpu/lal_yukawa_colloid.cu | 12 +- lib/gpu/lal_yukawa_colloid_ext.cpp | 2 +- lib/gpu/lal_yukawa_ext.cpp | 2 +- lib/gpu/lal_zbl.cpp | 4 +- lib/gpu/lal_zbl.cu | 32 +-- lib/gpu/lal_zbl_ext.cpp | 2 +- src/GPU/pair_born_coul_long_gpu.cpp | 4 +- src/GPU/pair_born_coul_wolf_gpu.cpp | 2 +- src/GPU/pair_born_gpu.cpp | 2 +- src/GPU/pair_lj_gromacs_gpu.cpp | 30 +-- src/GPU/pair_zbl_gpu.cpp | 26 +- 117 files changed, 1347 insertions(+), 1347 deletions(-) diff --git a/lib/gpu/geryon/nvd_device.h b/lib/gpu/geryon/nvd_device.h index 3b7781753c..2d2a751f85 100644 --- a/lib/gpu/geryon/nvd_device.h +++ b/lib/gpu/geryon/nvd_device.h @@ -17,7 +17,7 @@ /* ----------------------------------------------------------------------- Copyright (2009) Sandia Corporation. Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains - certain rights in this software. This software is distributed under + certain rights in this software. This software is distributed under the Simplified BSD License. ----------------------------------------------------------------------- */ @@ -35,7 +35,7 @@ namespace ucl_cudadr { // -------------------------------------------------------------------------- // - COMMAND QUEUE STUFF // -------------------------------------------------------------------------- -typedef CUstream command_queue; +typedef CUstream command_queue; inline void ucl_sync(CUstream &stream) { CU_SAFE_CALL(cuStreamSynchronize(stream)); @@ -59,21 +59,21 @@ struct NVDProperties { /// Class for looking at device properties /** \note Calls to change the device outside of the class results in incorrect - * behavior + * behavior * \note There is no error checking for indexing past the number of devices **/ class UCL_Device { public: /// Collect properties for every GPU on the node /** \note You must set the active GPU with set() before using the device **/ inline UCL_Device(); - + inline ~UCL_Device(); /// Returns 1 (For compatibility with OpenCL) inline int num_platforms() { return 1; } /// Return a string with name and info of the current platform - inline std::string platform_name() + inline std::string platform_name() { return "NVIDIA Corporation NVIDIA CUDA Driver"; } /// Delete any contexts/data and set the platform number to be used @@ -97,24 +97,24 @@ class UCL_Device { /// Returns the default stream for the current device inline command_queue & cq() { return cq(0); } - + /// Returns the stream indexed by i inline command_queue & cq(const int i) { return _cq[i]; } - + /// Block until all commands in the default stream have completed inline void sync() { sync(0); } - + /// Block until all commands in the specified stream have completed inline void sync(const int i) { ucl_sync(cq(i)); } - + /// Get the number of command queues currently available on device - inline int num_queues() + inline int num_queues() { return _cq.size(); } - + /// Add a stream for device computations inline void push_command_queue() { - _cq.push_back(CUstream()); - CU_SAFE_CALL(cuStreamCreate(&_cq.back(),0)); + _cq.push_back(CUstream()); + CU_SAFE_CALL(cuStreamCreate(&_cq.back(),0)); } /// Remove a stream for device computations @@ -124,19 +124,19 @@ class UCL_Device { CU_SAFE_CALL_NS(cuStreamDestroy(_cq.back())); _cq.pop_back(); } - + /// Set the default command queue (by default this is the null stream) - /** \param i index of the command queue (as added by push_command_queue()) + /** \param i index of the command queue (as added by push_command_queue()) If i is 0, the default command queue is set to the null stream **/ inline void set_command_queue(const int i) { if (i==0) _cq[0]=0; else _cq[0]=_cq[i]; } - + /// Get the current CUDA device name inline std::string name() { return name(_device); } /// Get the CUDA device name - inline std::string name(const int i) + inline std::string name(const int i) { return std::string(_properties[i].name); } /// Get a string telling the type of the current device @@ -148,38 +148,38 @@ class UCL_Device { inline int device_type() { return device_type(_device); } /// Get device type (UCL_CPU, UCL_GPU, UCL_ACCELERATOR, UCL_DEFAULT) inline int device_type(const int i) { return UCL_GPU; } - + /// Returns true if host memory is efficiently addressable from device inline bool shared_memory() { return shared_memory(_device); } /// Returns true if host memory is efficiently addressable from device inline bool shared_memory(const int i) { return device_type(i)==UCL_CPU; } - + /// Returns true if double precision is support for the current device inline bool double_precision() { return double_precision(_device); } /// Returns true if double precision is support for the device inline bool double_precision(const int i) {return arch(i)>=1.3;} - + /// Get the number of compute units on the current device inline unsigned cus() { return cus(_device); } /// Get the number of compute units - inline unsigned cus(const int i) + inline unsigned cus(const int i) { return _properties[i].multiProcessorCount; } /// Get the number of cores in the current device inline unsigned cores() { return cores(_device); } /// Get the number of cores - inline unsigned cores(const int i) - { if (arch(i)<2.0) return _properties[i].multiProcessorCount*8; + inline unsigned cores(const int i) + { if (arch(i)<2.0) return _properties[i].multiProcessorCount*8; else if (arch(i)<2.1) return _properties[i].multiProcessorCount*32; else if (arch(i)<3.0) return _properties[i].multiProcessorCount*48; else return _properties[i].multiProcessorCount*192; } - + /// Get the gigabytes of global memory in the current device inline double gigabytes() { return gigabytes(_device); } /// Get the gigabytes of global memory - inline double gigabytes(const int i) + inline double gigabytes(const int i) { return static_cast(_properties[i].totalGlobalMem)/1073741824; } - + /// Get the bytes of global memory in the current device inline size_t bytes() { return bytes(_device); } /// Get the bytes of global memory @@ -188,13 +188,13 @@ class UCL_Device { // Get the gigabytes of free memory in the current device inline double free_gigabytes() { return free_gigabytes(_device); } // Get the gigabytes of free memory - inline double free_gigabytes(const int i) + inline double free_gigabytes(const int i) { return static_cast(free_bytes(i))/1073741824; } - + // Get the bytes of free memory in the current device inline size_t free_bytes() { return free_bytes(_device); } // Get the bytes of free memory - inline size_t free_bytes(const int i) { + inline size_t free_bytes(const int i) { CUDA_INT_TYPE dfree, dtotal; CU_SAFE_CALL_NS(cuMemGetInfo(&dfree, &dtotal)); return static_cast(dfree); @@ -203,21 +203,21 @@ class UCL_Device { /// Return the GPGPU compute capability for current device inline double arch() { return arch(_device); } /// Return the GPGPU compute capability - inline double arch(const int i) + inline double arch(const int i) { return static_cast(_properties[i].minor)/10+_properties[i].major;} - + /// Clock rate in GHz for current device inline double clock_rate() { return clock_rate(_device); } /// Clock rate in GHz - inline double clock_rate(const int i) + inline double clock_rate(const int i) { return _properties[i].p.clockRate*1e-6;} - + /// Get the maximum number of threads per block inline size_t group_size() { return group_size(_device); } /// Get the maximum number of threads per block - inline size_t group_size(const int i) + inline size_t group_size(const int i) { return _properties[i].p.maxThreadsPerBlock; } - + /// Return the maximum memory pitch in bytes for current device inline size_t max_pitch() { return max_pitch(_device); } /// Return the maximum memory pitch in bytes @@ -242,7 +242,7 @@ class UCL_Device { { return fission_by_counts(_device); } /// True if splitting device into subdevices by specified counts supported inline bool fission_by_counts(const int i) - { return false; } + { return false; } /// True if splitting device into subdevices by affinity domains supported inline bool fission_by_affinity() { return fission_by_affinity(_device); } @@ -259,7 +259,7 @@ class UCL_Device { /// List all devices along with all properties inline void print_all(std::ostream &out); - + private: int _device, _num_devices; std::vector _properties; @@ -279,16 +279,16 @@ UCL_Device::UCL_Device() { CU_SAFE_CALL_NS(cuDeviceComputeCapability(&major,&minor,m)); if (major==9999) continue; - + _properties.push_back(NVDProperties()); _properties.back().device_id=dev; _properties.back().major=major; _properties.back().minor=minor; - + char namecstr[1024]; CU_SAFE_CALL_NS(cuDeviceGetName(namecstr,1024,m)); _properties.back().name=namecstr; - + CU_SAFE_CALL_NS(cuDeviceTotalMem(&_properties.back().totalGlobalMem,m)); CU_SAFE_CALL_NS(cuDeviceGetAttribute(&_properties.back().multiProcessorCount, CU_DEVICE_ATTRIBUTE_MULTIPROCESSOR_COUNT, @@ -296,23 +296,23 @@ UCL_Device::UCL_Device() { CU_SAFE_CALL_NS(cuDeviceGetProperties(&_properties.back().p,m)); #if CUDA_VERSION >= 2020 CU_SAFE_CALL_NS(cuDeviceGetAttribute( - &_properties.back().kernelExecTimeoutEnabled, + &_properties.back().kernelExecTimeoutEnabled, CU_DEVICE_ATTRIBUTE_KERNEL_EXEC_TIMEOUT,dev)); CU_SAFE_CALL_NS(cuDeviceGetAttribute( &_properties.back().integrated, CU_DEVICE_ATTRIBUTE_INTEGRATED, dev)); CU_SAFE_CALL_NS(cuDeviceGetAttribute( - &_properties.back().canMapHostMemory, + &_properties.back().canMapHostMemory, CU_DEVICE_ATTRIBUTE_CAN_MAP_HOST_MEMORY, dev)); - CU_SAFE_CALL_NS(cuDeviceGetAttribute(&_properties.back().computeMode, + CU_SAFE_CALL_NS(cuDeviceGetAttribute(&_properties.back().computeMode, CU_DEVICE_ATTRIBUTE_COMPUTE_MODE,dev)); #endif #if CUDA_VERSION >= 3010 CU_SAFE_CALL_NS(cuDeviceGetAttribute( - &_properties.back().concurrentKernels, + &_properties.back().concurrentKernels, CU_DEVICE_ATTRIBUTE_CONCURRENT_KERNELS, dev)); CU_SAFE_CALL_NS(cuDeviceGetAttribute( - &_properties.back().ECCEnabled, + &_properties.back().ECCEnabled, CU_DEVICE_ATTRIBUTE_ECC_ENABLED, dev)); #endif } @@ -365,7 +365,7 @@ void UCL_Device::print_all(std::ostream &out) { cuDriverGetVersion(&driver_version); out << "CUDA Driver Version: " << driver_version/1000 << "." << driver_version%100 - << std::endl; + << std::endl; #endif if (num_devices() == 0) diff --git a/lib/gpu/geryon/nvd_kernel.h b/lib/gpu/geryon/nvd_kernel.h index e0bfb1bb5e..d03a715e1b 100644 --- a/lib/gpu/geryon/nvd_kernel.h +++ b/lib/gpu/geryon/nvd_kernel.h @@ -17,7 +17,7 @@ /* ----------------------------------------------------------------------- Copyright (2010) Sandia Corporation. Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains - certain rights in this software. This software is distributed under + certain rights in this software. This software is distributed under the Simplified BSD License. ----------------------------------------------------------------------- */ @@ -35,15 +35,15 @@ template class UCL_D_Mat; template class UCL_Vector; template class UCL_Matrix; #define UCL_MAX_KERNEL_ARGS 256 - + /// Class storing 1 or more kernel functions from a single string or file class UCL_Program { public: inline UCL_Program(UCL_Device &device) { _cq=device.cq(); } - inline UCL_Program(UCL_Device &device, const void *program, - const char *flags="", std::string *log=NULL) { + inline UCL_Program(UCL_Device &device, const void *program, + const char *flags="", std::string *log=NULL) { _cq=device.cq(); - init(device); + init(device); load_string(program,flags,log); } @@ -61,20 +61,20 @@ class UCL_Program { std::string *log=NULL) { std::ifstream in(filename); if (!in || in.is_open()==false) { - #ifndef UCL_NO_EXIT - std::cerr << "UCL Error: Could not open kernel file: " + #ifndef UCL_NO_EXIT + std::cerr << "UCL Error: Could not open kernel file: " << filename << std::endl; UCL_GERYON_EXIT; #endif return UCL_FILE_NOT_FOUND; } - + std::string program((std::istreambuf_iterator(in)), std::istreambuf_iterator()); in.close(); return load_string(program.c_str(),flags,log); } - + /// Load a program from a string and compile with flags inline int load_string(const void *program, const char *flags="", std::string *log=NULL) { @@ -94,12 +94,12 @@ class UCL_Program { CUresult err=cuModuleLoadDataEx(&_module,program,num_opts, options,(void **)values); - + if (log!=NULL) *log=std::string(clog); - + if (err != CUDA_SUCCESS) { - #ifndef UCL_NO_EXIT + #ifndef UCL_NO_EXIT std::cerr << std::endl << "----------------------------------------------------------\n" << " UCL Error: Error compiling PTX Program...\n" @@ -108,24 +108,24 @@ class UCL_Program { #endif return UCL_COMPILE_ERROR; } - + return UCL_SUCCESS; - } - + } + /// Load a precompiled program from a file inline int load_binary(const char *filename) { CUmodule _module; CUresult err = cuModuleLoad(&_module,filename); if (err==301) { - #ifndef UCL_NO_EXIT - std::cerr << "UCL Error: Could not open binary kernel file: " + #ifndef UCL_NO_EXIT + std::cerr << "UCL Error: Could not open binary kernel file: " << filename << std::endl; UCL_GERYON_EXIT; #endif return UCL_FILE_NOT_FOUND; } else if (err!=CUDA_SUCCESS) { - #ifndef UCL_NO_EXIT - std::cerr << "UCL Error: Error loading binary kernel file: " + #ifndef UCL_NO_EXIT + std::cerr << "UCL Error: Error loading binary kernel file: " << filename << std::endl; UCL_GERYON_EXIT; #endif @@ -138,7 +138,7 @@ class UCL_Program { // return UCL_ERROR; return UCL_SUCCESS; } - + friend class UCL_Kernel; private: CUmodule _module; @@ -149,23 +149,23 @@ class UCL_Program { /// Class for dealing with CUDA Driver kernels class UCL_Kernel { public: - UCL_Kernel() : _dimensions(1), _num_args(0) { + UCL_Kernel() : _dimensions(1), _num_args(0) { #if CUDA_VERSION < 4000 _param_size=0; #endif - _num_blocks[0]=0; + _num_blocks[0]=0; } - - UCL_Kernel(UCL_Program &program, const char *function) : + + UCL_Kernel(UCL_Program &program, const char *function) : _dimensions(1), _num_args(0) { #if CUDA_VERSION < 4000 _param_size=0; #endif - _num_blocks[0]=0; - set_function(program,function); - _cq=program._cq; + _num_blocks[0]=0; + set_function(program,function); + _cq=program._cq; } - + ~UCL_Kernel() {} /// Clear any function associated with the kernel @@ -189,7 +189,7 @@ class UCL_Kernel { /// Set the kernel argument. /** If not a device pointer, this must be repeated each time the argument - * changes + * changes * \note To set kernel parameter i (i>0), parameter i-1 must be set **/ template inline void set_arg(const unsigned index, const dtype * const arg) { @@ -202,27 +202,27 @@ class UCL_Kernel { CU_SAFE_CALL(cuParamSetv(_kernel, _offsets[index], arg, sizeof(dtype))); #endif else - assert(0==1); // Must add kernel parameters in sequential order + assert(0==1); // Must add kernel parameters in sequential order } - + /// Set a geryon container as a kernel argument. template - inline void set_arg(const UCL_D_Vec * const arg) + inline void set_arg(const UCL_D_Vec * const arg) { set_arg(&arg->begin()); } /// Set a geryon container as a kernel argument. template - inline void set_arg(const UCL_D_Mat * const arg) + inline void set_arg(const UCL_D_Mat * const arg) { set_arg(&arg->begin()); } /// Set a geryon container as a kernel argument. template - inline void set_arg(const UCL_Vector * const arg) + inline void set_arg(const UCL_Vector * const arg) { set_arg(&arg->device.begin()); } /// Set a geryon container as a kernel argument. template - inline void set_arg(const UCL_Matrix * const arg) + inline void set_arg(const UCL_Matrix * const arg) { set_arg(&arg->device.begin()); } /// Add a kernel argument. @@ -257,37 +257,37 @@ class UCL_Kernel { /// Add a geryon container as a kernel argument. template - inline void add_arg(const UCL_D_Vec * const arg) + inline void add_arg(const UCL_D_Vec * const arg) { add_arg(&arg->begin()); } /// Add a geryon container as a kernel argument. template - inline void add_arg(const UCL_D_Mat * const arg) + inline void add_arg(const UCL_D_Mat * const arg) { add_arg(&arg->begin()); } /// Add a geryon container as a kernel argument. template - inline void add_arg(const UCL_Vector * const arg) + inline void add_arg(const UCL_Vector * const arg) { add_arg(&arg->device.begin()); } /// Add a geryon container as a kernel argument. template - inline void add_arg(const UCL_Matrix * const arg) + inline void add_arg(const UCL_Matrix * const arg) { add_arg(&arg->device.begin()); } /// Set the number of thread blocks and the number of threads in each block /** \note This should be called before any arguments have been added \note The default command queue is used for the kernel execution **/ - inline void set_size(const size_t num_blocks, const size_t block_size) { - _dimensions=1; - _num_blocks[0]=num_blocks; + inline void set_size(const size_t num_blocks, const size_t block_size) { + _dimensions=1; + _num_blocks[0]=num_blocks; _num_blocks[1]=1; _num_blocks[2]=1; #if CUDA_VERSION >= 4000 _block_size[0]=block_size; _block_size[1]=1; _block_size[2]=1; - #else + #else CU_SAFE_CALL(cuFuncSetBlockShape(_kernel,block_size,1,1)); #endif } @@ -303,43 +303,43 @@ class UCL_Kernel { /** \note This should be called before any arguments have been added \note The default command queue is used for the kernel execution **/ inline void set_size(const size_t num_blocks_x, const size_t num_blocks_y, - const size_t block_size_x, const size_t block_size_y) { - _dimensions=2; - _num_blocks[0]=num_blocks_x; - _num_blocks[1]=num_blocks_y; + const size_t block_size_x, const size_t block_size_y) { + _dimensions=2; + _num_blocks[0]=num_blocks_x; + _num_blocks[1]=num_blocks_y; _num_blocks[2]=1; #if CUDA_VERSION >= 4000 _block_size[0]=block_size_x; _block_size[1]=block_size_y; _block_size[2]=1; - #else + #else CU_SAFE_CALL(cuFuncSetBlockShape(_kernel,block_size_x,block_size_y,1)); #endif } - + /// Set the number of thread blocks and the number of threads in each block /** \note This should be called before any arguments have been added \note The default command queue for the kernel is changed to cq **/ inline void set_size(const size_t num_blocks_x, const size_t num_blocks_y, const size_t block_size_x, const size_t block_size_y, - command_queue &cq) + command_queue &cq) {_cq=cq; set_size(num_blocks_x, num_blocks_y, block_size_x, block_size_y);} /// Set the number of thread blocks and the number of threads in each block /** \note This should be called before any arguments have been added \note The default command queue is used for the kernel execution **/ inline void set_size(const size_t num_blocks_x, const size_t num_blocks_y, - const size_t block_size_x, + const size_t block_size_x, const size_t block_size_y, const size_t block_size_z) { - _dimensions=2; - _num_blocks[0]=num_blocks_x; - _num_blocks[1]=num_blocks_y; - _num_blocks[2]=1; + _dimensions=2; + _num_blocks[0]=num_blocks_x; + _num_blocks[1]=num_blocks_y; + _num_blocks[2]=1; #if CUDA_VERSION >= 4000 _block_size[0]=block_size_x; _block_size[1]=block_size_y; _block_size[2]=block_size_z; - #else + #else CU_SAFE_CALL(cuFuncSetBlockShape(_kernel,block_size_x,block_size_y, block_size_z)); #endif @@ -352,10 +352,10 @@ class UCL_Kernel { const size_t block_size_x, const size_t block_size_y, const size_t block_size_z, command_queue &cq) { _cq=cq; - set_size(num_blocks_x, num_blocks_y, block_size_x, block_size_y, + set_size(num_blocks_x, num_blocks_y, block_size_x, block_size_y, block_size_z); } - + /// Run the kernel in the default command queue inline void run() { #if CUDA_VERSION >= 4000 @@ -367,12 +367,12 @@ class UCL_Kernel { CU_SAFE_CALL(cuLaunchGridAsync(_kernel,_num_blocks[0],_num_blocks[1],_cq)); #endif } - + /// Clear any arguments associated with the kernel - inline void clear_args() { - _num_args=0; + inline void clear_args() { + _num_args=0; #if CUDA_VERSION < 4000 - _offsets.clear(); + _offsets.clear(); _param_size=0; #endif } @@ -390,7 +390,7 @@ class UCL_Kernel { unsigned _num_blocks[3]; unsigned _num_args; friend class UCL_Texture; - + #if CUDA_VERSION >= 4000 unsigned _block_size[3]; void * _kernel_args[UCL_MAX_KERNEL_ARGS]; diff --git a/lib/gpu/geryon/nvd_mat.h b/lib/gpu/geryon/nvd_mat.h index 51cfe1d56f..042e2978c3 100644 --- a/lib/gpu/geryon/nvd_mat.h +++ b/lib/gpu/geryon/nvd_mat.h @@ -17,12 +17,12 @@ /* ----------------------------------------------------------------------- Copyright (2010) Sandia Corporation. Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains - certain rights in this software. This software is distributed under + certain rights in this software. This software is distributed under the Simplified BSD License. ----------------------------------------------------------------------- */ /*! \file */ - + #ifndef NVD_MAT_H #define NVD_MAT_H @@ -52,6 +52,6 @@ namespace ucl_cudadr { #include "ucl_print.h" #undef UCL_PRINT_ALLOW -} // namespace ucl_cudadr +} // namespace ucl_cudadr #endif diff --git a/lib/gpu/geryon/nvd_memory.h b/lib/gpu/geryon/nvd_memory.h index 5f7b98ba5c..0484e33de6 100644 --- a/lib/gpu/geryon/nvd_memory.h +++ b/lib/gpu/geryon/nvd_memory.h @@ -17,7 +17,7 @@ /* ----------------------------------------------------------------------- Copyright (2010) Sandia Corporation. Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains - certain rights in this software. This software is distributed under + certain rights in this software. This software is distributed under the Simplified BSD License. ----------------------------------------------------------------------- */ @@ -46,7 +46,7 @@ typedef CUdeviceptr device_ptr; // - HOST MEMORY ALLOCATION ROUTINES // -------------------------------------------------------------------------- template -inline int _host_alloc(mat_type &mat, copy_type &cm, const size_t n, +inline int _host_alloc(mat_type &mat, copy_type &cm, const size_t n, const enum UCL_MEMOPT kind, const enum UCL_MEMOPT kind2){ CUresult err=CUDA_SUCCESS; if (kind==UCL_NOT_PINNED) @@ -62,7 +62,7 @@ inline int _host_alloc(mat_type &mat, copy_type &cm, const size_t n, } template -inline int _host_alloc(mat_type &mat, UCL_Device &dev, const size_t n, +inline int _host_alloc(mat_type &mat, UCL_Device &dev, const size_t n, const enum UCL_MEMOPT kind, const enum UCL_MEMOPT kind2){ CUresult err=CUDA_SUCCESS; if (kind==UCL_NOT_PINNED) @@ -95,7 +95,7 @@ inline int _host_resize(mat_type &mat, const size_t n) { *(mat.host_ptr())=(typename mat_type::data_type*)malloc(n); else if (mat.kind()==UCL_WRITE_ONLY) err=cuMemHostAlloc((void **)mat.host_ptr(),n,CU_MEMHOSTALLOC_WRITECOMBINED); - else + else err=cuMemAllocHost((void **)mat.host_ptr(),n); if (err!=CUDA_SUCCESS || *(mat.host_ptr())==NULL) return UCL_MEMORY_ERROR; @@ -130,30 +130,30 @@ inline int _device_alloc(mat_type &mat, copy_type &cm, const size_t rows, const size_t cols, size_t &pitch, const enum UCL_MEMOPT kind) { CUresult err; - CUDA_INT_TYPE upitch; + CUDA_INT_TYPE upitch; err=cuMemAllocPitch(&mat.cbegin(),&upitch, cols*sizeof(typename mat_type::data_type),rows,16); - pitch=static_cast(upitch); + pitch=static_cast(upitch); if (err!=CUDA_SUCCESS) return UCL_MEMORY_ERROR; mat.cq()=cm.cq(); return UCL_SUCCESS; -} +} template inline int _device_alloc(mat_type &mat, UCL_Device &d, const size_t rows, const size_t cols, size_t &pitch, const enum UCL_MEMOPT kind) { CUresult err; - unsigned upitch; + unsigned upitch; err=cuMemAllocPitch(&mat.cbegin(),&upitch, cols*sizeof(typename mat_type::data_type),rows,16); - pitch=static_cast(upitch); + pitch=static_cast(upitch); if (err!=CUDA_SUCCESS) return UCL_MEMORY_ERROR; mat.cq()=d.cq(); return UCL_SUCCESS; -} +} template inline void _device_free(mat_type &mat) { @@ -175,33 +175,33 @@ inline int _device_resize(mat_type &mat, const size_t rows, const size_t cols, size_t &pitch) { _device_free(mat); CUresult err; - CUDA_INT_TYPE upitch; + CUDA_INT_TYPE upitch; err=cuMemAllocPitch(&mat.cbegin(),&upitch, cols*sizeof(typename mat_type::data_type),rows,16); - pitch=static_cast(upitch); + pitch=static_cast(upitch); if (err!=CUDA_SUCCESS) return UCL_MEMORY_ERROR; return UCL_SUCCESS; -} +} -inline void _device_view(CUdeviceptr *ptr, CUdeviceptr &in) { +inline void _device_view(CUdeviceptr *ptr, CUdeviceptr &in) { *ptr=in; } template -inline void _device_view(CUdeviceptr *ptr, numtyp *in) { - *ptr=0; +inline void _device_view(CUdeviceptr *ptr, numtyp *in) { + *ptr=0; } -inline void _device_view(CUdeviceptr *ptr, CUdeviceptr &in, - const size_t offset, const size_t numsize) { +inline void _device_view(CUdeviceptr *ptr, CUdeviceptr &in, + const size_t offset, const size_t numsize) { *ptr=in+offset*numsize; } template inline void _device_view(CUdeviceptr *ptr, numtyp *in, - const size_t offset, const size_t numsize) { - *ptr=0; + const size_t offset, const size_t numsize) { + *ptr=0; } // -------------------------------------------------------------------------- @@ -211,13 +211,13 @@ template inline void _device_image_alloc(mat_type &mat, copy_type &cm, const size_t rows, const size_t cols) { assert(0==1); -} +} template inline void _device_image_alloc(mat_type &mat, UCL_Device &d, const size_t rows, const size_t cols) { assert(0==1); -} +} template inline void _device_image_free(mat_type &mat) { @@ -245,7 +245,7 @@ inline void _device_zero(mat_type &mat, const size_t n, command_queue &cq) { // - HELPER FUNCTIONS FOR MEMCPY ROUTINES // -------------------------------------------------------------------------- -inline void _nvd_set_2D_loc(CUDA_MEMCPY2D &ins, const size_t dpitch, +inline void _nvd_set_2D_loc(CUDA_MEMCPY2D &ins, const size_t dpitch, const size_t spitch, const size_t cols, const size_t rows) { ins.srcXInBytes=0; @@ -257,13 +257,13 @@ inline void _nvd_set_2D_loc(CUDA_MEMCPY2D &ins, const size_t dpitch, ins.WidthInBytes=cols; ins.Height=rows; } - + template struct _nvd_set_2D_mem; -template <> struct _nvd_set_2D_mem<1> +template <> struct _nvd_set_2D_mem<1> { static CUmemorytype a() { return CU_MEMORYTYPE_HOST; } }; -template <> struct _nvd_set_2D_mem<2> +template <> struct _nvd_set_2D_mem<2> { static CUmemorytype a() { return CU_MEMORYTYPE_ARRAY; } }; -template struct _nvd_set_2D_mem +template struct _nvd_set_2D_mem { static CUmemorytype a() { return CU_MEMORYTYPE_DEVICE; } }; @@ -285,7 +285,7 @@ template<> struct _ucl_memcpy<2,2> { assert(0==1); } template - static inline void mc(p1 &dst, const size_t dpitch, const p2 &src, + static inline void mc(p1 &dst, const size_t dpitch, const p2 &src, const size_t spitch, const size_t cols, const size_t rows) { CUDA_MEMCPY2D ins; @@ -297,7 +297,7 @@ template<> struct _ucl_memcpy<2,2> { CU_SAFE_CALL(cuMemcpy2D(&ins)); } template - static inline void mc(p1 &dst, const size_t dpitch, const p2 &src, + static inline void mc(p1 &dst, const size_t dpitch, const p2 &src, const size_t spitch, const size_t cols, const size_t rows, CUstream &cq) { CUDA_MEMCPY2D ins; @@ -322,7 +322,7 @@ template<> struct _ucl_memcpy<2,0> { assert(0==1); } template - static inline void mc(p1 &dst, const size_t dpitch, const p2 &src, + static inline void mc(p1 &dst, const size_t dpitch, const p2 &src, const size_t spitch, const size_t cols, const size_t rows) { CUDA_MEMCPY2D ins; @@ -334,7 +334,7 @@ template<> struct _ucl_memcpy<2,0> { CU_SAFE_CALL(cuMemcpy2D(&ins)); } template - static inline void mc(p1 &dst, const size_t dpitch, const p2 &src, + static inline void mc(p1 &dst, const size_t dpitch, const p2 &src, const size_t spitch, const size_t cols, const size_t rows, CUstream &cq) { CUDA_MEMCPY2D ins; @@ -359,7 +359,7 @@ template<> struct _ucl_memcpy<2,1> { assert(0==1); } template - static inline void mc(p1 &dst, const size_t dpitch, const p2 &src, + static inline void mc(p1 &dst, const size_t dpitch, const p2 &src, const size_t spitch, const size_t cols, const size_t rows) { CUDA_MEMCPY2D ins; @@ -371,7 +371,7 @@ template<> struct _ucl_memcpy<2,1> { CU_SAFE_CALL(cuMemcpy2D(&ins)); } template - static inline void mc(p1 &dst, const size_t dpitch, const p2 &src, + static inline void mc(p1 &dst, const size_t dpitch, const p2 &src, const size_t spitch, const size_t cols, const size_t rows, CUstream &cq) { CUDA_MEMCPY2D ins; @@ -396,7 +396,7 @@ template<> struct _ucl_memcpy<0,2> { assert(0==1); } template - static inline void mc(p1 &dst, const size_t dpitch, const p2 &src, + static inline void mc(p1 &dst, const size_t dpitch, const p2 &src, const size_t spitch, const size_t cols, const size_t rows) { CUDA_MEMCPY2D ins; @@ -408,7 +408,7 @@ template<> struct _ucl_memcpy<0,2> { CU_SAFE_CALL(cuMemcpy2D(&ins)); } template - static inline void mc(p1 &dst, const size_t dpitch, const p2 &src, + static inline void mc(p1 &dst, const size_t dpitch, const p2 &src, const size_t spitch, const size_t cols, const size_t rows, CUstream &cq) { CUDA_MEMCPY2D ins; @@ -433,7 +433,7 @@ template<> struct _ucl_memcpy<1,2> { assert(0==1); } template - static inline void mc(p1 &dst, const size_t dpitch, const p2 &src, + static inline void mc(p1 &dst, const size_t dpitch, const p2 &src, const size_t spitch, const size_t cols, const size_t rows) { CUDA_MEMCPY2D ins; @@ -445,7 +445,7 @@ template<> struct _ucl_memcpy<1,2> { CU_SAFE_CALL(cuMemcpy2D(&ins)); } template - static inline void mc(p1 &dst, const size_t dpitch, const p2 &src, + static inline void mc(p1 &dst, const size_t dpitch, const p2 &src, const size_t spitch, const size_t cols, const size_t rows, CUstream &cq) { CUDA_MEMCPY2D ins; @@ -470,7 +470,7 @@ template <> struct _ucl_memcpy<1,0> { CU_SAFE_CALL(cuMemcpyDtoHAsync(dst.begin(),src.cbegin(),n,cq)); } template - static inline void mc(p1 &dst, const size_t dpitch, const p2 &src, + static inline void mc(p1 &dst, const size_t dpitch, const p2 &src, const size_t spitch, const size_t cols, const size_t rows) { CUDA_MEMCPY2D ins; @@ -482,7 +482,7 @@ template <> struct _ucl_memcpy<1,0> { CU_SAFE_CALL(cuMemcpy2D(&ins)); } template - static inline void mc(p1 &dst, const size_t dpitch, const p2 &src, + static inline void mc(p1 &dst, const size_t dpitch, const p2 &src, const size_t spitch, const size_t cols, const size_t rows, CUstream &cq) { CUDA_MEMCPY2D ins; @@ -507,7 +507,7 @@ template <> struct _ucl_memcpy<0,1> { CU_SAFE_CALL(cuMemcpyHtoDAsync(dst.cbegin(),src.begin(),n,cq)); } template - static inline void mc(p1 &dst, const size_t dpitch, const p2 &src, + static inline void mc(p1 &dst, const size_t dpitch, const p2 &src, const size_t spitch, const size_t cols, const size_t rows) { CUDA_MEMCPY2D ins; @@ -519,7 +519,7 @@ template <> struct _ucl_memcpy<0,1> { CU_SAFE_CALL(cuMemcpy2D(&ins)); } template - static inline void mc(p1 &dst, const size_t dpitch, const p2 &src, + static inline void mc(p1 &dst, const size_t dpitch, const p2 &src, const size_t spitch, const size_t cols, const size_t rows, CUstream &cq) { CUDA_MEMCPY2D ins; @@ -542,7 +542,7 @@ template <> struct _ucl_memcpy<1,1> { CUstream &cq) { memcpy(dst.begin(),src.begin(),n); } template - static inline void mc(p1 &dst, const size_t dpitch, const p2 &src, + static inline void mc(p1 &dst, const size_t dpitch, const p2 &src, const size_t spitch, const size_t cols, const size_t rows) { CUDA_MEMCPY2D ins; @@ -554,7 +554,7 @@ template <> struct _ucl_memcpy<1,1> { CU_SAFE_CALL(cuMemcpy2D(&ins)); } template - static inline void mc(p1 &dst, const size_t dpitch, const p2 &src, + static inline void mc(p1 &dst, const size_t dpitch, const p2 &src, const size_t spitch, const size_t cols, const size_t rows, CUstream &cq) { CUDA_MEMCPY2D ins; @@ -579,18 +579,18 @@ template struct _ucl_memcpy { CU_SAFE_CALL(cuMemcpyDtoDAsync(dst.cbegin(),src.cbegin(),n,cq)); } template - static inline void mc(p1 &dst, const size_t dpitch, const p2 &src, + static inline void mc(p1 &dst, const size_t dpitch, const p2 &src, const size_t spitch, const size_t cols, const size_t rows) { if (p1::PADDED==0 || p2::PADDED==0) { size_t src_offset=0, dst_offset=0; - for (size_t i=0; i::a(); @@ -601,12 +601,12 @@ template struct _ucl_memcpy { } } template - static inline void mc(p1 &dst, const size_t dpitch, const p2 &src, + static inline void mc(p1 &dst, const size_t dpitch, const p2 &src, const size_t spitch, const size_t cols, const size_t rows, CUstream &cq) { if (p1::PADDED==0 || p2::PADDED==0) { size_t src_offset=0, dst_offset=0; - for (size_t i=0; i -inline void ucl_mv_cpy(mat1 &dst, const size_t dpitch, const mat2 &src, - const size_t spitch, const size_t cols, +inline void ucl_mv_cpy(mat1 &dst, const size_t dpitch, const mat2 &src, + const size_t spitch, const size_t cols, const size_t rows) { _ucl_memcpy::mc(dst,dpitch,src,spitch,cols, rows); } template -inline void ucl_mv_cpy(mat1 &dst, const size_t dpitch, const mat2 &src, - const size_t spitch, const size_t cols, +inline void ucl_mv_cpy(mat1 &dst, const size_t dpitch, const mat2 &src, + const size_t spitch, const size_t cols, const size_t rows,CUstream &cq) { _ucl_memcpy::mc(dst,dpitch,src,spitch,cols, rows,cq); } -} // namespace ucl_cudart +} // namespace ucl_cudart #endif diff --git a/lib/gpu/geryon/nvd_texture.h b/lib/gpu/geryon/nvd_texture.h index 07650263a5..965595a448 100644 --- a/lib/gpu/geryon/nvd_texture.h +++ b/lib/gpu/geryon/nvd_texture.h @@ -17,7 +17,7 @@ /* ----------------------------------------------------------------------- Copyright (2010) Sandia Corporation. Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains - certain rights in this software. This software is distributed under + certain rights in this software. This software is distributed under the Simplified BSD License. ----------------------------------------------------------------------- */ @@ -28,7 +28,7 @@ #include "nvd_mat.h" namespace ucl_cudadr { - + /// Class storing a texture reference class UCL_Texture { public: @@ -38,39 +38,39 @@ class UCL_Texture { inline UCL_Texture(UCL_Program &prog, const char *texture_name) { get_texture(prog,texture_name); } /// Set the texture reference for this object - inline void get_texture(UCL_Program &prog, const char *texture_name) + inline void get_texture(UCL_Program &prog, const char *texture_name) { CU_SAFE_CALL(cuModuleGetTexRef(&_tex, prog._module, texture_name)); } /// Bind a float array where each fetch grabs a vector of length numel template - inline void bind_float(UCL_D_Vec &vec, const unsigned numel) + inline void bind_float(UCL_D_Vec &vec, const unsigned numel) { _bind_float(vec,numel); } /// Bind a float array where each fetch grabs a vector of length numel template - inline void bind_float(UCL_D_Mat &vec, const unsigned numel) + inline void bind_float(UCL_D_Mat &vec, const unsigned numel) { _bind_float(vec,numel); } /// Bind a float array where each fetch grabs a vector of length numel template - inline void bind_float(UCL_Vector &vec, const unsigned numel) + inline void bind_float(UCL_Vector &vec, const unsigned numel) { _bind_float(vec.device,numel); } /// Bind a float array where each fetch grabs a vector of length numel template - inline void bind_float(UCL_Matrix &vec, const unsigned numel) + inline void bind_float(UCL_Matrix &vec, const unsigned numel) { _bind_float(vec.device,numel); } /// Unbind the texture reference from the memory allocation inline void unbind() { } - /// Make a texture reference available to kernel - inline void allow(UCL_Kernel &kernel) { + /// Make a texture reference available to kernel + inline void allow(UCL_Kernel &kernel) { #if CUDA_VERSION < 4000 - CU_SAFE_CALL(cuParamSetTexRef(kernel._kernel, CU_PARAM_TR_DEFAULT, _tex)); + CU_SAFE_CALL(cuParamSetTexRef(kernel._kernel, CU_PARAM_TR_DEFAULT, _tex)); #endif } - + private: CUtexref _tex; friend class UCL_Kernel; @@ -80,7 +80,7 @@ class UCL_Texture { #ifdef UCL_DEBUG assert(numel!=0 && numel<5); #endif - CU_SAFE_CALL(cuTexRefSetAddress(NULL, _tex, vec.cbegin(), + CU_SAFE_CALL(cuTexRefSetAddress(NULL, _tex, vec.cbegin(), vec.numel()*vec.element_size())); if (vec.element_size()==sizeof(float)) CU_SAFE_CALL(cuTexRefSetFormat(_tex, CU_AD_FORMAT_FLOAT, numel)); diff --git a/lib/gpu/geryon/nvd_timer.h b/lib/gpu/geryon/nvd_timer.h index 4c3e993e0d..aefbaea0c3 100644 --- a/lib/gpu/geryon/nvd_timer.h +++ b/lib/gpu/geryon/nvd_timer.h @@ -17,7 +17,7 @@ /* ----------------------------------------------------------------------- Copyright (2010) Sandia Corporation. Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains - certain rights in this software. This software is distributed under + certain rights in this software. This software is distributed under the Simplified BSD License. ----------------------------------------------------------------------- */ @@ -41,7 +41,7 @@ class UCL_Timer { /// Clear any data associated with timer /** \note init() must be called to reuse timer after a clear() **/ inline void clear() { - if (_initialized) { + if (_initialized) { CU_DESTRUCT_CALL(cuEventDestroy(start_event)); CU_DESTRUCT_CALL(cuEventDestroy(stop_event)); _initialized=false; @@ -63,16 +63,16 @@ class UCL_Timer { /// Start timing on command queue inline void start() { CU_SAFE_CALL(cuEventRecord(start_event,_cq)); } - + /// Stop timing on command queue inline void stop() { CU_SAFE_CALL(cuEventRecord(stop_event,_cq)); } - + /// Block until the start event has been reached on device - inline void sync_start() + inline void sync_start() { CU_SAFE_CALL(cuEventSynchronize(start_event)); } /// Block until the stop event has been reached on device - inline void sync_stop() + inline void sync_stop() { CU_SAFE_CALL(cuEventSynchronize(stop_event)); } /// Set the time elapsed to zero (not the total_time) @@ -80,29 +80,29 @@ class UCL_Timer { CU_SAFE_CALL(cuEventRecord(start_event,_cq)); CU_SAFE_CALL(cuEventRecord(stop_event,_cq)); } - + /// Set the total time to zero inline void zero_total() { _total_time=0.0; } - + /// Add time from previous start and stop to total /** Forces synchronization **/ - inline double add_to_total() + inline double add_to_total() { double t=time(); _total_time+=t; return t/1000.0; } - + /// Add a user specified time to the total (ms) inline void add_time_to_total(const double t) { _total_time+=t; } - + /// Return the time (ms) of last start to stop - Forces synchronization - inline double time() { + inline double time() { float timer; CU_SAFE_CALL(cuEventSynchronize(stop_event)); CU_SAFE_CALL( cuEventElapsedTime(&timer,start_event,stop_event) ); - return timer; + return timer; } - + /// Return the time (s) of last start to stop - Forces synchronization inline double seconds() { return time()/1000.0; } - + /// Return the total time in ms inline double total_time() { return _total_time; } diff --git a/lib/gpu/geryon/ocl_device.h b/lib/gpu/geryon/ocl_device.h index 8dadcf2efd..20656c8489 100644 --- a/lib/gpu/geryon/ocl_device.h +++ b/lib/gpu/geryon/ocl_device.h @@ -17,7 +17,7 @@ /* ----------------------------------------------------------------------- Copyright (2009) Sandia Corporation. Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains - certain rights in this software. This software is distributed under + certain rights in this software. This software is distributed under the Simplified BSD License. ----------------------------------------------------------------------- */ @@ -40,13 +40,13 @@ #include "ucl_types.h" namespace ucl_opencl { - + // -------------------------------------------------------------------------- // - COMMAND QUEUE STUFF // -------------------------------------------------------------------------- -typedef cl_command_queue command_queue; +typedef cl_command_queue command_queue; typedef cl_context context_type; - + inline void ucl_sync(cl_command_queue &cq) { CL_SAFE_CALL(clFinish(cq)); } @@ -76,19 +76,19 @@ struct OCLProperties { /// Class for looking at data parallel device properties /** \note Calls to change the device outside of the class results in incorrect - * behavior + * behavior * \note There is no error checking for indexing past the number of devices **/ class UCL_Device { public: /// Collect properties for every device on the node /** \note You must set the active GPU with set() before using the device **/ inline UCL_Device(); - + inline ~UCL_Device(); /// Return the number of platforms (0 if error or no platforms) inline int num_platforms() { return _num_platforms; } - + /// Return a string with name and info of the current platform inline std::string platform_name(); @@ -104,38 +104,38 @@ class UCL_Device { * be allocated for use. clear() is called to delete any contexts and * associated data from previous calls to set(). **/ inline int set(int num); - + /// Delete any context and associated data stored from a call to set() inline void clear(); /// Get the current device number inline int device_num() { return _device; } - + /// Returns the context for the current device inline cl_context & context() { return _context; } - + /// Returns the default stream for the current device inline command_queue & cq() { return cq(_default_cq); } - + /// Returns the stream indexed by i inline command_queue & cq(const int i) { return _cq[i]; } - + /// Set the default command queue - /** \param i index of the command queue (as added by push_command_queue()) + /** \param i index of the command queue (as added by push_command_queue()) If i is 0, the command queue created with device initialization is used **/ inline void set_command_queue(const int i) { _default_cq=i; } - + /// Block until all commands in the default stream have completed inline void sync() { sync(_default_cq); } - + /// Block until all commands in the specified stream have completed inline void sync(const int i) { ucl_sync(cq(i)); } - + /// Get the number of command queues currently available on device - inline int num_queues() + inline int num_queues() { return _cq.size(); } - + /// Add a command queue for device computations (with profiling enabled) inline void push_command_queue() { cl_int errorv; @@ -143,7 +143,7 @@ class UCL_Device { _cq.back()=clCreateCommandQueue(_context,_cl_device, CL_QUEUE_PROFILING_ENABLE,&errorv); if (errorv!=CL_SUCCESS) { - std::cerr << "Could not create command queue on device: " << name() + std::cerr << "Could not create command queue on device: " << name() << std::endl; UCL_GERYON_EXIT; } @@ -160,76 +160,76 @@ class UCL_Device { /// Get the current OpenCL device name inline std::string name() { return name(_device); } /// Get the OpenCL device name - inline std::string name(const int i) + inline std::string name(const int i) { return std::string(_properties[i].name); } /// Get a string telling the type of the current device inline std::string device_type_name() { return device_type_name(_device); } /// Get a string telling the type of the device inline std::string device_type_name(const int i); - + /// Get current device type (UCL_CPU, UCL_GPU, UCL_ACCELERATOR, UCL_DEFAULT) inline int device_type() { return device_type(_device); } /// Get device type (UCL_CPU, UCL_GPU, UCL_ACCELERATOR, UCL_DEFAULT) inline int device_type(const int i); - + /// Returns true if host memory is efficiently addressable from device inline bool shared_memory() { return shared_memory(_device); } /// Returns true if host memory is efficiently addressable from device - inline bool shared_memory(const int i) + inline bool shared_memory(const int i) { return _shared_mem_device(_properties[i].device_type); } - + /// Returns true if double precision is support for the current device inline bool double_precision() { return double_precision(_device); } /// Returns true if double precision is support for the device - inline bool double_precision(const int i) + inline bool double_precision(const int i) {return _properties[i].double_precision;} - + /// Get the number of compute units on the current device inline unsigned cus() { return cus(_device); } /// Get the number of compute units - inline unsigned cus(const int i) + inline unsigned cus(const int i) { return _properties[i].compute_units; } /// Get the gigabytes of global memory in the current device inline double gigabytes() { return gigabytes(_device); } /// Get the gigabytes of global memory - inline double gigabytes(const int i) + inline double gigabytes(const int i) { return static_cast(_properties[i].global_mem)/1073741824; } /// Get the bytes of global memory in the current device inline size_t bytes() { return bytes(_device); } /// Get the bytes of global memory inline size_t bytes(const int i) { return _properties[i].global_mem; } - + /// Return the GPGPU revision number for current device //inline double revision() { return revision(_device); } /// Return the GPGPU revision number - //inline double revision(const int i) + //inline double revision(const int i) // { return //static_cast(_properties[i].minor)/10+_properties[i].major;} - + /// Clock rate in GHz for current device inline double clock_rate() { return clock_rate(_device); } /// Clock rate in GHz inline double clock_rate(const int i) { return _properties[i].clock*1e-3;} - + /// Return the address alignment in bytes inline int alignment() { return alignment(_device); } /// Return the address alignment in bytes inline int alignment(const int i) { return _properties[i].alignment; } - + /// Return the timer resolution inline size_t timer_resolution() { return timer_resolution(_device); } /// Return the timer resolution - inline size_t timer_resolution(const int i) + inline size_t timer_resolution(const int i) { return _properties[i].timer_resolution; } - + /// Get the maximum number of threads per block inline size_t group_size() { return group_size(_device); } /// Get the maximum number of threads per block - inline size_t group_size(const int i) + inline size_t group_size(const int i) { return _properties[i].work_group_size; } - + /// Return the maximum memory pitch in bytes for current device inline size_t max_pitch() { return max_pitch(_device); } /// Return the maximum memory pitch in bytes @@ -254,7 +254,7 @@ class UCL_Device { { return fission_by_counts(_device); } /// True if splitting device into subdevices by specified counts supported inline bool fission_by_counts(const int i) - { return _properties[i].partition_counts; } + { return _properties[i].partition_counts; } /// True if splitting device into subdevices by affinity domains supported inline bool fission_by_affinity() { return fission_by_affinity(_device); } @@ -271,10 +271,10 @@ class UCL_Device { /// List all devices along with all properties inline void print_all(std::ostream &out); - + /// Return the OpenCL type for the device inline cl_device_id & cl_device() { return _cl_device; } - + private: int _num_platforms; // Number of platforms int _platform; // UCL_Device ID for current platform @@ -287,7 +287,7 @@ class UCL_Device { std::vector _cl_devices; // OpenCL IDs for all devices int _num_devices; // Number of devices std::vector _properties; // Properties for each device - + inline void add_properties(cl_device_id); inline int create_context(); int _default_cq; @@ -300,7 +300,7 @@ UCL_Device::UCL_Device() { // --- Get Number of Platforms cl_uint nplatforms; cl_int errorv=clGetPlatformIDs(20,_cl_platforms,&nplatforms); - + if (errorv!=CL_SUCCESS) { _num_platforms=0; return; @@ -328,18 +328,18 @@ void UCL_Device::clear() { int UCL_Device::set_platform(int pid) { clear(); cl_int errorv; - + _cl_device=0; _device=-1; _num_devices=0; _default_cq=0; - + #ifdef UCL_DEBUG assert(pid namespace ucl_opencl { - + class UCL_Texture; template class UCL_D_Vec; template class UCL_D_Mat; @@ -41,10 +41,10 @@ class UCL_Program { public: inline UCL_Program() : _init_done(false) {} inline UCL_Program(UCL_Device &device) : _init_done(false) { init(device); } - inline UCL_Program(UCL_Device &device, const void *program, - const char *flags="", std::string *log=NULL) : - _init_done(false) { - init(device); + inline UCL_Program(UCL_Device &device, const void *program, + const char *flags="", std::string *log=NULL) : + _init_done(false) { + init(device); load_string(program,flags,log); } @@ -56,7 +56,7 @@ class UCL_Program { _device=device.cl_device(); _context=device.context(); _cq=device.cq(); - CL_SAFE_CALL(clRetainContext(_context)); + CL_SAFE_CALL(clRetainContext(_context)); CL_SAFE_CALL(clRetainCommandQueue(_cq)); _init_done=true; } @@ -65,7 +65,7 @@ class UCL_Program { /** \note Must call init() after each clear **/ inline void clear() { if (_init_done) { - CL_DESTRUCT_CALL(clReleaseProgram(_program)); + CL_DESTRUCT_CALL(clReleaseProgram(_program)); CL_DESTRUCT_CALL(clReleaseContext(_context)); CL_DESTRUCT_CALL(clReleaseCommandQueue(_cq)); _init_done=false; @@ -77,20 +77,20 @@ class UCL_Program { std::string *log=NULL) { std::ifstream in(filename); if (!in || in.is_open()==false) { - #ifndef UCL_NO_EXIT - std::cerr << "UCL Error: Could not open kernel file: " + #ifndef UCL_NO_EXIT + std::cerr << "UCL Error: Could not open kernel file: " << filename << std::endl; UCL_GERYON_EXIT; #endif return UCL_FILE_NOT_FOUND; } - + std::string program((std::istreambuf_iterator(in)), std::istreambuf_iterator()); in.close(); return load_string(program.c_str(),flags,log); } - + /// Load a program from a string and compile with flags inline int load_string(const void *program, const char *flags="", std::string *log=NULL) { @@ -103,23 +103,23 @@ class UCL_Program { CL_CHECK_ERR(error_flag); cl_build_status build_status; CL_SAFE_CALL(clGetProgramBuildInfo(_program,_device, - CL_PROGRAM_BUILD_STATUS, + CL_PROGRAM_BUILD_STATUS, sizeof(cl_build_status),&build_status, NULL)); - + if (build_status != CL_SUCCESS || log!=NULL) { size_t ms; - CL_SAFE_CALL(clGetProgramBuildInfo(_program,_device,CL_PROGRAM_BUILD_LOG,0, + CL_SAFE_CALL(clGetProgramBuildInfo(_program,_device,CL_PROGRAM_BUILD_LOG,0, NULL, &ms)); - char build_log[ms]; + char build_log[ms]; CL_SAFE_CALL(clGetProgramBuildInfo(_program,_device,CL_PROGRAM_BUILD_LOG,ms, build_log, NULL)); - + if (log!=NULL) *log=std::string(build_log); - + if (build_status != CL_SUCCESS) { - #ifndef UCL_NO_EXIT + #ifndef UCL_NO_EXIT std::cerr << std::endl << "----------------------------------------------------------\n" << " UCL Error: Error compiling OpenCL Program (" @@ -130,10 +130,10 @@ class UCL_Program { return UCL_COMPILE_ERROR; } } - + return UCL_SUCCESS; } - + /// Return the default command queue/stream associated with this data inline command_queue & cq() { return _cq; } /// Change the default command queue associated with matrix @@ -143,7 +143,7 @@ class UCL_Program { private: bool _init_done; cl_program _program; - cl_device_id _device; + cl_device_id _device; cl_context _context; cl_command_queue _cq; }; @@ -153,7 +153,7 @@ class UCL_Kernel { public: UCL_Kernel() : _dimensions(1), _function_set(false), _num_args(0) { _block_size[0]=0; _num_blocks[0]=0; } - + inline UCL_Kernel(UCL_Program &program, const char *function) : _dimensions(1), _function_set(false), _num_args(0) { _block_size[0]=0; _num_blocks[0]=0; set_function(program,function); } @@ -178,48 +178,48 @@ class UCL_Kernel { /** If not a device pointer, this must be repeated each time the argument * changes **/ template - inline void set_arg(const cl_uint index, const dtype * const arg) { - CL_SAFE_CALL(clSetKernelArg(_kernel,index,sizeof(dtype),arg)); + inline void set_arg(const cl_uint index, const dtype * const arg) { + CL_SAFE_CALL(clSetKernelArg(_kernel,index,sizeof(dtype),arg)); if (index>_num_args) { _num_args=index; #ifdef UCL_DEBUG if (_num_args>_kernel_info_nargs) { - std::cerr << "TOO MANY ARGUMENTS TO OPENCL FUNCTION: " + std::cerr << "TOO MANY ARGUMENTS TO OPENCL FUNCTION: " << _kernel_info_name << std::endl; assert(0==1); } #endif } } - + /// Set a geryon container as a kernel argument. template - inline void set_arg(const UCL_D_Vec * const arg) + inline void set_arg(const UCL_D_Vec * const arg) { set_arg(&arg->begin()); } /// Set a geryon container as a kernel argument. template - inline void set_arg(const UCL_D_Mat * const arg) + inline void set_arg(const UCL_D_Mat * const arg) { set_arg(&arg->begin()); } /// Set a geryon container as a kernel argument. template - inline void set_arg(const UCL_Vector * const arg) + inline void set_arg(const UCL_Vector * const arg) { set_arg(&arg->device.begin()); } /// Set a geryon container as a kernel argument. template - inline void set_arg(const UCL_Matrix * const arg) + inline void set_arg(const UCL_Matrix * const arg) { set_arg(&arg->device.begin()); } /// Add a kernel argument. template inline void add_arg(const dtype * const arg) { - CL_SAFE_CALL(clSetKernelArg(_kernel,_num_args,sizeof(dtype),arg)); - _num_args++; + CL_SAFE_CALL(clSetKernelArg(_kernel,_num_args,sizeof(dtype),arg)); + _num_args++; #ifdef UCL_DEBUG if (_num_args>_kernel_info_nargs) { - std::cerr << "TOO MANY ARGUMENTS TO OPENCL FUNCTION: " + std::cerr << "TOO MANY ARGUMENTS TO OPENCL FUNCTION: " << _kernel_info_name << std::endl; assert(0==1); } @@ -228,31 +228,31 @@ class UCL_Kernel { /// Add a geryon container as a kernel argument. template - inline void add_arg(const UCL_D_Vec * const arg) + inline void add_arg(const UCL_D_Vec * const arg) { add_arg(&arg->begin()); } /// Add a geryon container as a kernel argument. template - inline void add_arg(const UCL_D_Mat * const arg) + inline void add_arg(const UCL_D_Mat * const arg) { add_arg(&arg->begin()); } /// Add a geryon container as a kernel argument. template - inline void add_arg(const UCL_Vector * const arg) + inline void add_arg(const UCL_Vector * const arg) { add_arg(&arg->device.begin()); } /// Add a geryon container as a kernel argument. template - inline void add_arg(const UCL_Matrix * const arg) + inline void add_arg(const UCL_Matrix * const arg) { add_arg(&arg->device.begin()); } /// Set the number of thread blocks and the number of threads in each block /** \note This should be called before any arguments have been added \note The default command queue is used for the kernel execution **/ - inline void set_size(const size_t num_blocks, const size_t block_size) { - _dimensions=1; - _num_blocks[0]=num_blocks*block_size; - _block_size[0]=block_size; + inline void set_size(const size_t num_blocks, const size_t block_size) { + _dimensions=1; + _num_blocks[0]=num_blocks*block_size; + _block_size[0]=block_size; } /// Set the number of thread blocks and the number of threads in each block @@ -266,36 +266,36 @@ class UCL_Kernel { /** \note This should be called before any arguments have been added \note The default command queue is used for the kernel execution **/ inline void set_size(const size_t num_blocks_x, const size_t num_blocks_y, - const size_t block_size_x, const size_t block_size_y) { - _dimensions=2; - _num_blocks[0]=num_blocks_x*block_size_x; - _block_size[0]=block_size_x; - _num_blocks[1]=num_blocks_y*block_size_y; - _block_size[1]=block_size_y; + const size_t block_size_x, const size_t block_size_y) { + _dimensions=2; + _num_blocks[0]=num_blocks_x*block_size_x; + _block_size[0]=block_size_x; + _num_blocks[1]=num_blocks_y*block_size_y; + _block_size[1]=block_size_y; } - + /// Set the number of thread blocks and the number of threads in each block /** \note This should be called before any arguments have been added \note The default command queue for the kernel is changed to cq **/ inline void set_size(const size_t num_blocks_x, const size_t num_blocks_y, const size_t block_size_x, const size_t block_size_y, - command_queue &cq) + command_queue &cq) {_cq=cq; set_size(num_blocks_x, num_blocks_y, block_size_x, block_size_y);} /// Set the number of thread blocks and the number of threads in each block /** \note This should be called before any arguments have been added \note The default command queue is used for the kernel execution **/ inline void set_size(const size_t num_blocks_x, const size_t num_blocks_y, - const size_t block_size_x, + const size_t block_size_x, const size_t block_size_y, const size_t block_size_z) { - _dimensions=3; + _dimensions=3; const size_t num_blocks_z=1; - _num_blocks[0]=num_blocks_x*block_size_x; - _block_size[0]=block_size_x; - _num_blocks[1]=num_blocks_y*block_size_y; - _block_size[1]=block_size_y; - _num_blocks[2]=num_blocks_z*block_size_z; - _block_size[2]=block_size_z; + _num_blocks[0]=num_blocks_x*block_size_x; + _block_size[0]=block_size_x; + _num_blocks[1]=num_blocks_y*block_size_y; + _block_size[1]=block_size_y; + _num_blocks[2]=num_blocks_z*block_size_z; + _block_size[2]=block_size_z; } /// Set the number of thread blocks and the number of threads in each block @@ -305,13 +305,13 @@ class UCL_Kernel { const size_t block_size_x, const size_t block_size_y, const size_t block_size_z, command_queue &cq) { _cq=cq; - set_size(num_blocks_x, num_blocks_y, block_size_x, block_size_y, + set_size(num_blocks_x, num_blocks_y, block_size_x, block_size_y, block_size_z); } - + /// Run the kernel in the default command queue inline void run(); - + /// Clear any arguments associated with the kernel inline void clear_args() { _num_args=0; } @@ -320,7 +320,7 @@ class UCL_Kernel { /// Change the default command queue associated with matrix inline void cq(command_queue &cq_in) { _cq=cq_in; } #include "ucl_arg_kludge.h" - + private: cl_kernel _kernel; cl_program _program; @@ -328,7 +328,7 @@ class UCL_Kernel { size_t _block_size[3]; size_t _num_blocks[3]; bool _function_set; - + cl_command_queue _cq; // The default command queue for this kernel unsigned _num_args; @@ -348,7 +348,7 @@ inline int UCL_Kernel::set_function(UCL_Program &program, const char *function) CL_SAFE_CALL(clRetainProgram(_program)); cl_int error_flag; _kernel=clCreateKernel(program._program,function,&error_flag); - + if (error_flag!=CL_SUCCESS) { #ifndef UCL_NO_EXIT std::cerr << "UCL Error: Could not find function: " << function @@ -357,7 +357,7 @@ inline int UCL_Kernel::set_function(UCL_Program &program, const char *function) #endif return UCL_FUNCTION_NOT_FOUND; } - + #ifdef UCL_DEBUG _kernel_info_name=function; cl_uint nargs; @@ -375,7 +375,7 @@ inline int UCL_Kernel::set_function(UCL_Program &program, const char *function) #endif #endif - return UCL_SUCCESS; + return UCL_SUCCESS; } void UCL_Kernel::run() { diff --git a/lib/gpu/geryon/ocl_mat.h b/lib/gpu/geryon/ocl_mat.h index 2909d72a72..3135594dc3 100644 --- a/lib/gpu/geryon/ocl_mat.h +++ b/lib/gpu/geryon/ocl_mat.h @@ -17,12 +17,12 @@ /* ----------------------------------------------------------------------- Copyright (2010) Sandia Corporation. Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains - certain rights in this software. This software is distributed under + certain rights in this software. This software is distributed under the Simplified BSD License. ----------------------------------------------------------------------- */ /*! \file */ - + #ifndef OCL_MAT_H #define OCL_MAT_H @@ -54,6 +54,6 @@ namespace ucl_opencl { #include "ucl_print.h" #undef UCL_PRINT_ALLOW -} // namespace ucl_cudart +} // namespace ucl_cudart #endif diff --git a/lib/gpu/geryon/ocl_memory.h b/lib/gpu/geryon/ocl_memory.h index 7aed0a1a8c..28bb88941f 100644 --- a/lib/gpu/geryon/ocl_memory.h +++ b/lib/gpu/geryon/ocl_memory.h @@ -17,7 +17,7 @@ /* ----------------------------------------------------------------------- Copyright (2010) Sandia Corporation. Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains - certain rights in this software. This software is distributed under + certain rights in this software. This software is distributed under the Simplified BSD License. ----------------------------------------------------------------------- */ @@ -36,10 +36,10 @@ namespace ucl_opencl { // -------------------------------------------------------------------------- struct ocl_kernel_dim { size_t x,y,z; - ocl_kernel_dim(size_t _x = 1, size_t _y = 1, size_t _z = 1) : + ocl_kernel_dim(size_t _x = 1, size_t _y = 1, size_t _z = 1) : x(_x), y(_y), z(_z) {} operator size_t * () { return (size_t *)this; } - operator const size_t * () const { return (const size_t *)this; } + operator const size_t * () const { return (const size_t *)this; } }; typedef ocl_kernel_dim ucl_kernel_dim; @@ -53,13 +53,13 @@ typedef cl_mem device_ptr; // -------------------------------------------------------------------------- template -inline int _host_alloc(mat_type &mat, copy_type &cm, const size_t n, +inline int _host_alloc(mat_type &mat, copy_type &cm, const size_t n, const enum UCL_MEMOPT kind, const enum UCL_MEMOPT kind2){ cl_int error_flag; cl_context context; CL_SAFE_CALL(clGetMemObjectInfo(cm.cbegin(),CL_MEM_CONTEXT,sizeof(context), &context,NULL)); - + cl_mem_flags buffer_perm; cl_map_flags map_perm; if (kind2==UCL_NOT_SPECIFIED) { @@ -88,7 +88,7 @@ inline int _host_alloc(mat_type &mat, copy_type &cm, const size_t n, buffer_perm=CL_MEM_WRITE_ONLY | CL_MEM_ALLOC_HOST_PTR; else buffer_perm=CL_MEM_READ_WRITE | CL_MEM_ALLOC_HOST_PTR; - + if (kind==UCL_READ_ONLY) { #ifdef CL_VERSION_1_2 buffer_perm=buffer_perm | CL_MEM_HOST_READ_ONLY; @@ -102,9 +102,9 @@ inline int _host_alloc(mat_type &mat, copy_type &cm, const size_t n, } else map_perm=CL_MAP_READ | CL_MAP_WRITE; } - + mat.cbegin()=clCreateBuffer(context,buffer_perm,n,NULL,&error_flag); - if (error_flag != CL_SUCCESS) + if (error_flag != CL_SUCCESS) return UCL_MEMORY_ERROR; *mat.host_ptr() = (typename mat_type::data_type*) clEnqueueMapBuffer(cm.cq(),mat.cbegin(),CL_TRUE, @@ -125,7 +125,7 @@ inline int _host_view(mat_type &mat, copy_type &cm, const size_t n) { CL_SAFE_CALL(clGetMemObjectInfo(cm.cbegin(),CL_MEM_FLAGS,sizeof(orig_flags), &orig_flags,NULL)); orig_flags=orig_flags & ~CL_MEM_ALLOC_HOST_PTR; - + mat.cbegin()=clCreateBuffer(context, CL_MEM_USE_HOST_PTR | orig_flags, n, *mat.host_ptr(), &error_flag); @@ -135,7 +135,7 @@ inline int _host_view(mat_type &mat, copy_type &cm, const size_t n) { } template -inline int _host_alloc(mat_type &mat, UCL_Device &dev, const size_t n, +inline int _host_alloc(mat_type &mat, UCL_Device &dev, const size_t n, const enum UCL_MEMOPT kind, const enum UCL_MEMOPT kind2){ cl_mem_flags buffer_perm; cl_map_flags map_perm; @@ -160,7 +160,7 @@ inline int _host_alloc(mat_type &mat, UCL_Device &dev, const size_t n, cl_int error_flag; mat.cbegin()=clCreateBuffer(dev.context(),buffer_perm,n,NULL,&error_flag); - if (error_flag != CL_SUCCESS) + if (error_flag != CL_SUCCESS) return UCL_MEMORY_ERROR; *mat.host_ptr() = (typename mat_type::data_type*) @@ -210,7 +210,7 @@ inline int _host_resize(mat_type &mat, const size_t n) { map_perm=CL_MAP_READ | CL_MAP_WRITE; mat.cbegin()=clCreateBuffer(context,buffer_perm,n,NULL,&error_flag); - if (error_flag != CL_SUCCESS) + if (error_flag != CL_SUCCESS) return UCL_MEMORY_ERROR; *mat.host_ptr() = (typename mat_type::data_type*) clEnqueueMapBuffer(mat.cq(),mat.cbegin(),CL_TRUE, @@ -248,7 +248,7 @@ inline int _device_alloc(mat_type &mat, copy_type &cm, const size_t n, else assert(0==1); mat.cbegin()=clCreateBuffer(context,flag,n,NULL,&error_flag); - if (error_flag != CL_SUCCESS) + if (error_flag != CL_SUCCESS) return UCL_MEMORY_ERROR; mat.cq()=cm.cq(); CL_SAFE_CALL(clRetainCommandQueue(mat.cq())); @@ -278,7 +278,7 @@ inline int _device_alloc(mat_type &mat, UCL_Device &dev, const size_t n, assert(0==1); mat.cbegin()=clCreateBuffer(dev.context(),flag,n,NULL, &error_flag); - if (error_flag != CL_SUCCESS) + if (error_flag != CL_SUCCESS) return UCL_MEMORY_ERROR; mat.cq()=dev.cq(); CL_SAFE_CALL(clRetainCommandQueue(mat.cq())); @@ -304,7 +304,7 @@ inline int _device_alloc(mat_type &mat, UCL_Device &dev, const size_t rows, if (dev.device_type()!=UCL_CPU && cols%256!=0) padded_cols+=256-cols%256; pitch=padded_cols*sizeof(typename mat_type::data_type); - return _device_alloc(mat,dev,pitch*rows,kind); + return _device_alloc(mat,dev,pitch*rows,kind); } template @@ -342,7 +342,7 @@ inline int _device_resize(mat_type &mat, const size_t n) { else assert(0==1); mat.cbegin()=clCreateBuffer(context,flag,n,NULL,&error_flag); - if (error_flag != CL_SUCCESS) + if (error_flag != CL_SUCCESS) return UCL_MEMORY_ERROR; return UCL_SUCCESS; } @@ -380,7 +380,7 @@ inline int _device_resize(mat_type &mat, const size_t rows, else assert(0==1); mat.cbegin()=clCreateBuffer(context,flag,pitch*rows,NULL,&error_flag); - if (error_flag != CL_SUCCESS) + if (error_flag != CL_SUCCESS) return UCL_MEMORY_ERROR; return UCL_SUCCESS; } @@ -396,21 +396,21 @@ inline void _host_zero(void *ptr, const size_t n) { inline void _ocl_build(cl_program &program, cl_device_id &device, const char* options = "") { clBuildProgram(program,1,&device,options,NULL,NULL); - + cl_build_status build_status; - CL_SAFE_CALL(clGetProgramBuildInfo(program, device, CL_PROGRAM_BUILD_STATUS, + CL_SAFE_CALL(clGetProgramBuildInfo(program, device, CL_PROGRAM_BUILD_STATUS, sizeof(cl_build_status),&build_status, NULL)); if (build_status == CL_SUCCESS) return; - + size_t ms; - CL_SAFE_CALL(clGetProgramBuildInfo(program, device,CL_PROGRAM_BUILD_LOG, 0, + CL_SAFE_CALL(clGetProgramBuildInfo(program, device,CL_PROGRAM_BUILD_LOG, 0, NULL, &ms)); - char build_log[ms]; + char build_log[ms]; CL_SAFE_CALL(clGetProgramBuildInfo(program,device,CL_PROGRAM_BUILD_LOG,ms, build_log, NULL)); - + std::cerr << std::endl << "----------------------------------------------------------\n" << " Error compiling OpenCL Program...\n" @@ -423,13 +423,13 @@ inline void _ocl_kernel_from_source(cl_context &context, cl_device_id &device, cl_kernel &kernel, const char *function, const char *options="") { cl_int error_flag; - + cl_program program=clCreateProgramWithSource(context,lines,source, NULL,&error_flag); - CL_CHECK_ERR(error_flag); + CL_CHECK_ERR(error_flag); _ocl_build(program,device,options); kernel=clCreateKernel(program,function,&error_flag); - CL_CHECK_ERR(error_flag); + CL_CHECK_ERR(error_flag); } template @@ -452,17 +452,17 @@ inline void _device_zero(mat_type &mat, const size_t n, command_queue &cq) { cl_device_id device; CL_SAFE_CALL(clGetContextInfo(context,CL_CONTEXT_DEVICES, sizeof(cl_device_id),&device,NULL)); - + const char * szero[3]={ "#pragma OPENCL EXTENSION cl_khr_fp64 : enable\n", "__kernel void _device_zero(__global NUMTYP *a, const int offset)", " { int gid=get_global_id(0)+offset; a[gid]=(NUMTYP)0; }" }; - + cl_kernel kzero; _ocl_kernel_from_source(context,device,szero,3,kzero,"_device_zero", _UCL_DATA_ID::numtyp_flag()); - + cl_int offset=mat.offset(); CL_SAFE_CALL(clSetKernelArg(kzero,0,sizeof(cl_mem),(void *)&mat.begin())); CL_SAFE_CALL(clSetKernelArg(kzero,1,sizeof(cl_int),(void *)&offset)); @@ -486,7 +486,7 @@ template<> struct _ucl_memcpy<2,2> { assert(0==1); } template - static inline void mc(p1 &dst, const size_t dpitch, const p2 &src, + static inline void mc(p1 &dst, const size_t dpitch, const p2 &src, const size_t spitch, const size_t cols, const size_t rows, cl_command_queue &cq, const cl_bool block, @@ -504,7 +504,7 @@ template<> struct _ucl_memcpy<2,0> { assert(0==1); } template - static inline void mc(p1 &dst, const size_t dpitch, const p2 &src, + static inline void mc(p1 &dst, const size_t dpitch, const p2 &src, const size_t spitch, const size_t cols, const size_t rows, cl_command_queue &cq, const cl_bool block, @@ -522,7 +522,7 @@ template<> struct _ucl_memcpy<2,1> { assert(0==1); } template - static inline void mc(p1 &dst, const size_t dpitch, const p2 &src, + static inline void mc(p1 &dst, const size_t dpitch, const p2 &src, const size_t spitch, const size_t cols, const size_t rows, cl_command_queue &cq, const cl_bool block, @@ -540,7 +540,7 @@ template<> struct _ucl_memcpy<0,2> { assert(0==1); } template - static inline void mc(p1 &dst, const size_t dpitch, const p2 &src, + static inline void mc(p1 &dst, const size_t dpitch, const p2 &src, const size_t spitch, const size_t cols, const size_t rows, cl_command_queue &cq, const cl_bool block, @@ -558,7 +558,7 @@ template<> struct _ucl_memcpy<1,2> { assert(0==1); } template - static inline void mc(p1 &dst, const size_t dpitch, const p2 &src, + static inline void mc(p1 &dst, const size_t dpitch, const p2 &src, const size_t spitch, const size_t cols, const size_t rows, cl_command_queue &cq, const cl_bool block, @@ -587,9 +587,9 @@ template <> struct _ucl_memcpy<1,0> { dst.begin(),0,NULL,NULL)); } template - static inline void mc(p1 &dst, const size_t dpitch, const p2 &src, + static inline void mc(p1 &dst, const size_t dpitch, const p2 &src, const size_t spitch, const size_t cols, - const size_t rows, cl_command_queue &cq, + const size_t rows, cl_command_queue &cq, const cl_bool block, size_t dst_offset, size_t src_offset) { if (src.cbegin()==dst.cbegin()) { @@ -602,20 +602,20 @@ template <> struct _ucl_memcpy<1,0> { #ifdef UCL_DBG_MEM_TRACE std::cerr << "UCL_COPY 2NS\n"; #endif - if (spitch==dpitch && dst.cols()==src.cols() && + if (spitch==dpitch && dst.cols()==src.cols() && src.cols()==cols/src.element_size()) CL_SAFE_CALL(clEnqueueReadBuffer(cq,src.cbegin(),block,src_offset, spitch*rows, (char *)dst.begin()+dst_offset,0,NULL, NULL)); else - for (size_t i=0; i struct _ucl_memcpy<0,1> { #ifdef UCL_DBG_MEM_TRACE std::cerr << "UCL_COPY 3S\n"; #endif - return; + return; } #ifdef UCL_DBG_MEM_TRACE std::cerr << "UCL_COPY 3NS\n"; @@ -639,9 +639,9 @@ template <> struct _ucl_memcpy<0,1> { src.begin(),0,NULL,NULL)); } template - static inline void mc(p1 &dst, const size_t dpitch, const p2 &src, + static inline void mc(p1 &dst, const size_t dpitch, const p2 &src, const size_t spitch, const size_t cols, - const size_t rows, cl_command_queue &cq, + const size_t rows, cl_command_queue &cq, const cl_bool block, size_t dst_offset, size_t src_offset) { if (src.cbegin()==dst.cbegin()) { @@ -649,12 +649,12 @@ template <> struct _ucl_memcpy<0,1> { #ifdef UCL_DBG_MEM_TRACE std::cerr << "UCL_COPY 4S\n"; #endif - return; + return; } #ifdef UCL_DBG_MEM_TRACE std::cerr << "UCL_COPY 4NS\n"; #endif - if (spitch==dpitch && dst.cols()==src.cols() && + if (spitch==dpitch && dst.cols()==src.cols() && src.cols()==cols/src.element_size()) CL_SAFE_CALL(clEnqueueWriteBuffer(cq,dst.cbegin(),block,dst_offset, spitch*rows, @@ -667,7 +667,7 @@ template <> struct _ucl_memcpy<0,1> { NULL)); src_offset+=spitch; dst_offset+=dpitch; - } + } } }; @@ -687,33 +687,33 @@ template struct _ucl_memcpy { #ifdef UCL_DBG_MEM_TRACE else std::cerr << "UCL_COPY 6S\n"; #endif - + if (block==CL_TRUE) ucl_sync(cq); } template - static inline void mc(p1 &dst, const size_t dpitch, const p2 &src, + static inline void mc(p1 &dst, const size_t dpitch, const p2 &src, const size_t spitch, const size_t cols, const size_t rows, cl_command_queue &cq, const cl_bool block, size_t dst_offset, size_t src_offset) { - if (src.cbegin()!=dst.cbegin() || src_offset!=dst_offset) { + if (src.cbegin()!=dst.cbegin() || src_offset!=dst_offset) { #ifdef UCL_DBG_MEM_TRACE std::cerr << "UCL_COPY 7NS\n"; #endif - if (spitch==dpitch && dst.cols()==src.cols() && + if (spitch==dpitch && dst.cols()==src.cols() && src.cols()==cols/src.element_size()) CL_SAFE_CALL(clEnqueueCopyBuffer(cq,src.cbegin(),dst.cbegin(),src_offset, dst_offset,spitch*rows,0,NULL,NULL)); - + else - for (size_t i=0; i -inline void ucl_mv_cpy(mat1 &dst, const size_t dpitch, const mat2 &src, - const size_t spitch, const size_t cols, +inline void ucl_mv_cpy(mat1 &dst, const size_t dpitch, const mat2 &src, + const size_t spitch, const size_t cols, const size_t rows) { _ucl_memcpy::mc(dst,dpitch,src,spitch,cols, rows,dst.cq(),CL_TRUE, @@ -745,15 +745,15 @@ inline void ucl_mv_cpy(mat1 &dst, const size_t dpitch, const mat2 &src, } template -inline void ucl_mv_cpy(mat1 &dst, const size_t dpitch, const mat2 &src, - const size_t spitch, const size_t cols, +inline void ucl_mv_cpy(mat1 &dst, const size_t dpitch, const mat2 &src, + const size_t spitch, const size_t cols, const size_t rows,cl_command_queue &cq) { _ucl_memcpy::mc(dst,dpitch,src,spitch,cols, rows,cq,CL_FALSE, dst.byteoff(),src.byteoff()); } -} // namespace ucl_cudart +} // namespace ucl_cudart #endif diff --git a/lib/gpu/geryon/ocl_texture.h b/lib/gpu/geryon/ocl_texture.h index 8e72c51730..0e60045f55 100644 --- a/lib/gpu/geryon/ocl_texture.h +++ b/lib/gpu/geryon/ocl_texture.h @@ -17,7 +17,7 @@ /* ----------------------------------------------------------------------- Copyright (2010) Sandia Corporation. Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains - certain rights in this software. This software is distributed under + certain rights in this software. This software is distributed under the Simplified BSD License. ----------------------------------------------------------------------- */ @@ -28,7 +28,7 @@ #include "ocl_mat.h" namespace ucl_opencl { - + /// Class storing a texture reference class UCL_Texture { public: @@ -46,9 +46,9 @@ class UCL_Texture { /// Unbind the texture reference from the memory allocation inline void unbind() { } - /// Make a texture reference available to kernel + /// Make a texture reference available to kernel inline void allow(UCL_Kernel &kernel) { } - + private: friend class UCL_Kernel; }; diff --git a/lib/gpu/geryon/ocl_timer.h b/lib/gpu/geryon/ocl_timer.h index 627d19d66f..66b79dcab1 100644 --- a/lib/gpu/geryon/ocl_timer.h +++ b/lib/gpu/geryon/ocl_timer.h @@ -17,7 +17,7 @@ /* ----------------------------------------------------------------------- Copyright (2010) Sandia Corporation. Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains - certain rights in this software. This software is distributed under + certain rights in this software. This software is distributed under the Simplified BSD License. ----------------------------------------------------------------------- */ @@ -67,33 +67,33 @@ class UCL_Timer { clRetainCommandQueue(_cq); _initialized=true; } - + /// Start timing on default command queue inline void start() { UCL_OCL_MARKER(_cq,&start_event); } - + /// Stop timing on default command queue inline void stop() { UCL_OCL_MARKER(_cq,&stop_event); } - + /// Block until the start event has been reached on device - inline void sync_start() + inline void sync_start() { CL_SAFE_CALL(clWaitForEvents(1,&start_event)); } /// Block until the stop event has been reached on device - inline void sync_stop() + inline void sync_stop() { CL_SAFE_CALL(clWaitForEvents(1,&stop_event)); } /// Set the time elapsed to zero (not the total_time) - inline void zero() - { UCL_OCL_MARKER(_cq,&start_event); UCL_OCL_MARKER(_cq,&stop_event); } - + inline void zero() + { UCL_OCL_MARKER(_cq,&start_event); UCL_OCL_MARKER(_cq,&stop_event); } + /// Set the total time to zero inline void zero_total() { _total_time=0.0; } - + /// Add time from previous start and stop to total /** Forces synchronization **/ - inline double add_to_total() + inline double add_to_total() { double t=time(); _total_time+=t; return t/1000.0; } - + /// Add a user specified time to the total (ms) inline void add_time_to_total(const double t) { _total_time+=t; } @@ -107,12 +107,12 @@ class UCL_Timer { CL_SAFE_CALL(clGetEventProfilingInfo(start_event, CL_PROFILING_COMMAND_END, sizeof(cl_ulong), &tstart, NULL)); - return (tend-tstart)*t_factor; + return (tend-tstart)*t_factor; } - + /// Return the time (s) of last start to stop - Forces synchronization inline double seconds() { return time()/1000.0; } - + /// Return the total time in ms inline double total_time() { return _total_time; } diff --git a/lib/gpu/geryon/ucl_arg_kludge.h b/lib/gpu/geryon/ucl_arg_kludge.h index 646aa4d68f..eea913863d 100644 --- a/lib/gpu/geryon/ucl_arg_kludge.h +++ b/lib/gpu/geryon/ucl_arg_kludge.h @@ -17,7 +17,7 @@ /* ----------------------------------------------------------------------- Copyright (2010) Sandia Corporation. Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains - certain rights in this software. This software is distributed under + certain rights in this software. This software is distributed under the Simplified BSD License. ----------------------------------------------------------------------- */ @@ -38,47 +38,47 @@ template inline void add_args(t1 *a1, t2 *a2, t3 *a3, t4 *a4, t5 *a5) { - add_arg(a1); add_arg(a2); add_arg(a3); add_arg(a4); add_arg(a5); + add_arg(a1); add_arg(a2); add_arg(a3); add_arg(a4); add_arg(a5); } template inline void add_args(t1 *a1, t2 *a2, t3 *a3, t4 *a4, t5 *a5, t6 *a6) { - add_arg(a1); add_arg(a2); add_arg(a3); add_arg(a4); add_arg(a5); - add_arg(a6); + add_arg(a1); add_arg(a2); add_arg(a3); add_arg(a4); add_arg(a5); + add_arg(a6); } template inline void add_args(t1 *a1, t2 *a2, t3 *a3, t4 *a4, t5 *a5, t6 *a6, t7 *a7) { - add_arg(a1); add_arg(a2); add_arg(a3); add_arg(a4); add_arg(a5); - add_arg(a6); add_arg(a7); + add_arg(a1); add_arg(a2); add_arg(a3); add_arg(a4); add_arg(a5); + add_arg(a6); add_arg(a7); } template inline void add_args(t1 *a1, t2 *a2, t3 *a3, t4 *a4, t5 *a5, t6 *a6, t7 *a7, t8 *a8) { - add_arg(a1); add_arg(a2); add_arg(a3); add_arg(a4); add_arg(a5); - add_arg(a6); add_arg(a7); add_arg(a8); + add_arg(a1); add_arg(a2); add_arg(a3); add_arg(a4); add_arg(a5); + add_arg(a6); add_arg(a7); add_arg(a8); } template inline void add_args(t1 *a1, t2 *a2, t3 *a3, t4 *a4, t5 *a5, t6 *a6, t7 *a7, t8 *a8, t9 *a9) { - add_arg(a1); add_arg(a2); add_arg(a3); add_arg(a4); add_arg(a5); - add_arg(a6); add_arg(a7); add_arg(a8); add_arg(a9); + add_arg(a1); add_arg(a2); add_arg(a3); add_arg(a4); add_arg(a5); + add_arg(a6); add_arg(a7); add_arg(a8); add_arg(a9); } template inline void add_args(t1 *a1, t2 *a2, t3 *a3, t4 *a4, t5 *a5, t6 *a6, t7 *a7, t8 *a8, t9 *a9, t10 *a10) { - add_arg(a1); add_arg(a2); add_arg(a3); add_arg(a4); add_arg(a5); - add_arg(a6); add_arg(a7); add_arg(a8); add_arg(a9); add_arg(a10); + add_arg(a1); add_arg(a2); add_arg(a3); add_arg(a4); add_arg(a5); + add_arg(a6); add_arg(a7); add_arg(a8); add_arg(a9); add_arg(a10); } template inline void run(t1 *a1, t2 *a2, t3 *a3, t4 *a4, t5 *a5) { clear_args(); - add_arg(a1); add_arg(a2); add_arg(a3); add_arg(a4); add_arg(a5); + add_arg(a1); add_arg(a2); add_arg(a3); add_arg(a4); add_arg(a5); run(); } @@ -434,8 +434,8 @@ inline void run(t1 *a1, t2 *a2, t3 *a3, t4 *a4, t5 *a5, t6 *a6) { clear_args(); - add_arg(a1); add_arg(a2); add_arg(a3); add_arg(a4); add_arg(a5); - add_arg(a6); + add_arg(a1); add_arg(a2); add_arg(a3); add_arg(a4); add_arg(a5); + add_arg(a6); run(); } @@ -444,8 +444,8 @@ inline void run(t1 *a1, t2 *a2, t3 *a3, t4 *a4, t5 *a5, t6 *a6, t7 *a7) { clear_args(); - add_arg(a1); add_arg(a2); add_arg(a3); add_arg(a4); add_arg(a5); - add_arg(a6); add_arg(a7); + add_arg(a1); add_arg(a2); add_arg(a3); add_arg(a4); add_arg(a5); + add_arg(a6); add_arg(a7); run(); } @@ -454,8 +454,8 @@ inline void run(t1 *a1, t2 *a2, t3 *a3, t4 *a4, t5 *a5, t6 *a6, t7 *a7, t8 *a8) { clear_args(); - add_arg(a1); add_arg(a2); add_arg(a3); add_arg(a4); add_arg(a5); - add_arg(a6); add_arg(a7); add_arg(a8); + add_arg(a1); add_arg(a2); add_arg(a3); add_arg(a4); add_arg(a5); + add_arg(a6); add_arg(a7); add_arg(a8); run(); } @@ -464,8 +464,8 @@ inline void run(t1 *a1, t2 *a2, t3 *a3, t4 *a4, t5 *a5, t6 *a6, t7 *a7, t8 *a8, t9 *a9) { clear_args(); - add_arg(a1); add_arg(a2); add_arg(a3); add_arg(a4); add_arg(a5); - add_arg(a6); add_arg(a7); add_arg(a8); add_arg(a9); + add_arg(a1); add_arg(a2); add_arg(a3); add_arg(a4); add_arg(a5); + add_arg(a6); add_arg(a7); add_arg(a8); add_arg(a9); run(); } @@ -474,8 +474,8 @@ inline void run(t1 *a1, t2 *a2, t3 *a3, t4 *a4, t5 *a5, t6 *a6, t7 *a7, t8 *a8, t9 *a9, t10 *a10) { clear_args(); - add_arg(a1); add_arg(a2); add_arg(a3); add_arg(a4); add_arg(a5); - add_arg(a6); add_arg(a7); add_arg(a8); add_arg(a9); add_arg(a10); + add_arg(a1); add_arg(a2); add_arg(a3); add_arg(a4); add_arg(a5); + add_arg(a6); add_arg(a7); add_arg(a8); add_arg(a9); add_arg(a10); run(); } @@ -486,9 +486,9 @@ t6 *a6, t7 *a7, t8 *a8, t9 *a9, t10 *a10, t11 *a11) { clear_args(); - add_arg(a1); add_arg(a2); add_arg(a3); add_arg(a4); add_arg(a5); - add_arg(a6); add_arg(a7); add_arg(a8); add_arg(a9); add_arg(a10); - add_arg(a11); + add_arg(a1); add_arg(a2); add_arg(a3); add_arg(a4); add_arg(a5); + add_arg(a6); add_arg(a7); add_arg(a8); add_arg(a9); add_arg(a10); + add_arg(a11); run(); } @@ -499,8 +499,8 @@ t6 *a6, t7 *a7, t8 *a8, t9 *a9, t10 *a10, t11 *a11, t12 *a12) { clear_args(); - add_arg(a1); add_arg(a2); add_arg(a3); add_arg(a4); add_arg(a5); - add_arg(a6); add_arg(a7); add_arg(a8); add_arg(a9); add_arg(a10); + add_arg(a1); add_arg(a2); add_arg(a3); add_arg(a4); add_arg(a5); + add_arg(a6); add_arg(a7); add_arg(a8); add_arg(a9); add_arg(a10); add_arg(a11); add_arg(a12); run(); } @@ -512,9 +512,9 @@ t6 *a6, t7 *a7, t8 *a8, t9 *a9, t10 *a10, t11 *a11, t12 *a12, t13 *a13) { clear_args(); - add_arg(a1); add_arg(a2); add_arg(a3); add_arg(a4); add_arg(a5); - add_arg(a6); add_arg(a7); add_arg(a8); add_arg(a9); add_arg(a10); - add_arg(a11); add_arg(a12); add_arg(a13); + add_arg(a1); add_arg(a2); add_arg(a3); add_arg(a4); add_arg(a5); + add_arg(a6); add_arg(a7); add_arg(a8); add_arg(a9); add_arg(a10); + add_arg(a11); add_arg(a12); add_arg(a13); run(); } @@ -525,9 +525,9 @@ t6 *a6, t7 *a7, t8 *a8, t9 *a9, t10 *a10, t11 *a11, t12 *a12, t13 *a13, t14 *a14) { clear_args(); - add_arg(a1); add_arg(a2); add_arg(a3); add_arg(a4); add_arg(a5); - add_arg(a6); add_arg(a7); add_arg(a8); add_arg(a9); add_arg(a10); - add_arg(a11); add_arg(a12); add_arg(a13); add_arg(a14); + add_arg(a1); add_arg(a2); add_arg(a3); add_arg(a4); add_arg(a5); + add_arg(a6); add_arg(a7); add_arg(a8); add_arg(a9); add_arg(a10); + add_arg(a11); add_arg(a12); add_arg(a13); add_arg(a14); run(); } @@ -538,9 +538,9 @@ t6 *a6, t7 *a7, t8 *a8, t9 *a9, t10 *a10, t11 *a11, t12 *a12, t13 *a13, t14 *a14, t15 *a15) { clear_args(); - add_arg(a1); add_arg(a2); add_arg(a3); add_arg(a4); add_arg(a5); - add_arg(a6); add_arg(a7); add_arg(a8); add_arg(a9); add_arg(a10); - add_arg(a11); add_arg(a12); add_arg(a13); add_arg(a14); add_arg(a15); + add_arg(a1); add_arg(a2); add_arg(a3); add_arg(a4); add_arg(a5); + add_arg(a6); add_arg(a7); add_arg(a8); add_arg(a9); add_arg(a10); + add_arg(a11); add_arg(a12); add_arg(a13); add_arg(a14); add_arg(a15); run(); } @@ -553,10 +553,10 @@ t11 *a11, t12 *a12, t13 *a13, t14 *a14, t15 *a15, t16 *a16) { clear_args(); - add_arg(a1); add_arg(a2); add_arg(a3); add_arg(a4); add_arg(a5); - add_arg(a6); add_arg(a7); add_arg(a8); add_arg(a9); add_arg(a10); - add_arg(a11); add_arg(a12); add_arg(a13); add_arg(a14); add_arg(a15); - add_arg(a16); + add_arg(a1); add_arg(a2); add_arg(a3); add_arg(a4); add_arg(a5); + add_arg(a6); add_arg(a7); add_arg(a8); add_arg(a9); add_arg(a10); + add_arg(a11); add_arg(a12); add_arg(a13); add_arg(a14); add_arg(a15); + add_arg(a16); run(); } @@ -569,10 +569,10 @@ t11 *a11, t12 *a12, t13 *a13, t14 *a14, t15 *a15, t16 *a16, t17 *a17) { clear_args(); - add_arg(a1); add_arg(a2); add_arg(a3); add_arg(a4); add_arg(a5); - add_arg(a6); add_arg(a7); add_arg(a8); add_arg(a9); add_arg(a10); - add_arg(a11); add_arg(a12); add_arg(a13); add_arg(a14); add_arg(a15); - add_arg(a16); add_arg(a17); + add_arg(a1); add_arg(a2); add_arg(a3); add_arg(a4); add_arg(a5); + add_arg(a6); add_arg(a7); add_arg(a8); add_arg(a9); add_arg(a10); + add_arg(a11); add_arg(a12); add_arg(a13); add_arg(a14); add_arg(a15); + add_arg(a16); add_arg(a17); run(); } @@ -585,10 +585,10 @@ t11 *a11, t12 *a12, t13 *a13, t14 *a14, t15 *a15, t16 *a16, t17 *a17, t18 *a18) { clear_args(); - add_arg(a1); add_arg(a2); add_arg(a3); add_arg(a4); add_arg(a5); - add_arg(a6); add_arg(a7); add_arg(a8); add_arg(a9); add_arg(a10); - add_arg(a11); add_arg(a12); add_arg(a13); add_arg(a14); add_arg(a15); - add_arg(a16); add_arg(a17); add_arg(a18); + add_arg(a1); add_arg(a2); add_arg(a3); add_arg(a4); add_arg(a5); + add_arg(a6); add_arg(a7); add_arg(a8); add_arg(a9); add_arg(a10); + add_arg(a11); add_arg(a12); add_arg(a13); add_arg(a14); add_arg(a15); + add_arg(a16); add_arg(a17); add_arg(a18); run(); } @@ -601,10 +601,10 @@ t11 *a11, t12 *a12, t13 *a13, t14 *a14, t15 *a15, t16 *a16, t17 *a17, t18 *a18, t19 *a19) { clear_args(); - add_arg(a1); add_arg(a2); add_arg(a3); add_arg(a4); add_arg(a5); - add_arg(a6); add_arg(a7); add_arg(a8); add_arg(a9); add_arg(a10); - add_arg(a11); add_arg(a12); add_arg(a13); add_arg(a14); add_arg(a15); - add_arg(a16); add_arg(a17); add_arg(a18); add_arg(a19); + add_arg(a1); add_arg(a2); add_arg(a3); add_arg(a4); add_arg(a5); + add_arg(a6); add_arg(a7); add_arg(a8); add_arg(a9); add_arg(a10); + add_arg(a11); add_arg(a12); add_arg(a13); add_arg(a14); add_arg(a15); + add_arg(a16); add_arg(a17); add_arg(a18); add_arg(a19); run(); } @@ -617,10 +617,10 @@ t11 *a11, t12 *a12, t13 *a13, t14 *a14, t15 *a15, t16 *a16, t17 *a17, t18 *a18, t19 *a19, t20 *a20) { clear_args(); - add_arg(a1); add_arg(a2); add_arg(a3); add_arg(a4); add_arg(a5); - add_arg(a6); add_arg(a7); add_arg(a8); add_arg(a9); add_arg(a10); - add_arg(a11); add_arg(a12); add_arg(a13); add_arg(a14); add_arg(a15); - add_arg(a16); add_arg(a17); add_arg(a18); add_arg(a19); add_arg(a20); + add_arg(a1); add_arg(a2); add_arg(a3); add_arg(a4); add_arg(a5); + add_arg(a6); add_arg(a7); add_arg(a8); add_arg(a9); add_arg(a10); + add_arg(a11); add_arg(a12); add_arg(a13); add_arg(a14); add_arg(a15); + add_arg(a16); add_arg(a17); add_arg(a18); add_arg(a19); add_arg(a20); run(); } @@ -635,10 +635,10 @@ t16 *a16, t17 *a17, t18 *a18, t19 *a19, t20 *a20, t21 *a21) { clear_args(); - add_arg(a1); add_arg(a2); add_arg(a3); add_arg(a4); add_arg(a5); - add_arg(a6); add_arg(a7); add_arg(a8); add_arg(a9); add_arg(a10); - add_arg(a11); add_arg(a12); add_arg(a13); add_arg(a14); add_arg(a15); - add_arg(a16); add_arg(a17); add_arg(a18); add_arg(a19); add_arg(a20); + add_arg(a1); add_arg(a2); add_arg(a3); add_arg(a4); add_arg(a5); + add_arg(a6); add_arg(a7); add_arg(a8); add_arg(a9); add_arg(a10); + add_arg(a11); add_arg(a12); add_arg(a13); add_arg(a14); add_arg(a15); + add_arg(a16); add_arg(a17); add_arg(a18); add_arg(a19); add_arg(a20); add_arg(a21); run(); } @@ -654,10 +654,10 @@ t16 *a16, t17 *a17, t18 *a18, t19 *a19, t20 *a20, t21 *a21, t22 *a22) { clear_args(); - add_arg(a1); add_arg(a2); add_arg(a3); add_arg(a4); add_arg(a5); - add_arg(a6); add_arg(a7); add_arg(a8); add_arg(a9); add_arg(a10); - add_arg(a11); add_arg(a12); add_arg(a13); add_arg(a14); add_arg(a15); - add_arg(a16); add_arg(a17); add_arg(a18); add_arg(a19); add_arg(a20); + add_arg(a1); add_arg(a2); add_arg(a3); add_arg(a4); add_arg(a5); + add_arg(a6); add_arg(a7); add_arg(a8); add_arg(a9); add_arg(a10); + add_arg(a11); add_arg(a12); add_arg(a13); add_arg(a14); add_arg(a15); + add_arg(a16); add_arg(a17); add_arg(a18); add_arg(a19); add_arg(a20); add_arg(a21); add_arg(a22); run(); } @@ -673,10 +673,10 @@ t16 *a16, t17 *a17, t18 *a18, t19 *a19, t20 *a20, t21 *a21, t22 *a22, t23 *a23) { clear_args(); - add_arg(a1); add_arg(a2); add_arg(a3); add_arg(a4); add_arg(a5); - add_arg(a6); add_arg(a7); add_arg(a8); add_arg(a9); add_arg(a10); - add_arg(a11); add_arg(a12); add_arg(a13); add_arg(a14); add_arg(a15); - add_arg(a16); add_arg(a17); add_arg(a18); add_arg(a19); add_arg(a20); + add_arg(a1); add_arg(a2); add_arg(a3); add_arg(a4); add_arg(a5); + add_arg(a6); add_arg(a7); add_arg(a8); add_arg(a9); add_arg(a10); + add_arg(a11); add_arg(a12); add_arg(a13); add_arg(a14); add_arg(a15); + add_arg(a16); add_arg(a17); add_arg(a18); add_arg(a19); add_arg(a20); add_arg(a21); add_arg(a22); add_arg(a23); run(); } @@ -692,10 +692,10 @@ t16 *a16, t17 *a17, t18 *a18, t19 *a19, t20 *a20, t21 *a21, t22 *a22, t23 *a23, t24 *a24) { clear_args(); - add_arg(a1); add_arg(a2); add_arg(a3); add_arg(a4); add_arg(a5); - add_arg(a6); add_arg(a7); add_arg(a8); add_arg(a9); add_arg(a10); - add_arg(a11); add_arg(a12); add_arg(a13); add_arg(a14); add_arg(a15); - add_arg(a16); add_arg(a17); add_arg(a18); add_arg(a19); add_arg(a20); + add_arg(a1); add_arg(a2); add_arg(a3); add_arg(a4); add_arg(a5); + add_arg(a6); add_arg(a7); add_arg(a8); add_arg(a9); add_arg(a10); + add_arg(a11); add_arg(a12); add_arg(a13); add_arg(a14); add_arg(a15); + add_arg(a16); add_arg(a17); add_arg(a18); add_arg(a19); add_arg(a20); add_arg(a21); add_arg(a22); add_arg(a23); add_arg(a24); run(); } @@ -711,11 +711,11 @@ t16 *a16, t17 *a17, t18 *a18, t19 *a19, t20 *a20, t21 *a21, t22 *a22, t23 *a23, t24 *a24, t25 *a25) { clear_args(); - add_arg(a1); add_arg(a2); add_arg(a3); add_arg(a4); add_arg(a5); - add_arg(a6); add_arg(a7); add_arg(a8); add_arg(a9); add_arg(a10); - add_arg(a11); add_arg(a12); add_arg(a13); add_arg(a14); add_arg(a15); - add_arg(a16); add_arg(a17); add_arg(a18); add_arg(a19); add_arg(a20); - add_arg(a21); add_arg(a22); add_arg(a23); add_arg(a24); add_arg(a25); + add_arg(a1); add_arg(a2); add_arg(a3); add_arg(a4); add_arg(a5); + add_arg(a6); add_arg(a7); add_arg(a8); add_arg(a9); add_arg(a10); + add_arg(a11); add_arg(a12); add_arg(a13); add_arg(a14); add_arg(a15); + add_arg(a16); add_arg(a17); add_arg(a18); add_arg(a19); add_arg(a20); + add_arg(a21); add_arg(a22); add_arg(a23); add_arg(a24); add_arg(a25); run(); } @@ -732,11 +732,11 @@ t21 *a21, t22 *a22, t23 *a23, t24 *a24, t25 *a25, t26 *a26) { clear_args(); - add_arg(a1); add_arg(a2); add_arg(a3); add_arg(a4); add_arg(a5); - add_arg(a6); add_arg(a7); add_arg(a8); add_arg(a9); add_arg(a10); - add_arg(a11); add_arg(a12); add_arg(a13); add_arg(a14); add_arg(a15); - add_arg(a16); add_arg(a17); add_arg(a18); add_arg(a19); add_arg(a20); - add_arg(a21); add_arg(a22); add_arg(a23); add_arg(a24); add_arg(a25); + add_arg(a1); add_arg(a2); add_arg(a3); add_arg(a4); add_arg(a5); + add_arg(a6); add_arg(a7); add_arg(a8); add_arg(a9); add_arg(a10); + add_arg(a11); add_arg(a12); add_arg(a13); add_arg(a14); add_arg(a15); + add_arg(a16); add_arg(a17); add_arg(a18); add_arg(a19); add_arg(a20); + add_arg(a21); add_arg(a22); add_arg(a23); add_arg(a24); add_arg(a25); add_arg(a26); run(); } @@ -754,11 +754,11 @@ t21 *a21, t22 *a22, t23 *a23, t24 *a24, t25 *a25, t26 *a26, t27 *a27) { clear_args(); - add_arg(a1); add_arg(a2); add_arg(a3); add_arg(a4); add_arg(a5); - add_arg(a6); add_arg(a7); add_arg(a8); add_arg(a9); add_arg(a10); - add_arg(a11); add_arg(a12); add_arg(a13); add_arg(a14); add_arg(a15); - add_arg(a16); add_arg(a17); add_arg(a18); add_arg(a19); add_arg(a20); - add_arg(a21); add_arg(a22); add_arg(a23); add_arg(a24); add_arg(a25); + add_arg(a1); add_arg(a2); add_arg(a3); add_arg(a4); add_arg(a5); + add_arg(a6); add_arg(a7); add_arg(a8); add_arg(a9); add_arg(a10); + add_arg(a11); add_arg(a12); add_arg(a13); add_arg(a14); add_arg(a15); + add_arg(a16); add_arg(a17); add_arg(a18); add_arg(a19); add_arg(a20); + add_arg(a21); add_arg(a22); add_arg(a23); add_arg(a24); add_arg(a25); add_arg(a26); add_arg(a27); run(); } @@ -776,12 +776,12 @@ t21 *a21, t22 *a22, t23 *a23, t24 *a24, t25 *a25, t26 *a26, t27 *a27, t28 *a28) { clear_args(); - add_arg(a1); add_arg(a2); add_arg(a3); add_arg(a4); add_arg(a5); - add_arg(a6); add_arg(a7); add_arg(a8); add_arg(a9); add_arg(a10); - add_arg(a11); add_arg(a12); add_arg(a13); add_arg(a14); add_arg(a15); - add_arg(a16); add_arg(a17); add_arg(a18); add_arg(a19); add_arg(a20); - add_arg(a21); add_arg(a22); add_arg(a23); add_arg(a24); add_arg(a25); - add_arg(a26); add_arg(a27); add_arg(a28); + add_arg(a1); add_arg(a2); add_arg(a3); add_arg(a4); add_arg(a5); + add_arg(a6); add_arg(a7); add_arg(a8); add_arg(a9); add_arg(a10); + add_arg(a11); add_arg(a12); add_arg(a13); add_arg(a14); add_arg(a15); + add_arg(a16); add_arg(a17); add_arg(a18); add_arg(a19); add_arg(a20); + add_arg(a21); add_arg(a22); add_arg(a23); add_arg(a24); add_arg(a25); + add_arg(a26); add_arg(a27); add_arg(a28); run(); } @@ -798,11 +798,11 @@ t21 *a21, t22 *a22, t23 *a23, t24 *a24, t25 *a25, t26 *a26, t27 *a27, t28 *a28, t29 *a29) { clear_args(); - add_arg(a1); add_arg(a2); add_arg(a3); add_arg(a4); add_arg(a5); - add_arg(a6); add_arg(a7); add_arg(a8); add_arg(a9); add_arg(a10); - add_arg(a11); add_arg(a12); add_arg(a13); add_arg(a14); add_arg(a15); - add_arg(a16); add_arg(a17); add_arg(a18); add_arg(a19); add_arg(a20); - add_arg(a21); add_arg(a22); add_arg(a23); add_arg(a24); add_arg(a25); + add_arg(a1); add_arg(a2); add_arg(a3); add_arg(a4); add_arg(a5); + add_arg(a6); add_arg(a7); add_arg(a8); add_arg(a9); add_arg(a10); + add_arg(a11); add_arg(a12); add_arg(a13); add_arg(a14); add_arg(a15); + add_arg(a16); add_arg(a17); add_arg(a18); add_arg(a19); add_arg(a20); + add_arg(a21); add_arg(a22); add_arg(a23); add_arg(a24); add_arg(a25); add_arg(a26); add_arg(a27); add_arg(a28); add_arg(a29); run(); } @@ -820,11 +820,11 @@ t21 *a21, t22 *a22, t23 *a23, t24 *a24, t25 *a25, t26 *a26, t27 *a27, t28 *a28, t29 *a29, t30 *a30) { clear_args(); - add_arg(a1); add_arg(a2); add_arg(a3); add_arg(a4); add_arg(a5); - add_arg(a6); add_arg(a7); add_arg(a8); add_arg(a9); add_arg(a10); - add_arg(a11); add_arg(a12); add_arg(a13); add_arg(a14); add_arg(a15); - add_arg(a16); add_arg(a17); add_arg(a18); add_arg(a19); add_arg(a20); - add_arg(a21); add_arg(a22); add_arg(a23); add_arg(a24); add_arg(a25); - add_arg(a26); add_arg(a27); add_arg(a28); add_arg(a29); add_arg(a30); + add_arg(a1); add_arg(a2); add_arg(a3); add_arg(a4); add_arg(a5); + add_arg(a6); add_arg(a7); add_arg(a8); add_arg(a9); add_arg(a10); + add_arg(a11); add_arg(a12); add_arg(a13); add_arg(a14); add_arg(a15); + add_arg(a16); add_arg(a17); add_arg(a18); add_arg(a19); add_arg(a20); + add_arg(a21); add_arg(a22); add_arg(a23); add_arg(a24); add_arg(a25); + add_arg(a26); add_arg(a27); add_arg(a28); add_arg(a29); add_arg(a30); run(); } diff --git a/lib/gpu/geryon/ucl_basemat.h b/lib/gpu/geryon/ucl_basemat.h index 4edf83e057..1ded9f043b 100644 --- a/lib/gpu/geryon/ucl_basemat.h +++ b/lib/gpu/geryon/ucl_basemat.h @@ -17,7 +17,7 @@ /* ----------------------------------------------------------------------- Copyright (2009) Sandia Corporation. Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains - certain rights in this software. This software is distributed under + certain rights in this software. This software is distributed under the Simplified BSD License. ----------------------------------------------------------------------- */ @@ -52,10 +52,10 @@ /// Base class for vector/matrix containers /** All containers are associated with a default command queue. * For CUDA, this is the default stream. - * - * The default queue is used for asynchonrous operations on the container + * + * The default queue is used for asynchonrous operations on the container * that do not specify a queue. For OpenCL, this queue is also used in - * calls for reserving and copying memory **/ + * calls for reserving and copying memory **/ class UCL_BaseMat { public: UCL_BaseMat() : _cq(0), _kind(UCL_VIEW) { } @@ -68,8 +68,8 @@ class UCL_BaseMat { inline void sync() { ucl_sync(_cq); } /// Return the type/permissions of memory allocation /** Returns UCL_READ_WRITE, UCL_WRITE_ONLY, UCL_READ_ONLY, UCL_NOT_PINNED - * or UCL_VIEW **/ - inline enum UCL_MEMOPT kind() const { return _kind; } + * or UCL_VIEW **/ + inline enum UCL_MEMOPT kind() const { return _kind; } inline bool shared_mem_device() { #ifdef _OCL_MAT @@ -79,12 +79,12 @@ class UCL_BaseMat { cl_device_type device_type; CL_SAFE_CALL(clGetDeviceInfo(device,CL_DEVICE_TYPE, sizeof(device_type),&device_type,NULL)); - return _shared_mem_device(device_type); + return _shared_mem_device(device_type); #else return false; #endif } - + protected: command_queue _cq; enum UCL_MEMOPT _kind; diff --git a/lib/gpu/geryon/ucl_copy.h b/lib/gpu/geryon/ucl_copy.h index c6bff97a8c..c906a14f30 100644 --- a/lib/gpu/geryon/ucl_copy.h +++ b/lib/gpu/geryon/ucl_copy.h @@ -17,33 +17,33 @@ /* ----------------------------------------------------------------------- Copyright (2010) Sandia Corporation. Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains - certain rights in this software. This software is distributed under + certain rights in this software. This software is distributed under the Simplified BSD License. ----------------------------------------------------------------------- */ - + /*************************************************************************** The ucl_copy and ucl_cast_copy routines provide a general prototype for copying data between host and device memory (including texture memory) for the matrix and vector types in nvc_memory. - - For host/host and host/device transfers, typecasting is performed - automatically as necessary. - - The routines are written so that all branches can be removed by the + + For host/host and host/device transfers, typecasting is performed + automatically as necessary. + + The routines are written so that all branches can be removed by the compiler during template instantiation. - + The routines currently assume row-major ordering for all types. - + For asynchronous copy in the default command queue, async is boolean true; For asynchronous copy in a specified command queue, async is command queue Otherwise, set async to boolean false; - + When performing frequent data copies that require casting, it is more efficient to allocate a casting buffer once and then pass that buffer to the copy routine. This can be accomplished with the ucl_cast_copy routines. - - Examples + + Examples (x's represent alignment padding - to maintain alignment) (o's represent a larger matrix in memory) (vectors represented as single row) @@ -51,18 +51,18 @@ dst src command ---------------------------------------------------------------- 0 1 2 3 4 <-- 0 1 2 3 4 ucl_copy(dst,src,async) - + 0 1 2 3 <-- 0 1 2 3 4 ucl_copy(dst,src,4,async) - + 0 1 2 <-- 0 1 2 3 4 5 ucl_copy(dst,src,async) - 3 4 5 - + 3 4 5 + 0 1 2 3 4 5 <-- 0 1 2 ucl_copy(dst,src,async) 3 4 5 - + 0 1 2 <-- 0 1 2 ucl_copy(dst,src,async) 3 4 5 3 4 5 - + 0 1 2 <-- 0 1 2 ucl_copy(dst,src,6,async) 3 4 5 3 4 5 5 6 7 @@ -70,33 +70,33 @@ 0 1 2 <-- 0 1 2 3 ucl_copy(dst,src,2,3,async) 4 5 6 4 5 6 7 8 9 10 11 - + 0 1 2 x x <-- 0 1 2 ucl_copy(dst,src,async) 3 4 5 x x 3 4 5 - + 0 1 2 <-- 0 1 2 x x ucl_copy(dst,src,async) 3 4 5 3 4 5 x x - + 0 1 2 o o <-- 0 1 2 ucl_copy(dst,src,2,3,async) 3 4 5 o o 3 4 5 - o o o o o + o o o o o 0 1 2 o o <-- 0 1 2 3 4 5 ucl_copy(dst,src,2,3,async) - 3 4 5 o o - o o o o o + 3 4 5 o o + o o o o o 0 1 o o o <-- 0 1 2 3 4 5 ucl_copy(dst,src,2,2,async) - 2 3 o o o - o o o o o + 2 3 o o o + o o o o o 0 1 2 o o <-- 0 1 2 3 4 ucl_copy(dst,src,2,3,async) 5 6 7 o o 5 6 7 8 9 o o o o o 10 11 12 13 14 - + 0 1 2 5 6 7 <-- 0 1 2 3 4 ucl_copy(dst,src,2,3,async) 5 6 7 8 9 10 11 12 13 14 - + ***************************************************************************/ // Only allow this file to be included by nvc_memory.h and ocl_memory.h @@ -124,7 +124,7 @@ inline void _check_ucl_copy_perm(mat1 &dst, mat2 &src) { assert(0==1); } } -} +} // -------------------------------------------------------------------------- // - HOST-HOST COPY ROUTINES @@ -182,7 +182,7 @@ template <> struct _host_host_copy<1,1> { return; } #endif - + #ifdef UCL_DBG_MEM_TRACE std::cerr << "UCL_COPY 8NS\n"; #endif @@ -212,7 +212,7 @@ template struct _host_host_copy { static inline void hhc(mat1 &dst, const mat2 &src, const size_t rows, const size_t cols) { assert(0==1); - } + } }; // -------------------------------------------------------------------------- @@ -242,20 +242,20 @@ template struct _ucl_cast_copy<1,host_type2> { template static inline void cc(mat1 &dst, const mat2 &src, const size_t rows, const size_t cols, mat3 &cast_buffer) { - // Asynchronous currently pointless here + // Asynchronous currently pointless here #ifdef UCL_DEBUG assert(mat1::ROW_MAJOR==1 && mat2::ROW_MAJOR==1); assert(dst.numel()>=rows*cols && cast_buffer.numel()>=rows*cols); - if (mat1::VECTOR==0) assert(dst.rows()>=rows && dst.cols()>=cols); - if (mat2::VECTOR==0) assert(src.rows()>=rows && src.cols()>=cols); - #endif + if (mat1::VECTOR==0) assert(dst.rows()>=rows && dst.cols()>=cols); + if (mat2::VECTOR==0) assert(src.rows()>=rows && src.cols()>=cols); + #endif if (mat1::VECTOR) { ucl_mv_cpy(cast_buffer,cols*sizeof(typename mat2::data_type),src, src.row_bytes(),cols*sizeof(typename mat2::data_type),rows); for (size_t i=0; i(cast_buffer[i]); } else { - if (mat2::VECTOR) + if (mat2::VECTOR) ucl_mv_cpy(cast_buffer,cols*sizeof(typename mat2::data_type),src, cols*sizeof(typename mat2::data_type), cols*sizeof(typename mat2::data_type),rows); @@ -276,23 +276,23 @@ template struct _ucl_cast_copy<1,host_type2> { } template static inline void cc(mat1 &dst, const mat2 &src, const size_t rows, - const size_t cols, mat3 &cast_buffer, + const size_t cols, mat3 &cast_buffer, command_queue &cq) { - // Asynchronous currently pointless here + // Asynchronous currently pointless here #ifdef UCL_DEBUG assert(mat1::ROW_MAJOR==1 && mat2::ROW_MAJOR==1); assert(dst.numel()>=rows*cols && cast_buffer.numel()>=rows*cols); - if (mat1::VECTOR==0) assert(dst.rows()>=rows && dst.cols()>=cols); - if (mat2::VECTOR==0) assert(src.rows()>=rows && src.cols()>=cols); - #endif + if (mat1::VECTOR==0) assert(dst.rows()>=rows && dst.cols()>=cols); + if (mat2::VECTOR==0) assert(src.rows()>=rows && src.cols()>=cols); + #endif if (mat1::VECTOR) { ucl_mv_cpy(cast_buffer,cols*sizeof(typename mat2::data_type),src, src.row_bytes(),cols*sizeof(typename mat2::data_type),rows,cq); - cast_buffer.sync(); + cast_buffer.sync(); for (size_t i=0; i(cast_buffer[i]); } else { - if (mat2::VECTOR) + if (mat2::VECTOR) ucl_mv_cpy(cast_buffer,cols*sizeof(typename mat2::data_type),src, cols*sizeof(typename mat2::data_type), cols*sizeof(typename mat2::data_type),rows,cq); @@ -338,7 +338,7 @@ template struct _ucl_cast_copy { assert(src.numel()>=rows*cols && cast_buffer.numel()>=rows*cols); if (mat1::VECTOR==0) assert(dst.rows()>=rows && dst.cols()>=cols); if (mat2::VECTOR==0) assert(src.rows()>=rows && src.cols()>=cols); - if (mat3::VECTOR==0) { + if (mat3::VECTOR==0) { assert(cast_buffer.rows()>=rows && cast_buffer.cols()>=cols); assert(dst.rows()>=rows && dst.cols()>=cols); } @@ -404,9 +404,9 @@ template struct _ucl_cast_copy { #ifdef UCL_DEBUG assert(mat1::ROW_MAJOR==1 && mat2::ROW_MAJOR==1); assert(src.numel()>=rows*cols && cast_buffer.numel()>=rows*cols); - if (mat1::VECTOR==0) assert(dst.rows()>=rows && dst.cols()>=cols); - if (mat2::VECTOR==0) assert(src.rows()>=rows && src.cols()>=cols); - if (mat3::VECTOR==0) { + if (mat1::VECTOR==0) assert(dst.rows()>=rows && dst.cols()>=cols); + if (mat2::VECTOR==0) assert(src.rows()>=rows && src.cols()>=cols); + if (mat3::VECTOR==0) { assert(cast_buffer.rows()>=rows && cast_buffer.cols()>=cols); assert(dst.rows()>=rows && dst.cols()>=cols); } @@ -472,23 +472,23 @@ template <> struct _ucl_cast_copy<1,1> { template static inline void cc(mat1 &dst, const mat2 &src, const size_t numel, mat3 &cast_buffer, command_queue &cq) { - assert(0==1); + assert(0==1); } template static inline void cc(mat1 &dst, const mat2 &src, const size_t numel, mat3 &cast_buffer) { - assert(0==1); + assert(0==1); } template static inline void cc(mat1 &dst, const mat2 &src, const size_t rows, const size_t cols, mat3 &cast_buffer) { - assert(0==1); + assert(0==1); } template static inline void cc(mat1 &dst, const mat2 &src, const size_t rows, const size_t cols, mat3 &cast_buffer, command_queue &cq) { - assert(0==1); + assert(0==1); } }; @@ -497,23 +497,23 @@ template <> struct _ucl_cast_copy<0,0> { template static inline void cc(mat1 &dst, const mat2 &src, const size_t numel, mat3 &cast_buffer, command_queue &cq) { - assert(0==1); + assert(0==1); } template static inline void cc(mat1 &dst, const mat2 &src, const size_t numel, mat3 &cast_buffer) { - assert(0==1); + assert(0==1); } template static inline void cc(mat1 &dst, const mat2 &src, const size_t rows, const size_t cols, mat3 &cast_buffer) { - assert(0==1); + assert(0==1); } template static inline void cc(mat1 &dst, const mat2 &src, const size_t rows, const size_t cols, mat3 &cast_buffer, command_queue &cq) { - assert(0==1); + assert(0==1); } }; @@ -525,7 +525,7 @@ template <> struct _ucl_cast_copy<0,0> { /** \param numel Number of elements (not bytes) to copy * \param cast_buffer Buffer on host with enough storage for casting * - If the data types for the two matrices are same, no cast performed - * - Padding for 2D matrices is not considered in this routine. + * - Padding for 2D matrices is not considered in this routine. * - Currently does not handle textures **/ template inline void ucl_cast_copy(mat1 &dst, const mat2 &src, const size_t numel, @@ -551,7 +551,7 @@ inline void ucl_cast_copy(mat1 &dst, const mat2 &src, const size_t numel, * \param async Perform non-blocking copy on default stream * \param cast_buffer Buffer on host with enough storage for casting * - If the data types for the two matrices are same, no cast performed - * - Padding for 2D matrices is not considered in this routine. + * - Padding for 2D matrices is not considered in this routine. * - Currently does not handle textures **/ template inline void ucl_cast_copy(mat1 &dst, const mat2 &src, const size_t numel, @@ -580,7 +580,7 @@ inline void ucl_cast_copy(mat1 &dst, const mat2 &src, const size_t numel, * buffer is created for copy. When multiple casts occur, it is * more efficient to create a permanent casting buffer that can * be passed to an alternative copy routine. - * - Padding for 2D matrices is not considered in this routine. + * - Padding for 2D matrices is not considered in this routine. * - Currently does not handle textures **/ template inline void ucl_copy(mat1 &dst, const mat2 &src, const size_t numel, @@ -593,7 +593,7 @@ inline void ucl_copy(mat1 &dst, const mat2 &src, const size_t numel, #endif if (mat1::MEM_TYPE==1 && mat2::MEM_TYPE==1) _host_host_copy::hhc(dst,src,numel); - else if ((int)mat1::DATA_TYPE!=(int)mat2::DATA_TYPE && + else if ((int)mat1::DATA_TYPE!=(int)mat2::DATA_TYPE && (mat1::MEM_TYPE==1 || mat2::MEM_TYPE==1)) { if (mat1::MEM_TYPE==1) { UCL_H_Vec cast_buffer; @@ -606,8 +606,8 @@ inline void ucl_copy(mat1 &dst, const mat2 &src, const size_t numel, _ucl_cast_copy::cc(dst,src,numel, cast_buffer,cq); } - } else - ucl_mv_cpy(dst,src,numel*sizeof(typename mat2::data_type),cq); + } else + ucl_mv_cpy(dst,src,numel*sizeof(typename mat2::data_type),cq); } /// Copy matrix/vector (memory already allocated) @@ -619,7 +619,7 @@ inline void ucl_copy(mat1 &dst, const mat2 &src, const size_t numel, * buffer is created for copy. When multiple casts occur, it is * more efficient to create a permanent casting buffer that can * be passed to an alternative copy routine. - * - Padding for 2D matrices is not considered in this routine. + * - Padding for 2D matrices is not considered in this routine. * - The default stream is used for asynchronous copy * - Currently does not handle textures **/ template @@ -648,7 +648,7 @@ inline void ucl_copy(mat1 &dst, const mat2 &src, const size_t numel, cast_buffer); } } else - ucl_mv_cpy(dst,src,numel*sizeof(typename mat2::data_type)); + ucl_mv_cpy(dst,src,numel*sizeof(typename mat2::data_type)); } // -------------------------------------------------------------------------- @@ -659,11 +659,11 @@ inline void ucl_copy(mat1 &dst, const mat2 &src, const size_t numel, /** \param async Perform non-blocking copy on default stream * \param cast_buffer Buffer on host with enough storage for casting * - If src is a vector, routine assumes row-major rows by cols copy - * - If src is a matrix, routine will copy upper left tile of matrix + * - If src is a matrix, routine will copy upper left tile of matrix * - If dst is a vector, routine assumes row-major rows by cols copy - * - If dst is a matrix, routine will copy into left tile of matrix + * - If dst is a matrix, routine will copy into left tile of matrix * - If the data types for the two matrices are same, no cast performed - * - Padding for 2D matrices is not considered in this routine. + * - Padding for 2D matrices is not considered in this routine. * - Copy from vector to matrix and vice versa allowed * - Currently does not handle textures **/ template @@ -686,16 +686,16 @@ inline void ucl_cast_copy(mat1 &dst, const mat2 &src, const size_t rows, /// Asynchronous copy subset matrix rows,cols with cast (Device/Host transfer) /** \param cast_buffer Buffer on host with enough storage for casting * - If src is a vector, routine assumes row-major rows by cols copy - * - If src is a matrix, routine will copy upper left tile of matrix + * - If src is a matrix, routine will copy upper left tile of matrix * - If dst is a vector, routine assumes row-major rows by cols copy - * - If dst is a matrix, routine will copy into upper left tile of matrix + * - If dst is a matrix, routine will copy into upper left tile of matrix * - If the data types for the two matrices are same, no cast performed - * - Padding for 2D matrices is not considered in this routine. + * - Padding for 2D matrices is not considered in this routine. * - Copy from vector to matrix and vice versa allowed * - Currently does not handle textures **/ template inline void ucl_cast_copy(mat1 &dst, const mat2 &src, const size_t rows, - const size_t cols, mat3 &cast_buffer, + const size_t cols, mat3 &cast_buffer, command_queue &cq) { if ((int)mat1::DATA_TYPE==(int)mat2::DATA_TYPE) ucl_copy(dst,src,rows,cols,cq); @@ -710,11 +710,11 @@ inline void ucl_cast_copy(mat1 &dst, const mat2 &src, const size_t rows, /// Asynchronous copy of subset matrix rows,cols (memory already allocated) /** - If src is a vector, routine assumes row-major rows by cols copy - * - If src is a matrix, routine will copy upper left tile of matrix + * - If src is a matrix, routine will copy upper left tile of matrix * - If dst is a vector, routine assumes row-major rows by cols copy - * - If dst is a matrix, routine will copy into left tile of matrix + * - If dst is a matrix, routine will copy into left tile of matrix * - If the data types of the two matrices are not the same, - * casting will be performed automatically as long as the copy is + * casting will be performed automatically as long as the copy is * not device to device. For host/device transfers, a temporary * buffer is created for copy. When multiple casts occur, it is * more efficient to create a permanent casting buffer that can @@ -730,7 +730,7 @@ inline void ucl_copy(mat1 &dst, const mat2 &src, const size_t rows, #endif if (mat1::MEM_TYPE==1 && mat2::MEM_TYPE==1) _host_host_copy::hhc(dst,src,rows,cols); - else if ((int)mat1::DATA_TYPE!=(int)mat2::DATA_TYPE && + else if ((int)mat1::DATA_TYPE!=(int)mat2::DATA_TYPE && (mat1::MEM_TYPE==1 || mat2::MEM_TYPE==1)) { if (mat1::MEM_TYPE==1) { UCL_H_Vec cast_buffer; @@ -773,9 +773,9 @@ inline void ucl_copy(mat1 &dst, const mat2 &src, const size_t rows, /// Copy subset of matrix rows,cols (memory already allocated) /** \param async Perform non-blocking copy (ignored for host to host copy) * - If src is a vector, routine assumes row-major rows by cols copy - * - If src is a matrix, routine will copy upper left tile of matrix + * - If src is a matrix, routine will copy upper left tile of matrix * - If dst is a vector, routine assumes row-major rows by cols copy - * - If dst is a matrix, routine will copy into left tile of matrix + * - If dst is a matrix, routine will copy into left tile of matrix * - If the data types of the two matrices are not the same, * casting will be performed automatically as long as the copy is * not device to device. For host/device transfers, a temporary @@ -796,7 +796,7 @@ inline void ucl_copy(mat1 &dst, const mat2 &src, const size_t rows, ucl_copy(dst,src,rows,cols,dst.cq()); else if (mat1::MEM_TYPE==1 && mat2::MEM_TYPE==1) _host_host_copy::hhc(dst,src,rows,cols); - else if ((int)mat1::DATA_TYPE!=(int)mat2::DATA_TYPE && + else if ((int)mat1::DATA_TYPE!=(int)mat2::DATA_TYPE && (mat1::MEM_TYPE==1 || mat2::MEM_TYPE==1)) { if (mat1::MEM_TYPE==1) { UCL_H_Vec cast_buffer; @@ -846,7 +846,7 @@ inline void ucl_copy(mat1 &dst, const mat2 &src, const size_t rows, * \param cast_buffer Buffer on host with enough storage for casting * - If the data types for the two matrices are same, no cast performed * - The number of bytes copied is determined by entire src data - * - Padding for 2D matrices is not considered in this routine. + * - Padding for 2D matrices is not considered in this routine. * - Copy from vector to matrix and vice versa allowed * - Currently does not handle textures **/ template @@ -866,7 +866,7 @@ inline void ucl_cast_copy(mat1 &dst, const mat2 &src, /** \param cast_buffer Buffer on host with enough storage for casting * - If the data types for the two matrices are same, no cast performed * - The number of bytes copied is determined by entire src data - * - Padding for 2D matrices is not considered in this routine. + * - Padding for 2D matrices is not considered in this routine. * - Copy from vector to matrix and vice versa allowed * - Currently does not handle textures **/ template @@ -885,7 +885,7 @@ inline void ucl_cast_copy(mat1 &dst, const mat2 &src, /// Asynchronous copy of matrix/vector (memory already allocated) /** - The number of bytes copied is determined by entire src data * - If the data types of the two matrices are not the same, - * casting will be performed automatically as long as the copy is + * casting will be performed automatically as long as the copy is * not device to device. For host/device transfers, a temporary * buffer is created for copy. When multiple casts occur, it is * more efficient to create a permanent casting buffer that can @@ -924,7 +924,7 @@ template inline void ucl_copy(mat1 &dst, const mat2 &src, const bool async) { if (async) ucl_copy(dst,src,dst.cq()); - else if (dst.row_bytes()==src.row_bytes() && + else if (dst.row_bytes()==src.row_bytes() && src.kind()!=UCL_VIEW && dst.kind()!=UCL_VIEW && (int)mat1::DATA_TYPE==(int)mat2::DATA_TYPE) ucl_copy(dst,src,src.row_size()*src.rows(),async); diff --git a/lib/gpu/geryon/ucl_d_mat.h b/lib/gpu/geryon/ucl_d_mat.h index f1aaa27903..da55cc6ebc 100644 --- a/lib/gpu/geryon/ucl_d_mat.h +++ b/lib/gpu/geryon/ucl_d_mat.h @@ -17,7 +17,7 @@ /* ----------------------------------------------------------------------- Copyright (2009) Sandia Corporation. Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains - certain rights in this software. This software is distributed under + certain rights in this software. This software is distributed under the Simplified BSD License. ----------------------------------------------------------------------- */ @@ -37,23 +37,23 @@ class UCL_D_Mat : public UCL_BaseMat { ROW_MAJOR = 1, VECTOR = 0 }; - typedef numtyp data_type; + typedef numtyp data_type; UCL_D_Mat() : _cols(0) {} ~UCL_D_Mat() { _device_free(*this); } - + /// Construct with specified rows and cols /** \sa alloc() **/ UCL_D_Mat(const size_t rows, const size_t cols, UCL_Device &device, - const enum UCL_MEMOPT kind=UCL_READ_WRITE) : + const enum UCL_MEMOPT kind=UCL_READ_WRITE) : _cols(0) { alloc(rows,cols,device,kind); } - + /// Row major matrix on device /** The kind parameter controls memory optimizations as follows: * - UCL_READ_WRITE - Specify that you will read and write in kernels * - UCL_WRITE_ONLY - Specify that you will only write in kernels * - UCL_READ_ONLY - Specify that you will only read in kernels - * \param cq Default command queue for operations copied from another mat + * \param cq Default command queue for operations copied from another mat * \note - Coalesced access using adjacent cols on same row * UCL_D_Mat(row,col) given by array[row*row_size()+col] * \return UCL_SUCCESS if the memory allocation is successful **/ @@ -65,7 +65,7 @@ class UCL_D_Mat : public UCL_BaseMat { int err=_device_alloc(*this,cq,rows,cols,_pitch,kind); if (err!=UCL_SUCCESS) { #ifndef UCL_NO_EXIT - std::cerr << "UCL Error: Could not allocate " + std::cerr << "UCL Error: Could not allocate " << rows*cols*sizeof(numtyp) << " bytes on device.\n"; UCL_GERYON_EXIT; #endif @@ -82,9 +82,9 @@ class UCL_D_Mat : public UCL_BaseMat { #ifdef _OCL_MAT _offset=0; #endif - return err; + return err; } - + /// Row major matrix on device /** The kind parameter controls memory optimizations as follows: * - UCL_READ_WRITE - Specify that you will read and write in kernels @@ -118,15 +118,15 @@ class UCL_D_Mat : public UCL_BaseMat { #ifdef _OCL_MAT _offset=0; #endif - return err; + return err; } - + /// Do not allocate memory, instead use an existing allocation from Geryon /** This function must be passed a Geryon vector or matrix container. * No memory is freed when the object is destructed. * - The view does not prevent the memory from being freed by the - * allocating container when using CUDA APIs - * \param stride Number of _elements_ between the start of each row **/ + * allocating container when using CUDA APIs + * \param stride Number of _elements_ between the start of each row **/ template inline void view(ucl_type &input, const size_t rows, const size_t cols, const size_t stride) { @@ -145,7 +145,7 @@ class UCL_D_Mat : public UCL_BaseMat { #else _device_view(&_array,input.begin()); #endif - + #ifndef _UCL_DEVICE_PTR_MAT _end=_array+_cols; #endif @@ -157,39 +157,39 @@ class UCL_D_Mat : public UCL_BaseMat { * - The view does not prevent the memory from being freed by the * allocating container when using CUDA APIs **/ template - inline void view(ucl_type &input, const size_t rows, const size_t cols) + inline void view(ucl_type &input, const size_t rows, const size_t cols) { view(input,rows,cols,input.row_size()); } - + /// Do not allocate memory, instead use an existing allocation from Geryon /** This function must be passed a Geryon vector or matrix container. * No memory is freed when the object is destructed. * - The view does not prevent the memory from being freed by the - * allocating container when using CUDA APIs + * allocating container when using CUDA APIs * - If a matrix is used a input, all elements (including padding) * will be used for view **/ template inline void view(ucl_type &input, const size_t cols) { view(input,1,cols); } - + /// Do not allocate memory, instead use an existing allocation from Geryon /** This function must be passed a Geryon vector or matrix container. * No memory is freed when the object is destructed. * - The view does not prevent the memory from being freed by the - * allocating container when using CUDA APIs + * allocating container when using CUDA APIs * - If a matrix is used a input, all elements (including padding) * will be used for view **/ template - inline void view(ucl_type &input) + inline void view(ucl_type &input) { view(input,input.rows(),input.cols()); } - + /// Do not allocate memory, instead use an existing allocation /** - No memory is freed when the object is destructed. * - The view does not prevent the memory from being freed by the - * allocating container when using CUDA APIs - * \param stride Number of _elements_ between the start of each row **/ + * allocating container when using CUDA APIs + * \param stride Number of _elements_ between the start of each row **/ template inline void view(ptr_type input, const size_t rows, const size_t cols, - const size_t stride, UCL_Device &dev) { + const size_t stride, UCL_Device &dev) { clear(); _kind=UCL_VIEW; _cols=cols; @@ -215,7 +215,7 @@ class UCL_D_Mat : public UCL_BaseMat { template inline void view(ptr_type input, const size_t rows, const size_t cols, UCL_Device &dev) { view(input,rows,cols,cols,dev); } - + /// Do not allocate memory, instead use an existing allocation /** - No memory is freed when the object is destructed. * - The view does not prevent the memory from being freed by the @@ -223,13 +223,13 @@ class UCL_D_Mat : public UCL_BaseMat { template inline void view(ptr_type input, const size_t cols, UCL_Device &dev) { view(input,1,cols,dev); } - + /// Do not allocate memory, instead use an existing allocation from Geryon /** This function must be passed a Geryon vector or matrix container. * No memory is freed when the object is destructed. * - The view does not prevent the memory from being freed by the - * allocating container when using CUDA APIs - * \param stride Number of _elements_ between the start of each row **/ + * allocating container when using CUDA APIs + * \param stride Number of _elements_ between the start of each row **/ template inline void view_offset(const size_t offset,ucl_type &input,const size_t rows, const size_t cols, const size_t stride) { @@ -248,7 +248,7 @@ class UCL_D_Mat : public UCL_BaseMat { #else _device_view(&_array,input.begin(),offset,sizeof(numtyp)); #endif - + #ifndef _UCL_DEVICE_PTR_MAT _end=_array+_cols; #endif @@ -261,45 +261,45 @@ class UCL_D_Mat : public UCL_BaseMat { * allocating container when using CUDA APIs **/ template inline void view_offset(const size_t offset,ucl_type &input,const size_t rows, - const size_t cols) + const size_t cols) { view_offset(offset,input,rows,cols,input.row_size()); } - + /// Do not allocate memory, instead use an existing allocation from Geryon /** This function must be passed a Geryon vector or matrix container. * No memory is freed when the object is destructed. * - The view does not prevent the memory from being freed by the - * allocating container when using CUDA APIs + * allocating container when using CUDA APIs * - If a matrix is used a input, all elements (including padding) * will be used for view **/ template inline void view_offset(const size_t offset,ucl_type &input,const size_t cols) { view_offset(offset,input,1,cols); } - + /// Do not allocate memory, instead use an existing allocation from Geryon /** This function must be passed a Geryon vector or matrix container. * No memory is freed when the object is destructed. * - The view does not prevent the memory from being freed by the - * allocating container when using CUDA APIs + * allocating container when using CUDA APIs * - If a matrix is used a input, all elements (including padding) * will be used for view **/ template - inline void view_offset(const size_t offset, ucl_type &input) { - if (input.rows()==1) + inline void view_offset(const size_t offset, ucl_type &input) { + if (input.rows()==1) view_offset(offset,input,1,input.cols()-offset); - else + else view_offset(offset,input,input.rows()-offset/input.row_size(), input.cols()); } - + /// Do not allocate memory, instead use an existing allocation /** - No memory is freed when the object is destructed. * - The view does not prevent the memory from being freed by the - * allocating container when using CUDA APIs - * \param stride Number of _elements_ between the start of each row **/ + * allocating container when using CUDA APIs + * \param stride Number of _elements_ between the start of each row **/ template inline void view_offset(const size_t offset,ptr_type input,const size_t rows, const size_t cols,const size_t stride, - UCL_Device &dev) { + UCL_Device &dev) { clear(); _kind=UCL_VIEW; _cols=cols; @@ -307,7 +307,7 @@ class UCL_D_Mat : public UCL_BaseMat { _pitch=stride*sizeof(numtyp); _row_size=stride; this->_cq=dev.cq(); - + #ifdef _OCL_MAT _array=input; _offset=offset; @@ -320,7 +320,7 @@ class UCL_D_Mat : public UCL_BaseMat { _array=input+offset; #endif #endif - + #ifndef _UCL_DEVICE_PTR_MAT _end=_array+_cols; #endif @@ -332,20 +332,20 @@ class UCL_D_Mat : public UCL_BaseMat { * allocating container when using CUDA APIs **/ template inline void view_offset(const size_t offset,ptr_type input,const size_t rows, - const size_t cols, UCL_Device &dev) + const size_t cols, UCL_Device &dev) { view_offset(offset,input,rows,cols,cols,dev); } - + /// Do not allocate memory, instead use an existing allocation /** - No memory is freed when the object is destructed. * - The view does not prevent the memory from being freed by the * allocating container when using CUDA APIs **/ template - inline void view_offset(const size_t offset, ptr_type input, + inline void view_offset(const size_t offset, ptr_type input, const size_t cols, UCL_Device &dev) { view_offset(offset,input,1,cols,dev); } - + /// Free memory and set size to 0 - inline void clear() + inline void clear() { _device_free(*this); _cols=0; _kind=UCL_VIEW; } /// Resize the allocation to contain cols elements @@ -356,7 +356,7 @@ class UCL_D_Mat : public UCL_BaseMat { int err=_device_resize(*this,rows,cols,_pitch); if (err!=UCL_SUCCESS) { #ifndef UCL_NO_EXIT - std::cerr << "UCL Error: Could not allocate " + std::cerr << "UCL Error: Could not allocate " << rows*cols*sizeof(numtyp) << " bytes on device.\n"; UCL_GERYON_EXIT; #endif @@ -372,13 +372,13 @@ class UCL_D_Mat : public UCL_BaseMat { #ifdef _OCL_MAT _offset=0; #endif - return err; + return err; } - + /// Resize (only if bigger) the allocation to contain rows x cols elements /** \note Cannot be used on views **/ inline int resize_ib(const int rows, const int cols) - { if (cols>_cols || rows>_rows) return resize(rows,cols); + { if (cols>_cols || rows>_rows) return resize(rows,cols); else return UCL_SUCCESS; } /// Set each element to zero asynchronously in the default command_queue @@ -386,10 +386,10 @@ class UCL_D_Mat : public UCL_BaseMat { /// Set first n elements to zero asynchronously in the default command_queue inline void zero(const int n) { zero(n,_cq); } /// Set each element to zero asynchronously - inline void zero(command_queue &cq) + inline void zero(command_queue &cq) { _device_zero(*this,row_bytes()*_rows,cq); } /// Set first n elements to zero asynchronously - inline void zero(const int n, command_queue &cq) + inline void zero(const int n, command_queue &cq) { _device_zero(*this,n*sizeof(numtyp),cq); } @@ -445,7 +445,7 @@ class UCL_D_Mat : public UCL_BaseMat { inline size_t row_bytes() const { return _pitch; } /// Get the size in bytes of 1 element inline int element_size() const { return sizeof(numtyp); } - + #ifdef _OCL_MAT /// Return the offset (in elements) from begin() pointer where data starts /** \note Always 0 for host matrices and CUDA APIs **/ @@ -459,7 +459,7 @@ class UCL_D_Mat : public UCL_BaseMat { /// Return the offset (in bytes) from begin() pointer where data starts /** \note Always 0 for host matrices and CUDA APIs **/ inline size_t byteoff() const { return offset()*sizeof(numtyp); } - + private: size_t _pitch, _row_size, _rows, _cols; diff --git a/lib/gpu/geryon/ucl_d_vec.h b/lib/gpu/geryon/ucl_d_vec.h index fc1977f4b5..99a6c939c6 100644 --- a/lib/gpu/geryon/ucl_d_vec.h +++ b/lib/gpu/geryon/ucl_d_vec.h @@ -17,14 +17,14 @@ /* ----------------------------------------------------------------------- Copyright (2009) Sandia Corporation. Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains - certain rights in this software. This software is distributed under + certain rights in this software. This software is distributed under the Simplified BSD License. ----------------------------------------------------------------------- */ // Only allow this file to be included by CUDA and OpenCL specific headers #ifdef _UCL_MAT_ALLOW -/// Row vector on device +/// Row vector on device template class UCL_D_Vec : public UCL_BaseMat { public: @@ -37,7 +37,7 @@ class UCL_D_Vec : public UCL_BaseMat { ROW_MAJOR = 1, VECTOR = 1 }; - typedef numtyp data_type; + typedef numtyp data_type; UCL_D_Vec() : _cols(0) {} ~UCL_D_Vec() { _device_free(*this); } @@ -45,7 +45,7 @@ class UCL_D_Vec : public UCL_BaseMat { /// Construct with n columns /** \sa alloc() **/ UCL_D_Vec(const size_t n, UCL_Device &device, - const enum UCL_MEMOPT kind=UCL_READ_WRITE) : + const enum UCL_MEMOPT kind=UCL_READ_WRITE) : _cols(0) { alloc(n,device,kind); } /// Set up host vector with 'cols' columns and reserve memory @@ -58,7 +58,7 @@ class UCL_D_Vec : public UCL_BaseMat { template inline int alloc(const size_t cols, mat_type &cq, const enum UCL_MEMOPT kind=UCL_READ_WRITE) { - + clear(); _row_bytes=cols*sizeof(numtyp); @@ -82,8 +82,8 @@ class UCL_D_Vec : public UCL_BaseMat { #ifdef _OCL_MAT _offset=0; #endif - return err; - } + return err; + } /// Set up host vector with 'cols' columns and reserve memory /** The kind parameter controls memory optimizations as follows: @@ -116,7 +116,7 @@ class UCL_D_Vec : public UCL_BaseMat { #ifdef _OCL_MAT _offset=0; #endif - return err; + return err; } /// Do not allocate memory, instead use an existing allocation from Geryon @@ -142,18 +142,18 @@ class UCL_D_Vec : public UCL_BaseMat { #else _device_view(&_array,input.begin()); #endif - + #ifndef _UCL_DEVICE_PTR_MAT _end=_array+_cols; #endif } - + /// Do not allocate memory, instead use an existing allocation from Geryon /** This function must be passed a Geryon vector or matrix container. * No memory is freed when the object is destructed. * - The view does not prevent the memory from being freed by the - * allocating container when using CUDA APIs - * \param stride Number of _elements_ between the start of each row **/ + * allocating container when using CUDA APIs + * \param stride Number of _elements_ between the start of each row **/ template inline void view(ucl_type &input, const size_t rows, const size_t cols, const size_t stride) { view(input,rows,cols); } @@ -162,24 +162,24 @@ class UCL_D_Vec : public UCL_BaseMat { /** This function must be passed a Geryon vector or matrix container. * No memory is freed when the object is destructed. * - The view does not prevent the memory from being freed by the - * allocating container when using CUDA APIs + * allocating container when using CUDA APIs * - If a matrix is used a input, all elements (including padding) * will be used for view **/ template inline void view(ucl_type &input, const size_t cols) { view(input,1,cols); } - + /// Do not allocate memory, instead use an existing allocation from Geryon /** This function must be passed a Geryon vector or matrix container. * No memory is freed when the object is destructed. * - The view does not prevent the memory from being freed by the - * allocating container when using CUDA APIs + * allocating container when using CUDA APIs * - If a matrix is used a input, all elements (including padding) * will be used for view **/ template - inline void view(ucl_type &input) + inline void view(ucl_type &input) { view(input,input.rows()*input.row_size()); } - + /// Do not allocate memory, instead use an existing allocation /** - No memory is freed when the object is destructed. * - The view does not prevent the memory from being freed by the @@ -205,15 +205,15 @@ class UCL_D_Vec : public UCL_BaseMat { CL_SAFE_CALL(clRetainCommandQueue(dev.cq())); #endif } - + /// Do not allocate memory, instead use an existing allocation /** - No memory is freed when the object is destructed. * - The view does not prevent the memory from being freed by the - * allocating container when using CUDA APIs - * \param stride Number of _elements_ between the start of each row **/ + * allocating container when using CUDA APIs + * \param stride Number of _elements_ between the start of each row **/ template inline void view(ptr_type input, const size_t rows, const size_t cols, - const size_t stride, UCL_Device &dev) + const size_t stride, UCL_Device &dev) { view(input,rows,cols,stride); } /// Do not allocate memory, instead use an existing allocation @@ -223,7 +223,7 @@ class UCL_D_Vec : public UCL_BaseMat { template inline void view(ptr_type input, const size_t cols, UCL_Device &dev) { view(input,1,cols,dev); } - + /// Do not allocate memory, instead use an existing allocation from Geryon /** This function must be passed a Geryon vector or matrix container. * No memory is freed when the object is destructed. @@ -248,45 +248,45 @@ class UCL_D_Vec : public UCL_BaseMat { #else _device_view(&_array,input.begin(),offset,sizeof(numtyp)); #endif - + #ifndef _UCL_DEVICE_PTR_MAT _end=_array+_cols; #endif } - + /// Do not allocate memory, instead use an existing allocation from Geryon /** This function must be passed a Geryon vector or matrix container. * No memory is freed when the object is destructed. * - The view does not prevent the memory from being freed by the - * allocating container when using CUDA APIs - * \param stride Number of _elements_ between the start of each row **/ + * allocating container when using CUDA APIs + * \param stride Number of _elements_ between the start of each row **/ template inline void view_offset(const size_t offset,ucl_type &input,const size_t rows, - const size_t cols, const size_t stride) + const size_t cols, const size_t stride) { view_offset(offset,input,rows,cols); } /// Do not allocate memory, instead use an existing allocation from Geryon /** This function must be passed a Geryon vector or matrix container. * No memory is freed when the object is destructed. * - The view does not prevent the memory from being freed by the - * allocating container when using CUDA APIs + * allocating container when using CUDA APIs * - If a matrix is used a input, all elements (including padding) * will be used for view **/ template inline void view_offset(const size_t offset,ucl_type &input,const size_t cols) { view_offset(offset,input,1,cols); } - + /// Do not allocate memory, instead use an existing allocation from Geryon /** This function must be passed a Geryon vector or matrix container. * No memory is freed when the object is destructed. * - The view does not prevent the memory from being freed by the - * allocating container when using CUDA APIs + * allocating container when using CUDA APIs * - If a matrix is used a input, all elements (including padding) * will be used for view **/ template - inline void view_offset(const size_t offset, ucl_type &input) + inline void view_offset(const size_t offset, ucl_type &input) { view_offset(offset,input,input.rows()*input.row_size()-offset); } - + /// Do not allocate memory, instead use an existing allocation /** - No memory is freed when the object is destructed. * - The view does not prevent the memory from being freed by the @@ -302,7 +302,7 @@ class UCL_D_Vec : public UCL_BaseMat { _cols=cols; _row_bytes=_cols*sizeof(numtyp); this->_cq=dev.cq(); - + #ifdef _OCL_MAT _array=input; _offset=offset; @@ -315,20 +315,20 @@ class UCL_D_Vec : public UCL_BaseMat { _array=input+offset; #endif #endif - + #ifndef _UCL_DEVICE_PTR_MAT _end=_array+_cols; #endif } - + /// Do not allocate memory, instead use an existing allocation /** - No memory is freed when the object is destructed. * - The view does not prevent the memory from being freed by the - * allocating container when using CUDA APIs - * \param stride Number of _elements_ between the start of each row **/ + * allocating container when using CUDA APIs + * \param stride Number of _elements_ between the start of each row **/ template inline void view_offset(const size_t offset,ptr_type input,const size_t rows, - const size_t cols,const size_t stride,UCL_Device &dev) + const size_t cols,const size_t stride,UCL_Device &dev) { view_offset(offset,input,rows,cols,stride); } /// Do not allocate memory, instead use an existing allocation @@ -336,12 +336,12 @@ class UCL_D_Vec : public UCL_BaseMat { * - The view does not prevent the memory from being freed by the * allocating container when using CUDA APIs **/ template - inline void view_offset(const size_t offset, ptr_type input, + inline void view_offset(const size_t offset, ptr_type input, const size_t cols, UCL_Device &dev) { view_offset(offset,input,1,cols,dev); } - + /// Free memory and set size to 0 - inline void clear() + inline void clear() { _device_free(*this); _cols=0; _kind=UCL_VIEW; } /// Resize the allocation to contain cols elements @@ -369,9 +369,9 @@ class UCL_D_Vec : public UCL_BaseMat { #ifdef _OCL_MAT _offset=0; #endif - return err; + return err; } - + /// Resize (only if bigger) the allocation to contain cols elements /** \note Cannot be used on views **/ inline int resize_ib(const int cols) @@ -384,7 +384,7 @@ class UCL_D_Vec : public UCL_BaseMat { /// Set each element to zero asynchronously inline void zero(command_queue &cq) { _device_zero(*this,row_bytes(),cq); } /// Set first n elements to zero asynchronously - inline void zero(const int n, command_queue &cq) + inline void zero(const int n, command_queue &cq) { _device_zero(*this,n*sizeof(numtyp),cq); } #ifdef _UCL_DEVICE_PTR_MAT @@ -402,7 +402,7 @@ class UCL_D_Vec : public UCL_BaseMat { /// For CUDA-RT, get device pointer to one past last element inline numtyp * end() const { return _end; } #endif - + #ifdef _UCL_DEVICE_PTR_MAT /// Returns an API specific device pointer /** - For OpenCL, returns a &cl_mem object @@ -427,10 +427,10 @@ class UCL_D_Vec : public UCL_BaseMat { inline const numtyp ** cbegin() const { return &_array; } /// For CUDA-RT, allocate row vector and bind texture inline void safe_alloc(const size_t cols, UCL_Device &dev, - textureReference *t) + textureReference *t) { alloc(cols,dev); assign_texture(t); bind(); } /// For CUDA-RT, assign a texture to matrix - inline void assign_texture(textureReference *t) { _tex_ptr=t; } + inline void assign_texture(textureReference *t) { _tex_ptr=t; } /// For CUDA-RT, bind to texture inline void bind() { cuda_gb_get_channel(_channel); @@ -456,7 +456,7 @@ class UCL_D_Vec : public UCL_BaseMat { inline size_t row_bytes() const { return _row_bytes; } /// Get the size in bytes of 1 element inline int element_size() const { return sizeof(numtyp); } - + #ifdef _OCL_MAT /// Return the offset (in elements) from begin() pointer where data starts /** \note Always 0 for host matrices and CUDA APIs **/ @@ -473,7 +473,7 @@ class UCL_D_Vec : public UCL_BaseMat { private: size_t _row_bytes, _row_size, _rows, _cols; - + #ifdef _UCL_DEVICE_PTR_MAT device_ptr _array; #else diff --git a/lib/gpu/geryon/ucl_h_mat.h b/lib/gpu/geryon/ucl_h_mat.h index dc6da3de0c..1df3c2de4b 100644 --- a/lib/gpu/geryon/ucl_h_mat.h +++ b/lib/gpu/geryon/ucl_h_mat.h @@ -17,7 +17,7 @@ /* ----------------------------------------------------------------------- Copyright (2009) Sandia Corporation. Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains - certain rights in this software. This software is distributed under + certain rights in this software. This software is distributed under the Simplified BSD License. ----------------------------------------------------------------------- */ @@ -37,21 +37,21 @@ class UCL_H_Mat : public UCL_BaseMat { ROW_MAJOR = 1, VECTOR = 0 }; - typedef numtyp data_type; - + typedef numtyp data_type; + UCL_H_Mat() : _cols(0) { #ifdef _OCL_MAT _carray=(cl_mem)(0); #endif } ~UCL_H_Mat() { _host_free(*this); } - + /// Construct with specied number of rows and columns /** \sa alloc() **/ - UCL_H_Mat(const size_t rows, const size_t cols, UCL_Device &device, - const enum UCL_MEMOPT kind=UCL_READ_WRITE) + UCL_H_Mat(const size_t rows, const size_t cols, UCL_Device &device, + const enum UCL_MEMOPT kind=UCL_READ_WRITE) { _cols=0; _kind=UCL_VIEW; alloc(rows,cols,device,kind); } - + /// Set up host matrix with specied # of rows/cols and reserve memory /** The kind parameter controls memory pinning as follows: * - UCL_READ_WRITE - Specify that you will read and write from host @@ -74,7 +74,7 @@ class UCL_H_Mat : public UCL_BaseMat { << " bytes on host.\n"; _row_bytes=0; UCL_GERYON_EXIT; - #endif + #endif _row_bytes=0; return err; } @@ -84,7 +84,7 @@ class UCL_H_Mat : public UCL_BaseMat { _kind=kind; _end=_array+rows*cols; return err; - } + } /// Set up host matrix with specied # of rows/cols and reserve memory /** The kind parameter controls memory pinning as follows: @@ -117,15 +117,15 @@ class UCL_H_Mat : public UCL_BaseMat { _kind=kind; _end=_array+rows*cols; return err; - } - + } + /// Do not allocate memory, instead use an existing allocation from Geryon /** This function must be passed a Geryon vector or matrix container. * No memory is freed when the object is destructed. * - The view does not prevent the memory from being freed by the - * allocating container when using CUDA APIs - * - Viewing a device container on the host is not supported - * \param stride Number of _elements_ between the start of each row **/ + * allocating container when using CUDA APIs + * - Viewing a device container on the host is not supported + * \param stride Number of _elements_ between the start of each row **/ template inline void view(ucl_type &input, const size_t rows, const size_t cols, const size_t stride) { @@ -149,45 +149,45 @@ class UCL_H_Mat : public UCL_BaseMat { /** This function must be passed a Geryon vector or matrix container. * No memory is freed when the object is destructed. * - The view does not prevent the memory from being freed by the - * allocating container when using CUDA APIs - * - Viewing a device container on the host is not supported **/ + * allocating container when using CUDA APIs + * - Viewing a device container on the host is not supported **/ template - inline void view(ucl_type &input, const size_t rows, const size_t cols) + inline void view(ucl_type &input, const size_t rows, const size_t cols) { view(input,rows,cols,input.row_size()); } - + /// Do not allocate memory, instead use an existing allocation from Geryon /** This function must be passed a Geryon vector or matrix container. * No memory is freed when the object is destructed. * - The view does not prevent the memory from being freed by the - * allocating container when using CUDA APIs + * allocating container when using CUDA APIs * - If a matrix is used a input, all elements (including padding) - * will be used for view - * - Viewing a device container on the host is not supported **/ + * will be used for view + * - Viewing a device container on the host is not supported **/ template inline void view(ucl_type &input, const size_t cols) { view(input,1,cols); } - + /// Do not allocate memory, instead use an existing allocation from Geryon /** This function must be passed a Geryon vector or matrix container. * No memory is freed when the object is destructed. * - The view does not prevent the memory from being freed by the - * allocating container when using CUDA APIs + * allocating container when using CUDA APIs * - If a matrix is used a input, all elements (including padding) - * will be used for view when using CUDA APIs - * - Viewing a device container on the host is not supported **/ + * will be used for view when using CUDA APIs + * - Viewing a device container on the host is not supported **/ template - inline void view(ucl_type &input) + inline void view(ucl_type &input) { view(input,input.rows(),input.cols()); } - + /// Do not allocate memory, instead use an existing allocation /** - No memory is freed when the object is destructed. * - The view does not prevent the memory from being freed by the - * allocating container when using CUDA APIs - * - Viewing a device pointer on the host is not supported - * \param stride Number of _elements_ between the start of each row **/ + * allocating container when using CUDA APIs + * - Viewing a device pointer on the host is not supported + * \param stride Number of _elements_ between the start of each row **/ template inline void view(ptr_type *input, const size_t rows, const size_t cols, - const size_t stride, UCL_Device &dev) { + const size_t stride, UCL_Device &dev) { assert(rows==1 || stride==cols); clear(); _kind=UCL_VIEW; @@ -197,40 +197,40 @@ class UCL_H_Mat : public UCL_BaseMat { this->_cq=dev.cq(); _array=input; _end=_array+_cols; - + #ifdef _OCL_MAT _host_view(*this,dev,_row_bytes*rows); - #endif + #endif } /// Do not allocate memory, instead use an existing allocation /** - No memory is freed when the object is destructed. * - The view does not prevent the memory from being freed by the - * allocating container when using CUDA APIs - * - Viewing a device pointer on the host is not supported **/ + * allocating container when using CUDA APIs + * - Viewing a device pointer on the host is not supported **/ template inline void view(ptr_type *input, const size_t rows, const size_t cols, UCL_Device &dev) { view(input,rows,cols,cols,dev); } - + /// Do not allocate memory, instead use an existing allocation /** - No memory is freed when the object is destructed. * - The view does not prevent the memory from being freed by the - * allocating container when using CUDA APIs - * - Viewing a device pointer on the host is not supported **/ + * allocating container when using CUDA APIs + * - Viewing a device pointer on the host is not supported **/ template inline void view(ptr_type *input, const size_t cols, UCL_Device &dev) { view(input,1,cols,dev); } - + /// Do not allocate memory, instead use an existing allocation from Geryon /** This function must be passed a Geryon vector or matrix container. * No memory is freed when the object is destructed. * - The view does not prevent the memory from being freed by the - * allocating container when using CUDA APIs - * - Viewing a device container on the host is not supported - * \param stride Number of _elements_ between the start of each row **/ + * allocating container when using CUDA APIs + * - Viewing a device container on the host is not supported + * \param stride Number of _elements_ between the start of each row **/ template inline void view_offset(const size_t offset,ucl_type &input,const size_t rows, - const size_t cols, const size_t stride) { + const size_t cols, const size_t stride) { assert(rows==1 || stride==cols); clear(); _kind=UCL_VIEW; @@ -244,81 +244,81 @@ class UCL_H_Mat : public UCL_BaseMat { _host_view(*this,input,_row_bytes*_rows); #endif } - + /// Do not allocate memory, instead use an existing allocation from Geryon /** This function must be passed a Geryon vector or matrix container. * No memory is freed when the object is destructed. * - The view does not prevent the memory from being freed by the - * allocating container when using CUDA APIs - * - Viewing a device container on the host is not supported **/ + * allocating container when using CUDA APIs + * - Viewing a device container on the host is not supported **/ template inline void view_offset(const size_t offset,ucl_type &input,const size_t rows, - const size_t cols) + const size_t cols) { view_offset(offset,input,rows,cols,input.row_size()); } - + /// Do not allocate memory, instead use an existing allocation from Geryon /** This function must be passed a Geryon vector or matrix container. * No memory is freed when the object is destructed. * - The view does not prevent the memory from being freed by the - * allocating container when using CUDA APIs + * allocating container when using CUDA APIs * - If a matrix is used a input, all elements (including padding) - * will be used for view - * - Viewing a device container on the host is not supported **/ + * will be used for view + * - Viewing a device container on the host is not supported **/ template inline void view_offset(const size_t offset,ucl_type &input,const size_t cols) { view_offset(offset,input,1,cols); } - + /// Do not allocate memory, instead use an existing allocation from Geryon /** This function must be passed a Geryon vector or matrix container. * No memory is freed when the object is destructed. * - The view does not prevent the memory from being freed by the - * allocating container when using CUDA APIs + * allocating container when using CUDA APIs * - If a matrix is used a input, all elements (including padding) - * will be used for view - * - Viewing a device container on the host is not supported **/ + * will be used for view + * - Viewing a device container on the host is not supported **/ template - inline void view_offset(const size_t offset, ucl_type &input) { - if (input.rows()==1) + inline void view_offset(const size_t offset, ucl_type &input) { + if (input.rows()==1) view_offset(offset,input,1,input.cols()-offset); - else + else view_offset(offset,input,input.rows()-offset/input.row_size(), input.cols()); } - + /// Do not allocate memory, instead use an existing allocation /** - No memory is freed when the object is destructed. * - The view does not prevent the memory from being freed by the - * allocating container - * - Viewing a device pointer on the host is not supported **/ + * allocating container + * - Viewing a device pointer on the host is not supported **/ template inline void view_offset(const size_t offset,ptr_type *input,const size_t rows, const size_t cols, UCL_Device &dev) { view(input+offset,rows,cols,dev); } - + /// Do not allocate memory, instead use an existing allocation /** - No memory is freed when the object is destructed. * - The view does not prevent the memory from being freed by the - * allocating container when using CUDA APIs - * - Viewing a device pointer on the host is not supported - * \param stride Number of _elements_ between the start of each row **/ + * allocating container when using CUDA APIs + * - Viewing a device pointer on the host is not supported + * \param stride Number of _elements_ between the start of each row **/ template inline void view_offset(const size_t offset,ptr_type *input,const size_t rows, - const size_t cols,const size_t stride,UCL_Device &dev) + const size_t cols,const size_t stride,UCL_Device &dev) { view(input+offset,rows,cols,stride,dev); } /// Do not allocate memory, instead use an existing allocation /** - No memory is freed when the object is destructed. * - The view does not prevent the memory from being freed by the - * allocating container when using CUDA APIs - * - Viewing a device pointer on the host is not supported **/ + * allocating container when using CUDA APIs + * - Viewing a device pointer on the host is not supported **/ template - inline void view_offset(const size_t offset, ptr_type *input, + inline void view_offset(const size_t offset, ptr_type *input, const size_t cols, UCL_Device &dev) { view(input+offset,1,cols,dev); } - + /// Free memory and set size to 0 - inline void clear() - { _host_free(*this); _cols=0; _kind=UCL_VIEW; } + inline void clear() + { _host_free(*this); _cols=0; _kind=UCL_VIEW; } /// Resize the allocation to rows x cols elements /** \note Cannot be used on views **/ @@ -333,7 +333,7 @@ class UCL_H_Mat : public UCL_BaseMat { << " bytes on host.\n"; _row_bytes=0; UCL_GERYON_EXIT; - #endif + #endif _row_bytes=0; return err; } @@ -347,7 +347,7 @@ class UCL_H_Mat : public UCL_BaseMat { /// Resize (only if bigger) the allocation to contain rows x cols elements /** \note Cannot be used on views **/ inline int resize_ib(const int rows, const int cols) - { if (cols>_cols || rows>_rows) return resize(rows,cols); + { if (cols>_cols || rows>_rows) return resize(rows,cols); else return UCL_SUCCESS; } /// Set each element to zero @@ -376,21 +376,21 @@ class UCL_H_Mat : public UCL_BaseMat { inline size_t row_bytes() const { return _row_bytes; } /// Get the size in bytes of 1 element inline int element_size() const { return sizeof(numtyp); } - + /// Get element at index i inline numtyp & operator[](const int i) { return _array[i]; } /// Get element at index i inline const numtyp & operator[](const int i) const { return _array[i]; } - /// 2D access (row should always be 0) - inline numtyp & operator()(const int row, const int col) + /// 2D access (row should always be 0) + inline numtyp & operator()(const int row, const int col) { return _array[row*_cols+col]; } - /// 2D access (row should always be 0) + /// 2D access (row should always be 0) inline const numtyp & operator()(const int row, const int col) const { return _array[row*_cols+col]; } - + /// Returns pointer to memory pointer for allocation on host inline numtyp ** host_ptr() { return &_array; } - + /// Return the offset (in elements) from begin() pointer where data starts /** \note Always 0 for host matrices and CUDA APIs **/ inline size_t offset() const { return 0; } @@ -409,14 +409,14 @@ class UCL_H_Mat : public UCL_BaseMat { /// Returns an API specific device pointer (cl_mem& for OpenCL, void ** for CUDA) inline const void ** cbegin() const { return (const void **)&_array; } #endif - + private: numtyp *_array, *_end; size_t _row_bytes, _rows, _cols; #ifdef _OCL_MAT device_ptr _carray; - #endif + #endif }; #endif diff --git a/lib/gpu/geryon/ucl_h_vec.h b/lib/gpu/geryon/ucl_h_vec.h index 773facdea0..a9d64349d9 100644 --- a/lib/gpu/geryon/ucl_h_vec.h +++ b/lib/gpu/geryon/ucl_h_vec.h @@ -17,7 +17,7 @@ /* ----------------------------------------------------------------------- Copyright (2009) Sandia Corporation. Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains - certain rights in this software. This software is distributed under + certain rights in this software. This software is distributed under the Simplified BSD License. ----------------------------------------------------------------------- */ @@ -37,21 +37,21 @@ class UCL_H_Vec : public UCL_BaseMat { ROW_MAJOR = 1, VECTOR = 1 }; - typedef numtyp data_type; - + typedef numtyp data_type; + UCL_H_Vec() : _cols(0) { #ifdef _OCL_MAT _carray=(cl_mem)(0); #endif } ~UCL_H_Vec() { _host_free(*this); } - + /// Construct with n columns /** \sa alloc() **/ - UCL_H_Vec(const size_t n, UCL_Device &device, - const enum UCL_MEMOPT kind=UCL_READ_WRITE) + UCL_H_Vec(const size_t n, UCL_Device &device, + const enum UCL_MEMOPT kind=UCL_READ_WRITE) { _cols=0; _kind=UCL_VIEW; alloc(n,device,kind); } - + /// Set up host vector with 'cols' columns and reserve memory /** The kind parameter controls memory pinning as follows: * - UCL_READ_WRITE - Specify that you will read and write from host @@ -84,7 +84,7 @@ class UCL_H_Vec : public UCL_BaseMat { _kind=kind; _end=_array+cols; return err; - } + } /// Set up host vector with 'cols' columns and reserve memory /** The kind parameter controls memory pinning as follows: @@ -108,7 +108,7 @@ class UCL_H_Vec : public UCL_BaseMat { << " bytes on host.\n"; _row_bytes=0; UCL_GERYON_EXIT; - #endif + #endif _row_bytes=0; return err; } @@ -118,13 +118,13 @@ class UCL_H_Vec : public UCL_BaseMat { _end=_array+cols; return err; } - + /// Do not allocate memory, instead use an existing allocation from Geryon /** This function must be passed a Geryon vector or matrix container. * No memory is freed when the object is destructed. * - The view does not prevent the memory from being freed by the - * allocating container when using CUDA APIs - * - Viewing a device container on the host is not supported **/ + * allocating container when using CUDA APIs + * - Viewing a device container on the host is not supported **/ template inline void view(ucl_type &input, const size_t rows, const size_t cols) { #ifdef UCL_DEBUG @@ -143,14 +143,14 @@ class UCL_H_Vec : public UCL_BaseMat { CL_SAFE_CALL(clRetainCommandQueue(input.cq())); #endif } - + /// Do not allocate memory, instead use an existing allocation from Geryon /** This function must be passed a Geryon vector or matrix container. * No memory is freed when the object is destructed. * - The view does not prevent the memory from being freed by the * allocating container when using CUDA APIs - * - Viewing a device container on the host is not supported - * \param stride Number of _elements_ between the start of each row **/ + * - Viewing a device container on the host is not supported + * \param stride Number of _elements_ between the start of each row **/ template inline void view(ucl_type &input, const size_t rows, const size_t cols, const size_t stride) { view(input,rows,cols); } @@ -159,31 +159,31 @@ class UCL_H_Vec : public UCL_BaseMat { /** This function must be passed a Geryon vector or matrix container. * No memory is freed when the object is destructed. * - The view does not prevent the memory from being freed by the - * allocating container when using CUDA APIs + * allocating container when using CUDA APIs * - If a matrix is used a input, all elements (including padding) - * will be used for view - * - Viewing a device container on the host is not supported **/ + * will be used for view + * - Viewing a device container on the host is not supported **/ template inline void view(ucl_type &input, const size_t cols) { view(input,1,cols); } - + /// Do not allocate memory, instead use an existing allocation from Geryon /** This function must be passed a Geryon vector or matrix container. * No memory is freed when the object is destructed. * - The view does not prevent the memory from being freed by the - * allocating container + * allocating container * - If a matrix is used a input, all elements (including padding) - * will be used for view - * - Viewing a device container on the host is not supported **/ + * will be used for view + * - Viewing a device container on the host is not supported **/ template - inline void view(ucl_type &input) + inline void view(ucl_type &input) { view(input,input.rows()*input.row_size()); } - + /// Do not allocate memory, instead use an existing allocation /** - No memory is freed when the object is destructed. * - The view does not prevent the memory from being freed by the - * allocating container when using CUDA APIs - * - Viewing a device pointer on the host is not supported **/ + * allocating container when using CUDA APIs + * - Viewing a device pointer on the host is not supported **/ template inline void view(ptr_type *input, const size_t rows, const size_t cols, UCL_Device &dev) { @@ -197,38 +197,38 @@ class UCL_H_Vec : public UCL_BaseMat { this->_cq=dev.cq(); _array=input; _end=_array+_cols; - + #ifdef _OCL_MAT _host_view(*this,dev,_row_bytes); - #endif + #endif } - + /// Do not allocate memory, instead use an existing allocation /** - No memory is freed when the object is destructed. * - The view does not prevent the memory from being freed by the * allocating container when using CUDA APIs - * - Viewing a device pointer on the host is not supported - * \param stride Number of _elements_ between the start of each row **/ + * - Viewing a device pointer on the host is not supported + * \param stride Number of _elements_ between the start of each row **/ template inline void view(ptr_type *input, const size_t rows, const size_t cols, - const size_t stride, UCL_Device &dev) + const size_t stride, UCL_Device &dev) { view(input,rows,cols,stride); } /// Do not allocate memory, instead use an existing allocation /** - No memory is freed when the object is destructed. * - The view does not prevent the memory from being freed by the * allocating container when using CUDA APIs - * - Viewing a device pointer on the host is not supported **/ + * - Viewing a device pointer on the host is not supported **/ template inline void view(ptr_type *input, const size_t cols, UCL_Device &dev) { view(input,1,cols,dev); } - + /// Do not allocate memory, instead use an existing allocation from Geryon /** This function must be passed a Geryon vector or matrix container. * No memory is freed when the object is destructed. * - The view does not prevent the memory from being freed by the * allocating container when using CUDA APIs - * - Viewing a device container on the host is not supported **/ + * - Viewing a device container on the host is not supported **/ template inline void view_offset(const size_t offset,ucl_type &input,const size_t rows, const size_t cols) { @@ -246,76 +246,76 @@ class UCL_H_Vec : public UCL_BaseMat { _host_view(*this,input,_row_bytes); #endif } - + /// Do not allocate memory, instead use an existing allocation from Geryon /** This function must be passed a Geryon vector or matrix container. * No memory is freed when the object is destructed. * - The view does not prevent the memory from being freed by the - * allocating container when using CUDA APIs - * - Viewing a device container on the host is not supported - * \param stride Number of _elements_ between the start of each row **/ + * allocating container when using CUDA APIs + * - Viewing a device container on the host is not supported + * \param stride Number of _elements_ between the start of each row **/ template inline void view_offset(const size_t offset,ucl_type &input,const size_t rows, - const size_t cols, const size_t stride) + const size_t cols, const size_t stride) { view_offset(offset,input,rows,cols); } /// Do not allocate memory, instead use an existing allocation from Geryon /** This function must be passed a Geryon vector or matrix container. * No memory is freed when the object is destructed. * - The view does not prevent the memory from being freed by the - * allocating container when using CUDA APIs + * allocating container when using CUDA APIs * - If a matrix is used a input, all elements (including padding) - * will be used for view - * - Viewing a device container on the host is not supported **/ + * will be used for view + * - Viewing a device container on the host is not supported **/ template inline void view_offset(const size_t offset,ucl_type &input,const size_t cols) { view_offset(offset,input,1,cols); } - + /// Do not allocate memory, instead use an existing allocation from Geryon /** This function must be passed a Geryon vector or matrix container. * No memory is freed when the object is destructed. * - The view does not prevent the memory from being freed by the - * allocating container when using CUDA APIs + * allocating container when using CUDA APIs * - If a matrix is used a input, all elements (including padding) - * will be used for view - * - Viewing a device container on the host is not supported **/ + * will be used for view + * - Viewing a device container on the host is not supported **/ template - inline void view_offset(const size_t offset, ucl_type &input) + inline void view_offset(const size_t offset, ucl_type &input) { view_offset(offset,input,input.rows()*input.row_size()-offset); } - + /// Do not allocate memory, instead use an existing allocation /** - No memory is freed when the object is destructed. * - The view does not prevent the memory from being freed by the - * allocating container when using CUDA APIs - * - Viewing a device pointer on the host is not supported **/ + * allocating container when using CUDA APIs + * - Viewing a device pointer on the host is not supported **/ template inline void view_offset(const size_t offset,ptr_type *input,const size_t rows, const size_t cols, UCL_Device &dev) { view(input+offset,rows,cols,dev); } - + /// Do not allocate memory, instead use an existing allocation /** - No memory is freed when the object is destructed. * - The view does not prevent the memory from being freed by the - * allocating container when using CUDA APIs - * - Viewing a device pointer on the host is not supported - * \param stride Number of _elements_ between the start of each row **/ + * allocating container when using CUDA APIs + * - Viewing a device pointer on the host is not supported + * \param stride Number of _elements_ between the start of each row **/ template inline void view_offset(const size_t offset,ptr_type *input,const size_t rows, - const size_t cols,const size_t stride,UCL_Device &dev) + const size_t cols,const size_t stride,UCL_Device &dev) { view(input+offset,rows,cols,stride,dev); } /// Do not allocate memory, instead use an existing allocation /** - No memory is freed when the object is destructed. * - The view does not prevent the memory from being freed by the - * allocating container when using CUDA APIs - * - Viewing a device pointer on the host is not supported **/ + * allocating container when using CUDA APIs + * - Viewing a device pointer on the host is not supported **/ template - inline void view_offset(const size_t offset, ptr_type *input, + inline void view_offset(const size_t offset, ptr_type *input, const size_t cols, UCL_Device &dev) { view(input+offset,1,cols,dev); } - + /// Free memory and set size to 0 - inline void clear() + inline void clear() { _host_free(*this); _kind=UCL_VIEW; _cols=0; } /// Resize the allocation to contain cols elements @@ -324,7 +324,7 @@ class UCL_H_Vec : public UCL_BaseMat { assert(_kind!=UCL_VIEW); _row_bytes=cols*sizeof(numtyp); int err=_host_resize(*this,_row_bytes); - + if (err!=UCL_SUCCESS) { #ifndef UCL_NO_EXIT std::cerr << "UCL Error: Could not allocate " << _row_bytes @@ -340,7 +340,7 @@ class UCL_H_Vec : public UCL_BaseMat { _end=_array+cols; return err; } - + /// Resize (only if bigger) the allocation to contain cols elements /** \note Cannot be used on views **/ inline int resize_ib(const int cols) @@ -348,7 +348,7 @@ class UCL_H_Vec : public UCL_BaseMat { /// Set each element to zero inline void zero() { _host_zero(_array,row_bytes()); } - + /// Set first n elements to zero inline void zero(const int n) { _host_zero(_array,n*sizeof(numtyp)); } @@ -373,35 +373,35 @@ class UCL_H_Vec : public UCL_BaseMat { inline size_t row_bytes() const { return _row_bytes; } /// Get the size in bytes of 1 element inline int element_size() const { return sizeof(numtyp); } - + /// Get element at index i inline numtyp & operator[](const int i) { return _array[i]; } /// Get element at index i inline const numtyp & operator[](const int i) const { return _array[i]; } - /// 2D access (row should always be 0) - inline numtyp & operator()(const int row, const int col) + /// 2D access (row should always be 0) + inline numtyp & operator()(const int row, const int col) { return _array[col]; } - /// 2D access (row should always be 0) + /// 2D access (row should always be 0) inline const numtyp & operator()(const int row, const int col) const { return _array[col]; } - + /// Returns pointer to memory pointer for allocation on host inline numtyp ** host_ptr() { return &_array; } - + /// Return the offset (in elements) from begin() pointer where data starts /** \note Always 0 for host matrices and CUDA APIs **/ inline size_t offset() const { return 0; } /// Return the offset (in bytes) from begin() pointer where data starts /** \note Always 0 for host matrices and CUDA APIs **/ inline size_t byteoff() const { return 0; } - + #ifdef _OCL_MAT /// For OpenCL, returns a reference to the cl_mem object inline device_ptr & cbegin() { return _carray; } /// For OpenCL, returns a reference to the cl_mem object inline const device_ptr & cbegin() const { return _carray; } #endif - + private: numtyp *_array, *_end; size_t _row_bytes, _cols; diff --git a/lib/gpu/geryon/ucl_matrix.h b/lib/gpu/geryon/ucl_matrix.h index 301325b454..b93d1c7f68 100644 --- a/lib/gpu/geryon/ucl_matrix.h +++ b/lib/gpu/geryon/ucl_matrix.h @@ -34,25 +34,25 @@ class UCL_Matrix { ROW_MAJOR = 1, VECTOR = 0 }; - typedef hosttype data_type; + typedef hosttype data_type; /// Host Allocation UCL_H_Mat host; - + /// Device Allocation UCL_D_Mat device; UCL_Matrix() { } ~UCL_Matrix() { } - + /// Construct with specied number of rows and columns /** \sa alloc() **/ - UCL_Matrix(const size_t rows, const size_t cols, UCL_Device &acc, + UCL_Matrix(const size_t rows, const size_t cols, UCL_Device &acc, const enum UCL_MEMOPT kind1=UCL_READ_WRITE, const enum UCL_MEMOPT kind2=UCL_READ_WRITE) { _ucl_s_obj_help< ucl_same_type::ans >:: alloc(host,device,_buffer,rows,cols,acc,kind1,kind2); } - + /// Set up host matrix with specied # of rows/cols and reserve memory /** The kind1 parameter controls memory access from the host * - UCL_READ_WRITE - Specify that you will read and write from host @@ -74,7 +74,7 @@ class UCL_Matrix { const enum UCL_MEMOPT kind2=UCL_READ_WRITE) { return _ucl_s_obj_help< ucl_same_type::ans >:: alloc(host,device,_buffer,rows,cols,cq,kind1,kind2); } - + /// Set up host matrix with specied # of rows/cols and reserve memory /** The kind1 parameter controls memory access from the host * - UCL_READ_WRITE - Specify that you will read and write from host @@ -92,9 +92,9 @@ class UCL_Matrix { const enum UCL_MEMOPT kind2=UCL_READ_WRITE) { return _ucl_s_obj_help< ucl_same_type::ans >:: alloc(host,device,_buffer,rows,cols,acc,kind1,kind2); } - + /// Free memory and set size to 0 - inline void clear() + inline void clear() { host.clear(); device.clear(); } /// Resize the allocation to contain cols elements @@ -106,10 +106,10 @@ class UCL_Matrix { return _ucl_s_obj_help< ucl_same_type::ans >:: dev_resize(device,host,_buffer,rows,cols); } - + /// Resize (only if bigger) the allocation to contain cols elements inline int resize_ib(const int new_rows, const int new_cols) - { if (new_rows>rows() || new_cols>cols()) return resize(new_rows,new_cols); + { if (new_rows>rows() || new_cols>cols()) return resize(new_rows,new_cols); else return UCL_SUCCESS; } /// Set each element to zero (asynchronously on device) @@ -118,14 +118,14 @@ class UCL_Matrix { inline void zero(const int n) { zero(n,cq()); } /// Set each element to zero (asynchronously on device) inline void zero(command_queue &cq) { - host.zero(); + host.zero(); if (device.kind()!=UCL_VIEW) device.zero(cq); else if (_buffer.numel()>0) _buffer.zero(); } /// Set first n elements to zero (asynchronously on device) - inline void zero(const int n, command_queue &cq) { - host.zero(n); - if (device.kind()!=UCL_VIEW) device.zero(n,cq); + inline void zero(const int n, command_queue &cq) { + host.zero(n); + if (device.kind()!=UCL_VIEW) device.zero(n,cq); else if (_buffer.numel()>0) _buffer.zero(); } @@ -136,26 +136,26 @@ class UCL_Matrix { /// Get the number of columns inline size_t cols() const { return host.cols(); } /// Get the memory usage (bytes) of the s-object (including any buffers) - inline size_t host_mem_usage() + inline size_t host_mem_usage() { return host.row_bytes()*host.rows()+_buffer.row_bytes()*_buffer.rows(); } /// Get the memory usage (bytes) of the s-object (including any buffers) - inline size_t device_mem_usage() + inline size_t device_mem_usage() { return device.row_bytes()*device.rows(); } - + /// Get element at index i inline hosttype & operator[](const int i) { return host[i]; } /// Get element at index i inline const hosttype & operator[](const int i) const { return host[i]; } - /// 2D access (row should always be 0) - inline hosttype & operator()(const int row, const int col) + /// 2D access (row should always be 0) + inline hosttype & operator()(const int row, const int col) { return host(row,col); } - /// 2D access (row should always be 0) + /// 2D access (row should always be 0) inline const hosttype & operator()(const int row, const int col) const { return host(row,col); } - + /// Returns pointer to memory pointer for allocation on host inline hosttype ** host_ptr() { return host.host_ptr(); } - + /// Return the default command queue/stream associated with this data inline command_queue & cq() { return host.cq(); } /// Change the default command queue associated with this data @@ -172,7 +172,7 @@ class UCL_Matrix { /// Update the allocation on the host asynchronously - inline void update_host() + inline void update_host() { _ucl_s_obj_help< ucl_same_type::ans >:: copy(host,device,_buffer,true); } /// Update the allocation on the host (true for asynchronous copy) @@ -202,7 +202,7 @@ class UCL_Matrix { /// Update the allocation on the device asynchronously - inline void update_device() + inline void update_device() { _ucl_s_obj_help< ucl_same_type::ans >:: copy(device,host,_buffer,true); } /// Update the allocation on the device (true for asynchronous copy) diff --git a/lib/gpu/geryon/ucl_nv_kernel.h b/lib/gpu/geryon/ucl_nv_kernel.h index bdba8ff7ae..437631ec3a 100644 --- a/lib/gpu/geryon/ucl_nv_kernel.h +++ b/lib/gpu/geryon/ucl_nv_kernel.h @@ -17,7 +17,7 @@ /* ----------------------------------------------------------------------- Copyright (2010) Sandia Corporation. Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains - certain rights in this software. This software is distributed under + certain rights in this software. This software is distributed under the Simplified BSD License. ----------------------------------------------------------------------- */ @@ -53,9 +53,9 @@ typedef struct _double4 double4; #define BLOCK_SIZE_Y blockDim.y #define __kernel extern "C" __global__ #define __local __shared__ -#define __global +#define __global #define atom_add atomicAdd -#define ucl_inline static __inline__ __device__ +#define ucl_inline static __inline__ __device__ #endif diff --git a/lib/gpu/geryon/ucl_print.h b/lib/gpu/geryon/ucl_print.h index 87b3d3d7ff..98ae8a8c06 100644 --- a/lib/gpu/geryon/ucl_print.h +++ b/lib/gpu/geryon/ucl_print.h @@ -17,10 +17,10 @@ /* ----------------------------------------------------------------------- Copyright (2010) Sandia Corporation. Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains - certain rights in this software. This software is distributed under + certain rights in this software. This software is distributed under the Simplified BSD License. ----------------------------------------------------------------------- */ - + // Only allow this file to be included by nvc_memory.h and ocl_memory.h #ifdef UCL_PRINT_ALLOW @@ -40,7 +40,7 @@ template <> struct _ucl_print<1> { } template static inline void p(mat_type &mat, const size_t rows, const size_t cols, - std::ostream &out, const std::string delim, + std::ostream &out, const std::string delim, const std::string row_delim) { int offset=0; int row_size=cols; @@ -58,12 +58,12 @@ template <> struct _ucl_print<1> { } template static inline void p(const mat_type &mat,const size_t rows,const size_t cols, - std::ostream &out,const std::string delim, + std::ostream &out,const std::string delim, const std::string row_delim, UCL_Device &dev) { - p(mat,rows,cols,out,delim,row_delim); + p(mat,rows,cols,out,delim,row_delim); } }; - + template struct _ucl_print { template static inline void p(mat_type &mat, const size_t n, std::ostream &out, @@ -83,7 +83,7 @@ template struct _ucl_print { } template static inline void p(mat_type &mat, const size_t rows, const size_t cols, - std::ostream &out, const std::string delim, + std::ostream &out, const std::string delim, const std::string row_delim) { UCL_H_Vec temp; temp.alloc(mat.rows()*mat.cols(),mat); @@ -91,12 +91,12 @@ template struct _ucl_print { ucl_copy(temp,mat,rows*cols,false); else ucl_copy(temp,mat,rows,cols,false); - _ucl_print<1>::p(temp,rows,cols,out,delim,row_delim); + _ucl_print<1>::p(temp,rows,cols,out,delim,row_delim); } template - static inline void p(const mat_type &mat, const size_t rows, + static inline void p(const mat_type &mat, const size_t rows, const size_t cols,std::ostream &out, - const std::string delim, + const std::string delim, const std::string row_delim, UCL_Device &dev) { UCL_H_Vec temp; temp.alloc(mat.rows()*mat.cols(),dev); @@ -104,9 +104,9 @@ template struct _ucl_print { ucl_copy(temp,mat,rows*cols,false); else ucl_copy(temp,mat,rows,cols,false); - _ucl_print<1>::p(temp,rows,cols,out,delim,row_delim); + _ucl_print<1>::p(temp,rows,cols,out,delim,row_delim); } -}; +}; // ------------------------------------------------------------------------- // - Non-const routines that do not require a device object @@ -123,13 +123,13 @@ inline void ucl_print(mat_type &mat, const size_t n, std::ostream &out, } _ucl_print::p(mat,n,out,delim); } - + /// Outputs n elements of mat delimited by a space template inline void ucl_print(mat_type &mat, const size_t n, std::ostream &out) { ucl_print(mat,n,out," "); } - + /// Outputs n elements of mat delimited by a space to standard out template inline void ucl_print(mat_type &mat, const size_t n) { @@ -139,8 +139,8 @@ inline void ucl_print(mat_type &mat, const size_t n) { /// Outputs upper left rows and cols of mat delimited by the string delim template inline void ucl_print(mat_type &mat, const size_t rows, const size_t cols, - std::ostream &out, const std::string delim, - const std::string row_delim) { + std::ostream &out, const std::string delim, + const std::string row_delim) { if (rows*cols>mat.numel()) { std::cerr << "Attempted to ucl_print " << rows*cols << " elements of matrix " << "that only has " << mat.numel() << " elements."; @@ -148,17 +148,17 @@ inline void ucl_print(mat_type &mat, const size_t rows, const size_t cols, } _ucl_print::p(mat,rows,cols,out,delim,row_delim); } - + /// Outputs upper left rows and cols of mat delimited by a space template inline void ucl_print(mat_type &mat, const size_t rows, const size_t cols, std::ostream &out) { ucl_print(mat,rows,cols,out," ","\n"); } - + /// Outputs upper left rows and cols of mat delimited by a space to std out template -inline void ucl_print(mat_type &mat, const size_t rows, +inline void ucl_print(mat_type &mat, const size_t rows, const size_t cols) { ucl_print(mat,rows,cols,std::cout," ","\n"); } @@ -177,7 +177,7 @@ inline void ucl_print(mat_type &mat, std::ostream &out) { else ucl_print(mat,mat.rows(),mat.cols(),out," ","\n"); } - + // ------------------------------------------------------------------------- // - Const routines that do not require a device object // ------------------------------------------------------------------------- @@ -193,14 +193,14 @@ inline void ucl_print(const mat_type &mat, const size_t n, std::ostream &out, } _ucl_print::p(mat,n,out,delim,dev); } - + /// Outputs n elements of mat delimited by a space template inline void ucl_print(const mat_type &mat, const size_t n, std::ostream &out, UCL_Device &dev) { ucl_print(mat,n,out," ",dev); } - + /// Outputs n elements of mat delimited by a space to standard out template inline void ucl_print(const mat_type &mat, const size_t n, @@ -211,7 +211,7 @@ inline void ucl_print(const mat_type &mat, const size_t n, /// Outputs upper left rows and cols of mat delimited by the string delim template inline void ucl_print(const mat_type &mat,const size_t rows,const size_t cols, - std::ostream &out, const std::string delim, + std::ostream &out, const std::string delim, const std::string row_delim, UCL_Device &dev) { if (rows*cols>mat.numel()) { std::cerr << "Attempted to ucl_print " << rows*cols << " elements of matrix " @@ -220,17 +220,17 @@ inline void ucl_print(const mat_type &mat,const size_t rows,const size_t cols, } _ucl_print::p(mat,rows,cols,out,delim,row_delim,dev); } - + /// Outputs upper left rows and cols of mat delimited by a space template inline void ucl_print(const mat_type &mat,const size_t rows,const size_t cols, std::ostream &out, UCL_Device &dev) { ucl_print(mat,rows,cols,out," ","\n",dev); } - + /// Outputs upper left rows and cols of mat delimited by a space to std out template -inline void ucl_print(const mat_type &mat, const size_t rows, +inline void ucl_print(const mat_type &mat, const size_t rows, const size_t cols, UCL_Device &dev) { ucl_print(mat,rows,cols,std::cout," ","\n",dev); } @@ -256,27 +256,27 @@ inline void ucl_print(const mat_type &mat, std::ostream &out, UCL_Device &dev) { template inline std::ostream & operator << (std::ostream &out, UCL_H_Vec &mat) - { ucl_print(mat,out); return out; } + { ucl_print(mat,out); return out; } template inline std::ostream & operator << (std::ostream &out, UCL_H_Mat &mat) - { ucl_print(mat,out); return out; } + { ucl_print(mat,out); return out; } template inline std::ostream & operator << (std::ostream &out, UCL_D_Vec &mat) - { ucl_print(mat,out); return out; } + { ucl_print(mat,out); return out; } template inline std::ostream & operator << (std::ostream &out, UCL_D_Mat &mat) - { ucl_print(mat,out); return out; } + { ucl_print(mat,out); return out; } template inline std::ostream & operator << (std::ostream &out, UCL_Vector &mat) - { ucl_print(mat.host,out); return out; } + { ucl_print(mat.host,out); return out; } template inline std::ostream & operator << (std::ostream &out, UCL_Matrix &mat) - { ucl_print(mat.host,out); return out; } + { ucl_print(mat.host,out); return out; } #endif diff --git a/lib/gpu/geryon/ucl_s_obj_help.h b/lib/gpu/geryon/ucl_s_obj_help.h index 0b8c0251c1..a10f3cdb3f 100644 --- a/lib/gpu/geryon/ucl_s_obj_help.h +++ b/lib/gpu/geryon/ucl_s_obj_help.h @@ -3,7 +3,7 @@ ------------------- W. Michael Brown - Helper routines for allocating memory for s-objects and performing + Helper routines for allocating memory for s-objects and performing host/device updates. (Different routines depending on whether the same type is used on the host and device). @@ -141,29 +141,29 @@ template <> struct _ucl_s_obj_help<1> { } template - static inline void copy(t1 &dst, t2 &src, const int cols, t3 &buffer, + static inline void copy(t1 &dst, t2 &src, const int cols, t3 &buffer, const bool async) { ucl_copy(dst,src,cols,async); } template - static inline void copy(t1 &dst, t2 &src, const int cols, t3 &buffer, + static inline void copy(t1 &dst, t2 &src, const int cols, t3 &buffer, command_queue &cq) { ucl_copy(dst,src,cols,cq); } template - static inline void copy(t1 &dst, t2 &src, const int rows, const int cols, + static inline void copy(t1 &dst, t2 &src, const int rows, const int cols, t3 &buffer, const bool async) { ucl_copy(dst,src,rows,cols,async); } template - static inline void copy(t1 &dst, t2 &src, const int rows, const int cols, + static inline void copy(t1 &dst, t2 &src, const int rows, const int cols, t3 &buffer, command_queue &cq) { ucl_copy(dst,src,rows,cols,cq); } - + template static inline int dev_resize(t1 &device, t2 &host, t3 &buff,const int cols) { if (device.kind()==UCL_VIEW) { @@ -181,7 +181,7 @@ template <> struct _ucl_s_obj_help<1> { } template - static inline int dev_resize(t1 &device, t2 &host, t3 &buff, const int rows, + static inline int dev_resize(t1 &device, t2 &host, t3 &buff, const int rows, const int cols) { if (device.kind()==UCL_VIEW) { device.view(host); @@ -255,7 +255,7 @@ template struct _ucl_s_obj_help { e1=_buffer.alloc(cols,cq,kind1); if (e1!=UCL_SUCCESS) return e1; - return device.alloc(cols,cq,kind2); + return device.alloc(cols,cq,kind2); } } @@ -314,7 +314,7 @@ template struct _ucl_s_obj_help { e1=_buffer.alloc(rows,cols,cq,kind1); if (e1!=UCL_SUCCESS) return e1; - return device.alloc(rows,cols,cq,kind2); + return device.alloc(rows,cols,cq,kind2); } } @@ -329,25 +329,25 @@ template struct _ucl_s_obj_help { } template - static inline void copy(t1 &dst, t2 &src, const int cols, t3 &buffer, + static inline void copy(t1 &dst, t2 &src, const int cols, t3 &buffer, const bool async) { ucl_cast_copy(dst,src,cols,buffer,async); } template - static inline void copy(t1 &dst, t2 &src, const int cols, t3 &buffer, + static inline void copy(t1 &dst, t2 &src, const int cols, t3 &buffer, command_queue &cq) { ucl_cast_copy(dst,src,cols,buffer,cq); } - + template - static inline void copy(t1 &dst, t2 &src, const int rows, const int cols, + static inline void copy(t1 &dst, t2 &src, const int rows, const int cols, t3 &buffer, const bool async) { ucl_cast_copy(dst,src,rows,cols,buffer,async); } template - static inline void copy(t1 &dst, t2 &src, const int rows, const int cols, + static inline void copy(t1 &dst, t2 &src, const int rows, const int cols, t3 &buffer, command_queue &cq) { ucl_cast_copy(dst,src,rows,cols,buffer,cq); } @@ -373,7 +373,7 @@ template struct _ucl_s_obj_help { } template - static inline int dev_resize(t1 &device, t2 &host, t3 &buff, const int rows, + static inline int dev_resize(t1 &device, t2 &host, t3 &buff, const int rows, const int cols) { int err=buff.resize(rows,cols); if (err!=UCL_SUCCESS) diff --git a/lib/gpu/geryon/ucl_types.h b/lib/gpu/geryon/ucl_types.h index 46be4bcb06..cb3dce8430 100644 --- a/lib/gpu/geryon/ucl_types.h +++ b/lib/gpu/geryon/ucl_types.h @@ -17,7 +17,7 @@ /* ----------------------------------------------------------------------- Copyright (2010) Sandia Corporation. Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains - certain rights in this software. This software is distributed under + certain rights in this software. This software is distributed under the Simplified BSD License. ----------------------------------------------------------------------- */ @@ -26,65 +26,65 @@ // Assign an integer id based on the data type: (int, float, double, etc) template struct _UCL_DATA_ID; -template <> struct _UCL_DATA_ID { +template <> struct _UCL_DATA_ID { enum { id=1 }; - static inline const char * name() { return "double"; } - static inline const char * numtyp_flag() { return "-D NUMTYP=double"; } + static inline const char * name() { return "double"; } + static inline const char * numtyp_flag() { return "-D NUMTYP=double"; } }; -template <> struct _UCL_DATA_ID { +template <> struct _UCL_DATA_ID { enum { id=2 }; - static inline const char * name() { return "float"; } - static inline const char * numtyp_flag() { return "-D NUMTYP=float"; } + static inline const char * name() { return "float"; } + static inline const char * numtyp_flag() { return "-D NUMTYP=float"; } }; -template <> struct _UCL_DATA_ID { +template <> struct _UCL_DATA_ID { enum { id=3 }; - static inline const char * name() { return "unsigned"; } - static inline const char * numtyp_flag() { return "-D NUMTYP=unsigned"; } + static inline const char * name() { return "unsigned"; } + static inline const char * numtyp_flag() { return "-D NUMTYP=unsigned"; } }; -template <> struct _UCL_DATA_ID { +template <> struct _UCL_DATA_ID { enum { id=4 }; - static inline const char * name() { return "int"; } - static inline const char * numtyp_flag() { return "-D NUMTYP=int"; } + static inline const char * name() { return "int"; } + static inline const char * numtyp_flag() { return "-D NUMTYP=int"; } }; -template <> struct _UCL_DATA_ID { +template <> struct _UCL_DATA_ID { enum { id=5 }; - static inline const char * name() { return "char"; } - static inline const char * numtyp_flag() { return "-D NUMTYP=char"; } + static inline const char * name() { return "char"; } + static inline const char * numtyp_flag() { return "-D NUMTYP=char"; } }; -template <> struct _UCL_DATA_ID { +template <> struct _UCL_DATA_ID { enum { id=6 }; - static inline const char * name() { return "unsigned char"; } - static inline const char * numtyp_flag() { return "-D NUMTYP=unsigned char"; } + static inline const char * name() { return "unsigned char"; } + static inline const char * numtyp_flag() { return "-D NUMTYP=unsigned char"; } }; -template <> struct _UCL_DATA_ID { +template <> struct _UCL_DATA_ID { enum { id=7 }; - static inline const char * name() { return "short"; } - static inline const char * numtyp_flag() { return "-D NUMTYP=short"; } + static inline const char * name() { return "short"; } + static inline const char * numtyp_flag() { return "-D NUMTYP=short"; } }; -template <> struct _UCL_DATA_ID { +template <> struct _UCL_DATA_ID { enum { id=8 }; - static inline const char * name() { return "unsigned short"; } - static inline const char * numtyp_flag() { return "-D NUMTYP=unsigned short"; } + static inline const char * name() { return "unsigned short"; } + static inline const char * numtyp_flag() { return "-D NUMTYP=unsigned short"; } }; -template <> struct _UCL_DATA_ID { +template <> struct _UCL_DATA_ID { enum { id=9 }; - static inline const char * name() { return "long"; } - static inline const char * numtyp_flag() { return "-D NUMTYP=long"; } + static inline const char * name() { return "long"; } + static inline const char * numtyp_flag() { return "-D NUMTYP=long"; } }; -template <> struct _UCL_DATA_ID { +template <> struct _UCL_DATA_ID { enum { id=10 }; - static inline const char * name() { return "unsigned long"; } - static inline const char * numtyp_flag() { return "-D NUMTYP=unsigned long"; } + static inline const char * name() { return "unsigned long"; } + static inline const char * numtyp_flag() { return "-D NUMTYP=unsigned long"; } }; -template <> struct _UCL_DATA_ID { +template <> struct _UCL_DATA_ID { enum { id=11 }; - static inline const char * name() { return "long double"; } - static inline const char * numtyp_flag() { return "-D NUMTYP=long double"; } + static inline const char * name() { return "long double"; } + static inline const char * numtyp_flag() { return "-D NUMTYP=long double"; } }; -template struct _UCL_DATA_ID { +template struct _UCL_DATA_ID { enum { id=0 }; - static inline const char * name() { return "error_type"; } - static inline const char * numtyp_flag() { return "-D NUMTYP=error_type"; } + static inline const char * name() { return "error_type"; } + static inline const char * numtyp_flag() { return "-D NUMTYP=error_type"; } }; // Host memory allocation types @@ -97,7 +97,7 @@ enum UCL_MEMOPT { UCL_NOT_SPECIFIED }; -enum UCL_DEVICE_TYPE { +enum UCL_DEVICE_TYPE { UCL_DEFAULT, ///< Unknown device type UCL_CPU, ///< Device is a CPU UCL_GPU, ///< Device is a GPU @@ -111,7 +111,7 @@ enum UCL_ERROR_FLAG { UCL_FUNCTION_NOT_FOUND, ///< Kernel function not found UCL_COMPILE_ERROR, ///< Error compiling kernel UCL_MEMORY_ERROR -}; +}; template const char * ucl_template_name() { return _UCL_DATA_ID::name(); } diff --git a/lib/gpu/geryon/ucl_vector.h b/lib/gpu/geryon/ucl_vector.h index 89f1528969..7fe2604de6 100644 --- a/lib/gpu/geryon/ucl_vector.h +++ b/lib/gpu/geryon/ucl_vector.h @@ -34,25 +34,25 @@ class UCL_Vector { ROW_MAJOR = 1, VECTOR = 1 }; - typedef hosttype data_type; + typedef hosttype data_type; /// Host Allocation UCL_H_Vec host; - + /// Device Allocation UCL_D_Vec device; - + UCL_Vector() { } ~UCL_Vector() { } /// Construct with n columns /** \sa alloc() **/ - UCL_Vector(const size_t cols, UCL_Device &acc, + UCL_Vector(const size_t cols, UCL_Device &acc, const enum UCL_MEMOPT kind1=UCL_READ_WRITE, const enum UCL_MEMOPT kind2=UCL_READ_WRITE) { _ucl_s_obj_help< ucl_same_type::ans >:: alloc(host,device,_buffer,cols,acc,kind1,kind2); } - + /// Set up the vector with 'cols' columns and reserve memory /** The kind1 parameter controls memory access from the host * - UCL_READ_WRITE - Specify that you will read and write from host @@ -89,12 +89,12 @@ class UCL_Vector { * \return UCL_SUCCESS if the memory allocation is successful **/ inline int alloc(const size_t cols, UCL_Device &acc, const enum UCL_MEMOPT kind1=UCL_READ_WRITE, - const enum UCL_MEMOPT kind2=UCL_READ_WRITE) + const enum UCL_MEMOPT kind2=UCL_READ_WRITE) { return _ucl_s_obj_help< ucl_same_type::ans >:: alloc(host,device,_buffer,cols,acc,kind1,kind2); } - + /// Free memory and set size to 0 - inline void clear() + inline void clear() { host.clear(); device.clear(); } /// Resize the allocation to contain cols elements @@ -106,7 +106,7 @@ class UCL_Vector { return _ucl_s_obj_help< ucl_same_type::ans >:: dev_resize(device,host,_buffer,cols); } - + /// Resize (only if bigger) the allocation to contain cols elements inline int resize_ib(const int new_cols) { if (new_cols>cols()) return resize(new_cols); else return UCL_SUCCESS; } @@ -117,14 +117,14 @@ class UCL_Vector { inline void zero(const int n) { zero(n,cq()); } /// Set each element to zero (asynchronously on device) inline void zero(command_queue &cq) { - host.zero(); + host.zero(); if (device.kind()!=UCL_VIEW) device.zero(cq); else if (_buffer.numel()>0) _buffer.zero(); } /// Set first n elements to zero (asynchronously on device) - inline void zero(const int n, command_queue &cq) { - host.zero(n); - if (device.kind()!=UCL_VIEW) device.zero(n,cq); + inline void zero(const int n, command_queue &cq) { + host.zero(n); + if (device.kind()!=UCL_VIEW) device.zero(n,cq); else if (_buffer.numel()>0) _buffer.zero(); } @@ -135,27 +135,27 @@ class UCL_Vector { /// Get the number of columns inline size_t cols() const { return host.cols(); } /// Get the memory usage (bytes) of the s-object (including any buffers) - inline size_t host_mem_usage() + inline size_t host_mem_usage() { return host.row_bytes()+_buffer.row_bytes(); } /// Get the memory usage (bytes) of the s-object (including any buffers) - inline size_t device_mem_usage() + inline size_t device_mem_usage() { return device.row_bytes(); } - - + + /// Get element at index i inline hosttype & operator[](const int i) { return host[i]; } /// Get element at index i inline const hosttype & operator[](const int i) const { return host[i]; } - /// 2D access (row should always be 0) - inline hosttype & operator()(const int row, const int col) + /// 2D access (row should always be 0) + inline hosttype & operator()(const int row, const int col) { return host[col]; } - /// 2D access (row should always be 0) + /// 2D access (row should always be 0) inline const hosttype & operator()(const int row, const int col) const { return host[col]; } - + /// Returns pointer to memory pointer for allocation on host inline hosttype ** host_ptr() { return host.host_ptr(); } - + /// Return the default command queue/stream associated with this data inline command_queue & cq() { return host.cq(); } /// Change the default command queue associated with this data @@ -172,7 +172,7 @@ class UCL_Vector { /// Update the allocation on the host asynchronously - inline void update_host() + inline void update_host() { _ucl_s_obj_help< ucl_same_type::ans >:: copy(host,device,_buffer,true); } /// Update the allocation on the host (true for asynchronous copy) @@ -202,7 +202,7 @@ class UCL_Vector { /// Update the allocation on the device asynchronously - inline void update_device() + inline void update_device() { _ucl_s_obj_help< ucl_same_type::ans >:: copy(device,host,_buffer,true); } /// Update the allocation on the device (true for asynchronous copy) diff --git a/lib/gpu/lal_beck_ext.cpp b/lib/gpu/lal_beck_ext.cpp index 1552b640e8..226c2d477b 100644 --- a/lib/gpu/lal_beck_ext.cpp +++ b/lib/gpu/lal_beck_ext.cpp @@ -103,7 +103,7 @@ int ** beck_gpu_compute_n(const int ago, const int inum_full, subhi, tag, nspecial, special, eflag, vflag, eatom, vatom, host_start, ilist, jnum, cpu_time, success); } - + void beck_gpu_compute(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, int *ilist, int *numj, int **firstneigh, const bool eflag, const bool vflag, diff --git a/lib/gpu/lal_born.cpp b/lib/gpu/lal_born.cpp index 36898b3910..7c1ed944d3 100644 --- a/lib/gpu/lal_born.cpp +++ b/lib/gpu/lal_born.cpp @@ -80,7 +80,7 @@ int BornT::init(const int ntypes, double **host_cutsq, coeff2.alloc(lj_types*lj_types,*(this->ucl_device),UCL_READ_ONLY); this->atom->type_pack4(ntypes,lj_types,coeff2,host_write,host_a,host_c, - host_d,host_offset); + host_d,host_offset); cutsq_sigma.alloc(lj_types*lj_types,*(this->ucl_device),UCL_READ_ONLY); this->atom->type_pack2(ntypes,lj_types,cutsq_sigma,host_write,host_cutsq, @@ -113,7 +113,7 @@ void BornT::reinit(const int ntypes, double **host_rhoinv, this->atom->type_pack4(ntypes,_lj_types,coeff1,host_write,host_rhoinv, host_born1,host_born2,host_born3); this->atom->type_pack4(ntypes,_lj_types,coeff2,host_write,host_a,host_c, - host_d,host_offset); + host_d,host_offset); } template diff --git a/lib/gpu/lal_born_coul_long.cpp b/lib/gpu/lal_born_coul_long.cpp index 242961e80c..68695c4938 100644 --- a/lib/gpu/lal_born_coul_long.cpp +++ b/lib/gpu/lal_born_coul_long.cpp @@ -84,7 +84,7 @@ int BornCoulLongT::init(const int ntypes, double **host_cutsq, double **host_rho coeff2.alloc(lj_types*lj_types,*(this->ucl_device),UCL_READ_ONLY); this->atom->type_pack4(ntypes,lj_types,coeff2,host_write,host_a,host_c, - host_d,host_offset); + host_d,host_offset); cutsq_sigma.alloc(lj_types*lj_types,*(this->ucl_device),UCL_READ_ONLY); this->atom->type_pack4(ntypes,lj_types,cutsq_sigma,host_write,host_cutsq, diff --git a/lib/gpu/lal_born_coul_long_ext.cpp b/lib/gpu/lal_born_coul_long_ext.cpp index 8c1ff0413f..feb7472e74 100644 --- a/lib/gpu/lal_born_coul_long_ext.cpp +++ b/lib/gpu/lal_born_coul_long_ext.cpp @@ -113,7 +113,7 @@ int** borncl_gpu_compute_n(const int ago, const int inum_full, vatom, host_start, ilist, jnum, cpu_time, success, host_q, boxlo, prd); } - + void borncl_gpu_compute(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, int *ilist, int *numj, int **firstneigh, const bool eflag, const bool vflag, diff --git a/lib/gpu/lal_born_coul_wolf.cpp b/lib/gpu/lal_born_coul_wolf.cpp index fa832206ee..7ebd7b744f 100644 --- a/lib/gpu/lal_born_coul_wolf.cpp +++ b/lib/gpu/lal_born_coul_wolf.cpp @@ -84,7 +84,7 @@ int BornCoulWolfT::init(const int ntypes, double **host_cutsq, double **host_rho coeff2.alloc(lj_types*lj_types,*(this->ucl_device),UCL_READ_ONLY); this->atom->type_pack4(ntypes,lj_types,coeff2,host_write,host_a,host_c, - host_d,host_offset); + host_d,host_offset); cutsq_sigma.alloc(lj_types*lj_types,*(this->ucl_device),UCL_READ_ONLY); this->atom->type_pack4(ntypes,lj_types,cutsq_sigma,host_write,host_cutsq, diff --git a/lib/gpu/lal_born_coul_wolf_ext.cpp b/lib/gpu/lal_born_coul_wolf_ext.cpp index 5083afe0c4..254b1c905b 100644 --- a/lib/gpu/lal_born_coul_wolf_ext.cpp +++ b/lib/gpu/lal_born_coul_wolf_ext.cpp @@ -115,7 +115,7 @@ int** borncw_gpu_compute_n(const int ago, const int inum_full, vatom, host_start, ilist, jnum, cpu_time, success, host_q, boxlo, prd); } - + void borncw_gpu_compute(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, int *ilist, int *numj, int **firstneigh, const bool eflag, const bool vflag, diff --git a/lib/gpu/lal_born_ext.cpp b/lib/gpu/lal_born_ext.cpp index 171020e769..b1ebf5804c 100644 --- a/lib/gpu/lal_born_ext.cpp +++ b/lib/gpu/lal_born_ext.cpp @@ -133,7 +133,7 @@ int ** born_gpu_compute_n(const int ago, const int inum_full, subhi, tag, nspecial, special, eflag, vflag, eatom, vatom, host_start, ilist, jnum, cpu_time, success); } - + void born_gpu_compute(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, int *ilist, int *numj, int **firstneigh, const bool eflag, const bool vflag, diff --git a/lib/gpu/lal_buck.cpp b/lib/gpu/lal_buck.cpp index aa82f0014d..0da4068d51 100644 --- a/lib/gpu/lal_buck.cpp +++ b/lib/gpu/lal_buck.cpp @@ -79,7 +79,7 @@ int BuckT::init(const int ntypes, double **host_cutsq, coeff2.alloc(lj_types*lj_types,*(this->ucl_device),UCL_READ_ONLY); this->atom->type_pack4(ntypes,lj_types,coeff2,host_write,host_a,host_c, - host_offset); + host_offset); UCL_H_Vec dview; sp_lj.alloc(4,*(this->ucl_device),UCL_READ_ONLY); diff --git a/lib/gpu/lal_buck_coul.cpp b/lib/gpu/lal_buck_coul.cpp index 9de019d871..e4f829fc5c 100644 --- a/lib/gpu/lal_buck_coul.cpp +++ b/lib/gpu/lal_buck_coul.cpp @@ -81,7 +81,7 @@ int BuckCoulT::init(const int ntypes, double **host_cutsq, coeff2.alloc(lj_types*lj_types,*(this->ucl_device),UCL_READ_ONLY); this->atom->type_pack4(ntypes,lj_types,coeff2,host_write,host_a,host_c, - host_offset); + host_offset); cutsq.alloc(lj_types*lj_types,*(this->ucl_device),UCL_READ_ONLY); this->atom->type_pack4(ntypes,lj_types,cutsq,host_write,host_cutsq, diff --git a/lib/gpu/lal_buck_coul_ext.cpp b/lib/gpu/lal_buck_coul_ext.cpp index 3335f4ba47..e5a5e1315b 100644 --- a/lib/gpu/lal_buck_coul_ext.cpp +++ b/lib/gpu/lal_buck_coul_ext.cpp @@ -112,7 +112,7 @@ int ** buckc_gpu_compute_n(const int ago, const int inum_full, vatom, host_start, ilist, jnum, cpu_time, success, host_q, boxlo, prd); } - + void buckc_gpu_compute(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, int *ilist, int *numj, int **firstneigh, const bool eflag, const bool vflag, diff --git a/lib/gpu/lal_buck_coul_long.cpp b/lib/gpu/lal_buck_coul_long.cpp index bf9b5fb101..81faada116 100644 --- a/lib/gpu/lal_buck_coul_long.cpp +++ b/lib/gpu/lal_buck_coul_long.cpp @@ -83,7 +83,7 @@ int BuckCoulLongT::init(const int ntypes, double **host_cutsq, coeff2.alloc(lj_types*lj_types,*(this->ucl_device),UCL_READ_ONLY); this->atom->type_pack4(ntypes,lj_types,coeff2,host_write,host_a,host_c, - host_offset); + host_offset); cutsq.alloc(lj_types*lj_types,*(this->ucl_device),UCL_READ_ONLY); this->atom->type_pack1(ntypes,lj_types,cutsq,host_write,host_cutsq); diff --git a/lib/gpu/lal_buck_coul_long_ext.cpp b/lib/gpu/lal_buck_coul_long_ext.cpp index 51e0d233d3..28a89746b3 100644 --- a/lib/gpu/lal_buck_coul_long_ext.cpp +++ b/lib/gpu/lal_buck_coul_long_ext.cpp @@ -111,7 +111,7 @@ int** buckcl_gpu_compute_n(const int ago, const int inum_full, vatom, host_start, ilist, jnum, cpu_time, success, host_q, boxlo, prd); } - + void buckcl_gpu_compute(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, int *ilist, int *numj, int **firstneigh, const bool eflag, const bool vflag, diff --git a/lib/gpu/lal_buck_ext.cpp b/lib/gpu/lal_buck_ext.cpp index 36a780426c..336aab6d4c 100644 --- a/lib/gpu/lal_buck_ext.cpp +++ b/lib/gpu/lal_buck_ext.cpp @@ -129,7 +129,7 @@ int ** buck_gpu_compute_n(const int ago, const int inum_full, subhi, tag, nspecial, special, eflag, vflag, eatom, vatom, host_start, ilist, jnum, cpu_time, success); } - + void buck_gpu_compute(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, int *ilist, int *numj, int **firstneigh, const bool eflag, const bool vflag, diff --git a/lib/gpu/lal_cg_cmm.cpp b/lib/gpu/lal_cg_cmm.cpp index 11974e05e0..d361e32b09 100644 --- a/lib/gpu/lal_cg_cmm.cpp +++ b/lib/gpu/lal_cg_cmm.cpp @@ -80,7 +80,7 @@ int CGCMMT::init(const int ntypes, double **host_cutsq, lj3.alloc(cmm_types*cmm_types,*(this->ucl_device),UCL_READ_ONLY); this->atom->type_pack4(ntypes,cmm_types,lj3,host_write,host_lj3,host_lj4, - host_offset); + host_offset); UCL_H_Vec dview; sp_lj.alloc(4,*(this->ucl_device),UCL_READ_ONLY); diff --git a/lib/gpu/lal_cg_cmm_ext.cpp b/lib/gpu/lal_cg_cmm_ext.cpp index 2a00271736..b6fc110b15 100644 --- a/lib/gpu/lal_cg_cmm_ext.cpp +++ b/lib/gpu/lal_cg_cmm_ext.cpp @@ -104,7 +104,7 @@ int** cmm_gpu_compute_n(const int ago, const int inum_full, subhi, tag, nspecial, special, eflag, vflag, eatom, vatom, host_start, ilist, jnum, cpu_time, success); } - + void cmm_gpu_compute(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, int *ilist, int *numj, int **firstneigh, const bool eflag, const bool vflag, diff --git a/lib/gpu/lal_cg_cmm_long_ext.cpp b/lib/gpu/lal_cg_cmm_long_ext.cpp index 2fa3f2aead..ee0a0269e5 100644 --- a/lib/gpu/lal_cg_cmm_long_ext.cpp +++ b/lib/gpu/lal_cg_cmm_long_ext.cpp @@ -110,7 +110,7 @@ int** cmml_gpu_compute_n(const int ago, const int inum_full, vatom, host_start, ilist, jnum, cpu_time, success, host_q,boxlo,prd); } - + void cmml_gpu_compute(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, int *ilist, int *numj, int **firstneigh, const bool eflag, const bool vflag, diff --git a/lib/gpu/lal_charmm_long_ext.cpp b/lib/gpu/lal_charmm_long_ext.cpp index 3f7445f306..e24c650be4 100644 --- a/lib/gpu/lal_charmm_long_ext.cpp +++ b/lib/gpu/lal_charmm_long_ext.cpp @@ -115,11 +115,11 @@ int** crml_gpu_compute_n(const int ago, const int inum_full, vatom, host_start, ilist, jnum, cpu_time, success, host_q, boxlo, prd); } - + void crml_gpu_compute(const int ago, const int inum_full, - const int nall, double **host_x, int *host_type, + const int nall, double **host_x, int *host_type, int *ilist, int *numj, int **firstneigh, - const bool eflag, const bool vflag, const bool eatom, + const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, const double cpu_time, bool &success, double *host_q, const int nlocal, double *boxlo, double *prd) { diff --git a/lib/gpu/lal_colloid.cu b/lib/gpu/lal_colloid.cu index 89ba71deef..28a9809b19 100644 --- a/lib/gpu/lal_colloid.cu +++ b/lib/gpu/lal_colloid.cu @@ -132,7 +132,7 @@ __kernel void k_colloid(const __global numtyp4 *restrict x_, g[1] *= (numtyp)42.0*K[0]/K[4]+(numtyp)6.0*K[1]+K[4]; g[2] *= (numtyp)-42.0*K[0]/K[5]+(numtyp)6.0*K[2]+K[5]; g[3] *= (numtyp)-42.0*K[0]/K[6]+(numtyp)6.0*K[2]+K[6]; - + fR = colloid1[mtype].x*colloid2[mtype].w/r/(numtyp)37800.0; evdwl = fR * (h[0]-h[1]-h[2]+h[3]); numtyp dUR = evdwl/r + (numtyp)5.0*fR*(g[0]+g[1]-g[2]-g[3]); @@ -296,7 +296,7 @@ __kernel void k_colloid_fast(const __global numtyp4 *restrict x_, g[1] *= (numtyp)42.0*K[0]/K[4]+(numtyp)6.0*K[1]+K[4]; g[2] *= (numtyp)-42.0*K[0]/K[5]+(numtyp)6.0*K[2]+K[5]; g[3] *= (numtyp)-42.0*K[0]/K[6]+(numtyp)6.0*K[2]+K[6]; - + fR = colloid1[mtype].x*colloid2[mtype].w/r/(numtyp)37800.0; evdwl = fR * (h[0]-h[1]-h[2]+h[3]); numtyp dUR = evdwl/r + (numtyp)5.0*fR*(g[0]+g[1]-g[2]-g[3]); diff --git a/lib/gpu/lal_colloid_ext.cpp b/lib/gpu/lal_colloid_ext.cpp index f88ced8443..8e1b18e72f 100644 --- a/lib/gpu/lal_colloid_ext.cpp +++ b/lib/gpu/lal_colloid_ext.cpp @@ -110,7 +110,7 @@ int ** colloid_gpu_compute_n(const int ago, const int inum_full, subhi, tag, nspecial, special, eflag, vflag, eatom, vatom, host_start, ilist, jnum, cpu_time, success); } - + void colloid_gpu_compute(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, int *ilist, int *numj, int **firstneigh, const bool eflag, const bool vflag, diff --git a/lib/gpu/lal_coul_debye_ext.cpp b/lib/gpu/lal_coul_debye_ext.cpp index f205cd6adf..af9156c24c 100644 --- a/lib/gpu/lal_coul_debye_ext.cpp +++ b/lib/gpu/lal_coul_debye_ext.cpp @@ -124,7 +124,7 @@ int** cdebye_gpu_compute_n(const int ago, const int inum_full, vatom, host_start, ilist, jnum, cpu_time, success, host_q, boxlo, prd); } - + void cdebye_gpu_compute(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, int *ilist, int *numj, int **firstneigh, const bool eflag, const bool vflag, diff --git a/lib/gpu/lal_coul_dsf_ext.cpp b/lib/gpu/lal_coul_dsf_ext.cpp index 174ec0d839..026dd924c9 100644 --- a/lib/gpu/lal_coul_dsf_ext.cpp +++ b/lib/gpu/lal_coul_dsf_ext.cpp @@ -106,7 +106,7 @@ int** cdsf_gpu_compute_n(const int ago, const int inum_full, vatom, host_start, ilist, jnum, cpu_time, success, host_q, boxlo, prd); } - + void cdsf_gpu_compute(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, int *ilist, int *numj, int **firstneigh, const bool eflag, const bool vflag, diff --git a/lib/gpu/lal_coul_ext.cpp b/lib/gpu/lal_coul_ext.cpp index c124622cee..f03d8fcdfc 100644 --- a/lib/gpu/lal_coul_ext.cpp +++ b/lib/gpu/lal_coul_ext.cpp @@ -124,7 +124,7 @@ int** coul_gpu_compute_n(const int ago, const int inum_full, vatom, host_start, ilist, jnum, cpu_time, success, host_q, boxlo, prd); } - + void coul_gpu_compute(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, int *ilist, int *numj, int **firstneigh, const bool eflag, const bool vflag, diff --git a/lib/gpu/lal_coul_long.cpp b/lib/gpu/lal_coul_long.cpp index 513e6d074d..b4c6a44d2f 100644 --- a/lib/gpu/lal_coul_long.cpp +++ b/lib/gpu/lal_coul_long.cpp @@ -51,7 +51,7 @@ int CoulLongT::init(const int ntypes, double **host_scale, const double qqrd2e, const double g_ewald) { int success; success=this->init_atomic(nlocal,nall,max_nbors,maxspecial,cell_size, - gpu_split,_screen,coul_long,"k_coul_long"); + gpu_split,_screen,coul_long,"k_coul_long"); if (success!=0) return success; diff --git a/lib/gpu/lal_coul_long.h b/lib/gpu/lal_coul_long.h index 6ed9c1a018..d12198fccc 100644 --- a/lib/gpu/lal_coul_long.h +++ b/lib/gpu/lal_coul_long.h @@ -40,9 +40,9 @@ class CoulLong : public BaseCharge { int init(const int ntypes, double **scale, const int nlocal, const int nall, const int max_nbors, const int maxspecial, const double cell_size, - const double gpu_split, FILE *screen, - const double host_cut_coulsq, double *host_special_coul, - const double qqrd2e, const double g_ewald); + const double gpu_split, FILE *screen, + const double host_cut_coulsq, double *host_special_coul, + const double qqrd2e, const double g_ewald); /// Send updated coeffs from host to device (to be compatible with fix adapt) void reinit(const int ntypes, double **scale); diff --git a/lib/gpu/lal_coul_long_ext.cpp b/lib/gpu/lal_coul_long_ext.cpp index 2bc2af082e..06c102b2d1 100644 --- a/lib/gpu/lal_coul_long_ext.cpp +++ b/lib/gpu/lal_coul_long_ext.cpp @@ -114,28 +114,28 @@ void cl_gpu_clear() { } int** cl_gpu_compute_n(const int ago, const int inum_full, - const int nall, double **host_x, int *host_type, - double *sublo, double *subhi, tagint *tag, int **nspecial, - tagint **special, const bool eflag, const bool vflag, - const bool eatom, const bool vatom, int &host_start, - int **ilist, int **jnum, const double cpu_time, - bool &success, double *host_q, double *boxlo, - double *prd) { + const int nall, double **host_x, int *host_type, + double *sublo, double *subhi, tagint *tag, int **nspecial, + tagint **special, const bool eflag, const bool vflag, + const bool eatom, const bool vatom, int &host_start, + int **ilist, int **jnum, const double cpu_time, + bool &success, double *host_q, double *boxlo, + double *prd) { return CLMF.compute(ago, inum_full, nall, host_x, host_type, sublo, - subhi, tag, nspecial, special, eflag, vflag, eatom, - vatom, host_start, ilist, jnum, cpu_time, success, - host_q, boxlo, prd); + subhi, tag, nspecial, special, eflag, vflag, eatom, + vatom, host_start, ilist, jnum, cpu_time, success, + host_q, boxlo, prd); } void cl_gpu_compute(const int ago, const int inum_full, const int nall, - double **host_x, int *host_type, int *ilist, int *numj, - int **firstneigh, const bool eflag, const bool vflag, - const bool eatom, const bool vatom, int &host_start, - const double cpu_time, bool &success, double *host_q, - const int nlocal, double *boxlo, double *prd) { + double **host_x, int *host_type, int *ilist, int *numj, + int **firstneigh, const bool eflag, const bool vflag, + const bool eatom, const bool vatom, int &host_start, + const double cpu_time, bool &success, double *host_q, + const int nlocal, double *boxlo, double *prd) { CLMF.compute(ago,inum_full,nall,host_x,host_type,ilist,numj, - firstneigh,eflag,vflag,eatom,vatom,host_start,cpu_time,success, - host_q,nlocal,boxlo,prd); + firstneigh,eflag,vflag,eatom,vatom,host_start,cpu_time,success, + host_q,nlocal,boxlo,prd); } double cl_gpu_bytes() { diff --git a/lib/gpu/lal_device.cpp b/lib/gpu/lal_device.cpp index 1943de64c6..e95f2b30ef 100644 --- a/lib/gpu/lal_device.cpp +++ b/lib/gpu/lal_device.cpp @@ -650,8 +650,8 @@ int DeviceT::compile_kernels() { int flag=0; if (_compiled) - return flag; - + return flag; + dev_program=new UCL_Program(*gpu); int success=dev_program->load_string(device,compile_string().c_str()); if (success!=UCL_SUCCESS) diff --git a/lib/gpu/lal_dipole_lj.cu b/lib/gpu/lal_dipole_lj.cu index 42c2bde144..745bdb7f27 100644 --- a/lib/gpu/lal_dipole_lj.cu +++ b/lib/gpu/lal_dipole_lj.cu @@ -238,7 +238,7 @@ __kernel void k_dipole_lj(const __global numtyp4 *restrict x_, if (mui.w > (numtyp)0.0 && muj.w > (numtyp)0.0) { r3inv = r2inv*rinv; r5inv = r3inv*r2inv; - r7inv = r5inv*r2inv; + r7inv = r5inv*r2inv; pdotp = mui.x*muj.x + mui.y*muj.y + mui.z*muj.z; pidotr = mui.x*delx + mui.y*dely + mui.z*delz; pjdotr = muj.x*delx + muj.y*dely + muj.z*delz; @@ -251,7 +251,7 @@ __kernel void k_dipole_lj(const __global numtyp4 *restrict x_, forcecoul.x += pre1*delx + pre2*mui.x + pre3*muj.x; forcecoul.y += pre1*dely + pre2*mui.y + pre3*muj.y; forcecoul.z += pre1*delz + pre2*mui.z + pre3*muj.z; - + numtyp crossx = pre4 * (mui.y*muj.z - mui.z*muj.y); numtyp crossy = pre4 * (mui.z*muj.x - mui.x*muj.z); numtyp crossz = pre4 * (mui.x*muj.y - mui.y*muj.x); @@ -463,7 +463,7 @@ __kernel void k_dipole_lj_fast(const __global numtyp4 *restrict x_, forcecoul.x += pre1*delx + pre2*mui.x + pre3*muj.x; forcecoul.y += pre1*dely + pre2*mui.y + pre3*muj.y; forcecoul.z += pre1*delz + pre2*mui.z + pre3*muj.z; - + numtyp crossx = pre4 * (mui.y*muj.z - mui.z*muj.y); numtyp crossy = pre4 * (mui.z*muj.x - mui.x*muj.z); numtyp crossz = pre4 * (mui.x*muj.y - mui.y*muj.x); diff --git a/lib/gpu/lal_dipole_lj_ext.cpp b/lib/gpu/lal_dipole_lj_ext.cpp index 2591d3c0ed..76722a20b4 100644 --- a/lib/gpu/lal_dipole_lj_ext.cpp +++ b/lib/gpu/lal_dipole_lj_ext.cpp @@ -109,7 +109,7 @@ int** dpl_gpu_compute_n(const int ago, const int inum_full, vatom, host_start, ilist, jnum, cpu_time, success, host_q, host_mu, boxlo, prd); } - + void dpl_gpu_compute(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, int *ilist, int *numj, int **firstneigh, const bool eflag, const bool vflag, diff --git a/lib/gpu/lal_dipole_lj_sf.cu b/lib/gpu/lal_dipole_lj_sf.cu index 5769c3a1a1..9847e84823 100644 --- a/lib/gpu/lal_dipole_lj_sf.cu +++ b/lib/gpu/lal_dipole_lj_sf.cu @@ -249,7 +249,7 @@ __kernel void k_dipole_lj_sf(const __global numtyp4 *restrict x_, if (mui.w > (numtyp)0.0 && muj.w > (numtyp)0.0) { r3inv = r2inv*rinv; r5inv = r3inv*r2inv; - + pdotp = mui.x*muj.x + mui.y*muj.y + mui.z*muj.z; pidotr = mui.x*delx + mui.y*dely + mui.z*delz; pjdotr = muj.x*delx + muj.y*dely + muj.z*delz; @@ -259,7 +259,7 @@ __kernel void k_dipole_lj_sf(const __global numtyp4 *restrict x_, aforcecoul.x = pre1*delx; aforcecoul.y = pre1*dely; aforcecoul.z = pre1*delz; - + bfac = (numtyp)1.0-(numtyp)4.0*rsq*ucl_sqrt(rsq)*rcutcoul2inv*ucl_sqrt(rcutcoul2inv)+ (numtyp)3.0*rsq*rsq*rcutcoul2inv*rcutcoul2inv; presf = (numtyp)2.0*r2inv*pidotr*pjdotr; @@ -493,7 +493,7 @@ __kernel void k_dipole_lj_sf_fast(const __global numtyp4 *restrict x_, if (mui.w > (numtyp)0.0 && muj.w > (numtyp)0.0) { r3inv = r2inv*rinv; r5inv = r3inv*r2inv; - + pdotp = mui.x*muj.x + mui.y*muj.y + mui.z*muj.z; pidotr = mui.x*delx + mui.y*dely + mui.z*delz; pjdotr = muj.x*delx + muj.y*dely + muj.z*delz; @@ -503,14 +503,14 @@ __kernel void k_dipole_lj_sf_fast(const __global numtyp4 *restrict x_, aforcecoul.x = pre1*delx; aforcecoul.y = pre1*dely; aforcecoul.z = pre1*delz; - + bfac = (numtyp)1.0-(numtyp)4.0*rsq*ucl_sqrt(rsq)*rcutcoul2inv*ucl_sqrt(rcutcoul2inv)+ (numtyp)3.0*rsq*rsq*rcutcoul2inv*rcutcoul2inv; presf = (numtyp)2.0*r2inv*pidotr*pjdotr; bforcecoul.x = bfac * (pjdotr*mui.x+pidotr*muj.x-presf*delx); bforcecoul.y = bfac * (pjdotr*mui.y+pidotr*muj.y-presf*dely); bforcecoul.z = bfac * (pjdotr*mui.z+pidotr*muj.z-presf*delz); - + forcecoul.x += (numtyp)3.0*r5inv*(aforcecoul.x + bforcecoul.x); forcecoul.y += (numtyp)3.0*r5inv*(aforcecoul.y + bforcecoul.y); forcecoul.z += (numtyp)3.0*r5inv*(aforcecoul.z + bforcecoul.z); diff --git a/lib/gpu/lal_dipole_lj_sf_ext.cpp b/lib/gpu/lal_dipole_lj_sf_ext.cpp index 840afbe1c2..68b935ff38 100644 --- a/lib/gpu/lal_dipole_lj_sf_ext.cpp +++ b/lib/gpu/lal_dipole_lj_sf_ext.cpp @@ -109,7 +109,7 @@ int** dplsf_gpu_compute_n(const int ago, const int inum_full, vatom, host_start, ilist, jnum, cpu_time, success, host_q, host_mu, boxlo, prd); } - + void dplsf_gpu_compute(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, int *ilist, int *numj, int **firstneigh, const bool eflag, const bool vflag, diff --git a/lib/gpu/lal_dpd.cpp b/lib/gpu/lal_dpd.cpp index f05707ef1d..4f6f2d641f 100644 --- a/lib/gpu/lal_dpd.cpp +++ b/lib/gpu/lal_dpd.cpp @@ -76,7 +76,7 @@ int DPDT::init(const int ntypes, coeff.alloc(lj_types*lj_types,*(this->ucl_device),UCL_READ_ONLY); this->atom->type_pack4(ntypes,lj_types,coeff,host_write,host_a0,host_gamma, - host_sigma,host_cut); + host_sigma,host_cut); UCL_H_Vec host_rsq(lj_types*lj_types,*(this->ucl_device), UCL_WRITE_ONLY); @@ -164,7 +164,7 @@ void DPDT::update_coeff(int ntypes, double **host_a0, double **host_gamma, UCL_H_Vec host_write(_lj_types*_lj_types*32,*(this->ucl_device), UCL_WRITE_ONLY); this->atom->type_pack4(ntypes,_lj_types,coeff,host_write,host_a0,host_gamma, - host_sigma,host_cut); + host_sigma,host_cut); } template class DPD; diff --git a/lib/gpu/lal_dpd_ext.cpp b/lib/gpu/lal_dpd_ext.cpp index 792f638cd8..26bbb660b8 100644 --- a/lib/gpu/lal_dpd_ext.cpp +++ b/lib/gpu/lal_dpd_ext.cpp @@ -106,7 +106,7 @@ int ** dpd_gpu_compute_n(const int ago, const int inum_full, const int nall, vatom, host_start, ilist, jnum, cpu_time, success, host_v, dtinvsqrt, seed, timestep, boxlo, prd); } - + void dpd_gpu_compute(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, int *ilist, int *numj, int **firstneigh, const bool eflag, const bool vflag, diff --git a/lib/gpu/lal_ellipsoid_extra.h b/lib/gpu/lal_ellipsoid_extra.h index 51f785b905..71668f5e02 100644 --- a/lib/gpu/lal_ellipsoid_extra.h +++ b/lib/gpu/lal_ellipsoid_extra.h @@ -463,7 +463,7 @@ ucl_inline void gpu_quat_to_mat_trans(__global const numtyp4 *qif, const int qi, mat[1] = twoij+twokw; mat[4] = w2-i2+j2-k2; mat[7] = twojk-twoiw; - + mat[2] = twoik-twojw; mat[5] = twojk+twoiw; mat[8] = w2-i2-j2+k2; diff --git a/lib/gpu/lal_gauss.cpp b/lib/gpu/lal_gauss.cpp index ef1559c5b6..1ef215d7ff 100644 --- a/lib/gpu/lal_gauss.cpp +++ b/lib/gpu/lal_gauss.cpp @@ -75,7 +75,7 @@ int GaussT::init(const int ntypes, gauss1.alloc(lj_types*lj_types,*(this->ucl_device),UCL_READ_ONLY); this->atom->type_pack4(ntypes,lj_types,gauss1,host_write,host_a,host_b, - host_cutsq,host_offset); + host_cutsq,host_offset); UCL_H_Vec dview; sp_lj.alloc(4,*(this->ucl_device),UCL_READ_ONLY); @@ -99,7 +99,7 @@ void GaussT::reinit(const int ntypes, double **host_cutsq, double **host_a, host_write[i]=0.0; this->atom->type_pack4(ntypes,_lj_types,gauss1,host_write,host_a,host_b, - host_cutsq,host_offset); + host_cutsq,host_offset); } template diff --git a/lib/gpu/lal_gauss_ext.cpp b/lib/gpu/lal_gauss_ext.cpp index 834c03cf64..7fa4b68870 100644 --- a/lib/gpu/lal_gauss_ext.cpp +++ b/lib/gpu/lal_gauss_ext.cpp @@ -125,7 +125,7 @@ int ** gauss_gpu_compute_n(const int ago, const int inum_full, subhi, tag, nspecial, special, eflag, vflag, eatom, vatom, host_start, ilist, jnum, cpu_time, success); } - + void gauss_gpu_compute(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, int *ilist, int *numj, int **firstneigh, const bool eflag, const bool vflag, diff --git a/lib/gpu/lal_gayberne.cpp b/lib/gpu/lal_gayberne.cpp index 5abef659b6..ba15af672e 100644 --- a/lib/gpu/lal_gayberne.cpp +++ b/lib/gpu/lal_gayberne.cpp @@ -84,19 +84,19 @@ int GayBerneT::init(const int ntypes, const double gamma, sigma_epsilon.alloc(lj_types*lj_types,*(this->ucl_device),UCL_READ_ONLY); this->atom->type_pack2(ntypes,lj_types,sigma_epsilon,host_write, - host_sigma,host_epsilon); + host_sigma,host_epsilon); this->cut_form.alloc(lj_types*lj_types,*(this->ucl_device),UCL_READ_ONLY); this->atom->type_pack2(ntypes,lj_types,this->cut_form,host_write, - host_cutsq,h_form); + host_cutsq,h_form); lj1.alloc(lj_types*lj_types,*(this->ucl_device),UCL_READ_ONLY); this->atom->type_pack4(ntypes,lj_types,lj1,host_write,host_lj1,host_lj2, - host_cutsq,h_form); + host_cutsq,h_form); lj3.alloc(lj_types*lj_types,*(this->ucl_device),UCL_READ_ONLY); this->atom->type_pack4(ntypes,lj_types,lj3,host_write,host_lj3,host_lj4, - host_offset); + host_offset); dev_error.alloc(1,*(this->ucl_device),UCL_WRITE_ONLY); dev_error.zero(); @@ -209,7 +209,7 @@ void GayBerneT::loop(const bool _eflag, const bool _vflag) { (BX/this->_threads_per_atom))); NGX=static_cast(ceil(static_cast(this->_last_ellipse)/BX)); this->pack_nbors(NGX,BX, 0, this->_last_ellipse,ELLIPSE_SPHERE, - ELLIPSE_ELLIPSE,_shared_types,_lj_types); + ELLIPSE_ELLIPSE,_shared_types,_lj_types); this->time_nbor1.stop(); this->time_ellipsoid.start(); @@ -242,7 +242,7 @@ void GayBerneT::loop(const bool _eflag, const bool _vflag) { NGX=static_cast(ceil(static_cast(this->ans->inum()- this->_last_ellipse)/BX)); this->pack_nbors(NGX,BX,this->_last_ellipse,this->ans->inum(), - SPHERE_ELLIPSE,SPHERE_ELLIPSE,_shared_types,_lj_types); + SPHERE_ELLIPSE,SPHERE_ELLIPSE,_shared_types,_lj_types); this->time_nbor2.stop(); this->time_ellipsoid2.start(); @@ -300,7 +300,7 @@ void GayBerneT::loop(const bool _eflag, const bool _vflag) { NGX=static_cast(ceil(static_cast(this->ans->inum())/BX)); this->time_nbor1.start(); this->pack_nbors(NGX, BX, 0, this->ans->inum(),SPHERE_SPHERE, - ELLIPSE_ELLIPSE,_shared_types,_lj_types); + ELLIPSE_ELLIPSE,_shared_types,_lj_types); this->time_nbor1.stop(); this->time_ellipsoid.start(); this->k_ellipsoid.set_size(GX,BX); diff --git a/lib/gpu/lal_gayberne.cu b/lib/gpu/lal_gayberne.cu index 71f29c2742..dc6e00ec82 100644 --- a/lib/gpu/lal_gayberne.cu +++ b/lib/gpu/lal_gayberne.cu @@ -26,58 +26,58 @@ ucl_inline void compute_eta_torque(numtyp m[9],numtyp m2[9], const numtyp4 shape den = ucl_recip(den); ans[0] = shape.x*(m[5]*m[1]*m2[2]+(numtyp)2.0*m[4]*m[8]*m2[0]- - m[4]*m2[2]*m[2]-(numtyp)2.0*m[5]*m2[0]*m[7]+ - m2[1]*m[2]*m[7]-m2[1]*m[1]*m[8]- - m[3]*m[8]*m2[1]+m[6]*m[5]*m2[1]+ - m[3]*m2[2]*m[7]-m2[2]*m[6]*m[4])*den; + m[4]*m2[2]*m[2]-(numtyp)2.0*m[5]*m2[0]*m[7]+ + m2[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+m[7]*m[3]*m2[8])*den; + (numtyp)2.0*m[4]*m2[6]*m[8]-m[1]*m2[7]*m[8]+ + m[2]*m[7]*m2[7]-(numtyp)2.0*m2[6]*m[7]*m[5]- + m[3]*m2[7]*m[8]+m[5]*m[6]*m2[7]- + m[4]*m[6]*m2[8]+m[7]*m[3]*m2[8])*den; ans[7] = shape.z*-(m[1]*m[8]*m2[6]-m[2]*m2[6]*m[7]- - (numtyp)2.0*m2[7]*m[0]*m[8]+m[5]*m2[8]*m[0]+ - (numtyp)2.0*m2[7]*m[2]*m[6]+m[3]*m2[6]*m[8]- - m[3]*m[2]*m2[8]-m[5]*m[6]*m2[6]+ - m[0]*m2[8]*m[7]-m2[8]*m[1]*m[6])*den; + (numtyp)2.0*m2[7]*m[0]*m[8]+m[5]*m2[8]*m[0]+ + (numtyp)2.0*m2[7]*m[2]*m[6]+m[3]*m2[6]*m[8]- + m[3]*m[2]*m2[8]-m[5]*m[6]*m2[6]+ + m[0]*m2[8]*m[7]-m2[8]*m[1]*m[6])*den; ans[8] = shape.z*(m[1]*m[5]*m2[6]-m[2]*m2[6]*m[4]- - m[0]*m[5]*m2[7]+m[3]*m[2]*m2[7]- - m[4]*m[6]*m2[6]-m[7]*m2[7]*m[0]+ - (numtyp)2.0*m[4]*m2[8]*m[0]+m[7]*m[3]*m2[6]+ - m[6]*m[1]*m2[7]-(numtyp)2.0*m2[8]*m[3]*m[1])*den; + m[0]*m[5]*m2[7]+m[3]*m[2]*m2[7]- + m[4]*m[6]*m2[6]-m[7]*m2[7]*m[0]+ + (numtyp)2.0*m[4]*m2[8]*m[0]+m[7]*m[3]*m2[6]+ + m[6]*m[1]*m2[7]-(numtyp)2.0*m2[8]*m[3]*m[1])*den; } __kernel void k_gayberne(const __global numtyp4 *restrict x_, diff --git a/lib/gpu/lal_lj.cpp b/lib/gpu/lal_lj.cpp index 2190e40516..978b33e5d7 100644 --- a/lib/gpu/lal_lj.cpp +++ b/lib/gpu/lal_lj.cpp @@ -76,11 +76,11 @@ int LJT::init(const int ntypes, lj1.alloc(lj_types*lj_types,*(this->ucl_device),UCL_READ_ONLY); this->atom->type_pack4(ntypes,lj_types,lj1,host_write,host_lj1,host_lj2, - host_cutsq); + host_cutsq); lj3.alloc(lj_types*lj_types,*(this->ucl_device),UCL_READ_ONLY); this->atom->type_pack4(ntypes,lj_types,lj3,host_write,host_lj3,host_lj4, - host_offset); + host_offset); UCL_H_Vec dview; sp_lj.alloc(4,*(this->ucl_device),UCL_READ_ONLY); diff --git a/lib/gpu/lal_lj96.cpp b/lib/gpu/lal_lj96.cpp index b59495c41a..191f211ae4 100644 --- a/lib/gpu/lal_lj96.cpp +++ b/lib/gpu/lal_lj96.cpp @@ -76,11 +76,11 @@ int LJ96T::init(const int ntypes, lj1.alloc(lj_types*lj_types,*(this->ucl_device),UCL_READ_ONLY); this->atom->type_pack4(ntypes,lj_types,lj1,host_write,host_lj1,host_lj2, - host_cutsq); + host_cutsq); lj3.alloc(lj_types*lj_types,*(this->ucl_device),UCL_READ_ONLY); this->atom->type_pack4(ntypes,lj_types,lj3,host_write,host_lj3,host_lj4, - host_offset); + host_offset); UCL_H_Vec dview; sp_lj.alloc(4,*(this->ucl_device),UCL_READ_ONLY); diff --git a/lib/gpu/lal_lj96_ext.cpp b/lib/gpu/lal_lj96_ext.cpp index c7ec9f4448..5c4a58c5e8 100644 --- a/lib/gpu/lal_lj96_ext.cpp +++ b/lib/gpu/lal_lj96_ext.cpp @@ -103,7 +103,7 @@ int** lj96_gpu_compute_n(const int ago, const int inum_full, subhi, tag, nspecial, special, eflag, vflag, eatom, vatom, host_start, ilist, jnum, cpu_time, success); } - + void lj96_gpu_compute(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, int *ilist, int *numj, int **firstneigh, const bool eflag, const bool vflag, diff --git a/lib/gpu/lal_lj_class2_long.cpp b/lib/gpu/lal_lj_class2_long.cpp index 0109446b95..497e5989ad 100644 --- a/lib/gpu/lal_lj_class2_long.cpp +++ b/lib/gpu/lal_lj_class2_long.cpp @@ -80,11 +80,11 @@ int LJClass2LongT::init(const int ntypes, double **host_cutsq, lj1.alloc(lj_types*lj_types,*(this->ucl_device),UCL_READ_ONLY); this->atom->type_pack4(ntypes,lj_types,lj1,host_write,host_lj1,host_lj2, - host_cutsq, host_cut_ljsq); + host_cutsq, host_cut_ljsq); lj3.alloc(lj_types*lj_types,*(this->ucl_device),UCL_READ_ONLY); this->atom->type_pack4(ntypes,lj_types,lj3,host_write,host_lj3,host_lj4, - host_offset); + host_offset); sp_lj.alloc(8,*(this->ucl_device),UCL_READ_ONLY); for (int i=0; i<4; i++) { diff --git a/lib/gpu/lal_lj_class2_long_ext.cpp b/lib/gpu/lal_lj_class2_long_ext.cpp index fa3e95f1f2..6ed15126d9 100644 --- a/lib/gpu/lal_lj_class2_long_ext.cpp +++ b/lib/gpu/lal_lj_class2_long_ext.cpp @@ -110,7 +110,7 @@ int** c2cl_gpu_compute_n(const int ago, const int inum_full, vatom, host_start, ilist, jnum, cpu_time, success, host_q, boxlo, prd); } - + void c2cl_gpu_compute(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, int *ilist, int *numj, int **firstneigh, const bool eflag, const bool vflag, diff --git a/lib/gpu/lal_lj_coul.cpp b/lib/gpu/lal_lj_coul.cpp index 00a5c108d9..a8255318bd 100644 --- a/lib/gpu/lal_lj_coul.cpp +++ b/lib/gpu/lal_lj_coul.cpp @@ -79,11 +79,11 @@ int LJCoulT::init(const int ntypes, lj1.alloc(lj_types*lj_types,*(this->ucl_device),UCL_READ_ONLY); this->atom->type_pack4(ntypes,lj_types,lj1,host_write,host_lj1,host_lj2, - host_cut_ljsq, host_cut_coulsq); + host_cut_ljsq, host_cut_coulsq); lj3.alloc(lj_types*lj_types,*(this->ucl_device),UCL_READ_ONLY); this->atom->type_pack4(ntypes,lj_types,lj3,host_write,host_lj3,host_lj4, - host_offset); + host_offset); cutsq.alloc(lj_types*lj_types,*(this->ucl_device),UCL_READ_ONLY); this->atom->type_pack1(ntypes,lj_types,cutsq,host_write,host_cutsq); diff --git a/lib/gpu/lal_lj_coul_debye.cpp b/lib/gpu/lal_lj_coul_debye.cpp index 1b230096a4..92167f314f 100644 --- a/lib/gpu/lal_lj_coul_debye.cpp +++ b/lib/gpu/lal_lj_coul_debye.cpp @@ -80,11 +80,11 @@ int LJCoulDebyeT::init(const int ntypes, lj1.alloc(lj_types*lj_types,*(this->ucl_device),UCL_READ_ONLY); this->atom->type_pack4(ntypes,lj_types,lj1,host_write,host_lj1,host_lj2, - host_cut_ljsq, host_cut_coulsq); + host_cut_ljsq, host_cut_coulsq); lj3.alloc(lj_types*lj_types,*(this->ucl_device),UCL_READ_ONLY); this->atom->type_pack4(ntypes,lj_types,lj3,host_write,host_lj3,host_lj4, - host_offset); + host_offset); cutsq.alloc(lj_types*lj_types,*(this->ucl_device),UCL_READ_ONLY); this->atom->type_pack1(ntypes,lj_types,cutsq,host_write,host_cutsq); diff --git a/lib/gpu/lal_lj_coul_debye_ext.cpp b/lib/gpu/lal_lj_coul_debye_ext.cpp index 8ec189a764..3a0a3593e7 100644 --- a/lib/gpu/lal_lj_coul_debye_ext.cpp +++ b/lib/gpu/lal_lj_coul_debye_ext.cpp @@ -110,7 +110,7 @@ int** ljcd_gpu_compute_n(const int ago, const int inum_full, vatom, host_start, ilist, jnum, cpu_time, success, host_q, boxlo, prd); } - + void ljcd_gpu_compute(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, int *ilist, int *numj, int **firstneigh, const bool eflag, const bool vflag, diff --git a/lib/gpu/lal_lj_coul_ext.cpp b/lib/gpu/lal_lj_coul_ext.cpp index 297ac7414e..b803101b9e 100644 --- a/lib/gpu/lal_lj_coul_ext.cpp +++ b/lib/gpu/lal_lj_coul_ext.cpp @@ -109,7 +109,7 @@ int** ljc_gpu_compute_n(const int ago, const int inum_full, vatom, host_start, ilist, jnum, cpu_time, success, host_q, boxlo, prd); } - + void ljc_gpu_compute(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, int *ilist, int *numj, int **firstneigh, const bool eflag, const bool vflag, diff --git a/lib/gpu/lal_lj_coul_long.cpp b/lib/gpu/lal_lj_coul_long.cpp index 71205af0ea..29d648bed2 100644 --- a/lib/gpu/lal_lj_coul_long.cpp +++ b/lib/gpu/lal_lj_coul_long.cpp @@ -80,11 +80,11 @@ int LJCoulLongT::init(const int ntypes, lj1.alloc(lj_types*lj_types,*(this->ucl_device),UCL_READ_ONLY); this->atom->type_pack4(ntypes,lj_types,lj1,host_write,host_lj1,host_lj2, - host_cutsq, host_cut_ljsq); + host_cutsq, host_cut_ljsq); lj3.alloc(lj_types*lj_types,*(this->ucl_device),UCL_READ_ONLY); this->atom->type_pack4(ntypes,lj_types,lj3,host_write,host_lj3,host_lj4, - host_offset); + host_offset); sp_lj.alloc(8,*(this->ucl_device),UCL_READ_ONLY); for (int i=0; i<4; i++) { diff --git a/lib/gpu/lal_lj_coul_long_ext.cpp b/lib/gpu/lal_lj_coul_long_ext.cpp index 95bd369336..6f8b5c9fe1 100644 --- a/lib/gpu/lal_lj_coul_long_ext.cpp +++ b/lib/gpu/lal_lj_coul_long_ext.cpp @@ -133,7 +133,7 @@ int** ljcl_gpu_compute_n(const int ago, const int inum_full, vatom, host_start, ilist, jnum, cpu_time, success, host_q, boxlo, prd); } - + void ljcl_gpu_compute(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, int *ilist, int *numj, int **firstneigh, const bool eflag, const bool vflag, diff --git a/lib/gpu/lal_lj_coul_msm.cpp b/lib/gpu/lal_lj_coul_msm.cpp index 7559a93b90..1358de9ee1 100644 --- a/lib/gpu/lal_lj_coul_msm.cpp +++ b/lib/gpu/lal_lj_coul_msm.cpp @@ -81,11 +81,11 @@ int LJCoulMSMT::init(const int ntypes, lj1.alloc(lj_types*lj_types,*(this->ucl_device),UCL_READ_ONLY); this->atom->type_pack4(ntypes,lj_types,lj1,host_write,host_lj1,host_lj2, - host_cutsq, host_cut_ljsq); + host_cutsq, host_cut_ljsq); lj3.alloc(lj_types*lj_types,*(this->ucl_device),UCL_READ_ONLY); this->atom->type_pack4(ntypes,lj_types,lj3,host_write,host_lj3,host_lj4, - host_offset); + host_offset); // pack gcons and dgcons int nrows, ncols; diff --git a/lib/gpu/lal_lj_coul_msm_ext.cpp b/lib/gpu/lal_lj_coul_msm_ext.cpp index ceff1f7c66..bf520e4dc5 100644 --- a/lib/gpu/lal_lj_coul_msm_ext.cpp +++ b/lib/gpu/lal_lj_coul_msm_ext.cpp @@ -112,7 +112,7 @@ int** ljcm_gpu_compute_n(const int ago, const int inum_full, vatom, host_start, ilist, jnum, cpu_time, success, host_q, boxlo, prd); } - + void ljcm_gpu_compute(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, int *ilist, int *numj, int **firstneigh, const bool eflag, const bool vflag, diff --git a/lib/gpu/lal_lj_cubic.cpp b/lib/gpu/lal_lj_cubic.cpp index 933795a8f6..21ea22845c 100644 --- a/lib/gpu/lal_lj_cubic.cpp +++ b/lib/gpu/lal_lj_cubic.cpp @@ -77,11 +77,11 @@ int LJCubicT::init(const int ntypes, lj1.alloc(lj_types*lj_types,*(this->ucl_device),UCL_READ_ONLY); this->atom->type_pack4(ntypes,lj_types,lj1,host_write,host_lj1,host_lj2, - host_cutsq); + host_cutsq); lj2.alloc(lj_types*lj_types,*(this->ucl_device),UCL_READ_ONLY); this->atom->type_pack4(ntypes,lj_types,lj2,host_write,host_cut_inner_sq, - host_cut_inner,host_sigma,host_epsilon); + host_cut_inner,host_sigma,host_epsilon); lj3.alloc(lj_types*lj_types,*(this->ucl_device),UCL_READ_ONLY); this->atom->type_pack2(ntypes,lj_types,lj3,host_write,host_lj3,host_lj4); diff --git a/lib/gpu/lal_lj_cubic_ext.cpp b/lib/gpu/lal_lj_cubic_ext.cpp index a45d02a8ca..efbcee0a9f 100644 --- a/lib/gpu/lal_lj_cubic_ext.cpp +++ b/lib/gpu/lal_lj_cubic_ext.cpp @@ -107,7 +107,7 @@ int ** ljcb_gpu_compute_n(const int ago, const int inum_full, subhi, tag, nspecial, special, eflag, vflag, eatom, vatom, host_start, ilist, jnum, cpu_time, success); } - + void ljcb_gpu_compute(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, int *ilist, int *numj, int **firstneigh, const bool eflag, const bool vflag, diff --git a/lib/gpu/lal_lj_dsf.cpp b/lib/gpu/lal_lj_dsf.cpp index 384cf75d1f..1efac3e821 100644 --- a/lib/gpu/lal_lj_dsf.cpp +++ b/lib/gpu/lal_lj_dsf.cpp @@ -84,11 +84,11 @@ int LJDSFT::init(const int ntypes, double **host_cutsq, double **host_lj1, lj1.alloc(lj_types*lj_types,*(this->ucl_device),UCL_READ_ONLY); this->atom->type_pack4(ntypes,lj_types,lj1,host_write,host_lj1,host_lj2, - host_cut_ljsq, host_cutsq); + host_cut_ljsq, host_cutsq); lj3.alloc(lj_types*lj_types,*(this->ucl_device),UCL_READ_ONLY); this->atom->type_pack4(ntypes,lj_types,lj3,host_write,host_lj3,host_lj4, - host_offset); + host_offset); sp_lj.alloc(8,*(this->ucl_device),UCL_READ_ONLY); for (int i=0; i<4; i++) { diff --git a/lib/gpu/lal_lj_dsf_ext.cpp b/lib/gpu/lal_lj_dsf_ext.cpp index f516da6622..25802e7544 100644 --- a/lib/gpu/lal_lj_dsf_ext.cpp +++ b/lib/gpu/lal_lj_dsf_ext.cpp @@ -113,7 +113,7 @@ int** ljd_gpu_compute_n(const int ago, const int inum_full, vatom, host_start, ilist, jnum, cpu_time, success, host_q, boxlo, prd); } - + void ljd_gpu_compute(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, int *ilist, int *numj, int **firstneigh, const bool eflag, const bool vflag, diff --git a/lib/gpu/lal_lj_expand.cpp b/lib/gpu/lal_lj_expand.cpp index c6d8a92e96..34a4d71c0b 100644 --- a/lib/gpu/lal_lj_expand.cpp +++ b/lib/gpu/lal_lj_expand.cpp @@ -76,11 +76,11 @@ int LJExpandT::init(const int ntypes, double **host_cutsq, lj1.alloc(lj_types*lj_types,*(this->ucl_device),UCL_READ_ONLY); this->atom->type_pack4(ntypes,lj_types,lj1,host_write,host_lj1,host_lj2, - host_cutsq, host_shift); + host_cutsq, host_shift); lj3.alloc(lj_types*lj_types,*(this->ucl_device),UCL_READ_ONLY); this->atom->type_pack4(ntypes,lj_types,lj3,host_write,host_lj3,host_lj4, - host_offset); + host_offset); UCL_H_Vec dview; sp_lj.alloc(4,*(this->ucl_device),UCL_READ_ONLY); diff --git a/lib/gpu/lal_lj_expand.cu b/lib/gpu/lal_lj_expand.cu index a951b4107a..9281ad27bd 100644 --- a/lib/gpu/lal_lj_expand.cu +++ b/lib/gpu/lal_lj_expand.cu @@ -82,9 +82,9 @@ __kernel void k_lj_expand(const __global numtyp4 *restrict x_, int mtype=itype*lj_types+jtype; if (r2invucl_device),UCL_READ_ONLY); this->atom->type_pack4(ntypes,lj_types,mie1,host_write,host_mie1,host_mie2, - host_gamA,host_gamR); + host_gamA,host_gamR); mie3.alloc(lj_types*lj_types,*(this->ucl_device),UCL_READ_ONLY); this->atom->type_pack4(ntypes,lj_types,mie3,host_write,host_mie3,host_mie4, - host_offset,host_cutsq); + host_offset,host_cutsq); UCL_H_Vec dview; sp_lj.alloc(4,*(this->ucl_device),UCL_READ_ONLY); diff --git a/lib/gpu/lal_mie_ext.cpp b/lib/gpu/lal_mie_ext.cpp index f43cde2650..9b03903c4f 100644 --- a/lib/gpu/lal_mie_ext.cpp +++ b/lib/gpu/lal_mie_ext.cpp @@ -107,7 +107,7 @@ int ** mie_gpu_compute_n(const int ago, const int inum_full, subhi, tag, nspecial, special, eflag, vflag, eatom, vatom, host_start, ilist, jnum, cpu_time, success); } - + void mie_gpu_compute(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, int *ilist, int *numj, int **firstneigh, const bool eflag, const bool vflag, diff --git a/lib/gpu/lal_morse_ext.cpp b/lib/gpu/lal_morse_ext.cpp index d07a83cd34..0338bc07a8 100644 --- a/lib/gpu/lal_morse_ext.cpp +++ b/lib/gpu/lal_morse_ext.cpp @@ -104,7 +104,7 @@ int** mor_gpu_compute_n(const int ago, const int inum_full, subhi, tag, nspecial, special, eflag, vflag, eatom, vatom, host_start, ilist, jnum, cpu_time, success); } - + void mor_gpu_compute(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, int *ilist, int *numj, int **firstneigh, const bool eflag, const bool vflag, diff --git a/lib/gpu/lal_neighbor_gpu.cu b/lib/gpu/lal_neighbor_gpu.cu index add9c65fd4..b0b3cfb90c 100644 --- a/lib/gpu/lal_neighbor_gpu.cu +++ b/lib/gpu/lal_neighbor_gpu.cu @@ -118,24 +118,24 @@ __kernel void transpose(__global tagint *restrict out, const __global tagint *restrict in, int columns_in, int rows_in) { - __local tagint block[BLOCK_CELL_2D][BLOCK_CELL_2D+1]; - - unsigned ti=THREAD_ID_X; - unsigned tj=THREAD_ID_Y; - unsigned bi=BLOCK_ID_X; - unsigned bj=BLOCK_ID_Y; - - unsigned i=bi*BLOCK_CELL_2D+ti; - unsigned j=bj*BLOCK_CELL_2D+tj; - if ((i 1e-5) { cnt++; @@ -240,11 +240,11 @@ __kernel void calc_neigh_list_cell(const __global numtyp4 *restrict x_, if ((cnt & (t_per_atom-1))==0) neigh_list=neigh_list+stride; } - } + } } } - __syncthreads(); - } // for (k) + __syncthreads(); + } // for (k) } } } diff --git a/lib/gpu/lal_neighbor_shared.cpp b/lib/gpu/lal_neighbor_shared.cpp index b399d7441a..f1458b35be 100644 --- a/lib/gpu/lal_neighbor_shared.cpp +++ b/lib/gpu/lal_neighbor_shared.cpp @@ -51,8 +51,8 @@ void NeighborShared::clear() { void NeighborShared::compile_kernels(UCL_Device &dev, const int gpu_nbor, const std::string flags) { if (_compiled) - return; - + return; + _gpu_nbor=gpu_nbor; if (_gpu_nbor==0) { nbor_program=new UCL_Program(dev); diff --git a/lib/gpu/lal_pppm.cu b/lib/gpu/lal_pppm.cu index 11703d6d2a..24636b9a93 100644 --- a/lib/gpu/lal_pppm.cu +++ b/lib/gpu/lal_pppm.cu @@ -270,19 +270,19 @@ __kernel void interp(const __global numtyp4 *restrict x_, int my=mz+fast_mul(ny,npts_x); for (int m=0; mucl_device),UCL_READ_ONLY); this->atom->type_pack2(ntypes,lj_types,sigma_epsilon,host_write, - host_sigma,host_epsilon); + host_sigma,host_epsilon); this->cut_form.alloc(lj_types*lj_types,*(this->ucl_device),UCL_READ_ONLY); this->atom->type_pack2(ntypes,lj_types,this->cut_form,host_write, - host_cutsq,h_form); + host_cutsq,h_form); lj1.alloc(lj_types*lj_types,*(this->ucl_device),UCL_READ_ONLY); this->atom->type_pack4(ntypes,lj_types,lj1,host_write,host_lj1,host_lj2, - host_cutsq,h_form); + host_cutsq,h_form); lj3.alloc(lj_types*lj_types,*(this->ucl_device),UCL_READ_ONLY); this->atom->type_pack4(ntypes,lj_types,lj3,host_write,host_lj3,host_lj4, - host_offset); + host_offset); dev_error.alloc(1,*(this->ucl_device),UCL_WRITE_ONLY); dev_error.zero(); @@ -197,7 +197,7 @@ void RESquaredT::loop(const bool _eflag, const bool _vflag) { (BX/this->_threads_per_atom))); NGX=static_cast(ceil(static_cast(this->_last_ellipse)/BX)); this->pack_nbors(NGX,BX, 0, this->_last_ellipse,ELLIPSE_ELLIPSE, - ELLIPSE_ELLIPSE,_shared_types,_lj_types); + ELLIPSE_ELLIPSE,_shared_types,_lj_types); this->time_nbor1.stop(); this->time_ellipsoid.start(); @@ -214,7 +214,7 @@ void RESquaredT::loop(const bool _eflag, const bool _vflag) { // ------------ ELLIPSE_SPHERE --------------- this->time_nbor2.start(); this->pack_nbors(NGX,BX, 0, this->_last_ellipse,ELLIPSE_SPHERE, - ELLIPSE_SPHERE,_shared_types,_lj_types); + ELLIPSE_SPHERE,_shared_types,_lj_types); this->time_nbor2.stop(); this->time_ellipsoid2.start(); @@ -245,7 +245,7 @@ void RESquaredT::loop(const bool _eflag, const bool _vflag) { NGX=static_cast(ceil(static_cast(this->ans->inum()- this->_last_ellipse)/BX)); this->pack_nbors(NGX,BX,this->_last_ellipse,this->ans->inum(), - SPHERE_ELLIPSE,SPHERE_ELLIPSE,_shared_types,_lj_types); + SPHERE_ELLIPSE,SPHERE_ELLIPSE,_shared_types,_lj_types); this->time_nbor3.stop(); this->time_ellipsoid3.start(); @@ -300,7 +300,7 @@ void RESquaredT::loop(const bool _eflag, const bool _vflag) { NGX=static_cast(ceil(static_cast(this->ans->inum())/BX)); this->time_nbor1.start(); this->pack_nbors(NGX, BX, 0, this->ans->inum(),SPHERE_SPHERE, - ELLIPSE_ELLIPSE,_shared_types,_lj_types); + ELLIPSE_ELLIPSE,_shared_types,_lj_types); this->time_nbor1.stop(); this->time_ellipsoid.start(); this->k_ellipsoid.set_size(GX,BX); diff --git a/lib/gpu/lal_soft.cpp b/lib/gpu/lal_soft.cpp index 337bdd6738..727b112ea5 100644 --- a/lib/gpu/lal_soft.cpp +++ b/lib/gpu/lal_soft.cpp @@ -74,7 +74,7 @@ int SoftT::init(const int ntypes, double **host_cutsq, coeff.alloc(lj_types*lj_types,*(this->ucl_device),UCL_READ_ONLY); this->atom->type_pack4(ntypes,lj_types,coeff,host_write,host_prefactor, - host_cut,host_cutsq); + host_cut,host_cutsq); UCL_H_Vec dview; sp_lj.alloc(4,*(this->ucl_device),UCL_READ_ONLY); @@ -98,7 +98,7 @@ void SoftT::reinit(const int ntypes, double **host_cutsq, host_write[i]=0.0; this->atom->type_pack4(ntypes,_lj_types,coeff,host_write,host_prefactor, - host_cut,host_cutsq); + host_cut,host_cutsq); } template diff --git a/lib/gpu/lal_soft_ext.cpp b/lib/gpu/lal_soft_ext.cpp index 441fe35839..d3b3fa2598 100644 --- a/lib/gpu/lal_soft_ext.cpp +++ b/lib/gpu/lal_soft_ext.cpp @@ -125,7 +125,7 @@ int ** soft_gpu_compute_n(const int ago, const int inum_full, subhi, tag, nspecial, special, eflag, vflag, eatom, vatom, host_start, ilist, jnum, cpu_time, success); } - + void soft_gpu_compute(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, int *ilist, int *numj, int **firstneigh, const bool eflag, const bool vflag, diff --git a/lib/gpu/lal_sw_ext.cpp b/lib/gpu/lal_sw_ext.cpp index 8cb51307a1..4959650c90 100644 --- a/lib/gpu/lal_sw_ext.cpp +++ b/lib/gpu/lal_sw_ext.cpp @@ -114,7 +114,7 @@ int ** sw_gpu_compute_n(const int ago, const int inum_full, subhi, tag, nspecial, special, eflag, vflag, eatom, vatom, host_start, ilist, jnum, cpu_time, success); } - + void sw_gpu_compute(const int ago, const int nlocal, const int nall, const int nlist, double **host_x, int *host_type, int *ilist, int *numj, int **firstneigh, const bool eflag, diff --git a/lib/gpu/lal_table_ext.cpp b/lib/gpu/lal_table_ext.cpp index 4eb7e0ce1b..a2b5c61e74 100644 --- a/lib/gpu/lal_table_ext.cpp +++ b/lib/gpu/lal_table_ext.cpp @@ -103,7 +103,7 @@ int ** table_gpu_compute_n(const int ago, const int inum_full, subhi, tag, nspecial, special, eflag, vflag, eatom, vatom, host_start, ilist, jnum, cpu_time, success); } - + void table_gpu_compute(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, int *ilist, int *numj, int **firstneigh, const bool eflag, const bool vflag, diff --git a/lib/gpu/lal_tersoff.cu b/lib/gpu/lal_tersoff.cu index 4a71518b53..8140b503ce 100644 --- a/lib/gpu/lal_tersoff.cu +++ b/lib/gpu/lal_tersoff.cu @@ -815,7 +815,7 @@ __kernel void k_tersoff_three_end(const __global numtyp4 *restrict x_, __kernel void k_tersoff_three_end_vatom(const __global numtyp4 *restrict x_, const __global numtyp4 *restrict ts1_in, const __global numtyp4 *restrict ts2_in, - const __global numtyp4 *restrict ts4_in, + const __global numtyp4 *restrict ts4_in, const __global numtyp *restrict cutsq, const __global int *restrict map, const __global int *restrict elem2param, @@ -974,7 +974,7 @@ __kernel void k_tersoff_three_end_vatom(const __global numtyp4 *restrict x_, numtyp delr2[3]; delr2[0] = kx.x-jx.x; - delr2[1] = kx.y-jx.y; + delr2[1] = kx.y-jx.y; delr2[2] = kx.z-jx.z; numtyp rsq2 = delr2[0]*delr2[0] + delr2[1]*delr2[1] + delr2[2]*delr2[2]; diff --git a/lib/gpu/lal_tersoff_ext.cpp b/lib/gpu/lal_tersoff_ext.cpp index a608a57179..e6dc539035 100644 --- a/lib/gpu/lal_tersoff_ext.cpp +++ b/lib/gpu/lal_tersoff_ext.cpp @@ -118,7 +118,7 @@ int ** tersoff_gpu_compute_n(const int ago, const int inum_full, subhi, tag, nspecial, special, eflag, vflag, eatom, vatom, host_start, ilist, jnum, cpu_time, success); } - + void tersoff_gpu_compute(const int ago, const int nlocal, const int nall, const int nlist, double **host_x, int *host_type, int *ilist, int *numj, int **firstneigh, const bool eflag, diff --git a/lib/gpu/lal_tersoff_extra.h b/lib/gpu/lal_tersoff_extra.h index 21a0315f71..47d16678f0 100644 --- a/lib/gpu/lal_tersoff_extra.h +++ b/lib/gpu/lal_tersoff_extra.h @@ -186,7 +186,7 @@ ucl_inline numtyp ters_bij_d(const numtyp zeta, if (tmp > param_c2) return param_beta * ((numtyp)-0.5*ucl_powr(tmp,(numtyp)-1.5) * // error in negligible 2nd term fixed 9/30/2015 - // (1.0 - 0.5*(1.0 + 1.0/(2.0*param->powern)) * + // (1.0 - 0.5*(1.0 + 1.0/(2.0*param->powern)) * ((numtyp)1.0 - ((numtyp)1.0 + (numtyp)1.0 /((numtyp)2.0 * param_powern)) * ucl_powr(tmp,-param_powern))); if (tmp < param_c4) return (numtyp)0.0; diff --git a/lib/gpu/lal_tersoff_mod.cu b/lib/gpu/lal_tersoff_mod.cu index 13c8147d99..297cd50944 100644 --- a/lib/gpu/lal_tersoff_mod.cu +++ b/lib/gpu/lal_tersoff_mod.cu @@ -831,8 +831,8 @@ __kernel void k_tersoff_mod_three_end(const __global numtyp4 *restrict x_, __kernel void k_tersoff_mod_three_end_vatom(const __global numtyp4 *restrict x_, const __global numtyp4 *restrict ts1_in, const __global numtyp4 *restrict ts2_in, - const __global numtyp4 *restrict ts4_in, - const __global numtyp4 *restrict ts5_in, + const __global numtyp4 *restrict ts4_in, + const __global numtyp4 *restrict ts5_in, const __global numtyp *restrict cutsq, const __global int *restrict map, const __global int *restrict elem2param, @@ -993,7 +993,7 @@ __kernel void k_tersoff_mod_three_end_vatom(const __global numtyp4 *restrict x_, numtyp delr2[3]; delr2[0] = kx.x-jx.x; - delr2[1] = kx.y-jx.y; + delr2[1] = kx.y-jx.y; delr2[2] = kx.z-jx.z; numtyp rsq2 = delr2[0]*delr2[0] + delr2[1]*delr2[1] + delr2[2]*delr2[2]; diff --git a/lib/gpu/lal_tersoff_mod_ext.cpp b/lib/gpu/lal_tersoff_mod_ext.cpp index 7817e7d08d..7f0af3fce9 100644 --- a/lib/gpu/lal_tersoff_mod_ext.cpp +++ b/lib/gpu/lal_tersoff_mod_ext.cpp @@ -118,7 +118,7 @@ int ** tersoff_mod_gpu_compute_n(const int ago, const int inum_full, subhi, tag, nspecial, special, eflag, vflag, eatom, vatom, host_start, ilist, jnum, cpu_time, success); } - + void tersoff_mod_gpu_compute(const int ago, const int nlocal, const int nall, const int nlist, double **host_x, int *host_type, int *ilist, int *numj, int **firstneigh, const bool eflag, diff --git a/lib/gpu/lal_tersoff_mod_extra.h b/lib/gpu/lal_tersoff_mod_extra.h index 370aceb634..a130d98488 100644 --- a/lib/gpu/lal_tersoff_mod_extra.h +++ b/lib/gpu/lal_tersoff_mod_extra.h @@ -180,12 +180,12 @@ ucl_inline numtyp ters_bij_d(const numtyp zeta, { numtyp tmp = param_beta * zeta; if (tmp > param_ca1) return (numtyp)-0.5*(param_powern/param_powern_del) * - ucl_powr(tmp,(numtyp)-0.5*(param_powern/param_powern_del)) / zeta; + ucl_powr(tmp,(numtyp)-0.5*(param_powern/param_powern_del)) / zeta; if (tmp < param_ca4) return (numtyp)0.0; numtyp tmp_n = ucl_powr(tmp,param_powern); return (numtyp)-0.5 *(param_powern/param_powern_del) * - ucl_powr((numtyp)1.0+tmp_n, (numtyp)-1.0-((numtyp)1.0 / + ucl_powr((numtyp)1.0+tmp_n, (numtyp)-1.0-((numtyp)1.0 / ((numtyp)2.0*param_powern_del)))*tmp_n / zeta; } diff --git a/lib/gpu/lal_tersoff_zbl.cu b/lib/gpu/lal_tersoff_zbl.cu index 97eb72b04f..4a3550e60b 100644 --- a/lib/gpu/lal_tersoff_zbl.cu +++ b/lib/gpu/lal_tersoff_zbl.cu @@ -835,7 +835,7 @@ __kernel void k_tersoff_zbl_three_end(const __global numtyp4 *restrict x_, __kernel void k_tersoff_zbl_three_end_vatom(const __global numtyp4 *restrict x_, const __global numtyp4 *restrict ts1_in, const __global numtyp4 *restrict ts2_in, - const __global numtyp4 *restrict ts4_in, + const __global numtyp4 *restrict ts4_in, const __global numtyp *restrict cutsq, const __global int *restrict map, const __global int *restrict elem2param, @@ -994,7 +994,7 @@ __kernel void k_tersoff_zbl_three_end_vatom(const __global numtyp4 *restrict x_, numtyp delr2[3]; delr2[0] = kx.x-jx.x; - delr2[1] = kx.y-jx.y; + delr2[1] = kx.y-jx.y; delr2[2] = kx.z-jx.z; numtyp rsq2 = delr2[0]*delr2[0] + delr2[1]*delr2[1] + delr2[2]*delr2[2]; diff --git a/lib/gpu/lal_tersoff_zbl_ext.cpp b/lib/gpu/lal_tersoff_zbl_ext.cpp index fce240f8fe..ccfcf6839d 100644 --- a/lib/gpu/lal_tersoff_zbl_ext.cpp +++ b/lib/gpu/lal_tersoff_zbl_ext.cpp @@ -129,7 +129,7 @@ int ** tersoff_zbl_gpu_compute_n(const int ago, const int inum_full, subhi, tag, nspecial, special, eflag, vflag, eatom, vatom, host_start, ilist, jnum, cpu_time, success); } - + void tersoff_zbl_gpu_compute(const int ago, const int nlocal, const int nall, const int nlist, double **host_x, int *host_type, int *ilist, int *numj, int **firstneigh, const bool eflag, diff --git a/lib/gpu/lal_tersoff_zbl_extra.h b/lib/gpu/lal_tersoff_zbl_extra.h index 79afb4de82..32c05a3716 100644 --- a/lib/gpu/lal_tersoff_zbl_extra.h +++ b/lib/gpu/lal_tersoff_zbl_extra.h @@ -212,7 +212,7 @@ ucl_inline numtyp ters_bij_d(const numtyp zeta, if (tmp > param_c2) return param_beta * ((numtyp)-0.5*ucl_powr(tmp,(numtyp)-1.5) * // error in negligible 2nd term fixed 9/30/2015 - // (1.0 - 0.5*(1.0 + 1.0/(2.0*param->powern)) * + // (1.0 - 0.5*(1.0 + 1.0/(2.0*param->powern)) * ((numtyp)1.0 - ((numtyp)1.0 + (numtyp)1.0 /((numtyp)2.0 * param_powern)) * ucl_powr(tmp,-param_powern))); if (tmp < param_c4) return (numtyp)0.0; diff --git a/lib/gpu/lal_yukawa.cpp b/lib/gpu/lal_yukawa.cpp index 88cb8cdb3c..a316d195ac 100644 --- a/lib/gpu/lal_yukawa.cpp +++ b/lib/gpu/lal_yukawa.cpp @@ -75,7 +75,7 @@ int YukawaT::init(const int ntypes, coeff.alloc(lj_types*lj_types,*(this->ucl_device),UCL_READ_ONLY); this->atom->type_pack4(ntypes,lj_types,coeff,host_write,host_a,host_offset, - host_cutsq); + host_cutsq); UCL_H_Vec dview; sp_lj.alloc(4,*(this->ucl_device),UCL_READ_ONLY); diff --git a/lib/gpu/lal_yukawa_colloid.cpp b/lib/gpu/lal_yukawa_colloid.cpp index bfe398c62e..af29938a68 100644 --- a/lib/gpu/lal_yukawa_colloid.cpp +++ b/lib/gpu/lal_yukawa_colloid.cpp @@ -96,7 +96,7 @@ int YukawaColloidT::init(const int ntypes, coeff.alloc(lj_types*lj_types,*(this->ucl_device),UCL_READ_ONLY); this->atom->type_pack4(ntypes,lj_types,coeff,host_write,host_a, - host_offset,host_cutsq); + host_offset,host_cutsq); UCL_H_Vec dview; sp_lj.alloc(4,*(this->ucl_device),UCL_READ_ONLY); diff --git a/lib/gpu/lal_yukawa_colloid.cu b/lib/gpu/lal_yukawa_colloid.cu index ad02f202a3..48ab47bc94 100644 --- a/lib/gpu/lal_yukawa_colloid.cu +++ b/lib/gpu/lal_yukawa_colloid.cu @@ -89,10 +89,10 @@ __kernel void k_yukawa_colloid(const __global numtyp4 *restrict x_, if (rsqucl_device),UCL_READ_ONLY); this->atom->type_pack4(ntypes,lj_types,coeff1,host_write,host_sw1,host_sw2, - host_zze, host_cutsq); + host_zze, host_cutsq); coeff2.alloc(lj_types*lj_types,*(this->ucl_device),UCL_READ_ONLY); this->atom->type_pack4(ntypes,lj_types,coeff2,host_write,host_d1a,host_d2a, - host_d3a,host_d4a); + host_d3a,host_d4a); coeff3.alloc(lj_types*lj_types,*(this->ucl_device),UCL_READ_ONLY); this->atom->type_pack4(ntypes,lj_types,coeff3,host_write,host_sw3,host_sw4,host_sw5); diff --git a/lib/gpu/lal_zbl.cu b/lib/gpu/lal_zbl.cu index 30bbc8aa2e..b7f379c833 100644 --- a/lib/gpu/lal_zbl.cu +++ b/lib/gpu/lal_zbl.cu @@ -134,10 +134,10 @@ __kernel void k_zbl(const __global numtyp4 *restrict x_, force = dzbldr(r, coeff2[mtype].x, coeff2[mtype].y, coeff2[mtype].z, coeff2[mtype].w, coeff1[mtype].z); - if (rsq>cut_innersq) { - t = r - cut_inner; - force = t*t * (coeff1[mtype].x + coeff1[mtype].y*t); - } + if (rsq>cut_innersq) { + t = r - cut_inner; + force = t*t * (coeff1[mtype].x + coeff1[mtype].y*t); + } force *= (numtyp)-1.0*ucl_recip(r); @@ -148,10 +148,10 @@ __kernel void k_zbl(const __global numtyp4 *restrict x_, if (eflag>0) { numtyp e=e_zbl(r, coeff2[mtype].x, coeff2[mtype].y, coeff2[mtype].z, coeff2[mtype].w, coeff1[mtype].z); - e += coeff3[mtype].z; - if (rsq > cut_innersq) { - e += t*t*t * (coeff3[mtype].x + coeff3[mtype].y*t); - } + e += coeff3[mtype].z; + if (rsq > cut_innersq) { + e += t*t*t * (coeff3[mtype].x + coeff3[mtype].y*t); + } energy+=e; } @@ -237,10 +237,10 @@ __kernel void k_zbl_fast(const __global numtyp4 *restrict x_, force = dzbldr(r, coeff2[mtype].x, coeff2[mtype].y, coeff2[mtype].z, coeff2[mtype].w, coeff1[mtype].z); - if (rsq>cut_innersq) { - t = r - cut_inner; - force += t*t * (coeff1[mtype].x + coeff1[mtype].y*t); - } + if (rsq>cut_innersq) { + t = r - cut_inner; + force += t*t * (coeff1[mtype].x + coeff1[mtype].y*t); + } force *= (numtyp)-1.0*ucl_recip(r); @@ -251,10 +251,10 @@ __kernel void k_zbl_fast(const __global numtyp4 *restrict x_, if (eflag>0) { numtyp e=e_zbl(r, coeff2[mtype].x, coeff2[mtype].y, coeff2[mtype].z, coeff2[mtype].w, coeff1[mtype].z); - e += coeff3[mtype].z; - if (rsq > cut_innersq) { - e += t*t*t * (coeff3[mtype].x + coeff3[mtype].y*t); - } + e += coeff3[mtype].z; + if (rsq > cut_innersq) { + e += t*t*t * (coeff3[mtype].x + coeff3[mtype].y*t); + } energy+=e; } diff --git a/lib/gpu/lal_zbl_ext.cpp b/lib/gpu/lal_zbl_ext.cpp index 5fd003b8ca..37aa74351b 100644 --- a/lib/gpu/lal_zbl_ext.cpp +++ b/lib/gpu/lal_zbl_ext.cpp @@ -106,7 +106,7 @@ int ** zbl_gpu_compute_n(const int ago, const int inum_full, subhi, tag, nspecial, special, eflag, vflag, eatom, vatom, host_start, ilist, jnum, cpu_time, success); } - + void zbl_gpu_compute(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, int *ilist, int *numj, int **firstneigh, const bool eflag, const bool vflag, diff --git a/src/GPU/pair_born_coul_long_gpu.cpp b/src/GPU/pair_born_coul_long_gpu.cpp index 4e457de4a5..b6a7e57038 100644 --- a/src/GPU/pair_born_coul_long_gpu.cpp +++ b/src/GPU/pair_born_coul_long_gpu.cpp @@ -182,8 +182,8 @@ void PairBornCoulLongGPU::init_style() int success = borncl_gpu_init(atom->ntypes+1, cutsq, rhoinv, born1, born2, born3, a, c, d, sigma, offset, force->special_lj, atom->nlocal, - atom->nlocal+atom->nghost, 300, maxspecial, - cell_size, gpu_mode, screen, cut_ljsq, + atom->nlocal+atom->nghost, 300, maxspecial, + cell_size, gpu_mode, screen, cut_ljsq, cut_coulsq, force->special_coul, force->qqrd2e, g_ewald); diff --git a/src/GPU/pair_born_coul_wolf_gpu.cpp b/src/GPU/pair_born_coul_wolf_gpu.cpp index 4a7e0f223c..931252be6b 100644 --- a/src/GPU/pair_born_coul_wolf_gpu.cpp +++ b/src/GPU/pair_born_coul_wolf_gpu.cpp @@ -71,7 +71,7 @@ double borncw_gpu_bytes(); /* ---------------------------------------------------------------------- */ PairBornCoulWolfGPU::PairBornCoulWolfGPU(LAMMPS *lmp) : PairBornCoulWolf(lmp), - gpu_mode(GPU_FORCE) + gpu_mode(GPU_FORCE) { respa_enable = 0; reinitflag = 0; diff --git a/src/GPU/pair_born_gpu.cpp b/src/GPU/pair_born_gpu.cpp index e80a6509ad..46729ab77c 100644 --- a/src/GPU/pair_born_gpu.cpp +++ b/src/GPU/pair_born_gpu.cpp @@ -155,7 +155,7 @@ void PairBornGPU::init_style() born1, born2, born3, a, c, d, sigma, offset, force->special_lj, atom->nlocal, atom->nlocal+atom->nghost, 300, maxspecial, - cell_size, gpu_mode, screen); + cell_size, gpu_mode, screen); GPU_EXTRA::check_flag(success,error,world); if (gpu_mode == GPU_FORCE) { diff --git a/src/GPU/pair_lj_gromacs_gpu.cpp b/src/GPU/pair_lj_gromacs_gpu.cpp index 5833b8198f..d749eacba3 100644 --- a/src/GPU/pair_lj_gromacs_gpu.cpp +++ b/src/GPU/pair_lj_gromacs_gpu.cpp @@ -153,7 +153,7 @@ void PairLJGromacsGPU::init_style() maxspecial=atom->maxspecial; int success = ljgrm_gpu_init(atom->ntypes+1, cutsq, lj1, lj2, lj3, lj4, - force->special_lj, atom->nlocal, + force->special_lj, atom->nlocal, atom->nlocal+atom->nghost, 300, maxspecial, cell_size, gpu_mode, screen, ljsw1, ljsw2, ljsw3, ljsw4, ljsw5, cut_inner, cut_inner_sq); @@ -215,31 +215,31 @@ void PairLJGromacsGPU::cpu_compute(int start, int inum, int eflag, if (rsq < cutsq[itype][jtype]) { r2inv = 1.0/rsq; - r6inv = r2inv*r2inv*r2inv; + r6inv = r2inv*r2inv*r2inv; forcelj = r6inv * (lj1[itype][jtype]*r6inv - lj2[itype][jtype]); - if (rsq > cut_inner_sq[itype][jtype]) { + if (rsq > cut_inner_sq[itype][jtype]) { r = sqrt(rsq); t = r - cut_inner[itype][jtype]; - fswitch = r*t*t*(ljsw1[itype][jtype] + ljsw2[itype][jtype]*t); - forcelj += fswitch; + fswitch = r*t*t*(ljsw1[itype][jtype] + ljsw2[itype][jtype]*t); + forcelj += fswitch; } - fpair = factor_lj*forcelj * r2inv; + fpair = factor_lj*forcelj * r2inv; - f[i][0] += delx*fpair; - f[i][1] += dely*fpair; - f[i][2] += delz*fpair; + f[i][0] += delx*fpair; + f[i][1] += dely*fpair; + f[i][2] += delz*fpair; - if (eflag) { - evdwl = r6inv * (lj3[itype][jtype]*r6inv - lj4[itype][jtype]); - evdwl += ljsw5[itype][jtype]; + if (eflag) { + evdwl = r6inv * (lj3[itype][jtype]*r6inv - lj4[itype][jtype]); + evdwl += ljsw5[itype][jtype]; if (rsq > cut_inner_sq[itype][jtype]) { eswitch = t*t*t*(ljsw3[itype][jtype] + ljsw4[itype][jtype]*t); evdwl += eswitch; } - evdwl *= factor_lj; - } + evdwl *= factor_lj; + } - if (evflag) ev_tally_full(i,evdwl,0.0,fpair,delx,dely,delz); + if (evflag) ev_tally_full(i,evdwl,0.0,fpair,delx,dely,delz); } } } diff --git a/src/GPU/pair_zbl_gpu.cpp b/src/GPU/pair_zbl_gpu.cpp index faf6e9b29d..f1f6bdd44b 100644 --- a/src/GPU/pair_zbl_gpu.cpp +++ b/src/GPU/pair_zbl_gpu.cpp @@ -210,15 +210,15 @@ void PairZBLGPU::cpu_compute(int start, int inum, int eflag, int vflag, jtype = type[j]; if (rsq < cut_globalsq) { - r = sqrt(rsq); + r = sqrt(rsq); fpair = dzbldr(r, itype, jtype); - if (rsq > cut_innersq) { - t = r - cut_inner; - fswitch = t*t * - (sw1[itype][jtype] + sw2[itype][jtype]*t); - fpair += fswitch; - } + if (rsq > cut_innersq) { + t = r - cut_inner; + fswitch = t*t * + (sw1[itype][jtype] + sw2[itype][jtype]*t); + fpair += fswitch; + } fpair *= -1.0/r; f[i][0] += delx*fpair; @@ -227,12 +227,12 @@ void PairZBLGPU::cpu_compute(int start, int inum, int eflag, int vflag, if (eflag) { evdwl = e_zbl(r, itype, jtype); - evdwl += sw5[itype][jtype]; - if (rsq > cut_innersq) { - eswitch = t*t*t * - (sw3[itype][jtype] + sw4[itype][jtype]*t); - evdwl += eswitch; - } + evdwl += sw5[itype][jtype]; + if (rsq > cut_innersq) { + eswitch = t*t*t * + (sw3[itype][jtype] + sw4[itype][jtype]*t); + evdwl += eswitch; + } } if (evflag) ev_tally_full(i,evdwl,0.0,fpair,delx,dely,delz); From 317dcdf1783be17ca25cc2eeae91e80f32cc7368 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Fri, 24 Jun 2016 14:12:05 -0400 Subject: [PATCH 14/15] Cleanup of USER-HADRESS documentation to match the current state. regenerate jpg images. --- doc/Eqs/HADRESS_AT_pair_coul_dsf.jpg | Bin 5732 -> 0 bytes doc/Eqs/HADRESS_AT_pair_lj.png | Bin 2870 -> 0 bytes doc/Eqs/HADRESS_CG_pair_lj.png | Bin 2924 -> 0 bytes doc/Eqs/HADRESS_Switching_Function_Slab.png | Bin 3285 -> 0 bytes doc/Eqs/HADRESS_Switching_Function_Sphere.png | Bin 2540 -> 0 bytes doc/Eqs/HADRESS_System_Hamiltonian.png | Bin 3653 -> 0 bytes doc/Eqs/HADRESS_System_Potentials.png | Bin 7050 -> 0 bytes doc/src/Eqs/HADRESS_AT_pair_coul_dsf.jpg | Bin 0 -> 11269 bytes doc/{ => src}/Eqs/HADRESS_AT_pair_coul_dsf.tex | 1 + doc/src/Eqs/HADRESS_AT_pair_lj.jpg | Bin 0 -> 4495 bytes doc/{ => src}/Eqs/HADRESS_AT_pair_lj.tex | 1 + doc/src/Eqs/HADRESS_CG_pair_lj.jpg | Bin 0 -> 4599 bytes doc/{ => src}/Eqs/HADRESS_CG_pair_lj.tex | 1 + .../Eqs/HADRESS_Switching_Function_Cylinder.jpg | Bin 0 -> 7257 bytes .../Eqs/HADRESS_Switching_Function_Cylinder.tex | 3 ++- doc/src/Eqs/HADRESS_Switching_Function_Slab.jpg | Bin 0 -> 9792 bytes .../Eqs/HADRESS_Switching_Function_Slab.tex | 3 ++- .../Eqs/HADRESS_Switching_Function_Sphere.jpg | Bin 0 -> 7257 bytes .../Eqs/HADRESS_Switching_Function_Sphere.tex | 3 ++- doc/src/Eqs/HADRESS_System_Hamiltonian.jpg | Bin 0 -> 5403 bytes .../Eqs/HADRESS_System_Hamiltonian.tex | 3 ++- doc/src/Eqs/HADRESS_System_Potentials.jpg | Bin 0 -> 9616 bytes doc/{ => src}/Eqs/HADRESS_System_Potentials.tex | 3 ++- doc/{ => src}/JPG/HADRESS_MODEL_LAMMPS.png | Bin doc/{ => src}/fix_lambdah_calc.txt | 4 ++-- doc/{ => src}/pair_lj_hars.txt | 8 ++++---- 26 files changed, 19 insertions(+), 11 deletions(-) delete mode 100644 doc/Eqs/HADRESS_AT_pair_coul_dsf.jpg delete mode 100644 doc/Eqs/HADRESS_AT_pair_lj.png delete mode 100644 doc/Eqs/HADRESS_CG_pair_lj.png delete mode 100644 doc/Eqs/HADRESS_Switching_Function_Slab.png delete mode 100644 doc/Eqs/HADRESS_Switching_Function_Sphere.png delete mode 100644 doc/Eqs/HADRESS_System_Hamiltonian.png delete mode 100644 doc/Eqs/HADRESS_System_Potentials.png create mode 100644 doc/src/Eqs/HADRESS_AT_pair_coul_dsf.jpg rename doc/{ => src}/Eqs/HADRESS_AT_pair_coul_dsf.tex (94%) create mode 100644 doc/src/Eqs/HADRESS_AT_pair_lj.jpg rename doc/{ => src}/Eqs/HADRESS_AT_pair_lj.tex (92%) create mode 100644 doc/src/Eqs/HADRESS_CG_pair_lj.jpg rename doc/{ => src}/Eqs/HADRESS_CG_pair_lj.tex (92%) create mode 100644 doc/src/Eqs/HADRESS_Switching_Function_Cylinder.jpg rename doc/{ => src}/Eqs/HADRESS_Switching_Function_Cylinder.tex (88%) create mode 100644 doc/src/Eqs/HADRESS_Switching_Function_Slab.jpg rename doc/{ => src}/Eqs/HADRESS_Switching_Function_Slab.tex (88%) create mode 100644 doc/src/Eqs/HADRESS_Switching_Function_Sphere.jpg rename doc/{ => src}/Eqs/HADRESS_Switching_Function_Sphere.tex (88%) create mode 100644 doc/src/Eqs/HADRESS_System_Hamiltonian.jpg rename doc/{ => src}/Eqs/HADRESS_System_Hamiltonian.tex (87%) create mode 100644 doc/src/Eqs/HADRESS_System_Potentials.jpg rename doc/{ => src}/Eqs/HADRESS_System_Potentials.tex (92%) rename doc/{ => src}/JPG/HADRESS_MODEL_LAMMPS.png (100%) rename doc/{ => src}/fix_lambdah_calc.txt (98%) rename doc/{ => src}/pair_lj_hars.txt (97%) diff --git a/doc/Eqs/HADRESS_AT_pair_coul_dsf.jpg b/doc/Eqs/HADRESS_AT_pair_coul_dsf.jpg deleted file mode 100644 index 2edcc1fc5340367d4231cd02fae2a0ebcd7f43ab..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 5732 zcma)AXHZl9vyLDj9qFA=q?Z7S^d`MZk)m`6C`5r!0)&9{K&T?Usi1%$5KwyWNSEHL z^cD!cc=3JzGk5NXd*}XU&e`+q?z6k+ne*YyMn2V3CnaJe0ssJ{ni?vG008d7?en91 zcW>{9{qf4T=B|^Ht`Y!%jw8OZ#k<9KJPg&90VM;>o3{XHuVJVQ0QhkO0B=J9fQwt# z+YJD~3j_dc*#H32sQ>_-TV}0+>}>$YPFr0C@Fya!ujv*Mx@nku+**x)F0~#Pc>sW# zOjAY4*k^h-Yd0yQn=(9Sy5i2_)IH(EJC&TE#GuYtn@0>U2UHf@9GW3_UAS>q@0A$f z|LSk%2&q*FrOFDtPY)js_nx>P>nNU1`7B(vKb)TRzB`yOG-QD64Vy@;H<>ethuVOaEq}@7a?~W zj}Plz9g-Y+KiXi@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ju!ofpp;M{S<)+obJY zTCYwa7R|^%6#H#y#i~2ROk^zCt(dR1S|^xEvTlh8dOJ3 zOWPKzZ@_9gdMZ$;0Tikmt&{sd1it`JoLAVt6Oc3MN-RRluO09#=}R{{bbm7r`A9fhOX-{oErX2$5(4&if|mtZRg(RwP&r z%#!&3_P5BtvUS1#=(zklKPZUo?g=J#Pj;er13Ozy}Zj=->9b n^m{ogF7PW(z!C%SWD+jGpLG(@Zz1GgA6vlO)EZF-zj6D&>0&9; diff --git a/doc/Eqs/HADRESS_CG_pair_lj.png b/doc/Eqs/HADRESS_CG_pair_lj.png deleted file mode 100644 index 518845994a31634824469370b1a786121b777050..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2924 zcmZ`*c{tQ-8~!m!LQ)PR%h=6j8)Qy1mKb7?RFrMVHYQBQjNdSlU6zoLrDVx^lIQW;vn|#W!~p+ z#No)6W+wKuspb6DyT$#Yy^++ymUUEq}Cc?~qfxyCTxCUqzlSdv;($?_OHu6W1tV zI%#rRv83rx(9Z4A4x=Bf%VXe?u{5xLAuIG7o|<3aWbkvexkOD^n9d5D*1M1~5GPk? zAR1t$$*1y+@vZpq)ts8Jt&nNnB_2;#oR+S38v-93s4>^7X^g`_S+&ao@GfP=N$tc> zq#tF6-sF}d8UE8{Eahz`BTJ5pYhTJWZ;mwKwm2Aw9}9*bYFHzKf>8qzajf)YH)ge< zH0$=~gYzOJ!u4Fp?>b{i-8@>KHoGz-8eNO0jcY*HPJxCUDbp`5&DxNkQxVS=j_oy# z)-cgP_(JGkcwokAeNO;p#C~l>5I0(GHesZnH5bJyrpL`CbFF#1r#miKZq(9wX;)iC zcs~JJ+f^gzUhG6LIe^buPTSM+HSEWN$lL>h;;w1ZisIy%VJwe}GH>D1;(*t=@=1NW zMx2}2)?{zI-p#zBq=T%c*#L37tjM)<<_8?4?kr(FGgL;)z_U#LWr2)!*?83&4+30T zv(slprr*O`CVPNx#@ ziVE501v51AZ9igPjUkP^_?qi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@L|f(#_}&SGw|V56~vq#hi)w0*d-^ z?<`6c0<<;kf>W7#h`PRmh)Q!~8Mmrv$evkg7F+Obbciag5kD+z{Z+fK<`YXY*5Vo; z+Mo4lrpDs!Rm_c}_Kpi`vsjW`?+vloe7e^6B8~*(+8}ciIhzN z3ReJ6H?lpFxT!t({*v0I_Q~%5v><(*?=%SJsxIg_zwnys+9CTccWm_fAzuutMvq z==o8+D@j~|#jD)Yxo9xNEJbd}ob7aO+mf*HlwwDuy0L$+mk0>0dTyFQdvIfZH1D|> zl|hXC3+dZ(Ejf(n0ir;%;F)k`FRPR%k8qNC?m@T!boKiBvf1#~m9SVM*zjp=|AC0h6(^axo_0hvOe}QACQJ~s`?dJrFq&7$W-n(KU~ea z=b%UGF-?~rY2WD_3tY;RcWi2U>v1ud6hb8dT@q=VbO#uu*jwg;YVcC;PlYRAS5RdZ zj>$()nz+|c-iY^c^`>>VWKzBT{xac3kT>HM3iH7+&7m3Bz2&SpEilJh_&ro*F-STj?<3yI;c46(!6bEnn^;VfNq8L|X#^FITe(`479& B1}6Xj diff --git a/doc/Eqs/HADRESS_Switching_Function_Sphere.png b/doc/Eqs/HADRESS_Switching_Function_Sphere.png deleted file mode 100644 index 6a16b9838feb23e1d0c327a3bb7bb4094de4d02a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2540 zcmbW3=OYx31ICfPSN5v2zGakfHfP>R)}f5ESDjV%-6?#@=#0$l5E;pgIG04`iBLv1 zoii_-&E2=(zwmore4fvn=lzppX>P*CEW}JjMa2dI8(LFQQ6v7kIpdYT6kL(7`&+t} zW;R9?3gxf<-}y?nAoh368)9t^r7|43UW?%*dgm$Ggv}?FzSV2{3T_80QBg60A%-BE z2D$TqU6P~>mc)M#)zZK%On>C~#=K$s0-?4WWaHYNyZWPf2ul-(xKps6*3w8&bXUw` z{w55Af)E6^iuy+hpeKOq5=qfQplRF-CPN#^(2ar@`ilxjs?R$rml$F|VXC@(KxWlG znfFZCS4!j?n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_System_Hamiltonian.png b/doc/Eqs/HADRESS_System_Hamiltonian.png deleted file mode 100644 index 2e76b48195384051e451558ff4c0c7b927065601..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3653 zcmai1cQ_kv*N)<~X{ga3C6uIU&l=HIP*EeOnz3gPGe{Z~MN8~mvuL$7TeWJG+M}wi zy+^4{M2%Yc()YT)^~ZO8&viY|Ip;q2ea>_KJTZm_+ANI!FaiJo79F^zF#vE$isGx# z(@@?Y7QSC8hQ?K0UmXB=pU8A(PfLlZ{Ef9?fXc6Y>y!ZG2shRT03Lw>fUrma;DiE& ztpNZ5(g47Q9i>nf0Kn~&+h_!(BrZAVYHI?>PZPhiQX&Q)xP?E(!vB5m^?BR|0GQo% zG}TS8Q`>plwYf^{(E{6(0CNOQ_tk{}nvTJ+%^16etH0GaKJ(>L<iOlK5)-+*|Qggwxj8>qt1KkZ5+wC>J^okkON zuu_O7lZ#gu2kG-w%OOvwn>)I?(0SzeRqLrwj6$n#2S4`uD*OK8m6UWf2zx@{EZ~LF zoJBAN|LiP-5}w^@+KLUcB`PJZ^4y)0Po{_0?ss?cj`NS*IluafFL>$X+hk71WYD$i z43<6ov^Ip~cb|qX1?`T73dDrv*0@ZHh`?<6fI)cjEx-q4n@)w?Vh zFcsMm9_QqJQ96cw31`haeG?_dPz@Ay!q*?3!Zk58jWpboE}73P%gg-X&w67T&oM_< zr#9^TA27^=Whz%j5on3hVOqafG2A8L^>a5WO>A%7JCAu~t<%s9pQ65#Jo;&|?ca4g z-=d3(m+L+r8lL_3H*rO>H)?duT?vtjp}q$eIzAZci1@+!=bdBC1zXb5@0-9SxLZ6y zNq@ZO)peIl>7votEm?+!Bh4DqwzLkyQgHB9@tzZSYH?8A=z}20S||sdP&J{qO%S{S z5(I(08bPe0qA3w0k^F}Ge!_k_uY2;cVM&6!aDQK2qlr-?OER4}d$pWZ@|#UitF|iF z)@t0NK~!S7X(vIqm;vt^kI_Od71FHS?Jm;!43`KEfu!U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VYISeY6g5q*4*^(L~MIA^&1mrjJ26;$RTp z#ihBg7EAXq)TgxObTI`z>+tx^N1gX>sv=ppLSQ#az1s?bdQ{dwcuk zt^VYws3<}6JqLSxdwSDmb8~Z^2u>+3F0N?1F2etln$V|WV+0auniu8oyhw`bLfhS< zg$hsE@<)G{VzV;eVk~Qcf;1x_^AG7{V$53)zPGmn%CR^l`hu{`6C(X_+b+I-puLFA zV=4p+r6xD>^~w>$+3Hz((DsGY6fOVGshkrRmqPg=39GbMp?sOuXNEi-&&8!-zDL3~ z><=Ybm?P~V+H6nhj+viF(E`YH(sUibXjH^~%K9OK(K5$4*<+kl9Q~Xr1|TafqbMP* zAR#MnBCVvNAgdy;BqlAbA}w9X)THvi1ZZz3lnd_v7R;McM^gkDe>-?mN@D?FFdU=? zLZa<4ZjSbzAYG6c$kYap^1_5rJfwdB+7^$r_w;eI4*?-Pon0_UJRa$3k9KgfxBX8X zPZ6k_g#1@52EyNv0ZCB!|C1*g0{TnT(Ee{C(hue8hCzlPkszd(w^sn#!P!qu?*(P; z12F&np`*8_w;w?I->1Fcu#keY{>A;A{k=T{Feq;?%B0c>gFJb;dtfo3JlF5*7` DUK-Pm diff --git a/doc/Eqs/HADRESS_System_Potentials.png b/doc/Eqs/HADRESS_System_Potentials.png deleted file mode 100644 index 8cfcfe6124fcc1f29806a871ba474a9e3e94bcaa..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 7050 zcmb`MWl&t(w(lE)LvWV>L4wmj&_vI(xr!PThKS-sK>c1FZNMj}{LA06c!JB&P)cpjDxs zTX8T@w&Lp13~Iozd#Uyk0H}uH-& zlob2}0Pq9?0DBeyfCL->pmIgDXiB19pj)XZ$^m{y!bUn#GhA0CLwD4u^!KeW=pYRM z&@jH1d#U5IaG0~7wlF{%+}UFH=toXG5{g9&3Zo}FjCL8|*eVr3Ju=N;^r*EN`p>~6vPK6O|@ z2YHr6!{>14zX3)rfNv8rpf~qL$2ca^Rz5o*1%>ErqJ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_fB8f4{F6mN4qL3+_`P zVyYM$wVKlhM0mJjFWYB$xjqT4cAgeGXb3y%Chw;J*aDA)O zE-{A*GVG5|=Bnmveyq_Slo>6q-hn%zua^+PD2xc=iqUVL-%OCaa%_>jP+FALLa;|oEs4na z?Yd60vh(Ly4nF4bYWWY?1Tr29>bu!=BtQXUy0h0@JXGAuwM)uW6XR7EMGSI<-p-#e zOW{6$FzBo?gZz9xDN}GOrb$h=1U+irke4chrgQeHS?U6;NxI~O&%W;LpF^#;Lmn1; zLmo+UNdNewi9n+u7WeB@Sv0)63s9Xyu?bP&amKEFqlRMxw)={XzCfPO>r&;tZ-+~! z30*Oacp7td+a+dFj1eD90N$JyY=oE`-?bHZV29opUeuw`*B8s-m+Lr}GlT*NaaxhZ zXPZL&s|yRQl>P&I3!Yc=p%gOYOjCBZIO3=4RrqrcmN-M6u94{Mk#^Ks64Jevsg@OI zxYu@9-4&S9VNRFUid%S1vS^#yXH~4HVu2QFBzZ5lFYZ0(Wc7@8p3HV(m9QWK%~DkQ zIkgeb0)`9@#@0y=f})qRtWDV$J7Vi2%j(ou!;nYI&9Z1wRX*|o&d2R6VCI_F{kvw|ZkwGV)uok`Ek|D{f#xrwEt>l;fZ z6B{>AdoLyvYkPNBM@wIK4_`+c6I-Yy#9tuLUog*-{&WoD;^+be0RO(e p=3Rb7>4blDsExaeqo;?xi!-Y8z@Ofpe-6t4ujRpV6|XEp{|_8adp!UE diff --git a/doc/src/Eqs/HADRESS_AT_pair_coul_dsf.jpg b/doc/src/Eqs/HADRESS_AT_pair_coul_dsf.jpg new file mode 100644 index 0000000000000000000000000000000000000000..61399489d6af9ca18b830591b691f09532690168 GIT binary patch literal 11269 zcmch71ymf}vThH9I|K+egS)$X@Ss70YtUf90|bXKI0Q(r;4Z;ExCM6@++9O}5CWI~ z$bIMh_nx)RyZ5cvvue6$b)>mE;uV01yZOK#w2bVG)o4P?3>Q zkdaVPP*Bj&P|-07urM(&FiG&A;1EDaDWDKia&k&qb_PmnR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?>@QoAu5VaD?5p~m#*8p5%gOx1$crd2aMQ3NbouO;{>c-_L8nmk+v0NN9h+g3 z4O9nWaGKq;IO@<}8TL*0UdO~}P38=XnSY=IQ4W$7_0bjFmcx}kht7E6Ei)Yu5$xGd zRH6eL(ROrzGa^liLz3-8>H;O#5p-=~uZHZp(%4Yp^qFIi(!1*K6*v9M{$+SDuEVy} XBr_+Z5|=CL3@lQAyN!P%`sjZEDXb?D literal 0 HcmV?d00001 diff --git a/doc/Eqs/HADRESS_AT_pair_lj.tex b/doc/src/Eqs/HADRESS_AT_pair_lj.tex similarity index 92% rename from doc/Eqs/HADRESS_AT_pair_lj.tex rename to doc/src/Eqs/HADRESS_AT_pair_lj.tex index 6e28b198b0..99a251a129 100644 --- a/doc/Eqs/HADRESS_AT_pair_lj.tex +++ b/doc/src/Eqs/HADRESS_AT_pair_lj.tex @@ -1,4 +1,5 @@ \documentstyle[12pt]{article} +\pagestyle{empty} \begin{document} diff --git a/doc/src/Eqs/HADRESS_CG_pair_lj.jpg b/doc/src/Eqs/HADRESS_CG_pair_lj.jpg new file mode 100644 index 0000000000000000000000000000000000000000..71b775193006292c2d1a03dc78899e4ab34c7ca0 GIT binary patch literal 4599 zcmbW42Q*ymy2sx!!|0ua5Mszkh!&!RAc-E|AbJggFwqG^7(@xtq6S}dg2Y5GBZ3e$ zdMAk%qPHNT%-s3D@0@ebIqROa?!C`m|NXAD_p|oezxQ4LXFU&bf;bBpHB~iK0R#d7 zgmeMoG`IyQDJb9+c0U|Ei5g2o*K^nX??60vC~jmo7_6U6YoPmAiFY zMO95*L-Ve_fuWJHiK*>ZR+t41n#kW z!`9lG+SjN!XC2%fp1LUbe-cHG2Wu}$LG=>An6uWZrEJG&3hRO4cr7-yM7?kIeJ>h150YMXJ4(`aOrcb{l` zCMW5%*13r44S^Rp`__D&ADfg{DQvUS8HPNH@%uczpMqG6mln+v+?NF_LK!>Pa*9@_ zQl1>3^R@gNHLsi4>;?-L@Z0|2`KhMF(C9L0sa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tIalu+NE|64_1b| z7Gc2MimeGVE4$v@^VMR?EPMZoock}RMXCFHL92~8PG5&xx9YFhJ6kR@%ozt8SMEQL zINc5qs>mk$*8*ap?Ll(#e{NWo9xE1D-kN{Qf|efmWxwm2T}>YRiAfc>$l0a!$&G8P z05+8F&>JaVnDjw;UzE=U>mLX##;hdEP5E__4qWjx3+KqSQk$n+!?U|mRL=}qP7Kl@ zRqt@*@rP=!wej~g5^ zuu1H!(LLNGvLZz>%vl*`$S$r-%|!Q3nMtXSO%dI#E8()9z9oSKuA9mVo zo55b!S2>n)_(N|ku6J?&*$fx7sw+j#4(;@Hv4=oz? zKTl9jy+-f#jsm)idL-|F6FOjf$U@Ng9^SOhh9-jClq&B=zG=%rTvbomSM3kZ!mnr} zN-8qj7%6XL8wt$vuv{A46J^jUm}&KNwPj`2Tw*!DJP&p&*xU6N;<_8U!N+Yvp0_03 ztJUm_rS@d~!C`5B!d-+OTbXqa2F>1`u$O(W-}qW-$5NS&AK$jL&@9os+*~jszAUjQ zz81AcYW?eD0+BmcW=;@gPY%fKoDE&3Wvs!z!-7w)!|?~apCANKlZI#+pf{)jSV<-I z@A5c`sXWBCq2|wd*_St{JkyV%&~!dd1wK=7^_kpP!}O ziLEa#%BHuPTYBkPc*xgmrP>wX{eE{@rj^Rh7D1+{J|dFH-yaK~-q^CYi(UGPjjTi2oMU1$FeeE4hbu-?+L ep}88K2jZI|6`dUr?z&cLu=)4#_&=@0$^Qbg$a*pW literal 0 HcmV?d00001 diff --git a/doc/Eqs/HADRESS_CG_pair_lj.tex b/doc/src/Eqs/HADRESS_CG_pair_lj.tex similarity index 92% rename from doc/Eqs/HADRESS_CG_pair_lj.tex rename to doc/src/Eqs/HADRESS_CG_pair_lj.tex index 86194536fc..c66fb30105 100644 --- a/doc/Eqs/HADRESS_CG_pair_lj.tex +++ b/doc/src/Eqs/HADRESS_CG_pair_lj.tex @@ -1,4 +1,5 @@ \documentstyle[12pt]{article} +\pagestyle{empty} \begin{document} diff --git a/doc/src/Eqs/HADRESS_Switching_Function_Cylinder.jpg b/doc/src/Eqs/HADRESS_Switching_Function_Cylinder.jpg new file mode 100644 index 0000000000000000000000000000000000000000..e7dda32d4daa4f0768c955531ff890c7cdb1d12b GIT binary patch literal 7257 zcmbuD1yqz>yZ7&5Xa;HN9;Ca5MvwtSx)ns4p@#+o5DDo}P$Z;#kQ`D;rIfCrJEajM zKYX9}J>U7Bv(~rXbI!ikb;r8*+H3#TUi-TK`+q%gJr9uHhpWQ@5C{N3Hy3a{1t6R&cMJW$;~GuEG8z# z%qb-Y6Ok1V6%+Y02#A1y073+zAtt5~VP#+y`ER%D7Jv*NumKH$L2LjP83;@Uy6ym& zZ{~>u`bPu)*+5ueY#dxXd;&tEn+`Rk02T-g#=-{U;9z6l^nQNxAHXKVA!il7i%X$v ziN}Vd6bVkq!e>{iXr<tMZ(L+ITv*uHU~IfUTp%ppn*ftxg`ck zc?=TXhKen4?EgXg2id;|_VRy3_8(yXmkR?xz@VGO1Cs#?z{wd`b`as;0@fe#`A+k| z(H60!Dvx-X+M>yc{v@-$oJFuJ zMR(qi)7Sl-f?-Q&3@TOue`|OhD5gW9^VgGCpTl=xr0g)fWLw>2R#i?g3df?OlOJ;o9rZfFY&7BiSur+{(h>&CR4dODWh9y*n$#bww)(ZVKi#pn z(^J0=UmTYVimO^al6NSr;k5mX5m26r{g&@ZfL(&zO!5bT93%~nOSXGn{jps5V~~8% zxMW_(XCc)j{c)T&){X|l%O0QA3R)?m2Zzc1} zelTKQvO?-t$tX@Z<&=!#}P=1g}#eY{@~YzF}>6CAL|*X?PK*^zcIK)R)g) zZNJmg!^T@r3CSd)s`Ylm3oxRNx|)&TAoZG0i0jrS5~ZGh2F zN>KkPzgt-oZ$1JOmV&fKTHE6^{;s^YFsZ}MqdOHHd%DT{F*_3A`d8%h4a%0&sl`D3 zX0w8MGu|^69Ra#(YKD9r0Is@Rkpqw&$@N#n#}}JM0FcC|dWk?cj1tg&5NWdZnj=gl zQBtRC-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#6VEw|%?+>`e|pDlHXEP_O#iH@mO8z!;|K=qx*a!~D;NxW{T3OX>lys0 zC$Cue!?ZHM9d9%gF-|R4(YSw{pXHg;)y?!Sn{mL#f2d1x$N34RNlMZBv^@-UQ!O zD2^lSy*0GQRKe%4r&V$7rJ=QT>{RO!3dtvklBbwy^O}0|IZz^yWATag({La6iY3lo zQ!QNigFO*0@UZ6(nL#t(@Kk=)uMO#=b#ERbjNB3N{t-RC%(LAmL2?jgaLT9nT>_?%qs&i&%R6L9Nh3 b)e2gSDo2!Py%b-cKlCiM=D%Wrt|$Kw7RFVY literal 0 HcmV?d00001 diff --git a/doc/Eqs/HADRESS_Switching_Function_Cylinder.tex b/doc/src/Eqs/HADRESS_Switching_Function_Cylinder.tex similarity index 88% rename from doc/Eqs/HADRESS_Switching_Function_Cylinder.tex rename to doc/src/Eqs/HADRESS_Switching_Function_Cylinder.tex index bd6b156c03..d45783ab91 100644 --- a/doc/Eqs/HADRESS_Switching_Function_Cylinder.tex +++ b/doc/src/Eqs/HADRESS_Switching_Function_Cylinder.tex @@ -1,4 +1,5 @@ \documentclass[12pt]{article} +\pagestyle{empty} \begin{document} @@ -12,4 +13,4 @@ \right. \end{eqnarray*} -\end{document} \ No newline at end of file +\end{document} diff --git a/doc/src/Eqs/HADRESS_Switching_Function_Slab.jpg b/doc/src/Eqs/HADRESS_Switching_Function_Slab.jpg new file mode 100644 index 0000000000000000000000000000000000000000..b9f03bf571e733e42eb8eacb2295b8e593e853ad GIT binary patch literal 9792 zcmb_?bx>T*w(lNnkU@h4_dw9#ZXtLG?(P=cAxKC91eX8_?hq{K3>sX6GuYr3oB+Xs z&Eq@w-E(h!=lpT+tJk~MuIjy4b@i|M*K4g_tC4faRe(TQUP&GRfdByX@BqjKKo-En zzyM>QV}ik8EG$fH2r(`M2M0n<^a!7rnu3;wnu3aoj){wfj)8-bii%a}DaSJ&etv#h z77+(o@m%{;wOd10ci%tWmg7K@0#2AqbTagzN!m zALfY;`bPu)Zv&yA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kf zLDu1N!SY#n#?|jP{W5?ErKPUodJZQzsT-R3Zk|K>F%&;w%n{D7{&OZOwrpNGx z)G-;wQuv69om)!u!K2KNWzqoe`*E>L5>302)YElzBKqRl!#a5SCB%=H_bHY2#v}Bv z6KbOv;<6>vu8tSK*^O-(_vqQ>mznbnhM&n5Ad)^5E+WcJEO!OWdPPYze|9l%N0Z!D zq>>dabTaNnUKUxew7hzru@T>P04Ie zI+|Mk+)=Rl{DVZoB1Oj_ExUrq4z`Vb-FLwM8VGqNgIILK>GlseA-bLQTzuwZ%rAO} zX9ryg*MK{z2(p_vdQW(LWkjUt32g(Gzqql+aM{uGJN=q9*pDzu@v0e(27u^pr~g=$ zrT6pvt$2%#6VEw|%?+>`e|pDlHXEP_O#iH@mO8z!;|K=qx*a!~D;NxW{T3OX>lys0 zC$Cue!?ZHM9d9%gF-|R4(YSw{pXHg;)y?!Sn{mL#f2d1x$N34RNlMZBv^@-UQ!O zD2^lSy*0GQRKe%4r&V$7rJ=QT>{RO!3dtvklBbwy^O}0|IZz^yWATag({La6iY3lo zQ!QNigFO*0@UZ6(nL#t(@Kk=)uMO#=b#ERbjNB3N{t-RC%(LAmL2?jgaLT9nT>_?%qs&i&%R6L9Nh3 b)e2gSDo2!Py%b-cKlCiM=D%Wrt|$Kw7RFVY literal 0 HcmV?d00001 diff --git a/doc/Eqs/HADRESS_Switching_Function_Sphere.tex b/doc/src/Eqs/HADRESS_Switching_Function_Sphere.tex similarity index 88% rename from doc/Eqs/HADRESS_Switching_Function_Sphere.tex rename to doc/src/Eqs/HADRESS_Switching_Function_Sphere.tex index bd6b156c03..d45783ab91 100644 --- a/doc/Eqs/HADRESS_Switching_Function_Sphere.tex +++ b/doc/src/Eqs/HADRESS_Switching_Function_Sphere.tex @@ -1,4 +1,5 @@ \documentclass[12pt]{article} +\pagestyle{empty} \begin{document} @@ -12,4 +13,4 @@ \right. \end{eqnarray*} -\end{document} \ No newline at end of file +\end{document} diff --git a/doc/src/Eqs/HADRESS_System_Hamiltonian.jpg b/doc/src/Eqs/HADRESS_System_Hamiltonian.jpg new file mode 100644 index 0000000000000000000000000000000000000000..4b3780d3e922dfa7b287b30c30035336906e5f96 GIT binary patch literal 5403 zcmb`K2T)Vrm&acSBte=~>7j%UL7Md9j~`u{(h`~=y@-_16lo$5q(e}ocZJXi9l; zV0zG5F91KECk5y)1OC-OWMFa%2oy$nf$H3$=^{V|0)xrO!4wqadI|mPRzGLC*xlowbov9hrX2nq>{h|0=ckylVu()?3P zTSr$<|Av{lg{2h=eap$&#nsK-!#@BM7!({58vP*VVQgGHHZ46P6PNY)Np?|jNoiSm z#k1%24UJ8N=9bpBm&D#zef*wsf&wKpqETE)Y9AVv??U)|@@r^F8IW5u34Sf3Xh790sku1};|CE#?K z^;9vvBW74N(^Z@KGM($=7r&4vQGk@#>u8`1^Q z8r+du&epc>M?nu4+6c`_R8ki@OsxBuxDG|17lRSCK#*Yl{tM_j+C2AU^}w)p)F*l< z(E9@JX|9E4Jlb+z2i!$I83hLS1c zxEtR7eZNLlN$bltkyV_#Z{24bX{L8fuowB}Od}J+FIpFmFu9|)-fuJhy)=31l*i_0 zs8{L~GN0=?bKFlqr}p-S00rJl zgWYYxR0P70toNJLVFg|Z=q1_5<2!f@hN|pP^S0K14kB3Mss`vd;#@dgxsJyJ)0aaq zZ;_vFjHrm=ZKh_CYo#c!2>!L((sYh=d~FE{!MC?c2`%vg56wgnx24&1d&ol_JFK-@ zo-V8=TN5XS6?bqAylH()ny(sT6H87tj=g=*zoq1(H7;HOeuj}Zh$m3Z33KOVPqaz>f**fXoiswhZGuN0uvF3W; z={wJ(+$9n$bqQyMf!@0Lz*o%J+x@+@xDoEnUSLFrZjk z%_4bNt|lSZ_6x_&-zZ%~%VbOZQL9AuF~#^98u(UGgaw3aq<2n}%iQxhRWzy5m=fQ;MgIT<`n=Zk*GSp=TU!zV8;?CgU+ zPAGaV`3Eh>?=v@(%`5Z!Ws#o&RnFM_p{yI1DdcBjn9htNSzI2#*|_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S&>#f;9&I%x=1Q<7RxsyvwuJ=FcFm3H$8XiTP2Q_uC(hN3ETdG*!^V$m-rYsv@*@gE@7mmjtKMW22(mT?v;J+~N|7GI;t>feT F{{cefgF65K literal 0 HcmV?d00001 diff --git a/doc/Eqs/HADRESS_System_Potentials.tex b/doc/src/Eqs/HADRESS_System_Potentials.tex similarity index 92% rename from doc/Eqs/HADRESS_System_Potentials.tex rename to doc/src/Eqs/HADRESS_System_Potentials.tex index 821df897ad..ecae7d0bcc 100644 --- a/doc/Eqs/HADRESS_System_Potentials.tex +++ b/doc/src/Eqs/HADRESS_System_Potentials.tex @@ -1,5 +1,6 @@ \documentclass[12pt]{article} +\pagestyle{empty} \begin{document} \begin{eqnarray}\label{hadress_V} @@ -7,4 +8,4 @@ && V^{CG}_\alpha \equiv \displaystyle\frac{1}{2}\sum_{\beta,\beta\neq \alpha}^{N} V^{CG}(|\textbf{R}_\alpha - \textbf{R}_\beta|) \end{eqnarray} -\end{document} \ No newline at end of file +\end{document} diff --git a/doc/JPG/HADRESS_MODEL_LAMMPS.png b/doc/src/JPG/HADRESS_MODEL_LAMMPS.png similarity index 100% rename from doc/JPG/HADRESS_MODEL_LAMMPS.png rename to doc/src/JPG/HADRESS_MODEL_LAMMPS.png diff --git a/doc/fix_lambdah_calc.txt b/doc/src/fix_lambdah_calc.txt similarity index 98% rename from doc/fix_lambdah_calc.txt rename to doc/src/fix_lambdah_calc.txt index 178f727d16..848a9a4716 100644 --- a/doc/fix_lambdah_calc.txt +++ b/doc/src/fix_lambdah_calc.txt @@ -60,11 +60,11 @@ Depending on the shape of the Hybrid region which might be either slab, sphere o the resolution of every atom based on the center of mass of its molecule. The following switching function is defined for a simulation box whose atomistic region is limited to \[-0.5LAT 0.5LAT\]: -:c,image(Eqs/HADRESS_Switching_Function_Slab.png) +:c,image(Eqs/HADRESS_Switching_Function_Slab.jpg) The following switching function is defined for a spherical/cylinderical atomistic region located at the middle of the simulation box: -:c,image(Eqs/HADRESS_Switching_Function_Sphere.png) +:c,image(Eqs/HADRESS_Switching_Function_Sphere.jpg) A setup of a Hamiltonian Adaptive Resolution Simulation is shown below. The box is partitioned into three different region types, namely: Coarse-grained (CG), Hybrid (HY), and Atomistic (AT). In each region, diff --git a/doc/pair_lj_hars.txt b/doc/src/pair_lj_hars.txt similarity index 97% rename from doc/pair_lj_hars.txt rename to doc/src/pair_lj_hars.txt index 7813f40aa2..4b91d41ee2 100644 --- a/doc/pair_lj_hars.txt +++ b/doc/src/pair_lj_hars.txt @@ -56,7 +56,7 @@ pair_style hybrid/overlay lj/cut/hars/cg 1.1224 1 0 lj/cut/hars/at 1.5 1 0 In the H-AdResS scheme, the description of the interactions within a system of particles is given in terms of a global Hamiltonian function H, which has the following form "(Potestio2013_1)"_#Potestio2013_1, "(Potestio2013_2)"_#Potestio2013_2, "(Heidari2016)"_#Heidari2016: -:c,image(Eqs/HADRESS_System_Hamiltonian.png) +:c,image(Eqs/HADRESS_System_Hamiltonian.jpg) The term K is the atomistic kinetic energy, and Vint consists of all the intramolecular bonded interactions (e.g. bond stretching). The value of the switching function is determined by the sizes LAT @@ -65,12 +65,12 @@ LHY of the atomistic and hybrid regions, respectively, and of the spe In the Hamiltonian, the non-bonded potential energy contribution of each molecule is given by a weighted sum of two terms VαCG and VαAT, defined as: -:c,image(Eqs/HADRESS_System_Potentials.png) +:c,image(Eqs/HADRESS_System_Potentials.jpg) The {lj/cut/hars/at} styles compute the standard 12/6 Lennard-Jones potential for the atoms located in atomistic (high resolution) and hybrid region. The general formula is given by -:c,image(Eqs/HADRESS_AT_pair_lj.png) +:c,image(Eqs/HADRESS_AT_pair_lj.jpg) rc is the cutoff. @@ -87,7 +87,7 @@ summation. The {lj/cut/hars/cg} styles compute the standard 12/6 Lennard-Jones potential for the atoms located in the low resolution (coarse-grained) and hybrid region. The general formula is given by -:c,image(Eqs/HADRESS_CG_pair_lj.png) +:c,image(Eqs/HADRESS_CG_pair_lj.jpg) rc is the cutoff. As mentioned above, the interactions in the coarse-grained region are computed based on the center of mass of the particles. From 9a31a54693198255025a06b824eb1af267ac26c3 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Fri, 24 Jun 2016 14:29:42 -0400 Subject: [PATCH 15/15] fix a few small issues on USER-HADRESS docs. still much more work to do. --- doc/src/fix_lambdah_calc.txt | 4 ++-- doc/src/pair_lj_hars.txt | 10 ++++------ 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/doc/src/fix_lambdah_calc.txt b/doc/src/fix_lambdah_calc.txt index 848a9a4716..4c264b32b8 100644 --- a/doc/src/fix_lambdah_calc.txt +++ b/doc/src/fix_lambdah_calc.txt @@ -78,9 +78,9 @@ coarse-grained water molecules in the coarse-grained region, this number equals water molecules and ions such as Na and Cl and they interact differently in the coarse-grained region, this number is 3. -The {LHY} specifies the length of the Hybrid region. For the cases of cylinderical or spherical hybrid regions, this quantity denotes {rHY}. +The {LHY} specifies the length of the hybrid region. For the cases of cylinderical or spherical hybrid regions, this quantity denotes {rHY}. -The {LAT} determines the length of Atomistic region. For the cases of cylinderical or spherical hybrid regions, this quantity denotes {rAT}. +The {LAT} determines the length of atomistic region. For the cases of cylinderical or spherical hybrid regions, this quantity denotes {rAT}. The {Pflag} switches off and on the constant-pressure route. diff --git a/doc/src/pair_lj_hars.txt b/doc/src/pair_lj_hars.txt index 4b91d41ee2..8ded669048 100644 --- a/doc/src/pair_lj_hars.txt +++ b/doc/src/pair_lj_hars.txt @@ -14,11 +14,8 @@ pair_style lj/cut/hars/cg command :h3 pair_style style args :pre -style = :l - {lj/cut/hars/at} or - {lj/cut/coul/dsf/hars/at} or - {lj/cut/hars/cg} :pre -args = list of arguments for a particular style :l +style = {lj/cut/hars/at} or {lj/cut/coul/dsf/hars/at} or {lj/cut/hars/cg} +args = list of arguments for a particular style :ul {lj/cut/hars/at} args = cutoff All_AT Flag_Load_File cutoff = global cutoff for Lennard Jones interactions (distance units) All_AT = Fully atomic simulation flag, = {0} or {1} @@ -44,7 +41,8 @@ args = list of arguments for a particular style :l {1} Fully coarse-grained simulation is on and HAdResS is off Flag_Load_File = Flag of employing compensation energy file, = {0} or {1} {0} Do not employ compensation energy until TpStart - {1} Employ compensation energy file immediately :pre + {1} Employ compensation energy file immediately +:pre [Examples:]

  • LAMMPS WWW Site - LAMMPS Documentation - LAMMPS Commands +