GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Astro::Constants(3) User Contributed Perl Documentation Astro::Constants(3)

Astro::Constants - This library provides physical constants for use in Physics and Astronomy based on values from CODATA2014.

version 0.14

    use strict;         # important!
    use Astro::Constants::MKS qw/:long/;

    # to calculate the gravitational force of the Sun on the Earth in Newtons, use GMm/r^2
    my $force_sun_earth = GRAVITATIONAL * MASS_SOLAR * MASS_EARTH / ASTRONOMICAL_UNIT**2;

This module provides physical and mathematical constants for use in Astronomy and Astrophysics.

The ":long" tag imports all the constants in their long name forms (i.e. GRAVITATIONAL). Useful subsets can be imported with these tags: ":fundamental" ":conversion" ":mathematics" ":cosmology" ":planetary" ":electromagnetic" or ":nuclear". Alternate names such as LIGHT_SPEED instead of SPEED_LIGHT or HBAR instead of H_BAR are imported with ":alternates". I'd like to move away from their use, but they have been in the module for years. Short forms of the constant names are included to provide backwards compatibility with older versions based on Jeremy Bailin's Astroconst library and are available through the import tag ":short".

The values are stored in Physical_Constants.xml in the data directory and are mostly based on the 2014 CODATA values from NIST.

Long name constants are constructed with the constant pragma and are not interpolated in double quotish situations because they are really inlined functions. Short name constants are constructed with the age-old idiom of fiddling with the symbol table using typeglobs, e.g. "*PI = \3.14159", and may be slower than the long name constants.

You are tired of typing in all those numbers and having to make sure that they are all correct. How many significant figures is enough or too much? Where's the definitive source, Wikipedia? And which mass does "$m1" refer to, solar or lunar?

The constant values in this module are protected against accidental re-assignment in your code. The test suite protects them against accidental finger trouble in my code. Other people are using this module, so more eyeballs are looking for errors and we all benefit. The constant names are a little longer than you might like, but you gain in the long run from readable, sharable code that is clear in meaning. Your programming errors are a little easier to find when you can see that the units don't match. Isn't it reassuring that you can verify how a number is produced and which meeting of which standards body is responsible for its value?

Trusting someone else's code does carry some risk, which you should consider, but have you also considered the risk of doing it yourself with no one else to check your work?

And plus, it's FASTER

Benchmarking has shown that the imported constants can be more than 3 times faster than using variables or other constant modules because of the way the compiler optimizes your code. So, if you've got a lot of calculating to do, this is the module to do it with.

    299792458   MKS

speed of light in a vacuum

This constant is also available using the short name $A_c as well as the alternate name "LIGHT_SPEED" (imported using the :alternate tag for backwards compatibility)

    1.380649e-23        MKS

Boltzmann's constant

This constant is also available using the short name $A_k

    6.67430e-11 MKS

universal gravitational constant

This constant is also available using the short name $A_G

    1.602176634e-19     MKS

electron volt

This constant is also available using the short name $A_eV

    6.62607015e-34      MKS

Planck constant

This constant is also available using the short name $A_h

    1.0545718176763e-34 MKS

the reduced Planck constant, Planck's constant (exact) /2pi

This constant is also available using the short name $A_hbar as well as the alternate name "HBAR" (imported using the :alternate tag for backwards compatibility)

    1.602176634e-19     MKS

electron charge (defined positive)

This constant is also available using the short name $A_e as well as the alternate name "ELECTRON_CHARGE" (imported using the :alternate tag for backwards compatibility)

    5.670374419e-8      MKS

Stefan-Boltzmann constant

This constant is also available using the short name $A_sigma

    7.565723e-16        MKS

radiation density constant, 4 * sigma / c

This constant is also available using the short name $A_arad as well as the alternate name "A_RAD" (imported using the :alternate tag for backwards compatibility)

    2.897771955e-3      MKS

Wien wavelength displacement law constant

This constant is also available using the short name $A_Wien

    7.2973525693e-3     MKS

fine structure constant

This constant is also available using the short name $A_alpha

    376.730313461

characteristic impedance of vacuum

This constant is also available using the short name $A_Z0 as well as the alternate name "VACUUM_IMPEDANCE" (imported using the :alternate tag for backwards compatibility)

    8.8541878128e-12    MKS

