Drift Chamber Simulation keeps getting killed

Hi,
I’m simulating a Drift Chamber and use Comsol as a field solver and adapted the Comsol example. 100 muons passing through the chamber at different distances from the anode wire and I want to collect all the data from drift.GetEndPoint(xf, yf, zf, tf, status) and save it in a file. I have run it before with distance spacings of 1 cm and it worked fine. Now I tried to rerun the code with a spacing of 1 mm and the program keeps taking too long and gets killed. I use a gas file that covers energies from 100 V/cm to 500000 V/cm in 20 steps with a logarithmic spacing because I have electric potentials of -10000 V to 2000 V. I have tried different gas, mesh and potential files to see if it is maybe too much to load into garfield but nothing changed. This is my code:

#include <cstdlib>
#include <iostream>
#include <fstream>

#include <sys/stat.h>
#include <sys/types.h> 

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

#include "Garfield/ComponentComsol.hh"
#include "Garfield/ViewField.hh"
#include "Garfield/ViewFEMesh.hh"
#include "Garfield/MediumMagboltz.hh"
#include "Garfield/Sensor.hh"
#include "Garfield/AvalancheMicroscopic.hh"
#include "Garfield/AvalancheMC.hh"
#include "Garfield/Random.hh"
#include "Garfield/DriftLineRKF.hh"
#include "Garfield/TrackHeed.hh"

using namespace Garfield;

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

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

  // Load the field map.
  ComponentComsol fm;
  fm.Initialise("mesh.mphtxt", "dielectrics.dat", "field.txt", "mm");
  fm.PrintRange();


  // Setup the gas.
   MediumMagboltz gas;
   gas.LoadGasFile("ar_82_co2_18_293K_1bar_500000.gas");
  // Load the ion mobilities.
  const std::string path = std::getenv("GARFIELD_INSTALL");
  gas.LoadIonMobility(path + "/share/Garfield/Data/IonMobility_Ar+_Ar.txt");
  // Associate the gas with the corresponding field map material.
  fm.SetGas(&gas); 
  fm.PrintMaterials();
 
  // Create the sensor.
  Sensor sensor;
  sensor.AddComponent(&fm);
  //sensor.SetArea(-25.2, 0, -0.5, 0, 0.1, 0.5);


  // Set up Heed.
  TrackHeed track;
  track.SetParticle("muon");
  track.SetEnergy(3.e9);
  track.SetSensor(&sensor);

  // RKF integration.
  DriftLineRKF drift(&sensor);
  //drift.SetGainFluctuationsPolya(0., 20000.);
  
  
  // Create a new directory
  const std::string outputDir = "electron_positions_mu_3GeV_293K_1mm_test/";
  mkdir(outputDir.c_str(), 0777);
  
  for (double x0 = -0.1; x0 >= -25.2; x0 -= 0.1) {
        std::ofstream outFile(outputDir + "electron_positions_" + std::to_string(x0) + ".txt");
        if (!outFile) {
            std::cerr << "Fehler beim Erstellen der Datei!" << std::endl;
            return 1;
        }

        // Write the header
        outFile << "x y z E t x_e y_e z_e t_e\n";

        constexpr unsigned int nEvents = 100;
        for (unsigned int i = 0; i < nEvents; ++i) {
            std::cout << i << "/" << nEvents << "\n";
            sensor.ClearSignal();
            track.NewTrack(x0, 0.05, 0.496, 0, 0, 0, -1);
            for (const auto& cluster : track.GetClusters()) {
                for (const auto& electron : cluster.electrons) {
                    double xe = electron.x;
                    double ye = electron.y;
                    double ze = electron.z;
                    double ee = electron.e;
                    double te = electron.t;

                    drift.DriftElectron(electron.x, electron.y, electron.z, electron.t);
                    double xf = 0., yf = 0., zf = 0., tf = 0.;
                    int status = 0;
                    drift.GetEndPoint(xf, yf, zf, tf, status);

                    // Write the data to the file
                    outFile << xe << " " << ye << " " << ze << " " << ee << " " << te << " " << xf << " " << yf << " " << zf << " " << tf << "\n";
                }
            }
        }

        outFile.close();
    }

  app.Run(kTRUE);
}

And this is the terminal output:

Do you have any idea what could be the reason for the program to get stopped after a specific time? I would appreciate your help, thanks!

Dear @JFBW

How exactly did you scale your geometry from 1cm spaced wires to your 1mm spaced wires? Did you make a new geometry in comsol and exported new fields or did you modify “cm” into “mm” in the line below?

I would suggest to keep an eye on GPU and Mem use of your pc and check if there is something anomalous ongoing and try to add more debug output: how many clusters are there for each track and what is the gain for each drifted electron? These could help you (us) to understand better what is going (wr)on(g).
greets
Piet

Dear @Piet,

Thanks for your quick reply! Sorry, I forgot to mention that the chamber has only one anode wire. The Comsol files are just the mesh and field map in mm as built in Comsol. By trying other meshes I meant building a new mesh in Comsol and exporting it along with the updated field map, the “mm” was kept as it was not changed in Comsol. By spacing I just mean the initial positions of the muons passing through the chamber. So the anode wire is at x=0 and the muons start from 0.1 cm anode distance to 25.2 cm anode distance in 1 cm steps for the first simulation where everything went well and now in 0.1 cm steps. This is represented by this line

The gain varies very much from about 75 to 10⁹, I think because all the secondary electrons lost by e.g. attachment don’t reach the gain region at x=0. The number of clusters varies from 25 to 35, which seems fine since the detector is only 1 cm high. I have tried reducing the number of events, and using 1 instead of 100 events works fine.
I’ve also checked the RAM and swap file and they don’t seem to be working at their limits. But for the calculation only one of the 8 CPUs is used, which is running at 100%…
Is there a way to implement the use of more CPUs in parallel?

Dear @JFBW

(1) Thanks for your information … so your geometry is more a Drift Tube with a single wire, not a (multi-wire) Drift Chamber. Do you have a circular geometry? what is the radius of your (outer) tube and of your anode wire? In case it is more a parallel plane geometry, what exactly are the cathodes and how far are they from the wire? Can you make a small drawing of your elementary cell you are simulating? Understanding your geometry is fundamental to get an idea of what you are doing.

(2) A wire-based detector typically operates at a gain of 1-few 10^5, with the exception of drift chambers that want to do cluster-counting, there gains can be few 10^6. A gain of 10^9 seems definitely too high and not a realistic condition. Could you think of trying to simulate at lower voltage?

(3) to run with more CPUs in parallel you should have a look (study) to run garfield++ in multithread mode. I know some groups are working on this code (using MPI), but I am not sure this code has been integrated or whether there are examples available. Maybe @hschindl can tell?

Dear @Piet,

(1 and 2) Here is a schematic drawing of a similar chamber from https://indico.cern.ch/event/426015/contributions/1047606/attachments/906077/1278746/DriftChamber_ICFA2005.pdf. In my case the anode wire is located at x=0 and the drift area is extending in negative x-direction. So it’s basically half a tube with a drift chamber with a constant drift field being the other half.
grafik

I will try lower voltages but in the end I have to stick to the said voltages to get comparable results, but I thought about the voltages being an issue as well, because for some events I get errors like this:

DriftLineRKF::IntegrateAlpha:
    Cannot retrieve alpha at mid point or end point.
DriftLineRKF::Avalanche:
    Cannot retrieve alpha at drift line point 1669, segment 2
DriftLineRKF::Avalanche:
    Warning: Integrating the Townsend coefficients would lead to exponential overflow.
    Avalanche truncated.

I have read here How is the induction signal calculated in garfield++? that at least the exponential overflow could be caused by the voltages. I don’t know if it could be the gas file, because I checked for the large field strength near the anode wire to be covered. Do you know, where these errors could come from and if it’s ok to have a few of them for one muon event creating about 70-90 drift lines?

