## Planet Builder 1.0

The place to discuss creating, porting and modifying Celestia's source code.

Moderator: selden

Rassilon wrote:I thought of something else too...how do I go about figuring out the size of a star when all I have is distance stellar type and magnitude? Ive searched the web and Ill be damned if I can figure it out with the formulas they give...I suppose what I need is the math formulas chris uses in Celestia...guess its time for one of those searches through the code...so how many lines is Celestia up to now lol?

The calculation of star radius in Celestia is based on the luminosity and surface temperature of the star. In star.cpp, there are tables to derive surface temperature from stellar class. Then, given the L = the luminosity of the star relative to the sun, Ts = temp of the sun, Ta = temp of the star, the size in solar radii is sqrt(L)*(Ta/Ts)^2

--Chris

chris

Posts: 4218
Joined: Mon Jan 28, 2002 12:21 pm
Location: Seattle, Washington, USA

Thanks chris that helps alot...Maybe now I can get my planets positioned the way I want them...
I'm trying to teach the cavemen how to play scrabble, its uphill work. The only word they know is Uhh and they dont know how to spell it!

Rassilon

Posts: 1887
Joined: Mon Jan 28, 2002 9:19 pm
Location: Altair

Well its not working for me for some odd reason...either its Visual Basic or I've left something out...At any rate heres the code I added:

Code: Select all
`    oTemp(0) = 50000:  oTemp(1) = 50000: oTemp(2) = 50000: oTemp(3) = 50000: oTemp(4) = 47000    oTemp(5) = 44500:  oTemp(6) = 41000: oTemp(7) = 38000: oTemp(8) = 35800: oTemp(9) = 33000        bTemp(0) = 30000:  bTemp(1) = 25400: bTemp(2) = 22000: bTemp(3) = 18700: bTemp(4) = 17000    bTemp(5) = 15400:  bTemp(6) = 14000: bTemp(7) = 13000: bTemp(8) = 11900: bTemp(9) = 10500        aTemp(0) = 9520:  aTemp(1) = 9230: aTemp(2) = 8970: aTemp(3) = 8720: aTemp(4) = 8460    aTemp(5) = 8200:  aTemp(6) = 8020: aTemp(7) = 7850: aTemp(8) = 7580: aTemp(9) = 7390        aTemp(0) = 9520:  aTemp(1) = 9230: aTemp(2) = 8970: aTemp(3) = 8720: aTemp(4) = 8460    aTemp(5) = 8200:  aTemp(6) = 8020: aTemp(7) = 7850: aTemp(8) = 7580: aTemp(9) = 7390        fTemp(0) = 7200:  fTemp(1) = 7050: fTemp(2) = 6890: fTemp(3) = 6740: fTemp(4) = 6590    fTemp(5) = 6440:  fTemp(6) = 6360: fTemp(7) = 6280: fTemp(8) = 6200: fTemp(9) = 6110        gTemp(0) = 6030:  gTemp(1) = 5940: gTemp(2) = 5860: gTemp(3) = 5830: gTemp(4) = 5800    gTemp(5) = 5770:  gTemp(6) = 5700: gTemp(7) = 5630: gTemp(8) = 5570: gTemp(9) = 5410    kTemp(0) = 5250:  kTemp(1) = 5080: kTemp(2) = 4900: kTemp(3) = 4730: kTemp(4) = 4590    kTemp(5) = 4350:  kTemp(6) = 4200: kTemp(7) = 4060: kTemp(8) = 3990: kTemp(9) = 3920    kTemp(0) = 5250:  kTemp(1) = 5080: kTemp(2) = 4900: kTemp(3) = 4730: kTemp(4) = 4590    kTemp(5) = 4350:  kTemp(6) = 4200: kTemp(7) = 4060: kTemp(8) = 3990: kTemp(9) = 3920    mTemp(0) = 3850:  mTemp(1) = 3720: mTemp(2) = 3580: mTemp(3) = 3470: mTemp(4) = 3370    mTemp(5) = 3240:  mTemp(6) = 3050: mTemp(7) = 2940: mTemp(8) = 2640: mTemp(9) = 2600        SOLAR_RADIUS = 696000    SOLAR_TEMP = 5860    SOLAR_ABSMAG = 4.83    LN_MAG = 1.085736        ' find the luminosity and the radius        lumStar = (SOLAR_ABSMAG - Log(starMag) * LN_MAG)        Select Case s        Case "O"            starTemp = oTemp(lumSub)        Case "B"            starTemp = bTemp(lumSub)        Case "A"            starTemp = aTemp(lumSub)        Case "F"            starTemp = fTemp(lumSub)        Case "G"            starTemp = gTemp(lumSub)        Case "K"            starTemp = kTemp(lumSub)        Case "M"            starTemp = mTemp(lumSub)        Case "R"            starTemp = mTemp(lumSub)        Case "S"            starTemp = mTemp(lumSub)        Case Else            starTemp = 10000        End Select        ' in kilometers        starRadius = SOLAR_RADIUS * Sqr(lumStar) * (SOLAR_TEMP / starTemp) ^ 2        ' divide to find times bigger than sun        starRadius = starRadius / SOLAR_RADIUS`

