"That their main business was not put into the mind knowledge which was not there before, but to turn the mind's eye towards light so that it might see for itself."
...Plato's advice to educators(429-347BC)

Reply #2 on: May 14, 2010, 11:17:57 pm » posted from:Taipei,T\'ai-pei,Taiwan

I am sorry that I was too busy in the last two weeks so that I was not able to help you with the coding. Finally, I tried to modify from my previous version and the result (for two magnets) is the following :

I have an abstract accepted WEE Loo Kang Physics Educators as Designers of Simulation Using Easy Java Simulation Simulated Learning/ Using Simulations to Teach Physics Contributed FI05 Salon Ballroom II 7/20/2010 2:30 PM 2:40 PM http://sgeducation.blogspot.com/2010/02/american-association-of-physics.html

« Last Edit: May 16, 2010, 10:03:01 am by lookang »

Reply #7 on: May 16, 2010, 10:38:16 pm » posted from:Singapore,,Singapore

is it? i didn't upload the jar yet, only the attachment cos it is still unfinished. i am still working on it.

but i just reuploaded 02 version on the first post in case you are looking at that one.

i managed to work 2 bar magnets now,

i will try to have no magnet( not working) , one magnet(seems to work) , 2 bar magnet (working ).

i am working on the magnet field only, the compass is not correct yet because i wanted to show the magnet inside as a uniform magnetic field of 225T which the original wolfgang and paco version shows as a large uniform magnetic field due to short distance to any of the dipoles.

will fix the compass after i figure out the field part. thanks!

« Last Edit: June 08, 2010, 09:19:25 am by lookang »

Reply #11 on: May 18, 2010, 10:56:31 pm » posted from:Taipei,T\'ai-pei,Taiwan

The following functions has been modified: public double[] getB(double xm,double ym) : to compute magnetic field at (xm,ym) related to (xMagnet,yMagnet)

in public void computeField () : bf1=getB((x-xMagnet)*cs+(y-yMagnet)*sc,-(x-xMagnet)*sc+(y-yMagnet)*cs);//FKH bf2=getB((x-xMagnet2)*cs2+(y-yMagnet2)*sc2,-(x-xMagnet2)*sc2+(y-yMagnet2)*cs2);//FKH // the above two lines calculate field from two magnets xField[ i ][j] = lcst*(bf1[0]*cs-bf1[1]*sc)+rcst*(bf2[0]*cs2-bf2[1]*sc2);//FKH yField[ i ][j] = lcst*(bf1[0]*sc+bf1[1]*cs)+rcst*(bf2[0]*sc2+bf2[1]*cs2);//FKH //calculate the sum of magnet field from two magnets magField[ i ][j]=Math.sqrt(xField[ i ][j]*xField[ i ][j]+yField[ i ][j]*yField[ i ][j]);

« Last Edit: June 08, 2010, 09:04:27 am by lookang »

Reply #12 on: June 08, 2010, 08:47:17 am » posted from:Singapore,,Singapore

Hi prof Hwang! i been thinking and looking at the codes for the 2 bar magnet java applet. I am unable to remix applet faster now, due to my baby girl 3 month old! need to pay more attention to family needs. BTW U can join facebook to see more photos of the baby! LOL http://www.facebook.com/lookang

i managed to get your codes to work in my own remix java applet at the top post.

i am stuck figuring out a clever way to make the getB values to saturate to the direction of the orientation of the bar magnet for both magnets. I have a version 04 that works for one magnet but not both .

