# Accessing Townsend coefficients (alpha, gamma)

**URL:** <https://root-forum.cern.ch/t/accessing-townsend-coefficients-alpha-gamma/44642>\
**Category:** Garfield++\
**Created:** [April 29, 2021, 7:30am UTC](https://root-forum.cern.ch/t/accessing-townsend-coefficients-alpha-gamma/44642 "2021-04-29T07:30:26Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ikempf](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/i/439d5e/32.png) [@ikempf](https://root-forum.cern.ch/u/ikempf)\
**Post date:** [April 29, 2021, 7:30am UTC](https://root-forum.cern.ch/t/accessing-townsend-coefficients-alpha-gamma/44642/1 "2021-04-29T07:30:26Z")

</div>

Hi!

I was wondering whether there is a way to get the first Townsend ionisation coefficient (alpha) from the simulations. In the user manual in section 2.5.1 on the drift tube it is stated:

> First, we prepare a table of transport parameters (drift velocity, diffusion coefficients, Townsend  
> coefficient, and attachment coefficient) as a function of the electric field E (and, in general, also  
> the magnetic field B as well as the angle between E and B).

So it appears that in creating the gas files with gas.GenerateGasTable(ncoll) the Townsend coefficients should be calculated. How can I find these coefficients? I have looked at the gas files but am a bit confused because I did not find this information.

Is there also a way to get the Townsend coefficients for ions (gamma)?

Thank you very much for your help!

---

<div class="post-metadata">

**Author:** ![hschindl](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/h/977dab/32.png) [@hschindl](https://root-forum.cern.ch/u/hschindl)\
**Post date:** [April 29, 2021, 10:33am UTC](https://root-forum.cern.ch/t/accessing-townsend-coefficients-alpha-gamma/44642/2 "2021-04-29T10:33:18Z")

</div>

Hi,

after generating the gas file (or loading an existing one), you can retrieve the Townsend coefficient at a given electric (and magnetic) field using something like this:

```auto
// E = 20 kV/cm
double ex = 20.e3, ey = 0, ez = 0.;
double bx = 0., by = 0., bz = 0.;
double alpha = 0.;
gas.ElectronTownsend(ex, ey, ez, bx, by, bz, alpha);
std::cout << "Townsend coefficient at E = " << ex * 1.e-3 << " kV/cm: " << alpha << " / cm";

```

This function will interpolate between the values stored in the gas table.  
If instead you want to get the values at the exact electric field that was used in Magboltz, you can do something like this:

```auto
// Take the first entry in the list of electric fields.
int ie = 0;
// Take the first entry in the list of magnetic fields and angles.
int ib = 0;
int ia = 0;
gas.GetElectronTownsend(ie, ib, ia, alpha);
alpha = exp(alpha);

```

The last line is needed because it’s log(alpha) that’s stored in the table not alpha itself.

I should add a little example for this to the repository…

There is no analogous function for ions, because they don’t contribute to the multiplication in a gas.

---

<div class="post-metadata">

**Author:** ![ikempf](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/i/439d5e/32.png) [@ikempf](https://root-forum.cern.ch/u/ikempf)\
**Post date:** [April 29, 2021, 12:43pm UTC](https://root-forum.cern.ch/t/accessing-townsend-coefficients-alpha-gamma/44642/4 "2021-04-29T12:43:50Z")

</div>

I have attached a short working example of the Townsend coefficient calculation, in case other users stumble upon the same question. Thank you again for your help!

[Townsend\_Coefficients.cpp](https://root-forum.cern.ch/uploads/short-url/rMBRkCzoJboSjQfiWsXcs7Hsglu.cpp) (2.0 KB)

---

<div class="post-metadata">

**Author:** ![system](https://root-forum.cern.ch/uploads/default/original/3X/e/f/efe4f24398fd8ffeb76bccb6ecc46d9d9c003376.png) [@system](https://root-forum.cern.ch/u/system)\
**Post date:** [May 13, 2021, 12:43pm UTC](https://root-forum.cern.ch/t/accessing-townsend-coefficients-alpha-gamma/44642/5 "2021-05-13T12:43:59Z")

</div>

Closed on May 13, 2021, 12:43pm UTC

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
