Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 12th, 2012  |  syntax: None  |  size: 1.77 KB  |  hits: 10  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. /* HelmholtzCoils - demonstrating separation of analysis and toolkit interface in NDIToolbox by creating a
  2. simple magnetic field calculator
  3.  
  4. Chris Coughlin (TRI/Austin, Inc.)
  5. */
  6.  
  7. #ifndef HELMHOLTZCOILS_H_
  8. #define HELMHOLTZCOILS_H_
  9.  
  10. #define _USE_MATH_DEFINES // Required on some platforms to get mathematical constants
  11. #include <cmath>
  12. #include <cfloat>
  13.  
  14. static const double mu_0 = 4*M_PI*1e-7;
  15.  
  16. class HelmholtzCoils {
  17. public:
  18.     HelmholtzCoils(int turns_per_coil, double current_per_coil, double coil_radius):
  19.         N(turns_per_coil), I(current_per_coil), a(coil_radius), lhcoil_position(-a/2), rhcoil_position(a/2) { }
  20.    
  21.     const double H(const double position) const; // Magnetic field at position (m) in A/m
  22.     const double centerH(void) const { return H(0); } // Magnetic field at dead center of coils
  23.     const double B(const double position) const { return mu_0*H(position)*1000; } // Flux density at position (m) in mT
  24.     const double centerB(void) const { return B(0); } // Flux density at dead center of coils
  25.     const double B_mG(const double position) const { return B(position) * 1e4; } // Flux density at position (m) in mG
  26.    
  27.     const double wirelength(void) const; // Length of wire (m) to make N turns of radius a
  28.     const double awg_recommendation(void) const; // Lookup table to make AWG recommendations based on current I
  29.        
  30. private:
  31.     int N; // Turns per coil
  32.     double I; // Current (A) per coil
  33.     double a; // Common radius (m) of coils
  34.     double lhcoil_position; // Position of left coil (m), defined as -a/2
  35.     double rhcoil_position; // Position of right coil (m), defined as a/2
  36.     // Geometry correction for magnetic field calcs
  37.     const double geometry_correction(const double coil_position, const double position) const;
  38. };
  39.  
  40. #endif // HELMHOLTZCOILS_H_