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

Community Tip - Learn all about PTC Community Badges. Engage with PTC and see how many you can earn! X

Translate the entire conversation x

non linear solver update to guess values

remslie
14-Alexandrite

non linear solver update to guess values

Hi,

I have a problem that is sensitive to guess values. I am attempting to copy a method that was posted some time ago 

https://community.ptc.com/t5/Mathcad/Solve-block-problem-3-1/td-p/43434

but I get an error as follows:

remslie_0-1767532076731.png

I am sure the fix is trival but I have a had no luck fixing it. Any help would be appreciated.

Thanks

Ross

 

ACCEPTED SOLUTION

Accepted Solutions
Werner_E
25-Diamond I
(To:remslie)

Using the values given (1000 frequency values from 0.1 to 100 with a constant step width of 0.1) I experienced no problems when using the very same guess values (all 0.05) for all of them. Even though these guesses are way off from the actual results. usually its better to use guesses nearer to the actual expected values.

Here I create a table with values using 0.05 as guess throughout.

Werner_E_0-1767554636419.png

The table created that way is identical to the table ANS6 created by Terry. There are just tiny differences in the range of 10-20 which sure can be ignored.

See details in the attached sheet where I used Terry's sheet as a start. 

This means to me that you could omit the guess values in your function f and use the same guesses (or better ones) throughout.

I did it in hat sheet and called the function f2(w).

I show how to create individual functions alpha(w), etc. and use a range for plotting.

When I was about to suggest using "logspace" instead of "vec" to create a vector of values which are equally spaced in a log-lin plot, I experienced the solve block failing.

I created a function which would trap this error

Werner_E_1-1767556468642.png

so we can see which frequencies out of the 1000 used made the solve block fail and it was found that just two frequency were problematic.

Werner_E_2-1767556504272.png

