/// <summary>Performs necessary initialization of the device, like mapping to the equation system.</summary> /// <param name="adapter">The equation system builder.</param> /// <param name="context">Context of current simulation.</param> public override void Initialize(IEquationSystemAdapter adapter, ISimulationContext context) { stamper.Register(adapter, bprimeNode, cprimeNode, eprimeNode); voltageBc.Register(adapter, bprimeNode, cprimeNode); voltageBe.Register(adapter, bprimeNode, eprimeNode); voltageCs.Register(adapter, cprimeNode, Substrate); capacbe.Register(adapter, bprimeNode, eprimeNode); capacbc.Register(adapter, bprimeNode, cprimeNode); capaccs.Register(adapter, cprimeNode, Substrate); chargebe = context.SimulationParameters.IntegrationMethodFactory.CreateInstance(); chargebc = context.SimulationParameters.IntegrationMethodFactory.CreateInstance(); chargecs = context.SimulationParameters.IntegrationMethodFactory.CreateInstance(); gb.Register(adapter, bprimeNode, Base); gc.Register(adapter, cprimeNode, Collector); ge.Register(adapter, eprimeNode, Emitter); vT = PhysicalConstants.Boltzmann * PhysicalConstants.CelsiusToKelvin(Parameters.NominalTemperature) / PhysicalConstants.DevicearyCharge; VoltageBaseEmitter = DeviceHelpers.PnCriticalVoltage(Parameters.SaturationCurrent, vT); }
/// <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; }
/// <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; }