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

Community Tip - Stay updated on what is happening on the PTC Community by subscribing to PTC Community Announcements. X

Multiple ODE's in MathCad

ME_10255445
6-Contributor

Multiple ODE's in MathCad

Hi guys,

 

I have a question..

I modelled a 4th oder ODE in MathCad which works smoothly..

But when I tried to upgrade the script into (a system of ODE’s) 3 or 4 ODE’s, I couldn’t get it well working.

 

Note that I checked the boundary/matching conditions and they are correct. So something else could be wrong.

 

I’ve included the file in the mail.  

 

Would you like to help me here?

 

Thanks in advance!

 

18 REPLIES 18

The Odesolse finction cannot work with a boundary problem.

For this there are others tools. The Shot method for example (a programming). Or the bvalfit etc function.

  

 

Dear Valery,

Could you help me with an example?

I'm not sure how the bvalfit works..

Thnx in advance

Attached is an attempt using the shooting method.  I've split it into two sections; one from x = 0 to x = s1, and one from x = s1 to x = L, matching the specified boundary conditions at x = s1.

Unfortunately, it doesn't get one of the final boundary conditions correct (that for W``(L)).

Alan

 

 

 

Dear Alan,

I would like to thank you very much for your help, at least I'm a step further now.

 

 

Hallo Alan and everyone,

 

Firstly, thank u Alan and eveyone who gave his time for this.

 

Idon't know how to work with guesses and I don't even understand it.

But also a question, I thought I know the exact values for the boundary/matching conditions, so why do we need guess values?

Maybe I lack the experience here, but previously I used to program similar models in Maple but here (in MathCad) it does'nt work..

 

Any Idea?

 

Thanks in advance

 

This solution might not be satisfactory as it does not use a solver for a differential equation, but at least its a solution.

 

You are asking for two polynomials of fourth order which are zero at 0 and s1 resp. s1 and L, have their second derivative at 0 resp. L to zero and have matching first and second derivatives at the joint position s1.

Actually this means 10 conditions for 10 variables (the coefficients of the polynomials) which you can either solve using the symbolic solver or using a numeric solve block. Of course, as we know the fourth derivative of both functions being q/EI we could set the coefficient of x^4 in both functions to q/(24 EI). But I decided to let Mathcad do the job 😉

Here is what Mathcad came up with

Werner_E_0-1652295973509.png

As you can see, the necessary conditions are met (apart from minor numerical inaccuracies):

Werner_E_2-1652296192498.png

 

i still have no idea how to get odesolve to come up with this solution, though.

 

MC15 sheet attached

So here is a method which uses odesolve - unfortunately still not the "natural" way.

First we use a separate solve block with "odesolve" for U and for W and turn it into a function of the value d2 of the second derivative at x=s1.

Werner_E_0-1652300534267.png

 

The only condition not met when we calculate the functions using the same value for d2 is that we also want the first derivatives at s1 to match.

So we define a function to calculate the difference of the first derivatives at s1 for any value of d2

Werner_E_1-1652300621417.png

and use it in a solve block with "find" to iterate the values of d2 until we arrive at a value where the first derivatives are equal.

Werner_E_2-1652300674465.png

Werner_E_3-1652300697082.png

Wish it would work in one go basically the way you had set it up, but it looks like Mathcad isn't capable enough to do so. However, I would be happy to be proven wrong.

Mathcad15 worksheet attached

 

ME_10255445
6-Contributor
(To:Werner_E)

Hi mate,

 

How wonderful is this update..

Thanks so much for your time and efforts 

I'll check it and let u know.

ME_10255445_1-1652698980886.jpeg

 

Thx,

 Mohamed 

LucMeekes
23-Emerald III
(To:ME_10255445)

With reference to https://community.ptc.com/t5/Mathcad/Toolbox-Solving-Ordinary-Differential-Equations-symbolically/m-p/689336#M192090

Your system of 2 ODE's can be solved as follows:

LucMeekes_0-1653059279080.png

LucMeekes_1-1653059293827.png

LucMeekes_2-1653059303554.png

LucMeekes_3-1653059311780.png

LucMeekes_4-1653059321816.png

LucMeekes_5-1653059331906.png

LucMeekes_6-1653059356880.png

Note that the value of d2 is:

LucMeekes_7-1653059409742.png