permittivity of free space, epsilon_0, the electric constant

This constant is also available using the short name $A_eps0 as well as the alternate name "PERMITIVITY_0" (imported using the :alternate tag for backwards compatibility)

    1.25663706212e-6    MKS

permeability of free space, mu_0, the magnetic constant

This constant is also available using the short name $A_mu0 as well as these alternate names (imported using the :alternate tag): PERMEABILITY_0, CONSTANT_MAGNETIC

    3.14159265358979324

trig constant pi

This constant is also available using the short name $A_pi

    12.5663706143592

trig constant pi times 4 (shorthand for some calculations)

This constant is also available using the short name $A_4pi as well as the alternate name "FOURPI" (imported using the :alternate tag for backwards compatibility)

    3282.80635001174

a measure of solid angle in square degrees and a SI derived unit

This constant is also available using the short name $A_ster

    2.71828182846

base of natural logarithm

This constant is also available using the short name $A_exp

    1.66053906660e-27   MKS

unified atomic mass unit, 1 u

This constant is also available using the short name $A_amu

    3.08567758149e16    MKS

parsec

This constant is also available using the short name $A_pc

    149_597_870_700     MKS

astronomical unit

This constant is also available using the short name $A_AU

    9_460_730_472_580_800       MKS

the distance that light travels in vacuum in one Julian year

This constant is also available using the short name $A_ly

    1e-10       MKS

Angstrom

This constant is also available using the short name $A_AA

    1e-26       MKS

Jansky, a unit of flux density

This constant is also available using the short name $A_Jy

    6.02214076e23

Avogadro's number

This constant is also available using the short name $A_NA

    31_557_600

defined as exactly 365.25 days of 86400 SI seconds

This constant is also available using the short name $A_yr as well as the alternate name "YEAR_JULIAN" (imported using the :alternate tag for backwards compatibility)

    31_556_925.1

the period of time for the ecliptic longitude of the Sun to increase 360 degrees, approximated by the Gregorian calendar

    31_558_149.8

the period of revolution of the Earth around the Sun in a fixed reference frame

    31_558_432.6

the period between successive passages of the Earth through perihelion

    29_947_974.3

the period between successive passages of the Sun (as seen from the geocenter) through the same lunar node

    1.9884e30   MKS

solar mass

This constant is also available using the short name $A_msun as well as the alternate name "SOLAR_MASS" (imported using the :alternate tag for backwards compatibility)

    3.828e26    MKS

solar luminosity

This constant is also available using the short name $A_Lsun as well as the alternate name "SOLAR_LUMINOSITY" (imported using the :alternate tag for backwards compatibility)

    1.87834e-26 MKS

Critical Density parameter expressed in terms of <math>{ρ<sub>c</sub><over>h<sup>2</sup>} = {3 × (100 km s<sup>−1</sup> Mpc<sup>−1</sup>)<sup>2</sup> <over>8 π G}</math> Multiply by the square of the dimensionless Hubble parameter, h, in your calculations to get the actual value

This constant is also available using the short name $A_rhoc as well as the alternate name "RHO_C" (imported using the :alternate tag for backwards compatibility)

    3.0853056e17

Hubble time *h, the inverse of Hubble's constant valued at 100 km/s/Mpc (DEPRECATED - see ChangeLog)

This constant is also available using the short name $A_tH

    2.72548

cosmic microwave background temperature in Kelvin

This constant is also available using the short name $A_TCMB as well as the alternate name "CMB_TEMPERATURE" (imported using the :alternate tag for backwards compatibility)

    -26.74

visual brightness of the Sun

This constant is also available using the short name $A_Vsun as well as the alternate name "SOLAR_V_MAG" (imported using the :alternate tag for backwards compatibility)

    4.83

solar absolute V magnitude

This constant is also available using the short name $A_MVsun as well as the alternate name "SOLAR_V_ABS_MAG" (imported using the :alternate tag for backwards compatibility)

    6.96e8      MKS

solar radius

This constant is also available using the short name $A_rsun as well as the alternate name "SOLAR_RADIUS" (imported using the :alternate tag for backwards compatibility)

    5.9722e24   MKS

mass of Earth

This constant is also available using the short name $A_mearth as well as the alternate name "EARTH_MASS" (imported using the :alternate tag for backwards compatibility)

    6.378_136_6e6       MKS

