# How can I solve coupled equations by the method of line(MOL)?

I want to solve 3 coupled PDEs equations. They depend on time, radius and length. I used the method of lines (MOL) and converted them to a system of ODEs in time. Now I want to solve them using MATLAB. Here are the equations:

\begin{align} &\frac{\partial C_{i,p}}{\partial t} + \frac{u_{cp}C_{i,p}}{r} + C_{i,p}\frac{\partial u_{cp}}{\partial r} + u_{cp} \frac{\partial C_{i,p}}{\partial r} - D_{eff}\left(\frac{\partial^2 C_{i,p}}{\partial r^2} + \frac{1}{r} \frac{\partial C_{i,p}}{\partial r}\right) = - \frac{(1-\epsilon_f)}{\epsilon_f} \rho_f \frac{\partial q_i}{\partial t}\\ &\frac{\partial q_i}{\partial t} = k_s (q_i^{eq} - q_i)\\ &q_i^{eq} = \frac{q_s b P_i}{[1 + (bP_i)^n]^{1/n}}\\ &q_s = q_{s0} \exp\left[\eta \left(1 - \frac{T}{T_0}\right)\right]\\ &b = b_0 \exp\left[\frac{-\Delta H}{R T_0}\left(1 - \frac{T_0}{T}\right)\right]\\ &\eta = A + B\left(1 -\frac{T_0}{T}\right)\\ &P_i = C_{i,p}/RT\\ &T = T_f\\ &\rho C_{pf}\frac{\partial T_f}{\partial t}-\frac{\lambda_f}{(1-\epsilon_f)} \left[\frac{\partial^{2}T_f}{\partial r^{2}}+\frac{1}{r}\frac{\partial T_f}{\partial r}+\frac{\partial^{2}T_f}{\partial z^{2}}\right] = \rho_f \Delta H_{ads} \frac{\partial q_{i}}{\partial t} \end{align}

I want to use ode15s to solve them. I create one matrix where the rows indicate radius nodes and the columns indicate length nodes. I have a problem because they are coupled together and I cant use ode15s for solving them. Because ode15s solve one equation from time=[0:end] and then solve another. I want to solve all of the equations step by step, first for time=1 then time=2, etc. Can anyone help me solve this set of ODEs using ode15 in MATLAB?

• ode15s definitely can solve an ODE system of more than one equation. What in the documentation gave you the idea that it was for only a single equation? The first example in the ode15s documentation is for a system with 3 equations. – Bill Greene Oct 18 '15 at 13:44
• yes.but for coupled equation its important that solve all equation together in special time. for example first time and then solve all of them in secend time and so on. .i used ode15s and call equation 1.it solve this equation,for all time.then solve second equation.its a problem.because by this method we ignored coupled equations effects. – fatemeh Oct 18 '15 at 14:47
• I typed your equations... but they still are not consistent, please fix that. – nicoguaro Oct 19 '15 at 0:11
• For MOL you should first take all your PDE's and put the time derivatives by themselves on the left hand side (e.g. your first equation schematically would become $a \partial_tC + b \partial_tq = F(C,q,\partial_rC,...)$). Then you must semi-discretize the PDEs, replacing the spatial derivatives of continuous fields with discrete approximations over your mesh. This is how you get a MOL ODE system. – GeoMatt22 Oct 19 '15 at 0:26

In short, yes, you can solve the entire semi-discretized PDE at once using ode15s, or any other ODE solver (ignoring, for the moment, issues of stability and accuracy). I would not arrange the unknowns from the semi-discretized system as a matrix; instead, I would arrange them as one long vector. Although indexing this vector will be cumbersome, expressing the unknowns as a vector better conforms to the interface of MATLAB (and other) ODE solvers, and is consistent with the way the semi-discrete equations are presented in the literature.