Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 51 additions & 26 deletions packages/dim-isq/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand Down
26 changes: 26 additions & 0 deletions packages/dim-isq/quantities.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand All @@ -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 },
Expand All @@ -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 },
},
},
});
44 changes: 44 additions & 0 deletions packages/dim-isq/src/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ export {
type Amount,
// Base quantities
amount,
type AngularAcceleration,
angularAcceleration,
type AngularVelocity,
angularVelocity,
type Area,
area,
type Capacitance,
Expand All @@ -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,
Expand All @@ -52,6 +68,8 @@ export {
isq,
type IsqDims,
isqDims,
type KinematicViscosity,
kinematicViscosity,
type Length,
length,
type Luminosity,
Expand All @@ -64,23 +82,49 @@ 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,
pressure,
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";
144 changes: 144 additions & 0 deletions packages/dim-isq/src/quantities.generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,68 @@ export const pressure: QuantityFactory<Pressure> = isq.factory({
export type Frequency = D<{ T: -1 }>;
export const frequency: QuantityFactory<Frequency> = isq.factory({ T: -1 });

/** Density (L⁻³·M) */
export type Density = D<{ L: -3; M: 1 }>;
export const density: QuantityFactory<Density> = isq.factory({ L: -3, M: 1 });

/** SpecificVolume (L³·M⁻¹) */
export type SpecificVolume = D<{ L: 3; M: -1 }>;
export const specificVolume: QuantityFactory<SpecificVolume> = isq.factory({
L: 3,
M: -1,
});

/** Momentum (L·M·T⁻¹) */
export type Momentum = D<{ L: 1; M: 1; T: -1 }>;
export const momentum: QuantityFactory<Momentum> = isq.factory({
L: 1,
M: 1,
T: -1,
});

/** AngularVelocity (T⁻¹) */
export type AngularVelocity = D<{ T: -1 }>;
export const angularVelocity: QuantityFactory<AngularVelocity> = isq.factory({
T: -1,
});

/** AngularAcceleration (T⁻²) */
export type AngularAcceleration = D<{ T: -2 }>;
export const angularAcceleration: QuantityFactory<AngularAcceleration> = isq
.factory({ T: -2 });

/** Torque (L²·M·T⁻²) */
export type Torque = D<{ L: 2; M: 1; T: -2 }>;
export const torque: QuantityFactory<Torque> = 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<DynamicViscosity> = isq.factory({
L: -1,
M: 1,
T: -1,
});

/** KinematicViscosity (L²·T⁻¹) */
export type KinematicViscosity = D<{ L: 2; T: -1 }>;
export const kinematicViscosity: QuantityFactory<KinematicViscosity> = isq
.factory({ L: 2, T: -1 });

/** SurfaceTension (M·T⁻²) */
export type SurfaceTension = D<{ M: 1; T: -2 }>;
export const surfaceTension: QuantityFactory<SurfaceTension> = isq.factory({
M: 1,
T: -2,
});

/** Wavenumber (L⁻¹) */
export type Wavenumber = D<{ L: -1 }>;
export const wavenumber: QuantityFactory<Wavenumber> = isq.factory({ L: -1 });

/** Charge (T·I) */
export type Charge = D<{ T: 1; I: 1 }>;
export const charge: QuantityFactory<Charge> = isq.factory({ T: 1, I: 1 });
Expand Down Expand Up @@ -176,6 +238,36 @@ export type MagneticFluxDensity = D<{ M: 1; T: -2; I: -1 }>;
export const magneticFluxDensity: QuantityFactory<MagneticFluxDensity> = 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<ElectricFieldStrength> = 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<Permittivity> = 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<Permeability> = 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<CurrentDensity> = isq.factory({
L: -2,
I: 1,
});

/** LuminousFlux (J) */
export type LuminousFlux = D<{ J: 1 }>;
export const luminousFlux: QuantityFactory<LuminousFlux> = isq.factory({
Expand Down Expand Up @@ -205,3 +297,55 @@ export const catalyticActivity: QuantityFactory<CatalyticActivity> = isq
export type ThermalConductance = D<{ L: 2; M: 1; T: -3; Θ: -1 }>;
export const thermalConductance: QuantityFactory<ThermalConductance> = 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<HeatCapacity> = 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<SpecificHeatCapacity> = isq
.factory({ L: 2, T: -2, Θ: -1 });

/** SpecificEnergy (L²·T⁻²) */
export type SpecificEnergy = D<{ L: 2; T: -2 }>;
export const specificEnergy: QuantityFactory<SpecificEnergy> = 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<ThermalConductivity> = isq
.factory({ L: 1, M: 1, T: -3, Θ: -1 });

/** VolumetricFlowRate (L³·T⁻¹) */
export type VolumetricFlowRate = D<{ L: 3; T: -1 }>;
export const volumetricFlowRate: QuantityFactory<VolumetricFlowRate> = isq
.factory({ L: 3, T: -1 });

/** MassFlowRate (M·T⁻¹) */
export type MassFlowRate = D<{ M: 1; T: -1 }>;
export const massFlowRate: QuantityFactory<MassFlowRate> = isq.factory({
M: 1,
T: -1,
});

/** Concentration (L⁻³·N) */
export type Concentration = D<{ L: -3; N: 1 }>;
export const concentration: QuantityFactory<Concentration> = isq.factory({
L: -3,
N: 1,
});

/** MolarMass (M·N⁻¹) */
export type MolarMass = D<{ M: 1; N: -1 }>;
export const molarMass: QuantityFactory<MolarMass> = isq.factory({
M: 1,
N: -1,
});
Loading