The code is pretty much copied straight from your source as you can see...but I must be missing something...because a star coded like this in the stc file in Celestia is 17.24 x rSun:

Code: Select all
`400001 {   RA  5.1732   Dec  -72.4188   Distance  13371.5285   SpectralType "A1Ib"   AppMag 15.00 # Radii: 0.554110757590765}`

AppMag is the value assigned to starMag...

As you can see the Radii is 0.55 rounded up according to my program...
I'm trying to teach the cavemen how to play scrabble, its uphill work. The only word they know is Uhh and they dont know how to spell it!

Rassilon

Posts: 1887
Joined: Mon Jan 28, 2002 9:19 pm
Location: Altair

Well I found the problem...I forgot to convert from apparent to absolute...but now with the new code Im getting invalid procedure call errors...and its a bit random so Im thinking Im pretty much screwed on getting this perfect...

Heres the new code if it does any good...

Code: Select all
`Function Log10(X As Double) As Double    Log10 = Log(X) / Log(10)End FunctionLY_PER_PARSEC = 3.26167        appMag = starMag        absMag = (appMag + 5 - 5 * Log10(distValue / LY_PER_PARSEC))`

These are the two lines which are giving me the error:

Code: Select all
`lumStar = (SOLAR_ABSMAG - Log(absMag) * LN_MAG)starRadius = SOLAR_RADIUS * Sqr(lumStar) * (SOLAR_TEMP / starTemp) ^ 2`

It doesnt specify if its because the value is zero or something basically I believe that means the procedure itself is illegal...justr not all the time...so Im skipping this till later...maybe I wont even include it...back to the old guessing game

Ok well the reason is negitive numbers so by using the Abs() command I cleared that out...and viola...no change...still doesnt compute the correct values...suprised? Hell I even omitted the spectural class and made it always class V and still no go...wtf is going on? Ive looked and looked over Celestias source finally figured out that I was needing absolute magnitude over apparent and it STILL wont work...Im beginning to think its Visual Basic...plus the fact I really dont know if these values are even computing right....
I'm trying to teach the cavemen how to play scrabble, its uphill work. The only word they know is Uhh and they dont know how to spell it!

Rassilon

Posts: 1887
Joined: Mon Jan 28, 2002 9:19 pm
Location: Altair

Rassilon wrote:These are the two lines which are giving me the error:

Code: Select all
`lumStar = (SOLAR_ABSMAG - Log(absMag) * LN_MAG)starRadius = SOLAR_RADIUS * Sqr(lumStar) * (SOLAR_TEMP / starTemp) ^ 2`

It doesnt specify if its because the value is zero or something basically I believe that means the procedure itself is illegal...justr not all the time...so Im skipping this till later...maybe I wont even include it...back to the old guessing game

Ok well the reason is negitive numbers so by using the Abs() command I cleared that out...and viola...no change...still doesnt compute the correct values...suprised?

I think that you're computing the luminosity of the star incorrectly. To convert from absolute magnitude to units of solar luminosity, use this

Code: Select all
`lumStar = exp((SOLAR_ABSMAG - mag) / LN_MAG)`

You were actually doing it backwards, converting from luminosity to absolute magnitude As a result, you were taking the log of a negative number, well, it doesn't work so well . . .

Don't get too frustrated, just keep on coding . . .

--Chris

chris

Posts: 4218
Joined: Mon Jan 28, 2002 12:21 pm
Location: Seattle, Washington, USA

Yeah thats what it was...I dont know what I did but I was copying the code straight from Celestia's source and hell I mustve copied the wrong formula...doh...

Thanks for being patient...even though Im not
I'm trying to teach the cavemen how to play scrabble, its uphill work. The only word they know is Uhh and they dont know how to spell it!

Rassilon

Posts: 1887
Joined: Mon Jan 28, 2002 9:19 pm
Location: Altair

