Skip to content

Commit

Permalink
Add some alternative dimension names
Browse files Browse the repository at this point in the history
  • Loading branch information
sharkdp authored and David Peter committed Sep 5, 2023
1 parent eaa1eff commit 89ece08
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 17 deletions.
2 changes: 1 addition & 1 deletion examples/population_growth.nbt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
let initial_population = 50_000 people
let growth_rate: Rate = 2 percent per year
let growth_rate: 1 / Time = 2 percent per year

fn predict_population(time: Time) = initial_population × e^(growth_rate time) // round

Expand Down
27 changes: 12 additions & 15 deletions modules/core/dimensions.nbt
Original file line number Diff line number Diff line change
@@ -1,38 +1,39 @@
### Physical dimensions

dimension Angle = 1
dimension Angle = 1 # SI: plane angle
dimension SolidAngle = Angle^2

dimension Length
dimension Area = Length^2
dimension Volume = Length^3
dimension Wavenumber = 1 / Length

dimension Time
dimension Frequency = 1 / Time
dimension Speed = Length / Time
dimension Speed = Length / Time # also: velocity
dimension Acceleration = Length / Time^2
dimension Jerk = Length / Time^3

dimension Mass
dimension Momentum = Mass × Speed
dimension Force = Mass × Acceleration = Momentum / Time
dimension Energy = Momentum^2 / Mass = Mass × Speed^2 = Force × Length
dimension Power = Energy / Time = Force × Speed
dimension Pressure = Force / Area = Energy / Volume
dimension Energy = Momentum^2 / Mass = Mass × Speed^2 = Force × Length # also: work, amount of heat
dimension Power = Energy / Time = Force × Speed # also: radiant flux
dimension Pressure = Force / Area = Energy / Volume # also: stress
dimension Action = Energy × Time
dimension MassDensity = Mass / Length^3
dimension MomentOfInertia = Mass × Length^2
dimension AngularMomentum = MomentOfInertia × Angle / Time
dimension Torque = Length × Force
dimension Torque = Length × Force # also: moment of force
dimension EnergyDensity = Energy / Volume

dimension Current
dimension Charge = Current × Time
dimension Voltage = Energy / Charge = Power / Current
dimension Charge = Current × Time # SI: electric charge
dimension Voltage = Energy / Charge = Power / Current # ISQ: electric tension, SI: electric potential difference
dimension Capacitance = Charge / Voltage
dimension Resistance = Voltage / Current
dimension Resistance = Voltage / Current # SI: electric resistance
dimension Resistivity = Resistance × Length
dimension Conductance = 1 / Resistance
dimension Conductance = 1 / Resistance # SI: electric conductance
dimension Conductivity = Conductance / Length
dimension MagneticFluxDensity = Force / (Charge × Speed)
dimension MagneticFlux = MagneticFluxDensity × Area
Expand Down Expand Up @@ -63,11 +64,7 @@ dimension Irradiance = Power / Area

dimension Activity = 1 / Time
dimension AbsorbedDose = Energy / Mass
dimension EquivalentDose = Energy / Mass
dimension EquivalentDose = Energy / Mass # also: dose equivalent

dimension DynamicViscosity = Pressure × Time
dimension KinematicViscosity = Length^2 / Time

# Other useful names

dimension Rate = 1 / Time
2 changes: 1 addition & 1 deletion numbat/tests/interpreter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ fn test_incompatible_dimension_errors() {
expect_exact_failure(
"m + 1 / m",
" left hand side: Length\n\
right hand side: Length⁻¹\n\n\
right hand side: Length⁻¹ [= Wavenumber]\n\n\
Suggested fix: multiply right hand side by Length²",
);
expect_exact_failure(
Expand Down

0 comments on commit 89ece08

Please sign in to comment.