CFD Online Logo CFD Online URL
Home > Forums > General Forums > Main CFD Forum

Python Doublet + Uniform Flow // Streamfunction Polar Plot Help

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

LinkBack Thread Tools Search this Thread Display Modes
Old   May 25, 2016, 03:41
Default Python Doublet + Uniform Flow // Streamfunction Polar Plot Help
New Member
Join Date: May 2016
Posts: 2
Rep Power: 0
nn2e11 is on a distinguished road
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:
import numpy
from matplotlib import pyplot
from matplotlib import cm

r_min, r_max = 0,1
theta_min, theta_max = 0,2*numpy.pi
theta=numpy.linspace(theta_min, theta_max,N)

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
nn2e11 is offline   Reply With Quote


cfd, doublet, python, sink, source

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Too high omega and k values in vortex flow simulation thomas. OpenFOAM Running, Solving & CFD 9 March 30, 2016 06:45
Modified pimpleFoam solver to MRFPimpleFoam solver hiuluom OpenFOAM Programming & Development 12 June 14, 2015 21:22
[swak4Foam] Air Conditioned room groovyBC Sebaj OpenFOAM Community Contributions 7 October 31, 2012 14:16
[snappyHexMesh] Layers:problem with curvature giulio.topazio OpenFOAM Meshing & Mesh Conversion 10 August 22, 2012 09:03
fluid flow fundas ram Main CFD Forum 5 June 17, 2000 21:31

All times are GMT -4. The time now is 02:54.