I have a question...has anyone noticed a gap in the cluster at all...I dont mean a small one I mean one that could easily span 30 light years near the top of the generated cluster (also im noticing the stars more lined up than before too)...I dont remember seeing that but as with the notepad incedent...which didnt at first have chr\$(10) appended to the script...worked fine...now all the sudden didnt...now again theres an issue with the cluster right out of nowhere...and I know I didnt change anything except add the new variables chris helped me with...and theres no way in hell thats affecting the stars because I use that exclusively for the planets...but yeah I know how I miss things so who knows...but at any rate if anyone notices this with the current version they have let me know...

Anyways I may have to redo the way I generate the cluster...and that will be another week or so tacked on to 1.2's release...oh joy
I'm trying to teach the cavemen how to play scrabble, its uphill work. The only word they know is Uhh and they dont know how to spell it!

Rassilon

Posts: 1887
Joined: Mon Jan 28, 2002 9:19 pm
Location: Altair

Heres what I mean by gap lol guess what this time is not me I swear...

I found out whats causing it...I added a string buffer routine to improve performance...what it does is loads the script string to maybe 5000 characters them moves to over to a buffer string...somehow this move is corrupting the data or the actual randomizer routine in the program itself...I take it out it works fine....When I look at the stc file there is no gap in the count of stars...which would make sense as also not only is there a gap but like I said before the stars seem more lined up than mixed up like theyt were originally...sooo too bad for that because with the buffer it was running 10 times faster than before...10,000 stars took a little over 2 minutes!...

(double edit - Randomize Timer in the for loop was causing this go figure...Its been there since day one...Hey if it wasnt for bad luck I would have none at all)

Oh well suppose maybe I should just stick to graphics...or get linux...I bet the same code under linux would work fine...well same variant of C++ that is...
Last edited by Rassilon on Fri Nov 15, 2002 12:55 pm, edited 1 time in total.
I'm trying to teach the cavemen how to play scrabble, its uphill work. The only word they know is Uhh and they dont know how to spell it!

Rassilon

Posts: 1887
Joined: Mon Jan 28, 2002 9:19 pm
Location: Altair

Hi Rassilon...

Downloaded Ver 1.1 and generated a rather interesting looking ssc file. Took about three minutes on my setup. I've got pulsars, asteroids, moons, four ringed planets and two earth like planets! Still haven't seen them in celestia though.
A couple of questions.

1/ Can I tag this file on the end of extrasolar.ssc? Celestia will not talk to my extras folder. In fact the newly generated system is the only file I have in there.

2/ Is pulsar.3ds in the new textures zip file?

I will download this later tonight! I can't wait to see the results...aah for an Nvidia card!
bh

Answer to 1> Yes you can if you like...but it 'should' work fine in the extras folder...You mention that this is the only files in the extras folder? so I take it you havent tried any other addons to see if they work as well? In the celestia root folder theres a file named celestia.cfg In that file there sjould be this line:

ExtrasDirectory "extras"

If you dont see that line add it in...

Answer for 2...Oops I forgot that...Download the PSR1257.zip located in my website (links in my signature) and unzip to the celestia root or your desktop and move them over manually to your celestia root folder...models go in models textures go in textures\medres...and ssc goes in the extras folder...The starnames.dat you will need to access the pulsar by name only...or append this to starnames.dat located in the data directory...

300001:PSR1257

In any case thats what you need for the pulsar...I will make sure to include it in ver 1.2 update when it becomes available...

btw Another point goes to making seperate addon folders lol...It will cut back on my missing files maybe by 1 %
I'm trying to teach the cavemen how to play scrabble, its uphill work. The only word they know is Uhh and they dont know how to spell it!

Rassilon

Posts: 1887
Joined: Mon Jan 28, 2002 9:19 pm
Location: Altair

SUCCESS!! Yippie!

10,000 stars

Finally figured out all the bugs and other bs...Ill be doing up a few extra planet classes now and should have this thing up by tomorrow...hell I just did a cluster of 10k stars in under 20 SECONDS!!!...it fricken screams now...

There will be tons more added features like a config file to save your settings and the ability to save your logs to the HD...A bit more convenient...I only hope there will be no more bugs and we can put this proggy to rest...If not oh well...
I'm trying to teach the cavemen how to play scrabble, its uphill work. The only word they know is Uhh and they dont know how to spell it!

Rassilon

Posts: 1887
Joined: Mon Jan 28, 2002 9:19 pm
Location: Altair

