org.opensourcephysics.cabrillo.tracker
Class DynamicSystem

java.lang.Object
  extended by org.opensourcephysics.cabrillo.tracker.TTrack
      extended by org.opensourcephysics.cabrillo.tracker.PointMass
          extended by org.opensourcephysics.cabrillo.tracker.ParticleModel
              extended by org.opensourcephysics.cabrillo.tracker.DynamicParticle
                  extended by org.opensourcephysics.cabrillo.tracker.DynamicParticlePolar
                      extended by org.opensourcephysics.cabrillo.tracker.DynamicSystem
All Implemented Interfaces:
java.beans.PropertyChangeListener, java.util.EventListener, Drawable, Interactive, Measurable, Trackable, ODE

public class DynamicSystem
extends DynamicParticlePolar

This models a system of 2 particles that interact via internal forces.

Version:
1.0
Author:
D. Brown

Nested Class Summary
 
Nested classes/interfaces inherited from class org.opensourcephysics.cabrillo.tracker.PointMass
PointMass.FrameData
 
Nested classes/interfaces inherited from class org.opensourcephysics.cabrillo.tracker.TTrack
TTrack.StepArray
 
Field Summary
protected  ParticleModel[] models
           
protected  TTrack.StepArray noSteps
           
protected  java.lang.String[] particleNames
           
protected  DynamicParticle[] particles
           
protected  double[] particleState
           
protected  TTrack.StepArray realSteps
           
protected  java.util.TreeMap<java.lang.Integer,double[]> relativeStates
           
protected  DynamicSystemInspector systemInspector
           
protected  javax.swing.JMenuItem systemInspectorItem
           
protected  int systemInspectorX
           
protected  int systemInspectorY
           
 
Fields inherited from class org.opensourcephysics.cabrillo.tracker.DynamicParticle
frameStates, initialState, iterationsPerStep, points, solver, state, system
 
Fields inherited from class org.opensourcephysics.cabrillo.tracker.ParticleModel
dt, endFrame, functionEditor, functionPanel, inspector, inspectorH, inspectorX, inspectorY, invalidWarningShown, lastValidFrame, loading, nan, prevX, prevY, refreshDerivsLater, refreshing, refreshStepsLater, showInspector, startFrame, startFrameUndefined, t0, time, timeFormat, tracePt, tracePtsPerStep, traceX, traceY, xLimit, yLimit
 
Fields inherited from class org.opensourcephysics.cabrillo.tracker.PointMass
aAtOrigin, accelerationMenu, accelFootprintMenu, aDeriv, aDerivSpill, aFootprint, aFootprints, algorithm, aMap, aTailsToOriginItem, aTailsToPositionItem, autotrackItem, aVisibleItem, aVisibleOnAll, aVisMap, BOUNCE_DETECT, bounceDerivs, bounceDerivsSpill, derivData, FINITE_DIFF, mass, massField, massLabel, mSeparator, params, positionFootprintMenu, trace, traceStroke, traceVisible, validData, vAtOrigin, vDeriv, vDerivSpill, velocFootprintMenu, velocityMenu, vFootprint, vFootprints, vMap, vTailsToOriginItem, vTailsToPositionItem, vVisibleItem, vVisibleOnAll, vVisMap, xData, xVisibleOnAll, xVisMap, yData
 
Fields inherited from class org.opensourcephysics.cabrillo.tracker.TTrack
alphabet, angleField, angleLabel, angleSeparator, attachments, autoAdvance, autoAdvanceItem, autoTrackerMarking, circleFootprintListener, clearStepsItem, closeButton, colorItem, constantsLoadedFromXML, data, dataBuilderItem, dataDescriptions, dataFrames, dataProp, dataValid, defaultColors, defaultFootprint, deleteStepItem, deleteTrackItem, description, descriptionItem, enabled, fieldBorder, footprint, footprintListener, footprintMenu, footprints, frc, hint, isMarking, keyFrames, labelFont, locked, lockedItem, magField, magLabel, magSeparator, markByDefault, markByDefaultItem, menu, name, nameAction, nameDialog, nameField, nameItem, panels, partName, point, preferredColumnOrder, properties, refreshDataLater, skippedStepWarningCheckbox, skippedStepWarningDialog, skippedStepWarningOn, skippedStepWarningTextpane, stepLabel, steps, stepSeparator, stepSizeWhenFirstMarked, stepValueLabel, support, targetIndex, tField, tLabel, toolbarPointComponents, toolbarTrackComponents, trackerPanel, trailLength, trailVisible, trailVisibleItem, tSeparator, tValueLabel, viewable, visible, visibleItem, worldBounds, xField, xLabel, xSeparator, xSpinner, yField, yLabel, ySeparator, ySpinner
 
