Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SpiceSharp.Algebra.SingularException : The matrix was found to be singular when eliminating row 3. #58

Open
marcin-golebiowski opened this issue Apr 25, 2021 · 4 comments
Labels
bug Something isn't working

Comments

@marcin-golebiowski
Copy link
Member

Could you please check why there is the exception: "SpiceSharp.Algebra.SingularException : The matrix was found to be singular when eliminating row 3." for circuit:

        [Test]
        public void When_SimplestCircuit_Expect_Reference()
        {
            var ckt = new Circuit(
                new VoltageSource("V1", "OUT", "0", 10),
                new BehavioralResistor("R1", "OUT", "0", "V(OUT,0)"));

            var op = new OP("Simple circuit"); 
            var refExport = new RealCurrentExport(op, "V1");
            op.ExportSimulationData += (sender, args) =>
            {
                Assert.AreEqual(-1, refExport.Value, 1e-8);
            };

            op.Run(ckt);
        }

The circuit works in LTSpice:

image
image

@svenboulanger
Copy link
Member

svenboulanger commented Apr 25, 2021

I can already venture a guess here. In the first iteration, v(OUT) = 0, so this means that the resistor has i = V(OUT)^2 with 0 for all derivatives, which makes the matrix singular.

So the question is then, how can we fix this... Maybe I should make some minimum (GMIN) value for derivatives to make sure that a behavioral component always produces something...

@marcin-golebiowski
Copy link
Member Author

marcin-golebiowski commented Apr 25, 2021

Looks like that. Following test passed:

         [Test]
        public void When_SimplestCircuit_Expect_Reference()
        {
            var ckt = new Circuit(
                new VoltageSource("V1", "OUT", "0", 10),
                new BehavioralResistor("R1", "OUT", "0", $"V(OUT,0) + {1e-12}" ));

            var op = new OP("Simple circuit"); 
            var refExport = new RealCurrentExport(op, "V1");
            op.ExportSimulationData += (sender, args) =>
            {
                Assert.AreEqual(-1, refExport.Value, 1e-8);
            };

            op.Run(ckt);
        }

@svenboulanger
Copy link
Member

svenboulanger commented Apr 25, 2021

Hey Marcin, does LTSpice generate some kind of warning messages (like adding a GMIN resistor to ground somehwere)?

EDIT: Reason I ask is because depending on the situation, this might be an issue for Spice# and not Spice#.Behavioral...

@svenboulanger svenboulanger added the bug Something isn't working label Apr 25, 2021
@marcin-golebiowski
Copy link
Member Author

It's little funny but there was some error in the SPICE Error log:
"Questionable use of curly braces in "b§r1 out 0 r={v(out,0)}"
Error: undefined symbol in: "v"

However it was only about using of curly braces.
Following circuit:

Simple behavioral resistor circui
V1 OUT 0 10.0
R1 OUT 0 R=V(OUT,0)
.OP
.PROBE

doesn't generate any warnings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants