Dear all,
I’m currently simulating negative ion drift using AvalancheMC::DriftNegativeIon with a field map from COMSOL (ComponentComsol). The simulation generally works well, but for certain starting points, the drift appears to hang — the function never returns, memory usage increases continuously, and the program does not proceed beyond that call.
Here are some details:
- I tried to debug what happened
std::cout<<(*x_s)[i]/10<<" "<<(*y_s)[i]/10<<" "<<(*z_s)[i]/10+250<<" "<<i<<std::endl;
drift.DriftNegativeIon((*x_s)[i]/10,(*y_s)[i]/10,(*z_s)[i]/10+250,0);
std::cout<<"Drift done"<<std::endl;
The terminal shows
......
50.1142 -16.9341 160.907 1180
Drift done
50.1145 -17 160.832 1181
Drift done
50.122 -17.0694 160.761 1182
So (x, y, z) = (50.122, -17.0694, 160.761) caused the problem.
- Step size configuration
auto step = [](double x, double y, double z) {
if (z>3.) return 1.;
else return 1e-3;
};
drift.SetStepDistanceFunction(step);
No error message is shown, but DriftNegativeIon(…) does not complete.
- I attempted to check the drift region using:
sensor.IsInside(x, y, z)
and it returns true.
Questions:
- What could cause DriftNegativeIon to hang even when the point seems inside the drift region?
- Is there any built-in timeout or maximum step count mechanism in AvalancheMC to prevent infinite loops?
- Is there a way to safely skip problematic points during simulation?