Re: [ROOT] [ROOT}: PI, c, etc

From: Tony Colley (tony.colley@itt.com)
Date: Wed Jul 24 2002 - 15:55:52 MEST


Root Community:

This is not part of ROOT, but it is what we use here at ITT for 
mathematical and physical constants. You are welcome to fold it into 
your own code.

The ROOT Development Team (RDT) is also welcome to fold it into ROOT 
somewhere. If the RDT would let me know exactly where in the ROOT 
hierarchy they would want this and what the naming, formatting & 
documentation conventions are, I would be willing to do that part of the 
effort myself.

Cheers,
Tony Colley


Alberto Pulvirenti wrote:

>Hi Andreas,
>
>PI is obtained by TMath::Pi()
>
>about the others, I think there is no place where they are stored...
>
>Regards
>
>On Wed, 24 Jul 2002, Andreas Salzburger wrote:
>
>  
>
>>hi "root-talk-community",
>>
>>i've just a small question, i guess it's solved very fast.
>>how can i have access to constants like pi, c, hbar, etc .. in root?
>>
>>Thank's
>>Andi
>>
>>
>>
>>    
>>
>
>  
>




//=============================================================================
// ITT DEFENSE AEROSPACE/COMMUNICATIONS DIVISION
// 1919 West Cook Road Fort Wayne, Indiana 46801
//=============================================================================
// Copyright 2002 ITT Industries as an unpublished work.
// All rights reserved.
//
// This computer software is proprietary to  ITT Industries  and shall not be
// reproduced, disclosed or used  without the prior written permission of ITT
// Corporation.
//=============================================================================
//
// NOTE: The documentation in this file is optimized for doxygen (which uses
//       doxygen, HTML, and LaTeX markup), which obfuscates it somewhat for
//       preformatted reading.
//
/*! \file
 * $Source: /users/cvs/ittdcsf/itt_utils/include/FundamentalConstants.h,v $
 * $Revision: 1.6 $ $Date: 2002/07/11 17:19:36 $ $Author: awcolley $
 *
 * Purpose:<pre>
 *   Defines fundamental constants.
 *
 *   SOURCE: The NIST Reference on Constants, Units, and Uncertainty
 *           http://physics.nist.gov/cuu/Constants/index.html
 *           (except as noted)
 *</pre>
 */
#ifndef INC_FUNDAMENTALCONSTANTS_H
#define INC_FUNDAMENTALCONSTANTS_H

#include "declspec_utils.h"

namespace itt 
{

  // Values related to Pi
  // cout << fixed << setprecision(20) << Pi gives (on a PentiumIII):
  //                  3.141592653589793116

  /*! \brief \f$\pi\f$ -- Archimedes Constant.
   *
   * Source:
   * http://numbers.computation.free.fr/Constants/Miscellaneous/digits.html 
   */
  extern const double UTILS_DECLSPEC Pi;
  /*! \brief \f$2 \pi\f$ */
  extern const double UTILS_DECLSPEC TwoPi;       // 2*pi
  /*! \brief \f$\pi / 2\f$ */
  extern const double UTILS_DECLSPEC PiOver2;     // pi/2
  /*! \brief \f$\pi / 4\f$ */
  extern const double UTILS_DECLSPEC PiOver4;     // pi/4
  /*! \brief \f$1 / \pi\f$ */
  extern const double UTILS_DECLSPEC InvPi;       // 1/pi
  /*! \brief convert radians to degrees.
   *
   * \f$180 / \pi\f$ 
   */
  extern const double UTILS_DECLSPEC RadToDeg;    // 180/pi
  /*! \brief convert degrees to radians.
   *
   * \f$\pi / 180\f$
   */
  extern const double UTILS_DECLSPEC DegToRad;    // pi/180