radius of Earth

This constant is also available using the short name $A_rearth as well as the alternate name "EARTH_RADIUS" (imported using the :alternate tag for backwards compatibility)

    5772

surface temperature of sun (photosphere)

This constant is also available using the short name $A_Tsun as well as the alternate name "SOLAR_TEMPERATURE" (imported using the :alternate tag for backwards compatibility)

    1408        MKS

mean solar density

This constant is also available using the short name $A_dsun as well as the alternate name "SOLAR_DENSITY" (imported using the :alternate tag for backwards compatibility)

    5515        MKS

mean Earth density

This constant is also available using the short name $A_dearth as well as the alternate name "EARTH_DENSITY" (imported using the :alternate tag for backwards compatibility)

    274.78      MKS

solar surface gravity

This constant is also available using the short name $A_gsun as well as the alternate name "SOLAR_GRAVITY" (imported using the :alternate tag for backwards compatibility)

    9.80665     MKS

Earth surface gravity

This constant is also available using the short name $A_gearth as well as the alternate name "EARTH_GRAVITY" (imported using the :alternate tag for backwards compatibility)

    1.7381e6    MKS

lunar radius

This constant is also available using the short name $A_rmoon as well as the alternate name "LUNAR_RADIUS" (imported using the :alternate tag for backwards compatibility)

    7.346e22    MKS

lunar mass

This constant is also available using the short name $A_mmoon as well as the alternate name "LUNAR_MASS" (imported using the :alternate tag for backwards compatibility)

    3.84402e8   MKS

lunar orbital semi-major axis

This constant is also available using the short name $A_amoon as well as the alternate name "LUNAR_SM_AXIS" (imported using the :alternate tag for backwards compatibility)

    0.0549

lunar orbital eccentricity

This constant is also available using the short name $A_emoon as well as the alternate name "LUNAR_ECCENTRICITY" (imported using the :alternate tag for backwards compatibility)

    6.6524587321e-29    MKS

Thomson cross-section

This constant is also available using the short name $A_sigmaT as well as the alternate name "THOMSON_XSECTION" (imported using the :alternate tag for backwards compatibility)

    9.1093837015e-31    MKS

mass of electron

This constant is also available using the short name $A_me as well as the alternate name "ELECTRON_MASS" (imported using the :alternate tag for backwards compatibility)

    1.67262192369e-27   MKS

mass of proton

This constant is also available using the short name $A_mp as well as the alternate name "PROTON_MASS" (imported using the :alternate tag for backwards compatibility)

    1.67492749804e-27   MKS

neutron mass

This constant is also available using the short name $A_mn as well as the alternate name "NEUTRON_MASS" (imported using the :alternate tag for backwards compatibility)

    1.6738e-27

mass of Hydrogen atom -- This value is from the IUPAC and is a little smaller than MASS_PROTON + MASS_ELECTRON, but within the uncertainty given here. The current value is 1.008u +/- 0.0002 derived from a range of terrestrial materials. If this is for precision work, you had best understand what you're using. See https://iupac.org/what-we-do/periodic-table-of-elements/

This constant is also available using the short name $A_mH as well as the alternate name "HYDROGEN_MASS" (imported using the :alternate tag for backwards compatibility)

    6.6446573357e-27

mass of alpha particle

This constant is also available using the short name $A_ma

    2.8179403262e-15    MKS

classical electron radius

This constant is also available using the short name $A_re as well as the alternate name "ELECTRON_RADIUS" (imported using the :alternate tag for backwards compatibility)

    5.29177210903e-11   MKS

Bohr radius

This constant is also available using the short name $A_a0 as well as the alternate name "BOHR_RADIUS" (imported using the :alternate tag for backwards compatibility)

    69_911_000  MKS

Volumetric mean radius of Jupiter

This constant is also available using the short name $A_rjup

    1.89819e27  MKS

mass of Jupiter

This constant is also available using the short name $A_mjup

This is a helper function that rounds a value or list of values to 5 significant figures.

Give this method the string of the constant and it returns the precision or uncertainty listed.

  $rel_precision = precision('GRAVITATIONAL');
  $abs_precision = precision('MASS_EARTH');

