Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong solar panel output #166

Closed
ShotgunNinja opened this issue Apr 28, 2017 · 30 comments
Closed

Wrong solar panel output #166

ShotgunNinja opened this issue Apr 28, 2017 · 30 comments

Comments

@ShotgunNinja
Copy link

ShotgunNinja commented Apr 28, 2017

This refer to a stock + MFI + Kopernicus + GPP installation.

At 13.982766706 Gm from Ciro (the GPP star replacing Kerbol):

  • solar irradiance sould be 1360 W/m²
  • the solar panel output should be 1.64 kW (EC/s)

The results are in line with expectation.
(The small difference in output is due to the default thermal efficiency curve of ModuleDeployableSolarPanel).

However, at 13.982766706 Gm from Grannus (a brown drawf orbiting Ciro in GPP):

  • solar irradiance should be 42 W/m²
  • the solar panel output should be 0.05 kW (EC/s)

The solar panel output is wrong. Notably, the irradiance value reported by the thermal debug window is correct. The similarity in value with output at 1AU from Ciro point to maybe an error in determining the active star.
(The output is in fact identical to the one at 1AU from Ciro, except for some 20% difference due to default thermal efficiency curve in ModuleDeployableSolarPanel).

Best regards.

@Sigma88
Copy link
Contributor

Sigma88 commented Apr 28, 2017

I think thomas already is aware of this, but if you could provide some logs it might help even more :)

@ShotgunNinja
Copy link
Author

Absolutely, here you go: KSP.log & output_log.txt

@Sigma88
Copy link
Contributor

Sigma88 commented May 22, 2017

@OhioBob and @Galileo88 seem to still have problems, even after the update

see IRC conversation (which sadly I cannot copy here because kiwi sucks)
transcript provided by regex

PS: guys if you have any logs, feel free to post them here.
possibly in a simple system, not a modded one.

better if stock with just 1 star added, with the least amount of changes possible, so basically a sun clone that only has a different Ec output (can't remember which is the parameter by memory)

@OhioBob
Copy link

OhioBob commented May 22, 2017

Thomas, the solar panel bug is an issue we've discussed in the past. I've worked out a solution that allows me to get the correct solar panel power output around multiple stars with different luminosities, but it requires that you undo a change that you made in Kopernicus 1.2.2-3. You can read a more detailed description of the problem and my proposed solution here: http://www.braeunig.us/KSP/GPP/SolarPanels.txt

I hope that you consider reverting the change you made in 1.2.2-3 in future releases of Kopernicus.

@StollD
Copy link
Member

StollD commented May 23, 2017

@OhioBob Well.. the problem is that I already reverted everything sun-related in 1.2.2-3, because it broke everything.

The only change I made is how the solar panels detect the star they are tracking

EDIT: Actually that might be incorrect. I will revert more stuff and send you a build

@StollD
Copy link
Member

StollD commented May 23, 2017

This issue is also interesting, because as far as I can see, blackracks dll and the release dll use the same star code

@OhioBob
Copy link

OhioBob commented May 23, 2017

@StollD that's very strange that you say blackrack's dll and the release dll are the same because I'm definitely seeing different behavior in the game. Using the release version, when I'm at given distance X from either star, I get the same charge rate regardless of the respective luminosities. When I use blackracks's dll, the charge rates are proportional to the luminosities.

@OhioBob
Copy link

OhioBob commented May 23, 2017

@StollD here's a test you can do for yourself. Download this, http://www.braeunig.us/KSP/Test.zip and place the Test folder in the GameData folder of your stock installation. All this does is adds a second star orbiting the Sun that has a luminosity 10% of the Sun. Put a 3x2 solar panel in orbit around both stars at a distance of 13.6 Gm (1 AU). Using the release dll, the power output of the solar panels will be about 1.64 around both stars. Now switch to blackrack's dll and repeat. The power output around the TestStar will be about 1.64, and around the Sun it will be about 16.4.

@StollD
Copy link
Member

StollD commented May 23, 2017

Ok, I made some commits, and I rewrote half of the star and solar panel code in Kopernicus.

The result of that is: When I have a vessel orbiting the Sun at 1 AU (13.6 Gm), the solar panels are receiving an energy flow of about 1.6, which is the value I get in stock too.

Around TestStar, I have an energy flow between 0.16 and 0.19. The range is, because the vessel can still receive some flux from the sun, depending on it's current position. The same mechanic applies when orbiting the sun, but the value you get is way smaller there.

I will send you a build tomorrow (or ask Sigma / GregroxMun / KillAshley for one). :)

