Many improvments + install script

This commit is contained in:
2026-03-03 18:11:00 +00:00
parent 03452517b5
commit 386f6fe928
12 changed files with 710 additions and 44 deletions

View File

@@ -96,10 +96,7 @@ export function calcCooling(thermo, cooling, chamberGeom) {
const { Dt, Dc, Lc } = chamberGeom
// Simplified Bartz heat flux [W/m²] using typical exhaust gas properties
const mu = 6e-5 // Pa·s — typical rocket exhaust dynamic viscosity
const cp = 2000 // J/(kg·K)
const Pr = 0.7
const T_wall = 800 // K — assumed hot-gas-side wall temperature
const { mu = 6e-5, cp = 2000, Pr = 0.7, T_wall = 800 } = cooling
const q_est = (0.026 / Math.pow(Dt, 0.2)) *
(Math.pow(mu, 0.2) * cp / Math.pow(Pr, 0.6)) *
@@ -110,9 +107,9 @@ export function calcCooling(thermo, cooling, chamberGeom) {
const q_total = q_est * chamberArea
const { channelCount } = cooling
const channelArea = channelCount > 0 ? q_total / channelCount : 0
const q_perChannel = channelCount > 0 ? q_total / channelCount : 0
return { method, q_est, q_total, channelCount, channelArea }
return { method, q_est, q_total, channelCount, q_perChannel }
}
if (method === 'film') {

View File

@@ -16,6 +16,7 @@ export const EQUATIONS = [
name: 'Fundamental Thrust Equation',
formula: 'F = ṁ·Vₑ + (pₑ pₐ)·Aₑ',
category: 'Thrust',
description: 'Calculates total thrust from momentum thrust and pressure thrust. Used when exit conditions and mass flow are known.',
variables: ['F', 'mdot', 'Ve', 'pe', 'pa', 'Ae'],
solvers: {
F: v => v.mdot * v.Ve + (v.pe - v.pa) * v.Ae,
@@ -40,6 +41,7 @@ export const EQUATIONS = [
name: 'Thrust from Isp',
formula: 'F = ṁ·Isp·g₀',
category: 'Thrust',
description: 'Relates thrust, mass flow, and specific impulse. Commonly used when Isp is known instead of exhaust velocity.',
variables: ['F', 'mdot', 'Isp', 'g0'],
solvers: {
F: v => v.mdot * v.Isp * v.g0,
@@ -55,6 +57,7 @@ export const EQUATIONS = [
name: 'Effective Exhaust Velocity',
formula: 'cₑ = F / ṁ',
category: 'Thrust',
description: 'Defines effective exhaust velocity as thrust divided by mass flow. Includes both momentum and pressure thrust effects.',
variables: ['ceff', 'F', 'mdot'],
solvers: {
ceff: v => v.F / v.mdot,
@@ -69,6 +72,7 @@ export const EQUATIONS = [
name: 'Isp from Effective Exhaust Velocity',
formula: 'Isp = cₑ / g₀',
category: 'Specific Impulse',
description: 'Converts effective exhaust velocity to specific impulse. Related by the standard gravitational acceleration.',
variables: ['Isp', 'ceff', 'g0'],
solvers: {
Isp: v => v.ceff / v.g0,
@@ -82,6 +86,7 @@ export const EQUATIONS = [
name: 'Isp from Thrust & Mass Flow',
formula: 'Isp = F / (ṁ·g₀)',
category: 'Specific Impulse',
description: 'Directly calculates specific impulse from thrust and mass flow. Fundamental performance metric for rocket engines.',
variables: ['Isp', 'F', 'mdot', 'g0'],
solvers: {
Isp: v => v.F / (v.mdot * v.g0),
@@ -97,6 +102,7 @@ export const EQUATIONS = [
name: 'Characteristic Velocity',
formula: 'c* = p₀·Aₜ / ṁ',
category: 'Nozzle Performance',
description: 'Defines characteristic velocity as a measure of combustion chamber performance. Independent of nozzle expansion.',
variables: ['cstar', 'p0', 'At', 'mdot'],
solvers: {
cstar: v => (v.p0 * v.At) / v.mdot,
@@ -111,6 +117,7 @@ export const EQUATIONS = [
name: 'c* from Thrust Coefficient & Isp',
formula: 'c* = Isp·g₀ / Cꜰ',
category: 'Nozzle Performance',
description: 'Relates characteristic velocity to thrust coefficient and specific impulse. Useful for nozzle analysis.',
variables: ['cstar', 'Isp', 'g0', 'CF'],
solvers: {
cstar: v => (v.Isp * v.g0) / v.CF,
@@ -126,6 +133,7 @@ export const EQUATIONS = [
name: 'Thrust Coefficient',
formula: 'Cꜰ = F / (p₀·Aₜ)',
category: 'Nozzle Performance',
description: 'Defines thrust coefficient as a dimensionless nozzle performance factor. Typical values are 1.41.9 for ideal nozzles.',
variables: ['CF', 'F', 'p0', 'At'],
solvers: {
CF: v => v.F / (v.p0 * v.At),
@@ -141,6 +149,7 @@ export const EQUATIONS = [
name: 'Tsiolkovsky Rocket Equation (cₑ)',
formula: 'Δv = cₑ·ln(m₀/mf)',
category: 'Rocket Equation',
description: 'The rocket equation in terms of effective exhaust velocity. Calculates delta-v available from propellant mass ratio.',
variables: ['dv', 'ceff', 'm0', 'mf'],
solvers: {
dv: v => v.ceff * Math.log(v.m0 / v.mf),
@@ -155,6 +164,7 @@ export const EQUATIONS = [
name: 'Tsiolkovsky Rocket Equation (Isp)',
formula: 'Δv = Isp·g₀·ln(m₀/mf)',
category: 'Rocket Equation',
description: 'The classic Tsiolkovsky rocket equation using specific impulse. Foundation of trajectory design and mission planning.',
variables: ['dv', 'Isp', 'g0', 'm0', 'mf'],
solvers: {
dv: v => v.Isp * v.g0 * Math.log(v.m0 / v.mf),
@@ -170,6 +180,7 @@ export const EQUATIONS = [
name: 'Mass Ratio',
formula: 'MR = m₀ / mf',
category: 'Rocket Equation',
description: 'Ratio of initial to final mass. Determines the exponential factor in the Tsiolkovsky equation.',
variables: ['MR', 'm0', 'mf'],
solvers: {
MR: v => v.m0 / v.mf,
@@ -183,6 +194,7 @@ export const EQUATIONS = [
name: 'Propellant Mass',
formula: 'mₚ = m₀ mf',
category: 'Rocket Equation',
description: 'Mass of propellant consumed during burn. Difference between initial (wet) and final (dry) mass.',
variables: ['mp', 'm0', 'mf'],
solvers: {
mp: v => v.m0 - v.mf,
@@ -196,6 +208,7 @@ export const EQUATIONS = [
name: 'Propellant Mass Fraction',
formula: 'ζ = mₚ / m₀',
category: 'Rocket Equation',
description: 'Fraction of total mass that is propellant. Higher values indicate more efficient rocket design.',
variables: ['zeta', 'mp', 'm0'],
solvers: {
zeta: v => v.mp / v.m0,
@@ -209,6 +222,7 @@ export const EQUATIONS = [
name: 'Burn Time',
formula: 'tᵦ = mₚ / ṁ',
category: 'Rocket Equation',
description: 'Duration of main engine burn. Calculated from total propellant mass and mass flow rate.',
variables: ['tb', 'mp', 'mdot'],
solvers: {
tb: v => v.mp / v.mdot,
@@ -223,6 +237,7 @@ export const EQUATIONS = [
name: 'Isentropic Temperature Ratio',
formula: 'T/T₀ = (1 + (γ1)/2·M²)⁻¹',
category: 'Isentropic Flow',
description: 'Static to stagnation temperature ratio for isentropic flow. Key relation for compressible flow analysis.',
variables: ['T', 'T0', 'M', 'gamma'],
solvers: {
T: v => v.T0 / (1 + (v.gamma - 1) / 2 * v.M * v.M),
@@ -241,6 +256,7 @@ export const EQUATIONS = [
name: 'Isentropic Pressure Ratio',
formula: 'p/p₀ = (1 + (γ1)/2·M²)^(γ/(γ1))',
category: 'Isentropic Flow',
description: 'Static to stagnation pressure ratio for isentropic flow. Essential for nozzle and intake analysis.',
variables: ['p_static', 'p0', 'M', 'gamma'],
solvers: {
p_static: v => {
@@ -265,6 +281,7 @@ export const EQUATIONS = [
name: 'Isentropic Density Ratio',
formula: 'ρ/ρ₀ = (1 + (γ1)/2·M²)^(1/(γ1))',
category: 'Isentropic Flow',
description: 'Static to stagnation density ratio for isentropic flow. Used in continuity equations and flow analysis.',
variables: ['rho', 'rho0', 'M', 'gamma'],
solvers: {
rho: v => {
@@ -287,6 +304,7 @@ export const EQUATIONS = [
name: 'Speed of Sound',
formula: 'a = √(γ·R·T)',
category: 'Isentropic Flow',
description: 'Local speed of sound as a function of temperature and gas properties. Used to define Mach number.',
variables: ['a_sound', 'gamma', 'R', 'T'],
solvers: {
a_sound: v => Math.sqrt(v.gamma * v.R * v.T),
@@ -301,6 +319,7 @@ export const EQUATIONS = [
name: 'Flow Velocity',
formula: 'v = M·a',
category: 'Isentropic Flow',
description: 'Flow velocity as Mach number times local speed of sound. Relates Mach number to actual velocity.',
variables: ['v_flow', 'M', 'a_sound'],
solvers: {
v_flow: v => v.M * v.a_sound,
@@ -315,6 +334,7 @@ export const EQUATIONS = [
name: 'Nozzle Expansion Ratio',
formula: 'ε = Aₑ / Aₜ',
category: 'Nozzle Geometry',
description: 'Ratio of exit area to throat area. Determines the degree of expansion in the nozzle divergent section.',
variables: ['eps', 'Ae', 'At'],
solvers: {
eps: v => v.Ae / v.At,
@@ -328,6 +348,7 @@ export const EQUATIONS = [
name: 'Isentropic Area Ratio (supersonic)',
formula: 'ε = (1/Mₑ)·[(2/(γ+1))·(1+(γ1)/2·Mₑ²)]^((γ+1)/(2(γ1)))',
category: 'Nozzle Geometry',
description: 'Relates exit area ratio to exit Mach number for isentropic supersonic flow. Critical for nozzle design.',
variables: ['eps', 'Me', 'gamma'],
solvers: {
eps: v => areaRatioFromMach(v.Me, v.gamma),
@@ -340,6 +361,7 @@ export const EQUATIONS = [
name: 'Choked Throat Mass Flow',
formula: 'ṁ = Aₜ·p₀·√(γ/(R·T₀))·(2/(γ+1))^((γ+1)/(2(γ1)))',
category: 'Nozzle Geometry',
description: 'Mass flow through a choked throat condition. Maximum mass flow for given stagnation conditions.',
variables: ['mdot', 'At', 'p0', 'gamma', 'R', 'T0'],
solvers: {
mdot: v => {
@@ -380,6 +402,7 @@ export const EQUATIONS = [
name: 'Nozzle Exit Pressure',
formula: 'pₑ = p₀·(1 + (γ1)/2·Mₑ²)^(γ/(γ1))',
category: 'Nozzle Geometry',
description: 'Static pressure at the nozzle exit. Calculated from chamber pressure and exit Mach number.',
variables: ['pe', 'p0', 'Me', 'gamma'],
solvers: {
pe: v => {
@@ -402,6 +425,7 @@ export const EQUATIONS = [
name: 'Nozzle Exit Temperature',
formula: 'Tₑ = T₀ / (1 + (γ1)/2·Mₑ²)',
category: 'Nozzle Geometry',
description: 'Static temperature at the nozzle exit. Lower than stagnation temperature due to expansion.',
variables: ['Te', 'T0', 'Me', 'gamma'],
solvers: {
Te: v => v.T0 / (1 + (v.gamma - 1) / 2 * v.Me * v.Me),
@@ -416,6 +440,7 @@ export const EQUATIONS = [
name: 'Nozzle Exit Velocity',
formula: 'Vₑ = Mₑ·√(γ·R·Tₑ)',
category: 'Nozzle Geometry',
description: 'Actual exhaust velocity at nozzle exit. Product of exit Mach number and local speed of sound.',
variables: ['Ve', 'Me', 'gamma', 'R', 'Te'],
solvers: {
Ve: v => v.Me * Math.sqrt(v.gamma * v.R * v.Te),
@@ -432,6 +457,7 @@ export const EQUATIONS = [
name: 'Thrust-to-Weight Ratio',
formula: 'TWR = F / (mᵥ·g₀)',
category: 'Performance',
description: 'Ratio of thrust to vehicle weight. Values > 1 allow acceleration and ascent.',
variables: ['TWR', 'F', 'm_vehicle', 'g0'],
solvers: {
TWR: v => v.F / (v.m_vehicle * v.g0),
@@ -446,6 +472,7 @@ export const EQUATIONS = [
name: 'Total Impulse',
formula: 'J = F·tᵦ',
category: 'Performance',
description: 'Total impulse as integrated thrust over burn time. Used for classification and performance assessment.',
variables: ['J', 'F', 'tb'],
solvers: {
J: v => v.F * v.tb,
@@ -459,6 +486,7 @@ export const EQUATIONS = [
name: 'Isp from Total Impulse',
formula: 'Isp = J / (mₚ·g₀)',
category: 'Performance',
description: 'Calculates specific impulse from total impulse and propellant mass. Alternative method for performance analysis.',
variables: ['Isp', 'J', 'mp', 'g0'],
solvers: {
Isp: v => v.J / (v.mp * v.g0),
@@ -474,6 +502,7 @@ export const EQUATIONS = [
name: 'Oxidiser/Fuel Ratio',
formula: 'O/F = ṁₒₓ / ṁf',
category: 'Propellant',
description: 'Mass flow ratio of oxidiser to fuel. Optimum value depends on propellant pair and design parameters.',
variables: ['OF', 'mdot_ox', 'mdot_f'],
solvers: {
OF: v => v.mdot_ox / v.mdot_f,
@@ -487,6 +516,7 @@ export const EQUATIONS = [
name: 'Total Mass Flow',
formula: 'ṁ = ṁₒₓ + ṁf',
category: 'Propellant',
description: 'Total propellant mass flow is sum of oxidiser and fuel mass flows. Used in bipropellant engines.',
variables: ['mdot', 'mdot_ox', 'mdot_f'],
solvers: {
mdot: v => v.mdot_ox + v.mdot_f,
@@ -500,12 +530,70 @@ export const EQUATIONS = [
name: 'Mass Flow Split from O/F',
formula: 'ṁ_f = ṁ/(1+OF), ṁ_ox = ṁ·OF/(1+OF)',
category: 'Propellant',
description: 'Splits total mass flow into oxidiser and fuel flows given their mass ratio. Used for injection design.',
variables: ['mdot', 'OF', 'mdot_f', 'mdot_ox'],
solvers: {
mdot_f: Object.assign(v => v.mdot / (1 + v.OF), { requires: () => ['mdot', 'OF'] }),
mdot_ox: Object.assign(v => v.mdot * v.OF / (1 + v.OF), { requires: () => ['mdot', 'OF'] }),
},
},
// ── Chamber Characteristic Length ──────────────────────────────────────
{
id: 'chamber_characteristic_length',
name: 'Chamber Characteristic Length',
formula: 'L* = Vᶜ / Aₜ',
category: 'Nozzle Performance',
description: 'Characteristic chamber length relates chamber volume to throat area. Typical range 0.51.5 m for liquid rockets.',
variables: ['Lstar', 'Vc', 'At'],
solvers: {
Lstar: v => v.Vc / v.At,
Vc: v => v.Lstar * v.At,
At: v => v.Vc / v.Lstar,
},
},
// ── Specific Gas Constant from Molar Mass ─────────────────────────────
{
id: 'specific_gas_constant',
name: 'Specific Gas Constant',
formula: 'R = R̄ / Mₘ',
category: 'Isentropic Flow',
description: 'Specific gas constant for a particular gas, derived from the universal gas constant and molar mass. R̄ = 8.314 J/(mol·K).',
variables: ['R', 'Mm'],
solvers: {
R: v => 8.314 / v.Mm,
Mm: v => 8.314 / v.R,
},
},
// ── Vehicle Mass Identity ─────────────────────────────────────────────
{
id: 'vehicle_mass_identity',
name: 'Vehicle Mass (Wet Mass)',
formula: 'mᵥ = m₀',
category: 'Performance',
description: 'Identity relation: vehicle mass equals initial (wet) mass for TWR calculation.',
variables: ['m_vehicle', 'm0'],
solvers: {
m_vehicle: v => v.m0,
m0: v => v.m_vehicle,
},
},
// ── Subsonic Area Ratio ───────────────────────────────────────────────
{
id: 'area_ratio_mach_subsonic',
name: 'Isentropic Area Ratio (subsonic)',
formula: 'ε = (1/Mₑ)·[(2/(γ+1))·(1+(γ1)/2·Mₑ²)]^((γ+1)/(2(γ1)))',
category: 'Nozzle Geometry',
description: 'Isentropic area ratio as a function of Mach number (subsonic branch). Used for intake and subsonic flow analysis.',
variables: ['eps', 'Me', 'gamma'],
solvers: {
eps: v => areaRatioFromMach(v.Me, v.gamma),
Me: v => machFromAreaRatio(v.eps, v.gamma, false),
},
},
]
// Equation presets: named groups that seed the workspace with a useful set of variables

View File

@@ -115,6 +115,12 @@ export const UNIT_FAMILIES = {
{ id: '—', label: '—', toSI: v => v, fromSI: v => v },
],
},
molar_mass: {
units: [
{ id: 'g/mol', label: 'g/mol', toSI: v => v * 0.001, fromSI: v => v * 1000 },
{ id: 'kg/mol', label: 'kg/mol', toSI: v => v, fromSI: v => v },
],
},
}
export function getUnitsForFamily(familyId) {

View File

@@ -92,6 +92,20 @@ export const VARIABLES = {
unitFamily: 'area',
},
Lstar: {
id: 'Lstar', symbol: 'L*', name: 'Characteristic Chamber Length', units: 'm',
description: 'Characteristic length of the combustion chamber: L* = Vᶜ/Aₜ. Higher values indicate larger chambers.',
category: 'Nozzle Performance',
unitFamily: 'length',
},
Vc: {
id: 'Vc', symbol: 'Vᶜ', name: 'Chamber Volume', units: 'm³',
description: 'Total volume of the combustion chamber',
category: 'Nozzle Performance',
unitFamily: 'volume',
},
// ── Tsiolkovsky Rocket Equation ───────────────────────────────────────
dv: {
id: 'dv', symbol: 'Δv', name: 'Delta-v', units: 'm/s',
@@ -155,6 +169,13 @@ export const VARIABLES = {
category: 'Isentropic Flow',
unitFamily: 'spec_gas',
},
Mm: {
id: 'Mm', symbol: 'Mₘ', name: 'Molar Mass', units: 'kg/mol',
description: 'Molar mass of the exhaust gas mixture. Used to calculate specific gas constant: R = R̄/Mₘ',
category: 'Isentropic Flow',
unitFamily: 'molar_mass',
},
T: {
id: 'T', symbol: 'T', name: 'Static Temperature', units: 'K',
description: 'Local static temperature at a cross-section',