如何使用 NxM 矩阵作为 `pdepe` 中的初始条件

How can I use NxM matrix to be my initial condition in `pdepe`

我使用 Matlab 求解器 pdepe 求解了一个 PDE。初始条件是一个 ODE 的解,我在另一个 m.file 中求解。现在,我有了大小为 NxM 的矩阵形式的 ODE 解。我如何使用它作为我在 pdepe 中的 IC?这可能吗?当我使用 for loop 时,pdepe 仅将最后一次迭代作为初始条件。感谢任何帮助。

根据 pdepe documentation,求解器的初始条件函数的语法为:

u = icFun(x);

其中指定值 x 处的 PDE 初始值在列向量 u 中返回。 因此,只有当 PDE 是具有 M 个空间网格点的 N 未知数系统时,初始条件才会是 N x M 矩阵。

因此,N x M 矩阵可用于填充初始条件,但需要一些映射将给定列与特定值 x 相关联。例如,在调用 pdepe 的主函数中,可能有

% icData is the NxM matrix of data
% xMesh is an 1xM row vector that has the spatial value for each column of icData
icFun = @(x) icData(:,x==xMesh);

这种方法的唯一缺点是初始条件的网格以及 pdepe 解受初始数据的约束。这可以通过使用如下插值方案来克服:

% icData is the NxM matrix of data
% xMesh is an 1xM row vector that has the spatial value for each column of icData
icFun = @(x) interp1(xMesh,icData',x,'pchip')';

其中存在转置以符合 interp1 对数据的解释。

使用 'method of line' 样式在每个网格上定义不同的条件比使用 pdepe

更容易

MOL也更灵活地用于3D问题等不同情况 只是说:))