This is the web version of EJS interface
EJS version 4.3.7
  1. Author=Michael R. Gallis - PSU/Schuylkill
  2. Abstract=mrg3@psu.edu
  3. CaptureTools=false
  4. DataTools=false
  5. LanguageTools=false
  6. EmersionSupport=true
  7. AppletColSupport=false
  8. UseInterpreter=true
  9. DetectedFiles=./MagneticDipoleField3D/MagneticDipoleField3D.html;
  10. AuxiliaryFiles=./MagneticDipoleField3D/;

Magnetic Dipole Field

    NameValueTypeDimension
    NameValueTypeDimension
    NameValueTypeDimension

    Init Page

    calFieldVectors(); if(!showLines && !showField){ // select something at start showLines=true; computeFieldline(true); }
    Indep. Var. Increment
    d xp /dtp=Bx/n
    d yp /dtp=By/n
    d zp /dtp=Bz/n
    SolverRungeKuttaFehlberg AbsoluteTolerance=tol
    compte the fieldline in positive B direction
    Indep. Var. Increment
    d xn /dtn=-Bx/n
    d yn /dtn=-By/n
    d zn /dtn=-Bz/n
    SolverRungeKuttaFehlberg AbsoluteTolerance=tol

    FixRel Page

    if(!pActive && !nActive){ // stop computation if field lines are not active _pause(); computeFieldline(false); }
    public double[] computeDipoleField (double x, double y, double z) { double rsquared = (x*x+y*y+z*z);// radius squared double r=Math.sqrt(rsquared); // radius if(r<magnetSize){return new double[]{0,0,0};} double pdotr=Math.sin(theta)*x/r+Math.cos(theta)*z/r; double r3=r*rsquared; // radius cubed double Fx = (3*pdotr*x/r-Math.sin(theta))/r3; double Fy = 3*pdotr*y/r; double Fz = (3*pdotr*z/r-Math.cos(theta))/r3; return new double[]{Fx,Fy,Fz}; } public double normalize(double[] a){ double n= Math.sqrt(a[0]*a[0]+a[1]*a[1]+a[2]*a[2]); if(n==0)return 0; a[0]/=n; a[1]/=n; a[2]/=n; return n; }
    public void calFieldVectors() { if(!showField)return; double delta=scale*range/(nb-1); double min=-range/2; double x=scale*min; for(int i=0;i<nb;i++) { double y=scale*min; for(int j=0;j<nb;j++) { double[] B=computeDipoleField( x, y, 0); double mag=mColor[i][j][0]=normalize(B); // normalize B but save magnitude double vSize=Math.log10(1+0.1*mag); // lookang for bigger vector size //double vSize=Math.log10(1.05+0.005*mag); // log-scale for length vSize=moment*Math.min(vSize,1*delta); // lookang for uniform length //vSize=moment*Math.min(vSize,2*delta); // limit size if (mag==0) { // lookang for http://www.cafeaulait.org/course/week2/43.html xBField[i][j][0]=0; } else { xBField[i][j][0]=vSize*B[0]; } //xBField[i][j][0]=mag==0?0:vSize*B[0]; if (mag==0) { yBField[i][j][0]=0; } else { yBField[i][j][0]=vSize*B[1]; } // yBField[i][j][0]=mag==0?0:vSize*B[1]; if (mag==0) { zBField[i][j][0]=0; } else { zBField[i][j][0]=vSize*B[2]; } //zBField[i][j][0]=mag==0?0:vSize*B[2]; y+=delta; } x+=delta; } }
    public void computeFieldline(boolean play) { _pause(); tp=tn=0; xp=handle[0]; yp=handle[1]; zp=handle[2]; xn=handle[0]; yn=handle[1]; zn=handle[2]; _view.positiveFieldlineTrail.moveToPoint(handle[0],handle[1],handle[2]); _view.negativeFieldlineTrail.moveToPoint(handle[0],handle[1],handle[2]); pActive=nActive=true; if(play)_play(); }
    public void changeN () { // for vectors lookang xBField=new double[nb][nb][1]; yBField=new double[nb][nb][1]; zBField=new double[nb][nb][1]; mColor=new double[nb][nb][1]; calFieldVectors(); }
    EJSVIEW: Click link to view it's content
    Control variables:(testing)
    double,int,double,double,double
    title="Magnetic Dipole Fields"
    layout=border
    visible=true
    location="110,100"
    size="769,668"
    position=east
    layout=border
    position=center
    variable=theta
    minimum=-Math.PI/2
    maximum=Math.PI/2
    orientation=VERTICAL
    enabled=showField
    dragaction=calFieldVectors()
    position=south
    layout=HBOX
    borderType=LOWERED_ETCHED
    position=center
    layout=HBOX
    visible=showField
    position=center
    layout=border
    position=west
    text=" |m| = "
    background=RED
    position=center
    variable=moment
    format="0.0#"
    action=moment=Math.max(moment,0.01); moment=Math.min(moment,10); calFieldVectors()
    columns=4
    size="0,24"
    tooltip="dipole moment"
    layout=VBOX
    layout=HBOX
    position=north
    variable=showField
    selected=true
    text="Field Vector "
    actionon=calFieldVectors()
    background=255,175,175,64
    tooltip="Show the field vectors"
    position=west
    text=" N = "
    background=255,175,175,64
    position=center
    variable=nb
    format="0"
    action=nb=Math.max(nb,9); nb=Math.min(nb,100); changeN ();
    columns=4
    size="0,24"
    tooltip="B field grid size"
    variable=nb
    minimum=0.0
    maximum=1.0
    pressaction=nb=Math.max(nb,9); nb=Math.min(nb,100); changeN ();
    background=255,175,175,64
    tooltip="B field grid size"
    position=east
    layout=HBOX
    layout=border
    visible=showLines
    position=center
    layout=HBOX
    position=west
    text=" x = "
    background=MAGENTA
    position=center
    variable=handlesliderx
    format="0.0"
    action=handle[0]=handlesliderx; computeFieldline(true);
    tooltip="position x"
    position=north
    variable=handlesliderx
    minimum=-range/2
    maximum=range/2
    action=handle[0]=handlesliderx; computeFieldline(true);
    background=MAGENTA
    layout=border
    visible=showLines
    position=center
    layout=HBOX
    position=west
    text=" y = "
    background=MAGENTA
    position=center
    variable=handleslidery
    format="0.0"
    action=handle[1]=handleslidery; computeFieldline(true);
    tooltip="position y"
    position=north
    variable=handleslidery
    minimum=-range/2
    maximum=range/2
    action=handle[1]=handleslidery; computeFieldline(true);
    background=MAGENTA
    layout=border
    visible=showLines
    position=center
    layout=HBOX
    position=west
    text=" z = "
    background=MAGENTA
    position=center
    variable=handlesliderz
    format="0.0"
    action=handle[2]=handlesliderz; computeFieldline(true);
    tooltip="position z"
    position=north
    variable=handlesliderz
    minimum=-range/2
    maximum=range/2
    action=handle[2]=handlesliderz; computeFieldline(true);
    background=MAGENTA
    variable=showLines
    selected=false
    text="Field Lines"
    background=MAGENTA
    tooltip="Show the field lines"
    position=west
    layout=FLOW:center,0,0
    variable=_isPaused
    enabled=showLines
    imageOn=/org/opensourcephysics/resources/controls/images/play.gif
    actionOn=_play()
    imageOff=/org/opensourcephysics/resources/controls/images/pause.gif
    actionOff=_pause()
    image="/org/opensourcephysics/resources/controls/images/erase.gif"
    action=_view.positiveFieldlineTrail.clear(); _view.negativeFieldlineTrail.clear();
    visible=showLines
    image=/org/opensourcephysics/resources/controls/images/reset.gif
    action=_reset()
    position=center
    minimumX=-range/2
    maximumX=range/2
    minimumY=-range/2
    maximumY=range/2
    minimumZ=-range/2
    maximumZ=range/2
    projectionMode="PERSPECTIVE_ON"
    cameraAzimuth=1.4500000000000006
    cameraAltitude=0.6758311853159397
    cameraFocusX=0.0
    cameraFocusY=0.0
    cameraFocusZ=0.0
    cameraRotation=0.0
    cameraDistanceToScreen=5.0
    illumination=true
    decorationType=CENTERED_AXES
    allowQuickRedraw=false
    squareAspect=true
    showCoordinates=BOTTOM_LEFT
    background=WHITE
    foreground=BLACK
    x=0
    y=0
    z=-magnetSize/2
    sizeX=magnetSize
    sizeY=magnetSize
    sizeZ=magnetSize
    enabledPosition=ENABLED_NONE
    fillColor=RED
    drawingLines=false
    x=0
    y=0
    z=magnetSize/2
    sizeX=magnetSize
    sizeY=magnetSize
    sizeZ=magnetSize
    enabledPosition=ENABLED_NONE
    fillColor=BLUE
    drawingLines=false
    visible=showLines
    position=handle
    x=handle[0]
    y=handle[1]
    z=handle[2]
    position=handle
    sizeX=.05
    sizeY=0.05
    sizeZ=0.05
    enabledPosition=ENABLED_ANY
    releaseAction=computeFieldline(true)
    fillColor=ORANGE
    inputX=xp
    inputY=yp
    inputZ=zp
    enabledPosition=ENABLED_NONE
    active=pActive
    lineColor=MAGENTA
    lineWidth=2
    inputX=xn
    inputY=yn
    inputZ=zn
    enabledPosition=ENABLED_NONE
    lineColor=MAGENTA
    lineWidth=2
    visible=showField
    minimumX=-scale*range/2
    maximumX=scale*range/2
    minimumY=-scale*range/2
    maximumY=scale*range/2
    minimumZ=-scale*range/2
    maximumZ=scale*range/2
    xcomponent=xBField
    ycomponent=yBField
    zcomponent=zBField
    elementposition=CENTERED
    magnitude=mColor
    autoscale=false
    minimum=0
    maximum=4
    levels=32
    sizeX=range*scale
    sizeY=range*scale
    fillColor=255,175,175,64
    resolution="0,0,0"
    angle=theta