## simulations.experiments.magnetostatics Class TeachSpinExperiment

```java.lang.Object simulations.experiments.BaseExperiment simulations.experiments.magnetostatics.TeachSpinExperiment
```

public class TeachSpinExperiment
extends BaseExperiment

Experiment consists of two ring currents, one above the other. The top one represents the small magnet in the teach spin experiment, and the bottom one represents the bottom current ring in the teach spin experiment. In this experiment we let the current in the bottom current ring vary sinusoidally with time, I(t) = I0 sin (omega * t) and calculate the corresponding motion of the magnet due to this changing current in a purely magnetostatic fashion (that is there is no currrent induced anywhere in this problem due to a changing magnetic flux through any ring--e.g. there are no induced electric fields or currents of importance). We also assume that this magnet motion is quasi-static--that is it is very slow compared to the natural frequency of oscillation of the magnet on the spring from which it is suspended, so that the magnetic force on the dipole simply results in a displacement from equilibrium that is proportional to the force.

Version:
1.0
Author:
Michael Danziger, John Belcher

 Field Summary `private  EMCollection` `collection`           the EMCollection consisting of the dipole and the current ring ` double` `deltaR`           the amplitude of the motion of the magnet ` double` `dIdt`           the current time rate of change of current in the ring ` CurrentRing` `dipole`           the dipole in the Teach Spin experiment ` double` `I`           the current current in the ring ` double` `I0`           the amplitude of the sinusoidal variation in the current in the lower current ring ` double` `I1`           the amplitude of the sinusoidal variation in the current in the lower current ring ` double` `omega`           the constant current in the magnetic dipole ` double` `R`           the radius of the lower current ring in pixels ` CurrentRing` `ring`           the lower ring in the Teach Spin experiment ` double` `t`           the time ` double` `v`           the current velocity of the magnet along the z-axis ` double` `z`           the current position of the magnet along the z-axis ` double` `z0`           the initial position of the magnet on the z-axis ` double` `Z0`           the fixed position of the lower current ring center along the z-axis

 Fields inherited from class simulations.experiments.BaseExperiment `eps, FieldMotionType, FieldType, FluidFlowSpeed, Fnorm, Fpower, numberSmallSteps`

 Constructor Summary ```TeachSpinExperiment(double R, double deltaR, double I1, double z0, double Z0, double I0, double omega)```           constructor for the experiment

 Method Summary ` void` `ConstructEMSource()`           Constructs the EMSource representing the two current rings in the experiment with the given initial conditions ` void` `Evolve(double dt)`           Evolves the experiment by a time step "dt" ` void` ```Evolve(double dt, double maxStep)```           Evolves the experiment. ` BaseObject` `getEMSource()`           returns the collecton of BaseObjects constructed in ConstructEMSource() ` double` ```getFlowSpeed(Vec3 r, Vec RegionFlow)```           Method to find the flow speed in a given region when we are determining that speed according to region. ` double` ```getHue(double TargetHue, Vec3 r, Vec RegionColor)```           Method to find the hue in a given region when we are coloring according to region (Color Mode 4).

 Methods inherited from class java.lang.Object `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

 Field Detail

### R

`public double R`
the radius of the lower current ring in pixels

### deltaR

`public double deltaR`
the amplitude of the motion of the magnet

### I0

`public double I0`
the amplitude of the sinusoidal variation in the current in the lower current ring

### I1

`public double I1`
the amplitude of the sinusoidal variation in the current in the lower current ring

### omega

`public double omega`
the constant current in the magnetic dipole

### z0

`public double z0`
the initial position of the magnet on the z-axis

### Z0

`public double Z0`
the fixed position of the lower current ring center along the z-axis

### z

`public double z`
the current position of the magnet along the z-axis

### v

`public double v`
the current velocity of the magnet along the z-axis

### I

`public double I`
the current current in the ring

### dIdt

`public double dIdt`
the current time rate of change of current in the ring

### t

`public double t`
the time

### ring

`public CurrentRing ring`
the lower ring in the Teach Spin experiment

### dipole

`public CurrentRing dipole`
the dipole in the Teach Spin experiment

### collection

`private EMCollection collection`
the EMCollection consisting of the dipole and the current ring

 Constructor Detail

### TeachSpinExperiment

```public TeachSpinExperiment(double R,
double deltaR,
double I1,
double z0,
double Z0,
double I0,
double omega)```
constructor for the experiment

Parameters:
`R` - the radius of the lower current ring
`deltaR` - the amplitude of the variation in the height of the magnet
`I1` - the constant current in the magnet
`z0` - the initial position of the magnet above the lower current ring
`Z0` - the initial position of the lower current ring along the z-axis
`I0` - the amplitude of the variation in the current in the lower current ring
`omega` - the angular frequency of the time variation in current
 Method Detail

### ConstructEMSource

`public void ConstructEMSource()`
Constructs the EMSource representing the two current rings in the experiment with the given initial conditions

Specified by:
`ConstructEMSource` in class `BaseExperiment`

### getEMSource

`public BaseObject getEMSource()`
Description copied from class: `BaseExperiment`
returns the collecton of BaseObjects constructed in ConstructEMSource()

Specified by:
`getEMSource` in class `BaseExperiment`

### Evolve

```public void Evolve(double dt,
double maxStep)```
Evolves the experiment. This is easy because we have an analytic expression for the position of the magnet as a function of time and the current in the ring as a function of time. The state of the EMSource representing the ring and magnet must be updated to reflect the change

### Evolve

`public void Evolve(double dt)`
Evolves the experiment by a time step "dt"

Specified by:
`Evolve` in class `BaseExperiment`

### getHue

```public double getHue(double TargetHue,
Vec3 r,
Vec RegionColor)```
Method to find the hue in a given region when we are coloring according to region (Color Mode 4).

Specified by:
`getHue` in class `BaseExperiment`
Parameters:
`TargetHue` - This is the target hue from the renderer.
`r` - This is the vector postion of the point in the image.
`RegionColor` - This is the varous hues for the regions.
Returns:
The hue for the part of the image map at r.

### getFlowSpeed

```public double getFlowSpeed(Vec3 r,
Vec RegionFlow)```
Method to find the flow speed in a given region when we are determining that speed according to region. This method is used when we have set experiment.FieldMotionType to one of either Constants.FIELD_MOTION_VREFIELD or Constants.FIELD_MOTION_VRBFIELD.

Specified by:
`getFlowSpeed` in class `BaseExperiment`
Parameters:
`r` - This is the vector postion of the point in the image.
`RegionFlow` - This is the flow speeds for the regions.
Returns:
The flow speed for the part of the image map at r.