public static void ElectricityInput(VIRCurrent Current, ElectricalOIinheritance SourceInstance, IntrinsicElectronicData ComingFrom, IntrinsicElectronicData Thiswire) { //Logger.Log("ElectricityInput" + Thiswire + " ComingFrom > " + ComingFrom); //Logger.Log("5 > " + Current + " Categorytype > " + Thiswire.Categorytype + " ComingFrom > " + ComingFrom.Categorytype); //Logger.Log("poke > " + SourceInstance.InData.Data.SupplyDependent[SourceInstance].ToString()); if (!Thiswire.Data.SupplyDependent[SourceInstance].CurrentComingFrom.ContainsKey(ComingFrom)) { Thiswire.Data.SupplyDependent[SourceInstance].CurrentComingFrom[ComingFrom] = Current; } else { //Logger.Log("AADD"); Thiswire.Data.SupplyDependent[SourceInstance].CurrentComingFrom[ComingFrom].addCurrent(Current); } if (!(Thiswire.Data.SupplyDependent[SourceInstance].ResistanceComingFrom.Count > 0)) { var sync = ElectricalManager.Instance.electricalSync; sync.StructureChange = true; sync.NUStructureChangeReact.Add(Thiswire.ControllingDevice); sync.NUResistanceChange.Add(Thiswire.ControllingDevice); sync.NUCurrentChange.Add(Thiswire.ControllingDevice); Logger.LogErrorFormat("Resistance isn't initialised on", Category.Electrical); return; } Thiswire.Data.SupplyDependent[SourceInstance].SourceVoltage = (float)Current.Current() * (ElectricityFunctions.WorkOutResistance(Thiswire.Data.SupplyDependent[SourceInstance].ResistanceComingFrom)); //ELCurrent.CurrentWorkOnNextListADD(Thiswire); Thiswire.ElectricityOutput(Current, SourceInstance); }
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); }