gelöst Bitte um Überprüfung der KCL-demo (LTspice Marotte?)

Hallo Rudi,

ich habe mal denselben Test gemacht wie Du, Rudi habe ich dabei mit Udo ersetzt. Obwohl mein Ergebnis dann dasselbe ist wie bei Dir, habe ich überlegt, wie man überprüfen kann mit welchem pi LTspice rechnet.
Dazu habe ich das gestern angehängte help-file von Mike E. benutzt und dessen pi-Wert als my.pi in das Sim.file hinterlegt.
Dann müsste doch eigentlich ein Vergleichstest zwischen den Messwerten mit und ohne my.pi, bzw. mit und ohne Udo (oder Rudi) zeigen, ob es Unterschiede gibt.

Mache ich da einen Denkfehler oder siehst Du das auch so.
log-file ist angehängt. (Aus Versehen ist Deines auch noch mit angehängt.)

Frohe Ostern
Udo
 

Anhänge

  • 1745047906258.png
    1745047906258.png
    31 KB · Aufrufe: 2
  • pi_Thematik.png
    pi_Thematik.png
    70,1 KB · Aufrufe: 2
Hallo Udo,

ich habe einen Verdacht, nämlich den, dass LTspice gar nicht die gesamten 21 Stellen Deines PI-Wertes benutzt!
Mach doch einmal folgenden Test:

.meas pi.cpy param my.pi

und schau dann in der Log-Datei nach, welchen Wert LTspice der Kopie zuweist.

Rudi

P.S.: Henkobike hat freundlicherweise auch den PI-Wert gecheckt mit dem gleichen Ergebnis wie bei mir. Bei Dir jedoch gab es jeweils total gleiche Werte, egal mit welchem PI. Ein bisschen merkwürdig, meine ich (oder auch nicht?).
 
Zuletzt bearbeitet:
Ich habe inzwischen selber noch einen Test gemacht, siehe untenstehenden Screenshot.
Dieser erste Test ist zunächst OHNE die bei der TRAN-Simulation besser einzuschliessende Option

.opt plotwinsize=0 numdgt=15 [measdgt=15]

pi_test3.png

Das Gleiche dann mit obiger Option ausgeführt ergibt:

pi_test4.png

Man vergleiche die Werte in der LOG-Datei!
Happy PI-ing! wünscht

RudiS
 
Zuletzt bearbeitet:
Ich habe noch ein anderes Beispiel durchgeführt und dies als Frage an die groups.io gerichtet.

Hier nun mein Anschreiben und die Antwort der group (Namen habe ich aus Vertraulichkeitsgründen unterdrückt) dazu:

Hi All,
I had a discussion with LTspiceVXII and LTspice24 users about the accuracy of measurement results, shown up in the spice error log. To verify how the constant “pi” is handled, we made a simple example, such as:
.opt plotwinsize=0 numdgt=15 measdgt=15
.param x=pi
.param y=sqrt(x)
.param z=y**2
.op or .tran
.meas z_value param z
.meas x_value param x
Spice error log shows:
z_value: z=3.14159265359
x_value: x=3.14159265359


To our surprise, we observed different results between users, although the same setup was implemented.
Mike Engelhardt’s LTspice XV!! Help-file Copyright © 1998-2018 Analog Devices Corporation Shows on page 105:
The following constants are internally defined:
Name Value
E 2.7182818284590452354
pi 3.14159265358979323846
K 1.3806503e-23
Q 1.602176462e-19

The solver was set to „Alternate“. We assume, "Alternate" is 1000 times more accurate compared to “Normal”

My question is now a general one, independent on the practical significance of pi:
What is the accuracy LTspiceXVII and LTspice24…. Is using for calculations and measurements, shown in the log-file ?
and are there differences between LTspice versions?

Thanks a lot in advance
-------------------------------------------------------------------------------------
Antwort

11:20 (vor 1 Stunde)


an LTspice

Similar we've had similar discussions here in the past. Printed results in LTspice's logfile are double precision floating point, if measdgt>6 is assigned. Otherwise, it is single precision. Double precision can only support a maximum of 16 decimal digits, and single precision a maximum of 7, although sometimes you will get only 6 (hence the significance of measdgt).

The "constants" pre-assigned in LTspice are variously imprecise:

Constant LTspice "Accepted or SI definition"
--------------------------------------------------------------------------
e 2.7182818284590452354 2.718281828459045235360287471352..
π 3.14159265358979323846 3.141592653589793238462643383279..
k 1.3806503e-23 1.380649e−23
q 1.602176462e-19 1.602176634e−19

