|
[Sponsors] |
Python Doublet + Uniform Flow // Streamfunction Polar Plot Help |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
May 25, 2016, 04: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') Thank you for your time |
|
Tags |
cfd, doublet, python, sink, source |
Thread Tools | Search this Thread |
Display Modes | |
|
|
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 07:45 |
Modified pimpleFoam solver to MRFPimpleFoam solver | hiuluom | OpenFOAM Programming & Development | 12 | June 14, 2015 22:22 |
[swak4Foam] Air Conditioned room groovyBC | Sebaj | OpenFOAM Community Contributions | 7 | October 31, 2012 15:16 |
[snappyHexMesh] Layers:problem with curvature | giulio.topazio | OpenFOAM Meshing & Mesh Conversion | 10 | August 22, 2012 10:03 |
fluid flow fundas | ram | Main CFD Forum | 5 | June 17, 2000 22:31 |