Jump to content

Failure to accurately simulate high-Q resonance


Recommended Posts

I'm having difficulty accurately modeling a high-Q circuit in SystemC AMS. The AC sweep "sees" the shunt, but a time-series simulation doesn't. Any suggestions?

The schematic is as follows:
 

/* >--- R1 ---+-------+--->
 *            |       |
 *            Cc      R2
 *            |       |
 *          --+--    GND
 *          |   |
 *          L   |
 *          |   C
 *          R   |
 *          |   |
 *          --+--
 *            |
 *           GND
 */

This forms a resonant shunt at 59.977 Mhz with very high Q (quality factor). The AC sweep sees it:

image.png.91479585a82ff2ba7050dd5f8cbe5890.png

...but a sca_eln::sca_vsource injected at the null frequency doesn't: (this is output:input ratio is indistinguishable from a resistor divider)

image.png.6a3d854c34615b30764b4a80e024c529.png

Source code follows:

#include <systemc.h>
#include <systemc-ams.h>

/* >--- R1 ---+-------+--->
 *            |       |
 *            Cc      R2
 *            |       |
 *          --+--    GND
 *          |   |
 *          L   |
 *          |   C
 *          R   |
 *          |   |
 *          --+--
 *            |
 *           GND
 */

SC_MODULE(rlcc) {
	sca_eln::sca_terminal a, b;
	sca_eln::sca_r r1, r2, r;
	sca_eln::sca_c cc, c;
	sca_eln::sca_l l;
	sca_eln::sca_node_ref gnd;

	rlcc(sc_core::sc_module_name) :
				a("a"), b("b"), r1("r1", 50), r2("r2", 50),
				cc("cc", 1e-14), c("c", .0005e-9),
				r("r", 1.0927083e-5),
				l("l", 0.01380688e-3),
				n1("n1"), n2("n2"),
				gnd("gnd") {

		r1.p(a);
		r1.n(b);
		r2.p(b);
		r2.n(gnd);
		cc.p(b);
		cc.n(n1);
		c.p(n1);
		c.n(gnd);
		l.p(n1);
		l.n(n2);
		r.p(n2);
		r.n(gnd);
	}
private:
	sca_eln::sca_node n1, n2;
};

SC_MODULE(rc_example) {
	sca_eln::sca_vsource i_vin;
	rlcc rlcc_inst;

	sca_eln::sca_node vin;
	sca_eln::sca_node vout;
	sca_eln::sca_node_ref gnd;

	SC_CTOR(rc_example)
		: i_vin("i_vin", 0, 0, 1.0, 59.97735e6,0,sc_core::SC_ZERO_TIME,1.0),
		rlcc_inst("rlcc"), vin("vin"), vout("vout"), gnd("gnd") {

		i_vin.p(vin);
		i_vin.n(gnd);
		i_vin.set_timestep(10.0, sc_core::SC_PS);

		rlcc_inst.a(vin);
		rlcc_inst.b(vout);
	}
};

int sc_main(int argc, char* argv[]){
	sc_set_time_resolution(10.0, SC_PS);
	sca_util::sca_information_off();
	
	rc_example dut("dut");

	sca_util::sca_trace_file* trtf = sca_util::sca_create_tabular_trace_file( "tr.tab" );
	sca_util::sca_trace( trtf, dut.vin, "vin" );
	sca_util::sca_trace( trtf, dut.vout, "vout" );
	sc_start(100, SC_NS);
	trtf->disable();

	SC_REPORT_INFO("sc_main", "transient domain simulation done");

	sca_util::sca_trace_file* actf = sca_util::sca_create_tabular_trace_file( "ac.tab" );
	sca_util::sca_trace( actf, dut.vin, "vin" );
	sca_util::sca_trace( actf, dut.vout, "vout" );
	sca_ac_start(59.975e6, 59.980e6, 100000);

	SC_REPORT_INFO("sc_main", "frequency domain simulation done");

	return 0;
}

Here's the Python code to form these plots:

import numpy as np
import matplotlib.pyplot as plt

t, y1, y2 = np.loadtxt('tr.tab', comments='%', unpack=True)

fig, ax = plt.subplots()
ax.plot(t, y1, label='vin')
ax.plot(t, y2, label='vout')
ax.set(xlabel='Time', ylabel='Volts', title="Resonator")
ax.grid(True)
ax.legend()

f, vii, viq, voi, voq = np.loadtxt('ac.tab', comments='%', unpack=True)
vi = vii + 1j * viq
vo = voi + 1j * voq

nmin = np.argmin(np.abs(vo))
fmin = f[np.argmin(np.abs(vo))]
print(f"Minimum at {fmin/1e6:.3} MHz")

fig, ax = plt.subplots()
ax.plot(f/1e6, np.abs(vo), label='vin')
ax.plot(fmin/1e6, np.abs(vo[nmin]), 'ro', fillstyle='none')
ax.set(xlabel='Frequency (MHz)', ylabel='Amplitude', title='AC Sweep')
plt.grid(True)
plt.legend()

plt.show()

 

Link to comment
Share on other sites

Hi,
It appears as if your transient domain simulation did not run long enough. Due to the very high Q of your filter, the settling time is quite long. In the first 100 nanoseconds that are simulated, there is almost no settling effect. I tried to let the simulation run longer (0.5 milliseconds) and the settling of the output signal starts to become noticeable.

The ac simulation always simulates the settled state of the system, so there the shunt is clearly visible.

The system is a so-called stiff system with high difference in the time constants. For such systems, numerical issues may become a problem.

shunt_settling_example.png

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...