# Fail to plot electric field lines in a neBEM geometry

**URL:** <https://root-forum.cern.ch/t/fail-to-plot-electric-field-lines-in-a-nebem-geometry/63174>\
**Category:** Garfield++\
**Created:** [March 20, 2025, 3:24pm UTC](https://root-forum.cern.ch/t/fail-to-plot-electric-field-lines-in-a-nebem-geometry/63174 "2025-03-20T15:24:13Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![gtsileda](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/g/8c91f0/32.png) [@gtsileda](https://root-forum.cern.ch/u/gtsileda)\
**Post date:** [March 20, 2025, 3:24pm UTC](https://root-forum.cern.ch/t/fail-to-plot-electric-field-lines-in-a-nebem-geometry/63174/1 "2025-03-20T15:24:13Z")

</div>

[microb2.C](https://root-forum.cern.ch/uploads/short-url/pVbqwiIuRKECbVNCrBgQRyBn9IM.C) (3.7 KB)

 ![Screenshot from 2025-03-20 16-13-12](https://root-forum.cern.ch/uploads/default/original/3X/2/2/22cbbeb84950af9d395feff7f9ee4b00c34f8a3d.png)

Dear experts,

Please have a look at the attached code and picture. I built a neBEM example in garfield++ that I used in past with the standalone version. The left and top central plot are obtained with the garfield++ code I provided, while the bottom central and right plot with the standalone garfield.  
I would like to have superimposed on the left plot the electric field lines as shown on the bottom central plot. I am getting when I execute it: **ViewField::EqualFluxIntervals:**  
\*\* The flux changes sign over the line.\*\*  
Could you please have a look?

Thanks a lot in advance

Georgios

---

<div class="post-metadata">

**Author:** ![bellenot](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/bellenot/32/29217_2.png) [@bellenot](https://root-forum.cern.ch/u/bellenot)\
**Post date:** [March 20, 2025, 3:26pm UTC](https://root-forum.cern.ch/t/fail-to-plot-electric-field-lines-in-a-nebem-geometry/63174/2 "2025-03-20T15:26:23Z")

</div>

I am adding @hschindl in the loop.

---

<div class="post-metadata">

**Author:** ![hschindl](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/h/977dab/32.png) [@hschindl](https://root-forum.cern.ch/u/hschindl)\
**Post date:** [March 24, 2025, 2:40pm UTC](https://root-forum.cern.ch/t/fail-to-plot-electric-field-lines-in-a-nebem-geometry/63174/3 "2025-03-24T14:40:15Z")

</div>

Hi Georgios,  
thanks for your message and apologies for the delay in getting back to you.

I managed to get a plot showing both the contours of the potential and the field lines using the piece of code below (essentially the same as yours):

```cpp
  ViewField fieldView(&nebem);
  fieldView.SetPlane(0, -1, 0, 0, 0, 0);
  fieldView.SetArea(-0.01, -0.01, 0.0, 0.01, 0.01, 0.01);
  fieldView.SetNumberOfContours(10);
  fieldView.PlotContour();

  std::vector<double> x1;
  std::vector<double> y1;
  std::vector<double> z1;
  fieldView.EqualFluxIntervals(-0.008, 0., 0.007, 0.008, 0., 0.007,
                               x1, y1, z1, 15);
  fieldView.PlotFieldLines(x1, y1, z1, true, false);

```

I had to reduce the number of periodic copies though to get a result in a reasonable amount of time.

Just a small comment: instead of using a finite thickness for the anode plane and drift plane, you could set the thickness to zero. This will reduce the number of surface panels and elements.

---

<div class="post-metadata">

**Author:** ![gtsileda](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/g/8c91f0/32.png) [@gtsileda](https://root-forum.cern.ch/u/gtsileda)\
**Post date:** [March 27, 2025, 6:11pm UTC](https://root-forum.cern.ch/t/fail-to-plot-electric-field-lines-in-a-nebem-geometry/63174/4 "2025-03-27T18:11:44Z")

</div>

Thank you so much!  
Following your suggestion I decreased the periodic copies from 10 to 2, and it works fine!

Best regards

Georgios

---

<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:** [April 10, 2025, 6:12pm UTC](https://root-forum.cern.ch/t/fail-to-plot-electric-field-lines-in-a-nebem-geometry/63174/5 "2025-04-10T18:12:00Z")

</div>

Closed on April 10, 2025, 6:12pm UTC

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