This is the web version of EJS interface
EJS version 4.2
  1. Title=Hard Disk Gas
  2. Author=Wolfgang Christian remix by lookang
  3. Keywords=molecular dynamics, gas, hard disk model
  4. Abstract=DiskCollisions models an ideal two dimensional gas using hard disks. Note the use of periodic boundary conditions.
  5. CaptureTools=false
  6. DataTools=false
  7. LanguageTools=true
  8. UseInterpreter=true
  9. AuxiliaryFiles=./HardDiskGas/;
  10. DetectedFiles=./HardDiskGas/disk_gas.html;

Hard Disk Gas

dDiskGas/disk_gas
    NameValueTypeDimension
    NameValueTypeDimension
    NameValueTypeDimension

    Initialize Particles

    double xi=diameter; double yi=diameter; for(int i=0; i<n; i++){ x[i]=xi; y[i]=yi; double angle = 2*Math.PI*Math.random(); angleslider[i] = angle; // added by wee for slider to vary magnitude of v0 vx[i]=v0*Math.sin(angle); vy[i]=v0*Math.cos(angle); xi += 1.5*diameter; if(xi+diameter>cellSize){ xi = diameter; yi += 1.5*diameter; } }

    particle motion

    Indep. Var. Increment
    d x[i] /dt=vx[i]
    d y[i] /dt=vy[i]
    SolverRungeKutta AbsoluteTolerance=0.001
    Euler method is exact because particles move with constant velocity between collisions.

    Name:E,active=E,條件:Method:E,(誤差範圍E),stopatEvent=E
    E


    動作
    E

    Name:c,active=c,條件:Method:c,(誤差範圍c),stopatEvent=c
    c


    動作
    c

    Name:t,active=t,條件:Method:t,(誤差範圍t),stopatEvent=t
    t


    動作
    t

    Name:,active=,條件:Method:,(誤差範圍),stopatEvent=


    動作

    Constraints

    periodicBoundary(); TKE = 0; TMOM = 0; for(int i=0; i<n; i++){ speed[i]=Math.sqrt(vx[i]*vx[i]+vy[i]*vy[i]); // label for the mass introduced by wee l_m[i]="m"+((i+1)); KE[i] = 0.5*mass[i]*speed[i]*speed[i]; TKE = TKE+ KE[i]; MOM[i] = mass[i]*speed[i]; TMOM = TMOM + MOM[i]; } if(!accumulateData) _view.speedHistogram.clear();
    public void periodicBoundary () { for(int i=0; i<n; i++){ x[i]=position(x[i],cellSize); y[i]=position(y[i],cellSize); } } // Adjusts the position of a particle assuming periodic boundary conditions. // The position will be in the interval [0,size). public double position(final double r, final double size) { return r<0 ? r%size+size : r%size; } //Computes the minimum separation using periodic boundary conditions. public double separation(final double dr, final double size) { //http://msdn.microsoft.com/en-us/library/system.math.floor.aspx //Math.floor Returns the largest integer less than or equal to the specified number. return dr-size*Math.floor(dr/size+0.5); }
    double dv; public String double2String(double v,double divider){ if(v>0)dv=0.5; else if(v<0)dv=-0.5; else dv=0; return (int)(v*divider+dv)/divider+""; } // this code has to do with displaying the number 2.3 instead of 2.300000001 when using % %
    EJSVIEW: Click link to view it's content
    Control variables:(testing)
    int,double,double
    title=Hard Disk Gas
    layout=border:0,0
    visible=true
    location="0,0"
    size="400,500"
    position=center
    autoscaleX=false
    autoscaleY=false
    minimumX=0
    maximumX=cellSize
    minimumY=0
    maximumY=cellSize
    square=true
    x=cellSize/2
    y=cellSize/2
    sizex=cellSize
    sizey=cellSize
    enabled=true
    style=RECTANGLE
    secondaryColor=black
    color=GREEN
    elementnumber=n
    x=x
    y=y
    sizex=diameter
    sizey=diameter
    enabled=true
    color=LIGHTGRAY
    numberOfElements=n
    x=x
    y=y
    sizeX=diameter
    sizeY=diameter
    pixelSize=true
    text=%l_m%
    numberOfElements=n
    x=x
    y=y
    sizeX=vx
    sizeY=vy
    scalex=0.2
    scaley=0.2
    visible=arrowvisible
    style=ARROW
    lineColor=MAGENTA
    fillColor=MAGENTA
    position=south
    layout=VBOX
    border=8,2,2,2
    borderType=LOWERED_ETCHED
    position=west
    layout=HBOX
    variable=n
    minimum=1
    maximum=nmax
    format="n=0"
    variable=v0
    value=1
    minimum=0.0
    maximum=2
    format="vo = 0.0"
    dragaction=//_initialize() for(int i=0; i<n; i++){ vx[i]=v0*Math.sin(angleslider[i]); vy[i]=v0*Math.cos(angleslider[i]);; }
    variable=e
    minimum=0.5
    maximum=1
    format="e=0.00"
    ticks=6
    closest=true
    dragaction=_initialize()
    position=center
    layout=HBOX
    position=west
    layout=HBOX
    variable=_isPaused
    tooltip="Start and stop the simulation."
    imageOn=/org/opensourcephysics/resources/controls/images/play.gif
    actionOn=_play()
    imageOff=/org/opensourcephysics/resources/controls/images/pause.gif
    actionOff=_pause()
    image=/org/opensourcephysics/resources/controls/images/step.gif
    action=_step()
    tooltip="Advance the simulation."
    image=/org/opensourcephysics/resources/controls/images/reset.gif
    action=_reset()
    tooltip="Reset the simulation."
    variable=t
    format="t = 0.00 s"
    editable=false
    variable=arrowvisible
    text="velocity"
    variable=accumulateData
    text=Accumulate Data
    position=west
    layout=VBOX
    visible=false
    position=center
    variable=cellSize
    format="cellSize=0.00"
    position=north
    variable=n
    format="n=0"
    position=south
    variable=t
    format="t=0.00"
    position=west
    variable=dt
    format="dt=0.00"
    position=east
    variable=accumulateData
    format="accumulateData=0"
    variable=diameter
    format="diameter=0.00"
    variable=collision1
    format="collision1=0.0"
    variable=collision2
    format="collision2=0.00"
    variable=KE[0]
    format="KEone=0.00"
    variable=KE[1]
    format="KEtwo=0.00"
    variable=TKE
    format="TKE = 0.00"
    variable=MOM[0]
    format="MOMone=0.00"
    variable=MOM[1]
    format="MOMtwo=0.00"
    variable=TMOM
    format="TMOM=0.00"
    layout=border
    visible=true
    location="0,350"
    size="350,350"
    position=center
    autoscaleX=true
    autoscaleY=true
    minimumX=0
    maximumX=1
    xMarginPercentage=10
    yMarginPercentage=10
    titleX=speed
    titleY=Probability
    input=speed
    discrete=false
    normalized=true
    binWidth=0.02
    binStyle=BIN
    layout=border
    visible=true
    location="0,0"
    size="300,300"
    position=center
    layout=border
    position=center
    input=speed
    norepeat=true
    showRowNumber=false
    columnNames="speed"
    columnFormat="0.00"