From a067215dc4cd17a8e9636ab75c9f654bc7a7c651 Mon Sep 17 00:00:00 2001 From: Greg Troszak Date: Sun, 15 Mar 2026 14:39:04 -0400 Subject: [PATCH] feat(dim-isq): add 22 derived quantities Add density, specificVolume, momentum, angularVelocity, angularAcceleration, torque, dynamicViscosity, kinematicViscosity, surfaceTension, wavenumber, heatCapacity, specificHeatCapacity, specificEnergy, thermalConductivity, electricFieldStrength, permittivity, permeability, currentDensity, volumetricFlowRate, massFlowRate, concentration, and molarMass. Closes #10 --- packages/dim-isq/README.md | 77 ++++++---- packages/dim-isq/quantities.spec.ts | 26 ++++ packages/dim-isq/src/mod.ts | 44 ++++++ packages/dim-isq/src/quantities.generated.ts | 144 +++++++++++++++++++ 4 files changed, 265 insertions(+), 26 deletions(-) diff --git a/packages/dim-isq/README.md b/packages/dim-isq/README.md index 6546614..149a46b 100644 --- a/packages/dim-isq/README.md +++ b/packages/dim-isq/README.md @@ -62,30 +62,52 @@ bun add @isentropic/dim-isq ### Derived -| Quantity | Dimension | -| --------------------- | ------------- | -| `area` | L² | -| `volume` | L³ | -| `velocity` | L·T⁻¹ | -| `acceleration` | L·T⁻² | -| `force` | M·L·T⁻² | -| `energy` | M·L²·T⁻² | -| `power` | M·L²·T⁻³ | -| `pressure` | M·L⁻¹·T⁻² | -| `frequency` | T⁻¹ | -| `charge` | I·T | -| `voltage` | M·L²·T⁻³·I⁻¹ | -| `resistance` | M·L²·T⁻³·I⁻² | -| `capacitance` | M⁻¹·L⁻²·T⁴·I² | -| `inductance` | M·L²·T⁻²·I⁻² | -| `conductance` | M⁻¹·L⁻²·T³·I² | -| `magneticFlux` | M·L²·T⁻²·I⁻¹ | -| `magneticFluxDensity` | M·T⁻²·I⁻¹ | -| `luminousFlux` | J | -| `illuminance` | J·L⁻² | -| `absorbedDose` | L²·T⁻² | -| `catalyticActivity` | N·T⁻¹ | -| `thermalConductance` | M·L²·T⁻³·Θ⁻¹ | +| Quantity | Dimension | +| ----------------------- | ------------- | +| `area` | L² | +| `volume` | L³ | +| `velocity` | L·T⁻¹ | +| `acceleration` | L·T⁻² | +| `force` | M·L·T⁻² | +| `energy` | M·L²·T⁻² | +| `power` | M·L²·T⁻³ | +| `pressure` | M·L⁻¹·T⁻² | +| `frequency` | T⁻¹ | +| `density` | M·L⁻³ | +| `specificVolume` | M⁻¹·L³ | +| `momentum` | M·L·T⁻¹ | +| `angularVelocity` | T⁻¹ | +| `angularAcceleration` | T⁻² | +| `torque` | M·L²·T⁻² | +| `dynamicViscosity` | M·L⁻¹·T⁻¹ | +| `kinematicViscosity` | L²·T⁻¹ | +| `surfaceTension` | M·T⁻² | +| `wavenumber` | L⁻¹ | +| `charge` | I·T | +| `voltage` | M·L²·T⁻³·I⁻¹ | +| `resistance` | M·L²·T⁻³·I⁻² | +| `capacitance` | M⁻¹·L⁻²·T⁴·I² | +| `inductance` | M·L²·T⁻²·I⁻² | +| `conductance` | M⁻¹·L⁻²·T³·I² | +| `magneticFlux` | M·L²·T⁻²·I⁻¹ | +| `magneticFluxDensity` | M·T⁻²·I⁻¹ | +| `electricFieldStrength` | M·L·T⁻³·I⁻¹ | +| `permittivity` | M⁻¹·L⁻³·T⁴·I² | +| `permeability` | M·L·T⁻²·I⁻² | +| `currentDensity` | I·L⁻² | +| `luminousFlux` | J | +| `illuminance` | J·L⁻² | +| `absorbedDose` | L²·T⁻² | +| `catalyticActivity` | N·T⁻¹ | +| `thermalConductance` | M·L²·T⁻³·Θ⁻¹ | +| `heatCapacity` | M·L²·T⁻²·Θ⁻¹ | +| `specificHeatCapacity` | L²·T⁻²·Θ⁻¹ | +| `specificEnergy` | L²·T⁻² | +| `thermalConductivity` | M·L·T⁻³·Θ⁻¹ | +| `volumetricFlowRate` | L³·T⁻¹ | +| `massFlowRate` | M·T⁻¹ | +| `concentration` | N·L⁻³ | +| `molarMass` | M·N⁻¹ | ## Contributing @@ -97,8 +119,11 @@ for how to add one. - **Angle is dimensionless** — radians and steradians are indistinct from scalars at the type level -- **Torque and energy share the same dimension** — both are M·L²·T⁻², so the - type system can't distinguish them +- **Several quantities share dimensions** — the type system can't distinguish + quantities that have identical dimension exponents: + - `torque` and `energy` share M·L²·T⁻² + - `angularVelocity` and `frequency` share T⁻¹ + - `specificEnergy` and `absorbedDose` share L²·T⁻² ## License diff --git a/packages/dim-isq/quantities.spec.ts b/packages/dim-isq/quantities.spec.ts index 85f55d7..b86b50a 100644 --- a/packages/dim-isq/quantities.spec.ts +++ b/packages/dim-isq/quantities.spec.ts @@ -39,6 +39,16 @@ export default defineQuantitySpec({ power: { M: 1, L: 2, T: -3 }, pressure: { M: 1, L: -1, T: -2 }, frequency: { T: -1 }, + density: { M: 1, L: -3 }, + specificVolume: { M: -1, L: 3 }, + momentum: { M: 1, L: 1, T: -1 }, + angularVelocity: { T: -1 }, + angularAcceleration: { T: -2 }, + torque: { M: 1, L: 2, T: -2 }, + dynamicViscosity: { M: 1, L: -1, T: -1 }, + kinematicViscosity: { L: 2, T: -1 }, + surfaceTension: { M: 1, T: -2 }, + wavenumber: { L: -1 }, // Electromagnetism charge: { I: 1, T: 1 }, @@ -49,6 +59,10 @@ export default defineQuantitySpec({ conductance: { M: -1, L: -2, T: 3, I: 2 }, magneticFlux: { M: 1, L: 2, T: -2, I: -1 }, magneticFluxDensity: { M: 1, T: -2, I: -1 }, + electricFieldStrength: { M: 1, L: 1, T: -3, I: -1 }, + permittivity: { M: -1, L: -3, T: 4, I: 2 }, + permeability: { M: 1, L: 1, T: -2, I: -2 }, + currentDensity: { I: 1, L: -2 }, // Photometry luminousFlux: { J: 1 }, @@ -60,6 +74,18 @@ export default defineQuantitySpec({ // Thermal thermalConductance: { M: 1, L: 2, T: -3, "Θ": -1 }, + heatCapacity: { M: 1, L: 2, T: -2, "Θ": -1 }, + specificHeatCapacity: { L: 2, T: -2, "Θ": -1 }, + specificEnergy: { L: 2, T: -2 }, + thermalConductivity: { M: 1, L: 1, T: -3, "Θ": -1 }, + + // Flow and transport + volumetricFlowRate: { L: 3, T: -1 }, + massFlowRate: { M: 1, T: -1 }, + + // Amount-based + concentration: { N: 1, L: -3 }, + molarMass: { M: 1, N: -1 }, }, }, }); diff --git a/packages/dim-isq/src/mod.ts b/packages/dim-isq/src/mod.ts index ac872bf..bac66a9 100644 --- a/packages/dim-isq/src/mod.ts +++ b/packages/dim-isq/src/mod.ts @@ -26,6 +26,10 @@ export { type Amount, // Base quantities amount, + type AngularAcceleration, + angularAcceleration, + type AngularVelocity, + angularVelocity, type Area, area, type Capacitance, @@ -34,16 +38,28 @@ export { catalyticActivity, type Charge, charge, + type Concentration, + concentration, type Conductance, conductance, type Current, current, + type CurrentDensity, + currentDensity, + type Density, + density, + type DynamicViscosity, + dynamicViscosity, + type ElectricFieldStrength, + electricFieldStrength, type Energy, energy, type Force, force, type Frequency, frequency, + type HeatCapacity, + heatCapacity, type Illuminance, illuminance, type Inductance, @@ -52,6 +68,8 @@ export { isq, type IsqDims, isqDims, + type KinematicViscosity, + kinematicViscosity, type Length, length, type Luminosity, @@ -64,6 +82,16 @@ export { magneticFluxDensity, type Mass, mass, + type MassFlowRate, + massFlowRate, + type MolarMass, + molarMass, + type Momentum, + momentum, + type Permeability, + permeability, + type Permittivity, + permittivity, type Power, power, type Pressure, @@ -71,16 +99,32 @@ export { type Resistance, resistance, type Scalar, + type SpecificEnergy, + specificEnergy, + type SpecificHeatCapacity, + specificHeatCapacity, + type SpecificVolume, + specificVolume, + type SurfaceTension, + surfaceTension, type Temperature, temperature, type ThermalConductance, thermalConductance, + type ThermalConductivity, + thermalConductivity, type Time, time, + type Torque, + torque, type Velocity, velocity, type Voltage, voltage, type Volume, volume, + type VolumetricFlowRate, + volumetricFlowRate, + type Wavenumber, + wavenumber, } from "./quantities.generated.ts"; diff --git a/packages/dim-isq/src/quantities.generated.ts b/packages/dim-isq/src/quantities.generated.ts index 96e27c3..16846f0 100644 --- a/packages/dim-isq/src/quantities.generated.ts +++ b/packages/dim-isq/src/quantities.generated.ts @@ -113,6 +113,68 @@ export const pressure: QuantityFactory = isq.factory({ export type Frequency = D<{ T: -1 }>; export const frequency: QuantityFactory = isq.factory({ T: -1 }); +/** Density (L⁻³·M) */ +export type Density = D<{ L: -3; M: 1 }>; +export const density: QuantityFactory = isq.factory({ L: -3, M: 1 }); + +/** SpecificVolume (L³·M⁻¹) */ +export type SpecificVolume = D<{ L: 3; M: -1 }>; +export const specificVolume: QuantityFactory = isq.factory({ + L: 3, + M: -1, +}); + +/** Momentum (L·M·T⁻¹) */ +export type Momentum = D<{ L: 1; M: 1; T: -1 }>; +export const momentum: QuantityFactory = isq.factory({ + L: 1, + M: 1, + T: -1, +}); + +/** AngularVelocity (T⁻¹) */ +export type AngularVelocity = D<{ T: -1 }>; +export const angularVelocity: QuantityFactory = isq.factory({ + T: -1, +}); + +/** AngularAcceleration (T⁻²) */ +export type AngularAcceleration = D<{ T: -2 }>; +export const angularAcceleration: QuantityFactory = isq + .factory({ T: -2 }); + +/** Torque (L²·M·T⁻²) */ +export type Torque = D<{ L: 2; M: 1; T: -2 }>; +export const torque: QuantityFactory = isq.factory({ + L: 2, + M: 1, + T: -2, +}); + +/** DynamicViscosity (L⁻¹·M·T⁻¹) */ +export type DynamicViscosity = D<{ L: -1; M: 1; T: -1 }>; +export const dynamicViscosity: QuantityFactory = isq.factory({ + L: -1, + M: 1, + T: -1, +}); + +/** KinematicViscosity (L²·T⁻¹) */ +export type KinematicViscosity = D<{ L: 2; T: -1 }>; +export const kinematicViscosity: QuantityFactory = isq + .factory({ L: 2, T: -1 }); + +/** SurfaceTension (M·T⁻²) */ +export type SurfaceTension = D<{ M: 1; T: -2 }>; +export const surfaceTension: QuantityFactory = isq.factory({ + M: 1, + T: -2, +}); + +/** Wavenumber (L⁻¹) */ +export type Wavenumber = D<{ L: -1 }>; +export const wavenumber: QuantityFactory = isq.factory({ L: -1 }); + /** Charge (T·I) */ export type Charge = D<{ T: 1; I: 1 }>; export const charge: QuantityFactory = isq.factory({ T: 1, I: 1 }); @@ -176,6 +238,36 @@ export type MagneticFluxDensity = D<{ M: 1; T: -2; I: -1 }>; export const magneticFluxDensity: QuantityFactory = isq .factory({ M: 1, T: -2, I: -1 }); +/** ElectricFieldStrength (L·M·T⁻³·I⁻¹) */ +export type ElectricFieldStrength = D<{ L: 1; M: 1; T: -3; I: -1 }>; +export const electricFieldStrength: QuantityFactory = isq + .factory({ L: 1, M: 1, T: -3, I: -1 }); + +/** Permittivity (L⁻³·M⁻¹·T⁴·I²) */ +export type Permittivity = D<{ L: -3; M: -1; T: 4; I: 2 }>; +export const permittivity: QuantityFactory = isq.factory({ + L: -3, + M: -1, + T: 4, + I: 2, +}); + +/** Permeability (L·M·T⁻²·I⁻²) */ +export type Permeability = D<{ L: 1; M: 1; T: -2; I: -2 }>; +export const permeability: QuantityFactory = isq.factory({ + L: 1, + M: 1, + T: -2, + I: -2, +}); + +/** CurrentDensity (L⁻²·I) */ +export type CurrentDensity = D<{ L: -2; I: 1 }>; +export const currentDensity: QuantityFactory = isq.factory({ + L: -2, + I: 1, +}); + /** LuminousFlux (J) */ export type LuminousFlux = D<{ J: 1 }>; export const luminousFlux: QuantityFactory = isq.factory({ @@ -205,3 +297,55 @@ export const catalyticActivity: QuantityFactory = isq export type ThermalConductance = D<{ L: 2; M: 1; T: -3; Θ: -1 }>; export const thermalConductance: QuantityFactory = isq .factory({ L: 2, M: 1, T: -3, Θ: -1 }); + +/** HeatCapacity (L²·M·T⁻²·Θ⁻¹) */ +export type HeatCapacity = D<{ L: 2; M: 1; T: -2; Θ: -1 }>; +export const heatCapacity: QuantityFactory = isq.factory({ + L: 2, + M: 1, + T: -2, + Θ: -1, +}); + +/** SpecificHeatCapacity (L²·T⁻²·Θ⁻¹) */ +export type SpecificHeatCapacity = D<{ L: 2; T: -2; Θ: -1 }>; +export const specificHeatCapacity: QuantityFactory = isq + .factory({ L: 2, T: -2, Θ: -1 }); + +/** SpecificEnergy (L²·T⁻²) */ +export type SpecificEnergy = D<{ L: 2; T: -2 }>; +export const specificEnergy: QuantityFactory = isq.factory({ + L: 2, + T: -2, +}); + +/** ThermalConductivity (L·M·T⁻³·Θ⁻¹) */ +export type ThermalConductivity = D<{ L: 1; M: 1; T: -3; Θ: -1 }>; +export const thermalConductivity: QuantityFactory = isq + .factory({ L: 1, M: 1, T: -3, Θ: -1 }); + +/** VolumetricFlowRate (L³·T⁻¹) */ +export type VolumetricFlowRate = D<{ L: 3; T: -1 }>; +export const volumetricFlowRate: QuantityFactory = isq + .factory({ L: 3, T: -1 }); + +/** MassFlowRate (M·T⁻¹) */ +export type MassFlowRate = D<{ M: 1; T: -1 }>; +export const massFlowRate: QuantityFactory = isq.factory({ + M: 1, + T: -1, +}); + +/** Concentration (L⁻³·N) */ +export type Concentration = D<{ L: -3; N: 1 }>; +export const concentration: QuantityFactory = isq.factory({ + L: -3, + N: 1, +}); + +/** MolarMass (M·N⁻¹) */ +export type MolarMass = D<{ M: 1; N: -1 }>; +export const molarMass: QuantityFactory = isq.factory({ + M: 1, + N: -1, +});