I would like to use Matlab's pdepe to solve this system:

$$ s_t =(sr)_x + s_{ xx } \\ r_t =(\frac{ A }{ B }r^2+s)_x + \frac{ A }{ -K } r_{ xx } $$

where $A$, $B$ and $K$ are constants. I need to solve this using MATLAB pdepe. The problem is the nonlinear term in my equation: I don't know how to treat the nonlinear part. Boundary and initial conditions are not a problem in that part.

So I've tried to write my PDE in the form that pdepe expects: $$\left( \begin{array}{c} 1 \\ 1 \\ \end{array}\right) \times \frac{ \partial }{ \partial t }\left( \begin{array}{c} s \\ r \\ \end{array}\right)=\left( \begin{array}{c} s\frac{ \partial r }{ \partial x } + r\frac{ \partial s }{ \partial x } \\ 2\frac{A}{B}r\frac{ \partial r }{ \partial x } +\frac{ \partial s }{ \partial x }\\ \end{array}\right)+\frac{ \partial }{ \partial x }\left( \begin{array}{c} \frac{ \partial s }{ \partial x } \\ \frac{A}{-K}\frac{ \partial r }{ \partial x } \\ \end{array}\right)+\left( \begin{array}{c} 0 \\ 0 \\ \end{array}\right) $$

In MATLAB:

function [c,f,s] = eqtn(x,t,u,DuDx)

c = 1;

f = ????

s = 0;

How to code the function $f$?

up vote 1 down vote accepted

The most straightforward way to write the eqtn function is to define the nonlinear terms as part of the returned s vector as follows:

f = [DuDx(1); -A/K*DuDx(2)];
s = [u(1)*DuDx(2)+u(2)*DuDx(1); 2*A/B*u(2)*DuDx(2)+DuDx(1)];

The question that immediately comes to mind is which terms are appropriate to include in the f vector compared to s?

The PDE system for many physical problems is derived based on the notion of some quantity being conserved over time. This directly leads to the idea of a "flux" which is what the f vector represents. That is, f has a well-defined meaning in the physical problem.

The definition of f is particularly important in defining boundary conditions. Boundary conditions in pdepe take the form

p + q*f=0

at the right and left ends of the domain. If the boundary condition has a non-zero q, its value depends directly on how f is defined.

  • If we assume s vector is a part of f vector. What if, in the system they have another function in the first equation. For example, $ s_t =(sr)_x + s_{ xx }+r^2 $ ; $ r_t =(\frac{ A }{ B }r^2+s)_x + \frac{ A }{ -K }r_{ xx } $ . Is the vector of s still depend on f vector? or it is possible to add another function ( such as p=[u(1)^2 ; 0] in the matlab code? – Nana Dec 16 '17 at 14:03
  • Sorry, I don't understand the question. In general the s vector contains all the spatially-dependent (or constant) terms that are not part of f. – Bill Greene Dec 16 '17 at 14:26
  • okay I get it. Thank you Dr for helping me. Now I understand. s vector can contains constant too. Thank you so much! – Nana Dec 16 '17 at 14:58

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.