public void KITFixedUpdate(IResourceManager resMan) { _spaceTemperature = FlightIntegrator.ActiveVesselFI == null ? 4 : FlightIntegrator.ActiveVesselFI.backgroundRadiationTemp; hotBathTemperature = Math.Max(4, Math.Max(part.temperature, part.skinTemperature)); var hasRadiators = FNRadiator.HasRadiatorsForVessel(vessel); if (!hasRadiators) { radiatorTemperature = 0; maximumPowerSupplyInMegaWatt = 0; currentPowerSupplyInMegaWatt = 0; return; } radiatorTemperature = FNRadiator.GetAverageRadiatorTemperatureForVessel(vessel); _timeWarpModifer = PluginHelper.GetTimeWarpModifer(); _hotColdBathRatio = 1 - Math.Min(1, radiatorTemperature / hotBathTemperature); _thermalConversionEfficiency = maxConversionEfficiency * _hotColdBathRatio; maximumPowerSupplyInMegaWatt = _hotColdBathRatio > requiredTemperatureRatio ? _thermalConversionEfficiency * maximumPowerCapacity * (1 / maxConversionEfficiency) : _thermalConversionEfficiency * maximumPowerCapacity * (1 / maxConversionEfficiency) * Math.Pow(_hotColdBathRatio * (1 / requiredTemperatureRatio), hotColdBathRatioExponent); }
public override void OnFixedUpdateResourceSuppliable(double fixedDeltaTime) { var hasRadiators = FNRadiator.HasRadiatorsForVessel(vessel); // get radiator temperature if (hasRadiators) { radiatorTemperature = FNRadiator.GetAverageRadiatorTemperatureForVessel(vessel); } else if (!_stackAttachedParts.Any()) { return; } else { radiatorTemperature = _stackAttachedParts.Min(m => m.temperature); } if (double.IsNaN(radiatorTemperature)) { return; } timeWarpModifer = PluginHelper.GetTimeWarpModifer(); spaceTemperature = FlightIntegrator.ActiveVesselFI == null ? 4 : FlightIntegrator.ActiveVesselFI.backgroundRadiationTemp; hotBathTemperature = Math.Max(4, Math.Max(part.temperature, part.skinTemperature)); var hotColdBathRatio = 1 - Math.Min(1, radiatorTemperature / hotBathTemperature); var thermalConversionEfficiency = maxConversionEfficiency * hotColdBathRatio; maximumPowerSupplyInMegaWatt = hotColdBathRatio > requiredTemperatureRatio ? thermalConversionEfficiency * maximumPowerCapacity * (1 / maxConversionEfficiency) : thermalConversionEfficiency * maximumPowerCapacity * (1 / maxConversionEfficiency) * Math.Pow(hotColdBathRatio * (1 / requiredTemperatureRatio), hotColdBathRatioExponent); var currentUnfilledResourceDemand = Math.Max(0, GetCurrentUnfilledResourceDemand(ResourceSettings.Config.ElectricPowerInMegawatt)); var requiredRatio = Math.Min(1, currentUnfilledResourceDemand / maximumPowerSupplyInMegaWatt); currentPowerSupplyInMegaWatt = requiredRatio * maximumPowerSupplyInMegaWatt; var wasteheatInMegaJoules = (1 - thermalConversionEfficiency) * currentPowerSupplyInMegaWatt; if (hasRadiators) { SupplyFnResourcePerSecondWithMax(maximumPowerSupplyInMegaWatt, wasteheatInMegaJoules, ResourceSettings.Config.WasteHeatInMegawatt); } else // dump heat in attached part { DumpWasteheatInAttachedParts(fixedDeltaTime, wasteheatInMegaJoules); } ExtractSystemHeat(fixedDeltaTime); // generate thermal power SupplyFnResourcePerSecondWithMax(currentPowerSupplyInMegaWatt, maximumPowerSupplyInMegaWatt, ResourceSettings.Config.ElectricPowerInMegawatt); }