I have these three differential equations in which I need to solve numerically:

$$ \frac{dn_0}{dt}= -n_0(t)W_{01}(t) + n_1(t)K_{10} $$

$$ \frac{dn_1}{dt}= -n_1(t)W_{12}(t) - n_1(t)K_{10} + n_2(t)K_{21} + n_0(t)W_{01}(t) $$

$$ \frac{dn_2}{dt}= n_1(t)W_{12}(t) - n_2(t)K_{21} $$

such that

$$ n_0(0)=1 $$ $$ n_0(N)=0 $$ $$ n_1(0)=0 $$ $$ n_1(N)=1 $$ $$ n_2(0)=0 $$ $$ n_2(N)=0 $$

Using the central finite difference formula:

$$\frac{n_{0}(t + \Delta t) - n_{0}(t - \Delta t)}{2\Delta t}=-n_0(t)W_{01}(t) + n_1(t)K_{10}$$

$$\frac{n_{1}(t + \Delta t) - n_{1}(t - \Delta t)}{2\Delta t}=-n_1(t)W_{12}(t) - n_1(t)K_{10} + n_2(t)K_{21} + n_0(t)W_{01}(t)$$

$$\frac{n_{2}(t + \Delta t) - n_{2}(t - \Delta t)}{2\Delta t}=n_1(t)W_{12}(t) - n_2(t)K_{21} $$

How do I determine the functions $n0$, $n1$ and $n2$ knowing that $n0 + n1 + n2 =1$, and that the three equations are coupled?

And I could not understand how to calculate the derivatives, how can I determine their value with the finite difference method without knowing the functions?

Can someone please help me?

  • $\begingroup$ Would Computational Science be a better home for this question? $\endgroup$ – Qmechanic Jan 7 '19 at 12:03
  • $\begingroup$ Do you understand what the finite difference method is supposed to do? Or are you trying to put the proverbial cart before the horse by getting the simulation done before knowing how it works? $\endgroup$ – Kyle Kanos Jan 7 '19 at 13:06

You have $3(N-1)$ unknown quantities, $n_0(1) \dots n_0(N-1)$, $n_1(1) \dots n_1(N-1)$, and $n_2(1) \dots n_2(N-1)$.

The central difference equations give you $3(N-1)$ linear equations in those quantities, and also in $n_0(0), n_0(N), n_1(0), n_1(N), n_2(0), n_2(N)$, but you know those 6 values from the boundary conditions.

Set up the equations as a $3(N-1) \times 3(N-1)$ matrix and vectors of length $3(N-1)$ and solve them with MATLAB or whatever software you have.

Since the finite difference equations and the boundary conditions are consistent with the fact that $n_0 + n_1 + n_2 = 1$ everywhere, the numerical solution should have the same property.

You find the derivatives using the central difference approximation in your OP, i.e. $$n'_0(k) \approx \frac{n_0(k+1) - n_0(k-1)}{2h}, \quad k = 1 \dots N$$ and similarly for $n'_1$ and $n'_2$, where $h$ is the value of $\Delta t$ in "real world" physical units.

  • $\begingroup$ Hmm, so I did it now. $$ \frac{n_{0_{i+1}} - n_{0_{i-1}}}{2\Delta t}= -n_0(t_i)W_{01}(t_i) + n_1(t_i)K_{10}$$ with $$ t_i= (i-1)\Delta t $$ and $$ i= 2,3,... N-1 $$ for $$ \Delta t=\frac{b-a}{N-1} $$ knowing that this gives a system of the type $$ Au=B$$ I can not think of a way to fill the array. I say, on the right side of the equation, what values $ n_0(t_i)$ and $n_1(t_i)$ assume as $t_i$ varies? $\endgroup$ – M. Douglas Jan 7 '19 at 23:17

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