I'm going to describe how to solve
a set of differential equations,
ordinary differential equations.
In this case, two equations, they're similar,
make the little easier to input the information
for the demonstration.
But we have initial condition sorry,
independent variables V, capital V,
and at V equals zero, or one of our dependent variable CA
is CA zero.
And that's a value, we know 21.39.
And likewise, for CB, at V equals zero, CB is CB zero.
And so we have a number of parameters,
and we have the numerical values.
And then we have listed here on the left
the iteration scheme, so we're gonna step through
in small steps for dV.
This case, dV is point O five,
and we're gonna step through into V is equal to 20.
So 400 steps,
and the equations that we use to calculate CA
at the next step, so we know for example, CA zero,
and then we want to calculate CA one, so we take CA zero,
and then we calculate these four k values.
And that gives us CA one
and we get CA two from CA one et cetera.
And here are the k values
from the Runga-Kutta Method, fourth order.
Keep in mind, this is going to work
if we don't have equations that are very stiff,
because I'm doing this calculation with a fixed step size.
So what I've done is put in the names for the constants,
and then I put in their value next to it.
Now originally, what I ended up doing
was going into formulas under create from selection
in the left column.
This is how we name the cells,
I won't do it since I've already done it here.
But you'll notice this first cell
if we look in the upper left, it's named P,
this cell is KA and so forth.
And I put the unit's here, again, not important here,
but it's a good practice to put unit
so we don't get confused later.
And so over here where we're gonna do
the iteration step through,
I've entered our initial value at v equals zero,
this is CA zero, this is CB zero.
And then I put here the equation for K one.
So in this cell is this equation that's down here,
the bottom left for K one, where CA n is equal to CA zero,
so we look at the equation,
and I'll move over to make the it easier to see
s six times t six, that's s six and t six,
that's CA zero CB zero.
So those are starting values,
and likewise k two k three k four,
and then we can calculate CA using the equation
that CA one is CA zero,
that's s six up here and the formula for this cell,
plus k one plus two k two plus two k three plus k four
multiplied by dV and divided by six.
So I calculated the new value of CA
for a V value of point O five.
And I did the same thing for CB a verly,
very similar equation. Right.
Now what I wanna is repeat this 400 times.
And so what I'm going to do is just take these cells
and notice what I've done by filling we're every point five,
we're gonna do the calculation,
let me pause and do this up to a volume of 20.
So you can see if going to cell 406
we have a value of 20.
And now I want to copy these formulas.
So for example, let me show you a few steps.
You notice as v increases
CA and CB are decreasing slightly.
Well, I'm just gonna again pause
and do this all the way out to V equals 20.
And so you can see, essentially here, these two cells,
the cells I made yellow,
that's the solution that we're looking for at V equals 20.
This is the value for CA this is the value for CB.
So we solve these two ordinary differential equations
by using a fixed step fourth order Runge-Kutta Method.
We could certainly use a smaller step size,
we end up getting the same answer
within the accuracy ranges to them.
So it's certainly faster to not use small step size
and you can see the calculations are fast.
The other thing we can do that you saw since we're in Excel
We could say, what?
How does our answer change
if we change one of these parameters?
So for example, suppose we look at changing v zero.
And what we want to know is, what's the new final value,
let me call it final for CA and the new.
Let's just do CA for now.
So I'm gonna put in just to few random values for V zero.
So my do is create a simple data table.
Those are the values of v zero.
So what I wanna do is, in this cell,
I wanna insert the value,
that's the solution to our differential equation
for S that's value and cell as for six
we just looked at.
And so I wanna now do the calculation
for a bunch of different values of v zero.
And so what we do is select these locations these cells,
and we go to data.
In what if analysis data table
and what we wanna enter is column input cell,
and that's our value for v zero. And then if we hit OK,
you can see it's now calculated of course
at V zero is one what we started out with,
so it calculates the value and then as V zero changes,
the solution changes
and it is solving the differential equations
seven times very quickly,
to give us a quick way of looking at
how the solution depends on this particular parameter.
So we can certainly look at
more complicated differential equations
and solve them in Excel.
And the only thing that will slow
is typing in these values of the case.