# The weighting potential is right, but not the weight field

**URL:** <https://root-forum.cern.ch/t/the-weighting-potential-is-right-but-not-the-weight-field/55082>\
**Category:** Garfield++\
**Created:** [May 29, 2023, 8:46am UTC](https://root-forum.cern.ch/t/the-weighting-potential-is-right-but-not-the-weight-field/55082 "2023-05-29T08:46:44Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![newconcept1979](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/newconcept1979/32/26349_2.png) [@newconcept1979](https://root-forum.cern.ch/u/newconcept1979)\
**Post date:** [May 29, 2023, 8:46am UTC](https://root-forum.cern.ch/t/the-weighting-potential-is-right-but-not-the-weight-field/55082/1 "2023-05-29T08:46:44Z")

</div>

The component was import from comsol, it is about two electrode with 2 cm gap,  
the code from Garfield++ is like this:

```auto
fm.Initialise("Mesh.mphtxt", "dielectrics.dat", "Potential.txt", "cm");
  fm.SetWeightingField("wPotential.txt","signal");
  double wxx,wyy,wzz;
  fm.WeightingField(0,0,1.5,wxx,wyy,wzz,"signal");
  for(int i=0;i<5;i++)cout<<" **********************************************************"<<endl;
  cout<<"weighting field=="<<" "<<wxx<<" "<<wyy<<" "<<wzz<<endl;
  for(int i=0;i<5;i++)cout<<" **********************************************************"<<endl; 
  cout<<"weighting potential=="<<fm.WeightingPotential(0,0,1.5,"signal")<<endl;
  for(int i=0;i<5;i++)cout<<" **********************************************************"<<endl;
// fm.EnableMirrorPeriodicityX();
// fm.EnableMirrorPeriodicityY();
  fm.PrintRange();

the key comment from file "wPotential.txt" is like this:

% Model: Untitled.mph
% Version: COMSOL 6.0.0.318
% Date: May 29 2023, 10:48
% Dimension: 3
% Nodes: 209692
% Expressions: 1
% Description: 电势
% Length unit: cm
% x y z V (V) 
1.191319747821612 1.349350904721154 2.5200000000000005 1
1.176234877953045 1.349041862073355 2.5500000000000007 0.9900892934114793
1.1631253566345796 1.3737282090550813 2.5200000000000005 1
1.1611500080844779 1.3487328194255563 2.5800000000000005 0.9850500777901273
1.1477913822477244 1.3731249561488506 2.5500000000000007 0.9899360030835282
1.134432756410971 1.3975170928721445 2.5200000000000005 1
1.1557649679462398 1.335173746850126 2.5200000000000005 1
1.1406800980776728 1.3348647042023272 2.5500000000000007 0.9935233578674209
1.1273214722409195 1.3592568409256212 2.5200000000000005 1
1.1202101880708677 1.3209965889790978 2.5200000000000005 1
1.0648373206384905 1.3663363628476513 2.5200000000000005 1
......
......
......

the related output comment is like this:

**********************************************************
 **********************************************************
 **********************************************************
 **********************************************************
 **********************************************************
weighting field== 0 0 0
**********************************************************
 **********************************************************
 **********************************************************
 **********************************************************
 **********************************************************
weighting potential==0.494956
**********************************************************
 **********************************************************
 **********************************************************
 **********************************************************
 **********************************************************

```

the result of weighting field seems wrong, as my opinion, it should be like this:(0,0, 0.5) .  
it seems something is wrong with the file “wPotential.txt” from comsol,  
is there something special when producing related file using comsol?

---

<div class="post-metadata">

**Author:** ![vpadulan](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/vpadulan/32/25315_2.png) [@vpadulan](https://root-forum.cern.ch/u/vpadulan)\
**Post date:** [May 30, 2023, 7:49am UTC](https://root-forum.cern.ch/t/the-weighting-potential-is-right-but-not-the-weight-field/55082/2 "2023-05-30T07:49:21Z")

</div>

Hi @newconcept1979 ,

Maybe @hschindl could give you a hand on this.

Cheers,  
Vincenzo

---

<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:** [May 31, 2023, 9:05am UTC](https://root-forum.cern.ch/t/the-weighting-potential-is-right-but-not-the-weight-field/55082/3 "2023-05-31T09:05:08Z")

</div>

Sorry for the delay…  
@djjansse if you have a moment could you take a look at this?

---

<div class="post-metadata">

**Author:** ![newconcept1979](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/newconcept1979/32/26349_2.png) [@newconcept1979](https://root-forum.cern.ch/u/newconcept1979)\
**Post date:** [June 6, 2023, 6:51am UTC](https://root-forum.cern.ch/t/the-weighting-potential-is-right-but-not-the-weight-field/55082/4 "2023-06-06T06:51:33Z")

</div>

The potential and weighting potential file export from Comsol as same format, why the files were imported correctly(the potential and weighting potential can be calculated), but the weighting field can not be calculated? or the result of weighting field is wrong.

---

<div class="post-metadata">

**Author:** ![newconcept1979](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/newconcept1979/32/26349_2.png) [@newconcept1979](https://root-forum.cern.ch/u/newconcept1979)\
**Post date:** [June 7, 2023, 12:28am UTC](https://root-forum.cern.ch/t/the-weighting-potential-is-right-but-not-the-weight-field/55082/5 "2023-06-07T00:28:49Z")

</div>

Anybody can help me?

---

<div class="post-metadata">

**Author:** ![newconcept1979](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/newconcept1979/32/26349_2.png) [@newconcept1979](https://root-forum.cern.ch/u/newconcept1979)\
**Post date:** [June 9, 2023, 8:08am UTC](https://root-forum.cern.ch/t/the-weighting-potential-is-right-but-not-the-weight-field/55082/6 "2023-06-09T08:08:53Z")

</div>

@hschindl , @djjansse, can you give me a help?

---

<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 23, 2023, 8:09am UTC](https://root-forum.cern.ch/t/the-weighting-potential-is-right-but-not-the-weight-field/55082/7 "2023-06-23T08:09:11Z")

</div>

Closed on June 23, 2023, 8:09am UTC

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