numerical solution for coupled first order DE

asifvg1

New member
Joined
Mar 31, 2021
Messages
1
How can I numerically solve the below equation, assume I have K(z), the solution is in the [0,L] domain, the conditions are: A(0)=1, B(L)=1
1. dA/dz = -K(z)*A(z) -K(z)*B(z)
2. dB/dz = -K(z)*A(z) -K(z)*B(z)
 
How can I numerically solve the below equation, assume I have K(z), the solution is in the [0,L] domain, the conditions are: A(0)=1, B(L)=1
1. dA/dz = -K(z)*A(z) -K(z)*B(z)
2. dB/dz = -K(z)*A(z) -K(z)*B(z)
Please show us what you have tried and exactly where you are stuck.

Please follow the rules of posting in this forum, as enunciated at:


Please share your work/thoughts about this problem.
 
How can I numerically solve the below equation, assume I have K(z), the solution is in the [0,L] domain, the conditions are: A(0)=1, B(L)=1
1. dA/dz = -K(z)*A(z) -K(z)*B(z)
2. dB/dz = -K(z)*A(z) -K(z)*B(z)
There are, of course, many different numerical methods that can be used. I, personally, would divide the interval from 0 to L into N (some large number) sub intervals, 0 to L/N, L/N to 2L/N, 2L/N to 3L/N, etc.. Then write the differential equations as "difference equations", approximating the derivatives by difference quotients:
[math]\frac{dA}{dz}= \frac{A(z_{n+1})- A(z_n)}{z_{n+1}- z_n}[/math] and
[math]\frac{dB}{dz}= \frac{B(z_{n+1})- B(z_n)}{z_{n+1}- z_n}[/math]Of course, with the 0 to L divided into N equal intervals every interval's length, so every [math]z_{n+ 1}- z_n[/math], is [math]\frac{L}{N}[/math] and those can be written
[math]\frac{dA}{dz}= \frac{N(A(z_{n+1})- A(z_n))}{L}[/math] and
[math]\frac{dB}{dz}= \frac{N(B(z_{n+1})- B(z_n))}{z_{L}}[/math]
So the equations become
[math]\frac{N(A(z_{n+1})- A(z_n))}{L}= -K(z_n)A(z_n)- K(z_n)B(z_n)[/math] and
[math]\frac{N(B(z_{n+1})- B(z_n))}{z_{L}}= -K(z_n)A(z_n)- K(z_n)B(z_n)[/math]That gives you a system of 2N equations to solve for 2n+ 2 values of [math]A(z_n)[/math] and [math]B(z_n)[/math]. That "+ 2" is the reason you need the boundary conditions, A(0)= 1 and
B(L)= 1,

(Of course, you should see immediately that [math]\frac{dA}{dz}= \frac{dB}{dz}[/math] so that A and B can only differ by a constant.)
 
Top