This notebook simulates a dilute solution of nd = 5000 independent, non-interacting dumbbells (two beads joined by a nonlinear FENE spring) by Brownian dynamics. A simple shear flow is switched on suddenly and the time evolution of the viscosity, η, the first normal stress coefficient and the second normal stress coefficient is followed, together with their steady-state values as a function of . The results are compared with the figures of Ref. 1 (Binous and Phillips, JNNFM, 1999).
Ψ
1
Ψ
2
λ
γ
Model and numerical scheme
Every bead i moves according to dr_i = (u(r_i) + F_i) dt + Sqrt[2 dt] N(0,1) per Cartesian component (Euler-Maruyama scheme), where u = (Gs*y, 0, 0) is the imposed shear flow and F_i the spring force. With Q = r2 - r1 and Q^2 the squared extension, the spring force on bead 1 is F = k Q/(1 - Q^2/CL) (FENE, CL = L^2 = 10) and on bead 2 it is -F. The relaxation time is lambda = SL = 1/(4 k) = 1/12, so = G*SL. If a dumbbell would exceed the maximum extension in a finite step, Q^2 is reset to CL - 0.05.
Every bead i moves according to dr_i = (u(r_i) + F_i) dt + Sqrt[2 dt] N(0,1) per Cartesian component (Euler-Maruyama scheme), where u = (Gs*y, 0, 0) is the imposed shear flow and F_i the spring force. With Q = r2 - r1 and Q^2 the squared extension, the spring force on bead 1 is F = k Q/(1 - Q^2/CL) (FENE, CL = L^2 = 10) and on bead 2 it is -F. The relaxation time is lambda = SL = 1/(4 k) = 1/12, so
λ
γ
Material functions (normalisation of Eqs. 19-21 of Ref. 1)
From the averages over the dumbbells: η = <Fx Qy>/(); = <Fx Qx - Fy Qy>/(2 ()^2); = <Fy Qy - Fz Qz>/(2 ()^2). Time is shown as t/λ, where t is measured from the start of the shear.
From the averages over the dumbbells: η = <Fx Qy>/(
λ
γ
Ψ
1
λ
γ
Ψ
2
λ
γ
Structure of the notebook
1) Parameters and random-number generator.
2) Check that the Brownian displacements have mean 0 and variance 2 dt.
3) init[]: random initial dumbbells.
4) step[Gs]: one time step; it returns the stress-related averages.
5) Three start-up runs: G=60 (lambda*gdot=5, green), G=96 (lambda*gdot=8, red) and G=12 (lambda*gdot=1, blue); after each run η, and are plotted versus t/λ, because the next run overwrites the variables Vis, N1, N2, tl.
6) Overlay of the three runs.
7) steady[lg] and fig3: steady-state values for several, tabulated, plotted and laid over the corresponding figure of Ref. 1. Each run takes nequil + nsteps = 15500 steps for 5000 dumbbells; the fig3 cell performs 8 runs and is the slowest.
1) Parameters and random-number generator.
2) Check that the Brownian displacements have mean 0 and variance 2 dt.
3) init[]: random initial dumbbells.
4) step[Gs]: one time step; it returns the stress-related averages.
5) Three start-up runs: G=60 (lambda*gdot=5, green), G=96 (lambda*gdot=8, red) and G=12 (lambda*gdot=1, blue); after each run η,
Ψ
1
Ψ
2
6) Overlay of the three runs.
7) steady[lg] and fig3: steady-state values for several
λ
γ
Parametersnd = number of dumbbells (nb = 2×nd beads). Maximum extension squared =10 and L≈3.16 and spring constant k=3 give =10 in units of the Hookean equilibrium length (RL=1), as in the paper by Binous and Phillips (=3.16). SL is the time constant lambda=1/(4k). G is the shear rate, so lambda*gdot = G*SL (G=60 → 5; G=72 → 6, G=12 → 1 and G=96 → 8).Reference:[1] H. Binous and R. J. Phillips, “Dynamic Simulation of One and Two Particles Sedimenting in Viscoelastic Suspensions of FENE Dumbbells,” Journal of Non-Newtonian Fluid Mechanics, vol. 83, pp. 93-130, 1999. DOI: https://doi.org/10.1016/S0377-0257(98)00141-4
2
L
2
L
L
In[]:=
(*Numberofdumbbells(nd)andnumberofbeads(nb=2×nd)*)nd=5000;nb=2nd;(*RL=initialdumbbelllength;RV=half-sizeofthecubicboxfortheinitialbeadpositions;CL=L^2,themaximumextensionsquared(FENE);k=springconstant*)RL=1;RV=10;CL=10;k=3;(*dt=timestepoftheEuler(Euler-Maruyama)scheme*)dt=0.0001;(*Numberofstepsofeachstage:equilibrationatzeroshear(nequil)andproductionundershear(nsteps)*)nequil=500;(*zero-shearequilibrationsteps,t=0.5=6lambda*)nsteps=15000;(*productionsteps,t/lambdaupto18*)(*SL=lambda=1/(4k),therelaxationtime;solambda*gdot=G*SLandthedimensionlesstimeist/lambda=t/SL*)SL=1/(4k);(*ra=random-numbergenerator(aneural-netlayerusedasafastvectorisedsampler):ra[]returns3nbindependentN(0,1)numbers,oneforeachcoordinateofeachbead*)ra=RandomArrayLayer[NormalDistribution[],"Output"->3nb];
Check of the Brownian displacements (variance should be 2 dt).
In[]:=
(*DrawonesetofBrowniandisplacementsSqrt[2dt]N(0,1)forallbeadcoordinates*)gdisp=Sqrt[2dt]ra[];(*Output:{numberofsamples,mean(shouldbe~0),variance,expectedvariance2dt}*){Length[gdisp],Mean[gdisp],Variance[gdisp],2dt}
Out[]=
{30000,-0.000114221,0.000200563,0.0002}
Initial position of the dumbbells: bead 1 at random in a box of half-size RV, bead 2 at distance RL in a random direction. Odd entries of xd,yd,zd are bead 1, even entries are bead 2.
In[]:=
(*init[]:(re)initialisetheglobalbeadcoordinatelistsxd,yd,zd(lengthnb=2nd)withafreshrandomensembleofdumbbells*)init[]:=Module[{x1,y1,z1,cz,phi,sn},(*Bead1ofeverydumbbell:uniformrandompositioninthecube[-RV,RV]^3*)x1=RV(2RandomReal[{0,1},nd]-1);y1=RV(2RandomReal[{0,1},nd]-1);z1=RV(2RandomReal[{0,1},nd]-1);(*Randomdirectionontheunitsphere:cz=cos(theta)uniformin[-1,1],phiuniformin[0,2Pi),sn=sin(theta)*)cz=2RandomReal[{0,1},nd]-1;phi=2PiRandomReal[{0,1},nd];sn=Sqrt[1-cz^2];(*Interleavethebeads:oddentries=bead1,evenentries=bead2=bead1+RL*(unitvector),soeverydumbbellstartswithlengthRL*)xd=Riffle[x1,x1+RLsnCos[phi]];yd=Riffle[y1,y1+RLsnSin[phi]];zd=Riffle[z1,z1+RLcz];];
One Euler step (shear rate Gs). Spring force on bead 1 is k Q/(1-Q^2/CL) (FENE), on bead 2 the opposite. Bead velocity = imposed shear flow (u_x = Gs*y) + spring force; plus a random displacement Sqrt[2 dt]*N(0,1). Returns the dumbbell averages {<Fx Qx>,<Fy Qy>,<Fz Qz>,<Fx Qy>}.
In[]:=
(*step[Gs]:advancealldumbbellsbyonetimestepinsimpleshearflowu=(Gs*y,0,0);Gs=0givesastepwithoutflow(equilibration)*)step[Gs_]:=Module[{x1,x2,y1,y2,z1,z2,qx,qy,qz,d,f,fx,fy,fz,gd,gx,gy,gz,ux,uy,uz},(*Unpackcoordinates:entries1;;-1;;2arebead1,entries2;;-1;;2arebead2ofeachdumbbell*)x1=xd[[1;;-1;;2]];x2=xd[[2;;-1;;2]];y1=yd[[1;;-1;;2]];y2=yd[[2;;-1;;2]];z1=zd[[1;;-1;;2]];z2=zd[[2;;-1;;2]];(*ConnectorvectorQ=r2-r1ofeverydumbbell*)qx=x2-x1;qy=y2-y1;qz=z2-z1;(*d=Q^2,thesquaredextensionofeverydumbbell*)d=qx^2+qy^2+qz^2;(*Safeguard:whereQ^2exceedsCL(possibleafterafiniteEulerstep)resetittoCL-0.05sotheFENEforcestaysfiniteandpositive*)d=Map[If[#>CL,CL-0.05,#]&,d];(*FENEspringcoefficientf=k/(1-Q^2/CL):theforceonbead1isf*Q(towardsbead2),theforceonbead2is-f*Q*)f=k/(1-d/CL);fx=fqx;fy=fqy;fz=fqz;(*BrowniandisplacementsSqrt[2dt]N(0,1),storedas(x,y,z)triplets;thenextthreelinessplitthemintox,y,zparts(stride3)*)gd=Sqrt[2dt]ra[];gx=gd[[1;;-1;;3]];gy=gd[[2;;-1;;3]];gz=gd[[3;;-1;;3]];(*Beadvelocities:imposedshearflowu_x=Gs*yplusthespringforce(+onbead1,-onbead2);Rifflere-interleavesbead1andbead2*)ux=Riffle[Gsy1+fx,Gsy2-fx];uy=Riffle[fy,-fy];uz=Riffle[fz,-fz];(*Euler-Maruyamaupdate:r(t+dt)=r(t)+dt*velocity+Browniandisplacement*)xd=xd+dtux+gx;yd=yd+dtuy+gy;zd=zd+dtuz+gz;(*Returnthedumbbellaverages(computedwiththeQandFofthestartofthestep){<FxQx>,<FyQy>,<FzQz>,<FxQy>}*){Total[fxqx],Total[fyqy],Total[fzqz],Total[fxqy]}/nd];
Run: equilibrate at zero shear, then apply the shear suddenly (G=60, lambda*gdot=5, as in Fig. 1). Normalization as in Eqs. 19-21:
eta = <Fx Qy>/(lambda gdot), Psi1 = <Fx Qx - Fy Qy>/(2 (lambda gdot)^2), Psi2 = <Fy Qy - Fz Qz>/(2 (lambda gdot)^2).
eta = <Fx Qy>/(lambda gdot), Psi1 = <Fx Qx - Fy Qy>/(2 (lambda gdot)^2), Psi2 = <Fy Qy - Fz Qz>/(2 (lambda gdot)^2).
In[]:=
(*Shearrateincodeunits:lambda*gdot=G*SL=60/12=5*)G=60;(*Normalisationfactors:SNN=2(lambdagdot)^2forPsi1,Psi2;SNV=lambdagdotfortheviscosity*)SNN=2(SLG)^2;SNV=GSL;(*Newrandomensembleofdumbbells*)init[];(*Equilibrateatzeroshear*)Do[step[0],{nequil}];(*Checkoftheequilibriumstate:meansquaredextension<Q^2>ofthedumbbells*)Print["equilibrium <Q^2> (FENE-P estimate 0.857): ",Mean[(xd[[2;;-1;;2]]-xd[[1;;-1;;2]])^2+(yd[[2;;-1;;2]]-yd[[1;;-1;;2]])^2+(zd[[2;;-1;;2]]-zd[[1;;-1;;2]])^2]];(*Production:applytheshearsuddenly;res[[n]]={<FxQx>,<FyQy>,<FzQz>,<FxQy>}atstepn*)res=Table[step[G],{nsteps}];(*Viscosityeta=<FxQy>/(lambdagdot)*)Vis=res[[All,4]]/SNV;(*FirstnormalstresscoefficientPsi1=<FxQx-FyQy>/(2(lambdagdot)^2)*)N1=(res[[All,1]]-res[[All,2]])/SNN;(*SecondnormalstresscoefficientPsi2=<FyQy-FzQz>/(2(lambdagdot)^2)*)N2=(res[[All,2]]-res[[All,3]])/SNN;(*Dimensionlesstimet/lambdaafterthestartofshear*)tl=Range[nsteps]dt/SL;
equilibrium <Q^2> (FENE-P estimate 0.857): 0.92445
Plotting the viscosity vs t/lambda (compare paper Fig. 1: overshoot ~0.65 near t/lambda~0.9, plateau ~0.53 for lambda*gdot=5).
In[]:=
(*Viscosityetaversust/lambdaonalog-linearscale(greencurve:G=60,lambda*gdot=5).Theplotisstoredsothatthethreerunscanbeoverlaidlater*)p1=ListLogLinearPlot[Transpose[{tl,Vis}],PlotRange->All,PlotStyle->RGBColor[0,0.6,0],Frame->True,FrameLabel->{"t/λ","η"}];
Plotting the first normal stress coefficient (paper Fig. 2: ~0.27 peak, plateau ~0.245 for lambda*gdot=5).
In[]:=
(*FirstnormalstresscoefficientPsi1versust/lambdaonalog-linearscale(greencurve:G=60,lambda*gdot=5).Theplotisstoredsothatthethreerunscanbeoverlaidlater*)p1b=ListLogLinearPlot[Transpose[{tl,N1}],PlotRange->All,PlotStyle->RGBColor[0,0.6,0],Frame->True,FrameLabel->{"t/λ",""}];
Ψ
1
Second normal stress (should be ~0).
In[]:=
(*SecondnormalstresscoefficientPsi2versust/lambdaonalog-linearscale(greencurve:G=60,lambda*gdot=5).Theplotisstoredsothatthethreerunscanbeoverlaidlater*)p1c=ListLogLinearPlot[Transpose[{tl,N2}],PlotRange->All,PlotStyle->RGBColor[0,0.6,0],Frame->True,FrameLabel->{"t/λ",""}];
Ψ
2
In[]:=
(*Secondrun:G=96giveslambda*gdot=G*SL=8*)G=96;(*SameprocedureasforG=60:normalisation,equilibrationatzeroshear,suddenshear,thenviscosity,Psi1,Psi2andt/lambda(resultsoverwriteVis,N1,N2,tl)*)SNN=2(SLG)^2;SNV=GSL;init[];Do[step[0],{nequil}];Print["equilibrium <Q^2> (FENE-P estimate 0.857): ",Mean[(xd[[2;;-1;;2]]-xd[[1;;-1;;2]])^2+(yd[[2;;-1;;2]]-yd[[1;;-1;;2]])^2+(zd[[2;;-1;;2]]-zd[[1;;-1;;2]])^2]];res=Table[step[G],{nsteps}];Vis=res[[All,4]]/SNV;N1=(res[[All,1]]-res[[All,2]])/SNN;N2=(res[[All,2]]-res[[All,3]])/SNN;tl=Range[nsteps]dt/SL;
Plotting the viscosity vs t/lambda (compare paper Fig. 1: overshoot ~ 0.66 near t/lambda~ 0.9, plateau ~ 0.44 for lambda*gdot=8).
Plotting the first normal stress coefficient (paper Fig. 2: ~ 0.18 peak, plateau ~ 0.16 for lambda*gdot=8).
Second normal stress (should be ~0).
Plotting the viscosity vs t/lambda (compare paper Fig. 1: overshoot ~ 0.82 near t/lambda ~ 5, plateau ~ 0.81 for lambda*gdot=1).
Plotting the first normal stress coefficient (paper Fig. 2: ~ 0.63 peak, plateau ~ 0.62 for lambda*gdot=1).
Second normal stress (should be ~0).
steady values for several lambda*gdot.
Steady-state averages (drop everything before t/lambda=5) and overshoot peak (15-point moving average).
Comparison with Ref . 1 (Binous and Phillips, JNNFM, 1999)