Exemplo n.º 1
0
        public void When_NMOSIVCharacteristic_Expect_NoException()
        {
            // <example_DC>
            // Create the mosfet and its model
            var nmos      = new Mosfet1("M1", "d", "g", "0", "0", "example");
            var nmosmodel = new Mosfet1Model("example");

            nmosmodel.SetParameter("kp", 150.0e-3);

            // Build the circuit
            var ckt = new Circuit(
                new VoltageSource("Vgs", "g", "0", 0),
                new VoltageSource("Vds", "d", "0", 0),
                nmosmodel,
                nmos
                );

            // Sweep the base current and vce voltage
            var dc = new DC("DC 1", new[]
            {
                new ParameterSweep("Vgs", new LinearSweep(0, 3, 0.2)),
                new ParameterSweep("Vds", new LinearSweep(0, 5, 0.1)),
            });

            // Export the collector current
            var currentExport = new RealPropertyExport(dc, "M1", "id");

            // Run the simulation
            dc.ExportSimulationData += (sender, args) =>
            {
                var vgsVoltage = dc.GetCurrentSweepValue()[0];
                var vdsVoltage = dc.GetCurrentSweepValue()[1];
                var current    = currentExport.Value;
            };
            dc.Run(ckt);
            // </example_DC>
        }