You can see that e and π are simply rounded truncations. But k and q were re-defined by SI in 2019, i.e. since the constants were originally coded into LTspice (SWCAD) - possibly even the original Berkeley SPICE. (SI defines elementary charge as "e", not "q".) It seems like LTspice has never updated its values for k and q, even in 24.1.x. It doesn't seem much to get upset about, but LTspice ought to respect the accepted values.

Simulation accuracy is a tricky subject, because the way SPICE works is to approximate the operating point at every step according defined "tolerances" listed in Control Panel > SPICE. Changing any one of those settings may have subtle or major effects on the assumed behaviour of the circuit, i.e. the solution at any one point will probably be "wrong". But because SPICE is assumed deterministic, the result should be same every time you run it with unchanged conditions.

As the solver code is tweaked for convergence, you could expect minor variations in simulated results. After all, if you use enough precision, you will get minor variations in the physically measured value of anything.

--
Regards,
 
@ Rudi and Hencobike.

Von der groups.io habe ich noch eine Rückmeldung von Profis erhalten. Ich wurde gebeten, die Ergebnisse der anderen user mit Hinweis auf die verwendeten LTspice Versionen zu geben. Da ich ein eigenes Sim.-beispiel "pi.asc"
bei meiner Kontaktaufnahme (siehe #25) benutzt habe, wäre ich Euch dankbar, wenn Ihr das angehängte file ausführen könntet, mit Hinweis auf die verschiedenen LT Versionen.
Danke
------
Udo
 

Anhänge

  • pi.asc
    430 Bytes · Aufrufe: 3
Ein Vergleich meines Beispiels pi.asc hat gezeigt, dass mit verschiedenen LTspice Versionen bei 3 Usern (RudiS, Hencobike und mir) der Wert pi identisch mit 11 Stellen nach dem Komma dargestellt wird.
Von der groups.io habe ich noch folgendes mail erhalten:
pi 3.14159265358979323846
Looks OK so far. The value listed in the Help just has more digits (greater precision) than the values printed in the Error Log file. It should be obvious why that happened.

Do you have the different values for pi that you found from different users? Can we see them?

If the value differed in different LTspice versions, perhaps its value was updated internally. Anything identified as LTspice 24 was done by Analog Devices, not by Mike Engelhardt as either an LTC employee or an ADI employee. Mike's value for pi might have been unchanged since before 2000 when he started working on SwitcherCAD III which became LTspice III. New pairs of eyes (after Mike left) may have noticed that pi's value needed to be corrected.

The solver was set to „Alternate“. We assume, "Alternate" is 1000 times more accurate compared to “Normal”
Let's be really careful about that statement. The Alternate solver is not necessarily 1000 times more accurate, even if the wording in the Help suggests that. The Alternate solver has about 3 digits more numerical resolution because of the way its numbers are stored internally, and that extra resolution could be capable of yielding better accuracy, but it does not guarantee it. Accuracy is not the same as resolution.

Because SPICE/LTspice is a nonlinear circuit solver, what Tony said is true, that every result of a circuit calculation is an approximation and not exact. This is not about numerical resolution or math calculation accuracy; it is because you can't get exact results from circuits that are nonlinear and whose parameters shift with the slightest change in the inputs, making it impossible to solve a voltage or current's value exactly. This is where the SPICE *TOL settings affect the outcome. SPICE/LTspice calculates differently when a circuit is 100% linear, and those calculations (and results) theoretically could be as accurate as the math allows them to be - those solutions are theoretically "exact", to the degree that the number resolution and the math allows them to be.

The values you printed from parameters has nothing to do with that. Parameter values are set, or calculated from math formulas and then set, but they are never subject to Newton iterations which are at the core of SPICE's/LTspice's need to approximate nonlinear circuits. Well, you did calculate a square-root and then a square, so yes, those calculations might be subject to whatever math (in)accuracy there is in your operating system's math routines.

Note that when LTspice needs to do a math calculation, it calls the appropriate O.S. math routine to actually do that calculation. This is why we sometimes get strange error codes, coming from your O.S.'s math routines, which end up in the waveforms - values such as -1.#QNAN. That is the math routine's error code. Wine users and Windows users and MAC users might see different error codes in a few cases, because they are OS-specific.
-----
Udo
 

Benutzer welche diesen Thread betrachten (Mitglieder: 0, Gäste: 1)

Wer hat diesen Thread gelesen

Zurück
Oben