Netlist that shows the problem:
* C:\Users\MikaelBe\Docs\Simulations\PYLT_test\PYLT_test.asc
* Generated by LTspice 26.0.2 for Windows.
V1 N001 0 0 AC 1
R1 vo 0 1k
X§U2 N002 vo 2ndOrderLowpass f0=10k Q=.707 H=2 ;§pnba IN)OUT
R3 N002 N001 1k
.ac dec 10 1 1MEG
* Library below included based on ModelFile attribute of instance X§U2 (C:\Users\MikaelBe\AppData\Local\LTspice\lib\sym\SpecialFunctions\2ndOrdLowpass.asy)
.lib 2ndOrderLowpass.sub
.backanno
.end
Test program:
from PyLTSpice import SimRunner, SpiceEditor, LTspice
from spicelib.log.ltsteps import LTSpiceLogReader
import spicelib
runner = SimRunner(output_folder='./' )
netlist = SpiceEditor(".\\PYLT_test.net")
print("netlist loaded")
for r1 in ('1k', '10k'):
netlist.set_component_value('R1', r1)
for r3 in ('1k', '10k'):
netlist.set_component_value('R3', r3)
run_netlist_file = "r1_{}-r3_{}.net".format(r1, r3)
raw, log = runner.run_now(netlist, run_filename=run_netlist_file, timeout=6000)
Error message:
Traceback (most recent call last):
File "C:\Users\MikaelBe\Docs\Simulations\PYLT_test\PYLT_test.py", line 16, in <module>
netlist.set_component_value('R3', r3)
~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^
File "C:\Users\MikaelBe\AppData\Local\Python\pythoncore-3.14-64\Lib\site-packages\spicelib\editor\spice_subcircuit.py", line 676, in set_component_value
component = self.get_component(reference)
File "C:\Users\MikaelBe\AppData\Local\Python\pythoncore-3.14-64\Lib\site-packages\spicelib\editor\spice_subcircuit.py", line 481, in get_component
if component.reference.upper() == ref_upped:
^^^^^^^^^^^^^^^^^^^
File "C:\Users\MikaelBe\AppData\Local\Python\pythoncore-3.14-64\Lib\site-packages\spicelib\editor\primitives.py", line 124, in reference
self.reset_attributes()
~~~~~~~~~~~~~~~~~~~~~^^
File "C:\Users\MikaelBe\AppData\Local\Python\pythoncore-3.14-64\Lib\site-packages\spicelib\editor\spice_subcircuit_instance.py", line 47, in reset_attributes
self._subcircuit = self._netlist.get_subcircuit_named(self.value) # In case it isn't given, get it from the parent
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^
File "C:\Users\MikaelBe\AppData\Local\Python\pythoncore-3.14-64\Lib\site-packages\spicelib\editor\spice_subcircuit.py", line 337, in get_subcircuit_named
return self.find_subckt_in_included_libs(name) # If it is not found in the current circuit, it may be in the included libraries
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
File "C:\Users\MikaelBe\AppData\Local\Python\pythoncore-3.14-64\Lib\site-packages\spicelib\editor\spice_subcircuit.py", line 1022, in find_subckt_in_included_libs
sub_circuit = self.find_subckt_in_lib(lib_filename, subcircuit_name)
File "C:\Users\MikaelBe\AppData\Local\Python\pythoncore-3.14-64\Lib\site-packages\spicelib\editor\spice_subcircuit.py", line 960, in find_subckt_in_lib
reg_subckt = re.compile(SUBCKT_CLAUSE_FIND + subckt_name, re.IGNORECASE)
~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~
TypeError: can only concatenate str (not "float_unit") to str
If I edit the netlist to swap the R3 and X§U2 lines, the traceback instead points to the run_now line:
Traceback (most recent call last):
File "C:\Users\MikaelBe\Docs\Simulations\PYLT_test\PYLT_test.py", line 18, in <module>
raw, log = runner.run_now(netlist, run_filename=run_netlist_file, timeout=6000)
If I delete the X§U2 line, it simulates correctly.
I see the same behavior with 2ndOrderNotch and 2ndOrderAllpass, but not with UniversalOpamp, so it's not merely the presence of '=' signs in the parameters that triggers this.
LTspice version 26.0.2
$ pip show PyLTSpice | findstr Version
Version: 6.0.1
Netlist that shows the problem:
Test program:
Error message:
If I edit the netlist to swap the R3 and X§U2 lines, the traceback instead points to the run_now line:
If I delete the X§U2 line, it simulates correctly.
I see the same behavior with 2ndOrderNotch and 2ndOrderAllpass, but not with UniversalOpamp, so it's not merely the presence of '=' signs in the parameters that triggers this.
LTspice version 26.0.2
$ pip show PyLTSpice | findstr Version
Version: 6.0.1