Message: The Strangest Problem I've ever met Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

Question The Strangest Problem I've ever met 

Forum: Fields: Magnetic and Otherwise
Date: 19 Feb, 2009
From: Zukai Wang <Zukai Wang>

Dear All:
    Actually, I really have no idea which category my problem belongs to.
    If my magnetic field definition is in a simple way like this:
------------------------------------------------------------------------- 
void ExN02MagneticField::GetFieldValue(const double Point[3],double *Bfield) const
{
     Bfield[0]=0.;
     Bfield[1]=0.;
     Bfield[2]=0.;
if(fabs(Point[0])<75.*mm && fabs(Point[1])<405.*mm && fabs(Point[2])<705.*mm)
     Bfield[0]=-6450.*gauss;}
--------------------------------------------------------------------------
    The whole project works well.

    But when I put on a real magnetic field like this:

------------------------------------------------------------------
   void ExN02MagneticField::GetFieldValue(const double Point[3],double *Bfield) const
{
     Bfield[0]=0.;
     Bfield[1]=0.;
     Bfield[2]=0.;

 fstream in;

 G4double x=0.,y=0.,z=0.,Bx=0.,By=0.,Bz=0.;

 if (fabs(fabs(Point[0])-70.*mm)<5.*mm)
   in.open("Bmap36.dat");

  else if (fabs(fabs(Point[0])-60.*mm)<5.*mm)
   in.open("Bmap37.dat");

 else if (fabs(fabs(Point[0])-50.*mm)<5.*mm)
   in.open("Bmap38.dat");  

 else  if (fabs(fabs(Point[0])-40.*mm)<5.*mm)
   in.open("Bmap39.dat");

 else  if (fabs(fabs(Point[0])-30.*mm)<5.*mm)

 {  if (fabs(Point[1])<75.*mm)
    in.open("Bmap401.dat");

 else if (fabs(Point[1])<145.*mm)
   in.open("Bmap4022.dat");

 else in.open("Bmap4021.dat");
  }

  else  if (fabs(fabs(Point[0])-20.*mm)<5.*mm)

 {if (fabs(Point[1])<65.*mm)
    in.open("Bmap411.dat");

  else in.open("Bmap412.dat");}

 else  if (fabs(fabs(Point[0])-10.*mm)<5.*mm)
   in.open("Bmap42.dat");

 else  if (fabs(Point[0])<5.*mm)
   in.open("Bmap43.dat");

  while ( fabs(Point[1])<405.*mm && fabs(Point[2])<705.*mm) 

{
     in>>x>>y>>z>>Bx>>By>>Bz;

 if (!in.good()) break;

 if(Point[0]>0 && fabs(Point[1]-y*mm)<5.*mm && fabs(Point[2]-z*mm)<5.*mm)

{    Bfield[0]=Bx*gauss;
     Bfield[1]=By*gauss;
     Bfield[2]=Bz*gauss;

     break;
    }

else if (Point[0]<0 && fabs(Point[1]-y*mm)<5.*mm && fabs(Point[2]-z*mm)<5.*mm)

{     Bfield[0]=Bx*gauss;
     Bfield[1]=-By*gauss;
     Bfield[2]=-Bz*gauss;

     break;
       }

else if (Point[0]>0 && fabs(-Point[1]-y*mm)<5.*mm && fabs(Point[2]-z*mm)<5.*mm)

{     Bfield[0]=Bx*gauss;
     Bfield[1]=-By*gauss;
     Bfield[2]=Bz*gauss;

     break;
       }

else if (Point[0]<0 && fabs(-Point[1]-y*mm)<5.*mm && fabs(Point[2]-z*mm)<5.*mm)

{     Bfield[0]=Bx*gauss;
     Bfield[1]=By*gauss;
     Bfield[2]=-Bz*gauss;

     break;
       }

else if (Point[0]>0 && fabs(Point[1]-y*mm)<5.*mm && fabs(-Point[2]-z*mm)<5.*mm)

{    Bfield[0]=Bx*gauss;
     Bfield[1]=By*gauss;
     Bfield[2]=-Bz*gauss;

     break;
       }

   else if (Point[0]<0 && fabs(Point[1]-y*mm)<5.*mm && fabs(-Point[2]-z*mm)<5.*mm)

{     Bfield[0]=Bx*gauss;
     Bfield[1]=-By*gauss;
     Bfield[2]=Bz*gauss;

     break;
       }

  else if (Point[0]>0 && fabs(-Point[1]-y*mm)<5.*mm && fabs(-Point[2]-z*mm)<5.*mm)

{     Bfield[0]=Bx*gauss;
     Bfield[1]=-By*gauss;
     Bfield[2]=-Bz*gauss;

     break;
       }

  else if (Point[0]<0*mm && fabs(-Point[1]-y*mm)<5.*mm && fabs(-Point[2]-z*mm)<5.*mm)

{     Bfield[0]=Bx*gauss;
     Bfield[1]=By*gauss;
     Bfield[2]=Bz*gauss;

     break;
       }
 }

if (in.good())
   in.close();

} --------------------------------------------------------------------------

    The magnetic field values must be read from several files. The magnetic field values of more than 17000*8 points should be defined. I have edited the data files in a certain way to make the running of the program as fast as possible. The codes compiled and nothing wrong has been found.
    I shoot Krypton 78 in the particle gun and it will hit a detector which can record its kinetic energy and other information. The information has been showed on the screen. And at the end of an event, the event id should show up on the screen according to my codes. However, the event id has never appeared on the screen. Never one event has been finished!
    I wrote something in SteppingAction to track the Krypton 78 and found it pass through the magnetic field quickly (only 3 or 4 min) and hit the detector.
    And then, this ion kept on going. It reached the end of World and since then, the program ceased running. I mean, it was not aborted, it just stopped as if the poor ion did not know what to do next!
    I then increased the size of World. The ion (Kr78) lost all its energy in the last step, and the program stopped again! 
    No errors and no segment faults have been reported. If I didn't track the ion from the particle gun, I would think that the whole program might last for hours!
    So, I doubt that the pointers (or something else) has exceed the maximum of Geant4.8.3(my version). If you have come across similar problems, I'd like to thank you in advance for your direction.
                                                         Zukai Wang

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

1 Note: Re: The Strangest Problem I've ever met   (Tom Roberts - 19 Feb, 2009)
(_ Question: Re: The Strangest Problem I've ever met   (Zukai Wang - 20 Feb, 2009)
(_ Question: Is This the Reason?   (Zukai Wang - 20 Feb, 2009)
 Add Message Add Message
to: "The Strangest Problem I've ever met"

 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 ]