# Question when using AvalancheMicroscopic::DriftElectron()

**URL:** <https://root-forum.cern.ch/t/question-when-using-avalanchemicroscopic-driftelectron/62587>\
**Category:** Garfield++\
**Tags:** root\
**Created:** [January 6, 2025, 7:33am UTC](https://root-forum.cern.ch/t/question-when-using-avalanchemicroscopic-driftelectron/62587 "2025-01-06T07:33:39Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![Crisps](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/crisps/32/39101_2.png) [@Crisps](https://root-forum.cern.ch/u/Crisps)\
**Post date:** [January 6, 2025, 7:33am UTC](https://root-forum.cern.ch/t/question-when-using-avalanchemicroscopic-driftelectron/62587/1 "2025-01-06T07:33:40Z")

</div>

Dear experts

I tried to use `AvalancheMicroscopic` to simulate the drifting of electrons in some drift chamber. I setup all fields, then:

```auto
//setup fields, wires, etc.
AvalancheMicroscopic* drift = new AvalancheMicroscopic();
//some setup
drift->DriftElectron(del_x, del_y, del_z, del_t, 0);

```

then I got these outputs and simulation never ends.

```auto
MediumMagboltz::GetElectronCollisionRate:
    Rate at 40.5373 eV is not included in the current table.
    Increasing energy range to 42.5642 eV.
AvalancheMicroscopic::TransportElectron: Increasing null-collision rate by 5%.
MediumMagboltz::GetElectronCollisionRate:
    Rate at 44.8318 eV is not included in the current table.
    Increasing energy range to 47.0734 eV.
MediumMagboltz::GetElectronCollisionRate:
    Rate at 66.9145 eV is not included in the current table.
    Increasing energy range to 70.2602 eV.
MediumMagboltz::GetElectronCollisionRate:
    Rate at 71.5861 eV is not included in the current table.
    Increasing energy range to 75.1655 eV.
MediumMagboltz::GetElectronCollisionRate:
    Rate at 105.317 eV is not included in the current table.
    Increasing energy range to 110.583 eV.
MediumMagboltz::GetElectronCollisionRate:
    Rate at 112.109 eV is not included in the current table.
    Increasing energy range to 117.714 eV.
MediumMagboltz::GetElectronCollisionRate:
    Rate at 128.653 eV is not included in the current table.
    Increasing energy range to 135.086 eV.
MediumMagboltz::GetElectronCollisionRate:
    Rate at 145.646 eV is not included in the current table.
    Increasing energy range to 152.928 eV.
......

```

What should I do?

---

<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:** [January 6, 2025, 9:18am UTC](https://root-forum.cern.ch/t/question-when-using-avalanchemicroscopic-driftelectron/62587/2 "2025-01-06T09:18:37Z")

</div>

Hello,

Adding @hschindl in the loop.

Best,  
D

---

<div class="post-metadata">

**Author:** ![djjansse](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/d/8baadc/32.png) [@djjansse](https://root-forum.cern.ch/u/djjansse)\
**Post date:** [January 6, 2025, 9:38am UTC](https://root-forum.cern.ch/t/question-when-using-avalanchemicroscopic-driftelectron/62587/3 "2025-01-06T09:38:34Z")

</div>

Dear @Crisps,

If the simulation appears to run unusually long while continuously increasing the computed energy range, it might indicate that the electric field is abnormally strong in a specific region of your detector or that the gas setup is not configured correctly.

Could you share the snippets of code you are using to configure these two aspects of the simulation, along with the corresponding outputs when the script is executed?

Kind regards,  
Djunes

---

<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:** [January 6, 2025, 10:01am UTC](https://root-forum.cern.ch/t/question-when-using-avalanchemicroscopic-driftelectron/62587/4 "2025-01-06T10:01:32Z")

</div>

Indeed! It could also be that the electron is drifting over a **very** long distance. What are the dimensions of your chamber?

---

<div class="post-metadata">

**Author:** ![Crisps](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/crisps/32/39101_2.png) [@Crisps](https://root-forum.cern.ch/u/Crisps)\
**Post date:** [January 6, 2025, 1:57pm UTC](https://root-forum.cern.ch/t/question-when-using-avalanchemicroscopic-driftelectron/62587/5 "2025-01-06T13:57:47Z")

</div>

Thank you all for replies, my chamber is small that 8mm x 8mm, and here is the code that set Wires:

```auto
void userCode(){
//something
    wire.AddWire(-0.84, -0.8, d_field, 0, "field");
    wire.AddWire(0., -0.8, d_field, 0, "field");
    wire.AddWire(0.84, -0.8, d_field, 0, "field");
    wire.AddWire(-0.84, 0., d_field, 0, "field");
    wire.AddWire(0.84, 0., d_field, 0, "field");
    wire.AddWire(-0.84, 0.8, d_field, 0, "field");
    wire.AddWire(0., 0.8, d_field, 0, "field");
    wire.AddWire(0.84, 0.8, d_field, 0, "field");
    wire.AddWire(0., 0., d_sense, 1800, "sense");
}

```

and another piece of code (I tried `AvalancheMC` this time to speed up):

```auto
double del_x = 0.5, del_y = 0.5, del_z = 0., del_t = 0., ke = 0., dummy;
        for(int i=0; i<1; i++){
            drift.DriftElectron(del_x, del_y, del_z, del_t);
            double x0, y0, z0, t0, x1, y1, z1, t1;
            int i_dummy;
            drift.GetElectronEndpoint(0, x0, y0, z0, t0, x1, y1, z1, t1, i_dummy);
            std::cout<<"end point "<<x1<<","<<y1<<std::endl;
            size_t ne = drift.GetNumberOfElectronEndpoints();
            std::cout<<ne<<" electrons!!!!!"<<std::endl;
        }

```

gives the output that `ne` is handrads of thouthends. But I only drift 1 electron, why? I didn’t use  
`AvalancheElectron`. My Garfield++ is version 5.0

```auto
end point 0.000910321,0.000856642
2404093 electrons!!!!!

```

---

<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:** [January 6, 2025, 2:18pm UTC](https://root-forum.cern.ch/t/question-when-using-avalanchemicroscopic-driftelectron/62587/6 "2025-01-06T14:18:45Z")

</div>

Hi,

how did you limit the drift area? Do you have equipotential planes surrounding the wires? Or did you constrain it using `SetArea`?  
The fact that you get a number \> 1 for the number of electrons is indeed strange.  
Could you provide a _**minimal (!) working example**_ that reproduces this issue?

---

<div class="post-metadata">

**Author:** ![Crisps](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/crisps/32/39101_2.png) [@Crisps](https://root-forum.cern.ch/u/Crisps)\
**Post date:** [January 6, 2025, 2:36pm UTC](https://root-forum.cern.ch/t/question-when-using-avalanchemicroscopic-driftelectron/62587/7 "2025-01-06T14:36:23Z")

</div>

Here is a minimal (I believe it’s minimized enough…) example:  
[minimal.cxx](https://root-forum.cern.ch/uploads/short-url/aT5NaymxqjrjkRIJcS8yHBBo9qJ.cxx) (3.7 KB)  
[IonMobility\_He+\_He.txt](https://root-forum.cern.ch/uploads/short-url/9vBXhSlIk7jcMC7S7fkc1B1fRRG.txt) (513 Bytes)  
[He\_90\_iC4H10\_10\_760Torr\_293.15K\_10emin\_to\_500000emax.gas.txt](https://root-forum.cern.ch/uploads/short-url/t4mX8VD7jHUKxaUMuwDGaOscILu.txt) (229.8 KB)  
I changed the gas file extension to `txt` in order to upload it.

---

<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:** [January 6, 2025, 3:27pm UTC](https://root-forum.cern.ch/t/question-when-using-avalanchemicroscopic-driftelectron/62587/8 "2025-01-06T15:27:31Z")

</div>

Thanks! Your program still had quite a lot of lines that were not really relevant for reproducing the issue that you reported. I trimmed it down further:

[minimal.cxx](https://root-forum.cern.ch/uploads/short-url/6qWqpnCgkj3Del2EATdLTUDBOYB.cxx) (1.9 KB)

With this program, and using the HEAD version of Garfield, I’m not able to reproduce the problem that you encountered. Both with `AvalancheMicroscopic` and `AvalancheMC` it runs reasonably fast and the electron ends up on the central wire.

Could you try with the HEAD version of Garfield? The “v5.0” tag is about a year old; I don’t remember offhand any major bugfix that could explain the problem that you have, but still…

 ![mc](https://root-forum.cern.ch/uploads/default/original/3X/9/5/95e9415a9278f5afbaaaaff64c27881ff497bdf4.jpeg)  
 ![microscopic](https://root-forum.cern.ch/uploads/default/original/3X/2/e/2e7252cc1815a6879c7ebd603589d93a238b33c2.jpeg)

---

<div class="post-metadata">

**Author:** ![Crisps](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/crisps/32/39101_2.png) [@Crisps](https://root-forum.cern.ch/u/Crisps)\
**Post date:** [January 6, 2025, 3:44pm UTC](https://root-forum.cern.ch/t/question-when-using-avalanchemicroscopic-driftelectron/62587/10 "2025-01-06T15:44:30Z")

</div>

Can I ask that did you used the same gas file that I provided? Just to exclude the potential source of this issue.

---

<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:** [January 6, 2025, 3:58pm UTC](https://root-forum.cern.ch/t/question-when-using-avalanchemicroscopic-driftelectron/62587/11 "2025-01-06T15:58:59Z")

</div>

Yes, I used the gas file that you sent…

---

<div class="post-metadata">

**Author:** ![Crisps](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/crisps/32/39101_2.png) [@Crisps](https://root-forum.cern.ch/u/Crisps)\
**Post date:** [January 6, 2025, 4:03pm UTC](https://root-forum.cern.ch/t/question-when-using-avalanchemicroscopic-driftelectron/62587/12 "2025-01-06T16:03:57Z")

</div>

OK, I just tried to run this example by the newest version on GitLab and it works just fine, then it should be some bugs in the old version (tag 5.0). I will use newest version, thank you so much!

---

<div class="post-metadata">

**Author:** ![Crisps](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/crisps/32/39101_2.png) [@Crisps](https://root-forum.cern.ch/u/Crisps)\
**Post date:** [January 6, 2025, 4:12pm UTC](https://root-forum.cern.ch/t/question-when-using-avalanchemicroscopic-driftelectron/62587/13 "2025-01-06T16:12:59Z")

</div>

Just a small question, I used `AvalancheMC` and `AvalancheMicroscopic` to drift electrons, and it’s 0.004s and 0.15s per drifting simulation respectively, are these reasonable values? Especially latter is quite slower (I understand it’s calculating cross section, just wondering if it’s normal value…)

---

<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:** [January 6, 2025, 4:33pm UTC](https://root-forum.cern.ch/t/question-when-using-avalanchemicroscopic-driftelectron/62587/14 "2025-01-06T16:33:23Z")

</div>

To me these values seems quite reasonable. with`AvalancheMicroscopic` you do not calculate the cross sections, but you simulate all individual electron gas molecule collisions, which can easily run into millions of steps. `AvalancheMC` is as you see at least 10x faster.  
greets  
Piet

---

<div class="post-metadata">

**Author:** ![Crisps](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/crisps/32/39101_2.png) [@Crisps](https://root-forum.cern.ch/u/Crisps)\
**Post date:** [January 7, 2025, 12:29am UTC](https://root-forum.cern.ch/t/question-when-using-avalanchemicroscopic-driftelectron/62587/15 "2025-01-07T00:29:41Z")

</div>

Understood, thank you!

---

<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 21, 2025, 12:30am UTC](https://root-forum.cern.ch/t/question-when-using-avalanchemicroscopic-driftelectron/62587/16 "2025-01-21T00:30:33Z")

</div>

Closed on January 21, 2025, 12:30am UTC

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