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

Odesolve bug? Another bug?

Cornel
19-Tanzanite

Odesolve bug? Another bug?

Hi,

Change variable a from below and look at the V2(t)...Why odesolve block is behaving like this? Is it normal?
Prime 10 file attached.
The expected behaviour is like a =7.

Cornel_3-1718623701982.png

 

Cornel_4-1718623713461.png

 

Cornel_5-1718623726172.png

 

Cornel_6-1718623740384.png

 

Cornel_7-1718623753126.png

 

Cornel_9-1718623787557.png

 

Cornel_10-1718623800847.png

 

Cornel_11-1718623813812.png

32 REPLIES 32
Cornel
19-Tanzanite
(To:Cornel)

The above results are for this:

Cornel_0-1718624284243.png


IF I change to Fixed:

Cornel_1-1718624309283.png

Cornel_2-1718624319711.png

 

If I change to Adaptive:

Cornel_3-1718624347013.png

Endless running:

Cornel_4-1718624359101.png

 

And If I change to Radau:

Cornel_5-1718624391699.png

Cornel_6-1718624414390.png

Cornel_7-1718624425168.png

Cornel_8-1718624436386.png

 

From a=4 until a=8 its ok, but when a=9 not:

Cornel_9-1718624456486.png

 

a = 10, 11 - ok

a = 12 - NOT ok...


It seems that Radau doesn't make so many misses (at least in this example), and at least as not many as Adams/BDF does. 

Its a bug? Or what's happening?

The solution to this relatively simple initial value problem fails due to the discontinuity of the inhomogeneity. This means that "theoretically" there is no statement about the existence and uniqueness of the solution. Perhaps reformulating it as an integral equation will help. Numerically, less sensitivity can then be expected. Or the inhomogeneity can be approximated by a continuous function. However, MC would probably be unable to cope with this.

But we do not want to stay with differential eq form (derivative), and not to go to intergrals where odesolve block cannot be used?

Maybe Odesolve is not so good for this problem? I am not sure how could this problem can be translated to other methods of solving differential equations...maybe AdamsBDF Mathcad algorithm? But I do not know at this moment how to translate the above diff eq to others algorithm like AdamsBDF or others...

ttokoro
20-Turquoise
(To:Cornel)

image.pngimage.pngimage.png

Cornel
19-Tanzanite
(To:ttokoro)

We should maintain the values for C1 and R1 as there were defined initially, not to changed them...as we like..

Cornel_0-1718630756296.png

Cornel
19-Tanzanite
(To:Cornel)

But anyway, the problem is still present even so:
Below is with Adams/BDF:

Cornel_3-1718631025861.png

 

Cornel_1-1718630910555.png

Cornel_2-1718630924977.png

 

And with Radau:

Cornel_4-1718631078969.png

 

For all a:0...12 the same results are maintained in this example with Radau:

Cornel_5-1718631092110.png

But as I said previously, we should not changed the values of components. We should have the initial values:

Cornel_6-1718631148857.png

 

Cornel
19-Tanzanite
(To:Cornel)

Cornel_2-1718631613993.png

 

Hm, but I see that having Radau option selected:

Cornel_0-1718631520154.png


And with initial condition set to 0V, not 10^(-a), then the things seems to be good so far for this example:

Cornel_1-1718631551350.png

 

So, the Radau is better than Adams/BDF?

 

Cornel
19-Tanzanite
(To:Cornel)

I found a case where Radau misses:

Cornel_0-1718631800211.png

Cornel_1-1718631814159.png

 

Cornel
19-Tanzanite
(To:Cornel)

With Radau:

Cornel_0-1718637403792.png

Cornel_1-1718637422558.png

 

With Adams/BDF:

Cornel_2-1718637444146.png

Cornel_3-1718637456067.png

As already mentioned, this task cannot in principle be solved over the entire time axis in one go. But it would be possible to proceed step by step according to the levels/intervals of the inhomogeneity (where it is constant in sections). To do this, the solution is calculated up to the end of the first section using the original initial value and then the next constant section is calculated using the final value as the new initial value. But my programming skills are not sufficient for that. In any case, the curves calculated so far over the entire time length with only one initial value should be treated with caution, as there may be peculiarities of the numerics involved.

What is the first section and what is the second section? Make a drawing.

Cornel
19-Tanzanite
(To:Cornel)

So, the question is this: the fault is from Mathcad ode algorithm or the fault is not the fault and in the fact this should be the expected behaviour to misses some pulses some time to time?

