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?



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?



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.