R中的非线性摆:获得角度的精确时间演变的问题
Nonlinear pendulum in R: Problem to obtain the exact evolution in time of the angle
我正在做一个简单的钟摆问题,在知道一个数据集后得到角度θ在一个时间间隔内的演化。为了得出解决方案,我基于 Meléndez et alt 的工作,得出以下 θ(t) 时间演化的精确表达式。
我在 R 中的哪个地方是这样的:
PositionAng <- function(t,AngIn,FreAng)
{
2 * acos(sin(AngIn/2) * sn(K.fun((sin(AngIn/2)^2)-FrecAng * t), (sin(AngIn/2)^2))
}
函数 θ(t) 的值的计算变得越来越复杂,当我 运行 我的程序根据 Melendez 的工作得到一个非常不同的图。
我的图表它没有椭圆曲率并且是线性的。
我想知道我的代码是否有错误,或者我可以通过其他方式解决。
从角度为:pi/4(45度)绳子长度为0.8m,重力为9.8的情况开始m/s^2.
我已经与图书馆(椭圆)合作找到这样的结果,但我不知道我的图表会发生什么。
我构建了以下代码:
library(elliptic)
L <- 0.8
g <- 9.8
AngIn <- pi/4
#Angular frequency
FrequencyAng <- function(g,L)
{
2*pi*(sqrt(g/L))
}
#Obtain the value of the angle in a certain second t.
PositionAng <- function(t,AngIn,FreAng)
{
2 * acos(sin(AngIn/2) * sn(K.fun((sin(AngIn/2)^2)-FrecAng * t), (sin(AngIn/2)^2))
}
#Function that applies the previous formula using the different intervals (t).
Test <- function(L,g,AngIn)
{
FrecAng <- 0
t = seq(from= 0, to= 10, by= 0.1)
PosAng <- PositionAng(t,AngIn,FrecAng)
return (PosAng)
}
#Evolution of the angle as a function of time
EvolAng <- Test(L,g,AngIn)
plot(EvolAng,
type = "l",
main = "Evolution of the angle in time",
ylab = "Angle",
xlab = "Time
)
sn是雅可比的椭圆函数
我想获得如下所示的东西
.
正如 Oliver 指出的那样,您的问题是您在 Test
中将 FrecAng
设置为 0。由于 PositionAng
仅使用 t
一次,即乘以 FrecAng
(即 0),因此此项始终为 0,因此此函数产生一个常数。我认为应该是:
Test <- function(L,g,AngIn)
{
FrecAng <- FrequencyAng(g, L)
t = seq(from = 0, to = 10, by = 0.1)
PosAng <- PositionAng(t, AngIn, FrecAng)
return (PosAng)
}
产生:
EvolAng <- Test(L, g, AngIn)
plot(EvolAng,
type = "l",
main = "Evolution of the angle in time",
ylab = "Angle",
xlab = "Time")
这似乎给出了合理的结果 - 对于更长的摆,我们有看起来像简谐运动的东西:
plot(Test(20, 9.8, pi/4),
type = "l",
main = "Evolution of the angle in time",
ylab = "Angle",
xlab = "Time")
但对于更短的长度,我们看到 non-linear 效果:
plot(Test(0.4, 9.8, pi/4),
type = "l",
main = "Evolution of the angle in time",
ylab = "Angle",
xlab = "Time")
我正在做一个简单的钟摆问题,在知道一个数据集后得到角度θ在一个时间间隔内的演化。为了得出解决方案,我基于 Meléndez et alt 的工作,得出以下 θ(t) 时间演化的精确表达式。
我在 R 中的哪个地方是这样的:
PositionAng <- function(t,AngIn,FreAng)
{
2 * acos(sin(AngIn/2) * sn(K.fun((sin(AngIn/2)^2)-FrecAng * t), (sin(AngIn/2)^2))
}
函数 θ(t) 的值的计算变得越来越复杂,当我 运行 我的程序根据 Melendez 的工作得到一个非常不同的图。
我的图表它没有椭圆曲率并且是线性的。
我想知道我的代码是否有错误,或者我可以通过其他方式解决。
从角度为:pi/4(45度)绳子长度为0.8m,重力为9.8的情况开始m/s^2.
我已经与图书馆(椭圆)合作找到这样的结果,但我不知道我的图表会发生什么。
我构建了以下代码:
library(elliptic)
L <- 0.8
g <- 9.8
AngIn <- pi/4
#Angular frequency
FrequencyAng <- function(g,L)
{
2*pi*(sqrt(g/L))
}
#Obtain the value of the angle in a certain second t.
PositionAng <- function(t,AngIn,FreAng)
{
2 * acos(sin(AngIn/2) * sn(K.fun((sin(AngIn/2)^2)-FrecAng * t), (sin(AngIn/2)^2))
}
#Function that applies the previous formula using the different intervals (t).
Test <- function(L,g,AngIn)
{
FrecAng <- 0
t = seq(from= 0, to= 10, by= 0.1)
PosAng <- PositionAng(t,AngIn,FrecAng)
return (PosAng)
}
#Evolution of the angle as a function of time
EvolAng <- Test(L,g,AngIn)
plot(EvolAng,
type = "l",
main = "Evolution of the angle in time",
ylab = "Angle",
xlab = "Time
)
sn是雅可比的椭圆函数
我想获得如下所示的东西
正如 Oliver 指出的那样,您的问题是您在 Test
中将 FrecAng
设置为 0。由于 PositionAng
仅使用 t
一次,即乘以 FrecAng
(即 0),因此此项始终为 0,因此此函数产生一个常数。我认为应该是:
Test <- function(L,g,AngIn)
{
FrecAng <- FrequencyAng(g, L)
t = seq(from = 0, to = 10, by = 0.1)
PosAng <- PositionAng(t, AngIn, FrecAng)
return (PosAng)
}
产生:
EvolAng <- Test(L, g, AngIn)
plot(EvolAng,
type = "l",
main = "Evolution of the angle in time",
ylab = "Angle",
xlab = "Time")
这似乎给出了合理的结果 - 对于更长的摆,我们有看起来像简谐运动的东西:
plot(Test(20, 9.8, pi/4),
type = "l",
main = "Evolution of the angle in time",
ylab = "Angle",
xlab = "Time")
但对于更短的长度,我们看到 non-linear 效果:
plot(Test(0.4, 9.8, pi/4),
type = "l",
main = "Evolution of the angle in time",
ylab = "Angle",
xlab = "Time")