dsmc- DSMC library for rarefied gas dynamics

Safe HaskellNone




Macroscopic parameters calculation.

We use regular spatial grid and time averaging for sampling. Sampling should start after particle system has reached steady state. Samples are then collected in each cell for a certain number of time steps.

Sampling is performed in MacroSamplingMonad to ensure consistency of averaging process. During sampling, basic parameters are calculated like number of molecules per cell or mean square of thermal velocity. After sampling these are used to derive final (intensive) parameters like number density or temperature.



type MacroSamples = Array U DIM1 BasicMacroParametersSource

Vector which stores averaged macroscropic parameters in each cell.

If samples are collected for M iterations, then this vector is built as a sum of vectors V1, .. VM, where Vi is vector of parameters sampled on i-th time step divided by M.

type MacroField = Array U DIM1 (Point, IntensiveMacroParameters)Source

Array of central points of grid cells with averaged macroscopic parameters attached to every point.

type BasicMacroParameters = (Double, Vec3, Double)Source

Basic macroscopic parameters calculated in every cell: particle count, mean absolute velocity, mean square of thermal velocity.

Particle count is non-integer because of averaging.

These are then post-processed into number density, flow velocity, pressure and translational temperature.

Note the lack of root on thermal velocity!

type IntensiveMacroParameters = (Double, Vec3, Double, Double)Source

Intensive macroscopic parameters available after averaging has completed. These are: number density, absolute velocity, pressure and translational temperature.

Macroscopic sampling monad

type MacroSamplingMonad = StateT SamplingState (ReaderT Int GridMonad)Source

Monad which keeps track of sampling process data and stores options of macroscopic sampling.

GridMonad is used to ensure that only safe values for cell count and classifier are used in updateSamples and averageSamples (that may otherwise cause unbounded access errors). Note that steady condition is not handled by this monad (instead, caller code should decide when to start averaging).

Inner Reader Monad stores averaging steps setting.

data SamplingState Source

State of sampling process.



Sampling has not started yet.

Incomplete Int MacroSamples

Sampling is in progress, not enough samples yet. Integer field indicates how many steps are left.

Complete MacroSamples

Averaging is complete, use getField to unload the samples.



:: MacroSamplingMonad r 
-> ParallelSeeds 
-> Grid

Grid used to sample macroscopic parameters.

-> Body 
-> Int

Use that many points to approximate every cell volume.

-> Int

Averaging steps count.

-> DSMCRootMonad (r, SamplingState) 

Run MacroSamplingMonad action with given sampling options and return final Complete state with macroscopic samples.

updateSamples :: Ensemble -> MacroSamplingMonad BoolSource

Gather samples from ensemble. Return True if sampling is finished, False otherwise.



:: Double

Mass of molecule.

-> Double

Statistical weight of single molecule.

-> MacroSamplingMonad (Maybe MacroField) 

Fetch macroscopic field of intensive parameters if averaging is complete.