Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Move all modules into structure, even candidates for culling.

  • Loading branch information...
commit 07bd952149ed14ea701cdfa58c418a1d15772c44 1 parent af1b7f6
@bjornbm authored
View
2  AD.hs → Numeric/Units/Dimensional/AD.hs
@@ -3,7 +3,7 @@
{-# LANGUAGE ExistentialQuantification #-}
{-# LANGUAGE Rank2Types #-}
-module AD (diff, Lift (lift)) where
+module Numeric.Units.Dimensional.AD (diff, Lift (lift)) where
import Numeric.Units.Dimensional (Dimensional (Dimensional), Quantity, Div)
import Numeric.AD (AD, Mode)
View
53 Numeric/Units/Dimensional/Constants.hs
@@ -0,0 +1,53 @@
+module Numeric.Units.Dimensional.Constants where
+
+import Numeric.Units.Dimensional.Prelude
+import Numeric.NumType (Neg3, Neg2, Neg1, Zero, Pos1, Pos2, Pos3)
+import qualified Prelude
+
+-- Dim l m t i th n j
+
+-- Physics handbook p12
+-- Empty Space
+speedOfLight :: Fractional a => Velocity a
+speedOfLight = 2.99792458e8 *~ (meter / second) -- in vacuum.
+permeability :: Floating a => Permeability a
+permeability = 4e-7 *~ (volt * second / ampere / meter) * pi
+permittivity :: Floating a => Permittivity a
+permittivity = permeability^neg1 * speedOfLight^neg2
+
+-- Gravitation
+gravitationalConstant :: Fractional a => Quantity (Dim Pos3 Neg1 Neg2 Zero Zero Zero Zero) a
+gravitationalConstant = 6.67259e-11 *~ (newton * meter^pos2 / kilo gram^pos2)
+
+-- Particle Masses
+electronMass :: Fractional a => Mass a
+electronMass = 9.109390e-31 *~ kilo gram
+
+-- Physics handbook p13
+elementaryCharge :: Fractional a => ElectricCharge a
+elementaryCharge = 1.6021773e-19 *~ coulomb
+
+-- Physics handbook p14
+planck :: Fractional a => Quantity (Dim Pos2 Pos1 Neg1 Zero Zero Zero Zero) a
+planck = 6.626076e-34 *~ (joule * second)
+rydberg :: Floating a => WaveNumber a
+rydberg = electronMass * elementaryCharge^pos4 / (_8 * permittivity^pos2 * planck^pos3 * speedOfLight)
+boltzmann :: Fractional a => Entropy a
+boltzmann = 1.38066e-23 *~ (joule / kelvin)
+
+-- Dim l m t i th n j
+
+-- Physics handbook p15
+planckLength :: Fractional a => Length a
+planckLength = 1.616e-35 *~ meter
+planckMass :: Fractional a => Mass a
+planckMass = 2.177e-8 *~ kilo gram
+planckTime :: Fractional a => Time a
+planckTime = 5.391e-44 *~ second
+planckTemperature :: Fractional a => ThermodynamicTemperature a
+planckTemperature = 1.417e-32 *~ kelvin
+
+avogrado :: Fractional a => Quantity (Dim Zero Zero Zero Zero Zero Neg1 Zero) a
+avogrado = 6.022137e23 *~ mole^neg1
+molarGasConstant :: Fractional a => MolarEntropy a
+molarGasConstant = boltzmann * avogrado
View
57 Numeric/Units/Dimensional/Formulae.hs
@@ -0,0 +1,57 @@
+module Numeric.Units.Dimensional.Formulae where
+
+import Numeric.Units.Dimensional.Prelude
+import Numeric.Units.Dimensional.Constants
+import qualified Prelude
+
+
+-- | @dewPoint temperature relativeHumidity@ calculates the dew point
+-- based on the August-Roche-Magnus approximation vapor pressure
+-- of water in air as a function of temperature. It is considered
+-- to have an 1-sigma uncertainty less of 0.4 °C for:
+-- 0 °C < temperature < 60 °C,
+-- 0.01 < relativeHumidity < 1,
+-- 0 °C < dewPoint t rh < 50 °C.
+--
+-- Reference: @http://www.paroscientific.com/dewpoint.htm@
+dewPoint :: Floating a => ThermodynamicTemperature a -> Dimensionless a -> ThermodynamicTemperature a
+dewPoint t rh = b * gamma t rh / (a - gamma t rh)
+ where
+ gamma t rh = a * t / (b + t) + log rh
+ a = 17.27 *~ one
+ b = 237.7 *~ degreeCelsius
+
+
+-- Arrhenius equation
+-- ------------------
+-- | @arrheniusEquation e t@ is a variation of Arrhenius equation
+-- giving the ratio of collisions exceeding the activation energy @e@
+-- (joules per mole) to the total number of collisions in a medium at
+-- a temperature @t@.
+arrheniusEquation :: Floating a => MolarEnergy a -> ThermodynamicTemperature a -> Dimensionless a
+arrheniusEquation e t = exp (negate e / (molarGasConstant * t))
+
+-- | @arrheniusEquation' e t@ is a variation of Arrhenius equation
+-- giving the ratio of collisions exceeding the activation energy @e@
+-- (joules per molecule) to the total number of collisions in a medium
+-- at a temperature @t@.
+arrheniusEquation' :: Floating a => Energy a -> ThermodynamicTemperature a -> Dimensionless a
+arrheniusEquation' e t = exp (negate e / (boltzmann * t))
+
+-- | Activation energy per mole given two samples of temperature and rate.
+activationEnergy :: Floating a
+ => (ThermodynamicTemperature a, Dimensionless a)
+ -> (ThermodynamicTemperature a, Dimensionless a)
+ -> MolarEnergy a
+activationEnergy (t1, k1) (t2, k2) = negate molarGasConstant * (log k2 - log k1) / (t2^neg1 - t1^neg1)
+
+-- | Activation energy per molecule given two samples of temperature and rate.
+activationEnergy' :: Floating a
+ => (ThermodynamicTemperature a, Dimensionless a)
+ -> (ThermodynamicTemperature a, Dimensionless a)
+ -> Energy a
+activationEnergy' (t1, k1) (t2, k2) = negate boltzmann * (log k2 - log k1) / (t2^neg1 - t1^neg1)
+
+-- | @http://en.wikipedia.org/wiki/Calorie@
+thermochemicalCalorie :: Fractional a => Unit DEnergy a
+thermochemicalCalorie = prefix 4.184 joule
View
5 PosVel.lhs → Numeric/Units/Dimensional/LinearAlgebra/PosVel.lhs
@@ -4,14 +4,13 @@ The convention in this module is that a @C@ denotes cartesian coordinates and an
> {-# OPTIONS_GHC -fglasgow-exts #-}
> {-# LANGUAGE Haskell98 #-}
-> module PosVel where
+> module Numeric.Units.Dimensional.LinearAlgebra.PosVel where
> import qualified Prelude
> import Numeric.Units.Dimensional.Prelude
> import Numeric.Units.Dimensional (Dimensional (Dimensional))
> import Numeric.Units.Dimensional.LinearAlgebra
-> import Data.HList
-> import VectorAD (applyLinear)
+> import Numeric.Units.Dimensional.LinearAlgebra.VectorAD (applyLinear)
Type synonyms for clearer documentation.
View
3  Rotation.hs → Numeric/Units/Dimensional/LinearAlgebra/Rotation.hs
@@ -1,8 +1,7 @@
{-# LANGUAGE TypeOperators #-}
-module Rotation where
+module Numeric.Units.Dimensional.LinearAlgebra.Rotation where
-import Data.HList ((:*:))
import Numeric.Units.Dimensional.Prelude
import Numeric.Units.Dimensional.LinearAlgebra
import qualified Prelude
View
4 VectorAD.hs → Numeric/Units/Dimensional/LinearAlgebra/VectorAD.hs
@@ -1,6 +1,6 @@
{-# OPTIONS_GHC -fglasgow-exts #-}
-module VectorAD where
+module Numeric.Units.Dimensional.LinearAlgebra.VectorAD where
import qualified Prelude
import Data.HList (HMap)
@@ -10,7 +10,7 @@ import Numeric.Units.Dimensional.LinearAlgebra.Vector (Vec (ListVec), MulD, DivD
import Numeric.Units.Dimensional.LinearAlgebra.HListExtras (HZipWith)
import Numeric.AD (AD, diffF', Mode)
import qualified Numeric.AD (lift)
-import AD
+import Numeric.Units.Dimensional.AD
-- | If @f@ is a function of a quantity that returns a 'Vector', then
View
12 dimensional-experimental.cabal
@@ -1,5 +1,5 @@
Name: dimensional-experimental
-Version: 0.1
+Version: 0.3
License: BSD3
License-File: LICENSE
Copyright: Bjorn Buckwalter 2008-2011
@@ -32,10 +32,12 @@ Build-Depends:
Exposed-Modules:
- AD,
- VectorAD,
- PosVel,
- Rotation
+ Numeric.Units.Dimensional.AD
+ Numeric.Units.Dimensional.Constants
+ Numeric.Units.Dimensional.Formulae
+ Numeric.Units.Dimensional.LinearAlgebra.VectorAD
+ Numeric.Units.Dimensional.LinearAlgebra.Rotation
+ Numeric.Units.Dimensional.LinearAlgebra.PosVel
Extra-source-files: README, LICENSE
View
2  examples/G19.hs
@@ -1,6 +1,6 @@
import Numeric.Units.Dimensional.Prelude
import Numeric.Units.Dimensional.LinearAlgebra
-import Rotation
+import Numeric.Units.Dimensional.LinearAlgebra.Rotation
import qualified Prelude
Please sign in to comment.
Something went wrong with that request. Please try again.