Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #65 from MaksimZh/constants

Constants
  • Loading branch information...
commit afb00fa3333f9e3560c405436b21e685db553c8e 2 parents 27ea1e6 + 0d1b539
@cristicbz authored
View
20 scid/constants/cgs/additional.d
@@ -0,0 +1,20 @@
+/** Contains some useful constants
+ *
+ * $(DDOC_SECTION_H System of units:) symmetric CGS
+ * Origin: $(LINK2 http://physics.nist.gov/cuu/index.html,
+ * The NIST Reference on Constants, Units, and Uncertainty)
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Version: alpha
+ *
+ */
+
+module scid.constants.cgs.additional;
+
+// TODO: should this go to units modules?
+/// Atomic mass constant [g]
+enum double ATOMIC_MASS = 1.660_538_921e-24;
+enum double D_ATOMIC_MASS = 0.000_000_073e-24; /// Standard uncertainty
+
+/// Bohr magneton [erg / G]
+enum double BOHR_MAGNETON = 9.274_009_68e-25;
+enum double D_BOHR_MAGNETON = 0.000_000_20e-25; /// Standard uncertainty
View
42 scid/constants/cgs/basic.d
@@ -0,0 +1,42 @@
+/** Contains fundamental and other widely used constants
+ *
+ * $(DDOC_SECTION_H System of units:) symmetric CGS
+ * Origin: $(LINK2 http://physics.nist.gov/cuu/index.html,
+ * The NIST Reference on Constants, Units, and Uncertainty)
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Version: alpha
+ *
+ */
+
+module scid.constants.cgs.basic;
+
+/// Newtonian constant of gravitation, [cm^3 / (g * s^2)]
+enum double GRAVITY = 6.673_84e-8;
+enum double U_GRAVITY = 0.000_80e-8; /// Standard uncertainty
+
+/// Speed of light in vacuum [cm / s]
+enum double SPEEDLIGHT = 2.997_924_58e+10;
+
+/// Planck constant [erg * s]
+enum double PLANCK = 6.626_069_57e-27;
+enum double D_PLANCK = 0.000_000_29e-27; /// Standard uncertainty
+
+/// Planck constant over 2*pi [erg * s]
+enum double PLANCK_2PI = 1.054_571_726e-27;
+enum double D_PLANCK_2PI = 0.000_000_047e-27; /// Standard uncertainty
+
+/// Elementary charge [statC]
+enum double ECHARGE = 4.803_204_25e-10;
+enum double D_ECHARGE = 0.000_000_10e-10; /// Standard uncertainty
+
+/// Fine-structure constant
+enum double FINE_STRUCT = 7.297_352_5698e-3;
+enum double D_FINE_STRUCT = 0.000_000_0024e-3; /// Standard uncertainty
+
+/// Avogadro constant
+enum double AVOGADRO = 6.022_141_29e+23;
+enum double D_AVOGADRO = 0.000_000_27e+23; /// Standard uncertainty
+
+/// Boltzman constant [erg]
+enum double BOLTZMAN = 1.380_6488e-16;
+enum double D_BOLTZMAN = 0.000_0013e-16; /// Standard uncertainty
View
23 scid/constants/cgs/particles.d
@@ -0,0 +1,23 @@
+/** Contains characteristics of elementary particles
+ *
+ * $(DDOC_SECTION_H System of units:) symmetric CGS
+ * Origin: $(LINK2 http://physics.nist.gov/cuu/index.html,
+ * The NIST Reference on Constants, Units, and Uncertainty)
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Version: alpha
+ *
+ */
+
+module scid.constants.cgs.particles;
+
+/// Electron characteristics
+enum ELECTRON : double
+{
+ /// g-factor
+ GFACTOR = -2.002_319_304_361_53,
+ D_GFACTOR = 0.000_000_000_000_53, /// Standard uncertainty
+
+ /// Mass [g]
+ MASS = 9.109_382_91e-28,
+ D_MASS = 0.000_000_40e-28 /// Standard uncertainty
+}
View
53 scid/constants/math.d
@@ -0,0 +1,53 @@
+/** Contains frequently used mathematical constants.
+ * There are constants imported directly from std.math and some of them are
+ * renamed.
+ *
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Version: alpha
+ *
+ * Macros:
+ * SQRT = √
+ */
+
+module scid.constants.math;
+
+public import std.math :
+ EXP1 = E,
+ LOG2T,
+ LOG2E,
+ LOG2,
+ LOG10E,
+ LN2,
+ LN10,
+ PI,
+ PI_2,
+ PI_4,
+ M_1_PI,
+ M_2_PI,
+ M_2_SQRTPI,
+ SQRT2,
+ SQRT1_2;
+
+/* Values obtained from Wolfram Alpha.
+ * Wolfram Alpha LLC. 2011. Wolfram|Alpha.
+ * http://www.wolframalpha.com/input/?i=e+in+base+16
+ * (access Nov 3, 2011).
+ */
+/** Square roots of small numbers
+ */
+enum SQRT : real
+{
+ _2 = SQRT2, /// $(SQRT)2
+ _3 = 0x1.bb67ae8584caa73b25742d7078b84p+0L, /// $(SQRT)3
+ _5 = 0x1.1e3779b97f4a7c15f39cc0605cedcp+1L, /// $(SQRT)5
+ _6 = 0x1.3988e1409212e7d0321914321a556p+1L, /// $(SQRT)6
+ _7 = 0x1.52a7fa9d2f8e9b78e753f30fe1bd1p+1L, /// $(SQRT)7
+ _10 = 0x1.94c583ada5b529204a2bc830cd9c0p+1L, /// $(SQRT)10
+
+ _1_2 = SQRT1_2, /// $(SQRT)1/2
+ _1_3 = 0x1.279a74590331c4d218f81e4afb258p-1L, /// $(SQRT)1/3
+ _1_5 = 0x1.c9f25c5bfedd93565294670094afap-2L, /// $(SQRT)1/5
+ _1_6 = 0x1.a20bd700c2c3dfc042cc1aed7871ep-2L, /// $(SQRT)1/6
+ _1_7 = 0x1.83091e6a7f7e688a2cf23a5b4b213p-2L, /// $(SQRT)1/7
+ _1_10 = 0x1.43d136248490edb36e896cf3d7b00p-2L /// $(SQRT)1/10
+}
View
13 scid/constants/si/additional.d
@@ -0,0 +1,13 @@
+/** Contains some useful constants
+ *
+ * $(DDOC_SECTION_H System of units:) symmetric SI
+ * Origin: $(LINK2 http://physics.nist.gov/cuu/index.html,
+ * The NIST Reference on Constants, Units, and Uncertainty)
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Version: alpha
+ *
+ */
+
+module scid.constants.si.additional;
+
+// TODO
View
13 scid/constants/si/basic.d
@@ -0,0 +1,13 @@
+/** Contains fundamental and other widely used constants
+ *
+ * $(DDOC_SECTION_H System of units:) symmetric SI
+ * Origin: $(LINK2 http://physics.nist.gov/cuu/index.html,
+ * The NIST Reference on Constants, Units, and Uncertainty)
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Version: alpha
+ *
+ */
+
+module scid.constants.si.basic;
+
+// TODO
View
79 scid/constants/si/particles.d
@@ -0,0 +1,79 @@
+/** Contains characteristics of elementary particles
+ *
+ * $(DDOC_SECTION_H System of units:) symmetric SI
+ * Origin: $(LINK2 http://physics.nist.gov/cuu/index.html,
+ * The NIST Reference on Constants, Units, and Uncertainty)
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Version: alpha
+ *
+ */
+
+module scid.constants.si.particles;
+
+/// Electron characteristics
+enum ELECTRON : double
+{
+ /// Charge to mass quotient [C / kg]
+ CHARGE_TO_MASS = -1.758_820_088e+11,
+ D_CHARGE_TO_MASS = 0.000_000_039e+11, /// Standard uncertainty
+
+ /// Compton wavelength [m]
+ COMPTONWL = 2.426_310_2389e-12,
+ D_COMPTONWL = 0.000_000_0016e-12, /// Standard uncertainty
+
+ /// g-factor
+ GFACTOR = -2.002_319_304_361_53,
+ D_GFACTOR = 0.000_000_000_000_53, /// Standard uncertainty
+
+ /// Magnetic momentum [J / T]
+ MAG_MOM = -9.284_764_30e-24,
+ D_MAG_MOM = 0.000_000_21e-24, /// Standard uncertainty
+
+ /// Mass [kg]
+ MASS = 9.109_382_91e-31,
+ D_MASS = 0.000_000_40e-31 /// Standard uncertainty
+}
+
+/// Proton characteristics
+enum PROTON : double
+{
+ /// Charge to mass quotient [C / kg]
+ CHARGE_TO_MASS = 9.578_833_58e+7,
+ D_CHARGE_TO_MASS = 0.000_000_21e+7, /// Standard uncertainty
+
+ /// Compton wavelength [m]
+ COMPTONWL = 1.321_409_856_23e-15,
+ D_COMPTONWL = 0.000_000_000_94e-15, /// Standard uncertainty
+
+ /// g-factor
+ GFACTOR = 5.585_694_713,
+ D_GFACTOR = 0.000_000_046, /// Standard uncertainty
+
+ /// Magnetic momentum [J / T]
+ MAG_MOM = 1.410_606_743e-26,
+ D_MAG_MOM = 0.000_000_033e-26, /// Standard uncertainty
+
+ /// Mass [kg]
+ MASS = 1.672_621_777e-27,
+ D_MASS = 0.000_000_074e-27 /// Standard uncertainty
+}
+
+/// Neutron characteristics
+enum NEUTRON : double
+{
+ /// Compton wavelength [m]
+ COMPTONWL = 1.319_590_9068e-15,
+ D_COMPTONWL = 0.000_000_0011e-15, /// Standard uncertainty
+
+ /// g-factor
+ GFACTOR = -3.826_085_45,
+ D_GFACTOR = 0.000_000_90, /// Standard uncertainty
+
+ /// Magnetic momentum [J / T]
+ MAG_MOM = -0.966_236_47e-26,
+ D_MAG_MOM = 0.000_000_23e-26, /// Standard uncertainty
+
+ /// Mass [kg]
+ MASS = 1.674_927_351e-27,
+ D_MASS = 0.000_000_074e-27 /// Standard uncertainty
+}
View
224 scid/constants/units/basic.d
@@ -0,0 +1,224 @@
+/** Contains conversion coefficients for units.
+ *
+ * Origin: $(LINK2 http://physics.nist.gov/cuu/index.html,
+ * The NIST Reference on Constants, Units, and Uncertainty),
+ * Wikipedia
+ *
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Version: alpha
+ *
+ * Exmaples:
+ * ----------
+ * LengthInMeters = LengthInAngstroms * ANGSTROM.METER;
+ * ----------
+ *
+ * _PS postfix means "per second" $(BR)
+ * _PM postfix means "per meter"
+ */
+
+module scid.constants.units.basic;
+
+private
+{
+ import std.math;
+ import scid.constants.cgs.basic;
+}
+
+//------------------------------------------------------------------------------
+// Length units
+public
+{
+
+/** Standard lenght unit in SI.
+ *
+ * Conversion coefficients are available for:
+ */
+enum METER : double
+{
+ ANGSTROM = 1e10 ///
+}
+
+/** Standard lenght unit in CGS.
+ *
+ * Conversion coefficients are available for:
+ */
+enum CENTIMETER : double
+{
+ ANGSTROM = 1e8 ///
+}
+
+/** Lenght unit.
+ *
+ * Conversion coefficients are available for:
+ */
+enum ANGSTROM : double
+{
+ METER = 1e-10, ///
+ CENTIMETER = 1e-8 /// ditto
+}
+
+}
+
+//------------------------------------------------------------------------------
+// Energy units
+public
+{
+
+/** Standard energy unit in SI.
+ *
+ * Conversion coefficients are available for:
+ */
+enum JOULE : double
+{
+ ERG = 1e7, ///
+ ELECTRONVOLT = 6.241_509_343e+18, /// ditto
+ MILLIELECTRONVOLT = 6.241_509_343e+15 /// ditto
+}
+
+/** Standard energy unit in CGS.
+ *
+ * Conversion coefficients are available for:
+ */
+enum ERG : double
+{
+ JOULE = 1e-7, ///
+ ELECTRONVOLT = 6.241_509_343e+11, /// ditto
+ MILLIELECTRONVOLT = 6.241_509_343e+8 /// ditto
+}
+
+/** Energy unit.
+ *
+ * Conversion coefficients are available for:
+ */
+enum ELECTRONVOLT : double
+{
+ JOULE = 1.602_176_565e-19, ///
+ ERG = 1.602_176_565e-12, /// ditto
+}
+
+}
+
+//------------------------------------------------------------------------------
+// Electric charge units
+public
+{
+
+/** Standard electric charge unit in SI.
+ *
+ * Conversion coefficients are available for:
+ */
+enum COULOMB : double
+{
+ STATCOULOMB = SPEEDLIGHT * 1e-1 ///
+}
+
+/** Standard electric charge unit in CGS.
+ *
+ * Conversion coefficients are available for:
+ */
+enum STATCOULOMB : double
+{
+ COULOMB = 1e1 / SPEEDLIGHT ///
+}
+
+}
+
+//------------------------------------------------------------------------------
+// Electric current units
+public
+{
+
+/** Standard electric current unit in SI.
+ *
+ * Conversion coefficients are available for:
+ */
+enum AMPERE : double
+{
+ STATC_PS = COULOMB.STATCOULOMB ///
+}
+
+/** Standard electric current unit in CGS.
+ *
+ * Conversion coefficients are available for:
+ */
+enum STATC_PS : double
+{
+ AMPERE = STATCOULOMB.COULOMB ///
+}
+
+}
+
+//------------------------------------------------------------------------------
+// Electric voltage units
+public
+{
+
+/** Standard electric voltage unit in SI.
+ *
+ * Conversion coefficients are available for:
+ */
+enum VOLT : double
+{
+ STATVOLT = STATCOULOMB.COULOMB * 1e9 ///
+}
+
+/** Standard electric voltage unit in CGS.
+ *
+ * Conversion coefficients are available for:
+ */
+enum STATVOLT : double
+{
+ VOLT = COULOMB.STATCOULOMB * 1e-9 ///
+}
+
+}
+
+//------------------------------------------------------------------------------
+// Magnetic induction units
+public
+{
+
+/** Standard magnetic induction unit in SI.
+ *
+ * Conversion coefficients are available for:
+ */
+enum TESLA : double
+{
+ GAUSS = 1e4 ///
+}
+
+/** Standard magnetic induction unit in CGS.
+ *
+ * Conversion coefficients are available for:
+ */
+enum GAUSS : double
+{
+ TESLA = 1e-4 ///
+}
+
+}
+
+//------------------------------------------------------------------------------
+// Magnetic field strength units
+public
+{
+
+/** Standard magnetic field strength unit in SI.
+ *
+ * Conversion coefficients are available for:
+ */
+enum AMPER_PM : double
+{
+ OERSTED = PI * 4e3 ///
+}
+
+/** Standard magnetic field strength unit in CGS.
+ *
+ * Conversion coefficients are available for:
+ */
+enum OERSTED : double
+{
+ AMPER_PM = 2.5e-4 / PI ///
+}
+
+}
View
41 scid/constants/units/siprefixes.d
@@ -0,0 +1,41 @@
+/** Contains SI prefixes for multiple and submultiple units.
+ *
+ * Origin: Wikipedia
+ *
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Version: alpha
+ *
+ * Exmaples:
+ * ----------
+ * TimeInPicoseconds = TimeInSeconds / PREFIX.PICO;
+ * ----------
+ *
+ */
+
+module scid.constants.units.siprefixes;
+
+/// SI prefixes
+enum PREFIX : double
+{
+ YOTTA = 1e24, /// Multiple prefixes
+ ZETTA = 1e21, /// ditto
+ EXA = 1e18, /// ditto
+ PETA = 1e15, /// ditto
+ TERA = 1e12, /// ditto
+ GIGA = 1e9, /// ditto
+ MEGA = 1e6, /// ditto
+ KILO = 1e3, /// ditto
+ HECTO = 1e2, /// ditto
+ DECA = 1e1, /// ditto
+
+ DECI = 1e-1, /// Submultiple prefixes
+ CENTI = 1e-2, /// ditto
+ MILLI = 1e-3, /// ditto
+ MICRO = 1e-6, /// ditto
+ NANO = 1e-9, /// ditto
+ PICO = 1e-12, /// ditto
+ FEMTO = 1e-15, /// ditto
+ ATTO = 1e-18, /// ditto
+ ZEPTO = 1e-21, /// ditto
+ YOCTO = 1e-24 /// ditto
+}
Please sign in to comment.
Something went wrong with that request. Please try again.