  /*! \brief \f$e\f$ -- the Euler Number (base of natural log).
   *
   * Source:
   * http://numbers.computation.free.fr/Constants/Miscellaneous/digits.html 
   */
  extern const double UTILS_DECLSPEC E;
  /*! \brief \f$\ln{10}\f$ -- natural log of 10 (to convert log to ln).
   *
   * Source:
   * http://numbers.computation.free.fr/Constants/Miscellaneous/digits.html 
   */
  extern const double UTILS_DECLSPEC Ln10;
  /*! \brief \f$\log{e}\f$ -- base-10 log of \f$e\f$ (to convert ln to log).
   *
   * Source:
   * http://numbers.computation.free.fr/Constants/Miscellaneous/digits.html 
   */
  extern const double UTILS_DECLSPEC LogE;
  
  /*! \brief \f$c\f$ -- speed of light in a vacuum
   *
   * units: \f$\mathbf{m} \: \mathbf{s}^{-1}\f$
   */
  extern const double UTILS_DECLSPEC C;           // m s^-1

  /*! \brief \f$c_{cgs}\f$ -- speed of light in a vacuum (CGS units)
   *
   * units: \f$\mathbf{cm} \: \mathbf{s}^{-1}\f$
   */
  extern const double UTILS_DECLSPEC Ccgs;        // cm s^-1

  /*! \brief uncertainty of \f$c\f$ */
  extern const double UTILS_DECLSPEC C_uncertainty;

  /*! \brief \f$G\f$ -- gravitational constant 
   *
   * units: \f$\mathbf{m}^3 \: \mathbf{kg}^{-1} \: \mathbf{s}^{-2}\f$
   */
  extern const double UTILS_DECLSPEC G;           // m^3 kg^-1 s^-2

  /*! \brief \f$G_{cgs}\f$ -- gravitational constant (CGS units)
   *
   * units: \f$\mathbf{cm}^3 \: \mathbf{g}^{-1} \: \mathbf{s}^{-2}\f$
   */
  extern const double UTILS_DECLSPEC Gcgs;        // cm^3 g^-1 s^-2

  /*! \brief uncertainty of \f$G\f$ */
  extern const double UTILS_DECLSPEC G_uncertainty;

  /*! \brief \f$G/\hbar c\f$
   *
   * units: \f$\mathbf{(GeV} / \mathbf{c}^2)^{-2}\f$
   */
  extern const double UTILS_DECLSPEC G_hbarC;     // (GeV / c^2)^-2

  /*! \brief uncertainty of \f$G/\hbar c\f$ */
  extern const double UTILS_DECLSPEC G_hbarC_uncertainty;

  /*! \brief \f$g_n\f$ -- standard acceleration of gravity
   *
   * units: \f$\mathbf{m} \: \mathbf{s}^{-2}\f$
   */
  extern const double UTILS_DECLSPEC Gn;          // m s^-2

  /*! \brief uncertainty of \f$g_n\f$ */
  extern const double UTILS_DECLSPEC Gn_uncertainty;
  
  /*! \brief \f$h\f$ -- Planck's constant
   *
   * units: \f$\mathbf{J} \: \mathbf{s}\f$
   */
  extern const double UTILS_DECLSPEC H;           // J s

  /*! \brief \f$h_{cgs}\f$ -- Planck's constant (CGS units)
   *
   * units: \f$\mathbf{erg} \: \mathbf{s}\f$
   */
  extern const double UTILS_DECLSPEC Hcgs;        // erg s

  /*! \brief uncertainty of \f$h\f$ */
  extern const double UTILS_DECLSPEC H_uncertainty;

  /*! \brief \f$\hbar\f$ -- Planck's constant divided by \f$2\pi\f$
   *
   * units: \f$\mathbf{J} \: \mathbf{s}\f$
   */
  extern const double UTILS_DECLSPEC Hbar;        // J s

  /*! \brief \f$\hbar_{cgs}\f$ -- Planck's constant divided by \f$2\pi\f$
   * (CGS units)
   *
   * units: \f$\mathbf{erg} \: \mathbf{s}\f$
   */
  extern const double UTILS_DECLSPEC Hbar_cgs;    // erg s

  /*! \brief uncertainty of \f$\hbar\f$ */
  extern const double UTILS_DECLSPEC Hbar_uncertainty;

  /*! \brief \f$hc\f$ -- Planck's constant times speed of light
   *
   * units: \f$\mathbf{J} \: \mathbf{m}\f$
   */
  extern const double UTILS_DECLSPEC HC;          // J m

