CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Post-Processing

Plot streamlines with Python

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   September 12, 2016, 10:29
Default Plot streamlines with Python
  #1
Senior Member
 
Join Date: Mar 2015
Posts: 250
Rep Power: 12
KateEisenhower is on a distinguished road
Hello all,

currently I am trying to plot streamlines with python. It is working so far and following is a kind of minimal example:

Code:
import numpy as np
import matplotlib.pyplot as plt

Y, X = np.mgrid[-2:2:4j, -2:2:4j]

U = np.array([[-77., -3.4, -3.4, -14.],
[-5.6, -2.1,-2.1,-5.6],
[-4.3,-0.7,-0.7,-4.3],
[-3.,0.5,0.5,13.]])

V = np.array([[-500., 5, -5., 5.],
[-1.4, 500,1.2,2.5],
[-1.4,-0.1,1.2,2.5],
[-5.,-3.6,-2.3,-1.]])

speed = np.sqrt(U*U +V*V)

fig0, ax0 = plt.subplots()
strm  = ax0.streamplot(X, Y, U, V, density = 3, color = speed, arrowsize = 1, arrowstyle = '->', minlength = 0.2, linewidth = 1, transform = None, cmap=plt.cm.autumn)
fig0.colorbar(strm.lines)

plt.show()
As you can see, the velocity-component V on the upper left hand corner (-500) is way higher than the rest. However pyplot shows me this velocity component on the lower left hand corner in the plot.

I would really appreciate if someone could point me in the right direction.

Best regards,

Kate
KateEisenhower is offline   Reply With Quote

Old   September 12, 2016, 22:06
Default
  #2
Senior Member
 
Pablo Higuera
Join Date: Jan 2011
Location: Auckland
Posts: 627
Rep Power: 19
Phicau is on a distinguished road
Hi Kate,

I guess that is the standard, the first row starting from the bottom. What you are looking for is this:

U = np.flipud(U)
V = np.flipud(V)

Best,

Pablo
Phicau is offline   Reply With Quote

Old   September 13, 2016, 03:15
Default
  #3
Senior Member
 
Join Date: Mar 2015
Posts: 250
Rep Power: 12
KateEisenhower is on a distinguished road
Hello Pablo,

thank you! This flipud utility is exactly what I need then.
But can you explain what the thinking is behind plotting the data upside down in standard mode?

All the best,

Kate
KateEisenhower is offline   Reply With Quote

Reply


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
[swak4Foam] Foam warnings - related to swak4Foam Salam-H OpenFOAM Community Contributions 20 August 2, 2015 15:40
Plot Streamlines R_21 OpenFOAM Post-Processing 0 June 26, 2015 17:32
[OpenFOAM] Paraview: how to plot streamlines and surface mesh together serena ParaView 3 September 9, 2012 22:13
CFD-Post how to plot stress and streamlines? Airone CFX 3 July 9, 2010 11:56
plot streamlines JJ Main CFD Forum 2 December 20, 1999 12:21


All times are GMT -4. The time now is 17:48.