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

Community Tip - Did you get an answer that solved your problem? Please mark it as an Accepted Solution so others with the same problem can find the answer easily. X

ODE solving inside programs

ptc-2487356
1-Newbie

ODE solving inside programs

Hello! This is my problem: I have to solve a second order ordinary differential equation with a set of different values for a parameter, and I would like to avoid to do it manually. I've tried to put the Rkadapt inside a program, but it refuses to accept the vector containing the derivatives (it doesn't recognize the variable t inside D(t,y)), while it seems to accept the vector with initial conditions. Actually, MathCad produces a result if leave D(t,y) OUTSIDE the program, but since my parameter expressing initial conditions is contained also in D(t,y), it gives the solution with a value of the parameter defined above, not with the values defined inside the program (on the contrary it seems to recognize the changing initial conditions defined inside the program). Is there any way to do it? Is there some other way to do it without using programs? Thanks in advance
5 REPLIES 5
RichardJ
19-Tanzanite
(To:ptc-2487356)

Take a look at this thread: http://www.ptc.com/forums/viewtopic.php?t=3778 and this thread: http://www.ptc.com/forums/viewtopic.php?t=4065 Richard

Could you post the sheet? Rkadapt is quite commonly used within a program structure -- no problem. But your wording suggests that you are doing something wrong. Rkadapt (along with the other command line solvers), does not take as a parameter a vector of derivatives. Rather it takes a function which returns such a value. While common usage does not make a distinction between a function and an expression whose value is the value of the function, mathematics and programming both do. To use any of the command line solvers you must define a function that calculates the derivatives and you must pass the function (i.e., just the name to which the function has been assigned) to the solver.

Dear Tom, thanks for answering me. I follow your suggestion and I attach a MathCad 11 sheet with the ODE (it involves some auxiliary functions), first alone, and than inside a program. As you will see, apparently it works, but since I leave outside the program the initial conditions containing the parameter Delta (these can be moved inside the program without errors) and the vector of the derivatives (which I cannot move inside), the results refer all to the initial value of Delta, defined above in the sheet, outside the program. Obviously I'm making something wrong. I thank you in advance for any suggestion. Best regards Marino

I hope you're using MC13 or 14, as the simple approach only works with those. This can be done with MC11, but it requires a few contortions that I prefer to avoid. If you still have problems, I suggest starting a thread over in the collaboratory (see announcement in main forum for link), where there are more people and it's easier to post and download files.

Thank you so much Tom. I have MathCad14, so there are no problems! Thank you again Best regards Marino
Top Tags