[Solved] Error: vector I(R1) not found!

Hello everyone,

I am getting an error when I try to check the resistor current in the simulator (Error: vector I(R1) not found!). I already simplified the circuit trying to debug the issue, but it feels that I am doing something wrong. What looks strange to me is that I can get the voltages, and current of the DC source, but not currents of the components in the schematics. Is this a feature of the ngspice or I my mistake?

.title KiCad schematic
.save all
.probe alli
.probe p(R2)
.probe p(R1)
.probe p(V1)
.probe p(R3)
.dc V1 0 5 100m
R2 Net-_R1-Pad2_ 0 1k
R1 Net-_R1-Pad1_ Net-_R1-Pad2_ 1k
V1 Net-_R1-Pad1_ 0 DC 1 
R3 Net-_R1-Pad2_ 0 1k
.end

Thank you in advance for any comments

Regards,
Ivan

I have found the answer myself, it required just a bit of googling. I will copy it here, just in the case someone else will have a similar issue

I(element_name) is an extension added only to the commercial SPICE versions. In ngspice (which is based on Berkeley Spice 3) you can only plot currents through (independent) voltage sources. These are the only currents that appear in the circuit equations SPICE works from. If you have a more complex circuit you would need to add a zero volt source (in series) with the component to get its current

Source:

Sorry for spaming

1 Like

This has been necessary in the past.

Now, with ngspice-40, the command ‘.probe alli’ is doing this for you, so no extra effort is required.

Loading your netlist into standard ngspice, typing ‘run’ and the ‘display’ will reveal
r1#branch : current, real, 51 long
among others.
Plotting by
plot i(R1)
will show the current.

2 Likes

Thank you for your reply.

I run ngspice from KiCAD, and there I still get “vector not found”, even thought I compiled and installed ngspice-40 shared library. I need to check if I did not mess with the library path. Or may it happen that it is somehow related to the KiCAD itself?

Difficult to answer without more information.
What is your KiCad version and operating system?
Could you upload the project?

OS is Ubuntu 20.04.3 LTS

Application: KiCad x86_64 on x86_64

Version: 7.99.0-unknown-9d452a6097~172~ubuntu20.04.1, release build

Libraries:
	wxWidgets 3.2.1
	FreeType 2.10.1
	HarfBuzz 2.6.4
	FontConfig 2.13.1
	libcurl/7.68.0 OpenSSL/1.1.1f zlib/1.2.11 brotli/1.0.7 libidn2/2.2.0 libpsl/0.21.0 (+libidn2/2.2.0) libssh/0.9.3/openssl/zlib nghttp2/1.40.0 librtmp/2.3

Platform: Ubuntu 20.04.3 LTS, 64 bit, Little endian, wxGTK, gnome-flashback-metacity, x11

Build Info:
	Date: May 20 2023 16:03:13
	wxWidgets: 3.2.1 (wchar_t,wx containers) GTK+ 3.24
	Boost: 1.71.0
	OCC: 7.5.2
	Curl: 7.68.0
	ngspice: 40
	Compiler: GCC 9.4.0 with C++ ABI 1013

Build settings:

the project is attached

spice_R.zip (31.6 KB)

Just for information, if someone else will have the same issue.

It turned out that on Ubuntu KiCad uses libngspice-kicad library (I do not really know what is the difference between this one and the ngspice-40). So, because of some reason for me installation of ngspice-40 from the source did not work, but installing libngspice-kicad from Index of /kicad/kicad-dev-nightly/ubuntu did the job, i.e. now the current vectors are there

1 Like