필터 지우기
필터 지우기

Algorithm to calculate trajectories from a vector field

조회 수: 20 (최근 30일)
Ashfaq Ahmed
Ashfaq Ahmed 2022년 1월 10일
댓글: Jon 2022년 1월 26일
Dear altruists,
Suppose, I have a two-dimensional vector field, i.e., for each point (x, y) I have a vector (u, v), whereas u and v are functions of x and y.
This vector field canonically defines a set of trajectories, i.e. a set of paths a particle would take if it follows along the vector field. In the following image, the vector field is depicted in blue, and there are four trajectories (which are my expected outcome), depicted in dark red:
I am looking for an algorithm which will give me a trajectory of a virtual particle I imagine from anypoint of that vector field. The trajectories must satisfy some kind of minimum denseness in the plane (for every point in the plane we must have a 'nearby' trajectory), or some other condition to get a reasonable set of trajectories.
I could not find anything useful on Google on this, so I posted it here because I always get responses from this community :)
Before I start devising such an algorithm by myself: Are there any known algorithms for this problem? What is their name, for which keywords do I have to search?

채택된 답변

Jon
Jon 2022년 1월 10일
편집: Jon 2022년 1월 10일
The trajectories you are seeking are solutions to a set of ordinary differential equations with initial conditions given by the starting point of the particle. You can solve ode's using MATLAB ode solvers see https://www.mathworks.com/help/matlab/ordinary-differential-equations.html
These functions will solve a system of ode's dx/dt = f(x). Since these functions only a require that you create a function that gives the derivatives (dx/dt) as a function of the system state (x). The same fuction that you are using to generate your vector fields can be used to provide the needed derivatives at a given state values. If your vector fields are from experimental data, you could probably use the data you have and some interpolation to calculate the derivatives needed for the ode solver.
  댓글 수: 15
Ashfaq Ahmed
Ashfaq Ahmed 2022년 1월 26일
편집: Ashfaq Ahmed 2022년 1월 26일
Hi @Jon, I have submitted the project with some changes and it went really good! I have, however, one confusion that I could never solve. Could you please tell me why did this line always make 41x2 matrix for p?
[t,p] = ode45(f,tspan,p0);
This was the comment you wrote on 11 January -
https://www.mathworks.com/matlabcentral/answers/1626260-algorithm-to-calculate-trajectories-from-a-vector-field#comment_1930410
Jon
Jon 2022년 1월 26일
The rows in p are the time steps, the columns are the x and y positions. So I guess you understand why it had two columns. Regarding the number of rows, being 41, I this corresponds to the number of time steps the algorithm takes to go from 0 to tspan. The ode45 solver is a variable step size solver, so you don't have direct control of how many steps it takes. It depends upon the vector field and also the options for the error tolerances.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Ordinary Differential Equations에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by