y0=[r(LeadingBeadidx:LastBeadidx+1,:),v(LeadingBeadidx:LastBeadidx+1,:),...
sigmau(LeadingBeadidx:LastBeadidx+1)];
y0=reshape(y0,[],1);
[t,YSol]=ode45(@(t,y) MasterODE(t,y,m(LeadingBeadidx:LastBeadidx+1),...
e(LeadingBeadidx:LastBeadidx+1),alpha,E,G,mu,InitSegV),...
[0,dt],y0,ODEoptions);
YSol=reshape(YSol(t==dt,:),[],7);
function dVardt= MasterODE(t,Var,m,e,alpha,E,G,mu,InitSegV)
GPUCompute=numel(Var)>=700 && gpuDeviceCount>=1;
if GPUCompute
try
Var=gpuArray(Var);
m=gpuArray(m);
e=gpuArray(e);
catch
end
end
Var=reshape(Var,[],7);
r=Var(:,1:3);
v=Var(:,4:6);
sigmau=Var(:,7);
f=Viscoelastic(au,sigmau,dispu,lu)-Viscoelastic(ad,sigmad,dispd,ld);
f=f+SurfaceTension(au,ad,r,dispcross,dispu,dispd,alpha);
f=f+ExternalField(e,E);
f=f+InterElectric(e,r);
drdt=v;
dvdt=f./m;
dsigmaudt=(G./lu).*dludt-(G./mu).*sigmau;
dVardt=[drdt,dvdt,dsigmaudt];
dVardt(isnan(dVardt))=0;
dVardt=reshape(dVardt,[],1);
if GPUCompute
dVardt=gather(dVardt);
end
end
...
Warning: Matrix is singular, close to singular or badly scaled. Results may be inaccurate. RCOND = NaN.
Warning: Matrix is singular, close to singular or badly scaled. Results may be inaccurate. RCOND = NaN.
Warning: Matrix is singular, close to singular or badly scaled. Results may be inaccurate. RCOND = NaN.
Warning: Failure at t=0.000000e+00. Unable to meet integration tolerances without reducing the step size below the smallest
value allowed (7.905050e-323) at time t.