Get Help

Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Community
- :
- PTC Mathcad
- :
- PTC Mathcad
- :
- ODE solve tolerance

Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Highlighted

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

09-13-2018
03:05 AM

09-13-2018
03:05 AM

Greetings!

I am solving a pair of odes using mathcad built in odesolve function. I want to know if there is a way to alter the default tolerance and number of iterations of this function.

Because when i solve it its gives a statement that solution is not converging to a solution refer to Help.

Thanks.

Solved! Go to Solution.

1 ACCEPTED SOLUTION

Accepted Solutions

Highlighted

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

09-17-2018
04:17 AM

09-17-2018
04:17 AM

You can change the tolerance via the menu or by typing TOL:=... at the top.

But the problem is that the numerical derivative of v is not defined at the end values (0 and 0.34) - its wrongly set to 0!.

So you may extend the ends a little bit like shown in the picture to make it work.

22 REPLIES 22

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

09-13-2018
03:22 AM

09-13-2018
03:22 AM

Re: ODE solve tolerance

You can change the value of TOL. Set TOL:=10^-6 say (the default value is 10^-3).

However, this might not be the root cause of your problem. There are many reasons why the solution might not converge. It would be a good idea to upload your worksheet so the community can investigate.

Alan

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

09-13-2018
04:02 AM

09-13-2018
04:02 AM

Re: ODE solve tolerance

@Asad wrote:

Greetings!

I am solving a pair of odes using mathcad built in odesolve function. I want to know if there is a way to alter the number of iterations of this function.

Thanks.

May by so

Odesolve(y, t, [number of iterations])

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

09-17-2018
02:58 AM

09-17-2018
02:58 AM

Re: ODE solve tolerance

I am using mathcad prime 2.0 to solve the ODEs. In the solve block I have typed
x:=odesolve(x(z),0.47,1000000000)
and now it gives a new error that there is not enough memory for this calculation.
I am uploading the work sheet, help would be highly appreciated!
A little about the ODEs:
there are two varibles velocity (v) and concentration (x) that are varying along the z-axial direction.
Taking an initial guess for dx/dz in the first equation to obtain and answer for v and dv/dz.
Then using the answers obtained in last step I put them in the second equation to solve for x and dx/dz.
After successfully getting an answer I will then make a mathcad while loop with these solve blocks and iterate them until a desired solution is obtained.
Thanks

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

09-17-2018
03:01 AM

09-17-2018
03:01 AM

Re: ODE solve tolerance

and if i put another zero

x:=odesolve(x,0.47, 10000000000)

it says found a number with a magniture greater than 10^307 while trying to evaluate this expression

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

09-17-2018
03:05 AM

09-17-2018
03:05 AM

Re: ODE solve tolerance

Is there a way to change the tolerance?

Highlighted

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

09-17-2018
04:17 AM

09-17-2018
04:17 AM

You can change the tolerance via the menu or by typing TOL:=... at the top.

But the problem is that the numerical derivative of v is not defined at the end values (0 and 0.34) - its wrongly set to 0!.

So you may extend the ends a little bit like shown in the picture to make it work.

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

09-17-2018
05:42 AM

09-17-2018
05:42 AM

Re: ODE solve tolerance

Or, just change the end time for the v ode to something significantly larger:

Alan

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

09-17-2018
06:15 AM

09-17-2018
06:15 AM

Re: ODE solve tolerance

Hmm, thats interesting, that the end value of the first odesolve block has such an impact on the acceptance of the start value in the second solve block.

Its also a matter of the precision settings. With TOL:=10^-9 the solve block still fails with end value 0.5 in the first one.

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

09-17-2018
09:36 AM

09-17-2018
09:36 AM

Re: ODE solve tolerance

I've just noticed the following taken from the Prime 2 help file:

Alan

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

09-17-2018
11:33 AM

09-17-2018
11:33 AM

Re: ODE solve tolerance

After your first post I played around and found that your way of working around the problem failed as long as I had TOL:=10^-9 in front. When I changed it to the default 10^-3 the second odesolve block worked OK. So in contrary to what the help says it look like the setting of TOL has some effect on the solve block.

