post-kerbin-mining-corporation / NearFutureSolar

Adds more solar panel parts to Kerbal Space Program
32 stars 25 forks source link

Replace hardcoded home planet distance from sun #43

Closed jsolson closed 6 years ago

jsolson commented 6 years ago

In a 2.5x rescale a 30 ec/sec panel would only generate 4.8 ec/sec at Kerbin.

The method used does not handle well Kerbin's in a very eccentric orbit since it's current distance from Sun is always changing. The semi major axis value would probably be better, but then I've seen one mod where Kerbin is a moon of something. SMA would be wrong then. I don't know how stock would handle those scenarios either.

ChrisAdderley commented 6 years ago

That's not really a problem as this is just a reference, right? As long as we're at "about" sun alt at home, values should be fairly consistent.

jsolson commented 6 years ago

Yup, "about" right is good enough. I checked both the stock module and the module Kopernicus replaces it with and they are both slightly high couple percent from the advertised rate at Kerbin in a 2.5 rescale. Now that I think about it they both might be comparing Kerbins SMA to the vessel's altitude above the sun. The SMA would be the distance to the center of the sun in Kerbin's circular orbit, and that would make the vessel appear slightly closer than the baseline.

On a Kerbin in an orbit with an apoapsis twice that of the periapsis things would get weird. If you started the session at periapsis Kerbin altitude would be read there, and half a year later (in the same session) when Kerbin got to apoapsis the EC rates would be 1/4 of normal. If you exit and then return to the game at that point, Kerbin altitude gets read at apoapsis and EC rates go back to normal, and then jump to 4 times that when Kerbin gets back to periapsis.

ChrisAdderley commented 6 years ago

Ok so in the case that sun alt at home is calculated dynamically and has the potential to be wrong... wouldn't it be better to make distance from sun a KSPField and have the rescale/the planet pack be responsible for configuring it?

jsolson commented 6 years ago

I think the best answer is just worry about the stock home world circular orbit situation.

Perusing the KopernicusSolarPanel class you've got things like multiple stars, luminosity, power curves, and is the panel underwater. I would pose the question to someone on the Kopernicus team before jumping that shark.

The PhysicsGlobals class has SolarLuminosity and SolarLuminosityAtHome. There may be a more correct answer there. If there's a GetVesselSolarLuminocity() somewhere then this might work:

float realFlow = energyFlow * (float)( GetVesselSolarLuminocity() / PhysicsGlobals.SolarLuminosityAtHome);