GithubHelp home page GithubHelp logo

nimboltz's Introduction

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?-

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.