Community Tip - You can change your system assigned username to something more personal in your community settings. X

Translate the entire conversation x

Issue with odesolve() in Mathcad Prime 10

engr_mkhalid
10-Marble

Issue with odesolve() in Mathcad Prime 10

Hello everyone,

 

I am solving mass and energy balances for a CSTR using odesolve in a solve block in Mathcad Prime 10. The system includes species balances and an energy balance with the heat of the reaction. However, the solver is not working.

Are there specific issues with my guess values, constraints, or equation setup that I should check? Any guidance on properly structuring odesolve would be helpful.

Thanks!

ACCEPTED SOLUTION

Accepted Solutions
Werner_E
25-Diamond I
(To:Werner_E)

I "fixed" the unit mismatches in your equations - especially the bold "fix" in equation #4 sure is NOT CORRECT!

I just wanted to demonstrate that the solve block with odesolve works OK once you get your equations fixed.

With my 'fixes" the results of Ca, Cb and Cc all looks the same - presumably because of the equal initial value of 10 mol/cm^3.

I tried an initial value of 0 for Ca, but then the solve block fails. A value of 10^-15 was accepted.

Maybe k*Ca*Cb should be in the nominator of the fourth equation?
But as long as you did not fix the equations the correct way it does not make much sense to investigate any further.

Werner_E_0-1739479027196.png

 

Prime 10 sheet attached

 

View solution in original post

5 REPLIES 5
LucMeekes
23-Emerald III
(To:engr_mkhalid)

The solver is working OK, but you're not feeding it a (set of) differential equation(s).

 I see a 'd' in front of some identifiers, clearly intended to denote a differential, but the parameter to which you want to differentiate isn't clear. Specifically I'm missing something like:

LucMeekes_0-1739471138744.png

or

LucMeekes_1-1739471157109.png

to denote e.g. the first derivative of the function Ca with respect to parameter t. You can find these differential operators in the ........Operators menu under the "Math' tab.

In addition something like:

LucMeekes_2-1739471270803.png

confuses Prime. Is Ca a function of t (left hand side of the = ) or is it just a parameter, independent of t (right hand)?

I propose you look up examples of the use of odesolve in the Help system of Prime. Click the circled question mark on the top right of the Prime screen, and search for odesolve.

 

Further:

- If you want to use kJ as a unit, you should define it as a unit (Change its label to 'Unit'.) You find labels in the "style' part of the Math tab on the ribbon.
- You define an R, which is almost half of the (predefined) universal gas constant R, is that intentional?. Type R= and change the label of that R to a 'Constant' and you'll see.

- For Odesolve you don't need any guess values, but you do need initial conditions and they must be placed in the "Constraints' section of the solve block. You now have Ca(t)=0, but that isn't an initial condition. Ca(0)=0 could be an intial condition.

- The function plot() doesn't do what you (might) want. It's undefined. You may want to look up Plots from the menu. It starts with 'Insert plot'.

 

Success!
Luc

 

 

Do you mean your function dC_A(t,...) to be the derivative of the function Ca(t) ?

 

Which units are the functions Ca, Cb, and C supposed to return? All three mol/[volume] ?

T is obviously supposed to return a temperature.

 

Did you look up the example(s) about solving a system of differential equations in the help pages?

E.g. Task 3–4: Solving Multiple ODEs with Solve Blocks

 

Werner_E
25-Diamond I
(To:Werner_E)

Here is how I think you intended to set up your system:

Werner_E_0-1739476965847.png

It fails because you have unit mismatches in all but the very first equation!

The second and third equation seem to be missing a factor V(t) in the first summand.

Not sure about the last equation. The first summand has the correct unit K/s, but the second one is way off wrt the units!!

 

To check the units you may define dummy functions which return the correct units

Werner_E_1-1739477367478.png

Then evaluate the right hand sides of your equations and see if there is an error.

I already added the V(t) in the second and third equation - not sure if this fix is the correct one !!!!

Werner_E_2-1739477491853.png

 

 

 

Werner_E
25-Diamond I
(To:Werner_E)

I "fixed" the unit mismatches in your equations - especially the bold "fix" in equation #4 sure is NOT CORRECT!

I just wanted to demonstrate that the solve block with odesolve works OK once you get your equations fixed.

With my 'fixes" the results of Ca, Cb and Cc all looks the same - presumably because of the equal initial value of 10 mol/cm^3.

I tried an initial value of 0 for Ca, but then the solve block fails. A value of 10^-15 was accepted.

Maybe k*Ca*Cb should be in the nominator of the fourth equation?
But as long as you did not fix the equations the correct way it does not make much sense to investigate any further.

Werner_E_0-1739479027196.png

 

Prime 10 sheet attached

 

Hi @engr_mkhalid,

 

I wanted to see if you got the help you needed.

If so, please mark the appropriate reply as the Accepted Solution. It will help other members who may have the same question.
Please note that industry experts also review the replies and may eventually accept one of them as solution on your behalf.
Of course, if you have more to share on your issue, please pursue the conversation. 

 

Thanks,
Anurag 

Announcements

Top Tags