Message: Re: Space varying Magnetic Field Problem Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

None Re: Space varying Magnetic Field Problem 

Forum: Fields: Magnetic and Otherwise
Re: Question Space varying Magnetic Field Problem (Michael Rinaldi)
Date: 07 Jun, 2010
From: John Apostolakis <John Apostolakis>

Dear Mike,

The key question is not whether the track you obtain is smooth - it is  
whether it is accurate enough.  And it is not simple to answer whether  
or not you are providing an accurate enough description of your  
magnetic field with your relatively coarse 3D grid.  It depends on the  
accuracy requirements for the tracks which are most sensitive for your  

It is not clear from your description what type of field you are  
modeling - and this affects significantly the answer.  If the field  
has large gradients or changes direction in the region you are  
traversing (with particles), then the linear interpolation is likely a  
poor description.  This will affect the quality of the results.

I can see two ways to estimate if your track is accurate enough for  
your requirements:
   - to compare a simulation with the current coarse grid (1 cm^3) to  
one with a finer grid e.g.  (0.1cm)^3  checking the endpoint of a key  
particle or key observable that you will measure ( e.g. propagating a  
muon through it and seeing where it ends up, or measuring the energy  
deposition in a few smallish volume that is important).   Unless your  
field is very non-uniform
   - to do a numerical integration the difference between a fully  
accurate and a coarse description of the field for a few typical  
tracks.  Likely this is easier outside Geant4 than inside it.

The default stepper (G4ClassicalRK4) is not ideal for fields which are  
not smooth up to 2nd or 3rd derivative - but it is robust, so it will  
give you a reasonable answer.   In the absence of the higher  
derivatives, it will not make as efficient use of the field  
evaluations as a lower order stepper.  For fields which do not have  
continuous higher derivatives, we recommend G4SimpleRunge or  
G4SimpleHeum.  If you make a comparison of their efficiency and  
accuracy, we will be interested in your results.

Finally I note that linear interpolations are simple and fast, but  
more sophisticated interpolation methods which take into account that  
they are approximating a magnetic field, while costlier to compute,  
are much better suited to high order Runge-Kutta solvers.


On Jun 8, 2010, at 1:24 AM, Michael Rinaldi wrote:

> *** Discussion title: Fields: Magnetic and Otherwise
> Hi folks, I've constructed a model that implements a 3D space  
> varying magnetic field in a particular volume. The field is read in  
> from a file and is a set of values of Bx, By, and Bz. The field  
> values are defined on a 1 cm grid. I wrote the GetFieldValue()  
> function to return the pertinent field components as needed by the  
> stepper. My problem is that
> I get vastly different steps by changing the field value slightly.
> The function GetFieldValue(const G4double point[4], double *field)  
> that is required from me is written so that each time it is called  
> my code does a tri-linear interpolation on my 3D grid to find the  
> field at the input point from the stepper  
> point[0],point[1],point[2]. I'm thinking that since this  
> interpolation is happening on a coarse 1cm x 1cm x 1cm
> grid then the field values are not smooth enough to give a good  
> smooth track.
> I'd like some advice as to the best way to proceed. Should I  
> increase the grid by a factor of 10 so that it is defined every 1mm  
> instead of 1cm or should I use a different stepper. Currently I'm  
> simply using
> G4ChordFinder *chordFinder = new G4ChordFinder(magField, stepMinimum);
> which I believe uses the RK4 stepper. If I need to change the  
> stepper how do I do that?
> Thanks, Mike
> -------------------------------------------------------------
> Visit this GEANT4 at message (to reply  
> or unsubscribe) at:

 Add Message Add Message
to: "Re: Space varying Magnetic Field Problem"

 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 ]