In a very simple synchrotron simulation, I have uniform magnetic field defined over 1m (-50cm to 50cm in the coordinate system). There is a planar geometry at the end with material G4_Galactic
in fact every material that I have in this sim is G4_Galactic
(world volume as well).
Primary generator: 11GeV electron created at (0,0,-2*m)
Magnetic field: Uniform 1.5 T over 1m.
void MagneticField::GetFieldValue(const G4double point[], G4double* field) const{
double Bx = 0;
double x = point[0], y = point[1], z = point[2];
if( std::abs(z) <= 50*cm and std::abs(y) < 5*cm and std::abs(x) < 1*cm ) {
Bx = 1.5*tesla;
}
field[0] = Bx;
field[1] = 0.0;
field[2] = 0.0;
}
I then use: /physics_list/em/SyncRadiationAll true
.
Not very clear picture but the 20cm axes are at (0,0,0).
I also added /vis/scene/add/magneticField 30
to see the field line, and the field lines are only drawn from z=0 to z=50*cm. This seems like a visual artifact.
But Instead of synchrotron radiation starting from the start of magnetic field region (-50cm), it starts only later through the magnetic field. It seemed like visual artifact because of drawing again. But when I look at origin vertices of the synchrotron photon, it confirms the visual that it starts some way later.
This is the z coordinate of vertices of the synchrotron photon (pid == 22). It says the synchrotron photons only get created around ~z=-320mm Instead of expected z=-500mm.
I was experimenting a bunch of ways. Everything else same, I add a planar G4_Galactic
geometry of z=1mm thickness at z= -50*cm.
Now the synchrotron radiation correctly starts at z=-50cm to z=50cm.
I originally bumped into this problem because I am working on another more complex project where I use parallel geometry to use as virtual detectors. And it appeared, the presence and absence of some parallel planes (all G4_Galactic
) seemed to affect the synchrotron radiation, completely baffling.
This is a small toy project, here is the entire source code if its helpful.
zipped source code
void Geometry::ConstructSDandField(){
fMagneticField = new MagneticField();
fMagneticField->Activate();
}
and the Activate function
void MagneticField::Activate(){
G4TransportationManager* transportationmanager = G4TransportationManager::GetTransportationManager();
auto fFieldMgr = transportationmanager->GetFieldManager();
fFieldMgr->SetDetectorField(this);
auto dof = 12;
auto equation = new G4Mag_UsualEqRhs(this);
auto stepper = new G4ClassicalRK4(equation, dof);
G4double minStep = 0.01 * mm;
G4ChordFinder* chordFinder = nullptr;
if (stepper) {
auto intgrDriver = new G4IntegrationDriver<G4ClassicalRK4>(minStep, stepper, stepper->GetNumberOfVariables());
if (intgrDriver) {
chordFinder = new G4ChordFinder(intgrDriver);
}
}
G4double deltaChord = 0.1 * mm;
chordFinder->SetDeltaChord(deltaChord);
G4double deltaIntersection = 0.001 * mm;
fFieldMgr->SetDeltaIntersection(deltaIntersection);
G4double deltaOneStep = 0.01 * mm;
fFieldMgr->SetAccuraciesWithDeltaOneStep(deltaOneStep);
//
G4double epsMax = 1.0e-5; // Pure number -- maximum relative integration error
G4double epsMin = 2.5e-7; //
fFieldMgr->SetMinimumEpsilonStep(epsMin);
fFieldMgr->SetMaximumEpsilonStep(epsMax);
fFieldMgr->SetChordFinder(chordFinder);
I am not entirely sure about this function because I copied it over from one of the examples(extended/field/field06
).
Also, just dropping axes shows the correct extent of magnetic field with (/vis/scene/add/magneticField 20
)
Geant4 Version: 11.3.0
Operating System: Linux
Compiler/Version: 15.1.1
CMake Version: 4.0.3