# Method of Lines (MOL) for coupled PDEs

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

• What is $\partial m / \partial t$? Can you show the full equation with the source term? – Maxim Umansky Aug 16 '20 at 15:40
• The equations are there in the link that I have attached- scicomp.stackexchange.com/questions/35729/… – Nishant Kumar Gupta Aug 16 '20 at 16:20
• 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. – Maxim Umansky Aug 16 '20 at 16:40
• 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? – Nishant Kumar Gupta Aug 16 '20 at 18:48
• 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. – Maxim Umansky Aug 16 '20 at 21:54