def plot_traj2d(ax, sol, length, nskip=100): sol = sol[::nskip] x, y = pos_(sol).T b = length/2. pt0 = pos_(sol) pt1 = np.array([pos_(s) + pct.rot2d(tht_(s)).dot([ b, 0]) for s in sol]) pt2 = np.array([pos_(s) + pct.rot2d(tht_(s)).dot([-b, 0]) for s in sol]) for (x0, y0), (x1, y1), (x2, y2) in zip(pt0, pt1, pt2): ax.plot([x0, x1], [y0, y1], 'r-', lw=2) ax.plot([x0, x2], [y0, y2], 'g-', lw=2) ax.plot(x, y, 'k:', lw=2) return ax
def torque_dep2d(u, params): R, (x, y) = pct.rot2d(tht_(u)), pos_(u) Kcm = np.diag([params.cmf_long, params.cmf_short]) E_12 = R.dot(params.elecf(x, y)) dip = params.vol*params.eps_f*Kcm.dot(E_12) return np.cross(dip, E_12)
def force_drag2d(u, params): r, r2 = params.r, params.r2 if r > 1: K22 = 16*(r2-1)/((2*r2-3)*log(r+sqrt(r2-1))/sqrt(r2-1) + r) K11 = 8*(r2-1)/((2*r2-1)*log(r+sqrt(r2-1))/sqrt(r2-1) - r) else: K11 = K22 = 6 K_12 = params.mu_f*np.pi*params.a*np.diag([K11, K22]) R, (x, y) = pct.rot2d(tht_(u)), pos_(u) return (R.T).dot(K_12).dot(R).dot(params.vf(x, y) - vel_(u))
def torque_drag2d(u, params): R, (x, y) = pct.rot2d(tht_(u)), pos_(u) L_xy = pct.jac2d(params.vf, x, y) L_12 = R.dot(L_xy).dot(R.T) # velocity gradient D_12 = (L_12 + L_12.T)/2 # rate of deformation W_12 = (L_12 - L_12.T)/2 # rate of rotation r, r2 = params.r, params.r2 if r > 1: a0 = -2/(r2-1) - r*log((r-sqrt(r2-1))/(r+sqrt(r2-1)))/(r2-1)**1.5 b0 = r2/(r2-1) + r*log((r-sqrt(r2-1))/(r+sqrt(r2-1)))/(r2-1)**1.5/2 else: a0 = b0 = 2/3. k3 = 16*np.pi*params.mu_f*params.a**3*r/(r2*a0 + b0)/3. t3 = (r**2 - 1)*D_12[0,1] + (1 + r**2)*(W_12[1,0] - omg_(u)) return k3*t3
def force_dep2d(u, params): R, (x, y) = pct.rot2d(tht_(u)), pos_(u) Kcm = np.diag([params.cmf_long, params.cmf_short]) dip = params.vol*params.eps_f*Kcm.dot(R).dot(params.elecf(x, y)) return pct.jac2d(params.elecf, x, y).dot(R.T).dot(dip)