From b72b814694ca33834a9c7d8ceb0f90ee5b218b55 Mon Sep 17 00:00:00 2001 From: Sigma88 Date: Thu, 19 Mar 2020 16:17:12 +0100 Subject: [PATCH] calculate flux differently --- src/Kopernicus/Components/KopernicusSolarPanels.cs | 13 +++++++------ src/Kopernicus/Components/KopernicusStar.cs | 6 +++--- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/Kopernicus/Components/KopernicusSolarPanels.cs b/src/Kopernicus/Components/KopernicusSolarPanels.cs index 54374fec1..dc2196ba0 100644 --- a/src/Kopernicus/Components/KopernicusSolarPanels.cs +++ b/src/Kopernicus/Components/KopernicusSolarPanels.cs @@ -59,7 +59,7 @@ void FixedUpdate() KopernicusStar star = KopernicusStar.CelestialBodies[SP.trackingBody]; star.shifter.ApplyPhysics(); - vessel.solarFlux = star.CalculateFluxAt(vessel); + vessel.solarFlux = star.CalculateFluxAt(vessel) * PhysicsGlobals.SolarLuminosityAtHome / 1360; } } } @@ -109,7 +109,7 @@ void FixedUpdate() { KopernicusStar trackingStar = KopernicusStar.CelestialBodies[SP.trackingBody]; - Double bestFlux = vessel.solarFlux; + Double bestFlux = vessel.solarFlux * 1360 / PhysicsGlobals.SolarLuminosityAtHome; KopernicusStar bestStar = trackingStar; Double totalFlux = 0; Single totalAoA = SP.sunAOA; @@ -124,7 +124,8 @@ void FixedUpdate() { // Use this star star.shifter.ApplyPhysics(); - vessel.solarFlux = star.CalculateFluxAt(vessel); + double flux = star.CalculateFluxAt(vessel); + vessel.solarFlux += flux * PhysicsGlobals.SolarLuminosityAtHome / 1360; // Change the tracking body SP.trackingBody = star.sun; @@ -143,9 +144,9 @@ void FixedUpdate() _totalFlow += SP._flowRate; totalFlow += SP.flowRate; - if (bestFlux < vessel.solarFlux) + if (bestFlux < flux) { - bestFlux = vessel.solarFlux; + bestFlux = flux; bestStar = star; } @@ -161,7 +162,7 @@ void FixedUpdate() // Restore the starting star trackingStar.shifter.ApplyPhysics(); - totalFlux += trackingStar.CalculateFluxAt(vessel); + totalFlux += trackingStar.CalculateFluxAt(vessel) * PhysicsGlobals.SolarLuminosityAtHome / 1360; vessel.solarFlux = totalFlux; SP.sunAOA = totalAoA; diff --git a/src/Kopernicus/Components/KopernicusStar.cs b/src/Kopernicus/Components/KopernicusStar.cs index f362407bd..340ec3c07 100755 --- a/src/Kopernicus/Components/KopernicusStar.cs +++ b/src/Kopernicus/Components/KopernicusStar.cs @@ -305,7 +305,7 @@ public Double CalculateFluxAt(Vessel vessel) if (directSunlight) { - Double output = PhysicsGlobals.SolarLuminosity / (12.5663706143592 * realDistanceToSun * realDistanceToSun) * PhysicsGlobals.SolarLuminosityAtHome / 1360; + Double output = PhysicsGlobals.SolarLuminosity / (12.5663706143592 * realDistanceToSun * realDistanceToSun); return output; } @@ -337,14 +337,14 @@ public static void SunBodyFlux(ModularFlightIntegrator MFI) star.shifter.ApplyPhysics(); // Calculate Flux - solarFlux += star.CalculateFluxAt(MFI.Vessel); + solarFlux += star.CalculateFluxAt(MFI.Vessel) * PhysicsGlobals.SolarLuminosityAtHome / 1360; } // Set Physics to the Current Star KopernicusStar.Current.shifter.ApplyPhysics(); // Calculate Flux - solarFlux += Current.CalculateFluxAt(MFI.Vessel); + solarFlux += Current.CalculateFluxAt(MFI.Vessel) * PhysicsGlobals.SolarLuminosityAtHome / 1360; // Reapply MFI.Vessel.directSunlight = solarFlux > 0;