Simulation killed by Electric Field

Hi.

I am applying constant Electric Field on each logic volume using FieldManager.
However, applying electric field I want makes simulation killed.

276   auto eFieldDrift = G4ThreeVector(-4.40e-5, 0, 0);     // 440 V/cm
277   ApplyElectricFieldToVolume(eFieldDrift, driftLV);

Here is code for applying constant electric field on driftLV while ApplyElectricFieldToVolume is

153 void GarfieldDetectorConstruction::ApplyElectricFieldToVolume(G4ThreeVector value, G4LogicalVolume* volume) {
154
155         if (!volume) return;
156
157         auto eField = new G4UniformElectricField(value);
158         auto eqEM = new G4EqMagElectricField(eField);
159         auto stepper = new G4ClassicalRK4(eqEM);
160         auto driver = new G4MagInt_Driver(1e-6 * mm, stepper);
161         auto chordFinder = new G4ChordFinder(driver);
162
163         auto fieldManager = new G4FieldManager(eField, chordFinder);
164         fieldManager->SetDetectorField(eField);
165
166         fieldManager->SetAccuraciesWithDeltaOneStep(1e-7 * mm);
167
168         volume->SetFieldManager(fieldManager, true);
169
170         G4cout << "E field Applied " << value / (volt / m) << G4endl;
171         G4cout << "E field Applied to " << volume->GetName() << G4endl;
172 }

There is no problem in compile and just applying Electric Field.

./electron.out:E field Applied (-4.4e+13,0,0)V/m to volume: Drift

But program is killed as remaining following log.

/vis/scene/notifyHandlers scene-0
### Run 0 starts.
... set ntuple merging row mode : row-wise - done
... create file : Garfield.root - done
... open analysis file : Garfield.root - done
... open analysis file : Garfield.root - done
--> Event 0 starts.
[1]    9969 killed     ./exampleGeant4Interface

When I input

440 * volt / m

to vector, it does same.
Only input number 440 works well but it is not E field I want.
Is there any problem in stepping or anything else? :frowning:

The field is in teravolt per meter, could it be a typo?

Hi.

Well, it is not a typo.
I want to apply 14000 V/m but Geant4 reads my command as TeraVolt/m.
Even though I input -440e-5, considering what Geant4 reads, it stops.
In other words, Geant4 only works in TeraVolts/m scales.

When you supply a value with units, you should be multiplying by the units you want to use. In your case, you would specify

G4double myField = 14000*volt/meter;

and Geant4 will use that value.

If you want to print out a Geant4 value with units, then you must divide by the units you want to display,

G4cout << "I have set myField to " << myField/(volt/meter) << " V/m" << G4endl;

Or you can use G4BestUnit, and Geant4 will pick an appropriate unit for you, trying to keep the numeric value “small”:

G4cout << "I have set myField to " << G4BestUnit(myField) << G4endl;

Hi.

Thanks for your answer!
However, when I input with unit as multiplying, the simulation stops with the error in my post. I have tried both

G4double myField = 44000 * volt / m;

and

G4double myField = 440 * volt / cm;

then those two kill simulation and make error message in the post.

And output is not a issue now, since error occurs when there is an output script or not.

I think you’re going to need more details to track this down. There aren’t any magic numeric values that would kill things. Are you able to build and run Geant4 with debugging info (cmake -DCMAKE_BUILD_TYPE=Debug)? Then you can get a traceback of your crash.

@mkelsey , with G4BestUnit you must specify the unit category :
G4BestUnit (myField,“Electric field”)

@eunjeon , do not forget #include “G4SystemOfUnits.hh”
and/or #include “G4UnitsTable.hh”

interactively you can do: /units/list