Message: Re: Getting NAN for values of Point in a magnetic field class  Not Logged In (login) 
Thanks for the quick response!
Alright, so this is a run with an initial electron trajectory of (1,1,1), from the origin. The magnetic field is constant in the direction of r so it should have no effect on the particle, which is travelling in the direction of r. Whenever I get NAN values for the x, y, or z coordinates, I set the field equal to 0 (just as a temporary means of avoiding passing NAN values to the field matrix). I've output the value of the (x,y,z) coordinates when they are not NAN, values of sin(theta) and cos(phi) just to see if these calculations are working, and the values of the field in both spherical and cartesian coordinates:
********************************************************************************************************* * G4Track Information: Particle = e, Track ID = 1, Parent ID = 0 *********************************************************************************************************
Step# X(mm) Y(mm) Z(mm) KinE(MeV) dE(MeV) StepLeng TrackLeng NextVolume ProcName 0 0 0 0 1 0 0 0 hallPhys initStep previous Bx, By, Bz: 1.38137e314; 6.94803e310; 6.95317e310 x, y, z: 0; 0; 0 sin(theta), cos(phi): nan; nan Br, Btheta, Bphi: 0.0001; 0; 0 Bx, By, Bz: nan; nan; nan previous Bx, By, Bz: 7.41034e315; 1.97626e323; 1.49167e154 x, y, z: 842.349; 842.349; 842.349 sin(theta), cos(phi): 0.816497; 0.707107 Br, Btheta, Bphi: 0.0001; 0; 0 Bx, By, Bz: 5.7735e05; 5.7735e05; 5.7735e05 previous Bx, By, Bz: 5.7735e05; 5.7735e05; 5.7735e05 One of x, y, or z is NAN: set Bx = By = Bz = 0 previous Bx, By, Bz: 0; 0; 0 One of x, y, or z is NAN: set Bx = By = Bz = 0 previous Bx, By, Bz: 0; 6.94802e310; 6.94784e310 One of x, y, or z is NAN: set Bx = By = Bz = 0 previous Bx, By, Bz: 6.95317e310; 6.94802e310; nan One of x, y, or z is NAN: set Bx = By = Bz = 0 previous Bx, By, Bz: 0; 0; 0 One of x, y, or z is NAN: set Bx = By = Bz = 0 previous Bx, By, Bz: 0; 0; 0 One of x, y, or z is NAN: set Bx = By = Bz = 0 previous Bx, By, Bz: 0; 0; 0 x, y, z: 1684.7; 1684.7; 1684.7 sin(theta), cos(phi): 0.816497; 0.707107 Br, Btheta, Bphi: 0.0001; 0; 0 Bx, By, Bz: 5.7735e05; 5.7735e05; 5.7735e05 previous Bx, By, Bz: 5.7735e05; 5.7735e05; 5.7735e05 One of x, y, or z is NAN: set Bx = By = Bz = 0 previous Bx, By, Bz: 0; 0; 0 One of x, y, or z is NAN: set Bx = By = Bz = 0 previous Bx, By, Bz: 0; 6.94803e310; 2.122e314 x, y, z: 84.2349; 84.2349; 84.2349 sin(theta), cos(phi): 0.816497; 0.707107 Br, Btheta, Bphi: 0.0001; 0; 0 Bx, By, Bz: 5.7735e05; 5.7735e05; 5.7735e05 After a slight hiccup at the start (which seems to be the result of having small values for the coordinates; see below), the field remains constant, interspersed with instances of NAN values for the coordinates. As for the path of the particle, it ends up travelling out some distance along (1,1,1), then back toward the origin, then back out, and on and on, with its net movement tending toward the origin. By the end, it reaches absurdly small values for its coordinates; for example:
x, y, z: 1.44338e315; 1.44338e315; 1.44338e315
x, y, z: 2.88675e315; 2.88675e315; 2.88675e315
x, y, z: 1.44338e316; 1.44338e316; 1.44338e316 Additionally, at this point, despite having numerical values for the coordinates, the calculation of other quantities returns NAN. For example:
x, y, z: 2.88675e202; 2.88675e202; 2.88675e202 sin(theta), cos(phi): nan; 0.707107 Br, Btheta, Bphi: 0.0001; 0; 0 Bx, By, Bz: nan; nan; nan previous Bx, By, Bz: nan; nan; nan This only occurs for very small values of (x,y,z), including 0. Hopefully that helps. If not, please let me know what more information I can provide.
Thank you, Aaron

Inline Depth:  Outline Depth:  Add message: 
to: 