Constructor Summary
DynamicSystem()
          No-arg constructor.
DynamicSystem(DynamicParticle[] parts)
          Constructor with particles.
 
Method Summary
 boolean addParticle(DynamicParticle particle)
          Adds a particle to this system.
protected  void cleanup()
          Cleans up associated resources when this track is deleted or cleared.
 void delete()
          Deletes this system.
 void draw(DrawingPanel panel, java.awt.Graphics _g)
          Overrides DynamicParticle draw method.
 java.lang.String getDisplayName()
          Gets a display name for this model.
 double[] getInitialState()
          Gets the initial state.
 double[] getInitialValues()
          Gets the initial values.
static XML.ObjectLoader getLoader()
          Returns an ObjectLoader to save and load data for this class.
 double getMass()
          Gets the mass.
 javax.swing.JMenu getMenu(TrackerPanel trackerPanel)
          Returns a menu with items that control this track.
protected  ParticleModel[] getModels()
          Gets the particle models associated with this model.
 void getRate(double[] state, double[] rate)
          Gets the rate based on a specified state.
protected  double[] getRelativePolarState(double[] state)
          Converts a two-body cartesian state {x1, vx1, y1, vy1, x2, vx2, y2, vy2, t} to a relative polar state {r, vr, theta, omega, t}.
protected  double[] getState(DynamicParticle particle)
          Gets the current state of the specified particle.
 DynamicSystemInspector getSystemInspector()
          Gets the system inspector.
protected  double[] getSystemState(double[] state)
          Gets the state of this system based on the states of its particles.
 java.util.ArrayList<java.awt.Component> getToolbarTrackComponents(TrackerPanel trackerPanel)
          Overrides TTrack getToolbarTrackComponents method.
protected  void initializeFunctionPanel()
          Creates and initializes the ModelFunctionPanel.
 boolean isDependent()
          Overrides TTrack isDependent method to return true.
 void propertyChange(java.beans.PropertyChangeEvent e)
          Responds to property change events.
protected  void refreshData(DatasetManager data, TrackerPanel trackerPanel)
          Refreshes the data.
protected  void refreshInitialTime()
          Refreshes initial time parameter for this model.
protected  void refreshSystemParameters()
          Refreshes the initial positions, velocities and particle masses based on the values for the particles in this system.
 boolean removeParticle(DynamicParticle particle)
          Removes a particle from this system.
 boolean setParticles(DynamicParticle[] newParticles)
          Sets the particles in this system.
protected  void setTracePositions(double[] state)
          Sets the positions of the trace points based on a specified state.
 
Methods inherited from class org.opensourcephysics.cabrillo.tracker.DynamicParticlePolar
getPolarState, getXYForces, initializeInitEditor
 
Methods inherited from class org.opensourcephysics.cabrillo.tracker.DynamicParticle
getEndFrame, getNextTracePositions, getStartFrame, getState, refreshSteps, reset, resetState, restoreState, saveState, setEndFrame, setSolver, setStartFrame
 
Methods inherited from class org.opensourcephysics.cabrillo.tracker.ParticleModel
createMassAndTimeParameters, drawMe, findInteractive, getFunctionEditor, getInitEditor, getInspector, getParamEditor, getToolbarPointComponents, isAutoTrackable, isModelsVisible, isStepComplete, refreshDerivsIfNeeded, setAnglesInRadians, setLocked, setMass, setName, setTrackerPanel, trimSteps
 
