Commit 1655c078 authored by Håkan Wennlöf's avatar Håkan Wennlöf
Browse files

Added setting for `max_charge_bunches` in [TransientPropagation], to reduce...

Added setting for `max_charge_bunches` in [TransientPropagation], to reduce the negative effects of unexpectedly large energy deposits.

The setting allows a user to decide on a maximum number of charge bunches that can be propagated form a single deposit. Setting this overrides and increases `charge_per_step` for any deposit that exceeds the product of `charge_per_step` and `max_charge_bunches`. This speeds up handling of large deposits, while reducing the simulation precision for them.
parent e037aede
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
@@ -43,6 +43,7 @@ TransientPropagationModule::TransientPropagationModule(Configuration& config,
    config_.setDefault<double>("timestep", Units::get(0.01, "ns"));
    config_.setDefault<double>("integration_time", Units::get(25, "ns"));
    config_.setDefault<unsigned int>("charge_per_step", 10);
    config_.setDefault<unsigned int>("max_charge_bunches", 10000);

    // Models:
    config_.setDefault<std::string>("mobility_model", "jacoboni");
@@ -60,6 +61,7 @@ TransientPropagationModule::TransientPropagationModule(Configuration& config,
    integration_time_ = config_.get<double>("integration_time");
    distance_ = config_.get<unsigned int>("distance");
    charge_per_step_ = config_.get<unsigned int>("charge_per_step");
    max_charge_bunches_ = config_.get<unsigned int>("max_charge_bunches");

    output_plots_ = config_.get<bool>("output_plots");
    boltzmann_kT_ = Units::get(8.6173e-5, "eV/K") * temperature_;
@@ -136,6 +138,11 @@ void TransientPropagationModule::initialize() {
                                  100,
                                  0,
                                  static_cast<double>(Units::convert(0.25 * model_->getSensorSize().z(), "um")));
        charge_bunch_size_histo_ = CreateHistogram<TH1D>("charge_bunch_size_histo",
                                                         "Charge bunch size;size [charges];Number of charge bunches",
                                                         static_cast<int>(100 * charge_per_step_),
                                                         0,
                                                         static_cast<int>(100 * charge_per_step_));

        drift_time_histo_ = CreateHistogram<TH1D>("drift_time_histo",
                                                  "Drift time;Drift time [ns];charge carriers",
@@ -182,6 +189,12 @@ void TransientPropagationModule::run(Event* event) {
                   << Units::display(deposit.getLocalPosition(), {"mm", "um"});

        auto charge_per_step = charge_per_step_;
        if(deposit.getCharge() / charge_per_step > max_charge_bunches_) {
            charge_per_step = deposit.getCharge() / max_charge_bunches_;
            LOG(INFO) << "Deposited charge: " << deposit.getCharge()
                      << ", which exceeds the maximum number of charge bunches 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) {
@@ -222,6 +235,7 @@ void TransientPropagationModule::run(Event* event) {

            if(output_plots_) {
                drift_time_histo_->Fill(static_cast<double>(Units::convert(time, "ns")), charge_per_step);
                charge_bunch_size_histo_->Fill(charge_per_step);
            }
        }
    }
@@ -424,8 +438,11 @@ TransientPropagationModule::propagate(Event* event,

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

        potential_difference_->Write();
        step_length_histo_->Write();
        charge_bunch_size_histo_->Write();
        drift_time_histo_->Write();
        recombine_histo_->Write();
        trapped_histo_->Write();
+2 −1
Original line number Diff line number Diff line
@@ -97,6 +97,7 @@ namespace allpix {
        bool output_plots_{};
        unsigned int distance_{};
        unsigned int charge_per_step_{};
        unsigned int max_charge_bunches_{};

        // Models for electron and hole mobility and lifetime
        Mobility mobility_;
@@ -116,7 +117,7 @@ namespace allpix {

        // Output plots
        Histogram<TH1D> potential_difference_, induced_charge_histo_, induced_charge_e_histo_, induced_charge_h_histo_;
        Histogram<TH1D> step_length_histo_;
        Histogram<TH1D> step_length_histo_, charge_bunch_size_histo_;
        Histogram<TH1D> drift_time_histo_;
        Histogram<TH1D> recombine_histo_;
        Histogram<TH1D> trapped_histo_;