  /*! \brief \f$(hc)_{cgs}\f$ -- Planck's constant times speed of light
   * (CGS units)
   *
   * units: \f$\mathbf{erg} \: \mathbf{cm}\f$
   */
  extern const double UTILS_DECLSPEC HCcgs;       // erg cm

  /*! \brief \f$k\f$ -- Boltzmann's constant
   *
   * units: \f$\mathbf{J} \: \mathbf{K}^{-1}\f$
   */
  extern const double UTILS_DECLSPEC K;           // J K^-1

  /*! \brief \f$k_{cgs}\f$ -- Boltzmann's constant (CGS units)
   *
   * units: \f$\mathbf{erg} \: \mathbf{K}^{-1}\f$
   */
  extern const double UTILS_DECLSPEC Kcgs;        // erg K^-1

  /*! \brief uncertainty of \f$k\f$ */
  extern const double UTILS_DECLSPEC K_uncertainty;

  /*! \brief \f$\sigma\f$ -- Stefan-Boltzmann constant
   *
   * units: \f$\mathbf{W} \: \mathbf{m}^{-2} \: \mathbf{K}^{-4}\f$
   */
  extern const double UTILS_DECLSPEC Sigma;       // W m^-2 K^-4

  /*! \brief uncertainty of \f$\sigma\f$ */
  extern const double UTILS_DECLSPEC Sigma_uncertainty;

  /*! \brief \f$N_{\mathbf{A}}\f$ -- Avogadro's Number
   *
   * units: \f$\mathbf{mol}^{-1}\f$
   */
  extern const double UTILS_DECLSPEC Na;          // mol^-1

  /*! \brief uncertainty of \f$N_{\mathbf{A}}\f$ */
  extern const double UTILS_DECLSPEC Na_uncertainty;

  /*! \brief \f$R\f$ -- universal gas constant, \f$R \equiv k N_{\mathbf{A}}\f$
   *
   * units: \f$\mathbf{J} \: \mathbf{K}^{-1} \: \mathbf{mol}^{-1}\f$
   *
   * Source:
   * http://scienceworld.wolfram.com/physics/UniversalGasConstant.html
   */
  extern const double UTILS_DECLSPEC R;           // J K^-1 mol^-1

  /*! \brief uncertainty of \f$R\f$ */
  extern const double UTILS_DECLSPEC R_uncertainty;
  
  /*! \brief \f$m_a\f$ -- molecular weight of dry air
   *
   * units: \f$\mathbf{kg} \: \mathbf{kmol}^{-1}\f$ <i>or</i>
   * \f$\mathbf{g} \: \mathbf{mol}^{-1}\f$
   *
   * Source:
   * <i>1976 US Standard Atmosphere</i>,
   * also see http://atmos.nmsu.edu/jsdap/encyclopediawork.html
   */
  extern const double UTILS_DECLSPEC MWair;       // kg kmol^-1  or  g mol^-1

  /*! \brief \f$R_g(\mathbf{air})\f$ -- dry air gas constant (\f$R / m_a\f$)
   *
   * units: \f$\mathbf{J} \: \mathbf{kg}^{-1} \: \mathbf{K}^{-1}\f$
   *
   * Source:
   * http://atmos.nmsu.edu/education_and_outreach/encyclopedia/gas_constant.htm
   */
  extern const double UTILS_DECLSPEC Rgair;       // J kg^-1 K^-1

  /*! \brief \f$e\f$ -- Elementary charge
   *
   * units: \f$\mathbf{C}\f$
   */
  extern const double UTILS_DECLSPEC Qe;          // C

  /*! \brief uncertainty of \f$e\f$ */
  extern const double UTILS_DECLSPEC Qe_uncertainty;

} // end of itt namespace

#endif // ADD NOTHING AFTER HERE


