import scipy
from numpy import *
#Variable Declaration
m=2 #mass in kg
q=3 #charge in C
v=array([4,0,3]) #initial velocity in m/s
E=array([12,10,0]) #electric field in V/m
t=1 #time in sec
#Calculations
a=q*E/m #acceleration in m/s^2 after 1 sec
u=array([18*t+4,15*t,3]) #velocity in m/s after 1 sec
modofu=scipy.sqrt(dot(u,u))
KE=0.5*m*(modofu)**2 #kinetic energy in J at t=1 sec
s=array([9*t**2+4*t+1,7.5*t**2-2,3*t]) #position after 1 sec in m
#Results
print 'At time t=1 sec,'
print' The acceleration of the particle =',a,'m/s^2'
print 'Its velocity =',u,'m/s'
print 'Its kinetic energy =',KE,'J'
print 'Its position =',s,'m'
import scipy
#Variable Declaration
ar=array([1,0,0]) #Unit vector along radial direction
ath=array([0,1,0]) #Unit vector along theta direction
aph=array([0,0,1]) #Unit vector along phi direction
x=4
y=-3
z=10
muo=4*scipy.pi*10**-7 #permeability of free space
m1=5 #magnetic moment in A/m^2
#Calculations
r=scipy.sqrt(x**2+y**2+z**2)
p=scipy.sqrt(x**2+y**2)
sinphi=y/p
cosphi=x/p
sintheta=1/scipy.sqrt(5)
costheta=2/scipy.sqrt(5)
B1=muo*m1*(2*costheta*ar+sintheta*ath)/(4*scipy.pi*r**3)
m2=3*(sintheta*sinphi*ar+costheta*sinphi*ath+cosphi*aph)
T2=cross(m2,B1)*10**9
T2x=round(dot(T2,ar),3)
T2y=round(dot(T2,ath),3)
T2z=round(dot(T2,aph),3)
T2r=array([T2x,T2y,T2z]) #torque in nNm
#Result
print 'Torque T2 =',T2r,'nNm'
import scipy
#Variable Declaration
muo=4*scipy.pi*10**-7 #permeability of free space
mur=2 #relative permeability
ax=array([1,0,0]) #Unit vector along x direction
ay=array([0,1,0]) #Unit vector along y direction
az=array([0,0,1]) #Unit vector along z direction
#Calculations
J=(-5-10)*10**-6/(4*scipy.pi*10**-7*2.5) #in kA/m^2
Jb=1.5*J #in kA/m^2
MbyB=(1.5)*10**4/(4*scipy.pi*2.5)
Mv=MbyB*10*10**-3*ax+MbyB*5*10**-3*ay
Kb=cross(az,Mv)
#Results
print 'J =',round(J,3),'kA/m^2'
print 'Jb =',round(Jb,3),'kA/m^2'
print 'M =(',round(dot(Mv,ax),3),'y,',round(dot(Mv,ay),3),'x, 0) kA/m'
print 'Kb =(',round(dot(Kb,ax),3),'x,',round(dot(Kb,ay),3),'y, 0) kA/m'
import scipy
from numpy import *
#Variable Declaration
ax=array([1,0,0]) #Unit vector along x direction
ay=array([0,1,0]) #Unit vector along y direction
az=array([0,0,1]) #Unit vector along z direction
H1=array([-2,6,4]) #in A/m
mu0=4*scipy.pi*10**-7 #permeability of free space
mur1=5 #relative permeabililty in region 1
mur2=2 #relative permeabililty in region 2
an=array([-1,1,0])/scipy.sqrt(2)
#Calculatios
mu1=mu0*mur1
mu2=mu0*mur2
M1=(mur1-1)*H1 # magnetisation in region 1 in A/m
B1=mu1*H1*10**6 # field in micro Wb/m^2
B1x=round(dot(B1,ax),2) # x component of B1
B1y=round(dot(B1,ay),1) # y component of B1
B1z=round(dot(B1,az),2) # z component of B1
B1r=array([B1x,B1y,B1z]) # B1 rounded to 2 decimal places
H1n=dot(H1,an)*an
H1t=H1-H1n
H2t=H1t # using transverse boundary condition
H2n=(mu1/mu2)*H1n # using normal boundary condition
H2=H2t+H2n # in A/m
B2=mu2*H2*10**6 # field in micro Wb/m^2
B2x=round(dot(B2,ax),2) # x component of B2
B2y=round(dot(B2,ay),2) # y component of B2
B2z=round(dot(B2,az),2) # z component of B2
B2r=array([B2x,B2y,B2z]) # B2 rounded to 2 decimal places
#Results
print 'M1= ',M1,'A/m'
print 'B1= ',B1r,'micro Wb/m^2'
print 'H2= ',H2,'A/m'
print 'B2= ',B2r,'micro Wb/m^2'
import scipy
from numpy import *
#Variable declaration
p=10*10**-2 #in m
a=1*10**-2 #in m
Ur=1000 #relative permeability
Uo=4*scipy.pi*10**-7 #permeability of free space
n=200 #number of turns
phi=0.5*10**-3 #flux in the core in Wb
U=Uo*Ur #permeability of steel core
#Calculation
I=phi*2*scipy.pi*p/(U*n*scipy.pi*a*a) #current in A
#Result
print 'The current that will produce a flux of 0.5 mWb =',round(I,3),'A'
import scipy
from numpy import *
#Variable Declaration
Uo=4*scipy.pi*10**-7 #permeability of free space
Ur=50 #relative permeability of coil
l1=30*10**-2
s=10*10**-4
l3=9*10**-2
la=1*10**-2
B=1.5 #flux density in Wb/m^2
N=400 #number of turns
#Calculations
R1=l1/(Uo*Ur*s)
R2=R1
R3=l3/(Uo*Ur*s)
Ra=la/(Uo*s)
R=R1*R2/(R1+R2)
Req=R3+Ra+R
I=B*s*Req/N #current in A
#Result
print 'The current required =',round(I,3),'A'
import scipy
from numpy import *
#Variable Declaration
m=400 #mass in kg
g=9.8 #acceleration due to gravity in m/s^2
Ur=3000 #relative permeability of the iron yoke
Uo=4*scipy.pi*10**-7 #permeability of free space
S=40*10**-4 #cross sectional area of iron yoke in m^2
la=1*10**-4 #air gaps in m
li=50*10**-2 #mean length of yoke in m
I=1 #excitation current in A
#Calculations
B=scipy.sqrt(m*g*Uo/S) #field in Wb/m^2
Ra=2*la/(Uo*S)
Ri=li/(Uo*Ur*S)
N=(Ra+Ri)/(Ra*Uo)*B*la #number of turns
#Result
print 'The nmber of turns in the coil when the excitation current is 1 A ='
print round(N,0)