沿朱莉娅速度场移动的情节点
下面的代码创建速度字段。我在(0.5,0.5)中绘制了一个蓝点。如何绘制一系列与速度场一起移动的点?
using PyPlot
xs = range(0,1,step=0.03)
ys = range(0,1,step=0.03)
nfreq = 20
as = randn(nfreq, nfreq)
aas = randn(nfreq, nfreq)
bs = randn(nfreq, nfreq)
bbs = randn(nfreq, nfreq)
f(x,y) = sum( as[i,j]*sinpi(x*i+ aas[i,j])*sinpi(y*j )/(i^2+j^2)^(1.5) for i=1:nfreq, j=1:nfreq)
g(x,y) = sum( bs[i,j]*sinpi(x*i)*sinpi(y*j + bbs[i,j])/(i^2+j^2)^(1.5) for i=1:nfreq, j=1:nfreq)
quiver(xs,ys, f.(xs,ys'), g.(xs,ys'))
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用 dindicalialequations.jl ,特别是来自 pronishare -diffeq.jl 。
<
在这种情况下,要计算从
[0.1,0.1]
开始的轨迹,我们可以做类似的事情:这使用标准求解器之一来计算轨迹。
f(u,t,p)
方法定义为符合odeproblem
预期的签名。输出
sol
是一种特殊的数据结构,可存储(自动选择)时间点,轨迹/解决方案数据以及有关计算方式的一些信息:要访问轨迹本身,请使用
sol.u
:然后,您可以将此数据绘制为散点图以及向量字段本身。
You could use DifferentialEquations.jl, specifically one of the ODE solvers from OrdinaryDiffEq.jl.
Here is a basic (but very useful) tutorial.
In this case, to compute the trajectory starting at
[0.1, 0.1]
, we could do something like:This uses one of the standard solvers to compute the trajectory.
The
F(u,t,p)
method is defined to comply with the signature expected byODEProblem
.The output
sol
is a special data structure that stores the (automatically-chosen) time points, the trajectory/solution data, and some info about how the computation went:To access the trajectory itself, use
sol.u
:You could then plot this data as a scatter plot along with the vector field itself.