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

ODE solve give very spiky response ?

JXBWk
13-Aquamarine

ODE solve give very spiky response ?

To all

 

I am looking at the ODESolve with a “saw tooth” input (y’’) and I get a very spiky response – see attached (mcad 15 wsheet will follow)

Why is that?

Tried different time steps but always get this rather spiky response

 

Thanks

John

1 ACCEPTED SOLUTION

Accepted Solutions
AlanStevens
17-Peridot
(To:JXBWk)

Works better as set of first order equations:

Eqns.png

 

Avoid numerical differentiation wherever possible!

 

Alan

 

View solution in original post

13 REPLIES 13

Try to convert one 2-d ODE into two 1-st Odes!

Werner_E
24-Ruby V
(To:JXBWk)

Would suggest that you attach your worksheet.

Would adding more steps in odesolve (third, optional argument) be of help?

Maybe worth a try although i guess that the problem stems from the numeric derivations and not from the result of odesolve.

Hard to be of more hep without having the sheet to play with.

LucMeekes
23-Emerald III
(To:JXBWk)

 

I guess Amax=20 and tf=0.011. What are your values forLucMeekes_1-1668548279451.png and LucMeekes_2-1668548298092.png  ?

If they are 3 and 5 respectively I get:

LucMeekes_3-1668548496389.png

Success!

Luc

 

 

 

 

prop_design
15-Moonstone
(To:JXBWk)

odesolve use to be mathcad's best solver. however, their statespace solver is much better. the help and quicksheets can get you started. if you want some example files, I can post them. the users here on the forum helped me get a pwm input working. i haven't tried a sawtooth wave but i expect it would handle it well. the nice thing about the statespace solver is it can handle a lot more inputs than odesolve can.

JXBWk
13-Aquamarine
(To:JXBWk)

can't find the option to edit original post ! attached mcad 15 worksheet.

The Prime 8 conversion is not quite working. Does not like the y''(t) notation

Werner_E
24-Ruby V
(To:JXBWk)

Still not perfect, but maybe its helps

Werner_E_0-1668605803881.png

Its interesting that even lowing the number of steps from the default 10^3 to 10^2 give a coarse but mainly spike-less result.

 

JXBWk
13-Aquamarine
(To:Werner_E)

Thanks. Yes. Have been playing with the number of time steps and it's almost as if 150-250 steps give the "best" results

No idea why numerically one gets all this spikes.

Maybe the transition back to zero be done in a zero time is creating some sort of infinity in the process

Maybe I'll try to have a the ramp-down i.e. max-back to zero in a very small time step

Werner_E
24-Ruby V
(To:JXBWk)


Maybe I'll try to have a the ramp-down i.e. max-back to zero in a very small time step


No, I already tried and it didn't help.

Werner_E_0-1668610611579.pngWerner_E_1-1668610629249.png

 

Actually odesolve creates a couple of discrete points and performs some sort of interpolation behind the scenes to be able to provide a function. You may do the very same manually but use some sort of smoothing before applying interpolation.

I found the expsmooth seems to provide a good result and using it the numeric derivative seems to produce less spikes. You may also play around using different interpolation methods (lspline, pspline or maybe simple linear interpolation).

But as long as we are dealing with numeric methods (odesolve and the derivative) we have to reckon with artifacts of some kind.

Werner_E_0-1668614046032.png

MC15 sheet attached

LucMeekes
23-Emerald III
(To:JXBWk)

OK, the true answer is probably this:

LucMeekes_1-1668613118740.png

and stems from:

LucMeekes_2-1668613162249.png

With those,

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

we can:

LucMeekes_3-1668613284376.png

(note that these expression run much further to the right of the vertical grey line).

 

Compare to the numerical approximation by Odesolve:

LucMeekes_4-1668613479334.png

LucMeekes_5-1668613494100.png

Note the difference in z''<>Z'':

LucMeekes_6-1668613594660.png

 

Success!
Luc

JXBWk
13-Aquamarine
(To:LucMeekes)

@LucMeekes 

Thaks for the input. I naively assumed that this is an academic case - a single degree of freedom (spring-mass) subjected to a "ground" acceleration

If I got this right another input shape will work just fine. It still remains as to why that profile shape is giving odd answer

Not having the worksheet from which you have taken the pictures I may have to re-do bits of it as I 'll be interested to see the effect of a different wn value. much smaller

 

Thanks

Regards

John

AlanStevens
17-Peridot
(To:JXBWk)

Works better as set of first order equations:

Eqns.png

 

Avoid numerical differentiation wherever possible!

 

Alan

 

JXBWk
13-Aquamarine
(To:AlanStevens)

a comparison of the "normal approach" and @AlanStevens suggestion

 

odesolve_compare.png

LucMeekes
23-Emerald III
(To:JXBWk)

Ah, apologies. I made one mistake, sign of y''. With the correct sign the result is:

LucMeekes_0-1668719276834.png

And that results in:

LucMeekes_1-1668719317891.png

And the comparison with the Odesolve result:

LucMeekes_2-1668719348176.png

Now the results match better.

With that corrected, you were wondering about a lower value of wn, How about f=60 instead of 600.

LucMeekes_3-1668719428984.png

 

And the comparison with Odesolve shows as:

LucMeekes_4-1668719492387.png

I attach the Mathcad sheet. For you to run it in Mathcad 15 you will have to get the LODEsolve.xmcd file from https://community.ptc.com/t5/Mathcad/Toolbox-Solving-Ordinary-Differential-Equations-symbolically/m-... and replace the referenced file (LODEsolve.mcd) with that LODEsolve.xmcd.

I can only hope it runs as smoothly in your Mathcad 15 as it does in my Mathcad 11.

 

Success!
Luc

 

Top Tags