Ras',

What's the status of the next release?

I discovered another bug in v1.1.
When I asked it to generate a cluster of 1 star, checked the box for "planetary systems" and set the value at the bottom right to 100%, both Sample.ssc and Sample.stc were empty

This is with all other settings left unchanged from the startup defaults.
Selden

selden

Posts: 9902
Joined: Tue Sep 03, 2002 7:21 pm
Location: NY, USA

lol ill fix that...try two stars for now and see if that does it...you might want to set the planetary chance to something like 100% and make sure you uncheck cluster explicit in the options box...

Release is delayed due to the fact im trying to make sure there are absolutely no more bugs and Im adding a custom planet option where you can add in custom planets or named planets if you like...This can be used to add in planets that use models or the like...

btw test the holy crap out of that thing...try to trip it up as much as you can and let me know what other bugs you find...thanks selden...
I'm trying to teach the cavemen how to play scrabble, its uphill work. The only word they know is Uhh and they dont know how to spell it!

Rassilon

Posts: 1887
Joined: Mon Jan 28, 2002 9:19 pm
Location: Altair

Ras',

Well, I seem to be able to get 1 planetary system if I specify 10 stars...

Another collection of bugs:

The title bar of v1.1 says "Global Cluster Generator"
I think that's supposed to be "Globular..."

The Cluster generator needs an "interrupt" button to make it stop in the middle of a run. Killing it from the task manager is rather inconvenient..

Apparently v1.1 has problems with its probabilities for new planets.
I'd expect a probability of 10% to put planets around 1/10
of the stars of the cluster, but it seems more like 1/100.

Part of it may be your choice for the default random number seed. You should use one that itself has random bits on and off in it. (I usually use Pi in some form.)

Suggestion: it'd be nice to be able to specify the average number of planets per system.

Sometimes it doesn't seem to create any new planets at all.
For example, usually when I just change parameters and press Generate again, the planetary output file is the same as the last time. (as when I reduced the number of stars, but the resulting planetary .ssc started at a star index number greater than than the number of stars I'd requested.) It should zero the output arrays and recalculate all new stars and planets from scratch. Even if you don't change any parameters, the results should be different each time you press Generate, since the random seed for the new sequence should pick up where the last batch left off -- with different planets areound different stars. (The stars seem to be randomized reasonably, but not the planets.)

I hope this helps a little.
Selden

selden

Posts: 9902
Joined: Tue Sep 03, 2002 7:21 pm
Location: NY, USA

selden wrote:Ras',

Well, I seem to be able to get 1 planetary system if I specify 10 stars...

Another collection of bugs:

The title bar of v1.1 says "Global Cluster Generator"
I think that's supposed to be "Globular..."

I'll fix that...

The Cluster generator needs an "interrupt" button to make it stop in the middle of a run. Killing it from the task manager is rather inconvenient..

Will be in v1.2

Apparently v1.1 has problems with its probabilities for new planets.
I'd expect a probability of 10% to put planets around 1/10
of the stars of the cluster, but it seems more like 1/100.

Part of it may be your choice for the default random number seed. You should use one that itself has random bits on and off in it. (I usually use Pi in some form.)

Suggestion: it'd be nice to be able to specify the average number of planets per system.

Ill put the specifier in and random seed should be in 1.1 but maybe I skipped it in the options...regardless its in 1.2

Sometimes it doesn't seem to create any new planets at all.
For example, usually when I just change parameters and press Generate again, the planetary output file is the same as the last time. (as when I reduced the number of stars, but the resulting planetary .ssc started at a star index number greater than than the number of stars I'd requested.) It should zero the output arrays and recalculate all new stars and planets from scratch. Even if you don't change any parameters, the results should be different each time you press Generate, since the random seed for the new sequence should pick up where the last batch left off -- with different planets areound different stars. (The stars seem to be randomized reasonably, but not the planets.)

I hope this helps a little.

I think I got it to plot planets better...btw selden on 1.2 beta make sure you place it on the c:\drive...I will probably fix it so as to recognize the config file no matter what drive...in C++ I remember it was "//directory" tried that in VB didnt work well I used "\\directory" but does it matter?
Ill try it and see...

Off to work...
I'm trying to teach the cavemen how to play scrabble, its uphill work. The only word they know is Uhh and they dont know how to spell it!

Rassilon

Posts: 1887
Joined: Mon Jan 28, 2002 9:19 pm
Location: Altair

PreviousNext

### Who is online

Users browsing this forum: No registered users and 1 guest