00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
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