Sorry, something went wrong.

@OhioBob
Copy link

OhioBob commented May 23, 2017

Thanks, I look forward to testing it out.

Sorry, something went wrong.

@Sigma88
Copy link
Contributor

Sigma88 commented May 23, 2017

@OhioBob sent you a copy on the forum

Sorry, something went wrong.

@OhioBob
Copy link

OhioBob commented May 24, 2017

@StollD, I just tested out the dev version. You've made great progress on it, but there are still a couple things not quite right. For some reason the "sun exposure" is not reading the right number. When in orbit I've adjusted the solar panel so that I know I'm getting 100% sun exposure, but the display is showing a fraction significantly less than one.

There also seems to be a "inverse square law" problem. I tested it out in GPP and when around Ciro (the main star) I was able to move closer to or farther away from the star and the energy flow seemed to adjust correctly. And when around Grannus (the red dwarf) the energy flow seemed to adjust correctly when moving away from the star, but not when moving closer. I was getting the correct energy flow when 1 AU from Grannus, but when I moved to 0.5 AU away, the energy flow went up by a factor of 20, instead of 4 as it should have.

Other than those two items, I think it was doing what it is suppose to do. When 1 AU away, I was definitely getting the correct energy flows. I also tested it in the in stock with my TestStar and it seemed to work there as well.

It also looks like all our ring problems are fixed. From what I could tell, everything looked good.

@OhioBob
Copy link

OhioBob commented May 24, 2017

I've done some further testing with a Gigantor solar panel at different distances from Ciro and Grannus. Although some of the energy flow numbers don't strictly obey the inverse square law, it's not nearly as bad as I previously thought. The numbers are at least in the right ballpark. There could be some other factors at play of which I'm unaware that could be accounting for the discrepancy.

However, the sun exposure numbers don't make any sense. Even though I was perfectly aligning the solar panel with the sun (sun exposure = 1.0), I was getting sun exposure numbers ranging from 0.33 to 0.67. I also couldn't detect any pattern in the numbers, they seemed fairly randomly.

@StollD
Copy link
Member

StollD commented May 24, 2017 via email

@OhioBob
Copy link

OhioBob commented May 24, 2017

OK, that makes sense. I think it would probably be best to change the sun exposure thing back to the way it was. The way it is now is very confusing. If I'm orbiting one star or the other, I'd like to be able to see a sun exposure of 1.00 when the panel is aligned to that star. That's what everybody is use to.

If you can change that one thing, then I think it's good to go from what I can tell. It appears that all our issues have been addressed and corrected. I just hope I haven't missed anything. Kopernicus is a great mod, we certainly couldn't do without it. Your efforts are appreciated. Thank you.

@Sigma88
Copy link
Contributor

Sigma88 commented May 24, 2017

I was thinking about this, and since I don't think it's obvious how flux and exposure should be calculated, I thought of listing here some possible solutions.

First of all let's address flux which is the simplest:

Flux

total flux should be the sum of the fluxes coming from each star, normalized over that star's exposure:

  • fluxTOT = flux1*exp1 + flux2*exp2 + flux3*exp3 + .... + fluxN*expN

I did not think this was possible, but since you said the current exposure accounts for all the exposures I guess this should be possible

Exposure

