# Maybe a bug in class MediumMagboltz

**URL:** <https://root-forum.cern.ch/t/maybe-a-bug-in-class-mediummagboltz/58359>\
**Category:** Garfield++\
**Created:** [March 2, 2024, 5:36am UTC](https://root-forum.cern.ch/t/maybe-a-bug-in-class-mediummagboltz/58359 "2024-03-02T05:36:36Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![newconcept1979](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/newconcept1979/32/26349_2.png) [@newconcept1979](https://root-forum.cern.ch/u/newconcept1979)\
**Post date:** [March 2, 2024, 5:36am UTC](https://root-forum.cern.ch/t/maybe-a-bug-in-class-mediummagboltz/58359/1 "2024-03-02T05:36:36Z")

</div>

When producing .gas file of mixture with 93% argon and 7% carbon dioxide, the error occured at ELECTRIC FIELD = 2002.3331 VOLTS/CM, the output on terminal is:

WARNING ENERGY OUT OF RANGE,INCREASE ELECTRON ENERGY INTEGRATION RANGE

the relevant code is:

MediumMagboltz gas;  
gas.SetComposition(“Ar”, 93.,“CO2”, 7.);  
gas.SetTemperature(293.15);  
gas.SetPressure(760.);  
gas.SetFieldGrid(10,5e5,50,true);

---

<div class="post-metadata">

**Author:** ![Danilo](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/danilo/32/34528_2.png) [@Danilo](https://root-forum.cern.ch/u/Danilo)\
**Post date:** [March 2, 2024, 7:45am UTC](https://root-forum.cern.ch/t/maybe-a-bug-in-class-mediummagboltz/58359/2 "2024-03-02T07:45:25Z")

</div>

Hi,

Have you had a look to this answer? [Maybe a bug - #3 by hschindl](https://root-forum.cern.ch/t/maybe-a-bug/58358/3)  
Best,  
D

---

<div class="post-metadata">

**Author:** ![newconcept1979](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/newconcept1979/32/26349_2.png) [@newconcept1979](https://root-forum.cern.ch/u/newconcept1979)\
**Post date:** [March 2, 2024, 12:17pm UTC](https://root-forum.cern.ch/t/maybe-a-bug-in-class-mediummagboltz/58359/3 "2024-03-02T12:17:33Z")

</div>

@Danilo , yes, but the error occured at 2kV/cm.

---

<div class="post-metadata">

**Author:** ![newconcept1979](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/newconcept1979/32/26349_2.png) [@newconcept1979](https://root-forum.cern.ch/u/newconcept1979)\
**Post date:** [March 4, 2024, 6:38am UTC](https://root-forum.cern.ch/t/maybe-a-bug-in-class-mediummagboltz/58359/4 "2024-03-04T06:38:27Z")

</div>

By the way, for argon, at ELECTRIC FIELD = 10. VOLTS/CM, the same error occured.

---

<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:** [March 4, 2024, 11:33am UTC](https://root-forum.cern.ch/t/maybe-a-bug-in-class-mediummagboltz/58359/5 "2024-03-04T11:33:16Z")

</div>

I ran Jan 15th an Ar:CO2 93:7 gas mixture using the latest nightly built on lxplus, with the following setup and it ran without any problem. Note my max field was 1e5 V/cm, not 5e5 V/cm as yours, so I would suggest that if you are interested in the outcome for fields of 2kV/cm or 10kV/cm you leave the maximum field 100kV/cm as in the example.

> const double pressure = 760.;  
> const double temperature = 293.15;  
> // Setup the gas.  
> MediumMagboltz gas(“Ar”, 93., “CO2”, 7.);  
> gas.SetTemperature(temperature);  
> gas.SetPressure(pressure);  
> // Set the field range to be covered by the gas table.  
> const size\_t nE = 20;  
> const double emin = 100.;  
> const double emax = 100000.;  
> // Flag to request logarithmic spacing.  
> constexpr bool useLog = true;  
> gas.SetFieldGrid(emin, emax, nE, useLog);  
> // Define precision  
> const int ncoll = 10;  
> // Run Magboltz to generate the gas table.  
> gas.GenerateGasTable(ncoll);  
> // Save the table.  
> gas.WriteGasFile(“ar\_93\_co2\_07.gas”);

Instead you can prepare a second file where you cover the fields between 100kV/cm and 500kV/cm:

> gas.SetFieldGrid(1e5,5e5,9,true);

and for this one I would suggest you increment the maximum electron energy (defaults to 40eV) to something one or few orders of magnitude higher, I would try first with 400eV:

> SetMaxElectronEnergy(const double e);

see Garfield++ usergide §3.2.3 p31. Let us know if you can reproduce the “bug” running at a lower maximum electric field.

---

<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:** [March 4, 2024, 1:47pm UTC](https://root-forum.cern.ch/t/maybe-a-bug-in-class-mediummagboltz/58359/6 "2024-03-04T13:47:12Z")

</div>

Unfortunately this issue does occur from time to time. It means that the estimate of the max. electron energy made internally in Magboltz before running the simulation fails. As a workaround you can slightly modify the electric field value(s). I’ll put it on my to-do list to see if we can find a proper fix…

---

<div class="post-metadata">

**Author:** ![newconcept1979](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/newconcept1979/32/26349_2.png) [@newconcept1979](https://root-forum.cern.ch/u/newconcept1979)\
**Post date:** [March 5, 2024, 6:22am UTC](https://root-forum.cern.ch/t/maybe-a-bug-in-class-mediummagboltz/58359/7 "2024-03-05T06:22:54Z")

</div>

when the code is:  
MediumMagboltz gas;

gas.SetComposition(“Ar”, 93.,“CO2”,7.);

gas.SetTemperature(293.15);

gas.SetPressure(760.);

gas.SetFieldGrid(100,2e5,50,true);

int ncoll=10;

gas.GenerateGasTable(ncoll);

everything worked well.

* * *

but when change the code from  
gas.SetFieldGrid(100,2e5,50,true);  
to  
gas.SetFieldGrid(100,1e5,50,true);

the error  
“WARNING ENERGY OUT OF RANGE,INCREASE ELECTRON ENERGY INTEGRATION RANGE”  
at electric field value 1930.6977 VOLTS/CM.

* * *

so, maybe, the Magboltz would stall at large electric field value  
or some values  
or some range.

---

<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:** [March 19, 2024, 6:23am UTC](https://root-forum.cern.ch/t/maybe-a-bug-in-class-mediummagboltz/58359/8 "2024-03-19T06:23:51Z")

</div>

Closed on March 19, 2024, 6:23am UTC

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