Message Boards Message Boards

5 Replies
4 Total Likes
View groups...
Share this post:

Why does Mathematica not solve this simple integral (using units)?

Posted 11 years ago
I am trying to find the volume of a PFR reactor. For this purpose I have written the rate expression as a function of conversion, and stuffed it in to an integral. I am using the AutomaticUnits package by Jon McLoone.

The problem is that when I execute the equation containing the integral, Mathematica starts working, but returns no result. I abort the operation after waiting what I would call suffcient time :-)  My setup is seen below:
 rA[X_] := k*((1 - X)/(1 + 2* X)*P/(R  T) - (
       X/(1 + 2 *X)*P/(R  T)*((2*X)/(1 + 2 *X) *P/(R  T))^2)/
       kc) /. {k -> 0.0440238  Minute^-1,
     kc -> 0.025  Mol^2* Liter^-2} //. {P -> 10  Atmosphere,
    T ->  127  Kelvin + 273.15  Kelvin,
    R -> 0.08205746  (Liter*Atmosphere)/(Kelvin*Mol)}
 V == FA0*\!\(
\*SubsuperscriptBox[\(\[Integral]\), \(0\), \( .9*0.512618\)]\(
\*SuperscriptBox[\(rA[X]\), \(-1\)] \[DifferentialD]X\)\)  /. {FA0 ->
   2.5  Mol Minute^-1}

I have investigated it for a long time now, and have found out the following:
  • If I remove the Units, the expression Evaluates as it is supposed to.
  • If I keep the units, and take the reciprocal of 1/rA   (   so just rA   ), it evaluates. Not with the correct answer of course.
  • I have done the exact same operations once before, but with a much smaller function rA, which worked!
I am pretty much on bare ground, and hope someone can help me by pointing out my mistakes. I am afraid the answer is obvious, but I have stared too much at the same two lines of code, and have hence become immune toward finding a solution.

I am using Mathematica 9.

Best Regards

Simon P.
5 Replies
I had not heard of the AutomaticUnits package until your note. 
In my version, Mathematica treats all these "units" as undefined symbols.
Most conveniently cancel.

The AutomaticUnits package I found at
is three years old.  There could be incompatibilities with Mathematica 9.
POSTED BY: Bruce Miller
Posted 11 years ago
Hello Ilian,

So I assume we can conclude that it is an inexplicability in the AutomaticUnits package?
Seems to work fine using the built-in units support in Mathematica 9:
 In[2]:= rA[X_] := k*((1 - X)/(1 + 2*X)*P/(R T) - (X/(1 + 2*X)*P/(R T)*((2*X)/(1 + 2*X)*P/(R T))^2)/
        kc) /. {k -> Quantity[0.0440238, 1/"Minutes"],
     kc -> Quantity[0.025, "Moles"^2/"Liters"^2]} //. {P ->
     Quantity[10, "Atmospheres"], T -> Quantity[127 + 273.15, "Kelvins"],
    R -> Quantity[0.08205746, "Liters" "Atmospheres"/("Kelvins" "Moles")]}
 In[2]:= V = Quantity[2.5, "Moles"/"Minutes"] Integrate[1/rA[x], {x, 0, 0.9*0.512618}]
 Out[3]= Quantity[0.270514, ("Meters")^3]

In[4]:= UnitConvert[V, "Liters"]

Out[4]= Quantity[270.514, "Liters"]
POSTED BY: Ilian Gachevski
What do you get as a result?   I hope I decyphered the linear syntax of your second input correctly.
 In[1]:= $Version
 Out[1]= "9.0 for Mac OS X x86 (64-bit) (January 24, 2013)"
 In[2]:= rA[X_] := k*((1 - X)/(1 + 2*X)*
        P/(R T) - (X/(1 + 2*X)*P/(R T)*((2*X)/(1 + 2*X)*P/(R T))^2)/
        kc) /. {k -> 0.0440238 Minute^-1,
     kc -> 0.025 Mol^2*Liter^-2} //. {P -> 10 Atmosphere,
    T -> 127 Kelvin + 273.15 Kelvin,
    R -> 0.08205746 (Liter*Atmosphere)/(Kelvin*Mol)}

In[3]:= V == FA0*Integrate[ 1/rA[x], {x, 0, 0.9*0.512618}] /. {FA0 -> 2.5 Mol Minute^-1}

Out[3]= V == 270.514 Liter

Do you mean "V=" at the end? 
POSTED BY: Bruce Miller
Posted 11 years ago
Hello Bruce,

Thank you for your reply!

You have decyphered it all correctly. I am sorry you had to do that. I use the *dintt* method in Mathematica, and so it pasted it oddly. 

When I remove the units in the function rA and calculate, I get the same result as you in a matter of seconds (270.514 Liters), which is what I would expect. Nevertheless, when I execute the "V==" with units in rA, Mathematica just keeps running, without finding anything. So after waiting a long time, I just abort. Naturally I would like to calculate the expression with units. Add why does it help reciprocating the reciprocal ( 1/rA )?

What is funny, we run the same operating system, and the same version of Mathematica. Thus I do not get why it does that. Did you use the AutomaticUnits package when you executed?

Best Regards

Simon P.
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
or Discard

Group Abstract Group Abstract