# Issue with multible gas volumes as active medium

**URL:** <https://root-forum.cern.ch/t/issue-with-multible-gas-volumes-as-active-medium/64629>\
**Category:** Garfield++\
**Tags:** garfield\
**Created:** [February 3, 2026, 2:56pm UTC](https://root-forum.cern.ch/t/issue-with-multible-gas-volumes-as-active-medium/64629 "2026-02-03T14:56:47Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ErikEhlert](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/e/85e7bf/32.png) [@ErikEhlert](https://root-forum.cern.ch/u/ErikEhlert)\
**Post date:** [February 3, 2026, 2:56pm UTC](https://root-forum.cern.ch/t/issue-with-multible-gas-volumes-as-active-medium/64629/1 "2026-02-03T14:56:48Z")

</div>

Hello,

I’m just starting with Garfield++ and have hit my first roadblock during the geometry/detector setup.

Tl-dr: Only one of the gas volumes is used as active medium.

I am trying to simulate a 3 layer GEM detector. For this I have created a model and calculated the E-Flieds using ElmerFEM. In order to define finer meshes around the foils I have cut the gas into smaller chunks. Together with the foils I get a total of 20 volumes 11 of which are suppose to be gas. Her you can see the section of one of the foils:

 ![Screenshot_20260203_150540](https://root-forum.cern.ch/uploads/default/original/3X/b/7/b746983d47e316c7b8b61acaa117ebde71003ab6.png) ![Screenshot_20260203_150550](https://root-forum.cern.ch/uploads/default/original/3X/d/3/d35aeb6c8030e00881877609df87e99343d02756.png)

The import into Garfield works without issue and the SetGas function also finds all the appropriate materials, here the output of the ComponentElmer::Initialise, ComponentElmer::SetGas, and ComponentElmer::PrintRange :

```auto
ComponentElmer::Initialise:
    Read 345010 nodes and 226158 elements from file ./mesh.header.
    Read potentials from file ./gem_cell.result.
    Set material 0 of 20 to eps 1.
    Set material 1 of 20 to eps 1.
    Set material 2 of 20 to eps 1.
    Set material 3 of 20 to eps 1e+09.
    Set material 4 of 20 to eps 4.
    Set material 5 of 20 to eps 1e+09.
    Set material 6 of 20 to eps 1.
    Set material 7 of 20 to eps 1.
    Set material 8 of 20 to eps 1.
    Set material 9 of 20 to eps 1.
    Set material 10 of 20 to eps 1e+09.
    Set material 11 of 20 to eps 4.
    Set material 12 of 20 to eps 1e+09.
    Set material 13 of 20 to eps 1.
    Set material 14 of 20 to eps 1.
    Set material 15 of 20 to eps 1.
    Set material 16 of 20 to eps 1.
    Set material 17 of 20 to eps 1e+09.
    Set material 18 of 20 to eps 4.
    Set material 19 of 20 to eps 1e+09.
ComponentElmer::Initialise: Finished.
ComponentElmer::Prepare:
    Caching the bounding boxes of all elements... done.
    Initialized tetrahedral tree.
ComponentElmer::SetGas: Associating material 0 with Ar/CO2.
ComponentElmer::SetGas: Associating material 1 with Ar/CO2.
ComponentElmer::SetGas: Associating material 2 with Ar/CO2.
ComponentElmer::SetGas: Associating material 6 with Ar/CO2.
ComponentElmer::SetGas: Associating material 7 with Ar/CO2.
ComponentElmer::SetGas: Associating material 8 with Ar/CO2.
ComponentElmer::SetGas: Associating material 9 with Ar/CO2.
ComponentElmer::SetGas: Associating material 13 with Ar/CO2.
ComponentElmer::SetGas: Associating material 14 with Ar/CO2.
ComponentElmer::SetGas: Associating material 15 with Ar/CO2.
ComponentElmer::SetGas: Associating material 16 with Ar/CO2.
ComponentElmer::PrintRange:
        Dimensions of the elementary block
                          0 < x < 0.007 cm,
                          0 < y < 0.0121244 cm,
                    -0.1005 < z < 0.6185 cm,
                      -3500 < V < 0 V.
        Periodicities
            x: mirror with length 0.007 cm
            y: mirror with length 0.0121244 cm
            z: none

```

Here I seam to make a mistake, because only one of the gas volumes gets used as such. Here a plot of the mesh, only the lowest volume gets plotted as a gas:

 ![Screenshot_20260203_152837](https://root-forum.cern.ch/uploads/default/original/3X/f/3/f306a2fde47b719844163bcb77c87fac5f973f1d.png)

When I define a sensor I also see the behavior which can be seen in the plot.

```python
sensor_gem.IsInside(0, 0, 0.02)

```

returns

```python
False

```

While:

```python
sensor_gem.IsInside(0, 0, -0.02)

```

returns

```python
True

```

Here is a link to the Jupyter notebook and the used Elmer files (The link expires on 17.02.26): (Or not, not allowed to post links jet ☹ )

Can someone help me with this? Sadly I was not able to find any useful information myself.

Root version:

```auto
  | Welcome to ROOT 6.38.00 https://root.cern |
  | (c) 1995-2025, The ROOT Team; conception: R. Brun, F. Rademakers |
  | Built for linuxx8664gcc on Jan 19 2026, 09:49:56 |
  | From tags/v6-38-00@v6-38-00 |

```

Garfield version: commit 331c1c07 from 25.12.2025

Thanks in advance for any help.  
Greetings

Erik Ehlert

---

<div class="post-metadata">

**Author:** ![jblomer](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/j/439d5e/32.png) [@jblomer](https://root-forum.cern.ch/u/jblomer)\
**Post date:** [February 3, 2026, 11:03pm UTC](https://root-forum.cern.ch/t/issue-with-multible-gas-volumes-as-active-medium/64629/2 "2026-02-03T23:03:52Z")

</div>

Welcome to the ROOT forum!

Perhaps @hschindl can 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:** [February 4, 2026, 8:29am UTC](https://root-forum.cern.ch/t/issue-with-multible-gas-volumes-as-active-medium/64629/3 "2026-02-04T08:29:23Z")

</div>

Dear Erik

Apologies, only after a few posts you will be allowed to post links. This is a safety issue for protection against spam.

From what I recall I believe the gas volume must be unique, and I am not sure a code modification to assign different volumes to be the sensible volume of the sensor in which electrons and ions can drift would be easy. Actually you can see it [here](https://gitlab.cern.ch/garfield/garfieldpp/-/blob/master/Source/ComponentFieldMap.cc#L824) only the volume/material with lowest permittivity is set as driftable, and if several materials have the same permittivity, it is the last one that is being assigned as driftable medium.

Looking at `componentFieldMap` source code, Isaw there is a method `DriftMedium(const std::size_t imat)`, so you could try to call this method from your `componentElmer` and identify each gas “material” as a drift medium, hoping that it is not overwriting as it did with the `setGas` method. Alternatively you could modify locally the `ComponentFieldMap::SetDefaultDriftMedium` to assign multiple media as drifting medium, or you could copy it into a new `ComponentFieldMap::SetMultipleDriftMedia` method to do so. However, be careful, this is experimentally, and I am just suggesting what I were to do in this situation. I do not know whether this might break code downstream (e.g. when drifting electrons), so this is a trial-and-error approach. Maybe @hschindl might know better and comment if this is a possible way out.

As an alternative, I would look into the possibilities to merge different volumes in Elmer/GMesh after meshing, but before calculating the solution. This way you would load a single material into garfield and assign it to be the gas and you will be fine. Googling a bit, I found this information that you could study / try out (I am not an Elmer expert):

 ![Screenshot 2026-02-04 at 09.26.56](https://root-forum.cern.ch/uploads/default/original/3X/b/a/bad3249734a28b39bfc9c8623f8f1ed7f04c62b3.png)

Kind regards  
Piet

---

<div class="post-metadata">

**Author:** ![ErikEhlert](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/e/85e7bf/32.png) [@ErikEhlert](https://root-forum.cern.ch/u/ErikEhlert)\
**Post date:** [February 4, 2026, 11:38am UTC](https://root-forum.cern.ch/t/issue-with-multible-gas-volumes-as-active-medium/64629/4 "2026-02-04T11:38:12Z")

</div>

Hi,

Thanks for the quick and extensive reply 🙂

Using DriftMedium seams to have done the trick!

 ![image](https://root-forum.cern.ch/uploads/default/original/3X/7/3/736c2fcedeaf3e2aeca624a1621a3bd20b13c6d9.png)

Thanks a lot

Erik

---

<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:** [February 4, 2026, 2:12pm UTC](https://root-forum.cern.ch/t/issue-with-multible-gas-volumes-as-active-medium/64629/5 "2026-02-04T14:12:48Z")

</div>

ok. great to know it works this way.  
greets  
Piet

---

<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:** [February 18, 2026, 2:13pm UTC](https://root-forum.cern.ch/t/issue-with-multible-gas-volumes-as-active-medium/64629/6 "2026-02-18T14:13:43Z")

</div>

Closed on February 18, 2026, 2:13pm UTC

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