/// <summary> /// Initializes a new instance of the <see cref="CurrentDecibelExport"/> class. /// </summary> /// <param name="name">Name of export.</param> /// <param name="simulation">A simulation</param> /// <param name="source">An identifier</param> public CurrentDecibelExport(string name, Simulation simulation, string source) : base(simulation) { Name = name ?? throw new ArgumentNullException(nameof(name)); Source = source ?? throw new ArgumentNullException(nameof(source)); ExportImpl = new ComplexPropertyExport(simulation, source, "i"); }
/// <summary> /// Initializes a new instance of the <see cref="CurrentExport"/> class. /// </summary> /// <param name="name">Name of export.</param> /// <param name="simulation">A simulation.</param> /// <param name="source">A name of current source.</param> public CurrentExport(string name, Simulation simulation, string source) : base(simulation) { Name = name ?? throw new System.NullReferenceException(nameof(name)); Source = source ?? throw new System.NullReferenceException(nameof(source)); if (simulation is FrequencySimulation) { ExportImpl = new ComplexPropertyExport(simulation, source, "i"); } else { ExportRealImpl = new RealPropertyExport(simulation, source, "i"); } }
public void When_SimpleCapacitorFrequency_Expect_Reference() { var ckt = new Circuit( new VoltageSource("V1", "in", "0", 0).SetParameter("acmag", 1.0), new Capacitor("C1", "in", "0", 1e-3), new BehavioralCapacitor("C2", "in", "0", "1m*x")); var ac = new AC("ac", new DecadeSweep(1, 1e6, 5)); var refExport = new ComplexPropertyExport(ac, "C1", "i"); var actExport = new ComplexPropertyExport(ac, "C2", "i"); ac.ExportSimulationData += (sender, args) => { Assert.AreEqual(refExport.Value.Real, actExport.Value.Real, 1e-9); Assert.AreEqual(refExport.Value.Imaginary, actExport.Value.Imaginary, 1e-9); }; ac.Run(ckt); }
public void When_CapacitorAC_Expect_Reference() { var ckt = new Circuit( new VoltageSource("V1", "in", "0", new Sine(0, 1, 100)), new Capacitor("C1", "in", "0", 1e-6), new BehavioralCurrentSource("C2", "in", "0", "1u*ddt(V(in))")); var ac = new AC("tran", new DecadeSweep(1, 1e6, 2)); var reference = new ComplexPropertyExport(ac, "C1", "i"); var actual = new ComplexPropertyExport(ac, "C2", "i"); ac.ExportSimulationData += (sender, args) => { var r = reference.Value; var a = actual.Value; Assert.AreEqual(r.Real, a.Real, 1e-12); Assert.AreEqual(r.Imaginary, a.Imaginary, 1e-12); }; ac.Run(ckt); }