Methods inherited from class org.opensourcephysics.cabrillo.tracker.PointMass
createGUI, createStep, deleteStep, erase, erase, getAArray, getAcceleration, getAccelerationFootprint, getAccelerationFootprints, getAccelerations, getFootprint, getFootprintLength, getFootprints, getNextVisibleStep, getPreviousVisibleStep, getRotationData, getRotationData, getStep, getStepLength, getTargetDescription, getVArray, getVelocities, getVelocity, getVelocityFootprint, getVelocityFootprints, getWorldAcceleration, getWorldPosition, getWorldVelocity, isAcceleration, isAVisible, isLabelsVisible, isPosition, isPositionVisible, isStepVisible, isTraceVisible, isVelocity, isVVisible, remark, remark, setAccelerationFootprint, setAccelerationFootprints, setAlgorithm, setAVisible, setAVisibleOnAll, setColor, setFootprint, setLabelsVisible, setPositionVisible, setPositionVisibleOnAll, setTraceVisible, setVelocityFootprint, setVelocityFootprints, setVVisible, setVVisibleOnAll, updateDerivatives, updateDerivatives, updateDerivatives, updateDerivatives, updateDerivatives, updateDerivatives
 
Methods inherited from class org.opensourcephysics.cabrillo.tracker.TTrack
addFootprint, addPropertyChangeListener, addPropertyChangeListener, autoMarkAt, createWarningDialog, firePropertyChange, getColor, getData, getDataDescription, getDataName, getDescription, getFootprint, getFootprints, getFrameForData, getMarkedPoint, getMarkingCursor, getMessage, getName, getPreferredDataOrder, getProperty, getPropertyNames, getSkippedStepWarningDialog, getStep, getSteps, getStepSizeWarningDialog, getTargetIndex, getTrailLength, getWorldBounds, getX, getXMax, getXMax, getXMin, getXMin, getY, getYMax, getYMax, getYMin, getYMin, isAutoAdvance, isAutoTrackable, isEmpty, isEnabled, isLocked, isMarkByDefault, isMeasured, isTrailVisible, isViewable, isVisible, refreshData, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, setAutoAdvance, setColorToDefault, setDefaultNameAndColor, setDescription, setEnabled, setFootprint, setFootprints, setFootprints, setMarkByDefault, setMarking, setProperty, setTargetIndex, setTargetIndex, setTargetIndex, setTrailLength, setTrailVisible, setViewable, setVisible, setX, setXY, setY, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

particles

protected DynamicParticle[] particles

models

protected ParticleModel[] models

particleState

protected double[] particleState

systemInspector

protected DynamicSystemInspector systemInspector

systemInspectorItem

protected javax.swing.JMenuItem systemInspectorItem

particleNames

protected java.lang.String[] particleNames

realSteps

protected TTrack.StepArray realSteps

noSteps

protected TTrack.StepArray noSteps

systemInspectorX

protected int systemInspectorX

systemInspectorY

protected int systemInspectorY

relativeStates

protected java.util.TreeMap<java.lang.Integer,double[]> relativeStates
Constructor Detail

DynamicSystem

public DynamicSystem()
No-arg constructor.


DynamicSystem

public DynamicSystem(DynamicParticle[] parts)
Constructor with particles.

Parameters:
parts - an array of up to two dynamic particles
Method Detail

draw

public void draw(DrawingPanel panel,
                 java.awt.Graphics _g)
Overrides DynamicParticle draw method.

Specified by:
draw in interface Drawable
Overrides:
draw in class DynamicParticle
Parameters:
panel - the drawing panel requesting the drawing
_g - the graphics context on which to draw

getDisplayName

public java.lang.String getDisplayName()
Gets a display name for this model.

Overrides:
getDisplayName in class DynamicParticle
Returns:
the display name

getMenu

public javax.swing.JMenu getMenu(TrackerPanel trackerPanel)
Returns a menu with items that control this track.

Overrides:
getMenu in class ParticleModel
Parameters:
trackerPanel - the tracker panel
Returns:
a menu

getToolbarTrackComponents

public java.util.ArrayList<java.awt.Component> getToolbarTrackComponents(TrackerPanel trackerPanel)
Overrides TTrack getToolbarTrackComponents method.

Overrides:
getToolbarTrackComponents in class PointMass
Parameters:
trackerPanel - the tracker panel
Returns:
a list of components

getMass

public double getMass()
Gets the mass. Overrides PointMass method.

