public void When_ParallelMultiplierTransient_Expect_Reference() { // Create circuit // WARNING: We simulate both possibilities together, because the // timestep varies if we split them due to different timestep truncation. var ckt = new Circuit( new VoltageSource("V1r", "inr", "0", new Pulse(1, 5, 1e-6, 1e-9, 0.5e-6, 2e-6, 6e-6)), new VoltageSource("Vsupplyr", "vddr", "0", 5), new Resistor("R1r", "outr", "0", 1.0e3), CreateMOS3("M1r", "outr", "inr", "vddr", "vddr", "DMOS") .SetParameter("w", 1e-6) .SetParameter("l", 1e-6), CreateMOS3("M2r", "outr", "inr", "vddr", "vddr", "DMOS") .SetParameter("w", 1e-6) .SetParameter("l", 1e-6), new VoltageSource("V1a", "ina", "0", new Pulse(1, 5, 1e-6, 1e-9, 0.5e-6, 2e-6, 6e-6)), new VoltageSource("Vsupplya", "vdda", "0", 5), new Resistor("R1a", "outa", "0", 1.0e3), CreateMOS3("M1a", "outa", "ina", "vdda", "vdda", "DMOS") .SetParameter("w", 1e-6) .SetParameter("l", 1e-6) .SetParameter("m", 2.0), CreateMOS3Model("DMOS", false, "VTO = -0.7 KP = 3.8E+1 THETA = .25 VMAX = 3.5E5 KF=1e-24")); // Create simulation var tran = new Transient("tran", 1e-9, 10e-6); tran.BiasingParameters.Gmin = 0.0; // May interfere with comparison var v_ref = new RealVoltageExport(tran, "outr"); var v_act = new RealVoltageExport(tran, "outa"); tran.ExportSimulationData += (sender, args) => { var tol = Math.Max(Math.Abs(v_ref.Value), Math.Abs(v_act.Value)) * CompareRelTol + CompareAbsTol; Assert.AreEqual(v_ref.Value, v_act.Value, tol); }; tran.Run(ckt); v_ref.Destroy(); v_act.Destroy(); }
public void When_MultipliersTransient_Expect_Reference() { /* * Pulsed voltage source towards a resistive voltage divider between 0V and 5V * Output voltage is expected to behavior like the reference */ // Build circuit var model = CreateDiodeModel("1N914", "Is = 2.52e-9 Rs = 0.568 N = 1.752 Cjo = 4e-12 M = 0.4 tt = 20e-9"); var ckt = new Circuit( new VoltageSource("V1r", "inr", "0", new Pulse(0, 5, 1e-6, 10e-9, 10e-9, 1e-6, 2e-6)), new VoltageSource("Vsupplyr", "vddr", "0", 5.0), new Resistor("R1r", "vddr", "outr", 10.0e3), new Resistor("R2r", "outr", "0", 10.0e3), new VoltageSource("V1a", "ina", "0", new Pulse(0, 5, 1e-6, 10e-9, 10e-9, 1e-6, 2e-6)), new VoltageSource("Vsupplya", "vdda", "0", 5.0), new Resistor("R1a", "vdda", "outa", 10.0e3), new Resistor("R2a", "outa", "0", 10.0e3), model, new Diode("D1", "ina", "outa", model.Name) .SetParameter("m", 3.0) .SetParameter("n", 2.0)); ParallelSeries(ckt, name => new Diode(name, "", "", model.Name), "inr", "outr", 3, 2); // Create simulation var tran = new Transient("tran", 1e-9, 10e-6); tran.BiasingParameters.Gmin = 0.0; // May interfere with comparison var v_ref = new RealVoltageExport(tran, "outr"); var v_act = new RealVoltageExport(tran, "outa"); tran.ExportSimulationData += (sender, args) => { var tol = Math.Max(Math.Abs(v_ref.Value), Math.Abs(v_act.Value)) * CompareRelTol + CompareAbsTol; Assert.AreEqual(v_ref.Value, v_act.Value, tol); }; tran.Run(ckt); v_ref.Destroy(); v_act.Destroy(); }