# Warning energy out of range, increase electron energy integration range

**URL:** <https://root-forum.cern.ch/t/warning-energy-out-of-range-increase-electron-energy-integration-range/42823>\
**Category:** Garfield++\
**Created:** [December 21, 2020, 6:13pm UTC](https://root-forum.cern.ch/t/warning-energy-out-of-range-increase-electron-energy-integration-range/42823 "2020-12-21T18:13:25Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jason\_Forson](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/jason_forson/32/24369_2.png) [@Jason\_Forson](https://root-forum.cern.ch/u/Jason_Forson)\
**Post date:** [December 21, 2020, 6:13pm UTC](https://root-forum.cern.ch/t/warning-energy-out-of-range-increase-electron-energy-integration-range/42823/1 "2020-12-21T18:13:26Z")

</div>

Hello,

So my Garfield installation otherwise seems to work just fine, the simulations work just fine, gas files made by others work just fine. I just have problems when I try generate Gas files myself.

Here’s the code.

```auto
#include <iostream>

#include <TCanvas.h>
#include <TROOT.h>
#include <TApplication.h>

#include "Garfield/MediumMagboltz.hh"
#include "Garfield/FundamentalConstants.hh"

using namespace Garfield;

int main(int argc, char * argv[]) {

  TApplication app("app", &argc, argv);

  //const double pressure = 3 * AtmosphericPressure; //Same Comp, Different Pressure                                                                                                                                      
  const double pressure = 58; //Same Pressure, Different Comp                                                                                                                                                             
  const double temperature = 293.15;

  // Setup the gas.                                                                                                                                                                                                       
  MediumMagboltz gas;
  gas.SetComposition("Ar", 93., "CO2", 7.);
  //gas.SetComposition("iC4H10", 100.); //Same Comp, Different Pressure                                                                                                                                                   
  gas.SetTemperature(temperature);

  gas.SetPressure(pressure);

  // Set the field range to be covered by the gas table.                                                                                                                                                                  
  const int nFields = 20;
  const double emin = 100.;
  const double emax = 100000.;
  // Flag to request logarithmic spacing.                                                                                                                                                                                 
  constexpr bool useLog = true;

  gas.SetFieldGrid(emin, emax, nFields, useLog);

  const int ncoll = 10;

  // Run Magboltz to generate the gas table.                                                                                                                                                                              
  gas.GenerateGasTable(ncoll);

  // Save the table.                                                                                                                                                                                                      
  gas.WriteGasFile("ar_93_co2_7.gas");
  // app.Run(kTRUE);                                                                                                                                                                                                      

}

```

Which seems to work if I also put in a “ulimit -s unlimited” to get it to properly use all resources.

Here’s the results

```auto
Heed:
    Database path: /home/jason/garfield/Heed/heed++/database
MediumMagboltz::SetComposition:
    Ar/CO2 (93/7)
MediumMagboltz::GenerateGasTable: Found 44 excitations and 18 ionisations.
    Ar EXC 1S5 J=2 METASTABLE ELEVEL= 11.548 , energy = 11.5478 eV.
    Ar EXC 1S4 J=1 RESONANT ELEVEL= 11.624 , energy = 11.6238 eV.
    Ar EXC 1S3 J=0 METASTABLE ELEVEL= 11.723 , energy = 11.7228 eV.
    Ar EXC 1S2 J=1 RESONANT ELEVEL= 11.828 , energy = 11.8278 eV.
    Ar EXC 2P10 J=1 ELEVEL= 12.907 , energy = 12.9068 eV.
    Ar EXC 2P9 J=3 ELEVEL= 13.076 , energy = 13.0758 eV.
    Ar EXC 2P8 J=2 ELEVEL= 13.095 , energy = 13.0948 eV.
    Ar EXC 2P7 J=1 ELEVEL= 13.153 , energy = 13.1528 eV.
    Ar EXC 2P6 J=2 ELEVEL= 13.172 , energy = 13.1718 eV.
    Ar EXC 2P5 J=0 ELEVEL= 13.273 , energy = 13.2728 eV.
    Ar EXC 2P4 J=1 ELEVEL= 13.283 , energy = 13.2828 eV.
    Ar EXC 2P3 J=2 ELEVEL= 13.302 , energy = 13.3018 eV.
    Ar EXC 2P2 J=1 ELEVEL= 13.328 , energy = 13.3278 eV.
    Ar EXC 2P1 J=0 ELEVEL= 13.480 , energy = 13.4798 eV.
    Ar EXC 3D6 J=0 ELEVEL= 13.845 , energy = 13.8448 eV.
    Ar EXC 3D5 J=1 RESONANT ELEVEL= 13.864 , energy = 13.8638 eV.
    Ar EXC 3D3 J=2 ELEVEL= 13.903 , energy = 13.9028 eV.
    Ar EXC 3D4! J=4 ELEVEL= 13.979 , energy = 13.9788 eV.
    Ar EXC 3D4 J=3 ELEVEL= 14.013 , energy = 14.0128 eV.
    Ar EXC 3D1!! J=2 ELEVEL= 14.063 , energy = 14.0628 eV.
    Ar EXC 2S5 J=2 ELEVEL= 14.068 , energy = 14.0678 eV.
    Ar EXC 2S4 J=1 RESONANT ELEVEL= 14.090 , energy = 14.0898 eV.
    Ar EXC 3D1! J=3 ELEVEL= 14.099 , energy = 14.0988 eV.
    Ar EXC 3D2 J=1 RESONANT ELEVEL= 14.153 , energy = 14.1528 eV.
    Ar EXC 3S1!!!!J=2 ELEVEL= 14.214 , energy = 14.2138 eV.
    Ar EXC 3S1!! J=2 ELEVEL= 14.234 , energy = 14.2338 eV.
    Ar EXC 3S1!!! J=3 ELEVEL= 14.236 , energy = 14.2358 eV.
    Ar EXC 2S3 J=0 ELEVEL= 14.241 , energy = 14.2408 eV.
    Ar EXC 2S2 J=1 RESONANT ELEVEL= 14.255 , energy = 14.2548 eV.
    Ar EXC 3S1! J=1 RESONANT ELEVEL= 14.304 , energy = 14.3038 eV.
    Ar EXC 4D5 J=1 RESONANT ELEVEL= 14.711 , energy = 14.7108 eV.
    Ar EXC 3S4 J=1 RESONANT ELEVEL= 14.848 , energy = 14.8478 eV.
    Ar EXC 4D2 J=1 RESONANT ELEVEL= 14.859 , energy = 14.8588 eV.
    Ar EXC 4S1! J=1 RESONANT ELEVEL= 15.004 , energy = 15.0038 eV.
    Ar EXC 3S2 J=1 RESONANT ELEVEL= 15.022 , energy = 15.0218 eV.
    Ar EXC 5D5 J=1 RESONANT ELEVEL= 15.118 , energy = 15.1178 eV.
    Ar EXC 4S4 J=1 RESONANT ELEVEL= 15.186 , energy = 15.1858 eV.
    Ar EXC 5D2 J=1 RESONANT ELEVEL= 15.190 , energy = 15.1898 eV.
    Ar EXC 6D5 J=1 RESONANT ELEVEL= 15.308 , energy = 15.3078 eV.
    Ar EXC 5S1! J=1 RESONANT ELEVEL= 15.351 , energy = 15.3508 eV.
    Ar EXC 4S2 J=1 RESONANT ELEVEL= 15.360 , energy = 15.3598 eV.
    Ar EXC 5S4 J=1 RESONANT ELEVEL= 15.366 , energy = 15.3658 eV.
    Ar EXC 6D2 J=1 RESONANT ELEVEL= 15.374 , energy = 15.3738 eV.
    Ar EXC HIGH J=1 RESONANT ELEVEL= 15.660 , energy = 15.6598 eV.
    Ar IONISATION CHARGE STATE =1 ELOSS= 15.75961, energy = 15.7594 eV.
    Ar IONISATION CHARGE STATE =2 ELOSS= 43.38928, energy = 43.3887 eV.
    Ar IONISATION CHARGE STATE =3 ELOSS= 84.124 , energy = 84.1228 eV.
    Ar IONISATION L3 SHELL ELOSS= 248.4 , energy = 248.397 eV.
    Ar IONISATION L2 SHELL ELOSS= 250.6 , energy = 250.597 eV.
    Ar IONISATION L1 SHELL ELOSS= 326.3 , energy = 326.296 eV.
    Ar IONISATION K SHELL ELOSS= 3205.9 , energy = 3205.86 eV.
    CO2 IONISATION CO2+ ELOSS= 13.776 , energy = 13.7758 eV.
    CO2 IONISATION-EXC CO2+(A2PIu) ELOSS= 17.314 , energy = 17.3138 eV.
    CO2 IONISATION-EXC CO2+(B2SIG+u) ELOSS= 18.077 , energy = 18.0768 eV.
    CO2 DISSOCIATIVE ION O+ ELOSS= 19.07 , energy = 19.0698 eV.
    CO2 DISSOCIATIVE ION CO+ ELOSS= 19.47 , energy = 19.4698 eV.
    CO2 DISSOCIATIVE ION C+ ELOSS= 27.82 , energy = 27.8197 eV.
    CO2 DISSOCIATIVE ION CO2++ ELOSS= 37.4 , energy = 37.3995 eV.
    CO2 DISSOCIATIVE ION C++ ELOSS= 72.0 , energy = 71.9991 eV.
    CO2 DISSOCIATIVE ION O++ ELOSS= 74.0 , energy = 73.9991 eV.
    CO2 IONISATION CARBON K-SHELL ELOSS= 285.0 , energy = 284.996 eV.
    CO2 IONISATION OXYGEN K-SHELL ELOSS= 532.0 , energy = 531.993 eV.
MediumMagboltz::GenerateGasTable: E = 100 V/cm, B = 0 T, angle: 1.5708 rad
 RM48 INITIALIZED: 54217137 0 0

          PROGRAM MAGBOLTZ 2 VERSION 11.9 

          MONTE CARLO SOLUTION FOR MIXTURE OF 2 GASES.
     ------------------------------------------------------

       GASES USED PERCENTAGE USED 

      ARGON ANISOTROPIC 2014 93.0000
      CO2 2018 ANISOTROPIC 7.0000

  GAS TEMPERATURE = 20.0 DEGREES CENTIGRADE.
  GAS PRESSURE = 58.0 TORR.

  INTEGRATION FROM 0.0 TO 8.00 EV. IN 4000 STEPS. 

 PENNING EFFECTS NOT INCLUDED

 ANISOTROPIC SCATTERING TYPE 2 (OKHRIMOVSKYY) USED IF AVAILABLE

 SHORT DECORRELATION LENGTH = 400000 COLLISIONS.

 THERMAL MOTION OF GAS NOT INCLUDED

  ELECTRIC FIELD = 100.0000 VOLTS/CM.
  MAGNETIC FIELD = 0.0000 KILOGAUSS.
  ANGLE BETWEEN ELECTRIC AND MAGNETIC FIELD = 90.000 DEGREES.
  CYCLOTRON FREQ. = 0.000D+00 RADIANS/PICOSECOND

  INITIAL ELECTRON ENERGY = 0.160 EV.

  TOTAL NUMBER OF REAL COLLISIONS = 400000000

  NULL COLLISION FREQUENCY AT 8 EQUALLY SPACED ENERGY INTERVALS (*10**12/SEC)
      0.102D+00 0.141D+00 0.184D+00 0.244D+00
      0.323D+00 0.415D+00 0.489D+00 0.489D+00

  REAL COLLISION FREQUENCY AT 8 EQUALLY SPACED ENERGY INTERVALS (*10**12/SEC)
      0.933D-02 0.341D-01 0.767D-01 0.136D+00
      0.196D+00 0.260D+00 0.343D+00 0.438D+00

    VEL POS TIME ENERGY COUNT DIFXX DIFYY DIFZZ

    39.76 0.416D+02 0.105D+10 1.4100 100 59450.4 51618.4 0.0
 WARNING ENERGY OUT OF RANGE,INCREASE ELECTRON ENERGY INTEGRATION RANGE 

```

Which is weird to me, because as I understand the program it should be calculating the range it needs before it starts anyway. So it sets it’s own limit and seems to guess wrong.

Any help would be appreciated.

---

<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:** [December 21, 2020, 10:16pm UTC](https://root-forum.cern.ch/t/warning-energy-out-of-range-increase-electron-energy-integration-range/42823/2 "2020-12-21T22:16:01Z")

</div>

Hi,  
you’re right, by default Magboltz tries to guess a suitable upper limit of the electron energy range. This seems to fail in your case (not sure why, will take a look, but it might be because of the low pressure).  
As a quick fix, you could switch off the automatic determination of the energy range, adding a line

```auto
gas.EnableAutoEnergyLimit(false);

```

and set the upper energy limit (in eV) explicitly, e. g.

```auto
gas.SetMaxElectronEnergy(100.);

```

---

<div class="post-metadata">

**Author:** ![Jason\_Forson](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/jason_forson/32/24369_2.png) [@Jason\_Forson](https://root-forum.cern.ch/u/Jason_Forson)\
**Post date:** [December 22, 2020, 4:35pm UTC](https://root-forum.cern.ch/t/warning-energy-out-of-range-increase-electron-energy-integration-range/42823/3 "2020-12-22T16:35:55Z")

</div>

Doing this with max electron energy set to 1 MeV will let the program for a few 4-6 hours instead of a minute or two, but it still gives that error and ends prematurely. I’m trying again with setting max electron energy to 1 GeV but otherwise something else seems to be up.

---

<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:** [January 5, 2021, 4:36pm UTC](https://root-forum.cern.ch/t/warning-energy-out-of-range-increase-electron-energy-integration-range/42823/4 "2021-01-05T16:36:01Z")

</div>

Closed on January 5, 2021, 4:36pm UTC

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