PulseCore

Chapter 5 · Section 1

The Stars in the Matter Step

Stars live on the bodies of matter (Chapter 4). A body is a clump: its mass m (cells) is its gas gas plus the stars it holds; pop is its list of star lots, each { m, n, mb, pb, born, life, cls, alive, metalFree, Z }; pend is gas set aside toward its next stars, in Suns; zm is its metals in cells (stars.js:134–139).

The order of the theory is the order of the code. BPT Part 2.9's road runs gas, collapse, star, life, death, remnant, and BPT Part 3.14 closes the loop with feedback: stars heat and disperse the gas that would make more of them. Each matter sub-step (a quarter flip), after Matter.step(), stepMatterPost() app.js:658 walks that road once:

  1. If the level holds no stable matter, decay the bodies (Part 5.2).
  2. Set matter.flipNow, then call stepStars(matter, now, tauSun, dt, physLife) stars.js:140, unless the level holds no stable matter or no stars; now is Tempos since the Data Nova, (pulseCounter + subDone − birthFrame)/2 (app.js:665).
  3. applyFeedback(sev) app.js:758: supernovae and feeding wells push the gas (Part 5.12).
  4. Flashes for supernovae and planetary nebulae (app.js:667–668); first-event banners (starToasts() app.js:731).
  5. Stellar Null Wells registered from the stars that collapsed (Part 5.13).

stepStars() itself, for every body: mix metals through its cloud; form stars if the cloud is dense and cool enough (Parts 5.7 and 5.8); mark giants; end the stars whose lives are over (Part 5.9), returning their ejecta and metals (Part 5.10) and blowing winds (Part 5.11); then add the wind bodies and recount the tallies. Its events go back as sev: stars born, first stars, supernovae, wells, white dwarfs, neutron stars, pair-instability supernovae and nebulae.

After each step scene.setMatter() (app.js:674) redraws the bodies: each body's points become its stars, colored and sized by type, and its gas, a dim haze in the data's color (scene3d.js:697). So every Part below ends on the same screen: the torus's surface, its gas haze and its starlight.

This overview Part computes nothing of its own; the numbers are in the Parts that follow.

The method, in plain steps:

each matter sub-step, if the universe can make stars:
    clouds that are dense and hold a Sun of gas turn gas into stars (Part 5.7), in lots (Part 5.8)
    every lot ages; at the end of its life it dies by its mass (Part 5.9):
        its ejecta and new metals go back to the gas (Part 5.10), supernovae blow winds (Part 5.11)
        and push and heat the gas round them (Part 5.12); the heaviest leave Stellar Null Wells (Part 5.13)
    the tallies and readouts are updated (Part 5.14)

The code:

// public/game-v8.4/stars.js:140
export function stepStars(matter, now, tauSun, dt = 1, life = 0) {
    const S = matter.stars || (matter.stars = { sun: null, formed: 0, metals: 0, gasMass: 0, sn: 0, pisn: 0, wd: 0, ns: 0, bh: 0, firstAt: null, byType: {} });
    const ev = { born: 0, firstStars: null, sn: [], wells: [], wd: 0, ns: 0, pisn: 0, pn: [] };
    if (!matter.bodies.length || !(matter.G > 0)) return ev;
    const G = matter.G * (matter.gk || 1), B2 = matter.B * matter.B, CL = matter.cloud || 8, CC = Math.ceil(matter.cols / CL);   /* clouds are 8 × 8 cells of the level's full field whatever the gravity mesh; on a smaller field (a phone's scale model) the same share of the universe (matter.cloud, app.js cloudCells) */
    if (S.sun === null) S.sun = matter.sunCells || SUN_CELLS;   /* 8.2: the Sun of the universe's level (app.js) */
    const blockOf = (b) => Math.floor(matter.wrapR(b.r) / matter.B) * matter.GC + Math.floor(matter.wrapC(b.c) / matter.B);
    let totalGas = 0;