Message: Re: How to set up magnetic and gravity field Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

Feedback Re: How to set up magnetic and gravity field 

Forum: Fields: Magnetic and Otherwise
Re: Question How to set up magnetic and gravity field (Max)
Date: 23 Apr, 2013
From: Gumplinger Peter <Gumplinger Peter>

Hi Max,

> I have an existing simulation, which simulates the transport of ultra
> cold neutrons in a gravity field. I have to implement spin tracking in a
> magnetic field to this existing simulation.

> As far as I know, the current geant version (9.6) supports spintracking
> for UCN out of the box. My problem is, that I don't know how to
> implement the magnetic field and keep the gravity field.

Currently, in version 9.6, we provide for only the situation of either tracking in the gravity field or spin tracking in a EM field but not both. So, you'll have to write your own derived G4EquationOfMotion and G4Field classes. The two have to have an 'agreed convention' as to which components of the field correspond to gravity and magnetic field. You can recycle the code found in:

G4EqGravityField, G4Mag_SpinEqRhs and G4UniformGravityField, G4MagneticField

with the convention, for example, that in Field[] [0-2] is the magn. field and [3-5] is the gravity field (similar to G4EqEMFieldWithSpin and G4ElectroMagneticField for B and E fields).

> Do I have to create a second fieldmanager and asign it to a logic volume
> (e.g. logicworld)?

No.

> Or is it possible to just create one field, which is
> magnetic and gravity at once?

Yes.

> A link to an example where two fields are
> implemented would probably also help; I didn't find an example...

I am attaching some code that won't work with 9.6 as it is already developed with the next release in mind, but you'll get the idea what you'll need to be coding. This is the full blown all possibilities/options version of the EofM, including:

   // Force due to B field - Field[0,1,2]
   // add force due to E field - Field[3,4,5]
   // add force due to gravity field - Field[6,7,8]
   // add force due to grad(&#8901;B) == (&#8901;grad)B when (gradxB) = 0

and spin tracking.

Hope this helps, Peter

   Attachment:

      http://hypernews.slac.stanford.edu/HyperNews/geant4/get/AUX/2013/04/23/20.29-28148-G4EofM.cc

 Add Message Add Message
to: "Re: How to set up magnetic and gravity 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 ]