Контуры скорости сосредоточены в центре - PullRequest
0 голосов
/ 21 сентября 2019

Я пытаюсь построить карту контуров скорости потока источника с помощью команды contour.Каким-то образом мои контуры продолжают концентрироваться в исходной точке.

contour_map

Может кто-нибудь сказать мне, как расширить контуры, чтобы заполнить весь график?

Вот мой код,

import math
import numpy
from matplotlib import pyplot

N = 50                           # number of points in each direction
x_start, x_end = -1, 1            # boundaries in the x-direction
y_start, y_end = -1, 1            # boundaries in the y-direction
x = numpy.linspace(x_start, x_end, N)    # creates a 1D-array with the x-coordinates
y = numpy.linspace(y_start, y_end, N)    # creates a 1D-array with the y-coordinates
X, Y = numpy.meshgrid(x, y)              # generates a mesh grid

strength_source = 5.0                      # source strength
x_source, y_source = 0.0, 0.0           # location of the source


# compute the velocity field on the mesh grid
u_source = (strength_source / (2 * math.pi) *
            (X - x_source) / ((X - x_source)**2 + (Y - y_source)**2))
v_source = (strength_source / (2 * math.pi) *
            (Y - y_source) / ((X - x_source)**2 + (Y - y_source)**2))

Z = numpy.sqrt(u_source**2 + v_source**2)
cp = pyplot.contour(X, Y, Z)

pyplot.show()

1 Ответ

0 голосов
/ 21 сентября 2019

Вы можете использовать contourf вместо contour

pyplot.contourf(X, Y, Z, 10, origin='lower')
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...