def rk2_step(sld_bodies, free_stream, vort_elems, dt): k1 = np.zeros((len(vort_elems), 1), dtype=complex) pos, strg, delta = np.array([ vort_elems[i].pos for i in range(len(vort_elems)) ]), np.array([vort_elems[i].strg for i in range(len(vort_elems))]), vort_elems[0].delta poscp = [vort_elems[i].poscp for i in range(len(vort_elems))] k1[:] += [ VPM.vel_body(sld_bodies, vort_elems[i].pos) for i in range(len(vort_elems)) ] for i in range(len(vort_elems)): k1[i] += free_stream k1[:, 0] += vel_vort(pos, pos, strg, delta) for i in range(len(vort_elems)): vort_elems[i].pos += 0.5 * k1[i][0] * dt for body in sld_bodies: body.move_body(0.5 * dt) VPM.depenetrator(sld_bodies, vort_elems) A = VPM.get_coefficient_mat(sld_bodies) b = VPM.get_rhs(sld_bodies, free_stream, vort_elems) gamma = VPM.solve_gamma(sld_bodies, A, b) k2 = np.zeros((len(vort_elems), 1), dtype=complex) pos, strg, delta = np.array([ vort_elems[i].pos for i in range(len(vort_elems)) ]), np.array([vort_elems[i].strg for i in range(len(vort_elems))]), vort_elems[0].delta poscp = [vort_elems[i].poscp for i in range(len(vort_elems))] k2[:] += [ VPM.vel_body(sld_bodies, vort_elems[i].pos) for i in range(len(vort_elems)) ] for i in range(len(vort_elems)): k2[i] += free_stream k2[:, 0] += vel_vort(pos, pos, strg, delta) for i in range(len(vort_elems)): vort_elems[i].poscp += k2[i][0] * dt vort_elems[i].pos = cp.copy(vort_elems[i].poscp) for body in sld_bodies: body.move_body(0.5 * dt) VPM.depenetrator(sld_bodies, vort_elems)
def plot_velfield(grid,SimulationData_pos,SimulationData_strg,body,fignum,Vinf=1+0j): x,y = grid z = x + 1j*y vel = np.zeros_like(z,dtype = complex) # print(np.shape(vel)) for i in range(np.shape(vel)[1]): vel[i] = np.array([VPM.vel_body([body],z[i][j]) for j in range(np.shape(vel)[0])])[0] + Vinf vel[i] += itg.vel_vort(z[i].copy(),SimulationData_pos.copy(),SimulationData_strg.copy(),body.get_pnl_len()[0]/np.pi) plt.figure(fignum) plt.quiver(x,y,vel.real,vel.imag,scale = 75.0) plt.plot(body.get_vert().real,body.get_vert().imag,'b') plt.gca().set_aspect('equal',adjustable='box') plt.show()