// f0: (V1 - V2) / R - I public override double DCFunction(DCSolver solver, int f) { if (f == 0) { double L = (solver.GetNetVoltage(PinConnections[0]) - solver.GetNetVoltage(PinConnections[1])) / Resistance; double R = solver.GetPinCurrent(this, 0); return(L - R); } else { return(0.0d); } }
// f0: Is * (e ^ ((Vd - IRs)/(n*Vt)) - 1) - I public override double DCFunction(DCSolver solver, int f) { if (f == 0) { double L = SaturationCurrent * (Math.exp_safe(((solver.GetNetVoltage(PinConnections[0]) - solver.GetNetVoltage(PinConnections[1])) - SeriesResistance * solver.GetPinCurrent(this, 0)) / (IdealityFactor * Math.vTherm)) - 1); double R = solver.GetPinCurrent(this, 0); return(L - R); } else { return(0.0d); } }
public override double DCDerivative(DCSolver solver, int f, VariableIdentifier var) { if (f == 0) { if (var.type == VariableType.NET) { if (var.net == PinConnections[0]) { return(SaturationCurrent * (1 / (IdealityFactor * Math.vTherm)) * Math.exp_deriv(((solver.GetNetVoltage(PinConnections[0]) - solver.GetNetVoltage(PinConnections[1]) - SeriesResistance * solver.GetPinCurrent(this, 0))) / (IdealityFactor * Math.vTherm))); } else if (var.net == PinConnections[1]) { return(-1 * SaturationCurrent * (1 / (IdealityFactor * Math.vTherm)) * Math.exp_deriv(((solver.GetNetVoltage(PinConnections[0]) - solver.GetNetVoltage(PinConnections[1]) - SeriesResistance * solver.GetPinCurrent(this, 0))) / (IdealityFactor * Math.vTherm))); } } else { if ((var.component == this) && (var.pin == 0)) { return(-1 * SeriesResistance * SaturationCurrent * (1 / (IdealityFactor * Math.vTherm)) * Math.exp_deriv(((solver.GetNetVoltage(PinConnections[0]) - solver.GetNetVoltage(PinConnections[1]) - SeriesResistance * solver.GetPinCurrent(this, 0))) / (IdealityFactor * Math.vTherm)) - 1); } } } return(0.0d); }