简体   繁体   English

绘制受简单圆形轨道影响的流场 - 双曲吸引子,以极坐标给出,在笛卡尔坐标系中 - Python

[英]Plotting flow field influenced by a simple circular orbit - hyperbolic attractor, given in polar coordinates, in Cartesian coordinate system - Python

I may have bitten more off than I can chew for a project and have to plot, as the title says, a flow field, or vector field as given in the example: The vector field I need to create, no need for the colours...对于一个项目,我可能咬得比我能咀嚼的还要多,并且必须像标题所说的那样绘制流场或矢量场,如示例中所示:我需要创建的矢量场,不需要颜色。 ..

The dynamics of this system as given in the example with polar coordinates are: r' = 5 * r^2 * (1-r) and φ' = r极坐标示例中给出的该系统的动力学为:r' = 5 * r^2 * (1-r) 和 φ' = r

The system has a circular periodic orbit with radius 1 and is centered at the origin.The orbit is a hyperbolic attractor with B = R^2 \\ {(0, 0)}.该系统有一个半径为1的圆形周期轨道,以原点为中心。轨道是一个双曲吸引子,B = R^2 \\ {(0, 0)}。 The period is T = 2π and the asymptotic phase is given exactly by θ(r, φ) = φ − 1/5r + 0.2.周期为 T = 2π,渐近相位由 θ(r, φ) = φ − 1/5r + 0.2 精确给出。

As given on page 1511 of this PDF 如本 PDF 第 1511 页所述

Now, I've been googling something similar for days now, but can't seem to properly define the orbit, and all I seem to find is tutorials on planetary orbits or the Lorenz attractor.现在,我几天来一直在谷歌搜索类似的东西,但似乎无法正确定义轨道,我似乎找到的只是行星轨道或洛伦兹吸引子的教程。 The best I've managed to come up with is this:我设法想出的最好的是:

import numpy as np
import matplotlib.pyplot as plt

x, y = np.mgrid[2:-2:20j, 2:-2:20j]

r = np.sqrt(x**2 + y**2)
phi = np.arctan(y/x)

dr = 5*(r**2)*(1-r)
dphi = r

dx = (5*(r**2)*(1-r)*np.cos(phi)) - ((r**2)*np.sin(phi))
dy = (5*(r**2)*(1-r)*np.cos(phi)) + ((r**2)*np.sin(phi))

fig, ax = plt.subplots()
ax.quiver(x, y, dx, dy)
ax.set(aspect=1, title='NOT GOOD', xlabel='X', ylabel='Y')

plt.show()

Now, this returns a bad quiver plot, and I honestly don't know if I am even going the right direction.现在,这返回了一个糟糕的箭袋情节,老实说,我什至不知道我是否朝着正确的方向前进。 Would anyone care to explain how one would properly solve this so even a moron like me could understand?有没有人愿意解释一下如何正确解决这个问题,这样即使像我这样的白痴也能理解? Please.请。 Do I enter it as a function and do a streamplot of that, would I define it before or after converting from polar to Cartesian?我是否将它作为函数输入并对其进行流图,我是在从极坐标转换为笛卡尔坐标之前还是之后定义它? Is my math even correct?我的数学甚至正确吗?

I think the rotation matrix to get the vector field in Cartesian coordinates was messed up:我认为在笛卡尔坐标中获得矢量场的旋转矩阵搞砸了:

import numpy as np
import matplotlib.pyplot as plt

x, y = np.mgrid[2:-2:20j, 2:-2:20j]

r = np.sqrt(x**2 + y**2)
phi = np.arctan2(y, x)

dr = 5*(r**2)*(1-r)
dphi = r

dx = dr*np.cos(phi) - dphi*np.sin(phi)
dy = dr*np.sin(phi) + dphi*np.cos(phi)

norm_dr = np.sqrt(dx**2 + dy**2)

fig, ax = plt.subplots()
ax.quiver(x, y, dx/norm_dr, dy/norm_dr)
ax.set(aspect=1, title='GOOD?', xlabel='X', ylabel='Y')

plt.show()

the vectors are also normed in the plot, thus they all have the same size向量也在图中被归一化,因此它们都具有相同的大小

结果图

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM