molecular
Class MolecularPiston

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--java.awt.Panel
                    |
                    +--java.applet.Applet
                          |
                          +--edu.davidson.tools.SApplet
                                |
                                +--molecular.MolecularPiston
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable

public class MolecularPiston
extends SApplet

See Also:
Serialized Form

Fields inherited from class edu.davidson.tools.SApplet
clock, dataConnections, dataListeners, dataSources, lock
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
MolecularPiston()
           
 
Method Summary
 void addCaption(java.lang.String cap)
          Adds a title to ensemble in top-center
 int addParticle(double xin, double yin, double xvel, double yvel, double r)
          Adds one particle to the ensemble
 int addParticleDataSource(int i)
           
 void createParticles(int n)
           
 void forward()
          Start the animation
 java.lang.String getAppletInfo()
           
 double getBWPos()
          Returns the bottom wall position
 int getEnsembleID()
          Returns the id of the ensemble.
 int getHistogramID(int nbins, double vmin, double vmax)
          Returns the id of the velocity histogram.
 double getLWPos()
          Returns the left wall position
 java.lang.String getParameter(java.lang.String key, java.lang.String def)
           
 java.lang.String[][] getParameterInfo()
           
 int getParticleID(int i)
          Returns the object identifier of the particle.
 double getPistonPos()
           
 double getRWPos()
          Returns the right wall position
 double getTWPos()
          Returns the top wall position
 void init()
           
 void pause()
          Stop the animation
 void removeParticle(int i)
          Removes ith particle from ensemble
 void removeWallTemp(java.lang.String wall)
           
 void setAutoRefresh(boolean ar)
          Repaint whenevers the system parameters are changed.
 void setBackgroundRGB(int r, int g, int b)
          Sets Background color inside piston
 void setBG2Color(int r, int g, int b)
          Sets Background color above piston head
 void setBoltzmann(double kb)
           
 void setBorderWidth(int w)
           
 void setConstrainIsothermal(boolean tf)
          Method constrains the temperature of the ensemble to a fixed value.
 void setDefault()
          Reset the clock to time=0.
 void setDefaultColor(int r, int g, int b)
          Sets default color when adding new particles.
 void setDefaultMass(double m)
          Sets default mass when adding new particles.
 void setDefaultPiston()
           
 void setDefaultSize(double r)
          Sets default size when adding new particles.
 void setDefaultTemp(double t)
           
 void setDelay(int delay)
          Sets calculation time delay
 void setDisplayOffset(int xoff, int yoff)
          Sets offsets for title
 void setDragable(boolean d)
          Method allows the piston to be dragable
 void setDt(double dt)
          Sets calculation time step
 void setFPS(int fps)
          Sets frames per second of animation
 void setGravity(double gr)
          Sets Gravitational constant that acts on piston
 void setInitialPistonPos(double h)
           
 void setKE(double k)
          Puts value in kinetic energy field
 void setMaxParticles(int p)
          Sets maximum number of particles that can be stored in arrays
 void setMessage(java.lang.String msg)
          Adds a message to small yellow box opposite coordinate display.
 void setMinPistonHeight(double h)
          Method sets minimum piston height for piston when dragging.
 void setOrientation(java.lang.String or)
           
 void setParticleMass(int i, double m)
          Sets mass of particle default value is 1 unit.
 void setParticlePos(int i, double xin, double yin)
          Sets Position of particle
 void setParticleRGB(int i, int rd, int gr, int bl)
          Sets color of particle
 void setParticles(int n)
           
 void setParticleVel(int i, double xvel, double yvel)
          Sets Velocity of particle
 void setPeriodicH(boolean p)
          Sets Periodic periodic boundary conditions
 void setPeriodicV(boolean p)
          Sets Periodic periodic boundary conditions
 void setPiston(java.lang.String str, boolean parsemode)
           
 void setPistonMass(double m)
          Sets Mass of piston
 void setPistonWidth(int pw)
          Sets width of piston
 void setPpu(int p)
          Sets pixels per unit of ensemble
 void setRGB(int r, int g, int b)
          Sets color of title
 void setShowControls(boolean s)
          Shows or hides control panel
 void setTemp(double temp)
          Set the temperature of the ensemble in 1 step.
 void setTemperature(double temp, int steps)
          Set the temperature of the ensemble in n steps.
 void setVolume(double vol, int steps)
          Move the piston to set the volume for the ensemble.
 void setVolumeIsothermal(double vol, int steps)
          Move the piston to set the volume for the ensemble.
 void setWallTemp(java.lang.String wall, double t)
          Sets Velocity of particle
 void start()
           
 void stepForward()
          Steps simulation forward one time step
 
