Jump to content

Solver error with simple RLC circuit


Recommended Posts

Hi everybody,

I am trying to simulate a simple RLC circuit usin ELN moc but I got the following error message:

 

Error: SystemC-AMS: Initialization equation system failed in sca_linear_solver_0: 4
  The error is in the following net (max. 50):
        rlc1.Vsc
        rlc1.Isc
        rlc1.Racc
        rlc1.Ls
        rlc1.Cacc

The error is may  be near:
                rlc1.Ls  and
                rlc1.n2

In file: ../../../../../../src/scams/impl/solver/linear/sca_linear_solver.cpp:1619
In process: sca_implementation_0.cluster_process_0 @ 0 s

 

I inject a current into the circuit with a TDF isource and then I want to obtain the circuit voltage with a vsink in parallel.

Does anybody know where is the problem, please?

Here you can see the main:

#include "systemc-ams.h"
#include "rlc.h"
#include "const_load.h"

int sc_main(int argc, char* argv[])
{
// Connecting signals
  sca_tdf::sca_signal<double> Isc, Vsc;

// Instantiation of supercapacitor components
  rlc rlc1("rlc1");
  const_load load("load");


// Port binding
  rlc1.in(Isc);
  rlc1.out(Vsc);

  load.out(Isc);

// Tracing
  sca_util::sca_trace_file* atf = sca_util::sca_create_tabular_trace_file( "test_trace.dat" );
  sca_util::sca_trace( atf, Vsc, "Vsc" );
  sca_util::sca_trace( atf, Isc, "Isc" );
  sc_start(10, sc_core::SC_SEC);
//  sc_start();

  sca_util::sca_close_tabular_trace_file( atf );

  return 0;
}


rlc.h:

#include <systemc-ams>

SC_MODULE (rlc)
{
// Interface and internal components declaration
  sca_tdf::sca_in<double> in; // Isc
  sca_tdf::sca_out<double> out; // Vsc
  sca_eln::sca_tdf::sca_isource *Isc;
  sca_eln::sca_tdf::sca_vsink *Vsc;
  sca_eln::sca_node n1, n2, n3;
  sca_eln::sca_node_ref gnd;
  sca_eln::sca_r *Racc;
  sca_eln::sca_c *Cacc;
  sca_eln::sca_l *Ls;

  SC_CTOR (rlc) : n1("n1"), n2("n2"), n3("n3")
  {
// Output voltage instantiation
    Vsc = new sca_eln::sca_tdf::sca_vsink("Vsc");
    Vsc->p(n1);
    Vsc->n(gnd);
    Vsc->outp(out);
// Load current instantiation
    Isc = new sca_eln::sca_tdf::sca_isource("Isc");
    Isc->inp(in);
    Isc->p(n1);
    Isc->n(gnd);
// Racc instantiation
    Racc = new sca_eln::sca_r("Racc");
    Racc->p(n1);
    Racc->n(n2);
    Racc->value = 0.34;
// Ls instantiation
    Ls = new sca_eln::sca_l("Ls");
    Ls->p(n2);
    Ls->n(n3);
    Ls->value=0.00000093;
// Cacc instantiation
    Cacc = new sca_eln::sca_c("Cacc");
    Cacc->p(n3);
    Cacc->n(gnd);
    Cacc->value=0.8;
  }

};

While the const_load is just a tdf module having as output a value of -1.0 connected to the TDF isource.

 

Thank you very much!

 

Alex

Link to comment
Share on other sites

The equation setup error occurs because the inductor Ls acts also as a current source during DC operation point calculation so that you have two conflicting current sources in the same branch (there's no current flowing through the vsink branch). The problem can be solved by specifying that the initial linked flux phi0 is undefined by assigning sca_util::SCA_UNDEFINED to Ls->phi0 (confer to SystemC AMS LRM 2.0, clause 4.3.1.8.1 for details).

 

Please note that your rlc module lacks a destructor, which deletes the instantiated sub-modules.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...