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

Community Tip - Want the oppurtunity to discuss enhancements to PTC products? Join a working group! X

[Mathcad Prime 2.0] - Struggeling to solve newtonian differential equation of 2nd order

NS_10096872
4-Participant

[Mathcad Prime 2.0] - Struggeling to solve newtonian differential equation of 2nd order

Hi everyone,

I am currently trying to solve a differential equation in Mathcad. However, after watching a bunch of Youtube-Tutorials on how to use the solve-block with ODEs, I am still not able to get the result.  What am I doing wrong? Your help is much appreciated 🙂

 

greetings
nerphan

1 ACCEPTED SOLUTION

Accepted Solutions

If you don't mind  the red errors from the numeric engine when defining your functions, you can leave your worksheet unchanged and just add the two regions with the substitute commands and change the first line in your solve block (and of course lower the time end value). And you may use different function names for the new functions if you don't want to overwrite the old definitions.

But personally I would prefer avoiding the errors by adding the function as a second argument to the functions as shown above.

Werner_E_0-1635379874832.png

BTW, when you try to duplicate the regions with the substitute commands you will notice that ever so often Prime infamous "auto-labelling feature" comes in the way. You have to try to give the various phi the label which finally works. Sometimes its necessary to change the label from "-" (meaning "automatic") to "variable", sometimes you have to do just the opposite. Prime auto-labelling sure is a PITA, especially when you use the symbolic engine.

 

View solution in original post

20 REPLIES 20
LucMeekes
23-Emerald III
(To:NS_10096872)

