In this unit we are going to do some problems in electricity and magnetism.  We will do a few problems in calculating static fields, and then   a couple of  circuits.  

As usual, units are very important and so we need to setup the unit system first.  

I prefer to use, Volts, Coulombs, Meters, and Seconds, and Tesla
Electric field is in units of Volts/Meter or Newton/Coulomb.  Current is Amperes = Coulombs/sec.  

Basic understanding of  circuits is very important to understand detectors for neutrinos.  We will explain.

Two charges q and -q are at locations (0, +1/2) and (0, -1/2)   meters.  Calculate the electric field.  
First we calculate the potential and then take its gradient.

Setup the constants. mu0 is the Magnetic Permeability and kcoulomb is Coulombs constant.  kcoulomb = 1/(4 Pi epsilon)  

Look at the units.  mu0 gives you magnetic field after dividing by current.  
kcoulomb gives you force when multiplied by charge^2 and divided by distance^2.

mu0 = QuantityMagnitude[UnitConvert[Quantity[1,"MagneticConstant"],"Tesla Meter/Ampere"]]

kcoulomb = N[QuantityMagnitude[UnitConvert[ Quantity[1,"CoulombsConstant"],"Newton * meter^2/Coulomb^2"]]]

Let’s check that these constants are correctly defined.  1/Sqrt[epsilon * mu0]  should be the speed of light.  This should be in meters/second.

ϵ0  = 1/(4 Pi * kcoulomb); 
clight =  1/Sqrt[mu0*ϵ0]

Let’s do a problem of the electric field between two charges.

q1 = 2*10^-6 ;  (* units are Coulomb *)  
q2 = -10^-6;  
p1 = {0,+1/2,0};   (* positions  make it 3 dimensional*)  
p2 = {0,-1/2,0}; (* units are in meters *)  
dipole [x_,y_,z_] :=  kcoulomb *(q1/Sqrt[(x-p1[[1]])^2+(y-p1[[2]])^2+(z-p1[[3]])^2] +
 q2/Sqrt[(x-p2[[1]])^2+(y-p2[[2]])^2+(z-p2[[3]])^2]);  (* Potential *)  
r = {0,2,0};
dipole[r[[1]],r[[2]],r[[3]] ]

The units are Newtons*meters. This is in units of energy or potential.  Recall that 1 kg has a force of 9.8 Newtons in your hand.  Moving it by 1 meter takes 9.8 joules.  If weight falls the energy is released in motion or velocity of the object. If the weight is lifted then the energy is added.  

Similarly, when a charge moves in an electric field, energy is added or taken away.  In either case, this can be detected as current.  

This is the basis of all detectors.   Including the sensors in your iphone.

echarge = QuantityMagnitude[UnitConvert[Quantity[1,"ElectronCharge"],"Coulombs"]]//N

q1inelectrons = q1/echarge

?ContourPlot

c1=ContourPlot[dipole[x,y,0],{x,-1,1},{y,-1,1},Contours->30]

?Grad

efield[x_,y_]:=  Grad[dipole[x,y,0],{x,y}]//Evaluate

efield[0,0]

v1=VectorPlot[efield[x,y],{x,-1,1},{y,-1,1}, VectorPoints->Automatic,StreamPoints -> 20]

Show[c1,v1]

What about the strength of the electric field between the two charges along the line in x ? Pay attention to units. Notice that ultimately all electrical units have to do with  Distance, Time, Mass and Charge. There are only ultimately 4 units. Everything else is terms of these units.  

Electric Field :  kg m/ sec^2 / coulomb = newton/coulomb = volts/meter

Norm[efield[0,0]]

Norm[efield[-1,0]]

Plot[Norm[efield[x,0]],{x,-2,2},Frame->True, FrameLabel->{"Distance meters","Field Volts/meter or Newtons/Coulomb"},LabelStyle->{Medium,Italic}]

Magnetic Field calculations are more difficult because they need calculus and complicated integrals.  But let’s just calculate the field of a wire using basic formulas.  

 The magnetic field of a wire is in a circle around the wire with the field dropping as 1/distance from wire.  How can we represent this ? Easiest to do this in cylindrical coordinates.

mu0  (* the magnetic permeability Tesla Meter/Ampere *)

I0=1;  (* current in the wire *) 
B0 = mu0 * I0/(2 Pi);   (* this is in Tesla * meter *)

BwireField[x_,y_,z_]:= {B0*y/(x^2+y^2), -B0*x/(x^2+y^2),0}

BwireField[10,0,0]

Plot[Norm[BwireField[x,0,0]],{x,0.1, 10},Frame->True,FrameLabel->{"Radius meter","B Field Tesla"},LabelStyle->{Medium,Italic}]

VectorPlot3D[BwireField[x,y,z],{x,-1,1.},{y,-1,1},{z,-2,2},VectorPoints -> 20, VectorStyle->Arrowheads[0.001],VectorScale->Tiny ]

Now we will do some circuits.  

The most important non-trivial circuit is an RC filter.  
This is where a resistor and capacitor are in series and we have to measure the voltage in between.  


The units are Volts, Amperes, Ohms, and Farads. 
We will setup the input voltage to be an oscillating voltage

This is a little more advanced, but it is not difficult to teach with Mathematica.

