Message: Re: When is called GetFieldValue() ? Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

None Re: When is called GetFieldValue() ? 

Forum: Fields: Magnetic and Otherwise
Re: Question When is called GetFieldValue() ? (Kayo Matsuura)
Date: 25 Nov, 2014
From: John Apostolakis <John Apostolakis>

Dear Kayo,

Geant4's transportation process calls a class in the geometry called G4PropagatorInField, which is responsible to figure out where the next intersection will occur between the curved path (due to the field) and the geometry boundaries of the volumes.

This class calls other classes which are responsible for integrating the trajectory in the magnetic field, typically using Runge Kutta integration.  The value of the field will be sampled several time by those classes - typically at the initial position (PreStep point), the estimated mid-point of the step (along a straight line), the estimated endpoint (with a first approximation of the curvature from the deflection).  

There are several reasons why a recalculation might occur, which will result in further calls to the field method:
  - if a boundary was not encountered, then the estimated intersection using a straight line from start to end is computed, and a corresponding point along the path are computed (the second requires further calls to the field);
  - if the integration error too large, e.g. because the magnetic field varied too much, or the step was otherwise too long, then the trial step is reduced, and further evaluations will be done
  - in some integration methods (steppers) in order to estimate the integration error it is necessary to make additional integration steps which 

So if you add a print method in your field, and set 
  /tracking/verbose 1
you will see that the field is called several times for a typical step.

Hope this helps.

Regards,
John
===================================================
John Apostolakis,  PH Department, CERN


> On 25 Nov 2014, at 17:05, Kayo Matsuura <matsuura@hepl.hiroshima-u.ac.jp> wrote:
> 
> 
> *** Discussion title: Fields: Magnetic and Otherwise
> 
> Dear G4 users,
> 
> I use geatn4.9.5.p02.
> If non-uniform magneticfield is used, my field class must be defined bellow. 
> 
> class myField : public G4MagneticField
> {
> public:
>  void GetFieldValue(const double Point[4], double *pField) const;
> };
> void myField::GetFiledValue(const double Point[4], double *pField) const
> {
>  pFiled[0] = Bx;
>  pField[1] = By;
>  pField[2] = Bz; <- Bx, By, Bz are given as function of Position. 
> }  
> 
> So, I have a question about GetFieldValue().
> When is called GetFieldValue()?
> I think it is called at each step.
> If this is right, what value is set to Point[4]? PreStepPoint, PostStepPoint or other value?
> Thus, field transition along step is ignored? 
> 
> Best Regards,
> Kayo Matsuura
> 
> -------------------------------------------------------------
> Visit this GEANT4 at hypernews.slac.stanford.edu message (to reply or unsubscribe) at: 
> http://hypernews.slac.stanford.edu/HyperNews/geant4/get/emfields/219.html 

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

1 Ok: Re: When is called GetFieldValue() ?   (Kayo Matsuura - 26 Nov, 2014)
 Add Message Add Message
to: "Re: When is called GetFieldValue() ?"

 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 ]