total exposure is a bit tricky, here are some ideas, with pros and cons.... in the following formulas, the stars are numbered in order of flux, so "flux1" is the highest, "flux2" is the second highest, etc...

  • expTOT = fluxTOT / (flux1 + flux2 + flux3 + ... + fluxN)

    • PROS: this is the % of the maximum possible flux you are getting
    • CONS: in a region where fluxes from different stars are similar, you won't get 100% exposure by looking just at one star
  • expTOT = fluxTOT / flux1

    • PROS: this compares the flux you are getting with the highest single-star flux
    • CONS: this could go over 100% where fluxTOT > flux1
  • expTOT = (fluxTOT / flux1) clamped between 0 and 1

    • PROS: this compares the flux you are getting with the highest single-star flux
    • CONS: exposure is not proportional to flux




honeslty, I would go with the second option over the third and this is why:



suppose you are on kerbin, looking directly at the sun, you get 100% flux and 100% exposure

now suppose you add a second sun, very close to the stock sun, with the second option you would get 200% flux and 200% exposure. with the third you would get 200% flux and 100% exposure

and I think it's a fairly good solution to show double exposure when there are two stars (of equal flux) in the sky... it gives you the impression that 2 stars are illuminating the panels instead of just 1.

@Galileo88
Copy link

Huge thanks!

@Galileo88
Copy link

I also really like the second idea Sigma.

@StollD
Copy link
Member

StollD commented May 24, 2017

fluxTOT = flux1exp1 + flux2exp2 + flux3exp3 + .... + fluxNexpN

Congrats. You figured out my code without looking at my code :P

I will go with option 2 then. Thanks :D

@Sigma88
Copy link
Contributor

Sigma88 commented May 24, 2017

@StollD well that was the most logical option for the flux :)

I'm glad it can be done

@OhioBob
Copy link

OhioBob commented May 24, 2017

If you guys want option 2, then I'm overruled. But I think I prefer option 1. If we're close to one star or the other, the flux we're receiving from the nearby star is so much greater than that we're getting from the distant star that the exposure will be effectively 100%.

With option 2, wouldn't flux1 be practically nil if we're far away. If we're in close proximity to a second star far away from the first, then flux2 >> flux1. I think fluxTOT / flux1 would give us like a billion percent.

I'm assuming here that flux ≈ luminosity / distance^2.

@StollD
Copy link
Member

StollD commented May 24, 2017

What @Sigma88 means with flux1 is the flux value from the nearest star, I think.

@Sigma88
Copy link
Contributor

Sigma88 commented May 24, 2017

@OhioBob @StollD

in my example, flux1 is the highest flux the solar panel receives from any star.

it's not necessarily the flux from the closest star, let's say one star is brighter than the other (like ciro/grannus) it's possible to be closer to grannus but still get more Ec/s if you look at ciro.

in this example flux1 comes from ciro and flux2 from grannus

so, let's say in your current position you can get 100 Ec/s from ciro (ignoring grannus) or 50Ec/s from grannus (ignoring ciro)

and assume we are between the two stars, so we need to face one or the other, but we can't get light from both

now, if you point your solar panels at ciro to get 100Ec/s, the calculated exposureTOT will be:

  • if we use the first formula:
    expTOT = (fluxCiro*expCiro + fluxGrannus*expGrannus) / (fluxCiro + fluxGrannus)
    ................= (100*1 + 50*0) / (100 + 50)
    ................= 100/150 = 0.66 = 66%

  • if we use the second formula:
    expTOT = (fluxCiro*expCiro+fluxGrannus*expGrannus)/(fluxCiro)
    ................= (100*1 + 50*0) / (100)
    ................= 100/100 = 1 = 100%


now, let's say we are in a position from which we can get 90% exposure from ciro and 60% exposure from grannus

  • if we use the first formula:
    expTOT = (fluxCiro*expCiro + fluxGrannus*expGrannus) / (fluxCiro + fluxGrannus)
    ................= (100*0.9 + 50*0.6) / (100 + 50)
    ................= 120/150 = 0.8 = 80%

  • if we use the second formula:
    expTOT = (fluxCiro*expCiro+fluxGrannus*expGrannus)/(fluxCiro)
    ................= (100*0.9 + 50*0.6) / (100)
    ................= 120/100 = 1.2 = 120%


in these examples, ciro is the flux1 not because it is the star with the highest luminosity, but because it is the star with the highest luminosity/distance^2

