test
In [18]:
from IPython.core.display import display, HTML
display(HTML("<style>.container { width:100% !important; }</style>"))
In [1]:
import math
import numpy as np
import matplotlib.pyplot as plt
# from matplotlib import pyplot
%matplotlib inline
N = 50                                # number of points in each direction
xStart, xEnd = -2.0, 2.0            # boundaries in the x-direction
yStart, yEnd = -1.0, 1.0            # boundaries in the y-direction
x = np.linspace(xStart, xEnd, N)    # creates a 1D-array with the x-coordinates
y = np.linspace(yStart, yEnd, N)    # creates a 1D-array with the y-coordinates

X, Y = np.meshgrid(x, y)

sourceStrength = 5.0                      # source strength
xSource, ySource = -1.0, 0.0             # location of the source

# compute the velocity field on the mesh grid
uSource = sourceStrength/(2*math.pi) * (X-xSource)/((X-xSource)**2 + (Y-ySource)**2)
vSource = sourceStrength/(2*math.pi) * (Y-ySource)/((X-xSource)**2 + (Y-ySource)**2)


sinkStrength = -5.0                     # strength of the sink
xSink, ySink = 1.0, 0.0                # location of the sink

# compute the velocity on the mesh grid
uSink = sinkStrength/(2*math.pi) * (X-xSink)/((X-xSink)**2 + (Y-ySink)**2)
vSink = sinkStrength/(2*math.pi) * (Y-ySink)/((X-xSink)**2 + (Y-ySink)**2)


# compute the velocity of the pair source/sink by superposition
uPair = uSource + uSink
vPair = vSource + vSink
In [6]:
from pylab import rcParams
rcParams['figure.figsize'] = 5, 15
# fig.set_size_inches(18.5, 10.5, forward=True)
In [12]:
speed = np.sqrt(uPair*uPair + vPair*vPair)


fig0, ax0 = plt.subplots(figsize=(18,7))
ax0.set_xlim([-2, 2])
ax0.set_ylim([-1, 1])
strm = ax0.streamplot(X, Y, uPair, vPair, color=speed,  density=2, linewidth=1.5, cmap=plt.cm.bwr)

cbar=fig0.colorbar(strm.lines)
In [13]:
fig0, ax1 = plt.subplots(figsize=(18,7))

lw = 5*speed / speed.max()
ax1.streamplot(X, Y, uPair, vPair, density=2, color='r', linewidth=lw)
ax1.set_xlim([-2, 2])
ax1.set_ylim([-1, 1])

plt.show()