Sections are the intervals of length, e.g. tend/1000 on the time axis, in which V1 and I(Vx) are constant. The first section starts at t=0 and ends at (as far as can be seen in the diagram) up to t=0.605. The second section starts at t=0.605 and goes up to t=0.61, etc. The solution in the first section has the initial value given at t=0. For the solution in the second section, the ordinate in the final value from the first section is taken as the initial value at t=0.605, etc. The overall solution is therefore put together section by section. This should be clear even without a drawing ;-). I cannot see any other numerical MC-compatible way.

@Werner_E  what are your thoughts about what you see in this thread? Do you think that this reason described above by Alfred to be the reason on why the V2(t) signal misses pulses?

Cornel
19-Tanzanite
(To:Cornel)

Or do You think is rather because Mathcad ode algoritm fail?

Werner_E
25-Diamond I
(To:Cornel)

I have no idea. Maybe you are pushing Prime to its numerical limits.

Cornel
19-Tanzanite
(To:Werner_E)

But maybe:
@Werner_E could you try this exercise in Mathcad 15 to see if Mathcad 15 deliver same result as Prime 10?
@LucMeekes  could you try this exercise in Mathcad 11 to see if Mathcad 11 deliver same result as Prime 10?

Cornel_0-1718699218604.png

Cornel_1-1718699226124.png

Werner_E
25-Diamond I
(To:Cornel)

Mathcad 15 won't allow units with odesolve

 

I would suggest defining V1(t) that way

Werner_E_0-1718715785255.png

 

There is an inconsistency in your function I(Vx). its not continuous at Vx=0.7V
The signal jumps from 0.207 uA down to 0A

Werner_E_1-1718716592143.png

 

 

Cornel
19-Tanzanite
(To:Werner_E)

Even though, this behaviour is still maintained. Try without units in Mathcad 15. For me my question is if this behaviour is the expected behaviour or not (meaning that there is a fault in Mathcad odesolve algorithm)

This result is with:

Cornel_1-1718720221308.png

 

Cornel_0-1718720084739.png

 

This result is with:

Cornel_2-1718720238618.png

 

Cornel_3-1718720246466.png


But if we change R1 from 10 to 12 then also Radau misses pulses:

Cornel_4-1718720310098.png

 

 

Werner_E
25-Diamond I
(To:Cornel)

I did not expect that the suggested definition of V1 would change the behaviour of the sheet. I just suggested it because its much shorter 😉

 

But in my opinion, however, the discontinuity in I(Vx) should be definitely fixed!

 

I also don't think that the algorithm(s) used for odesolve is/are faulty but rather it seems to be a 'natural' limitation of a numerical approach, implemented using numbers stored in standard IEEE format.

 

I am not sure if I could be bothered to retype anything in Mathcad just to find out if we experience similar effects in Mathcad, too, or not. There would be no benefit knowing that and my guess is that we would also experience such effects in Mathcad, too.

Please excuse me if I'm butting in again:
The numerical MC solution algorithms are very likely to be error-free if the theoretical background can be assumed to be verifiable. In the present case, this is not the case. The explicit ODE to be solved is V2'=f(t,V1, V2). However, according to the Picard-Lindelöf theorem, the function f must be continuous and a solution only exists in the continuity region. This is not the case in the present case because of the pointwise discontinuity of V! und I(V1). The MC algorithm then calculates something uncontrollably contestable. I see only the section-by-section process described above as a possibility for a numerical solution method in MC. Since the inhomogeneities are section-by-section constant, a shifted exp arc in each section should lead to a sawtooth curve overall due to the negative real eigenvalue of the characteristic polynomial. Unfortunately, my programming skills are not sufficient for this.

As @ttokoro  had shown, the numeric solution seems to work pretty well using different input values (without the sheet of course we can only guess that he actually did)

@ttokoro uses a capacity 10000 times larger than originally uses by @Cornel  and so of course a 10000 times larger time constant tau of 5 microseconds (and not 500 ps as in Cornels original approach).

See Re: Odesolve bug? Another bug?
Unfortunately @ttokoro did not post his sheet (as usual) and @Cornel had troubles duplicating what @ttokoro's picture shows. Maybe @ttokoro  did not use a true periodic signal, we don't see which value he had chosen for "a", ...- we don't know.

But do you think that the result (using the larger capacity value) would look significally differently when calculated section-by-section as you suggest from what can be seen in @ttokoro s picture?

