This is the web version of EJS interface
EJS version 4.2.7
  1. Title=Alternating Current Generator Model
  2. Author=Fu-Kwun Hwang - Dept. of Physics, National Taiwan Normal Univ. & lookang
  3. Keywords=Alternating Current Generator Model
  4. Level=High School, Pre University
  5. Abstract=hwang@phy.ntnu.edu.tw remixed by lookang
  6. CaptureTools=false
  7. DataTools=true
  8. LanguageTools=true
  9. EmersionSupport=false
  10. UseInterpreter=true
  11. AuxiliaryFiles=./ACgenerator/;
  12. DetectedFiles=./ACgenerator/ACgenerator.html;./ACgenerator/ACgeneratorEx.html;
    NameValueTypeDimension
    NameValueTypeDimension
    NameValueTypeDimension
    NameValueTypeDimension
    NameValueTypeDimension
    NameValueTypeDimension
    NameValueTypeDimension
    NameValueTypeDimension

    Init Page

    // may need to change this to suit the new variables of lengthx and lengthz for(int i=0;i<n;i++){ y1[i]=-lengthz/2+lengthz/n*i; // AD y3[i]=lengthz/2-lengthz/n*i; // BC x2[i]=a-lengthx/n*i; //AB x4[i]=a-lengthx/n*i; // DC } for(int i=0;i<n5;i++){ x5s[i]=a+2*R-i*R/n5; // XA' // x6s[i]=a+i*D; // YD' } for(int i=0;i<n6;i++){ // x5s[i]=a+2*R-i*R/4; // XA' x6s[i]=a+4*R-i*4*R/n6; // YD' } setparam (); //

    Evol Page

    Indep. Var. Increment
    d y1[i] /dt=-size*8*sign*2*currentsign1
    d y3[i] /dt=size*8*sign*2*currentsign1
    d x2[i] /dt=size*8*sign*2*currentsign1
    d x4[i] /dt=-size*8*sign*2*currentsign1
    d x5s[i] /dt=size*8*sign*2*currentsign1
    d x6s[i] /dt=-size*8*sign*2*currentsign1
    d z7s[i] /dt=vz7*sign3
    d y8s[i] /dt=-vy8*sign3
    d y9s[i] /dt=vy8*sign3
    SolverMidPointTolerance=0.001
    // for making angle == cta //if(_isPlaying()){ cs=Math.cos(cta); sc=Math.sin(cta); // define mathematical eqn vb[1]=2*b*sc; // define direction of coil vb[1]= 2*b*sc; not need vb[2]=2*b*cs; // define direction of coil vb[2]= 2*b*cs; not need cos change the drawing objects vc[1]=2*(lengthz/2)*sc; // use for flux visualization va[0] = 2*(lengthx/2); // use for flux visualization y2s=lengthz/2*sc; // control position of particles AB z2s=lengthz/2*cs; // control position of particles AB y4s=-lengthz/2*sc; // control position of particles DC z4s=-lengthz/2*cs; // control position of particles DC for(int i=0;i<n;i++){ // position of current particles on AD if(y1[i]<(lengthz/2)-(lengthz/n)*(i+1))y1[i]+=(lengthz/n); else if(y1[i]>(lengthz/2)-(lengthz/n)*i)y1[i]-=(lengthz/n); // position of current particles on DC if(y3[i]<(lengthz/2)-(lengthz/n)*(i+1))y3[i]+=(lengthz/n); else if(y3[i]>(lengthz/2)-(lengthz/n)*i)y3[i]-=(lengthz/n); // position of current particles on AB // the logic is //if(x2[i]<start-(equaldistance)*(i+1))x2[i]+=equaldistance; // else if(x2[i]>start-(equaldistance)*i)x2[i]-=equaldistance; s_m2[i] =double2String(i,1); // for debugging purposes the text on the 3D view if(x2[i]<a-(lengthx/n)*(i+1))x2[i]+=lengthx/n; else if(x2[i]>a-(lengthx/n)*i)x2[i]-=lengthx/n; // position of current particles on DC if(x4[i]<a-(lengthx/n)*(i+1))x4[i]+=lengthx/n; else if(x4[i]>a-(lengthx/n)*i)x4[i]-=lengthx/n; //if(x4[i]>-a+(lengthx/n)*(i+1))x4[i]-=(lengthx/n); // else if(x4[i]<-a+(lengthx/n)*i)x4[i]+=(lengthx/n); y1s[i]=y1[i]*sc; z1s[i]=y1[i]*cs; // position of current particles on BC x3s=a-lengthx; // added to control particles on BC controllable by lengthx y3s[i]=y3[i]*sc; z3s[i]=y3[i]*cs; if((y1[i]-R)*(y1[i]+R)<0)s1[i]=false; else s1[i]=true; // help added by lookang // z7s[i] change to xyz10s[i] > - Pos xyz + (i+1)*(sizexyz)/i xyz[i] = xyz[i] - sizexyz/i; // battery wire } for(int i=0;i<n5;i++){ // top 0 degree connecting wire from brush to coil // original //if(x5s[i]<a+8*R-(i+1)*D)x5s[i]+=D; // else if(x5s[i]>a+8*R-i*D)x5s[i]-=D; //if(x5s[i]<a+2*R-(i+1)*R)x5s[i]+=R/n; // else if(x5s[i]>a+2*R-i*R)x5s[i]-=R/n; // if(x2[i]<a-(lengthx/n)*(i+1))x2[i]+=lengthx/n; // else if(x2[i]>a-(lengthx/n)*i)x2[i]-=lengthx/n; s_m5[i] =double2String(i,1); if(x5s[i]<a+2*R-(2*R/n5)*(i+1))x5s[i]+=2*R/n5; else if(x5s[i]>a+2*R-(2*R/n5)*i)x5s[i]-=2*R/n5; //if(x5s[i]<a-(i+1)*R/4)x5s[i]+=R/4; // else if(x5s[i]>-a+i*R/4)x5s[i]-=R/4; } for(int i=0;i<n6;i++){ // bottom 180 degree connecting wire from brush to coil //if(x6s[i]<a+2*R-(i+1)*D)x6s[i]+=D; // else if(x6s[i]>a+2*R-i*D)x6s[i]-=D; if(x6s[i]<a+4*R-(4*R/n6)*(i+1))x6s[i]+=4*R/n6; else if(x6s[i]>a+4*R-(4*R/n6)*i)x6s[i]-=4*R/n6; //if(x6s[i]>a+(i+1)*D)x6s[i]-=D; // else if(x6s[i]<a+i*D)x6s[i]+=D; // battery top wire particles spacing //disable move to a imax = 2 loop to create lesser particles // current does not work strange currentsign = current/Math.abs(current); // if ( current>0 ) { // for particles movement currentsign1=1; } else if ( current <0) { // for particles movement currentsign1=-1; } else { // for particles movement currentsign1=-0; } if(z7s[i]>-R*1.15+(i+1)*2.25*R/4)z7s[i]-=2.25*R/4; // by trial n error to achieve range from ehich particle appear n disappear else if(z7s[i]<-R*1.15+i*2.25*R/4)z7s[i]+=2.25*R/4; //if(z7s[i]>0-(i+1)*2.25*R/5)z7s[i]-=D; // by trial n error to achieve look of particles // else if(z7s[i]<0-i*2.25*R/5)z7s[i]+=D; // top battery wire if(y8s[i]>-0-R*2+(i+1)*(R*2)/4)y8s[i]-=R*2/4; // by trial n error to achieve look of particles else if(y8s[i]<-0-R*2+i*(R*2)/4)y8s[i]+=R*2/4; // bottom battery wire if(y9s[i]>-0-R*2+(i+1)*(R*2)/4)y9s[i]-=R*2/4; // by trial n error to achieve look of particles else if(y9s[i]<-0-R*2+i*(R*2)/4)y9s[i]+=R*2/4; } // to modify this particle distribution and appear/disappear //}
    s_m1 = " i = "+double2String(current,10.)+" $\\micro$ A";
    Array
    // created by lookang for slider ctadegree0360 ctadegree = Math.atan2(sc,cs)*180/(pi); // added Math.abs(ctadegree0360-ctadegree0360s)<180 to connect true if need a static plot of 0 to 360 ctadegree0360s = ctadegree0360; // for the plot of flux vs angle if ( ctadegree<0 ) { ctadegree0360 = ctadegree +360; } else { ctadegree0360 =ctadegree; } //created by lookang for comparison to get getAlpha(cta) -bf*omega to model contact previously missing cta02pi = Math.atan2(sc,cs); // omega //omegadegree = omega*180/(pi); omegadegree = omega*180/pi; // split ring cta1 cta2 //cta1degree = cta1*180/(pi); //cta2degree = cta2*180/(pi); // for split ring cta1degree=cta2degree //cta1degree=-cta2degree; // sliders display to work // cta1 = cta1degree*pi/180; // cta2 = cta2degree*pi/180; //to calculate omega from cta, a trick i learnt hwang http://www.phy.ntnu.edu.tw/ntnujava/index.php?topic=701.0 omegas=omega; // for use in storing omega to display motion without blinking out //omega=(cta-ctastored)/dt; the code produced intermitent values 0 , 7.5 0,7.5 etc ctastored = cta; omega = compute_Omega (); T=2*pi/omega;
    // http://en.wikipedia.org/wiki/Magnetic_flux // area A = va[0]*vb[1] //flux = B*(va[0]*vb[1]) cos angle between B&A magneticflux=B*(va[0]*vb[1]); fluxhwang=B*a*b; E0=fluxhwang*omega/20; // emf = N*B*A*cos(?)*d?/dt E=N*B*(a*b)*cs*omega; showE=Math.abs(E*omega)>0;// && _isPlaying(); c2=(cta % pi2)/pi2; if(c2<0)c2+=1;
    //handle= "z:"+cta; // no need // // adapted from http://www.compadre.org/OSP/document/ServeFile.cfm?ID=9218&DocID=1237#Doc1237 angle = _view.angleFunction.evaluate(t); //value of the angle of loop // make phi = NBAcos(angleB&A) A = lengthx*lengthz; flux = N*B*A*Math.cos(angle+pi/2); cta = angle; // for merging the variables in different models // actually getCurrent() is d ( phi(t) ) /dt current=N*B*A*getCurrent()/Resistance; // remodel to reflect the A level context emf = current*Resistance; meterDisplay=current; // actually meterDisplay is inducedemf if (meterDisplay >100) meterDisplay =100; //limits on meterDisplay if (meterDisplay <-100) meterDisplay=-100; // make ammeter set to zero when t = 0 if ( t==0 ) { current = 0; emf = 0; }
    public void setparam () { // a2=I*L*B*b/Inertia; // from T = inertia.ctadoubledot // from F.b = inertia.ctadoubledot // IBL.b = inertia.ctadoubledot // suspect a2 = ctadoubledot //I = current; // to make 2 models work together v0=4*size*current; vy1=vx4=v0; vx2=-v0; vy3=-v0; BZ0=-(zmin+(B+2)*range/4); }
    double dv; public String double2String(double v,double divider){ if(v>0)dv=0.5; else if(v<0)dv=-0.5; else dv=0; return (int)(v*divider+dv)/divider+""; } // this code has to do with displaying the number 2.3 instead of 2.300000001 when using % %
    // actually getcurrent is getdsinomegatoverdt public double getCurrent () { //angleFunction is name of the input field for 5*t for example double thetaMinus = _view.angleFunction.evaluate(t-dt); //angle at t-dt double thetaPlus = _view.angleFunction.evaluate(t+dt); //angle at t+dt return (Math.sin(thetaPlus)-Math.sin(thetaMinus))/dt/2; // central difference approximation }
    public double compute_Omega() { double thetaMinus1 = _view.angleFunction.evaluate(t-dt); //angle at t-dt double thetaPlus1 = _view.angleFunction.evaluate(t+dt); //angle at t+dt return ((thetaPlus1)-(thetaMinus1))/dt/2; // central difference approximation }
    public double getAlpha (double cta) { sign2=sign; // keep the direction of force same. sign2 stored sign for force draw a2*sign2*3 sign3 = sign4; //sign3 =sign; // sign3 stored sign for particle in battery wires if(!Is)sign=-sign; // boolean Is current state is not 0, sign =-sign if(!Is)sign3=-sign3; // make sign3 flip if electron is selected if (I>0){ sign4 = 1; // battery wire constant direction } else { sign4 = -1; // battery wire constant negative direction } if (splitring==true){ if(Math.cos(cta)>=0&&cta02pi<=cta2&&cta02pi<=pi/2&&cta02pi>=0) { //contact sign=1; // 1stQ return a2*Math.abs(Math.cos(cta)); } else if (Math.cos(cta)<=0&&cta02pi>=pi-cta2&&cta02pi>=pi/2&&cta02pi<=pi) { sign=-1; //2ndQ //sign4 = 1; return a2*Math.abs(Math.cos(cta)); } else if(Math.cos(cta)<=0&&cta02pi<=-pi-cta1&&cta02pi>=-pi&&cta02pi<=-pi/2) { sign=-1; // 3rdQ //sign4 = 1; return a2*Math.abs(Math.cos(cta)); } else if (Math.cos(cta)>=0&&cta02pi>=cta1&&cta02pi>=-pi/2&&cta02pi<=0) { sign=1; //4thQ //sign4 = 1; return a2*Math.abs(Math.cos(cta)); } else { sign = 0; // no contact no magnetic force sign4 = 0; return 0; } } else { //sign4 = 1; // for the particles on the battery wires direction of motion return a2*(Math.cos(cta)); // for no split ring } }
    EJSVIEW: Click link to view it's content
    Control variables:(testing)
    double,double,double,double,double,double,double,double,double,int,double,double
    title="Alternating Current Generator Model"
    layout=border
    visible=true
    location="-120,45"
    size="600,641"
    position=center
    minimumX=xmin
    maximumX=xmax
    minimumY=ymin
    maximumY=ymax
    minimumZ=zmin
    maximumZ=zmax
    cameraAzimuth=7.410000000000139
    cameraAltitude=0.14920367320509445
    cameraFocusX=0.0
    cameraFocusY=0.0
    cameraFocusZ=0.0
    cameraRotation=0.0
    cameraDistanceToScreen=4.919999999999991
    background=200,220,208
    x=0
    y=0
    z=0
    x=a
    y=R*sc
    z=R*cs
    sizeX=0
    sizeY=sc*lengthz/2-R*sc
    sizeZ=cs*lengthz/2-R*cs
    lineColor=RED
    lineWidth=3
    x=a
    y=(R)*sc+sc*lengthz/2-R*sc
    z=(R)*cs+cs*lengthz/2-R*cs
    sizeX=-lengthx
    sizeY=0
    sizeZ=0
    lineColor=RED
    lineWidth=3
    x=a
    y=-R*sc
    z=-R*cs
    sizeX=0
    sizeY=-(sc*lengthz/2-R*sc)
    sizeZ=-(cs*lengthz/2-R*cs)
    lineColor=BLUE
    lineWidth=3
    x=a
    y=-R*sc+-(sc*lengthz/2-R*sc)
    z=-R*cs+-(cs*lengthz/2-R*cs)
    sizeX=-lengthx
    sizeY=0
    sizeZ=0
    lineColor=BLUE
    lineWidth=3
    x=a-lengthx
    y=0
    z=0
    sizeX=0
    sizeY=sc*lengthz/2
    sizeZ=cs*lengthz/2
    lineColor=RED
    lineWidth=3
    x=a-lengthx
    y=0
    z=0
    sizeX=0
    sizeY=-(sc*lengthz/2)
    sizeZ=-(cs*lengthz/2)
    lineColor=BLUE
    lineWidth=3
    firstDirection=va
    secondDirection=vc
    x=a-(lengthx/2)
    y=0
    z=zflux
    visible=true
    lineColor=128,128,128,128
    fillColor=128,128,128,128
    visible=label==true
    x=a
    y=(R)*sc+sc*lengthz/2-R*sc
    z=(R)*cs+cs*lengthz/2-R*cs
    text="A"
    lineColor=WHITE
    fillColor=WHITE
    font=Arial,BOLD,32
    x=a-lengthx
    y=(R)*sc+sc*lengthz/2-R*sc
    z=(R)*cs+cs*lengthz/2-R*cs
    text="B"
    lineColor=WHITE
    fillColor=WHITE
    font=Arial,BOLD,32
    x=a-lengthx
    y=-R*sc+-(sc*lengthz/2-R*sc)
    z=-R*cs+-(cs*lengthz/2-R*cs)
    text="C"
    lineColor=WHITE
    fillColor=WHITE
    font=Arial,BOLD,32
    x=a
    y=-R*sc+-(sc*lengthz/2-R*sc)
    z=-R*cs+-(cs*lengthz/2-R*cs)
    text="D"
    lineColor=WHITE
    fillColor=WHITE
    font=Arial,BOLD,32
    x=12*R
    y=0
    z=0
    sizeX=-D*6*2
    sizeY=0
    sizeZ=0
    lineColor=WHITE
    x=6*R
    y=0
    z=0
    text="P"
    lineColor=WHITE
    fillColor=WHITE
    font=Arial,BOLD,32
    x=a-lengthx
    y=0
    z=0
    text="Q"
    lineColor=WHITE
    fillColor=WHITE
    font=Arial,BOLD,32
    x=a+8*R/4
    y=R*sc*1.5
    z=R*cs*1.5
    text="X"
    lineColor=WHITE
    fillColor=WHITE
    font=Arial,BOLD,32
    x=a+8*R/2
    y=-R*sc*1.5
    z=-R*cs*1.5
    text="Y"
    lineColor=WHITE
    fillColor=WHITE
    font=Arial,BOLD,32
    x=a
    y=R*sc*4/4
    z=R*cs*4/4
    text="A'"
    lineColor=WHITE
    fillColor=WHITE
    font=Arial,BOLD,32
    x=a
    y=-R*sc*4/4
    z=-R*cs*4/4
    text="D'"
    lineColor=WHITE
    fillColor=WHITE
    font=Arial,BOLD,32
    x=a
    y=(R)*sc+sc*lengthz/2-R*sc
    z=(R)*cs+cs*lengthz/2-R*cs
    text="*"
    lineColor=WHITE
    fillColor=WHITE
    font=Arial,BOLD,32
    x=a
    y=-R*sc
    z=-R*cs
    sizeX=0
    sizeY=R*sc*2*0.9
    sizeZ=R*cs*2*0.9
    lineColor=200,220,208
    lineWidth=stroke*3.1
    visible=true
    points=36
    min=cta1
    max=cta2
    variable="c"
    functionx="a+8*R/4"
    functiony="1.5*R*sin(c+cta)"
    functionz="1.5*R*cos(c+cta)"
    lineColor=RED
    lineWidth=stroke*5
    x=8*R/4+a
    y=0
    z=R*1.65
    sizeX=R/4
    sizeY=R/4
    sizeZ=R/4
    fillColor=RED
    x=a
    y=R*sc
    z=R*cs
    sizeX=8*R/4
    sizeY=0
    sizeZ=0
    lineColor=RED
    lineWidth=stroke*3
    x=a+R*8/4
    y=R*sc
    z=R*cs
    sizeX=0
    sizeY=R*sc*0.35
    sizeZ=R*cs*0.35
    lineColor=RED
    lineWidth=stroke*3
    points=36
    min=cta1
    max=cta2
    variable="c"
    functionx="a+8*R/2"
    functiony="1.5*R*sin(c+cta+pi)"
    functionz="1.5*R*cos(c+cta+pi)"
    lineColor=BLUE
    lineWidth=stroke*5
    x=8*R/2+a
    y=0
    z=-R*1.65
    sizeX=R/4
    sizeY=R/4
    sizeZ=R/4
    fillColor=BLUE
    x=a
    y=-R*sc
    z=-R*cs
    sizeX=8*R/2
    sizeY=0
    sizeZ=0
    lineColor=BLUE
    lineWidth=stroke*3
    x=a+8*R/2
    y=-R*sc
    z=-R*cs
    sizeX=0
    sizeY=-R*sc*0.35
    sizeZ=-R*cs*0.35
    lineColor=BLUE
    lineWidth=stroke*3
    x=-a*7*R
    y=0
    z=0
    sizeX=R*2
    sizeY=R*2
    sizeZ=R/4
    transformation="y:-90d & x:"+(-cta)
    fillColor=CYAN
    x=a-10*R
    y=R*sc*0.8
    z=R*cs*0.8
    sizeX=R*1.5/5
    sizeY=R*1.5/5
    sizeZ=R*1.5
    transformation="y:90d"
    fillColor=CYAN
    x=a-9*R+(R+2*a-lengthx)/2
    y=0
    z=0
    sizeX=R*1.5/2
    sizeY=R*1.5/2
    sizeZ=R+2*a-lengthx
    transformation="y:-90d & x:"+(-cta)
    fillColor=CYAN
    visible=false
    x=8*R/4+a
    y=0
    z=R*1.65
    sizeX=0
    sizeY=-R*2
    sizeZ=0
    lineWidth=stroke*1.5
    x=8*R/4+a
    y=-R*2
    z=R*1.65
    sizeX=0
    sizeY=0
    sizeZ=-R*3.5
    lineWidth=stroke*1.5
    x=8*R/2+a
    y=-R*3.5
    z=-R*1.65+R/2.5
    sizeX=-R-R
    sizeY=1.5*R
    sizeZ=-0.6*R
    lineWidth=stroke*1.5
    x=8*R/2+a
    y=-R*3.5
    z=-R*1.65+R/2.5
    text="+"
    lineColor=RED
    fillColor=RED
    font=Arial,BOLD,32
    x=8*R/2+a
    y=-R*3.5
    z=-R*1.65+R/2.5
    sizeX=-R
    sizeY=0
    sizeZ=0
    lineWidth=stroke*1.5
    visible=false
    x=8*R/2+a
    y=0
    z=-R*1.65
    sizeX=0
    sizeY=-R*4.5
    sizeZ=0
    lineWidth=stroke*1.5
    x=8*R/2+a
    y=-R*4.5
    z=-R*1.65
    sizeX=0
    sizeY=0
    sizeZ=R/2.5
    lineWidth=stroke*1.5
    x=8*R/2+a
    y=-R*4.5
    z=-R*1.65+R/2.5
    sizeX=-R
    sizeY=0
    sizeZ=0
    lineWidth=stroke*1.5
    x=8*R/2+a
    y=-R*4.5
    z=-R*1.65+R/2.5
    text="-"
    font=Arial,BOLD,32
    x=8*R/4+a
    y=0
    z=R*1.65
    sizeX=0
    sizeY=R*3
    sizeZ=0
    lineWidth=stroke*1.5
    x=8*R/4+a
    y=R*3
    z=R*1.65
    sizeX=0
    sizeY=0
    sizeZ=-R*1.65*2
    lineWidth=stroke*1.5
    x=8*R/4+a
    y=R*5
    z=-R*1.65
    sizeX=R*2
    sizeY=0
    sizeZ=0
    lineWidth=stroke*1.5
    x=3*R+a
    y=R*5
    z=-R*2.8
    text="R"
    font=Arial,BOLD,32
    x=3*R+a
    y=R*5
    z=-R*1.65
    sizeX=R/2
    sizeY=R/2
    sizeZ=R
    transformation="y:90d"
    fillColor=GRAY
    x=8*R/2+a
    y=0
    z=-R*1.65
    sizeX=0
    sizeY=R*5
    sizeZ=0
    visible=true
    lineWidth=stroke*1.5
    x=8*R/4+a
    y=R*5
    z=-R*1.65
    sizeX=0
    sizeY=-R*2
    sizeZ=0
    lineWidth=stroke*1.5
    x=8*R/4+a
    y=R*5
    z=-R*1.65
    sizeX=0
    sizeY=0
    sizeZ=R/2
    lineWidth=stroke*1.5
    x=8*R/2+a
    y=R*5
    z=-R*1.65
    sizeX=0
    sizeY=0
    sizeZ=R/2
    lineWidth=stroke*1.5
    x=8*R/4+a
    y=R*5
    z=-R*1.15
    sizeX=0
    sizeY=-R/2
    sizeZ=0
    lineWidth=stroke*1.5
    x=8*R/2+a
    y=R*5
    z=-R*1.15
    sizeX=0
    sizeY=-R/2
    sizeZ=0
    lineWidth=stroke*1.5
    numberOfElements=4
    x=8*R+a
    y=-R*2
    z=z7s
    sizeX=size
    sizeY=size
    sizeZ=size
    visible=false
    lineColor=clr
    fillColor=clr2
    numberOfElements=4
    x=8*R+a
    y=y8s
    z=R*1.15
    sizeX=size
    sizeY=size
    sizeZ=size
    visible=false
    lineColor=clr
    fillColor=clr2
    numberOfElements=4
    x=8*R+a
    y=y9s
    z=-R*1.15
    sizeX=size
    sizeY=size
    sizeZ=size
    visible=false
    lineColor=clr
    fillColor=clr2
    numberOfElements=n
    x=x1s
    y=y1s
    z=z1s
    sizeX=size
    sizeY=size
    sizeZ=size
    visible=s1
    lineColor=clr
    fillColor=clr2
    numberOfElements=n
    x=x2
    y=y2s
    z=z2s
    visible=false
    text=%s_m2%
    numberOfElements=n
    x=x2
    y=y2s
    z=z2s
    sizeX=size
    sizeY=size
    sizeZ=size
    lineColor=clr
    fillColor=clr2
    numberOfElements=n
    x=x3s
    y=y3s
    z=z3s
    sizeX=size
    sizeY=size
    sizeZ=size
    lineColor=clr
    fillColor=clr2
    numberOfElements=n
    x=x4
    y=y4s
    z=z4s
    sizeX=size
    sizeY=size
    sizeZ=size
    lineColor=clr
    fillColor=clr2
    numberOfElements=n5
    x=x5s
    y=R*sc
    z=R*cs
    visible=false
    text=%s_m5%
    numberOfElements=n5
    x=x5s
    y=R*sc
    z=R*cs
    sizeX=size
    sizeY=size
    sizeZ=size
    lineColor=clr
    fillColor=clr2
    numberOfElements=n6
    x=x6s
    y=-R*sc
    z=-R*cs
    sizeX=size
    sizeY=size
    sizeZ=size
    lineColor=clr
    fillColor=clr2
    numberOfElements=n
    x=x2
    y=y2s
    z=z2s
    sizeX=0
    sizeY=omegas*lengthz*Math.sin(cta+pi/2)/10
    sizeZ=omegas*lengthz*Math.cos(cta+pi/2)/10
    visible=showF
    lineColor=0,192,0
    fillColor=0,192,0
    numberOfElements=n
    x=x4
    y=y4s
    z=z4s
    sizeX=0
    sizeY=omegas*lengthz*Math.sin(cta+3*pi/2)/10
    sizeZ=omegas*lengthz*Math.cos(cta+3*pi/2)/10
    visible=showF
    lineColor=0,192,0
    fillColor=0,192,0
    numberOfElements=4
    x=x6s
    y=-R*sc
    z=-R*cs
    sizeX=0
    sizeY=-a2*sign2
    sizeZ=0
    visible=false
    lineColor=DARKGRAY
    fillColor=DARKGRAY
    numberOfElements=4
    x=x5s
    y=R*sc
    z=R*cs
    sizeX=0
    sizeY=a2*sign2
    sizeZ=0
    visible=false
    lineColor=DARKGRAY
    fillColor=DARKGRAY
    numberOfElements=n
    x=x1
    y=y1s
    z=z1s
    sizeX=0
    sizeY=vy1*sign*sc
    sizeZ=vy1*sign*cs
    visible=false
    lineColor=MAGENTA
    fillColor=MAGENTA
    numberOfElements=n
    x=x2
    y=y2s
    z=z2s
    sizeX=current/25*sign
    sizeY=0
    sizeZ=0
    visible=showV
    lineColor=MAGENTA
    fillColor=MAGENTA
    numberOfElements=n
    x=x3
    y=y3s
    z=z3s
    sizeX=0
    sizeY=vy3*sign*sc
    sizeZ=vy3*sign*cs
    visible=false
    lineColor=MAGENTA
    fillColor=MAGENTA
    numberOfElements=n
    x=x4
    y=y4s
    z=z4s
    sizeX=-current/25*sign
    sizeY=0
    sizeZ=0
    visible=showV
    lineColor=MAGENTA
    fillColor=MAGENTA
    minimumX=xmin
    maximumX=xmax
    minimumY=ymin
    maximumY=ymax
    minimumZ=BZ0
    maximumZ=0
    xcomponent=bfx
    ycomponent=bfy
    zcomponent=bfz
    length=xmax*B
    visible=showBF
    mincolor=ORANGE
    maxcolor=ORANGE
    z=zmax*1.5
    text=%l_current%
    lineWidth=stroke
    x=0
    y=0
    z=(zmin-zmax)/2
    sizeX=xmax-xmin
    sizeY=ymax-ymin
    sizeZ=(zmax-zmin)/8
    visible=B>0
    lineColor=GRAY
    fillColor=255,0,0,100
    resolution="1,1,1"
    x=0
    y=0
    z=(zmin-zmax)/1.8
    visible=B>0
    text="N"
    lineColor=BLACK
    fillColor=BLACK
    font=Monospaced,BOLD,30
    x=0
    y=0
    z=-(zmin-zmax)/2
    sizeX=xmax-xmin
    sizeY=ymax-ymin
    sizeZ=(zmax-zmin)/8
    visible=B>0
    lineColor=GRAY
    fillColor=0,0,255,100
    resolution="1,1,1"
    x=0
    y=0
    z=-(zmin-zmax)/1.8
    visible=B>0
    text="S"
    lineColor=BLACK
    fillColor=BLACK
    font=Monospaced,BOLD,30
    visible=B<0
    x=0
    y=0
    z=-(zmin-zmax)/2
    sizeX=xmax-xmin
    sizeY=ymax-ymin
    sizeZ=(zmax-zmin)/8
    lineColor=GRAY
    fillColor=255,0,0,100
    resolution="1,1,1"
    x=0
    y=0
    z=-(zmin-zmax)/1.8
    text="N"
    lineColor=BLACK
    fillColor=BLACK
    font=Monospaced,BOLD,30
    x=0
    y=0
    z=(zmin-zmax)/2
    sizeX=xmax-xmin
    sizeY=ymax-ymin
    sizeZ=(zmax-zmin)/8
    lineColor=GRAY
    fillColor=0,0,255,100
    resolution="1,1,1"
    x=0
    y=0
    z=(zmin-zmax)/1.8
    text="S"
    lineColor=BLACK
    fillColor=BLACK
    font=Monospaced,BOLD,30
    points=50
    min=0
    max=R
    variable="x"
    functionx="a+5*R+x"
    functiony="4*R"
    functionz="E0*cos(2*pi*x/(R))"
    x=a+5*R+c2*R
    y=4*R
    z=E0*Math.cos(c2*pi2)
    sizeX=size2
    sizeY=size2
    sizeZ=size2
    x=6.5*R
    y=-4*R
    z=0
    sizeX=0.1
    sizeY=0.1
    sizeZ=0.1
    visible=false
    x=0
    y=0
    z=0
    sizeX=5
    sizeY=5
    sizeZ=4
    transformation="y:90d"
    closedTop=false
    fillColor=GRAY
    drawingLines=false
    drawingFill=true
    x=1.5
    y=0
    z=0
    sizeX=4.2
    sizeY=4.2
    transformation="y:90d"
    lineColor=LIGHTGRAY
    fillColor=YELLOW
    lineWidth=3
    x=1.8
    y=0
    z=-.6
    sizeX=0
    sizeY=meterDisplay/100
    sizeZ=Math.sqrt(4-meterDisplay*meterDisplay/(100*100))
    lineColor=BLACK
    fillColor=BLACK
    lineWidth=2
    points=9
    min=-1.0
    max=1.0
    variable="s"
    functionx="1.8"
    functiony="1.8*Math.sin(s)"
    functionz=".8+Math.cos(s)"
    javaSyntax=true
    x=1.8
    y=0
    z=1.8
    text="0 $\\micro$ A"
    x=1.8
    y=-1.8
    z=-1.8/2
    text=%s_m1%
    x=1.8
    y=0
    z=1.8
    sizeX=0
    sizeY=0
    sizeZ=-0.3
    lineColor=DARKGRAY
    x=7*R
    y=4*R
    z=0
    sizeX=0.05
    sizeY=0.1
    sizeZ=0.1
    transformation="z:90d"
    x=0
    y=0
    z=0
    sizeX=5
    sizeY=5
    sizeZ=4
    transformation="y:90d"
    closedTop=false
    fillColor=GRAY
    drawingLines=false
    drawingFill=true
    x=1.5
    y=0
    z=0
    sizeX=4.2
    sizeY=4.2
    transformation="y:90d"
    lineColor=LIGHTGRAY
    fillColor=255,255,0,100
    lineWidth=3
    x=1.8
    y=0
    z=-.6
    sizeX=0
    sizeY=meterDisplay/100
    sizeZ=Math.sqrt(4-meterDisplay*meterDisplay/(100*100))
    lineColor=BLACK
    fillColor=BLACK
    lineWidth=2
    points=9
    min=-1.0
    max=1.0
    variable="s"
    functionx="1.8"
    functiony="1.8*Math.sin(s)"
    functionz=".8+Math.cos(s)"
    javaSyntax=true
    x=1.8
    y=0
    z=1.8
    text="0 $\\micro$ A"
    x=1.8
    y=-1.8
    z=-1.8/2
    text=%s_m1%
    x=1.8
    y=0
    z=1.8
    sizeX=0
    sizeY=0
    sizeZ=-0.3
    lineColor=DARKGRAY
    x=2.4
    y=1.2
    z=-2
    text="+"
    lineColor=RED
    fillColor=RED
    font=Arial,BOLD,32
    x=2.4
    y=-1.5
    z=-2
    text="-"
    font=Arial,BOLD,32
    position=south
    layout=VBOX
    layout=HBOX
    position=center
    layout=GRID:1,0,0,0
    variable=ctadegree0360
    value=0
    minimum=0
    maximum=360
    format="$\\theta$ = 000 deg"
    enabled=false
    background=0,192,255
    tooltip="angular displacement of armature"
    variable=omegadegree
    minimum=-360
    maximum=360
    format="$\\omega$ = 000 deg/s"
    enabled=false
    background=200,0,200,255
    tooltip="angular velocity of armature"
    variable=t
    minimum=0
    maximum=100
    format="t = 0.0 s"
    enabled=false
    tooltip="time t"
    variable=flux
    minimum=-100
    maximum=100
    format="$\\Phi$ = 0.0 Wb"
    enabled=false
    background=GRAY
    tooltip="magnetic flux in Weber (Wb)"
    variable=emf
    minimum=-100
    maximum=100
    format="$\\epsilon$ = 0.0 $\\micro$ V"
    enabled=false
    background=PINK
    tooltip="induced electromotive force emf in $\\micro$V"
    position=north
    layout=HBOX
    background=YELLOW
    position=center
    variable=current
    value=0
    minimum=-100
    maximum=100
    format="i=0.00 $\\micro$ A"
    enabled=false
    dragaction=setparam ()
    background=YELLOW
    tooltip="induced current in the circuit produced by the electromagnetic induction in the coilsied by the "
    layout=HBOX
    variable=showF
    mnemonic="v"
    background=0,192,0
    tooltip="To visualize motion v"
    variable=omegas*lengthz
    minimum=-2
    maximum=2
    format="v = 0.0 m/s"
    enabled=false
    background=0,192,0
    tooltip="To visualize motion v"
    layout=HBOX
    layout=HBOX
    variable=showBF
    mnemonic="b"
    background=ORANGE
    tooltip="To visualize the external magnetic field from the NS magnets in the z direction"
    position=center
    variable=B
    minimum=-2.0
    maximum=2.0
    format="Bz=0.00 $\\micro$ T"
    dragaction=_initialize(); setparam ();
    background=ORANGE
    tooltip="External magnetic field from the NS magnets in the z direction"
    variable=lengthx
    value=1.4999699999999998
    minimum=0
    maximum=2*a
    format="Lengthx=0.00 m"
    dragaction=_initialize(); setparam ();
    background=GREEN
    tooltip="length of coil in x direction"
    variable=lengthz
    minimum=R*2
    maximum=2*a
    format="Lengthz=0.00 m"
    dragaction=_initialize(); setparam ();
    background=GREEN
    tooltip="length of coil in z direction"
    variable=N
    minimum=1
    maximum=7
    format="N = 0"
    ticks=7
    closest=true
    dragaction=_initialize(); setparam ();
    background=GREEN
    tooltip="number of turns of coils in the loop"
    variable=Resistance
    value=2
    minimum=1
    maximum=7
    format="R = 0 $\\Omega$"
    ticks=7
    closest=true
    dragaction=_initialize(); setparam ();
    background=LIGHTGRAY
    tooltip="resistance conneted to the loop generating induced e.m.f"
    position=south
    layout=HBOX
    layout=HBOX
    position=center
    text=" $\\theta$(t) = "
    background=CYAN
    tooltip="angle of loop as a function of time"
    position=east
    variable="6.2831*t"
    independent="t"
    javaSyntax=false
    action=t0=t=0; current=getCurrent(); _view.clearData();
    columns=2
    variable=showGraph
    selected=true
    text="show graph"
    variable=Is
    selected=true
    text=%l_current%
    mnemonic="c"
    action=if(Is){ sign=1.; sign3 =-sign3; // added by lookang for electron vy1 = vy1; // for current vy3 = vy3; vx2 = vx2; vx4 = vx4; //vz7 = vz7; v0 = v0; clr=yellow; clr2=yellow; clabel="+"; l_current="Current flow"; }else{ sign=-1.; sign3=sign3; // added by lookang vy1 = -vy1; // for current vy3 = -vy3; vx2 = -vx2; vx4 = -vx4; v0 = -v0; //vz7= -vz7; clr=green; clr2=green2; clabel="-"; l_current="Elecron flow"; }
    background=clr
    tooltip="current or electron"
    variable=showV
    text="velocity"
    mnemonic="v"
    background=MAGENTA
    tooltip="to visualize the velocity of the charged particles"
    variable=label
    selected=true
    text="labels?"
    mnemonic="l"
    background=WHITE
    tooltip="to see text labels for ease of verbalization"
    position=east
    layout=HBOX
    variable=_isPaused
    tooltip="paly / pause simulation"
    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/stepforward.gif"
    action=_step();
    image=/org/opensourcephysics/resources/controls/images/reset.gif
    action=_reset()
    tooltip="reset simulation"
    position=east
    layout=border
    position=center
    variable=zflux
    value=0
    minimum=-1
    maximum=1.0
    orientation=VERTICAL
    background=GRAY
    tooltip="z axis slider for the flux visualization"
    layout=VBOX
    visible=showGraph
    onClosing=showGraph=false;
    location="0,384"
    size="600,333"
    position=center
    autoscaleX=true
    autoscaleY=true
    minimumX=t0
    minimumY=-25
    maximumY=25
    title="Flux and Current vs Time"
    titleX="time(s)"
    titleY="current($\mu$A) & flux (A.U.)"
    visible=vstime
    interiorBackground=200,220,208
    inputX=t
    inputY=flux
    visible=fluxgraph
    norepeat=true
    lineColor=GRAY
    lineWidth=2
    xLabel="time"
    yLabel="flux"
    inputX=t
    inputY=current
    visible=currentgraph
    norepeat=true
    lineColor=YELLOW
    lineWidth=2
    yLabel="current"
    inputX=t
    inputY=emf
    visible=emfgraph
    lineColor=RED
    lineWidth=2
    yLabel="emf"
    autoscaleY=true
    maximumX=360
    minimumY=-25
    maximumY=25
    title="Flux and Current vs Angle $\theta$"
    titleX="Angle $\theta$ (deg)"
    titleY="current($\mu$A) & flux (A.U.)"
    visible=vsangle
    interiorBackground=200,220,208
    inputX=cta*180/pi
    inputY=flux
    visible=fluxgraph
    lineColor=GRAY
    lineWidth=2
    xLabel="angle"
    yLabel="flux"
    inputX=cta*180/pi
    inputY=current
    visible=currentgraph
    lineColor=YELLOW
    lineWidth=2
    yLabel="current"
    y=20
    pixelSize=true
    measured=false
    enabledPosition=true
    text=" -Current"
    font=Monospaced,BOLD,14
    elementposition=WEST
    lineColor=YELLOW
    x=0
    y=10
    pixelSize=true
    measured=false
    enabledPosition=true
    text=" -flux"
    font=Monospaced,BOLD,14
    elementposition=WEST
    lineColor=GRAY
    x=0
    y=-20
    pixelSize=true
    measured=false
    enabledPosition=true
    text=" -emf"
    font=Monospaced,BOLD,14
    elementposition=WEST
    lineColor=RED
    inputX=cta*180/pi
    inputY=emf
    visible=emfgraph
    lineColor=RED
    lineWidth=2
    yLabel="emf"
    position=south
    layout=FLOW:center,0,0
    borderType=LOWERED_ETCHED
    image="/org/opensourcephysics/resources/controls/images/erase.gif"
    action=t0=t; _view.resetTraces()
    tooltip="Clears the data."
    position=center
    image="/org/opensourcephysics/resources/controls/images/wrench_monkey.gif"
    action=_tools.showDataTool(_view.currentTrail,_view.fluxTrail);
    tooltip="Opens the data tool."
    layout=HBOX
    variable=_isPaused
    tooltip="paly / pause simulation"
    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/stepforward.gif"
    action=_step();
    image=/org/opensourcephysics/resources/controls/images/reset.gif
    action=_reset()
    tooltip="reset simulation"
    variable=vstime
    text="vs time"
    variable=vsangle
    selected=true
    text="vs angle"
    variable=currentgraph
    text="current"
    background=YELLOW
    variable=fluxgraph
    text="flux"
    background=GRAY
    variable=emfgraph
    selected=true
    text="emf"
    background=RED