This is your code! public double[] getB(double xm,double ym) { double[] b=new double[2]; for(int i=0; i < nd; i + +) { double dx=xm-dipoles[ i ][0];//-xm;////(xMagnet*cs+yMagnet*sc);//FKH double dy=ym-dipoles[ i ][1];//-ym;//(-xMagnet*sc+yMagnet*cs);//FKH double r2=dx*dx+dy*dy; double r=Math.sqrt(r2); double r3=r2*r; double cos=dx/r; double sin=dy/r; b[0]+=m*(3*cos*cos-1)/r3; //x component b[1]+=m*3*sin*cos/r3; //y component if(r2==0) { b[0]=b[1]=0; } } // b[2] = Math.sqrt(b[0]*b[0]+b[1]*b[1]); // magnitude // b[3] = Math.atan2(b[1],b[0]); // angle return b; }

This is my code changes (latest version which i still couldn't get it to work the way inside the magnet) //inside any magnet if (xCompass<(xm+Magnetsizex/2) && xCompass>(xm-(Magnetsizex/2)) && yCompass<(ym+Magnetsizey/2) && yCompass>(ym-Magnetsizey/2)) { test = true; b[0] = (225)*vectorfieldmaxopposite/100; // saturate to direction of magnet Bx'=255 if vectorfieldmaxopposite=1 b[1] = (0)*vectorfieldmaxopposite/100; // saturate to direction of magnet By' =0

}

else // original code for field { test=false; b[0]+=m*(3*cos*cos-1)/r3*vectorfieldmaxopposite/100; ; //x component vectorfieldmaxopposite/100 is a factor i made b[1]+=m*3*sin*cos/r3*vectorfieldmaxopposite/100; ; //y component }

it is not working the way that i conceptualize it would work. chance to look at it and make the codes work? i think your teaching method is great, u do it on your applet and i study it. can help?

Reply #13 on: June 08, 2010, 03:53:31 pm » posted from:Taipei,T\'ai-pei,Taiwan

Are you trying to add a visual effect to the applet, or you really need a very accurate calculation for the magnetic field insode the magnet?

The magnetic field of the above applet were calculated with finite number of current loop. The magnetic field strength is inverse proportional to distance squrare. So the error dur to field calculation become too large. May be that is the reason you try to "saturate: it.

I would suggest you just calculate the field at one of the end point as the magnetic field inside the magnet. i.e. assume the field is uniform inside the magnet (the same vector as the field at the center of end point).

The magnetic field of the above applet were calculated with finite number of current loop. The magnetic field strength is inverse proportional to distance square. So the error dur to field calculation become too large. May be that is the reason you try to "saturate: it.

Yes! i don't believe B field inside the bar magnet can be so big and direction random, it should an uniform B field in my understanding.

I would suggest you just calculate the field at one of the end point as the magnetic field inside the magnet. i.e. assume the field is uniform inside the magnet (the same vector as the field at the center of end point).

i don't quite get what is mentioned here. but i will try again soon

« Last Edit: June 08, 2010, 09:09:17 pm by lookang »

Reply #15 on: June 08, 2010, 09:56:18 pm » posted from:Singapore,,Singapore

i did it!!! with your guidance for the past 3 years+, i managed to do this just now! LOL

// inside both magnet1&2 if ((xCompass<(xMagnet+Magnetsizex/2) && xCompass>(xMagnet-(Magnetsizex/2)) && yCompass<(yMagnet+Magnetsizey/2) && yCompass>(yMagnet-Magnetsizey/2))&&(xCompass<(xMagnet2+Magnetsizex2/2) && xCompass>(xMagnet2-(Magnetsizex2/2)) && yCompass<(yMagnet2+Magnetsizey2/2) && yCompass>(yMagnet2-Magnetsizey2/2))) { //test = true; // create uniform field bxField = (lcst*(225*cs-0*sc)+rcst*(225*cs2-0*sc2))*vectorfieldmaxopposite/100; // saturate to direction of magnet Bx'=0 for both magnets byField = (lcst*(225*sc+0*cs)+rcst*(225*sc2+0*cs2))*vectorfieldmaxopposite/100;//saturate to direction of magnet By' =0 for both magnets

} //inside magnet1 else if (xCompass<(xMagnet+Magnetsizex/2) && xCompass>(xMagnet-(Magnetsizex/2)) && yCompass<(yMagnet+Magnetsizey/2) && yCompass>(yMagnet-Magnetsizey/2)) { //test = false; bxField = (lcst*(225*cs-0*sc)+rcst*(bf2[0]*cs2-bf2[1]*sc2))*vectorfieldmaxopposite/100;// uniform B1x=225 but B2x still calculate normally byField = (lcst*(225*sc+0*cs)+rcst*(bf2[0]*sc2+bf2[1]*cs2))*vectorfieldmaxopposite/100;//uniform B1y=0 but B2y still calculate normally }

"That their main business was not put into the mind knowledge which was not there before, but to turn the mind's eye towards light so that it might see for itself."
...Plato's advice to educators(429-347BC)