Skip to content

melchiorrecaruso/adimRT

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

adimRT Library

Another library for type checking of dimensioned quantities at run-time in FreePascal. From a circular's idea.

Actions Status

What it's

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.

How to use

Example 1: Calculate speed

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

Example 2: Calculate Borh radius

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.

Requirements

Supported mathematical formulae:

References

LICENSE

GNU Lesser General Public License v3.0

About

Type checking of units of measurement at run time in FreePascal

Topics

Resources

License

LGPL-3.0, Unknown licenses found

Licenses found

LGPL-3.0
COPYING.LGPL
Unknown
COPYING.modifiedLGPL

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published