Methods inherited from class edu.davidson.tools.SApplet
addDataListener, addDataSource, cleanupDataConnections, clearAllData, clearData, deleteDataConnection, deleteDataConnections, destroy, getClockID, getClockTime, getDataConnectionFromDL, getDataConnectionFromDS, getDataFromDS, getDataListener, getDataListener, getDataSource, getDataSource, getID, getRunningID, getSourceData, getSourceVariables, isAutoRefresh, isClockRunning, makeDataConnection, removeDataListener, removeDataSource, reset, reverse, setClockContinous, setClockCycle, setClockOneShot, setClockTime, setConnectionBlock, setConnectionListener, setConnectionSmoothing, setConnectionSource, setConnectionStride, setExternalClock, setFPS, setRunningID, setRunningID, setTimeContinuous, setTimeCycle, setTimeOneShot, startClock, stepClock, stepTime, stepTimeBack, stepTimeForward, stopClock, updateDataConnection, updateDataConnections
 
Methods inherited from class java.applet.Applet
getAccessibleContext, getAppletContext, getAudioClip, getAudioClip, getCodeBase, getDocumentBase, getImage, getImage, getLocale, getParameter, isActive, newAudioClip, play, play, resize, resize, setStub, showStatus, stop
 
Methods inherited from class java.awt.Panel
addNotify
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paint, paintComponents, preferredSize, print, printComponents, remove, remove, removeAll, removeContainerListener, removeNotify, setFont, setLayout, update, validate
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, addPropertyChangeListener, bounds, checkImage, checkImage, contains, contains, createImage, createImage, disable, dispatchEvent, enable, enable, enableInputMethods, getBackground, getBounds, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getInputContext, getInputMethodRequests, getLocation, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isDisplayable, isDoubleBuffered, isEnabled, isFocusTraversable, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MolecularPiston

public MolecularPiston()
Method Detail

addCaption

public void addCaption(java.lang.String cap)
Adds a title to ensemble in top-center
Parameters:
cap - String

addParticle

public int addParticle(double xin,
                       double yin,
                       double xvel,
                       double yvel,
                       double r)
Adds one particle to the ensemble
Parameters:
xin - double initial xposition
yin - double initial yposition
xvel - double initial x-velocity
yvel - double initial y-velocity
r - double particle radius

addParticleDataSource

public int addParticleDataSource(int i)

createParticles

public void createParticles(int n)

forward

public void forward()
Start the animation
Overrides:
forward in class SApplet

getAppletInfo

public java.lang.String getAppletInfo()
Overrides:
getAppletInfo in class java.applet.Applet

getBWPos

public double getBWPos()
Returns the bottom wall position
Returns:
double

getEnsembleID

public int getEnsembleID()
Returns the id of the ensemble. This id can be used to make data connections.
Returns:
int The id.

getHistogramID

public int getHistogramID(int nbins,
                          double vmin,
                          double vmax)
Returns the id of the velocity histogram. This id can be used to make data connections.
Parameters:
nbins - int The number of bins in the histogram.
min - double The minimum velocity
max - double The maximum velocity
Returns:
int The id.

getLWPos

public double getLWPos()
Returns the left wall position
Returns:
double

getParameter

public java.lang.String getParameter(java.lang.String key,
                                     java.lang.String def)

getParameterInfo

public java.lang.String[][] getParameterInfo()
Overrides:
getParameterInfo in class java.applet.Applet

getParticleID

public int getParticleID(int i)
Returns the object identifier of the particle. This id can be used to make data connections. Each particle has an index ranging from 0 to N-1 that specifies its postion in an array where N is the total number of particles. This index must be converted to an object identifier in order to make a data connection.
Parameters:
i - int the particle index.
Returns:
int the object identifier.

getPistonPos

public double getPistonPos()

getRWPos

public double getRWPos()
Returns the right wall position
Returns:
double

getTWPos

public double getTWPos()
Returns the top wall position
Returns:
double

init

public void init()
Overrides:
init in class java.applet.Applet

pause

public void pause()
Stop the animation
Overrides:
pause in class SApplet

removeParticle

public void removeParticle(int i)
Removes ith particle from ensemble
Parameters:
i - int particle number

removeWallTemp

public void removeWallTemp(java.lang.String wall)

setAutoRefresh

public void setAutoRefresh(boolean ar)
Description copied from class: SApplet
Repaint whenevers the system parameters are changed.
Overrides:
setAutoRefresh in class SApplet
Following copied from class: edu.davidson.tools.SApplet
Parameters:
autoRefresh - Automatic repaint?

setBackgroundRGB

public void setBackgroundRGB(int r,
                             int g,
                             int b)
Sets Background color inside piston
Parameters:
r - int red
g - int green
b - int blue

setBG2Color

public void setBG2Color(int r,
                        int g,
                        int b)
Sets Background color above piston head
Parameters:
r - int red
g - int green
b - int blue

setBoltzmann

public void setBoltzmann(double kb)

setBorderWidth

public void setBorderWidth(int w)

setConstrainIsothermal

public void setConstrainIsothermal(boolean tf)
Method constrains the temperature of the ensemble to a fixed value. Used for isothermal expansion and compression when piston is moving.
Parameters:
tf - boolean

setDefault

public void setDefault()
Description copied from class: SApplet
Reset the clock to time=0.
Overrides:
setDefault in class SApplet

setDefaultColor