I investigated further (details see in attached sheet) and it looks that at these frequencies we have some kind of spikes (don't look like asymptotes any more but I am not sure) the solve block has troubles with.

I used the suggested mean values as guesses and not omega1  worked but omega2 still failed.

Not sure if these frequencies have a special meaning to you.

I am also not sure if the approach you found in that thread would be of help in this case. As I showed the solve block had no problems with the frequencies linear spaced from 0.1 to 100 with step width 0.1. So there was no need to awkwardly use the results of the 'previous' calculation as guesses.

I looked to the left and right of the problematic frequencies until the solve block would work and used these values as guesses in your function f.

Now both frequencies worked:

Werner_E_4-1767557664652.png

I also tried the results from frequency w1 instead of the all 0.05 and now no frequency from the vector failed, but some frequency near both(!) problematic ones did.

I am not sure which troubles you encountered and if going through all these hassles is it worth to achieve results (of doubtful accuracy) at these positions.

Maybe the error trapping function f3 already suffices for your needs?

 

Prime 11 sheet attached

 

BTW, if you set the system variable CTOL to a large value like 0.1 all frequencies in the last vector omega work Ok, but it looks like the values returned are awfully inaccurate. Setting CTOL to a smaller value than the default 0.001 may make more frequencies fail

View solution in original post

8 REPLIES 8

Hi,

omega in your sheet is a range.  Mathcad Prime 11 can now create a vector.

Program uses columns 6 and 7 that do not exist so cause errors.  Changed them to 3 and 4.

Put the creation of omega and small program below not in the solve block above.

 

Cheers

Terry

Werner_E
25-Diamond I
(To:remslie)

Using the values given (1000 frequency values from 0.1 to 100 with a constant step width of 0.1) I experienced no problems when using the very same guess values (all 0.05) for all of them. Even though these guesses are way off from the actual results. usually its better to use guesses nearer to the actual expected values.

Here I create a table with values using 0.05 as guess throughout.

Werner_E_0-1767554636419.png

The table created that way is identical to the table ANS6 created by Terry. There are just tiny differences in the range of 10-20 which sure can be ignored.

See details in the attached sheet where I used Terry's sheet as a start. 

This means to me that you could omit the guess values in your function f and use the same guesses (or better ones) throughout.

I did it in hat sheet and called the function f2(w).

I show how to create individual functions alpha(w), etc. and use a range for plotting.

When I was about to suggest using "logspace" instead of "vec" to create a vector of values which are equally spaced in a log-lin plot, I experienced the solve block failing.

I created a function which would trap this error

Werner_E_1-1767556468642.png

so we can see which frequencies out of the 1000 used made the solve block fail and it was found that just two frequency were problematic.

Werner_E_2-1767556504272.png

I investigated further (details see in attached sheet) and it looks that at these frequencies we have some kind of spikes (don't look like asymptotes any more but I am not sure) the solve block has troubles with.

I used the suggested mean values as guesses and not omega1  worked but omega2 still failed.

Not sure if these frequencies have a special meaning to you.

I am also not sure if the approach you found in that thread would be of help in this case. As I showed the solve block had no problems with the frequencies linear spaced from 0.1 to 100 with step width 0.1. So there was no need to awkwardly use the results of the 'previous' calculation as guesses.

I looked to the left and right of the problematic frequencies until the solve block would work and used these values as guesses in your function f.

Now both frequencies worked:

Werner_E_4-1767557664652.png

I also tried the results from frequency w1 instead of the all 0.05 and now no frequency from the vector failed, but some frequency near both(!) problematic ones did.

I am not sure which troubles you encountered and if going through all these hassles is it worth to achieve results (of doubtful accuracy) at these positions.

Maybe the error trapping function f3 already suffices for your needs?

 

Prime 11 sheet attached

 

BTW, if you set the system variable CTOL to a large value like 0.1 all frequencies in the last vector omega work Ok, but it looks like the values returned are awfully inaccurate. Setting CTOL to a smaller value than the default 0.001 may make more frequencies fail

remslie
14-Alexandrite
(To:Werner_E)

Werner, Terry,

Many thanks for the corrections Terry and in depth look into my problem Werner. The problem is  non-linear involving a ball tuned mass damper rolling in a semi-circular track mounted to a structure that is vibrating. In Terry's sheet I have included equations for rotation of the ball (P) and translation of the base structure (D). 

The response is sensitive to the amplitude of force (Fo) and becomes more non-linear as Fo increases with jumps in response- see plots below of what occurs. 

remslie_0-1767677239596.png

remslie_1-1767677265685.png

Werner, the values you are trapping with NaN would appear to be the values of omega that fall within this non-linear jump zone. I note that Terry's program fails to give a solution when Fo is > 3.5 N. It would be nice to be able to plot the P and D curves for higher values of Fo up to the points where the jump occurs. This would require smaller increments in omega as the solution approaches the jump.

Any assistance would be greatly appreciated.

Regards,

Ross

 

remslie
14-Alexandrite
(To:remslie)

Werner, Terry,

I don't believe the mathcad sheet attached correctly. I have zipped it and try again.

Ross

Werner_E
25-Diamond I
(To:remslie)

The program which creates ANS6 will fail completely(!!) if the solve block just fails for one single frequency!
Even with F0=3 it already fails if you use a smaller step width for the frequencies (0.05 instead of 0.1):

Werner_E_0-1767711358279.png

I rewrote the program (->ANS1) so that is does not fail completely when the solve block fails for a single frequency but rather returns NaN's in this case. That way you get at least all the other values for the non-failing frequencies.

The purpose of the program you found was to use the results of the previous frequency as guesses for the calculation of each frequency. The hope is that these guesses will better fit and increase the possibility for the solve block to find a solution. My program for ANS1 consequently uses the results of the last working frequency as guesses.

For testing purposes, I also created a matrix ANS2, in which simply the very same guess values 0.1 are used for each frequency.
It turns out that ANS1 and ANS2 provide identical values but ANS2 tends to fail a few times more often than ANS1. So using previous values as guesses has still a small benefit and so I used it for the further calculations.

 

I set F0 to 5 and ran the frequencies from 2 to 5, with a smaller step size of only 0.01. Of the 301 frequencies generated in this way, the solve block failed to find a solution for just six – three around w=2.6 and three around w=3.22 (with a step size of 0.001, already 27 frequencies fail).

The corresponding graphs therefore look like this:

Werner_E_1-1767711820708.png

or by just drawing the points and not connecting them like this

Werner_E_2-1767711852052.png

The method of course also works for F0 larger than 3.5.


But if your goal is to duplicate the graphs you have embedded, I see another, more serious problem. What the graphics show are not functions (just one unique value for each argument). For some curves, I see several amplitude values for some frequencies. Here, for example, there are three values for the red trace at w=4.

Werner_E_3-1767712008285.png

However, a numerical solution block always gives you only just one solution (if any 🙂 ), even if the system should have several solutions. Which solution you get depends on the guess values used.
So you would have to call the solution block with different guess values for each frequency w in order to obtain these different solutions, and you would have to know from your application (and you probably don't) which guesses you should use. I imagine that would be rather difficult.

 

BTW, in the attached sheet I added a solve block with F0 as additional argument of function f.

That way its easy to show traces for multiple forces in one plot.

 

Werner_E_2-1767757980291.pngWerner_E_0-1767757812303.png

One observation at last:
I noticed that your first and second equation look quite equal apart from the variables used - with one exception:

Werner_E_0-1767724100446.png

Is the different sign done on purpose?

Its doesn't change anything concerning the main problem, though.

 

remslie
14-Alexandrite
(To:Werner_E)

Werner,

Many thanks for your time and efforts. Your knowledge and skills in MathCad programming are truely impressive.

BTW the sign change in the two equations you highlighted is correct.

Thanks again and have a great 2026.

Ross

Werner_E
25-Diamond I
(To:remslie)

A Happy 2026 to you, too.

 

BTW, you may use "filterNaN" so the traces look (falsely) as if they were continuous.

Werner_E_0-1767758384479.png

Werner_E_1-1767758399907.png

But I doubt that its a good idea giving a wrong impression.

AlanStevens
19-Tanzanite
(To:remslie)

The dimensions in your equations are not compatible.  For example, in:

dimensions.png

the units of the first term are seconds^-2, those of the second are metres.seconds^-2 (unless your values 10 and/or 56 have undeclared units also).  You would have seen this immediately if you had actually assigned units to your variables when you defined them, instead of just writing them separately as text.

 

Alan 

Announcements

Top Tags