Message: Problems with a local magnetic field Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

Question Problems with a local magnetic field 

Keywords: local magnetic field logical volume
Forum: Fields: Magnetic and Otherwise
Date: 22 Apr, 2005
From: Lewis Dartnell <>

I am having problems getting a local magnetic field assigned to a logical volume to work correctly, as per the examples given in answer to Questions 33 and 10 in this forum. No error messages are thrown up when I compile my files, and the program executes without complaint. But in the visualisation of the output the proton tracks pass straight through the 'MagAnomaly' region, blissfully unaware of any magnetic field...

All of the appropriate header files are included at the top of my file:

#include "G4TransportationManager.hh"
#include "G4UniformMagField.hh"
#include "G4Mag_UsualEqRhs.hh"
#include "G4ClassicalRK4.hh"
#include "G4MagIntegratorStepper.hh"
#include "G4ChordFinder.hh"
#include "G4FieldManager.hh"


The Runge Kutta, ChordFinder, and field manager are then all set up further down in my :

    static const G4double fieldValue = 1.*tesla;

    MagField = new G4UniformMagField(G4ThreeVector(0., fieldValue, 0. ));
    iEquation = new G4Mag_UsualEqRhs(MagField);
    iStepper = new G4ClassicalRK4(iEquation);
    iChordFinder = new G4ChordFinder(MagField, 0.01*mm, iStepper);
    fieldMgr = new G4FieldManager(MagField, iChordFinder);

all of these pointers are initialised in DetectorConstructor.hh


This fieldMgr is then assigned to a hemi-spherical logical volume which I then place as a physical volume within the WorldVolume:

   G4Sphere* MagAnomaly = new G4Sphere("MagAnomaly", innerRadiusOfTheSphere, outerRadiusOfTheSphere, StartPhiAngle, DeltaPhiAngle, StartThetaAngle, DeltaThetaAngle);
  MagAnomaly_log = new G4LogicalVolume(MagAnomaly, MartianAir, "MagAnomaly_log", fieldMgr, 0, 0);
  MagAnomaly_phys = new G4PVPlacement(0,
             G4ThreeVector(MagAnomalyPos_x, MagAnomalyPos_y, MagAnomalyPos_z),
             MagAnomaly_log,"MagAnomaly", WorldVolume_log, false, 0);

This WorldVolume was originally given a localised magnetic field with the method used in Exercise#2 - ie. a global field restricted to co-ordinates within a hemi-sphere (x^2 + y^2 +z^2 < 1 && y>1). This worked fine, so I know that the problem lies in the attribution of a local magnetic field to the MagAnomaly volume, and not problems with particle definitions, trackers, etc.

Can anyone help me out with this please...?

Inline Depth:
 1 1
 All All
Outline Depth:
 1 1
 2 2
 All All
Add message: (add)

1 Feedback: Re: Problems with a local magnetic field   (Peter Gumplinger - 09 May, 2005)
 Add Message Add Message
to: "Problems with a local magnetic field"

 Subscribe Subscribe

This site runs SLAC HyperNews version 1.11-slac-98, derived from the original HyperNews

[ Geant 4 Home | Geant 4 HyperNews | Search | Request New Forum | Feedback ]