G4ElectricField constructors?

_Geant4 Version: 11.0.0
_Operating System:_Sonoma 14.3
_Compiler/Version: X code 15.3
_CMake Version:_3.29.2

Hi all,

I’m trying to import an e-field generated by COMSOL into a modified field02 example which, by default, creates an homogenous e-field. Is there a constructor for G4Electric field which can import a text file with a format similar to below?

|7.346988369455761|0.8841730029139034|0.4999999999999995|87.18113153304148|34.47954264940927|-233816.788|

|—|—|—|—|—|—|
|7.2809019933791435|1.3222957924789833|0.25000000000000056|23.02541298|22.04191510702367|-228993.7522|
|7.346988369455761|0.8841730029139051|-5.68E-16|1.1060937004707132|14.276146036184704|-223523.2229|

etc…where the order (from left to right) is x, y, z, Ex, Ey, Ez.

If not which formats might G4 accept and which constructor should I use?

Regards

Tim

Unfortunately, Geant4 doesn’t not provide any method of importing a mesh (COMSOL or equivalent) electric field. You’ll need to write the relevant code yourself (although I think one of the examples might have it), as a subclass of G4ElectricField.

You may also consider using G4CMPMeshElectricField with G4CMPG4CMPTriLinearInterpolator the G4CMP library (GitHub - kelseymh/G4CMP: A low energy condensed matter physics package for Geant4), but that’s going to bring in lots of stuff that you don’t need, just to get the mesh field support. I have yet to write proper technical documentation for the package, so I am not recommending it for your purpose.

Thanks Mike. I feared it was so. Never mind, I’ve done similar in the past.

Regards

Tim