Commit 14175658 authored by Paul Schütze's avatar Paul Schütze
Browse files

Merge branch 'dynamicChargePerStep_backport' into 'v2.3-stable'

[v2.3-stable] Changed default value of `max_charge_groups` to 0

See merge request allpix-squared/allpix-squared!800
parents 9d188d5c 5dff1e92
Loading
Loading
Loading
Loading
+18 −3
Original line number Diff line number Diff line
@@ -66,6 +66,7 @@ GenericPropagationModule::GenericPropagationModule(Configuration& config,
    config_.setDefault<double>("timestep_max", Units::get(0.5, "ns"));
    config_.setDefault<double>("integration_time", Units::get(25, "ns"));
    config_.setDefault<unsigned int>("charge_per_step", 10);
    config_.setDefault<unsigned int>("max_charge_groups", 0);
    config_.setDefault<double>("temperature", 293.15);

    // Models:
@@ -112,6 +113,7 @@ GenericPropagationModule::GenericPropagationModule(Configuration& config,
    propagate_electrons_ = config_.get<bool>("propagate_electrons");
    propagate_holes_ = config_.get<bool>("propagate_holes");
    charge_per_step_ = config_.get<unsigned int>("charge_per_step");
    max_charge_groups_ = config_.get<unsigned int>("max_charge_groups");

    // Enable multithreading of this module if multithreading is enabled and no per-event output plots are requested:
    // FIXME: Review if this is really the case or we can still use multithreading
@@ -534,9 +536,9 @@ void GenericPropagationModule::initialize() {

        group_size_histo_ = CreateHistogram<TH1D>("group_size_histo",
                                                  "Charge carrier group size;group size;number of groups transported",
                                                  static_cast<int>(charge_per_step_ - 1),
                                                  1,
                                                  static_cast<double>(charge_per_step_));
                                                  static_cast<int>(100 * charge_per_step_),
                                                  0,
                                                  static_cast<int>(100 * charge_per_step_));

        recombine_histo_ =
            CreateHistogram<TH1D>("recombination_histo",
@@ -604,6 +606,8 @@ void GenericPropagationModule::run(Event* event) {
            continue;
        }

        total_deposits_++;

        // Loop over all charges in the deposit
        unsigned int charges_remaining = deposit.getCharge();

@@ -611,6 +615,13 @@ void GenericPropagationModule::run(Event* event) {
                   << Units::display(deposit.getLocalPosition(), {"mm", "um"});

        auto charge_per_step = charge_per_step_;
        if(max_charge_groups_ > 0 && deposit.getCharge() / charge_per_step > max_charge_groups_) {
            charge_per_step = static_cast<unsigned int>(ceil(static_cast<double>(deposit.getCharge()) / max_charge_groups_));
            deposits_exceeding_max_groups_++;
            LOG(INFO) << "Deposited charge: " << deposit.getCharge()
                      << ", which exceeds the maximum number of charge groups allowed. Increasing charge_per_step to "
                      << charge_per_step << " for this deposit.";
        }
        while(charges_remaining > 0) {
            // Define number of charges to be propagated and remove charges of this step from the total
            if(charge_per_step > charges_remaining) {
@@ -907,6 +918,8 @@ GenericPropagationModule::propagate(const ROOT::Math::XYZPoint& pos,

void GenericPropagationModule::finalize() {
    if(output_plots_) {
        group_size_histo_->Get()->GetXaxis()->SetRange(1, group_size_histo_->Get()->GetNbinsX() + 1);

        step_length_histo_->Write();
        drift_time_histo_->Write();
        uncertainty_histo_->Write();
@@ -921,4 +934,6 @@ void GenericPropagationModule::finalize() {
                               std::max(1u, static_cast<unsigned int>(total_propagated_charges_));
    LOG(INFO) << "Propagated total of " << total_propagated_charges_ << " charges in " << total_steps_
              << " steps in average time of " << Units::display(average_time, "ns");
    LOG(INFO) << deposits_exceeding_max_groups_ * 100.0 / total_deposits_ << "% of deposits have charge exceeding the "
              << max_charge_groups_ << " charge groups allowed, with a charge_per_step value of " << charge_per_step_ << ".";
}
+2 −0
Original line number Diff line number Diff line
@@ -104,6 +104,7 @@ namespace allpix {
        bool output_plots_{}, output_linegraphs_{}, output_animations_{}, output_plots_lines_at_implants_{};
        bool propagate_electrons_{}, propagate_holes_{};
        unsigned int charge_per_step_{};
        unsigned int max_charge_groups_{};

        // Models for electron and hole mobility and lifetime
        Mobility mobility_;
@@ -125,6 +126,7 @@ namespace allpix {
        std::atomic<unsigned int> total_propagated_charges_{};
        std::atomic<unsigned int> total_steps_{};
        std::atomic<long unsigned int> total_time_picoseconds_{};
        std::atomic<unsigned int> total_deposits_{}, deposits_exceeding_max_groups_{};
        Histogram<TH1D> step_length_histo_;
        Histogram<TH1D> drift_time_histo_;
        Histogram<TH1D> uncertainty_histo_;
+2 −1
Original line number Diff line number Diff line
@@ -5,7 +5,7 @@
**Output**: PropagatedCharge

### Description
Simulates the propagation of electrons and/or holes through the sensitive sensor volume of the detector. It allows to propagate sets of charge carriers together in order to speed up the simulation while maintaining the required accuracy. The propagation process for these sets is fully independent and no interaction is simulated. The maximum size of the set of propagated charges and thus the accuracy of the propagation can be controlled.
Simulates the propagation of electrons and/or holes through the sensitive sensor volume of the detector. It allows to propagate sets of charge carriers together in order to speed up the simulation while maintaining the required accuracy. The propagation process for these sets is fully independent and no interaction is simulated. The maximum size of the set of propagated charges and thus the accuracy of the propagation can be controlled via the `charge_per_step` parameter. The maximum number of charge groups to be propagated for a single deposit position can be controlled via the `max_charge_groups` parameter.

The propagation consists of a combination of drift and diffusion simulation. The drift is calculated using the charge carrier velocity derived from the charge carrier mobility and the magnetic field via a calculation of the Lorentz drift. The correct mobility for either electrons or holes is automatically chosen, based on the type of the charge carrier under consideration. Thus, also input with both electrons and holes is treated properly. The mobility model can be chosen using the `mobility_model` parameter, and a list of available models can be found in the user manual.

@@ -44,6 +44,7 @@ This module requires an installation of Eigen3.
* `trapping_model`: Model for simulating charge carrier trapping from radiation-induced damage. Defaults to `none`, a list of available models can be found in the documentation. All models require explicitly setting a fluence parameter.
* `fluence`: 1MeV-neutron equivalent fluence the sensor has been exposed to.
* `charge_per_step` : Maximum number of charge carriers to propagate together. Divides the total number of deposited charge carriers at a specific point into sets of this number of charge carriers and a set with the remaining charge carriers. A value of 10 charges per step is used by default if this value is not specified.
* `max_charge_groups`: Maximum number of charge groups to propagate from a single deposit point. Temporarily increases the value of `charge_per_step` to reduce the number of propagated groups if the deposit is larger than the value `max_charge_groups`*`charge_per_step`, thus reducing the negative performance impact of unexpectedly large deposits. If it is set to 0, there is no upper limit on the number of charge groups propagated. The default value is 0 charge groups.
* `spatial_precision` : Spatial precision to aim for. The timestep of the Runge-Kutta propagation is adjusted to reach this spatial precision after calculating the uncertainty from the fifth-order error method. Defaults to 0.25nm.
* `timestep_start` : Timestep to initialize the Runge-Kutta integration with. Appropriate initialization of this parameter reduces the time to optimize the timestep to the *spatial_precision* parameter. Default value is 0.01ns.
* `timestep_min` : Minimum step in time to use for the Runge-Kutta integration regardless of the spatial precision. Defaults to 1ps.
+1 −0
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ depletion_voltage = 150V
log_level = INFO
temperature = 293K
charge_per_step = 1
max_charge_groups = 0
propagate_electrons = false
propagate_holes = true
recombination_model = "srh_auger"
+1 −0
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ depletion_voltage = 150V
log_level = INFO
temperature = 293K
charge_per_step = 1
max_charge_groups = 0
propagate_electrons = false
propagate_holes = true
trapping_model = "custom"
Loading