topic Re: Stiff ode solvers in PTC Mathcad
https://community.ptc.com/t5/PTC-Mathcad/Stiff-ode-solvers/m-p/749983#M197389
<P>The constant tp is neither defined nor initialized anywhere. How does the processor calculate sin (2πt / tp)?</P>Fri, 24 Sep 2021 06:44:03 GMT-MFra-2021-09-24T06:44:03ZStiff ode solvers
https://community.ptc.com/t5/PTC-Mathcad/Stiff-ode-solvers/m-p/706715#M193850
<P>I previously posted a version of this question, but did not get any response. So I decided to rephrase and try again.</P>
<P> </P>
<P>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):</P>
<P>"The return value of this function must match the problem size"</P>
<P>"This value must be real"</P>
<P>(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.)</P>
<P>Thanks to anyone who chimes in. </P>
<P>If you run the worksheet, be patient. It takes a while to calculate. </P>
<P> </P>Sun, 10 Jan 2021 19:17:44 GMThttps://community.ptc.com/t5/PTC-Mathcad/Stiff-ode-solvers/m-p/706715#M193850JohnRudnicki2021-01-10T19:17:44ZRe: Stiff ode solvers
https://community.ptc.com/t5/PTC-Mathcad/Stiff-ode-solvers/m-p/749899#M197380
<P><SPAN class="VIiyi"><SPAN class="JLqJ4b ChMk0b" data-language-for-alternatives="en" data-language-to-translate-into="ru" data-phrase-index="0"><SPAN>What is the initial setting of the problem that you want to solve with the program?</SPAN></SPAN></SPAN></P>
<P> </P>
<P>P.S. Crosspost: <A href="https://community.ptc.com/t5/PTC-Mathcad/Error-messages-in-solving-a-system-of-ode-s/m-p/704764" target="_blank">https://community.ptc.com/t5/PTC-Mathcad/Error-messages-in-solving-a-system-of-ode-s/m-p/704764</A></P>Thu, 23 Sep 2021 19:56:53 GMThttps://community.ptc.com/t5/PTC-Mathcad/Stiff-ode-solvers/m-p/749899#M197380VladimirN2021-09-23T19:56:53ZRe: Stiff ode solvers
https://community.ptc.com/t5/PTC-Mathcad/Stiff-ode-solvers/m-p/749983#M197389
<P>The constant tp is neither defined nor initialized anywhere. How does the processor calculate sin (2πt / tp)?</P>Fri, 24 Sep 2021 06:44:03 GMThttps://community.ptc.com/t5/PTC-Mathcad/Stiff-ode-solvers/m-p/749983#M197389-MFra-2021-09-24T06:44:03ZRe: Stiff ode solvers
https://community.ptc.com/t5/PTC-Mathcad/Stiff-ode-solvers/m-p/750017#M197392
<BLOCKQUOTE><HR /><LI-USER uid="263723"></LI-USER> wrote:<BR />
<P>The constant tp is neither defined nor initialized anywhere. How does the processor calculate sin (2πt / tp)?</P>
<HR /></BLOCKQUOTE>
<P>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).</P>
<P>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.</P>Fri, 24 Sep 2021 10:03:14 GMThttps://community.ptc.com/t5/PTC-Mathcad/Stiff-ode-solvers/m-p/750017#M197392Werner_E2021-09-24T10:03:14ZRe: Stiff ode solvers
https://community.ptc.com/t5/PTC-Mathcad/Stiff-ode-solvers/m-p/750032#M197394
<P>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.</P>Fri, 24 Sep 2021 11:36:20 GMThttps://community.ptc.com/t5/PTC-Mathcad/Stiff-ode-solvers/m-p/750032#M197394-MFra-2021-09-24T11:36:20ZRe: Stiff ode solvers
https://community.ptc.com/t5/PTC-Mathcad/Stiff-ode-solvers/m-p/750072#M197401
<P>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).</P>
<P>A solve block which is evaluated symbolically (a feature not available in Prime) does not need any guess values for the variables solved for.</P>
<P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Werner_E_0-1632490641958.png" style="width: 712px;"><img src="https://community.ptc.com/t5/image/serverpage/image-id/46544i196D0AAD7A0E7AAD/image-dimensions/712x93?v=v2" width="712" height="93" role="button" title="Werner_E_0-1632490641958.png" alt="Werner_E_0-1632490641958.png" /></span></P>
<P>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:</P>
<P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Werner_E_1-1632491078893.png" style="width: 473px;"><img src="https://community.ptc.com/t5/image/serverpage/image-id/46545iEA884A6E732282B5/image-dimensions/473x84?v=v2" width="473" height="84" role="button" title="Werner_E_1-1632491078893.png" alt="Werner_E_1-1632491078893.png" /></span></P>
<P>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:</P>
<P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Werner_E_2-1632491172634.png" style="width: 586px;"><img src="https://community.ptc.com/t5/image/serverpage/image-id/46546iA0A4355CB6456413/image-dimensions/586x82?v=v2" width="586" height="82" role="button" title="Werner_E_2-1632491172634.png" alt="Werner_E_2-1632491172634.png" /></span></P>
<P> </P>
<P> </P>
<P> </P>Fri, 24 Sep 2021 13:48:09 GMThttps://community.ptc.com/t5/PTC-Mathcad/Stiff-ode-solvers/m-p/750072#M197401Werner_E2021-09-24T13:48:09ZRe: Stiff ode solvers
https://community.ptc.com/t5/PTC-Mathcad/Stiff-ode-solvers/m-p/750095#M197405
<P>Thanks for the clarification. However, I always prefer to define variables and then reset them in case I need them for a symbolic calculation.</P>Fri, 24 Sep 2021 14:58:22 GMThttps://community.ptc.com/t5/PTC-Mathcad/Stiff-ode-solvers/m-p/750095#M197405-MFra-2021-09-24T14:58:22ZRe: Stiff ode solvers
https://community.ptc.com/t5/PTC-Mathcad/Stiff-ode-solvers/m-p/750109#M197408
<BLOCKQUOTE><HR /><LI-USER uid="263723"></LI-USER> wrote:<BR />
<P>Thanks for the clarification. However, I always prefer to define variables and then reset them in case I need them for a symbolic calculation.</P>
<HR /></BLOCKQUOTE>
<P>You sure do not define a variable x if you intend to define a function f(x):=.... later.</P>
<P>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.</P>
<P> </P>
<P>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.</P>Fri, 24 Sep 2021 15:48:21 GMThttps://community.ptc.com/t5/PTC-Mathcad/Stiff-ode-solvers/m-p/750109#M197408Werner_E2021-09-24T15:48:21ZRe: Stiff ode solvers
https://community.ptc.com/t5/PTC-Mathcad/Stiff-ode-solvers/m-p/750127#M197411
<P>Please delete. Thank you.</P>
<P> </P>Sat, 25 Sep 2021 17:22:19 GMThttps://community.ptc.com/t5/PTC-Mathcad/Stiff-ode-solvers/m-p/750127#M197411-MFra-2021-09-25T17:22:19Z