(3) I will have a look and see what’s possible for me to do, thank you!

Hi,
not sure if multi-threading is the solution here… Can you try a few things to help track down where the problem comes from?

Does it happen for specific (ranges of) starting points? Instead of simulating a track and looping over the clusters and electrons, can you simulate drift lines from specific initial positions? Then once you have identified a “problematic” initial position, enable debugging in DriftLineRKF and look at the debug output.

The messages Cannot retrieve alpha... and Avalanche truncated. suggest that there could be an issue with your field map. The first message means that when integrating the Townsend coefficient over a drift line segment, one of the integration points does not have a valid electric field; which is quite odd. Can you make a plot of the electric field and/or potential in your chamber?

Hi @hschindl , thank you for your reply!
Here are the plots of the profile and the contour:


As I tried to figure out the problematic initial positions I noticed, that the problem starts happening in the left region of the chamber and, as you can see in the contour plot, the field lines at the top and bottom are getting “pushed” inside the chamber the further you get away from the anode wire because the chamber is surrounded by a ground potential cage and the potential difference between ground and field shaping cathode strips is getting higher the further you go to the left.
The debugging looks something like this (just one drift line, because the terminal can not store all the information of all drift lines):

DriftLineRKF::DriftLine:
    Initial step size: 1.71766e-06 ns.
    Step size ok.
    Adapting H to 16.2894.
    H restricted to 10 times the previous value.
    Step size ok.
    Adapting H to 56.9229.
    H restricted to 10 times the previous value.
    Step size ok.
    Adapting H to 143.126.
    H restricted to 10 times the previous value.
    Step size ok.
    Adapting H to 177.138.
    H restricted to 10 times the previous value.
    Step size ok.
    Adapting H to 56.0562.
    H restricted to 10 times the previous value.
    Step size ok.
    Adapting H to 17.7076.
    H restricted to 10 times the previous value.
    Step size ok.
    Adapting H to 5.56944.
    Step size ok.
    Adapting H to 0.25509.
    Step size ok.
    Adapting H to 22.3904.
    H restricted to 10 times the previous value.
    Step size ok.
    Adapting H to 0.67132.
    Step size ok.
    Adapting H to 1.84541.
    Step size ok.
    Adapting H to 0.13672.
    Step size ok.
    Adapting H to 14.3577.
    H restricted to 10 times the previous value.
    Step size ok.
    Adapting H to 4.54852.
    Step size ok.
    Adapting H to 2.52581.
    Step size ok.
    Adapting H to 3.41895.
    Step size ok.
    Adapting H to 2.98205.
    Step size ok.
    Adapting H to 0.442169.
    Step size ok.
    Adapting H to 7.5187.
    H restricted to 10 times the previous value.
    Step size ok.
    Adapting H to 2.50551.
    Step size ok.
    Adapting H to 3.24568.
    Step size ok.
    Adapting H to 0.230882.
    Step size ok.
    Adapting H to 10.3833.
    H restricted to 10 times the previous value.
    Step size ok.
    Adapting H to 3.37231.
    Step size ok.
    Adapting H to 2.8335.
    Step size ok.
    Adapting H to 3.06927.
    Step size ok.
    Adapting H to 2.95992.
    Step size ok.
    Adapting H to 0.2304.
    Step size ok.
    Adapting H to 11.6333.
    H restricted to 10 times the previous value.
    Step size ok.
    Adapting H to 3.77165.
    Step size ok.
    Adapting H to 3.00245.
    Step size ok.
    Adapting H to 0.187006.
    Step size ok.
    Adapting H to 10.6307.
    H restricted to 10 times the previous value.
    Step size ok.
    Adapting H to 0.428683.
    Step size ok.
    Adapting H to 6.44371.
    H restricted to 10 times the previous value.
    Step size ok.
    Adapting H to 2.04792.
    Step size ok.
    Adapting H to 0.175905.
    Step size ok.
    Adapting H to 15.1943.
    H restricted to 10 times the previous value.
    Step size ok.
    Adapting H to 4.80656.
    Step size ok.
    Adapting H to 2.91.
    Step size ok.
    Adapting H to 3.77202.
    Step size ok.
    Adapting H to 0.277002.
    Step size ok.
    Adapting H to 10.0358.
    H restricted to 10 times the previous value.
    Step size ok.
    Adapting H to 3.15249.
    Step size ok.
    Adapting H to 0.238162.
    Step size ok.
    Adapting H to 14.4779.
    H restricted to 10 times the previous value.
    Step size ok.
    Adapting H to 4.54788.
    Step size ok.
    Adapting H to 3.27894.
    Step size ok.
    Adapting H to 3.9178.
    Step size ok.
    Adapting H to 0.177971.
    Step size ok.
    Adapting H to 18.2938.
    H restricted to 10 times the previous value.
    Step size ok.
    Adapting H to 5.74092.
    Step size ok.
    Adapting H to 0.318928.
    Step size ok.
    Adapting H to 20.0087.
    H restricted to 10 times the previous value.
    Step size ok.
    Adapting H to 6.25434.
    Step size ok.
    Adapting H to 0.259219.
    Step size ok.
    Adapting H to 14.9165.
    H restricted to 10 times the previous value.
    Step size ok.
    Adapting H to 4.63211.
    Step size ok.
    Adapting H to 3.44032.
    Step size ok.
    Adapting H to 2.09837.
    Step size ok.
    Adapting H to 0.278564.
    Step size ok.
    Adapting H to 43.3099.
    H restricted to 10 times the previous value.
    Step size ok.
    Adapting H to 14.1499.
    Step size ok.
    Adapting H to 0.383182.
    Step size ok.
    Adapting H to 35.9524.
    H restricted to 10 times the previous value.
    Step size ok.
    Adapting H to 10.7857.
    Step size ok.
    Adapting H to 0.1786.
    Step size ok.
    Adapting H to 21.0931.
    H restricted to 10 times the previous value.
    Step size ok.
    Adapting H to 6.30484.
    Step size ok.
    Adapting H to 0.181722.
    Step size ok.
    Adapting H to 27.867.
    H restricted to 10 times the previous value.
    Step size ok.
    Adapting H to 8.47639.
    Step size ok.
    Adapting H to 0.3005.
    Step size ok.
    Adapting H to 15.3818.
    H restricted to 10 times the previous value.
    Step size ok.
    Adapting H to 4.35372.
    Step size ok.
    Adapting H to 3.54612.
    Step size ok.
    Adapting H to 4.20043.
    Step size ok.
    Adapting H to 0.197219.
    Step size ok.
    Adapting H to 20.3179.
    H restricted to 10 times the previous value.
    Step size ok.
    Adapting H to 7.1218.
    Step size ok.
    Adapting H to 4.35069.
    Step size ok.
    Adapting H to 5.72906.
    Step size ok.
    Adapting H to 0.374313.
    Step size ok.
    Adapting H to 25.6109.
    H restricted to 10 times the previous value.
    Step size ok.
    Adapting H to 7.52115.
    Step size ok.
    Adapting H to 0.290683.
    Step size ok.
    Adapting H to 17.7757.
    H restricted to 10 times the previous value.
    Step size ok.
    Adapting H to 6.44423.
    Step size ok.
    Adapting H to 5.75901.
    Step size ok.
    Adapting H to 0.131088.
    Step size ok.
    Adapting H to 15.1041.
    H restricted to 10 times the previous value.
    Step size ok.
    Adapting H to 5.23516.
    Step size ok.
    Adapting H to 4.46212.
    Step size ok.
    Adapting H to 4.66102.
    Step size ok.
    Adapting H to 0.0898211.
    Step size ok.
    Adapting H to 9.42115.
    H restricted to 10 times the previous value.
    Step size ok.
    Adapting H to 2.74886.
    Step size ok.
    Adapting H to 1.34318.
    Step size ok.
    Adapting H to 2.39615.
    Step size ok.
    Adapting H to 1.67605.
    Step size ok.
    Adapting H to 2.29484.
    Step size ok.
    Adapting H to 1.9209.
    Step size ok.
    Adapting H to 0.088593.
    Step size ok.
    Adapting H to 14.494.
    H restricted to 10 times the previous value.
    Step size ok.
    Adapting H to 0.0697347.
    Step size ok.
    Adapting H to 28.1447.
    H restricted to 10 times the previous value.
    Step size ok.
    Adapting H to 8.97041.
    H restricted to 10 times the previous value.
    Step size ok.
    Adapting H to 0.0540994.
    Step size ok.
    Adapting H to 9.49108.
    H restricted to 10 times the previous value.
    Step size ok.
    Adapting H to 2.78938.
    Step size ok.
    Adapting H to 0.869285.
    Step size ok.
    Adapting H to 2.70817.
    Step size ok.
    Adapting H to 1.2832.
    Step size ok.
    Adapting H to 2.36152.
    Step size ok.
    Adapting H to 1.62048.
    Step size ok.
    Adapting H to 2.24379.
    Step size ok.
    Adapting H to 1.88018.
    Step size ok.
    Adapting H to 2.23618.
    Step size ok.
    Adapting H to 2.07999.
    Step size ok.
    Adapting H to 0.0809891.
    Step size ok.
    Adapting H to 13.2944.
    H restricted to 10 times the previous value.
    Step size ok.
    Adapting H to 3.96968.
    Step size ok.
    Adapting H to 0.056035.
    Step size ok.
    Adapting H to 6.67378.
    H restricted to 10 times the previous value.
    Step size ok.
    Adapting H to 0.0251324.
    Step size ok.
    Adapting H to 5.74437.
    H restricted to 10 times the previous value.
    Step size ok.
    Adapting H to 2.04893.
    Step size ok.
    Adapting H to 0.0511939.
    Step size ok.
    Adapting H to 3.35974.
    H restricted to 10 times the previous value.
    Step size ok.
    Adapting H to 1.55451.
    Step size ok.
    Adapting H to 0.561161.
    Step size ok.
    Adapting H to 1.55823.
    Step size ok.
    Adapting H to 0.287175.
    Step size ok.
    Adapting H to 0.683804.
    Step size ok.
    Adapting H to 0.443136.
    Step size ok.
    Adapting H to 0.512336.
    Step size ok.
    Adapting H to 0.45957.
    Step size ok.
    Adapting H to 0.0216006.
    Step size ok.
    Adapting H to 2.14637.
    H restricted to 10 times the previous value.
    Step size ok.
    Adapting H to 0.0157887.
    Step size ok.
    Adapting H to 1.30881.
    H restricted to 10 times the previous value.
    Step size ok.
    Adapting H to 0.39488.
    Step size ok.
    Adapting H to 0.233416.
    Step size ok.
    Adapting H to 0.317728.
    Step size ok.
    Adapting H to 0.270534.
    Step size ok.
    Adapting H to 0.320516.
    Step size ok.
    Adapting H to 0.530073.
    Step size ok.
    Adapting H to 0.0547367.
    Step size ok.
    Adapting H to 1.45535.
    H restricted to 10 times the previous value.
    Step size ok.
    Adapting H to 0.0679207.
    Step size ok.
    Adapting H to 1.40213.
    H restricted to 10 times the previous value.
    Step size ok.
    Adapting H to 0.0361552.
    Step size ok.
    Adapting H to 0.00278268.
    Step size ok.
    Adapting H to 3.63294.
    H restricted to 10 times the previous value.
    Step size ok.
    Adapting H to 1.18461.
    H restricted to 10 times the previous value.
    Step size ok.
    Adapting H to 0.0111768.
    Step size ok.
    Adapting H to 1.09542.
    H restricted to 10 times the previous value.
    Step size ok.
    Adapting H to 0.682553.
    Step size ok.
    Adapting H to 0.0242304.
    Step size ok.
    Adapting H to 2.83653.
    H restricted to 10 times the previous value.
    Step size ok.
    Adapting H to 0.864515.
    Step size ok.
    Adapting H to 0.102092.
    Step size ok.
    Adapting H to 1.41634.
    H restricted to 10 times the previous value.
    Step size ok.
    Adapting H to 0.324817.
    Step size ok.
    Adapting H to 0.0339764.
    Step size ok.
    Adapting H to 1.41074.
    H restricted to 10 times the previous value.
    Step size ok.
    Adapting H to 0.465813.
    Step size ok.
    Adapting H to 0.0290448.
    Step size ok.
    Adapting H to 1.81675.
    H restricted to 10 times the previous value.
    Step size ok.
    Adapting H to 0.682043.
    Step size ok.
    Adapting H to 0.048683.
    Step size ok.
    Adapting H to 1.84681.
    H restricted to 10 times the previous value.
    Step size ok.
    Adapting H to 0.151069.
    Step size ok.
    Adapting H to 0.986831.
    Step size ok.
    Adapting H to 0.10358.
    Step size ok.
    Adapting H to 0.977472.
    Step size ok.
    Adapting H to 0.0463558.
    Step size ok.
    Adapting H to 1.62687.
    H restricted to 10 times the previous value.
    Step size ok.
    Adapting H to 0.406713.
    Step size ok.
    Adapting H to 0.0459812.
    Step size ok.
    Adapting H to 1.97169.
    H restricted to 10 times the previous value.
    Step size ok.
    Adapting H to 0.0679949.
    Step size ok.
    Adapting H to 0.890165.
    H restricted to 10 times the previous value.
    Step size ok.
    Adapting H to 0.0629176.
    Step size ok.
    Adapting H to 0.0138125.
    Step size ok.
    Adapting H to 1.60258.
    H restricted to 10 times the previous value.
    Step size ok.
    Adapting H to 0.233226.
    Step size ok.
    Adapting H to 0.0355145.
    Step size ok.
    Adapting H to 0.750028.
    H restricted to 10 times the previous value.
    Step size ok.
    Adapting H to 0.0440265.
    Step size ok.
    Adapting H to 0.649733.
    H restricted to 10 times the previous value.
    Point 2 outside.
