Import electric field from COMSOL

Dear experts,

I try to import the field map from COMSOL and I have checked that the voltage of different place has been import successfully. But the electric field isn’t defined. I also checked that the electric filed could be plotted normally.

  ComponentComsol fm;
  fm.Initialise("mesh.mphtxt", "dielectrics.dat", "field.txt", "cm");
  fm.EnableMirrorPeriodicityX();
  fm.EnableMirrorPeriodicityY();
  fm.PrintRange();
  fm.SetMedium(0,&gas);  
  fm.SetMedium(1,&metal);
  fm.PrintMaterials();

  Sensor sensor;
  sensor.AddComponent(&fm);
  sensor.SetArea(
    -1, -1, 0,
    1, 1, 30
  );


  std::vector<std::array<double,3>> points;
  std::array good_point = {0.3,0.1,15.0};
  std::array bad_point = {0.8,0.0,0.0};
  points.push_back(good_point);
  points.push_back(bad_point);
  
  for(int i=0;i<points.size();i++){
      double ex,ey,ez,v;
      Medium* m;
      int status;
      double x=points[i][0];
      double y=points[i][1];
      double z=points[i][2];
      // Check if electric field at point is defined
      sensor.ElectricField(x,y,z,ex,ey,ez,v,m,status);
      if(!status){
          drift.DriftElectron(x,y,z,0.0);
          std::cout<<"Successfully drifted ("<<x<<","<<y<<","<<z<<")"<<std::endl;
      }else{
          std::cout<<"No field at ("<<x<<","<<y<<","<<z<<")"<<std::endl;
      }
  } 

The output is

No field at (0.3,0.1,15)

No field at (0.8,0,0)

The status # is -5

I would appreciate it very much if you could help me to figure it out.

Dear @Linnuo,

Only the potential map can be imported, not the field. See COMSOL | Garfield++ for further instructions.

Kind regards,
Djunes

Dear @djjansse

Thank you so much. I think the electric field has been successfully imported. Is there any way to define the active mediu,. It seems that the point is onside the mesh but not in an active medium.

Best,
Linnuo

Dear @Linnuo,

Oh good, in that case I misunderstood.In principle fm.SetGas(&gas) should do the job. Maybe try that instead of fm.SetMedium(0,&gas) fm.SetMedium(1,&metal)?

Kind regards,
Djunes

Dear @djjansse ,

Thank you so much for your reply. I solved it by changing the Permittivity of the gas in the dielectric.dat file to absolute zero, though I do not know why.

Best,
Linnuo

Dear @Linnuo
A material with permittivity is automatically recognised in the code as a gas and set as a driftable medium. Alternatively you can use the methods provided by Djunes.
greets
Piet

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