You will write three functions that follow a reversible reaction in a closed container. One takes one small step in time. One runs many steps. One tests if the reaction is at equilibrium.
The idea. In a small time step dt, the forward reaction changes kf * a * dt of A into B, and the reverse reaction changes kr * b * dt of B back into A. At equilibrium the two rates are equal, so kf * a equals kr * b.
Your tasks.
step(a, b, kf, kr, dt). It returns the new amounts (a, b).run(a, b, kf, kr, dt, steps). It repeats step and returns the final (a, b).at_equilibrium(a, b, kf, kr, tolerance). It returns True if the forward and the reverse rates differ by less than tolerance.Have you tried it?
Do the tasks in the editor first, and run the checker after each one. Its hints help when a check fails. When you are ready, compare your code with this solution.
Log in to join the discussion.
Loading…