Home | News | Documentation | Download

Garfield+Elmer Electric Field visualization

Dear All,

I have used Elmer to solve the electrostatic’s field equations, and I have succesfully imported it on Garfield with the “ComponentElmer” class. I was also able to plot the equipotential surfaces with ViewField. However, what I really need to visualize is the electric field lines. Is this possible to do? This is the piece of code that I am using:

   const double ext_x = 19.0;        // external box x-width
   const double ext_y = 1.0;        // external box y-width
   const double ext_z = 25.0;        // external box z-width

 TCanvas * c1 = new TCanvas();

ComponentElmer * elm = new ComponentElmer("Field_cage_2/mesh.header","Field_cage_2/mesh.elements","Field_cage_2/mesh.nodes","Field_cage_2/dielectrics.dat","Field_cage_2/field_cage_2.result","mm"); 
elm->SetMedium(0,gas);
 
 Sensor* sensor = new Sensor();
 sensor->AddComponent(elm);
 sensor->SetArea(-1*ext_x,-1*ext_y,-1*ext_z,ext_x,ext_y,ext_z);

 // Set up the object for field visualization.
   ViewField * vf = new ViewField();
   vf->SetSensor(sensor);
   vf->SetCanvas(c1);
   vf->SetArea(-1*ext_x,-1*ext_z,ext_x,ext_z);
   vf->SetNumberOfContours(50);
   vf->SetNumberOfSamples2d(50,50);
   vf->SetPlane(0,-1,0,0,0,0);

 ViewFEMesh * vFE = new ViewFEMesh();
  vFE->SetCanvas(cdrift);
   vFE->SetComponent(elm);
   vFE->SetPlane(0,-1,0,0,0,0);
   vFE->SetFillMesh(true);
   vFE->SetColor(1,kBlue);
  
   vFE->SetArea(-1*ext_x,-1*ext_z,-1*ext_z,ext_x,ext_z,ext_z);
   vf->PlotContour("v");
   vFE->Plot();
   app.Run(kTRUE);

     return 0;
 }

Thank you very much in advance!

Sabrina

If you have your electric field lines as X and Y vectors you can draw them in the TCanvas you created using TPolyLine.

Dear Couet,

Thank you very much for your reply. Unfortunately the problem is that the way Elmer stores the info about the potential (in the automatically generated ‘field_cage_2.result’ file) is not trivial (at least for me), so it is very convenient that garfield can understand it and plot it just by saying ‘view field’. I was wondering if there is a workaround or something I missed to view the actual field…

Cheers,

Sabrina

In that case, I think it is more a question for the Garfield people.

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