I have a simple chemical system $A\rightarrow B$ with $k_1$ and $A_1\rightarrow B$ with $k_2$. I can easily solve it with different packages but I wanted to learn the Euler way. I am solving it in Python. I can describe $A$ and $A_1$ but with $B$ I have some difficulties, hope you guys could help. so the equations goes like this:
da_dt = -k1* ca
da1_dt = -k2 *ca1
db_dt = (k1 * ca) + (k2 * ca1)
In python euler I wrote it like that :
import numpy as np
import matplotlib.pyplot as plt
Nt = 1000
time = 10
delt = time/Nt
ca0_0 = 1
ca1_0 = 0.5
k1 = 1
k2 = 1
tt = np.linspace(0,time,Nt+1)
ca = np.zeros(Nt+1)
ca1 = np.zeros(Nt+1)
cb = np.zeros(Nt+1)
ca[0] = ca0_0
ca1[0] = ca1_0
cb[0] = 0
for t in range(0, Nt):
ca[t+1] = ca[t] - ca[t] * k1 * delt
ca1[t+1] = ca1[t] -ca1[t] *k2 *delt
#here needs to come the cb part
which is absolutley wrong. I just can't grasp the idea what to do with the final B product.
Solved with help of @user10354138