algorithm - How do I use MATLAB to solve this PDE -
i have following question on practice exam:
i need use matlab solve it. problem is, have not seen problem before , i'm struggling started.
i have 1x1 grid, split 10x10. know can calculate whole bottom row besides corners using 1/10 * x*2. know can calculate entire right row using (1/10)(1+t)^2. however, cannot figure out how enough points able fill in values entire grid. know must have partial derivatives given in problem, i'm not quite sure come play (especially u_x equation). can me start here?
i don't need whole solution. once have enough points can write matlab program solve rest. really, think need x=0 axis solved, fill in middle of grid.
i have calculated bottom row, minus 2 corners, 0.001, 0.004, 0.009, 0.016, 0.025, 0.036, 0.049, 0.064, 0.081. , similarly, entire right row trival calculate using given boundry condition. can't piece go there.
edit: third boundry condition equation mistyped. should read:
u_x(0,t) = 1/5t, not u(0,t) = 1/5t
first realise equation have solve linear wave equation, , numerical scheme given can 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
time step , h
delta x
in space.
the reformulated numerical scheme makes clear left- , right-hand sides second order centred finite difference approximations of u_tt
, u_xx
respectively.
to solve problem numerically, however, need use form given because explicit update formula need implement numerically: gives solution @ time n+1
function of previous 2 times n
, n-1
. need start initial condition , march solution in time.
observe solution assigned on boundaries of domain (x=0
, x=1
), values of discretized solution u^(n)_0
, u^(n)_10
known n
(t=n*k
). @ n
th time step unknown vector [u^(n+1)_1, u^(n+1)_2, ..., u^(n+1)_9]
.
observe use update formula find solution @ n+1
step, requires knowledge of solution @ two previous steps. so, how start n=0
if need information two previous times? initial conditions come play. have solution @ n=0
(t=0
), have u_t
@ t=0
. these 2 pieces of information combined can give both u^0
, u^1
, started.
i use 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 numerical scheme used n=1
gives need define linear system both u^1_m
, u^2_m
m=1,...,9
.
to summarize:
--use start-up scheme find solution @ n=1
, n=2
simultaneously.
--from there on march in time using numerical scheme given.
if lost check out things like: finite difference schemes, finite difference schemes advection equations, finite difference schemes hyperbolic equations, time marching.
editing:
for boundary condition on u_x
typically use ghost cell method:
introduce ghost cell @
m=-1
, i.e. fictitious (or auxiliary) grid point used deal boundary condition, not part of solution.the first node
m=0
unknown vector, i.e. working[u_0 u_1 ... u_9]
.use left side boundary condition close system. specifically, writing down centered approx of boundary condition
u^n_(1) - u^n_(-1) = 2*h*u_x(0,k*n)
the above equation allows express solution on ghost node in terms on solution on internal, real node. therefore can apply time-marching numerical scheme (the 1 given)
m=0
node. (the numerical scheme appliedm=0
contain contributionsm=-1
ghost node, have expressed in terms ofm=1
node.)