Another library for type checking of dimensioned quantities at run-time in FreePascal. From a circular's idea.
Ensuring coherence of physical dimensions in physical equations or mathematical relationships involving various variables is crucial. Dimensional analysis provides a fundamental tool to verify this coherence and correct any errors in the expressions.
The adimRT library allows defining variables and constants in terms of quantity and units of measurement, automating dimensional analysis at run-time.
uses
adim;
var
distance: TQuantity;
time: TQuantity;
speed: TQuantity;
begin
distance := 5000*m;
time := 2*hr;
speed := distance/time;
writeln('The value of speed is ', KilometerPerHourUnit.ToString(speed);
end;Output:
The value of speed is 2.5 km/h
uses
adim;
var
plank: TQuantity;
e0: TQuantity;
ke: TQuantity;
mass: TQuantity;
radius: TQuantity;
begin
plank := 6.62607015E-34*J*s; // Planck constant
e0 := 8.8541878128E-12*F/m; // vacuum permittivity
ke := 1/(4*pi*e0); // Coulomb constant
mass := 9.1093837015E-31*kg; // mass of an electron
radius := (SquarePower(plank/2/pi)/mass)/(ke*SquarePower(charge));
writeln('The value of the Bohr radius is ', MeterUnit.ToString(radius, 10, 10, []));
end;Output:
The value of the Bohr radius is 5.291772109E-11 m
Refer to the adim test source code for additional examples.
- Mechanics
- Fluid Mechanics
- Electricity and Magnetism
- Heat and Thermodynamics
- Waves and Hearing
- Light and Vision
- Relativity
- Quantum Mechanics
- Units of measurement