I am trying to solve the set of equations posted here- Solving the heat diffusion equation with source term One of the methods I have learnt to solve second order PDEs is the 'method of lines', where we discretize all independent variables except one. So for this example, I can discretize the spatial domain as follows- $$\frac{\partial^2 T}{\partial x^2} = \frac{T_{i+1}-2T_i+T_{i-1}}{(\Delta x)^2} \hspace{11pt} \forall \hspace{3pt}i = 2,3,4...N-1$$ And I can write the time derivative as- $$\frac{\partial T}{\partial t} = \frac{dT_i}{dt}$$

Ordinarily without the source term, this would have given me a system of ODEs which I could have solved using the ode45/ode15s command in MATLAB. With the addition of a non-linear source term, I now get a coupled system of PDEs. I am not sure how to incorporate the $\frac{\partial m}{\partial t}$ term in the system of ODEs formed by the variables $T_i$. Thanks in advance

  • $\begingroup$ What is $\partial m / \partial t$? Can you show the full equation with the source term? $\endgroup$ – Maxim Umansky Aug 16 at 15:40
  • $\begingroup$ The equations are there in the link that I have attached- scicomp.stackexchange.com/questions/35729/… $\endgroup$ – Nishant Kumar Gupta Aug 16 at 16:20
  • 1
    $\begingroup$ Since $m(x,t)$ is an evolving quantity you will need to solve spatially discretized equations for $d m_i / dt$, using method of lines as well. Then add the time derivative $d m_i / dt$ to the equation for $T_i$, with the appropriate coefficient. $\endgroup$ – Maxim Umansky Aug 16 at 16:40
  • $\begingroup$ So if I have $N$ grid points in the spatial domain, then my solution vector $[T_i, m_i]$ would be of the size $2N$, where the first N values correspond to the $T_i$s and the next N values correspond to $m_i$. Is that correct? $\endgroup$ – Nishant Kumar Gupta Aug 16 at 18:48
  • 1
    $\begingroup$ Yes, you'd have to solve 2n ODEs. How to pack $T_i$ and $m_i$ in a vector it is a choice between $[T_0,T_1,...T_n, m_0,m_1, ...,m_n]$ and $[T_0,m_0, T_1,m_1,... T_n, m_n]$. For what you are doing the order does not matter. $\endgroup$ – Maxim Umansky Aug 16 at 21:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.