Skip to main content
Chemistry LibreTexts

Numerical Solutions

  • Page ID
  • Code \(\PageIndex{1}\) (Python):

    import numpy as np
    from scipy.integrate import odeint
    import matplotlib.pyplot as plt
    def rxn1st(C,t,*k):
      r1=k[0]*C[0] #k[0]*(concentation of A)
      dAdt=-r1 #rate of change of A decreased by forward reaction and increased by reverse reaction
      dBdt=r1 #rate of change of B increased by forward reaction and decreased by reverse reaction
    t=np.linspace(0,10,101) #the first number is the beginning point, the second number is the end, and the third is the number of points.
    C0=[1,0] #initial concentrations of A and B
    cA=C[:,0] #define cA to give the concentration from the first (zeroth) column of the C array
    cB=C[:,1] #define cB to give the concentration from the second column of the C array
    • Was this article helpful?