Esempio n. 1
0
        /// <summary>This method is called each time an equation is solved.</summary>
        /// <param name="context">Context of current simulation.</param>
        public override void OnEquationSolution(ISimulationContext context)
        {
            var vcrit = DeviceHelpers.PnCriticalVoltage(Parameters.SaturationCurrent, vt);

            var(newvolt, limited) = DeviceHelpers.PnLimitVoltage(voltage.GetValue(), Voltage, vt, vcrit);

            var dVolt = newvolt - Voltage;
            var dCurr = Conductance * dVolt;

            var reltol = context.SimulationParameters.RelativeTolerance;
            var abstol = context.SimulationParameters.AbsoluteTolerance;

            if (limited || !MathHelper.InTollerance(Current, Current + dCurr, abstol, reltol))
            {
                context.ReportNotConverged(this);
            }

            Voltage = newvolt;
        }
Esempio n. 2
0
        /// <summary>This method is called each time an equation is solved.</summary>
        /// <param name="context">Context of current simulation.</param>
        public override void OnEquationSolution(ISimulationContext context)
        {
            var iS = Parameters.SaturationCurrent;

            var nF       = Parameters.ForwardEmissionCoefficient;
            var nR       = Parameters.ReverseEmissionCoefficient;
            var polarity = Parameters.IsPnp ? -1 : +1;

            // critical voltages to prevent numerical overflow
            var vbecrit = DeviceHelpers.PnCriticalVoltage(iS, nF * vT);
            var vbccrit = DeviceHelpers.PnCriticalVoltage(iS, nR * vT);

            var vvbe = voltageBe.GetValue() * polarity;
            var vvbc = voltageBc.GetValue() * polarity;

            var(vbe, limited)  = DeviceHelpers.PnLimitVoltage(vvbe, VoltageBaseEmitter, nF * vT, vbecrit);
            var(vbc, limited2) = DeviceHelpers.PnLimitVoltage(vvbc, VoltageBaseCollector, nR * vT, vbccrit);

            // calculate current deltas
            var delvbe = vbe - VoltageBaseEmitter;
            var delvbc = vbc - VoltageBaseCollector;
            var cchat  = CurrentCollector + (Transconductance + OutputConductance) * delvbe -
                         (OutputConductance + ConductanceMu) * delvbc;
            var cbhat = CurrentBase + ConductancePi * delvbe + ConductanceMu * delvbc;
            var cc    = CurrentCollector;
            var cb    = CurrentBase;

            var reltol = context.SimulationParameters.RelativeTolerance;
            var abstol = context.SimulationParameters.AbsoluteTolerance;

            // request another iteration if not converged
            if (limited || limited2 ||
                !MathHelper.InTollerance(cchat, cc, abstol, reltol) ||
                !MathHelper.InTollerance(cbhat, cb, abstol, reltol))
            {
                context.ReportNotConverged(this);
            }

            // update voltages
            VoltageBaseEmitter      = vbe;
            VoltageBaseCollector    = vbc;
            VoltageCollectorEmitter = vbc - vbe;
        }