pulsar/src/Material.hs

31 lines
1.3 KiB
Haskell

{-# LANGUAGE NoImplicitPrelude #-}
module Material where
import Numeric.Units.Dimensional.Prelude
{- |
The Material Module and data-type present the physical properties of materials, for use in items, structures, etc
-}
-- All temperature points are assumed to be STP, and should be given in Kelvin
data Material = Material {
name :: String,
meltingPoint :: ThermodynamicTemperature Double, --Solid to liquid or vice versa
boilingPoint :: ThermodynamicTemperature Double, --Liquid to vapour or vice versa
tensileStength :: Pressure Integer, --This is going to be in MPa, so no point keeping fractions around
compressiveStrength :: Pressure Integer,
density :: Density Double
} deriving (Show, Eq)
freezingPoint :: Material -> ThermodynamicTemperature Double
freezingPoint = meltingPoint
condensationPoint :: Material -> ThermodynamicTemperature Double
condensationPoint = boilingPoint
defaultMaterial :: Material
defaultMaterial = Material "Default" (10000 *~ kelvin) (100000 *~ kelvin) (100 *~ mega pascal) (100 *~ mega pascal) (100 *~ (kilo gram / cubic meter))
genMaterial :: String -> Double -> Double -> Integer -> Integer -> Double -> Material
genMaterial n mp bp ts cs d = Material n (mp *~ kelvin) (bp *~ kelvin) (ts *~ mega pascal) (cs *~ mega pascal) (d *~ (kilo gram / cubic meter))