Navigation

Main Page
Download
Support
Installation
Tutorial
Examples
Reference Manual
Publications


Hosted by Get Ion Beam Simulator at SourceForge.net. Fast, secure and Free Open Source software downloads

Analytic magnetic field

You can manually define the magnetic field to what ever shape you like. To get a gaussian peak in y-direction for example, you can do the following:

bool fout[3] = { true, true, true };
MeshVectorField bfield( geom, fout );
for( int32_t i = 0; i < bfield.size(0); i++ ) {
    //double x = bfield.origo(0)+i*bfield.h();
    for( int32_t j = 0; j < bfield.size(1); j++ ) {
        //double y = bfield.origo(1)+j*bfield.h();
        for ( int32_t k = 0; k < bfield.size(2); k++ ) {
            double z = bfield.origo(2)+k*bfield.h();

            const double z_ave = 2.0e-3;
            const double s = 2.5e-3;
            double t = z-z_ave;
            double By0 = -100.0e-3;
            double By = By0*exp(-t*t/(2.0*s*s));

            bfield.set( i, j, k, Vec3D( 0, By, 0 ) );
        }
    }
}


Copyright © 2010-2011 Taneli Kalvas
Last modified: Mon Jun 23 15:30:53 EEST 2014