packages feed

ZEBEDDE-0.1.0.0: ZEBEDDE/Core/Molecule.lhs

\section{Atoms and Molecules}

> module ZEBEDDE.Core.Molecule (Atom,
>                              	element,
>                               mass,
>                              	position,
>                               doToAtom,
>                               Molecule,
>                               name,
>                               basis,
>                               atoms,
>                               newMolecule,
>                               doToMolecule,
>                               doToMolecule') where


> import ZEBEDDE.Core.Vector

\subsection{Atoms}

An atom has a name, a molecular weight and a position. 

> type Atom = (String,Int,Vec)       

Access elements of an atom.

> element    :: Atom -> String
> element    (a,_,_) = a

> mass     :: Atom -> Int
> mass     (_,b,_) = b

> position :: Atom -> Vec
> position (_,_,c) = c

Apply function to the vector component of an atom.

> doToAtom f (string,mass,vec) = (string,mass,f vec)

\subsection{Molecule}
Create molecule strucure, \\ 3 vecorts specifying location and orientation \\ and it is a name and a list of atoms.

> type Basis = (Vec,Vec,Vec)
> type Molecule = (String,Basis,[Atom])
> name  (n,_,_) = n
> basis (_,b,_) = b
> atoms (_,_,a) = a

> getBasis :: [Atom] -> Basis
> getBasis atoms = (position (atoms!!0),position (atoms!!1),position (atoms!!2))
> newMolecule name atoms = (name,getBasis atoms,atoms) 

Apply a function to the atoms of the molecule.

> doToMolecule :: ([Atom] -> [Atom]) -> Molecule -> Molecule
> doToMolecule f  (string,axis,atoms) =  newMolecule string (f atoms)

Apply a function to each of the positions of the atoms of the molecule. 

> doToMolecule' :: (Vec -> Vec) -> (Molecule -> Molecule)
> doToMolecule' f   =  doToMolecule (map (doToAtom f))