# Problems with DriftLineRKF and AvalancheMicroscopic

**URL:** <https://root-forum.cern.ch/t/problems-with-driftlinerkf-and-avalanchemicroscopic/63230>\
**Category:** Garfield++\
**Created:** [March 28, 2025, 5:42am UTC](https://root-forum.cern.ch/t/problems-with-driftlinerkf-and-avalanchemicroscopic/63230 "2025-03-28T05:42:47Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![VictorM](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/victorm/32/36543_2.png) [@VictorM](https://root-forum.cern.ch/u/VictorM)\
**Post date:** [March 28, 2025, 5:42am UTC](https://root-forum.cern.ch/t/problems-with-driftlinerkf-and-avalanchemicroscopic/63230/1 "2025-03-28T05:42:48Z")

</div>

Hello,  
I have two problems when simulating electron avalanches in my geometry:

1. The avalanche size is very different from DriftLineRKF (~10^5) to AvalancheMicroscopic (~10^2).

2. When I enhance the field (boundary condition 2, cathode, in sif file), I get the error:  
DriftLineRKF::DriftLine: Step size has become smaller than int. accuracy. Stop.  
DriftLineRKF::AddIonTail:  
Unable to obtain an ion tail; tail not added.  
For weaker fields like -550 V, this error does not occur. I enhanced the accuracy using the statement (also with lower numbers):  
void SetIntegrationAccuracy(const double eps = 1.e-4);

There are similar topics in the forum, but they didn’t help.  
Does someone has an idea what is happening here or see a problem in my code? It is attached. I use Gmsh+Elmer+Garfield++.

Thank you!

[aval.zip](https://root-forum.cern.ch/uploads/short-url/tMIw9lhfgkXqmPPYkc9vDc0TfRB.zip) (14.5 KB)

---

<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 28, 2025, 6:58am UTC](https://root-forum.cern.ch/t/problems-with-driftlinerkf-and-avalanchemicroscopic/63230/2 "2025-03-28T06:58:06Z")

</div>

Hello,

Adding @hschindl in the loop!

D

---

<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 28, 2025, 8:04am UTC](https://root-forum.cern.ch/t/problems-with-driftlinerkf-and-avalanchemicroscopic/63230/3 "2025-03-28T08:04:33Z")

</div>

Dear @VictorM

I am missing a couple of files to compile your code. Could you maybe upload a new version that includes the following:

> THGEM/mesh.header does not exist.  
> THGEM/mesh.elements does not exist.  
> THGEM/mesh.nodes does not exist.  
> THGEM/THGEM.result does not exist.  
> THGEM/THGEM\_WTlel.result does not exist.

I ll try to install gmesh and elmer in the meanwhile and see if I can calculate those files.  
Thanks  
Piet

---

<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 28, 2025, 9:21am UTC](https://root-forum.cern.ch/t/problems-with-driftlinerkf-and-avalanchemicroscopic/63230/4 "2025-03-28T09:21:07Z")

</div>

Hi,

if there is a discrepancy between `DriftLineRKF` and `AvalancheMicroscopic`, it could be due to the low pressure. Can you try switching on RKN steps in `AvalancheMicroscopic` (`EnableRKNSteps`)? Also, the avalanche size that you get from `AvalancheMicroscopic` will fluctuate from avalanche to avalanche; the _average_ gain should be consistent with `DriftLineRKF` though.

Regarding the message `Unable to obtain an ion tail; tail not added.`: was the ion mobility imported successfully? Can you show the output log?

I also noticed a couple of things reading through the code:

- The lines

```cpp
 const size_t nMaterials = elm.GetNumberOfMaterials();
  for (size_t i = 0; i < nMaterials; ++i) {
    const double eps = elm.GetPermittivity(i);
    if (fabs(eps - 1.) < 1.e-3) elm.SetMedium(i, &gas);
  }

```

and

```cpp
  elm.SetGas(&gas);

```

are redundant, i. e. do the same thing (associate regions with ε = 1 with the gas medium).

- The lines

```cpp
void SetIntegrationAccuracy(const double eps = 1.e-4);
void EnableSignalCalculation(const bool on = true);
void GetGain(const double eps = 1.e-4);
void GetEndPoint(double& x, double& y, double& z, double& t, int& st);

```

are probably left-overs that you copy+pasted into the code? You should remove them.

---

<div class="post-metadata">

**Author:** ![VictorM](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/victorm/32/36543_2.png) [@VictorM](https://root-forum.cern.ch/u/VictorM)\
**Post date:** [March 28, 2025, 6:07pm UTC](https://root-forum.cern.ch/t/problems-with-driftlinerkf-and-avalanchemicroscopic/63230/5 "2025-03-28T18:07:58Z")

</div>

Thank you for your reply! The files are too large for uploading them here. I try to share them with you, I’ll let you know asap.

---

<div class="post-metadata">

**Author:** ![VictorM](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/victorm/32/36543_2.png) [@VictorM](https://root-forum.cern.ch/u/VictorM)\
**Post date:** [March 28, 2025, 10:13pm UTC](https://root-forum.cern.ch/t/problems-with-driftlinerkf-and-avalanchemicroscopic/63230/6 "2025-03-28T22:13:35Z")

</div>

Thank you for reviewing the code! Yes, it requires some clean-up…

I now used EnableRKNSteps for AvalancheMicroscopic and will check whether the avalanches are now similar in size to those calculated using RKF. Thank you for this hint! I did not find it in the documentation, is it described somewhere what this is?

The output is attached. The IonMobility was imported successfully.  
I couldn’t get rid of the accuracy problem when playing around with SetIntegrationAccuracy.

[nohup.zip](https://root-forum.cern.ch/uploads/short-url/4RoXEblEn7n58bq1TSzL1DDGmv1.zip) (3.2 KB)

---

<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 29, 2025, 2:04pm UTC](https://root-forum.cern.ch/t/problems-with-driftlinerkf-and-avalanchemicroscopic/63230/7 "2025-03-29T14:04:34Z")

</div>

There is a (very brief) description of the method on page 85 of the user guide:

> **[UserGuide.pdf](https://garfieldpp.web.cern.ch/garfieldpp/documentation/UserGuide.pdf)**
>
> 746.66 KB

PS: you did not set the integration accuracy explicitly in the program you sent.

---

<div class="post-metadata">

**Author:** ![VictorM](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/victorm/32/36543_2.png) [@VictorM](https://root-forum.cern.ch/u/VictorM)\
**Post date:** [March 31, 2025, 8:24pm UTC](https://root-forum.cern.ch/t/problems-with-driftlinerkf-and-avalanchemicroscopic/63230/9 "2025-03-31T20:24:50Z")

</div>

Thanks again.

I added something like

> drift.SetIntegrationAccuracy(1.e-3);

Then, the error

> DriftLineRKF::AddIonTail:  
> Unable to obtain an ion tail; tail not added.

disappears. The error

> DriftLineRKF::DriftLine: Step size has become smaller than int. accuracy. Stop.

persists. Only for really high values like 10, this error disappears. What is a reasonable value for the accuracy?  
I also tried to set a maximum step size of 1e-3, but that doesn’t help here.  
As said, for lower fields, this problem does not occur.

Regarding AvalancheMicroscopic: Using

> aval.EnableRKNSteps(true);

on the first look. the avalanches are still underestimated, compared the DriftLineRKF result, by a factor of about 3 to 10 - depending on the fields. I will have a closer look at it.

---

<div class="post-metadata">

**Author:** ![VictorM](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/victorm/32/36543_2.png) [@VictorM](https://root-forum.cern.ch/u/VictorM)\
**Post date:** [March 31, 2025, 8:25pm UTC](https://root-forum.cern.ch/t/problems-with-driftlinerkf-and-avalanchemicroscopic/63230/10 "2025-03-31T20:25:47Z")

</div>

@Piet, in case you still want to try to run the code, here are the mesh files: [mesh – Google&nbsp;Drive](https://drive.google.com/drive/folders/1HO7bg9LTCt93ogtwDXYTsOT4PEWPkesE?usp=sharing)

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:** [April 14, 2025, 8:26pm UTC](https://root-forum.cern.ch/t/problems-with-driftlinerkf-and-avalanchemicroscopic/63230/11 "2025-04-14T20:26:01Z")

</div>

Closed on April 14, 2025, 8:26pm UTC

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