Yo,<div><br></div><div>I checked in the first version of a Java stand-alone magnetic field interpolator into "magfield" in the svn repository. It reads the same binary file ced uses, clas12_torus_fieldmap_binary.dat, which is in the data directory after checkout. It does not yet read the ascii file that gemc uses (from which the binary file was derived) but it will. At the moment there is just one class that you need to instantiate: Torus (see the javadocs in the doc folder). The functionality is simple:<div>
<br></div><div>1) create a Torus by a static method in the Torus class that accepts a File object corresponding to the binary file</div><div>2) you get get the field (in kiloGauss) at any x,y,z. See the documentation for coordinate system discussion, units, etc.</div>
<div>3) you can globally invert the field to make inbenders into out benders, and vice versa. </div><div>4) you can tell it to return zero for all requests, i.e. turn the magnet off--useful (I found) for debugging.</div><div>
<br></div><div>See the main program in Torus for an example.</div><div><br></div><div>Its own jar file magfield.jar is in the lib folder. Alternatively,  eclipse uses can just make a dependency on the project</div><div><br>
</div><div><b>What could go wrong?</b></div><div><br></div><div>The field map is only for 30 degrees (in phi) of the field. i.e. half of sector one. Obtaining values for the other half and other sectors requires some inversions and rotations. I think I did it right but who knows? Someone should double check. It agrees with red, and ced's swimming seems to work properly. </div>
<div><br></div><div><b>Notes:</b></div><div><br></div><div>1) It uses float arithmetic, not double--purely to make the field map smaller. I don't know if this is sufficient.</div><div><br></div><div>2) The interpolation is simple tri-linear</div>
<div><br></div><div>3) After some consideration I decided to be math library agnostic. It does not use any 3rd party definitions of a 3-vector from any math library. It uses arrays of three floats as generic 3-vectors, with x,y,z corresponding to the 0,1 and 2 indices.</div>
<div><br></div><div>Cheers,</div><div>dph<br clear="all"><div><br></div>-- <br>David P. Heddle, Ph.D.<br>
Associate Professor and Chair<br>
Department of Mathematics<br>
Christopher Newport University<br>
1 University Place<br>
Newport News, VA 23606<br>
</div></div>