Clear[R1];  Clear[C1];  Clear[V0]; Clear[V];
R1 = 1000;   (* Ohm *)  
C1 = 10^-6;  (* Farad *)  
V0 = 1 ; (* Volts *)  
omega = 2*Pi*6000;  (*   The frequency is 600 Hz   *)  
V[t_]:=  V0*Sin[omega* t];

The charge on the capacitor of q[t]  changes according to the current.  The input voltage must be equal to the sum of the voltages across R and C.

eq1 = V[t] == R1*D[q[t],t] + q[t]/C1;

soln=DSolve[eq1&& q[0]==0,q[t],t]//Flatten//Simplify

This looks complicated. But it is easy to see what is happening.  It is in this form
Constant * ( Exp[-t/T] +  A Cos[ w t + phi] ) 
The time constant T = R*C.    

This solution is only useful for t>0.  For backwards time it will give nonsensical answers. It is as if the voltage was turned on at t=0.  

The first part slowly dies out as the capacitor charges up and then we just have a slightly shifted oscillation of the same frequency.  

The voltage on the capacitor is    q[t]/C 

Try changing the frequency to see what happens. As the frequency goes higher the amplitude of the voltage on the capacitor falls.

Plot[{V[t],(1/C1)*q[t]/.soln},{t,0.,0.005}]

What about a RLC  circuit. What does that do ?

Clear[R1];  Clear[C1];  Clear[V0]; Clear[V];
R1 = 100;   (* Ohm *)  
C1 = 10^-6;  (* Farad *)  
L1 = 10^-1; (* Henry *)  
V0 = 1 ; (* Volts *)  
omega = 2*Pi*600;  (*   The frequency is 600 Hz   *)  
omega = 1/Sqrt[L1*C1];
alpha  = R1/(2 L1); 
dampingfactor = alpha/omega; 
(* V[t_]:=  V0*Sin[omega* t];  *) 
V[t_]:= V0*UnitStep[t];

omega//N

timescale = 2*Pi/omega //N

alpha

1/(R1*C1)

dampingfactor//N

The input voltage must be equal to the sum of the voltages across R and C  and L
Voltage across R is just current * R 
Voltage across C is just   charge/C  
Voltage across L is      (change-in-current)*L   

We need some initial conditions:   charge on C is 0 at time = 0 and current at t=0 is zero

Clear[omega];  (* let's keep it a variable *)  
eq2 = V[t] == R1*D[q[t],t] + q[t]/C1 + L1*D[q[t],{t,2}]; 
soln2=DSolve[eq2&& q[0]==0 && q'[0]==0,q[t],t]//Flatten//Simplify

D[q[t]/.soln2,t]*R1

It is very difficult to understand from this complicated equation. We will not try here. For a proper understanding we need to use Fourier or Laplace transforms.  But Mathematica lets us explore this.  Let’s just plot it without too much concern.  

The circuit displays resonance characteristics. When hit with a disturbance it oscillates with a characteristic frequency.  If there is an energy absorbing resistor, it dampens.

Manipulate[Plot[{V[t]/.{omega-> ok},{q[t]/.soln2/.{omega-> ok}}/C1},{t,0,0.01}, PlotRange ->{{-0.005,0.01},{-1.,3.}}], {ok, 500., 5000.}]

We will finish with a demonstration of waves on a string.  

Imagine a string with length L.  
When it is plucked, vibrations are excited with fundamental wavelength of  2L.  

frequency W =   V* 2*Pi/(2L) where V is the velocity of the wave. 

Higher vibrations are also excited with different amplitudes. 
Wi = i* W 

This creates a pattern that moves back and forth on the string. But the ends of the string are fixed.

Setup frequency and wave number parameters.

L = 10;  V= 1.;  
Kn = Table[i*Pi/L, {i,1, 11}];
ωn = Table[i*V*Pi/L, {i,1,11}]; 
Bn1 = {1,1/2,0,0,0,0,0,0,0,0,0};  
Bn = {1,0,1/3,0,1/5,0,1/7,0,1/100,0,1/11};

setup the wavefunction as a function of time and space.  It is a sum of sins and cosines.

Pckt[x_,t_]:= Sum[Bn1[[i]]*Cos[ωn[[i]]*t]*Sin[Kn[[i]]*x],{i,1,11}];

We are now going to introduce how to animate a plot.  We are going to plot the wavefunction over the length of the string, but then move the time variable from 1 to 20 and see how the wave changes.  You can change the Bn parameters and see what the wave looks like.

Animate[Plot[Pckt[x,t],{x,0,10},PlotRange->{{0,10},{-2.,2.}}],{t,1,20}]

The basic theory of circuits is needed to understand detectors.  This will be covered by Steve Linden.  
But let me just establish some simple ideas for you.    

All  detectors produce electrical charge in response to some stimulus.  The eye has rods and cones that produce current when light falls on them.  


Ref:   Denis Baylor,  Proc. National Acad. Sci. Vol 93, pp 560-565  Jan. 1996  

In electrical considerations, a detector is often represented by a capacitor that is also producing charge.  Then we put a resistor across it and measure a voltage. That is it.  

 

Steven will tell you about detectors, but always remember that any effect, even a neutrino interaction is being converted into electrical current. 

Almost all detectors are small variations on the above concept.

Finally,  Perhaps the most important analysis tool is the integral transform, which includes Fourier and Laplace transforms.  All of physics including quantum mechanics and advanced particle physics, probability theory, and large fraction of mathematical analysis depends on the Fourier transform.  

Let’s go to the notebook Fourier-demo.nb