At the moment you need to know whether the uncertainty is relative or absolute. Looking to fix this in future versions.

Nothing is exported by default, so the module doesn't clobber any of your variables. Select from the following tags:
  • ":long" (use this one to get the most constants)
  • ":short"
  • ":fundamental"
  • ":conversion"
  • ":mathematics"
  • ":cosmology"
  • ":planetary"
  • ":electromagnetic"
  • ":nuclear"
  • ":alternates"

I've gotten rid of "list_constants" and "describe_constants" because they are now in the documentation. Use "perldoc Astro::Constants" for that information.

  • Astro::Cosmology
  • Perl Data Language
  • NIST <http://physics.nist.gov>
  • Astronomical Almanac <http://asa.usno.navy.mil>
  • IAU 2015 Resolution B3 <http://iopscience.iop.org/article/10.3847/0004-6256/152/2/41/meta>
  • Neil Bower's review on providing read-only values <http://neilb.org/reviews/constants.html>
  • Test::Number::Delta
  • Test::Deep::NumberTolerant for testing values within objects

Reference Documents:

  • IAU 2009 system of astronomical constants <http://aa.usno.navy.mil/publications/reports/Luzumetal2011.pdf>
  • Astronomical Constants 2016.pdf <http://asa.usno.navy.mil/static/files/2016/Astronomical_Constants_2016.pdf>
  • IAU recommendations concerning units <https://www.iau.org/publications/proceedings_rules/units>
  • Re-definition of the Astronomical Unit <http://syrte.obspm.fr/IAU_resolutions/Res_IAU2012_B2.pdf>

* <https://github.com/duffee/Astro-Constants>

File issues/suggestions at the Github repository <https://github.com/duffee/Astro-Constants>. The venerable RT <https://rt.cpan.org/Dist/Display.html?Status=Active&Queue=Astro-Constants> is the canonical bug tracker that is clocked by meta::cpan <https://metacpan.org/pod/Astro::Constants>.

Using "strict" is a must with this code. Any constants you forgot to import will evaluate to 0 and silently introduce errors in your code. Caveat Programmer.

If you are using this module, drop me a line using any available means at your disposal, including *gasp* email (address in the Author section), to let me know how you're using it. What new features would you like to see? If you've had an experience with using the module, let other people know what you think, good or bad, by rating it at cpanratings <http://cpanratings.perl.org/rate/?distribution=Astro-Constants>.

If you want to add in your own constants or override the factory defaults, run make, edit the PhysicalConstants.xml file and then run "dzil build" again. If you have a pre-existing PhysicalConstants.xml file, drop it in place before running "dzil build".

the original astroconst sites have disappeared

I plan to deprecate the short names and change the order in which long names are constructed, moving to a noun_adjective format. LIGHT_SPEED and SOLAR_MASS become SPEED_LIGHT and MASS_SOLAR. This principle should make the code easier to read with the most important information coming at the beginning of the name.

(Gleaned from the Astroconst home page - astroconst.org <http://web.astroconst.org> )

Astroconst is a set of header files in various languages (currently C, Fortran, Perl, Java, IDL and Gnuplot) that provide a variety of useful astrophysical constants without constantly needing to look them up.

The generation of the header files from one data file is automated, so you can add new constants to the data file and generate new header files in all the appropriate languages without needing to fiddle with each header file individually.

This package was created and is maintained by Jeremy Bailin. It's license states that it is completely free, both as in speech and as in beer.

No warranty expressed or implied. This is free software. If you want someone to assume the risk of an incorrect value, you better be paying them.

(What would you want me to test in order for you to depend on this module?)

from Jeremy Bailin's astroconst header files

The Astroconst values have been gleaned from a variety of sources, and have quite different precisions depending both on the known precision of the value in question, and in some cases on the precision of the source I found it from. These values are not guaranteed to be correct. Astroconst is not certified for any use whatsoever. If your rocket crashes because the precision of the lunar orbital eccentricity isn't high enough, that's too bad.

Jeremy Balin, for writing the astroconst package and helping test and develop this module.

Doug Burke, for giving me the idea to write this module in the first place, tidying up Makefile.PL, testing and improving the documentation.

Boyd Duffee <duffee@cpan.org>

This software is copyright (c) 2018 by Boyd Duffee.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

2020-04-19 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.