In this video we will describe how to use POLYMATH to solve ordinary differential equations,
in particular we'll do this for an example of a packed bed catalytic reactor where the
mass balances have been obtained in another video, and so the exact same numbers will
be used here.
So we're solving differential equations in essentially a plug flow reactor, where the
independent variable is the catalyst weight.
And so the first thing we want to do is, once we've opened POLYMATH, is select differential
equations, and then we're going to want to save into a file, and then we're ready to
start entering differential equations, so this button, enter new differential equation,
and we'll write the equation for the product M as a function of the independent variable
W, the cumulative weight.
There's no M coming into the reactor, so the initial condition is zero, and the equation
is the rate constant multiplied by the pressure of hydrogen (first order reaction in pressure).
And then we can put a comment in here like "The molar flow rate of M." And then you can
see what that does.
It puts comments preceded by the number symbol.
Well we have the differential equation that we're solving, an initial condition, now we
can do the same thing for the other differential equations, now I've already previously typed
them so I'll just copy them in here.
So we have three differential equations, and then we can start entering the other information.
For example, we need the rate constant, which is 1.74, and if I want I can certainly add
a comment by putting a tine and putting, in this case what might be useful is the units
of the rate constant.
I can also enter other variables such as the initial pressure, and pressure's constant
so this is the total pressure in the system, this is in bar.
And of course I'm going to want the pressure of hydrogen because that shows up in these
expressions, and I can write that as the mole fraction of hydrogen multiplied by this total
pressure, which means we want to enter an equation for the mole fraction of hydrogen,
and I can write the mole fraction in terms of flow rates.
So the mole fraction of hydrogen would be the molar flow rate of hydrogen divided by
the total molar flow rate.
So that's the molar flow rate of hydrogen, plus the flow rate of M, plus the flow rate
of C, where C is the other reactant that reacts with hydrogen.
That gives me now the mole fraction of hydrogen, which allows me to calculate the pressure,
and the pressure then appears in these equations.
So I'm almost finished with the differential equations, what I need now is the initial
and final conditions which is this button.
So the initial value for W, the catalyst weight, is zero.
At the beginning of the reactor there's no catalyst yet.
And for this particular problem we're going to integrate to total catalyst weight, which
happens to be 4.8 kilograms.
So now we have the initial and final values, and we can solve this equation.
What we're going to do is enter a few other equations just to demonstrate the ability,
once we have the equations in here, that we want to calculate, for example, in addition
to the molar flow rates, like the concentration of C, which is related to the molar flow rate
of C divided by the volumetric flow rate.
So I've entered equations to calculate the concentrations, but now we need the volumetric
flow rate.
So the volumetric flow rate (it's a gas phase system) is going to equal to the total molar
flow rate, total molar flow rate meaning flow rate of hydrogen, flow rate of C, flow rate
of M, multiplied by R, the gas constant, and T, and divided by the pressure, which means
we need to enter a value for T, which is 170 degrees C. So we need to make this an absolute
value, and we need to enter a value for R, which is 83.14, and this is another case where
a comment might be useful.
This is in cubic centimeters, and bar and moles Kelvin.
So now we think we're ready to solve the equation, but we actually have a mistake, and one way
we check is if we click this, it will tell us that we have an undefined variable FM,
and the reason for that is that I made a typo.
This should be the flow rate of M, not derivative of just M, because the flow rate of M is what
we're using in these calculations as molar flow rate.
Now if I check this, we have to have an initial value for FM, and so I change that, and it
says the program is ready to solve.
And to solve it, we hit the solve arrow, and it gives us the values for the variables,
their initial value, their final values, so these are concentrations, the molar flow rate's
initial value, the final value you notice we're reacting essentially to zero.
So obviously we can't have the flow rate of C in a real system being negative, so we have
essentially reacted almost everything that's entered the reactor, and we have a slight
excess of hydrogen relative to reactant C. It shows what the differential equations are,
it shows the explicit equations and the comments, and gives additional information.
Now, we can go back, for example, we have two windows in this.
Here's our original equations.
When we asked it to solve and it gave us a report, we could instead ask it to generate
a graph, and so if we do Solve, it's now plotting for us the flow rates, and in this case it's
allowing the possibility because of the way the equations are set up that we could go
negative even though in reality that cannot take place.
So this is the flow rate of hydrogen, the flow rate of reactant C, and then the flow
rate of product M. Now I've made the scales a little better to make it a little clearer
to see by just reformatting, and that's going into options and to format, and then for example
i could put a title of a "Packed bed reactor," and I can change the format of the axes, the
font, for the earlier version I showed you, I changed the minimum value for Y, and I can
change the font sizes, and I think that gives us a pretty good idea of the options that
we have.
Well, we can also, for example the label format, I could put a decimal there.
I could change the fonts to make them bigger, but essentially, we're able to calculate the
flow rates as a function of the weight of catalyst, and solve the differential equations
using POLYMATH.
I was going to say, we can also look at the data numerically.
This brings up a table that we could download into Excel, for example.
This shows the values used that generate the graph.
And so, this is a good demonstration of using POLYMATH.
If we now, for the same system, wanted to account for a pressure drop through this packed
bed reactor, all we'd have to is add another equation with initial conditions and it would
be very easy to solve it.
Likewise, if we wanted to make it isothermal, we could just add an energy balance and a
rate constant dependence on temperature, and re-solve it.