DriftLineRKF::Terminate:
    Bisection ended at cycle 13.
DriftLineRKF::Avalanche: Avalanche starts at step 166.
DriftLineRKF::Avalanche:
    Final number of electrons: 919.914
    Number of positive ions:   930.327
    Number of negative ions:   11.4133
    Charge scaling factor:     1
    Avalanche development:
 Step      Electrons     Ions
     0       1.0000000       0.0000000
     1       1.0000000       0.0000000
     2       1.0000000       0.0000000
     3       1.0000000       0.0000000
     4       1.0000000       0.0000000
     5       0.9999997       0.0000000
     6       0.9999973       0.0000000
     7       0.9999757       0.0000000
     8       0.9999279       0.0000000
     9       0.9999263       0.0000000
    10       0.9999126       0.0000000
    11       0.9999100       0.0000000
    12       0.9999055       0.0000000
    13       0.9999053       0.0000000
    14       0.9999037       0.0000000
    15       0.9999023       0.0000000
    16       0.9999021       0.0000000
    17       0.9999021       0.0000000
    18       0.9999021       0.0000000
    19       0.9999021       0.0000000
    20       0.9999021       0.0000000
    21       0.9999021       0.0000000
    22       0.9999021       0.0000000
    23       0.9999021       0.0000000
    24       0.9999021       0.0000000
    25       0.9999021       0.0000000
    26       0.9999021       0.0000000
    27       0.9999021       0.0000000
    28       0.9999021       0.0000000
    29       0.9999021       0.0000000
    30       0.9999021       0.0000000
    31       0.9999021       0.0000000
    32       0.9999021       0.0000000
    33       0.9999021       0.0000000
    34       0.9999021       0.0000000
    35       0.9999021       0.0000000
    36       0.9999021       0.0000000
    37       0.9999021       0.0000000
    38       0.9999021       0.0000000
    39       0.9999021       0.0000000
    40       0.9999021       0.0000000
    41       0.9999021       0.0000000
    42       0.9999021       0.0000000
    43       0.9999021       0.0000000
    44       0.9999021       0.0000000
    45       0.9999021       0.0000000
    46       0.9999021       0.0000000
    47       0.9999021       0.0000000
    48       0.9999021       0.0000000
    49       0.9999021       0.0000000
    50       0.9999021       0.0000000
    51       0.9999021       0.0000000
    52       0.9999021       0.0000000
    53       0.9999021       0.0000000
    54       0.9999021       0.0000000
    55       0.9999021       0.0000000
    56       0.9999021       0.0000000
    57       0.9999021       0.0000000
    58       0.9999021       0.0000000
    59       0.9999021       0.0000000
    60       0.9999021       0.0000000
    61       0.9999021       0.0000000
    62       0.9999021       0.0000000
    63       0.9999021       0.0000000
    64       0.9999021       0.0000000
    65       0.9999021       0.0000000
    66       0.9999021       0.0000000
    67       0.9999021       0.0000000
    68       0.9999021       0.0000000
    69       0.9999021       0.0000000
    70       0.9999021       0.0000000
    71       0.9999021       0.0000000
    72       0.9999021       0.0000000
    73       0.9999021       0.0000000
    74       0.9999021       0.0000000
    75       0.9999021       0.0000000
    76       0.9999021       0.0000000
    77       0.9999021       0.0000000
    78       0.9999021       0.0000000
    79       0.9999021       0.0000000
    80       0.9999021       0.0000000
    81       0.9999021       0.0000000
    82       0.9999021       0.0000000
    83       0.9999021       0.0000000
    84       0.9999021       0.0000000
    85       0.9999021       0.0000000
    86       0.9999021       0.0000000
    87       0.9999021       0.0000000
    88       0.9999021       0.0000000
    89       0.9999021       0.0000000
    90       0.9999021       0.0000000
    91       0.9999021       0.0000000
    92       0.9999021       0.0000000
    93       0.9999021       0.0000000
    94       0.9999021       0.0000000
    95       0.9999021       0.0000000
    96       0.9999021       0.0000000
    97       0.9999021       0.0000000
    98       0.9999021       0.0000000
    99       0.9999021       0.0000000
   100       0.9999021       0.0000000
   101       0.9999021       0.0000000
   102       0.9999021       0.0000000
   103       0.9999021       0.0000000
   104       0.9999021       0.0000000
   105       0.9999021       0.0000000
   106       0.9999021       0.0000000
   107       0.9999021       0.0000000
   108       0.9999021       0.0000000
   109       0.9999021       0.0000000
   110       0.9999021       0.0000000
   111       0.9999021       0.0000000
   112       0.9999021       0.0000000
   113       0.9999021       0.0000000
   114       0.9999021       0.0000000
   115       0.9999021       0.0000000
   116       0.9999021       0.0000000
   117       0.9999021       0.0000000
   118       0.9999021       0.0000000
   119       0.9999021       0.0000000
   120       0.9999021       0.0000000
   121       0.9999021       0.0000000
   122       0.9999021       0.0000000
   123       0.9999021       0.0000000
   124       0.9999021       0.0000000
   125       0.9999021       0.0000000
   126       0.9999021       0.0000000
   127       0.9999021       0.0000000
   128       0.9999021       0.0000000
   129       0.9999021       0.0000000
   130       0.9999021       0.0000000
   131       0.9999021       0.0000000
   132       0.9999021       0.0000000
   133       0.9999021       0.0000000
   134       0.9999021       0.0000000
   135       0.9999021       0.0000000
   136       0.9999021       0.0000000
   137       0.9999021       0.0000000
   138       0.9999021       0.0000000
   139       0.9999021       0.0000000
   140       0.9999021       0.0000000
   141       0.9999021       0.0000000
   142       0.9999021       0.0000000
   143       0.9999021       0.0000000
   144       0.9999021       0.0000000
   145       0.9999021       0.0000000
   146       0.9999018       0.0000000
   147       0.9998983       0.0000000
   148       0.9998623       0.0000000
   149       0.9998536       0.0000000
   150       0.9996841       0.0000000
   151       0.9996545       0.0000000
   152       0.9993557       0.0000000
   153       0.9993450       0.0000000
   154       0.9993442       0.0000000
   155       0.9993370       0.0000000
   156       0.9992490       0.0000000
   157       0.9992457       0.0000000
   158       0.9992210       0.0000000
   159       0.9989301       0.0000000
   160       0.9989083       0.0000000
   161       0.9986550       0.0000000
   162       0.9970901       0.0000000
   163       0.9968198       0.0000000
   164       0.9926035       0.0000000
   165       0.9904739       0.0000000
   166       0.9901966       0.0000000
   167       0.9869557       0.0000005
   168       0.9812052       0.0001168
   169       0.9808056       0.0000219
   170       0.9767091       0.0004756
   171       0.9693006       0.0062992
   172       0.9688943       0.0007518
   173       0.9613313       0.0048906
   174       0.9581981       0.0009937
   175       0.9456958       0.0186691
   176       0.9460416       0.0039286
   177       0.9810450       0.0720296
   178       0.9857122       0.0064876
   179       1.0672813       0.1019270
   180       1.2245882       0.1782710
   181       1.2500217       0.0278354
   182       1.6430308       0.4246799
   183       1.7383942       0.1002773
   184       4.6160879       3.0084369
   185       5.3058293       0.7032037
   186       5.4808728       0.1780734
   187       7.8138719       2.3759412
   188      16.3514777       8.6876900
   189      18.6776625       2.3519648
   190     103.2289566      85.9638937
   191     134.7282689      31.7232576
   192     919.9141479     794.3873268

