cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

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

Stiff ode solvers

JohnRudnicki
14-Alexandrite

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. 

 

8 REPLIES 8

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

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

Werner_E
24-Ruby V
(To:-MFra-)


@-MFra- wrote:

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


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.

-MFra-
21-Topaz II
(To:Werner_E)

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.

Werner_E
24-Ruby V
(To:-MFra-)

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.

Werner_E_0-1632490641958.png

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:

Werner_E_1-1632491078893.png

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:

Werner_E_2-1632491172634.png

 

 

 

-MFra-
21-Topaz II
(To:Werner_E)

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

Werner_E
24-Ruby V
(To:-MFra-)


@-MFra- wrote:

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


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.

-MFra-
21-Topaz II
(To:Werner_E)

Please delete. Thank you.

 

Top Tags