I am currently working with Geant4.10.6.p01 on a Windows 10 system and encountering difficulties in setting up a non-uniform electric field for my simulation. My simulation volume is relatively small, on the scale of a few hundred nanometers, and involves a sharp tip geometry.
Initially, I successfully established a Uniform E Field within my Geant4 model, adapting files from the field02 example. With this setup, I was able to simulate electron trajectories bending appropriately under the influence of the field, and visualize the field using the /vis/scene/add/electricField
command. This confirmed that the uniform e field was correctly implemented and functioning as expected.
Transitioning to a Non-Uniform Electric Field Configuration
My goal is to move beyond a uniform e field and implement a more realistic, non-uniform electric field, particularly around the sharp tip in my model. While Geant4 examples don’t directly provide a non-uniform electric field setup, the purging magnet example offers a template for handling non-uniform magnetic fields. Following this approach, I adapted the purging magnet code to define an electric field. For testing purposes, I even used the same field data file (“PurgMag3D.TABLE”) initially used in the purging magnet example.
The Geant4 output suggests that the field file is being read correctly. The output messages are very similar to those observed when running the purging magnet example, indicating successful data loading:
Electric field
—> Reading the field grid from PurgMag3D.TABLE … [ Number of values x,y,z: 6 6 10 ]
—> … done reading —> assumed the order: x, y, z, Bx, By, Bz —> Min values x,y,z: -5e-06 -5e-06 -2.6e-05 cm —> Max values x,y,z: 5e-06 1.7e-05 1e-05 cm —> The field will be offset by 0 cm
Challenges in Visualizing and Observing Non-Uniform Field Effects
Despite the seemingly successful loading of the field data, I am facing issues in observing the non-uniform electric field in my simulation. Electron trajectories are not curving as expected, which contrasts with the behavior observed under the uniform e field. Furthermore, when attempting to visualize the electric field using Geant4 visualization commands, I receive the message “No Electric field in this extent.”
This indicates that while the field data might be loaded, it is not being correctly applied or recognized within the simulation environment. The step size and stepper configurations appear to be initialized correctly, as indicated by the output:
F02ElectricFieldSetup: The minimal step is equal to 0.001 mm G4ClassicalRK4 is called
Code Implementation for Non-Uniform Electric Field
The F02ElectricFieldSetup
constructor, adapted from the Field02 example, is configured as follows. The line setting up the uniform e field is commented out, and the PurgMagTabulatedEField3D
class is instantiated to load the non-uniform field data:
F02ElectricFieldSetup::F02ElectricFieldSetup() :
fMinStep(0.0010*mm), // minimal step of 1 micrometers
fFieldManager(0),
fChordFinder(0),
fEquation(0),
fEMfield(0),
fElFieldValue(),
fStepper(0),
fIntgrDriver(0),
fStepperType(4), // ClassicalRK4 – the default stepper
fFieldMessenger(nullptr)
{
// fEMfield = new G4UniformElectricField(G4ThreeVector(0.0,-1.0*kilovolt/cm,0.0));
G4double zOffset = 0.0 * mm;
fEMfield = new PurgMagTabulatedEField3D("PurgMag3D.TABLE", zOffset);
fEquation = new G4EqMagElectricField(fEMfield);
fFieldManager = GetGlobalFieldManager();
UpdateIntegrator();
fFieldMessenger = new F02FieldMessenger(this);
}
The PurgMagTabulatedEField3D
class is structurally similar to PurgMagTabulatedField3D
from the purging magnet example, with the key distinction being its inheritance from G4ElectricField
instead of G4MagneticField
:
class PurgMagTabulatedEField3D
#ifndef STANDALONE
: public G4ElectricField
#endif
Seeking Guidance and Suggestions
I am seeking advice and suggestions on why the non-uniform electric field is not behaving as expected. Is there a potential issue in how the PurgMagTabulatedEField3D
class is implemented or configured for electric fields? Are there any specific steps or considerations that are crucial when transitioning from a uniform e field to a non-uniform field in Geant4, especially when adapting code from magnetic field examples? Any insights or troubleshooting tips would be greatly appreciated.
Thanks,
Chris