src/polywell_conf.hpp

Go to the documentation of this file.
00001 //
00002 // Ephi - simulation of magnetic fields and particles
00003 // Copyright (C) 2007 Indrek Mandre <indrek(at)mare.ee>
00004 // For more information please see http://www.mare.ee/indrek/ephi/
00005 //
00006 // This program is free software; you can redistribute it and/or modify
00007 // it under the terms of the GNU General Public License as published by
00008 // the Free Software Foundation; either version 2 of the License, or
00009 // (at your option) any later version.
00010 //
00011 // This program is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 // GNU General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU General Public License along
00017 // with this program; if not, write to the Free Software Foundation, Inc.,
00018 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
00019 //
00020 
00021 // Polywell simulation. Simulate the movement of a single electron
00022 // inside the polywell magnetic containment system.
00023 
00024 #ifndef __polywell_conf_hpp__
00025 #define __polywell_conf_hpp__
00026 
00028 class CoilFactory
00029 {
00030 public:
00031   virtual ~CoilFactory () { }
00032 
00034   virtual bool make (Statics& statics, const vect3d& pos, const vect3d& normal,
00035       prec_t radius, prec_t wr, prec_t I, prec_t q_per_m) const = 0;
00036 
00038   virtual bool make_coilpair (Statics& statics, const vect3d& pos, const vect3d& normal,
00039       prec_t distance, prec_t radius, prec_t wr, prec_t I, prec_t q_per_m) const
00040   {
00041     vect3d n = normal.normal();
00042     return make (statics, pos + 0.5 * distance * n, -normal, radius, wr, I, q_per_m) &&
00043         make (statics, pos - 0.5 * distance * n, normal, radius, wr, I, q_per_m);
00044   }
00045 };
00046 
00048 class ShapedCoilFactory : public CoilFactory
00049 {
00050 public:
00051   ShapedCoilFactory (int n = 1);
00052   ShapedCoilFactory (int w, int h, prec_t hs = 1.0, prec_t vs = 1.0);
00053   virtual ~ShapedCoilFactory();
00054 
00055   bool make (Statics& statics, const vect3d& pos, const vect3d& normal,
00056       prec_t radius, prec_t wr, prec_t I, prec_t q_per_m) const;
00057 
00058   void set(int x, int y, bool v);
00059   void set_all (bool v);
00060   void set_circle ();
00061 
00062   int get_width () const { return width; }
00063   int get_height () const { return height; }
00064   prec_t get_hscale () const { return hscale; }
00065   prec_t get_vscale () const { return vscale; }
00066   void set_scale (prec_t hs, prec_t vs) { hscale = hs; vscale = vs; }
00067 
00068   bool get(int x, int y, vect3d& offset) const;
00069   int count() const;
00070   void print ();
00071 
00072 private:
00073   int width, height;
00074   prec_t hscale, vscale;
00075   std::vector<bool> grid;
00076 };
00077 
00079 extern void make_polywell_dodecahedron (Statics& statics, prec_t R, prec_t magnet_radius,
00080     prec_t magnet_spacing, prec_t I, prec_t q_per_m = 0, const CoilFactory& cf = ShapedCoilFactory());
00082 extern void make_polywell_cube (Statics& statics, prec_t R, prec_t magnet_radius,
00083     prec_t magnet_spacing, prec_t I, prec_t q_per_m = 0, const CoilFactory& cf = ShapedCoilFactory());
00085 extern void make_solenoid (Statics& statics, size_t n, prec_t R, prec_t wire_radius,
00086     prec_t spacing, prec_t I, const CoilFactory& cf = ShapedCoilFactory());
00087 
00088 extern const transf3d_pair& cube_polywell_transform (vect3d& p);
00089 
00090 #endif // !__polywell_conf_hpp__
00091 

Generated on Thu Dec 6 20:31:14 2007 for Ephi by  doxygen 1.5.0