# Using multiple dynamic weighting potentials/fields from TCAD

**URL:** <https://root-forum.cern.ch/t/using-multiple-dynamic-weighting-potentials-fields-from-tcad/63577>\
**Category:** Garfield++\
**Created:** [May 19, 2025, 11:59am UTC](https://root-forum.cern.ch/t/using-multiple-dynamic-weighting-potentials-fields-from-tcad/63577 "2025-05-19T11:59:06Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hua-Zhen\_Li](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/hua-zhen_li/32/27088_2.png) [@Hua-Zhen\_Li](https://root-forum.cern.ch/u/Hua-Zhen_Li)\
**Post date:** [May 19, 2025, 11:59am UTC](https://root-forum.cern.ch/t/using-multiple-dynamic-weighting-potentials-fields-from-tcad/63577/1 "2025-05-19T11:59:06Z")

</div>

Dear experts,

Hi, recently we are trying to simulate the current response of a 3D diamond detector, in which the electrodes’ resistance matters and we need to introduce a series of weighting fields at different time points (we already have the .dat and .grd files). Since we are using TCAD to generate electric fields, I notice there is a function in Garfield::ComponentTcad3d class:

bool SetWeightingField (const std::string &datfile1, const std::string &datfile2, const double dv, const double t, const std::string &label)

I wonder how it can be used? like, can it be called multiple times in a simulation to introduce multiple (~10) weighting fields? If not, is there any methods to calculate the induced current using these fields in Garfield?

Thank you very much!  
Huazhen

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [May 19, 2025, 1:17pm UTC](https://root-forum.cern.ch/t/using-multiple-dynamic-weighting-potentials-fields-from-tcad/63577/2 "2025-05-19T13:17:44Z")

</div>

I think @hschindl can help you.

---

<div class="post-metadata">

**Author:** ![djjansse](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/d/8baadc/32.png) [@djjansse](https://root-forum.cern.ch/u/djjansse)\
**Post date:** [May 20, 2025, 8:23am UTC](https://root-forum.cern.ch/t/using-multiple-dynamic-weighting-potentials-fields-from-tcad/63577/3 "2025-05-20T08:23:16Z")

</div>

Dear Huazhen,

The function you need to use depends on the boundary condition applied to the electrode for which you’re calculating the weighting field:

- `dv·δ(t)`
- `dv·Θ(t)`

For the former (`dv·δ(t)`), you should use the `SetDynamicWeightingField` function. For the latter (`dv·Θ(t)`), you can use `SetDynamicWeightingPotential`. Both functions are intended for sensors with a doping profile, where the weighting field is calculated by adding a small voltage increment (`dv`) to the electrode under study while the sensor is biased. The weighting field is then obtained by subtracting the field map of the biased sensor without perturbation (`datfile1`) from the map with the perturbation (`datfile2`).

In your case, this is not needed. Instead:

- `datfile1` can be a file where all electrodes are grounded.
- `datfile2` is the configuration where all electrodes are grounded except the one of interest, which is set to a voltage `dv`.

To import each time slice of the solution, you can call `SetDynamicWeightingPotential` or `SetDynamicWeightingField`for each time `t`. Note that when `t = 0`, it is automatically flagged as the prompt component.

Here’s an example:

```auto
std::vector<double> times = {0., 0.1, 1., 2.1, 3.5, 8.}; // ns
const std::string label = "Readout";

ComponentTcad3d 3DDiamond;
3DDiamond("n5_dut_des.grd", "n5_dut_des.dat");

// Load field maps
for (int tt = 0; tt < times.size(); ++tt) {
  std::ostringstream oss;
  oss << std::setfill('0') << std::setw(4) << tt;
  std::string number = oss.str();
  
  const std::string wpFileName = "n8_trans_" + number + "_dut_des.dat";
  
  3DDiamond.SetDynamicWeightingPotential("n5_dut_des.dat", wpFileName,
                                         0.01, times[tt], label);
}

sensor.AddElectrode(&RSD, label);

```

Kind regards,  
Djunes

---

<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:** [June 3, 2025, 8:23am UTC](https://root-forum.cern.ch/t/using-multiple-dynamic-weighting-potentials-fields-from-tcad/63577/4 "2025-06-03T08:23:45Z")

</div>

Closed on June 3, 2025, 8:23am UTC

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