Tuesday, April 12, 2011

Multi Dipole Magnetic Simulation

Introduction

Multi Dipole Simulation of two bar magnets one attached to a wheel the other to a fixed point external to the wheel. Each magnet consists of 5 dipoles at 1cm distance apart for a total of 5cm length per magnet. The magnets are at 0 degrees and 180 degrees respectively.
The strength of the magnets are 0.01 Amperes per meter squared(A/m^2).

Multi Dipole simulation omega=180 degrees phi=0
Disk Mass 1.2kg 25cm in diameter
Bar Magnets Length 5cm
Dipole Length 1cm
Added Friction from normal of force


Program Code



N=5000;
Kfriction=0.01;
m=0.01;
M=0.01;
R=0.25;

Uo=4e-7*%pi;
L=0.01;
I=2;
J=2;
d=(I+J)*L+0.05;
phi=0.0*%pi;
omega=1.0*%pi;
rot_v=0.0;
dt=0.1;
mass=1.2;
theta=1.95*%pi;
for n=1:1:N
    m1=[m*cos(theta+phi) m*sin(theta+phi)];
    m2=[M*cos(omega) M*sin(omega)];
    Fx=0.0;
    Fy=0.0;
    
    for i=-I:1:I
        for j=-J:1:J
            p1x=R*cos(theta)+j*L*cos(theta+phi);
            p1y=R*sin(theta)+j*L*sin(theta+phi);
            p2x=R+d-L*i*cos(omega);
            p2y=L*i*sin(omega);
            
            r=[p2x-p1x p2y-p1y];
            v=(3*Uo/(4*%pi*sqrt(sum(r^2))^5)*(sum(m1.*r)*m2+sum(m2.*r)*m1+sum(m1.*m2)*r-5.0*sum(m1.*r)*sum(m2.*r)/sum(r^2)*r));
            Fx=Fx+v(1);
            Fy=Fy+v(2);
           
        end
    end
    rproj=[-sin(theta) cos(theta)];
    rnorm=[cos(theta) sin(theta) ];
    Ffr=abs(Kfriction*sum([Fx Fy].*rnorm));
    Frot=sum([Fx Fy].*rproj);
    Fsign=Frot/abs(Frot);
    F=Frot-Fsign*Ffr;
    rot_v=rot_v+F*dt/(R*mass);
    theta=theta+rot_v*dt;
    th(n)=theta*180.0/%pi;
    
end


Conculsion
 Wheel is Oscillating back and forth

No comments:

Post a Comment