我正在尝试使用R来解决以下问题,我需要帮助,因为我不熟悉这些包。我尝试按照本书Solving differential equations in R第211页上的示例进行操作,但我没有运气。
这是我的代码
library(bvpSolve)
couple_ode <- function(theta, Y, delta){
with(as.list(Y), {
ds <- ((sin(2*omega) + sin(delta)/tan(theta)*cos(2*omega) - sin(delta/tan(theta) - sin(delta)*sin(2*omega))) * s + (cos(2*omega)*sin(theta) + sin(2*omega)*cos(theta))) / (cos(2*omega) + sin(delta))
domega <- 0.5* ((cos(delta)^2 - sin(delta)* (sin(2*omega)/tan(theta)+cos(2*omega)+1)*(sin(delta)+1)) * s + (cos(2*omega)*cos(theta)-sin(2*omega)*sin(theta))*sin(delta)+cos(theta)) / (s*sin(delta)*(cos(2*omega)+sin(delta))) - 1
return(list(c(ds, domega)))
})
}
thetas <- seq(from = 0.001, to = pi/4, by = 0.01)
phi_w <- 35/180*pi
delta <- 43/180*pi
y_ini <- c(s = NA, omega = 0)
y_end <- c(s = NA, omega = 0.5*(phi_w+asin(sin(phi_w)/sin(delta))))
Sol <- bvptwp(x = thetas, func = couple_ode, order = c(1,1), par = delta, yini = y_ini, yend = y_end)
这是我得到的错误:
NaNs producedNaNs producedNaNs producedNaNs producedNaNs producedNaNs producedNaNs producedNaNs producedNaNs producedNaNs producedNaNs producedNaNs producedNaNs producedNaNs producedNaNs producedNaNs producedNaNs producedNaNs producedNaNs producedNaNs producedNaNs producedError in bvpsolver(1, yini, x, func, yend, parms, order, ynames, xguess, :
The Expected No. Of mesh points Exceeds Storage Specifications.
我不确定我得到的错误是数字障碍还是我的代码错了。我想我应该给出一些猜测价值,但不知道如何。
更新到原始帖子: 等式中有1 / tan(theta)项,边界值从theta = 0开始,所以很自然会出现错误。但即使将其改为0.001。我仍然有同样的问题。