Overrides:
getMass in class ParticleModel
Returns:
the mass

isDependent

public boolean isDependent()
Overrides TTrack isDependent method to return true.

Overrides:
isDependent in class ParticleModel
Returns:
true if this track is dependent

addParticle

public boolean addParticle(DynamicParticle particle)
Adds a particle to this system.

Parameters:
particle - the particle to add
Returns:
true if particle added

removeParticle

public boolean removeParticle(DynamicParticle particle)
Removes a particle from this system.

Parameters:
particle - the particle to remove
Returns:
true if particle removed

setParticles

public boolean setParticles(DynamicParticle[] newParticles)
Sets the particles in this system.

Parameters:
newParticles - an array of zero to two dynamic particles
Returns:
true if particles accepted

delete

public void delete()
Deletes this system. Overrides DynamicParticle method to clean up particles after deleting.

Overrides:
delete in class DynamicParticle

getRate

public void getRate(double[] state,
                    double[] rate)
Gets the rate based on a specified state.

Specified by:
getRate in interface ODE
Overrides:
getRate in class DynamicParticle
Parameters:
state - the state
rate - the rate of change of the state

getInitialValues

public double[] getInitialValues()
Gets the initial values.

Overrides:
getInitialValues in class ParticleModel
Returns:
initial values {x1, vx1, y1, vy1, x2, vx2, y2, vy2, t}

propertyChange

public void propertyChange(java.beans.PropertyChangeEvent e)
Responds to property change events.

Specified by:
propertyChange in interface java.beans.PropertyChangeListener
Overrides:
propertyChange in class ParticleModel
Parameters:
e - the property change event

getSystemInspector

public DynamicSystemInspector getSystemInspector()
Gets the system inspector.

Returns:
the system inspector

getInitialState

public double[] getInitialState()
Gets the initial state. Overrides DynamicParticle method.

Overrides:
getInitialState in class DynamicParticlePolar
Returns:
the initial state

refreshData

protected void refreshData(DatasetManager data,
                           TrackerPanel trackerPanel)
Refreshes the data. Overrides PointMass method.

Overrides:
refreshData in class PointMass
Parameters:
data - the DatasetManager
trackerPanel - the tracker panel

cleanup

protected void cleanup()
Cleans up associated resources when this track is deleted or cleared.

Overrides:
cleanup in class ParticleModel

refreshInitialTime

protected void refreshInitialTime()
Refreshes initial time parameter for this model. Overrides ParticleModel.

Overrides:
refreshInitialTime in class ParticleModel

refreshSystemParameters

protected void refreshSystemParameters()
Refreshes the initial positions, velocities and particle masses based on the values for the particles in this system.


setTracePositions

protected void setTracePositions(double[] state)
Sets the positions of the trace points based on a specified state.

Overrides:
setTracePositions in class DynamicParticle
Parameters:
state - the state

initializeFunctionPanel

protected void initializeFunctionPanel()
Creates and initializes the ModelFunctionPanel.

Overrides:
initializeFunctionPanel in class DynamicParticlePolar

getSystemState

protected double[] getSystemState(double[] state)
Gets the state of this system based on the states of its particles.

Parameters:
state - the particle state {x1, vx1, y1, vy1, x2, vx2, y2, vy2, t}
Returns:
the system state {x_cm, vx_cm, y_cm, vy_cm, t}

getState

protected double[] getState(DynamicParticle particle)
Gets the current state of the specified particle.

Parameters:
particle - the particle
Returns:
the state of the particle {x, vx, y, vy, t}

getModels

protected ParticleModel[] getModels()
Gets the particle models associated with this model.

Overrides:
getModels in class ParticleModel
Returns:
an array of particle models

getRelativePolarState

protected double[] getRelativePolarState(double[] state)
Converts a two-body cartesian state {x1, vx1, y1, vy1, x2, vx2, y2, vy2, t} to a relative polar state {r, vr, theta, omega, t}.

Parameters:
state - the cartesian state of both particles
Returns:
the polar state of particle 1 relative to particle 2

getLoader

public static XML.ObjectLoader getLoader()
Returns an ObjectLoader to save and load data for this class.

Returns:
the object loader