This is version 55.
It is not the current version, and thus it cannot be edited.
[Back to current version]
[Restore this version]
Stray Field Calculator
- for MA7 and MA7 (horizontal field), the central field is in x direction
- for MA6, MA09, MA10, MA15 and MB11 (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 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;
g5y = Math.pow(bb*10000./5.*runit*fact, 1.0/3);
g5a = g5y * Math.pow(2,1.0/3)
if (y == 0) y=1;
if (horizontal) {
bx=xb;
by=yb*yp/y;
bz=yb*zp/y;
g5x = g5a;
g5z = g5y;
} else {
bx=yb*xp/y;
by=yb*yp/y;
bz=xb;
g5x = g5y;
g5z = g5a;
}
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);
if (runit == 1) {
rprec = 2;
} else {
rprec = 0;
}
document.getElementById("g5x").innerHTML = g5x.toFixed(2);
document.getElementById("g5y").innerHTML = g5y.toFixed(2);
document.getElementById("g5z").innerHTML = g5z.toFixed(2);
return;
}
function turn(dim) {
xp = parseFloat(document.getElementById("x").value);
yp = parseFloat(document.getElementById("y").value);
zp = parseFloat(document.getElementById("z").value);
r = Math.sqrt(xp*xp+yp*yp+zp*zp);
document.getElementById("x").value = "0";
document.getElementById("y").value = "0";
document.getElementById("z").value = "0";
document.getElementById(dim).value = r;
calc();
}
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.012,10)"> MA10
<input type="radio" name=m onClick="mag(0,0.033,14.9)"> MA15
<input type="radio" name=m onClick="mag(1,0.0121,11)"> MA11
<input type="radio" name=m onClick="mag(0,0.0235,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>position</td><td colspan=3><div id=msg align=right style='color: red;'></div></td><td>5 Gauss distance</td></tr><tr>
<tr><td>x</td><td><input type=text id=x size=6 value="0" onChange="calc();"><input type=button value="turn to x" onClick="turn('x');"></td>
<td>Bx=</td><td><div id=bx align=right></div></td><td></td><td>rx=<span id=g5x align=right></span></td></tr>
<tr><td>y</td><td><input type=text id=y size=6 value="1" onChange="calc();"><input type=button value="turn to y" onClick="turn('y');"></td>
<td>By=</td><td><div id=by align=right></div></td><td></td><td>ry=<span id=g5y align=right></span></td></tr>
<tr><td>z</td><td><input type=text id=z size=6 value="0" onChange="calc();"><input type=button value="turn to z" onClick="turn('z');"></td>
<td>Bz=</td><td><div id=bz align=right></div></td><td></td><td>rz=<span id=g5z align=right></span></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-Feb-2019 15:03:30 UTC by MarkusZolliker.
|