@Sigma88
Copy link
Contributor

Sigma88 commented May 24, 2017

another thing to consider:

by using the first formula we are basically defining 100% as the maximum theoretical exposure, which will never be achieved unless you can manage to get all the existing stars in your field of view.

this will more than likely feel like a bug to a decent number of users that will start reporting it. not that we should care about that if we feel that the first formula is the way to go. I just think that we can get more meaningful information from the second rather than the first or third

@OhioBob
Copy link

OhioBob commented May 24, 2017

@Sigma88 OK, I was thinking flux1 was the flux from the star with the greatest luminosity. If flux1 is the greatest flux regardless of what star it is coming from, then that changes my analysis. (You said that but it didn't sink in the first time I read it.)

To be honest, I'm not really too concerned with the examples you provide because for the fluxes to be as similar as you illustrate, we'd have to be somewhere in between the stars far from either one. In that case the sunlight would be so meager that solar panels would be ineffective. The only time solar panels matter is when we're close to one of the stars, and in that case the flux from one will far overpower the flux from the other.

So let me see if I understand the math for a case when we are close to one star and far from the other. Let's say we are near Grannus and receiving 1000 Ec/s from Grannus and 0.1 Ec/s from Ciro. Our solar panels are pointed toward Grannus, so we have 100% exposure from Grannus; and let's say we're getting 50% exposure from Ciro. We have,

fluxTOT = 1000 * 1 + 0.1 * 0.5 = 1000.05

Using the first formula,

expTOT = 1000.05 / (1000 + 0.1) = 0.99995

And using the second formula,

expTOT = 1000.05 / 1000 = 1.00005

Is that correct? If so, I think I could be satisfied with either formula. If y'all prefer formula two, I'm good with that.

@Sigma88
Copy link
Contributor

Sigma88 commented May 24, 2017

Yes that's exactly what I was proposing.

I know in your case (GPP) the differences between the two aproaches are negligeable, but I want to find the most solid solution for any kind of situation.

If the two stars are too far apart the two solutions converge (as you showed with your example), and when the two stars are too close together they could be treated as a single star (first formula) or as two different stars (second formula) and the only effective difference would be that with the first your max exposure would be 100% while with the second it would be 200%.

The real situation where they differ is when you have binary stars at planetary distances (think RSS with a red dwarf in place of jupiter)

In this system you can find yourself in very differe t situations, where using the first or second formula could give completely different results.

@OhioBob
Copy link

OhioBob commented May 24, 2017

I understand. Your explanation makes perfect sense. Number 2 it is then.

@Sigma88
Copy link
Contributor

Sigma88 commented May 29, 2017

with the latest release this issue has been solved

I think we can close this issue,

if anyone is still having problems feel free to post here again, and I will re-open it

@Sigma88 Sigma88 closed this as completed May 29, 2017
@bladela
Copy link

bladela commented Dec 23, 2017

Hi
It seems the solar panels are still not working
Kerbal Space Program - 1.3.1.1891 (LinuxPlayer) en-us
OS: Linux 4.13 Debian oldstable-updates 64bit
CPU: Intel(R) Core(TM) i5-4670 CPU @ 3.40GHz (4)
RAM: 15986
GPU: GeForce GTX 950/PCIe/SSE2 (2048MB)
SM: 50 (OpenGL 4.5.0 NVIDIA 375.82)

Kopernicus version : 1.3.1-3

Thanks
KSP.log.zip

@StollD
Copy link
Member

StollD commented Dec 23, 2017

Kopernicus version : 1.3.1-3

Not at all.

Your log shows that you have two Kopernicus versions installed, both compiled for 1.3.0 (and thereby not starting on 1.3.1). I see no sign that your planetary system gets patched at all.

But you are kind of correct, since no Kopernicus loads, it cannot provide what the solar panel module (that is applied even if Kopernicus refuses to load) needs. The result are broken solar panels.

TL;DR; Clean up your GameData and update Kopernicus (your KerbalAlarmClock seems to be screaming for help too)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants