# Inclusion of thermal effects in Garfield++

**URL:** <https://root-forum.cern.ch/t/inclusion-of-thermal-effects-in-garfield/59455>\
**Category:** Garfield++\
**Created:** [May 24, 2024, 2:58pm UTC](https://root-forum.cern.ch/t/inclusion-of-thermal-effects-in-garfield/59455 "2024-05-24T14:58:37Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Aneesha6](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/aneesha6/32/28535_2.png) [@Aneesha6](https://root-forum.cern.ch/u/Aneesha6)\
**Post date:** [May 24, 2024, 2:58pm UTC](https://root-forum.cern.ch/t/inclusion-of-thermal-effects-in-garfield/59455/1 "2024-05-24T14:58:37Z")

</div>

I am using Garfield++ to generate gas tables. I set the gas temperature to 20 degrees centigrade and let the code run, but I notice the following in the terminal output-

> THERMAL MOTION OF GAS NOT INCLUDED

I looked at the Garfield++ user manual to find that thermal effects are turned OFF by default since the gas is assumed to be at 0 K, and there is a function called EnableThermalMotion() to turn it on.

However, I was hoping that setting the gas to a temperature greater than 0 K would override the default value and generate a gas file that has thermal motion included. Could someone please clarify this for me?

Additionally, if the thermal motion is turned off in the gas, what is causing the diffusion? My understanding was that thermal motion contributes to the diffusion of an electron cloud.

---

<div class="post-metadata">

**Author:** ![Piet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/piet/32/12536_2.png) [@Piet](https://root-forum.cern.ch/u/Piet)\
**Post date:** [May 24, 2024, 4:45pm UTC](https://root-forum.cern.ch/t/inclusion-of-thermal-effects-in-garfield/59455/2 "2024-05-24T16:45:03Z")

</div>

Dear @Aneesha6

When you set the temperature to let’s say 293.15K (20\*C) that is used for the calculation of the transport parameters of the gas that depend on the pressure and temperature (actually they depend on the number density of the gas: the number of gas molecules or atoms / cm3).

For the computation of the gas tables Magboltz calculates the scattering of electrons on gas molecules. The electrons have energy from the electric field, they are light and they quickly gain speed. Instead by default the gas molecules are considered at rest (so not moving / vibrating =\> at 0K). Consider that 293K is 0.025eV, so this thermal motion of the gas is way lower than the few eV that the electrons gain in typical electric fields in gaseous detectors. So by default the impact of the thermal motion of the atoms/molecules is negligible and does not justify the additional computation time and is turned off. And results obtained like this agree with the measurements.

If you are curious, you can calculate two gas tables, one with thermal motion ON and one with thermal motion OFF and compare the results. I would think that the differences would be smaller than the uncertainty on the observables calculated by Magboltz, but you can check.

Diffusion of the electrons is due to the scattering on gas molecules, where the outgoing electron has different speed and velocity (direction).

---

<div class="post-metadata">

**Author:** ![Aneesha6](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/aneesha6/32/28535_2.png) [@Aneesha6](https://root-forum.cern.ch/u/Aneesha6)\
**Post date:** [May 26, 2024, 4:06pm UTC](https://root-forum.cern.ch/t/inclusion-of-thermal-effects-in-garfield/59455/3 "2024-05-26T16:06:45Z")

</div>

Thank you for your detailed response. It was beneficial.  
I am trying to create gas files with the default option and one without it. I have a question about how to override the default option.  
My generate.c file is as follows:

```auto
#include <iostream>
#include "Garfield/MediumMagboltz.hh"
#include "Garfield/FundamentalConstants.hh"
using namespace Garfield;

int main(int argc, char * argv[]) {
  const double pressure = 1 * AtmosphericPressure;
  const double temperature = 293.15;
 
  // Setup the gas.
  MediumMagboltz gas("CH4", 100.);
  gas.SetTemperature(temperature);
  gas.SetPressure(pressure);
void EnableThermalMotion(const bool on);

  // Set the field range to be covered by the gas table. 
  std::vector<double> efields = {6250., 12500., 25000., 50000.,100000.};
  std::vector<double> bfields = {0.};
  std::vector<double> angles = {0.};
  gas.SetFieldGrid(efields, bfields, angles);

  const int ncoll = 10;
  // Run Magboltz to generate the gas table.
  gas.GenerateGasTable(ncoll);
  // Save the table. 
  gas.WriteGasFile("ch4.gas");

}

```

When I ran the generate.c executable, I notice that the terminal output still says that ‘THERMAL MOTION IS NOT INCLUDED.’ Am I setting the flag correctly?

---

<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:** [May 26, 2024, 5:47pm UTC](https://root-forum.cern.ch/t/inclusion-of-thermal-effects-in-garfield/59455/4 "2024-05-26T17:47:42Z")

</div>

You need to replace the line

```auto
void EnableThermalMotion(const bool on);

```

by

```auto
gas.EnableThermalMotion(true);

```

and recompile.

---

<div class="post-metadata">

**Author:** ![Aneesha6](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/aneesha6/32/28535_2.png) [@Aneesha6](https://root-forum.cern.ch/u/Aneesha6)\
**Post date:** [June 5, 2024, 2:40am UTC](https://root-forum.cern.ch/t/inclusion-of-thermal-effects-in-garfield/59455/5 "2024-06-05T02:40:22Z")

</div>

I compared the generated gas files with thermal motion toggled and found that the diffusion coefficients increased by about 2% for all the electric fields I tried, which is within the uncertainty given by Magboltz.

I appreciate your help!

---

<div class="post-metadata">

**Author:** ![Piet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/piet/32/12536_2.png) [@Piet](https://root-forum.cern.ch/u/Piet)\
**Post date:** [June 5, 2024, 7:26am UTC](https://root-forum.cern.ch/t/inclusion-of-thermal-effects-in-garfield/59455/6 "2024-06-05T07:26:51Z")

</div>

Great! If you like you can also share here some plots.  
Let us know if you need further help.  
greets  
Piet

---

<div class="post-metadata">

**Author:** ![Aneesha6](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/aneesha6/32/28535_2.png) [@Aneesha6](https://root-forum.cern.ch/u/Aneesha6)\
**Post date:** [June 6, 2024, 4:31pm UTC](https://root-forum.cern.ch/t/inclusion-of-thermal-effects-in-garfield/59455/7 "2024-06-06T16:31:12Z")

</div>

I did not make plots but I am sharing my terminal output for anyone who would like to look at the numbers.

 ![image](https://root-forum.cern.ch/uploads/default/original/3X/8/4/8452e591346b4ea18c07ccec0edb51ea8cd76e2c.jpeg)

---

<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:** [June 20, 2024, 4:31pm UTC](https://root-forum.cern.ch/t/inclusion-of-thermal-effects-in-garfield/59455/8 "2024-06-20T16:31:18Z")

</div>

Closed on June 20, 2024, 4:31pm UTC

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