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

Note Re: The Strangest Problem I've ever met 

Forum: Fields: Magnetic and Otherwise
Re: Question The Strangest Problem I've ever met (Zukai Wang)
Date: 19 Feb, 2009
From: Tom Roberts <Tom Roberts>

You most definitely do not want to open and read a file during EVERY call to GetFieldValue() -- this will slow your simulation down by a truly enormous factor! You consider "only 3 or 4 min" to be "quickly" -- I routinely track hundreds of particles per second for many meters through magnetic field maps. Even a single sprintf() or sscanf() during tracking slows it down unacceptably.

Arrange the code so you open and read the files ONCE during initialization and keep the results around to use in GetFieldValue(). It is generally better (more general, easier to modify) to use a single file with a field map, rather than multiple files. A good design has the field map file describe its own geometrical structure (boundaries of the map, grid within the map, units, etc.) and the code uses this rather than hard-coded values for the geometry. I strongly recommend an ASCII format, so you can edit it easily, and can write conversion programs from the output of an EM modeling program (superfish, tosca, ...) to the format your simulation reads. Field maps of several tens of megabytes are not a problem on modern computers.

Whenever a track reaches the edge of the world, the track is killed. Similarly, when a track stops (kinetic energy goes to 0 or below a limit set in the program) it is killed unless there is an applicable physics process that makes it get captured or decay (which also kills the track). Just think about it -- how could a track possibly be tracked outside the known world? Or tracked forever while stopped?

Normally, when all tracks have been processed (i.e. tracked until they are killed), the run is ended and the program exits. But you must do this in your main program, as in the examples.

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

1 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: "Re: 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 ]