2021.7.9 - After reconfirmation, this is not a bug, but each sub-component must be manually set to the same spice configuration, because kicad will not automatically process them into the same configuration.
— Previous description —
There is a problem with the latest KiCAD 5.99 export spice netlist. including the version downloaded yesterday.
I uploaded an example. In this example, KiCAD cannot always generate the correct netlist. It discards the external model file (missing .include) and ignores the spice setting for LMV358.
But it doesn’t always make mistakes, and an occasional edit will produce the correct results, but you have to try your luck.
=============================
Windows 10 64bit 21H1 (Professional)
For some reason, in the spice setting of the component, the model file cannot be loaded, causing all the spice information related to it to be discarded.
If this model file is clearly pointed out in a text (although it has been set in spice in the component settings, it is invalid), it will not go wrong.
Edit: Sorry, this measure is no longer valid after some changes have been made.
Sorry, i changed the file name (including various manual modifications) in various tests to find the cause of the bug, and forgot to restore it. But the bug is real, and the cause has been found.
When you put the command set ngbehavior=kips
into the .control section, it will not become effective. It has to be put into the user definied initialization file .spiceinit (or spice.rc, as an alternative name).
Reason is that this command has to be set before the circuit is loaded and parsed. The PSPICE compatibility checks and modifications are done during circuit loading. The .control section will become active only later, when the circuit is already loaded.
No bug here: the schematic is just incorrect:
the op amp has 2 units (of 3) in schematic.
One has the spice model set (unit A), and the other has no model (unit C), that is a kind of model.
Moreover, one unit is missing (unit B). It can be needed depending on the kind of simulation.
One cannot have 2 different info: one for a unit one other for unit C, therefore 2 different models.
Kicad cannot know what is the right info.
I tried the .spiceinit file and it made ngspice.exe work very well.
But after I removed the set ngbehavior=kips in KiCAD, no matter how I changed the content (including restoring it), I couldn’t export the correct spice netlist.
I don’t know why KiCAD can output the results correctly sometimes. I don’t know what conditions are triggered to make this happen.
The model file has stated that there is only one unit, as long as the pin assignment is correct, it can work, it has been verified, and there is no abnormality when you are lucky.
After testing more than a hundred times, I guessed that KiCAD did not get a correct confirmation from the dynamic library of ngspice, so it discarded the part that was considered wrong.
But ngspice’s connection library can occasionally return a signal indicating OK, so KiCAD will correctly generate a spice netlist. I just don’t understand why this happens.
After I replaced the ordinary op amp symbol with the op amp symbol of the simulation library, there was no error anymore.
So, do circuit diagrams and simulation diagrams have to be drawn separately? I think that as long as the model file is correct, the ordinary symbol library can be handled correctly as a spice component.
Because the op amp pins of the simulation library are different from the real LMV358, it will be very troublesome if KiCAD cannot handle this conversion.
You should either place all three units into your circuit, as you do when soldering the device onto the PCB, even if one OpAmp remanes unconnected (One should ask themselves, if this is allowed), and then (at least for now) add the spice model to all three units, or select a generic OpAmp, if Eeschema is mainly used as schematic entry for ngspice.
I re-verified that the same model file should be used for the separate parts of the component and it will not cause an error. Because KiCAD does not automatically associate the relationship between the separated parts of the component and the spice model file, each sub-component needs to be manually configured to the same settings, including the model file.