This is version 29.
It is not the current version, and thus it cannot be edited.
[Back to current version]
[Restore this version]
Stray Field Calculator
- for MA7 (horizontal field), the central field is in x direction
- for MA6, MA09 and MA15 (vertical field), the central field is in z direction
- the origin of the coordinate system is the center of the magnet (= sample position)
- a dipole approximation is used, therefore positions very close to the magnet might not be precise
- for MA02 and MA11 we have no stray field numbers
<html>
<script>
var horizontal=0;
var runit=1;
var bunit=0;
var fact=0; // factor
var field=0;
var maxfield=0;
function errmsg(text) {
document.getElementById("msg").innerHTML=text;
document.getElementById("b").innerHTML="";
document.getElementById("bx").innerHTML="";
document.getElementById("by").innerHTML="";
document.getElementById("bz").innerHTML="";
}
function calc() {
// x: along axis
// y: perpendicular to axis
if (fact == 0) {
errmsg("please select magnet");
return;
}
xp = parseFloat(document.getElementById("x").value);
yp = parseFloat(document.getElementById("y").value);
zp = parseFloat(document.getElementById("z").value);
bb = parseFloat(document.getElementById("bb").value);
if (horizontal) {
x=xp;
y=Math.sqrt(yp*yp+zp*zp);
} else {
x=zp;
y=Math.sqrt(yp*yp+xp*xp);
}
r2=x*x+y*y;
r3=r2*Math.sqrt(r2);
if (fact*runit/r3 > 1) {
errmsg("distance too low");
return;
}
xb=bb*Math.pow(10,bunit)*runit*fact*(3*x*x/r2-1)/r3;
yb=bb*Math.pow(10,bunit)*runit*fact*3*x*y/r2/r3;
console.log(xb,yb,horizontal);
if (y == 0) y=1;
if (horizontal) {
bx=xb;
by=yb*yp/y;
bz=yb*zp/y;
} else {
bx=yb*xp/y;
by=yb*yp/y;
bz=xb;
}
prec = 5-bunit;
b = Math.sqrt(bx*bx+by*by+bz*bz);
if (b > 0) {
eps = Math.pow(0.1,prec);
while (eps > 0.009 * b) {
prec++; eps *= 0.1;
}
}
errmsg("");
document.getElementById("bx").innerHTML = bx.toFixed(prec);
document.getElementById("by").innerHTML = by.toFixed(prec);
document.getElementById("bz").innerHTML = bz.toFixed(prec);
document.getElementById("b").innerHTML = b.toFixed(prec);
return;
}
function mag(h,f,b) {
horizontal=h;
fact=f/b;
maxfield=b;
document.getElementById("bb").value=b;
calc();
}
</script>
<form>
<!-- mag(h,f,b)
h: 1/0 for horizontal/vertical
f: stray field at 1 m perpendicular to field, when central field at max.
b: max. field
-->
<input type="radio" name=m onClick="mag(0,0.0032,6)"> MA6
<input type="radio" name=m onClick="mag(1,0.017,6.8)"> MA7
<input type="radio" name=m onClick="mag(0,0.015,9)"> MA09
<input type="radio" name=m onClick="mag(0,0.0125,10)"> MA10
<input type="radio" name=m onClick="mag(0,0.033,14.9)"> MA15
<input type="radio" name=m onClick="mag(0,0.0257,11)"> MB11
<p>
<table>
<tr><td colspan=2><b>central field</b></td>
<td rowspan=9 valign=top><input type=button value=">" onClick="calc();"></td>
<td colspan=2><b>stray field</b></td></tr>
<tr><td></td><td><input type=text id=bb size=6 value="" onChange="calc();">Tesla</td>
<td>B=</td><td><div id=b align=right></div></td><td>
<input type="radio" name=b onClick="bunit=0;calc();" checked> Tesla
<input type="radio" name=b onClick="bunit=3;calc();"> mTesla
<input type="radio" name=b onClick="bunit=4;calc();"> Gauss<td></tr>
<tr><td colspan=2>stray field at position</td><td><div id=msg align=right style='color: red;'></div></td><td></td></tr><tr>
<tr><td>x</td><td><input type=text id=x size=6 value="0" onChange="calc();"></td>
<td>Bx=</td><td><div id=bx align=right></div></tr>
<tr><td>y</td><td><input type=text id=y size=6 value="1" onChange="calc();"></td>
<td>By=</td><td><div id=by align=right></div></td></tr>
<tr><td>z</td><td><input type=text id=z size=6 value="0" onChange="calc();"></td>
<td>Bz=</td><td><div id=bz align=right></div></td></tr>
<tr><td colspan=2>
<input type="radio" name=r onClick="runit=1;calc();" checked> m
<input type="radio" name=r onClick="runit=1000000;calc();"> cm
<input type="radio" name=r onClick="runit=1000000000;calc();"> mm
</td></tr>
</table>
</form>
</html>
This particular version was published on 13-Nov-2017 15:16:04 UTC by MarkusZolliker.
|