public static void ElectricityOutput(VIRCurrent Current, ElectricalOIinheritance SourceInstance, IntrinsicElectronicData Thiswire) { //Logger.Log("4 > " + Current); //Logger.Log("poke > " + SourceInstance.InData.Data.SupplyDependent[SourceInstance].ToString()); var OutputSupplyingUsingData = Thiswire.Data.SupplyDependent[SourceInstance]; VIRCurrent SupplyingCurrent = null; float Divider = (ElectricityFunctions.WorkOutResistance(OutputSupplyingUsingData.ResistanceComingFrom)); foreach (KeyValuePair <IntrinsicElectronicData, VIRResistances> JumpTo in OutputSupplyingUsingData .ResistanceComingFrom) { if (OutputSupplyingUsingData.ResistanceComingFrom.Count > 1) { SupplyingCurrent = Current.SplitCurrent(Divider / JumpTo.Value.Resistance()); } else { SupplyingCurrent = Current; } OutputSupplyingUsingData.CurrentGoingTo[JumpTo.Key] = SupplyingCurrent; if (JumpTo.Key != null && JumpTo.Key.Categorytype != PowerTypeCategory.DeadEndConnection) { JumpTo.Key.ElectricityInput(SupplyingCurrent, SourceInstance, Thiswire); } } }
public static VIRCurrent ElectricalStageTransformerCalculate(TransformerModule TransformInformation, VIRCurrent Current, float ResistanceModified, float inVoltage, bool FromHighSide = false) { double TurnRatio = TransformInformation.TurnRatio; if (!FromHighSide) { TurnRatio = 1 / TransformInformation.TurnRatio; } double Voltage = (Current.Current() * ResistanceModified); //Logger.Log("Current.Current() > " + Current.Current() + " ResistanceModified > " + ResistanceModified); //Logger.Log(TransformInformation.TurnRatio + " < TurnRatio " + TransformInformation.VoltageLimiting + " < VoltageLimiting " + TransformInformation.VoltageLimitedTo + " < VoltageLimitedTo "); if (Voltage != 0) { double offcut = 0; //double V2 = Voltage / TurnRatio; //double R2 = V2 / ((Voltage / V2) * (Voltage / ResistanceModified)); //double R2 = (ResistanceModified / Math.Pow(TurnRatio, 2.0)); double V2 = Voltage / TurnRatio; double R2 = V2 / ((Voltage / V2) * (Voltage / ResistanceModified)); //Logger.Log(R2 + " < R2 " + V2 + " < V2 " + ResistanceModified + " < ResistanceModified" + TurnRatio + " < TurnRatio " + Voltage + " < Voltage "); if (!(TransformInformation.VoltageLimiting == 0)) { //if Total Voltage greater than that then Push some of it to ground to == VoltageLimitedTo And then everything after it to ground/ //float VVoltage = ElectricityFunctions.WorkOutVoltage(TransformInformation.ControllingNode.Node); if (V2 + inVoltage > TransformInformation.VoltageLimiting) { offcut = ((V2 + inVoltage) - TransformInformation.VoltageLimitedTo); V2 = V2 - offcut; if (V2 < 0) { V2 = 0; } } } //inVoltage TurnRatio = TurnRatio * (V2 / (Voltage / TurnRatio)); //Logger.Log("V2 " + V2.ToString()); //Logger.Log("I2 " + I2.ToString()); //Logger.Log("Current.Current() " + Current.Current().ToString()); var ReturnCurrent = Current.SplitCurrent((float)TurnRatio); //Logger.Log("ReturnCurrent " + ReturnCurrent.Current().ToString()); return(ReturnCurrent); } return(Current); }