When I open the sheet you posted (in Prime 5) the second odesolveblock fails - even when I delete the last line and retype it.

Strange effects, indeed.

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

09-17-2018
10:13 AM

09-17-2018
10:13 AM

Re: ODE solve tolerance

A similar problem occurs in mathcad 15. However, if Adams/BDF is replaced by Radau in the second odesolve it works ok with 0.34 as the end time in both. Of course, this isn't an option in Prime.

Alan

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

09-17-2018
06:31 AM

09-17-2018
06:31 AM

Re: ODE solve tolerance

Can both of you please send me your worksheet file because my answer is still not converging.

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

09-17-2018
09:25 AM

09-17-2018
09:25 AM

Re: ODE solve tolerance

Strangely, when I reloaded my worksheet it also failed! However, by deleting the last odesolve command and simply re-entering it the calculation converged!

Worksheet attached.

Alan

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

09-13-2018
07:48 AM

09-13-2018
07:48 AM

Re: ODE solve tolerance

Hi Asad,

Have you tried to change algorithm?

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

09-14-2018
02:04 AM

09-14-2018
02:04 AM

Re: ODE solve tolerance

@-MFra- wrote:

Hi Asad,

Have you tried to change algorithm?

Only in Mathcad 15!

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

09-18-2018
02:21 AM

09-18-2018
02:21 AM

Re: ODE solve tolerance

RIght! So a combination of both of your solutions worked for me and if the solution does not converge I just alter the starting and ending points of the boundary conditions.

I worked on it and:

v:=odesolve(v(z),2,100000000) with v(0)=0.4

x:=odesolve(x(z),1.2,1000000) with x(10^-307)=x_in

then for the second iteration

v:=odesolve(v(z),0.9) with v(10^-306)=0.4

x:=odesolve(x(z),0.47) with x(10^-305)=x_in

Thanks a lot for the help!

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

09-18-2018
02:23 AM

09-18-2018
02:23 AM

Re: ODE solve tolerance

Also, is there any other function besides odesolve to solve the differential equations like the ones stated in comments such as radau or any other. For better accuracy..

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

09-18-2018
12:30 PM

09-18-2018
12:30 PM

Re: ODE solve tolerance

As was already written in contrary to Mathcad 15 and below we can not manually chose the algorithm used by odesolve - we have to rely on the automatic selection.

For other ways to solve ODEs numerically you may look up the various function in the help.

See the attached picture.

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

09-19-2018
03:44 AM

09-19-2018
03:44 AM

Re: ODE solve tolerance

Can you send me your worksheet file in which you have set the initial and final boundary conditions for the derivative of v.

The worksheet of the picture you posted.

Thanks!

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

09-19-2018
07:05 AM

09-19-2018
07:05 AM

Re: ODE solve tolerance

@Asad wrote:

Can you send me your worksheet file in which you have set the initial and final boundary conditions for the derivative of v.

The worksheet of the picture you posted.

Thanks!

I did not save and store that worksheet.

I could change the few values again and post but it won't help as I am using a newer version of Prime and you would not be able to open the worksheet as you wrote that you are using Prime 2. Newer versions of prime are not able to save a sheet in an older format.

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

09-18-2018
03:34 PM

09-18-2018
03:34 PM

Re: ODE solve tolerance

The other functions are still there and usable, but they require setting up and they don't use a solve block. They also don't improve the accuracy. (If you have accuracy issues the old wisdom suggests rescaling your problem.)

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

09-19-2018
08:06 AM

09-19-2018
08:06 AM

Re: ODE solve tolerance

@FredKohlhepp wrote:

SpoilerSpoilerRadau, Rkfixed, Rkadapt and the others do not return a function like odesolve; they return a matrix of points with the ordinate points in the first column and solutions in the subsequent columns.

When I open this (the "Quote function" did not replicate it) I saw the first paragraph and

>Spoiler

Two clicks later I saw this:

So, what's a "Spoiler"?