Esempio n. 1
0
        /// <summary>
        /// Generates heat in the editor scene
        /// </summary>
        protected void GenerateHeatFlight()
        {
            if (storageEnabled && heatStored < heatStorageMaximum)
            {
                heatModule.AddFlux(moduleID, 0f, -maxHeatRate);
                Fields["systemHeatGeneration"].guiName = Localizer.Format("#LOC_SystemHeat_ModuleSystemHeatSink_Field_SystemHeatGeneration");
                if (heatModule.currentLoopTemperature >= heatModule.nominalLoopTemperature)
                {
                    storageTemperature = Mathf.Clamp(storageTemperature + (-heatModule.consumedSystemFlux * TimeWarp.fixedDeltaTime) / (heatStorageSpecificHeat * heatStorageMass), 0f, 5000f); // Q = mcT
                    heatStored         = Mathf.Clamp(heatStored + (-heatModule.consumedSystemFlux) * TimeWarp.fixedDeltaTime, 0f, heatStorageMaximum);
                }
            }
            else if (!storageEnabled && heatStored > 0f)
            {
                Fields["systemHeatGeneration"].guiName = Localizer.Format("#LOC_SystemHeat_ModuleSystemHeatSink_Field_SystemHeatGeneration_Dump");
                heatModule.AddFlux(moduleID, storageTemperature, heatStorageDumpRate);
                heatStored         = Mathf.Clamp(heatStored - heatStorageDumpRate * TimeWarp.fixedDeltaTime, 0f, heatStorageMaximum);
                storageTemperature = storageTemperature - heatStorageDumpRate * TimeWarp.fixedDeltaTime / (heatStorageSpecificHeat * heatStorageMass); // Q = mcT
            }

            else
            {
                heatModule.AddFlux(moduleID, 0f, 0f);
            }
        }
        protected virtual void HandleHeatGeneration()
        {
            // Determine heat to be generated
            CurrentHeatGeneration = CalculateWasteHeatGeneration();

            if (CoreIntegrity <= 0f)
            {
                FuelStatus    = Localizer.Format("#LOC_SystemHeat_ModuleSystemHeatFissionReactor_Field_FuelStatus_Meltdown");
                ReactorOutput = Localizer.Format("#LOC_SystemHeat_ModuleSystemHeatFissionReactor_Field_ReactorOutput_Meltdown");
            }
            else
            {
                ReactorOutput = String.Format("{0:F1} {1}", CurrentHeatGeneration, Localizer.Format("#LOC_SystemHeat_Units_kW"));
            }

            if (heatModule)
            {
                if (Enabled)
                {
                    heatModule.AddFlux(moduleID, NominalTemperature, CurrentHeatGeneration, true);
                }
                else
                {
                    heatModule.AddFlux(moduleID, 0f, CurrentHeatGeneration, false);
                }
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Generates heat in the editor scene
        /// </summary>
        protected void GenerateHeatEditor()
        {
            float engineFraction = 0f;

            if (multiModule != null)
            {
                if ((multiModule.runningPrimary && engineModuleID == multiModule.primaryEngineID) || (!multiModule.runningPrimary && engineModuleID == multiModule.secondaryEngineID))
                {
                    engineFraction = engineModule.thrustPercentage / 100f;
                    Fields["systemHeatGeneration"].guiActiveEditor = true;
                    Fields["systemTemperature"].guiActiveEditor    = true;
                    heatModule.AddFlux(moduleID, systemOutletTemperature, engineFraction * systemPower);
                    systemHeatGeneration = String.Format("{0:F0} kW", engineFraction * systemPower);
                }
                else
                {
                    systemHeatGeneration = String.Format("{0:F0} kW", engineFraction * systemPower);
                    heatModule.AddFlux(moduleID, 0f, engineFraction * systemPower);
                    Fields["systemHeatGeneration"].guiActiveEditor = false;
                    Fields["systemTemperature"].guiActiveEditor    = false;
                }
            }
            else
            {
                engineFraction = engineModule.thrustPercentage / 100f;
                Fields["systemHeatGeneration"].guiActiveEditor = true;
                Fields["systemTemperature"].guiActiveEditor    = true;
                heatModule.AddFlux(moduleID, systemOutletTemperature, engineFraction * systemPower);
                systemHeatGeneration = String.Format("{0:F1} kW", engineFraction * systemPower);
            }
        }
        /// <summary>
        /// Generates heat in the editor scene
        /// </summary>
        protected void GenerateHeatEditor()
        {
            float engineFraction = 0f;

            if (multiModule != null)
            {
                if ((multiModule.runningPrimary && engineModuleID == multiModule.primaryEngineID) || (!multiModule.runningPrimary && engineModuleID == multiModule.secondaryEngineID))
                {
                    engineFraction = engineModule.thrustPercentage / 100f;
                    Fields["systemHeatGeneration"].guiActiveEditor = true;
                    Fields["systemTemperature"].guiActiveEditor    = true;
                    heatModule.AddFlux(moduleID, systemOutletTemperature, engineFraction * systemPower);
                    systemHeatGeneration = Localizer.Format("#LOC_SystemHeat_ModuleSystemHeatEngine_Field_HeatGeneration_Running", (engineFraction * systemPower).ToString("F0"));
                }
                else
                {
                    systemHeatGeneration = Localizer.Format("#LOC_SystemHeat_ModuleSystemHeatEngine_Field_HeatGeneration_Running", (engineFraction * systemPower).ToString("F0"));
                    heatModule.AddFlux(moduleID, 0f, engineFraction * systemPower);
                    Fields["systemHeatGeneration"].guiActiveEditor = false;
                    Fields["systemTemperature"].guiActiveEditor    = false;
                }
            }
            else
            {
                engineFraction = engineModule.thrustPercentage / 100f;
                Fields["systemHeatGeneration"].guiActiveEditor = true;
                Fields["systemTemperature"].guiActiveEditor    = true;
                heatModule.AddFlux(moduleID, systemOutletTemperature, engineFraction * systemPower);
                systemHeatGeneration = Localizer.Format("#LOC_SystemHeat_ModuleSystemHeatEngine_Field_HeatGeneration_Running", (engineFraction * systemPower).ToString("F0"));
            }
        }
Esempio n. 5
0
        public override void FixedUpdate()
        {
            base.FixedUpdate();

            if (heatModule != null)
            {
                //Utils.Log($"{0} {temperatureCurve.Evaluate(0f)}\n{350f} {temperatureCurve.Evaluate(350f)}\n{1000} {temperatureCurve.Evaluate(1000f)}\n");
                if (HighLogic.LoadedSceneIsFlight)
                {
                    if (base.IsCooling)
                    {
                        float flux = -temperatureCurve.Evaluate(heatModule.LoopTemperature);
                        heatModule.AddFlux(moduleID, 0f, flux);
                        RadiatorEfficiency = Localizer.Format("#LOC_SystemHeat_ModuleSystemHeatRadiator_RadiatorEfficiency_Running",
                                                              (-flux / temperatureCurve.Evaluate(temperatureCurve.Curve.keys[temperatureCurve.Curve.keys.Length - 1].time) * 100f).ToString("F0"));
                    }
                    else
                    {
                        heatModule.AddFlux(moduleID, 0f, 0f);
                        RadiatorEfficiency = Localizer.Format("#LOC_SystemHeat_ModuleSystemHeatRadiator_RadiatorEfficiency_Offline");
                    }
                }

                if (HighLogic.LoadedSceneIsEditor)
                {
                    float flux = -1.0f * temperatureCurve.Evaluate(heatModule.LoopTemperature);
                    heatModule.AddFlux(moduleID, 0f, flux);

                    //Utils.Log($"BLAH {heatModule.LoopTemperature} {flux} {temperatureCurve.Evaluate(heatModule.LoopTemperature)}");
                    RadiatorEfficiency = Localizer.Format("#LOC_SystemHeat_ModuleSystemHeatRadiator_RadiatorEfficiency_Running",
                                                          ((-temperatureCurve.Evaluate(heatModule.LoopTemperature) / temperatureCurve.Evaluate(temperatureCurve.Curve.keys[temperatureCurve.Curve.keys.Length - 1].time)) * 100f).ToString("F0"));
                }
            }
        }
        public override void FixedUpdate()
        {
            base.FixedUpdate();

            if (heatModule != null)
            {
                //Utils.Log($"{0} {temperatureCurve.Evaluate(0f)}\n{350f} {temperatureCurve.Evaluate(350f)}\n{1000} {temperatureCurve.Evaluate(1000f)}\n");
                if (HighLogic.LoadedSceneIsFlight)
                {
                    if (base.IsCooling)
                    {
                        float flux = -temperatureCurve.Evaluate(heatModule.LoopTemperature);

                        if (heatModule.LoopTemperature >= heatModule.nominalLoopTemperature)
                        {
                            heatModule.AddFlux(moduleID, 0f, flux);
                        }
                        else
                        {
                            heatModule.AddFlux(moduleID, 0f, 0f);
                        }
                        RadiatorEfficiency = Localizer.Format("#LOC_SystemHeat_ModuleSystemHeatRadiator_RadiatorEfficiency_Running",
                                                              (-flux / temperatureCurve.Evaluate(temperatureCurve.Curve.keys[temperatureCurve.Curve.keys.Length - 1].time) * 100f).ToString("F0"));

                        if (scalarModule != null)
                        {
                            scalarModule.SetScalar(Mathf.MoveTowards(scalarModule.GetScalar, Mathf.Clamp01((heatModule.currentLoopTemperature - draperPoint) / maxTempAnimation), TimeWarp.fixedDeltaTime * heatAnimationRate));
                        }
                    }
                    else
                    {
                        heatModule.AddFlux(moduleID, 0f, 0f);
                        RadiatorEfficiency = Localizer.Format("#LOC_SystemHeat_ModuleSystemHeatRadiator_RadiatorEfficiency_Offline");
                        if (scalarModule != null)
                        {
                            scalarModule.SetScalar(Mathf.MoveTowards(scalarModule.GetScalar, 0f, TimeWarp.fixedDeltaTime * heatAnimationRate));
                        }
                    }
                }

                if (HighLogic.LoadedSceneIsEditor)
                {
                    float flux = -1.0f * temperatureCurve.Evaluate(heatModule.LoopTemperature);
                    if (heatModule.LoopTemperature >= heatModule.nominalLoopTemperature)
                    {
                        heatModule.AddFlux(moduleID, 0f, flux);
                    }
                    else
                    {
                        heatModule.AddFlux(moduleID, 0f, 0f);
                    }

                    //Utils.Log($"BLAH {heatModule.LoopTemperature} {flux} {temperatureCurve.Evaluate(heatModule.LoopTemperature)}");
                    RadiatorEfficiency = Localizer.Format("#LOC_SystemHeat_ModuleSystemHeatRadiator_RadiatorEfficiency_Running",
                                                          ((-temperatureCurve.Evaluate(heatModule.LoopTemperature) / temperatureCurve.Evaluate(temperatureCurve.Curve.keys[temperatureCurve.Curve.keys.Length - 1].time)) * 100f).ToString("F0"));
                }
            }
        }
Esempio n. 7
0
 void GenerateHeatFlight()
 {
     if (converterModule.ModuleIsActive())
     {
         heatModule.AddFlux(moduleID, systemOutletTemperature, systemPower, true);
     }
     else
     {
         heatModule.AddFlux(moduleID, 0f, 0f, false);
     }
 }
Esempio n. 8
0
 protected void GenerateHeatEditor()
 {
     if (editorThermalSim)
     {
         heatModule.AddFlux(moduleID, systemOutletTemperature, systemPower.Evaluate(systemOutletTemperature));
     }
     else
     {
         heatModule.AddFlux(moduleID, 0f, 0f);
     }
 }
Esempio n. 9
0
 protected void GenerateHeatEditor()
 {
     if (base.IsActivated)
     {
         heatModule.AddFlux(moduleID, systemOutletTemperature, systemPower, true);
     }
     else
     {
         heatModule.AddFlux(moduleID, 0f, 0f, false);
     }
 }
 protected void GenerateHeatEditor()
 {
     if (heatModule)
     {
         if (editorThermalSim)
         {
             heatModule.AddFlux(moduleID, systemOutletTemperature, systemPower, true);
         }
         else
         {
             heatModule.AddFlux(moduleID, 0f, 0f, false);
         }
     }
 }
 /// <summary>
 /// Generates heat in the editor scene
 /// </summary>
 protected void GenerateHeatEditor()
 {
     if (Enabled)
     {
         float tDelta    = LoopGoalTemperature - CalculateNominalTemperature();
         float heatToAdd = temperatureDeltaHeatCurve.Evaluate(tDelta);
         heatModule.AddFlux(moduleID, tDelta, heatToAdd);
         CurrentPowerConsumption = -temperatureDeltaCostCurve.Evaluate(tDelta);
     }
     else
     {
         heatModule.AddFlux(moduleID, 0f, 0f);
         CurrentPowerConsumption = 0f;
     }
 }
Esempio n. 12
0
        /// <summary>
        /// Generates heat in the editor scene
        /// </summary>
        protected void GenerateHeatEditor()
        {
            if (Enabled)
            {
                Fields["PowerStatus"].guiActive       = true;
                Fields["PowerStatus"].guiActiveEditor = true;
                float outputHeat        = HeatRate;
                float outletTemperature = sourceModule.nominalLoopTemperature;

                float powerCost = temperatureDeltaCostCurve.Evaluate(OutletAdjustement);

                double amt = this.part.RequestResource(PartResourceLibrary.ElectricityHashcode, powerCost * TimeWarp.fixedDeltaTime, ResourceFlowMode.ALL_VESSEL);
                CurrentPowerConsumption = -powerCost;


                outletTemperature = Mathf.Clamp(outletTemperature + OutletAdjustement, 0f, float.MaxValue);

                if (destModule.LoopTemperature <= outletTemperature * 1.5f)
                {
                    sourceModule.AddFlux(moduleID, 0f, -HeatRate);


                    outputHeat = Mathf.Min(-sourceModule.consumedSystemFlux, HeatRate) + temperatureDeltaHeatCurve.Evaluate(OutletAdjustement);

                    PowerStatus = Localizer.Format("#LOC_SystemHeat_ModuleSystemHeatExchanger_Field_PowerCost_Active", powerCost.ToString("F0"));
                    Status      = Localizer.Format("#LOC_SystemHeat_ModuleSystemHeatExchanger_Field_Status_Active", outletTemperature.ToString("F0"), outputHeat.ToString("F0"), sourceModule.consumedSystemFlux.ToString("F1"));
                    destModule.AddFlux(moduleID, outletTemperature, outputHeat);
                }
                else
                {
                    PowerStatus = Localizer.Format("#LOC_SystemHeat_ModuleSystemHeatExchanger_Field_PowerCost_Active", powerCost.ToString("F0"));
                    Status      = Localizer.Format("#LOC_SystemHeat_ModuleSystemHeatExchanger_Field_Status_TooHot");
                    destModule.AddFlux(moduleID, outletTemperature, 0f);
                    sourceModule.AddFlux(moduleID, 0f, 0f);
                }
            }
            else
            {
                Fields["PowerStatus"].guiActive       = false;
                Fields["PowerStatus"].guiActiveEditor = false;
                Status = Localizer.Format("#LOC_SystemHeat_ModuleSystemHeatExchanger_Field_Status_Disabled");
                destModule.AddFlux(moduleID, 0f, 0f);
                sourceModule.AddFlux(moduleID, 0f, 0f);
            }
        }
        public override void FixedUpdate()
        {
            base.FixedUpdate();

            if (heatModule != null)
            {
                if (HighLogic.LoadedSceneIsFlight)
                {
                    if (base.IsCooling)
                    {
                        float radiativeFlux  = -temperatureCurve.Evaluate(heatModule.LoopTemperature);
                        float convectiveFlux = 0f;

                        if (vessel.atmDensity > 0d)
                        {
                            Fields["ConvectionStatus"].guiActive = true;
                            HeatLoop lp = heatModule.Loop;
                            if (lp != null)
                            {
                                float tDelta = lp.ConvectionTemperature - Mathf.Clamp(heatModule.LoopTemperature,
                                                                                      (float)PhysicsGlobals.SpaceTemperature, temperatureCurve.Curve.keys[temperatureCurve.Curve.keys.Length - 1].time);

                                convectiveFlux = Mathf.Clamp(
                                    tDelta * heatModule.Loop.ConvectionFlux * (float)part.heatConvectiveConstant * convectiveArea * 0.5f,
                                    float.MinValue, 0f);
                            }

                            ConvectionStatus = Localizer.Format("#LOC_SystemHeat_ModuleSystemHeatRadiator_ConvectionStatus_Running", convectiveFlux.ToString("F1"));
                        }
                        else
                        {
                            Fields["ConvectionStatus"].guiActive = false;
                        }

                        heatModule.AddFlux(moduleID, 0f, radiativeFlux + convectiveFlux, false);


                        RadiatorEfficiency = Localizer.Format("#LOC_SystemHeat_ModuleSystemHeatRadiator_RadiatorEfficiency_Running",
                                                              (-radiativeFlux / temperatureCurve.Evaluate(temperatureCurve.Curve.keys[temperatureCurve.Curve.keys.Length - 1].time) * 100f).ToString("F0"));
                        RadiatorStatus = Localizer.Format("#LOC_SystemHeat_ModuleSystemHeatRadiator_RadiatorStatus_Running", radiativeFlux.ToString("F1"));

                        if (scalarModule != null)
                        {
                            scalarModule.SetScalar(Mathf.MoveTowards(scalarModule.GetScalar, Mathf.Clamp01((heatModule.currentLoopTemperature - draperPoint) / maxTempAnimation), TimeWarp.fixedDeltaTime * heatAnimationRate));
                        }
                    }
                    else
                    {
                        Fields["RadiatorStatus"].guiActive   = false;
                        Fields["ConvectionStatus"].guiActive = false;
                        heatModule.AddFlux(moduleID, 0f, 0f, false);
                        RadiatorEfficiency = Localizer.Format("#LOC_SystemHeat_ModuleSystemHeatRadiator_RadiatorEfficiency_Offline");
                        if (scalarModule != null)
                        {
                            scalarModule.SetScalar(Mathf.MoveTowards(scalarModule.GetScalar, 0f, TimeWarp.fixedDeltaTime * heatAnimationRate));
                        }
                    }
                }

                if (HighLogic.LoadedSceneIsEditor)
                {
                    if (sunTracking)
                    {
                        this.Events["ToggleEditorSunTracking"].guiName = "Disable Sun Tracking";
                    }
                    else
                    {
                        this.Events["ToggleEditorSunTracking"].guiName = "Enable Sun Tracking";
                    }

                    float radiativeFlux  = -temperatureCurve.Evaluate(heatModule.LoopTemperature);
                    float convectiveFlux = 0f;

                    HeatLoop lp = heatModule.Loop;
                    if (lp != null)
                    {
                        float tDelta = lp.ConvectionTemperature - Mathf.Clamp(heatModule.LoopTemperature,
                                                                              (float)PhysicsGlobals.SpaceTemperature, temperatureCurve.Curve.keys[temperatureCurve.Curve.keys.Length - 1].time);

                        convectiveFlux = Mathf.Clamp(
                            tDelta * heatModule.Loop.ConvectionFlux * (float)part.heatConvectiveConstant * convectiveArea * 0.5f,
                            float.MinValue, 0f);

                        //Utils.Log($"tD {tDelta}, tC, {lp.ConvectionTemperature} tL {heatModule.LoopTemperature}, tMax {temperatureCurve.Curve.keys[temperatureCurve.Curve.keys.Length - 1].time}, convA {convectiveArea}");
                    }


                    heatModule.AddFlux(moduleID, 0f, radiativeFlux + convectiveFlux, false);

                    ConvectionStatus   = Localizer.Format("#LOC_SystemHeat_ModuleSystemHeatRadiator_ConvectionStatus_Running", convectiveFlux.ToString("F1"));
                    RadiatorEfficiency = Localizer.Format("#LOC_SystemHeat_ModuleSystemHeatRadiator_RadiatorEfficiency_Running",
                                                          ((temperatureCurve.Evaluate(heatModule.LoopTemperature) / temperatureCurve.Evaluate(temperatureCurve.Curve.keys[temperatureCurve.Curve.keys.Length - 1].time)) * 100f).ToString("F0"));
                }
            }
        }