liveBook · Manning

Mass

As explained in Julia as a Second Language

Mass is a physical quantity measuring an object's inertia and its contribution to gravitational interactions.

Mass measures an object's inertia and its contribution to gravitational interactions. In a rocket model, it is the quantity that determines how much the vehicle accelerates under engine thrust. section 8.5

Rocket modeling starts with a mass budget: estimate propellant needs, payload capacity, and travel distance before adding details about instruments, batteries, or solar cells. section 8.5

A useful rocket mass model separates:

  • Dry mass: the mass of an empty propellant tank. section 8.1
  • Propellant mass: the propellant currently remaining. section 8.1
  • Total mass: the tank's dry mass plus its remaining propellant. section 8.1
  • Rocket mass: the combined mass of payload, tank, engine, and other modeled components. section 8.5 section 8.1

Updating mass as propellant is consumed

A SmallTank initialized with 50 units of propellant returns 40 after consuming 10, then 30 after consuming another 10. Refilling restores its propellant to 370 units, so its mass changes with tank state. section 8.1

Listing 8.5 Adding propellant tank abilities and behavior
# Accessors (setters and getters)
propellant(tank::Tank) = tank.propellant               #1
function propellant!(tank::Tank, amount::Real)         #1
    tank.propellant = amount
end
 
isempty(tank::Tank) = tank.propellant <= 0             #2
mass(tank::Tank) = drymass(tank) + propellant(tank)    #3
 
# Actions
function refill!(tank::Tank)                           #4
    propellant!(tank, totalmass(tank) - drymass(tank))
    tank                                               #5
end
 
function consume!(tank::Tank, amount::Real)            #6
    remaining = max(propellant(tank) - amount, 0)
    propellant!(tank, remaining)
    remaining
end

Inspect the Julia implementation that computes tank mass from drymass(tank) + propellant(tank), alongside refill and consume behavior. section 8.1

How Julia as a Second Language covers it

How deep it goes
Defines mass conceptually and implements tank mass from dry mass plus propellant, while deferring detailed spacecraft contents.
Examples
Demonstrates mass through rocket payloads, fixed-capacity tanks, flexible tanks, propellant consumption, refilling, and engine definitions.
What you can do after
Build it from scratch as a Julia model that represents rocket mass and updates it when propellant is consumed or replenished.
How it connects
Connects mass with inertia, gravitational interactions, thrust, acceleration, specific impulse, propellant, tanks, payloads, and composite types.

This explainer was generated by Manning's knowledge graph from the text of Julia as a Second Language. The section links point to the parts of the book it draws on.