[英]How do I use MATLAB to solve this PDE
I have the following question on a practice exam: 我在练习考试中有以下问题:
I need to use MATLAB to solve it. 我需要使用MATLAB来解决它。 The problem is, I have not seen a problem like this before and I'm struggling to get started.
问题是,我之前没有看到这样的问题而且我正在努力开始。
I have my 1x1 grid, split into 10x10. 我有1x1网格,分成10x10。 I know I can calculate the whole bottom row besides the corners using 1/10 * x*2.
我知道我可以使用1/10 * x * 2计算角落以外的整个底行。 I also know I can calculate the entire right row using (1/10)(1+t)^2.
我也知道我可以使用(1/10)(1 + t)^ 2计算整个右行。 However, I cannot figure out how to get enough points to be able to fill in the values for the entire grid.
但是,我无法弄清楚如何获得足够的分数来填充整个网格的值。 I know it must have something to do with the partial derivatives given in the problem, but I'm not quite sure where they come into play (especially the u_x equation).
我知道它必须与问题中给出的偏导数有关,但我不太确定它们在哪里发挥作用(尤其是u_x方程)。 Can someone help me get a start here?
有人可以帮助我从这里开始吗?
I don't need the whole solution. 我不需要整个解决方案。 Once I have enough points I can easily write a matlab program to solve the rest.
一旦我有足够的积分,我就可以轻松编写一个matlab程序来解决剩下的问题。 Really, I think I just need the x=0 axis solved, then I just fill in the middle of the grid.
真的,我想我只需要解决x = 0轴,然后我就填写网格的中间部分。
I have calculated the bottom row, minus the two corners, to be 0.001, 0.004, 0.009, 0.016, 0.025, 0.036, 0.049, 0.064, 0.081. 我已计算出底行,减去两个角,为0.001,0.004,0.009,0.016,0.025,0.036,0.049,0.064,0.081。 And similarly, the entire right row is trival to calculate using the given boundry condition.
类似地,使用给定的边界条件计算整个右行是很简单的。 I just can't piece together where to go from there.
我只是无法拼凑到哪里去那里。
Edit: the third boundry condition equation was mistyped. 编辑:第三个边界条件方程输入错误。 it should read:
它应该是:
u_x(0,t) = 1/5t, NOT u(0,t) = 1/5t u_x(0,t)= 1 / 5t,NOT u(0,t)= 1 / 5t
First realise that the equation you have to solve is the linear wave equation , and the numerical scheme you are given can be rewritten as 首先要意识到你必须解决的方程是线性波方程 ,你给出的数值方案可以改写为
( u^(n+1)_m - 2u^n_m + u^(n-1)_m )/k^2 = ( u^n_(m-1) - 2u^n_m + u^n_(m+1) )/h^2
where k
is the time step and h
is the delta x
in space. 其中
k
是时间步长, h
是空间中的delta x
。
The reformulated numerical scheme makes clear that the left- and right-hand sides are the second order centred finite difference approximations of u_tt
and u_xx
respectively. 重新构造的数值方案清楚地表明,左侧和右侧分别是
u_tt
和u_xx
二阶中心有限差分近似。
To solve the problem numerically, however, you need to use the form given to you because it is the explicit update formula that you need to implement numerically: it gives you the solution at time n+1
as a function of the previous two times n
and n-1
. 但是,要以数字方式解决问题,您需要使用给定的形式,因为它是您需要以数字方式实现的显式更新公式:它在时间
n+1
为您提供前两次的函数n
和n-1
。 You need to start from the initial condition and march the solution in time. 您需要从初始条件开始并及时进行解决方案。
Observe that the solution is assigned on the boundaries of the domain ( x=0
and x=1
), so the values of the discretized solution u^(n)_0
and u^(n)_10
are known for any n
( t=n*k
). 观察到解决方案是在域的边界上分配的(
x=0
和x=1
),因此离散化解u^(n)_0
和u^(n)_10
的值对于任何n
都是已知的( t=n*k
)。 At the n
th time step your unknown is the vector [u^(n+1)_1, u^(n+1)_2, ..., u^(n+1)_9]
. 在第
n
个步骤,你的未知是向量[u^(n+1)_1, u^(n+1)_2, ..., u^(n+1)_9]
。
Observe also that to use the update formula to find the solution at the n+1
step, requires the knowledge of the solution at two previous steps. 另请注意,要使用更新公式在
n+1
步骤中找到解决方案,需要在前两个步骤中了解解决方案。 So, how do you start from n=0
if you need information from two previous times? 那么,你如何从开始
n=0
,如果你需要从前面两个时间的信息? This is where the initial conditions come into play. 这是初始条件发挥作用的地方。 You have the solution at
n=0
( t=0
), but you also have u_t
at t=0
. 你有
n=0
( t=0
)的解决方案,但你在t=0
也有u_t
。 These two pieces of information combined can give you both u^0
and u^1
and get you started. 这两条信息组合起来可以给你
u^0
和u^1
并让你入门。
I would use the following start-up scheme: 我会使用以下启动方案:
u^0_m = u(h*m,0) // initial condition on u
(u^2_m - u^0_m)/(2k) = u_t(h*m,0) // initial condition on u_t
that combined with the numerical scheme used with n=1
gives you everything you need to define a linear system for both u^1_m
and u^2_m
for m=1,...,9
. 与
n=1
使用的数值方案相结合,为m=1,...,9
提供了为u^1_m
和u^2_m
定义线性系统所需的一切。
To summarize: 总结一下:
--use the start-up scheme to find solution at n=1
and n=2
simultaneously . --use启动方案来发现在溶液
n=1
和n=2
同时进行 。
--from there on march in time using the numerical scheme you are given. - 使用您给出的数值方案从3月开始。
If you are completely lost check out things like: finite difference schemes, finite difference schemes for advection equations, finite difference schemes for hyperbolic equations, time marching. 如果你完全迷失了,请查看:有限差分格式,平流方程的有限差分格式,双曲线方程的有限差分格式,时间推进等。
EDITING: 编辑:
For the boundary condition on u_x
you typically use the ghost cell method: 对于
u_x
上的边界条件,通常使用ghost单元格方法:
Introduce a ghost cell at m=-1
, ie a fictitious (or auxiliary) grid point that is used to deal with boundary condition, but that is not part of the solution. 在
m=-1
处引入鬼影单元,即用于处理边界条件的虚拟(或辅助)网格点,但这不是解决方案的一部分。
The first node m=0
is back into your unknown vector, ie you are now working with [u_0 u_1 ... u_9]
. 第一个节点
m=0
回到你的未知向量,即你现在正在使用[u_0 u_1 ... u_9]
。
Use the left side boundary condition to close the system. 使用左侧边界条件关闭系统。 Specifically, by writing down the centered approx of the boundary condition
具体地说,通过记下边界条件的居中近似值
u^n_(1) - u^n_(-1) = 2*h*u_x(0,k*n)
The above equation allows you to express the solution on the ghost node in terms on the solution on an internal, real node. 上面的等式允许您根据内部实节点上的解决方案在ghost节点上表达解决方案。 Therefore you can apply the time-marching numerical scheme (the one you are given) to the
m=0
node. 因此,您可以将时间推进的数值方案(您给出的方案)应用于
m=0
节点。 (The numerical scheme applied to m=0
would contain contributions from the m=-1
ghost node, but now you have that expressed in terms of the m=1
node.) (应用于
m=0
的数值方案将包含来自m=-1
重影节点的贡献,但现在您已根据m=1
节点表示。)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.