See if it works with this. (I cannot check, I'm limited to Prime Express).

 

Success!
Luc

NS_10096872
4-Participant
(To:LucMeekes)

Hi Luc,

thx for you answer. Mathcad still gives me an error unfortnately 😞

NS_10096872_0-1635346776414.png

 

First problem:

Screenshot 2021-10-27 100158.jpg

Which propagates:

Fred_Kohlhepp_0-1635343500108.png

You need to reformulate the solve block equations to reflect the true expression for the function you're solving for.

Fred_Kohlhepp_1-1635343707732.png

I can't run it (constrained to Express), but attached file is an attempt at an edit.

Hi Fred_Kohlhepp,

 

I can't open your document, as my Prime 2.0 does not seem to be compatible with it. But I think your answer is identical to that, what luc did (see screenshot in my reply to him)

LucMeekes
23-Emerald III
(To:NS_10096872)

Fred saved the file from Prime 7 (There's no way in Prime to save to the format of a previous version), so you cannot open that in Prime 2.

I've created a translation to Prime 2 of Fred's file, so you can see for yourself.

I've also built the system in Mathcad 11, and it will not solve. Mathcad 11 complains "Cannot evaluate this accurately at one or more of the values you specified"... whatever that may mean.

 

Success!
Luc

 

 

 

Have you tried to change the end value from 6 s to something as low as just 1 s? See my approach below which works up to t.end=1.2 seconds. Just be curious if MC11 can cope with your approach using a more reasonable end value.

I was surprised that your posted attempt by copy and paste the function terms directly to the solve block did not work (it also didn't by lowering the end value).

 

Here is my try.

It works, but not up to 6 seconds. Can't get it farther than 1,2 seconds. As you can see in the plot the values for phi shoot high up.

Guess you should check your equations.

I attach a pdf print and the worksheet in Prime 6 format.

Luc seems to have found a method to convert sheets back to older versions so maybe he can convert the sheet to Prime 2 format for you.

Werner_E_0-1635378528727.png

I could not make it work without redefining F.a and h by substituting the function phi(t) and its derivative by simple variables. Thats a bit awkward but at least I could avoid having to copy and paste expressions.

 

If you don't mind  the red errors from the numeric engine when defining your functions, you can leave your worksheet unchanged and just add the two regions with the substitute commands and change the first line in your solve block (and of course lower the time end value). And you may use different function names for the new functions if you don't want to overwrite the old definitions.

But personally I would prefer avoiding the errors by adding the function as a second argument to the functions as shown above.

Werner_E_0-1635379874832.png

BTW, when you try to duplicate the regions with the substitute commands you will notice that ever so often Prime infamous "auto-labelling feature" comes in the way. You have to try to give the various phi the label which finally works. Sometimes its necessary to change the label from "-" (meaning "automatic") to "variable", sometimes you have to do just the opposite. Prime auto-labelling sure is a PITA, especially when you use the symbolic engine.

 

NS_10096872
4-Participant
(To:Werner_E)

Hallo Werner,

thanks alot man, your solution worked for me and you were right about the equations, I found the mistake and now the solution looks more plausible.

NS_10096872_0-1635421494856.png

 

How can you evaluate the time needed to travel to 90°?

I tried this, but it didn't work:

NS_10096872_1-1635422655229.png

 

"Sometimes its necessary to change the label from "-" (meaning "automatic") to "variable","

I did not understand that, could you show me an explample please?

 

 

LucMeekes
23-Emerald III
(To:NS_10096872)

Here's an example, in Prime 2.

LucMeekes_0-1635443143216.png

Prime has this miraculous DANGEROUS feature of autolabelling. It labels whatever you type to one of the 7 types of label that I put in.You can select any mathematical item on your sheet and look at the Label that Prime has set for it. If necessary (and sometimes it IS necessary) you can change the label of the item.

If an item is 'not labelled' it shows in Prime 2 as (none), in some later version of Prime that was renamed to (-) which means "automatic".

Two items with (exactly) the same name, but different labels are treated as different items. That's clear for a unit m versus a variable m, because the unit shows differently from a variable.

Now the display of a (none) or (Variable) labelled item is the same, so it is easy to overlook this and often times this causes problems, especially in symbolics.

Hope this helps.

 

Success!
Luc

 

NS_10096872
4-Participant
(To:LucMeekes)

Thanx alot Luc on explaining on that. So far, this auto-albelling bug did not seem to occur on Prime 2.0


How can you evaluate the time needed to travel to 90°?

I tried this, but it didn't work:


The symbolic solve won't work with the only numerically derived function phi.

You may use either a solve block

Werner_E_0-1635454883697.png

 

or the "root" command - either by providing a guess value

Werner_E_1-1635454915116.png

or by providing a range

Werner_E_2-1635454951251.png

 


"Sometimes its necessary to change the label from "-" (meaning "automatic") to "variable","

I did not understand that, could you show me an explample please?


As you obviously were able to retype what I had shown in the picture(s) you were lucky and did not run into the troubles I experienced. Maybe the problem with the auto-labelling feature and symbolic evaluations was introduced in a later version than the one you are using.

According to variable labels Luc has already answered in more detail.

 

 

Seems to work ok if you make n have the same dimensions as nleer, and if you change the functions to be functions of phi not t.

g0.JPG.

Hi AlanStevens,

thanks for the answer mate :). As I had a mistake in one of the equation (see below)

NS_10096872_0-1635423367388.png

the diagramm after the corrected equation does not seem to represent the expected solution. I think it matters, if i make all the functions depended on phi instead of t.

forgot to post the diagramm:

 

NS_10096872_0-1635428781131.png

 

The difference is because I assumed x' was derivative with respect to phi, rather than with respect to t.  Correcting that I get:

g0.JPG

Alan

 

Thanks alot to you guys! Wouldn't be able to make this progress without your help.

 

Could you please explain me the following things?

  1.  So I have added a transmission-ration "i" to the equation. The next thing I want to find is the corresponding "i"...
    1. which leads to the shortest time t_90deg (the time needed to travel to 90 deg)
    2. which leads to a specified t_90deg (e.g. t_90deg should be 3.5 s)
  2. What kind of constraint do I have to add, to tell the system to stop @90deg (phi'(t_90deg=0), (angular velocity)

NS_10096872_1-1635729134675.png

 

 

ad 1) Asking for the shortest t.90 time seems senseless as the larger you chose i, the shorter the time

Werner_E_0-1635741386777.png

 

ad 2) not clear what you mean.  What exactly do you want to "stop"?

 

pdf of the modified file attached.

 

P.S.: I had to play around with the definition of n to get it to work finally as of big troubles with Primes auto-label "feature". Really looks like this problem was introduced after the version you are using.

 

NS_10096872
4-Participant
(To:Werner_E)

Hi Werner_E,

thanks alot. All your answers helped me to successfully complete my calculations! 🙂

Could you please explain what you did here? This is something I could never think of.

NS_10096872_0-1638303611454.png

 

odesolve usually return a function, so the normal usage would be

f := odesolve(....)

And you can use that function as expected, like f(2)=...

In your case the solve block is additionally dependent on a variable i.

Dependent on i a different function is returned.

So actually phi(i) is something like a function NAME (like f in the example above).

But Prime wont allow us to use it like phi(i)(2)=... and also not like phi(i,2)=....

So I defined a new function phi(i,t) which first calls the solve block and "stores" the result (a function) in f and then calls that function with the desired argument t. It may not have been the best idea to give it that function the same name phi. Probably naming the result of the solve block phi.temp(i) and calling that function in the definition of phi would have been more clear.

There is a drawback with that definition, though: If you use the phi(i,t) for plotting and the plot is, lets say, evaluated for 1000 points, then the solve block would be called 1000 times! The same applies if you numerically integrate that function.

If things like that should be done, it would be more efficient to use something like

f:=phi(3) (lets say we are interested in the result function with i=3) and then plot or integrate the function f(t).

Top Tags