public override void ApplyModelValues(ISimulationContext context) { var Is = DefinitionDevice.Param.SaturationCurrent; var Vt = DefinitionDevice.Param.ThermalVoltage; var n = DefinitionDevice.Param.IdealityCoefficient; var Vd = voltage.GetValue(); // calculates current through the diode and it's derivative DeviceHelpers.PnJunction(Is, Vd, Vt * n, out var Id, out var Geq); Current = Id; // stamp the equivalent circuit var Ieq = Id - Geq * Vd; conductanceStamper.Stamp(Geq); currentStamper.Stamp(Ieq); }
/// <summary>Gets values for the device model based on voltage across the diode.</summary> /// <param name="vd">Voltage across the diode.</param> /// <returns></returns> private (double id, double geq, double cd) GetModelValues(double vd) { var m = Parameters.JunctionGradingCoefficient; var vj = Parameters.JunctionPotential; var fc = Parameters.ForwardBiasDepletionCapacitanceCoefficient; var tt = Parameters.TransitTime; var iss = Parameters.SaturationCurrent; var jc = Parameters.JunctionCapacitance; var bv = Parameters.ReverseBreakdownVoltage; double id, geq; if (vd >= smallBiasTreshold) { DeviceHelpers.PnJunction(iss, vd, vt, out id, out geq); id += vd * gmin; geq += gmin; } else if (vd > -bv) { id = -iss; geq = gmin; } else { id = -iss * (Math.Exp(-(bv + vd) / vt) - 1 + bv / vt); geq = iss * Math.Exp(-(bv + vd) / vt) / vt; } var cd = -tt * geq; if (vd < capacitanceTreshold) { cd += jc / Math.Pow(1 - vd / vj, m); } else { cd += jc / Math.Pow(1 - fc, 1 + m) * (1 - fc * (1 + m) + m * vd / vj); } return(id, geq, cd); }