Simulator: Spice_Primitive=X property doesn't get used on multi-component parts after using undo/redo
Description
When using a multi-component part (like a TL072 opamp), configuring Spice simulation properties for one component may break after deleting a the component and and ctrl-z'ing.
The underlying issue is the order that the components are evaluated in. If the first component (in my example power pins) lacks the "Spice_Primitive: X" parameter, then the primitive is not assigned for subsequent components of that part.
This .sch example is broken, the TL072 power pins are above the opamp component in the .sch file
$Comp
L Amplifier_Operational:TL072 U1
U 3 1 60B7365F
P 2550 3550
F 0 "U1" H 2508 3596 50 0000 L CNN
F 1 "TL072" H 2508 3505 50 0000 L CNN
F 2 "" H 2550 3550 50 0001 C CNN
F 3 "http://www.ti.com/lit/ds/symlink/tl071.pdf" H 2550 3550 50 0001 C CNN
3 2550 3550
1 0 0 -1
$EndComp
$Comp
L Amplifier_Operational:TL072 U1
U 1 1 60B719A8
P 3950 3250
F 0 "U1" H 3950 3617 50 0000 C CNN
F 1 "TL072" H 3950 3526 50 0000 C CNN
F 2 "" H 3950 3250 50 0001 C CNN
F 3 "http://www.ti.com/lit/ds/symlink/tl071.pdf" H 3950 3250 50 0001 C CNN
F 4 "X" H 3950 3250 50 0001 C CNN "Spice_Primitive"
F 5 "TL072" H 3950 3250 50 0001 C CNN "Spice_Model"
F 6 "Y" H 3950 3250 50 0001 C CNN "Spice_Netlist_Enabled"
F 7 "3 2 8 4 1" H 3950 3250 50 0001 C CNN "Spice_Node_Sequence"
F 8 "C:\\Users\\danie\\Documents\\kicad\\KiCad-Spice-Library-master\\Models\\Operational Amplifier\\Tl072.lib" H 3950 3250 50 0001 C CNN "Spice_Lib_File"
1 3950 3250
1 0 0 -1
$EndComp
This .sch example works, I have only moved the power pins below opamp component
$Comp
L Amplifier_Operational:TL072 U1
U 1 1 60B719A8
P 3950 3250
F 0 "U1" H 3950 3617 50 0000 C CNN
F 1 "TL072" H 3950 3526 50 0000 C CNN
F 2 "" H 3950 3250 50 0001 C CNN
F 3 "http://www.ti.com/lit/ds/symlink/tl071.pdf" H 3950 3250 50 0001 C CNN
F 4 "X" H 3950 3250 50 0001 C CNN "Spice_Primitive"
F 5 "TL072" H 3950 3250 50 0001 C CNN "Spice_Model"
F 6 "Y" H 3950 3250 50 0001 C CNN "Spice_Netlist_Enabled"
F 7 "3 2 8 4 1" H 3950 3250 50 0001 C CNN "Spice_Node_Sequence"
F 8 "C:\\Users\\danie\\Documents\\kicad\\KiCad-Spice-Library-master\\Models\\Operational Amplifier\\Tl072.lib" H 3950 3250 50 0001 C CNN "Spice_Lib_File"
1 3950 3250
1 0 0 -1
$EndComp
$Comp
L Amplifier_Operational:TL072 U1
U 3 1 60B7365F
P 2550 3550
F 0 "U1" H 2508 3596 50 0000 L CNN
F 1 "TL072" H 2508 3505 50 0000 L CNN
F 2 "" H 2550 3550 50 0001 C CNN
F 3 "http://www.ti.com/lit/ds/symlink/tl071.pdf" H 2550 3550 50 0001 C CNN
3 2550 3550
1 0 0 -1
$EndComp
This also works, if I add the "Spice_Primitive: X" parameter to the power pins component
$Comp
L Amplifier_Operational:TL072 U1
U 3 1 60B7365F
P 2550 3550
F 0 "U1" H 2508 3596 50 0000 L CNN
F 1 "TL072" H 2508 3505 50 0000 L CNN
F 2 "" H 2550 3550 50 0001 C CNN
F 3 "http://www.ti.com/lit/ds/symlink/tl071.pdf" H 2550 3550 50 0001 C CNN
F 4 "X" H 2550 3550 50 0001 C CNN "Spice_Primitive"
3 2550 3550
1 0 0 -1
$EndComp
$Comp
L Amplifier_Operational:TL072 U1
U 1 1 60B719A8
P 3950 3250
F 0 "U1" H 3950 3617 50 0000 C CNN
F 1 "TL072" H 3950 3526 50 0000 C CNN
F 2 "" H 3950 3250 50 0001 C CNN
F 3 "http://www.ti.com/lit/ds/symlink/tl071.pdf" H 3950 3250 50 0001 C CNN
F 4 "X" H 3950 3250 50 0001 C CNN "Spice_Primitive"
F 5 "TL072" H 3950 3250 50 0001 C CNN "Spice_Model"
F 6 "Y" H 3950 3250 50 0001 C CNN "Spice_Netlist_Enabled"
F 7 "3 2 8 4 1" H 3950 3250 50 0001 C CNN "Spice_Node_Sequence"
F 8 "C:\\Users\\danie\\Documents\\kicad\\KiCad-Spice-Library-master\\Models\\Operational Amplifier\\Tl072.lib" H 3950 3250 50 0001 C CNN "Spice_Lib_File"
1 3950 3250
1 0 0 -1
$EndComp
Workaround
My current workaround is to assign the "Spice_Primitive" property to all of the schematic components of a multi-component part.
Steps to reproduce
- insert the TL072 opamp component
- insert the power pins component
- build a simple test circuit that uses the single opamp
- apply a Spice model to the opamp component using the Edit UI
- run the simulation, it will work (save and backup .sch file)
- delete the opamp component, then ctrl-z to re-add it
- run the simulation, it will fail (save .sch file)
The order of the components will have changed in the .sch file as well.
KiCad Version
Application: KiCad
Version: (5.1.10)-1, release build
Libraries:
wxWidgets 3.0.5
libcurl/7.71.0 OpenSSL/1.1.1g (Schannel) zlib/1.2.11 brotli/1.0.7 libidn2/2.3.0 libpsl/0.21.0 (+libidn2/2.3.0) libssh2/1.9.0 nghttp2/1.41.0
Platform: Windows 8 (build 9200), 64-bit edition, 64 bit, Little endian, wxMSW
Build Info:
wxWidgets: 3.0.5 (wchar_t,wx containers,compatible with 2.8)
Boost: 1.73.0
OpenCASCADE Community Edition: 6.9.1
Curl: 7.71.0
Compiler: GCC 10.2.0 with C++ ABI 1014
Build settings:
USE_WX_GRAPHICS_CONTEXT=OFF
USE_WX_OVERLAY=OFF
KICAD_SCRIPTING=ON
KICAD_SCRIPTING_MODULES=ON
KICAD_SCRIPTING_PYTHON3=OFF
KICAD_SCRIPTING_WXPYTHON=ON
KICAD_SCRIPTING_WXPYTHON_PHOENIX=OFF
KICAD_SCRIPTING_ACTION_MENU=ON
BUILD_GITHUB_PLUGIN=ON
KICAD_USE_OCE=ON
KICAD_USE_OCC=OFF
KICAD_SPICE=ON