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
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,