Conversation
Updated env to add sympy and optional python-mumps, not available in Pyodide
Added NetlistStateSpace class in pathsim_rf for netlist integration
cover the new class as well as associated subclass
import only NetlistStateSpace as to keep netlist parser not accessible directly
|
Small problem, python_mumps is only compatible with python>=3.11 and pathsim_rf has release starting from 3.9. |
|
Do we really need mumps? Wouldnt scipy superLU do for the sparse solve? |
|
This would be possible. However, on large netlist, I suspect it will be significantly slower. I am currently checking if python-mumps 0.0.3 (compatible with python 3.9) is going to work with current implementation
|
|
0.0.3 is compatible with python 3.9 but there may be some rework to do. I intend to make python-mumps only available starting python 3.11. The code already have a fallback to sympy if python-mumps is not installed so this would work with python<=3.10 (sympy), python>= 3.11 (sympy and/or python-mumps) |
|
There may be some other issues. python-mumps package from pypi do not include mumps... (conda/mamba package does) |
|
note : the addition of K coupling can make the system not that sparse. on a netlist with 396 k, mumps implementation takes 0.8s, scipy more than 10 minutes. |
improve significantly the time for large netlist with k couplings
|
Current status : passed sympy LU to scipy LU solve. On a netlist with 31 L, 64 R and 397 k python-mumps is installed with mamba and pypi have no way of installing mumps (pypi python-mumps install does not have mumps included) I see two options: I recommend solution 1, test including python-mumps will be skipped (TestFastReduction class in tests/test_netlist_statespace.py) |
|
I will check it. Factor of almost 40 between scipy superLU and mumps seems insane. Also a linear system of n roughly 100 should solve way faster then that. Generally I am for less dependencies. |
|
Here is the use case I'm using MediumCoupled.txt Nevertheless the argument of less dependencies is perfectly understandable. from pathsim_rf.netlist_to_statespace import NetlistStateSpace
state_space_sym = NetlistStateSpace("MediumCoupled.txt", output_voltages=["N3"], reduction_mode="symbolic")
state_space_mumps = NetlistStateSpace("MediumCoupled.txt", output_voltages=["N3"], reduction_mode="fast") |
|
Thanks for the netlist. The time goes into Second issue: this netlist has inductor cutsets (no capacitors, 22 node groups reach ground only through inductors). |
|
Yes, my current tests are consistent with this |
Removed sympy and python-mumps dependencies for compatibility.
|
Current implementation remove mumps and sympy dependencies. |
|
Is this because the circuits are degenerate and you have cutsets of inductors etc? |
|
The matrix E can be singular in my use cases. Matrix L is dense due to k couplings. I expect to code to work for classic circuit topologies but this may be a problem for heavy coupled problem like the few I'm using. |
|
New implementation from mass_matrix_netlist import MMDAENetlist
test_mmn = MMDAENetlist("filter.net")This expose the full problem to pathsim so wiring is more convenient with labels conn_0 = Connection(pulsesource[0], test_mmn["V1"])
...
conn_14 = Connection(test_mmn["V(n1)"], scope[5])I believe Pathview only use index so this will be a problem for large netlist. |
|
PathView can use the port labels of the block. So if there is a way that you construct them from the netlist (net labels, or even from the parameters) this should work. |
Added test for string input path handling and updated netlist path handling in existing tests.
Summary
This PR adds support for importing linear SPICE-like netlists into PathSim as state-space models.
The new
NetlistStateSpaceblock converts RLC circuits and independent sources into an explicit state-space representation using Modified Nodal Analysis (MNA), allowing circuits described by netlists to be directly integrated into PathSim simulations.Main changes
Added
netlist_to_statespace.pywith:.paramhandlingAdded
NetlistStateSpaceto the publicpathsim_rfAPI.Added
sympyas a dependency for symbolic reduction.Added
python-mumpsas a dependency for fast numerical reduction.Added parser tests covering:
Added state-space tests covering:
Added validation netlists:
tests/filter.nettests/filter_without_load.netAdded the
netlist_import.ipynbdocumentation example demonstrating:Files added
src/pathsim_rf/netlist_to_statespace.pytests/test_netlist_parser.pytests/test_netlist_statespace.pytests/filter.nettests/filter_without_load.netdocs/source/examples/netlist_import.ipynbFiles modified
src/pathsim_rf/__init__.pypyproject.tomlValidation
The new test suite validates the netlist parser and the generated state-space models. Both symbolic and fast reduction paths are tested, including their numerical equivalence.
The added documentation example provides an end-to-end validation of a netlist-derived state-space model against an equivalent PathSim implementation.