求解 Frenet 框架的非线性 ODE 系统

牡蛎

我已经用 2 个变量检查了python 非线性 ODE,这不是我的情况。也许我的情况不被称为nonlinear ODE,请纠正我。

问题Frenet Frame实际上是,其中有 3 个向量 T(s)、N(s) 和 B(s);参数 s>=0。并且有 2 个标量具有已知的数学公式表达式 t(s) 和 k(s)。我有初始值 T(0)、N(0) 和 B(0)。

diff(T(s), s) =             k(s)*N(s)
diff(N(s), s) = -k(s)*T(s)            + t(s)*B(s)
diff(B(s), s) =            -t(s)*N(s)

那么我怎样才能以数字或符号方式得到 T(s)、N(s) 和 B(s)?

我已经检查过,scipy.integrate.ode但我根本不知道如何将 k(s)*N(s) 传递给它的第一个参数

def model (z, tspan):
   T = z[0]
   N = z[1]
   B = z[2]

   dTds =            k(s) * N           # how to express function k(s)?      
   dNds = -k(s) * T          + t(s) * B
   dBds =           -t(s)* N

   return [dTds, dNds, dBds]


z = scipy.integrate.ode(model, [T0, N0, B0]
xdze2

这是使用solve_ivpScipy 接口(而不是odeint)获得数值解的代码:

import numpy as np
from scipy.integrate import solve_ivp

from scipy.integrate import cumtrapz
import matplotlib.pylab as plt

# Define the parameters as regular Python function:
def k(s):
    return 1

def t(s):
    return 0

# The equations: dz/dt = model(s, z):
def model(s, z):
    T = z[:3]   # z is a (9, ) shaped array, the concatenation of T, N and B 
    N = z[3:6]
    B = z[6:]

    dTds =            k(s) * N  
    dNds = -k(s) * T          + t(s) * B
    dBds =           -t(s)* N

    return np.hstack([dTds, dNds, dBds])


T0, N0, B0 = [1, 0, 0], [0, 1, 0], [0, 0, 1] 

z0 = np.hstack([T0, N0, B0])

s_span = (0, 6) # start and final "time"
t_eval = np.linspace(*s_span, 100)  # define the number of point wanted in-between,
                                    # It is not necessary as the solver automatically
                                    # define the number of points.
                                    # It is used here to obtain a relatively correct 
                                    # integration of the coordinates, see the graph

# Solve:
sol = solve_ivp(model, s_span, z0, t_eval=t_eval, method='RK45')
print(sol.message)
# >> The solver successfully reached the end of the integration interval.

# Unpack the solution:
T, N, B = np.split(sol.y, 3)  # another way to unpack the z array
s = sol.t

# Bonus: integration of the normal vector in order to get the coordinates
#        to plot the curve  (there is certainly better way to do this)
coords = cumtrapz(T, x=s)

plt.plot(coords[0, :], coords[1, :]);
plt.axis('equal'); plt.xlabel('x'); plt.xlabel('y');

T、N 和 B 是向量。因此,有 9 个方程需要求解:z是 (9,) 数组。

对于恒定曲率且无扭转,结果是一个圆:

一个圆圈

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

使用ode求解来求解3个差分方程(Lorenz方程)的非线性系统:Matlab中的ode23s

来自分类Dev

在MATLAB中定义和求解嵌套的非线性ODE

来自分类Dev

MATLAB:如何求解高维非线性ODE?

来自分类Dev

使用外力读取求解 ODE 系统

来自分类Dev

当非线性方程求解器从 ODE 求解器调用时,fsolve 不匹配形状错误

来自分类Dev

求解一个简单的非线性系统

来自分类Dev

求解非线性ODE 2.在Matlab中进行数值排序

来自分类Dev

使用Matlab使用Euler方法求解ODE系统

来自分类Dev

用python和图形求解ODE的系统(蔡氏电路)

来自分类Dev

求解ODE系统时对scipy.integrate.ode使用自适应时间步长

来自分类Dev

Dymola中求解非线性系统模型的最大能力是多少?

来自分类Dev

在matlab中使用具有多个输入的fsolve求解非线性系统

来自分类Dev

刚性ODE求解器

来自分类Dev

求解并绘制分段ODE

来自分类Dev

如何在Python中求解三角方程组的非线性系统(MATLAB可以轻松解决)

来自分类Dev

用初始条件作为2D数组求解Julia中的ODE系统

来自分类Dev

内插后用ode45求解ODE

来自分类Dev

在python中求解非线性方程

来自分类Dev

Matlab中非线性矩阵方程的求解

来自分类Dev

在 Matlab 中求解非线性方程

来自分类Dev

matlab非线性方程求解器

来自分类Dev

迭代求解非线性方程

来自分类Dev

Sympy:求解非线性方程

来自分类Dev

odeint的非线性ODE解决方案

来自分类Dev

用SciPy数值求解ODE

来自分类Dev

Python中的Ode求解器

来自分类Dev

使用 SciPy 数值求解 ODE

来自分类Dev

用R求解非平方线性系统

来自分类Dev

用光斑求解线性系统(Cholesky因式分解)