我想通过求解运动方程来跟踪一个小时的粒子路径。对于时间步长,t= np。排列 (0, 3600,10)。这是正确的吗?

问题描述 投票:0回答:1

我想通过求解运动方程来跟踪一个小时的粒子路径。对于时间步长, t= np。排列 (0, 3600,10)。 它是否正确? 持续时间是否取决于时间步长。如果我将时间写为 t= np.arange(0, 3600,0.2l) 而不是(注 10 被替换为 0.2),它仍然会给出一小时的路径吗?谢谢。

numpy numerical-methods numerical-integration odeint
1个回答
-1
投票

物理上,duration仅取决于startstop值,计算如下:duration = start - stop.

然而,大多数时候我们无法处理模拟数据,因此我们必须在某些时间点对信号进行采样。我们的时间样本(某些时间点)与模拟时间的关系如下:


  start                            stop
     |------------------------------|-----------   (Anlog Time)
     *      *      *      *      *      *      *   (Time samples)

在上面的方案中,我们通过对模拟时间(信号)进行采样来检索时间样本的向量。如果我们只包含时间间隔(开始,停止)内的时间样本,我们会看到向量中包含的时间样本取决于 startstopstep 值。

根据函数

np.arange(start,stop,step,...)
的文档,输出值是在半开区间[start, stop)中生成的。这个半开间隔导致持续时间取决于 step 值。因此,持续时间取决于给定的 startstopstep 值。如果我们生成了向量 t,则持续时间计算如下:duration = t[-1]-t[0].

例如,我们可以计算给定startstopstep值的持续时间如下(您可以更改步长值,您将看到它如何影响分辨率和持续时间):

import numpy as np

start = 0       # Start in seconds [s]
stop = 3600     # Stop in seconds [s]
step = 10       # Time steps [s] (Sampling)

t = np.arange(start,stop,step)  # Sampled time in [s]

D = t[-1] - t[0] # Duration in [s]

如果您希望持续时间仅取决于 startstop 值,您可以使用不同的函数,即

np.linspace(...,endpoint=True)
:

import numpy as np

start = 40       # Start in seconds [s]
stop = 3600      # Stop in seconds [s]
N = 3            # Number of samples (N must not be 1)
t = np.linspace(start, stop, N, endpoint=True)

D = t[-1] - t[0]

© www.soinside.com 2019 - 2024. All rights reserved.