C:/nobackup/private/physical_svn/trunk/include/physical/unit.hpp

Go to the documentation of this file.
00001 
00002 /*=============================================================================
00003     physical quantities / units / constants
00004     Copyright (c) 2006, 2007 Martin Schulz
00005     http://physical.sourceforge.net
00006   
00007     This is private code by Martin Schulz.
00008   
00009     Use, modification and distribution is subject to the Boost Software
00010     License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
00011     http://www.boost.org/LICENSE_1_0.txt)
00012 =============================================================================*/
00013 
00014 #ifndef PHYSICAL_UNIT
00015 #define PHYSICAL_UNIT
00016 
00017 #include "physical/quantity.hpp"
00018 #include "physical/dynamicunit.hpp"
00019 #include "physical/dynamicphysical.hpp"
00020 
00021 namespace physical {
00022 
00023 namespace unit_si_double { typedef double real; namespace quantity=quantity_si_double; };  
00024 namespace unit_si_float { typedef float real; namespace quantity=quantity_si_float; };  
00025 
00026 #define UNIT0(AAA)             namespace unit_si_double { AAA; }; namespace unit_si_float { AAA; };
00027 
00028 
00029                 UNIT0( const static double pi=3.14 ); // FIXME what header file do I need here?..
00030 
00031                 // todo: additional types
00032                 //              baseunit only default-ctor=1;
00033                 //              derivedunit only conversion c'tor from other entities.. 
00034 
00035                 // statically predefined SI base units : (from table 1)
00036                 UNIT0( const static quantity::scalar                                                            unity(1) ); // not really a SI unit but nevertheless...
00037                 UNIT0( const static quantity::length                                                            meter(1) );
00038                 UNIT0( const static quantity::mass                                                                      kilogram(1) );
00039                 UNIT0( const static quantity::time                                                                      second(1) );
00040                 UNIT0( const static quantity::electric_current                                          ampere(1) );
00041                 UNIT0( const static quantity::temperature                                                       kelvin(1) );
00042                 UNIT0( const static quantity::amount_of_substance                                       mol(1) );
00043                 UNIT0( const static quantity::amount_of_substance                                       mole(1) );
00044                 UNIT0( const static quantity::luminous_intensity                                        candela(1) );
00045 
00046                 // some statically predefined SI derived units: (from table 2)
00047                 UNIT0( const static quantity::area                                                              square_meter                    =       meter*meter );
00048                 UNIT0( const static quantity::volume                                                            cubic_meter                             =       meter*meter*meter );
00049                 UNIT0( const static quantity::velocity                                                          meter_per_second                =       meter/second );
00050                 UNIT0( const static quantity::acceleration                                                      meter_per_second_squared =      meter/(second*second) );
00051                 UNIT0( const static quantity::wave_number                                                       reciprocal_meter                =       unity/meter );
00052                 UNIT0( const static quantity::mass_density                                                      kilogram_per_cubic_meter =      kilogram/cubic_meter );
00053                 UNIT0( const static quantity::specific_volume                                           cubic_meter_per_kilogram =      cubic_meter/kilogram );
00054                 UNIT0( const static quantity::current_density                                           ampere_per_square_meter =       ampere/square_meter );
00055                 UNIT0( const static quantity::magnetic_field_strength                           ampere_per_meter                =       ampere/meter );
00056                 UNIT0( const static quantity::amount_of_substance_concentration         mole_per_cubic_meter    =       mol/cubic_meter );
00057                 UNIT0( const static quantity::luminance                                                         candela_per_square_meter =      candela/square_meter );
00058                 UNIT0( const static quantity::mass_fraction                                             kilogram_per_kilogram   =       kilogram/kilogram );
00059 
00060                 // SI derived units with special names (from table 3)
00061                 UNIT0( const static quantity::plane_angle                                                       radian                                  =       meter/meter );
00062                 UNIT0( const static quantity::solid_angle                                                       steradian                               =       square_meter/square_meter );
00063                 UNIT0( const static quantity::frequency                                                         hertz                                   =       unity/second );
00064                 UNIT0( const static quantity::force                                                                     newton                                  =       meter*kilogram/(second*second) );
00065                 UNIT0( const static quantity::pressure                                                          Pascal                                  =       newton/square_meter );
00066                 UNIT0( const static quantity::energy                                                            joule                                   =       newton*meter );
00067                 UNIT0( const static quantity::power                                                                     watt                                    =       joule/second );
00068                 UNIT0( const static quantity::electric_charge                                           coulomb                                 =       second*ampere );
00069                 UNIT0( const static quantity::electric_potential_difference                     volt                                    =       watt/ampere );
00070                 UNIT0( const static quantity::capacitance                                                       farad                                   =       coulomb/volt );
00071                 UNIT0( const static quantity::electric_resistance                                       ohm                                             =       volt/ampere );
00072                 UNIT0( const static quantity::electric_conductance                                      siemens                                 =       ampere/volt );
00073                 UNIT0( const static quantity::magnetic_flux                                             weber                                   =       volt*second );
00074                 UNIT0( const static quantity::magnetic_flux_density                                     tesla                                   =       weber/square_meter );
00075                 UNIT0( const static quantity::inductance                                                        henry                                   =       weber/ampere );
00076                 UNIT0( const static quantity::luminous_flux                                             lumen                                   =       candela*steradian );
00077                 UNIT0( const static quantity::illuminance                                                       lux                                     =       lumen/square_meter );
00078                 UNIT0( const static quantity::activity_of_a_radionuclide                        becquerel                               =       unity/second );
00079                 UNIT0( const static quantity::absorbed_dose                                                     gray                                    =       joule/kilogram );
00080                 UNIT0( const static quantity::dose_equivalent                                           sievert                                 =       joule/kilogram );
00081                 UNIT0( const static quantity::catalytic_activity                                        katal                                   =       mol/second );
00082 
00083                 // some statically predefinded non-base units: 
00084                 UNIT0( const static quantity::length                                                            centimeter                              =       (real)0.01*meter );
00085                 UNIT0( const static quantity::length                                                            millimeter                              =       (real)0.001*meter );
00086                 UNIT0( const static quantity::length                                                            kilometer                               =       (real)1000*meter );
00087                 UNIT0( const static quantity::mass                                                                      gram                                    =       (real)0.001*kilogram );
00088                 UNIT0( const static quantity::time                                                                      minute                                  =       (real)60*second );
00089                 UNIT0( const static quantity::time                                                                      hour                                    =       (real)60*minute );
00090                 UNIT0( const static quantity::plane_angle                                                       revolution                              =   (real)(2*pi)*radian );
00091                 UNIT0( const static quantity::angular_velocity                                          revolution_per_second   =   revolution/second );
00092                 UNIT0( const static quantity::angular_velocity                                          revolution_per_minute   =   revolution/minute );
00093                 
00094                 // some predefined dynamic units:
00095 
00096                 /* the temperature units in common use by humans do not have the same origin from 
00097                    the thermodynamic temperature measured in Kelvin. */
00098                 UNIT0( const static DynamicUnit<quantity::system> celsius(unit_si_double::kelvin, physical::detail::DynamicScale(1., 273.15)) );
00099                 UNIT0( const static DynamicUnit<quantity::system> fahrenheit(celsius, physical::detail::DynamicScale(5./9., -5./9.*32)) );
00100                 UNIT0( const static DynamicUnit<quantity::system> reaumur(celsius, physical::detail::DynamicScale(5./4., 0.)) );
00101 
00102 #undef UNIT0
00103 
00104 
00105 }; // namespace physical
00106 
00107 #endif

Generated on Mon Apr 2 22:25:03 2007 for physical_svn by  doxygen 1.5.1-p1
hosted on SourceForge.net Logo