public void setDefaultColor(int r,
                            int g,
                            int b)
Sets default color when adding new particles. All particles created after calling this method will have this color
Parameters:
r - int red
g - int green
b - int blue

setDefaultMass

public void setDefaultMass(double m)
Sets default mass when adding new particles. All particles created after calling this method will have this mass
Parameters:
m - double mass

setDefaultPiston

public void setDefaultPiston()

setDefaultSize

public void setDefaultSize(double r)
Sets default size when adding new particles. All particles created after calling this method will have this radius
Parameters:
r - double radius

setDefaultTemp

public void setDefaultTemp(double t)

setDelay

public void setDelay(int delay)
Sets calculation time delay
Parameters:
delay - int delay milliseconds

setDisplayOffset

public void setDisplayOffset(int xoff,
                             int yoff)
Sets offsets for title
Parameters:
int - xoff
int - yoff

setDragable

public void setDragable(boolean d)
Method allows the piston to be dragable
Parameters:
d - boolean

setDt

public void setDt(double dt)
Sets calculation time step
Overrides:
setDt in class SApplet
Parameters:
dt - double timestep

setFPS

public void setFPS(int fps)
Sets frames per second of animation
Parameters:
fps - int

setGravity

public void setGravity(double gr)
Sets Gravitational constant that acts on piston
Parameters:
gr - double

setInitialPistonPos

public void setInitialPistonPos(double h)

setKE

public void setKE(double k)
Puts value in kinetic energy field
Parameters:
k - double value to be inserted in field

setMaxParticles

public void setMaxParticles(int p)
Sets maximum number of particles that can be stored in arrays
Parameters:
p - max particles

setMessage

public void setMessage(java.lang.String msg)
Adds a message to small yellow box opposite coordinate display.
Parameters:
msg - String

setMinPistonHeight

public void setMinPistonHeight(double h)
Method sets minimum piston height for piston when dragging. Does not apply to normal piston opperation. Method protects against crushing particles and crashing program.
Parameters:
h - double height in units. (usually around 3 to 7)

setOrientation

public void setOrientation(java.lang.String or)

setParticleMass

public void setParticleMass(int i,
                            double m)
Sets mass of particle default value is 1 unit.
Parameters:
i - int particle number
m - double mass.

setParticlePos

public void setParticlePos(int i,
                           double xin,
                           double yin)
Sets Position of particle
Parameters:
i - int particle number
xin - double initial x-position
yin - double initial y-position

setParticleRGB

public void setParticleRGB(int i,
                           int rd,
                           int gr,
                           int bl)
Sets color of particle
Parameters:
i - int particle number
rd - int red value (<256)
gr - int green value (<256)
bl - int blue value (<256)

setParticles

public void setParticles(int n)

setParticleVel

public void setParticleVel(int i,
                           double xvel,
                           double yvel)
Sets Velocity of particle
Parameters:
i - int particle number
xvel - double initial x-velocity
yvel - double initial y-velocity

setPeriodicH

public void setPeriodicH(boolean p)
Sets Periodic periodic boundary conditions
Parameters:
p - boolean

setPeriodicV

public void setPeriodicV(boolean p)
Sets Periodic periodic boundary conditions
Parameters:
p - boolean

setPiston

public void setPiston(java.lang.String str,
                      boolean parsemode)

setPistonMass

public void setPistonMass(double m)
Sets Mass of piston
Parameters:
m - double new mass of piston

setPistonWidth

public void setPistonWidth(int pw)
Sets width of piston
Parameters:
pw - double new mass of piston

setPpu

public void setPpu(int p)
Sets pixels per unit of ensemble
Parameters:
p - int

setRGB

public void setRGB(int r,
                   int g,
                   int b)
Sets color of title
Parameters:
r - int red
g - int green
b - int blue

setShowControls

public void setShowControls(boolean s)
Shows or hides control panel
Parameters:
s - boolean

setTemp

public void setTemp(double temp)
Set the temperature of the ensemble in 1 step.
Parameters:
temp - double The new temperature.

setTemperature

public void setTemperature(double temp,
                           int steps)
Set the temperature of the ensemble in n steps. Data will be sent to data listeners after each step.
Parameters:
temp - double The new temperature.
steps - int The number of steps.

setVolume

public void setVolume(double vol,
                      int steps)
Move the piston to set the volume for the ensemble.
Parameters:
vol - The new volume.
numSteps - The number of dV steps for the move.

setVolumeIsothermal

public void setVolumeIsothermal(double vol,
                                int steps)
Move the piston to set the volume for the ensemble.
Parameters:
vol - The new volume.
numSteps - The number of dV steps for the move.

setWallTemp

public void setWallTemp(java.lang.String wall,
                        double t)
Sets Velocity of particle
Parameters:
wall - string Which wall? [top, bottom, right, left]
t - double The wall temperature

start

public void start()
Overrides:
start in class java.applet.Applet

stepForward

public void stepForward()
Steps simulation forward one time step

Copyright Wolfgang Christian

Visit the Davidson CollegePhyslets Page