//=============================================================================
// ITT DEFENSE AEROSPACE/COMMUNICATIONS DIVISION
// 1919 West Cook Road Fort Wayne, Indiana 46801
//=============================================================================
// Copyright 2002 ITT Industries as an unpublished work.
// All rights reserved.
//
// This computer software is proprietary to  ITT Industries  and shall not be
// reproduced, disclosed or used  without the prior written permission of ITT
// Corporation.
//=============================================================================
// Programmer Notes:
//
//   Except as noted below, all values are from:
//
//           The NIST Reference on Constants, Units, and Uncertainty
//
//           http://physics.nist.gov/cuu/Constants/index.html
//
//=============================================================================
/*! \file
 * $Source: /users/cvs/ittdcsf/itt_utils/src/FundamentalConstants.cpp,v $
 * $Revision: 1.5 $ $Date: 2002/07/11 17:19:36 $ $Author: awcolley $
 */
#include "FundamentalConstants.h"

namespace itt 
{

// Values related to Pi
// cout << fixed << setprecision(20) << Pi gives (on a PentiumIII):
//                  3.141592653589793116
  const double Pi = 3.14159265358979323846;
  const double TwoPi    = 2.0 * Pi;
  const double PiOver2  = Pi / 2.0;
  const double PiOver4  = Pi / 4.0;
  const double InvPi    = 1.0 / Pi;
  const double RadToDeg = 180.0 / Pi;
  const double DegToRad = Pi / 180.0;

// e (base of natural log)
  const double E = 2.71828182845904523536;

// natural log of 10 (to convert log to ln)
  const double Ln10 = 2.30258509299404568402;
  
// base-10 log of e  (to convert ln to log)
  const double LogE = 0.43429448190325182765;
  
// Velocity of light
  const double C = 2.99792458e8;        // m s^-1
  const double Ccgs = 100.0 * C;        // cm s^-1
  const double C_uncertainty = 0.0;     // exact

// Gravitational constant
  const double G = 6.673e-11;           // m^3 kg^-1 s^-2
  const double Gcgs = G / 1000.0;       // cm^3 g^-1 s^-2
  const double G_uncertainty = 0.010e-11;

// G over h-bar C
  const double G_hbarC = 6.707e-39;     // (GeV/c^2)^-2
  const double G_hbarC_uncertainty = 0.010e-39;
  
// Standard acceleration of gravity
  const double Gn = 9.80665;            // m s^-2
  const double Gn_uncertainty = 0.0;    // exact

// Planck's constant
  const double H = 6.62606876e-34;      // J s
  const double Hcgs = 1.0e7 * H;        // erg s
  const double H_uncertainty = 0.00000052e-34;

// h-bar (h over 2 pi)
  const double Hbar = 1.054571596e-34;  // J s
  const double Hbar_cgs = 1.0e7 * Hbar; // erg s
  const double Hbar_uncertainty = 0.000000082e-34;

// hc (h * c)
  const double HC = H * C;              // J m
  const double HCcgs = Hcgs * Ccgs;     // erg cm

// Boltzmann's constant
  const double K = 1.3806503e-23;       // J K^-1
  const double Kcgs = 1.0e7 * K;        // erg K^-1
  const double K_uncertainty = 0.0000024e-23;

// Stefan-Boltzmann constant
  const double Sigma = 5.6704e-8;       // W m^-2 K^-4
  const double Sigma_uncertainty = 0.000040e-8;

// Avogadro constant (Avogadro's Number)
  const double Na = 6.02214199e+23;     // mol^-1
  const double Na_uncertainty = 0.00000047e+23;

// Universal Gas constant (Na * K)
// http://scienceworld.wolfram.com/physics/UniversalGasConstant.html
  const double R = K * Na;              // J K^-1 mol^-1
  const double R_uncertainty = R*((K_uncertainty/K) + (Na_uncertainty/Na));

// Molecular weight of dry air
// 1976 US Standard Atmosphere,
// also see http://atmos.nmsu.edu/jsdap/encyclopediawork.html
  const double MWair = 28.9644;         // kg kmol^-1 (or gm mol^-1)

// Dry Air Gas Constant (R / MWair)
// http://atmos.nmsu.edu/education_and_outreach/encyclopedia/gas_constant.htm
  const double Rgair = (1000.0 * R) / MWair; // J kg^-1 K^-1
  
// Elementary charge
  const double Qe = 1.602176462e-19;    // C
  const double Qe_uncertainty = 0.000000063e-19;
  
} // end of itt namespace



This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:51:00 MET