I have already written something about ttokoro's "solution". In my opinion, there is nothing to add to that. And since his solution was not published, it is not a solution.

Cornel's numerical solution attempt does not fail because of the parameters. Rather, it is fundamentally wrong because the prerequisites (as described, continuity) for the existence of the solution with the impulse approach over the full time are not met. But this is required for the calculation algorithm, and it is based on it.

The numerical approximation algorithms are not concerned IMHO as you may think of the square wave signal of being a trapezoid signal , with very steep slopes. Now V1 can be considered continuous and we can expect a solution.
@Cornel  may try modelling his V1(t) as such a trapezoid signal and see if it helps in any way.

 

I am more concerned about the function I(V2(t)) which (apart from the already mentioned discontinuity which seems to be a modelling error of Cornel) somehow feeds back to the function V2 we are looking for and limits/controls the current in the circuit.

This function I() makes it quite difficult to solve symbolically even for a small range of t where V1 is constant throughout.

Cornel
19-Tanzanite
(To:Werner_E)


@Werner_E wrote:

The numerical approximation algorithms are not concerned IMHO as you may think of the square wave signal of being a trapezoid signal , with very steep slopes. Now V1 can be considered continuous and we can expect a solution.
@Cornel  may try modelling his V1(t) as such a trapezoid signal and see if it helps in any way.


 I have made the calculations with V1(t) more as a trapezoid signal:
With:

Cornel_0-1718786680081.png

Cornel_6-1718786929153.png

 

 

And with Radau:

Cornel_3-1718786771022.png

Cornel_7-1718786945394.png

 

Cornel_5-1718786821867.png

Cornel
19-Tanzanite
(To:Cornel)

@Werner_E @LucMeekes @AlfredFlaßhaar 
Hm...maybe its has something to do with this, look. So? A true pulse/square wave signal causes problems?

Cornel_1-1718787936362.png

 

Cornel_2-1718787954169.png

 

But...which is good:

 

Cornel_3-1718788210153.png

 

Cornel
19-Tanzanite
(To:Cornel)

Cornel_0-1718796612523.png

Cornel_1-1718796625508.png

Cornel_2-1718796645453.png

It is obvious to make the vertical edges/flanks of the individual pulses slightly slanted. After all, the beginning and end of a rectangular pulse are switching processes that do not take place at one point in time but in a short time interval. It would be interesting to get information from Cornel about whether the linearity and inclination at the pulse edge are suitable models of the switching process. With a trapezoidal pulse, the inhomogeneity of the original equation is of course continuous and, in theory, the existence of the solution is then assured. However, since the expected inclination of the pulse edge is very close to the vertical, numerical problems are to be expected. The tangent will appear in the calculations. A sensitive divergence takes place near 90°. The length of the representable numbers will then be decisive.

The problem becomes even more interesting if equation solutions are generated using a sequence of trapezoidal pulses, with the pulse edges becoming increasingly steeper. Nothing can be said about the sequence of the associated equation solutions, whether it converges and thus trapezoidal impulses lead to acceptable approximate solutions. It would then be a very difficult problem to solve from real analysis (Lit.: Natanson, Hewit/Stromberg). The usual ideas of differential quotients and integrals would then no longer be sufficient.

Summary:
I still believe that with the tools available in MC only a "piece-by-piece solution" is possible. Regardless of this, I would be interested to know how the rectangular impulse is processed in the algorithm in the solution presented by Luc.

Cornel
19-Tanzanite
(To:Werner_E)

I think in ttokoro picture he used V2(0s)=0V or something like a=-12 (having R1=10, C1=10^-8). Look at his picture and at my second picture from 2 comments below ttokoro's comment. But of course he should post better his worksheet.

 

I posted a second comment after his comment showing that with his chosen values for C1=10^-8 and R1=10, and having Adams/BDF for a=1 for example the V2(t) signal misses some pulses(more triangle in shape with this C1 value). I do not remember right now If for others values of parameter a, Adams/BDF misses pulses (I am on the phone now when writing this comment). And only for Radau V2(t) signal looks ok for all defined values of a=0...12 in this case of C1=10^-8 and R1=10. 

 

Anyway, for me is still unclear this behaviour of odesolve block, If is indeed as somehow Alfred comments or if Its a fault of odesolve block algorithm or has other reasons. That's why I suggested If someone can do this exercise at least in Mathcad 11 and Mathcad 15 for this moment to see If the results are the same as in Prime 10. 

Announcements

Top Tags