# Python Doublet + Uniform Flow // Streamfunction Polar Plot Help

 Register Blogs Members List Search Today's Posts Mark Forums Read

 May 25, 2016, 03:41 Python Doublet + Uniform Flow // Streamfunction Polar Plot Help #1 New Member   not_real_name Join Date: May 2016 Posts: 2 Rep Power: 0 Hello, Python,CFD and cfd-online newbie here. I am using Spyder (Python 3.5) and I managed to plot my streamfunction in cartesian coordinates. I tried transforming and plotting in polar coordinates but I am not sure that what i have done is correct. I am not even sure what the plot should look like :/ When I run the code the result is: [See attached picture] The code is this: Code: ```import numpy from matplotlib import pyplot from matplotlib import cm N=1000 r_min, r_max = 0,1 theta_min, theta_max = 0,2*numpy.pi r=numpy.linspace(r_min,r_max,N) theta=numpy.linspace(theta_min, theta_max,N) X,Y=numpy.meshgrid(r*numpy.cos(theta),r*numpy.sin(theta)) kappa = 1 r_doublet, theta_doublet=0,0 def velocity_doublet(strength, rd, thetad, X, Y): u = - strength/(2*numpy.pi)*((X-rd*numpy.cos(thetad))**2-(Y-rd*numpy.sin(thetad))**2)/((X-rd*numpy.cos(thetad))**2+(Y-rd*numpy.sin(thetad))**2)**2 v = - strength/(2*numpy.pi)*2*(X-rd*numpy.cos(thetad))*(Y-rd*numpy.sin(thetad))/((X-rd*numpy.cos(thetad))**2+(Y-rd*numpy.sin(thetad))**2)**2 return u, v def stream_function_doublet(strength, rd, thetad, X, Y): psi = - strength/(2*numpy.pi)*(Y-rd*numpy.sin(thetad))/((X-rd*numpy.cos(thetad))**2+(Y-rd*numpy.sin(thetad))**2) return psi # computes the velocity field on the mesh grid u_doublet, v_doublet = velocity_doublet(kappa, r_doublet, theta_doublet, X, Y) # computes the stream-function on the mesh grid psi_doublet = stream_function_doublet(kappa, r_doublet, theta_doublet, X, Y) #pyplot.streamplot(X, Y, u_doublet, v_doublet, #density=2, linewidth=1, arrowsize=1, arrowstyle='->') #pyplot.scatter(r_doublet, theta_doublet, color='#CD2305', s=80, marker='.'); #ax = pyplot.subplot(111, polar=True) #ax.plot(X,Y, u_doublet,v_doublet, color='r', ls='none', marker='.') u_inf = 1.0 # the speed of the freestream u_freestream = u_inf * numpy.ones((N, N), dtype=float) v_freestream = numpy.zeros((N, N), dtype=float) psi_freestream = u_inf * Y u = u_freestream + u_doublet v = v_freestream + v_doublet psi = psi_freestream + psi_doublet ax = pyplot.subplot(111, polar=True) pyplot.scatter(r_doublet*numpy.cos(theta_doublet), r_doublet*numpy.sin(theta_doublet), color='b', s=500, marker='o') ax.contour(X,Y, psi, levels=[-1,1,N], colors='#CD2305',linestyles='solid')``` To compare, these are the stream plots of the doublet [upper plot] and of the doublet + uniform flow superposition [lower plot] Thank you for your time

 Tags cfd, doublet, python, sink, source