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

1.0g way too common #5581

Closed
Bombum451 opened this issue Apr 28, 2023 · 8 comments
Closed

1.0g way too common #5581

Bombum451 opened this issue Apr 28, 2023 · 8 comments

Comments

@Bombum451
Copy link

Observed behaviour

Too many planets have exactly 1.0g of gravity

Expected behaviour

Should be more variation, and not exactly 1.0g

Steps to reproduce

Check out Zarelium (-12, -1, -2). All 5 main planets have exactly 1.0g

My pioneer version (and OS):
v20230203 (e77da96) Windows

@zonkmachine
Copy link
Member

zonkmachine commented Jun 16, 2023

Since the surface gravity for our solar system seem to work well, and it's fed real and good data, it should be the automatically generated planets that gets suboptimal values for either mass or radius (or both). The planet mass seem to be generated first (I haven't found where).

The line controlling the surface radius is:

sbody->m_radius = fixed::FromDouble(pow(sbody->GetMassAsFixed().ToDouble(), 0.5));

Simplified: radius = pow(mass, 0.5));
Radius is just a function of mass with no function for varying density built in.

Surface gravity is computed in SystemBody::CalcSurfaceGravity(), the responsible line is:

return G * GetMass() / pow(r, 2);

Now we add the radius equation into the gravity equation.
G * mass / pow(r, 2); <- r = pow(mass, 0.5)
G * mass / pow(pow(mass,0.5), 2);
G * 1 !
Since the mass is number of earth masses the result will always be 1.0g for planets between 1 and 200 earth masses.

The surface gravity code above, I trace to commit 5286161
@fluffyfreak

A quick fix could perhaps be to lower the exponent a bit from 0.5 to something like 0.4- 0.45 just to get some variation in there. A more advanced fix would include some randomised mean density. If I'm right above that is.

@zonkmachine
Copy link
Member

// http://phl.upr.edu/library/notes/standardmass-radiusrelationforexoplanets

It looks like this file has been moved. I think it's this one:
https://phl.upr.edu/library/labnotes/standard-mass-radius-relation-for-exoplanets

@fluffyfreak
Copy link
Contributor

I have been summoned! 😂

Yeah, that was from when I knew things and was smart, so much time has passed since 2014 (omfg)

@fluffyfreak
Copy link
Contributor

That is some great detective work and yeah I never thought of that before 🤔 I guess that we don't take into account the possible variations in density due to the being Rocky->Ocean->etc type worlds that 1->200 Earth masses can be. Even 1 Earth mass world might have very different radius due to it's composition.

@zonkmachine
Copy link
Member

zonkmachine commented Jun 21, 2023

Here's a oneliner that randomizes volume to achieve varying density. I'm also testing adding mean density and escape velocity to the planet infobox. If you accept a simple/temporary fix for this I'm happy to pull something.

diff --git a/src/galaxy/StarSystemGenerator.cpp b/src/galaxy/StarSystemGenerator.cpp
index f97387cd3..ab057ecb3 100644
--- a/src/galaxy/StarSystemGenerator.cpp
+++ b/src/galaxy/StarSystemGenerator.cpp
@@ -703,8 +703,11 @@ void StarSystemRandomGenerator::PickPlanetType(SystemBody *sbody, Random &rand)
                sbody->m_radius = fixed::FromDouble(pow(sbody->GetMassAsFixed().ToDouble(), 0.5));
        } else {
                // Anything bigger than 200 EU masses is a Gas Giant or bigger but the density changes to decrease from here on up...
                sbody->m_radius = fixed::FromDouble(22.6 * (1.0 / pow(sbody->GetMassAsFixed().ToDouble(), double(0.0886))));
        }
+       // randomize radius
+       sbody->m_radius = fixed::FromDouble(sbody->GetRadiusAsFixed().ToDouble() * (1.2 - (0.4 * rand.Double()))); // +/-20% radius
+
        // enforce minimum size of 10km
        sbody->m_radius = std::max(sbody->GetRadiusAsFixed(), fixed(1, 630));
 

@zonkmachine
Copy link
Member

zonkmachine commented Jun 21, 2023

The rand function should probably have a normal distribution. overkill

@Web-eWorks
Copy link
Member

Closing as fixed by #5592 - future improvements can be tracked via a feature request post in the forums or additional defect reports.

@zonkmachine
Copy link
Member

Just dropping this here. The custom systems needs to be checked and fixed separately. In the example below the planet Death has a density that is higher than any known elements. Unfortunately I won't have time to look into this anytime soon.

death

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

4 participants