Skip to content

A library to interface with Magboltz (Boltzmann transport equation solver for gas mixtures)

Notifications You must be signed in to change notification settings

SciNim/NimBoltz

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NimBoltz

A simple interfacer to MagBoltz, a program that solves the Boltzmann transport equations for electrons in gas mixtures given external electric and magnetic fields. It is one of the most fundamental programs in gaseous detector physics to simulate properties of gases used in gaseous detectors.

It requires magboltz as a binary somewhere in your PATH. See Installing Magboltz below if you’re unsure about how.

What this library allows you to do is to avoid having to manually write the extremely pedantic Magboltz input files. An example for a Magboltz input looks as follows:

2         1         1         1         0.00000   
2    11   80   80   80   80   
97.7000   2.3000    0.0000    0.0000    0.0000    0.0000    26.8500   787.5648  
60000.000 0.000     0.000     
0         0         0         0         0.00000   

Nice right?

Further, if you define multiple gas mixtures / settings this library will run multiple Magboltz processes for you in parallel, so you don’t have to manually start N processes each with their own input and output file names. The file names are created based on the used parameters.

Using this library

Of interest is mainly the initMagboltz procedure:

proc initMagboltz*[F: SomeUnit, P: Pressure](
  gases: seq[Gas], pressure: P, temp: Kelvin, E: F,
  nMax: int,
  usePenning = true, gasMotionThermal = true,
  B: Tesla = 0.T,
  Bθ: Degree = 0.°,
  eFinal = 0.0,
  outpath = "resources"
                                          ): Magboltz

with which you construct a Magboltz object, which stores the gases and settings for a calculation. The gases come from either initGas or initGases:

proc initGas*(id: int, fraction: float): Gas =
  let gM = getGas(id)
  result = Gas(name: gM.name, id: gM.id, frac: fraction)

proc initGas*(name: string, fraction: float): Gas =
  let gM = getGas(name)
  result = Gas(name: gM.name, id: gM.id, frac: fraction)

proc initGases*[T: int | string](gases: varargs[(T, float)]): seq[Gas] =
  for arg in gases:
    result.add initGas(arg[0], arg[1])

where as you can see we either allow to take the Magboltz IDs for the gases as listed in #sec:available_gases below or their names. The names as strings are case insensitive.

Once a Magboltz object is defined all you need to do is run runMagboltz and it will call Magboltz for you. All files will be stored in the outpath directory as given to initMagboltz.

If you wish to run multiple processes in parallel, simply call runMagboltz with an array / seq input.

So for example:

import nimboltz
let gases = initGases([("argon", 97.7), ("isobutane", 2.3)])
let mb = initMagboltz(gases, 1050.mbar, 300.K, 60.kV•cm⁻¹, nMax = 10,
                      usePenning = true, gasMotionThermal = true)
# to run a single calculation:
# runMagboltz(mb)
# to run multiple in parallel:
var mb1 = mb # to keep modifying it simple, we just copy...
var mb2 = mb
var mb3 = mb
var mb4 = mb
mb1.temp = 300.K # ... and reassign what we want changed
mb2.temp = 330.K
mb3.temp = 360.K
mb4.temp = 390.K
let mbs = [mb1, mb2, mb3, mb4]
runMagboltz(mbs)

In the future this will likely also provide some basic parsing of the Magboltz output files, but not today.

Installing Magboltz

Download the Magboltz source code from here:

https://magboltz.web.cern.ch/magboltz/

Assuming you are on a Unix system, you might want to do:

cd ~
mkdir -p src/Magboltz # for example for source code you compile
cd src/Magboltz
wget https://magboltz.web.cern.ch/magboltz/magboltz-11.17.f # for latest version as of writing
gfortran -O3 -o magboltz magboltz-11.17.f

which downloads and compiles Magboltz with optimizations enabled.

Then you should make sure to add ~/src/Magboltz to your PATH, by adding

export PATH=$PATH:$HOME/src/Magboltz

to your ~/.bashrc, ~/.zshrc or wherever you store your terminal configurations.

After starting a new terminal Magboltz should be available as magboltz from any directory.

Available Magboltz gases

RoutineGasLast updateNotesStar rating
GAS1CF42001anisotropic scattering5*
GAS2Argon19975*
GAS3Helium 419975*
GAS4Helium 319925*
GAS5Neon19925*
GAS6Krypton20014*
GAS7Xenon20014*
GAS8methane19945*
GAS9ethane19995*
GAS10propane19994*
GAS11isobutane19993*
GAS12CO220015*
GAS13C(CH3)4 neo-pentane19953*
GAS14H2019983*
GAS15Oxygen19903-body attachment included4*
GAS16Nitrogen1985Pitchford and Phelps4*
GAS17nitric oxide1995attaching gas4*
GAS18nitrous oxide1995attaching gas4*
GAS19C2H4 ethene19994*
GAS20C2H2 acetylene19923*
GAS21Hydrogen20015*
GAS22Deuterium19985*
GAS23Carbon monoxide19985*
GAS24methylal19882*
GAS25DME19984*
GAS26Reid step model?anisotropic version-
GAS27Maxwell model?-
GAS28Reid ramp model?-
GAS29C2F61999anisotropic4*
GAS30SF6?do not use high percentage3*
GAS31NH3 ammonia19993*
GAS32C3H6 propene19994*
GAS33C3H6 cyclopropane19994*
GAS34CH3OH methanol19992*
GAS35C2H5OH ethanol19993*
GAS36C3H7OH isopropanol19992*
GAS37Cæsium2001no dimers2*
GAS38Fluorine?Morgan2*
GAS39CS22001ion drift, dark matter2*
GAS40COS20012*
GAS41CD42001TPCs in neutron background environment3*
GAS42BF3 Boron trifluoride2001anisotropic3*
GAS43C2HF5 or C2H2F4?estimated no data, anisotropic1*
GAS44Helium 32002anisotropic5*
GAS45Helium 42002anisotropic5*
GAS46Neon2002anisotropic5*
GAS47Argon2002anisotropic5*
GAS48Krypton2002anisotropic4*
GAS49Xenon2002anisotropic4*
GAS50methane2002anisotropic5*
GAS52-80Dummy routines?-

About

A library to interface with Magboltz (Boltzmann transport equation solver for gas mixtures)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages