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
- :
- Re: Stiff ode solvers

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

01-10-2021
02:17 PM

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

01-10-2021
02:17 PM

Stiff ode solvers

I previously posted a version of this question, but did not get any response. So I decided to rephrase and try again.

I have been trying to compare the solvers (BDF, Radua, Stiffr and Stiffb) for stiff odes. Could be doing something stupid but BDF is the only one that I can get to run consistently. For the others I get error messages I do not understand (in this context):

"The return value of this function must match the problem size"

"This value must be real"

(BTW. Documentation says Stiffb does not work for more than 8 equations, but it seems like it should be "8 or more". 7 worked. 8 did not.)

Thanks to anyone who chimes in.

If you run the worksheet, be patient. It takes a while to calculate.

Labels:

8 REPLIES 8

09-23-2021
03:56 PM

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

09-23-2021
03:56 PM

What is the initial setting of the problem that you want to solve with the program?

P.S. Crosspost: https://community.ptc.com/t5/PTC-Mathcad/Error-messages-in-solving-a-system-of-ode-s/m-p/704764

09-24-2021
02:44 AM

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

09-24-2021
02:44 AM

The constant tp is neither defined nor initialized anywhere. How does the processor calculate sin (2πt / tp)?

09-24-2021
05:55 AM

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

09-24-2021
05:55 AM

@-MFra- wrote:

The solve block is evaluated symbolically and the result is assigned to a function D which has tp (substituted by y[5) as one of its arguments. So all is OK and when you let the sheet run it works OK (at least with BDF and Radau & IC21).

BTW, VladimirN had unearthed a more than 8 months old question and obviously no one had an idea so far why the solvers other than BDF fail.

09-24-2021
07:36 AM

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

09-24-2021
07:36 AM

Although you work in symbolic, don't you have to initialize the variables first and then reset them for symbolic computation? otherwise if you write tp = ? before the Given, it marks it in red. As a result nothing changes, on this I agree.

09-24-2021
09:37 AM

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

09-24-2021
09:37 AM

Why would you write tp = ... ? Sure the variable is not defined but its not necessary to define it as its just used as a formal function argument (disguised as y[5).

A solve block which is evaluated symbolically (a feature not available in Prime) does not need any guess values for the variables solved for.

Here is an example to demonstrate defining a function similar but much simplified to the one in the worksheet. Neither a nor b need to be initialized - "a", because we evaluate symbolically and "b" because its provided as function argument:

And here is the same using "substitute" to change the name of the formal function argument, similar to the procedure done in the worksheet but not using a vector as we only deal with one single variable:

09-24-2021
10:58 AM

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

09-24-2021
10:58 AM

Thanks for the clarification. However, I always prefer to define variables and then reset them in case I need them for a symbolic calculation.

09-24-2021
11:38 AM

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

09-24-2021
11:38 AM

@-MFra- wrote:

You sure do not define a variable x if you intend to define a function f(x):=.... later.

And so it also was not done in the worksheet with the variable tp (and others). The use of the solve block with symbolic evaluation and the substitution with x[5 just obscured the fact, that its just a "simple" definition of a function D of tp and other arguments.

But of course I agree thats its often good habit to define variables (and un-define them symbolically) which are used in symbolic evaluations and assignments to avoid the error from the numeric engine.

09-24-2021
02:25 PM

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

09-24-2021
02:25 PM

Please delete. Thank you.