This is for a drift line without an error i guess. When the program gets killed the driftLineRKF gets stuck in a loop of setting the step size H, adapting and restricting it like this:

    Step size ok.
    Adapting H to 0.00291849.
    Step size ok.
    Adapting H to 29.3596.
    H restricted to 10 times the previous value.
    Step size ok.
    Adapting H to 0.00473557.
    Step size ok.
    Adapting H to 0.00190766.
    Step size ok.
    Adapting H to 0.000788671.
    Step size ok.
    Adapting H to 52.5461.
    H restricted to 10 times the previous value.
    Step size ok.
    Adapting H to 0.0013425.
    Step size ok.
    Adapting H to 47.733.
    H restricted to 10 times the previous value.
    Step size ok.
    Adapting H to 0.00209236.
    Step size ok.

I refined the mesh and the field map in comsol to “extremely fine” and the errors are just a few now but not gone. Is it possible that the RKF integration can’t handle the shape of field lines in these regions? Or can something be done by manipulating the step size?

Yes, using DriftLineRKF with FEM field maps can be a bit tricky. Can you try imposing an upper limit to the step size? You can set the limit yourself explicitly; for instance

drift.SetMaximumStepSize(0.01);

will set the max. step size to 0.1 mm. Or you can try

drift.SetMaximumStepSize();

which will try to guess a reasonable upper limit based on the dimensions of the chamber.

I tried adjusting the step size to several values but unfortunately it didn’t solve the problem. But simulating just drift lines at different positions and simulating just one event and then simulating the drift lines works fine. Just for more than one event the calculation gets stuck.
I also tried do disable the avalanche calculation but it did not help. I noticed that for the drift lines that were calculated correctly the gain can still be obtained by double gain = drift.GetGain(); although the avalanche calculation is disabled. Is that correct? I added the line drift.EnableAvalanche(false); before the drift.DriftElectron(xe, ye, ze, te);.

Would it be a better choice to use AvalancheMC to calculate the drift?

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