def _Biot_Savart_SingleHelixSeg(helixseg, fieldpoint_vector, returnasVectors=False): """ Given a helix segment on the surface of a cylinder and a vector indicating the field point, this function computes Bx,By,Bz,and B2. Errors are also given. The results are Teslas per amp of current so You can multiply the result by the actual current to get the field. """ R = helixseg.cylind.radius const = mu_0 / float(4 * pi * R) M = helixseg.M / float(R) phiS = helixseg.cylind_startvect.phi # this is guaranteed to be zero if phiS != 0.0: print "Someone has changed the definition of HelixSeg" raise Exception phiE = helixseg.cylind_endvect.phi x = fieldpoint_vector.x / float(R) y = fieldpoint_vector.y / float(R) fieldpoint_cylind = helixseg.transform_to_helixcoords( fieldpoint_vector ) # We need some transformation to flip into coordinates referenced to the cylinder. z = (helixseg.cylind_startvect.z - fieldpoint_cylind.z) / float(R) # print "x,y,z,M,phiS,phiE:",x," ",y," ",z," ",M," ",phiS," ",phiE Bx, dBx = quadrature(Afunc, phiS, phiE, args=(x, y, z, M, phiS)) By, dBy = quadrature(Bfunc, phiS, phiE, args=(x, y, z, M, phiS)) Bz, dBz = quadrature(Cfunc, phiS, phiE, args=(x, y, z, M, phiS)) Bvect = Vector((const * Bx, const * By, const * Bz), type="CARTESIAN") dBvect = Vector((const * dBx, const * dBy, const * dBz), type="CARTESIAN") Bvect = helixseg.transform_from_helixcoords(Bvect) dBvect = helixseg.transform_from_helixcoords(dBvect) if returnasVectors == True: return (Bvect, dBvect) else: return ( (Bvect.x, Bvect.y, Bvect.z, Bvect.magnitude * Bvect.magnitude), (dBvect.x, dBvect.y, dBvect.z, (dBvect.magnitude) * (dBvect.magnitude)), )
def KernelTest(): print Cfunc(0, 0, 0, 0, 0, 0) print quadrature(Cfunc, 0, pi, args=(0, 0, 0, 0, 0))