which corresponds to what @Werner_E found.

 

If you want to run this in Mathcad 15, be sure to take the proper LODEsolve reference file,

you need to replace the LODEsolve.mcd with LODEsolve.xmcd

 

Success!
Luc

 

LucMeekes
23-Emerald III
(To:ME_10255445)

Oh, and in case you wonder if it can be done with three sections...

Hoping/assuming I have set the proper initial/boundary conditions, here goes:

LucMeekes_0-1653062112084.pngLucMeekes_1-1653062119103.pngLucMeekes_2-1653062131381.png

LucMeekes_3-1653062139326.png

LucMeekes_4-1653062165664.png

LucMeekes_5-1653062189827.png

LucMeekes_6-1653062217272.png

And in case you're wondering about d2 and d3... they are 0.1 each. That is respectively:

LucMeekes_7-1653062337284.png

 

The Mathcad 11 file is attached again.

Success!
Luc

 

 

ME_10255445
6-Contributor
(To:LucMeekes)

Dear Luc,

 

Thank you very much for this amazing effort. I appreciate it 

 

Just one issue.. when I download your files, they don't run (calculate). That graph above doesn't plot any outcome! 

I see the screenshot you included, so I know it should work but maybe it has to do with the version I'm working with (MathCad 15)..

 

Any idea how I can get out of this dilemma?

 

Thanks in advance 🙂 

 

LucMeekes
23-Emerald III
(To:ME_10255445)

Yes. How about pressing the [F9] key every now and then, to calculate the sheet up to the point where it's being displayed. Or press [Ctl-F9] to calculate the entire sheet...

I generally have Autocalculation switched OFF in my files. That way I can edit the expressions without being hampered by Mathcad trying to calculate every change I make, and slowing down my editing.

 

Success!
Luc

 

ME_10255445
6-Contributor
(To:LucMeekes)

With each step I do consider that..

But looks like my version (MathCad 15) doesn't like some functions/expressions as below: 

The function LODESOLVE is not recognised along with some expressions in red..

Any idea why?

Something to do with the version I'm using maybe?

 

ME_10255445_0-1654632946624.png

 

LucMeekes
23-Emerald III
(To:ME_10255445)

You probably forgot to change the include file. At the top of my sheet is a reference to LODEsolve.mcd, that is the file that contains the definition of the function LODEsolve. Without that include file, the sheet will not work. And there are two incarnations of the LODEsolve file, one is LODEsolve.mcd (that runs in Mathcad 11), the other is LODEsolve.xmcd (that runs in Mathcad 15).  LODEsolve.mcd will not work in Mathcad 15, and LODEsolve.xmcd will not work in Mathcad 11.

You have to get the LODEsolve.xmcd from this thread:

https://community.ptc.com/t5/Mathcad/Toolbox-Solving-Ordinary-Differential-Equations-symbolically/m-p/689336#M192090

Scroll to the bottom of that thread to grab the latest version of LODEsolve.xmcd

Save that file on your computer, and replace the present reference to LODEsolve.mcd with a reference to the LODEsolve.xmcd file.

 

Success!
Luc

 

P.S. Also note that the function for solving LODE's is named LODEsolve, not LodeSolve nor LODESOLVE.

ME_10255445
6-Contributor
(To:LucMeekes)

Thanks Luc,

 

I did that, and I'm a step further now..

But I ran into an error (pattern math exception)..

Probably the symbols?

 
 
 

ME_10255445_7-1654673580241.png

 

LucMeekes
23-Emerald III
(To:ME_10255445)

I assume that the example file LM_20201019_LODEsolve.xmcd in the other thread (still) works for you in Mathcad 15. That means that LODEsolve is still able to solve a set of differential equations, but is having problems with your specific set.

I can't debug at the moment, because I have no access to Mathcad 15.

Fortunately you actually do not have a set of differential equations, but a single differential equation that is split over multiple regions of the running variable. The general solution for that differential equation is a single one:

LucMeekes_1-1654692205594.png

for the first region, then replace U0 with U1 for the second region and with U2 for the third (and so on if you like).

The attached solution file uses this property to solve your problem.

See if it works for you.

 

Success!
Luc

 

LucMeekes
23-Emerald III
(To:ME_10255445)

A slightly more compact implementation, which is easier to expand to more sections is attached below.

 

Success!
Luc

Top Tags